Skip to content

swarmrl.engine.engine Module API Reference

Parent class for the engine.

Engine

Parent class for an engine.

An engine is an object that can generate data for the environment. Currently we have only an espresso model but this should be kept generic to allow for an experimental interface.

Source code in swarmrl/engine/engine.py
 8
 9
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
class Engine:
    """
    Parent class for an engine.

    An engine is an object that can generate data for the environment. Currently we
    have only an espresso model but this should be kept generic to allow for an
    experimental interface.
    """

    def integrate(
        self,
        n_slices: int,
        force_model: ForceFunction,
    ) -> None:
        """

        Parameters
        ----------
        n_slices: int
            Number of time slices to integrate
        force_model
            A an instance of ForceFunction
        """
        raise NotImplementedError

    def get_particle_data(self) -> dict:
        """
        Get type, id, position, velocity and director of the particles
        as a dict of np.array
        """
        raise NotImplementedError

    def finalize(self):
        """
        Optional: to clean up after finishing the simulation (e.g. writing the last
        chunks of trajectory)
        """
        pass

finalize()

Optional: to clean up after finishing the simulation (e.g. writing the last chunks of trajectory)

Source code in swarmrl/engine/engine.py
40
41
42
43
44
45
def finalize(self):
    """
    Optional: to clean up after finishing the simulation (e.g. writing the last
    chunks of trajectory)
    """
    pass

get_particle_data()

Get type, id, position, velocity and director of the particles as a dict of np.array

Source code in swarmrl/engine/engine.py
33
34
35
36
37
38
def get_particle_data(self) -> dict:
    """
    Get type, id, position, velocity and director of the particles
    as a dict of np.array
    """
    raise NotImplementedError

integrate(n_slices, force_model)

Parameters

n_slices: int Number of time slices to integrate force_model A an instance of ForceFunction

Source code in swarmrl/engine/engine.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def integrate(
    self,
    n_slices: int,
    force_model: ForceFunction,
) -> None:
    """

    Parameters
    ----------
    n_slices: int
        Number of time slices to integrate
    force_model
        A an instance of ForceFunction
    """
    raise NotImplementedError