comocheng / kineticmodelssite

a django site for kinetic models
4 stars 9 forks source link

Decouple model species representations from explicit definitions #136

Closed kiancm closed 3 years ago

kiancm commented 3 years ago

This is an experimental change that represents species as a chemical formula with a specific combination of isomers and resonance structures.

rwest commented 3 years ago

Is here a reasonable place to discuss the idea?

Some thoughts so far:

  1. We need something to represent what is meant by a thing in a kinetic model. Something that gets an ODE and has a concentration. I call this a Species. If we want to include all measured/published kinetics (eg. import http://primekinetics.org or https://kinetics.nist.gov) then it might not even have a chemical formula, because they may have measured the rate of "A + B -> products" and "Products" has no formula. However, if we limit ourselves to things in CHEMKIN files, then they must have a formula, because that's part of how Chemkin works (the ODEs assume continuity equations, so to conserve mass you conserve atom types). Although you can have non-integer formulae like "CH1.935O0.02N0.04" to represent coal or something. So, if we stick to Chemkin files, we can assume each Species has a unique formula. Certainly makes sense for a Species object to have a formula field.

  2. We could have a table of Formula and link to it from the Species. However, if we have a canonical way to write formulae (e.g. put the C first, then the H, then other atoms in alphabetical order) then we could just use a string, and can search, index, ensure uniqueness, etc. etc. just as easily, without needing table joins. ?

kiancm commented 3 years ago
  1. Yes, and this change is basically separating things in kinetic models from canonical data ie. We have a C4H10 "tree" with isomers n-butane and isobutane and respective resonance structures, and then a thing in a kinetic model with a given name that is some combination of things from the C4H10 tree.

  2. We are actually linking a species to the whole tree of data and specifying what elements in the tree the species is defined as

Basically we are divorcing "atomic" data from our species so that we can put uniqueness constraints on the data and not have to make a whole tree of isomers and structures for each individual species

kiancm commented 3 years ago

I should probably rename Formula to Molecule as it's basically analogous to an rmg molecule

rwest commented 3 years ago

image

An RMG Molecule is a Structure in this. Only one adjacancy list, representing one resonance structure. A typical RMG Species contains multiple resonance structures but they're all the same Isomer. Typically there's a 1-to-1 mapping from Isomer (RMG Species) to our databaseSpecies`; certainly in all RMG-built models. (But some hand-built and reduced models have lumped species comprising multiple isomers).