Skip to content

Commit a7006cc

Browse files
committed
wip
1 parent 3f7c1bf commit a7006cc

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

examples/2024-XZhang-minichem/mini.inp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ nx2 = 16
6868
nx3 = 1
6969

7070
<hydro>
71-
gamma = 1.42
71+
Rd = 3936.04
72+
gamma = 1.4
7273
grav_acc1 = -24.79
7374
implicit_flag = 1
7475

@@ -79,18 +80,6 @@ cloud = H2O(c), H2O(p)
7980
<chemistry>
8081
microphysics_config = water_ammonia.yaml
8182

82-
<thermodynamics>
83-
Rd = 3777. # mu = 2.3175 g/mol
84-
eps1 = 8.18 8.18 8.18
85-
beta1 = 0. 24.845 24.845
86-
rcp1 = 0.15 0.33 0.33
87-
Ttriple1 = 273.16
88-
Ptriple1 = 611.7
89-
90-
sa.relax = 1.0
91-
sa.max_iter = 5
92-
sa.ftol = 1.e-2
93-
9483
<forcing>
9584
#packages = bot_heating, top_cooling
9685
#bot_heating.flux = 8.

examples/2024-XZhang-minichem/minichem.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ Real Tbot, xtra, ptra, Ttop_tau, Tbot_tau, Trabot_tau;
4747
std::string met;
4848
bool use_mini, use_mini_ic, use_tra_ic, fix_bot_tra;
4949

50-
Real p0 = 1.e5;
51-
5250
//'OH','H2','H2O','H','CO','CO2','O','CH4','C2H2','NH3','N2','HCN', 'He'
5351
std::vector<double> vmass = {17.01, 2.02, 18.02, 1.01, 28.01, 44.01, 16.,
5452
16.05, 26.04, 17.04, 28.02, 27.03, 4.};
@@ -81,7 +79,7 @@ void MeshBlock::UserWorkBeforeOutput(ParameterInput *pin) {
8179
auto temp = get_temp(pimpl->peos, w);
8280
auto pres = get_pres(w);
8381
auto chi = (get_gammad() - 1.) / get_gammad();
84-
auto theta = temp * pow(p0 / pres, chi);
82+
auto theta = temp * pow(P0 / pres, chi);
8583

8684
auto temp_a = temp.accessor<Real, 3>();
8785
auto theta_a = theta.accessor<Real, 3>();
@@ -316,20 +314,25 @@ torch::Tensor setup_moist_adiabatic_profile(std::string infile) {
316314
}
317315

318316
void MeshBlock::ProblemGenerator(ParameterInput *pin) {
317+
// auto infile = pin->GetString("problem", "config_file");
318+
// auto w = setup_moist_adiabatic_profile(infile)
319+
319320
srand(Globals::my_rank + time(0));
320321

321322
// thermodynamic constants
322323
Real gamma = pin->GetReal("hydro", "gamma");
323-
auto mud = kintera::species_weights[0];
324-
auto Rd = kintera::constants::Rgas / mud;
324+
Real Rd = pin->GetReal("hydro", "Rd");
325325
Real cp = gamma / (gamma - 1.) * Rd;
326+
std::cout << "Rd = " << Rd << ", cp = " << cp << std::endl;
326327

327328
// set up an adiabatic atmosphere
328329
int max_iter = 400, iter = 0;
329330
Real Ttol = pin->GetOrAddReal("problem", "init_Ttol", 0.01);
330331

331332
// estimate surface temperature and pressure
332333
auto x1min = pcoord->x1f(is);
334+
auto x1max = pcoord->x1f(ie + 1);
335+
333336
Real Ts = T0 - grav / cp * x1min;
334337
Real Ps = P0 * pow(Ts / T0, cp / Rd);
335338

@@ -340,17 +343,19 @@ void MeshBlock::ProblemGenerator(ParameterInput *pin) {
340343
Real x1 = pcoord->x1v(i);
341344
Real x2 = pcoord->x2v(j);
342345
Real x3 = pcoord->x3v(k);
343-
Real temp = Ts - grav * x1 / cp;
344-
phydro->w(IPR, k, j, i) = p0 * pow(temp / Ts, cp / Rd);
346+
Real temp = T0 - grav * x1 / cp;
347+
phydro->w(IPR, k, j, i) = P0 * pow(temp / T0, cp / Rd);
345348
phydro->w(IDN, k, j, i) = phydro->w(IPR, k, j, i) / (Rd * temp);
346-
phydro->w(IVX, k, j, i) = phydro->w(IVY, k, j, i) = 0.;
349+
phydro->w(IVX, k, j, i) = 0.001 * (1. * rand() / RAND_MAX - 0.5);
347350
}
348351

349352
auto temp = get_temp(pimpl->peos, phydro->w);
350353
auto temp_a = temp.accessor<Real, 3>();
351354

352355
Tbot = temp_a[ks][js][is];
353356

357+
std::cout << "ptra = " << ptra << " Pa" << std::endl;
358+
354359
if (NCHEM > 0) {
355360
if (use_mini_ic) {
356361
// minichem initialize conserved variables

0 commit comments

Comments
 (0)