Skip to content

[bug] Python interface: Frozen status not working for station 3+ #95

Description

@Acnones

Summary

When using the Python interface, setting n_frz=3 (freeze at station 3) produces results identical to n_frz=0 (fully equilibrium). The frozen status appears to be silently ignored for station 3, and the solver behaves as if the flow remains in chemical equilibrium throughout.
To verify the expected results, the same computation was run using the CEA web interface. Four input/output files are attached (equilibrium.txt, n_frz=1.txt, n_frz=2.txt, n_frz=3.txt). The discrepancy between the Python output and n_frz=3.txt is what indicates the bug.

equilibrium.txt
n_frz=1.txt
n_frz=2.txt
n_frz=3.txt

Reproduction

Interface: Python
OS: Windows
CEA version/commit: 3.2.0
Python version: Python 3.12

Minimal script:

import cea
import numpy as np

T_RP1_I = 300.0
T_gox = 550

o2_pct = 0.92
co2_pct = 0.04
h2o_pct = 0.04

OF_MCC = 2.763
P_ch = 100

reac_names = ["RP-1", "O2", "CO2", "H2O"]
fuel_weights = np.array([1.0, 0.0, 0.0, 0.0])

reac = cea.Mixture(reac_names)
prod = cea.Mixture(reac_names, products_from_reactants=True)
solver = cea.RocketSolver(prod, reactants=reac)
solution = cea.RocketSolution(solver)

oxidant_weights = np.array([0.0, o2_pct, co2_pct, h2o_pct])
T_reactant = np.array([T_RP1_I, T_gox, T_gox, T_gox])
weights = reac.of_ratio_to_weights(oxidant_weights, fuel_weights, OF_MCC)

hc = reac.calc_property(cea.ENTHALPY, weights, T_reactant) / cea.R

for n_frz in range(4):
    solver.solve(solution, weights, P_ch, supar=[1.3, 23], hc=hc, iac=True, n_frz=n_frz)
    print("n_frz =", n_frz, {
        'cstar': float(round(solution.c_star[0], 0)),
        'cf':    float(round(solution.coefficient_of_thrust[-1], 4)),
        'isp':   float(round(solution.Isp[-1], 3)),
        'ivac':  float(round(solution.Isp_vacuum[-1], 3)),
    })

Expected behavior

Each n_frz value should freeze the composition at the corresponding station and produce distinct, progressively more frozen thermodynamic results. Specifically, for n_frz=3, the expected output is:
cf: 1.7430, isp: 3136.1, ivac: 3305.5.
Frozen composition from the freeze station should be carried forward, and all thermodynamic properties should reflect a frozen flow calculation from that point onward.

Actual behavior

n_frz=3 produces results identical to n_frz=0 (fully equilibrium), indicating the frozen flag is not applied:
n_frz = 0 → cf: 1.7745, isp: 3192.729, ivac: 3392.157
n_frz = 1 → cf: 1.7274, isp: 3040.425, ivac: 3194.451
n_frz = 2 → cf: 1.7167, isp: 3088.720, ivac: 3248.425
n_frz = 3 → cf: 1.7745, isp: 3192.729, ivac: 3392.157 ← identical to n_frz=0, wrong

Additional context

The issue appears specific to n_frz >= 3. Values n_frz=1 and n_frz=2 do produce different results from equilibrium, suggesting the freeze logic works up to station 2 but silently falls back to equilibrium for station 3+.
No error or warning is raised.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions