TurbineSpool
- class turbodesign.turbine_spool.TurbineSpool[source]
Used with turbines
This class (formerly named Spool) encapsulates both the generic geometry/plotting utilities from the original base spool and the turbine-solving logic that lived in the turbine-specific spool implementation.
Notes on differences vs. the two-class design: - field(default_factory=…) was previously used on a non-dataclass attribute
(t_streamline). Here it’s handled in __init__ to avoid a silent bug.
fluid defaults to Solution(‘air.yaml’) if not provided.
All turbine-specific methods (initialize/solve/massflow balancing/etc.) are preserved here. If you ever add a CompressorSpool in the future, consider splitting turbine/compressor behaviors behind a strategy/solver object.
- static __massflow_std__(blade_rows: List[BladeRow]) float[source]
Calculate massflow standard deviation across blade rows.
Computes the standard deviation of total massflow (without coolant) across all blade rows. Used as a convergence criterion for pressure balance and angle matching iterations. Warns if deviation exceeds 1.0 kg/s.
- Parameters:
blade_rows – List of all blade rows (inlet, stators, rotors, outlet)
- Returns:
Two times the standard deviation of massflow [kg/s]
- Return type:
float
- calculate_streamline_curvature(row: BladeRow, t_hub_shroud: List[float] | ndarray[tuple[Any, ...], dtype[_ScalarT]]) None[source]
Calculates the streamline curvature
- Parameters:
row (BladeRow) – current blade row
t_radial (Union[List[float], npt.NDArray]) – percent along line from hub to shroud
- export_properties(filename: str = 'turbine_spool.json') None[source]
Export turbine spool properties and blade row data to JSON file.
Exports comprehensive turbine design data including blade row properties, streamline coordinates, efficiency metrics, degree of reaction, stage loading, and power calculations for each stage. Useful for post-processing and result archiving.
- Parameters:
filename – Output JSON file path (default: “turbine_spool.json”)
- Returns:
None. Writes JSON file to specified path.
Example
>>> spool.export_properties("eee_hpt_results.json")
- plot_convergence(save_to_file: bool | str | None = None) None[source]
Plot convergence history showing massflow error vs iteration.
Displays a semi-log plot of the massflow standard deviation error across iterations. If convergence history is empty, warns user.
- Parameters:
save_to_file – If True, saves to “convergence.png”. If string, saves to that filename. If None/False, displays plot without saving.
- Returns:
None. Either displays plot or saves to file.
Example
>>> spool.solve() >>> spool.plot_convergence() # Display plot >>> spool.plot_convergence(save_to_file=True) # Save to convergence.png >>> spool.plot_convergence(save_to_file="my_convergence.png") # Save to custom file
- plot_velocity_triangles() None[source]
Plot velocity triangles for each blade row with improved styling and annotations.
- save_convergence_history(filename: str = 'convergence_history.jsonl') None[source]
Save convergence history to JSONL file.
Writes the convergence history collected during solve() to a JSON Lines file, where each line is a JSON object representing one iteration.
- Parameters:
filename – Output JSONL file path (default: “convergence_history.jsonl”)
- Returns:
None. Writes JSONL file to specified path.
Example
>>> spool.solve() >>> spool.save_convergence_history("turbine_convergence.jsonl")
- set_blade_row_exit_angles(radius: Dict[int, List[float]], beta: Dict[int, List[float]], IsSupersonic: bool = False) None[source]
Set intended exit flow angles for rows (useful when geometry is fixed).
- solve_for_static_pressure(upstream: BladeRow, row: BladeRow)[source]
Solve for static pressure at blade row exit using isentropic flow relations.
Uses massflow-area-Mach number relation to find static pressure from known total conditions. Attempts both subsonic and supersonic solutions and selects the subsonic solution.
- Parameters:
upstream – Upstream blade row providing inlet conditions
row – Current blade row where static pressure is being solved
- Returns:
None. Updates row.M, row.T, and row.P in-place.
- solve_massflow_for_power(target_power: float, massflow_guess: float | None = None, tol_rel: float = 0.001, max_iter: int = 8, relax: float = 0.7, bounds: tuple[float, float] = (1e-06, 1000000000.0)) tuple[float, float][source]
Power-driven closure: iterate inlet massflow to hit a target turbine power.
- This uses a simple algebraic update (no additional nested optimizer):
mdot_next = mdot_current * (P_target / P_current)
The inner flow solution still uses the existing pressure-balance method to maintain a consistent massflow between rows for the current guess.
- Parameters:
target_power – Desired turbine power [W]. Use a positive value for power extracted.
massflow_guess – Optional starting guess for inlet massflow [kg/s]. Defaults to self.massflow.
tol_rel – Relative tolerance on power error.
max_iter – Maximum outer iterations.
relax – Under-relaxation factor (0–1) for massflow updates.
bounds – (lower, upper) bounds for massflow during updates.
- Returns:
Tuple of (achieved_massflow_kg_s, achieved_power_W).