-
Notifications
You must be signed in to change notification settings - Fork 17
Improve moments radiation #137
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
Open
adamdempsey90
wants to merge
14
commits into
develop
Choose a base branch
from
dempsey/radfix3
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,715
−338
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d1ad36e
Update full coupling
adamdempsey90 efb60a2
Add sub cycling as an option
adamdempsey90 6a83101
substep is a bool not real
adamdempsey90 71cd205
Be careful of floors and tolerances
adamdempsey90 3dce9cc
Use better tolerances
adamdempsey90 747d992
Split and Unsplit moments.
adamdempsey90 67dd42e
Add Eps function
adamdempsey90 898c3d3
Add VNorm
adamdempsey90 1fb2369
Cleanup and removal of unneeded code
adamdempsey90 3484005
Update chicoma detection
adamdempsey90 cdb6b41
Remove "simple" matter coupling
adamdempsey90 5265146
Add substep to docs
adamdempsey90 108a6b9
No need to check opacities being finite or negative
adamdempsey90 e26ebb2
format
adamdempsey90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,11 +83,17 @@ ArtemisDriver<GEOM>::ArtemisDriver(ParameterInput *pin, ApplicationInput *app_in | |
| ndim = pm->ndim; | ||
|
|
||
| // Moments integrator | ||
| do_moment_unsplit = false; | ||
| do_moment_split = false; | ||
| if (do_moment) { | ||
| auto rad_int = pin->GetOrAddString("radiation/moment", "integrator", "rk2"); | ||
| PARTHENON_REQUIRE(((rad_int == "rk1") || (rad_int == "rk2") || (rad_int == "rk3")), | ||
| "radiation/integrator must be rk1,rk2, or rk3.") | ||
| rad_integrator = std::make_unique<Integrator_t>(rad_int); | ||
| do_moment_split = pin->GetOrAddBoolean("radiation/moment", "substep", false); | ||
| do_moment_unsplit = !do_moment_split; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we want |
||
| if (do_moment_split) { | ||
| rad_integrator = std::make_unique<Integrator_t>(rad_int); | ||
| } | ||
| } | ||
|
|
||
| // NBody integrator and initialization | ||
|
|
@@ -153,7 +159,7 @@ TaskListStatus ArtemisDriver<GEOM>::Step() { | |
| } | ||
|
|
||
| // Operator split, moments subcycling (M1 or P1) | ||
| if (do_moment) { | ||
| if (do_moment_split) { | ||
| status = Moments::MomentsDriver<GEOM>(pmesh, tm, rad_integrator.get()); | ||
| if (status != TaskListStatus::complete) return status; | ||
| } | ||
|
|
@@ -180,7 +186,7 @@ void ArtemisDriver<GEOM>::PreStepTasks() { | |
| // set the integration timestep | ||
| integrator->dt = tm.dt; | ||
| if (do_nbody) nbody_integrator->dt = tm.dt; | ||
| if (do_moment) rad_integrator->dt = tm.dt; | ||
| if (do_moment_split) rad_integrator->dt = tm.dt; | ||
|
|
||
| // Extract Base MeshData Registers | ||
| auto &base = pmesh->mesh_data.Get(); | ||
|
|
@@ -193,7 +199,7 @@ void ArtemisDriver<GEOM>::PreStepTasks() { | |
| auto &u1 = pmesh->mesh_data.Add("u1", u0); | ||
|
|
||
| // Assign registers with fields required for moments | ||
| if (do_moment) { | ||
| if (do_moment_split) { | ||
| parthenon::Metadata::FlagCollection moments_flags, geom_flags; | ||
| moments_flags.TakeUnion(pmesh->packages.Get("moments")->GetMetadataFlag()); | ||
| geom_flags.TakeUnion(pmesh->packages.Get("geometry")->GetMetadataFlag()); | ||
|
|
@@ -258,10 +264,13 @@ TaskCollection ArtemisDriver<GEOM>::StepTasks() { | |
| // Compute hydrodynamic fluxes | ||
| // NOTE(@adempsey): 1st stage of VL2 uses piecewise constant reconstruction | ||
| const bool do_pcm = ((stage == 1) && (integrator->GetName() == "vl2")); | ||
| TaskID gas_flx = none, dust_flx = none; | ||
| TaskID gas_flx = none, dust_flx = none, rad_flx = none; | ||
| if (do_gas && update_fluxes) | ||
| gas_flx = tl.AddTask(none, Gas::CalculateFluxes, u0.get(), do_pcm); | ||
| if (do_dust) dust_flx = tl.AddTask(none, Dust::CalculateFluxes, u0.get(), do_pcm); | ||
| if (do_moment_unsplit) { | ||
| rad_flx = tl.AddTask(none, Moments::CalculateFluxes, u0.get()); | ||
| } | ||
|
|
||
| // Compute (gas) diffusive fluxes | ||
| TaskID diff_flx = none; | ||
|
|
@@ -275,20 +284,23 @@ TaskCollection ArtemisDriver<GEOM>::StepTasks() { | |
|
|
||
| // Communicate and set fluxes | ||
| auto send_flx = | ||
| tl.AddTask(gas_flx | dust_flx | diff_flx, | ||
| tl.AddTask(gas_flx | dust_flx | rad_flx | diff_flx, | ||
| parthenon::SendBoundBufs<parthenon::BoundaryType::flxcor_send>, u0); | ||
| auto recv_flx = tl.AddTask(start_flx_recv, parthenon::ReceiveFluxCorrections, u0); | ||
| auto set_flx = tl.AddTask(recv_flx, parthenon::SetFluxCorrections, u0); | ||
|
|
||
| // Apply flux divergence | ||
| auto update = | ||
| tl.AddTask(gas_flx | dust_flx | set_flx, ArtemisUtils::ApplyUpdate<GEOM>, | ||
| u0.get(), u1.get(), g0, g1, bdt); | ||
| tl.AddTask(gas_flx | dust_flx | rad_flx | set_flx, | ||
| ArtemisUtils::ApplyUpdate<GEOM>, u0.get(), u1.get(), g0, g1, bdt); | ||
|
|
||
| // Apply "coordinate source terms" | ||
| TaskID gas_coord_src = update, dust_coord_src = update; | ||
| TaskID gas_coord_src = update, dust_coord_src = update, rad_coord_src; | ||
| if (do_gas) gas_coord_src = tl.AddTask(update, Gas::FluxSource, u0.get(), bdt); | ||
| if (do_dust) dust_coord_src = tl.AddTask(update, Dust::FluxSource, u0.get(), bdt); | ||
| if (do_moment_unsplit) { | ||
| rad_coord_src = tl.AddTask(update, Moments::FluxSource, u0.get(), bdt); | ||
| } | ||
|
|
||
| // Apply (gas) diffusion sources | ||
| TaskID gas_diff_src = gas_coord_src | diff_flx | set_flx; | ||
|
|
@@ -311,17 +323,20 @@ TaskCollection ArtemisDriver<GEOM>::StepTasks() { | |
| tl.AddTask(gravity_src, SelfGravity::SelfGravity<GEOM>, u0.get(), time, bdt); | ||
| } | ||
|
|
||
| TaskID rt_src = self_gravity_src; | ||
| TaskID rad_src = self_gravity_src; | ||
| // Note that radiation moments will handle this source term if active | ||
| if (do_raytrace && !do_moment) { | ||
| rt_src = tl.AddTask(self_gravity_src, Gas::DepositEnergy, u0.get(), bdt); | ||
| if (do_moment_unsplit) { | ||
| rad_src = | ||
| tl.AddTask(self_gravity_src, Moments::MatterCoupling<GEOM>, u0.get(), bdt); | ||
| } else if (do_raytrace && !do_moment) { | ||
| rad_src = tl.AddTask(self_gravity_src, Gas::DepositEnergy, u0.get(), bdt); | ||
| } | ||
|
|
||
| // Apply rotating frame source term | ||
| TaskID rframe_src = rt_src; | ||
| TaskID rframe_src = rad_src; | ||
| if (do_rotating_frame || do_orbital_advection) { | ||
| rframe_src = | ||
| tl.AddTask(rt_src, RotatingFrame::RotatingFrameForce, u0.get(), time, bdt); | ||
| tl.AddTask(rad_src, RotatingFrame::RotatingFrameForce, u0.get(), time, bdt); | ||
| } | ||
|
|
||
| // Apply drag source term | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does everything work correctly with package turn-on and turn-off if using moments unsplit mode? In that event, do we still take the radiation dt?