Skip to content

Turn on/off radiation#118

Open
adamdempsey90 wants to merge 7 commits intodevelopfrom
dempsey/pkg_time
Open

Turn on/off radiation#118
adamdempsey90 wants to merge 7 commits intodevelopfrom
dempsey/pkg_time

Conversation

@adamdempsey90
Copy link
Copy Markdown
Collaborator

Background

This adds the machinery to turn on/off and initialize/shutdown a package during a simulation. To start, I have enrolled moments and raytrace into this.

When moments comes on, it will set all variables to LTE values.

We should do the same for IMC and pretty much all of the packages.

I have tested this locally, and it works correctly, even through restarts.

Description of Changes

Checklist

  • New features are documented
  • Tests added for bug fixes and new features
  • (@lanl.gov employees) Update copyright on changed files
  • Any contribution that was created or modified with the assistance of generative AI must have a comment disclosing this such as // This file was created in part or in whole by generative AI

Comment thread src/radiation/moments/moments.cpp Outdated
Copy link
Copy Markdown
Collaborator

@RyanWollaeger RyanWollaeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

enum class PackageControl { inactive = -1, shutdown = 0, active = 1, initial = 2 };

template <class PKG>
inline PackageControl CheckPackageStatus(PKG &pkg, const Real time) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem for today... but something like this might be a bit more nuanced for non operator-split physics. For example, I don't think we would want to turn off physics in between the the 1st and 2nd stage of RK2. Not an issue at the moment, just thinking aloud.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only called before entering Step, so there won't be any switching mid RK-stage

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have expanded this use to physics that is done in the rk substeps, in those cases i also only turn on/off for the first stage

Comment thread src/radiation/moments/moments.cpp Outdated
const Real &sie = vmesh(b, gas::prim::sie(0), k, j, i);
const Real T = eos_d.TemperatureFromDensityInternalEnergy(rho, sie);
const Real Erad = arad * SQR(SQR(T));
vmesh(b, rad::cons::energy(0), k, j, i) = Erad;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should mask such initialization on material with optical depth >~ 1>?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that a batch of zones could skirt whatever criterion you impose and then you'd get bad numerical behavior of neighboring zones at the floor and not at the floor.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/radiation/moments/moments.cpp Outdated
@adamdempsey90
Copy link
Copy Markdown
Collaborator Author

I will add this machinery also to the cooling package

Comment on lines +47 to +50
// What to call here to set the field?
// Need a pmesh version of this
// jaybenne::InitializeRadiation(md.get(), true)
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If jaybenne had a mesh version of this function in addition to the meshblock version, we could turn imc on/off easily. @RyanWollaeger @pdmullen let's add that to jaybenne

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 43 to +45
//! \fn TaskListStatus SelfGravity::PoissonDriver
//! \brief
void SolvePoisson(TaskCollection &tc, Mesh *pmesh) {
void SolvePoisson(TaskCollection &tc, Mesh *pmesh, const Real time, const int stage) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this doesn't return TaskListStatus, but should it @pdmullen ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not. All we are doing is passing the TaskCollection tc to SolvePoisson and having that function add a region with its own tasks.

When we call Execute on the final TaskCollection, that returns TaskListStatus (see StepTasks.Execute()).

The comment is wrong in the //! \fn though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants