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

Seed Mechanisms revisited #153

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open

Seed Mechanisms revisited #153

wants to merge 68 commits into from

Conversation

rwest
Copy link
Member

@rwest rwest commented Mar 16, 2011

This used to be issue #147. It is now a 'pull request' - but I'm not actually requesting you pull it in to the master branch just yet.. wait until it's finished :-) See http://help.github.com/pull-requests/ for details about pull requests.

There is a new 'seedmech' branch for us to implement the changes to seed mechanism behaviour that we discussed in the meeting a couple of weeks ago. You can follow its progress here in this "pull request".

For the record, this is what we're aiming at, based on the meeting we had:

Name Treatment Pdep? React with core Prunable?
Seed Mechanism species specified in condition file Included in core at start k(T,P) as specified Cross-react at start No
Seed Mechanism (species not in condition file) Placed on edge at start AND added to chemkin files. k(T,P) as specified React only when included in core No
Reaction Library Placed on edge. k(T,P) or k_inf chosen by user in condition file React only when included in core Yes
Kinetics Library Used if RMG predicts reaction exists via family template. k_inf React only when included in core Yes

So far:

  • seed mechanisms are now read in to the edge not the core,
  • seed mechanisms are included in the chemkin files even though they're on the edge.
  • if a reaction is in a seed mechanism, be it with pressure dependence or otherwise, then it is removed from any PDep networks before they are sent to the ODE solver, or printed in the chemkin files

Still to do:

  • checking to see if I broke restart
  • changing the pressure-dependent behaviour: use FAME to fill in gaps in P-Dep networks, but the seed mechanism to over-ride specified rates. (work in progress)
  • ... add more below!

Please feel free to contribute :-)

git fetch official
git checkout -b seedmech official/seedmech

rwest and others added 30 commits March 1, 2011 19:07
Previously the restart mechanism would be appended to the
seed mechanisms.
By keeping it separate, we can do different things with the
restart mechanism and the real seed mechanisms.
We will not be generating cross-reactions from seed mechanisms,
so this will be redundant. Should also update the input-file reading etc.
We just calculated these so that we could print them out.
Now we re-use that list instead of calculating them again.
Updated:
* SeedMechanism class (removed the generateReactions attribute)
* Method calls (removed the p_generateReactions parameter).
* Input parsing (including warnings for old input files).
* Documentation.
* Examples.

Not updated:
 * GUI
We'd updated some console output yesterday in the wrong place, because
it was duplicated. Now we use the same method twice.
It's the CoreEdgeReactionModel that does things like writing 
chemkin files, so we will need access to the seed mechanism
from that context.
The CoreEdgeReactionModel has new methods to getCoreAndSeedSpecies(),
which can be used in place of getSpecies() for things like the chemkin
thermo data, chemkin species list, and chemkin transport data.
Chemkin file will include:
* Seed mechanism reactions
* PDep from reaction libraries (Troe etc.) UNLESS duplicates a seed rxn.
* PDep from FAME (UNLESS it duplicates a seed or pdep-from-reaction-library)
* NonPdep from RMG (UNLESS it duplicates a seed reaction)
…t file"

Because the seed mechanism is dealt with differently now, this fix needs
to be done differently. First I'm reverting the fix, then I'll re-fix it.

This reverts commit 62d1a55
and commit 99cda1c

Conflicts (because of other changes since the fix was introduced):

	source/RMG/jing/rxnSys/Chemkin.java
	source/RMG/jing/rxnSys/ReactionModelGenerator.java
	source/RMG/jing/rxnSys/ReactionSystem.java
…ODE solve.

If a reaction is in a seed mechanism, be it with pressure dependence or
otherwise, then it is removed from any PDep networks before they are
sent to the ODE solver. Similar filtering is in place for printing CHEMKIN
files.

This sort of re-implements 62d1a55.
In getCoreAndSeedSpeciesSet(), instead of making a new LinkedHashSet 
contaiting both the Core and the Seed species, I was modifying the 
Core set (adding the Seed species to it) and returning that. Oops!
This helped us figure out when PDep reactions are or are not excluded from the ODE solver
because they duplicate existing reactions.
More detail is stored in the log file (Logger.debug) than the console (Logger.info)
regarding where each of the species and reactions came from.
Now written only once per iteration, instead of once for each reaction system.
To preserve the previous behaviour (the over-writing meant only the last reaction
system was saved) it now saves only the last reaction system.

I have also moved where this happens, to be just after the printModelSize() call,
because writing the chemkin files now has the side-effect of reporting their 
size, and it looks nicer in the log file if this occurs straight after printModelSize().
Previously, they were all placed on the edge. This was a problem when a reaction
should have been in the core (based on all reagents being in the core in
the condition file). Such reactions are now placed in the core.

Also, we now add both forward and reverse directions, if reverse directions exist.

The addReactionSet(LinkedHashSet) method did almost exactly what I needed, but
it would discard reactions that had a reactant not in the core (you couldn't
have something entirely in the edge). Rather than change the behaviour
of that method (which is used elsewhere) I made a new method: addReactionSetFromSeed
This commit adds if statements to three classes, checking whether a Seed
Mechanism exists before attempting to grab the species (reactions) stored
in the Seed.  Otherwise, NPE occurs when running RMG with no Seed Mechanisms.
This commit switches the general order of adding reactions to the ODE input
file and CHEMKIN chem.inp file from:
   * Seed
   * Reaction Library pdepreactions
   * RMG (fame) pdepreactions
   * RMG nonpdep reactions

to:
   * Seed
   * Reaction Library pdepreactions
   * RMG nonpdep reactions
   # RMG (fame) pdepreactions

Example: Suppose user started with H and O2 in the input file, and Glarborg/C3
reaction library.  RMG would find H+O2=O+OH in Glarborg/C3 library and would
make HO2 (H+O2) included, thereby finding the O+OH well, making
H+O2(+m)=O+OH(+m).  In the previous order, RMG would add the RMG pdepreactions
reaction to the list, and then add the Glarborg/C3 reaction to the list: this
would be an incorrect duplicate.

With the new order, RMG adds the Glarborg/C3 reaction, and then recognizes
the RMG (fame) pdepreaction to be a duplicate and will not add it to the ODE
or CHEMKIN list.
All references to the now-obsolete GenerateReactions field have been removed.
rwest and others added 22 commits March 16, 2011 00:42
The line with the reaction on has to have the high-P limit in.
I used the highest available P.
(This fix has been done in other files on other branches)
This one was tricky, because the original published mechanism does not 
label some of the rates, and I had to guess what they were from 
what the numbers were similar to and what order they were in.

This is the relevant section of the original file from doi:10.1016/j.proci.2008.06.188

!C2H4+OH=CH2CH2OH                     6.0E37  -8.140    8043 ! JIM/GLA08 SEN/MIL06 1 atm
!  DUPLICATE                                                 !
!C2H4+OH=CH2CH2OH                     7.3E23  -6.910    2855 !
!  DUPLICATE                                                 !
!C2H4+OH=CH2CH2OH                     6.0E37  -7.770   10736 ! JIM/GLA08 SEN/MIL06 10 atm
!  DUPLICATE                                                 !
!C2H4+OH=CH2CH2OH                     3.0E26  -4.870    2297 ! JIM/GLA08 SEN/MIL06 10 atm
!  DUPLICATE                                                 !
!C2H4+OH=CH2CH2OH                     6.0E37  -7.440   14269 !
!  DUPLICATE                                                 !
 C2H4+OH=CH2CH2OH                     2.4E20  -2.399    3294 ! JIM/GLA08 fit to SEN/MIL06 60 atm,600-900K
!C2H4+OH=CH2CH2OH                     2.8E19  -2.410    1011 ! JIM/GLA08 SEN/MIL06 100 atm
!  DUPLICATE                                                 !
I'm not sure we can actually handle comments in the positions I've put them
but it's useful to record somewhere that the high P limit is in fact the 
100 atm estimate.
These were
CO + OH = CO2 + H
CO + OH = HOCO
HOCO = CO2 + H

The PLOG rates came from C3/reactions.full
…ile.

C2H5O species renamed to CH3CH2O in C1 library to match naming system in C2 and C3 libraries.
The Jasper et al. kinetics for the CH3 + HO2 = CH3O + OH reaction were
incorrect for four of the Glarborg reaction libraries.  The kinetics
were reported as such (doi: 10.1016/j.proci.2008.05.036):

k1a = 7.679 x 10^-12 (T/298K)^0.2688 exp(346.0 K /T) cm3 molecule-1 s-1

The current A value in all four libraries is the per-molecule A
multiplied by Avogadro's number; however, one also needs to divide by
298^0.2688 as RMG's reference temperature for the T^n term is 1 K.

Furthermore, three of the libraries have the incorrect sign for the
activation energy; the Ea should be negative.

This commit resolves the issue.

Thanks to Yushi Suzuki for pointing out the error!


When applying this patch to the glarborgplog branch, I updated all instances of these rates (including the temporary files)
Signed-off-by: Richard West <rwest@mit.edu>
These have been moved (still commented) to the pdepreactions.txt files.
Not sure how RMG (or chemkin) cope with comments on these lines,
so moving them to be safe.
These were only commented because they had been as part 
of Glarborg's original method of doing PDep. They should
not have been excluded.
The original explanation for these is given in commit 4eb2769 as:
    The light folders have some chemistry removed. For
    C1_light, CH2(S), CH, and C are turned off. For
    C2_light and C3_light, any species R-C*-OOH has been
    replaced with R-C=O + OH.


Since then, they have not always been updated when the non-light versions
have been, and so have a variety of bugs etc in. I am removing them
so that they are not used by mistake. If somebody wants them back,
I suggest they use the above description to re-generate them from the latest
non-light versions.
This brings in all master branch updates up to the present time.

Conflicts:
	databases/RMG_database/kinetics_libraries/Glarborg/C2/reactions.txt
	databases/RMG_database/kinetics_libraries/Glarborg/C2_light/reactions.txt
	databases/RMG_database/kinetics_libraries/Glarborg/C3/reactions.txt
	databases/RMG_database/kinetics_libraries/Glarborg/C3_light/reactions.txt
	source/RMG/jing/rxnSys/ReactionModelGenerator.java
	source/RMG/jing/rxnSys/SeedMechanism.java
all resolved.
@rwest
Copy link
Member Author

rwest commented Mar 28, 2011

The above block of commits (e422ef4 ... f777cb4 ) are all for converting the Glarborg seed mechanism / reaction library into PLOG format. Unfortunately this format cannot yet be read succesfully, but I think this conversion is now complete. thanks to @connie for the help.

@rwest
Copy link
Member Author

rwest commented Mar 28, 2011

I'm not sure this is going to work...
I think neither the ODE solver code (JDAS.java) nor the convergence checking code (appendUnreactedSpeciesStatus in ReactionSystem.java) are set up to handle Troe, Lindemann, or 3rd Body reactions on the edge, so the fluxes are not calculated correctly. After yet another day it's looking increasingly hard to fix, and I'm wondering if it's worth it.

Conflicts:
	source/RMG/jing/rxn/ReactionLibrary.java
	source/RMG/jing/rxnSys/SeedMechanism.java
When constructing a PDepRateConstant with some PLOG kinetics,
the mode is now set to Mode.PDEPARRHENIUS for that
rate constant.
…ion.

For FAME-generated PLOG reactions, there are probably the same number as
there are FAME pressures. However, if PLOG rates are read in from a
reaction library or seed mechanism, they will have a different number
of PLOG rates. I am about to remove the static nature of
PDepArrheniusKinetics.getNumPressures() so the current code will have to break,
for restart jobs where FAME-made pdep rates are expressed in PLOG form.
Hopefully this commit will help make it relatively easier to fix...?
…inetics

Instead of being a static list of Pressures (and static int numPressures) these
are not static, i.e. they are stored on each instance of PDepArrheniusKinetics.
This allows each PDepArrheniusKinetics object to have a different list of pressures.
This is important for rates that are read in from reaction libraries or seed
mechanisms.
… readPdepReactions.

Now that (as of d137bf2 )
we are always marking reactions read in via
the SeedMechanism.read as being FromPrimaryKineticLibrary,
we no longer need to pass the 'pkl' attribute which is
always true.
@rwest rwest mentioned this pull request Jun 7, 2012
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.

None yet

3 participants