Main Content

The following file, `spring.ssc`

, implements
a component called `spring`

.

The declaration section of the component contains:

Two rotational nodes,

`r`

and`c`

(for rod and case, respectively)Parameter

`k`

, with a default value of`10 N*m/rad`

, specifying the spring rateThrough and Across variables, torque

`t`

and angular velocity`w`

, to be connected to the rotational domain Through and Across variables later in the fileInternal variable

`theta`

, with a default value of`0 rad`

, specifying relative angle, that is, deformation of the spring

The `branches`

section establishes the relationship
between the component Through variable and the component nodes (and
therefore the domain Through variable). The ```
t : r.t ->
c.t
```

statement indicates that the torque through the spring
acts from node `r`

to node `c`

.

The equation section starts with an `assert`

construct, which checks that
the spring rate is greater than zero. If the block parameter is set incorrectly, the
`assert`

triggers a run-time error.

The first equation, `w == r.w - c.w`

, establishes the relationship
between the component Across variable and the component nodes (and therefore the domain Across
variable). It defines the angular velocity across the spring as the difference between the
node angular velocities.

The following two equations define the spring action:

`t = k * theta`

, that is, torque equals spring deformation times spring rate`w = theta.der`

, that is, angular velocity equals time derivative of spring deformation

component spring nodes r = foundation.mechanical.rotational.rotational; c = foundation.mechanical.rotational.rotational; end parameters k = { 10, 'N*m/rad' }; end variables theta = { 0, 'rad' }; t = { 0, 'N*m' }; % torque through w = { 0, 'rad/s' }; % velocity across end branches t : r.t -> c.t; % torque through from node r to node c end equations assert(k>0) % spring rate must be greater than zero w == r.w - c.w; % velocity across between node r and node c t == k * theta; w == theta.der; end end