Skip to content
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
15 changes: 9 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "external/parthenon"]
path = external/parthenon
url = https://github.com/parthenon-hpc-lab/parthenon.git
path = external/parthenon
url = https://github.com/parthenon-hpc-lab/parthenon.git
ignore = dirty
[submodule "external/singularity-opac"]
path = external/singularity-opac
url = https://github.com/lanl/singularity-opac.git
path = external/singularity-opac
url = https://github.com/lanl/singularity-opac.git
ignore = dirty
[submodule "external/singularity-eos"]
path = external/singularity-eos
url = https://github.com/lanl/singularity-eos.git
path = external/singularity-eos
url = https://github.com/lanl/singularity-eos.git
ignore = dirty
5 changes: 3 additions & 2 deletions env/bash
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ elif [[ $PARTITION == "darwin-volta-x86" ]]; then
module load cuda/12.3.1
module load gcc/12.2.0
module load hdf5/1.12.2
module load miniconda3
source /projects/opt/centos8/x86_64/miniconda3/py39_4.12.0/bin/activate /usr/projects/jovian/dependencies/python/volta-x86-py39
module load miniconda3/py311_23.11.0
source /usr/projects/jovian/dependencies/python/volta-x86-py311/bin/activate
shorten_prompt
module load cmake/3.26.3
module list
export UCX_TLS=^gdr_copy # claude-opus suggestion for GPU buffer-pinning error (may just be node cn410)
echo "...setup SUCCEEDED"
elif [[ $PARTITION == "darwin-a100" ]]; then
module purge
Expand Down
2 changes: 1 addition & 1 deletion external/singularity-eos
Submodule singularity-eos updated 126 files
2 changes: 1 addition & 1 deletion external/singularity-opac
Submodule singularity-opac updated 67 files
+5 −2 CMakeLists.txt
+40 −17 README.md
+3 −1 cmake/SetupDeps.cmake
+2 −0 plan_histories/69.md
+2 −0 plan_histories/70.md
+38 −0 plan_histories/71.md
+4 −6 singularity-opac/base/indexers.hpp
+0 −1 singularity-opac/base/opac_error.hpp
+0 −1 singularity-opac/base/radiation_types.hpp
+33 −34 singularity-opac/base/robust_utils.hpp
+14 −2 singularity-opac/base/sp5.hpp
+0 −1 singularity-opac/chebyshev/chebyshev.hpp
+33 −37 singularity-opac/chebyshev/vandermonde.hpp
+0 −1 singularity-opac/constants/constants.hpp
+0 −1 singularity-opac/neutrinos/brt_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/gray_opacity_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/gray_s_opacity_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/mean_neutrino_s_variant.hpp
+0 −1 singularity-opac/neutrinos/mean_neutrino_variant.hpp
+12 −13 singularity-opac/neutrinos/mean_opacity_neutrinos.hpp
+15 −19 singularity-opac/neutrinos/mean_s_opacity_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/neutrino_s_variant.hpp
+0 −1 singularity-opac/neutrinos/neutrino_variant.hpp
+0 −1 singularity-opac/neutrinos/non_cgs_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/non_cgs_s_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/opac_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/s_opac_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/spiner_opac_neutrinos.hpp
+0 −1 singularity-opac/neutrinos/thermal_distributions_neutrinos.hpp
+1 −2 singularity-opac/neutrinos/tophat_emissivity_neutrinos.hpp
+1 −2 singularity-opac/photons/epbremsstrahlung_opacity_photons.hpp
+0 −19 singularity-opac/photons/example_ascii/kap_plaw.txt
+0 −103 singularity-opac/photons/example_ascii/preproc_ascii_opac.py
+0 −1 singularity-opac/photons/gray_opacity_photons.hpp
+3 −2 singularity-opac/photons/gray_s_opacity_photons.hpp
+299 −220 singularity-opac/photons/mean_opacity_photons.hpp
+66 −2 singularity-opac/photons/mean_photon_s_variant.hpp
+12 −6 singularity-opac/photons/mean_photon_types.hpp
+208 −0 singularity-opac/photons/mean_photon_utils.hpp
+64 −6 singularity-opac/photons/mean_photon_variant.hpp
+260 −119 singularity-opac/photons/mean_s_opacity_photons.hpp
+55 −42 singularity-opac/photons/non_cgs_photons.hpp
+58 −25 singularity-opac/photons/non_cgs_s_photons.hpp
+3 −4 singularity-opac/photons/opac_photons.hpp
+0 −1 singularity-opac/photons/photon_s_variant.hpp
+6 −5 singularity-opac/photons/photon_variant.hpp
+26 −27 singularity-opac/photons/powerlaw_opacity_photons.hpp
+26 −26 singularity-opac/photons/powerlaw_s_opacity_photons.hpp
+3 −4 singularity-opac/photons/s_opac_photons.hpp
+0 −2 singularity-opac/photons/thermal_distributions_photons.hpp
+0 −1 singularity-opac/photons/thomson_s_opacity_photons.hpp
+2 −3 spack-repo/packages/singularity-opac_deps/package.py
+14 −11 test/CMakeLists.txt
+3 −2 test/catch2_define.cpp
+3 −1 test/test_brt_opacities.cpp
+3 −1 test/test_chebyshev.cpp
+3 −1 test/test_epbremsstrahlung_opacities.cpp
+3 −1 test/test_gray_opacities.cpp
+3 −1 test/test_gray_s_opacities.cpp
+0 −856 test/test_mean_opacities.cpp
+1,128 −0 test/test_multigroup_opacities.cpp
+2 −2 test/test_powerlaw_opacities.cpp
+3 −1 test/test_scalefree_opacities.cpp
+3 −1 test/test_spiner_opac_neutrinos.cpp
+2 −2 test/test_thermal_dist.cpp
+3 −1 test/test_thomson_s_opacities.cpp
+3 −1 test/test_variant.cpp
30 changes: 17 additions & 13 deletions src/jaybenne/jaybenne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
Real dlnu = -1.0;
Real h = -1.0;
Real sb = -1.0;
Real ac = -1.0; // radiation constant times light speed (set below)
std::vector<Real> nu_grid = JaybenneNull<std::vector<Real>>();
ParArray1D<Real> nu_bins;

Expand All @@ -458,6 +459,7 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
const OpacityAveraging gmode = use_planck ? Planck : Rosseland;

if constexpr (FT == FrequencyType::gray) {
ac = 4.0 * (jbn->template Param<Real>("stefan_boltzmann"));
mopacity = jbn->template Param<MeanOpacity>("mopacity_d");
mscattering = jbn->template Param<MeanScattering>("mscattering_d");
} else if constexpr (FT == FrequencyType::multigroup) {
Expand Down Expand Up @@ -498,14 +500,16 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
const Real temp = eos.TemperatureFromDensityInternalEnergy(rho, sie);
const Real cv = eos.SpecificHeatFromDensityInternalEnergy(rho, sie);
Real emis = JaybenneNull<Real>();
[[maybe_unused]] const auto acd = ac;
[[maybe_unused]] const auto gmoded = gmode;
[[maybe_unused]] auto mopac = mopacity;
[[maybe_unused]] auto opac = opacity;
[[maybe_unused]] const auto n_nubinsd = n_nubins;
[[maybe_unused]] const auto &nu_binsd = nu_bins;
[[maybe_unused]] const auto dlnud = dlnu;
if constexpr (FT == FrequencyType::gray) {
emis = mopac.Emissivity(rho, temp, gmoded);
const Real T4 = SQR(SQR(temp));
emis = mopac.AbsorptionCoefficient(rho, temp, 0, gmoded) * acd * T4;
} else if constexpr (FT == FrequencyType::multigroup) {
// NOTE: 'emis = opac.Emissivity(rho, temp);' may not integrate
emis = 0.0;
Expand Down Expand Up @@ -609,10 +613,10 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
[[maybe_unused]] const auto tau_ddmcd = tau_ddmc;
[[maybe_unused]] const auto lam_extd = lam_ext;
if constexpr (FT == FrequencyType::gray) {
ss_l = mscatter.RosselandMeanTotalScatteringCoefficient(rho_l, temp_l);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, gmode2d);
ss_u = mscatter.RosselandMeanTotalScatteringCoefficient(rho_u, temp_u);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, gmode2d);
ss_l = mscatter.ScatteringCoefficient(rho_l, temp_l, 0, gmode2d);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, 0, gmode2d);
ss_u = mscatter.ScatteringCoefficient(rho_u, temp_u, 0, gmode2d);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, 0, gmode2d);

// calculate optical thicknesses from lower and upper cell
const Real tau_lmin = dx_lmin * (ss_l + aa_l);
Expand Down Expand Up @@ -725,10 +729,10 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
[[maybe_unused]] const auto tau_ddmcd = tau_ddmc;
[[maybe_unused]] const auto lam_extd = lam_ext;
if constexpr (FT == FrequencyType::gray) {
ss_l = mscatter.RosselandMeanTotalScatteringCoefficient(rho_l, temp_l);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, gmode2d);
ss_u = mscatter.RosselandMeanTotalScatteringCoefficient(rho_u, temp_u);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, gmode2d);
ss_l = mscatter.ScatteringCoefficient(rho_l, temp_l, 0, gmode2d);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, 0, gmode2d);
ss_u = mscatter.ScatteringCoefficient(rho_u, temp_u, 0, gmode2d);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, 0, gmode2d);

// calculate optical thicknesses from lower and upper cell
const Real tau_lmin = dx_lmin * (ss_l + aa_l);
Expand Down Expand Up @@ -843,10 +847,10 @@ TaskStatus UpdateDerivedTransportFieldsImpl(MeshData<Real> *md, const Real dt) {
[[maybe_unused]] const auto tau_ddmcd = tau_ddmc;
[[maybe_unused]] const auto lam_extd = lam_ext;
if constexpr (FT == FrequencyType::gray) {
ss_l = mscatter.RosselandMeanTotalScatteringCoefficient(rho_l, temp_l);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, gmode2d);
ss_u = mscatter.RosselandMeanTotalScatteringCoefficient(rho_u, temp_u);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, gmode2d);
ss_l = mscatter.ScatteringCoefficient(rho_l, temp_l, 0, gmode2d);
aa_l = mopac.AbsorptionCoefficient(rho_l, temp_l, 0, gmode2d);
ss_u = mscatter.ScatteringCoefficient(rho_u, temp_u, 0, gmode2d);
aa_u = mopac.AbsorptionCoefficient(rho_u, temp_u, 0, gmode2d);

// calculate optical thicknesses from lower and upper cell
const Real tau_lmin = dx_lmin * (ss_l + aa_l);
Expand Down
4 changes: 3 additions & 1 deletion src/jaybenne/sourcing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ TaskStatus SourcePhotons(T *md, const Real t_start, const Real dt) {
} else if constexpr (ST == SourceType::emission) {
Real emis = JaybenneNull<Real>();
if constexpr (FT == FrequencyType::gray) {
emis = mopac.Emissivity(rho, temp, gmode);
const Real T4 = SQR(SQR(temp));
emis =
mopac.AbsorptionCoefficient(rho, temp, 0, gmoded) * 4.0 * sbd * T4;
} else if constexpr (FT == FrequencyType::multigroup) {
// Construct emission CDF
// calculate bin width (assuming log bin width)
Expand Down
44 changes: 32 additions & 12 deletions src/mcblock/mcblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,25 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
MeanOpacity mopacity;
std::string abs_model = pin->GetString("mcblock/absorption", "opacity_model");
if (frequency_type == FrequencyType::gray) {

// hard-coded numbers in Hz
const std::array<Real, 2> gray_bounds = {time_scale * 1.e12, time_scale * 3.e20};

if (abs_model == "none") {
auto opac = singularity::photons::Gray(1.e-100);
mopacity =
singularity::photons::MeanNonCGSUnits<singularity::photons::MeanOpacityBase>(
singularity::photons::MeanOpacityBase(opac, -1, 1, 2, -1, 1, 2), time_scale,
mass_scale, length_scale, temperature_scale);
singularity::photons::MeanOpacityBase(opac, -1, 1, 2, -1, 1, 2, gray_bounds,
1),
time_scale, mass_scale, length_scale, temperature_scale);
} else if (abs_model == "constant") {
Real kappa = pin->GetReal("mcblock/absorption", "constant_value");
auto opac = singularity::photons::Gray(kappa);
mopacity =
singularity::photons::MeanNonCGSUnits<singularity::photons::MeanOpacityBase>(
singularity::photons::MeanOpacityBase(opac, -1, 1, 2, -1, 1, 2), time_scale,
mass_scale, length_scale, temperature_scale);
singularity::photons::MeanOpacityBase(opac, -1, 1, 2, -1, 1, 2, gray_bounds,
1),
time_scale, mass_scale, length_scale, temperature_scale);
} else if (abs_model == "table") {
std::string table_filename = pin->GetString("mcblock/absorption", "opacity_table");
mopacity =
Expand Down Expand Up @@ -186,18 +192,21 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
std::string sct_model =
pin->GetOrAddString("mcblock/scattering", "opacity_model", "none");
if (frequency_type == FrequencyType::gray) {
const std::array<Real, 2> gray_bounds = {1.e12, 3.e20};
if (sct_model == "none") {
auto sopac = singularity::photons::GrayS(0.0, apm);
mscattering =
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityCGS>(
singularity::photons::MeanSOpacityCGS(sopac, -1., 1., 2, -1., 1., 2),
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityBase>(
singularity::photons::MeanSOpacityBase(sopac, -1., 1., 2, -1., 1., 2,
gray_bounds, 1),
time_scale, mass_scale, length_scale, 1.);
} else if (sct_model == "constant") {
Real kappa_s = pin->GetReal("mcblock/scattering", "constant_value");
auto sopac = singularity::photons::GrayS(kappa_s, apm);
mscattering =
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityCGS>(
singularity::photons::MeanSOpacityCGS(sopac, -1., 1., 2, -1., 1., 2),
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityBase>(
singularity::photons::MeanSOpacityBase(sopac, -1., 1., 2, -1., 1., 2,
gray_bounds, 1),
time_scale, mass_scale, length_scale, 1.);
} else {
PARTHENON_FAIL("Only none or constant scattering models supported!");
Expand Down Expand Up @@ -321,8 +330,8 @@ void ProblemGenerator(MeshBlock *pmb, ParameterInput *pin) {
const Real &rho = vmesh(b, fm::density(), k, j, i);
const Real &sie = vmesh(b, fm::sie(), k, j, i);
const Real temp = eos.TemperatureFromDensityInternalEnergy(rho, sie);
const Real aa = mopacity.AbsorptionCoefficient(rho, temp, gmode);
const Real ss = mscattering.RosselandMeanTotalScatteringCoefficient(rho, temp);
const Real aa = mopacity.AbsorptionCoefficient(rho, temp, 0, gmode);
const Real ss = mscattering.ScatteringCoefficient(rho, temp, 0, gmode);
vmesh(b, fm::absorption_opacity(), k, j, i) = aa;
vmesh(b, fm::scattering_opacity(), k, j, i) = ss;
});
Expand All @@ -338,6 +347,10 @@ void UpdateDerived(MeshData<Real> *md) {
PARTHENON_INSTRUMENT
namespace fm = field::material;
using parthenon::MakePackDescriptor;
using singularity::photons::OpacityAveraging;
using singularity::photons::Planck;
using singularity::photons::Rosseland;

auto pm = md->GetParentPointer();
auto &resolved_pkgs = pm->resolved_packages;
auto &jbn = pm->packages.Get("jaybenne");
Expand Down Expand Up @@ -376,15 +389,22 @@ void UpdateDerived(MeshData<Real> *md) {

// update opacity (TODO: only gray for now)
if (frequency_type == FrequencyType::gray) {

// get opacity average indicators
const auto &use_planck = jbn->template Param<bool>("use_planck");
const auto &use_rosseland = jbn->template Param<bool>("use_rosseland");
// set opacity mode for grey opacity
const OpacityAveraging gmode = (use_planck && !use_rosseland) ? Planck : Rosseland;

parthenon::par_for(
DEFAULT_LOOP_PATTERN, "Update opacity", parthenon::DevExecSpace(), 0,
vmesh.GetNBlocks() - 1, kbe.s, kbe.e, jbe.s, jbe.e, ibe.s, ibe.e,
KOKKOS_LAMBDA(const int &b, const int &k, const int &j, const int &i) {
const Real &rho = vmesh(b, fm::density(), k, j, i);
const Real &sie = vmesh(b, fm::sie(), k, j, i);
const Real temp = eos.TemperatureFromDensityInternalEnergy(rho, sie);
const Real aa = mopacity.AbsorptionCoefficient(rho, temp);
const Real ss = mscattering.RosselandMeanTotalScatteringCoefficient(rho, temp);
const Real aa = mopacity.AbsorptionCoefficient(rho, temp, 0, gmode);
const Real ss = mscattering.ScatteringCoefficient(rho, temp, 0, gmode);
vmesh(b, fm::absorption_opacity(), k, j, i) = aa;
vmesh(b, fm::scattering_opacity(), k, j, i) = ss;
});
Expand Down
2 changes: 1 addition & 1 deletion src/mcblock/opacity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using Scattering = singularity::photons::impl::S_Variant<
singularity::photons::NonCGSUnitsS<singularity::photons::ThomsonS>>;

using MeanScattering =
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityCGS>;
singularity::photons::MeanNonCGSUnitsS<singularity::photons::MeanSOpacityBase>;

} // namespace mcblock

Expand Down
Loading