Skip to content

Commit f9d54de

Browse files
authored
Centralize some runtime parameters and their docs (#1749)
in particular, this moves small_temp and small_dens to the top-level unit_test/_parameters, since every test needs them. We override it in a few tests, since they need much different defaults. This also moves the documentation about initializing composition up to a new centralized page, so we don't need to repeat it for every test.
1 parent 243a5f2 commit f9d54de

File tree

32 files changed

+88
-114
lines changed

32 files changed

+88
-114
lines changed

Docs/source/burn_cell.rst

+4-26
Original file line numberDiff line numberDiff line change
@@ -52,39 +52,17 @@ The parameters that affect the thermodynamics are:
5252

5353
* ``unit_test.temperature`` : the initial temperature
5454

55-
* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state
55+
The composition can be set either by specifying individual mass fractions
56+
or setting ``unit_test.uniform_xn`` as described in :ref:`sec:defining_unit_test_composition`.
5657

57-
* ``unit_test.small_dens`` : the low density cutoff used in the equation of state
58-
59-
The composition can be set either by setting each mass fraction explicitly via the
60-
parameters, ``unit_test.X1``, ``unit_test.X2``, ...,
61-
e.g.:
62-
63-
::
64-
65-
unit_test.X1 = 0.5
66-
unit_test.X2 = 0.2
67-
unit_test.X3 = 0.2
68-
unit_test.X4 = 0.1
69-
70-
where parameters up to ``X35`` are available. If the values don't sum to ``1``
71-
initially, then the test will do a normalization. This normalization can be
72-
disabled by setting:
58+
If the values don't sum to ``1`` initially, then the test will do a
59+
normalization. This normalization can be disabled by setting:
7360

7461
::
7562

7663
unit_test.skip_initial_normalization = 1
7764

7865

79-
Alternately, the composition can be set automatically by initializing all
80-
of the mass fractions equally (to $1/N$, where $N$ is the number of species),
81-
by setting:
82-
83-
::
84-
85-
unit_test.uniform_xn = 1
86-
87-
8866
Controlling time
8967
----------------
9068

Docs/source/comprehensive_tests.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _sec:comprehensive_tests:
2+
13
************************
24
Comprehensive Unit Tests
35
************************

Docs/source/eos_cell.rst

+2-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,8 @@ The parameters that affect the thermodynamics are:
2828

2929
* ``unit_test.temperature`` : the initial temperature
3030

31-
* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state
32-
33-
* ``unit_test.small_dens`` : the low density cutoff used in the equation of state
34-
35-
The composition can be set in the same way as in ``burn_cell``, either
36-
by setting each mass fraction explicitly via the parameters,
37-
``unit_test.X1``, ``unit_test.X2``, ..., or forcing them to be all
38-
equal via ``unit_test.uniform_xn=1``.
31+
The composition can be set either by specifying individual mass fractions
32+
or setting ``unit_test.uniform_xn`` as described in :ref:`sec:defining_unit_test_composition`.
3933

4034

4135
Building and Running the Code

Docs/source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ system.
9292
:hidden:
9393

9494
unit_tests
95+
unit_test_runtime_parameters
9596
comprehensive_tests
9697
one_zone_tests
9798

Docs/source/jac_cell.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ The parameters that affect the thermodynamics are:
3838

3939
* ``unit_test.temperature`` : the initial temperature
4040

41-
* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state
41+
The composition can be set either by specifying individual mass fractions
42+
or setting ``unit_test.uniform_xn`` as described in :ref:`sec:defining_unit_test_composition`.
4243

43-
* ``unit_test.small_dens`` : the low density cutoff used in the equation of state
44+
If the values don't sum to ``1`` initially, then the test will do a
45+
normalization. This normalization can be disabled by setting:
4446

45-
While the mass fractions can be set individually (using
46-
``unit_test.X1``, ``unit_test.X2``, ...), it is recommended to use
47-
``unit_test.uniform_xn=1`` to initialize all the mass fractions to be
48-
equal.
47+
::
48+
49+
unit_test.skip_initial_normalization = 1
4950

5051

5152
Building and Running the Code

Docs/source/one_zone_tests.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _sec:one_zone_tests:
2+
13
**************
24
One Zone Tests
35
**************
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
***********************************
2+
Unit Test Common Runtime Parameters
3+
***********************************
4+
5+
There are a number of runtime parameters that are common to all (or most) of the unit tests.
6+
These are defined in the top-level ``unit_test/_parameters`` file.
7+
8+
Thermodynamics
9+
==============
10+
11+
The equation of state enforces minimum density and temperatures, which must be set
12+
upon initialization. These are controlled by the following runtime parameters:
13+
14+
* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state
15+
16+
* ``unit_test.small_dens`` : the low density cutoff used in the equation of state
17+
18+
19+
.. _sec:defining_unit_test_composition:
20+
21+
Defining composition
22+
====================
23+
24+
Most of the unit tests require a composition to be defined (for the
25+
initial mass-fractions, $X_k$). There are a few ways this can be done
26+
(depending on the test).
27+
28+
* One-zone (``*_cell``) tests (see :ref:`sec:one_zone_tests`) usually do one of:
29+
30+
* *Explicitly setting the individual mass fractions.* This is
31+
controlled by the parameters ``unit_test.X1``, ``unit_test.X2``, ..., ``unit_test.X35``,
32+
e.g.:
33+
34+
::
35+
36+
unit_test.X1 = 0.5
37+
unit_test.X2 = 0.2
38+
unit_test.X3 = 0.2
39+
unit_test.X4 = 0.1
40+
41+
While many of the tests will renormalize the abundances, the user
42+
should take care to ensure that the mass fractions sum to unity.
43+
44+
* *Setting the composition to be uniform.* This is controlled by
45+
``unit_test.uniform_xn``. If this is set to ``1``, then each mass fraction
46+
is initialized to ``1 / NumSpec``.
47+
48+
* Comprehensive tests (see :ref:`sec:comprehensive_tests`) need many different compositions, since they are creating a cube
49+
of varying thermodynamic properties, and thus require a prescription
50+
to create the composition. This is done by setting ``unit_test.primary_species_1``,
51+
``unit_test.primary_species_2``, and ``unit_test.primary_species_3`` to one of the
52+
*names* of the species in the network.
53+
54+
The function ``setup_composition()`` is then used to set limits on
55+
the species abundances (it takes a parameter which is the index into
56+
the cube of data that is being initialized) which is then used by
57+
``get_xn()`` to create the individual mass fractions. Both of these
58+
routines are contained in ``react_util.H``.

unit_test/_parameters

+7
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,12 @@ X33 real 0.0e0
4040
X34 real 0.0e0
4141
X35 real 0.0e0
4242

43+
# do we set all of the mass fractions equal (to 1/NumSpec)?
4344
uniform_xn bool 0
4445

46+
# lowest temperature allowed in the EOS
47+
small_temp real 1.e5
48+
49+
# lowest density allowed in the EOS
50+
small_dens real 1.e5
51+

unit_test/burn_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
# the final time to integrate to
74
tmax real 1.e-2
85

unit_test/burn_cell_metal_chem/_parameters

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
run_prefix string "burn_cell_metal_chem"
44

55
# floor values of temperature and density
6-
small_temp real 1.e1
7-
small_dens real 1.e-30
6+
small_temp real 1.e1 100
7+
small_dens real 1.e-30 100
88

99
# the final time to integrate to
1010
tmax real 1.e20

unit_test/burn_cell_primordial_chem/_parameters

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
run_prefix string "burn_cell_primordial_chem"
44

55
# floor values of temperature and density
6-
small_temp real 1.e1
7-
small_dens real 1.e-30
6+
small_temp real 1.e1 100
7+
small_dens real 1.e-30 100
88

99
# the final time to integrate to
1010
tmax real 1.e20

unit_test/burn_cell_sdc/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
# the final time to integrate to
74
tmax real 1.e-2
85

unit_test/eos_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
density real 1.e7
74
temperature real 3.e9

unit_test/jac_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
density real 1.e7
74

85
temperature real 3.e9

unit_test/nse_net_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
run_prefix string ""
44

5-
small_temp real 1.e5
6-
small_dens real 1.e5
7-
85
density real 1.e7
96

107
temperature real 3.e9

unit_test/nse_net_cell/make_table/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_dens real 1.e5
4-
small_temp real 1.e5
5-
63
rho_min real 1.e6
74
rho_max real 1.e10
85

unit_test/nse_table_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
density real 1.23e9
74
temperature real 5.18e9
85
ye real 0.472

unit_test/part_func_cell/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
temperature real 5.e9
74

unit_test/test_aprox_rates/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ temp_min real 1.e6
66
temp_max real 1.e12
77

88
metalicity_max real 0.1e0
9-
10-
small_temp real 1.e4
11-
small_dens real 1.e-4

unit_test/test_conductivity/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ temp_min real 1.e6
66
temp_max real 1.e12
77

88
metalicity_max real 0.1e0
9-
10-
small_temp real 1.e4
11-
small_dens real 1.e-4

unit_test/test_eos/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ temp_min real 1.e6
66
temp_max real 1.e12
77

88
metalicity_max real 0.1e0
9-
10-
small_temp real 1.e4
11-
small_dens real 1.e-4

unit_test/test_jac/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ uniform_xn int 0
99

1010
tmax real 0.1e0
1111

12-
small_temp real 1.e5
13-
small_dens real 1.e5
14-
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
@namespace: unit_test
2-
3-
small_temp real 1.e5
4-
small_dens real 1.e5

unit_test/test_neutrino_cooling/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ temp_min real 1.e6
66
temp_max real 1.e12
77

88
metalicity_max real 0.1e0
9-
10-
small_temp real 1.e4
11-
small_dens real 1.e-4

unit_test/test_nse_interp/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
density real 1.23e9
74
temperature real 5.18e9
85
ye real 0.472

unit_test/test_parameters/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@ dens_max real 1.e9
55
temp_min real 1.e6
66
temp_max real 1.e12
77

8-
small_temp real 1.e4
9-
small_dens real 1.e-4
10-
118
test_string string "test"

unit_test/test_react/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ temp_max real 1.e15
77

88
tmax real 0.1e0
99

10-
small_temp real 1.e5
11-
small_dens real 1.e5
12-

unit_test/test_rhs/_parameters

-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ dens_min real 1.e6
44
dens_max real 1.e9
55
temp_min real 1.e6
66
temp_max real 1.e15
7-
8-
uniform_xn int 0
9-
10-
small_temp real 1.e5
11-
small_dens real 1.e5

unit_test/test_screening_templated/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,4 @@ temp_max real 1.e12
77

88
metalicity_max real 0.1e0
99

10-
small_temp real 1.e4
11-
small_dens real 1.e-4
12-
1310
loops int 1

unit_test/test_sdc/_parameters

-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,4 @@ dens_max real 1.e9
55
temp_min real 1.e6
66
temp_max real 1.e15
77

8-
# uniform composition
9-
uniform_xn int 0
10-
118
tmax real 0.1e0
12-
13-
small_temp real 1.e5
14-
small_dens real 1.e3
15-

unit_test/test_sdc_vode_rhs/_parameters

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
@namespace: unit_test
22

3-
small_temp real 1.e5
4-
small_dens real 1.e5
5-
63
density real 1.e7
74

85
temperature real 3.e9

unit_test/test_sdc_vode_rhs/vode_rhs_test.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void do_vode_rhs()
2323

2424
for (int n = 1; n <= NumSpec; ++n) {
2525

26-
massfractions[n-1] = get_xn(n);
26+
massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn);
2727

2828
if (massfractions[n-1] < 0 || massfractions[n-1] > 1) {
2929
amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!");

0 commit comments

Comments
 (0)