Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
chengcli committed Jul 21, 2024
1 parent 68a0781 commit 021ade8
Show file tree
Hide file tree
Showing 32 changed files with 1,097 additions and 246 deletions.
4 changes: 2 additions & 2 deletions examples/2018-Li-harp/giants_re.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
}
}

Expand Down
8 changes: 5 additions & 3 deletions examples/2019-Li-snap/bryan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
#include <climath/root.hpp>

// snap
#include <snap/thermodynamics/atm_thermodynamics.hpp>
#include <snap/stride_iterator.hpp>
#include <snap/thermodynamics/thermodynamics.hpp>

// special includes
#include "bryan_vapor_functions.hpp"
Expand All @@ -57,12 +58,13 @@ void MeshBlock::InitUserMeshBlockData(ParameterInput *pin) {

void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
auto pthermo = Thermodynamics::GetInstance();
auto &w = phydro->w;

for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, p0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), p0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
4 changes: 2 additions & 2 deletions examples/2019-Li-snap/jvortex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
5 changes: 3 additions & 2 deletions examples/2019-Li-snap/robert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ void MeshBlock::InitUserMeshBlockData(ParameterInput *pin) {
// Set temperature and potential temperature.
void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
auto pthermo = Thermodynamics::GetInstance();
auto &w = phydro->w;

Real gamma = peos->GetGamma();
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, p0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), p0);
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/2019-Li-snap/sedimentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
17 changes: 9 additions & 8 deletions examples/2019-Li-snap/straka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void MeshBlock::InitUserMeshBlockData(ParameterInput *pin) {
// access all physics in the simulation.
void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
auto pthermo = Thermodynamics::GetInstance();
auto &w = phydro->w;

// Loop over the grids. <code>js,je,is,ie</code> are members of the MeshBlock
// class. They are integer values representing the start index and the end
Expand All @@ -101,8 +102,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
// <code>phydro</code> is a pointer to the Hydro class, which has a member
// <code>w</code> that stores density, pressure, and velocities at each
// grid.
user_out_var(0, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, j, i) = pthermo->PotentialTemp(this, p0, k, j, i);
user_out_var(0, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, j, i) = pthermo->PotentialTemp(w.at(k, j, i), p0);
}
}

Expand Down Expand Up @@ -139,16 +140,16 @@ void Diffusion(MeshBlock *pmb, Real const time, Real const dt,
// Similar to what we have done in MeshBlock::UserWorkBeforeOutput, we use
// the Thermodynamics class to calculate temperature and potential
// temperature.
Real temp = pthermo->GetTemp(pmb, pmb->ks, j, i);
Real theta = pthermo->PotentialTemp(pmb, p0, pmb->ks, j, i);
Real temp = pthermo->GetTemp(w.at(pmb->ks, j, i));
Real theta = pthermo->PotentialTemp(w.at(pmb->ks, j, i), p0);

// The thermal diffusion is applied to the potential temperature field,
// which is not exactly correct. But this is the setting of the test
// program.
Real theta_ip1_j = pthermo->PotentialTemp(pmb, p0, k, j + 1, i);
Real theta_im1_j = pthermo->PotentialTemp(pmb, p0, k, j - 1, i);
Real theta_i_jp1 = pthermo->PotentialTemp(pmb, p0, k, j, i + 1);
Real theta_i_jm1 = pthermo->PotentialTemp(pmb, p0, k, j, i - 1);
Real theta_ip1_j = pthermo->PotentialTemp(w.at(k, j + 1, i), p0);
Real theta_im1_j = pthermo->PotentialTemp(w.at(k, j - 1, i), p0);
Real theta_i_jp1 = pthermo->PotentialTemp(w.at(k, j, i + 1), p0);
Real theta_i_jm1 = pthermo->PotentialTemp(w.at(k, j, i - 1), p0);

// Add viscous dissipation to the velocities. Now you encounter another
// variable called <code>u</code>. <code>u</code> stands for `conserved
Expand Down
4 changes: 2 additions & 2 deletions examples/2023-Chen-exo3/test_adiabat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, Ps, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), Ps);
// msv
user_out_var(2, k, j, i) =
pthermo->MoistStaticEnergy(this, grav * pcoord->x1v(i), k, j, i);
Expand Down
8 changes: 4 additions & 4 deletions examples/2023-Li-saturn-vla/saturn_radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down Expand Up @@ -286,7 +286,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
if (phydro->w(IPR, k, j, i) > 1.E5) continue;
Real temp_ad = pthermo->GetTemp(this, k, j, i);
Real temp_ad = pthermo->GetTemp(w.at(k, j, i));
// pa -> bar
Real temp_real = Jupiter::get_temp_fletcher16_cirs(
glat, phydro->w(IPR, k, j, i) / 1.E5);
Expand All @@ -304,7 +304,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
Real temp = pthermo->GetTemp(this, k, j, i);
Real temp = pthermo->GetTemp(w.at(k, j, i));
Real pH2S = xH2S * phydro->w(IPR, k, j, i);
Real pNa = xNa * phydro->w(IPR, k, j, i);
Real svp = sat_vapor_p_Na_H2S_Visscher(temp, pH2S);
Expand Down
8 changes: 4 additions & 4 deletions examples/2023-Li-uranus/uranus_mwr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down Expand Up @@ -286,7 +286,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
if (phydro->w(IPR, k, j, i) > 1.E5) continue;
Real temp_ad = pthermo->GetTemp(this, k, j, i);
Real temp_ad = pthermo->GetTemp(w.at(k, j, i));
// pa -> bar
Real temp_real = Jupiter::get_temp_fletcher16_cirs(
glat, phydro->w(IPR, k, j, i) / 1.E5);
Expand All @@ -304,7 +304,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
Real temp = pthermo->GetTemp(this, k, j, i);
Real temp = pthermo->GetTemp(w.at(k, j, i));
Real pH2S = phydro->w(iH2S, k, j, i) * phydro->w(IPR, k, j, i);
Real pNa = xNa * phydro->w(IPR, k, j, i);
Real svp = sat_vapor_p_Na_H2S_Visscher(temp, pH2S);
Expand Down
4 changes: 2 additions & 2 deletions examples/2024-CLi-RCEMIP/rcemip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
4 changes: 2 additions & 2 deletions examples/2024-CMetz-amars/amars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
4 changes: 2 additions & 2 deletions examples/2024-CMetz-amars/amarsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
4 changes: 2 additions & 2 deletions examples/2024-FDing-jupiter-rt/jupiter1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
8 changes: 4 additions & 4 deletions examples/2024-JHu-juno-mwr/juno_mwr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down Expand Up @@ -274,7 +274,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
if (phydro->w(IPR, k, j, i) > 1.E5) continue;
Real temp_ad = pthermo->GetTemp(this, k, j, i);
Real temp_ad = pthermo->GetTemp(w.at(k, j, i));
// pa -> bar
Real temp_real = Jupiter::get_temp_fletcher16_cirs(
glat, phydro->w(IPR, k, j, i) / 1.E5);
Expand All @@ -292,7 +292,7 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
Real temp = pthermo->GetTemp(this, k, j, i);
Real temp = pthermo->GetTemp(w.at(k, j, i));
Real pH2S = xH2S * phydro->w(IPR, k, j, i);
Real pNa = xNa * phydro->w(IPR, k, j, i);
Real svp = sat_vapor_p_Na_H2S_Visscher(temp, pH2S);
Expand Down
4 changes: 2 additions & 2 deletions examples/2024-Li-plume/plume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, p0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), p0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
7 changes: 3 additions & 4 deletions examples/2024-XZhang-cloud-rt/hjupiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

// canoe
#include <air_parcel.hpp>
#include <athena/coordinates/coordinates.hpp>
#include <configure.hpp>
#include <impl.hpp>
#include <athena/coordinates/coordinates.hpp>

// climath
#include <climath/core.h>
Expand Down Expand Up @@ -60,8 +60,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j) {
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, Ps, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), Ps);

pexo3->GetLatLon(&lat, &lon, k, j, i);
pexo3->GetUV(&U, &V, phydro->w(IVY, k, j, i), phydro->w(IVZ, k, j, i),
Expand Down Expand Up @@ -176,6 +176,5 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
AirParcelHelper::distribute_to_conserved(this, k, j, i, air);
pthermo->Extrapolate(&air, pcoord->dx1f(i), "isothermal", grav);
}

}
}
4 changes: 2 additions & 2 deletions examples/2024-XZhang-cloud-rt/hywater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
for (int k = ks; k <= ke; ++k)
for (int j = js; j <= je; ++j)
for (int i = is; i <= ie; ++i) {
user_out_var(0, k, j, i) = pthermo->GetTemp(this, k, j, i);
user_out_var(1, k, j, i) = pthermo->PotentialTemp(this, P0, k, j, i);
user_out_var(0, k, j, i) = pthermo->GetTemp(w.at(k, j, i));
user_out_var(1, k, j, i) = pthermo->PotentialTemp(w.at(k, j, i), P0);
// theta_v
user_out_var(2, k, j, i) =
user_out_var(1, k, j, i) * pthermo->RovRd(this, k, j, i);
Expand Down
Loading

0 comments on commit 021ade8

Please sign in to comment.