Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5b5d2ad
fix gpu error
chongchonghe Apr 15, 2025
10750e8
merge in SN branch
chongchonghe Apr 15, 2025
b2e97e2
merge in SN branch: cherry pick simulation.hpp
chongchonghe Apr 15, 2025
1c70c02
set lev = finest_level
chongchonghe Apr 15, 2025
f8e7659
add a check in test_SN
chongchonghe Apr 15, 2025
470cbb0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 15, 2025
657e2a8
fix bug
chongchonghe Apr 17, 2025
220b236
move evolutionStage update into SNDeposition
chongchonghe Apr 18, 2025
0ab6320
use periodic boundary condition for test_SN; also set n_amb = 1.0
chongchonghe Apr 18, 2025
41cf923
need to set is_periodic = 1 1 1 when using periodic b.c.
chongchonghe Apr 18, 2025
d9a0853
set to reflect B.C.
chongchonghe Apr 18, 2025
d9eee5b
use max_Eint_global for validation
chongchonghe Apr 18, 2025
ec279ae
set stencil_size as a constexpr
chongchonghe Apr 19, 2025
df6de82
add a spherical kernal
chongchonghe Apr 19, 2025
b6b9cb7
use static
chongchonghe Apr 19, 2025
993f402
cleanup
chongchonghe Apr 19, 2025
802a2fd
update SN.in for unit test
chongchonghe Apr 19, 2025
2c67646
cleanup
chongchonghe Apr 19, 2025
a628daf
Merge remote-tracking branch 'origin/development' into chong/particle…
chongchonghe Apr 19, 2025
b78ac24
a
chongchonghe Apr 19, 2025
2092074
fix bug; reformat
chongchonghe Apr 19, 2025
1968a39
fix bug in SN.in
chongchonghe Apr 19, 2025
a80b79f
cleanup
chongchonghe Apr 19, 2025
d34621e
fix tidy warning
chongchonghe Apr 19, 2025
32e6b0c
remove warning
chongchonghe Apr 19, 2025
45e2fe5
fix warning and tidy
chongchonghe Apr 19, 2025
4b9ccd4
SN_scheme_d
chongchonghe Apr 20, 2025
cf07d8f
empty if
chongchonghe Apr 20, 2025
29e71a1
define HasStarParticles() and check for unit system
chongchonghe Apr 20, 2025
14fc9c9
add SN kinetic energy to energy budget
chongchonghe Apr 20, 2025
2b57699
update test_SN to use AMR and periodic B.C.
chongchonghe Apr 20, 2025
5ea2d99
add parameter disable_SN_feedback
chongchonghe Apr 20, 2025
343a2fb
remove SNR mass check in gravity_3d test
chongchonghe Apr 20, 2025
4b9c09d
define an empty ParticleCreation
chongchonghe Apr 20, 2025
7c8a4cf
tmp
chongchonghe Apr 20, 2025
ef5ee4a
fix a bug in particle levels
chongchonghe Apr 20, 2025
2837e0c
add a parameter refine_half_domain
chongchonghe Apr 20, 2025
05690ce
update refine in test_SN
chongchonghe Apr 20, 2025
0c30d56
remove Gravity3D
chongchonghe Apr 20, 2025
d2b8125
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 20, 2025
699f28b
disable FPE in test_SN
chongchonghe Apr 22, 2025
11cf5fe
manually merge all recent commits from dev branch
chongchonghe Apr 24, 2025
9ab0c87
Merge branch 'development' into chong/particles/SN-deposition-new-model
chongchonghe Apr 24, 2025
1bfb9f5
cleanup
chongchonghe Apr 24, 2025
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
49 changes: 31 additions & 18 deletions src/particles/PhysicsParticles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <string>

#include "AMReX_Array4.H"
#include "AMReX_BLassert.H"
#include "AMReX_MultiFab.H"
#include "AMReX_ParticleInterpolators.H"
#include "AMReX_REAL.H"
#include "AMReX_SPACE.H"
#include "AMReX_Vector.H"
#include "hydro/hydro_system.hpp"
#include "particle_creation.hpp"
#include "particle_deposition.hpp"
#include "particle_destruction.hpp"
Expand Down Expand Up @@ -115,7 +115,8 @@ class PhysicsParticleDescriptorBase
[[nodiscard]] virtual auto computeMaxParticleSpeed(int lev) const -> amrex::ValLocPair<amrex::Real, amrex::RealVect> = 0;

// Methods that are implemented for some but not all particle types, so they cannot be pure virtual
virtual void depositSN(const amrex::Vector<amrex::MultiFab *> &state, int lev_min, amrex::Real step_end_time) { /* Default empty implementation */ }
virtual void depositSN(amrex::MultiFab &state, amrex::MultiFab &state_buffer, int lev, amrex::Real time, amrex::Real dt)
{ /* Default empty implementation */ }
#endif // AMREX_SPACEDIM == 3
};

Expand Down Expand Up @@ -568,7 +569,7 @@ template <typename ContainerType, typename problem_t, ParticleType particleType>
}

// Get the units data for this particle type
const auto &unitsData = quokka::get_units_data();
const auto &unitsData = get_units_data();
if (unitsData.find(particleType_) == unitsData.end()) {
amrex::Abort(
"Error: Particle type not defined in units data map. Please add units for this particle type in get_units_data().");
Expand Down Expand Up @@ -636,19 +637,21 @@ class StarParticleDescriptor : public PhysicsParticleDescriptor<ContainerType, p

#if AMREX_SPACEDIM == 3
// Implementation of supernova energy and momentum deposition from particles to grid
void depositSN(const amrex::Vector<amrex::MultiFab *> &state, int lev_min, amrex::Real step_end_time) override
void depositSN(amrex::MultiFab &state, amrex::MultiFab &state_buffer, int lev, amrex::Real time, amrex::Real dt) override
{
if (this->container_ != nullptr && this->getEvolutionStageIndex() >= 0) {
// Deposit supernova energy and momentum from level lev_min to finest level
// zero_out_input is false because we want to accumulate supernova contributions
// vol_weight is false because SNDeposition does the volume weighting
amrex::ParticleToMesh(*this->container_, state, lev_min, -1,
SNDeposition{step_end_time, this->getMassIndex(), HydroSystem<problem_t>::density_index,
this->getBirthTimeIndex(), this->getEvolutionStageIndex()},
false, false);

// Update particle evolution stages after deposition
updateEvolutionStage(this->container_, lev_min, step_end_time, this->getBirthTimeIndex(), this->getEvolutionStageIndex());
if (!quokka::disable_SN_feedback) {
// Requires CGS units
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(Physics_Traits<problem_t>::unit_system == UnitSystem::CGS,
"UnitSystem must be CGS for particleMeshInteraction");

// Deposit supernova energy and momentum from all particles. This also updates the evolution stage of the particles.
SNDeposition<ContainerType, problem_t>(this->container_, state, state_buffer, lev, time, dt, this->getMassIndex(),
this->getEvolutionStageIndex(), this->getBirthTimeIndex());
} else {
// Only update evolution stage but not deposit energy/momentum
updateEvolutionStage(this->container_, lev, time + dt, this->getBirthTimeIndex(), this->getEvolutionStageIndex());
}
}
}
#endif // AMREX_SPACEDIM == 3
Expand Down Expand Up @@ -678,6 +681,17 @@ template <typename problem_t> class PhysicsParticleRegister
return false;
}

// Check if registry contains any star particles
[[nodiscard]] auto HasStarParticles() const -> bool
{
for (const auto &[name, descriptor] : particleRegistry_) {
if (descriptor->isStarParticle()) {
return true;
}
}
return false;
}

// Utility method to convert particle type to string name (for writing plotfiles/checkpoints)
[[nodiscard]] static auto getParticleTypeName(ParticleType type) -> std::string
{
Expand Down Expand Up @@ -782,13 +796,12 @@ template <typename problem_t> class PhysicsParticleRegister
}

// Deposit supernova energy and momentum from all particles
void depositSN(const amrex::Vector<amrex::MultiFab *> &state, int lev_min, amrex::Real step_end_time)
void depositSN(amrex::MultiFab &state, amrex::MultiFab &state_buffer, int lev, amrex::Real time, amrex::Real dt)
{
// this function is only implemented for particles that belong to the StarParticleDescriptor class whose unique signature is that the
// isStarParticle() method returns true
// this function is only implemented for some particle types, so we specify the particle type manually here
for (const auto &[type, descriptor] : particleRegistry_) {
if (descriptor->isStarParticle()) {
descriptor->depositSN(state, lev_min, step_end_time);
descriptor->depositSN(state, state_buffer, lev, time, dt);
}
}
}
Expand Down
Loading
Loading