# Torsional Spring (`spring`)

> A torsional spring between two shafts: the torque grows with the twist.

![spring](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/spring.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/mechanical/spring/)

**Group:** Mechanical · **Kind:** `{"element":"spring","kind":"mechanical"}`

## When to use it

Use it for a shaft or coupling that twists under load, so the motor and the load can turn at different speeds and ring. Use Elastic Shaft to add damping in one part, and Gear for a rigid ratio.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `a` | mechanical | Side a, usually the motor |
| `b` | mechanical | Side b, usually the load |

## Common parameters

- `k`: Torque per radian of twist between the two sides (Default: required)
- `theta0`: Twist at the start, side a ahead of side b (Default: 0)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `k` | N·m/rad | required |  | Torque per radian of twist between the two sides |
| `theta0` | rad | 0 |  | Twist at the start, side a ahead of side b |

_Parameter descriptions are in English in both languages._

## Model

The torque from a to b is k·θ, where the twist θ is the integral of ωa - ωb and starts at theta0. In the solver the spring is an inductor of 1/k between the two shaft nodes, so it is integrated with the circuit and never changes the matrix. Two inertias J1 and J2 on a spring ring at ωr = sqrt(k·(J1 + J2)/(J1·J2)). The spring has no mass, damping or limit.

## Common mistakes

- A spring with no damping anywhere rings forever. Add a Torsional Damper, friction or an Elastic Shaft with d, or the oscillation never settles.
- A stiff spring between small inertias rings fast. Keep the maximum step well below 1/ωr, or the ringing is integrated coarsely.
- Put the two sides on different shaft nets. A spring with both pins on one net carries no torque.

Problems rules: `pin.unconnected`, `compile.error`

## Datasheet and sources

k is the torsional stiffness of the shaft or coupling in N·m/rad. A coupling datasheet gives it directly. For a solid round steel shaft it is G·π·d⁴/(32·L) with the shear modulus G, the diameter d and the length L.

## Example

Open the example with the command `file.openExample` and the name `demo:spring`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
