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

Add switch for calling Te solver #96

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions artisoptions_christinenonthermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) {

constexpr bool LTEPOP_EXCITATION_USE_TJ = false;

constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

constexpr bool FORCE_SAHA_ION_BALANCE(int element_z) { return false; }

constexpr bool single_level_top_ion = false;
Expand Down
2 changes: 2 additions & 0 deletions artisoptions_classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) { return fa

constexpr bool LTEPOP_EXCITATION_USE_TJ = true;

constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

constexpr bool FORCE_SAHA_ION_BALANCE(int element_z) { return false; }

constexpr bool single_level_top_ion = true;
Expand Down
4 changes: 4 additions & 0 deletions artisoptions_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) { return fa
// This is default on for classic, and off for nebularnlte, where it affects the super-level
constexpr bool LTEPOP_EXCITATION_USE_TJ = false;

//Switch to use Te solver to calculate Te from heating and cooling rates. Use Te=TJ instead when heating/cooling rates
// are too noisy to get a good Te solution (e.g. when only a few species are in NLTE)
constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

// Only include a single level for the highest ion stage
constexpr bool single_level_top_ion;

Expand Down
2 changes: 2 additions & 0 deletions artisoptions_kilonova_lte.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) { return fa

constexpr bool LTEPOP_EXCITATION_USE_TJ = true;

constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

constexpr bool FORCE_SAHA_ION_BALANCE(int element_z) { return true; }

constexpr bool single_level_top_ion = false;
Expand Down
2 changes: 2 additions & 0 deletions artisoptions_nltenebular.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) {

constexpr bool LTEPOP_EXCITATION_USE_TJ = false;

constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

constexpr bool FORCE_SAHA_ION_BALANCE(int element_z) { return false; }

constexpr bool single_level_top_ion = false;
Expand Down
2 changes: 2 additions & 0 deletions artisoptions_nltewithoutnonthermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ constexpr bool LEVEL_IS_NLTE(int element_z, int ionstage, int level) {

constexpr bool LTEPOP_EXCITATION_USE_TJ = false;

constexpr bool USE_TE_SOLVER = true; /// If not solving for Te then Te=TJ

constexpr bool FORCE_SAHA_ION_BALANCE(int element_z) { return false; }

constexpr bool single_level_top_ion = true;
Expand Down
16 changes: 12 additions & 4 deletions update_grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,14 @@ void solve_Te_nltepops(const int mgi, const int nonemptymgi, const int nts, cons

const double prev_T_e = grid::get_Te(mgi);
const auto sys_time_start_Te = std::time(nullptr);
const int nts_for_te = (titer == 0) ? nts - 1 : nts;

/// Find T_e as solution for thermal balance
call_T_e_finder(mgi, nts, globals::timesteps[nts_for_te].mid, MINTEMP, MAXTEMP, heatingcoolingrates,
bfheatingcoeffs);
if (USE_TE_SOLVER) {
const int nts_for_te = (titer == 0) ? nts - 1 : nts;

/// Find T_e as solution for thermal balance
call_T_e_finder(mgi, nts, globals::timesteps[nts_for_te].mid, MINTEMP, MAXTEMP, heatingcoolingrates,
bfheatingcoeffs);
}

const int duration_solve_T_e = std::time(nullptr) - sys_time_start_Te;

Expand Down Expand Up @@ -1024,6 +1027,11 @@ void update_grid_cell(const int mgi, const int nts, const int nts_prev, const in
// full-spectrum and binned J and nuJ estimators
radfield::fit_parameters(mgi, nts);

if (!USE_TE_SOLVER){
const double T_J = grid::get_TJ(mgi);
grid::set_Te(mgi, T_J); // instead of Te from heating/cooling rates
}

solve_Te_nltepops(mgi, nonemptymgi, nts, titer, heatingcoolingrates);
}
printout("Temperature/NLTE solution for cell %d timestep %d took %ld seconds\n", mgi, nts,
Expand Down
Loading