6 #include <application/application.hpp>
9 #include <athena/athena.hpp>
10 #include <athena/parameter_input.hpp>
28 snprintf(entry,
sizeof(entry),
"%s.re",
name.c_str());
29 re =
km2m(pin->GetOrAddReal(
"astronomy", entry, 0.));
31 snprintf(entry,
sizeof(entry),
"%s.rp",
name.c_str());
32 rp =
km2m(pin->GetOrAddReal(
"astronomy", entry,
re));
34 snprintf(entry,
sizeof(entry),
"%s.obliq",
name.c_str());
35 obliq =
deg2rad(pin->GetOrAddReal(
"astronomy", entry, 0.));
37 snprintf(entry,
sizeof(entry),
"%s.spinp",
name.c_str());
38 spinp =
day2sec(pin->GetOrAddReal(
"astronomy", entry, 0.));
40 snprintf(entry,
sizeof(entry),
"%s.orbit_a",
name.c_str());
41 orbit_a =
au2m(pin->GetOrAddReal(
"astronomy", entry, 0.));
43 snprintf(entry,
sizeof(entry),
"%s.orbit_e",
name.c_str());
44 orbit_e = pin->GetOrAddReal(
"astronomy", entry, 0.);
46 snprintf(entry,
sizeof(entry),
"%s.orbit_i",
name.c_str());
49 snprintf(entry,
sizeof(entry),
"%s.orbit_p",
name.c_str());
52 snprintf(entry,
sizeof(entry),
"%s.equinox",
name.c_str());
53 equinox = pin->GetOrAddReal(
"astronomy", entry, 0.);
55 snprintf(entry,
sizeof(entry),
"%s.grav_eq",
name.c_str());
56 grav_eq = pin->GetOrAddReal(
"astronomy", entry, 0.);
60 : parent(nullptr), spec_(nullptr), il_(-1) {
61 Application::Logger app(
"astro");
62 app->Log(
"Initialize CelestrialBody");
64 std::stringstream msg;
65 name = pin->GetOrAddString(
"astronomy",
"planet",
"unknown");
68 if (pin->DoesParameterExist(
"astronomy",
name +
".parent")) {
69 std::string parent_name = pin->GetString(
"astronomy",
name +
".parent");
75 if (pin->DoesParameterExist(
"astronomy",
name +
".spec_file")) {
76 std::string sfile = pin->GetString(
"astronomy",
name +
".spec_file");
78 app->Error(
"Cannot open spectral file " + sfile);
89 : parent(nullptr), name(myname), spec_(nullptr), il_(-1) {
90 Application::Logger app(
"astro");
91 app->Log(
"Initialize CelestrialBody");
93 std::stringstream msg;
96 if (pin->DoesParameterExist(
"astronomy",
name +
".parent")) {
97 std::string parent_name = pin->GetString(
"astronomy",
name +
".parent");
103 if (pin->DoesParameterExist(
"astronomy",
name +
".spec_file")) {
104 std::string sfile = pin->GetString(
"astronomy",
name +
".spec_file");
106 app->Error(
"Cannot open spectral file " + sfile);
117 Application::Logger app(
"astro");
118 app->Log(
"Destroy CelestrialBody");
128 nspec_ = spectrum.GetDim2();
132 for (
int i = 0; i <
nspec_; ++i) {
133 spec_[i].
x = spectrum(i, 0);
134 spec_[i].
y = spectrum(i, 1);
143 Real lat = M_PI / 2. - colat;
144 if (
spinp == 0. &&
orbit_p == 0.) dir.
mu = cos(-lon + M_PI) * cos(lat);
146 dir.
mu = cos((
time * 2. * M_PI * (-1. /
orbit_p)) - lon + M_PI) * cos(lat);
148 dir.
mu = cos((
time * 2. * M_PI * (1. /
spinp)) - lon + M_PI) * cos(lat);
164 return flux / (dist_au * dist_au);
175 for (
int i = il; i < iu; ++i) {
179 return flux / (dist_au * dist_au);
184 Real orbit_c = orbit_b * orbit_b /
orbit_a;
Real ParentInsolationFlux(Real wav, Real dist_au)
Real ParentDistanceInAu(Real time)
void ReadSpectraFile(std::string sfile)
void readCelestrialData(ParameterInput *pin, std::string myname)
Direction ParentZenithAngle(Real time, Real colat, Real lon)
CelestrialBody(ParameterInput *pin)
double deg2rad(double phi)
bool FileExists(std::string fname)
test file existance
void ReadDataTable(AthenaArray< Real > *data, std::string fname, char c=' ')
int find_place_in_table(int n, struct float_triplet *table, double x, double *dx, int il)
double splint(double xx, struct float_triplet *table, double dx)
void spline(int n, struct float_triplet *table, double y1_bot, double y1_top)