Examples.PreLoad
Preload of a spool using ElastoGap models.
Replicates the structure of Modelica.Mechanics.Translational.Examples.PreLoad.
A spool is driven by a sinusoidal force inside a housing. The spool makes contact with spring-loaded plates through ElastoGap elements (inner contacts). The spring plates are themselves constrained by outer ElastoGap contacts against the housing/fixed reference.
The model demonstrates how preload forces (from the compressed spring) interact with contact forces at the inner and outer ElastoGap interfaces.
Note: MSL uses a one-flange Force source. Here we use the two-flange Force with flange_b connected to a Fixed ground. Each ElastoGap heat_port is connected to a FixedTemperature boundary since Dyad has no conditional connectors.
Usage
TranslationalComponents.Examples.PreLoad()
Behavior
using TranslationalComponents #hide
using ModelingToolkit #hide
@named sys = TranslationalComponents.Examples.PreLoad() #hide
full_equations(sys) #hide<< @example-block not executed in draft mode >>Source
"""
Preload of a spool using ElastoGap models.
Replicates the structure of Modelica.Mechanics.Translational.Examples.PreLoad.
A spool is driven by a sinusoidal force inside a housing. The spool makes
contact with spring-loaded plates through ElastoGap elements (inner contacts).
The spring plates are themselves constrained by outer ElastoGap contacts
against the housing/fixed reference.
The model demonstrates how preload forces (from the compressed spring)
interact with contact forces at the inner and outer ElastoGap interfaces.
Note: MSL uses a one-flange Force source. Here we use the two-flange Force
with flange_b connected to a Fixed ground. Each ElastoGap heat_port is
connected to a FixedTemperature boundary since Dyad has no conditional
connectors.
"""
example component PreLoad
"Left fixed reference"
fixed_le = TranslationalComponents.Components.Fixed(s0 = -0.0955) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 780, "x2": 530, "y2": 880, "rot": 0}
},
"tags": []
}
}
"Housing rod"
housing = TranslationalComponents.Components.Rod(L = 0.0305) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 675, "x2": 670, "y2": 775, "rot": 0}
},
"tags": []
}
}
"Outer contact A (left)"
outer_contact_a = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.0015) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 1300, "x2": 250, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Outer contact B (right)"
outer_contact_b = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.0015) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 1370, "x2": 800, "y2": 1470, "rot": 0}
},
"tags": []
}
}
"Spring plate A (left)"
spring_plate_a = TranslationalComponents.Components.Mass(m = 10e-3, L = 0.002, s = initial -0.093, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 1300, "x2": 390, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Spring plate B (right)"
spring_plate_b = TranslationalComponents.Components.Mass(m = 10e-3, L = 0.002, s = initial -0.06925, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1300, "x2": 670, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Main spring between plates"
spring = TranslationalComponents.Components.Spring(c = 20e3, s_rel0 = 0.025) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 1300, "x2": 530, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Rod from springPlateA to inner contact area"
rod1 = TranslationalComponents.Components.Rod(L = 0.007) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 1180, "x2": 530, "y2": 1280, "rot": 0}
},
"tags": []
}
}
"Rod from inner contact area to springPlateB"
rod2 = TranslationalComponents.Components.Rod(L = 0.007) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 980, "x2": 530, "y2": 1080, "rot": 0}
},
"tags": []
}
}
"Rod for inner spool area (left side)"
rod3 = TranslationalComponents.Components.Rod(L = 0.00575) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 555, "x2": 530, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Rod for inner spool area (right side)"
rod4 = TranslationalComponents.Components.Rod(L = 0.00575) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 555, "x2": 670, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Inner contact A"
inner_contact_a = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 1080, "x2": 390, "y2": 1180, "rot": 0}
},
"tags": []
}
}
"Inner contact B"
inner_contact_b = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 1130, "x2": 800, "y2": 1230, "rot": 0}
},
"tags": []
}
}
"Friction (modelled as damper)"
friction = TranslationalComponents.Components.Damper(d = 2500) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 555, "x2": 390, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Spool"
spool = TranslationalComponents.Components.Mass(L = 0.19, m = 0.150, s = initial 0.01475, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 490, "y1": 210, "x2": 590, "y2": 310, "rot": 0}
},
"tags": []
}
}
"Sinusoidal driving force signal"
sine_force = BlockComponents.Sources.Sine(amplitude = 150, frequency = 0.01) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 50, "y1": 20, "x2": 150, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Force source (two-flange)"
force = TranslationalComponents.Sources.Force() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 70, "x2": 300, "y2": 170, "rot": 0}
},
"tags": []
}
}
"Ground for force source"
force_ground = TranslationalComponents.Components.Fixed() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 740, "y1": 180, "x2": 840, "y2": 280, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for outer contact A"
thermal1 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 1350, "x2": 120, "y2": 1450, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for outer contact B"
thermal2 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1420, "x2": 670, "y2": 1520, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for inner contact A"
thermal3 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 145, "y1": 1130, "x2": 245, "y2": 1230, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for inner contact B"
thermal4 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1180, "x2": 670, "y2": 1280, "rot": 0}
},
"tags": []
}
}
relations
# Outer spring-plate chain
connect(outer_contact_a.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 135, "y": 1350}, {"x": 135, "y": 725}], "E": -1},
{"S": -1, "M": [], "E": 2}
],
"junctions": [{"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
connect(outer_contact_a.flange_b, spring_plate_a.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring_plate_a.flange_b, spring.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring.flange_b, spring_plate_b.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring_plate_b.flange_b, outer_contact_b.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 685, "y": 1350}, {"x": 685, "y": 1420}], "E": 2}],
"renderStyle": "standard"
}
}
connect(outer_contact_b.flange_b, housing.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 815, "y": 1420}, {"x": 815, "y": 725}], "E": 2}],
"renderStyle": "standard"
}
}
connect(housing.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
# Rods connecting spring plates to inner contact area
connect(spring_plate_a.flange_b, rod1.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 405, "y": 1230}], "E": 2}],
"junctions": [{"x": 405, "y": 1350}],
"renderStyle": "standard"
}
}
connect(rod2.flange_b, spring_plate_b.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 555, "y": 1030}], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 555, "y": 1350}],
"renderStyle": "standard"
}
}
# Inner contact area
connect(inner_contact_a.flange_a, rod3.flange_a) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 265, "y": 1130}, {"x": 265, "y": 505}, {"x": 405, "y": 505}],
"E": -1
},
{"S": -1, "M": [], "E": 2}
],
"junctions": [{"x": 405, "y": 605}],
"renderStyle": "standard"
}
}
connect(inner_contact_a.flange_b, rod1.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 545, "y": 1130}, {"x": 545, "y": 1230}], "E": 2}],
"renderStyle": "standard"
}
}
connect(rod2.flange_a, inner_contact_b.flange_a) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 415, "y": 1030},
{"x": 415, "y": 930},
{"x": 685, "y": 930},
{"x": 685, "y": 1180}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(rod4.flange_b, inner_contact_b.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 825, "y": 605}, {"x": 825, "y": 1180}], "E": 2}],
"renderStyle": "standard"
}
}
# Inner rods and spool
connect(rod3.flange_b, rod4.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spool.flange_a, rod4.flange_a) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 422.5, "y": 260}, {"x": 422.5, "y": 405}], "E": -1},
{"S": -1, "M": [{"x": 415, "y": 505}, {"x": 545, "y": 505}], "E": -2},
{"S": -2, "M": [], "E": 2}
],
"junctions": [{"x": 415, "y": 405}, {"x": 545, "y": 605}],
"renderStyle": "standard"
}
}
# Friction from fixed reference
connect(friction.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 275, "y": 605}], "E": -1},
{"S": -1, "M": [], "E": -2},
{"S": -2, "M": [], "E": 2}
],
"junctions": [{"x": 275, "y": 725}, {"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
connect(friction.flange_b, rod3.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
# Force source
connect(sine_force.y, force.f) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 70}], "E": 2}],
"renderStyle": "standard"
}
}
connect(force.flange_b, spool.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 275, "y": 120}, {"x": 275, "y": 260}], "E": 2}],
"renderStyle": "standard"
}
}
connect(force.flange_a, force_ground.flange) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 790, "y": 120}], "E": 2}],
"renderStyle": "standard"
}
}
# Thermal connections
connect(outer_contact_a.heat_port, thermal1.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(outer_contact_b.heat_port, thermal2.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(inner_contact_a.heat_port, thermal3.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(inner_contact_b.heat_port, thermal4.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://TranslationalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 100,
"atol": {
"spool.s": 0.001,
"friction.v_rel": 0.001,
"inner_contact_a.s_rel": 0.001,
"inner_contact_b.s_rel": 0.001,
"outer_contact_a.v_rel": 0.001,
"outer_contact_b.s_rel": 0.001,
"outer_contact_b.v_rel": 0.001
},
"expect": {
"final": {"spool.s": 0.01475},
"signals": [
"spool.s",
"friction.v_rel",
"inner_contact_a.s_rel",
"inner_contact_b.s_rel",
"outer_contact_a.v_rel",
"outer_contact_b.s_rel",
"outer_contact_b.v_rel"
]
}
}
}
}
}
endFlattened Source
"""
Preload of a spool using ElastoGap models.
Replicates the structure of Modelica.Mechanics.Translational.Examples.PreLoad.
A spool is driven by a sinusoidal force inside a housing. The spool makes
contact with spring-loaded plates through ElastoGap elements (inner contacts).
The spring plates are themselves constrained by outer ElastoGap contacts
against the housing/fixed reference.
The model demonstrates how preload forces (from the compressed spring)
interact with contact forces at the inner and outer ElastoGap interfaces.
Note: MSL uses a one-flange Force source. Here we use the two-flange Force
with flange_b connected to a Fixed ground. Each ElastoGap heat_port is
connected to a FixedTemperature boundary since Dyad has no conditional
connectors.
"""
example component PreLoad
"Left fixed reference"
fixed_le = TranslationalComponents.Components.Fixed(s0 = -0.0955) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 780, "x2": 530, "y2": 880, "rot": 0}
},
"tags": []
}
}
"Housing rod"
housing = TranslationalComponents.Components.Rod(L = 0.0305) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 675, "x2": 670, "y2": 775, "rot": 0}
},
"tags": []
}
}
"Outer contact A (left)"
outer_contact_a = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.0015) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 150, "y1": 1300, "x2": 250, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Outer contact B (right)"
outer_contact_b = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.0015) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 1370, "x2": 800, "y2": 1470, "rot": 0}
},
"tags": []
}
}
"Spring plate A (left)"
spring_plate_a = TranslationalComponents.Components.Mass(m = 10e-3, L = 0.002, s = initial -0.093, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 1300, "x2": 390, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Spring plate B (right)"
spring_plate_b = TranslationalComponents.Components.Mass(m = 10e-3, L = 0.002, s = initial -0.06925, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1300, "x2": 670, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Main spring between plates"
spring = TranslationalComponents.Components.Spring(c = 20e3, s_rel0 = 0.025) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 1300, "x2": 530, "y2": 1400, "rot": 0}
},
"tags": []
}
}
"Rod from springPlateA to inner contact area"
rod1 = TranslationalComponents.Components.Rod(L = 0.007) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 1180, "x2": 530, "y2": 1280, "rot": 0}
},
"tags": []
}
}
"Rod from inner contact area to springPlateB"
rod2 = TranslationalComponents.Components.Rod(L = 0.007) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 980, "x2": 530, "y2": 1080, "rot": 0}
},
"tags": []
}
}
"Rod for inner spool area (left side)"
rod3 = TranslationalComponents.Components.Rod(L = 0.00575) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 430, "y1": 555, "x2": 530, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Rod for inner spool area (right side)"
rod4 = TranslationalComponents.Components.Rod(L = 0.00575) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 555, "x2": 670, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Inner contact A"
inner_contact_a = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 1080, "x2": 390, "y2": 1180, "rot": 0}
},
"tags": []
}
}
"Inner contact B"
inner_contact_b = TranslationalComponents.Components.ElastoGap(c = 1000e3, d = 250, s_rel0 = 0.001) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 1130, "x2": 800, "y2": 1230, "rot": 0}
},
"tags": []
}
}
"Friction (modelled as damper)"
friction = TranslationalComponents.Components.Damper(d = 2500) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 555, "x2": 390, "y2": 655, "rot": 0}
},
"tags": []
}
}
"Spool"
spool = TranslationalComponents.Components.Mass(L = 0.19, m = 0.150, s = initial 0.01475, v = initial 0) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 490, "y1": 210, "x2": 590, "y2": 310, "rot": 0}
},
"tags": []
}
}
"Sinusoidal driving force signal"
sine_force = BlockComponents.Sources.Sine(amplitude = 150, frequency = 0.01) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 50, "y1": 20, "x2": 150, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Force source (two-flange)"
force = TranslationalComponents.Sources.Force() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 400, "y1": 70, "x2": 300, "y2": 170, "rot": 0}
},
"tags": []
}
}
"Ground for force source"
force_ground = TranslationalComponents.Components.Fixed() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 740, "y1": 180, "x2": 840, "y2": 280, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for outer contact A"
thermal1 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 1350, "x2": 120, "y2": 1450, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for outer contact B"
thermal2 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1420, "x2": 670, "y2": 1520, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for inner contact A"
thermal3 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 145, "y1": 1130, "x2": 245, "y2": 1230, "rot": 0}
},
"tags": []
}
}
"Thermal boundary for inner contact B"
thermal4 = ThermalComponents.Sources.FixedTemperature(T = 293.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 570, "y1": 1180, "x2": 670, "y2": 1280, "rot": 0}
},
"tags": []
}
}
relations
# Outer spring-plate chain
connect(outer_contact_a.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 135, "y": 1350}, {"x": 135, "y": 725}], "E": -1},
{"S": -1, "M": [], "E": 2}
],
"junctions": [{"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
connect(outer_contact_a.flange_b, spring_plate_a.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring_plate_a.flange_b, spring.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring.flange_b, spring_plate_b.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spring_plate_b.flange_b, outer_contact_b.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 685, "y": 1350}, {"x": 685, "y": 1420}], "E": 2}],
"renderStyle": "standard"
}
}
connect(outer_contact_b.flange_b, housing.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 815, "y": 1420}, {"x": 815, "y": 725}], "E": 2}],
"renderStyle": "standard"
}
}
connect(housing.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
# Rods connecting spring plates to inner contact area
connect(spring_plate_a.flange_b, rod1.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 405, "y": 1230}], "E": 2}],
"junctions": [{"x": 405, "y": 1350}],
"renderStyle": "standard"
}
}
connect(rod2.flange_b, spring_plate_b.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 555, "y": 1030}], "E": -1}, {"S": -1, "M": [], "E": 2}],
"junctions": [{"x": 555, "y": 1350}],
"renderStyle": "standard"
}
}
# Inner contact area
connect(inner_contact_a.flange_a, rod3.flange_a) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 265, "y": 1130}, {"x": 265, "y": 505}, {"x": 405, "y": 505}],
"E": -1
},
{"S": -1, "M": [], "E": 2}
],
"junctions": [{"x": 405, "y": 605}],
"renderStyle": "standard"
}
}
connect(inner_contact_a.flange_b, rod1.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 545, "y": 1130}, {"x": 545, "y": 1230}], "E": 2}],
"renderStyle": "standard"
}
}
connect(rod2.flange_a, inner_contact_b.flange_a) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 415, "y": 1030},
{"x": 415, "y": 930},
{"x": 685, "y": 930},
{"x": 685, "y": 1180}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(rod4.flange_b, inner_contact_b.flange_b) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 825, "y": 605}, {"x": 825, "y": 1180}], "E": 2}],
"renderStyle": "standard"
}
}
# Inner rods and spool
connect(rod3.flange_b, rod4.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(spool.flange_a, rod4.flange_a) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 422.5, "y": 260}, {"x": 422.5, "y": 405}], "E": -1},
{"S": -1, "M": [{"x": 415, "y": 505}, {"x": 545, "y": 505}], "E": -2},
{"S": -2, "M": [], "E": 2}
],
"junctions": [{"x": 415, "y": 405}, {"x": 545, "y": 605}],
"renderStyle": "standard"
}
}
# Friction from fixed reference
connect(friction.flange_a, fixed_le.flange) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 275, "y": 605}], "E": -1},
{"S": -1, "M": [], "E": -2},
{"S": -2, "M": [], "E": 2}
],
"junctions": [{"x": 275, "y": 725}, {"x": 480, "y": 725}],
"renderStyle": "standard"
}
}
connect(friction.flange_b, rod3.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
# Force source
connect(sine_force.y, force.f) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 350, "y": 70}], "E": 2}],
"renderStyle": "standard"
}
}
connect(force.flange_b, spool.flange_a) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 275, "y": 120}, {"x": 275, "y": 260}], "E": 2}],
"renderStyle": "standard"
}
}
connect(force.flange_a, force_ground.flange) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 790, "y": 120}], "E": 2}],
"renderStyle": "standard"
}
}
# Thermal connections
connect(outer_contact_a.heat_port, thermal1.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(outer_contact_b.heat_port, thermal2.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(inner_contact_a.heat_port, thermal3.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(inner_contact_b.heat_port, thermal4.port) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"icons": {"default": "dyad://TranslationalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 100,
"atol": {
"spool.s": 0.001,
"friction.v_rel": 0.001,
"inner_contact_a.s_rel": 0.001,
"inner_contact_b.s_rel": 0.001,
"outer_contact_a.v_rel": 0.001,
"outer_contact_b.s_rel": 0.001,
"outer_contact_b.v_rel": 0.001
},
"expect": {
"final": {"spool.s": 0.01475},
"signals": [
"spool.s",
"friction.v_rel",
"inner_contact_a.s_rel",
"inner_contact_b.s_rel",
"outer_contact_a.v_rel",
"outer_contact_b.s_rel",
"outer_contact_b.v_rel"
]
}
}
}
}
}
endTest Cases
using TranslationalComponents
using DyadInterface: TransientAnalysis, rebuild_sol, ODEAlg
using ModelingToolkit: toggle_namespacing, get_initial_conditions, @named
using CSV, DataFrames, Plots
snapshotsdir = joinpath(dirname(dirname(pathof(TranslationalComponents))), "test", "snapshots")<< @setup-block not executed in draft mode >>Test Case case1
@named model_case1 = TranslationalComponents.Examples.PreLoad()
model_case1 = toggle_namespacing(model_case1, false)
model_case1 = toggle_namespacing(model_case1, true)
result_case1 = TransientAnalysis(; model = model_case1, alg = ODEAlg.Auto(), start = 0e+0, stop = 1e+2, abstol=1e-6, reltol=1e-6)
sol_case1 = rebuild_sol(result_case1)<< @setup-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.spool.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig0.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.spool.s], width=2, label="Actual value of spool.s")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of spool.s")
end
scatter!(plt, [df_case1.t[end]], [0.01475], label="Final Condition for `spool.s`")<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.friction.v_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig1.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.friction.v_rel], width=2, label="Actual value of friction.v_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of friction.v_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.inner_contact_a.s_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig2.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.inner_contact_a.s_rel], width=2, label="Actual value of inner_contact_a.s_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of inner_contact_a.s_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.inner_contact_b.s_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig3.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.inner_contact_b.s_rel], width=2, label="Actual value of inner_contact_b.s_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of inner_contact_b.s_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.outer_contact_a.v_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig4.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.outer_contact_a.v_rel], width=2, label="Actual value of outer_contact_a.v_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of outer_contact_a.v_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.outer_contact_b.s_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig5.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.outer_contact_b.s_rel], width=2, label="Actual value of outer_contact_b.s_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of outer_contact_b.s_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.outer_contact_b.v_rel])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.PreLoad_case1_sig6.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.outer_contact_b.v_rel], width=2, label="Actual value of outer_contact_b.v_rel")
if !isnothing(dfr_case1)
scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of outer_contact_b.v_rel")
end<< @setup-block not executed in draft mode >>plt<< @example-block not executed in draft mode >>Related
Examples
Experiments
Analyses