From 2743fb5eb3662e0333aab988ecebc9b776a2a371 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Mon, 9 Sep 2024 19:39:50 +0100 Subject: [PATCH] Fixup --- atomic.h | 2 +- globals.h | 1 + input.cc | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/atomic.h b/atomic.h index b7110d34e..587ffd350 100644 --- a/atomic.h +++ b/atomic.h @@ -378,7 +378,7 @@ inline auto get_includedlevels() -> int { return includedlevels; } [[nodiscard]] inline auto get_uptranslist(const int element, const int ion, const int level) -> LevelTransition * { const auto &levelref = globals::elements[element].ions[ion].levels[level]; - return globals::alltrans + levelref.alltrans_startdown + levelref.ndowntrans; + return globals::alltrans + levelref.alltrans_startup; } [[nodiscard]] inline auto get_uptransspan(const int element, const int ion, const int level) { diff --git a/globals.h b/globals.h index b6c2335fe..cad0e6765 100644 --- a/globals.h +++ b/globals.h @@ -84,6 +84,7 @@ struct EnergyLevel { double epsilon{-1}; // Excitation energy of this level relative to the neutral ground level. int alltrans_startdown{}; // index into globals::alltrans for first down transition from this level int ndowntrans{0}; // Number of down transitions from this level + int alltrans_startup{}; // index into globals::alltrans for first up transition from this level int nuptrans{0}; // Number of up transitions to this level int phixsstart{-1}; // index to start of photoionisation cross-sections table in global::allphixs int nphixstargets{0}; // number of target levels for photoionisation diff --git a/input.cc b/input.cc index 9f11affe7..e7f6dd432 100644 --- a/input.cc +++ b/input.cc @@ -490,6 +490,7 @@ void add_transitions_to_unsorted_linelist(const int element, const int ion, cons for (int level = 0; level < nlevelsmax; level++) { globals::elements[element].ions[ion].levels[level].alltrans_startdown = alltransindex; alltransindex += get_ndowntrans(element, ion, level); + globals::elements[element].ions[ion].levels[level].alltrans_startup = alltransindex; alltransindex += get_nuptrans(element, ion, level); set_ndowntrans(element, ion, level, 0); @@ -556,14 +557,13 @@ void add_transitions_to_unsorted_linelist(const int element, const int ion, cons .coll_str = transition.coll_str, .osc_strength = f_ul, .forbidden = transition.forbidden}; - temp_alltranslist[globals::elements[element].ions[ion].levels[lowerlevel].alltrans_startdown + - get_ndowntrans(element, ion, lowerlevel) + nloweruptrans - 1] = { - .lineindex = -1, - .targetlevelindex = level, - .einstein_A = transition.A, - .coll_str = transition.coll_str, - .osc_strength = f_ul, - .forbidden = transition.forbidden}; + temp_alltranslist[globals::elements[element].ions[ion].levels[lowerlevel].alltrans_startup + nloweruptrans - + 1] = {.lineindex = -1, + .targetlevelindex = level, + .einstein_A = transition.A, + .coll_str = transition.coll_str, + .osc_strength = f_ul, + .forbidden = transition.forbidden}; } } else if (pass == 1 && globals::rank_in_node == 0) { @@ -591,8 +591,8 @@ void add_transitions_to_unsorted_linelist(const int element, const int ion, cons const float f_ul = g_ratio * ME * pow(CLIGHT, 3) / (8 * pow(QE * nu_trans * PI, 2)) * transition.A; const int nupperdowntrans = get_ndowntrans(element, ion, level); - auto &downtransition = temp_alltranslist[globals::elements[element].ions[ion].levels[level].alltrans_startdown + - nupperdowntrans - 1]; + auto &downtransition = + temp_alltranslist[globals::elements[element].ions[ion].levels[level].alltrans_startdown + nupperdowntrans]; // this is what classic did, but it is not quite correct. The downtrans list should be searched to find the // correct index, not just using the last one. It probably works for the case where the transitions are sorted, @@ -604,7 +604,8 @@ void add_transitions_to_unsorted_linelist(const int element, const int ion, cons downtransition.coll_str = std::max(downtransition.coll_str, transition.coll_str); const int nloweruptrans = get_nuptrans(element, ion, lowerlevel); - auto &uptransition = get_uptranslist(element, ion, lowerlevel)[nloweruptrans]; + auto &uptransition = + temp_alltranslist[globals::elements[element].ions[ion].levels[lowerlevel].alltrans_startup + nloweruptrans]; // as above, the downtrans list should be searched to find the correct index instead of using the last one. // assert_always(uptransition.targetlevelindex == level);