Hi Alex,
The problem with the C(gr) composition is due to including it as a gas phase species, which is non-physical. You need to define a separate solid phase for the graphite and include it in your Mixture definition. For example,
def calculate_thermo(press, temp_ox, temp_fu, k_m): import cantera as ct # Initialize pure oxidizer solution object in Cantera. oxidizer_pure = ct.Solution('reactants.yaml', 'O2(L)') oxidizer_pure.TP = temp_ox, press # Set temperature and pressure for pure oxidizer # Initialize pure fuel solution object in Cantera. fuel_pure = ct.Solution('reactants.yaml', 'RP-1') fuel_pure.TP = temp_fu, press # Set temperature and pressure for pure fuel molar_ratio = k_m * fuel_pure.mean_molecular_weight / oxidizer_pure.mean_molecular_weight moles_oxidizer = molar_ratio / (1 + molar_ratio) moles_fuel = 1 - moles_oxidizer # Initialize gas state for two pure propellants gas = ct.Solution('nasa9-twophase.yaml') # excludes C(gr) from the gas phase species list carbon = ct.Solution('graphite.yaml') # Phase containing C(gr), built into Cantera # Create a mixture of the liquid phases with the gas-phase model, with the number of moles for fuel and oxidizer mix = ct.Mixture([(oxidizer_pure, moles_oxidizer), (fuel_pure, moles_fuel), (gas, 0), (carbon, 0)]) # Solve for the equilibrium state, at constant enthalpy and pressure mix.equilibrate('HP') temp = gas.T enthalpy = gas.enthalpy_mass entropy = gas.entropy_mass phase_masses = [mix.phase_moles(i) * mix.phase(i).mean_molecular_weight for i in range(mix.n_phases)] total_mass = sum(phase_masses) Y_carbon = phase_masses[3] / total_mass return Y_carbon calculate_thermo(10e6, 60, 298, 0.5)For me, this returns 0.29598, which is in pretty good agreement with CEA.
Regarding the difference in specific heats, this is a question of definitions. Cantera’s definition of cp is the partial derivative of enthalpy with respect to temperature at constant pressure and composition. The value returned by CEA is the derivative while holding the system at equilibrium. You can compute a value like what’s returned by CEA by computing dh/dT using a finite difference method where the mixture is equilibrated at constant T and P at each point before calculating the enthalpy. You can see a related example here: https://cantera.org/examples/python/thermo/sound_speed.py.html.
Regards,
Ray