-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the ODE integrators docs on tolerances (#1703)
this regenerates the plot comparing tolerances and includes it now as a script under burn_cell
- Loading branch information
Showing
11 changed files
with
4,155 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Comparing tolerances | ||
|
||
This is used the make the plot in the docs that compares tolerances. | ||
|
||
Compile `burn_cell` with `aprox13` and run the tests using the script | ||
`run_tol_compare.sh`. This will run 4 different instances with different | ||
tolerances. | ||
|
||
A plot comparing the relative error of the simulations (using the run with | ||
the tightest tolerances as the reference) can be made with `plot-tols.py`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
# read in the output from different tolerances | ||
tola = np.loadtxt("state_over_time_tol_a.txt") | ||
tolb = np.loadtxt("state_over_time_tol_b.txt") | ||
tolc = np.loadtxt("state_over_time_tol_c.txt") | ||
ref = np.loadtxt("state_over_time_tol_d.txt") | ||
|
||
labela = r"tol = $10^{-3}$" | ||
labelb = r"tol = $10^{-5}$" | ||
labelc = r"tol = $10^{-8}$" | ||
|
||
# compute the relative error with respect to the | ||
# tighest tolerance | ||
dta = np.abs(tola - ref) / np.abs(ref) | ||
dtb = np.abs(tolb - ref) / np.abs(ref) | ||
dtc = np.abs(tolc - ref) / np.abs(ref) | ||
|
||
# plot the output | ||
fig, ax = plt.subplots() | ||
|
||
itemp = 1 | ||
ihe4 = 2 | ||
ic12 = 3 | ||
isi28 = 7 | ||
ini56 = 14 | ||
|
||
fig, axes = plt.subplots(2, 2) | ||
|
||
for n, (ax, idx, name) in enumerate(zip(axes.flat, [ihe4, ic12, isi28, ini56], ["He4", "C12", "Si28", "Ni56"])): | ||
|
||
ax.plot(tola[:, 0], dta[:, idx], label=labela) | ||
ax.plot(tolb[:, 0], dtb[:, idx], label=labelb) | ||
ax.plot(tolc[:, 0], dtc[:, idx], label=labelc) | ||
|
||
ax.set_xlabel("time (s)") | ||
ax.set_ylabel(f"relative error {name}") | ||
|
||
ax.set_xscale("log") | ||
ax.set_yscale("log") | ||
|
||
if n == 0: | ||
ax.legend(fontsize="small") | ||
|
||
fig.tight_layout() | ||
fig.set_size_inches(8, 7) | ||
|
||
fig.savefig("tolerance-compare.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
RUNPARAMS=" | ||
unit_test.tmax=1.e-4 | ||
unit_test.nsteps=1000 | ||
unit_test.density=1.e8 | ||
unit_test.temperature=3.e9" | ||
|
||
./main3d.gnu.ex inputs_aprox13 ${RUNPARAMS} integrator.rtol_spec=1.0e-3 integrator.rtol_enuc=1.0e-3 integrator.atol_spec=1.0e-3 integrator.atol_enuc=1.0e-3 | ||
mv state_over_time.txt state_over_time_tol_a.txt | ||
|
||
./main3d.gnu.ex inputs_aprox13 ${RUNPARAMS} integrator.rtol_spec=1.0e-5 integrator.rtol_enuc=1.0e-5 integrator.atol_spec=1.0e-5 integrator.atol_enuc=1.0e-5 | ||
mv state_over_time.txt state_over_time_tol_b.txt | ||
|
||
./main3d.gnu.ex inputs_aprox13 ${RUNPARAMS} integrator.rtol_spec=1.0e-8 integrator.rtol_enuc=1.0e-8 integrator.atol_spec=1.0e-8 integrator.atol_enuc=1.0e-8 | ||
mv state_over_time.txt state_over_time_tol_c.txt | ||
|
||
./main3d.gnu.ex inputs_aprox13 ${RUNPARAMS} integrator.rtol_spec=1.0e-12 integrator.rtol_enuc=1.0e-12 integrator.atol_spec=1.0e-12 integrator.atol_enuc=1.0e-12 | ||
mv state_over_time.txt state_over_time_tol_d.txt | ||
|
Oops, something went wrong.