-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathltepop.h
More file actions
71 lines (59 loc) · 3.11 KB
/
ltepop.h
File metadata and controls
71 lines (59 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef LTEPOP_H
#define LTEPOP_H
#include <cmath>
#include <cstddef>
#include <vector>
#include "artisoptions.h"
#include "atomic.h"
#include "constants.h"
#include "globals.h"
#include "sn3d.h"
[[gnu::pure]] [[nodiscard]] DEVICE_FUNC auto calculate_levelpop(int nonemptymgi, int element, int ion, int level)
-> double;
[[gnu::pure]] [[nodiscard]] auto calculate_levelpop_boltzmann(int nonemptymgi, int element, int ion, int level)
-> double;
[[nodiscard]] DEVICE_FUNC auto find_uppermost_ion(int nonemptymgi, int element, double nne_hi, bool force_saha) -> int;
void calculate_ion_balance_nne(int nonemptymgi);
void calculate_cellpartfuncts(int nonemptymgi, int element);
[[nodiscard]] auto calculate_ionfractions(int element, int nonemptymgi, double nne, bool use_phi_saha)
-> std::vector<double>;
void set_groundlevelpops(int nonemptymgi, int element, float nne, bool force_saha);
[[gnu::pure]] [[nodiscard]] inline DEVICE_FUNC auto get_cellcache_levelpop(const int nonemptymgi,
const int uniquelevelindex) -> double {
assert_testmodeonly(globals::cellcache[cellcacheslotid].nonemptymgi == nonemptymgi);
const auto nn = globals::cellcache[cellcacheslotid].alllevels_pops[uniquelevelindex];
assert_testmodeonly(nn >= 0.);
return nn;
}
// Calculate the population of a level from either LTE or NLTE information
[[gnu::pure]] [[nodiscard]] inline DEVICE_FUNC auto get_cellcache_levelpop(const int nonemptymgi, const int element,
const int ion, const int level) -> double {
return get_cellcache_levelpop(nonemptymgi, get_uniquelevelindex(element, ion, level));
}
// Return the given ions groundlevel population for modelgridindex which was precalculated
// during update_grid and stored to the grid.
[[gnu::pure]] [[nodiscard]] inline DEVICE_FUNC auto get_groundlevelpop(const int nonemptymgi, const int element,
const int ion) -> double {
assert_testmodeonly(element < get_nelements());
assert_testmodeonly(ion < get_nions(element));
const double nn = grid::ion_groundlevelpops_allcells[(static_cast<ptrdiff_t>(nonemptymgi) * get_includedions()) +
get_uniqueionindex(element, ion)];
if (nn < MINPOP) {
if (grid::get_elem_abundance(nonemptymgi, element) > 0) {
return MINPOP;
}
return 0.;
}
return nn;
}
// Use the ground level population and partition function to get an ion population
[[gnu::pure]] [[nodiscard]] inline auto get_nnion(const int nonemptymgi, const int element, const int ion) -> double {
const auto nnion = get_groundlevelpop(nonemptymgi, element, ion) *
grid::ion_partfuncts_allcells[(static_cast<ptrdiff_t>(nonemptymgi) * get_includedions()) +
get_uniqueionindex(element, ion)] /
stat_weight(element, ion, 0);
assert_testmodeonly(nnion >= 0.);
assert_testmodeonly(std::isfinite(nnion));
return nnion;
}
#endif // LTEPOP_H