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
5 changes: 5 additions & 0 deletions src/plasma_simulation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from plasma_simulation.base import SimulationBase

__all__ = [
"SimulationBase",
]
60 changes: 60 additions & 0 deletions src/plasma_simulation/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from abc import ABCMeta, abstractmethod


class SimulationBase(metaclass=ABCMeta):
"""Abstract base class for simulations."""

@abstractmethod
def __init__(self, **kwargs):
"""Initialize the simulation."""
pass

@abstractmethod
def allocate(self, verbose: bool = False):
"""Allocate the simulation variables in memory."""
pass

@abstractmethod
def save_geometry_and_equil_vtk(self, verbose: bool = False):
"""Save geometry and equilibrium in VTK format."""
pass

@abstractmethod
def initialize_data_storage(self, verbose: bool = False):
"""Initialize the simulation data storage."""
pass

@abstractmethod
def run(self, verbose: bool = False):
"""Run the simulation."""
pass

@abstractmethod
def pproc(self, verbose: bool = False):
"""Post-process the simulation results."""
pass

@abstractmethod
def load_plotting_data(self, verbose: bool = False):
"""Load post-processed data for visualization."""
pass

@abstractmethod
def to_dict(self) -> dict:
"""Serialize the simulation configuration to a dictionary."""
pass

@abstractmethod
def from_dict(cls, dct: dict):
"""Deserialize a simulation configuration from a dictionary."""
pass

@abstractmethod
def from_file(cls, file_path: str):
"""Deserialize a simulation configuration from a file."""
pass

@abstractmethod
def export(self, file_path: str):
"""Export a simulation configuration to a YAML or JSON file based on the file extension."""
pass
18 changes: 18 additions & 0 deletions src/plasma_simulation/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

from plasma_simulation import SimulationBase


def test_import_app():
# Import check and API surface check.
assert SimulationBase is not None


def test_simulation_base_is_abstract():
with pytest.raises(TypeError, match="abstract class SimulationBase"):
SimulationBase()


if __name__ == "__main__":
test_import_app()
test_simulation_base_is_abstract()
Empty file.
9 changes: 0 additions & 9 deletions src/plasma_simulation/tests/unit/test_app.py

This file was deleted.

Loading