Skip to content

swarmrl.observables.director Module API Reference

Give position and angle.

Director

Bases: Observable, ABC

Position in box observable.

Source code in swarmrl/observables/director.py
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
57
58
class Director(Observable, ABC):
    """
    Position in box observable.
    """

    def __init__(self, particle_type: int = 0):
        """
        Constructor for the observable.

        Parameters
        ----------
        box_length : np.ndarray
                Length of the box with which to normalize.
        """
        super().__init__(particle_type=particle_type)

    def compute_single_observable(self, index: int, colloids: list):
        """
        Compute the position of the colloid.

        Parameters
        ----------
        index : int
                Index of the colloid for which the observable should be computed.
        other_colloids
                Other colloids in the system.
        """
        colloid = colloids[index]

        director = onp.copy(colloid.director)

        return director

    def compute_observable(self, colloids: List[Colloid]):
        """
        Compute the current state observable for all colloids.

        Parameters
        ----------
        colloids : List[Colloid] (n_colloids, )
                List of all colloids in the system.
        """
        indices = self.get_colloid_indices(colloids)

        return [self.compute_single_observable(i, colloids) for i in indices]

__init__(particle_type=0)

Constructor for the observable.

Parameters

box_length : np.ndarray Length of the box with which to normalize.

Source code in swarmrl/observables/director.py
19
20
21
22
23
24
25
26
27
28
def __init__(self, particle_type: int = 0):
    """
    Constructor for the observable.

    Parameters
    ----------
    box_length : np.ndarray
            Length of the box with which to normalize.
    """
    super().__init__(particle_type=particle_type)

compute_observable(colloids)

Compute the current state observable for all colloids.

Parameters

colloids : List[Colloid] (n_colloids, ) List of all colloids in the system.

Source code in swarmrl/observables/director.py
47
48
49
50
51
52
53
54
55
56
57
58
def compute_observable(self, colloids: List[Colloid]):
    """
    Compute the current state observable for all colloids.

    Parameters
    ----------
    colloids : List[Colloid] (n_colloids, )
            List of all colloids in the system.
    """
    indices = self.get_colloid_indices(colloids)

    return [self.compute_single_observable(i, colloids) for i in indices]

compute_single_observable(index, colloids)

Compute the position of the colloid.

Parameters

index : int Index of the colloid for which the observable should be computed. other_colloids Other colloids in the system.

Source code in swarmrl/observables/director.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def compute_single_observable(self, index: int, colloids: list):
    """
    Compute the position of the colloid.

    Parameters
    ----------
    index : int
            Index of the colloid for which the observable should be computed.
    other_colloids
            Other colloids in the system.
    """
    colloid = colloids[index]

    director = onp.copy(colloid.director)

    return director