Torque Control Permanent Magnet Synchronous Motor Environment
- class gym_electric_motor.envs.ContTorqueControlPermanentMagnetSynchronousMotorEnv(supply=None, converter=None, motor=None, load=None, ode_solver=None, reward_function=None, reference_generator=None, visualization=None, state_filter=None, callbacks=(), constraints=(<gym_electric_motor.constraints.SquaredConstraint object>, ), calc_jacobian=True, tau=0.0001, physical_system_wrappers=(), **kwargs)[source]
- Bases: - ElectricMotorEnvironment- Description:
- Environment to simulate a abc-domain continuous control set torque controlled permanent magnet synchr. motor. 
- Key:
- 'Cont-TC-PMSM-v0'
- Default Components:
- Supply: - IdealVoltageSupply
- Converter: - ContB6BridgeConverter
- Load: - ConstantSpeedLoad
- Ode-Solver: - EulerSolver
- Reference Generator: - WienerProcessReferenceGeneratorReference Quantity:- 'torque'
- Reward Function: - WeightedSumOfErrorsreward_weights:- 'torque' = 1.0
- Visualization: - MotorDashboardtorque and action plots
- Constraints: - SquaredConstrainton the currents- 'i_sd', 'i_sq'
 
- State Variables:
- ['omega' , 'torque', 'i_sd', 'i_sq', 'i_a', 'i_b', 'i_c', 'u_sd', 'u_sq', 'u_a', 'u_b', 'u_c', 'u_sup']
- Reference Variables:
- ['torque']
- Control Cycle Time:
- tau = 1e-4 seconds 
- Observation Space:
- Type: Tuple(State_Space, Reference_Space) 
- State Space:
- Box(low=13 * [-1], high=13 * [1]) 
- Reference Space:
- Box(low=[-1, -1], high=[1, 1]) 
- Action Space:
- Box(low=[-1, -1, -1], high=[1, 1, 1]) 
- Initial State:
- Zeros on all state variables. 
 - Example - >>> import gym_electric_motor as gem >>> from gym_electric_motor.reference_generators import LaplaceProcessReferenceGenerator >>> >>> # Select a different ode_solver with default parameters by passing a keystring >>> my_overridden_solver = 'scipy.solve_ivp' >>> >>> # Update the default arguments to the voltage supply by passing a parameter dict >>> my_changed_voltage_supply_args = {'u_nominal': 400.0} >>> >>> # Replace the reference generator by passing a new instance >>> my_new_ref_gen_instance = LaplaceProcessReferenceGenerator( ... reference_state='torque', ... sigma_range=(1e-3, 1e-2) ... ) >>> env = gem.make( ... 'Cont-TC-PMSM-v0', ... voltage_supply=my_changed_voltage_supply_args, ... ode_solver=my_overridden_solver, ... reference_generator=my_new_ref_gen_instance ... ) >>> terminated = True >>> for _ in range(1000): >>> if terminated: >>> state, reference = env.reset() >>> (state, reference), reward, terminated, truncated, _ = env.step(env.action_space.sample()) - Parameters:
- supply (env-arg) – Specification of the - VoltageSupplyfor the environment
- converter (env-arg) – Specification of the - PowerElectronicConverterfor the environment
- motor (env-arg) – Specification of the - ElectricMotorfor the environment
- load (env-arg) – Specification of the - MechanicalLoadfor the environment
- ode_solver (env-arg) – Specification of the - OdeSolverfor the environment
- reward_function (env-arg) – Specification of the - RewardFunctionfor the environment
- reference_generator (env-arg) – Specification of the - ReferenceGeneratorfor the environment
- visualization (env-arg) – Specification of the - ElectricMotorVisualizationfor the environment
- constraints (iterable(str/Constraint)) – - All Constraints of the environment. - str: A LimitConstraints for states (episode terminates, if the quantity exceeds the limit) 
 - can be directly specified by passing the state name here (e.g. ‘i’, ‘omega’) - instance of Constraint: More complex constraints (e.g. the SquaredConstraint can be initialized and 
 - passed to the environment. 
- calc_jacobian (bool) – Flag, if the jacobian of the environment shall be taken into account during the simulation. This may lead to speed improvements. Default: True 
- tau (float) – Duration of one control step in seconds. Default: 1e-4. 
- state_filter (list(str)) – List of states that shall be returned to the agent. Default: None (no filter) 
- callbacks (list(Callback)) – Callbacks for user interaction. Default: () 
- physical_system_wrappers (list(PhysicalSystemWrapper)) – List of Physical System Wrappers to modify the 
- Default (actions to and states from the physical system before they are used in the environment.) – () 
 
 - Note on the env-arg type:
- All parameters of type env-arg can be selected as one of the following types: - instance: Pass an already instantiated object derived from the corresponding base class (e.g. - reward_function=MyRewardFunction()). This is directly used in the environment.- dict: Pass a dict to update the default parameters of the default type. (e.g. - visualization=dict(state_plots=('omega', 'u')))- str: Pass a string out of the registered classes to select a different class for the component. This class is then initialized with its default parameters. The available strings can be looked up in the documentation. (e.g. - converter='Finite-2QC')
 - close()
- Called when the environment is deleted. Closes all its modules. 
 - make(*args, **kwargs)
 - render(*_, **__)
- Update the visualization of the motor. 
 - reset(seed=None, options=None, *_, **__)
- Reset of the environment and all its modules to an initial state. - Returns:
- The initial observation consisting of the initial state and initial reference. info(dict): Auxiliary information (optional) 
 
 - set_wrapper_attr(name: str, value: Any, *, force: bool = True) bool
- Sets the attribute name on the environment with value, see Wrapper.set_wrapper_attr for more info. 
 - step(action)
- Perform one simulation step of the environment with an action of the action space. - Parameters:
- action – Action to play on the environment. 
- Returns:
- Tuple of the new state and the next reference. reward(float): Amount of reward received for the last step. terminated(bool): Flag, indicating if a reset is required before new steps can be taken. info(dict): Auxiliary information (optional) 
- Return type:
 
 - action_space: spaces.Space[ActType]
 - property constraint_monitor
- The ConstraintMonitor of the environment. - Type:
- Returns(ConstraintMonitor) 
 
 - current_next_reference = None
 - current_reference = None
 - current_state = None
 - env_id = None
 - property limits
- Returns a list of limits of all states in the observation (called in state_filter) in the same order 
 - property nominal_state
- Returns a list of nominal values of all states in the observation (called in state_filter) in that order 
 - property np_random: Generator
- Returns the environment’s internal - _np_randomthat if not set will initialise with a random seed.- Returns:
- Instances of np.random.Generator 
 
 - property np_random_seed: int
- Returns the environment’s internal - _np_random_seedthat if not set will first initialise with a random int as seed.- If - np_random_seedwas set directly instead of through- reset()or- set_np_random_through_seed(), the seed will take the value -1.- Returns:
- the seed of the current np_random or -1, if the seed of the rng is unknown 
- Return type:
 
 - observation_space: spaces.Space[ObsType]
 - property physical_system
- Returns: PhysicalSystem: The Physical System of the Environment 
 - property reference_generator
- Returns: ReferenceGenerator: The ReferenceGenerator of the Environment 
 - property reference_names
- Returns a list of state names of all states in the observation (called in state_filter) in the same order 
 - property reward_function
- Returns: RewardFunction: The RewardFunction of the environment 
 - sim = SimulationEnvironment(tau=0.0, step=0)
 - property state_names
- Returns a list of state names of all states in the observation (called in state_filter) in the same order 
 - property unwrapped: Env[ObsType, ActType]
- Returns the base non-wrapped environment. - Returns:
- The base non-wrapped - gymnasium.Envinstance
- Return type:
- Env 
 
 - property visualizations
- Returns a list of all active motor visualizations. 
 - workspace = Workspace()