Skip to content

Commit

Permalink
add derived plasma_beta field
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWibking committed Oct 10, 2024
1 parent abc14ad commit 53876bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inputs/precipitator_mhd_lowres.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dt = 50.0 # time increment between outputs

<parthenon/output2>
file_type = hdf5 # HDF5 data dump
variables = prim, drho_over_rho, dP_over_P, dK_over_K, dT_over_T, entropy, temperature, tcool_over_tff, dv_x, dv_y, dv_z
variables = prim, drho_over_rho, dP_over_P, dK_over_K, dT_over_T, entropy, temperature, tcool_over_tff, plasma_beta, dv_x, dv_y, dv_z
dt = 50.0 # Time increment between outputs
id = prim # Name to append to output

Expand Down
12 changes: 12 additions & 0 deletions src/pgen/precipitator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ void ProblemInitPackageData(ParameterInput *pin, parthenon::StateDescriptor *pkg
m = Metadata({Metadata::Cell, Metadata::OneCopy}, std::vector<int>({1}));
pkg->AddField("tcool_over_tff", m);

// add plasma beta field
m = Metadata({Metadata::Cell, Metadata::OneCopy}, std::vector<int>({1}));
pkg->AddField("plasma_beta", m);

// add \delta \rho / \bar \rho field
m = Metadata({Metadata::Cell, Metadata::OneCopy}, std::vector<int>({1}));
pkg->AddField("drho_over_rho", m);
Expand Down Expand Up @@ -1223,6 +1227,7 @@ void UserMeshWorkBeforeOutput(Mesh *mesh, ParameterInput *pin,
auto &entropy = data->Get("entropy").data;
auto &temperature = data->Get("temperature").data;
auto &mach_sonic = data->Get("mach_sonic").data;
auto &plasma_beta = data->Get("plasma_beta").data;

auto &drho = data->Get("drho_over_rho").data;
auto &dP = data->Get("dP_over_P").data;
Expand Down Expand Up @@ -1270,6 +1275,12 @@ void UserMeshWorkBeforeOutput(Mesh *mesh, ParameterInput *pin,
const Real T = P / (kboltz * rho / mmw);
const Real c_s = std::sqrt(gam * P / rho); // ideal gas EOS

const Real bx = prim(IB1, k, j, i);
const Real by = prim(IB2, k, j, i);
const Real bz = prim(IB3, k, j, i);
const Real P_mag = 0.5 * (SQR(bx) + SQR(by) + SQR(bz));
const Real beta = P_mag / P;

const Real v1 = prim(IV1, k, j, i);
const Real v2 = prim(IV2, k, j, i);
const Real v3 = prim(IV3, k, j, i);
Expand All @@ -1286,6 +1297,7 @@ void UserMeshWorkBeforeOutput(Mesh *mesh, ParameterInput *pin,
entropy(k, j, i) = K;
temperature(k, j, i) = T;
mach_sonic(k, j, i) = M_s;
plasma_beta(k, j, i) = beta;
dv_x(k, j, i) = dv1 * velocity_unit * 1.0e-5; // km/s
dv_y(k, j, i) = dv2 * velocity_unit * 1.0e-5; // km/s
dv_z(k, j, i) = dv3 * velocity_unit * 1.0e-5; // km/s
Expand Down

0 comments on commit 53876bb

Please sign in to comment.