Skip to content
LIBRARY
Analog.Basic.Tests.TranslationalEMF.md

Analog.Basic.Tests.TranslationalEMF

Test circuit for TranslationalEMF driven by a sinusoidal voltage with a mass load.

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a TranslationalEMF (k=1 N/A). The mechanical flange is connected to a sliding mass (m=1 kg, horizontal, no gravity). The support is grounded via a Fixed component.

With an ideal voltage source and k=1:

  • vel = v/k = sin(2π·t)

  • s = (1 − cos(2π·t))/(2π)

  • a = 2π·cos(2π·t)

  • f = m·a = 2π·cos(2π·t)

  • i = −f/k = −2π·cos(2π·t)

Analogous to RotationalEMFTest in the standard library.

Usage

ElectricalComponents.Analog.Basic.Tests.TranslationalEMF()

Behavior

[connect(sine+y,voltagesource+V)connect(voltagesource+p,emf+p)connect(voltagesource+n,emf+n)connect(emf+n,ground+g)connect(fixed+flange,emf+support)connect(emf+flange,mass+flangea)sine.y(t)=sine.offset+sine.amplitudeifelse(tsine.starttime,sin(sine.phase+6.283185307179586sine.frequency(sine.starttime+t)),sin(sine.phase))voltagesource.v(t)=voltagesource.n.v(t)+voltagesource.p.v(t)voltagesource.i(t)=voltagesource.p.i(t)voltagesource.n.i(t)+voltagesource.p.i(t)=0voltagesource.v(t)=voltagesource.uVvoltagesource.V(t)emf.v(t)=emf.p.v(t)emf.n.v(t)0=emf.n.i(t)+emf.p.i(t)emf.i(t)=emf.p.i(t)emf.s(t)=emf.support.s(t)+emf.flange.s(t)emf.vel(t)=demf.s(t)dtemf.kemf.vel(t)=emf.v(t)emf.f(t)=emf.kemf.i(t)emf.fElectrical(t)=emf.f(t)emf.f(t)=emf.flange.f(t)emf.support.f(t)=emf.f(t)ground.g.v(t)=0fixed.flange.s(t)=fixed.s0mass.flangea.s(t)=12mass.L+mass.s(t)mass.flangeb.s(t)=mass.L2+mass.s(t)mass.v(t)=dmass.s(t)dtmass.a(t)=dmass.v(t)dt(mass.a(t)+mass.gsin(mass.theta))mass.m=mass.flangea.f(t)+mass.flangeb.f(t)]

Source

dyad
"""
Test circuit for TranslationalEMF driven by a sinusoidal voltage with a mass load.

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a TranslationalEMF
(k=1 N/A). The mechanical flange is connected to a sliding mass (m=1 kg,
horizontal, no gravity). The support is grounded via a Fixed component.

With an ideal voltage source and k=1:
- vel = v/k = sin(2π·t)
- s = (1 − cos(2π·t))/(2π)
- a = 2π·cos(2π·t)
- f = m·a = 2π·cos(2π·t)
- i = −f/k = −2π·cos(2π·t)

Analogous to `RotationalEMFTest` in the standard library.
"""
test component TranslationalEMF
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 10, "y1": 490, "x2": 110, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  "Voltage source driven by sine"
  voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 485, "x2": 255, "y2": 385, "rot": 0}
      },
      "tags": []
    }
  }
  "Translational EMF with k=1 N/A"
  emf = ElectricalComponents.Analog.Basic.TranslationalEMF(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 110, "x2": 320, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  "Electrical ground"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 490, "x2": 520, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  "Mechanical ground for EMF support"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 40, "y1": 180, "x2": 140, "y2": 280, "rot": 0}
      },
      "tags": []
    }
  }
  "Sliding mass (1 kg, horizontal)"
  mass = TranslationalComponents.Components.Mass(m = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 110, "x2": 540, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial emf.s = 0
  connect(sine.y, voltage_source.V) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 205, "y": 540}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.p, emf.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 0, "y": 435}, {"x": 0, "y": 20}, {"x": 270, "y": 20}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.n, emf.n) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 335, "y": 305}, {"x": 270, "y": 305}], "E": 2}
      ],
      "junctions": [{"x": 335, "y": 435}],
      "renderStyle": "standard"
    }
  }
  connect(emf.n, ground.g) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 270, "y": 305}, {"x": 335, "y": 305}], "E": -1},
        {"S": -1, "M": [{"x": 470, "y": 435}], "E": 2}
      ],
      "junctions": [{"x": 335, "y": 435}],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, emf.support) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 90, "y": 160}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(emf.flange, mass.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["emf.v", "emf.i", "emf.s", "emf.vel"]}}
    }
  }
}
end
Flattened Source
dyad
"""
Test circuit for TranslationalEMF driven by a sinusoidal voltage with a mass load.

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a TranslationalEMF
(k=1 N/A). The mechanical flange is connected to a sliding mass (m=1 kg,
horizontal, no gravity). The support is grounded via a Fixed component.

With an ideal voltage source and k=1:
- vel = v/k = sin(2π·t)
- s = (1 − cos(2π·t))/(2π)
- a = 2π·cos(2π·t)
- f = m·a = 2π·cos(2π·t)
- i = −f/k = −2π·cos(2π·t)

Analogous to `RotationalEMFTest` in the standard library.
"""
test component TranslationalEMF
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 10, "y1": 490, "x2": 110, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  "Voltage source driven by sine"
  voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 485, "x2": 255, "y2": 385, "rot": 0}
      },
      "tags": []
    }
  }
  "Translational EMF with k=1 N/A"
  emf = ElectricalComponents.Analog.Basic.TranslationalEMF(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 220, "y1": 110, "x2": 320, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
  "Electrical ground"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 420, "y1": 490, "x2": 520, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  "Mechanical ground for EMF support"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 40, "y1": 180, "x2": 140, "y2": 280, "rot": 0}
      },
      "tags": []
    }
  }
  "Sliding mass (1 kg, horizontal)"
  mass = TranslationalComponents.Components.Mass(m = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 440, "y1": 110, "x2": 540, "y2": 210, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial emf.s = 0
  connect(sine.y, voltage_source.V) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 205, "y": 540}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.p, emf.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 0, "y": 435}, {"x": 0, "y": 20}, {"x": 270, "y": 20}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.n, emf.n) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [], "E": -1},
        {"S": -1, "M": [{"x": 335, "y": 305}, {"x": 270, "y": 305}], "E": 2}
      ],
      "junctions": [{"x": 335, "y": 435}],
      "renderStyle": "standard"
    }
  }
  connect(emf.n, ground.g) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 270, "y": 305}, {"x": 335, "y": 305}], "E": -1},
        {"S": -1, "M": [{"x": 470, "y": 435}], "E": 2}
      ],
      "junctions": [{"x": 335, "y": 435}],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, emf.support) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 90, "y": 160}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(emf.flange, mass.flange_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["emf.v", "emf.i", "emf.s", "emf.vel"]}}
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt