Skip to content
LIBRARY
Examples.Damper.md

Examples.Damper

Demonstrate the use of damper models.

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

Three parallel systems compare different damping configurations, all starting with the same initial conditions (s=3 m, v=10 m/s, m=1 kg) connected to a wall at s0=4.5 m:

System 1 (top): mass1 → damper1(d=25) → fixed1. Pure velocity-dependent damping, exponential decay of velocity.

System 2 (middle): mass2 → [damper2(d=25) ‖ spring2(c=1, s_rel0=1)] → fixed2. Damper and spring in parallel, damped oscillation.

System 3 (bottom): mass3 → springDamper3(d=25, c=1, s_rel0=1) → fixed3. Single SpringDamper component, equivalent to system 2.

Usage

TranslationalComponents.Examples.Damper()

Behavior

[connect(mass1+flangeb,damper1+flangea)connect(damper1+flangeb,fixed1+flange)connect(mass2+flangeb,damper2+flangea)connect(damper2+flangea,spring2+flangea)connect(damper2+flangeb,spring2+flangeb)connect(damper2+flangeb,fixed2+flange)connect(mass3+flangeb,springdamper3+flange_a)connect(springdamper3+flange_b,fixed3+flange)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)damper1.srel(t)=damper1.flangeb.s(t)damper1.flangea.s(t)damper1.vrel(t)=ddamper1.srel(t)dtdamper1.flangeb.f(t)=damper1.f(t)damper1.flangea.f(t)=damper1.f(t)damper1.f(t)=damper1.ddamper1.vrel(t)damper1.lossPower(t)=damper1.vrel(t)damper1.f(t)fixed1.flange.s(t)=fixed1.s0mass2.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)damper2.srel(t)=damper2.flangeb.s(t)damper2.flangea.s(t)damper2.vrel(t)=ddamper2.srel(t)dtdamper2.flangeb.f(t)=damper2.f(t)damper2.flangea.f(t)=damper2.f(t)damper2.f(t)=damper2.ddamper2.vrel(t)damper2.lossPower(t)=damper2.f(t)damper2.vrel(t)spring2.srel(t)=spring2.flangea.s(t)+spring2.flangeb.s(t)spring2.flangeb.f(t)=spring2.f(t)spring2.flangea.f(t)=spring2.f(t)spring2.f(t)=spring2.c(spring2.srel0+spring2.srel(t))fixed2.flange.s(t)=fixed2.s0mass3.flangea.s(t)=12mass3.L+mass3.s(t)mass3.flangeb.s(t)=mass3.L2+mass3.s(t)mass3.v(t)=dmass3.s(t)dtmass3.a(t)=dmass3.v(t)dt(mass3.a(t)+mass3.gsin(mass3.theta))mass3.m=mass3.flangeb.f(t)+mass3.flangea.f(t)springdamper3.s_rel(t)=springdamper3.flange_b.s(t)springdamper3.flange_a.s(t)springdamper3.v_rel(t)=dspringdamper3.s_rel(t)dtspringdamper3.flange_b.f(t)=springdamper3.f(t)springdamper3.flange_a.f(t)=springdamper3.f(t)springdamper3.f_c(t)=springdamper3.c(springdamper3.s_rel0+springdamper3.s_rel(t))springdamper3.f_d(t)=springdamper3.dspringdamper3.v_rel(t)springdamper3.f(t)=springdamper3.f_c(t)+springdamper3.f_d(t)springdamper3.lossPower(t)=springdamper3.v_rel(t)springdamper3.f_d(t)fixed3.flange.s(t)=fixed3.s0]

Source

dyad
"""
Demonstrate the use of damper models.

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

Three parallel systems compare different damping configurations, all starting
with the same initial conditions (s=3 m, v=10 m/s, m=1 kg) connected to a
wall at s0=4.5 m:

**System 1 (top):** mass1 → damper1(d=25) → fixed1. Pure velocity-dependent
damping, exponential decay of velocity.

**System 2 (middle):** mass2 → [damper2(d=25) ‖ spring2(c=1, s_rel0=1)]
→ fixed2. Damper and spring in parallel, damped oscillation.

**System 3 (bottom):** mass3 → springDamper3(d=25, c=1, s_rel0=1) → fixed3.
Single SpringDamper component, equivalent to system 2.
"""
example component Damper
  "Mass for system 1"
  mass1 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 20, "x2": 200, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Pure damper"
  damper1 = TranslationalComponents.Components.Damper(d = 25) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 20, "x2": 540, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 1"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 170, "x2": 950, "y2": 270, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for system 2"
  mass2 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 300, "x2": 200, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  "Damper in parallel with spring"
  damper2 = TranslationalComponents.Components.Damper(d = 25) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 470, "y1": 300, "x2": 570, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring in parallel with damper"
  spring2 = TranslationalComponents.Components.Spring(s_rel0 = 1, c = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 470, "y1": 450, "x2": 570, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 2"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 500, "x2": 950, "y2": 600, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for system 3"
  mass3 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 720, "x2": 220, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Combined spring-damper"
  spring_damper3 = TranslationalComponents.Components.SpringDamper(s_rel0 = 1, d = 25, c = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 720, "x2": 560, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 3"
  fixed3 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 860, "y1": 800, "x2": 960, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # System 1: mass → damper → fixed
  connect(mass1.flange_b, damper1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(damper1.flange_b, fixed1.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 900, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # System 2: mass → [damper ‖ spring] → fixed
  connect(mass2.flange_b, damper2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(damper2.flange_a, spring2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 270, "y": 500}], "E": 2}],
      "junctions": [{"x": 270, "y": 350}],
      "renderStyle": "standard"
    }
  }
  connect(damper2.flange_b, spring2.flange_b) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 740, "y": 350}, {"x": 740, "y": 500}], "E": 2}
      ],
      "junctions": [{"x": 570, "y": 350}],
      "renderStyle": "standard"
    }
  }
  connect(damper2.flange_b, fixed2.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 900, "y": 350}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # System 3: mass → springDamper → fixed
  connect(mass3.flange_b, spring_damper3.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(spring_damper3.flange_b, fixed3.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 910, "y": 770}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {
          "mass1.s": 0.001,
          "mass1.v": 0.001,
          "mass2.s": 0.001,
          "mass2.v": 0.001,
          "mass3.s": 0.001,
          "mass3.v": 0.001
        },
        "expect": {
          "final": {
            "mass1.s": 3.4,
            "mass1.v": 0,
            "mass2.s": 3.38552676,
            "mass2.v": -0.01544582,
            "mass3.s": 3.38552676,
            "mass3.v": -0.01544582
          },
          "signals": [
            "mass1.s",
            "mass1.v",
            "mass2.s",
            "mass2.v",
            "mass3.s",
            "mass3.v",
            "damper1.s_rel",
            "damper1.v_rel",
            "damper2.s_rel",
            "damper2.v_rel",
            "spring_damper3.s_rel",
            "spring_damper3.v_rel"
          ]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Demonstrate the use of damper models.

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

Three parallel systems compare different damping configurations, all starting
with the same initial conditions (s=3 m, v=10 m/s, m=1 kg) connected to a
wall at s0=4.5 m:

**System 1 (top):** mass1 → damper1(d=25) → fixed1. Pure velocity-dependent
damping, exponential decay of velocity.

**System 2 (middle):** mass2 → [damper2(d=25) ‖ spring2(c=1, s_rel0=1)]
→ fixed2. Damper and spring in parallel, damped oscillation.

**System 3 (bottom):** mass3 → springDamper3(d=25, c=1, s_rel0=1) → fixed3.
Single SpringDamper component, equivalent to system 2.
"""
example component Damper
  "Mass for system 1"
  mass1 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 20, "x2": 200, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Pure damper"
  damper1 = TranslationalComponents.Components.Damper(d = 25) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 20, "x2": 540, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 1"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 170, "x2": 950, "y2": 270, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for system 2"
  mass2 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 300, "x2": 200, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  "Damper in parallel with spring"
  damper2 = TranslationalComponents.Components.Damper(d = 25) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 470, "y1": 300, "x2": 570, "y2": 400, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring in parallel with damper"
  spring2 = TranslationalComponents.Components.Spring(s_rel0 = 1, c = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 470, "y1": 450, "x2": 570, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 2"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 500, "x2": 950, "y2": 600, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for system 3"
  mass3 = TranslationalComponents.Components.Mass(L = 1, m = 1, s = initial 3, v = initial 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 720, "x2": 220, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Combined spring-damper"
  spring_damper3 = TranslationalComponents.Components.SpringDamper(s_rel0 = 1, d = 25, c = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 720, "x2": 560, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Wall for system 3"
  fixed3 = TranslationalComponents.Components.Fixed(s0 = 4.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 860, "y1": 800, "x2": 960, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # System 1: mass → damper → fixed
  connect(mass1.flange_b, damper1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(damper1.flange_b, fixed1.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 900, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # System 2: mass → [damper ‖ spring] → fixed
  connect(mass2.flange_b, damper2.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(damper2.flange_a, spring2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 270, "y": 500}], "E": 2}],
      "junctions": [{"x": 270, "y": 350}],
      "renderStyle": "standard"
    }
  }
  connect(damper2.flange_b, spring2.flange_b) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 740, "y": 350}, {"x": 740, "y": 500}], "E": 2}
      ],
      "junctions": [{"x": 570, "y": 350}],
      "renderStyle": "standard"
    }
  }
  connect(damper2.flange_b, fixed2.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 900, "y": 350}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # System 3: mass → springDamper → fixed
  connect(mass3.flange_b, spring_damper3.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(spring_damper3.flange_b, fixed3.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 910, "y": 770}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "atol": {
          "mass1.s": 0.001,
          "mass1.v": 0.001,
          "mass2.s": 0.001,
          "mass2.v": 0.001,
          "mass3.s": 0.001,
          "mass3.v": 0.001
        },
        "expect": {
          "final": {
            "mass1.s": 3.4,
            "mass1.v": 0,
            "mass2.s": 3.38552676,
            "mass2.v": -0.01544582,
            "mass3.s": 3.38552676,
            "mass3.v": -0.01544582
          },
          "signals": [
            "mass1.s",
            "mass1.v",
            "mass2.s",
            "mass2.v",
            "mass3.s",
            "mass3.v",
            "damper1.s_rel",
            "damper1.v_rel",
            "damper2.s_rel",
            "damper2.v_rel",
            "spring_damper3.s_rel",
            "spring_damper3.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

julia
plt

julia
plt