Skip to content

Commit

Permalink
Merge pull request #278 from akhoubani/howto-timestep
Browse files Browse the repository at this point in the history
Adding adaptive_time_step.md  file
  • Loading branch information
ashwinvis committed Apr 5, 2023
2 parents 199077b + 3be1da2 commit c2431fe
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
38 changes: 38 additions & 0 deletions docs/how-to/adaptive_time_step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# How to set adaptive time step in Nek5000

In the Nek5000 documentation, `variableDT` in `GENERAL` keys in [`.par` file](https://nek5000.github.io/NekDoc/problem_setup/case_files.html#parameter-file-par) is used to control whether the step size will be adjusted to match the `targetCFL`.

In Snek5000, you can enable this feature by setting `params.nek.general.variable_dt` to `True`.

For example, in the script below, we set `variable_dt` as `True`, which subsequently leads to an adaptive time step based on the `target_cfl`:

```python
---
emphasize-lines: 20-21
---
from snek5000_tgv.solver import Simul

params = Simul.create_default_params()
params.output.sub_directory = "examples_snek/tuto"

params.oper.nx = params.oper.ny = params.oper.nz = 8
params.oper.elem.order = params.oper.elem.order_out = 8
params.oper.nproc_min = 2

params.nek.velocity.residual_tol = 1e-07
params.nek.pressure.residual_tol = 1e-05

params.nek.general.write_control = "runTime"
params.nek.general.write_interval = 2.0

params.output.spatial_means.write_interval = 0.5

params.nek.general.end_time = 10
params.nek.general.dt = 1
params.nek.general.target_cfl = 1.4
params.nek.general.variable_dt = True
params.nek.general.extrapolation = "OIFS"

sim = Simul(params)
sim.make.exec("run_fg", nproc=2)
```
2 changes: 1 addition & 1 deletion docs/how-to/history_points.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ params.output.history_points.coords: list[tuple[float, float, float] | tuple[flo
```

For example, see the
[parameters used in the tutorial for snek5000-cbox](../tuto_cbox.myst.md#a-more-advanced-script-adated-for-a-particular-instability).
[parameters used in the tutorial for snek5000-cbox](../tuto_cbox.myst.md#a-more-advanced-script-adapted-for-a-particular-instability).

This should be coupled along with a `hpts()` call in `userchk()` subroutine in the
Nek5000 user file. For more information, see *documentation for
Expand Down
1 change: 1 addition & 0 deletions docs/how-to/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rebuild-nek.md
export-sans-snek5000.myst.md
archive-simulation-data.md
templates.md
adaptive_time_step.md
```

## For developer of Snek5000 solvers
Expand Down
2 changes: 1 addition & 1 deletion docs/tuto_cbox.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kernelspec:

# Demo sidewall convection (`snek5000-cbox` solver)

## A more advanced script adated for a particular instability
## A more advanced script adapted for a particular instability

This example is based on
[the study *From onset of unsteadiness to chaos in a differentially heated square cavity* by Le Quéré & Behnia (1998)](https://www.cambridge.org/core/journals/journal-of-fluid-mechanics/article/abs/from-onset-of-unsteadiness-to-chaos-in-a-differentially-heated-square-cavity/617F4CB2C23DD74C3D0CB872AE7C0045).
Expand Down

0 comments on commit c2431fe

Please sign in to comment.