Skip to content

Commit

Permalink
Make cont_index positive
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Sep 9, 2024
1 parent 412cf7a commit 4c8c269
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ inline void set_nuptrans(const int element, const int ion, const int level, cons
[[nodiscard]] inline auto get_emtype_continuum(const int element, const int ion, const int level,
const int upperionlevel) -> int {
const int phixstargetindex = get_phixtargetindex(element, ion, level, upperionlevel);
return globals::elements[element].ions[ion].levels[level].cont_index - phixstargetindex;
return globals::elements[element].ions[ion].levels[level].cont_index + phixstargetindex;
}

// Returns the energy of (element,ion,level).
Expand Down
7 changes: 3 additions & 4 deletions input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,16 @@ void read_phixs_data() {
read_phixs_file(1, tmpallphixs);
}

int cont_index = -1;
int cont_index = 0;
ptrdiff_t nbftables = 0;
for (int element = 0; element < get_nelements(); element++) {
const int nions = get_nions(element);
for (int ion = 0; ion < nions; ion++) {
const int nlevels = get_nlevels(element, ion);
for (int level = 0; level < nlevels; level++) {
const int nphixstargets = get_nphixstargets(element, ion, level);
globals::elements[element].ions[ion].levels[level].cont_index =
(nphixstargets > 0) ? cont_index : std::numeric_limits<int>::max();
cont_index -= nphixstargets;
globals::elements[element].ions[ion].levels[level].cont_index = (nphixstargets > 0) ? cont_index : -1;
cont_index += nphixstargets;
if (nphixstargets > 0) {
nbftables++;
}
Expand Down
2 changes: 1 addition & 1 deletion sn3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ inline void gsl_error_handler_printout(const char *reason, const char *file, int

[[nodiscard]] inline auto get_bflutindex(const int tempindex, const int element, const int ion, const int level,
const int phixstargetindex) -> int {
const int contindex = -1 - globals::elements[element].ions[ion].levels[level].cont_index + phixstargetindex;
const int contindex = globals::elements[element].ions[ion].levels[level].cont_index + phixstargetindex;

const int bflutindex = (tempindex * globals::nbfcontinua) + contindex;
assert_testmodeonly(bflutindex >= 0);
Expand Down

0 comments on commit 4c8c269

Please sign in to comment.