Skip to content
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

fix xrb_layered trailing whitespace #452

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Exec/science/xrb_layered/MaestroInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Maestro::InitLevelData(const int lev, [[maybe_unused]] const Real time, con
const auto dx = geom[lev].CellSizeArray();

if (perturb_model) {

// Generate random seed (or get from input), and RNG
int seed = 0;
if (problem_rp::pert_seed != -1) {
Expand All @@ -49,14 +49,14 @@ void Maestro::InitLevelData(const int lev, [[maybe_unused]] const Real time, con
seed = r();
}
std::default_random_engine generator(seed);

// Gaussian distribution
std::normal_distribution<double> noise(1.0, 0.001); // mean of 1, std dev 10^-3

// Loop through data and perturb
const auto lo = amrex::lbound(tileBox);
const auto hi = amrex::ubound(tileBox);

// Why for and not parallelfor?
// Because RNG's are not thread safe. so if we wanted to use ParallelFor, we would have to create a new RNG inside
// every iteration, but that loses the ability to keep a fixed seed and be fully reproducible.. maybe that wouldn't be so bad
Expand All @@ -66,28 +66,28 @@ void Maestro::InitLevelData(const int lev, [[maybe_unused]] const Real time, con
for (int j = lo.y; j<= hi.y; j++) {
for (int i = lo.x; i<= hi.x; i++) {
int r = AMREX_SPACEDIM == 2 ? j : k; // j if 2D, k if 3D

Real t0 = s0_arr(lev, r, Temp);
Real temp = t0 * noise(generator);
Real temp = t0 * noise(generator);
Real dens = s0_arr(lev, r, Rho); // no change

// Create new eos object based on these modified values
eos_t eos_state;
eos_state.T = temp;
eos_state.p = p0_arr(lev, r);
eos_state.rho = dens;
for (auto comp = 0; comp < NumSpec; comp++) {
eos_state.xn[comp] =
eos_state.xn[comp] =
s0_arr(lev, r, FirstSpec + comp) / s0_arr(lev, r, Rho);
}

auto eos_input_flag = eos_input_tp; // temperature & pressure eos
eos(eos_input_flag, eos_state);
scal(i, j, k, Rho) = eos_state.rho;
scal(i, j, k, RhoH) = eos_state.rho * eos_state.h; // re-compute enthalpy
scal(i, j, k, Temp) = eos_state.T;
for (auto comp=0; comp < NumSpec; comp++) {
scal(i, j, k, FirstSpec + comp) =
scal(i, j, k, FirstSpec + comp) =
eos_state.rho * eos_state.xn[comp];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Exec/science/xrb_layered/MaestroTagging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ void Maestro::StateError(TagBoxArray& tags, const MultiFab& state_mf,
tag_array_p[lev + max_lev * r] = TagBox::SET;
}
});
}
}
}
54 changes: 27 additions & 27 deletions Exec/science/xrb_layered/create_initial_model/toy_atm/init_1d.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
// (T_star) representing the NS, a hyperbolic tangent rise to a
// peak temperature (T_base) representing the base of an accreted
// layer at r=H_star, an isentropic profile representing the convective
// region at ignition, then a radiative profile from r=H_rad.
// Below, three different power-laws set the temperature profile
// region at ignition, then a radiative profile from r=H_rad.
// Below, three different power-laws set the temperature profile
// T = T0*(y/y0)^del
// where y is the column depth (=pressure/gravity) and, del is the power-law
// index, and T0 and y0 are the values at the beginning of a given region.
// Those regions have different physics: 1) an adiabatic zone
// where helium is burning and generating convection, 2) a stable region
// where nothing is burning, 3) a stable region with hot CNO burning.

// The composition transitions from pure ash, to helium and CNO, to a solar
// The composition transitions from pure ash, to helium and CNO, to a solar
// mixture including hydrogen, with initial hydrogen fraction X0 and CNO fraction
// Zcno (inputs file). The CNO is split between o14 and o15 with ratio
// determined by their beta decay times (70.621/122.266). Because hot CNO burns
Expand All @@ -40,23 +40,23 @@
// | . . +__
// | . . . `--- T ~ y^del_2
// | . . . `---+
// | . . . .`-
// | . . . .`-
// | . . . . `- T ~ y^del_3
// | . . . . `-
// | . . . . `-
// +-----+---+-----+---------------------> r
// | \ /
// | delta
// |< H_star>|
// |-----<y_2>----|
// |----------<y_3>---------|
// |-----<y_2>----|
// |----------<y_3>---------|
//
// The composition profile is:
//
// X
// ^
// | star | reg 1 | reg 2 | region 3
// 1.0 +--------*----------
// | star | reg 1 | reg 2 | region 3
// 1.0 +--------*----------
// | ash . \
// | . \ +--------- X0 (hydrogen)
// | . \ /
Expand All @@ -66,8 +66,8 @@
// | . / +--------- 1-X0-Zcno (helium)
// | .----------/--------------- Zcno (o14/o15)
// 0.0 +--------+---------+-----------------> r
// |<H_star>|
// |------<y_d>------|
// |<H_star>|
// |------<y_d>------|
// |
//
// The transition from ash to fuel is a hyperbolic tangent, parametrized
Expand Down Expand Up @@ -140,7 +140,7 @@ AMREX_INLINE void init_1d()
}
if (std::abs(sum) - 1.0_rt > NumSpec * smallx) {
amrex::Error("ERROR: fuel mass fractions don't sum to 1");
}
}



Expand Down Expand Up @@ -196,7 +196,7 @@ AMREX_INLINE void init_1d()
if (error < err_min) {
err_min = error;
n_best = n;
}
}
}

Real dens_base = (1.3 + n_best*0.001)*1.e6;
Expand All @@ -217,10 +217,10 @@ AMREX_INLINE void init_1d()

// Composition
for (int n = 0; n < NumSpec; ++n) {
model_hse(i, ispec+n) = xn_star[n] +
model_hse(i, ispec+n) = xn_star[n] +
0.5_rt * (xn_base[n] - xn_star[n]) *
(1.0_rt + std::tanh((xzn_hse(i) - (problem_rp::xmin + problem_rp::H_star - problem_rp::delta) + problem_rp::delta) / problem_rp::delta));
}
(1.0_rt + std::tanh((xzn_hse(i) - (problem_rp::xmin + problem_rp::H_star - problem_rp::delta) + problem_rp::delta) / problem_rp::delta));
}

// Temperature
model_hse(i, itemp) = problem_rp::T_star + 0.5_rt * (problem_rp::T_base - problem_rp::T_star) *
Expand All @@ -241,7 +241,7 @@ AMREX_INLINE void init_1d()
for (int i = 0; i < problem_rp::nx; ++i) {
if (model_hse(i, itemp) > 0.9995 * problem_rp::T_base) {
index_base = i+1;
break;
break;
}
}
} else {
Expand Down Expand Up @@ -348,9 +348,9 @@ AMREX_INLINE void init_1d()

// set to isothermal if hit threshold
if (temp_zone < problem_rp::T_lo) {
temp_zone = problem_rp::T_lo;
temp_zone = problem_rp::T_lo;
}

// std::cout << "T=" << temp_zone << std::endl;
}

Expand Down Expand Up @@ -400,7 +400,7 @@ AMREX_INLINE void init_1d()

// call the EOS one more time for this zone and then go on to the next
// (t, rho) -> (p)

eos_state.T = temp_zone;
eos_state.rho = dens_zone;
for (int n = 0; n < NumSpec; ++n) {
Expand Down Expand Up @@ -447,7 +447,7 @@ AMREX_INLINE void init_1d()


// integrate down -- using the temperature profile defined above

for (int i = index_base-1; i >= 0; --i) {

Real delx = xzn_hse(i+1) - xzn_hse(i);
Expand All @@ -459,7 +459,7 @@ AMREX_INLINE void init_1d()
}

// use our previous initial guess for density

dens_zone = model_hse(i+1, idens);


Expand All @@ -477,7 +477,7 @@ AMREX_INLINE void init_1d()
// find the density and pressure that are consistent

// HSE differencing

p_want = model_hse(i+1, ipres) -
delx * 0.5_rt * (dens_zone + model_hse(i+1, idens)) * problem_rp::g_const;

Expand Down Expand Up @@ -541,7 +541,7 @@ AMREX_INLINE void init_1d()

}


// auto deltastr = num_to_unitstring(delta);
auto dxstr = num_to_unitstring(dCoord);

Expand Down Expand Up @@ -576,7 +576,7 @@ AMREX_INLINE void init_1d()

of.close();

std::cout << "Saved model to " << outfile << std::endl;
std::cout << "Saved model to " << outfile << std::endl;

// some metadata
of << "# generated by toy_atm_layered" << std::endl;
Expand All @@ -600,11 +600,11 @@ AMREX_INLINE void init_1d()

of2 << std::setprecision(12) << std::setw(20) << xzn_hse(i) << std::endl;
of2 << std::setprecision(12) << std::setw(20) << eos_state.s << std::endl;
of2 << std::setprecision(12) << std::setw(20) << eos_state.cs << std::endl;
of2 << std::setprecision(12) << std::setw(20) << eos_state.cs << std::endl;
}

// compute the maximum HSE error

Real max_hse_error = -1.e30;

for (int i = 1; i < problem_rp::nx-1; ++i) {
Expand All @@ -620,5 +620,5 @@ AMREX_INLINE void init_1d()
}

std::cout << "maximum HSE error = " << max_hse_error << std::endl;

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ main (int argc,
// std::cout << "inputs file is " << inputs_name << std::endl;
}
} else {
std::cout << "No input file. Using defaults" << inputs_name << std::endl;
std::cout << "No input file. Using defaults" << inputs_name << std::endl;
}


Expand Down
6 changes: 3 additions & 3 deletions Exec/science/xrb_layered/plotfile_derive/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void main_main()
varnames = pf.varNames();

// find variable indices
// We want:
// We want:
// density, temperature, pressure, species
// vertical velocity, temperature perturbation
// we will assume here that the species are contiguous, so we will find
Expand Down Expand Up @@ -476,10 +476,10 @@ void main_main()
// Fluxes

// Convective heat flux : "Fconv_dT"
ga(i,j,k,4) = rho * cp * vely * delT;
ga(i,j,k,4) = rho * cp * vely * delT;

// Alternate version that should be equivalent : "Fconv_T"
// because <vdT> = <v(T-T0)> = <vT> - <v>T0 = <vT> (the vertical velocity averages to zero)
// because <vdT> = <v(T-T0)> = <vT> - <v>T0 = <vT> (the vertical velocity averages to zero)
ga(i,j,k,5) = rho * cp * vely * temp;

// MLT heat flux in the efficient regime : "Fconv_mlt"
Expand Down
4 changes: 2 additions & 2 deletions Exec/science/xrb_layered/scripts/chainslurm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ fi
firstcount=1

if [ $oldjob -eq "-1" ]
then
then
echo chaining $numjobs jobs

echo starting job 1 with no dependency
aout=`sbatch --parsable ${script}`
echo " " jobid: $aout
Expand Down
Loading