Skip to content

Commit 7f47a40

Browse files
authored
Merge pull request #249 from ReactionMechanismGenerator/debugging_docs
Improve Documentation
2 parents 0cd6ac6 + 3bac93d commit 7f47a40

File tree

5 files changed

+101
-2035
lines changed

5 files changed

+101
-2035
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ makedocs(
99
modules = [ReactionMechanismSimulator],
1010
pages = [
1111
"Home" => "index.md",
12+
"Installation.md",
1213
"Input.md",
1314
"Simulating.md",
1415
"Analysis.md",

docs/src/Analysis.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ Transitory sensitivity values can be computed using several different algorithms
8080
Please let us know on our Github issues page if we're missing any important
8181
property calculators.
8282

83+
## Crash Analysis
84+
85+
When thermodynamics and kinetics are poorly assigned mechanisms can become too stiff to simulate causing the solver to crash. In these
86+
cases it is very important to be able to efficiently identify potential offending thermochemistry and/or kinetics. Our crash analysis tool analyzes
87+
the reaction and species fluxes to identify NaN quantities and quantities that are unusually large. A crash report can be generated from the associated `Simulation` or `SystemSimulation` object with `printcrashanalysis(analyzecrash(sim;tol=tol))`. In general, the correct `tol` depends on how much faster the offending chemistry is than the real chemistry. Rather than use the default tolerance one should adjust `tol` to achieve a reasonable amount of possible offending thermochemistry and kinetics, adjusting up to reduce the amount identified while decreasing `tol` will cause
88+
the amount identified to increase.
89+
8390
## Plotting
8491

8592
### Plotting Mole Fractions

docs/src/Installation.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Install Julia
2+
RMS is written in Juila language. So before stepping any further, Julia needs to be installed. The download links can be found at [download Julia](https://julialang.org/downloads/). More instructions can be found from the [instruction page](https://julialang.org/downloads/platform/).
3+
4+
## Standard Installation
5+
With julia RMS can be installed with:
6+
7+
```
8+
using Pkg
9+
Pkg.add("ReactionMechanismSimulator")
10+
Pkg.build("ReactionMechanismSimulator")
11+
```
12+
13+
## Developer Installation
14+
Clone RMS to your machine in an appropriate location we will refer to as `RMS_PATH``:
15+
```
16+
git clone https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git
17+
```
18+
then you can install with
19+
```
20+
import Pkg
21+
Pkg.develop(Pkg.PackageSpec(path=RMS_PATH))
22+
Pkg.build("ReactionMechanismSimulator")
23+
```
24+
25+
## Testing RMS
26+
Unit and functional tests for RMS can be run with:
27+
```
28+
import Pkg
29+
Pkg.test("ReactionMechanismSimulator")
30+
```
31+
32+
## pyrms
33+
We also provide a python wrapper for RMS, [pyrms](https://github.com/ReactionMechanismGenerator/pyrms). Installation instructions are available on its github page.
34+
35+
## Julia-Python Linking
36+
The above instructions will automatically handle Julia-Python linking. However, in some cases it can be useful to use python from a specific conda environment. For these cases we provide instructions to relink Julia to a different Anaconda Python environment where `PATH_TO_YOUR_ENV` is the path to the Anaconda environment and `PATH_TO_PYTHON` is the path to the associated Python executable:
37+
38+
```
39+
import Pkg
40+
Pkg.add("PyCall")
41+
ENV["CONDA_JL_HOME"] = PATH_TO_YOUR_ENV
42+
Pkg.build("Conda")
43+
ENV["PYTHON"] = PATH_TO_PYTHON
44+
Pkg.build("PyCall")
45+
```

docs/src/Simulating.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,36 @@ sol = solve(react.ode,CVODE_BDF(),abstol=1e-20,reltol=1e-12;forwardsensitivities
109109

110110
In general CVODE_BDF tends to work well on these problems.
111111

112+
## Saving a Solution Object
113+
114+
The user may wish to save useful objects from above:
115+
116+
```
117+
bsol = Simulation(sol, domain)
118+
```
119+
120+
Saving the data to a Julia data structure ([JLD2](https://github.com/JuliaIO/JLD2.jl)) seems to work well. Once the `JLD2` package has been downloaded, data can be saved using the following commands:
121+
122+
```
123+
using JLD2, FileIO
124+
save("<file_name>.jld2", "bsol_saved", bsol)
125+
```
126+
127+
The data can be read back into Julia as a dictionary, and the desired data can be accessed using its corresponding key:
128+
129+
```
130+
d = load("<file_name>.jld2")
131+
bsol_loaded = d["bsol_saved"]
132+
```
133+
134+
Since the data is saved in HDF5 format, it can also be read into Python as follows:
135+
136+
```
137+
import h5py
138+
f = h5py.File("<file_name", "r")
139+
```
140+
141+
112142
## Threaded Sensitivity Analysis
113143
Instead of solving all of the sensitivity equations at once as is done in raw Forward sensitivity analysis we can
114144
first solve the equations without sensitivity analysis alone. With an interpolatable solution to the original equations the sensitivities associated with each parameter are decoupled from the sensitivities of every other parameter and can be solved independently. Solving these groups of equations sequentially is often significantly faster than solving the equations together. However, by parallelizing the solution of these equations using multithreading it is possible to achieve dramatic speed ups. This approach is not always competitive with adjoint sensitivities as the adjoint approach requires solution of a much smaller system of equations, however, in practice this approach is often more robust especially for large systems.

0 commit comments

Comments
 (0)