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

Improving Reaction Parser #34

Open
3 tasks
keniley1 opened this issue Aug 24, 2019 · 0 comments
Open
3 tasks

Improving Reaction Parser #34

keniley1 opened this issue Aug 24, 2019 · 0 comments

Comments

@keniley1
Copy link
Collaborator

Currently the reaction parser works, but it's sloppy. It is done entirely with C++ string parsing by identifying specific tokens and splitting each reaction one by one for loops. Each product and reactant for every reaction is recorded by looking for an exact string match, and the stoichiometric coefficient is implemented by tallying the number of times the exact match appears on each side of the equation. Accordingly, each kernel is named for the number of reactants it includes: FirstOrderReactant, SecondOrderReactant, FirstOrderProduct, SecondOrderProduct, etc... Besides being pretty misleading, this comes with a host of obvious problems:

  1. Stoichiometric coefficients are included by writing out the number of reactants/products; e.g. e + Ar -> 2e + Ar+ must be written as "e + Ar -> e + e + Ar+". It is cumbersome to have to write out every reactant and product; imagine having a fake "reaction" (an empirical formula meant to simulate photoionization, for example) made up of dozens of products and reactants - writing such a formula out would be both obnoxious and prone to errors.

  2. In a related matter, the above assumes order and stoichiometry are the same. This is not always the case, though it is usually true for typical plasma systems. No fractional orders are allowed.

  3. There is really no need to have so many kernels...one product and reactant kernel with a loop in the constructor to count the number of reactants and multiply them together should be sufficient.

SOLUTIONS:

  • A better parser that allows a reaction with "2e" to be read as "e + e".
  • Modified kernels to include stoichiometric coefficient as an exponent in std::pow.
  • (OPTIONAL) Better string parsing algorithm in general (possibly with Perl?).

Replacing kernels should be done with care. std::pow might incur a performance penalty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant