Skip to content

Commit 3d45ccd

Browse files
committed
add Kevin's documentation on saving solution objects
1 parent 7230de2 commit 3d45ccd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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)