Skip to content
Mass.md

Mass

Represents a sliding mass with inertia, subject to external and gravitational forces.

This component models the translational motion of a point mass along a single axis. It considers the mass's inertia, external forces applied through its two mechanical connection flanges (flange_a and flange_b), and a gravitational effect determined by parameters g and theta. The position s, velocity v, and acceleration a are related by v = der(s) and a = der(v). The core dynamic behavior is defined by Newton's second law, expressed as:

m \cdot (a + g \cdot \sin(\theta)) = \text{flange_a.f} + \text{flange_b.f}

math where m is the mass, a is its acceleration, g is the gravitational acceleration parameter, \theta is the angle parameter, and \text{flange_a.f} + \text{flange_b.f} represents the sum of external forces applied via the flanges.

This component extends from PartialRigid

Usage

Mass(L=0.0, m, g=-9.80665, theta=0.0)

Parameters:

NameDescriptionUnitsDefault value
LLength of component, from left flange to right flangem0
mMass of the sliding bodykg
gAcceleration due to gravity; its effect is scaled by sin(theta) using the specified default or user-provided value.m/s2-9.80665
thetaAngle defining the path of motion relative to how gravity's influence is calculated as per the component's equations (0 for horizontal).rad0

Connectors

Variables

NameDescriptionUnits
sAbsolute position of center of componentm
vAbsolute velocity of the mass along its path of motionm/s
aAbsolute acceleration of the mass along its path of motionm/s2

Behavior

flange_a.s(t)=12L+s(t)flange_b.s(t)=12L+s(t)v(t)=ds(t)dta(t)=dv(t)dt(a(t)+gsin(theta))m=flange_b.f(t)+flange_a.f(t)

Source

dyad
# Represents a sliding mass with inertia, subject to external and gravitational forces.
#
# This component models the translational motion of a point mass along a single axis. It considers the mass's inertia, external forces applied through its two mechanical connection flanges (`flange_a` and `flange_b`), and a gravitational effect determined by parameters `g` and `theta`. The position `s`, velocity `v`, and acceleration `a` are related by `v = der(s)` and `a = der(v)`. The core dynamic behavior is defined by Newton's second law, expressed as:
# ```math
# m \cdot (a + g \cdot \sin(\theta)) = \text{flange_a.f} + \text{flange_b.f}
# ```math
# where `m` is the mass, `a` is its acceleration, `g` is the gravitational acceleration parameter, `\theta` is the angle parameter, and `\text{flange_a.f} + \text{flange_b.f}` represents the sum of external forces applied via the flanges.
component Mass
  extends PartialRigid
  # Mass of the sliding body
  parameter m::Dyad.Mass
  # Absolute velocity of the mass along its path of motion
  variable v::Velocity
  # Absolute acceleration of the mass along its path of motion
  variable a::Acceleration
  # Acceleration due to gravity; its effect is scaled by sin(theta) using the specified default or user-provided value.
  parameter g::Acceleration = -9.80665
  # Angle defining the path of motion relative to how gravity's influence is calculated as per the component's equations (0 for horizontal).
  parameter theta::Angle = 0.0
relations
  # Velocity is the time derivative of absolute position 's' (likely inherited from PartialRigid)
  v = der(s)
  # Acceleration is the time derivative of velocity 'v'
  a = der(v)
  # Newton's second law: relates inertial forces, gravitational effects (per g, theta), and forces from flanges
  m*(a+g*sin(theta)) = flange_a.f+flange_b.f
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/Mass.svg"}}}
end
Flattened Source
dyad
# Represents a sliding mass with inertia, subject to external and gravitational forces.
#
# This component models the translational motion of a point mass along a single axis. It considers the mass's inertia, external forces applied through its two mechanical connection flanges (`flange_a` and `flange_b`), and a gravitational effect determined by parameters `g` and `theta`. The position `s`, velocity `v`, and acceleration `a` are related by `v = der(s)` and `a = der(v)`. The core dynamic behavior is defined by Newton's second law, expressed as:
# ```math
# m \cdot (a + g \cdot \sin(\theta)) = \text{flange_a.f} + \text{flange_b.f}
# ```math
# where `m` is the mass, `a` is its acceleration, `g` is the gravitational acceleration parameter, `\theta` is the angle parameter, and `\text{flange_a.f} + \text{flange_b.f}` represents the sum of external forces applied via the flanges.
component Mass
  # Left translational 1D flange
  flange_a = Flange() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Right translational 1D flange
  flange_b = Flange() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
  # Absolute position of center of component
  variable s::Dyad.Position
  # Length of component, from left flange to right flange
  parameter L::Length = 0.0
  # Mass of the sliding body
  parameter m::Dyad.Mass
  # Absolute velocity of the mass along its path of motion
  variable v::Velocity
  # Absolute acceleration of the mass along its path of motion
  variable a::Acceleration
  # Acceleration due to gravity; its effect is scaled by sin(theta) using the specified default or user-provided value.
  parameter g::Acceleration = -9.80665
  # Angle defining the path of motion relative to how gravity's influence is calculated as per the component's equations (0 for horizontal).
  parameter theta::Angle = 0.0
relations
  flange_a.s = s-L/2
  flange_b.s = s+L/2
  # Velocity is the time derivative of absolute position 's' (likely inherited from PartialRigid)
  v = der(s)
  # Acceleration is the time derivative of velocity 'v'
  a = der(v)
  # Newton's second law: relates inertial forces, gravitational effects (per g, theta), and forces from flanges
  m*(a+g*sin(theta)) = flange_a.f+flange_b.f
metadata {"Dyad": {"icons": {"default": "dyad://TranslationalComponents/Mass.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"