Skip to content
LIBRARY
Examples.InitialConditions.md

Examples.InitialConditions

Setting of initial conditions.

Replicates the structure of Modelica.Mechanics.Translational.Examples.InitialConditions.

Two systems demonstrate different ways of specifying initial conditions.

Top system: A chain fixed2 → s2 (spring) → m3 (mass) → sd2 (spring-damper) → m4 (mass) with positions chosen so the system starts at rest: m3.s = fixed2.s0 + s2.s_rel0 + m3.L/2 = 1 + 2 + 1.5 = 4.5 m m4.s = 4.5 + 1.5 + 4 + 2.5 = 12.5 m

Bottom system: A chain fixed1 → s1 (spring) → m1 (mass) → sd1 (spring-damper) → m2 (mass) with spring s1 starting compressed (s_rel=0.5 vs s_rel0=1), so the system is not at rest.

Usage

TranslationalComponents.Examples.InitialConditions()

Behavior

[connect(s2+flangea,fixed2+flange)connect(m3+flangea,s2+flangeb)connect(sd2+flangea,m3+flangeb)connect(m4+flangea,sd2+flangeb)connect(s1+flangea,fixed1+flange)connect(m1+flangea,s1+flangeb)connect(sd1+flangea,m1+flangeb)connect(m2+flangea,sd1+flangeb)fixed2.flange.s(t)=fixed2.s0s2.srel(t)=s2.flangea.s(t)+s2.flangeb.s(t)s2.flangeb.f(t)=s2.f(t)s2.flangea.f(t)=s2.f(t)s2.f(t)=s2.c(s2.srel0+s2.srel(t))m3.flangea.s(t)=12m3.L+m3.s(t)m3.flangeb.s(t)=m3.L2+m3.s(t)m3.v(t)=dm3.s(t)dtm3.a(t)=dm3.v(t)dt(m3.a(t)+m3.gsin(m3.theta))m3.m=m3.flangea.f(t)+m3.flangeb.f(t)sd2.srel(t)=sd2.flangeb.s(t)sd2.flangea.s(t)sd2.vrel(t)=dsd2.srel(t)dtsd2.flangeb.f(t)=sd2.f(t)sd2.flangea.f(t)=sd2.f(t)sd2.fc(t)=sd2.c(sd2.srel0+sd2.srel(t))sd2.fd(t)=sd2.dsd2.vrel(t)sd2.f(t)=sd2.fd(t)+sd2.fc(t)sd2.lossPower(t)=sd2.vrel(t)sd2.fd(t)m4.flangea.s(t)=12m4.L+m4.s(t)m4.flangeb.s(t)=m4.L2+m4.s(t)m4.v(t)=dm4.s(t)dtm4.a(t)=dm4.v(t)dt(m4.a(t)+m4.gsin(m4.theta))m4.m=m4.flangeb.f(t)+m4.flangea.f(t)fixed1.flange.s(t)=fixed1.s0s1.srel(t)=s1.flangeb.s(t)s1.flangea.s(t)s1.flangeb.f(t)=s1.f(t)s1.flangea.f(t)=s1.f(t)s1.f(t)=s1.c(s1.srel0+s1.srel(t))m1.flangea.s(t)=12m1.L+m1.s(t)m1.flangeb.s(t)=m1.L2+m1.s(t)m1.v(t)=dm1.s(t)dtm1.a(t)=dm1.v(t)dt(m1.a(t)+m1.gsin(m1.theta))m1.m=m1.flangea.f(t)+m1.flangeb.f(t)sd1.srel(t)=sd1.flangea.s(t)+sd1.flangeb.s(t)sd1.vrel(t)=dsd1.srel(t)dtsd1.flangeb.f(t)=sd1.f(t)sd1.flangea.f(t)=sd1.f(t)sd1.fc(t)=sd1.c(sd1.srel0+sd1.srel(t))sd1.fd(t)=sd1.dsd1.vrel(t)sd1.f(t)=sd1.fd(t)+sd1.fc(t)sd1.lossPower(t)=sd1.vrel(t)sd1.fd(t)m2.flangea.s(t)=12m2.L+m2.s(t)m2.flangeb.s(t)=m2.L2+m2.s(t)m2.v(t)=dm2.s(t)dtm2.a(t)=dm2.v(t)dt(m2.a(t)+m2.gsin(m2.theta))m2.m=m2.flangea.f(t)+m2.flangeb.f(t)]

Source

dyad
"""
Setting of initial conditions.

Replicates the structure of Modelica.Mechanics.Translational.Examples.InitialConditions.

Two systems demonstrate different ways of specifying initial conditions.

**Top system:** A chain fixed2 → s2 (spring) → m3 (mass) → sd2 (spring-damper) → m4 (mass)
with positions chosen so the system starts at rest:
  m3.s = fixed2.s0 + s2.s_rel0 + m3.L/2 = 1 + 2 + 1.5 = 4.5 m
  m4.s = 4.5 + 1.5 + 4 + 2.5 = 12.5 m

**Bottom system:** A chain fixed1 → s1 (spring) → m1 (mass) → sd1 (spring-damper) → m2 (mass)
with spring s1 starting compressed (s_rel=0.5 vs s_rel0=1), so the system
is not at rest.
"""
example component InitialConditions
  "Fixed reference at s=1 (top system)"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = 1)
  "Spring s2 with unstretched length 2 m (top system)"
  s2 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 1e3)
  "Mass m3 with L=3, starting at rest at s=4.5 (top system)"
  m3 = TranslationalComponents.Components.Mass(L = 3, m = 1, s = initial 4.5, v = initial 0)
  "Spring-damper sd2 with unstretched length 4 m (top system)"
  sd2 = TranslationalComponents.Components.SpringDamper(s_rel0 = 4, c = 111, d = 1)
  "Mass m4 with L=5, starting at rest at s=12.5 (top system)"
  m4 = TranslationalComponents.Components.Mass(L = 5, m = 1, s = initial 12.5, v = initial 0)
  "Fixed reference at s=-1 (bottom system)"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = -1)
  "Spring s1 with unstretched length 1 m, starting compressed (bottom system)"
  s1 = TranslationalComponents.Components.Spring(s_rel0 = 1, c = 1e3, s_rel = initial 0.5)
  "Mass m1 with L=1, starting with v=0 (bottom system)"
  m1 = TranslationalComponents.Components.Mass(L = 1, m = 1, v = initial 0)
  "Spring-damper sd1 (bottom system)"
  sd1 = TranslationalComponents.Components.SpringDamper(s_rel0 = 1, c = 111, d = 1, s_rel = initial 1, v_rel = initial 0)
  "Mass m2 with L=2 (bottom system)"
  m2 = TranslationalComponents.Components.Mass(L = 2, m = 1)
relations
  # Top system connections
  connect(s2.flange_a, fixed2.flange)
  connect(m3.flange_a, s2.flange_b)
  connect(sd2.flange_a, m3.flange_b)
  connect(m4.flange_a, sd2.flange_b)
  # Bottom system connections
  connect(s1.flange_a, fixed1.flange)
  connect(m1.flange_a, s1.flange_b)
  connect(sd1.flange_a, m1.flange_b)
  connect(m2.flange_a, sd1.flange_b)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {
          "m1.s": 0.01,
          "m1.v": 0.01,
          "m3.s": 0.001,
          "m3.v": 0.001,
          "m4.s": 0.001,
          "m4.v": 0.001,
          "sd1.s_rel": 0.01,
          "sd1.v_rel": 0.01
        },
        "expect": {
          "final": {"m3.s": 4.5, "m3.v": 0, "m4.s": 12.5, "m4.v": 0},
          "signals": [
            "m1.s",
            "m1.v",
            "m3.s",
            "m3.v",
            "m4.s",
            "m4.v",
            "sd1.s_rel",
            "sd1.v_rel",
            "sd2.s_rel",
            "sd2.v_rel"
          ]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Setting of initial conditions.

Replicates the structure of Modelica.Mechanics.Translational.Examples.InitialConditions.

Two systems demonstrate different ways of specifying initial conditions.

**Top system:** A chain fixed2 → s2 (spring) → m3 (mass) → sd2 (spring-damper) → m4 (mass)
with positions chosen so the system starts at rest:
  m3.s = fixed2.s0 + s2.s_rel0 + m3.L/2 = 1 + 2 + 1.5 = 4.5 m
  m4.s = 4.5 + 1.5 + 4 + 2.5 = 12.5 m

**Bottom system:** A chain fixed1 → s1 (spring) → m1 (mass) → sd1 (spring-damper) → m2 (mass)
with spring s1 starting compressed (s_rel=0.5 vs s_rel0=1), so the system
is not at rest.
"""
example component InitialConditions
  "Fixed reference at s=1 (top system)"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = 1)
  "Spring s2 with unstretched length 2 m (top system)"
  s2 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 1e3)
  "Mass m3 with L=3, starting at rest at s=4.5 (top system)"
  m3 = TranslationalComponents.Components.Mass(L = 3, m = 1, s = initial 4.5, v = initial 0)
  "Spring-damper sd2 with unstretched length 4 m (top system)"
  sd2 = TranslationalComponents.Components.SpringDamper(s_rel0 = 4, c = 111, d = 1)
  "Mass m4 with L=5, starting at rest at s=12.5 (top system)"
  m4 = TranslationalComponents.Components.Mass(L = 5, m = 1, s = initial 12.5, v = initial 0)
  "Fixed reference at s=-1 (bottom system)"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = -1)
  "Spring s1 with unstretched length 1 m, starting compressed (bottom system)"
  s1 = TranslationalComponents.Components.Spring(s_rel0 = 1, c = 1e3, s_rel = initial 0.5)
  "Mass m1 with L=1, starting with v=0 (bottom system)"
  m1 = TranslationalComponents.Components.Mass(L = 1, m = 1, v = initial 0)
  "Spring-damper sd1 (bottom system)"
  sd1 = TranslationalComponents.Components.SpringDamper(s_rel0 = 1, c = 111, d = 1, s_rel = initial 1, v_rel = initial 0)
  "Mass m2 with L=2 (bottom system)"
  m2 = TranslationalComponents.Components.Mass(L = 2, m = 1)
relations
  # Top system connections
  connect(s2.flange_a, fixed2.flange)
  connect(m3.flange_a, s2.flange_b)
  connect(sd2.flange_a, m3.flange_b)
  connect(m4.flange_a, sd2.flange_b)
  # Bottom system connections
  connect(s1.flange_a, fixed1.flange)
  connect(m1.flange_a, s1.flange_b)
  connect(sd1.flange_a, m1.flange_b)
  connect(m2.flange_a, sd1.flange_b)
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {
          "m1.s": 0.01,
          "m1.v": 0.01,
          "m3.s": 0.001,
          "m3.v": 0.001,
          "m4.s": 0.001,
          "m4.v": 0.001,
          "sd1.s_rel": 0.01,
          "sd1.v_rel": 0.01
        },
        "expect": {
          "final": {"m3.s": 4.5, "m3.v": 0, "m4.s": 12.5, "m4.v": 0},
          "signals": [
            "m1.s",
            "m1.v",
            "m3.s",
            "m3.v",
            "m4.s",
            "m4.v",
            "sd1.s_rel",
            "sd1.v_rel",
            "sd2.s_rel",
            "sd2.v_rel"
          ]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

  • Examples

  • Experiments

  • Analyses