Skip to content

Commit 7d144e3

Browse files
authored
some composition optimizations (#1913)
1 parent 3ab4acc commit 7d144e3

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

EOS/eos_composition.H

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,22 @@ void composition (T& state)
5858

5959
#ifdef AUX_THERMO
6060

61-
state.mu_e = 1.0 / state.aux[iye];
61+
state.mu_e = 1.0_rt / state.aux[iye];
6262
state.y_e = state.aux[iye];
6363
state.abar = state.aux[iabar];
6464
state.zbar = state.abar * state.y_e;
6565

6666
#else
6767

68-
amrex::Real sum = 0;
68+
state.y_e = 0.0_rt;
69+
state.abar = 0.0_rt;
6970
for (int n = 0; n < NumSpec; n++) {
70-
sum += state.xn[n] * zion[n] * aion_inv[n];
71+
state.y_e += state.xn[n] * zion[n] * aion_inv[n];
72+
state.abar += state.xn[n] * aion_inv[n];
7173
}
74+
state.abar = 1.0_rt / state.abar;
7275

73-
state.mu_e = 1.0 / sum;
74-
state.y_e = sum;
75-
76-
sum = 0;
77-
78-
for (int n = 0; n < NumSpec; n++) {
79-
sum += state.xn[n] * aion_inv[n];
80-
}
81-
82-
state.abar = 1.0 / sum;
76+
state.mu_e = 1.0_rt / state.y_e;
8377
state.zbar = state.abar * state.y_e;
8478
#endif
8579
}

EOS/helmholtz/actual_eos.H

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ void apply_electrons (T& state)
170170
// assume complete ionization
171171
[[maybe_unused]] amrex::Real ytot1 = 1.0e0_rt / state.abar;
172172

173-
// define mu -- the total mean molecular weight including both electrons and ions
174-
state.mu = 1.0e0_rt / (1.0e0_rt / state.abar + 1.0e0_rt / state.mu_e);
175-
176173
// enter the table with ye*den
177174
amrex::Real din = state.y_e * state.rho;
178175

@@ -1129,6 +1126,9 @@ void finalize_state (I input, T& state,
11291126
{
11301127
using namespace helmholtz;
11311128

1129+
// define mu -- the total mean molecular weight including both electrons and ions
1130+
state.mu = 1.0e0_rt / (1.0e0_rt / state.abar + 1.0e0_rt / state.mu_e);
1131+
11321132
// Calculate some remaining derivatives
11331133
if constexpr (has_pressure<T>::value) {
11341134
state.dpde = state.dpdT / state.dedT;

0 commit comments

Comments
 (0)