Skip to content
Force.md

Force

An ideal force source that applies equal and opposite forces to two translational mechanical flanges, controlled by an external signal.

This component models an ideal source of force acting between its two translational mechanical flanges, flange_a and flange_b (inherited from PartialTwoFlanges). The magnitude and direction of the force are determined by the external input signal f. The input f directly defines the force exerted by flange_a on the connected component. The core behavior is defined by the equations relating the flange forces to the input signal f :

flange_a.f=fflange_b.f=f

This component extends from PartialTwoFlanges

Usage

Force()

Connectors

  • flange_a - (Flange)

  • flange_b - (Flange)

  • f - This connector represents a real signal as an input to a component (RealInput)

Behavior

flange_a.f(t)=f(t)flange_b.f(t)=f(t)

Source

dyad
# An ideal force source that applies equal and opposite forces to two translational mechanical flanges, controlled by an external signal.
#
# This component models an ideal source of force acting between its two translational mechanical flanges, `flange_a` and `flange_b` (inherited from `PartialTwoFlanges`).
# The magnitude and direction of the force are determined by the external input signal `f`. The input `f` directly defines the force exerted by `flange_a` on the connected component.
# The core behavior is defined by the equations relating the flange forces to the input signal $f$ :
# ```math
# flange\_a.f = f \\
# flange\_b.f = -f
# ```
component Force
  extends PartialTwoFlanges
  # The external input signal defining the force magnitude and direction applied by flange_a; flange_b applies -f.
  f = RealInput() [{
    "Dyad": {"placement": {"icon": {"x1": 450, "y1": 100, "x2": 550, "y2": 200, "rot": 90}}}
  }]
relations
  flange_a.f = f
  flange_b.f = -f
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/Force.svg"}}}
end
Flattened Source
dyad
# An ideal force source that applies equal and opposite forces to two translational mechanical flanges, controlled by an external signal.
#
# This component models an ideal source of force acting between its two translational mechanical flanges, `flange_a` and `flange_b` (inherited from `PartialTwoFlanges`).
# The magnitude and direction of the force are determined by the external input signal `f`. The input `f` directly defines the force exerted by `flange_a` on the connected component.
# The core behavior is defined by the equations relating the flange forces to the input signal $f$ :
# ```math
# flange\_a.f = f \\
# flange\_b.f = -f
# ```
component Force
  # 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}}}}]
  # The external input signal defining the force magnitude and direction applied by flange_a; flange_b applies -f.
  f = RealInput() [{
    "Dyad": {"placement": {"icon": {"x1": 450, "y1": 100, "x2": 550, "y2": 200, "rot": 90}}}
  }]
relations
  flange_a.f = f
  flange_b.f = -f
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/Force.svg"}}}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using TranslationalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(TranslationalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/TranslationalComponents/khJb7/test/snapshots"