Skip to content

Conversation

doraemonho
Copy link
Collaborator

@doraemonho doraemonho commented Jan 6, 2025

Background

This is an ongoing and not yet finish development to implement the Super-Time-Stepping (STS) algorithm in Artemis to optimize diffusion calculations with relaxed timestep constraints.

Description of Changes

Core Changes

  • Modified core components to integrate STS functionality:
    • artemis_driver.cpp and artemis_driver.hpp: Added STS control parameters and initialization logic
    • artemis.cpp and artemis.hpp: Implemented STS integration points and modified timestep handling
    • gas.cpp: Modified the timestep calculation for STS timestep management

New Components

  • Added new sts/ directory containing implementation files for the STS algorithm
  • Introduced new configuration parameters for STS control
  • STS-specific utility functions and numerical solvers

Implementation Status

This is a work in progress, with the following features currently under development:

  • STS Integrator
  • Validation and testing pgen for STS implementation
  • flux correction term for different coordinates.

Checklist

  • New features are documented
  • Tests added for bug fixes and new features
  • (@lanl.gov employees) Update copyright on changed files

1.  Added sts folder and files to handle the update.

2. artemis.cpp/hpp modified
a) added sts flag
b) added Initialize for sts

3. artemis_driver.hpp
a) added sts flag
b) added the entry for sts in PreStepTasks() fn
c) added the entry for sts in PostStepTasks() fn
d) Added a check to remove diffusion from main step if sts is enabled

4. gas.cpp
a) Added the sts flag
b) Added the diffusion timetep for paramters
c) Modified the timestep compuation
- changed `sts.cpp/hpp` for implmenting the RKL1
- Bug Fixed in enterting sts_integrator section in `artemis_driver.cpp`
Workable STS rkl1 Solver Update && Format Fix
 - Bug fixed for sts.hpp
 - changed duffusion problem py script to sts solver
 - changed the conduction input file
typo fixed in thermal_duffusion.py
@doraemonho doraemonho requested a review from pdmullen March 4, 2025 00:23
@doraemonho
Copy link
Collaborator Author

I think most of the work on RKL1 solver has been finished and passed the CI on Darwin.
Please kindly review it and let me know any changes I should made.

Copy link
Collaborator

@adamdempsey90 adamdempsey90 left a comment

Choose a reason for hiding this comment

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

Mostly organizational comments. Looks good otherwise.

Some other things to do:

  • Update parameters for the new <sts> node
  • Update documentation in doc/

Comment on lines +162 to +168
if (parthenon::Globals::my_rank == 0 && info_output) {
Real ratio = tm.dt / min_diff_dt;
std::cout << "STS ratio: " << ratio << ", Taking " << s_sts << " steps." << std::endl;
if (ratio > 200.0) {
std::cout << "WARNING: ratio is > 200. Proceed at own risk." << std::endl;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This output should respect the ncycle_out parameter in parthenon/time. So you should make sure this tm.ncycle % tm.ncycle_out == 0 as well.

params.Add("do_sts", do_sts);

if (do_sts) {
params.Add("diff_dt", std::numeric_limits<Real>::max(), Params::Mutability::Mutable);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
params.Add("diff_dt", std::numeric_limits<Real>::max(), Params::Mutability::Mutable);
params.Add("diff_dt", Big<Real>(), Params::Mutability::Mutable);


Real muj = (2. * stage - 1.) / stage;
Real nuj = (1. - stage) / stage;
Real muj_tilde = muj * 2. / (std::pow(nstages, 2.) + nstages);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Real muj_tilde = muj * 2. / (std::pow(nstages, 2.) + nstages);
Real muj_tilde = muj * 2. / ( SQR(nstages) + nstages);

//! \brief Assembles the tasks for the STS RKL1 integrator
// comment: Maybe it should be moved back to artemis_driver.cpp
template <Coordinates GEOM>
TaskCollection STSRKL1(Mesh *pmesh, const Real time, Real dt, int stage, int nstages) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer any function that builds a TaskCollection or sets up Tasks to be in ArtemisDriver directly.

// Getting the integrator & time ratio between hyperbolic and parabolic terms
std::string sts_intg_mothod = pin->GetOrAddString("sts", "integrator", "none");
Real sts_max_dt_ratio = pin->GetOrAddReal("sts", "sts_max_dt_ratio", -1.0);
const bool info_output = pin->GetOrAddBoolean("sts", "info_output", false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this extra parameter needed? Printing the number of stages every ncycle_out is fine

@pdmullen pdmullen marked this pull request as draft June 25, 2025 14:15
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.

2 participants