Skip to content

Commit fe3c017

Browse files
committed
readme updated
1 parent 736af98 commit fe3c017

File tree

1 file changed

+77
-43
lines changed

1 file changed

+77
-43
lines changed

README.md

Lines changed: 77 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ The project is structured as follows:
2121
- `modules/`: Contains the different modules of the project.
2222
- `cli/`: CLI that enables the use of the cuqdyn-c library.
2323
- `cuqdyn-c/`: The main library that implements the functionality of the paper project.
24-
- `dotmat-introspector/`: Console app to introspect the contents of a .mat file.
2524
- `sacess/`: [External proyect](https://bitbucket.org/DavidPenas/sacess-library) adapted to enable the
2625
use of eSS in C.
2726
- `mexpreval/`: Rust crate. Parses the model from the XML file to evaluate it.
@@ -112,13 +111,13 @@ After this, the file `output/cuqdyn-results.txt` contains the results of the
112111
algorithm but reading it as a plain text is not very useful.
113112
To fix this, you can run: (Needs python3 and matplotlib installed)
114113

115-
Note: Be carefull when executing with `mpirun`, the number of precesses must be divisor
116-
of m - 1, where m is the number of rows in the input data matrix.
117-
118114
```bash
119115
python3 plot.py output/cuqdyn-results.txt
120116
```
121117

118+
Note: Be carefull when executing with `mpirun`, the number of precesses must be divisor
119+
of m - 1, where m is the number of rows in the input data matrix.
120+
122121
This will save a graphic representation for each y(t) in different png files
123122
inside the directory where the results are (output folder in this example).
124123

@@ -128,7 +127,7 @@ To get information about all the options the cli supports, you can run the follo
128127
./build-{variant}/modules/cli/cli help
129128
```
130129

131-
Also, you can run
130+
You can also run
132131

133132
```bash
134133
./build-{variant}/modules/cli/cli version
@@ -144,49 +143,83 @@ There are three types of input files that must be provided:
144143
This file contains the configuration of the eSS solver used in the sacess library.
145144
The specifications of this xml and how to build it are in
146145
this [link](https://bitbucket.org/DavidPenas/sacess-library/src/main/doc/manual/DOCUMENTATION_SACESS_SOFTWARE.pdf).
146+
147147
- **cuqdyn config xml:**
148148
This file contains the configuration of the cuqdyn solver used in the cuqdyn-c library.
149-
This file defines the rtol and atol used by the cvodes library inside the tolerances block
150-
and the ode model inside the ode_expr block. In the following example we define the Lotka Volterra model.
151-
There is an option to accelerate the process of evaluating the ODE by defining it inside the
149+
150+
- The tolerances block defines the rtol and atol used by the cvodes library.
151+
- The ode model is defined inside the ode_expr block.
152+
- y0 is the initial conditions of the ODE (If no present, the first row of the data matrix will be used) (Optional).
153+
- The states_transformer block defines the transformations applied to the different states in case of the observed data
154+
being a combination of the different states.
155+
156+
There is an option to accelerate the process of evaluating the ODE by defining it and the states transformer inside the
152157
mevalexpr module. We will talk about this later.
153-
```xml
154-
<?xml version="1.0" encoding="UTF-8" ?>
155-
156-
<cuqdyn-config>
157-
<tolerances>
158-
<rtol>1e-8</rtol>
159-
<atol>1e-9, 1e-10</atol>
160-
</tolerances>
161-
<ode_expr y_count="2" p_count="4">
162-
y1 * (p1 - p2 * y2)
163-
-y2 * (p3 - p4 * y1)
164-
</ode_expr>
165-
</cuqdyn-config>
166-
```
158+
159+
```xml
160+
<?xml version="1.0" encoding="UTF-8" ?>
161+
162+
<cuqdyn-config>
163+
<tolerances>
164+
<rtol>1e-8</rtol>
165+
<atol>1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8, 1e-8</atol>
166+
</tolerances>
167+
<ode_expr y_count="15" p_count="29">
168+
p20 - p21 * y1 - p17 * y1
169+
p17 * y1 - p19 * y2 - p18 * y2 * y8 - p21 * y2 - p2 * y2 * y10 + p3 * y4 - p4 * y2 * y13 + p5 * y5
170+
p19 * y2 + p18 * y2 * y8 - p21 * y3
171+
2 * y2 * y10 - p3 * y4
172+
4 * y2 * y13 - p5 * y5
173+
p11 * y13 - p1 * y6 * y10 + p5 * y5 - p23 * y6
174+
p23 * p22 * y6 - p1 * y11 * y7
175+
p15 * y9 - p16 * y8
176+
p13 + p12 * y7 - p14 * y9
177+
-p2 * y2 * y10 - p1 * y10 * y6 + p9 * y12 - p10 * y10 - p25 * y10 + p26 * y11
178+
-p1 * y11 * y7 + p25 * p22 * y10 - p26 * p22 * y11
179+
p7 + p6 * y7 - p8 * y12
180+
p1 * y10 * y6 - p11 * y13 - p4 * y2 * y13 + p24 * y14
181+
p1 * y11 * y7 - p24 * p22 * y14
182+
p28 + p27 * y7 - p29 * y15
183+
</ode_expr>
184+
<y0> <!-- Optional -->
185+
0.200000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000316, 0.002296, 0.004783, 0.000003, 0.002507, 0.003436, 0.000003, 0.060000, 0.000079, 0.000003
186+
</y0>
187+
<states_transformer count="6"> <!-- Optional -->
188+
y7
189+
y10 + y13
190+
y9
191+
y1 + y2 + y3
192+
y2
193+
y12
194+
</states_transformer>
195+
</cuqdyn-config>
196+
```
197+
167198
- **Data file:**
168199
The data file containing a mtrix of observed data and the initial value
169200
needed to solve the ODE. The data file should be a txt file written with the following format:
170-
```
171-
# The first row is gonna be used as the initial condition
172-
31 3 # Matrix dimensions so the parsing is easier
173-
0 10 5 # Column 1: time, Column 2: y1(t), Column 3: y2(t)
174-
.
175-
.
176-
.
177-
30 1e1 5e1
178-
```
201+
202+
```
203+
# The first row is gonna be used as the initial condition if y0 is not present in the config file
204+
31 3 # Matrix dimensions so the parsing is easier
205+
0 10 5 # Column 1: time, Column 2: y1(t), Column 3: y2(t)
206+
.
207+
.
208+
.
209+
30 1e1 5e1
210+
```
179211

180212
## Defining a new model
181213

182214
Using strings and evaluate them is slow compared to compiled instructions, so, to make this
183-
possible, we designed a way to define the models in Rust and compile them to machine code.
215+
possible, we designed a way to define the models in Rust and compile them to machine code.
184216

185217
Let's dig into it with an example of the Lotka Volterra model:
186218

187219
First of all, we need to write some Rust code. We will be using the following file
188220
`modules/mexpreval/src/models.rs`. Inside, we create a new unit struct and implement
189221
the Model trait like this:
222+
190223
```Rust
191224
#[derive(Default)]
192225
struct LotkaVolterra;
@@ -200,6 +233,7 @@ impl Model for LotkaVolterra {
200233
```
201234

202235
Once the model is defined, we should give it an identifier:
236+
203237
```Rust
204238
pub fn eval_model_fun(model: &str, ode_expr: &OdeExpr) -> Box<dyn Model> {
205239
match model {
@@ -213,18 +247,18 @@ pub fn eval_model_fun(model: &str, ode_expr: &OdeExpr) -> Box<dyn Model> {
213247
After you establish an identifier in the match at the bottom of the file, the model can be
214248
used indicating the identifier in the XML config file like this:
215249

216-
```xml
250+
```xml
217251
<?xml version="1.0" encoding="UTF-8" ?>
218252

219-
<cuqdyn-config>
220-
<tolerances>
221-
<rtol>1e-8</rtol>
222-
<atol>1e-9, 1e-10</atol>
223-
</tolerances>
224-
<ode_expr y_count="2" p_count="4">
225-
lotka-volterra
226-
</ode_expr>
227-
</cuqdyn-config>
228-
```
253+
<cuqdyn-config>
254+
<tolerances>
255+
<rtol>1e-8</rtol>
256+
<atol>1e-9, 1e-10</atol>
257+
</tolerances>
258+
<ode_expr y_count="2" p_count="4">
259+
lotka-volterra
260+
</ode_expr>
261+
</cuqdyn-config>
262+
```
229263

230264
Note that y_count and p_count are still present.

0 commit comments

Comments
 (0)