Skip to content
LIBRARY
Sources.SignForce.md

Sources.SignForce

Constant force changing sign with speed.

Model of constant force which changes sign with direction of movement. Positive force accelerates in both directions of movement. Negative force brakes in both directions of movement.

Around zero speed, regularization avoids numerical problems. Four regularization types are available:

  • Exp (default): f=fnominalcdotleft(frac21+ev/(0.01cdotv0)1right)

  • Sine: f=fnominalcdotsinleft(fracpi2cdotfracvv0right) for |v|<v0

  • Linear: f=fnominalcdotfracvv0 for |v|<v0

  • Cosine: f=fnominalcdottextsign(v)cdotleft(1cosleft(fracpi2cdotfracvv0right)right) for |v|<v0

This component extends from TranslationalComponents.Interfaces.PartialForce

Usage

TranslationalComponents.Sources.SignForce(f_nominal, v0=0.1)

Parameters:

NameDescriptionUnitsDefault value
regType of regularizationTranslation...ation.Exp()
f_nominalNominal force (if negative, force is acting as load)N
v0Regularization below v0m/s0.1

Connectors

  • flange - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. (Flange)

  • support - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. (Flange)

Variables

NameDescriptionUnits
sDistance between flange and support (= flange.s - support.s)m
fAccelerating force acting at flange (= flange.f)N
vVelocity of flange with respect to support (= der(s))m/s

Behavior

julia
using TranslationalComponents #hide
using ModelingToolkit #hide
@variables f_nominal #hide
@variables v0 #hide
@named sys = TranslationalComponents.Sources.SignForce(f_nominal=f_nominal, v0=v0) #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source

dyad
"""
Constant force changing sign with speed.

Model of constant force which changes sign with direction of movement.
Positive force accelerates in both directions of movement.
Negative force brakes in both directions of movement.

Around zero speed, regularization avoids numerical problems. Four regularization
types are available:

- Exp (default): ``f = -f_{nominal} \\cdot \\left(\\frac{2}{1 + e^{-v / (0.01 \\cdot v_0)}} - 1\\right)``
- Sine: ``f = -f_{nominal} \\cdot \\sin\\left(\\frac{\\pi}{2} \\cdot \\frac{v}{v_0}\\right)`` for ``|v| < v_0``
- Linear: ``f = -f_{nominal} \\cdot \\frac{v}{v_0}`` for ``|v| < v_0``
- Cosine: ``f = -f_{nominal} \\cdot \\text{sign}(v) \\cdot \\left(1 - \\cos\\left(\\frac{\\pi}{2} \\cdot \\frac{v}{v_0}\\right)\\right)`` for ``|v| < v_0``
"""
component SignForce
  extends TranslationalComponents.Interfaces.PartialForce
  "Nominal force (if negative, force is acting as load)"
  parameter f_nominal::Dyad.Force
  "Type of regularization"
  structural parameter reg::TranslationalComponents.Components.Regularization = TranslationalComponents.Components.Regularization.Exp()
  "Regularization below v0"
  parameter v0::Velocity(min = eps(Float64)) = 0.1
  "Velocity of flange with respect to support (= der(s))"
  variable v::Velocity
relations
  v = der(s)
  switch reg
    case Exp
      f = -f_nominal * (2.0 / (1.0 + exp(-v / (0.01 * v0))) - 1.0)
    case Sine
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), sin(π / 2 * v / v0))
    case Linear
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), v / v0)
    case Cosine
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), sign(v) * (1.0 - cos(π / 2 * v / v0)))
  end
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/SignForce.svg"}}}
end
Flattened Source
dyad
"""
Constant force changing sign with speed.

Model of constant force which changes sign with direction of movement.
Positive force accelerates in both directions of movement.
Negative force brakes in both directions of movement.

Around zero speed, regularization avoids numerical problems. Four regularization
types are available:

- Exp (default): ``f = -f_{nominal} \\cdot \\left(\\frac{2}{1 + e^{-v / (0.01 \\cdot v_0)}} - 1\\right)``
- Sine: ``f = -f_{nominal} \\cdot \\sin\\left(\\frac{\\pi}{2} \\cdot \\frac{v}{v_0}\\right)`` for ``|v| < v_0``
- Linear: ``f = -f_{nominal} \\cdot \\frac{v}{v_0}`` for ``|v| < v_0``
- Cosine: ``f = -f_{nominal} \\cdot \\text{sign}(v) \\cdot \\left(1 - \\cos\\left(\\frac{\\pi}{2} \\cdot \\frac{v}{v_0}\\right)\\right)`` for ``|v| < v_0``
"""
component SignForce
  "Flange of component"
  flange = Flange() {"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}
  "Support/housing of component"
  support = Flange() {"Dyad": {"placement": {"icon": {"x1": 450, "y1": 950, "x2": 550, "y2": 1050}}}}
  "Distance between flange and support (= flange.s - support.s)"
  variable s::Length
  "Accelerating force acting at flange (= flange.f)"
  variable f::Dyad.Force
  "Nominal force (if negative, force is acting as load)"
  parameter f_nominal::Dyad.Force
  "Type of regularization"
  structural parameter reg::TranslationalComponents.Components.Regularization = TranslationalComponents.Components.Regularization.Exp()
  "Regularization below v0"
  parameter v0::Velocity(min = eps(Float64)) = 0.1
  "Velocity of flange with respect to support (= der(s))"
  variable v::Velocity
relations
  s = flange.s - support.s
  support.f = -flange.f
  f = flange.f
  v = der(s)
  switch reg
    case Exp
      f = -f_nominal * (2.0 / (1.0 + exp(-v / (0.01 * v0))) - 1.0)
    case Sine
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), sin(π / 2 * v / v0))
    case Linear
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), v / v0)
    case Cosine
      f = -f_nominal * ifelse(abs(v) >= v0, sign(v), sign(v) * (1.0 - cos(π / 2 * v / v0)))
  end
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/SignForce.svg"}}}
end


Test Cases

No test cases defined.