ReactionMechanismGenerator / ReactionMechanismSimulator.jl

The amazing Reaction Mechanism Simulator for simulating large chemical kinetic mechanisms
https://reactionmechanismgenerator.github.io/ReactionMechanismSimulator.jl
MIT License
70 stars 33 forks source link

A new domain ConstantTVGasDomain #258

Open donerancl opened 2 months ago

donerancl commented 2 months ago

I made a new domain for constant temperature, constant volume gas. The pressure is calculated from the number of moles as simulation progresses.

I have used it in a simulation with a vapor liquid interface with no issues.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 162 lines in your changes are missing coverage. Please review.

Project coverage is 47.78%. Comparing base (1f37bfd) to head (a628c05).

:exclamation: Current head a628c05 differs from pull request most recent head 39319ca. Consider uploading reports for the commit 39319ca to get more accurate results

Files Patch % Lines
src/Domain.jl 0.00% 162 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #258 +/- ## ========================================== - Coverage 48.71% 47.78% -0.94% ========================================== Files 31 31 Lines 8313 8475 +162 ========================================== Hits 4050 4050 - Misses 4263 4425 +162 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

donerancl commented 1 month ago

I found a small bug in the rops function that we could include in this PR. In Simulation.jl line 254 raises an error if the array in the second term is empty (when using interfaces without reactions, e.g., VaporLiquidMassTransferInternalInterfaceConstantT) Nrxns = sum([length(sim.domain.phase.reactions) for sim in ssys.sims]) + sum([length(inter.reactions) for inter in ssys.interfaces if hasproperty(inter, :reactions)])

hwpang commented 1 month ago

Thanks for the PR! I see that the test is failing with

Test vapor-liquid phase multi-domain reactor simulation with VaporLiquidMassTransferInternalInterfaceConstantT and VolumeMaintainingOutlet interface: Test Failed at /home/runner/work/ReactionMechanismSimulator.jl/ReactionMechanismSimulator.jl/src/TestReactors.jl:143
  Expression: ≈((sol(sol.t[end]))[ind], 0.11758959354431776, rtol = 1.0e-5)
   Evaluated: 1.8655128553425897 ≈ 0.11758959354431776 (rtol=1.0e-5)

Could you take a look into it?

donerancl commented 1 month ago

@hwpang Just saw this and took a look. The temperature (298 K) for the test was below the range used to extrapolate kH and kLA, so my branch calculated the values of kH(T) and kLA(T) at the lowest temperature in the given range (350 K), making the results different. We could allow extrapolation if the kLA and kH values are not negative. It is probably alright in this case I would think.