From 271595a753e7207b8f5a5d3d6e5f0aa3729b7efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Karakaya?= Date: Thu, 19 Nov 2026 02:19:23 +0300 Subject: [PATCH] docs: reference pages by component, nested navigation, Fira fonts The reference split one component across several pages: the motor's equations were in Theory, its fields in the API reference, its file formats in Data Files, and its notes again in the solver guide. Each component now has one page with its model, symbols, API, file formats and references: - Propellers: an overview with the PropellerModel interface and the shared coefficients, with Tabulated Propeller and Blade-Element Propeller beneath it. - Motor, Battery (the former Battery Model page with the API tables added), Propulsion Solver (power chain, equilibrium, RPM bracket, API, feasibility rules, bus solver) and OpenMDAO. The content moves as it was, with duplicates removed. Two fixes on the way: the feasibility rules list esc_current_limit, and ct and cp are the coefficients at the solved point, not interpolated ones. Theory, API Reference, Data Files and Battery Model redirect to their new pages through mkdocs-redirects, now in the docs extra. Navigation: groups are collapsible submenus instead of flat sections, and a group's first page is its index, so Propellers opens its overview and the home page is the User Guide tab's own page. User Guide: the solver guide becomes "Solving an Operating Point" and links to the reference; it gains a blade-element example with QPROP files. Getting Started installs from PyPI first, and the home page mentions the blade-element model. Fonts: Fira Sans and Fira Code, and MathJax 4.1.3 with its Fira math font, pinned instead of the unpinned mathjax@3, so text and formulas share one typeface. Long display equations are split to fit the page. Co-Authored-By: Claude Opus 5.5 --- README.md | 8 +- docs/api_reference.md | 260 --------------- docs/data_files.md | 139 -------- docs/getting_started.md | 15 +- docs/index.md | 26 +- docs/javascripts/mathjax.js | 3 + .../battery.md} | 28 ++ .../blade_element_propeller.md} | 296 ++++++------------ docs/reference/motor.md | 138 ++++++++ docs/reference/openmdao.md | 17 + docs/reference/propellers.md | 52 +++ docs/reference/propulsion_solver.md | 199 ++++++++++++ docs/reference/table_propeller.md | 58 ++++ docs/usage.md | 266 +++------------- mkdocs.yml | 33 +- pyproject.toml | 1 + 16 files changed, 692 insertions(+), 847 deletions(-) delete mode 100644 docs/api_reference.md delete mode 100644 docs/data_files.md rename docs/{battery_model.md => reference/battery.md} (90%) rename docs/{theory.md => reference/blade_element_propeller.md} (54%) create mode 100644 docs/reference/motor.md create mode 100644 docs/reference/openmdao.md create mode 100644 docs/reference/propellers.md create mode 100644 docs/reference/propulsion_solver.md create mode 100644 docs/reference/table_propeller.md diff --git a/README.md b/README.md index c8d00693..eb0b8ad5 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,12 @@ The full documentation is available at: Key sections: - [Getting Started](https://setuav.github.io/PyThrust/getting_started/) -- [Propulsion Solver](https://setuav.github.io/PyThrust/usage/) +- [Solving an Operating Point](https://setuav.github.io/PyThrust/usage/) - [Examples](https://setuav.github.io/PyThrust/examples/) -- [Propulsion and Battery Theory](https://setuav.github.io/PyThrust/theory/) -- [Data Files](https://setuav.github.io/PyThrust/data_files/) +- [Propellers](https://setuav.github.io/PyThrust/reference/propellers/) +- [Motor](https://setuav.github.io/PyThrust/reference/motor/) +- [Battery](https://setuav.github.io/PyThrust/reference/battery/) +- [Propulsion Solver](https://setuav.github.io/PyThrust/reference/propulsion_solver/) ## License diff --git a/docs/api_reference.md b/docs/api_reference.md deleted file mode 100644 index da5fd898..00000000 --- a/docs/api_reference.md +++ /dev/null @@ -1,260 +0,0 @@ -# API Reference - -This page summarizes the main public classes and helpers. For implementation details, see the source modules under `pythrust/`. - -## Motor Model - -`pythrust.motor.MotorSpec` defines brushless motor electrical parameters: - -| Field | Unit | Description | -|---|---:|---| -| `kv_rpm_per_v` | RPM/V | Motor speed constant | -| `resistance_ohm` | ohm | Winding resistance | -| `no_load_current_a` | A | Datasheet no-load current | -| `current_max_a` | A | Maximum continuous or configured current limit | -| `torque_constant_kv_ratio` | - | Optional second-order ratio of torque to speed constant | -| `magnetic_lag_tau` | s | Optional magnetic lag time constant | -| `no_load_current_linear` | A·s | Optional linear speed term of the no-load current | -| `no_load_current_quadratic` | A·s² | Optional quadratic speed term of the no-load current | -| `resistance_quadratic` | ohm/A² | Optional current-dependent winding resistance | - -Use `get_no_load_current(rpm)` and `get_winding_resistance(current_a)` when evaluating speed-dependent or current-dependent motor behavior. - -`pythrust.io.read_qprop_motor(path, current_max_a=math.inf)` reads a QPROP motor file into a `MotorSpec`; see [Data Files](data_files.md). - -## Battery Models - -PyThrust exposes battery models from `pythrust.battery`: - -| Class | Purpose | -|---|---| -| `FixedVoltageBattery` | Fixed pack-voltage model with scalar discharge efficiency | -| `RateMapBattery` | Equivalent-circuit model using cell OCV and resistance curves | -| `BatteryState` | State of charge/depth of discharge passed to dynamic battery models | -| `BatteryPoint` | Evaluated terminal voltage, current, power, C-rate, efficiency, and feasibility | -| `BatteryNetwork` | Rate-map packs wired as parallel strings of series-connected packs | -| `NetworkState` / `NetworkPoint` | Per-pack states and the network's terminal and per-pack electrical state | - -`Battery` is the union of the two models and is the battery type accepted by -`PropulsionSolver`. - -`RateMapBattery.from_json(path, series=..., parallel=...)` loads one cell -dataset and applies the requested pack topology at runtime. - -Main `RateMapBattery` point-state helpers: - -| Method | Description | -|---|---| -| `state_at_current(state, current_a)` | Evaluate voltage, power, C-rate, efficiency, and feasibility at pack current | -| `state_at_c_rate(state, c_rate)` | Evaluate the state at cell C-rate | -| `state_at_voltage(state, voltage_v)` | Evaluate current required to hold pack terminal voltage | -| `state_at_power(state, power_w)` | Evaluate current and voltage at pack terminal power | -| `state_at_load_resistance(state, resistance_ohm)` | Evaluate a resistive load | -| `state_at_power_loss(state, power_loss_w)` | Evaluate a requested pack internal loss power | - -Main `RateMapBattery` integration helpers: - -| Method | Description | -|---|---| -| `integrate_current(...)` | Integrate over time at constant pack current | -| `integrate_c_rate(...)` | Integrate over time at constant cell C-rate | -| `integrate_power(...)` | Integrate over time at constant pack terminal power | -| `integrate_voltage(...)` | Integrate over time at constant pack terminal voltage | -| `integrate_load_resistance(...)` | Integrate over time at constant pack load resistance | -| `integrate_power_loss(...)` | Integrate over time at constant pack internal loss power | -| `integrate_current_to_dod(...)` | Integrate constant current until target DOD | -| `integrate_c_rate_to_dod(...)` | Integrate constant C-rate until target DOD | -| `integrate_power_to_dod(...)` | Integrate constant power until target DOD | -| `integrate_voltage_to_dod(...)` | Integrate constant voltage until target DOD | -| `integrate_load_resistance_to_dod(...)` | Integrate constant load resistance until target DOD | -| `integrate_power_loss_to_dod(...)` | Integrate constant internal loss power until target DOD | -| `integrate_power_profile(...)` | Integrate consecutive constant-power mission segments | - -`BatteryIntegrationResult` reports final state, sampled histories, delivered -energy, consumed charge, feasibility, and stop reason. - -## System Spec and Operating Point - -| Class | Purpose | -|---|---| -| `SystemSpec` | Lumped resistance of the ESC, wires and connectors, and the ESC's optional motor-side current limit | -| `OperatingPoint` | Solved RPM, thrust, torque, motor/battery current, voltage, efficiency, and feasibility state | - -## Propulsion Solver - -`PropulsionSolver` solves the coupled electrical and aerodynamic equilibrium for a single operating condition: - -```python -point = solver.solve_operating_point( - motor=motor, - battery=battery, - battery_state=state, # required for RateMapBattery - system=system, - propeller=propeller, - rho=1.225, - airspeed_mps=15.0, - throttle=0.7, -) -``` - -`battery_state` may be omitted for `FixedVoltageBattery`. It is required for -dynamic battery models such as `RateMapBattery`. - -`SolverConfig` controls numerical behavior: - -| Field | Default | Description | -|---|---:|---| -| `rpm_min` | `100.0` | Lower RPM bound | -| `rpm_max_margin` | `1.1` | Safety factor on estimated maximum RPM | -| `eps_rpm` | `1e-8` | RPM convergence tolerance | -| `eps_v` | `1e-8` | Voltage residual tolerance | -| `max_iter` | `100` | Maximum root-finder iterations | - -`OperatingPoint` includes propulsion outputs such as `rpm`, `thrust_n`, -`torque_nm`, `motor_current_a`, and `motor_voltage_v`, plus battery outputs: - -| Field | Description | -|---|---| -| `battery_power_w` | Battery-side power draw | -| `battery_voltage_v` | Battery terminal pack voltage | -| `battery_current_a` | Battery DC current draw | -| `battery_c_rate` | Cell C-rate for rate-map batteries, or `0.0` for fixed-voltage batteries | -| `battery_efficiency` | Battery model discharge efficiency at the solved point | - -## Bus Solver - -`BusSolver` solves several propulsion units that share one `BatteryNetwork`, -each at its own throttle. A `PropulsionUnit` holds a motor, its propeller and -its `SystemSpec`. The bus voltage sags with the units' total current: - -```python -from pythrust.propulsion import BusSolver, PropulsionUnit - -bus = BusSolver().solve( - network, - network.full_state(), - units=[left_unit, right_unit], - throttles=[0.7, 0.7], - rho=1.225, - airspeed_mps=15.0, -) -bus.voltage_v, bus.current_a, bus.thrust_n, bus.units, bus.network.packs -``` - -A unit at zero throttle draws no current. The point is infeasible when a unit -exceeds its motor or ESC current limit, a pack leaves its operating limits, a unit -has no operating point (its reason is prefixed with `unit__`), or the -network cannot supply the units' current at any voltage they run at -(`bus_overload`). An infeasible point need not balance the network. - -## Propeller Models - -The solver takes any object that satisfies `pythrust.propeller.PropellerModel`: - -| Member | Description | -|---|---| -| `diameter_m` | Propeller diameter in metres | -| `max_advance_ratio` | Advance ratio up to which the model is expected to give thrust; the RPM search starts there | -| `thrust_torque(rho, airspeed_mps, rpm)` | Thrust in N and shaft torque in N m; zero torque where the model has no data | - -`TablePropeller` is the model for tabulated coefficients. It holds a diameter -and, for each RPM band, a list of `PropellerDataPoint(j, ct, cp)` sorted by -advance ratio. `pythrust.io.read_apc` builds one from an APC performance file: - -```python -from pythrust.io import read_apc - -propeller = read_apc("PER3_13x65E.dat") -thrust_n, torque_nm = propeller.thrust_torque(rho=1.225, airspeed_mps=10.0, rpm=6000.0) -ct, cp = propeller.get_coefficients(rpm=6000.0, advance_ratio=0.3) -``` - -| Member | Description | -|---|---| -| `TablePropeller(diameter_m, data_by_rpm)` | Build a table from your own data | -| `scaled(diameter_m)` | The propeller at another diameter with its coefficients unchanged: a geometrically similar propeller, without the Reynolds number effects of the size change | -| `get_coefficients(rpm, advance_ratio)` | Interpolated `Ct` and `Cp`; zero past a band's largest advance ratio | -| `rpm_levels` | Sorted RPM bands | - -See [Data Files](data_files.md) for what `read_apc` takes from the file. - -### Blade Geometry - -`pythrust.io.read_qprop_propeller(path)` reads a QPROP propeller file into a -`BladeGeometry`, the input of a blade-element propeller model: - -| Field | Unit | Description | -|---|---:|---| -| `blade_count` | - | Number of blades | -| `radius_m` | m | Tip radius | -| `r_m` | m | Station radii, root to tip | -| `chord_m` | m | Chord at each station | -| `blade_angle_rad` | rad | Blade angle from the plane of rotation at each station | -| `sections` | - | `BladeSection` at each station | - -`BladeSection` holds QPROP's airfoil parameters: `cl0`, `cl_alpha_per_rad`, -`cl_min`, `cl_max`, `cd0`, `cd2_upper`, `cd2_lower`, `cl_at_cd0`, -`reynolds_ref` and `reynolds_exp`. Lift is -`CL = cl0 + cl_alpha_per_rad * alpha`, clipped to `[cl_min, cl_max]`; drag is -`CD = (cd0 + cd2 * (CL - cl_at_cd0)^2) * (Re / reynolds_ref)^reynolds_exp`, with -`cd2_upper` above `cl_at_cd0` and `cd2_lower` below it. - -`section_coefficients(section, alpha_rad, reynolds, mach)` evaluates that -model on scalars or NumPy arrays and returns `(CL, CD)`. It reproduces QPROP -1.22: the linear lift carries the Prandtl-Glauert factor `1 / sqrt(1 - M^2)`, -and the section stalls where that corrected lift passes `cl_max` or `cl_min`. -Two details are not in the QPROP guide and were measured from QPROP's output: a -stalled section's lift falls off as `cl_max * cos(alpha - cl0 / cl_alpha_per_rad)` -(`cl_min` on the negative side), and its added stall drag -`2 sin^2(alpha - alpha_cd0)`, with `alpha_cd0 = (cl_at_cd0 - cl0) / cl_alpha_per_rad`, -does not scale with the Reynolds number. - -### Blade-Element Propeller - -`BladeElementPropeller(geometry, mu=1.78e-5, speed_of_sound=340.0, stations=25)` -is a `PropellerModel` computed from a `BladeGeometry` with QPROP's -blade-element/vortex formulation: - -```python -from pythrust.io import read_qprop_propeller -from pythrust.propeller import BladeElementPropeller - -propeller = BladeElementPropeller(read_qprop_propeller("prop.txt")) -thrust_n, torque_nm = propeller.thrust_torque(rho=1.225, airspeed_mps=10.0, rpm=8000.0) -``` - -| Member | Description | -|---|---| -| `geometry` | The `BladeGeometry` | -| `mu`, `speed_of_sound` | Air viscosity in kg/(m s) and speed of sound in m/s; the defaults are QPROP's | -| `diameter_m` | Twice the tip radius | -| `max_advance_ratio` | Advance ratio at which the section at 75% radius has zero lift, an estimate of zero thrust | -| `thrust_torque(rho, airspeed_mps, rpm)` | Thrust in N and torque in N m; zero for both at zero RPM or where a station has no solution | - -The blade is analysed at `stations` points, the midpoints of equal intervals -from the first to the last station of the geometry. Chord, blade angle and -section parameters there come from a cubic spline through the geometry's -stations with zero third derivative in the end intervals, as in QPROP. Thrust -and torque match QPROP 1.22 to the four digits it prints. - -At a station with more than one solution, the model takes the one nearest the -flow without induced velocity. QPROP can pick another one at a stalled -station of a windmilling blade, and its thrust and torque then differ. - -## OpenMDAO - -`pythrust.openmdao.PropulsionComponent` wraps `PropulsionSolver` as an `ExplicitComponent` for optimization models. - -Its `propeller` option is a `TablePropeller`, for example `PropulsionComponent(propeller=read_apc("PER3_13x65E.dat"))`. - -Inputs include motor parameters, fixed battery voltage, system resistance, propeller diameter, throttle, density, and airspeed. Outputs include RPM, thrust, torque, battery current, battery power, motor current, motor voltage, and feasibility. - -!!! warning "Inputs are not real parts" - The motor inputs are independent: changing `kv_rpm_per_v` leaves - `resistance_ohm` and `no_load_current_a` unchanged, although a real motor - with a lower Kv has a higher resistance. `diameter_m` scales the - `propeller` option's table with unchanged coefficients, which describes a - geometrically similar propeller that may not exist. An optimizer that - varies Kv or diameter therefore drifts toward low Kv and large diameter. - Use datasheet values as fixed inputs, or check any optimum against real - motors and propellers. diff --git a/docs/data_files.md b/docs/data_files.md deleted file mode 100644 index 403b70bd..00000000 --- a/docs/data_files.md +++ /dev/null @@ -1,139 +0,0 @@ -# Data Files - -PyThrust ships no motor or propeller catalogs. You supply the data for the -components you analyze: propeller tables from the manufacturer's files, motor -constants from a datasheet or a test. - -## Propellers: APC Performance Files - -APC publishes a performance file for each of its propellers at -. The files -are named `PER3_.dat`, for example `PER3_13x65E.dat` for the 13x6.5E. - -`pythrust.io.read_apc` reads one file into a `TablePropeller`: - -```python -from pythrust.io import read_apc - -propeller = read_apc("PER3_13x65E.dat") -print(propeller.diameter_m) # 0.3302 -print(propeller.rpm_levels) # [1000.0, 2000.0, ..., 18000.0] -``` - -The reader takes from the file: - -| Item | Use | -|---|---| -| Size in the first line, such as `13x6.5E` | Diameter in inches, converted to metres | -| `PROP RPM = ...` headers | One table band per RPM | -| `J`, `Ct` and `Cp` columns | Advance ratio and the thrust and power coefficients | - -Rows with a negative `Ct` or `Cp`, where the propeller windmills, are left -out: each RPM band ends at the last advance ratio with positive thrust and -power. A file without a size in its first line, or without data rows, raises -`ValueError`. - -APC computes these tables with its own blade-element software; they are not -wind-tunnel measurements. - -## Propellers: QPROP Files - -A QPROP propeller file describes the blade itself: chord and blade angle at -radial stations, and the airfoil's lift and drag parameters. The format is -defined in the [QPROP user guide](https://web.mit.edu/drela/Public/web/qprop/qprop_doc.txt). -`pythrust.io.read_qprop_propeller` reads one into a `BladeGeometry` in SI units: - -```python -from pythrust.io import read_qprop_propeller - -blade = read_qprop_propeller("prop.txt") -print(blade.blade_count, blade.radius_m) -print(blade.r_m, blade.chord_m, blade.blade_angle_rad) -print(blade.sections[0].cl_alpha_per_rad) -``` - -The file holds, in order: - -| Line | Content | -|---|---| -| 1 | Name | -| 2 | `Nblades [R]`; without `R`, the last station's radius is the tip radius | -| 3 | `CL0 CL_a` | -| 4 | `CLmin CLmax` | -| 5 | `CD0 CD2u CD2l CLCD0` | -| 6 | `REref REexp` | -| 7 | `Rfac Cfac Bfac` | -| 8 | `Radd Cadd Badd` | -| 9 on | `r chord beta`, one station per line from root to tip | - -Radii and chords become `value * fac + add` in metres, and the blade angle -`beta * Bfac + Badd` in degrees, converted to radians. A station line may -append its own `CL0 CL_a CLmin CLmax CD0 CD2u CD2l CLCD0 REref REexp`; values it -leaves out take those of lines 3 to 6. Lines starting with `#` and blank lines -are skipped, and text after `!` is ignored. - -`CL_a` is read per radian. The QPROP guide does not state its unit; its example -value of 5.8 is a lift slope per radian. - -The tip radius `R` on line 2 is scaled like the station radii, as the QPROP -guide states. QPROP 1.22 itself applies `Rfac` and `Radd` only to the stations -and uses `R` as written, so a file that gives `R` with `Rfac` other than 1 or -`Radd` other than 0 gives different tip losses in QPROP and in PyThrust. -Without `R`, or with the radii in metres, the two agree. `R` must not be less -than the last station's radius. - -## Motors: QPROP Files - -A QPROP motor file gives a name, the motor type, then one parameter per line. -`pythrust.io.read_qprop_motor` reads one into a `MotorSpec`: - -```python -from pythrust.io import read_qprop_motor - -motor = read_qprop_motor("motor.txt", current_max_a=40.0) -``` - -| Type | Parameters, one per line | `MotorSpec` fields | -|---|---|---| -| 1 | `R Io Kv` | first-order model | -| 2 | `R0 Io0 Kv Kq tau Io1 Io2 R2`; at least the first three | second-order model | - -Kv and Kq are in rpm/V. `torque_constant_kv_ratio` is `Kq / Kv`, and a zero -`Kq` means `Kq = Kv`. `Io1` (A s) and `Io2` (A s^2) multiply the shaft speed in -rad/s and its square, and `R2` (ohm/A^2) the current squared. Type 2 -parameters left out are zero. - -QPROP files carry no current limit; `current_max_a` sets it and defaults to -infinity. QPROP reads only the first number on each line, so a line with -more than one number raises `ValueError` rather than shifting the -parameters. Motor types other than 1 and 2 are rejected. - -With the same propeller and motor files, `PropulsionSolver` and a -`BladeElementPropeller` give the RPM, thrust, torque and current that QPROP -1.22 gives at a set voltage, to the digits QPROP prints. - -## Motors: Datasheet Values - -Write the motor constants into a `MotorSpec`: - -```python -from pythrust.motor import MotorSpec - -motor = MotorSpec( - kv_rpm_per_v=860.0, # Kv - resistance_ohm=0.0258, # winding resistance Rm - no_load_current_a=1.3, # no-load current Io - current_max_a=65.0, # maximum continuous current -) -``` - -Datasheets give the no-load current at a stated voltage, usually 10 V. The -first-order model treats it as constant. For a motor without a published -current limit, pass `current_max_a=math.inf`; the solver then never reports -`current_limit`. - -## Batteries: Cell Datasets - -`RateMapBattery.from_json(...)` reads a cell dataset. The format is described -in [Battery Model](battery_model.md); `pythrust.dataset_dir()` holds the example -cell `batteries/example_liion_cell.json`. diff --git a/docs/getting_started.md b/docs/getting_started.md index 11a7e126..2258682e 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -20,7 +20,15 @@ Optional extras: ## Installation -Clone the repository and install the package in editable mode: +Install the released package from PyPI: + +```bash +pip install setuav-pythrust +pip install "setuav-pythrust[openmdao]" # with the OpenMDAO component +``` + +To work on PyThrust itself, clone the repository and install it in editable +mode: ```bash git clone https://github.com/Setuav/PyThrust.git @@ -42,7 +50,7 @@ pip install -e .[plot,openmdao,dev,docs] The core workflow is: 1. Download an APC propeller performance file, here `PER3_13x65E.dat` from - . See [Data Files](data_files.md). + . See [Tabulated Propeller](reference/table_propeller.md). 2. Define motor, battery, system, and propeller specifications. 3. Solve the operating point for an airspeed and throttle. @@ -83,6 +91,9 @@ print(point.motor_current_a) print(point.is_feasible) ``` +To compute the propeller from its blade geometry instead of a table, see +[Solving an Operating Point](usage.md#blade-element-propeller). + ## Run the Examples ```bash diff --git a/docs/index.md b/docs/index.md index 31d3895c..222cccb9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ Welcome to the official documentation for **PyThrust** - an open-source Python framework for electric propulsion system analysis, co-design, and parameter optimization in UAV applications. -PyThrust combines empirical propeller data, brushless motor models, battery/system loss modeling, and OpenMDAO integration so UAV designers can move from theoretical propulsion sizing to real component choices with traceable calculations. +PyThrust combines tabulated and blade-element propeller models, brushless motor models, battery/system loss modeling, and OpenMDAO integration so UAV designers can move from theoretical propulsion sizing to real component choices with traceable calculations. --- @@ -20,7 +20,7 @@ Electric UAV propulsion design usually crosses several domains: aerodynamics, mo - **Manufacturer data** - Read APC propeller performance files and enter motor datasheet constants, instead of sizing only against abstract component assumptions. + Read APC performance files, or QPROP propeller and motor files for a blade-element model, and enter motor datasheet constants, instead of sizing only against abstract component assumptions. - **Battery-aware analysis** @@ -50,17 +50,17 @@ Electric UAV propulsion design usually crosses several domains: aerodynamics, mo [Open guide](getting_started.md) -- **Propulsion Solver** +- **Solving an Operating Point** - Review solver inputs, equations, feasibility rules, result fields, and usage examples. + Wire a motor, propeller and battery into the solver and read the result. [Open guide](usage.md) -- **Battery Model** +- **Propellers** - Understand fixed-voltage and rate-map batteries, JSON datasets, and solver integration. + Tabulated coefficients from APC files, or a blade-element model from QPROP files. - [Open reference](battery_model.md) + [Open reference](reference/propellers.md) - **Examples** @@ -68,16 +68,16 @@ Electric UAV propulsion design usually crosses several domains: aerodynamics, mo [Open examples](examples.md) -- **Theory** +- **Motor and Battery** - Trace the propeller, motor, electrical loss, and battery equations used by the solver. + Drela's motor model with QPROP motor files, and fixed-voltage or rate-map batteries. - [Open theory](theory.md) + [Motor](reference/motor.md) · [Battery](reference/battery.md) -- **API Reference** +- **Propulsion Solver** - Find the main classes, data file readers, and OpenMDAO wrapper. + The equilibrium equations, RPM search, result fields, feasibility rules and bus solver. - [Open API](api_reference.md) + [Open reference](reference/propulsion_solver.md) diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js index d883c521..9d014352 100644 --- a/docs/javascripts/mathjax.js +++ b/docs/javascripts/mathjax.js @@ -4,6 +4,9 @@ window.MathJax = { displayMath: [["\\[", "\\]"], ["$$", "$$"]], processEscapes: true, }, + output: { + font: "mathjax-fira", + }, options: { ignoreHtmlClass: ".*|", processHtmlClass: "arithmatex", diff --git a/docs/battery_model.md b/docs/reference/battery.md similarity index 90% rename from docs/battery_model.md rename to docs/reference/battery.md index 481e90de..413c0898 100644 --- a/docs/battery_model.md +++ b/docs/reference/battery.md @@ -248,6 +248,20 @@ print(result.stop_reason) ## Python API +`pythrust.battery` exposes: + +| Class | Purpose | +|---|---| +| `FixedVoltageBattery` | Fixed pack-voltage model with scalar discharge efficiency | +| `RateMapBattery` | Equivalent-circuit model using cell OCV and resistance curves | +| `BatteryState` | State of charge/depth of discharge passed to dynamic battery models | +| `BatteryPoint` | Evaluated terminal voltage, current, power, C-rate, efficiency, and feasibility | +| `BatteryNetwork` | Rate-map packs wired as parallel strings of series-connected packs | +| `NetworkState` / `NetworkPoint` | Per-pack states and the network's terminal and per-pack electrical state | + +`Battery` is the union of the two models and is the battery type accepted by +`PropulsionSolver`. + Use explicit names for the two battery fidelities: === "Fixed voltage" @@ -292,6 +306,17 @@ result = battery.integrate_power(state=state, power_w=power, dt_s=dt) For the fixed-voltage model, `terminal_voltage` returns the configured voltage. For the rate-map model, it evaluates the cell/pack equivalent circuit. +Main `RateMapBattery` point-state helpers: + +| Method | Description | +|---|---| +| `state_at_current(state, current_a)` | Evaluate voltage, power, C-rate, efficiency, and feasibility at pack current | +| `state_at_c_rate(state, c_rate)` | Evaluate the state at cell C-rate | +| `state_at_voltage(state, voltage_v)` | Evaluate current required to hold pack terminal voltage | +| `state_at_power(state, power_w)` | Evaluate current and voltage at pack terminal power | +| `state_at_load_resistance(state, resistance_ohm)` | Evaluate a resistive load | +| `state_at_power_loss(state, power_loss_w)` | Evaluate a requested pack internal loss power | + ## Dataset Shape The JSON dataset describes one cell. Pack topology is passed when loading the @@ -319,6 +344,9 @@ dataset: battery = RateMapBattery.from_json(cell_path, series=4, parallel=2) ``` +`pythrust.dataset_dir()` holds the example cell +`batteries/example_liion_cell.json`. + The current implementation interpolates `OCV(dod)` and `R(dod)` directly. Manufacturer discharge curves are usually terminal voltage under load, so real datasets should document how `OCV(dod)` and `R(dod)` were derived. diff --git a/docs/theory.md b/docs/reference/blade_element_propeller.md similarity index 54% rename from docs/theory.md rename to docs/reference/blade_element_propeller.md index b0d1b88b..2bd5d938 100644 --- a/docs/theory.md +++ b/docs/reference/blade_element_propeller.md @@ -1,31 +1,14 @@ -# Propulsion and Battery Model Theory +# Blade-Element Propeller -This document defines the core mathematical model for the electric propulsion system (propeller + brushless motor + battery/ESC). +`BladeElementPropeller` follows the blade-element/vortex formulation of +Drela's QPROP [1], with the section model of the QPROP user guide [2]. Each +blade station is solved on its own; the stations' loads then sum to the +thrust and torque. -## 1) Symbols and Units +## Symbols | Symbol | Description | SI Unit | |---|---|---| -| $V$ | Flight airspeed | $\text{m/s}$ | -| $D$ | Propeller diameter | $\text{m}$ | -| $n$ | Propeller shaft speed | $\text{1/s}$ (with $n = \text{RPM}/60$) | -| $\rho$ | Air density | $\text{kg/m}^3$ | -| $J$ | Advance ratio | Dimensionless | -| $C_t, C_p$ | Thrust and power coefficients | Dimensionless | -| $T$ | Thrust force | $\text{N}$ | -| $Q$ | Propeller torque | $\text{N}\cdot\text{m}$ | -| $P_{\text{shaft}}$ | Shaft mechanical power | $\text{W}$ | -| $K_v$ | Motor speed constant | $\text{RPM/V}$ | -| $K_t$ | Motor torque constant | $\text{N}\cdot\text{m/A}$ | -| $I$ | Motor winding current | $\text{A}$ | -| $I_0$ | Motor no-load current | $\text{A}$ | -| $R$ | Motor internal winding resistance | $\Omega$ | -| $R_{\text{system}}$ | Lumped transmission system resistance | $\Omega$ | -| $V_m$ | Motor terminal voltage | $\text{V}$ | -| $V_{\text{back}}$ | Back-EMF voltage | $\text{V}$ | -| $V_{\text{pack}}$ | Battery terminal pack voltage | $\text{V}$ | -| $x$ | Battery depth of discharge | Dimensionless | -| $N_s, N_p$ | Pack cells in series and parallel | Dimensionless | | $\Omega$ | Propeller angular speed, $2\pi n$ | $\text{rad/s}$ | | $B$ | Number of blades | Dimensionless | | $R_{\text{tip}}$ | Propeller tip radius | $\text{m}$ | @@ -39,45 +22,98 @@ This document defines the core mathematical model for the electric propulsion sy | $Re, M$ | Section Reynolds and Mach numbers | Dimensionless | | $\mu, a$ | Air viscosity and speed of sound | $\text{kg/(m s)}$, $\text{m/s}$ | ---- - -## 2) Propeller Aerodynamics - -The solver needs the thrust $T$ and torque $Q$ of the propeller at an air -density, airspeed and RPM. PyThrust has two propeller models that give them: -a table of measured or computed coefficients, and a blade-element model that -computes them from the blade's geometry. Both use - -$$ -J = \frac{V}{n D}, \quad n = \frac{\text{RPM}}{60} -$$ - -$$ -T = C_t \rho n^2 D^4 -$$ +## QPROP Propeller Files -$$ -Q = \frac{C_p \rho n^2 D^5}{2\pi} -$$ +A QPROP propeller file describes the blade itself: chord and blade angle at +radial stations, and the airfoil's lift and drag parameters. The format is +defined in the [QPROP user guide](https://web.mit.edu/drela/Public/web/qprop/qprop_doc.txt). +`pythrust.io.read_qprop_propeller` reads one into a `BladeGeometry` in SI units: -$$ -P_{\text{shaft}} = 2\pi n Q = C_p \rho n^3 D^5 -$$ +```python +from pythrust.io import read_qprop_propeller -### 2.1) Tabulated Coefficients +blade = read_qprop_propeller("prop.txt") +print(blade.blade_count, blade.radius_m) +print(blade.r_m, blade.chord_m, blade.blade_angle_rad) +print(blade.sections[0].cl_alpha_per_rad) +``` -`TablePropeller` holds $C_t(J, \text{RPM})$ and $C_p(J, \text{RPM})$, for example -read from an APC performance file. It interpolates linearly in $J$ within each -RPM band, then linearly between the two bands around the RPM. +The file holds, in order: -### 2.2) Blade-Element Model +| Line | Content | +|---|---| +| 1 | Name | +| 2 | `Nblades [R]`; without `R`, the last station's radius is the tip radius | +| 3 | `CL0 CL_a` | +| 4 | `CLmin CLmax` | +| 5 | `CD0 CD2u CD2l CLCD0` | +| 6 | `REref REexp` | +| 7 | `Rfac Cfac Bfac` | +| 8 | `Radd Cadd Badd` | +| 9 on | `r chord beta`, one station per line from root to tip | + +Radii and chords become `value * fac + add` in metres, and the blade angle +`beta * Bfac + Badd` in degrees, converted to radians. A station line may +append its own `CL0 CL_a CLmin CLmax CD0 CD2u CD2l CLCD0 REref REexp`; values it +leaves out take those of lines 3 to 6. Lines starting with `#` and blank lines +are skipped, and text after `!` is ignored. + +`CL_a` is read per radian. The QPROP guide does not state its unit; its example +value of 5.8 is a lift slope per radian. + +The tip radius `R` on line 2 is scaled like the station radii, as the QPROP +guide states. QPROP 1.22 itself applies `Rfac` and `Radd` only to the stations +and uses `R` as written, so a file that gives `R` with `Rfac` other than 1 or +`Radd` other than 0 gives different tip losses in QPROP and in PyThrust. +Without `R`, or with the radii in metres, the two agree. `R` must not be less +than the last station's radius. + +## API + +### Blade Geometry + +`pythrust.io.read_qprop_propeller(path)` reads a QPROP propeller file into a +`BladeGeometry`, the input of a blade-element propeller model: + +| Field | Unit | Description | +|---|---:|---| +| `blade_count` | - | Number of blades | +| `radius_m` | m | Tip radius | +| `r_m` | m | Station radii, root to tip | +| `chord_m` | m | Chord at each station | +| `blade_angle_rad` | rad | Blade angle from the plane of rotation at each station | +| `sections` | - | `BladeSection` at each station | + +`BladeSection` holds QPROP's airfoil parameters, listed with their symbols in +[Section lift and drag](#section-lift-and-drag). +`section_coefficients(section, alpha_rad, reynolds, mach)` evaluates the section +model on scalars or NumPy arrays and returns `(CL, CD)`. + +### Blade-Element Propeller + +`BladeElementPropeller(geometry, mu=1.78e-5, speed_of_sound=340.0, stations=25)` +is a `PropellerModel` computed from a `BladeGeometry` with QPROP's +blade-element/vortex formulation: + +```python +from pythrust.io import read_qprop_propeller +from pythrust.propeller import BladeElementPropeller + +propeller = BladeElementPropeller(read_qprop_propeller("prop.txt")) +thrust_n, torque_nm = propeller.thrust_torque(rho=1.225, airspeed_mps=10.0, rpm=8000.0) +``` + +| Member | Description | +|---|---| +| `geometry` | The `BladeGeometry` | +| `mu`, `speed_of_sound` | Air viscosity in kg/(m s) and speed of sound in m/s; the defaults are QPROP's | +| `diameter_m` | Twice the tip radius | +| `max_advance_ratio` | Advance ratio at which the section at 75% radius has zero lift, an estimate of zero thrust | +| `thrust_torque(rho, airspeed_mps, rpm)` | Thrust in N and torque in N m; zero for both at zero RPM or where a station has no solution | -`BladeElementPropeller` follows the blade-element/vortex formulation of -Drela's QPROP [4], with the section model of the QPROP user guide [5]. Each -blade station is solved on its own; the stations' loads then sum to the -thrust and torque. +## Theory -#### Analysis stations +### Analysis stations The blade is described at stations $r_1 < \dots < r_K$ with chord, blade angle and section parameters. It is analysed at the midpoints of $N$ equal @@ -87,7 +123,7 @@ come from a cubic spline through the stations whose second derivative is constant in the first and last intervals (zero third derivative). The tip radius $R_{\text{tip}}$ is given, or else $r_K$. -#### Velocities +### Velocities Without induced velocity, a station at radius $r$ sees the axial velocity $U_a = V$ and the tangential velocity $U_t = \Omega r$, of magnitude @@ -114,7 +150,7 @@ $$ Re = \frac{\rho W c}{\mu}, \qquad M = \frac{W}{a} $$ -#### Circulation from the wake +### Circulation from the wake With the local wake advance ratio $\lambda_w$ and Prandtl's tip-loss factor $F_{\text{tip}}$ evaluated on it, @@ -139,7 +175,7 @@ $$ The square root grows near the hub and keeps the relation consistent with a heavily loaded actuator disk. -#### Section lift and drag +### Section lift and drag The section's lift is linear in the angle of attack, with the Prandtl-Glauert factor: @@ -182,7 +218,7 @@ output. | $c_{d0}$, $c_{d2,u}$, $c_{d2,l}$, $c_{l,cd0}$ | `cd0`, `cd2_upper`, `cd2_lower`, `cl_at_cd0` | | $Re_{\text{ref}}$, $e$ | `reynolds_ref`, `reynolds_exp` | -#### Station equation +### Station equation The section's lift gives the circulation $\Gamma_l = \tfrac{1}{2} W c\, c_l$. A station is solved where the two circulations agree: @@ -196,7 +232,7 @@ $-\arcsin(U_a/U) < \psi < \arccos(-U_t/U)$. PyThrust samples $\mathcal{R}$ on th range, takes the sign change nearest $\psi_0$, the flow without induced velocity, and refines the root with the Illinois method. -#### Thrust and torque +### Thrust and torque The lift and drag of a station resolve into thrust and torque along $\phi$. With $\Gamma = \tfrac{1}{2} W c\, c_l$ and $W\cos\phi = W_t$, $W\sin\phi = W_a$, @@ -213,7 +249,7 @@ $$ At zero RPM, or where a station has no root, the model gives zero thrust and torque. -#### Start of the RPM search +### Start of the RPM search The solver starts its RPM search at the advance ratio the propeller model gives as `max_advance_ratio`. For the blade-element model this is the advance @@ -224,7 +260,7 @@ $$ J_{\max} = \pi \, \frac{r_{75}}{R_{\text{tip}}} \tan\left(\beta_{75} + \frac{c_{l0}}{c_{l\alpha}}\right) $$ -#### Differences from QPROP +### Differences from QPROP - **Tip radius scaling.** A QPROP propeller file may give the tip radius on its second line. The QPROP guide scales it with `Rfac` and `Radd` like the @@ -235,7 +271,7 @@ $$ - **Externally induced velocity.** QPROP accepts a velocity induced by another rotor ahead of the propeller; PyThrust does not. -#### Verification against QPROP +### Verification against QPROP The tests compare PyThrust with QPROP 1.22 run on the same input files: @@ -250,142 +286,12 @@ The tests compare PyThrust with QPROP 1.22 run on the same input files: - **Propeller and motor:** with a QPROP motor file and a set voltage, RPM, thrust, torque and current agree to the digits QPROP prints. ---- - -## 3) Brushless DC Motor Model - -PyThrust uses Mark Drela's DC motor model [1, 2]. The torque constant, the -no-load current and the winding resistance are - -$$ -K_t = \frac{30}{\pi K_v} \cdot \frac{K_V}{K_Q} -$$ - -$$ -I = \frac{Q}{K_t} + I_0(\omega), \qquad -I_0(\omega) = I_{00} + I_{01}\,\omega + I_{02}\,\omega^2 -$$ - -$$ -R(I) = R_0 + R_2 I^2 -$$ - -and the back-EMF and terminal voltage are - -$$ -V_{\text{back}} = \frac{\text{RPM}}{K_v} (1 + \tau \omega) -$$ - -$$ -V_m = V_{\text{back}} + I R(I) -$$ - -where $\omega = n \cdot 2\pi$ in rad/s and $\tau$ is the magnetic lag time -constant. - -With the second-order terms at their defaults ($K_Q = K_V$, $I_{01} = I_{02} = 0$, -$R_2 = 0$, $\tau = 0$) this is the first-order model [1]: constant resistance and -constant no-load current. A motor from a datasheet uses the first-order model, -because the datasheet gives only $K_v$, $R_0$ and $I_{00}$, the last measured at a -stated voltage. - -| Symbol | `MotorSpec` field | -|---|---| -| $K_v$ | `kv_rpm_per_v` | -| $K_Q / K_V$ | `torque_constant_kv_ratio` | -| $R_0$, $R_2$ | `resistance_ohm`, `resistance_quadratic` | -| $I_{00}$, $I_{01}$, $I_{02}$ | `no_load_current_a`, `no_load_current_linear`, `no_load_current_quadratic` | -| $\tau$ | `magnetic_lag_tau` | - ---- - -## 4) Battery Model - -The fixed-voltage battery model uses a constant terminal pack voltage: - -$$ -V_{\text{pack}} = V_{\text{nominal}} -$$ - -The rate-map battery model uses a cell open-circuit voltage curve and a cell -resistance curve indexed by depth of discharge: - -$$ -V_{\text{cell}}(x, I_{\text{cell}}) = -OCV(x) - R(x)I_{\text{cell}} -$$ - -For a pack topology: - -$$ -V_{\text{pack}} = N_s V_{\text{cell}} -$$ - -$$ -I_{\text{cell}} = \frac{I_{\text{pack}}}{N_p} -$$ - -During mission stepping, state advances by charge conservation: - -$$ -x_{\text{next}} = x + \frac{I_{\text{cell}}}{Q_{\text{cell}}}\Delta t -$$ - -## 5) System Electrical Resistance & Power Chain - -The voltage drops across ESC MOSFETs, battery internal resistance, cables, and connectors are modeled as a lumped transmission system resistance ($R_{\text{system}}$): - -$$ -V_m = \text{throttle} \times V_{\text{pack}} - I R_{\text{system}} -$$ - -The overall electrical power drawn from the battery pack is: - -$$ -P_{\text{battery}} = \frac{V_m I + I^2 R_{\text{system}}}{\eta_{\text{discharge}}} -$$ - -For `RateMapBattery`, the equivalent-circuit terminal voltage already captures -the cell-level voltage sag from the battery curves. `R_system` should still be -used for wiring, ESC, connector, or other losses outside the battery model. - ---- - -## 6) Coupled Equilibrium Condition - -For a given throttle setting and airspeed, the equilibrium shaft speed (RPM) is the solution of the coupled electrical and aerodynamic torque equilibrium equation: - -$$ -F(\text{RPM}) = -V_{\text{back}}(\text{RPM}) -+ I(\text{RPM})R -+ I(\text{RPM})R_{\text{system}} -- \text{throttle} \times V_{\text{pack}}(x, I(\text{RPM})) -= 0 -$$ - -A root-finding method (e.g., Brent's method) solves $F(\text{RPM}) = 0$ for RPM. Once the equilibrium RPM is determined, $T, Q, P_{\text{shaft}}, I$, and efficiency parameters are calculated. - ---- - ## References -1. **First-Order DC Electric Motor Model** - Mark Drela, MIT Aero & Astro, February 2007 - [PDF Link](https://web.mit.edu/drela/Public/web/qprop/motor1_theory.pdf) - -2. **Second-Order DC Electric Motor Model** - Mark Drela, MIT Aero & Astro, March 2006 - [PDF Link](https://web.mit.edu/drela/Public/web/qprop/motor2_theory.pdf) - -3. **Battery Knockdown Factors for Conceptual Design** - Robert A. McDonald, AIAA Aviation Forum, 2024 - DOI: `10.2514/6.2024-3903` - -4. **QPROP Formulation** +1. **QPROP Formulation** Mark Drela, MIT Aero & Astro, June 2006 [PDF Link](https://web.mit.edu/drela/Public/web/qprop/qprop_theory.pdf) -5. **QPROP User Guide**, version 1.21 +2. **QPROP User Guide**, version 1.21 Mark Drela, MIT Aero & Astro, July 2007 [Text Link](https://web.mit.edu/drela/Public/web/qprop/qprop_doc.txt) diff --git a/docs/reference/motor.md b/docs/reference/motor.md new file mode 100644 index 00000000..71ef2e51 --- /dev/null +++ b/docs/reference/motor.md @@ -0,0 +1,138 @@ +# Motor + +## Symbols + +| Symbol | Description | SI Unit | +|---|---|---| +| $K_v$ | Motor speed constant | $\text{RPM/V}$ | +| $K_t$ | Motor torque constant | $\text{N}\cdot\text{m/A}$ | +| $I$ | Motor winding current | $\text{A}$ | +| $I_0$ | Motor no-load current | $\text{A}$ | +| $R$ | Motor internal winding resistance | $\Omega$ | +| $V_m$ | Motor terminal voltage | $\text{V}$ | +| $V_{\text{back}}$ | Back-EMF voltage | $\text{V}$ | + +## Model + +PyThrust uses Mark Drela's DC motor model [1, 2]. The torque constant, the +no-load current and the winding resistance are + +$$ +K_t = \frac{30}{\pi K_v} \cdot \frac{K_V}{K_Q} +$$ + +$$ +I = \frac{Q}{K_t} + I_0(\omega), \qquad +I_0(\omega) = I_{00} + I_{01}\,\omega + I_{02}\,\omega^2 +$$ + +$$ +R(I) = R_0 + R_2 I^2 +$$ + +and the back-EMF and terminal voltage are + +$$ +V_{\text{back}} = \frac{\text{RPM}}{K_v} (1 + \tau \omega) +$$ + +$$ +V_m = V_{\text{back}} + I R(I) +$$ + +where $\omega = n \cdot 2\pi$ in rad/s and $\tau$ is the magnetic lag time +constant. + +With the second-order terms at their defaults ($K_Q = K_V$, $I_{01} = I_{02} = 0$, +$R_2 = 0$, $\tau = 0$) this is the first-order model [1]: constant resistance and +constant no-load current. A motor from a datasheet uses the first-order model, +because the datasheet gives only $K_v$, $R_0$ and $I_{00}$, the last measured at a +stated voltage. + +| Symbol | `MotorSpec` field | +|---|---| +| $K_v$ | `kv_rpm_per_v` | +| $K_Q / K_V$ | `torque_constant_kv_ratio` | +| $R_0$, $R_2$ | `resistance_ohm`, `resistance_quadratic` | +| $I_{00}$, $I_{01}$, $I_{02}$ | `no_load_current_a`, `no_load_current_linear`, `no_load_current_quadratic` | +| $\tau$ | `magnetic_lag_tau` | + +## API + +`pythrust.motor.MotorSpec` defines brushless motor electrical parameters: + +| Field | Unit | Description | +|---|---:|---| +| `kv_rpm_per_v` | RPM/V | Motor speed constant | +| `resistance_ohm` | ohm | Winding resistance | +| `no_load_current_a` | A | Datasheet no-load current | +| `current_max_a` | A | Maximum continuous or configured current limit | +| `torque_constant_kv_ratio` | - | Optional second-order ratio of torque to speed constant | +| `magnetic_lag_tau` | s | Optional magnetic lag time constant | +| `no_load_current_linear` | A·s | Optional linear speed term of the no-load current | +| `no_load_current_quadratic` | A·s² | Optional quadratic speed term of the no-load current | +| `resistance_quadratic` | ohm/A² | Optional current-dependent winding resistance | + +Use `get_no_load_current(rpm)` and `get_winding_resistance(current_a)` when evaluating speed-dependent or current-dependent motor behavior. + +`pythrust.io.read_qprop_motor(path, current_max_a=math.inf)` reads a QPROP motor file into a `MotorSpec`; see [Data Files](propellers.md). + +## QPROP Motor Files + +A QPROP motor file gives a name, the motor type, then one parameter per line. +`pythrust.io.read_qprop_motor` reads one into a `MotorSpec`: + +```python +from pythrust.io import read_qprop_motor + +motor = read_qprop_motor("motor.txt", current_max_a=40.0) +``` + +| Type | Parameters, one per line | `MotorSpec` fields | +|---|---|---| +| 1 | `R Io Kv` | first-order model | +| 2 | `R0 Io0 Kv Kq tau Io1 Io2 R2`; at least the first three | second-order model | + +Kv and Kq are in rpm/V. `torque_constant_kv_ratio` is `Kq / Kv`, and a zero +`Kq` means `Kq = Kv`. `Io1` (A s) and `Io2` (A s^2) multiply the shaft speed in +rad/s and its square, and `R2` (ohm/A^2) the current squared. Type 2 +parameters left out are zero. + +QPROP files carry no current limit; `current_max_a` sets it and defaults to +infinity. QPROP reads only the first number on each line, so a line with +more than one number raises `ValueError` rather than shifting the +parameters. Motor types other than 1 and 2 are rejected. + +With the same propeller and motor files, `PropulsionSolver` and a +`BladeElementPropeller` give the RPM, thrust, torque and current that QPROP +1.22 gives at a set voltage, to the digits QPROP prints. + +## Datasheet Values + +Write the motor constants into a `MotorSpec`: + +```python +from pythrust.motor import MotorSpec + +motor = MotorSpec( + kv_rpm_per_v=860.0, # Kv + resistance_ohm=0.0258, # winding resistance Rm + no_load_current_a=1.3, # no-load current Io + current_max_a=65.0, # maximum continuous current +) +``` + +Datasheets give the no-load current at a stated voltage, usually 10 V. The +first-order model treats it as constant. For a motor without a published +current limit, pass `current_max_a=math.inf`; the solver then never reports +`current_limit`. + +## References + +1. **First-Order DC Electric Motor Model** + Mark Drela, MIT Aero & Astro, February 2007 + [PDF Link](https://web.mit.edu/drela/Public/web/qprop/motor1_theory.pdf) + +2. **Second-Order DC Electric Motor Model** + Mark Drela, MIT Aero & Astro, March 2006 + [PDF Link](https://web.mit.edu/drela/Public/web/qprop/motor2_theory.pdf) diff --git a/docs/reference/openmdao.md b/docs/reference/openmdao.md new file mode 100644 index 00000000..62a252ee --- /dev/null +++ b/docs/reference/openmdao.md @@ -0,0 +1,17 @@ +# OpenMDAO + +`pythrust.openmdao.PropulsionComponent` wraps `PropulsionSolver` as an `ExplicitComponent` for optimization models. + +Its `propeller` option is a `TablePropeller`, for example `PropulsionComponent(propeller=read_apc("PER3_13x65E.dat"))`. + +Inputs include motor parameters, fixed battery voltage, system resistance, propeller diameter, throttle, density, and airspeed. Outputs include RPM, thrust, torque, battery current, battery power, motor current, motor voltage, and feasibility. + +!!! warning "Inputs are not real parts" + The motor inputs are independent: changing `kv_rpm_per_v` leaves + `resistance_ohm` and `no_load_current_a` unchanged, although a real motor + with a lower Kv has a higher resistance. `diameter_m` scales the + `propeller` option's table with unchanged coefficients, which describes a + geometrically similar propeller that may not exist. An optimizer that + varies Kv or diameter therefore drifts toward low Kv and large diameter. + Use datasheet values as fixed inputs, or check any optimum against real + motors and propellers. diff --git a/docs/reference/propellers.md b/docs/reference/propellers.md new file mode 100644 index 00000000..1f3843c8 --- /dev/null +++ b/docs/reference/propellers.md @@ -0,0 +1,52 @@ +# Propeller Models + +The propulsion solver needs the thrust $T$ and torque $Q$ of the propeller at +an air density, airspeed and RPM. PyThrust ships no propeller data: you bring +a manufacturer's file and pick the model that reads it. + +| Model | Input | Page | +|---|---|---| +| `TablePropeller` | Tabulated thrust and power coefficients, such as an APC performance file | [Tabulated Propeller](table_propeller.md) | +| `BladeElementPropeller` | Blade geometry and airfoil parameters, such as a QPROP propeller file | [Blade-Element Propeller](blade_element_propeller.md) | + +## Model Interface + +The solver takes any object that satisfies `pythrust.propeller.PropellerModel`: + +| Member | Description | +|---|---| +| `diameter_m` | Propeller diameter in metres | +| `max_advance_ratio` | Advance ratio up to which the model is expected to give thrust; the RPM search starts there | +| `thrust_torque(rho, airspeed_mps, rpm)` | Thrust in N and shaft torque in N m; zero torque where the model has no data | + +## Coefficients + +| Symbol | Description | SI Unit | +|---|---|---| +| $V$ | Flight airspeed | $\text{m/s}$ | +| $D$ | Propeller diameter | $\text{m}$ | +| $n$ | Propeller shaft speed | $\text{1/s}$ (with $n = \text{RPM}/60$) | +| $\rho$ | Air density | $\text{kg/m}^3$ | +| $J$ | Advance ratio | Dimensionless | +| $C_t, C_p$ | Thrust and power coefficients | Dimensionless | +| $T$ | Thrust force | $\text{N}$ | +| $Q$ | Propeller torque | $\text{N}\cdot\text{m}$ | +| $P_{\text{shaft}}$ | Shaft mechanical power | $\text{W}$ | + +Both models relate thrust and torque to the coefficients by + +$$ +J = \frac{V}{n D}, \quad n = \frac{\text{RPM}}{60} +$$ + +$$ +T = C_t \rho n^2 D^4 +$$ + +$$ +Q = \frac{C_p \rho n^2 D^5}{2\pi} +$$ + +$$ +P_{\text{shaft}} = 2\pi n Q = C_p \rho n^3 D^5 +$$ diff --git a/docs/reference/propulsion_solver.md b/docs/reference/propulsion_solver.md new file mode 100644 index 00000000..cce4f12b --- /dev/null +++ b/docs/reference/propulsion_solver.md @@ -0,0 +1,199 @@ +# Propulsion Solver + +`PropulsionSolver` finds the shaft RPM at which the motor's electrical model +and the propeller's aerodynamic load agree, for a motor, propeller, battery, +throttle and airspeed. `BusSolver` does the same for several propulsion units +sharing one battery network. + +## Symbols + +| Symbol | Meaning | +|---|---| +| $\text{RPM}$ | Propeller shaft speed being solved | +| $n$ | Shaft speed in revolutions per second | +| $T$ | Thrust | +| $Q$ | Propeller shaft torque | +| $I$ | Motor winding current | +| $I_0$ | No-load current | +| $R_m$ | Motor winding resistance | +| $R_{\text{system}}$ | Lumped system resistance | +| $V_{\text{back}}$ | Motor back-EMF voltage | +| $V_m$ | Motor terminal voltage | +| $V_{\text{pack}}$ | Battery pack voltage | +| $x$ | Battery depth of discharge | +| $V_{\text{applied}}$ | Average voltage the throttle applies to the motor | + +## System Resistance and Power Chain + +The voltage drops across ESC MOSFETs, battery internal resistance, cables, and connectors are modeled as a lumped transmission system resistance ($R_{\text{system}}$): + +$$ +V_m = \text{throttle} \times V_{\text{pack}} - I R_{\text{system}} +$$ + +The overall electrical power drawn from the battery pack is: + +$$ +P_{\text{battery}} = \frac{V_m I + I^2 R_{\text{system}}}{\eta_{\text{discharge}}} +$$ + +For `RateMapBattery`, the equivalent-circuit terminal voltage already captures +the cell-level voltage sag from the battery curves. `R_system` should still be +used for wiring, ESC, connector, or other losses outside the battery model. + +## Equilibrium RPM + +The throttle command defines the average voltage available from the battery: + +$$ +V_{\text{applied}} = +\text{throttle} \cdot V_{\text{pack}} +$$ + +For `FixedVoltageBattery`, `V_pack` is the configured pack voltage. For +`RateMapBattery`, `V_pack` is evaluated from the current battery state and the +current implied by the candidate RPM: + +!!! note "Rate-map batteries are state dependent" + A `RateMapBattery` solve needs a `BatteryState` because terminal voltage depends on both depth of discharge and current. + +$$ +V_{\text{pack}} = V_{\text{pack}}(x, I) +$$ + +The solver searches for the RPM where the motor voltage demand plus system voltage drop equals the applied voltage: + +$$ +g(\text{RPM}) = +V_m(\text{RPM}) ++ I(\text{RPM}) R_{\text{system}} +- V_{\text{applied}} +$$ + +The equilibrium point is: + +$$ +g(\text{RPM}) = 0 +$$ + +PyThrust solves this scalar root-finding problem with Brent's method through `scipy.optimize.root_scalar`. + +## RPM Bracket + +Before solving, PyThrust builds a search interval: + +| Bound | How it is chosen | +|---|---| +| Lower RPM | At least `SolverConfig.rpm_min`; raised if airspeed and propeller `J` range require a higher RPM | +| Upper RPM | Estimated from `motor.kv_rpm_per_v * battery.terminal_voltage(0 A) * throttle`, then expanded by `rpm_max_margin` | + +If the residual does not change sign inside the bracket, the point is returned as infeasible with reason `no_bracket`. + +## API + +### Solving an Operating Point + +`PropulsionSolver` solves the coupled electrical and aerodynamic equilibrium for a single operating condition: + +```python +point = solver.solve_operating_point( + motor=motor, + battery=battery, + battery_state=state, # required for RateMapBattery + system=system, + propeller=propeller, + rho=1.225, + airspeed_mps=15.0, + throttle=0.7, +) +``` + +`battery_state` may be omitted for `FixedVoltageBattery`. It is required for +dynamic battery models such as `RateMapBattery`. + +| Class | Purpose | +|---|---| +| `SystemSpec` | Lumped resistance of the ESC, wires and connectors, and the ESC's optional motor-side current limit | +| `OperatingPoint` | Solved RPM, thrust, torque, motor/battery current, voltage, efficiency, and feasibility state | + +### Solver Configuration + +The numerical behavior of the root finder is controlled by `SolverConfig`: + +| Parameter | Type | Default | Description | +|---|---|---:|---| +| `rpm_min` | `float` | `100.0` | Lower bound limit for RPM | +| `rpm_max_margin` | `float` | `1.1` | Safety scaling factor applied to the upper RPM estimate | +| `eps_rpm` | `float` | `1e-8` | Convergence tolerance for shaft speed | +| `eps_v` | `float` | `1e-8` | Voltage residual tolerance | +| `max_iter` | `int` | `100` | Maximum root-finder iterations | + +### Result Fields + +`solve_operating_point(...)` returns an `OperatingPoint`: + +| Field | Meaning | +|---|---| +| `rpm` | Solved shaft speed | +| `advance_ratio` | Propeller advance ratio at the solved point | +| `ct`, `cp` | Thrust and power coefficients at the solved point | +| `thrust_n` | Thrust force | +| `torque_nm` | Propeller shaft torque | +| `shaft_power_w` | Mechanical shaft power | +| `motor_power_w` | Electrical power at motor terminals | +| `battery_power_w` | Battery-side power including system losses | +| `battery_voltage_v` | Battery terminal pack voltage at the solved point | +| `battery_current_a` | Battery DC current draw at the solved point | +| `battery_c_rate` | Cell C-rate for rate-map batteries, or `0.0` for fixed-voltage batteries | +| `battery_efficiency` | Discharge efficiency from the active battery model | +| `motor_current_a` | Motor winding current | +| `motor_voltage_v` | Motor terminal voltage | +| `propeller_efficiency` | Propulsive efficiency based on thrust power | +| `motor_efficiency` | Shaft power divided by motor electrical power | +| `system_efficiency` | Thrust power divided by battery power | +| `is_feasible` | Whether the point passed feasibility checks | +| `infeasible_reason` | Reason string when `is_feasible` is false | + +### Feasibility Rules + +An operating point is marked as infeasible when one of these checks fails: + +| Reason | Meaning | +|---|---| +| `throttle<=0` | No positive throttle command | +| `no_bracket` | The RPM search interval does not contain a valid voltage-balance root | +| `no_convergence` | The root finder did not converge | +| `current_limit` | `motor_current_a` exceeds `current_max_a` | +| `esc_current_limit` | `motor_current_a` exceeds the `SystemSpec`'s `max_current_a` | +| `battery_current_limit` | Rate-map battery current exceeds the configured cell current limit | +| `battery_voltage_cutoff` | Rate-map battery terminal cell voltage falls below cutoff | +| `battery_voltage_limit` | Rate-map battery terminal cell voltage exceeds the configured charge voltage | +| `battery_state_limit` | Rate-map battery state is outside the valid range | +| `invalid_coefficients` | Propeller coefficient lookup produced non-physical values | +| `invalid_efficiency` | Computed efficiency is outside the physically expected range | + +## Bus Solver + +`BusSolver` solves several propulsion units that share one `BatteryNetwork`, +each at its own throttle. A `PropulsionUnit` holds a motor, its propeller and +its `SystemSpec`. The bus voltage sags with the units' total current: + +```python +from pythrust.propulsion import BusSolver, PropulsionUnit + +bus = BusSolver().solve( + network, + network.full_state(), + units=[left_unit, right_unit], + throttles=[0.7, 0.7], + rho=1.225, + airspeed_mps=15.0, +) +bus.voltage_v, bus.current_a, bus.thrust_n, bus.units, bus.network.packs +``` + +A unit at zero throttle draws no current. The point is infeasible when a unit +exceeds its motor or ESC current limit, a pack leaves its operating limits, a unit +has no operating point (its reason is prefixed with `unit__`), or the +network cannot supply the units' current at any voltage they run at +(`bus_overload`). An infeasible point need not balance the network. diff --git a/docs/reference/table_propeller.md b/docs/reference/table_propeller.md new file mode 100644 index 00000000..ee81543b --- /dev/null +++ b/docs/reference/table_propeller.md @@ -0,0 +1,58 @@ +# Tabulated Propeller + +`TablePropeller` holds $C_t(J, \text{RPM})$ and $C_p(J, \text{RPM})$, for example +read from an APC performance file. It interpolates linearly in $J$ within each +RPM band, then linearly between the two bands around the RPM. + +## API + +`TablePropeller` is the model for tabulated coefficients. It holds a diameter +and, for each RPM band, a list of `PropellerDataPoint(j, ct, cp)` sorted by +advance ratio. `pythrust.io.read_apc` builds one from an APC performance file: + +```python +from pythrust.io import read_apc + +propeller = read_apc("PER3_13x65E.dat") +thrust_n, torque_nm = propeller.thrust_torque(rho=1.225, airspeed_mps=10.0, rpm=6000.0) +ct, cp = propeller.get_coefficients(rpm=6000.0, advance_ratio=0.3) +``` + +| Member | Description | +|---|---| +| `TablePropeller(diameter_m, data_by_rpm)` | Build a table from your own data | +| `scaled(diameter_m)` | The propeller at another diameter with its coefficients unchanged: a geometrically similar propeller, without the Reynolds number effects of the size change | +| `get_coefficients(rpm, advance_ratio)` | Interpolated `Ct` and `Cp`; zero past a band's largest advance ratio | +| `rpm_levels` | Sorted RPM bands | + +## APC Performance Files + +APC publishes a performance file for each of its propellers at +. The files +are named `PER3_.dat`, for example `PER3_13x65E.dat` for the 13x6.5E. + +`pythrust.io.read_apc` reads one file into a `TablePropeller`: + +```python +from pythrust.io import read_apc + +propeller = read_apc("PER3_13x65E.dat") +print(propeller.diameter_m) # 0.3302 +print(propeller.rpm_levels) # [1000.0, 2000.0, ..., 18000.0] +``` + +The reader takes from the file: + +| Item | Use | +|---|---| +| Size in the first line, such as `13x6.5E` | Diameter in inches, converted to metres | +| `PROP RPM = ...` headers | One table band per RPM | +| `J`, `Ct` and `Cp` columns | Advance ratio and the thrust and power coefficients | + +Rows with a negative `Ct` or `Cp`, where the propeller windmills, are left +out: each RPM band ends at the last advance ratio with positive thrust and +power. A file without a size in its first line, or without data rows, raises +`ValueError`. + +APC computes these tables with its own blade-element software; they are not +wind-tunnel measurements. diff --git a/docs/usage.md b/docs/usage.md index a91c04f1..2a364632 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -1,4 +1,4 @@ -# Propulsion Solver User & API Guide +# Solving an Operating Point This guide describes how PyThrust solves a motor-propeller operating point and how to interpret the result. @@ -16,39 +16,14 @@ The operating-point solver combines five inputs: | Input | Class or value | Purpose | |---|---|---| -| Motor | `pythrust.motor.MotorSpec` | Kv, winding resistance, no-load current, current limit, optional higher-order loss terms | -| Battery | `FixedVoltageBattery` or `RateMapBattery` | Fixed pack voltage or state-dependent pack voltage from cell curves | -| System | `SystemSpec` | Lumped resistance for ESC, battery internal resistance, wiring, and connectors | -| Propeller | A `PropellerModel`, such as `TablePropeller` | Thrust and torque at a given density, airspeed and RPM | +| Motor | [`MotorSpec`](reference/motor.md) | Kv, winding resistance, no-load current, current limit, optional higher-order loss terms | +| Battery | [`FixedVoltageBattery` or `RateMapBattery`](reference/battery.md) | Fixed pack voltage or state-dependent pack voltage from cell curves | +| System | [`SystemSpec`](reference/propulsion_solver.md) | Lumped resistance for ESC, battery internal resistance, wiring, and connectors | +| Propeller | A [`PropellerModel`](reference/propellers.md), such as `TablePropeller` or `BladeElementPropeller` | Thrust and torque at a given density, airspeed and RPM | | Flight condition | `rho`, `airspeed_mps`, `throttle` | Air density, freestream speed, and commanded voltage fraction | --- -## Symbols - -| Symbol | Meaning | -|---|---| -| $\text{RPM}$ | Propeller shaft speed being solved | -| $n$ | Shaft speed in revolutions per second | -| $V$ | Flight airspeed | -| $D$ | Propeller diameter | -| $J$ | Propeller advance ratio | -| $C_t$, $C_p$ | Propeller thrust and power coefficients | -| $T$ | Thrust | -| $Q$ | Propeller shaft torque | -| $K_v$ | Motor speed constant | -| $K_t$ | Motor torque constant | -| $I$ | Motor winding current | -| $I_0$ | No-load current | -| $R_m$ | Motor winding resistance | -| $R_{\text{system}}$ | Lumped system resistance | -| $V_{\text{back}}$ | Motor back-EMF voltage | -| $V_m$ | Motor terminal voltage | -| $V_{\text{pack}}$ | Battery pack voltage | -| $x$ | Battery depth of discharge | - ---- - ## What the Solver Does ```mermaid @@ -70,206 +45,20 @@ flowchart LR point --> outputs["RPM, thrust, current, voltage, efficiency"] ``` -### Step 1: Evaluate the propeller at a candidate RPM - -For each candidate RPM, PyThrust converts shaft speed to revolutions per second: - -$$ -n = \frac{\text{RPM}}{60} -$$ - -Then it calculates the propeller advance ratio: - -$$ -J = \frac{V}{nD} -$$ - -The propeller model gives thrust and torque at that RPM and advance ratio; a `TablePropeller` interpolates tabulated coefficients: - -$$ -C_t = C_t(\text{RPM}, J) -$$ - -$$ -C_p = C_p(\text{RPM}, J) -$$ - -From those coefficients, PyThrust computes thrust, torque, and shaft power: - -$$ -T = C_t \rho n^2 D^4 -$$ - -$$ -Q = \frac{C_p \rho n^2 D^5}{2\pi} -$$ - -$$ -P_{\text{shaft}} = C_p \rho n^3 D^5 -$$ - -### Step 2: Evaluate the motor state - -By default, PyThrust uses a first-order brushless DC motor model. The torque constant is: - -$$ -K_t = -\frac{30}{\pi K_v} -$$ - -The motor current needed to drive the propeller torque is: - -$$ -I = -\frac{Q}{K_t} + I_0 -$$ - -The back-EMF voltage is: - -$$ -V_{\text{back}} = -\frac{\text{RPM}}{K_v} -$$ - -The motor terminal voltage is: - -$$ -V_m = -V_{\text{back}} + I R_m -$$ - -### Drela / QPROP Motor Model Notes - -`MotorSpec` also includes optional parameters inspired by Mark Drela's QPROP motor models: - -| Field | Effect | -|---|---| -| `torque_constant_kv_ratio` | Adjusts the relation between speed constant and torque constant | -| `magnetic_lag_tau` | Adds magnetic lag to the back-EMF relation | -| `no_load_current_linear` | Adds a linear speed term to no-load current | -| `no_load_current_quadratic` | Adds a quadratic speed term to no-load current | -| `resistance_quadratic` | Adds current-dependent winding resistance | - -When these fields are left at their defaults, the model reduces to the simpler first-order motor equations above. See [Propulsion and Battery Theory](theory.md) for the full equations and Drela references. - ---- - -## Equilibrium RPM - -The throttle command defines the average voltage available from the battery: - -$$ -V_{\text{applied}} = -\text{throttle} \cdot V_{\text{pack}} -$$ - -For `FixedVoltageBattery`, `V_pack` is the configured pack voltage. For -`RateMapBattery`, `V_pack` is evaluated from the current battery state and the -current implied by the candidate RPM: - -!!! note "Rate-map batteries are state dependent" - A `RateMapBattery` solve needs a `BatteryState` because terminal voltage depends on both depth of discharge and current. - -$$ -V_{\text{pack}} = V_{\text{pack}}(x, I) -$$ - -The solver searches for the RPM where the motor voltage demand plus system voltage drop equals the applied voltage: - -$$ -g(\text{RPM}) = -V_m(\text{RPM}) -+ I(\text{RPM}) R_{\text{system}} -- V_{\text{applied}} -$$ - -The equilibrium point is: - -$$ -g(\text{RPM}) = 0 -$$ - -PyThrust solves this scalar root-finding problem with Brent's method through `scipy.optimize.root_scalar`. - ---- - -## RPM Bracket - -Before solving, PyThrust builds a search interval: - -| Bound | How it is chosen | -|---|---| -| Lower RPM | At least `SolverConfig.rpm_min`; raised if airspeed and propeller `J` range require a higher RPM | -| Upper RPM | Estimated from `motor.kv_rpm_per_v * battery.terminal_voltage(0 A) * throttle`, then expanded by `rpm_max_margin` | - -If the residual does not change sign inside the bracket, the point is returned as infeasible with reason `no_bracket`. - ---- - -## Solver Configuration - -The numerical behavior of the root finder is controlled by `SolverConfig`: - -| Parameter | Type | Default | Description | -|---|---|---:|---| -| `rpm_min` | `float` | `100.0` | Lower bound limit for RPM | -| `rpm_max_margin` | `float` | `1.1` | Safety scaling factor applied to the upper RPM estimate | -| `eps_rpm` | `float` | `1e-8` | Convergence tolerance for shaft speed | -| `eps_v` | `float` | `1e-8` | Voltage residual tolerance | -| `max_iter` | `int` | `100` | Maximum root-finder iterations | - ---- - -## Result Fields - -`solve_operating_point(...)` returns an `OperatingPoint`: - -| Field | Meaning | -|---|---| -| `rpm` | Solved shaft speed | -| `advance_ratio` | Propeller advance ratio at the solved point | -| `ct`, `cp` | Interpolated thrust and power coefficients | -| `thrust_n` | Thrust force | -| `torque_nm` | Propeller shaft torque | -| `shaft_power_w` | Mechanical shaft power | -| `motor_power_w` | Electrical power at motor terminals | -| `battery_power_w` | Battery-side power including system losses | -| `battery_voltage_v` | Battery terminal pack voltage at the solved point | -| `battery_current_a` | Battery DC current draw at the solved point | -| `battery_c_rate` | Cell C-rate for rate-map batteries, or `0.0` for fixed-voltage batteries | -| `battery_efficiency` | Discharge efficiency from the active battery model | -| `motor_current_a` | Motor winding current | -| `motor_voltage_v` | Motor terminal voltage | -| `propeller_efficiency` | Propulsive efficiency based on thrust power | -| `motor_efficiency` | Shaft power divided by motor electrical power | -| `system_efficiency` | Thrust power divided by battery power | -| `is_feasible` | Whether the point passed feasibility checks | -| `infeasible_reason` | Reason string when `is_feasible` is false | - ---- - -## Feasibility Rules - -An operating point is marked as infeasible when one of these checks fails: - -| Reason | Meaning | -|---|---| -| `throttle<=0` | No positive throttle command | -| `no_bracket` | The RPM search interval does not contain a valid voltage-balance root | -| `no_convergence` | The root finder did not converge | -| `current_limit` | `motor_current_a` exceeds `current_max_a` | -| `battery_current_limit` | Rate-map battery current exceeds the configured cell current limit | -| `battery_voltage_cutoff` | Rate-map battery terminal cell voltage falls below cutoff | -| `battery_voltage_limit` | Rate-map battery terminal cell voltage exceeds the configured charge voltage | -| `battery_state_limit` | Rate-map battery state is outside the valid range | -| `invalid_coefficients` | Propeller coefficient lookup produced non-physical values | -| `invalid_efficiency` | Computed efficiency is outside the physically expected range | +For each candidate RPM the solver asks the propeller model for thrust and +torque, turns the torque into motor current and voltage, and compares the +voltage the motor needs with the voltage the throttle applies. The RPM where +they match is the operating point. The equations, the RPM search, the result +fields and the feasibility rules are in the +[Propulsion Solver reference](reference/propulsion_solver.md). --- ## Example Usage -Here is a complete example showing how to read a propeller file, define specifications, and solve for an operating point. It needs the APC performance file `PER3_13x65E.dat` (see [Data Files](data_files.md)): +### Tabulated propeller + +Here is a complete example showing how to read a propeller file, define specifications, and solve for an operating point. It needs the APC performance file `PER3_13x65E.dat` (see [Tabulated Propeller](reference/table_propeller.md)): ```python from pythrust.battery import FixedVoltageBattery @@ -317,6 +106,33 @@ print(f"Feasible : {point.is_feasible}") print(f"Reason : {point.infeasible_reason}") ``` +### Blade-element propeller + +With a QPROP propeller file, the propeller is computed from its blade geometry +instead of a table; a QPROP motor file gives the motor (see +[Blade-Element Propeller](reference/blade_element_propeller.md) and +[Motor](reference/motor.md)): + +```python +from pythrust.io import read_qprop_motor, read_qprop_propeller +from pythrust.propeller import BladeElementPropeller + +propeller = BladeElementPropeller(read_qprop_propeller("prop.txt")) +motor = read_qprop_motor("motor.txt", current_max_a=40.0) + +point = solver.solve_operating_point( + motor=motor, + battery=battery, + system=system, + propeller=propeller, + rho=1.225, + airspeed_mps=15.0, + throttle=0.7, +) +``` + +### Rate-map battery + For a rate-map battery, load a cell dataset, create an explicit battery state, and pass that state into the solver: diff --git a/mkdocs.yml b/mkdocs.yml index d3f72228..2c52f325 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,8 +10,8 @@ theme: logo: images/setuav_logo.png favicon: images/setuav_logo.png font: - text: Ubuntu - code: Ubuntu Mono + text: Fira Sans + code: Fira Code palette: - media: "(prefers-color-scheme: light)" scheme: default @@ -29,12 +29,21 @@ theme: name: Switch to light mode features: - navigation.tabs - - navigation.sections + - navigation.indexes - navigation.top - search.suggest - search.highlight - content.code.copy +plugins: + - search + - redirects: + redirect_maps: + theory.md: reference/propulsion_solver.md + api_reference.md: reference/propulsion_solver.md + data_files.md: reference/propellers.md + battery_model.md: reference/battery.md + extra_css: - stylesheets/extra.css @@ -61,18 +70,22 @@ markdown_extensions: extra_javascript: - javascripts/mathjax.js - - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js + - https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js nav: - User Guide: - - Home: index.md + - index.md - Getting Started: getting_started.md - - Propulsion Solver: usage.md + - Solving an Operating Point: usage.md - Examples: examples.md - Reference: - - API Reference: api_reference.md - - Propulsion and Battery Theory: theory.md - - Battery Model: battery_model.md - - Data Files: data_files.md + - Propellers: + - reference/propellers.md + - Tabulated Propeller: reference/table_propeller.md + - Blade-Element Propeller: reference/blade_element_propeller.md + - Motor: reference/motor.md + - Battery: reference/battery.md + - Propulsion Solver: reference/propulsion_solver.md + - OpenMDAO: reference/openmdao.md - Developer Guide: - Development & Testing: development.md diff --git a/pyproject.toml b/pyproject.toml index c7c22969..8629e88c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dev = [ docs = [ "mkdocs-material>=9.5", "pymdown-extensions>=10.0", + "mkdocs-redirects>=1.2", ] [tool.setuptools.dynamic]