# Use of Basic Elements II – Ordinary Differential Equation System

This second example shall illustrate the formulation of an ordinary differential equation system (ODE system) in MOSAICmodeling. This example is the “Oregonator”, a theoretical model for a type of autocatalytic reactions. In this example, we will use the publication by D’Ambrosio et al. (2018), DOI: 10.1007/s10910-018-0922-5, as basis.

### Model description

The model consists of three differential equations:

Therein, , , and are the concentrations of relevant intermediates of this reaction network, i.e., , , and Ce(IV). is the concentration of , a constant. All and are parameters of the kinetics. For a more thorough discussion of the underlying physics, please consult the literature on the oregonator. We want to focus on the model implementation here.

### Model workflow

#### Notation

We beginn by setting up the notation. Therefore, perform the following steps:

1. Go to the Notation tab in the “Model” section
3. Add the base names below by clicking on “+ Name” at the bottom, entering these names, adding a description of the variable and confirming it
4. Go to the Indicies tab and add the index below
5. Once you have added all variables and symbols, click on “Save” at the top of the editor and save your notation at a suitable location in your folder structure
##### Base names
• , concentration of in mol/L
• , Stoichiometric factor
• , kinetic factor in various units
• , time in s
• , concentration of in mol/L
• , concentration of in mol/L
• , concentration of Ce(IV) in mol/L
##### Indices
• , Index of kinetic factors 1..NK

The notation of this example has ID 182866.

#### Equations

Go to the Equation tab. Proceed as follows:

1. Load the notation you just created
2. Add an informative description of the current equation
3. Type the first model equation in LaTeX style into the window MosaicTex. For the differential operator, you must use \diff{Var}{IndependentVariable}
4. Save the equation at a suitable location in your folder structure
5. Click on “New” at the top of the editor and repeat the steps 1 and 2
6. Enter the second model equation
7. Save this second equation as well

The three equations are available in MOSAICmodeling with the IDs 182867, 182868, and 182869.

#### Equation system

Now, we will combine our equations to an equation system. To this end, go to the Equation System tab and carry on as described below:

3. Go to the tab Connected Elements and click on “+ EQU/EQS” at the bottom of the editor
4. In the opening popup window, select your three equations and confirm (you can also add them one-by-one). They will then appear in the overview of connected elements

The equation system has ID 182870 within MOSAICmodeling.

### Simulation workflow

Start by going to the “Simulation” section of MOSAICmodeling.

#### Equation system

Go to the tab Equation System and select your newly saved equation system from above.

#### Indexing

Proceed to the tab Indexing. Specify the maximum value of the index for the kinetic factors, i.e., 5. Click on Confirm Index Data.

#### Specification

Go to the tab Specifications and then select the tab Variables. Proceed as follows:

2. In the specification window, you can see all possible variable classifications. Select ALL VARIABLES at the top. You should now see the four variables that are part of your model
3. Change the entry in the column Type for , and to Design Value
4. Change the type classification of the variables , , and to state variable.   The variable should already be classified as differential value. Your degree of freedom should now be zero
5. Assign the values given in Table 1 to the four variables
6. On the right side, set 2000.0 as end point for the differential variable
7. Save your variable specification by clicking on the “Save” button above the calculation of the degrees of freedom
8. Save your simulation by clicking on “Save” at the top of the editor

The simulation is available with ID 182871. The associated variable specification has ID 182872. Note that the values specificed for the state variables are used as initial conditions.

#### Evaluation

Finally, we want to determine the solution of our model:

1. Go to the Evaluation tab, then go to the Code Generation tab
2. Select your preferred language specification, e.g., Matlab ODE std
3. Click on Generate Code
4. Go to the tab View Code and copy the code into your respective modeling environment, e.g., Matlab
5. Execute the code
6. You will notice that (i) the solution requires a significant amount of time, and (ii) the solution does not fluctuate at all. The long computational time is caused by ODE45, which is not suitable for stiff systems such as the ODE system in this example. Therefore, replace the following line with the one given below that
% [X,Y] = ode45(@(X,Y)calculateDifferentials(X,Y,PARAMS),X_INTERVAL,Y_INIT');
[X,Y] = ode23s(@(X,Y)calculateDifferentials(X,Y,PARAMS),X_INTERVAL,Y_INIT');

You will now receive a solution must faster, but without any fluctuation. The problem here is the accuracy of the applied solver. Now, change the respective options as shown below:

% [X,Y] = ode45(@(X,Y)calculateDifferentials(X,Y,PARAMS),X_INTERVAL,Y_INIT');
% [X,Y] = ode23s(@(X,Y)calculateDifferentials(X,Y,PARAMS),X_INTERVAL,Y_INIT');
[X,Y] = ode23s(@(X,Y)calculateDifferentials(X,Y,PARAMS),X_INTERVAL,Y_INIT',odeset('RelTol',1e-7,'AbsTol',1e-7));

Execute the code again. You should now observe a fluctuation of the three concentrations. This illustrates that – although MOSAICmodeling (or any other modeling tool) can help you with setting up the model equations – it does not absolve you from knowing about numerical issues and how to address them in the tool of your preference.