Mass Spring Damper

Description

Environment to simulate a Mass-Spring-Damper System.

Equation

\[F_t = m \ddot{y_t} + d \dot{y_t} + k y_t\]

Parameters

\(d\): Damping constant
\(k\): Spring constant
\(m\): Mass of the oscillating object

Action

Num

Term in Equation

Term in Class

0

\(F_t\)

force

States

Num

Term in Equation

Term in Class

0

\(y_t\)

deflection

1

\(\dot{y_t}\)

velocity

Class

class exciting_environments.mass_spring_damper.mass_spring_damper_env.MassSpringDamper(batch_size=8, d=1, k=100, m=1, max_force=20, reward_func=None, tau=0.0001, constraints=[10, 10])[source]
State Variables:

['deflection' , 'velocity']

Action Variable:

['force']''

Observation Space (State Space):

Box(low=[-1, -1], high=[1, 1])

Action Space:

Box(low=-1, high=1)

Initial State:

Unless chosen otherwise, deflection and velocity is set to zero.

Example

>>> import jax
>>> import exciting_environments as excenvs
>>>
>>> # Create the environment
>>> env= excenvs.make('MassSpringDamper-v0',batch_size=2,d=2,k=0.5,max_force=10)
>>>
>>> # Reset the environment with default initial values
>>> env.reset()
>>>
>>> # Sample a random action
>>> action = env.action_space.sample(jax.random.PRNGKey(6))
>>>
>>> # Perform step
>>> obs,reward,terminated,truncated,info= env.step(action)
>>>
Parameters
  • batch_size (int) – Number of training examples utilized in one iteration. Default: 8

  • d (float) – Damping constant. Default: 1

  • k (float) – Spring constant. Default: 100

  • m (float) – Mass of the oscillating object. Default: 1

  • max_force (float) – Maximum force that can be applied to the system as action. Default: 20

  • reward_func (function) – Reward function for training. Needs Observation-Matrix and Action as Parameters. Default: None (default_reward_func from class)

  • tau (float) – Duration of one control step in seconds. Default: 1e-4.

  • constraints (array) – Constraints for states [‘deflection’,’velocity’] (array with length 2). Default: [1000,10]

Note: d,k,m and max_force can also be passed as lists with the length of the batch_size to set different parameters per batch. In addition to that constraints can also be passed as a list of lists with length 2 to set different constraints per batch.