Skip to content
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

WIP Integration test #108

Open
wants to merge 134 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
b5baf67
Add simple anisotropic step function test
pgrete Oct 3, 2021
e9ac8f6
Separate FillDerived and EstimateTimestep in driver in prep for STS list
pgrete Oct 3, 2021
2b30fca
Add diffflux parameter
pgrete Oct 3, 2021
db63255
Add RKL2 STS task list
pgrete Oct 3, 2021
a968fd8
Add calc of RKL2 stages
pgrete Oct 3, 2021
0e0986b
Remove unncessary register for rkl2
pgrete Oct 4, 2021
6da6766
Adopt STS RKL2 variable naming
pgrete Oct 4, 2021
d25abb3
Move calc of dt_diff into PreStep
pgrete Oct 4, 2021
b4dfdd9
Make tlim an argument for diff step test
pgrete Oct 6, 2021
5f20625
Adjust RKL2 conv test to gaussian profile
pgrete Oct 6, 2021
b75b496
Add conv panel to conv plot
pgrete Oct 6, 2021
3473da8
auto-format
pgrete Oct 6, 2021
3d26c40
rename diffusion integrator parameter
pgrete Oct 6, 2021
61a9c93
Add isotropic thermal conduction
pgrete Oct 6, 2021
647490d
Add isotropic cond to conv test
pgrete Oct 6, 2021
4e03d38
Add RKL2 conv test
pgrete Oct 6, 2021
a235952
Add new dt max ratio for rkl2 param
pgrete Oct 11, 2021
991d353
Add prolongation and fluxcorrect to RKL2 task list
pgrete Oct 11, 2021
7fd557d
Use base container as active STS container (workaround some AMR bug f…
pgrete Oct 12, 2021
755e06b
Merge branch 'pgrete/dt-fixes' into pgrete/sts
pgrete Oct 23, 2021
c2acc9e
Merge branch 'main' into pgrete/sts
pgrete Dec 8, 2021
1f9cf68
Add isotropic Spitzer thermal conduction timestep
pgrete Dec 8, 2021
1b9a797
Calc isotropic, non-const thermal diff
pgrete Dec 8, 2021
16ad2ca
Merge branch 'pgrete/cooling-hotfix' into pgrete/sts
pgrete Apr 12, 2022
c9f1dfb
Fix calc of saturated heat flux
pgrete Apr 12, 2022
8599682
Add LimO3 limiter
pgrete May 13, 2022
4ebb5d6
Add limo3 convergence
pgrete May 13, 2022
8800b51
Fix LimO3 recon
pgrete May 14, 2022
b416ce0
Merge branch 'pgrete/limo3' into pgrete/sts
pgrete May 16, 2022
3986cee
Merge branch 'main' into pgrete/sts
pgrete Jun 7, 2022
3f071d4
Fix saturated conduction prefactor
pgrete Jun 7, 2022
9582764
Remove calc of saturated conduction from cond coeff
pgrete Jun 7, 2022
115285d
Add upwinded saturated conduction in x-dir
pgrete Jun 7, 2022
51dca4f
Add saturated conduction prefactor
pgrete Jun 8, 2022
8194e97
Add x2 and x3 sat cond fluxes
pgrete Jun 8, 2022
ca3c397
Increase default rkl2 ratio to 400 and allow flux correction for all …
pgrete Jun 8, 2022
6494ab2
Remove parabolic timestep constraint for saturated conduction limit r…
pgrete Aug 9, 2022
6df018f
Add perturb to cloud pgen
pgrete Aug 10, 2022
1d0cb19
Add perturb to B (knowing this is not great...)
pgrete Aug 12, 2022
300c6a0
Revert "Add perturb to B (knowing this is not great...)"
pgrete Sep 24, 2022
9205e56
Revert "Add perturb to cloud pgen"
pgrete Sep 24, 2022
1749bb8
Limit cooling to upper bound of TFloor and cooling table cutoff
pgrete Sep 24, 2022
2bc56f8
Add oblique B field
pgrete Sep 24, 2022
68de864
Move cluster pgen to MeshPgen to allow for reductions
pgrete Jun 2, 2023
abc0822
Prepare hse test case for init pert
pgrete Jun 2, 2023
3905cc0
Git add sigma_v plus test for cluster pgen
pgrete Jun 3, 2023
196afe9
Fix index error in cooling test
pgrete Jun 3, 2023
8d05808
Move iFT to utils from turb driver
pgrete Jun 3, 2023
e046a66
Isolate fmft construtor
pgrete Jun 5, 2023
fbbe2dc
Separate OU and FT parts from turbulence pgen
pgrete Jun 15, 2023
cd2420c
Make FMFT smooth and consistent for mesh refinement runs
pgrete Jun 15, 2023
83de454
Fix update of internal RNG state
pgrete Jun 15, 2023
8c74b1d
Remove restriction on unit domain dims
pgrete Jun 15, 2023
6ed8170
Fix k_vec check on device
pgrete Jun 16, 2023
2571e1b
Add init perturb for velocity field
pgrete Jun 16, 2023
429d1b1
Move construction of modes to shared util
pgrete Jun 16, 2023
a616d93
Allow ghost zones filling in FMFT
pgrete Jun 16, 2023
639fcc1
Add initial magnetic field perturbations
pgrete Jun 16, 2023
b31f88e
Add doc for cluster init perturb
pgrete Jun 16, 2023
3ebd164
Fix typo for using host view
pgrete Jun 16, 2023
ec12f61
Update Parthenon to PR887
forrestglines Jun 21, 2023
44b94aa
Bug fixes
forrestglines Jun 21, 2023
3a4a572
cpp-py-formatter
Jun 21, 2023
de70cf8
Bump Kokkos and Parthenon
pgrete Jun 22, 2023
b853423
Merge remote-tracking branch 'origin/pgrete/init-pert' into pgrete/tu…
pgrete Jun 22, 2023
7e70e95
Add forced refinement
pgrete Jun 22, 2023
c02ef1f
Merge branch 'main' into pgrete/turb-next
pgrete Aug 9, 2023
46a5f1d
Merge branch 'pgrete/donut' into pgrete/turb-next
pgrete Aug 21, 2023
8910136
Add rescaling for turb sims, need to fix norm
pgrete Aug 21, 2023
f1195ca
Fix rescale norm
pgrete Aug 21, 2023
882745d
Add blob injection
pgrete Aug 21, 2023
a633576
Add rescale and blob inject doc
pgrete Aug 22, 2023
3b6ac2e
Merge branch 'main' into pgrete/sts
pgrete Sep 25, 2023
b0bd7ca
Update coords and driver
pgrete Sep 25, 2023
4ab8834
Fix test cases and add success check
pgrete Sep 25, 2023
3199c6a
Merge branch 'main' into pgrete/sts
pgrete Sep 28, 2023
42f9f3c
Add isotropic shear viscosity
pgrete Sep 28, 2023
1c51435
Add viscosity test problem
pgrete Sep 28, 2023
5fea712
Add viscosity convergence test
pgrete Sep 28, 2023
2cd1e60
Add Ohmic resistivity
pgrete Oct 4, 2023
93fa27f
Remove visc pgen and move to diffusion pgen
pgrete Oct 4, 2023
bd3834f
Add resis. conv test to diffusion one
pgrete Oct 4, 2023
6e0151e
Add linwave3d decay diffusion test and fix parabolic dt
pgrete Oct 5, 2023
98f2f1f
Fix test thresholds
pgrete Oct 5, 2023
a039fd5
Merge branch 'forrestglines/parthenon-pr930' into pgrete/turb-next
pgrete Oct 20, 2023
090383b
Fix typo in blob injection and update interface
pgrete Oct 20, 2023
d37d2d2
Add temperature field output for turb driver
pgrete Oct 23, 2023
d397e22
Add skeleton infrastructure for UserOutput
pgrete Nov 15, 2023
07c5f57
Dump block center vol locs
pgrete Nov 15, 2023
59ea93a
Add infrastructure to dump per-block data
pgrete Nov 15, 2023
af99f2f
Add vel stats
pgrete Nov 16, 2023
7a18c72
Add support for vector if stats and scalar stats
pgrete Nov 16, 2023
b990cf6
Fix higher order moments
pgrete Nov 16, 2023
dfd6650
Add mass weighted per-block stats
pgrete Nov 17, 2023
a8a81e1
Log edotcool
pgrete Nov 17, 2023
b90fb0d
Merge remote-tracking branch 'origin/pgrete/diffusion' into pgrete/next
pgrete Nov 21, 2023
4525aaf
Add total weight to per-block output
pgrete Nov 22, 2023
71004d5
Add vorticity mag to turb driver
pgrete Nov 22, 2023
07a8ee9
Add vort_mag to stats
pgrete Nov 22, 2023
709dba4
Bump Parthenon
pgrete Feb 16, 2024
4d0e643
Add Phoebus tracers
pgrete Mar 4, 2024
4c5a777
Fix/adapt tracers to AthenaPK
pgrete Mar 4, 2024
b993570
Add tracer support to turbulence pgen
pgrete Mar 4, 2024
1465cd4
Fix swarm interface
pgrete Mar 6, 2024
db3c876
Fix particle init
pgrete Mar 6, 2024
13505df
Call FillTracer every cycle
pgrete Mar 6, 2024
0e86320
Added brief instructions for new particle field
pgrete Mar 6, 2024
4973d8d
Update tracers.cpp
mbruggen Mar 6, 2024
7c57381
Simplify/dedup code
pgrete Mar 7, 2024
46b48e1
Add lookback time
pgrete Mar 7, 2024
ddc5c78
Update turbulence.cpp
evan1022 Mar 8, 2024
94c1eca
Update turbulence.cpp
evan1022 Mar 8, 2024
b81eb66
Update turbulence.cpp
mbruggen Mar 8, 2024
7be5d87
Update tracers.cpp
mbruggen Mar 8, 2024
bc39143
Update turbulence.cpp
mbruggen Mar 8, 2024
582dc2a
Update turbulence.cpp
mbruggen Mar 8, 2024
0a1a76e
Use MeshData in FillTracers to allow reduction
pgrete Mar 11, 2024
62b759a
Update FillTracers internals to loop over blocks logic
pgrete Mar 11, 2024
78ac98a
Calc correlations
pgrete Mar 11, 2024
b1ee6c0
Dump corr to file
pgrete Mar 11, 2024
4eeffab
Import interpolation from Phoebus
pgrete Mar 11, 2024
59dbdfa
Adjust interface
pgrete Mar 11, 2024
71c2cd4
User interpolation for FillTracers
pgrete Mar 11, 2024
6bb07d7
Use 2nd order time integrator for particles
pgrete Mar 11, 2024
d2dba04
Update tracers.cpp
evan1022 Mar 11, 2024
f5707cf
Merge remote-tracking branch 'origin/evan1022/tracers' into pgrete/tr…
pgrete Mar 12, 2024
60e8bc1
Fix csv header
pgrete Mar 12, 2024
79ddc4f
Add s and sdot to csv output
pgrete Mar 13, 2024
60de202
Merge branch 'pgrete/turb-next' into pgrete/next
pgrete Mar 20, 2024
ea1a914
Merge branch 'pgrete/tracer' into pgrete/next-w-tracer
pgrete Mar 20, 2024
db034f7
Trigger Build
pgrete Mar 20, 2024
6d218f7
Move weight outside func
pgrete Mar 20, 2024
acb6d03
Fix enrollment of deltaEcool
pgrete Mar 20, 2024
bae0ce0
Changed nlookback to 14
mbruggen Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
build/tst/regression/outputs/cluster_hse/analytic_comparison.png
build/tst/regression/outputs/cluster_tabular_cooling/convergence.png
build/tst/regression/outputs/aniso_therm_cond_ring_conv/ring_convergence.png
build/tst/regression/outputs/aniso_therm_cond_gauss_conv/cond.png
build/tst/regression/outputs/diffusion/ohm.png
build/tst/regression/outputs/diffusion/visc.png
build/tst/regression/outputs/field_loop/field_loop.png
build/tst/regression/outputs/riemann_hydro/shock_tube.png
build/tst/regression/outputs/turbulence/parthenon.hst
Expand Down
50 changes: 43 additions & 7 deletions docs/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,22 @@ conserved to primitive conversion if both are defined.

#### Diffusive processes

##### Anisotropic thermal conduction (required MHD)
##### Isotropic (hydro and MHD )and anisotropic thermal conduction (only MHD)
In the presence of magnetic fields thermal conduction is becoming anisotropic with the flux along
the local magnetic field direction typically being much stronger than the flux perpendicular to the magnetic field.

From a theoretical point of view, thermal conduction is included in the system of MHD equations by an additional
term in the total energy equation:
```math
\delta_t E + \nabla \cdot (... + \mathbf{F}) \quad \mathrm{with}\\
\mathbf{F} = - \kappa \mathbf{\hat b} (\mathbf{\hat b \cdot \nabla T})
\delta_t E + \nabla \cdot (... + \mathbf{F}_\mathrm{c})
```
where the full thermal conduction flux $`\mathbf{F}_\mathrm{c}`$ contains both the classic thermal conduction
```math
\mathbf{F}_\mathrm{classic} = - \kappa \mathbf{\hat b} (\mathbf{\hat b \cdot \nabla T})
```
as well as the saturated flux (as introduced by [^CM77])
```math
\mathbf{F}_\mathrm{sat} = - 5 \phi \rho^{-1/2} p^{3/2} \mathrm{sgn}(\mathbf{\hat b \cdot \nabla T}) \mathbf{\hat b}
```

From an implementation point of view, two options implemented and can be configured within a `<diffusion>` block in the input file.
Expand All @@ -86,23 +93,52 @@ the integration step (before flux correction in case of AMR, and calculating the
Moreover, they are implemented explicitly, i.e., they add a (potentially very restrictive) constraint to the timestep due to the scaling with $`\propto \Delta_x^2`$.
Finally, we employ limiters for calculating the temperature gradients following Sharma & Hammett (2007)[^SH07].
This prevents unphysical conduction against the gradient, which may be introduced because the off-axis gradients are not centered on the interfaces.
Similarly, to account for the different nature of classic and saturated fluxes (parabolic and hyperbolic, respectively),
we follow [^M+12] and use a smooth transition
```math
\mathbf{F}_\mathrm{c} = \frac{q}{q + F_\mathrm{classic}} \mathbf{F}_\mathrm{classic} \quad \mathrm{with} \quad q = 5 \phi \rho^{-1/2} p^{3/2}
```
and upwinding of the hyperbolic, saturated fluxes.

To enable conduction, set
To enable thermal conduction, set

Parameter: `conduction` (string)
- `none` : No thermal conduction
- `isotropic` : Isotropic thermal conduction
- `anisotropic` : Anisotropic thermal conduction

In addition the coefficient (or diffusivity) needs to be set

Parameter: `conduction_coeff` (string)
- `spitzer` : Anisotropic thermal conduction with a temperature dependent classic Spitzer thermal conductivity
$`\kappa (T) = c_\kappa T^{5/2} \mathrm{erg/s/K/cm}`$ and
$`c_\kappa`$ being constant prefactor (set via `diffusion/spitzer_cond_in_erg_by_s_K_cm` with a default value of $`4.6\times10^{-7}`$). Note, as indicated by the units in the input parameter name, this kind of thermal conductivity requires a full set of units
$`c_\kappa`$ being constant prefactor (set via the additional `diffusion/spitzer_cond_in_erg_by_s_K_cm` parameter with a default value of $`4.6\times10^{-7}`$). Note, as indicated by the units in the input parameter name, this kind of thermal conductivity requires a full set of units
to be defined for the simulation.
- `thermal_diff` : Contrary to a temperature dependent conductivity, a simple thermal diffusivity can be used instead for which
- `fixed` : Contrary to a temperature dependent conductivity, a simple thermal diffusivity can be used instead for which
the conduction flux is $`\mathbf{F} = - \chi \rho \mathbf{\hat b} (\mathbf{\hat b \cdot \nabla \frac{p_\mathrm{th}}{\rho}})`$
Here, the strength, $`\chi`$, is controlled via the `thermal_diff_coeff_code` parameter in code units.
Here, the strength, $`\chi`$, is controlled via the additional `thermal_diff_coeff_code` parameter in code units.
Given the dimensions of $`L^2/T`$ it is referred to a thermal diffusivity rather than thermal conductivity.

Parameter: `conduction_sat_phi` (float)
- Default value 0.3\
Factor to account for the uncertainty in the estimated of saturated fluxes, see [^CM77].
Default value corresponds to the typical value used in literature and goes back to [^MMM80] and [^BM82].


[^SH07]:
P. Sharma and G. W. Hammett, "Preserving monotonicity in anisotropic diffusion," Journal of Computational Physics, vol. 227, no. 1, Art. no. 1, 2007, doi: https://doi.org/10.1016/j.jcp.2007.07.026.

[^M+12]:
A. Mignone, C. Zanni, P. Tzeferacos, B. van Straalen, P. Colella, and G. Bodo, “THE PLUTO CODE FOR ADAPTIVE MESH COMPUTATIONS IN ASTROPHYSICAL FLUID DYNAMICS,” The Astrophysical Journal Supplement Series, vol. 198, Art. no. 1, Dec. 2011, doi: https://doi.org/10.1088/0067-0049/198/1/7

[^CM77]:
L. Cowie and C. F. McKee, “The evaporation of spherical clouds in a hot gas. I. Classical and saturated mass loss rates.,” , vol. 211, pp. 135–146, Jan. 1977, doi: https://doi.org/10.1086/154911

[^MMM80]:
C. E. Max, C. F. McKee, and W. C. Mead, “A model for laser driven ablative implosions,” The Physics of Fluids, vol. 23, Art. no. 8, 1980, doi: https://doi.org/10.1063/1.863183

[^BM82]:
S. A. Balbus and C. F. McKee, “The evaporation of spherical clouds in a hot gas. III - Suprathermal evaporation,” , vol. 252, pp. 529–552, Jan. 1982, doi: https://doi.org/10.1086/159581

### Additional MHD options in `<hydro>` block

Expand Down
68 changes: 68 additions & 0 deletions docs/turbulence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Turbulence problem generator

The problem generator has been refactored from its implementation in K-Athena.
Until the documentation is fully adapted, please consult https://gitlab.com/pgrete/kathena/-/wikis/turbulence for general information.

A sample input file is provided in [turbulence.in](../inputs/turbulence.in)

## Blob injection

In order to study the evolution of (cold) clouds in a turbulent environment,
blobs can be injected to the simulation.
The injection is a one off mechanism controlled by the following parameters

```
<problem/turbulence>
# only one of the following three conditions can be set at a given time
inject_once_at_time = -1.0
inject_once_at_cycle = -1
inject_once_on_restart = false # should not be set in the input file, but only via the command line upon restart

inject_n_blobs = -1 # number of blob to inject

# then for the given number of blobs follow parameters need to be given (starting to count with 0)
inject_blob_radius_0 = ... # float, in code length units, no default value
inject_blob_loc_0 = ...,...,... # location vector of three comma-separated floats, in code length units, no default value
inject_blob_chi_0 = ... # float, dimensionless, no default value, density ratio to existing value

inject_blob_radius_1 = ...
...
```

In practice, this will result in blobs being seeded at a given time, cycle, or upon restart
by adjusting the density within the blob's radius by a factor of $\chi$ and
at the same time adjusting the temperature by a factor of $1/\chi$ so that the
blob remain in pressure equilibrium.

While this is an action that is performed once, it can be repeated upon restart (or a later
time) by resetting the variables.

A current restriction is that the blobs cannot be seeded across a domain boundary (i.e.,
the periodicity of the box is not taken into account).

## Rescaling **not recommended*

*The rescaling described in the following is generally not recommended, as it result in a
state that is not naturally reached.
Moreover, given the artificial nature of a hard reset, some time after the rescaling is
required for the system to readjust.

For non-isothermal simulations, the plasma will eventually heat up over time due to dissipation.
One possibility to remove that extra heat (or add heat), is to rescale the temperature in the simulation.
This can be done via the following parameters:

```
<problem/turbulence>
# only one of the following three conditions can be set at a given time
rescale_once_at_time = -1.0
rescale_once_at_cycle = -1
rescale_once_on_restart = false # should not be set in the input file, but only via the command line upon restart

rescale_to_rms_Ms = -1.0
```

As the parameters suggest, rescaling is a one off action (though it can be repeated when
the parameters are set again for a subsequent restart).
The density and velocity field are not changed, only the specific internal energy is
adjusted so that the volume-weighted root mean squared sonic Mach number matches
the target value.
2 changes: 1 addition & 1 deletion external/parthenon
18 changes: 14 additions & 4 deletions inputs/diffusion.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# AthenaPK - a performance portable block structured AMR MHD code
# Copyright (c) 2021, Athena Parthenon Collaboration. All rights reserved.
# Copyright (c) 2021-2023, Athena Parthenon Collaboration. All rights reserved.
# Licensed under the BSD 3-Clause License (the "LICENSE");

<comment>
problem = Thermal diffusion setup
problem = Diffusion setup (for thermal, momentum and Ohmic diffusion tests)

<job>
problem_id = diffusion
Expand All @@ -14,7 +14,8 @@ Bx = 1.0 # Bx for x1 step function (permutated for iprobs in other direction
By = 0.0 # By for x1 step function (permutated for iprobs in other directions)

#iprob = 10 # Diffusion of Gaussian profile in x1 direction
sigma = 0.1 # standard deviation of Gaussian for iprob=10
t0 = 0.5 # Temporal offset for initial Gaussian profile
amp = 1e-6 # Amplitude of Gaussian profile

iprob = 20 # ring diffusion in x1-x2 plane; 21 for x2-x3 plane; 22 for x3-x1 plane

Expand Down Expand Up @@ -59,8 +60,17 @@ reconstruction = dc
gamma = 2.0

<diffusion>
conduction = thermal_diff
integrator = rkl2
conduction = anisotropic
conduction_coeff = fixed
thermal_diff_coeff_code = 0.01
viscosity = none # none (disabled), isotropic, or anisotropic
viscosity_coeff = fixed
mom_diff_coeff_code = 0.25
resistivity = none # none (disabled) or isotropic
resistivity_coeff = fixed
ohm_diff_coeff_code = 0.25
rkl2_max_dt_ratio = 100.0

<parthenon/output0>
file_type = hdf5
Expand Down
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ add_executable(
eos/adiabatic_glmmhd.cpp
units.hpp
eos/adiabatic_hydro.cpp
hydro/diffusion/diffusion.hpp
hydro/diffusion/conduction.cpp
hydro/diffusion/diffusion.cpp
hydro/diffusion/diffusion.hpp
hydro/diffusion/resistivity.cpp
hydro/diffusion/viscosity.cpp
hydro/hydro_driver.cpp
hydro/hydro.cpp
hydro/glmmhd/dedner_source.cpp
hydro/prolongation/custom_ops.hpp
hydro/srcterms/gravitational_field.hpp
hydro/srcterms/tabular_cooling.hpp
hydro/srcterms/tabular_cooling.cpp
outputs/per_block.cpp
refinement/gradient.cpp
refinement/other.cpp
tracers/tracers.cpp
tracers/tracers.hpp
utils/few_modes_ft.cpp
utils/few_modes_ft.hpp
utils/interpolation.hpp
utils/robust.hpp
)

add_subdirectory(pgen)
Expand Down
Loading