Skip to content

Commit

Permalink
Fix the scaling of the mass fractions (#71)
Browse files Browse the repository at this point in the history
The check on whether the input mass fractions sum to 1 was not being done correctly.
  • Loading branch information
brady-ryan authored Jul 16, 2024
1 parent 43c1ba6 commit f4d3200
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions toy_atm/init_1d.H
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,22 @@ AMREX_INLINE void init_1d()
if (problem_rp::fuel7_name != "")
xn_base[ifuel7] = problem_rp::fuel7_frac;

// check if they sum to 1
double sum{0.0};
// check if star comp. adds to 1
double sum_star{0.0};
for (auto e : xn_star) {
sum += e;
sum_star += e;
}
if (std::abs(sum) - 1.0_rt > NumSpec * smallx) {
if (std::abs(sum_star - 1.0_rt) > NumSpec * smallx) {
amrex::Error("ERROR: ash mass fractions don't sum to 1");
}

sum = 0.0;
// check if base comp. adds to 1
double sum_base{0.0};
for (auto e : xn_base) {
if (std::abs(sum) - 1.0_rt > NumSpec * smallx) {
amrex::Error("ERROR: fuel mass fractions don't sum to 1");
}
sum_base += e;
}
if (std::abs(sum_base - 1.0_rt) > NumSpec * smallx) {
amrex::Error("ERROR: fuel mass fractions don't sum to 1");
}

// Create a 1-d uniform grid that is identical to the mesh that we are
Expand Down

0 comments on commit f4d3200

Please sign in to comment.