Skip to content

Commit e42b7fa

Browse files
committed
Merge branch 'development' into use_cxx-20
2 parents 0b2908f + 3ab4acc commit e42b7fa

File tree

4 files changed

+69
-48
lines changed

4 files changed

+69
-48
lines changed

EOS/helmholtz/actual_eos.H

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -348,23 +348,26 @@ void apply_electrons (T& state)
348348

349349

350350
// electron chemical potential etaele
351-
amrex::Real etaele = 0.0e0_rt;
352-
amrex::constexpr_for<0, 16>([&] (auto K) {
353-
constexpr int k = K;
354-
constexpr auto m = electron_table_indexing::map[k];
355-
356-
etaele += ef[jat+m.dj][iat+m.di][m.n] * wdt[k];
357-
});
351+
[[maybe_unused]] amrex::Real etaele{};
352+
if constexpr (has_eta<T>) {
353+
amrex::constexpr_for<0, 16>([&] (auto K) {
354+
constexpr int k = K;
355+
constexpr auto m = electron_table_indexing::map[k];
358356

357+
etaele += ef[jat+m.dj][iat+m.di][m.n] * wdt[k];
358+
});
359+
}
359360

360361
// electron + positron number densities
361-
amrex::Real xnefer = 0.0e0_rt;
362-
amrex::constexpr_for<0, 16>([&] (auto K) {
363-
constexpr int k = K;
364-
constexpr auto m = electron_table_indexing::map[k];
362+
[[maybe_unused]] amrex::Real xnefer{};
363+
if constexpr (has_xne_xnp<T>) {
364+
amrex::constexpr_for<0, 16>([&] (auto K) {
365+
constexpr int k = K;
366+
constexpr auto m = electron_table_indexing::map[k];
365367

366-
xnefer += xf[jat+m.dj][iat+m.di][m.n] * wdt[k];
367-
});
368+
xnefer += xf[jat+m.dj][iat+m.di][m.n] * wdt[k];
369+
});
370+
}
368371

369372
// the desired electron-positron thermodynamic quantities
370373

@@ -375,22 +378,38 @@ void apply_electrons (T& state)
375378
amrex::Real x = din * din;
376379
amrex::Real pele = x * df_d;
377380
amrex::Real dpepdt = x * df_dt;
378-
[[maybe_unused]] amrex::Real s = dpepdd/state.y_e - 2.0e0_rt * din * df_d;
379-
[[maybe_unused]] amrex::Real dpepda = -ytot1 * (2.0e0_rt * pele + s * din);
380-
[[maybe_unused]] amrex::Real dpepdz = state.rho*ytot1*(2.0e0_rt * din * df_d + s);
381+
[[maybe_unused]] amrex::Real dpepda{};
382+
[[maybe_unused]] amrex::Real dpepdz{};
383+
if constexpr (has_dpdA<T> || has_dpdZ<T>) {
384+
amrex::Real s = dpepdd/state.y_e - 2.0e0_rt * din * df_d;
385+
if constexpr (has_dpdA<T>) {
386+
dpepda = -ytot1 * (2.0e0_rt * pele + s * din);
387+
}
388+
if constexpr (has_dpdZ<T>) {
389+
dpepdz = state.rho*ytot1*(2.0e0_rt * din * df_d + s);
390+
}
391+
}
381392

382393
x = state.y_e * state.y_e;
383394
amrex::Real sele = -df_t * state.y_e;
384395
amrex::Real dsepdt = -df_tt * state.y_e;
385396
amrex::Real dsepdd = -df_dt * x;
386-
[[maybe_unused]] amrex::Real dsepda = ytot1 * (state.y_e * df_dt * din - sele);
387-
[[maybe_unused]] amrex::Real dsepdz = -ytot1 * (state.y_e * df_dt * state.rho + df_t);
388397

389398
amrex::Real eele = state.y_e*free + state.T * sele;
390399
amrex::Real deepdt = state.T * dsepdt;
391400
amrex::Real deepdd = x * df_d + state.T * dsepdd;
392-
[[maybe_unused]] amrex::Real deepda = -state.y_e * ytot1 * (free + df_d * din) + state.T * dsepda;
393-
[[maybe_unused]] amrex::Real deepdz = ytot1* (free + state.y_e * df_d * state.rho) + state.T * dsepdz;
401+
402+
[[maybe_unused]] amrex::Real deepda{};
403+
if constexpr (has_dedA<T>) {
404+
amrex::Real dsepda = ytot1 * (state.y_e * df_dt * din - sele);
405+
deepda = -state.y_e * ytot1 * (free + df_d * din) + state.T * dsepda;
406+
}
407+
408+
[[maybe_unused]] amrex::Real deepdz{};
409+
if constexpr (has_dedZ<T>) {
410+
amrex::Real dsepdz = -ytot1 * (state.y_e * df_dt * state.rho + df_t);
411+
deepdz = ytot1* (free + state.y_e * df_d * state.rho) + state.T * dsepdz;
412+
}
394413

395414
if constexpr (has_pressure<T>) {
396415
state.p = state.p + pele;
@@ -549,14 +568,10 @@ void apply_radiation (T& state)
549568

550569
amrex::Real dpraddd = 0.0e0_rt;
551570
amrex::Real dpraddt = 4.0e0_rt * prad * tempi;
552-
[[maybe_unused]] amrex::Real dpradda = 0.0e0_rt;
553-
[[maybe_unused]] amrex::Real dpraddz = 0.0e0_rt;
554571

555572
amrex::Real erad = 3.0e0_rt * prad*deni;
556573
amrex::Real deraddd = -erad * deni;
557574
amrex::Real deraddt = 3.0e0_rt * dpraddt * deni;
558-
[[maybe_unused]] amrex::Real deradda = 0.0e0_rt;
559-
[[maybe_unused]] amrex::Real deraddz = 0.0e0_rt;
560575

561576
amrex::Real srad = (prad * deni + erad) * tempi;
562577
amrex::Real dsraddd = (dpraddd * deni - prad * deni * deni + deraddd) * tempi;
@@ -571,10 +586,10 @@ void apply_radiation (T& state)
571586
state.dpdr = dpraddd;
572587
state.dpdT = dpraddt;
573588
if constexpr (has_dpdA<T>) {
574-
state.dpdA = dpradda;
589+
state.dpdA = 0.0_rt;
575590
}
576591
if constexpr (has_dpdZ<T>) {
577-
state.dpdZ = dpraddz;
592+
state.dpdZ = 0.0_rt;
578593
}
579594
}
580595

@@ -583,10 +598,10 @@ void apply_radiation (T& state)
583598
state.dedr = deraddd;
584599
state.dedT = deraddt;
585600
if constexpr (has_dedA<T>) {
586-
state.dedA = deradda;
601+
state.dedA = 0.0_rt;
587602
}
588603
if constexpr (has_dedZ<T>) {
589-
state.dedZ = deraddz;
604+
state.dedZ = 0.0_rt;
590605
}
591606
}
592607

integration/integrator_data.H

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef INTEGRATOR_DATA_H
22
#define INTEGRATOR_DATA_H
33

4+
#include <limits>
5+
46
#include <burn_type.H>
57

68
// Define the size of the ODE system that VODE will integrate
@@ -12,6 +14,10 @@ constexpr int INT_NEQS = NumSpec + 1;
1214
// -failure_tolerance <= X <= 1.0 + failure_tolerance).
1315
constexpr amrex::Real species_failure_tolerance = 1.e-2_rt;
1416

17+
// for outputting the burn state failure, use enough precision
18+
// to be reproducible (not guaranteed for std::fixed)
19+
constexpr int OUTDIGITS = std::numeric_limits<amrex::Real>::max_digits10;
20+
1521
#ifdef NSE
1622
constexpr int MIN_NSE_BAILOUT_STEPS = 10;
1723
#endif

integration/integrator_setup_sdc.H

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,47 +219,47 @@ void integrator_cleanup (IntegratorT& int_state, BurnT& state,
219219
}
220220
std::cout << "zone = (" << state.i << ", " << state.j << ", " << state.k << ")" << std::endl;
221221
std::cout << "time = " << state.time << std::endl;
222-
std::cout << "dt = " << std::setprecision(16) << dt << std::endl;
223-
std::cout << "dens start = " << std::setprecision(16) << state.rho_orig << std::endl;
224-
std::cout << "temp start = " << std::setprecision(16) << state_save.T_in << std::endl;
225-
std::cout << "rhoe start = " << std::setprecision(16) << state_save.rhoe_in << std::endl;
222+
std::cout << "dt = " << std::setprecision(OUTDIGITS) << dt << std::endl;
223+
std::cout << "dens start = " << std::setprecision(OUTDIGITS) << state.rho_orig << std::endl;
224+
std::cout << "temp start = " << std::setprecision(OUTDIGITS) << state_save.T_in << std::endl;
225+
std::cout << "rhoe start = " << std::setprecision(OUTDIGITS) << state_save.rhoe_in << std::endl;
226226
std::cout << "xn start = ";
227227
for (const auto X : state_save.xn_in) {
228-
std::cout << std::setprecision(16) << X << " ";
228+
std::cout << std::setprecision(OUTDIGITS) << X << " ";
229229
}
230230
std::cout << std::endl;
231231
#ifdef AUX_THERMO
232232
std::cout << "aux start = ";
233233
for (const auto aux : state_save.aux_in) {
234-
std::cout << std::setprecision(16) << aux << " ";
234+
std::cout << std::setprecision(OUTDIGITS) << aux << " ";
235235
}
236236
std::cout << std::endl;
237237
#endif
238-
std::cout << "dens current = " << std::setprecision(16) << state.rho << std::endl;
239-
std::cout << "temp current = " << std::setprecision(16) << state.T << std::endl;
238+
std::cout << "dens current = " << std::setprecision(OUTDIGITS) << state.rho << std::endl;
239+
std::cout << "temp current = " << std::setprecision(OUTDIGITS) << state.T << std::endl;
240240
std::cout << "xn current = ";
241241
for (int n = 0; n < NumSpec; ++n) {
242-
std::cout << std::setprecision(16) << state.xn[n] << " ";
242+
std::cout << std::setprecision(OUTDIGITS) << state.xn[n] << " ";
243243
}
244244
std::cout << std::endl;
245245
#ifdef AUX_THERMO
246246
std::cout << "aux current = ";
247247
for (int n = 0; n < NumAux; ++n) {
248-
std::cout << std::setprecision(16) << state.aux[n] << " ";
248+
std::cout << std::setprecision(OUTDIGITS) << state.aux[n] << " ";
249249
}
250250
std::cout << std::endl;
251251
#endif
252-
std::cout << "A(rho) = " << std::setprecision(16) << state.ydot_a[SRHO] << std::endl;
253-
std::cout << "A(rho e) = " << std::setprecision(16) << state.ydot_a[SEINT] << std::endl;
252+
std::cout << "A(rho) = " << std::setprecision(OUTDIGITS) << state.ydot_a[SRHO] << std::endl;
253+
std::cout << "A(rho e) = " << std::setprecision(OUTDIGITS) << state.ydot_a[SEINT] << std::endl;
254254
std::cout << "A(rho X_k) = ";
255255
for (int n = 0; n < NumSpec; n++) {
256-
std::cout << std::setprecision(16) << state.ydot_a[SFS+n] << " ";
256+
std::cout << std::setprecision(OUTDIGITS) << state.ydot_a[SFS+n] << " ";
257257
}
258258
std::cout << std::endl;
259259
#ifdef AUX_THERMO
260260
std::cout << "A(rho aux_k) = ";
261261
for (int n = 0; n < NumAux; n++) {
262-
std::cout << std::setprecision(16) << state.ydot_a[SFX+n] << " ";
262+
std::cout << std::setprecision(OUTDIGITS) << state.ydot_a[SFX+n] << " ";
263263
}
264264
std::cout << std::endl;
265265
#endif

integration/integrator_setup_strang.H

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,18 @@ void integrator_cleanup (IntegratorT& int_state, BurnT& state,
190190
}
191191
std::cout << "zone = (" << state.i << ", " << state.j << ", " << state.k << ")" << std::endl;
192192
std::cout << "time = " << int_state.t << std::endl;
193-
std::cout << "dt = " << std::setprecision(16) << dt << std::endl;
194-
std::cout << "temp start = " << std::setprecision(16) << state_save.T_in << std::endl;
193+
std::cout << "dt = " << std::setprecision(OUTDIGITS) << dt << std::endl;
194+
std::cout << "temp start = " << std::setprecision(OUTDIGITS) << state_save.T_in << std::endl;
195195
std::cout << "xn start = ";
196196
for (const double X : state_save.xn_in) {
197-
std::cout << std::scientific << std::setprecision(16) << X << " ";
197+
std::cout << std::scientific << std::setprecision(OUTDIGITS) << X << " ";
198198
}
199199
std::cout << std::endl;
200-
std::cout << "dens current = " << std::setprecision(16) << state.rho << std::endl;
201-
std::cout << "temp current = " << std::setprecision(16) << state.T << std::endl;
200+
std::cout << "dens current = " << std::setprecision(OUTDIGITS) << state.rho << std::endl;
201+
std::cout << "temp current = " << std::setprecision(OUTDIGITS) << state.T << std::endl;
202202
std::cout << "xn current = ";
203203
for (const double X : state.xn) {
204-
std::cout << std::scientific << std::setprecision(16) << X << " ";
204+
std::cout << std::scientific << std::setprecision(OUTDIGITS) << X << " ";
205205
}
206206
std::cout << std::endl;
207207
std::cout << "energy generated = " << state.e << std::endl;

0 commit comments

Comments
 (0)