Thermodynamic properties for a 2-temperature plasma#2101
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2101 +/- ##
==========================================
- Coverage 77.71% 77.65% -0.06%
==========================================
Files 452 452
Lines 53316 53412 +96
Branches 8894 8914 +20
==========================================
+ Hits 41432 41479 +47
- Misses 8870 8899 +29
- Partials 3014 3034 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hello ! I have reread the Contributing guide, and I just seen that I have used merge instead of rebase in this work. Is it still possible to use Also, I have opened an enhancement request, to discuss the physics behind the code. |
|
As for the CI/CD tests, Locally, after running As for the examples, |
I think you can rebase your local branch on top of our One other thing: in commit 41ea41e, the files |
…`, `getGibbs_RT`, and `getPartialMolarEntropies`
…etStandardVolumes`
Changed the setState_TD method in the Phase class to be virtual, allowing derived classes to override this method for custom behavior.
748c69a to
c626963
Compare
|
Hello, I have rebased, rewrote the history and force push. |
speth
left a comment
There was a problem hiding this comment.
Thanks for working on this, @pag1pag. Overall I think this is a significant improvement in the consistency of how we handle the thermo properties when there are two distinct temperatures. However, there is still one discrepancy that we need to resolve, which involves the definitions of the standard concentration, the activities, and the species standard molar volumes. The implementation here defines a single value for the standard concentration,
Since the current kinetics implementation relies on there being only a single standard concentration for a phase, I think the best fix for this is to define the activity for the electron as
I'm not quite sure what the value of introducing the methods setState_TgTeP and setState_TgTeD is, over just calling setElectronTemperature followed by setState_TP or setState_TD (other than the fact that the latter currently overwrite the electron temperature). If these methods left the electron temperature alone, I think we could avoid adding these specialized methods (which are difficult to access in any case).
As an editorial note, the combination of formatting updates (specifically, rearranging the methods in both the header and implementation) with substantive code changes made this quite challenging to review. It's very difficult to identify where there are actual implementation changes versus just moving functions around. I would strongly recommend not mixing such changes in a single PR in the future.
| * @f] | ||
| * where heavy-species properties are evaluated at @f$ T @f$, electron properties | ||
| * at @f$ T_\text{e} @f$, and @f$ P @f$ is the total pressure of the mixture. | ||
| * For an ideal gas, enthalpy is indepedant of pressure. |
There was a problem hiding this comment.
| * For an ideal gas, enthalpy is indepedant of pressure. | |
| * For an ideal gas, internal energy is independent of pressure. |
| * @f] | ||
| * where heavy-species properties are evaluated at @f$ T @f$, electron properties | ||
| * at @f$ T_\text{e} @f$, and @f$ P @f$ is the total pressure of the mixture. | ||
| * For an ideal gas, enthalpy is indepedant of pressure. |
There was a problem hiding this comment.
| * For an ideal gas, enthalpy is indepedant of pressure. | |
| * For an ideal gas, enthalpy is independent of pressure. |
| """Get the mean temperature of the plasma [K]. | ||
| This is a mole-weighted average of the electron and heavy species temperatures. | ||
| """ |
| skip_cp = false; // Not implemented for PlasmaPhase | ||
| skip_entropy = false; // Not implemented for PlasmaPhase |
There was a problem hiding this comment.
These default to false, so presumably these lines can just be deleted now.
| // ================================================================= // | ||
| // ================================================================= // |
There was a problem hiding this comment.
I'd prefer to leave out these decorative dividers; the named method groups can stay.
| * \begin{align} | ||
| * \hat h(T, T_\text{e}, P) | ||
| * &= \sum_{k} X_k \tilde{h}_k(T_k) | ||
| * = \sum_{k} X_k h^\text{ref}_k(T_k) \\ | ||
| * &= \sum_{k \neq e} X_k h^\text{ref}_k(T) | ||
| * + X_\text{e} h_\text{e}^\text{ref}(T_\text{e}) | ||
| * \end{align} |
There was a problem hiding this comment.
I know we aren't broadly consistent about this, but I don't think we need a different decoration for mixture molar enthalpy and partial molar enthalpy. My preference would be to keep 0 to superscript ref here. I think it would be better to stay notationally consistent with IdealGasPhase so the meaningful differences stand out more clearly.
| try { | ||
| setTemperature(t); | ||
| if (m_distributionType == "isotropic") { | ||
| setElectronTemperature(t); | ||
| } else { | ||
| // Warning for other distribution types. | ||
| warn_user("PlasmaPhase::setState_TP", | ||
| "The electron temperature is not set equal to the gas temperature " | ||
| "when using '{}' electron energy distribution. " | ||
| "This may not be intended.", m_distributionType); | ||
| } | ||
| setPressure(p); |
There was a problem hiding this comment.
I'm not sure this is the best choice for how to handle setting T for either the isotropic or full EEDF-based cases. In the latter case, clearly we should not set the EEDF based on the gas temperature. But then there seems to be no way to set the temperature of the gas without triggering this warning (as now seen in various tests and the examples). On the other hand, it also seems strange to reset the electron state by setting T only in the case of an isotropic distribution.
My intuition would be that we should leave the electron state alone when setting T -- let that just be the gas temperature, and have that be true regardless of how the EEDF is specified. That also seems more consistent with introduction of the meanTemperature property.
|
|
||
| //! Set the state using an AnyMap containing any combination of properties | ||
| //! supported by the thermodynamic model | ||
| /*! | ||
| * Accepted keys are: | ||
| * * `X` (mole fractions) | ||
| * * `Y` (mass fractions) | ||
| * * `T` or `Tg` or `gas-temperature` [K] | ||
| * * `Te` or `electron-temperature` [K] | ||
| * * `P` or `pressure` [Pa] | ||
| * * `D` or `density` [kg/m^3] |
There was a problem hiding this comment.
I wonder if we can support the full set of options allowed at the ThermoPhase level, and avoid reimplementing much of that method, by simply setting the electron temperature first and then calling the base class method.
| // If the electron temperature is negative, throw an error. | ||
| if (Te < 0.0) { | ||
| throw CanteraError("PlasmaPhase::setElectronTemperature", | ||
| "Electron temperature cannot be negative."); | ||
| } |
There was a problem hiding this comment.
This guard should apply to setMeanElectronEnergy as well, which can be achieved by having that method call setElectronTemperature with the computed value.
| // Below are 5 methods already defined in IdealGasPhase, that do not need | ||
| // to be overridden, since they do not depend on the temperature. | ||
| // { | ||
| // void getEnthalpy_RT_ref(span<double> hrt) const override; | ||
| // void getGibbs_RT_ref(span<double> grt) const override; | ||
| // void getEntropy_R_ref(span<double> er) const override; | ||
| // void getIntEnergy_RT_ref(span<double> urt) const override; | ||
| // void getCp_R_ref(span<double> cprt) const override; | ||
| // } |
There was a problem hiding this comment.
I think this description is a bit misleading -- the reason these methods do not need to be overridden is the same as for getEnthalpy_RT and friends: because the electron temperature correction is handled by updateThermo. More generally, I think it would be more clear to document this all in the active sense as documentation for the updateThermo method, explaining that this method handles getting properties at the correct temperature for each species, rather than explaining the things we don't have to do here.
Note that the following assumes that a temperature can be defined for all species. While this may be true for all heavy species, electrons may not be characterized by an electron temperature (for instance, if the electron energy distribution function (EEDF) is far away from a Maxwellian). It is therefore assumed that the implementation below holds if, for instance, the EEDF is Maxwellian (which may be seen as a strong approximation in plasma). See also Cantera/enhancements#258 for details about the physics behind the code.
The partial pressure is defined as:$P_k = R T_k X_k \rho_m$ (with $\rho_m$ the mixture molar density).$P = \sum_k P_k = R \rho_m \sum_k X_k T_k$ $\overline{T}=\sum_k X_k T_k$ , the total pressure is rewritten $P = R \rho_m \overline{T}$ .
The total pressure is the sum of all partial pressure:
Introducing a mean temperature, defined by
The standard concentration ($c^°=\frac{P}{R \overline{T}}$ .$v_k = \frac{R T_k}{P}$ .
standardConcentration) uses this mean temperature:The standard volume (
getStandardVolumesandgetPartialMolarVolumes) isChanges proposed in this pull request
enthalpy_mole,entropy_mole,gibbs_mole,intEnergy_molemeanTemperature,pressure,setPressure,electronPressurestandardConcentrationgetChemPotentials,getPartialMolarEnthalpies,getPartialMolarIntEnergies,getPartialMolarVolumesgetStandardChemPotentials,getStandardVolumesgetGibbs_ref,getStandardVolumes_refsetStatemethod to account for additional electron temperature. Also introducesetState_TgTePandsetState_TgTeDto set electron temperature along with other quantities.If applicable, fill in the issue number this pull request is fixing
Closes #1872
If applicable, provide an example illustrating new features this pull request is introducing
AI Statement (required)
assistance.
Checklist
scons build&scons test) and unit tests address code coverage