-
Notifications
You must be signed in to change notification settings - Fork 289
Sts cleanup #719
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
Sts cleanup #719
Conversation
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.
Summary of Changes
Hello @danieljprice, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request focuses on a significant cleanup of the codebase by completely removing the Super-Timestepping (STS) functionality. This feature, previously employed for non-ideal MHD simulations, is now obsolete due to advancements in implicit resistivity implementation. The changes span across various core and utility modules, eliminating STS-specific code, compiler directives, and associated logic, thereby simplifying the simulation's time-stepping mechanisms and overall architecture.
Highlights
- Removal of Super-Timestepping (STS) Functionality: The core Super-Timestepping (STS) functionality, previously used for non-ideal MHD, has been entirely removed as it is now considered obsolete. This includes the deletion of dedicated STS modules and associated logic.
- Obsolete Feature Justification: The removal is justified by recent thesis work (Biriukov) and the new capability to implement implicit resistivity via the
resistivity_implicit
module, which negates the need for STS to alleviate non-ideal MHD timestep constraints. - Codebase Cleanup: Numerous files across the
build
,src/main
,src/setup
, andsrc/tests
directories have been updated to remove references, compiler flags, variables, and logic related to STS, streamlining the codebase. - Type Conversion Refinements: Several analysis utility files (
analysis_BRhoOrientation.F90
,analysis_NSmerger.f90
,analysis_bzrms.f90
,analysis_common_envelope.f90
,analysis_mapping_mass.f90
,analysis_polytropes.f90
,analysis_protostar_environ.F90
,analysis_sphere.f90
) have been updated to usereal()
for type conversions instead offloat()
, improving consistency and precision.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands on the current page.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request provides a significant cleanup by removing the obsolete super-timestepping (STS) functionality. The changes are extensive, touching many files from the build system to core physics routines, and appear to be consistent and well-executed. This simplification of the codebase is a valuable improvement.
I've also noticed that in several analysis files, the obsolete float()
intrinsic has been replaced with real()
. This is a great modernization. I've added a couple of comments with suggestions to make this pattern even more robust by explicitly specifying the kind
in the real()
conversion, which improves type safety and maintainability.
Overall, this is a solid cleanup effort.
@@ -1089,7 +1089,7 @@ subroutine reduceloc_mpi_real8(string,xproc,loc) | |||
real(kind=8) :: xred(2),xsend(2) | |||
|
|||
xsend(1) = xproc | |||
xsend(2) = float(id) | |||
xsend(2) = real(id) |
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.
It's good that you're replacing the obsolete float()
intrinsic with real()
. For better type safety and clarity, it's recommended to specify the kind
of the real number. Since xsend
is declared as real(kind=8)
, you could use real(id, kind=8)
or, more robustly, real(id, kind=kind(xsend))
. This ensures that the conversion is always to the correct precision, even if the kind of xsend
changes in the future.
xsend(2) = real(id, kind=kind(xsend))
drho = (log10(rhomax) - log10(rhomin))/real(nbins) | ||
dB = (log10(Bmax) - log10(Bmin))/real(nbins) | ||
dv = (log10(vmax) - log10(vmin))/real(nbins) | ||
dcost = (costmax - costmin)/real(nbins) | ||
dvt = (vtmax - vtmin )/real(nbins) |
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.
It's good practice to replace the obsolete float()
intrinsic with real()
. I've noticed this has been done in several analysis files. To further improve type safety and code clarity, I recommend specifying the kind
for the conversion. For example, real(nbins, kind=kind(drho))
. This ensures the integer is converted to the correct precision, matching the variable it's used with, and makes the code more robust against changes in floating-point precision settings. This applies to all similar conversions in this block and other files (e.g., analysis_NSmerger.f90
, analysis_sphere.f90
, etc.).
drho = (log10(rhomax) - log10(rhomin))/real(nbins, kind=kind(drho))
dB = (log10(Bmax) - log10(Bmin))/real(nbins, kind=kind(dB))
dv = (log10(vmax) - log10(vmin))/real(nbins, kind=kind(dv))
dcost = (costmax - costmin)/real(nbins, kind=kind(dcost))
dvt = (vtmax - vtmin )/real(nbins, kind=kind(dvt))
avvinbinmaj(i) = vinbinmaj(i) /real(bincountmaj(i)) | ||
alphabinmaj(i) = alphabinmaj(i)/real(bincountmaj(i)) | ||
partdensmaj(i) = real(bincountmaj(i))*particlemass/vol(i) | ||
endif | ||
if (bincountmin(i) > 0) then | ||
avvinbinmin(i) = vinbinmin(i) /float(bincountmin(i)) | ||
alphabinmin(i) = alphabinmin(i)/float(bincountmin(i)) | ||
partdensmin(i) = float(bincountmin(i))*particlemass/vol(i) | ||
print*, partdensmin(i) ,float(bincountmin(i)),particlemass,vol(i) | ||
avvinbinmin(i) = vinbinmin(i) /real(bincountmin(i)) | ||
alphabinmin(i) = alphabinmin(i)/real(bincountmin(i)) | ||
partdensmin(i) = real(bincountmin(i))*particlemass/vol(i) | ||
print*, partdensmin(i) ,real(bincountmin(i)),particlemass,vol(i) | ||
endif | ||
if (bincountavg(i) > 0) then | ||
avvinbinavg(i) = vinbinavg(i) /float(bincountavg(i)) | ||
alphabinavg(i) = alphabinavg(i)/float(bincountavg(i)) | ||
partdensavg(i) = float(bincountavg(i))*particlemass/(vol(i)*pi/dtheta) | ||
avvinbinavg(i) = vinbinavg(i) /real(bincountavg(i)) | ||
alphabinavg(i) = alphabinavg(i)/real(bincountavg(i)) | ||
partdensavg(i) = real(bincountavg(i))*particlemass/(vol(i)*pi/dtheta) |
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.
Good job replacing float()
with real()
. To make this more robust, you can specify the kind
for the type conversion, e.g., real(bincountmaj(i), kind=kind(avvinbinmaj))
. This ensures type consistency and avoids potential precision issues. This applies to all similar conversions in this block.
avvinbinmaj(i) = vinbinmaj(i) /real(bincountmaj(i), kind=kind(avvinbinmaj))
alphabinmaj(i) = alphabinmaj(i)/real(bincountmaj(i), kind=kind(alphabinmaj))
partdensmaj(i) = real(bincountmaj(i), kind=kind(partdensmaj))*particlemass/vol(i)
endif
if (bincountmin(i) > 0) then
avvinbinmin(i) = vinbinmin(i) /real(bincountmin(i), kind=kind(avvinbinmin))
alphabinmin(i) = alphabinmin(i)/real(bincountmin(i), kind=kind(alphabinmin))
partdensmin(i) = real(bincountmin(i), kind=kind(partdensmin))*particlemass/vol(i)
print*, partdensmin(i) ,real(bincountmin(i), kind=kind(partdensmin)),particlemass,vol(i)
endif
if (bincountavg(i) > 0) then
avvinbinavg(i) = vinbinavg(i) /real(bincountavg(i), kind=kind(avvinbinavg))
alphabinavg(i) = alphabinavg(i)/real(bincountavg(i), kind=kind(alphabinavg))
partdensavg(i) = real(bincountavg(i), kind=kind(partdensavg))*particlemass/(vol(i)*pi/dtheta)
Description:
Super-timestepping functionality [implemented for non-ideal MHD] is obsolete (c.f. Biriukov thesis work). We also now have the ability to implement implicit resistivity as done in sphNG via the resistivity_implicit module, so there is no longer a need for super-timestepping to alleviate the non-ideal MHD tilmestep constraint.
Components modified:
Type of change:
cleanup of obsolete functionality
Testing:
Code compiles and tests run in absence of sts functionality
Did you run the bots? yes
Did you update relevant documentation in the docs directory? n/a
Did you add comments such that the purpose of the code is understandable? yes
Is there a unit test that could be added for this feature/bug? no
If so, please describe what a unit test might check:
n/a
Related issues: #55