Skip to content

Commit adb2600

Browse files
authored
work on addressing some issues with the Jacobian scaling (#1479)
this applies if we run with scale_system=1 also as part of this change, allow the Circle theorem to use the numerical Jacobian.
1 parent 48bf41c commit adb2600

File tree

5 files changed

+47
-26
lines changed

5 files changed

+47
-26
lines changed

integration/integrator_rhs_strang.H

+7
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,17 @@ void jac ([[maybe_unused]] const amrex::Real time, BurnT& state, T& int_state, M
154154
}
155155

156156
// scale the energy derivatives
157+
157158
if (scale_system) {
159+
// first the row de/dX
158160
for (int j = 1; j <= INT_NEQS; ++j) {
159161
pd(net_ienuc,j) /= state.e_scale;
160162
}
163+
164+
// now the column dX/de
165+
for (int i = 1; i <= INT_NEQS; ++i) {
166+
pd(i,net_ienuc) *= state.e_scale;
167+
}
161168
}
162169

163170
// apply fudge factor:

integration/utils/circle_theorem.H

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <integrator_rhs_sdc.H>
1212
#endif
1313
#include <limits>
14+
#include <numerical_jacobian.H>
1415

1516
template<typename BurnT, typename T>
1617
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
@@ -19,7 +20,14 @@ void circle_theorem_sprad(const amrex::Real time, BurnT& state, T& int_state, am
1920

2021
ArrayUtil::MathArray2D<1, INT_NEQS, 1, INT_NEQS> jac_array;
2122

22-
jac(time, state, int_state, jac_array);
23+
if (integrator_rp::jacobian == 1) {
24+
jac(time, state, int_state, jac_array);
25+
} else {
26+
integrator_to_burn(int_state, state);
27+
jac_info_t jac_info;
28+
jac_info.h = 0.0_rt;
29+
numerical_jac(state, jac_info, jac_array);
30+
}
2331

2432
// the Gershgorin circle theorem says that the spectral radius is <
2533
// max_i ( -a_{ii} + sum_{j,j!=i} |a_{ij}|)

integration/utils/jacobian_utilities.H

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ template <typename BurnT>
1313
AMREX_GPU_HOST_DEVICE AMREX_INLINE
1414
Real temperature_to_energy_jacobian (const BurnT& state, const Real& jac_T)
1515
{
16-
Real jac_e = 0.0_rt;
17-
18-
jac_e = jac_T / state.cv;
16+
Real jac_e = jac_T / state.cv;
1917

2018
return jac_e;
2119
}

integration/utils/numerical_jacobian.H

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#endif
1313
#include <integrator_data.H>
1414

15+
1516
using namespace integrator_rp;
1617

1718
///
@@ -204,9 +205,15 @@ void numerical_jac(BurnT& state, const jac_info_t& jac_info, JacNetArray2D& jac)
204205

205206
// scale the energy derivatives
206207
if (scale_system) {
208+
// first the de/dX row
207209
for (int n = 1; n <= INT_NEQS; ++n) {
208210
jac(net_ienuc, n) /= state.e_scale;
209211
}
212+
213+
// now the dX/de column
214+
for (int m = 1; m <= INT_NEQS; ++m) {
215+
jac(m, net_ienuc) *= state.e_scale;
216+
}
210217
}
211218

212219
// apply boosting factor:

unit_test/burn_cell/ci-benchmarks/aprox13_RKC_unit_test.out

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
AMReX (23.06-6-g1e1c433b401c) initialized
1+
Initializing AMReX (23.08-206-g798ca3356d16)...
2+
AMReX (23.08-206-g798ca3356d16) initialized
23
starting the single zone burn...
34
Maximum Time (s): 0.01
45
State Density (g/cm^3): 1000000
@@ -32,8 +33,8 @@ RHS at t = 0
3233
Ni56 3.938787868e-40
3334
------------------------------------
3435
successful? 1
35-
- Hnuc = 8.558390239e+18
36-
- added e = 8.558390239e+16
36+
- Hnuc = 8.55839024e+18
37+
- added e = 8.55839024e+16
3738
- final T = 1516425860
3839
------------------------------------
3940
e initial = 1.284393683e+17
@@ -43,30 +44,30 @@ new mass fractions:
4344
He4 0.8760723967
4445
C12 0.1064099566
4546
O16 0.0001403204362
46-
Ne20 8.129701233e-05
47-
Mg24 0.0002972369574
47+
Ne20 8.129701234e-05
48+
Mg24 0.0002972369573
4849
Si28 0.01113151728
49-
S32 0.005297014797
50-
Ar36 0.0005641483161
51-
Ca40 6.109847027e-06
52-
Ti44 2.004306621e-09
53-
Cr48 3.272104798e-14
54-
Fe52 7.12614193e-20
55-
Ni56 1.224820021e-26
50+
S32 0.005297014805
51+
Ar36 0.0005641483217
52+
Ca40 6.109847214e-06
53+
Ti44 2.004306753e-09
54+
Cr48 3.2721052e-14
55+
Fe52 7.126143425e-20
56+
Ni56 1.224820426e-26
5657
------------------------------------
5758
species creation rates:
5859
omegadot(He4): -12.39276033
5960
omegadot(C12): 10.64099566
6061
omegadot(O16): 0.01403204362
61-
omegadot(Ne20): 0.008129701233
62-
omegadot(Mg24): 0.02972369574
62+
omegadot(Ne20): 0.008129701234
63+
omegadot(Mg24): 0.02972369573
6364
omegadot(Si28): 1.113151728
64-
omegadot(S32): 0.5297014797
65-
omegadot(Ar36): 0.05641483161
66-
omegadot(Ca40): 0.0006109847027
67-
omegadot(Ti44): 2.004306621e-07
68-
omegadot(Cr48): 3.272104798e-12
69-
omegadot(Fe52): 7.12614193e-18
70-
omegadot(Ni56): 1.224720021e-24
65+
omegadot(S32): 0.5297014805
66+
omegadot(Ar36): 0.05641483217
67+
omegadot(Ca40): 0.0006109847214
68+
omegadot(Ti44): 2.004306753e-07
69+
omegadot(Cr48): 3.2721052e-12
70+
omegadot(Fe52): 7.126143424e-18
71+
omegadot(Ni56): 1.224720426e-24
7172
number of steps taken: 255
72-
AMReX (23.06-6-g1e1c433b401c) finalized
73+
AMReX (23.08-206-g798ca3356d16) finalized

0 commit comments

Comments
 (0)