PyMHD 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymhd/__init__.py +31 -0
- pymhd/derivatives/TENO.py +278 -0
- pymhd/derivatives/WENO.py +323 -0
- pymhd/derivatives/__init__.py +24 -0
- pymhd/derivatives/compact.py +365 -0
- pymhd/derivatives/derivative.py +926 -0
- pymhd/numdiss.py +598 -0
- pymhd/plot/__init__.py +48 -0
- pymhd/plot/nd.py +1519 -0
- pymhd/plot/slc.py +648 -0
- pymhd/plot/spc.py +249 -0
- pymhd/preprocess/Athena.py +847 -0
- pymhd/preprocess/__init__.py +69 -0
- pymhd/preprocess/helper/NOTICE +42 -0
- pymhd/preprocess/helper/bin_convert.py +2000 -0
- pymhd/preprocess/helper/make_athdf.py +45 -0
- pymhd/spectra.py +376 -0
- pymhd/turbulence.py +917 -0
- pymhd-0.1.0.dist-info/METADATA +100 -0
- pymhd-0.1.0.dist-info/RECORD +22 -0
- pymhd-0.1.0.dist-info/WHEEL +4 -0
- pymhd-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# PyMHD: Python for Magnetohydrodynamic Turbulence.
|
|
2
|
+
# Copyright (c) 2026 Yuyang Hua (华宇阳)
|
|
3
|
+
# License: MIT
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
pymhd/preprocess/__init__.py
|
|
7
|
+
----------------------------
|
|
8
|
+
|
|
9
|
+
Unified interface for extracting turbulence data from simulation outputs. Currently supports:
|
|
10
|
+
- Athena++/AthenaK/AthenaPK output files.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Sequence
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from ..turbulence import Turbulence
|
|
19
|
+
|
|
20
|
+
def output2turbulence(
|
|
21
|
+
code : str,
|
|
22
|
+
outputs : str | Path | Sequence[str | Path] | None = None,
|
|
23
|
+
outn : str | None = None,
|
|
24
|
+
inputfile: str | Path | None = None,
|
|
25
|
+
t1 : float | None = None,
|
|
26
|
+
t2 : float | None = None,
|
|
27
|
+
casename : str | None = None,
|
|
28
|
+
) -> Turbulence:
|
|
29
|
+
"""Extract simulation output data and build a Turbulence object
|
|
30
|
+
|
|
31
|
+
Unified interface that dispatches to code-specific implementations.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
code : simulation code name. Use 'Athena' for Athena++/AthenaK/AthenaPK.
|
|
36
|
+
outputs : output file paths or glob pattern string
|
|
37
|
+
e.g., ['HGB.prim.00000.athdf', 'HGB.prim.00001.athdf'] or './outputs/*.prim.*.athdf';
|
|
38
|
+
If None, a default pattern inferred from the input file is adopted.
|
|
39
|
+
outn : output ID for resolving output file pattern when 'outputs' is None.
|
|
40
|
+
e.g., 'prim' for slice and spectra plots, 'nd' for numerical dissipation analysis.
|
|
41
|
+
inputfile : path to input parameter file, e.g. 'athinput.hgb', 'turb.athinput';
|
|
42
|
+
If None, automatically detect default Athena(++/K/PK) input files.
|
|
43
|
+
t1 : start time for filtering, defaults to None (no lower limit)
|
|
44
|
+
t2 : end time for filtering, defaults to None (no upper limit)
|
|
45
|
+
casename : case name, defaults to None (use parent directory name)
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
Turbulence: Turbulence object containing extracted field data
|
|
50
|
+
|
|
51
|
+
Examples
|
|
52
|
+
--------
|
|
53
|
+
>>> from pymhd import output2turbulence
|
|
54
|
+
>>> turbulence = output2turbulence(code='Athena', t1=10.0, t2=20.0)
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
if code != "Athena":
|
|
58
|
+
raise ValueError(
|
|
59
|
+
f"Unsupported code: '{code}'. Use 'Athena' as unified entry for Athena++/AthenaK/AthenaPK."
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
from .Athena import output2turbulence as o2t
|
|
63
|
+
|
|
64
|
+
return o2t(casename=casename, outputs=outputs, outn=outn, inputfile=inputfile, t1=t1, t2=t2)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
"output2turbulence"
|
|
69
|
+
]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Third-Party Notice: AthenaK
|
|
2
|
+
|
|
3
|
+
This directory includes code adapted from AthenaK:
|
|
4
|
+
- Upstream repository: https://github.com/IAS-Astrophysics/athenak
|
|
5
|
+
- License: BSD 3-Clause License
|
|
6
|
+
- Covered files:
|
|
7
|
+
* bin_convert.py
|
|
8
|
+
* make_athdf.py
|
|
9
|
+
- Modification notice:
|
|
10
|
+
* Adapted for integration in PyMHD.
|
|
11
|
+
|
|
12
|
+
The following is the original BSD 3-Clause License:
|
|
13
|
+
|
|
14
|
+
BSD 3-Clause License
|
|
15
|
+
|
|
16
|
+
Copyright (c) 2020, Institute for Advanced Study / High-Performance Computing / jmstone / Athena-Parthenon
|
|
17
|
+
All rights reserved.
|
|
18
|
+
|
|
19
|
+
Redistribution and use in source and binary forms, with or without
|
|
20
|
+
modification, are permitted provided that the following conditions are met:
|
|
21
|
+
|
|
22
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
23
|
+
list of conditions and the following disclaimer.
|
|
24
|
+
|
|
25
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
26
|
+
this list of conditions and the following disclaimer in the documentation
|
|
27
|
+
and/or other materials provided with the distribution.
|
|
28
|
+
|
|
29
|
+
* Neither the name of the copyright holder nor the names of its
|
|
30
|
+
contributors may be used to endorse or promote products derived from
|
|
31
|
+
this software without specific prior written permission.
|
|
32
|
+
|
|
33
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
34
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
35
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
36
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
37
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
38
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
39
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
40
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
41
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
42
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|