-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electron-temperature reaction #1099
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1099 +/- ##
==========================================
- Coverage 66.10% 65.15% -0.95%
==========================================
Files 313 315 +2
Lines 44963 45389 +426
Branches 19144 19279 +135
==========================================
- Hits 29721 29574 -147
- Misses 12658 13347 +689
+ Partials 2584 2468 -116
Continue to review full report at Codecov.
|
One difficult problem is the use of template (see my last commit). Since electron-temperature reaction use an extra data "Te", I built a special template to deal with the difference. Maybe there is a better way to handle this. |
Hi @BangShiuh ... thank you for submitting this PR (and for being persistent in getting this merged). As you probably have seen, the code base for reactions has changed considerably from 2.5.1, and is still in the process of changing. The background here is Cantera/enhancements#87, which will eliminate The current That said, it would be ideal if your addition would use the new framework; I am sure that @speth can provide some additional context. Also, note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BangShiuh ... thank you for continuing to push this forward. As explained in a previous comment, the way reactions are handled is currently undergoing significant changes. The proposed new functions for PlasmaKinetics
should likely use the new 'framework', which replaces RateCoeffMgr.h
in favor of MultiRate.h
. The comments you see below are meant to help you understand how the new framework is different from the legacy approach.
While most of what I am referring to is already in place, there are some pending changes in #1101, which may help clarify how the electron temperature can be handled. Of course, #1101 is not merged yet, so some details are still subject to change.
@BangShiuh, now that #1101 has been merged, can you implement a version of this that is works using the new reaction rate framework? I think this should now be possible without needing a new |
f41d2f8
to
03ff6fb
Compare
I can't figure out how to make the rate match in test_reaction.py. The eval function is suspicious. This might be wrong. rate(self.gas.T, self.gas.Te). Also, there are too many layers of functions in test_reaction.py. |
As of #1101, the second argument is pressure, with other parameters being buffered internally. I just simplified this in #1153, which will make what you are attempting here possible …
The idea of this unit test is that everything is handled the same way. The revised update mechanism in #1153 should help here as well. |
6d131b7
to
7cc5706
Compare
Yes, I think what you're seeing are issues with units. In |
@BangShiuh ... I believe @speth is correct in his assessment. Another way to look at this is that |
7cc5706
to
4ad4f49
Compare
@speth Thanks. I think I fixed it. The units are a little tricky. I will update the oxygen comments soon. |
4ad4f49
to
037f80b
Compare
I have reviewed the PR and is ready to be reviewed. The assertNear tolerance is still a problem. |
d1e2459
to
953f617
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BangShiuh ... the inconsistency in failing CI tests was somewhat puzzling to me, so I pulled and compiled locally (ubuntu 20.04 / Python 3.8); tests ran without problems.
Once I added the missing override
s to the three methods (clang
complained about this, although gcc
did not), nine of the test_reaction.py::TestETemp
tests started to fail (rate
and entries to gas.forward_rate_constant
evaluate as NaN
; there was also a failure in KineticsAddSpecies3.add_species_sequential
). It appears that the final
keyword (which imho belongs here) does make a difference. On a related note, adding final
and override
to BlowersMaselRate
(which imho should be added), does not produce any additional errors.
Regarding naming, I still hope that ETempRate
could be improved upon (see previous review).
@ischoegl I found out that void updateTe(double Te) need to be virtual. Do you know why? Maybe because update is override so the parent struct need access to updateTe. Once we agree on the name of the class (maybe TwoTempPlasmaReaction), I will update the code. |
I’m not sure why as there isn’t an overload involved. The base class doesn’t know about it (and it certainly shouldn’t be added to the base). |
I guess we need to figure out the difference of c++ version . |
@ischoegl m_elec_temp needs to have an initial value. Do you know how to prevent this kind of error in the future? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BangShiuh ... happy you located the bug! (which looks like one of the frustrating/hard-to-find ones). I have some minor remaining comments about nomenclature, but apart from that this looks mostly good to go from my side.
src/thermo/Phase.cpp
Outdated
@@ -26,6 +26,7 @@ Phase::Phase() : | |||
m_xml(new XML_Node("phase")), | |||
m_id("<phase>"), | |||
m_temp(0.001), | |||
m_elec_temp(0.001), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a more generic comment, shouldn't the electron temperature follow the phase temperature in cases that do not involve plasma (non-equilibrium)? This can likely be addressed when implementing Cantera/enhancements#127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be.
Hi @BangShiuh ... feel free to cherry-pick ischoegl/cantera@d618e63 |
cdd15ca
to
f6307ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update, @BangShiuh. This looks all good to me!
virtual void getParameters(AnyMap& node) const override; | ||
|
||
double evalFromStruct(const TwoTempPlasmaData& shared_data) { | ||
return m_A * std::exp(m_b * shared_data.logTe - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BangShiuh this is not equivalent to the form given in the docstrings above, isn't it?
k_f = A T_e^b \exp (-E_a/RT) \exp (-E_{a,e}/RT_e)
which is the form I would expect in 2-T plasma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TwoTempPlasma is no longer in Arrhenius. The docstrings should be update-to-date in TwoTempPlasmaRate.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm don't think the currently implemented form would work for (at least) our plasma models.
The currently implemented form is (1) :
k_f = A T_e^b \exp (-E_{a,g}/RT) \exp (E_{a,e} (T_e - T)/(R T T_e))
For T_e >> T which is typical in the discharge phase, it reduces to (2) :
k_f = A T_e^b \exp (E_{a,e}-E_{a,g}/RT)
This doesn't let you model Ionization and Excitation reactions.
In Kossyi's paper, these reactions are modeled as a function of the reduced electric field
For instance nitrogen ionization below :
In a 2-T model you could write them as a function of electron temperature. E/N is proportional to Te in the drift-diffusion approximation. You could convert these to an Arrhenius form, where the temperature is electron temperature :
k_f = A T_e^b \exp (-E_a/RT) \exp (-E_{a,e}/RT_e)
However, the form currently implemented in Cantera won't help.
It seems to be good to model electron attachment and detachment processes, as used by Kosssyi, but unfortunately these are not the main mechanisms in (at least) our plasma-assisted-combustion models.
How hard would it be to add the Electron-temperature Arrhenius form back ?
I'm really not familiar with C so cannot help unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the same as
You need to cancel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on ElectronCollisionPlasmaRate which will use the cross-section data and electron energy distribution function to calculate the reaction rates. Thank you for your interest in this feature! We would like to see more people contribute to this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It might be hard to read and slightly slower to compute, but it works so that's enough.
Your end goal is challenging but very helpful. How do you solve the electron energy distribution ? Bolsig / Bolos ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will write an electron Boltzmann equation solver similar to BOLOS in C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use this right-away 👏 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth an update to the documentation to note this use case of setting
Changes proposed in this pull request
If applicable, fill in the issue number this pull request is fixing
Closes #
If applicable, provide an example illustrating new features this pull request is introducing
Checklist
scons build
&scons test
) and unit tests address code coverage