Added spins to config file and got rid of more _act arrays
This commit is contained in:
parent
ebec3280f8
commit
75ad0f0e89
4 changed files with 178 additions and 185 deletions
42
config.cpp
42
config.cpp
|
|
@ -72,7 +72,6 @@ template<> bool Config::string_cast(const std::string str)
|
|||
throw std::runtime_error("Cannot convert \"" + str + "\" into a bool");
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
template<> std::vector<int> Config::string_cast(const std::string str)
|
||||
{
|
||||
auto error = std::runtime_error("Cannot convert \"" + str + "\" into an integer array");
|
||||
|
|
@ -90,6 +89,23 @@ template<> std::vector<int> Config::string_cast(const std::string str)
|
|||
return result;
|
||||
}
|
||||
|
||||
template<> std::vector<double> Config::string_cast(const std::string str)
|
||||
{
|
||||
auto error = std::runtime_error("Cannot convert \"" + str + "\" into an integer array");
|
||||
if (!( (str.front()=='{') && (str.back()=='}'))) throw error;
|
||||
std::string new_str = strip(str.substr(1, str.length()-2));
|
||||
std::replace(new_str.begin(), new_str.end(), ',', ' ');
|
||||
|
||||
std::vector<double> result;
|
||||
while (new_str.length() > 0) {
|
||||
size_t idx;
|
||||
auto value = std::stod(new_str, &idx);
|
||||
result.push_back(value);
|
||||
new_str = new_str.substr(idx, new_str.length()-idx);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// For mandatory parameters
|
||||
template<typename T>
|
||||
|
|
@ -109,6 +125,8 @@ T Config::get_parameter(Dictionary dictionary, std::string name, T default_value
|
|||
else return string_cast<T>((*item).second);
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void Config::error_checking()
|
||||
{
|
||||
#ifndef HAS_HDF5
|
||||
|
|
@ -130,9 +148,21 @@ void Config::error_checking()
|
|||
throw std::runtime_error("Binary black hole influence sphere output (binary_smbh_influence_sphere_output=true) requires exactly two live black holes (live_smbh_count=2)");
|
||||
if (pn_usage.size() != 7)
|
||||
throw std::runtime_error("PN usage array (pn_usage) must have exactly seven components");
|
||||
for (int i=0; i<7; i++)
|
||||
if (!((pn_usage[i] == 0) || (pn_usage[i] == 1)))
|
||||
throw std::runtime_error("PN usage array (pn_usage) must have ones and zeros only");
|
||||
if (binary_smbh_pn)
|
||||
for (int i=0; i<7; i++)
|
||||
if (!((pn_usage[i] == 0) || (pn_usage[i] == 1)))
|
||||
throw std::runtime_error("PN usage array (pn_usage) must be a 7-component vector filled with ones and zeros only");
|
||||
if ((smbh1_spin.size()!=3) || (smbh2_spin.size()!=3))
|
||||
throw std::runtime_error("Spins must be three-component vectors");
|
||||
if ((pn_usage[6]==1) && ((smbh1_spin[0]==nix) || (smbh2_spin[0]==nix)))
|
||||
throw std::runtime_error("Please define smbh1_spin and smbh2_spin or disable the spin by setting the last component of pn_usage to zero");
|
||||
std::cout << smbh1_spin[0] << std::endl;
|
||||
std::cout << smbh1_spin[1] << std::endl;
|
||||
std::cout << smbh1_spin[2] << std::endl;
|
||||
if ((pn_usage[6]==0) && ((smbh1_spin[0]!=nix) || (smbh2_spin[0]!=nix)))
|
||||
throw std::runtime_error("Spins (smbh1_spin and smbh2_spin) may not be defined if the last element of pn_usage is set to zero");
|
||||
|
||||
|
||||
if (ext_units_physical && ((unit_mass == 0) || (unit_length == 0)))
|
||||
throw std::runtime_error("Physical units for external gravity (ext_units_physical) requires ext_unit_mass and ext_unit_length to be positive numbers");
|
||||
if ((ext_m_bulge > 0) && (ext_b_bulge < 0))
|
||||
|
|
@ -177,8 +207,10 @@ Config::Config(std::string file_name)
|
|||
binary_smbh_influence_radius_factor = get_parameter<double>(dictionary, "binary_smbh_influence_radius_factor", 10.);
|
||||
|
||||
binary_smbh_pn = get_parameter<bool>(dictionary, "binary_smbh_pn", false);
|
||||
pn_usage = get_parameter<std::vector<int>>(dictionary, "pn_usage", std::vector<int>({1,1,1,1,1,1,1}));
|
||||
pn_usage = get_parameter<std::vector<int>>(dictionary, "pn_usage", std::vector<int>({-1,-1,-1,-1,-1,-1,-1}));
|
||||
pn_c = get_parameter<double>(dictionary, "pn_c", 0);
|
||||
smbh1_spin = get_parameter<std::vector<double>>(dictionary, "smbh1_spin", std::vector<double>({nix,nix,nix}));
|
||||
smbh2_spin = get_parameter<std::vector<double>>(dictionary, "smbh2_spin", std::vector<double>({nix,nix,nix}));
|
||||
|
||||
ext_units_physical = get_parameter<bool>(dictionary, "ext_units_physical", false);
|
||||
unit_mass = get_parameter<double>(dictionary, "unit_mass", !ext_units_physical);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue