Modifying your First Own Simulation - Introduction to Mixins

In the previous tutorial Creating your First Own Simulation we used experimental data collected by Karakaya and coworkers 1 for the catalytic conversion of CH4 over Rh at 873K in a stagnation flow reactor. The catalytic plate of their reactor was covered with a washcoat consisting of over 99 wt% Al2O3 and the catalytically active Rh. For the simulation in the mentioned tutorial we neglected the presence of the washcoat and assumed the surface to be a perfectly flat metal foil by setting the ratio of the catalytic to the geometrical area of the plate to be equal to one (f_cat_geo: 1).

In this second tutorial, we now want to study the influence of the washcoat numerically. Mixins provide a way to add (or to overwrite existing) simulation parameters of a case, i.e. parameters used by the driver for the simulation. This allows you to quickly vary a number of things like fitting variables, catalyst structure, or reaction mechanisms by just clicking on them in CaRMeN's user interface.

In this tutorial, we will create a series of mixins for the case you created in the previous tutorial.

Steps

  1. General Syntax of a Mixin
  2. Examples of Mixins
    1. Adding a Washcoat
    2. Changing the variable f_cat_geo
    3. Varying the Reaction Mechanism
  3. Concluding Remarks

1. General Syntax of a Mixin

Mixins follow the same data structure as cases. That means that a minimally valid mixin requires the presence of a package.json file (and optionally a carmen.yml file) in the Project Directory. In the tutorial Creating your First Own Simulation we used a single carmen.yml file to define the simulation parameters. In this tutorial we will follow the same strategy and define the mixins within the carmen.yml file.

NOTE: carmen.yml files can actually be given any name, as long as it contains the extension .yml and the name of the file matches the value given in the package.json file. In this and further tutorials however we will consequently stick to the file name carmen.yml for the sake of clarity.

To create a mixin open the carmen.yml file. We begin by adding a mixin field in the top-most level, i.e. at the same indentation level as the previously defined cases and resources fields. As for the other fields, mixins are given as an array, each one starting with one level of indentation (i.e. two blank spaces) followed by a - hyphen.

mixins:
  -
    # mixin definition 1
  -
    # mixin definition 2
  # ...

Mixins require a title key and a configuration field. The title field defines the name of the mixin as it is shown in CaRMeN's user interface. It is therefore important to give it a name which allows you to quickly and unequivocally identify it. The configuration field contains the parameters to be added to (or overwritten in) the case. Since the simulation parameters depend on the driver used, we must first define which driver we are working with. All parameters are then given as an array, each entry corresponding to a driver and starting with an additional level of indentation (i.e. two additional blank spaces) followed by a - hyphen. In this example we only use one driver, so only one entry is required:

# mixin definition
title: this title will be shown in the user interface
configuration:
  -
    # configuration item 1
    driver: detchem_stagnation
    parameters:
      # ...

NOTE: Mixins can only add or overwrite parameters of the driver. A mixin can neither modify the name of a case nor the experimental data.

The code snippet above shows the general syntax of a mixin. Each item in the mixin definition's configuration array requires a driver key and a parameters key.

The driver field defines the driver for which the values in the parameters field apply to. Here we use the the DETCHEM stagnation driver so we write detchem_stagnation. Under the parameters field, all driver parameters to be set in the case are listed.

2. Examples of Mixins

We will now present three examples to illustrate what mixins can be used for.

i. Adding a Washcoat

We now want to include the washcoat in the simulation and we will do so by writing a mixin. Open the carmen.yml file. Insert the general syntax of a mixin for the DETCHEM stagnation driver as shown above and add to the parameters field a washcoat key. For this example we chose the title of the mixin to be With washcoat.

#...
mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
          #...

The washcoat field contains all structural and chemical parameters corresponding to the washcoat used by Karakaya and coworkers 1. For the DETCHEM stagnation driver the washcoat field must contain a thickness key, a porosity key, a tortuosity key, a pore_diameter key, and a diffusion_limiting_species key. See the reference for the driver for more details.

#...
mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 100e-6
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 100e-9
            diffusion_limiting_species:
              - O2

The thickness field defines the thickness of the washcoat layer in meters (m). Karakaya et al. 1 achieved a layer of approximately 100 um, so we write 100e-6.

The porosity field defines the porosity of the washcoat, i.e. the ratio of the pore volume to the geometrical volume, and it can take values between 0 and 1. A value for the porosity was not provided by Karakaya et al. 1. From experience a porosity of 0.4 should be a fairly good approximation.

The tortuosity field defines the tortuosity of the washcoat, i.e. the ratio of contour length to the end-to-end length of the pores. A value for the tortuosity was also not provided by Karakaya et al. 1. For now, we will assume a value of 8.

The pore_diameter field defines the average diameter of the pores in the washcoat in meters (m). Karakaya and coworkers 1 determined the pore diameter to be approximately 100 nm, so we write 100e-9.

The diffusion_limiting_species field defines one or more species to be diffusion limiting, given as an array. A detailed description of the diffusion of species in porous media is computationally expensive. The DETCHEM software therefore simplifies the calculations by assuming one species to account for the diffusion limitations. For more information on the DETCHEM software see the DETCHEM user manual available for download from DETCHEM's homepage). Karakaya and coworkers 1 determined the O2 to be diffusion limiting.

Your carmen.yml file should look by now as follows:

cases:
  -
    title: My first simulation - CPOX 873 Rh
    data: ./CPOX_stag_873.csv
#   view:
#     label:
#       x: distance from disc (x/m)
#       y: mole fractions
    configuration:
      driver: detchem_stagnation
      output: ./mole_fractions
      parameters:
        inlet:
          temperature: 313.15
          gas_velocity: 0.5088
          mole_fractions:
            CH4: 0.053
            O2: 0.0257
            Ar: "*"
        surface:
          temperature: 873.15
        f_cat_geo: 1
        distance_inlet_disk: 0.039
        pressure: 49994
        chemical_model:
          $resource: model

mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2

resources:
  -
    name: model
    loader: chemical-model
    options:
      species_database:
        - ./moldata
        - ./thermo.ckt
      reactions:
        surface: ./surface.ckr

You may now proceed to load the Project Directory into CaRMeN and run the simulation as shown in the tutorial Quick Start. If you have followed all steps correctly you should see the following result in CaRMeN's Combiner View window.

First Simulation Washcoat

Running the My first simulation - CPOX 873 Rh simulation without selecting the With washcoat mixin will perform again a simulation where no washcoat is accounted for. You can toggle between the results of both simulations by either selecting or deselecting the mixin.

ii. Changing the variable f_cat_geo

We now want to change the value of the f_cat_geo variable in our simulation and we will do so by writing another mixin. Copy the syntax of the With washcoat mixin you just created and paste it so that you create a new array entry under mixins. For the new mixin we chose the name With washcoat, f_cat_geo = 30.

#...
mixins:
  -
    #...
  -
    title: With washcoat, f_cat_geo = 30
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
          f_cat_geo: 30

Now add a f_cat_geo key to the parameters field. Measurements of the specific active catalyst surface area performed by Karakaya et al. 1 provided a value for the ratio of the catalytic to the geometrical area of the plate of approximately 30, so we write f_cat_geo: 30.

Your carmen.yml file should look by now as follows:

cases:
  -
    title: My first simulation - CPOX 873 Rh
    data: ./CPOX_stag_873.csv
#   view:
#     label:
#       x: distance from disc (x/m)
#       y: mole fractions
    configuration:
      driver: detchem_stagnation
      output: ./mole_fractions
      parameters:
        inlet:
          temperature: 313.15
          gas_velocity: 0.5088
          mole_fractions:
            CH4: 0.053
            O2: 0.0257
            Ar: "*"
        surface:
          temperature: 873.15
        f_cat_geo: 1
        distance_inlet_disk: 0.039
        pressure: 49994
        chemical_model:
          $resource: model

mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
  -
    title: With washcoat, f_cat_geo = 30
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
          f_cat_geo: 30

resources:
  -
    name: model
    loader: chemical-model
    options:
      species_database:
        - ./moldata
        - ./thermo.ckt
      reactions:
        surface: ./surface.ckr

You may now proceed to load the Project Directory into CaRMeN and run the simulation as shown in the tutorial Quick Start. If you have followed all steps correctly you should see the following result in CaRMeN's Combiner View window.

First Simulation Washcoat f\_cat\_geo 30

You can directly compare the results of both simulations on one graph by selecting the mixins With washcoat and With washcoat, f_cat_geo = 30.

ADVANCED: You can reduce the size of your carmen.yml file by defining recurring parameters in an external file and importing the definition using a resource. In other words, you can use a resource as a definition, to which you can refer to. In this example you could copy the parameters for the washcoat into a file called washcoat.yml

thickness: 0.0001
porosity: 0.4
tortuosity: 8
pore_diameter: 1.0e-08
diffusion_limiting_species:
- O2

and replace the definition of the washcoat in the mixin with a resource referring to the washcoat.yml file by writing a point . followed by a slash / and the path to it. The two mixins and the new resource for the washcoat would look as follows

#...
mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            $resource: ./washcoat.yml

  -
    title: With washcoat, f_cat_geo = 30
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            $resource: ./washcoat.yml
          f_cat_geo: 30

iii. Varying the Reaction Mechanism

One common task in model development is to simulate the experimental data with different versions of a mechanism, for example after changing a kinetic or a thermodynamic constant. Modifying a mechanism file requires knowledge about the structure of such a file. We will introduce you to the format of the mechanism files used by CaRMeN in another section of this documentation. In this tutorial we will limit ourselves to introduce a second chemical model into our simulation, including a new reaction mechanism and a new set of chemical and thermodynamic data.

We now want to introduce a second chemical model into our simulation, without replacing the previous one, so that we are able to compare the results from both models on the same graph. We also want to account for the washcoat and for the new value of the f_cat_geo variable in our new simulation. For this we will create a new mixin and a new resource. The chemical model that we are going to introduce was developed by Schwiedernoch et al. 2 for the partial oxidation of methane to synthesis gas on a rhodium/alumina catalyst. The model includes a surface.ckr file with the reaction mechanism, a moldata file with the molar mass and kinetic theory parameters of each chemical species, and a thermo.ckt file with the the respective values for the enthalpy, entropy and heat capacity. The original files are available for download as a .zip-file from DETCHEM's homepage. The mentioned files are located in the downloaded folder under the path /PCCP 2018 10.1039_c7cp07777g/mechanisms/Schwiedernoch 2003 10.1016_S0009-2509(02)00589-4.

We will call the second model model 2. Since the name of the files surface.ckr, moldata, and themo.ckt from model 2 are the same as from the first model, we must create an additional folder in our Project Directory to store these files. We will call this folder model_2.

Create the new folder model_2 in your Project Directory and paste the surface.ckr, moldata, and themo.ckt files from model 2 in it. Now open your carmen.yml file. Copy the syntax of the With washcoat, f_cat_geo = 30 mixin you just created and paste it so that you create a new array entry under mixins:. For the new mixin we chose the name With washcoat, f_cat_geo = 30, model 2.

#...
mixins:
  -
    #...
  -
    #...
  -
    title: With washcoat, f_cat_geo = 30, model 2
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
          f_cat_geo: 30
          chemical_model:
            $resource: model 2
#...

Now add a chemical_model key to the parameters field. As we have done in the first tutorial, we will use the $resource macro to import a resource. In this example we chose the name model 2, so we write $resource: model 2. For more information on resources and their syntax see the chapter Resources under the manual section of this documentation. We must now create a resource definition for model 2. To do so, copy the model resource you created before and paste it so that you create a new array entry under resources, and rename it to model 2. Also, update the paths to the new files to ./model_2/moldata, ./model_2/thermo.ckt, and ./model_2/surface.ckr.

#...
resources:
  -
    #...
  -
    name: model 2
    loader: chemical-model
    options:
      species_database:
        - ./model_2/moldata
        - ./model_2/thermo.ckt
      reactions:
        surface: ./model_2/surface.ckr

Your carmen.yml file should look by now as follows:

cases:
  -
    title: My first simulation - CPOX 873 Rh
    data: ./CPOX_stag_873.csv
#   view:
#     label:
#       x: distance from disc (x/m)
#       y: mole fractions
    configuration:
      driver: detchem_stagnation
      output: ./mole_fractions
      parameters:
        inlet:
          temperature: 313.15
          gas_velocity: 0.5088
          mole_fractions:
            CH4: 0.053
            O2: 0.0257
            Ar: "*"
        surface:
          temperature: 873.15
        f_cat_geo: 1
        distance_inlet_disk: 0.039
        pressure: 49994
        chemical_model:
          $resource: model

mixins:
  -
    title: With washcoat
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2

  -
    title: With washcoat, f_cat_geo = 30
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
          f_cat_geo: 30

  -
    title: With washcoat, f_cat_geo = 30, model 2
    configuration:
      -
        driver: detchem_stagnation
        parameters:
          washcoat:
            thickness: 0.0001
            porosity: 0.4
            tortuosity: 8
            pore_diameter: 1.0e-08
            diffusion_limiting_species:
              - O2
          f_cat_geo: 30
          chemical_model:
            $resource: model 2

resources:
  -
    name: model
    loader: chemical-model
    options:
      species_database:
        - ./moldata
        - ./thermo.ckt
      reactions:
        surface: ./surface.ckr

  -
    name: model 2
    loader: chemical-model
    options:
      species_database:
        - ./model_2/moldata
        - ./model_2/thermo.ckt
      reactions:
        surface: ./model_2/surface.ckr

You may now proceed to load the Project Directory into CaRMeN and run the simulation as shown in the tutorial Quick Start. If you have followed all steps correctly you should see the following result in CaRMeN's Combiner View window.

First Simulation Washcoat f\_cat\_geo 30 model 2

You can directly compare the results of both simulations on one graph by selecting the mixins With washcoat, f_cat_geo = 30 and With washcoat, f_cat_geo = 30, model 2.

3. Concluding Remarks

You should now be able to quickly vary a number of aspects about your simulation by using mixins. This ability of combining different cases and mixins is at the core of CaRMeN's capabilities. We hope to have already convinced you by now of how CaRMeN can significantly accelerate and improve model development.

In the next tutorial Adding a Second Experiment we will show you what to pay attention to when working with more than one set of experimental data obtained from one reactor type. In other words, we will show you how to modify your mixins so that they are compatible with multiple cases using the same driver.

1. C. Karakaya, L. Maier and O. Deutschmann, Int. J. Chem. Kinet., 2016, 48, 144–160. DOI: 10.1002/kin.20980
2. R. Schwiedernoch, S. Tischer, C. Correa and O. Deutschmann, Chem. Eng. Sci., 2003, 58, 633–642. DOI: 10.1016/S0009-2509(02)00589-4

results matching ""

    No results matching ""