Skip to content

Commit 1539b01

Browse files
authored
remove jacobian = 3 option (#1069)
this did parts of the Jacobian numerically and the conversion to energy analytically. But it never seems to have been a big win, and maintaining this code path is not worth it.
1 parent ca6d256 commit 1539b01

File tree

2 files changed

+49
-74
lines changed

2 files changed

+49
-74
lines changed

integration/VODE/vode_dvjac.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void dvjac (IArray1D& pivot, int& IERPJ, burn_t& state, dvode_t& vstate)
6767
// We want to evaluate the Jacobian -- now the path depends on
6868
// whether we're using the numerical or analytic Jacobian.
6969

70-
if (vstate.jacobian_type != 2) {
70+
if (vstate.jacobian_type == 1) {
7171

7272
// For the analytic Jacobian, call the user-supplied function.
7373

integration/integrator_rhs_simplified_sdc.H

Lines changed: 48 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
#include <integrator_type_simplified_sdc.H>
99
#include <actual_network.H>
10+
#ifdef NEW_NETWORK_IMPLEMENTATION
11+
#include <rhs.H>
12+
#else
1013
#include <actual_rhs.H>
11-
#include <numerical_jacobian.H>
14+
#endif
1215
#ifdef NONAKA_PLOT
1316
#include <nonaka_plot.H>
1417
#endif
@@ -110,94 +113,66 @@ void jac (const Real time, burn_t& state, T& int_state, MatrixType& pd)
110113

111114
}
112115

113-
if (int_state.jacobian_type == 3) {
114-
jac_info_t jac_info;
115-
jac_info.h = int_state.H;
116-
117-
// the numerical Jacobian for SDC will automatically
118-
// put it into the correct form (in terms of energy)
119-
// so we can just operate on the integrator Jacobian storage
120-
// directly
116+
// Call the specific network routine to get the Jacobian.
121117

122-
numerical_jac(state, jac_info, pd);
118+
actual_jac(state, pd);
123119

124-
// apply fudge factor:
125-
126-
if (react_boost > 0.0_rt) {
127-
pd.mul(react_boost);
120+
// The Jacobian from the nets is in terms of dYdot/dY, but we want
121+
// it was dXdot/dX, so convert here.
122+
for (int n = 1; n <= NumSpec; n++) {
123+
for (int m = 1; m <= neqs; m++) {
124+
pd(n,m) = pd(n,m) * aion[n-1];
128125
}
126+
}
129127

130-
// jacobian = 3 is a hybrid numerical + analytic
131-
// implementation for simplified SDC. It uses a one-sided
132-
// difference numerical approximation for the reactive
133-
// part and then algebraically transforms it to the
134-
// correct state variables for SDC. This means we need to
135-
// account for the NumSpec+1 RHS evals
136-
int_state.NFE += NumSpec + 1;
137-
138-
} else {
139-
140-
// Call the specific network routine to get the Jacobian.
141-
142-
actual_jac(state, pd);
143-
144-
// The Jacobian from the nets is in terms of dYdot/dY, but we want
145-
// it was dXdot/dX, so convert here.
128+
for (int m = 1; m <= neqs; m++) {
146129
for (int n = 1; n <= NumSpec; n++) {
147-
for (int m = 1; m <= neqs; m++) {
148-
pd(n,m) = pd(n,m) * aion[n-1];
149-
}
150-
}
151-
152-
for (int m = 1; m <= neqs; m++) {
153-
for (int n = 1; n <= NumSpec; n++) {
154-
pd(m,n) = pd(m,n) * aion_inv[n-1];
155-
}
130+
pd(m,n) = pd(m,n) * aion_inv[n-1];
156131
}
132+
}
157133

158-
// apply fudge factor:
134+
// apply fudge factor:
159135

160-
if (react_boost > 0.0_rt) {
161-
pd.mul(react_boost);
162-
}
136+
if (react_boost > 0.0_rt) {
137+
pd.mul(react_boost);
138+
}
163139

164-
// The system we integrate has the form (rho X_k, rho e)
165-
166-
// pd is now of the form:
167-
//
168-
// SFS / d(rho X1dot)/dX1 d(rho X1dit)/dX2 ... 1/cv d(rho X1dot)/dT \
169-
// | d(rho X2dot)/dX1 d(rho X2dot)/dX2 ... 1/cv d(rho X2dot)/dT |
170-
// SFS-1+nspec | ... |
171-
// SEINT \ d(rho Edot)/dX1 d(rho Edot)/dX2 ... 1/cv d(rho Edot)/dT /
172-
//
173-
// SFS SEINT
174-
175-
// now correct the species derivatives
176-
// this constructs dy/dX_k |_e = dy/dX_k |_T - e_{X_k} |_T dy/dT / c_v
177-
178-
eos_re_t eos_state;
179-
eos_state.rho = state.rho;
180-
eos_state.T = state.T;
181-
eos_state.e = state.e;
182-
for (int n = 0; n < NumSpec; n++) {
183-
eos_state.xn[n] = state.xn[n];
184-
}
140+
// The system we integrate has the form (rho X_k, rho e)
141+
142+
// pd is now of the form:
143+
//
144+
// SFS / d(rho X1dot)/dX1 d(rho X1dit)/dX2 ... 1/cv d(rho X1dot)/dT \
145+
// | d(rho X2dot)/dX1 d(rho X2dot)/dX2 ... 1/cv d(rho X2dot)/dT |
146+
// SFS-1+nspec | ... |
147+
// SEINT \ d(rho Edot)/dX1 d(rho Edot)/dX2 ... 1/cv d(rho Edot)/dT /
148+
//
149+
// SFS SEINT
150+
151+
// now correct the species derivatives
152+
// this constructs dy/dX_k |_e = dy/dX_k |_T - e_{X_k} |_T dy/dT / c_v
153+
154+
eos_re_t eos_state;
155+
eos_state.rho = state.rho;
156+
eos_state.T = state.T;
157+
eos_state.e = state.e;
158+
for (int n = 0; n < NumSpec; n++) {
159+
eos_state.xn[n] = state.xn[n];
160+
}
185161
#ifdef AUX_THERMO
186-
// make the aux data consistent with the state X's
187-
set_aux_comp_from_X(eos_state);
162+
// make the aux data consistent with the state X's
163+
set_aux_comp_from_X(eos_state);
188164
#endif
189165

190-
eos(eos_input_re, eos_state);
166+
eos(eos_input_re, eos_state);
191167

192-
eos_xderivs_t eos_xderivs = composition_derivatives(eos_state);
168+
eos_xderivs_t eos_xderivs = composition_derivatives(eos_state);
193169

194-
for (int m = 1; m <= neqs; m++) {
195-
for (int n = 1; n <= NumSpec; n++) {
196-
pd(m, n) -= eos_xderivs.dedX[n-1] * pd(m, net_ienuc);
197-
}
170+
for (int m = 1; m <= neqs; m++) {
171+
for (int n = 1; n <= NumSpec; n++) {
172+
pd(m, n) -= eos_xderivs.dedX[n-1] * pd(m, net_ienuc);
198173
}
199-
200174
}
201175

202176
}
177+
203178
#endif

0 commit comments

Comments
 (0)