Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLTE Solver population checks #88

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions nltepop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,29 @@ void solve_nlte_pops_element(const int element, const int modelgridindex, const
assert_always(gsl_vector_get(popvec, index) >= 0.);
}

const double MAXPOP_nn = 1e16; // Allow for external definition of maximum population at some point
for (int ion = 0; ion < nions; ion++) {
const int nlevels_nlte = get_nlevels_nlte(element, ion);
const int index_gs = get_nlte_vector_index(element, ion, 0);
const double groundlevelpop = gsl_vector_get(popvec, index_gs);

for (int level = 1; level <= nlevels_nlte; level++) {
const int index = get_nlte_vector_index(element, ion, level);
double min_nlte_pop = MINPOP;
// we need to add a lower and an upper limit to the population
if (gsl_vector_get(popvec, index) < min_nlte_pop) {
gsl_vector_set(popvec, index, min_nlte_pop);
}

if ((gsl_vector_get(popvec, index) / groundlevelpop) > MAXPOP_nn) {
printout("[Warning] Population of level %d in ion %d of element %d is too high. Setting to %g\n", level, ion,
element, MAXPOP_nn);
// either we need to try and set a senisble max pop [or we set to lte]
gsl_vector_set(popvec, index, MAXPOP_nn * groundlevelpop);
}
}
}

for (int ion = 0; ion < nions; ion++) {
const int nlevels_nlte = get_nlevels_nlte(element, ion);
const int index_gs = get_nlte_vector_index(element, ion, 0);
Expand Down
Loading