Skip to content
LIBRARY
Examples.WhyArrows.md

Examples.WhyArrows

Demonstrate the importance of arrow direction in Translational models.

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

Top system (rods + sensors): Three rods (all L=1) are connected to a common Fixed reference. Position sensors measure positions at the extremities. When all arrows point in the same direction, positionSensor2.s == positionSensor3.s (both are 1 m away from Fixed in the positive direction), while positionSensor1.s differs (1 m in the negative direction).

Bottom left: fixed1(s0=-1.9) → spring1(s_rel0=2, c=11) → mass1(L=2, m=1). Bottom right: fixed2(s0=-1.9) → spring2(s_rel0=2, c=11) → mass2(L=2, m=1). Both systems are equivalent, demonstrating that sign conventions are consistent.

Usage

TranslationalComponents.Examples.WhyArrows()

Behavior

julia
using TranslationalComponents #hide
using ModelingToolkit #hide
@named sys = TranslationalComponents.Examples.WhyArrows() #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source

dyad
"""
Demonstrate the importance of arrow direction in Translational models.

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

**Top system (rods + sensors):** Three rods (all L=1) are connected to a
common Fixed reference. Position sensors measure positions at the extremities.
When all arrows point in the same direction, positionSensor2.s == positionSensor3.s
(both are 1 m away from Fixed in the positive direction), while
positionSensor1.s differs (1 m in the negative direction).

**Bottom left:** fixed1(s0=-1.9) → spring1(s_rel0=2, c=11) → mass1(L=2, m=1).
**Bottom right:** fixed2(s0=-1.9) → spring2(s_rel0=2, c=11) → mass2(L=2, m=1).
Both systems are equivalent, demonstrating that sign conventions are consistent.
"""
example component WhyArrows
  "Common fixed reference"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      },
      "tags": []
    }
  }
  "Rod 1 (L=1), extends in negative direction from fixed"
  rod1 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 210, "y1": 80, "x2": 310, "y2": 180}}
    }
  }
  "Rod 2 (L=1), extends in positive direction from fixed"
  rod2 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 620, "y1": 80, "x2": 720, "y2": 180}}
    }
  }
  "Rod 3 (L=1), extends in positive direction from fixed (flipped)"
  rod3 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 240, "x2": 320, "y2": 340, "rot": 180}
      },
      "tags": []
    }
  }
  "Position sensor at end of rod1 (negative side)"
  position_sensor1 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 80, "x2": 20, "y2": 180, "rot": 0}
      },
      "tags": []
    }
  }
  "Position sensor at end of rod2 (positive side)"
  position_sensor2 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 810, "y1": 80, "x2": 910, "y2": 180}}
    }
  }
  "Position sensor at end of rod3 (positive side, flipped rod)"
  position_sensor3 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 240, "x2": 20, "y2": 340, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed reference for bottom-left spring-mass"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = -1.9) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 740, "x2": 120, "y2": 840, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring for bottom-left system"
  spring1 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 11) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 590, "x2": 270, "y2": 690, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for bottom-left system"
  mass1 = TranslationalComponents.Components.Mass(L = 2, m = 1, s = initial 0, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 590, "x2": 340, "y2": 690, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed reference for bottom-right system"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = -1.9) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 720, "x2": 650, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring for bottom-right system"
  spring2 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 11) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 690, "y1": 590, "x2": 790, "y2": 690}}
    }
  }
  "Mass for bottom-right system (connected backwards to show equivalence)"
  mass2 = TranslationalComponents.Components.Mass(L = 2, m = 1, s = initial 0, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 860, "y1": 590, "x2": 960, "y2": 690, "rot": 180}
      },
      "tags": []
    }
  }
relations
  # Top system: rods from fixed, sensors at extremities
  connect(rod1.flange_b, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod3.flange_a, fixed.flange) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 365, "y": 290}, {"x": 365, "y": 180}, {"x": 500, "y": 180}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, rod2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_a, position_sensor1.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod2.flange_b, position_sensor2.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod3.flange_b, position_sensor3.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  # Bottom-left: fixed1 → spring1 → mass1
  connect(fixed1.flange, spring1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 70, "y": 640}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring1.flange_b, mass1.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  # Bottom-right: fixed2 → spring2 → mass2
  connect(fixed2.flange, spring2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 600, "y": 640}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring2.flange_b, mass2.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "solver": "Auto",
        "start": 0,
        "stop": 1,
        "params": {},
        "initial": {},
        "atol": {
          "position_sensor1.s": 0.001,
          "position_sensor2.s": 0.001,
          "position_sensor3.s": 0.001,
          "mass1.s": 0.001,
          "mass1.v": 0.001,
          "mass2.s": 0.001,
          "mass2.v": 0.001
        },
        "rtol": {},
        "abstol": 0.000001,
        "reltol": 0.000001,
        "automatic_discontinuity_detection": false,
        "expect": {
          "initial": {},
          "final": {
            "position_sensor1.s": -1,
            "position_sensor2.s": 1,
            "position_sensor3.s": 1,
            "mass1.s": -1.78624,
            "mass1.v": 0.5198,
            "mass2.s": -1.78624,
            "mass2.v": 0.5198
          },
          "signals": [
            "position_sensor1.s",
            "position_sensor2.s",
            "position_sensor3.s",
            "mass1.s",
            "mass1.v",
            "mass2.s",
            "mass2.v"
          ]
        }
      }
    },
    "labels": [
      {
        "label": "position_sensor2.s = position_sensor3.s",
        "x": 500,
        "y": 420,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      },
      {
        "label": "position_sensor3.s <> position_sensor1.s",
        "x": 500,
        "y": 470,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      },
      {
        "label": "Both systems are equivalent",
        "x": 490,
        "y": 890,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      }
    ],
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "path": {},
    "doc": {"behavior": true},
    "deprecated": null
  }
}
end
Flattened Source
dyad
"""
Demonstrate the importance of arrow direction in Translational models.

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

**Top system (rods + sensors):** Three rods (all L=1) are connected to a
common Fixed reference. Position sensors measure positions at the extremities.
When all arrows point in the same direction, positionSensor2.s == positionSensor3.s
(both are 1 m away from Fixed in the positive direction), while
positionSensor1.s differs (1 m in the negative direction).

**Bottom left:** fixed1(s0=-1.9) → spring1(s_rel0=2, c=11) → mass1(L=2, m=1).
**Bottom right:** fixed2(s0=-1.9) → spring2(s_rel0=2, c=11) → mass2(L=2, m=1).
Both systems are equivalent, demonstrating that sign conventions are consistent.
"""
example component WhyArrows
  "Common fixed reference"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      },
      "tags": []
    }
  }
  "Rod 1 (L=1), extends in negative direction from fixed"
  rod1 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 210, "y1": 80, "x2": 310, "y2": 180}}
    }
  }
  "Rod 2 (L=1), extends in positive direction from fixed"
  rod2 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 620, "y1": 80, "x2": 720, "y2": 180}}
    }
  }
  "Rod 3 (L=1), extends in positive direction from fixed (flipped)"
  rod3 = TranslationalComponents.Components.Rod(L = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 240, "x2": 320, "y2": 340, "rot": 180}
      },
      "tags": []
    }
  }
  "Position sensor at end of rod1 (negative side)"
  position_sensor1 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 80, "x2": 20, "y2": 180, "rot": 0}
      },
      "tags": []
    }
  }
  "Position sensor at end of rod2 (positive side)"
  position_sensor2 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 810, "y1": 80, "x2": 910, "y2": 180}}
    }
  }
  "Position sensor at end of rod3 (positive side, flipped rod)"
  position_sensor3 = TranslationalComponents.Sensors.PositionSensor() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 240, "x2": 20, "y2": 340, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed reference for bottom-left spring-mass"
  fixed1 = TranslationalComponents.Components.Fixed(s0 = -1.9) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 740, "x2": 120, "y2": 840, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring for bottom-left system"
  spring1 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 11) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 170, "y1": 590, "x2": 270, "y2": 690, "rot": 0}
      },
      "tags": []
    }
  }
  "Mass for bottom-left system"
  mass1 = TranslationalComponents.Components.Mass(L = 2, m = 1, s = initial 0, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 590, "x2": 340, "y2": 690, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed reference for bottom-right system"
  fixed2 = TranslationalComponents.Components.Fixed(s0 = -1.9) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 550, "y1": 720, "x2": 650, "y2": 820, "rot": 0}
      },
      "tags": []
    }
  }
  "Spring for bottom-right system"
  spring2 = TranslationalComponents.Components.Spring(s_rel0 = 2, c = 11) {
    "Dyad": {
      "placement": {"diagram": {"iconName": "default", "x1": 690, "y1": 590, "x2": 790, "y2": 690}}
    }
  }
  "Mass for bottom-right system (connected backwards to show equivalence)"
  mass2 = TranslationalComponents.Components.Mass(L = 2, m = 1, s = initial 0, v = initial 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 860, "y1": 590, "x2": 960, "y2": 690, "rot": 180}
      },
      "tags": []
    }
  }
relations
  # Top system: rods from fixed, sensors at extremities
  connect(rod1.flange_b, fixed.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod3.flange_a, fixed.flange) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 365, "y": 290}, {"x": 365, "y": 180}, {"x": 500, "y": 180}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, rod2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(rod1.flange_a, position_sensor1.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod2.flange_b, position_sensor2.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(rod3.flange_b, position_sensor3.flange) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  # Bottom-left: fixed1 → spring1 → mass1
  connect(fixed1.flange, spring1.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 70, "y": 640}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring1.flange_b, mass1.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  # Bottom-right: fixed2 → spring2 → mass2
  connect(fixed2.flange, spring2.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 600, "y": 640}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(spring2.flange_b, mass2.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "solver": "Auto",
        "start": 0,
        "stop": 1,
        "params": {},
        "initial": {},
        "atol": {
          "position_sensor1.s": 0.001,
          "position_sensor2.s": 0.001,
          "position_sensor3.s": 0.001,
          "mass1.s": 0.001,
          "mass1.v": 0.001,
          "mass2.s": 0.001,
          "mass2.v": 0.001
        },
        "rtol": {},
        "abstol": 0.000001,
        "reltol": 0.000001,
        "automatic_discontinuity_detection": false,
        "expect": {
          "initial": {},
          "final": {
            "position_sensor1.s": -1,
            "position_sensor2.s": 1,
            "position_sensor3.s": 1,
            "mass1.s": -1.78624,
            "mass1.v": 0.5198,
            "mass2.s": -1.78624,
            "mass2.v": 0.5198
          },
          "signals": [
            "position_sensor1.s",
            "position_sensor2.s",
            "position_sensor3.s",
            "mass1.s",
            "mass1.v",
            "mass2.s",
            "mass2.v"
          ]
        }
      }
    },
    "labels": [
      {
        "label": "position_sensor2.s = position_sensor3.s",
        "x": 500,
        "y": 420,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      },
      {
        "label": "position_sensor3.s <> position_sensor1.s",
        "x": 500,
        "y": 470,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      },
      {
        "label": "Both systems are equivalent",
        "x": 490,
        "y": 890,
        "rot": 0,
        "layer": "diagram",
        "attrs": {
          "fill": "#0000ff",
          "font-size": "40",
          "dominant-baseline": "central",
          "text-anchor": "middle"
        }
      }
    ],
    "icons": {"default": "dyad://TranslationalComponents/Example.svg"},
    "path": {},
    "doc": {"behavior": true},
    "deprecated": null
  }
}
end


Test Cases

julia
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

julia
@named model_case1 = TranslationalComponents.Examples.WhyArrows()
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+0, abstol=1e-6, reltol=1e-6)
sol_case1 = rebuild_sol(result_case1)
<< @setup-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.position_sensor1.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig0.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.position_sensor1.s], width=2, label="Actual value of position_sensor1.s")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of position_sensor1.s")
end
scatter!(plt, [df_case1.t[end]], [-1], label="Final Condition for `position_sensor1.s`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.position_sensor2.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig1.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.position_sensor2.s], width=2, label="Actual value of position_sensor2.s")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of position_sensor2.s")
end
scatter!(plt, [df_case1.t[end]], [1], label="Final Condition for `position_sensor2.s`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.position_sensor3.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig2.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.position_sensor3.s], width=2, label="Actual value of position_sensor3.s")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of position_sensor3.s")
end
scatter!(plt, [df_case1.t[end]], [1], label="Final Condition for `position_sensor3.s`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.mass1.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig3.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.mass1.s], width=2, label="Actual value of mass1.s")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of mass1.s")
end
scatter!(plt, [df_case1.t[end]], [-1.78624], label="Final Condition for `mass1.s`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.mass1.v])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig4.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.mass1.v], width=2, label="Actual value of mass1.v")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of mass1.v")
end
scatter!(plt, [df_case1.t[end]], [0.5198], label="Final Condition for `mass1.v`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.mass2.s])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig5.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.mass2.s], width=2, label="Actual value of mass2.s")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of mass2.s")
end
scatter!(plt, [df_case1.t[end]], [-1.78624], label="Final Condition for `mass2.s`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.mass2.v])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "TranslationalComponents.Examples.WhyArrows_case1_sig6.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.mass2.v], width=2, label="Actual value of mass2.v")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of mass2.v")
end
scatter!(plt, [df_case1.t[end]], [0.5198], label="Final Condition for `mass2.v`")
<< @setup-block not executed in draft mode >>
julia
plt
<< @example-block not executed in draft mode >>
  • Examples

  • Experiments

  • Analyses