Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/reusable-scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
TEST_FILES="bsplines/tests/ console/tests/ fields_background/tests/ geometry/tests/ initial/tests/ kinetic_background/tests/ linear_algebra/tests/"
;;
shard-2)
TEST_FILES="propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/ dispersion_relations/tests/ io/tests/ simulation/tests/ models/tests/test_gpu_LinearVlasovAmpereOneSpecies.py models/tests/test_gpu_VlasovAmpereOneSpecies.py"
TEST_FILES="api/tests/ propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/ dispersion_relations/tests/ io/tests/ simulation/tests/ models/tests/test_gpu_LinearVlasovAmpereOneSpecies.py models/tests/test_gpu_VlasovAmpereOneSpecies.py"
;;
shard-3)
TEST_FILES="feec/tests/"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- shard: shard-1
test_files: bsplines/tests/ console/tests/ fields_background/tests/ geometry/tests/ initial/tests/ kinetic_background/tests/ linear_algebra/tests/
- shard: shard-2
test_files: propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/ dispersion_relations/tests/ io/tests/ simulation/tests/ models/tests/test_gpu_LinearVlasovAmpereOneSpecies.py models/tests/test_gpu_VlasovAmpereOneSpecies.py
test_files: api/tests/ propagators/tests/ ode/tests/ polar/tests/ post_processing/tests/ dispersion_relations/tests/ io/tests/ simulation/tests/ models/tests/test_gpu_LinearVlasovAmpereOneSpecies.py models/tests/test_gpu_VlasovAmpereOneSpecies.py
- shard: shard-3
test_files: feec/tests/
- shard: shard-4
Expand Down
6 changes: 6 additions & 0 deletions src/struphy/api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from struphy.models.cold_plasma import ColdPlasma
from struphy.models.cold_plasma_vlasov import ColdPlasmaVlasov
from struphy.models.curl_curl import CurlCurl
from struphy.models.deterministic_particle_diffusion import (
DeterministicParticleDiffusion,
)
Expand All @@ -9,6 +10,7 @@
from struphy.models.guiding_center import GuidingCenter
from struphy.models.gyrokinetic_poisson import GyrokineticPoisson
from struphy.models.hasegawa_wakatani import HasegawaWakatani
from struphy.models.incompressible_navier_stokes_sph import IncompressibleNavierStokesSPH
from struphy.models.linear_extended_mh_duniform import LinearExtendedMHDuniform
from struphy.models.linear_mhd import LinearMHD
from struphy.models.linear_mhd_driftkinetic_cc import LinearMHDDriftkineticCC
Expand All @@ -25,6 +27,7 @@
from struphy.models.shear_alfven import ShearAlfven
from struphy.models.shear_alfven_curl_curl import ShearAlfvenCurlCurl
from struphy.models.shear_alfven_curl_curl_with_proj import ShearAlfvenCurlCurlwithProj
from struphy.models.toy_drift import ToyDrift
from struphy.models.two_fluid_quasi_neutral_toy import TwoFluidQuasiNeutralToy
from struphy.models.variational_barotropic_fluid import VariationalBarotropicFluid
from struphy.models.variational_compressible_fluid import VariationalCompressibleFluid
Expand All @@ -49,11 +52,13 @@
__all__ = [
"ColdPlasma",
"ColdPlasmaVlasov",
"CurlCurl",
"DeterministicParticleDiffusion",
"DriftKineticElectrostaticAdiabatic",
"GuidingCenter",
"GyrokineticPoisson",
"HasegawaWakatani",
"IncompressibleNavierStokesSPH",
"LinearExtendedMHDuniform",
"LinearMHD",
"LinearMHDDriftkineticCC",
Expand All @@ -68,6 +73,7 @@
"ShearAlfven",
"ShearAlfvenCurlCurl",
"ShearAlfvenCurlCurlwithProj",
"ToyDrift",
"TwoFluidQuasiNeutralToy",
"VariationalBarotropicFluid",
"VariationalCompressibleFluid",
Expand Down
Empty file.
26 changes: 26 additions & 0 deletions src/struphy/api/tests/test_public_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Regression coverage for the public lazy imports."""

import ast
import subprocess
import sys
from pathlib import Path

import pytest

pytestmark = pytest.mark.mpi_skip


def test_post_processing_exports():
Expand Down Expand Up @@ -31,3 +37,23 @@ def test_post_processing_exports():
capture_output=True,
text=True,
)


def test_api_models_match_models():
# Parse instead of import: importing struphy.api.models loads every model.
import struphy.models

api_init = Path(struphy.models.__file__).parents[1] / "api" / "models" / "__init__.py"
tree = ast.parse(api_init.read_text())
(api_all,) = [
ast.literal_eval(node.value)
for node in tree.body
if isinstance(node, ast.Assign) and any(getattr(t, "id", None) == "__all__" for t in node.targets)
]
api_imports = {
alias.name: node.module for node in tree.body if isinstance(node, ast.ImportFrom) for alias in node.names
}
assert sorted(api_all) == sorted(struphy.models.__all__)
assert sorted(struphy.models.__all__) == sorted(struphy.models._LAZY_IMPORTS)
# every exported name is imported from the module that defines it
assert api_imports == struphy.models._LAZY_IMPORTS
1 change: 1 addition & 0 deletions src/struphy/console/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def struphy_test(

if "unit" in group:
list_of_tests = [
f"{LIBPATH}/api/tests/",
f"{LIBPATH}/bsplines/tests/",
f"{LIBPATH}/console/tests/",
f"{LIBPATH}/dispersion_relations/tests/",
Expand Down
6 changes: 4 additions & 2 deletions src/struphy/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ class StruphyModel(metaclass=StruphyModelMeta):

Notes
-----
All Struphy models must be subclasses of ``StruphyModel`` and should be added to ``struphy/models/``
in one of the modules: ``fluid.py``, ``kinetic.py``, ``hybrid.py``, or ``toy.py``.
All Struphy models must be subclasses of ``StruphyModel``. Each model lives in its own module
``struphy/models/<model_name>.py`` (snake case of the class name). After adding a model, regenerate
``struphy/models/__init__.py`` with ``struphy build-init-files`` and add the model by hand to
``struphy/api/models/__init__.py``.

Time integration is performed by calling the ``integrate()`` method with a time step and
splitting algorithm (Lie-Trotter or Strang). The model manages the execution of all propagators
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/propagators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Options(OptionsBase):
# specific literals
OptsTemplate = Literal["implicit", "explicit"]
# propagator options
opt1: str = ("implicit",)
opt1: OptsTemplate = "implicit"

def __post_init__(self):
# checks
Expand Down
Loading