---
url: /dyad/stable/stdlib/TranslationalComponents/components/Components.ElastoGap.md
description: >-
  Dyad Components.ElastoGap docs.  1D translational spring damper combination
  with gap.
---

# `Components.ElastoGap` {#Components.ElastoGap}

1D translational spring damper combination with gap.

This component models a spring damper combination that can lift off. It can be connected between a sliding mass and the housing (model Fixed), to describe the contact of a sliding mass with the housing.

As long as `s_rel > s_rel0`, no force is exerted (`s_rel = flange_b.s - flange_a.s`). If `s_rel ≤ s_rel0`, the contact force is basically computed with a linear spring/damper characteristic. With parameter `n ≥ 1` (exponent of spring force), a nonlinear spring force can be modeled:

$$desiredContactForce = f\_{ref} \cdot \left|\frac{s\_{rel} - s\_{rel0}}{s\_{ref}}\right|^n + d \cdot \dot{s}\_{rel}$$

Hertzian contact is described by:

* Contact between two metallic spheres: `n = 1.5`

* Contact between two metallic plates: `n = 1`

The damping force is bounded by the spring force (`|f_d| ≤ |f_c|`) to prevent unphysical pulling/sticking forces and ensure continuity at the contact transition.

Dissipated power is exported through the `heat_port` connector. Connect it to a thermal network (e.g., `FixedTemperature`) to close the energy balance.

This component extends from [`TranslationalComponents.Interfaces.PartialCompliantWithRelativeStates`](../types/Interfaces.PartialCompliantWithRelativeStates.md)

## Usage {#Usage}

`TranslationalComponents.Components.ElastoGap(c, d, s_rel0=0, s_ref=1, f_ref=c * s_ref, n=1)`

## Parameters: {#Parameters:}

|     Name |                                           Description | Units | Default value |
| --------:| -----------------------------------------------------:| -----:| -------------:|
|      `c` |                                       Spring constant |   N/m |               |
|      `d` |                                      Damping constant | N.s/m |               |
| `s_rel0` |                             Unstretched spring length |     m |             0 |
|  `s_ref` |   Reference relative compression at which f_c = f_ref |     m |             1 |
|  `f_ref` |                       Reference spring force at s_ref |     N |     c \* s_ref |
|      `n` | Exponent of spring force (f_c = -f_ref \* |ratio|^n) |     – |             1 |

## Connectors {#Connectors}

* `flange_a` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

* `flange_b` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

* `heat_port` - This connector represents a thermal port with temperature and heat flow as the potential and flow variables, respectively. ([`HeatPort`](/stdlib/Dyad/connectors/HeatPort#HeatPort))

## Variables {#Variables}

|        Name |                                                                    Description | Units |
| -----------:| ------------------------------------------------------------------------------:| -----:|
|     `s_rel` | Relative displacement between flange_b and flange_a (flange_b.s - flange_a.s). |     m |
|     `v_rel` |        Relative velocity between flange_b and flange_a, defined as der(s_rel). |   m/s |
|         `f` |           Internal force exerted by the compliant element between the flanges. |     N |
|       `f_c` |                                                                   Spring force |     N |
|      `f_d2` |                                                           Linear damping force |     N |
|       `f_d` |                  Damping force limited by spring force (|f_d| <= |f_c|) |     N |
|     `ratio` |                                 Scaling ratio of relative compression to s_ref |     – |
| `lossPower` |     Loss power leaving component via heat_port (> 0 if heat is flowing out) |     W |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{s_rel}\left( t \right) &=  - \mathtt{flange_a.s}\left( t \right) + \mathtt{flange_b.s}\left( t \right) \\
\mathtt{v_rel}\left( t \right) &= \frac{\mathrm{d}\mathtt{s_rel}\left( t \right)}{\mathrm{d}t} \\
\mathtt{flange_b.f}\left( t \right) &= f\left( t \right) \\
\mathtt{flange_a.f}\left( t \right) &=  - f\left( t \right) \\
\mathtt{ratio}\left( t \right) &= \frac{\mathtt{s_rel}\left( t \right) - \mathtt{s_rel0}}{\mathtt{s_ref}} \\
\mathtt{f_c}\left( t \right) &= ifelse\left( \mathtt{s_rel}\left( t \right) < \mathtt{s_rel0},  - \left( \left|\mathtt{ratio}\left( t \right)\right| \right)^{n} ~ \mathtt{f_ref}, 0 \right) \\
\mathtt{f_d2}\left( t \right) &= ifelse\left( \mathtt{s_rel}\left( t \right) < \mathtt{s_rel0}, d ~ \mathtt{v_rel}\left( t \right), 0 \right) \\
\mathtt{f_d}\left( t \right) &= ifelse\left( \mathtt{s_rel}\left( t \right) < \mathtt{s_rel0}, min\left( max\left( \mathtt{f_d2}\left( t \right), \mathtt{f_c}\left( t \right) \right),  - \mathtt{f_c}\left( t \right) \right), 0 \right) \\
f\left( t \right) &= \mathtt{f_c}\left( t \right) + \mathtt{f_d}\left( t \right) \\
\mathtt{lossPower}\left( t \right) &= \mathtt{f_d}\left( t \right) ~ \mathtt{v_rel}\left( t \right) \\
\mathtt{heat_port.Q_flow}\left( t \right) &=  - \mathtt{lossPower}\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
1D translational spring damper combination with gap.

This component models a spring damper combination that can lift off.
It can be connected between a sliding mass and the housing (model Fixed),
to describe the contact of a sliding mass with the housing.

As long as `s_rel > s_rel0`, no force is exerted (`s_rel = flange_b.s - flange_a.s`).
If `s_rel ≤ s_rel0`, the contact force is basically computed with a linear
spring/damper characteristic. With parameter `n ≥ 1` (exponent of spring force),
a nonlinear spring force can be modeled:

```math
desiredContactForce = f_{ref} \cdot \left|\frac{s_{rel} - s_{rel0}}{s_{ref}}\right|^n + d \cdot \dot{s}_{rel}
```

Hertzian contact is described by:
- Contact between two metallic spheres: `n = 1.5`
- Contact between two metallic plates: `n = 1`

The damping force is bounded by the spring force (`|f_d| ≤ |f_c|`) to prevent
unphysical pulling/sticking forces and ensure continuity at the contact transition.

Dissipated power is exported through the `heat_port` connector. Connect it to a
thermal network (e.g., `FixedTemperature`) to close the energy balance.
"""
component ElastoGap
  extends TranslationalComponents.Interfaces.PartialCompliantWithRelativeStates
  "Spring constant"
  parameter c::TranslationalSpringConstant(min = 0)
  "Damping constant"
  parameter d::TranslationalDampingConstant(min = 0)
  "Unstretched spring length"
  parameter s_rel0::Dyad.Position = 0
  "Reference relative compression at which f_c = f_ref"
  parameter s_ref::Length(min = eps(Float64)) = 1
  "Reference spring force at s_ref"
  parameter f_ref::Dyad.Force(min = 0) = c * s_ref
  "Exponent of spring force (f_c = -f_ref * |ratio|^n)"
  parameter n::Real(min = 1) = 1
  "Thermal port for dissipated losses"
  heat_port = HeatPort() {"Dyad": {"placement": {"icon": {"x1": -50, "y1": 950, "x2": 50, "y2": 1050}}}}
  "Spring force"
  variable f_c::Dyad.Force
  "Linear damping force"
  variable f_d2::Dyad.Force
  "Damping force limited by spring force (|f_d| <= |f_c|)"
  variable f_d::Dyad.Force
  "Scaling ratio of relative compression to s_ref"
  variable ratio::Real
  "Loss power leaving component via heat_port (> 0 if heat is flowing out)"
  variable lossPower::Power
relations
  # Contact force: pushing only, continuous at transition
  ratio = (s_rel - s_rel0) / s_ref
  f_c = ifelse(s_rel < s_rel0, -f_ref * abs(ratio) ^ n, 0)
  f_d2 = ifelse(s_rel < s_rel0, d * v_rel, 0)
  f_d = ifelse(s_rel < s_rel0, min(max(f_d2, f_c), -f_c), 0)
  f = f_c + f_d
  lossPower = f_d * v_rel
  heat_port.Q_flow = -lossPower
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/ElastoGap.svg"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 1154, "rot": 0}]
  }
}
end
````

````dyad
"""
1D translational spring damper combination with gap.

This component models a spring damper combination that can lift off.
It can be connected between a sliding mass and the housing (model Fixed),
to describe the contact of a sliding mass with the housing.

As long as `s_rel > s_rel0`, no force is exerted (`s_rel = flange_b.s - flange_a.s`).
If `s_rel ≤ s_rel0`, the contact force is basically computed with a linear
spring/damper characteristic. With parameter `n ≥ 1` (exponent of spring force),
a nonlinear spring force can be modeled:

```math
desiredContactForce = f_{ref} \cdot \left|\frac{s_{rel} - s_{rel0}}{s_{ref}}\right|^n + d \cdot \dot{s}_{rel}
```

Hertzian contact is described by:
- Contact between two metallic spheres: `n = 1.5`
- Contact between two metallic plates: `n = 1`

The damping force is bounded by the spring force (`|f_d| ≤ |f_c|`) to prevent
unphysical pulling/sticking forces and ensure continuity at the contact transition.

Dissipated power is exported through the `heat_port` connector. Connect it to a
thermal network (e.g., `FixedTemperature`) to close the energy balance.
"""
component ElastoGap
  "Left mechanical translational flange (connector)"
  flange_a = Flange() {"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}
  "Right mechanical translational flange (connector)"
  flange_b = Flange() {"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}
  "Relative displacement between flange_b and flange_a (flange_b.s - flange_a.s)."
  variable s_rel::Distance(statePriority = 50)
  "Relative velocity between flange_b and flange_a, defined as der(s_rel)."
  variable v_rel::Velocity(statePriority = 50)
  "Internal force exerted by the compliant element between the flanges."
  variable f::Dyad.Force
  "Spring constant"
  parameter c::TranslationalSpringConstant(min = 0)
  "Damping constant"
  parameter d::TranslationalDampingConstant(min = 0)
  "Unstretched spring length"
  parameter s_rel0::Dyad.Position = 0
  "Reference relative compression at which f_c = f_ref"
  parameter s_ref::Length(min = eps(Float64)) = 1
  "Reference spring force at s_ref"
  parameter f_ref::Dyad.Force(min = 0) = c * s_ref
  "Exponent of spring force (f_c = -f_ref * |ratio|^n)"
  parameter n::Real(min = 1) = 1
  "Thermal port for dissipated losses"
  heat_port = HeatPort() {"Dyad": {"placement": {"icon": {"x1": -50, "y1": 950, "x2": 50, "y2": 1050}}}}
  "Spring force"
  variable f_c::Dyad.Force
  "Linear damping force"
  variable f_d2::Dyad.Force
  "Damping force limited by spring force (|f_d| <= |f_c|)"
  variable f_d::Dyad.Force
  "Scaling ratio of relative compression to s_ref"
  variable ratio::Real
  "Loss power leaving component via heat_port (> 0 if heat is flowing out)"
  variable lossPower::Power
relations
  s_rel = flange_b.s - flange_a.s
  v_rel = der(s_rel)
  flange_b.f = f
  flange_a.f = -f
  # Contact force: pushing only, continuous at transition
  ratio = (s_rel - s_rel0) / s_ref
  f_c = ifelse(s_rel < s_rel0, -f_ref * abs(ratio) ^ n, 0)
  f_d2 = ifelse(s_rel < s_rel0, d * v_rel, 0)
  f_d = ifelse(s_rel < s_rel0, min(max(f_d2, f_c), -f_c), 0)
  f = f_c + f_d
  lossPower = f_d * v_rel
  heat_port.Q_flow = -lossPower
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/ElastoGap.svg"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 1154, "rot": 0}]
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`AllComponents`](Components.ElastoGap.md)
