Skip to content
LIBRARY
Examples.ElastoGap.md

Examples.ElastoGap

Demonstrate usage of ElastoGap.

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

Two parallel systems compare the behaviour of SpringDamper (top) vs ElastoGap (bottom) for identical mass/stiffness/damping. Both masses start at the same position (s=2) and oscillate between two walls (rod ends) separated by 4 m via a Fixed at the centre.

Top system (SpringDamper): mass1 is connected between the rod ends through two SpringDampers (c=10, d=1.5, s_rel0=1). The spring-damper forces act continuously, so mass1 always feels the restoring force.

Bottom system (ElastoGap): mass2 is connected through two ElastoGaps (c=10, d=1.5, s_rel0=1.5). The gap allows mass2 to move freely in the region −0.5 m < s < 0.5 m (no contact force), which reduces the effective eigenfrequency compared to the top system.

Each ElastoGap heat port is connected to a FixedTemperature boundary so the thermal energy balance is closed.

Usage

TranslationalComponents.Examples.ElastoGap()

Behavior

[connect(springdamper1+flange_a,rod1+flangea)connect(springdamper1+flange_b,mass1+flangea)connect(mass1+flangeb,springdamper2+flange_a)connect(springdamper2+flange_b,rod2+flangeb)connect(elastogap1+flange_a,rod1+flangea)connect(elastogap1+flange_b,mass2+flangea)connect(mass2+flangeb,elastogap2+flange_a)connect(elastogap2+flange_b,rod2+flangeb)connect(elastogap1+heat_port,thermalground1+port)connect(elastogap2+heat_port,thermalground2+port)connect(rod1+flangeb,fixed+flange)connect(rod2+flangea,fixed+flange)connect(rod1+flangeb,rod2+flangea)fixed.flange.s(t)=fixed.s0rod1.flangea.s(t)=12rod1.L+rod1.s(t)rod1.flangeb.s(t)=rod1.L2+rod1.s(t)0=rod1.flangea.f(t)+rod1.flangeb.f(t)rod2.flangea.s(t)=12rod2.L+rod2.s(t)rod2.flangeb.s(t)=rod2.L2+rod2.s(t)0=rod2.flangea.f(t)+rod2.flangeb.f(t)springdamper1.s_rel(t)=springdamper1.flange_a.s(t)+springdamper1.flange_b.s(t)springdamper1.v_rel(t)=dspringdamper1.s_rel(t)dtspringdamper1.flange_b.f(t)=springdamper1.f(t)springdamper1.flange_a.f(t)=springdamper1.f(t)springdamper1.f_c(t)=springdamper1.c(springdamper1.s_rel0+springdamper1.s_rel(t))springdamper1.f_d(t)=springdamper1.dspringdamper1.v_rel(t)springdamper1.f(t)=springdamper1.f_d(t)+springdamper1.f_c(t)springdamper1.lossPower(t)=springdamper1.f_d(t)springdamper1.v_rel(t)springdamper2.s_rel(t)=springdamper2.flange_a.s(t)+springdamper2.flange_b.s(t)springdamper2.v_rel(t)=dspringdamper2.s_rel(t)dtspringdamper2.flange_b.f(t)=springdamper2.f(t)springdamper2.flange_a.f(t)=springdamper2.f(t)springdamper2.f_c(t)=springdamper2.c(springdamper2.s_rel0+springdamper2.s_rel(t))springdamper2.f_d(t)=springdamper2.dspringdamper2.v_rel(t)springdamper2.f(t)=springdamper2.f_c(t)+springdamper2.f_d(t)springdamper2.lossPower(t)=springdamper2.v_rel(t)springdamper2.f_d(t)mass1.flangea.s(t)=12mass1.L+mass1.s(t)mass1.flangeb.s(t)=mass1.L2+mass1.s(t)mass1.v(t)=dmass1.s(t)dtmass1.a(t)=dmass1.v(t)dt(mass1.a(t)+mass1.gsin(mass1.theta))mass1.m=mass1.flangea.f(t)+mass1.flangeb.f(t)elastogap1.s_rel(t)=elastogap1.flange_b.s(t)elastogap1.flange_a.s(t)elastogap1.v_rel(t)=delastogap1.s_rel(t)dtelastogap1.flange_b.f(t)=elastogap1.f(t)elastogap1.flange_a.f(t)=elastogap1.f(t)elastogap1.ratio(t)=elastogap1.s_rel0+elastogap1.s_rel(t)elastogap1.s_refelastogap1.f_c(t)=ifelse(elastogap1.s_rel(t)<elastogap1.s_rel0,(|elastogap1.ratio(t)|)elastogap1.nelastogap1.f_ref,0)elastogap1.f_d2(t)=ifelse(elastogap1.s_rel(t)<elastogap1.s_rel0,elastogap1.delastogap1.v_rel(t),0)elastogap1.f_d(t)=ifelse(elastogap1.s_rel(t)<elastogap1.s_rel0,min(max(elastogap1.f_d2(t),elastogap1.f_c(t)),elastogap1.f_c(t)),0)elastogap1.f(t)=elastogap1.f_c(t)+elastogap1.f_d(t)elastogap1.lossPower(t)=elastogap1.f_d(t)elastogap1.v_rel(t)elastogap1.heat_port.Q_flow(t)=elastogap1.lossPower(t)elastogap2.s_rel(t)=elastogap2.flange_a.s(t)+elastogap2.flange_b.s(t)elastogap2.v_rel(t)=delastogap2.s_rel(t)dtelastogap2.flange_b.f(t)=elastogap2.f(t)elastogap2.flange_a.f(t)=elastogap2.f(t)elastogap2.ratio(t)=elastogap2.s_rel0+elastogap2.s_rel(t)elastogap2.s_refelastogap2.f_c(t)=ifelse(elastogap2.s_rel(t)<elastogap2.s_rel0,(|elastogap2.ratio(t)|)elastogap2.nelastogap2.f_ref,0)elastogap2.f_d2(t)=ifelse(elastogap2.s_rel(t)<elastogap2.s_rel0,elastogap2.delastogap2.v_rel(t),0)elastogap2.f_d(t)=ifelse(elastogap2.s_rel(t)<elastogap2.s_rel0,min(max(elastogap2.f_d2(t),elastogap2.f_c(t)),elastogap2.f_c(t)),0)elastogap2.f(t)=elastogap2.f_c(t)+elastogap2.f_d(t)elastogap2.lossPower(t)=elastogap2.f_d(t)elastogap2.v_rel(t)elastogap2.heat_port.Q_flow(t)=elastogap2.lossPower(t)mass2.flangea.s(t)=12mass2.L+mass2.s(t)mass2.flangeb.s(t)=mass2.L2+mass2.s(t)mass2.v(t)=dmass2.s(t)dtmass2.a(t)=dmass2.v(t)dt(mass2.a(t)+mass2.gsin(mass2.theta))mass2.m=mass2.flangea.f(t)+mass2.flangeb.f(t)thermalground1.port.T(t)=thermalground1.Tthermalground2.port.T(t)=thermalground2.T]

Source

dyad
"""
Demonstrate usage of ElastoGap.

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

Two parallel systems compare the behaviour of SpringDamper (top) vs ElastoGap (bottom)
for identical mass/stiffness/damping. Both masses start at the same position (s=2)
and oscillate between two walls (rod ends) separated by 4 m via a Fixed at the centre.

**Top system (SpringDamper):** mass1 is connected between the rod ends through two
SpringDampers (c=10, d=1.5, s_rel0=1). The spring-damper forces act continuously,
so mass1 always feels the restoring force.

**Bottom system (ElastoGap):** mass2 is connected through two ElastoGaps (c=10,
d=1.5, s_rel0=1.5). The gap allows mass2 to move freely in the region
−0.5 m < s < 0.5 m (no contact force), which reduces the effective eigenfrequency
compared to the top system.

Each ElastoGap heat port is connected to a FixedTemperature boundary so the thermal
energy balance is closed.
"""
example component ElastoGap
  "Fixed reference at centre"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 290, "x2": 460, "y2": 390, "rot": 0}
      },
      "tags": []
    }
  }
  "Left rod (L=2)"
  rod1 = TranslationalComponents.Components.Rod(L = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 190, "x2": 290, "y2": 290, "rot": 0}
      },
      "tags": []
    }
  }
  "Right rod (L=2)"
  rod2 = TranslationalComponents.Components.Rod(L = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 530, "y1": 190, "x2": 630, "y2": 290, "rot": 0}
      },
      "tags": []
    }
  }
  "Left spring-damper (top system)"
  spring_damper1 = TranslationalComponents.Components.SpringDamper(c = 10, s_rel0 = 1, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 20, "x2": 290, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Right spring-damper (top system)"
  spring_damper2 = TranslationalComponents.Components.SpringDamper(c = 10, s_rel0 = 1, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 520, "y1": 20, "x2": 620, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for the top system"
  mass1 = TranslationalComponents.Components.Mass(m = 1, L = 0, s = initial 2, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 350, "y1": 20, "x2": 450, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Left elasto-gap (bottom system)"
  elasto_gap1 = TranslationalComponents.Components.ElastoGap(c = 10, s_rel0 = 1.5, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 450, "x2": 270, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Right elasto-gap (bottom system)"
  elasto_gap2 = TranslationalComponents.Components.ElastoGap(c = 10, s_rel0 = 1.5, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 530, "y1": 450, "x2": 630, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for the bottom system"
  mass2 = TranslationalComponents.Components.Mass(m = 1, L = 0, s = initial 2, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 450, "x2": 460, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal boundary for elasto_gap1"
  thermal_ground1 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -10, "y1": 620, "x2": 90, "y2": 720, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal boundary for elasto_gap2"
  thermal_ground2 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 340, "y1": 640, "x2": 440, "y2": 740, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(spring_damper1.flange_a, rod1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 135, "y": 70}, {"x": 135, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring_damper1.flange_b, mass1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(mass1.flange_b, spring_damper2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(spring_damper2.flange_b, rod2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 655, "y": 70}, {"x": 655, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.flange_a, rod1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 135, "y": 500}, {"x": 135, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.flange_b, mass2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(mass2.flange_b, elasto_gap2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(elasto_gap2.flange_b, rod2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 655, "y": 500}, {"x": 655, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.heat_port, thermal_ground1.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 550}, {"x": 140, "y": 670}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap2.heat_port, thermal_ground2.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 470, "y": 550}, {"x": 470, "y": 690}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_b, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod2.flange_a, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_b, rod2.flange_a) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {
          "elasto_gap1.v_rel": 0.01,
          "elasto_gap2.s_rel": 0.01,
          "spring_damper1.v_rel": 0.001,
          "spring_damper2.s_rel": 0.001
        },
        "expect": {
          "final": {
            "elasto_gap1.v_rel": 0.53753,
            "elasto_gap2.s_rel": 2.70789,
            "spring_damper1.v_rel": -0.00419,
            "spring_damper2.s_rel": 2.00035
          },
          "signals": [
            "elasto_gap1.v_rel",
            "elasto_gap2.s_rel",
            "spring_damper1.v_rel",
            "spring_damper2.s_rel"
          ]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Demonstrate usage of ElastoGap.

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

Two parallel systems compare the behaviour of SpringDamper (top) vs ElastoGap (bottom)
for identical mass/stiffness/damping. Both masses start at the same position (s=2)
and oscillate between two walls (rod ends) separated by 4 m via a Fixed at the centre.

**Top system (SpringDamper):** mass1 is connected between the rod ends through two
SpringDampers (c=10, d=1.5, s_rel0=1). The spring-damper forces act continuously,
so mass1 always feels the restoring force.

**Bottom system (ElastoGap):** mass2 is connected through two ElastoGaps (c=10,
d=1.5, s_rel0=1.5). The gap allows mass2 to move freely in the region
−0.5 m < s < 0.5 m (no contact force), which reduces the effective eigenfrequency
compared to the top system.

Each ElastoGap heat port is connected to a FixedTemperature boundary so the thermal
energy balance is closed.
"""
example component ElastoGap
  "Fixed reference at centre"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 290, "x2": 460, "y2": 390, "rot": 0}
      },
      "tags": []
    }
  }
  "Left rod (L=2)"
  rod1 = TranslationalComponents.Components.Rod(L = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 190, "x2": 290, "y2": 290, "rot": 0}
      },
      "tags": []
    }
  }
  "Right rod (L=2)"
  rod2 = TranslationalComponents.Components.Rod(L = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 530, "y1": 190, "x2": 630, "y2": 290, "rot": 0}
      },
      "tags": []
    }
  }
  "Left spring-damper (top system)"
  spring_damper1 = TranslationalComponents.Components.SpringDamper(c = 10, s_rel0 = 1, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 20, "x2": 290, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Right spring-damper (top system)"
  spring_damper2 = TranslationalComponents.Components.SpringDamper(c = 10, s_rel0 = 1, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 520, "y1": 20, "x2": 620, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for the top system"
  mass1 = TranslationalComponents.Components.Mass(m = 1, L = 0, s = initial 2, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 350, "y1": 20, "x2": 450, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Left elasto-gap (bottom system)"
  elasto_gap1 = TranslationalComponents.Components.ElastoGap(c = 10, s_rel0 = 1.5, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 450, "x2": 270, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Right elasto-gap (bottom system)"
  elasto_gap2 = TranslationalComponents.Components.ElastoGap(c = 10, s_rel0 = 1.5, d = 1.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 530, "y1": 450, "x2": 630, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for the bottom system"
  mass2 = TranslationalComponents.Components.Mass(m = 1, L = 0, s = initial 2, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 360, "y1": 450, "x2": 460, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal boundary for elasto_gap1"
  thermal_ground1 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -10, "y1": 620, "x2": 90, "y2": 720, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal boundary for elasto_gap2"
  thermal_ground2 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 340, "y1": 640, "x2": 440, "y2": 740, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(spring_damper1.flange_a, rod1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 135, "y": 70}, {"x": 135, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring_damper1.flange_b, mass1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(mass1.flange_b, spring_damper2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(spring_damper2.flange_b, rod2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 655, "y": 70}, {"x": 655, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.flange_a, rod1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 135, "y": 500}, {"x": 135, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.flange_b, mass2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(mass2.flange_b, elasto_gap2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(elasto_gap2.flange_b, rod2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 655, "y": 500}, {"x": 655, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap1.heat_port, thermal_ground1.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 550}, {"x": 140, "y": 670}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(elasto_gap2.heat_port, thermal_ground2.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 470, "y": 550}, {"x": 470, "y": 690}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_b, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod2.flange_a, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 410, "y": 240}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_b, rod2.flange_a) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {
          "elasto_gap1.v_rel": 0.01,
          "elasto_gap2.s_rel": 0.01,
          "spring_damper1.v_rel": 0.001,
          "spring_damper2.s_rel": 0.001
        },
        "expect": {
          "final": {
            "elasto_gap1.v_rel": 0.53753,
            "elasto_gap2.s_rel": 2.70789,
            "spring_damper1.v_rel": -0.00419,
            "spring_damper2.s_rel": 2.00035
          },
          "signals": [
            "elasto_gap1.v_rel",
            "elasto_gap2.s_rel",
            "spring_damper1.v_rel",
            "spring_damper2.s_rel"
          ]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt