---
url: /dyad/stable/stdlib/TranslationalComponents/examples/Examples.Accelerate.md
description: Dyad Examples.Accelerate docs.  Use of model Accelerate.
---

# `Examples.Accelerate` {#Examples.Accelerate}

Use of model Accelerate.

Demonstrates usage of component `Sources.AccelerationSource` by moving a mass with a predefined constant acceleration of 1 m/s².

Expected results after 1 s:

* acceleration a = 1 m/s²

* velocity v = 1 m/s

* position s = 0.5 m (of the AccelerationSource)

## Usage {#Usage}

`TranslationalComponents.Examples.Accelerate()`

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( constant\_{acc\_{+}y}, accelerate\_{+}a\_{ref} \right) \\
0 &= \mathrm{connect}\left( accelerate\_{+}flange, mass\_{+}flange\_{a} \right) \\
0 &= \mathrm{connect}\left( accelerate\_{+}support, fixed\_{+}flange \right) \\
\mathtt{constant_acc.y}\left( t \right) &= \mathtt{constant_acc.k} \\
\mathtt{accelerate.s}\left( t \right) &= \mathtt{accelerate.flange.s}\left( t \right) - \mathtt{accelerate.support.s}\left( t \right) \\
\mathtt{accelerate.support.f}\left( t \right) &=  - \mathtt{accelerate.flange.f}\left( t \right) \\
\mathtt{accelerate.v}\left( t \right) &= \frac{\mathrm{d}\mathtt{accelerate.s}\left( t \right)}{\mathrm{d}t} \\
\mathtt{accelerate.a}\left( t \right) &= \frac{\mathrm{d}\mathtt{accelerate.v}\left( t \right)}{\mathrm{d}t} \\
\mathtt{accelerate.a}\left( t \right) &= \mathtt{accelerate.a_ref}\left( t \right) \\
\mathtt{mass.flange_a.s}\left( t \right) &=  - \frac{1}{2} ~ \mathtt{mass.L} + \mathtt{mass.s}\left( t \right) \\
\mathtt{mass.flange_b.s}\left( t \right) &= \frac{\mathtt{mass.L}}{2} + \mathtt{mass.s}\left( t \right) \\
\mathtt{mass.v}\left( t \right) &= \frac{\mathrm{d}\mathtt{mass.s}\left( t \right)}{\mathrm{d}t} \\
\mathtt{mass.a}\left( t \right) &= \frac{\mathrm{d}\mathtt{mass.v}\left( t \right)}{\mathrm{d}t} \\
\left( \mathtt{mass.a}\left( t \right) + \mathtt{mass.g} ~ \sin\left( \mathtt{mass.theta} \right) \right) ~ \mathtt{mass.m} &= \mathtt{mass.flange_a.f}\left( t \right) + \mathtt{mass.flange_b.f}\left( t \right) \\
\mathtt{fixed.flange.s}\left( t \right) &= \mathtt{fixed.s0}
\end{align}
$$

## Source {#Source}

```dyad
"""
Use of model Accelerate.

Demonstrates usage of component `Sources.AccelerationSource` by moving a mass with a
predefined constant acceleration of 1 m/s².

Expected results after 1 s:
- acceleration a = 1 m/s²
- velocity v = 1 m/s
- position s = 0.5 m (of the AccelerationSource)
"""
example component Accelerate
  constant_acc = BlockComponents.Sources.Constant(k = 1.0) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  accelerate = TranslationalComponents.Sources.AccelerationSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 20, "y2": 120}}}
  }
  mass = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 20, "y2": 120}}}
  }
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 230, "y2": 330}}}
  }
relations
  connect(constant_acc.y, accelerate.a_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(accelerate.flange, mass.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(accelerate.support, fixed.flange) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 175}, {"x": 335, "y": 175}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {"accelerate.v": 0.01, "accelerate.s": 0.01},
        "expect": {
          "final": {"accelerate.v": 1, "accelerate.s": 0.5},
          "signals": ["accelerate.s", "accelerate.v"]
        }
      }
    }
  }
}
end
```

```dyad
"""
Use of model Accelerate.

Demonstrates usage of component `Sources.AccelerationSource` by moving a mass with a
predefined constant acceleration of 1 m/s².

Expected results after 1 s:
- acceleration a = 1 m/s²
- velocity v = 1 m/s
- position s = 0.5 m (of the AccelerationSource)
"""
example component Accelerate
  constant_acc = BlockComponents.Sources.Constant(k = 1.0) {"Dyad": {"placement": {"diagram": {"x1": 20, "x2": 120, "y1": 20, "y2": 120}}}}
  accelerate = TranslationalComponents.Sources.AccelerationSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "x2": 255, "y1": 20, "y2": 120}}}
  }
  mass = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {"placement": {"diagram": {"x1": 290, "x2": 390, "y1": 20, "y2": 120}}}
  }
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {"placement": {"diagram": {"x1": 285, "x2": 385, "y1": 230, "y2": 330}}}
  }
relations
  connect(constant_acc.y, accelerate.a_ref) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(accelerate.flange, mass.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
  connect(accelerate.support, fixed.flange) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 175}, {"x": 335, "y": 175}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {"accelerate.v": 0.01, "accelerate.s": 0.01},
        "expect": {
          "final": {"accelerate.v": 1, "accelerate.s": 0.5},
          "signals": ["accelerate.s", "accelerate.v"]
        }
      }
    }
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](oslwymz.svg)

```julia
plt
```

![](zgryfnd.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses
