-
Notifications
You must be signed in to change notification settings - Fork 7
Updating the main branch in Daniel's root repo with my changes after completing 2606.30729 #3
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
base: ConfigReader
Are you sure you want to change the base?
Changes from all commits
55c4611
e4a01ae
056fcce
0212ab7
a32647b
cbc4bb8
b7e988e
babcc11
8518b1c
26bd7e6
ba7d55e
0c3bfad
e0428a1
cfa3d4d
c002d29
4e65f60
81387c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,6 +294,28 @@ std::unique_ptr<Metric> Config::GetMetric(const ConfigCollection &theCfg) | |
| // All settings complete; create Metric object! | ||
| TheMetric = std::unique_ptr<Metric>(new BosonStarMetric(Phi_infinity, num_lines, rLogScale, Phi_filename, m_filename)); | ||
| } | ||
| else if (MetricName == "rotatingbosonstar") | ||
| { | ||
| // The rotating boson star with solitonic potential | ||
|
|
||
| // First setting to look up: using a logarithmic r coordinate or not. | ||
| // Don't need to output message if setting not found | ||
| bool rLogScale{false}; | ||
| bool flipAngularMomentum{false}; | ||
| std::string MetricFolder{"RotatingBosonStar/data_Will/"}; | ||
| int NumX{500}; | ||
| int NumTh{399}; | ||
| real L{1.}; | ||
| MetricSettings.LookupValue("RLogScale", rLogScale); | ||
| MetricSettings.LookupValue("FlipAngularMomentum", flipAngularMomentum); | ||
| MetricSettings.LookupValue("MetricFolder", MetricFolder); | ||
| MetricSettings.LookupValue("NumX", NumX); | ||
| MetricSettings.LookupValue("NumTh", NumTh); | ||
| MetricSettings.LookupValue("L", L); | ||
|
|
||
| // All settings complete; create Metric object! | ||
| TheMetric = std::unique_ptr<Metric>(new RotatingBosonStarMetric(rLogScale, MetricFolder, NumX, NumTh, L, flipAngularMomentum)); | ||
| } | ||
| //// METRIC ADD POINT B //// | ||
| // Add an else if clause to check for your new Metric object! | ||
| // To look for additional options in the metric configuration, use | ||
|
|
@@ -602,26 +624,32 @@ void Config::InitializeDiagnostics(const ConfigCollection &theCfg, DiagBitflag & | |
|
|
||
| //// Fluid four-velocity model selection and initialization //// | ||
|
|
||
| // Default fluid model and default parameters | ||
| real defaultxi{1.0}; | ||
| real defaultbetar{1.0}; | ||
| real defaultbetaphi{1.0}; | ||
| std::unique_ptr<FluidVelocityModel> theFluidModel{new GeneralCircularRadialFluid(defaultxi, defaultbetar, defaultbetaphi, theMetric)}; | ||
| // Fluid four-velocity model parameters (with sensible defaults) | ||
| real subKeplerianparam{1.0}; | ||
| real betaR{1.0}; | ||
| real betaPhi{1.0}; | ||
| real iscolowerbound{0.05}; | ||
| real iscoupperbound{1000.0}; | ||
|
|
||
| // Read in fluid velocity model | ||
| std::string fluidmodelstring{""}; | ||
| std::string fluidmodelstring{"GeneralCircularRadial"}; | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("FluidVelocityModel", fluidmodelstring); | ||
| if (fluidmodelstring == "GeneralCircularRadial") | ||
| { | ||
| real subKeplerianparam{defaultxi}; | ||
| real betaR{defaultbetar}; | ||
| real betaPhi{defaultbetaphi}; | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("xi", subKeplerianparam); | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("betar", betaR); | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("betaphi", betaPhi); | ||
|
|
||
| theFluidModel = std::unique_ptr<FluidVelocityModel>{new GeneralCircularRadialFluid(subKeplerianparam, betaR, betaPhi, theMetric)}; | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("ISCOLowerBound", iscolowerbound); | ||
| AllDiagSettings["EquatorialEmission"].LookupValue("ISCOUpperBound", iscoupperbound); | ||
| } | ||
| else | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback logic needs to be checked here: at the moment it always falls back to GeneralCircularRadial |
||
| { | ||
| ScreenOutput("Unknown FluidVelocityModel \"" + fluidmodelstring + "\". Using default GeneralCircularRadial model.", | ||
| Output_Other_Default); | ||
| } | ||
|
|
||
| std::unique_ptr<FluidVelocityModel> theFluidModel{ | ||
| new GeneralCircularRadialFluid(subKeplerianparam, betaR, betaPhi, theMetric, iscolowerbound, iscoupperbound)}; | ||
| // Other fluid velocity models can be checked for here... | ||
|
|
||
| // Set EquatorialEmissionDiagnostic options struct | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,7 +180,7 @@ std::string GeneralCircularRadialFluid::getFullDescriptionStr() const | |
| if (m_ISCOexists && m_theMetric->getrLogScale()) | ||
| trueISCOradius = exp(m_ISCOr); | ||
|
|
||
| return "Circular/radial flow (sub-Keplerian parameter xi = " + std::to_string(m_subKeplerParam) + ", beta_r = " + std::to_string(m_betaR) + ", beta_phi = " + std::to_string(m_betaPhi) + "; " + (m_ISCOexists ? "ISCO = " + std::to_string(trueISCOradius) : "no ISCO found") + ")"; | ||
| return "Circular/radial flow (sub-Keplerian parameter xi = " + std::to_string(m_subKeplerParam) + ", beta_r = " + std::to_string(m_betaR) + ", beta_phi = " + std::to_string(m_betaPhi) + "; " + (m_ISCOexists ? "ISCO = " + std::to_string(trueISCOradius) : "no ISCO found") + "; " + "ISCO lower bound = " + std::to_string(m_ISCOlowerbound) + ", ISCO upper bound = " + std::to_string(m_ISCOupperbound) + ")"; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -352,14 +352,20 @@ OneIndex GeneralCircularRadialFluid::GetRadialVelocityd(const Point &p) const | |
| */ | ||
| void GeneralCircularRadialFluid::FindISCO() | ||
| { | ||
| real lowerbound{0.0}; | ||
| real upperbound{1000.0}; | ||
| real lowerbound{m_ISCOlowerbound}; | ||
| real upperbound{m_ISCOupperbound}; | ||
| const SphericalHorizonMetric *sphermetric = dynamic_cast<const SphericalHorizonMetric *>(m_theMetric); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is perhaps something I need to look at as well: since I now made ISCO lower and upper bound configurable, it is perhaps not logical that these parameters will get overwritten if the metric is a SphericalHorizonMetric |
||
| if (sphermetric) | ||
| { | ||
| lowerbound = sphermetric->getrLogScale() ? log(sphermetric->getHorizonRadius()) : sphermetric->getHorizonRadius(); | ||
| upperbound = sphermetric->getrLogScale() ? log(10.0 * sphermetric->getHorizonRadius()) : 10.0 * sphermetric->getHorizonRadius(); | ||
| } | ||
| else if (m_theMetric->getrLogScale()) | ||
| { | ||
| // If not a spherical horizon metric, but we are using log(r) coordinates, then set the lower bound to 0.0 | ||
| lowerbound = log(m_ISCOlowerbound); // ln(0.05) = -3.912023005428146 | ||
| upperbound = log(m_ISCOupperbound); // ln(1000.0) = 6.907755278982137 | ||
| } | ||
|
|
||
| // Perform binary search for ISCO | ||
| // Allow only 1000 iterations max | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #include <fstream> | ||
| #include <iostream> | ||
| #include <sstream> | ||
| #include "Grid.h" | ||
|
|
||
| //! A class for a 2D grid that contains the values of the necessary functions. | ||
| Grid::Grid(int N_row, int N_col) | ||
| { | ||
| this->N_row = N_row; | ||
| this->N_col = N_col; | ||
| this->data = new double[N_row * N_col]; | ||
| size = N_row * N_col; | ||
| } | ||
|
|
||
| void Grid::initialize_from_file(std::string file) | ||
| { | ||
| std::ifstream inputFile(file); | ||
|
|
||
| if (!inputFile) | ||
| { | ||
| std::cerr << "Error opening file!" << std::endl; | ||
| } | ||
|
|
||
| std::string line; | ||
| int i = 0; | ||
| int j = 0; | ||
|
|
||
| while (std::getline(inputFile, line)) | ||
| { | ||
| std::istringstream iss(line); | ||
|
|
||
| double val; | ||
| while (iss >> val) | ||
| { | ||
| data[i * N_col + j] = val; | ||
| j += 1; | ||
| } | ||
| j = 0; | ||
| i += 1; | ||
| } | ||
| std::cout << "Grid initialized from " << file << std::endl | ||
| << std::endl; | ||
|
|
||
| // close the file | ||
| inputFile.close(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include <fstream> | ||
| #include <iostream> | ||
|
|
||
| #ifndef GRID_H | ||
| #define GRID_H | ||
|
|
||
| //! A class for a 2D grid that contains the values of the necessary functions. | ||
| class Grid | ||
| { | ||
| public: | ||
| //! Number of rows in the grid | ||
| int N_row; | ||
| //! Number of columns in the grid | ||
| int N_col; | ||
| //! Pointer to the data | ||
| double *data; | ||
| //! Number of rows times the number of columns | ||
| int size; | ||
| Grid(int N_row, int N_col); | ||
|
|
||
| //! Destructor | ||
| ~Grid() { delete[] this->data; } | ||
|
|
||
| //! Overload the () operator to access the data | ||
| double &operator()(int i, int j) { return this->data[i * N_col + j]; } | ||
| //! Overload the () operator to access the data (const version) | ||
| const double &operator()(int i, int j) const { return this->data[i * N_col + j]; } | ||
|
|
||
| void initialize_from_file(std::string file); | ||
| }; | ||
|
|
||
| #endif // GRID_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these outside of .gitignore, as these are all currently in the repo. Either move to exclude or prune