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(fixed+flange,emf+support)connect(emf+flange,mass+flangea)connect(ground+g,voltagesource+n)connect(emf+n,voltagesource+n)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.p.i(t)+voltagesource.n.i(t)=0voltagesource.v(t)=voltagesource.uVvoltagesource.V(t)emf.v(t)=emf.n.v(t)+emf.p.v(t)0=emf.n.i(t)+emf.p.i(t)emf.i(t)=emf.p.i(t)emf.s(t)=emf.flange.s(t)emf.support.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.flangeb.f(t)+mass.flangea.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": 350, "y1": 670, "x2": 450, "y2": 770, "rot": 0}
      },
      "tags": []
    }
  }
  "Voltage source driven by sine"
  voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 550, "x2": 550, "y2": 450, "rot": 0}
      },
      "tags": []
    }
  }
  "Translational EMF with k=1 N/A"
  emf = ElectricalComponents.Analog.Basic.TranslationalEMF(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 150, "x2": 550, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  "Electrical ground"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 680, "x2": 920, "y2": 780, "rot": 0}
      },
      "tags": []
    }
  }
  "Mechanical ground for EMF support"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 320, "x2": 330, "y2": 420, "rot": 90}
      },
      "tags": []
    }
  }
  "Sliding mass (1 kg, horizontal)"
  mass = TranslationalComponents.Components.Mass(m = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 810, "y1": 270, "x2": 910, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial emf.s = 0
  connect(sine.y, voltage_source.V) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 720}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.p, emf.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 110, "y": 500}, {"x": 110, "y": 80}, {"x": 500, "y": 80}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, emf.support) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 370, "y": 370}, {"x": 370, "y": 200}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(emf.flange, mass.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 200}, {"x": 770, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(ground.g, voltage_source.n) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 870, "y": 500}], "E": 2}]
    }
  }
  connect(emf.n, voltage_source.n) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 290}, {"x": 690, "y": 290}, {"x": 690, "y": 500}],
          "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": 350, "y1": 670, "x2": 450, "y2": 770, "rot": 0}
      },
      "tags": []
    }
  }
  "Voltage source driven by sine"
  voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 550, "x2": 550, "y2": 450, "rot": 0}
      },
      "tags": []
    }
  }
  "Translational EMF with k=1 N/A"
  emf = ElectricalComponents.Analog.Basic.TranslationalEMF(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 150, "x2": 550, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  "Electrical ground"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 680, "x2": 920, "y2": 780, "rot": 0}
      },
      "tags": []
    }
  }
  "Mechanical ground for EMF support"
  fixed = TranslationalComponents.Components.Fixed() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 230, "y1": 320, "x2": 330, "y2": 420, "rot": 90}
      },
      "tags": []
    }
  }
  "Sliding mass (1 kg, horizontal)"
  mass = TranslationalComponents.Components.Mass(m = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 810, "y1": 270, "x2": 910, "y2": 370, "rot": 0}
      },
      "tags": []
    }
  }
relations
  initial emf.s = 0
  connect(sine.y, voltage_source.V) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 500, "y": 720}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(voltage_source.p, emf.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 110, "y": 500}, {"x": 110, "y": 80}, {"x": 500, "y": 80}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(fixed.flange, emf.support) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 370, "y": 370}, {"x": 370, "y": 200}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(emf.flange, mass.flange_a) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 770, "y": 200}, {"x": 770, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(ground.g, voltage_source.n) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 870, "y": 500}], "E": 2}]
    }
  }
  connect(emf.n, voltage_source.n) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 290}, {"x": 690, "y": 290}, {"x": 690, "y": 500}],
          "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