Added Dehnen potential and moved external potentials to a new compilation unit

This commit is contained in:
Yohai Meiron 2020-04-01 15:18:25 -04:00
parent 62b0d7e491
commit c79cef895a
7 changed files with 168 additions and 278 deletions

View file

@ -3,9 +3,12 @@
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <limits>
using Dictionary = std::unordered_map<std::string,std::string>;
static constexpr double nix = -std::numeric_limits<double>::max(); // avoid nans
std::string Config::strip(const std::string str)
{
std::string str_new = str;
@ -138,6 +141,8 @@ void Config::error_checking()
throw std::runtime_error("To use external disk gravity, please specify positive ext_m_disk, ext_a_disk and ext_b_disk");
if (((ext_log_halo_r > 0) && (ext_log_halo_v <= 0)) || ((ext_log_halo_r <= 0) && (ext_log_halo_v > 0)))
throw std::runtime_error("To use external logarithmic halo gravity, please specify positive ext_log_halo_r and ext_log_halo_v");
if ((ext_dehnen_m > 0) && ((ext_dehnen_r <= 0) || (ext_dehnen_gamma <= 0)))
throw std::runtime_error("To use external Dehnen model, please specify positive ext_dehnen_r and ext_dehnen_gamma");
}
Config::Config(std::string file_name)
@ -186,7 +191,9 @@ Config::Config(std::string file_name)
ext_b_halo_plummer = get_parameter<double>(dictionary, "ext_b_halo_plummer", -1);
ext_log_halo_v = get_parameter<double>(dictionary, "ext_log_halo_v", 0);
ext_log_halo_r = get_parameter<double>(dictionary, "ext_log_halo_r", 0);
ext_dehnen_m = get_parameter<double>(dictionary, "ext_dehnen_m", 0);
ext_dehnen_r = get_parameter<double>(dictionary, "ext_dehnen_r", -1);
ext_dehnen_gamma = get_parameter<double>(dictionary, "ext_dehnen_gamma", -1);
error_checking();
}