Skip to content
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

Plasma phase #1190

Merged
merged 41 commits into from
Apr 25, 2022
Merged

Plasma phase #1190

merged 41 commits into from
Apr 25, 2022

Conversation

BangShiuh
Copy link
Contributor

@BangShiuh BangShiuh commented Feb 7, 2022

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

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@codecov
Copy link

codecov bot commented Feb 7, 2022

Codecov Report

Merging #1190 (eaab899) into main (b4616ef) will increase coverage by 0.02%.
The diff coverage is 71.76%.

@@            Coverage Diff             @@
##             main    #1190      +/-   ##
==========================================
+ Coverage   65.47%   65.50%   +0.02%     
==========================================
  Files         327      329       +2     
  Lines       46350    46664     +314     
  Branches    19688    19853     +165     
==========================================
+ Hits        30349    30566     +217     
- Misses      13476    13538      +62     
- Partials     2525     2560      +35     
Impacted Files Coverage Δ
src/thermo/Phase.cpp 81.48% <ø> (+0.35%) ⬆️
include/cantera/thermo/Phase.h 83.67% <60.00%> (-0.95%) ⬇️
src/numerics/funcs.cpp 71.92% <65.21%> (-28.08%) ⬇️
src/transport/IonGasTransport.cpp 75.20% <66.66%> (-0.53%) ⬇️
include/cantera/thermo/PlasmaPhase.h 71.42% <71.42%> (ø)
src/thermo/PlasmaPhase.cpp 73.29% <73.29%> (ø)
include/cantera/thermo/IdealGasPhase.h 94.73% <100.00%> (ø)
src/thermo/IdealGasPhase.cpp 77.70% <100.00%> (ø)
src/thermo/ThermoFactory.cpp 71.27% <100.00%> (-0.12%) ⬇️
src/kinetics/KineticsFactory.cpp 90.56% <0.00%> (-1.36%) ⬇️
... and 6 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BangShiuh Just a couple of small questions here

.vscode/c_cpp_properties.json Outdated Show resolved Hide resolved
src/numerics/funcs.cpp Outdated Show resolved Hide resolved
@BangShiuh
Copy link
Contributor Author

BangShiuh commented Feb 15, 2022

This PR is mostly done. One thing that I am not sure about is valuecache implementation. I hope I did it correctly. Another thing that might be a little confusing is the implementation of setElectronTemperature and setElectronEnergyDistrb. What I would like is that you can choose to use electron temperature to calculate electron energy distribution or you can use electron energy distribution to calculate electron temperature. Maybe there is a better to implement the mutually dependent relationship.

@ischoegl ischoegl self-requested a review February 15, 2022 19:10
Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BangShiuh ... for starters, I have a very high-level comment: based on how things are implemented, Plasma really is just a specialization of Phase, correct? Insofar, I think it would make sense to group the new classes with other specializations (and treat PlasmaPhase the same as any other ThermoPhase), rather than to create an entirely new parallel structure?

include/cantera/plasma/PlasmaPhase.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
test/data/oxygen-plasma.yaml Show resolved Hide resolved
include/cantera/plasma/PlasmaPhase.h Outdated Show resolved Hide resolved
@BangShiuh
Copy link
Contributor Author

Hi @BangShiuh ... for starters, I have a very high-level comment: based on how things are implemented, Plasma really is just a specialization of Phase, correct? Insofar, I think it would make sense to group the new classes with other specializations (and treat PlasmaPhase the same as any other ThermoPhase), rather than to create an entirely new parallel structure?

Yes, I think we had some discussion in #700 and decided to put plasma in a separate folder so that thermo is not getting more crowded. But if you think that is not a problem, I can definitely move it back.

@ischoegl
Copy link
Member

ischoegl commented Feb 20, 2022

I think we had some discussion in #700 and decided to put plasma in a separate folder so that thermo is not getting more crowded. But if you think that is not a problem, I can definitely move it back.

I think these should be kept in the same folder, as having headers for a derived class in a separate folder is somewhat confusing.

Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other thing I recalled from #1099 is this: #1099 (comment)

Could you include a mechanism here that makes Te track T for a regular IdealGasPhase?

@BangShiuh
Copy link
Contributor Author

@ischoegl I have made Te = T for IdealGasPhase. I made the setElectronTemperature throw NotImplementedError. For now, m_electronTemp is private of Phase. Do you think I should change it to protected so that I can use it directly or I should keep it private and use Phase::setElectronTemperature?

@ischoegl
Copy link
Member

ischoegl commented Feb 24, 2022

I made the setElectronTemperature throw NotImplementedError. For now, m_electronTemp is private of Phase. Do you think I should change it to protected so that I can use it directly or I should keep it private and use Phase::setElectronTemperature?

I believe this approach makes sense (for anything not outside of PlasmaPhase). For PlasmaPhase, things will get more interesting ... at the same time I am wondering whether there even should be a setter for Te as it is part of the thermodynamic state and thus not necessarily an independent variable?

@BangShiuh
Copy link
Contributor Author

BangShiuh commented Feb 26, 2022

@ischoegl Ultimately Te depends on T, E (electric field), and P. E provide energy for electron. Electrons lose energy to gas molecules which depends on gas density (pressure), gas temperature (weakly), and the collision cross-sections. So in the future, something like gas.TPE can be a way to set plasma state. Let me know if there is anything else that I can do in this PR.

@ischoegl
Copy link
Member

@BangShiuh … at the moment, this PR is still in draft status?

@BangShiuh BangShiuh marked this pull request as ready for review February 26, 2022 02:58
Copy link
Member

@ischoegl ischoegl left a 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 responding to the first round of review comments. The current round is mostly about formatting (there are some choices that are different from those commonly found in Cantera source code).

Beyond, I still am not sure about the introduction of the Plasma class in Python; from my viewpoint, it is not sufficiently distinct from other bulk phases. It probably needs to be integrated into Solution one way or another before this is ready to be merged.

include/cantera/thermo/IdealGasPhase.h Outdated Show resolved Hide resolved
include/cantera/thermo/PlasmaPhase.h Outdated Show resolved Hide resolved
include/cantera/thermo/PlasmaPhase.h Outdated Show resolved Hide resolved
include/cantera/thermo/PlasmaPhase.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/plasma.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/test/test_plasma.py Outdated Show resolved Hide resolved
src/thermo/PlasmaPhase.cpp Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
include/cantera/thermo/PlasmaPhase.h Outdated Show resolved Hide resolved
@BangShiuh BangShiuh force-pushed the plasma-phase branch 2 times, most recently from b5e60b4 to 77a1c14 Compare March 6, 2022 20:01
Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BangShiuh ... thanks for making the Plasma Python API consistent with other thermo phases!

The solution was to cast the child class to the parent class after initiation and cast back to the child class when using its member functions. It is a little tedious. Maybe we can figure out better ways to do this.

This is pretty much what is done elsewhere across the board (even the underlying C++) ... see ReactionRate, various Reactor implementations, etc. . So I think there's nothing wrong with using the same approach here.

interfaces/cython/cantera/thermo.pyx Outdated Show resolved Hide resolved
@BangShiuh BangShiuh force-pushed the plasma-phase branch 3 times, most recently from 975f534 to 0f06d40 Compare March 8, 2022 03:47
Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BangShiuh ... Although I still have a couple of minor comments, this looks mostly good to me.

include/cantera/numerics/funcs.h Outdated Show resolved Hide resolved
include/cantera/thermo/IdealGasPhase.h Outdated Show resolved Hide resolved
include/cantera/thermo/IdealGasPhase.h Outdated Show resolved Hide resolved
interfaces/cython/cantera/thermo.pyx Outdated Show resolved Hide resolved
interfaces/cython/cantera/thermo.pyx Outdated Show resolved Hide resolved
src/thermo/PlasmaPhase.cpp Outdated Show resolved Hide resolved
src/thermo/PlasmaPhase.cpp Outdated Show resolved Hide resolved
include/cantera/thermo/PlasmaPhase.h Outdated Show resolved Hide resolved
src/thermo/PlasmaPhase.cpp Outdated Show resolved Hide resolved
Use properties such as standard_enthalpies_RT
Use mean electron energy instead of electron temperature.
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @BangShiuh. This looks good to me. I did a little bit of cleanup of the history and commit messages and pushed that to your branch.

@speth speth merged commit 677558c into Cantera:main Apr 25, 2022
@BangShiuh BangShiuh deleted the plasma-phase branch April 29, 2022 16:34
@ischoegl ischoegl mentioned this pull request May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants