Skip to content
LIBRARY
Examples.SignConvention.md

Examples.SignConvention

Examples for the used sign conventions.

Demonstrates force sign conventions using the two-flange Force component. A positive input force of 1 N is applied to a 1 kg mass in three different wiring configurations:

  1. force.flange_b connected to mass.flange_a: force pushes mass in positive direction. Result: a = 1 m/s², v = 1 m/s after 1 s, s = 0.5 m after 1 s.

  2. force.flange_b connected to mass.flange_b: equivalent to system 1. It doesn't matter which flange of the mass is used, as long as force.flange_b is the side connected to the mass.

  3. force.flange_a connected to mass.flange_b, force.flange_b connected to fixed: arrows are opposed. The force now acts in the negative direction. Result: a = -1 m/s².

Usage

TranslationalComponents.Examples.SignConvention()

Behavior

[connect(constant1+y,force1+f)connect(force1+flangea,fixed1+flange)connect(force1+flangeb,mass1+flangea)connect(constant2+y,force2+f)connect(force2+flangea,fixed2+flange)connect(force2+flangeb,mass2+flangeb)connect(constant3+y,force3+f)connect(force3+flangea,mass3+flangeb)connect(force3+flangeb,fixed3+flange)constant1.y(t)=constant1.kforce1.flangea.f(t)=force1.f(t)force1.flangeb.f(t)=force1.f(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)fixed1.flange.s(t)=fixed1.s0constant2.y(t)=constant2.kforce2.flangea.f(t)=force2.f(t)force2.flangeb.f(t)=force2.f(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)fixed2.flange.s(t)=fixed2.s0constant3.y(t)=constant3.kforce3.flangea.f(t)=force3.f(t)force3.flangeb.f(t)=force3.f(t)mass3.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)fixed3.flange.s(t)=fixed3.s0]

Source

dyad
"""
Examples for the used sign conventions.

Demonstrates force sign conventions using the two-flange `Force` component.
A positive input force of 1 N is applied to a 1 kg mass in three different
wiring configurations:

1) `force.flange_b` connected to `mass.flange_a`: force pushes mass in positive
   direction. Result: a = 1 m/s², v = 1 m/s after 1 s, s = 0.5 m after 1 s.

2) `force.flange_b` connected to `mass.flange_b`: equivalent to system 1.
   It doesn't matter which flange of the mass is used, as long as `force.flange_b`
   is the side connected to the mass.

3) `force.flange_a` connected to `mass.flange_b`, `force.flange_b` connected to
   fixed: arrows are opposed. The force now acts in the negative direction.
   Result: a = -1 m/s².
"""
example component SignConvention
  "System 1: force.flange_b pushes at mass.flange_a"
  constant1 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": -100, "x2": 300, "y2": 0, "rot": 0}
      },
      "tags": []
    }
  }
  force1 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 20, "x2": 550, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  mass1 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 630, "y1": 20, "x2": 730, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  fixed1 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 150, "x2": 300, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  "System 2: force.flange_b pushes at mass.flange_b (equivalent to system 1)"
  constant2 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 350, "x2": 350, "y2": 450, "rot": 0}
      },
      "tags": []
    }
  }
  force2 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  mass2 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 640, "y1": 340, "x2": 740, "y2": 440, "rot": 0}
      },
      "tags": []
    }
  }
  fixed2 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 570, "x2": 290, "y2": 670, "rot": 0}
      },
      "tags": []
    }
  }
  "System 3: force.flange_a at mass (arrows opposed, reversed acceleration)"
  constant3 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 710, "x2": 500, "y2": 810, "rot": 0}
      },
      "tags": []
    }
  }
  force3 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 800, "x2": 670, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
  mass3 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 800, "x2": 290, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
  fixed3 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 810, "y1": 900, "x2": 910, "y2": 1000, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # System 1
  connect(constant1.y, force1.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": -50}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force1.flange_a, fixed1.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 250, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force1.flange_b, mass1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  initial mass1.s = 0.0
  initial mass1.v = 0.0
  # System 2
  connect(constant2.y, force2.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 450, "y": 400}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force2.flange_a, fixed2.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 240, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force2.flange_b, mass2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 840, "y": 500}, {"x": 840, "y": 390}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  initial mass2.s = 0.0
  initial mass2.v = 0.0
  # System 3
  connect(constant3.y, force3.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 620, "y": 760}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force3.flange_a, mass3.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(force3.flange_b, fixed3.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 860, "y": 850}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  initial mass3.s = 0.0
  initial mass3.v = 0.0
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": 0.5,
            "mass1.v": 1,
            "mass2.s": 0.5,
            "mass2.v": 1,
            "mass3.s": -0.5,
            "mass3.v": -1
          },
          "signals": ["mass1.s", "mass1.v", "mass2.s", "mass2.v", "mass3.s", "mass3.v"]
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Examples for the used sign conventions.

Demonstrates force sign conventions using the two-flange `Force` component.
A positive input force of 1 N is applied to a 1 kg mass in three different
wiring configurations:

1) `force.flange_b` connected to `mass.flange_a`: force pushes mass in positive
   direction. Result: a = 1 m/s², v = 1 m/s after 1 s, s = 0.5 m after 1 s.

2) `force.flange_b` connected to `mass.flange_b`: equivalent to system 1.
   It doesn't matter which flange of the mass is used, as long as `force.flange_b`
   is the side connected to the mass.

3) `force.flange_a` connected to `mass.flange_b`, `force.flange_b` connected to
   fixed: arrows are opposed. The force now acts in the negative direction.
   Result: a = -1 m/s².
"""
example component SignConvention
  "System 1: force.flange_b pushes at mass.flange_a"
  constant1 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": -100, "x2": 300, "y2": 0, "rot": 0}
      },
      "tags": []
    }
  }
  force1 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 20, "x2": 550, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  mass1 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 630, "y1": 20, "x2": 730, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  fixed1 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 150, "x2": 300, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  "System 2: force.flange_b pushes at mass.flange_b (equivalent to system 1)"
  constant2 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 350, "x2": 350, "y2": 450, "rot": 0}
      },
      "tags": []
    }
  }
  force2 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 450, "x2": 500, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  mass2 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 640, "y1": 340, "x2": 740, "y2": 440, "rot": 0}
      },
      "tags": []
    }
  }
  fixed2 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 570, "x2": 290, "y2": 670, "rot": 0}
      },
      "tags": []
    }
  }
  "System 3: force.flange_a at mass (arrows opposed, reversed acceleration)"
  constant3 = BlockComponents.Sources.Constant(k = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 400, "y1": 710, "x2": 500, "y2": 810, "rot": 0}
      },
      "tags": []
    }
  }
  force3 = TranslationalComponents.Sources.Force() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 800, "x2": 670, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
  mass3 = TranslationalComponents.Components.Mass(L = 1.0, m = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 190, "y1": 800, "x2": 290, "y2": 900, "rot": 0}
      },
      "tags": []
    }
  }
  fixed3 = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 810, "y1": 900, "x2": 910, "y2": 1000, "rot": 0}
      },
      "tags": []
    }
  }
relations
  # System 1
  connect(constant1.y, force1.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": -50}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force1.flange_a, fixed1.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 250, "y": 70}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force1.flange_b, mass1.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  initial mass1.s = 0.0
  initial mass1.v = 0.0
  # System 2
  connect(constant2.y, force2.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 450, "y": 400}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force2.flange_a, fixed2.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 240, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force2.flange_b, mass2.flange_b) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 840, "y": 500}, {"x": 840, "y": 390}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  initial mass2.s = 0.0
  initial mass2.v = 0.0
  # System 3
  connect(constant3.y, force3.f) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 620, "y": 760}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(force3.flange_a, mass3.flange_b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(force3.flange_b, fixed3.flange) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 860, "y": 850}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  initial mass3.s = 0.0
  initial mass3.v = 0.0
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": 0.5,
            "mass1.v": 1,
            "mass2.s": 0.5,
            "mass2.v": 1,
            "mass3.s": -0.5,
            "mass3.v": -1
          },
          "signals": ["mass1.s", "mass1.v", "mass2.s", "mass2.v", "mass3.s", "mass3.v"]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

julia
plt

  • Examples

  • Experiments

  • Analyses