Skip to content

Simulations

Simulation ¤

Bases: ABC

Source code in feniax/simulations/simulation.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class Simulation(ABC):

    def __init__(self, systems: dict[system.System], sol: solution.Solution, settings):
        """Manages how the various systems are run

        Parameters
        ----------
        systems : dict[system.System]
            System objects
        sol : solution.Solution
            Solution object
        settings : 
            Simulation settings

        """

        self.systems = systems
        self.sol = sol
        self.settings = settings

    @abstractmethod
    def trigger(self):
        """Launch the simulations

        """
        pass

    @abstractmethod
    def _run_systems(self):
        """Implements logic to run the systems: serial, parallel...

        """
        pass

    @abstractmethod
    def _post_run(self):
        """Anything to run after the systems are solved

        """
        pass

    def __init_subclass__(cls, **kwargs):
        assert "cls_name" in kwargs
        super().__init_subclass__()
        if kwargs["cls_name"] in __SIMULATION_DICT__:
            raise ValueError("Name %s already registered!" % kwargs["cls_name"])
        __SIMULATION_DICT__[kwargs["cls_name"]] = cls

__init__(systems, sol, settings) ¤

Manages how the various systems are run

Parameters:

Name Type Description Default
systems dict[System]

System objects

required
sol Solution

Solution object

required
settings

Simulation settings

required
Source code in feniax/simulations/simulation.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self, systems: dict[system.System], sol: solution.Solution, settings):
    """Manages how the various systems are run

    Parameters
    ----------
    systems : dict[system.System]
        System objects
    sol : solution.Solution
        Solution object
    settings : 
        Simulation settings

    """

    self.systems = systems
    self.sol = sol
    self.settings = settings

trigger() abstractmethod ¤

Launch the simulations

Source code in feniax/simulations/simulation.py
30
31
32
33
34
35
@abstractmethod
def trigger(self):
    """Launch the simulations

    """
    pass