diff --git a/_modules/gym_electric_motor/physical_system_wrappers/cos_sin_processor.html b/_modules/gym_electric_motor/physical_system_wrappers/cos_sin_processor.html
index 858530e5..ce1c6f13 100644
--- a/_modules/gym_electric_motor/physical_system_wrappers/cos_sin_processor.html
+++ b/_modules/gym_electric_motor/physical_system_wrappers/cos_sin_processor.html
@@ -168,7 +168,7 @@
Source code for gym_electric_motor.physical_system_wrappers.cos_sin_processo
return np.concatenate(
(
state,
- [np.cos(state[self._angle_index]), np.sin(state[self._angle_index])],
+ [np.cos(state[self._angle_index]*np.pi), np.sin(state[self._angle_index])*np.pi],
)
)
diff --git a/_modules/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.html b/_modules/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.html
index 72544ba3..89af8656 100644
--- a/_modules/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.html
+++ b/_modules/gym_electric_motor/physical_system_wrappers/dq_to_abc_action_processor.html
@@ -89,7 +89,6 @@ Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
from .physical_system_wrapper import PhysicalSystemWrapper
-
[docs]class DqToAbcActionProcessor(PhysicalSystemWrapper):
"""The DqToAbcActionProcessor converts an inner system with an AC motor and actions in abc coordinates to a
system to which actions in the dq-coordinate system can be applied.
@@ -115,12 +114,11 @@
Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
def wrapper(callable_):
for motor_type in motor_types:
cls._registry[motor_type] = callable_
-
return wrapper
@classmethod
def make(cls, motor_type, *args, **kwargs):
- assert motor_type in cls._registry.keys(), f"Not supported motor_type {motor_type}."
+ assert motor_type in cls._registry.keys(), f'Not supported motor_type {motor_type}.'
class_ = cls._registry[motor_type]
inst = class_(*args, **kwargs)
return inst
@@ -142,21 +140,20 @@ Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
[docs] def set_physical_system(self, physical_system):
# Docstring of super class
-
assert isinstance(
-
physical_system.electrical_motor, ps.ThreePhaseMotor
-
), "The motor in the system has to derive from the ThreePhaseMotor to define transformations."
+
assert isinstance(physical_system.electrical_motor, ps.ThreePhaseMotor), \
+
'The motor in the system has to derive from the ThreePhaseMotor to define transformations.'
super().set_physical_system(physical_system)
-
self._omega_index = physical_system.state_names.index("omega")
+
self._omega_index = physical_system.state_names.index('omega')
self._angle_index = physical_system.state_names.index(self._angle_name)
-
assert self._angle_name in physical_system.state_names, (
-
f"Angle {self._angle_name} not in the states of the physical system. "
-
f"Probably a flux observer is required."
-
)
+
self._pole_pair_number = physical_system._electrical_motor.motor_parameter['p']
+
assert self._angle_name in physical_system.state_names, \
+
f'Angle {self._angle_name} not in the states of the physical system. ' \
+
f'Probably a flux observer is required.'
self._angle_advance = 0.5
# If dead time has been added to the system increase the angle advance by the amount of dead time steps
-
if hasattr(physical_system, "dead_time"):
+
if hasattr(physical_system, 'dead_time'):
self._angle_advance += physical_system.dead_time
return self
@@ -171,10 +168,12 @@ Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
return normalized_state
def _advance_angle(self, state):
- return state[self._angle_index] + self._angle_advance * self._physical_system.tau * state[self._omega_index]
+ return state[self._angle_index] + self._angle_advance \
+ * self._physical_system.tau * state[self._omega_index] * self._pole_pair_number
class _ClassicDqToAbcActionProcessor(DqToAbcActionProcessor):
+
@property
def action_space(self):
return gymnasium.spaces.Box(-1, 1, shape=(2,), dtype=np.float64)
@@ -188,24 +187,25 @@ Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
return normalized_state
-DqToAbcActionProcessor.register_transformation(["PMSM"])(
- lambda angle_name="epsilon", *args, **kwargs: _ClassicDqToAbcActionProcessor(angle_name, *args, **kwargs)
+DqToAbcActionProcessor.register_transformation(['PMSM'])(
+ lambda angle_name='epsilon', *args, **kwargs: _ClassicDqToAbcActionProcessor(angle_name, *args, **kwargs)
)
-DqToAbcActionProcessor.register_transformation(["SCIM"])(
- lambda angle_name="psi_angle", *args, **kwargs: _ClassicDqToAbcActionProcessor(angle_name, *args, **kwargs)
+DqToAbcActionProcessor.register_transformation(['SCIM'])(
+ lambda angle_name='psi_angle', *args, **kwargs: _ClassicDqToAbcActionProcessor(angle_name, *args, **kwargs)
)
-@DqToAbcActionProcessor.register_transformation(["DFIM"])
+@DqToAbcActionProcessor.register_transformation(['DFIM'])
class _DFIMDqToAbcActionProcessor(DqToAbcActionProcessor):
+
@property
def action_space(self):
return gymnasium.spaces.Box(-1, 1, shape=(4,))
def __init__(self, physical_system=None):
- super().__init__("epsilon", physical_system=physical_system)
- self._flux_angle_name = "psi_abs"
+ super().__init__('epsilon', physical_system=physical_system)
+ self._flux_angle_name = 'psi_abs'
self._flux_angle_index = None
def simulate(self, action):
@@ -228,8 +228,26 @@ Source code for gym_electric_motor.physical_system_wrappers.dq_to_abc_action
def set_physical_system(self, physical_system):
super().set_physical_system(physical_system)
- self._flux_angle_index = physical_system.state_names.index("psi_angle")
+ self._flux_angle_index = physical_system.state_names.index('psi_angle')
return self
+
+@DqToAbcActionProcessor.register_transformation(['EESM'])
+class _EESMDqToAbcActionProcessor(DqToAbcActionProcessor):
+ @property
+ def action_space(self):
+ return gymnasium.spaces.Box(-1, 1, shape=(3,))
+
+ def __init__(self, physical_system=None):
+ super().__init__('epsilon', physical_system=physical_system)
+
+ def simulate(self, action):
+ # Docstring of superclass
+ advanced_angle = self._advance_angle(self._state)
+ abc_action = self._transformation(action[:-1], advanced_angle)
+ abc_action = np.append(abc_action, action[-1])
+ normalized_state = self._physical_system.simulate(abc_action)
+ self._state = normalized_state * self._physical_system.limits
+ return normalized_state