mutationpp / Mutationpp

The MUlticomponent Thermodynamic And Transport library for IONized gases in C++
GNU Lesser General Public License v3.0
101 stars 58 forks source link

Consistent change of reference temperature for thermo. #69

Open grgbellasvki opened 5 years ago

grgbellasvki commented 5 years ago

Small comment for discussion @jbscoggi . Many CFD codes use as a reference temperature T=0K instead of the 298.15K used by M++. I recommend the creation of a function like: shiftingConstantToZeroKelvin(double* const h_shift){ h_shift = h(298.15) - h(0); // invalid code, but you get the idea }

This is particularly important for NASA polynomials, where calling the enthalpy function with T=0 gives ambiguous results. Maybe, a linear extrapolation with the last valid database temperature using the local derivative (heat capacity) would be an option.

Briefly the transformation formula should be: h_zero(T) = h_Tref(T) + (h_Tref(Tref) - h_Tref(0)) assuming that h_zero(0) = h_tref(tref), which is the heat of formation for the species. Let me know if this is wrong.

jbscoggi commented 5 years ago

Hey @grgbellasvki, yes this is something that I wanted for a while. I think it might make more sense to shift the formation enthalpies for all the species. You could have some function like setReferenceTemperature(double T) in ThermoDB which allows the user to set it to whatever they want for any database. Since the shift does not depend on the type of database (just formation enthalpy and reference temperature), should be easy to do for all database types. Can you look into the specifics and let me know if you find any problems with that approach?

domilanza2002 commented 4 months ago

Good evening, I am trying to use this approach to shift the reference temperature from 25°C to 0°C. In particular, I am using python, so the branch pypi. The formula above works for RRHO and NASA-7, but when I try to use it with NASA-9, I get a huge (h-h0) enthalpy. In particular I am doing: import mutationpp as mpp mix=mpp.Mixture("nitrogen2") mix.equilibrate(298.15,101325) print(mix.mixtureHMinusH0Mass()) I get the value: 65604568531370.125

domilanza2002 commented 4 months ago

Good evening, I am trying to use this approach to shift the reference temperature from 25°C to 0°C. In particular, I am using python, so the branch pypi. The formula above works for RRHO and NASA-7, but when I try to use it with NASA-9, I get a huge (h-h0) enthalpy. In particular I am doing: import mutationpp as mpp mix=mpp.Mixture("nitrogen2") mix.equilibrate(298.15,101325) print(mix.mixtureHMinusH0Mass()) I get the value: 65604568531370.125

Just want to let you know that with the fix for the NASA-9 polynomials in the pull request #257 the problem is solved.