Skip to content
PrescribeInitialPosition.md

PrescribeInitialPosition

Sets the initial position of a translational mechanical flange.

This component is used to define the starting position for a one-dimensional translational mechanical system connected to its flange. It uses an initial equation to set the flange.s (position) to the specified parameter s0 at the very beginning of a simulation. During the simulation, the component exerts no force, as defined by the equation:

flange.f=0

The initial position is set using:

flange.s(0)=s0

Usage

PrescribeInitialPosition(s0)

Parameters:

NameDescriptionUnitsDefault value
s0Prescribed initial position for the flangem

Connectors

Behavior

flange.f(t)=0

Source

dyad
# Sets the initial position of a translational mechanical flange.
#
# This component is used to define the starting position for a one-dimensional translational mechanical system connected to its `flange`.
# It uses an `initial equation` to set the `flange.s` (position) to the specified parameter `s0` at the very beginning of a simulation.
# During the simulation, the component exerts no force, as defined by the equation:
# ```math
# flange.f = 0
# ```
# The initial position is set using:
# ```math
# flange.s(0) = s0
# ```
component PrescribeInitialPosition
  # Translational mechanical connector
  flange = Flange() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Prescribed initial position for the flange
  parameter s0::Dyad.Position
relations
  initial flange.s = s0
  flange.f = 0
metadata {
  "Dyad": {
    "labels": [{"label": "initial s = $(s0)", "x": 500, "y": 800, "rot": 0}],
    "icons": {"default": "dyad://TranslationalComponents/Position.svg"}
  }
}
end
Flattened Source
dyad
# Sets the initial position of a translational mechanical flange.
#
# This component is used to define the starting position for a one-dimensional translational mechanical system connected to its `flange`.
# It uses an `initial equation` to set the `flange.s` (position) to the specified parameter `s0` at the very beginning of a simulation.
# During the simulation, the component exerts no force, as defined by the equation:
# ```math
# flange.f = 0
# ```
# The initial position is set using:
# ```math
# flange.s(0) = s0
# ```
component PrescribeInitialPosition
  # Translational mechanical connector
  flange = Flange() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Prescribed initial position for the flange
  parameter s0::Dyad.Position
relations
  initial flange.s = s0
  flange.f = 0
metadata {
  "Dyad": {
    "labels": [{"label": "initial s = $(s0)", "x": 500, "y": 800, "rot": 0}],
    "icons": {"default": "dyad://TranslationalComponents/Position.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"
  • Examples

  • Experiments

  • Analyses