CAMP 1.0.0
Chemistry Across Multiple Phases
Boot CAMP: Part 2 - Mechanism

In the last installment of Boot CAMP we wrote the code for a simple box model. This time we'll build a simple chemical mechanism to run in the box model.

All CAMP input files are in json format, a widely used standard for structured data. Many free tools are available online to compose and validate json files, and many editors provide json syntax highlighting. If you are new to working with json files, we recommend writing the code in an online editor/validator like JSONLint.

There are two types of input files used by CAMP. We'll start with the simplest one. This is the file whose path we passed to the camp_core_t() constructor in part 1 of the tutorial. We named this file my_config_file.json and we'll make its contents as follows:

{
"camp-files" : [
"my_simple_mechanism.json"
]
}

CAMP configuration json files begin and end with curly brackets ("{}") that enclose an object named camp-files, which is a comma-separated array of file names that make up the chemical mechanism to load into CAMP. The mechanism data can be organized however you like, into as many files as you'd like. Thus, any number of camp-files may be specified and the arrangement of mechanism elements (species, reactions, etc.) within those files is up to you. Also note that json ignores most white space, so the code above is equivalent to:

{ "camp-files" : [ "my_simple_mechanism.json" ] }

One more note about the CAMP json files before we move on. CAMP ignores information in the input files that it is not interested in, as long as the file is in valid json format, and this information is not included as an element in an array CAMP uses. Thus, our configuration file could be:

{
"note" : "Remember to rename 'my simple mechanism' to something more meaningful",
"camp-files" : [
"my_simple_mechanism.json"
],
"change log" : [
"030919 md - created file",
"031019 md - revised file"
]
}

As far as CAMP is concerned, these files are equivalent. This is also a way to include comments in your json files, as comment flags are not part of the json standard. Note however that adding extra information as an element of the camp-files array (an array that CAMP uses) won't work, as CAMP expects these to be valid input file names.

The remaining CAMP input files describe the chemical mechanism and use the following format:

{
"camp-data" : [
...
]
}

Here, camp-data is a comma-separated array of model element objects. There can be any number of these input files, but they must all enclose their model elements with this text.

We'll start off wth a single file that describes our mechanism, my_simple_mechanism.json. The order of model elements in the camp-data array is arbitrary. We'll start with chemical species. In our first mechanism, we'll just have five: \(\ce{O3}\), \(\ce{NO}\), \(\ce{NO2}\), \(\ce{O2}\) and \(\ce{O}\). The input data for these gas-phase species in the camp-data array is:

{
"name" : "O3",
"type" : "CHEM_SPEC"
},
{
"name" : "NO",
"type" : "CHEM_SPEC"
},
{
"name" : "NO2",
"type" : "CHEM_SPEC"
},
{
"name" : "O2",
"type" : "CHEM_SPEC"
},
{
"name" : "O",
"type" : "CHEM_SPEC"
},

All CAMP model elements must have a unique name that is chosen by the user and a type that must be one of a set of CAMP data types. For chemical species, this type is CHEM_SPEC. Chemical species default to being gas-phase species, but can be specified as being condensed-phase, as we'll see later on.

Now, let's build our mechanism. We'll start with just two Arrhenius-type reactions:

{
"name" : "my simple mechanism",
"type" : "MECHANISM",
"reactions" : [
{
"type" : "ARRHENIUS",
"reactants" : {
"NO" : { },
"O3" : { }
},
"products" : {
"NO2" : { },
"O2" : { }
},
"A" : 26.59
},
{
"type" : "PHOTOLYSIS",
"reactants" : {
"NO2" : { }
},
"products" : {
"NO" : { },
"O" : { }
},
"my photo label" : "NO2 photolysis"
},
{
"type" : "ARRHENIUS",
"reactants" : {
"O" : { },
"O2" : { }
},
"products" : {
"O3" : { }
},
"A" : 2.183E-5
}
]
}

CAMP MECHANISM objects are collections of reactions, which are specified in the reactions array. For each reaction several elements must be specified. For Arrhenius-like reactions, these include the reactants and products, as well as the pre-exponential factor A. They also typically have some optional parameters, which assume default values unless they are specified in the input files. A description of the format used for each reaction's input data is described here. The empty curly brackets after the products and reactants allow for the inclusion of information specific to these species, such as reactant quantities (for self reactions) and product yields. For Arrhenius-like reactions, these are described in more detail here.

The only key-value pair not required by CAMP, but that is present in this input data is my photo label in the \(\ce{NO2}\) photolysis reaction. We'll use this label in part 3 of Boot CAMP to set the photolysis rate from our box model, and start generating results!

The full configuration and mechanism json files described in the part of the tutorial can be found in /doc/camp_tutorial/boot_camp/part_2_code.


< Previous: Boot CAMP: Part 1 - Box Model Index Next: Boot CAMP: Part 3 - Updating CAMP Parameters >