Skip to content

Commit

Permalink
Merge pull request #4 from lanl/brryan/units
Browse files Browse the repository at this point in the history
Units
  • Loading branch information
brryan authored Dec 12, 2024
2 parents c4ecc92 + 3e3f6cd commit 8a2fd66
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
1 change: 0 additions & 1 deletion env/bash
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,5 @@ function build_jaybenne {
make -j
make_status=$?

echo "${ABS_BUILD_DIR}"
return $make_status
}
36 changes: 31 additions & 5 deletions src/mcblock/mcblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,36 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
pkg->AddParam<>("eos_h", eos_h);
pkg->AddParam<>("eos_d", eos_h.GetOnDevice());

// Units (conversion factors from code to CGS)
const Real time_scale = pin->GetOrAddReal("mcblock", "time_scale", 1.);
const Real mass_scale = pin->GetOrAddReal("mcblock", "mass_scale", 1.);
const Real length_scale = pin->GetOrAddReal("mcblock", "length_scale", 1.);
const Real temperature_scale = pin->GetOrAddReal("mcblock", "temperature_scale", 1.);
pkg->AddParam<>("time_scale", time_scale);
pkg->AddParam<>("mass_scale", mass_scale);
pkg->AddParam<>("length_scale", length_scale);
pkg->AddParam<>("temperature_scale", temperature_scale);

// Absorption opacity model
OpacityModel opacity_model;
Opacity opacity;
std::string opacity_model_name = pin->GetString("mcblock", "opacity_model");
if (opacity_model_name == "none") {
opacity_model = OpacityModel::none;
opacity = singularity::photons::Gray(0.0);
opacity = singularity::photons::NonCGSUnits<singularity::photons::Gray>(
singularity::photons::Gray(0.0), time_scale, mass_scale, length_scale,
temperature_scale);
} else if (opacity_model_name == "constant") {
opacity_model = OpacityModel::constant;
Real kappa = pin->GetReal("mcblock", "opacity_constant_value");
opacity = singularity::photons::Gray(kappa);
opacity = singularity::photons::NonCGSUnits<singularity::photons::Gray>(
singularity::photons::Gray(kappa), time_scale, mass_scale, length_scale,
temperature_scale);
} else if (opacity_model_name == "ep_bremss") {
opacity_model = OpacityModel::epbremss;
opacity = singularity::photons::NonCGSUnits<singularity::photons::EPBremss>(
singularity::photons::EPBremss(), time_scale, mass_scale, length_scale,
temperature_scale);
} else {
// nothing else supported for now
PARTHENON_FAIL("Only none or constant opacity models supported!");
Expand All @@ -100,18 +119,25 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
pkg->AddParam<>("opacity_h", opacity);

// Scattering opacity model
// TODO(BRR) Remove apm with switch in singularity-opac to cm^2/g opacities?
const Real apm =
pin->GetOrAddReal("mcblock", "apm", 1.); // Average particle mass (code units)
pkg->AddParam<>("apm", apm);
ScatteringModel scattering_model;
Scattering scattering;
std::string scattering_model_name =
pin->GetOrAddString("mcblock", "scattering_model", "none");
if (scattering_model_name == "none") {
scattering_model = ScatteringModel::none;
scattering = singularity::photons::GrayS(0.0, 1.0);
scattering = singularity::photons::NonCGSUnitsS<singularity::photons::GrayS>(
singularity::photons::GrayS(0.0, apm), time_scale, mass_scale, length_scale,
temperature_scale);
} else if (scattering_model_name == "constant") {
// TODO(BRR): parse 2nd argument: average particle mass?
scattering_model = ScatteringModel::constant;
Real kappa_s = pin->GetReal("mcblock", "scattering_constant_value");
scattering = singularity::photons::GrayS(kappa_s, 1.0);
scattering = singularity::photons::NonCGSUnitsS<singularity::photons::GrayS>(
singularity::photons::GrayS(kappa_s, apm), time_scale, mass_scale, length_scale,
temperature_scale);
} else {
PARTHENON_FAIL("Only none or constant scattering models supported!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/mcblock/mcblock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mcblock {

// Model enums
enum class InitialRadiation { none, thermal };
enum class OpacityModel { none, constant };
enum class OpacityModel { none, constant, epbremss };
enum class ScatteringModel { none, constant };

std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin);
Expand Down
10 changes: 6 additions & 4 deletions src/mcblock/opacity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
namespace mcblock {

// Reduced absorption variant just for jaybenne
using Opacity = singularity::photons::impl::Variant<singularity::photons::Gray,
singularity::photons::EPBremss>;
using Opacity = singularity::photons::impl::Variant<
singularity::photons::NonCGSUnits<singularity::photons::Gray>,
singularity::photons::NonCGSUnits<singularity::photons::EPBremss>>;

// Reduced scattering variant just for jaybenne
using Scattering = singularity::photons::impl::S_Variant<singularity::photons::GrayS,
singularity::photons::ThomsonS>;
using Scattering = singularity::photons::impl::S_Variant<
singularity::photons::NonCGSUnitsS<singularity::photons::GrayS>,
singularity::photons::NonCGSUnitsS<singularity::photons::ThomsonS>>;

} // namespace mcblock

Expand Down

0 comments on commit 8a2fd66

Please sign in to comment.