From charlesreid1

On The Stack

Chart 1: Species Reaction Rates

For our first chart, we will make a D3 bar chart that shows a ranking of chemical species reaction rates.

Plot 1A (warm up): generation

  • Bar chart, horizontal
  • Magnitude of species generation term, ranked in order
  • Labels on left, bars on right

Plot 1B (warm up): consumption

  • Bar chart, horizontal
  • Magnitude of species consumption term, ranked in order
  • Labels on RIGHT, bars on LEFT

Plot 1C (1st real plot): net rates

  • Bar chart, split and on both sides
  • left side: consumption rate bars
  • right side, generation rate bars
  • ranked by: magnitude of gen/con rates

Notes

Monday August 1

If graphene as is isn't working... change the approach. Don't give up on Graphene.

Come up with a few ideas - ways of visualizing

Pick the simplest and go from there

After: go to literature, search out reaction pathways and mechanisms, verify your findings/visualization methods

A word on data vs. simulation: only visualizing simulation data - can't draw real conclusions, and only stating what the model assumptions imply. Like a thought experiment, incorrect assumptions lead to incorrect results.

With Graphene... what is it we're really trying to see? We're trying to understand a mechanism, which is like a giant Rube Goldberg machine, and how given inputs and a given starting state will create a chemical cascade into the output products.

Clarification questions

Q: to understand a mechanism... what is it we're trying to understand? Why can't we just print out everything we're interested in, and parse through the numbers ourselves?

A: Because it's complicated and nonlinear and stiff and extremely sensitive to small variations.

Q: okay, let's say we're dealing with a simpler reaction: for example, ammonia synthesis. Let's consider the Haber Process, in particular: what makes this reaction easier to "understand"?

A: Well, the answer is in the Fogler textbook - a basic course in undergraduate reactor design/reaction engineering. But in short, a simple reaction network allows you to:

  • Easily understand the affect of various inputs like temperature or reactant feed ratio
  • Construct both analytical (mathematical) and mental (intuitive) models of the process, understand the broader context of how rxn changes in thermochemical state space
  • If we want to know, "What happens when T goes up 20 degrees?," with a simple rxn network we can point to the mechanism and say, this changes that, that changes this, XYZ. But with a complex rxn network we shrug and say, I dunno, let's find out.
  • Where is the energy going, where is the mass going, what are the pathways, when and where and why do they open or close?
  • If you can get a better intuitive understanding of the reaction network, you can gain a deeper understanding of cause and effect: "T increased 20 degrees here, that shuts off the flow to this radical pool and opens up this other radical pool, which interferes with these pathways, and turns on these side reactions."
  • Or: "Here's what your gas looks like when it hits the catalyst at the top of the bed." "Use that condition to feed into the next condition, and you can see that those radicals that aren't available at the top, are available here, and that changes these pathways."

Uses of graphene

More about the uses of graphene: Ideally, we would be able to identify, under certain conditions, for example, "reactants follow these two pathways, which interact in this certain way. When you increase X, it shuts off Y, causing Z."

Then, you can figure out, Path 1 is XYZ, Path 2 is JKL, so now we can look at a different but related condition, and see what affect that change has.

I see a big potential issue: this network is an absolute SPIDER WEB. This raises the question of what I'm actually trying to do, and what filtering/processing will happen where in the process.

In reality, there may be dozens of pathways, connected by hundreds of side-paths. So the question is, what dominates?

Picking which species or which reactions to display requires defining a threshhold.

Full Species List         Full Rxn List
- - - - - - - - -                - - - - - - - - - - - 
- - - - - - - - -                - - - - - - - - - - - 
- - - - - - - - -                - - - - - - - - - - - 
- - - - - - - - -                - - - - - - - - - - - 

Reduced Species List         Reduced Rxn List
- - - -                                  - - - -
- - - -                                  - - - -

Starting point:

  • Ranked species list
  • Ranked reaction list
  • Use ranked list to construct a reduced graph

This raises more questions: how is this different from what I was doing before? Where does the processing happen - preprocessing, or with D3?

Avoid processing with D3 as much as possible. So, add an extra step between Cantera and D3: post-Cantera, pre-D3 processing of the reaction data with Python.

This is important, since the graphs can be very unwieldy. Want to do as much data reduction as possible with Python.

______________      ____________________      ___________      _____________________      _____________
|            |      |                  |      |         |      |                   |      |           |
|Cantera     |      | Cantera output   |      | Python  |      | Graphene input    |      | Graphene  |
|(full info) |----->| (reduced output) |----->| (magic) |----->| (processed input) |----->|           |
|            |      |                  |      |         |      |                   |      |           |
|____________|      |__________________|      |_________|      |___________________|      |___________|

Notes on using Cantera

If we use Cantera to run simulations of the gas and save the output at specified intervals, this will involve a lot of steps and code wrangling. Many of these steps were made more sensible and higher-level with OCM/Pantera (but this made them into a bit of a labyrinth). Things like taking care of the entire reactor network, installing walls where necessary, etc.

Since we are restarting Graphene, we will either have to do away with all of that, and go back to caveman style, or to re-implement everything into compact objects specific to Graphene, or to use Pantera, which would require more dusting off of more code and potentially opening more cans of worms.

The goal here is not to focus on Cantera or Pantera (maybe later). Right now the goal is to focus on D3. That means we need to get whatever Cantera code we need written and out of the way as soon as possible. That means charging through it. Let's focus on generating a single data set and visualizing a single reaction network, first, and then we can worry about making the output fancy.

(Also remember: OCM/Pantera was designed for an entirely different purpose - and will definitely be overkill for Graphene.)

Cantera output

The Cantera code would be running a batch reactor, and stepping through the differential equations, one step at a time. (Think autoignition, to start.) At each step, or at specified time intervals, we bottle up the gas and save the gas state. That's it - no other processing or saving or anything like that. The state of the gas can be reduced to a JSON object or a single string containing TPX (temperature, pressure, composition). These completely specify the thermochemical state of the gas, and any other quantity can be obtained from there.

The purpose of "bottling" the gas and saving that information is that it uses the absolute minimal storage space necessary. In the Python post-processing script, each gas can be "unbottled" and various properties tabulated - entropy, generation or consumption rates, reaction rate constants, and so on.

Python step

Next step is Python post-processing. Generally speaking, one Python post-processing script corresponds to one visualization in Graphene - Python script will create custom output for a particular type of D3 plot, in whatever structure it requires. (Remember: as little processing in D3 as possible.)

As mentioned above, the Cantera portion of Graphene is intended to run a simulation and save the state of the gas at periodic intervals. It is up to the post-processing script to decide what data is important, what relationships to create, and so on. This allows us to be as flexible as possible with the D3 visualizations.

Python is loading the thermochemical state of the gas, then creating a new gas object with that same thermochemical state. This gas object can then be queried to find out lots of interesting information. Some quantities we may be interested in:

  • Species concentrations (linear/log)
  • Species net/gross generation/consumption rates
  • Chemical reactions forward/reverse/net reaction rates
  • Chemical reactions kinetic rate constants
  • Chemical reactions largest energy release
  • Chemical reactions largest heat release rates

Energetics: a very small, fixed timestep has some associated amount of heat released. Where does this heat come from? ("It comes from reactions ABC. It comes from the consumption of XYZ.")

Mass: a very small, fixed timestep has zero mass change. But the balance of species changes. What are the various concentrations, and how quickly are they changing?

Flags