Skip to content

Commit 473650c

Browse files
committed
Test with RH jump conditions
1 parent b76f755 commit 473650c

1 file changed

Lines changed: 45 additions & 21 deletions

File tree

src/pgen/cloud.cpp

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <basic_types.hpp>
1818
#include <iomanip>
1919
#include <ios>
20+
#include <ostream>
2021
#include <parthenon/driver.hpp>
2122
#include <parthenon/package.hpp>
2223
#include <random>
@@ -29,7 +30,7 @@
2930
namespace cloud {
3031
using namespace parthenon::driver::prelude;
3132

32-
Real rho_wind, mom_wind, rhoe_wind, r_cloud, rho_cloud;
33+
Real rho_wind, mom_wind, rhoe_wind, r_cloud, rho_cloud, rho_amb, rhoe_amb;
3334
Real Bx = 0.0;
3435
Real By = 0.0;
3536
Real Bz = 0.0;
@@ -52,18 +53,37 @@ void InitUserMeshData(Mesh *mesh, ParameterInput *pin) {
5253

5354
r_cloud = pin->GetReal("problem/cloud", "r0_cgs") / units.code_length_cgs();
5455
rho_cloud = pin->GetReal("problem/cloud", "rho_cloud_cgs") / units.code_density_cgs();
55-
rho_wind = pin->GetReal("problem/cloud", "rho_wind_cgs") / units.code_density_cgs();
56-
auto T_wind = pin->GetReal("problem/cloud", "T_wind_cgs");
57-
auto v_wind = pin->GetReal("problem/cloud", "v_wind_cgs") /
58-
(units.code_length_cgs() / units.code_time_cgs());
56+
rho_amb = pin->GetReal("problem/cloud", "rho_amb_cgs") / units.code_density_cgs();
57+
auto T_amb = pin->GetReal("problem/cloud", "T_amb_cgs");
5958

6059
// mu_mh_gm1_by_k_B is already in code units
61-
rhoe_wind = T_wind * rho_wind / mbar_over_kb / gm1;
60+
rhoe_amb = T_amb * rho_amb / mbar_over_kb / gm1;
61+
const auto pressure =
62+
gm1 * rhoe_amb; // one value for entire domain given initial pressure equil.
63+
64+
auto mach = pin->GetReal("problem/cloud", "mach_wind");
65+
66+
// Uses Rankine Hugoniot relations for adiabatic gas to initialize problem
67+
Real jump1 = (gamma + 1.0) / (gm1 + 2.0 / (mach * mach));
68+
Real jump2 = (2.0 * gamma * mach * mach - gm1) / (gamma + 1.0);
69+
Real jump3 = 2.0 * (1.0 - 1.0 / (mach * mach)) / (gamma + 1.0);
70+
71+
rho_wind = rho_amb * jump1;
72+
const auto pressure_wind = pressure * jump2;
73+
rhoe_wind = pressure_wind / gm1;
74+
const auto T_wind = pressure_wind / rho_wind * mbar_over_kb;
75+
76+
const auto v_wind = jump3 * mach * std::sqrt(gamma * pressure / rho_amb);
77+
// const auto a_r = std::sqrt(gamma * pressure / rho_amb);
78+
// const auto S_3 =
79+
// a_r * std::sqrt(((gamma + 1.0) / (2 * gamma)) * (pressure_wind / pressure) +
80+
// gm1 / (2 * gamma));
81+
// const auto v_wind = (1.0 - rho_amb / rho_wind) * S_3;
82+
mom_wind = rho_wind * v_wind;
83+
6284
const auto c_s_wind = std::sqrt(gamma * gm1 * rhoe_wind / rho_wind);
6385
const auto chi_0 = rho_cloud / rho_wind; // cloud to wind density ratio
6486
const auto t_cc = r_cloud * std::sqrt(chi_0) / v_wind; // cloud crushting time (code)
65-
const auto pressure =
66-
gm1 * rhoe_wind; // one value for entire domain given initial pressure equil.
6787

6888
const auto T_cloud = pressure / rho_cloud * mbar_over_kb;
6989

@@ -107,6 +127,10 @@ void InitUserMeshData(Mesh *mesh, ParameterInput *pin) {
107127
msg << "## Uniform pressure (code units): " << pressure << std::endl;
108128
msg << "## Wind sonic Mach: " << v_wind / c_s_wind << std::endl;
109129
msg << "## Cloud crushing time: " << t_cc / units.myr() << " Myr" << std::endl;
130+
// msg << "shock mach in abmient meidum: " << S_3 / sqrt(gamma * pressure / rho_amb)
131+
// << std::endl;
132+
msg << "wind mach in abmient meidum: " << v_wind / sqrt(gamma * pressure / rho_amb)
133+
<< std::endl;
110134

111135
// (potentially) rescale global times only at the beginning of a simulation
112136
auto rescale_code_time_to_tcc =
@@ -162,7 +186,11 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
162186
"but `hydro/fluid` is not supporting MHD.");
163187
}
164188

189+
Units units(pin);
165190
auto steepness = pin->GetOrAddReal("problem/cloud", "cloud_steepness", 10);
191+
const auto r_cloud_cgs = pin->GetReal("problem/cloud", "r0_cgs");
192+
auto xshock = pin->GetOrAddReal("problem/cloud", "xshock_cgs", -3 * r_cloud_cgs) /
193+
units.code_length_cgs();
166194

167195
// initialize conserved variables
168196
auto &mbd = pmb->meshblock_data.Get();
@@ -180,22 +208,18 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
180208
const Real z = coords.Xc<3>(k);
181209
const Real rad = std::sqrt(SQR(x) + SQR(y) + SQR(z));
182210

183-
Real rho = rho_wind + 0.5 * (rho_cloud - rho_wind) *
184-
(1.0 - std::tanh(steepness * (rad / r_cloud - 1.0)));
185-
186-
Real mom;
187-
// Factor 1.3 as used in Grønnow, Tepper-García, & Bland-Hawthorn 2018,
188-
// i.e., outside the cloud boundary region (for steepness 10)
189-
if (rad > 1.3 * r_cloud) {
190-
mom = mom_wind;
211+
Real rho;
212+
// Set background
213+
if (y < xshock) {
214+
rho = rho_wind;
215+
u(IM2, k, j, i) = mom_wind;
216+
u(IEN, k, j, i) = rhoe_wind + 0.5 * mom_wind * mom_wind / rho_wind;
191217
} else {
192-
mom = 0.0;
218+
rho = rho_amb + 0.5 * (rho_cloud - rho_amb) *
219+
(1.0 - std::tanh(steepness * (rad / r_cloud - 1.0)));
220+
u(IEN, k, j, i) = rhoe_amb;
193221
}
194-
195222
u(IDN, k, j, i) = rho;
196-
u(IM2, k, j, i) = mom;
197-
// Can use rhoe_wind here as simulation is setup in pressure equil.
198-
u(IEN, k, j, i) = rhoe_wind + 0.5 * mom * mom / rho;
199223

200224
if (mhd_enabled) {
201225
u(IB1, k, j, i) = Bx;

0 commit comments

Comments
 (0)