-
Notifications
You must be signed in to change notification settings - Fork 191
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
Make GrMhd system compatible with 3D EoS #5479
Conversation
@nilsvu, @nilsdeppe, (perhaps @ermost should take a look at the modifications to primitive recovery too) |
src/Evolution/Systems/GrMhd/ValenciaDivClean/PrimitiveFromConservative.cpp
Outdated
Show resolved
Hide resolved
@@ -141,7 +141,12 @@ std::optional<PrimitiveRecoveryData> NewmanHamlin::apply( | |||
return std::nullopt; | |||
} | |||
} else if constexpr (ThermodynamicDim == 3) { | |||
ERROR("3d EOS not implemented"); | |||
Scalar<double> local_internal_energy( |
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.
const Scalar<double>
rest_mass_density, specific_internal_energy, electron_fraction); | ||
get(sound_speed_squared) = | ||
get(equation_of_state.sound_speed_squared_from_density_and_temperature( | ||
rest_mass_density, temperature, electron_fraction)) |
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.
Oh, CI is complaining about a missing semicolon on this line :)
Hi @isaaclegred, this looks great! The Con2Prim changes in Newman and KastaunMHD look good. Do you also want to modify KastaunHydro? |
Yep I can definitely do this, @ermost! |
@nilsdeppe should I rebase on develop and fix the conflict? |
Yes, though maybe wait a bit because #5494 will probably also cause a conflict? Edit: I'm currently rebasing that one |
9d14485
to
71c44fd
Compare
@nilsdeppe and @nilsvu any other comments or should I squash? |
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.
Looks good, please squash!
src/Evolution/Systems/GrMhd/ValenciaDivClean/PalenzuelaEtAl.cpp
Outdated
Show resolved
Hide resolved
src/Evolution/Systems/GrMhd/ValenciaDivClean/PrimitiveFromConservative.cpp
Outdated
Show resolved
Hide resolved
And yes please squash |
29d4ee5
to
b4c78a8
Compare
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.
Changes look good, but it looks like none of the ThermodynamicDim=3 code is tested. That seems important since we'll mostly run with 3D EOSs once the other changes to the executables go through. Could you please add tests for the code added here?
For the 3D Primitive recovery test, would it be possible to check what happens when the evolved electron fraction goes out of bounds? |
@ermost I can certainly add a test, what is the expected behavior in that case? |
That would be great, thank you @isaaclegred! It should be pushed back to the bounds of the EOS. so if you input ye_star < 0, you should get ye_min, and if you have ye_star > rho*ye_max, you should get ye_max. The undertermined part is what happens if D <0, but that should be caught in the fix atmosphere, or fix conservative part. i.e., whether you keep ye, or just replace it by the atmospheric value. |
6b9c0df
to
1132e8b
Compare
@ermost, @nilsdeppe, @nilsvu whenever you get a chance this is ready for review! I've also added some potentially unnecessary tests to GhMhd subcell related things with 3d EoSs. Let me know if there's anything else you'd like to see. |
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.
I'm happy for you to squash once @ermost has taken a look :)
(rho_h_w_squared / square(current_lorentz_factor) - | ||
current_pressure) / | ||
current_rest_mass_density - | ||
1.0; |
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.
LGTM, this has a catastrophic cancellation, but I don't know what to do about that other than to rework the entire recovery scheme (not worth it!)
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.
Yeah, I would guess we would be using Kastaun most of the time anyway, if this becomes a serious limitation we can take a look at trying to patch it up.
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.
I think it's an intrinsic limitation of the Newman Hamlin scheme in terms of iterating over pressure. For using tabulated EOS the above has always been fine for me, when I was using Newman-Hamlin.
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.
Yea, I think the "solution" is "use a better recovery scheme" 😅 Kastaun isn't perfect in this regard, but it isn't obvious to me that a "perfect" scheme is even possible
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.
I think something better would probably go towards a physicality preserving evolution scheme, but that is even harder :)
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.
Yes, that would be the dream... But agreed, very, very difficult :(
Thanks a lot for additional test @isaaclegred . This looks good to me. |
7124155
to
c709337
Compare
Just rebased on develop to fix conflicts |
c709337
to
eaf07b3
Compare
Uh oh, something went wrong during the rebase :( |
Yeah Con2Prim is broken now (like after fixing things to make it compile), I'm investigating |
@nilsdeppe @ermost I think this is ready to be looked at again. |
Looks good! Thanks for fixing this! |
LGTM, please squash :D |
81b3fa9
to
438c6c9
Compare
438c6c9
to
e7b4d9a
Compare
Changed some things to get rid of clang-tidy complaints, should be good to go when CI completes @nilsdeppe and @ermost! |
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.
@nilsvu please take a look again...
@@ -297,15 +323,17 @@ Primitives FunctionOfMu<EnforcePhysicality, ThermodynamicDim>::primitives( | |||
p_hat = get(equation_of_state_.pressure_from_density_and_energy( | |||
Scalar<double>(rho_hat), Scalar<double>(epsilon_hat))); | |||
} else if constexpr (ThermodynamicDim == 3) { | |||
ERROR("3d EOS not implemented"); | |||
p_hat = get(equation_of_state_.pressure_from_density_and_energy( | |||
Scalar<double>(rho_hat), Scalar<double>(epsilon_hat), |
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.
If you wanted to fix these, I think you need to swap the parens for braces: Scalar<double>{...}
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.
@nilsvu said to ignore these earlier I think, which is why I didn't change them, but I can change them if that's the way things are going.
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.
Sounds good!
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.
Merging as-is is fine, or squash in these things if you want to do them and merge then.
double eps_min{}; | ||
if constexpr (ThermodynamicDim == 3) { | ||
eps_min = equation_of_state_.specific_internal_energy_lower_bound( | ||
rest_mass_density_times_lorentz_factor_ / lorentz_max, | ||
electron_fraction_); | ||
} else { | ||
eps_min = equation_of_state_.specific_internal_energy_lower_bound( | ||
rest_mass_density_times_lorentz_factor_ / lorentz_max); | ||
} |
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.
(optional) move this code outside the if
because it's repeated in both branches?
eps_min = equation_of_state_.specific_internal_energy_lower_bound( | ||
rest_mass_density_times_lorentz_factor_ / lorentz_max); | ||
} | ||
q_ = tau / rest_mass_density_times_lorentz_factor; |
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.
(optional) Move this line outside the if
as well, and only do q_ = std::max(q_, eps_min)
in the EnforcePhysicality
branch? Seems easier to understand that way.
get<hydro::Tags::RestMassDensity<DataVector>>(subcell_prims)); | ||
} | ||
|
||
else if constexpr (EquationOfStateType::thermodynamic_dim == 2) { |
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.
I recommend you build clang-format into your workflow, it makes editing code a lot easier. Try running git-clang-format
and/or use your editor's formatting extensions.
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.
clang-format for some reason doesn't remove this whitespace :(
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.
Maybe the extra empty line tells it not to reformat
e7b4d9a
to
dfe89fc
Compare
@nilsvu, @nilsdeppe changes fixed and squashed |
Proposed changes
This PR adds support for 3D thermodynamic EoSs in the evolution system. Very little is changed (another instantiation is added) except in primitive recovery, where some logic needed to be added.
Upgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments