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

Analog.Basic.Tests.CCC

Test circuit for CCC (current-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a 5 Ω series resistor into the CCC input port (port 1). Since v1=0, the full source voltage drops across the resistor, producing i1 = V_source/R_series. A 10 Ω resistor loads the output port (port 2). CCC gain = 3.

Expected (algebraic, holds for all t):

  • v1 = 0 (zero input impedance)

  • i1 = sin(2π·t)/5 = 0.2·sin(2π·t)

  • i2 = gain·i1 = 0.6·sin(2π·t)

  • v2 = −R_load·i2 = −6·sin(2π·t)

Usage

ElectricalComponents.Analog.Basic.Tests.CCC()

Behavior

[connect(sine+y,vs+V)connect(vs+p,rseries+p)connect(rseries+n,ccc+p1)connect(vs+n,gnd1+g)connect(vs+n,ccc+n1)connect(ccc+p2,rload+p)connect(rload+n,ccc+n2)connect(gnd2+g,ccc+n2)sine.y(t)=sine.offset+sine.amplitudeifelse(tsine.starttime,sin(sine.phase+6.283185307179586sine.frequency(sine.starttime+t)),sin(sine.phase))vs.v(t)=vs.n.v(t)+vs.p.v(t)vs.i(t)=vs.p.i(t)vs.n.i(t)+vs.p.i(t)=0vs.v(t)=vs.uVvs.V(t)rseries.v(t)=rseries.p.v(t)rseries.n.v(t)rseries.i(t)=rseries.p.i(t)rseries.n.i(t)+rseries.p.i(t)=0rseries.v(t)=rseries.Rrseries.i(t)ccc.v1(t)=ccc.p1.v(t)ccc.n1.v(t)ccc.v2(t)=ccc.n2.v(t)+ccc.p2.v(t)ccc.i1(t)=ccc.p1.i(t)ccc.i2(t)=ccc.p2.i(t)0=ccc.n1.i(t)+ccc.p1.i(t)0=ccc.n2.i(t)+ccc.p2.i(t)ccc.i2(t)=ccc.gainccc.i1(t)ccc.v1(t)=0rload.v(t)=rload.n.v(t)+rload.p.v(t)rload.i(t)=rload.p.i(t)rload.n.i(t)+rload.p.i(t)=0rload.v(t)=rload.Rrload.i(t)gnd1.g.v(t)=0gnd2.g.v(t)=0]

Source

dyad
"""
Test circuit for CCC (current-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a 5 Ω series
resistor into the CCC input port (port 1). Since v1=0, the full source
voltage drops across the resistor, producing i1 = V_source/R_series.
A 10 Ω resistor loads the output port (port 2).
CCC gain = 3.

Expected (algebraic, holds for all t):
- v1 = 0  (zero input impedance)
- i1 = sin(2π·t)/5 = 0.2·sin(2π·t)
- i2 = gain·i1 = 0.6·sin(2π·t)
- v2 = −R_load·i2 = −6·sin(2π·t)
"""
test component CCC
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 310, "x2": 100, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  "Input voltage source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 410, "x2": 260, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Series resistor to convert voltage to current"
  r_series = ElectricalComponents.Analog.Basic.Resistor(R = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 310, "y1": 200, "x2": 410, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
  "CCC with gain=3"
  ccc = ElectricalComponents.Analog.Basic.CCC(gain = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 510, "y1": 320, "x2": 610, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Output load resistor"
  r_load = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 790, "y1": 410, "x2": 890, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Input-side ground"
  gnd1 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 580, "x2": 260, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
  "Output-side ground"
  gnd2 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 580, "x2": 680, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.p, r_series.p) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 210, "y": 250}, {"x": 310, "y": 250}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(r_series.n, ccc.p1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 250}, {"x": 460, "y": 321}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(vs.n, gnd1.g) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.n, ccc.n1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 210, "y": 470},
            {"x": 450, "y": 470},
            {"x": 450, "y": 420},
            {"x": 511, "y": 420}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(ccc.p2, r_load.p) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 611, "y": 250}, {"x": 840, "y": 250}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(r_load.n, ccc.n2) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 840, "y": 470}, {"x": 631, "y": 470}, {"x": 631, "y": 420}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(gnd2.g, ccc.n2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 630, "y": 420}], "E": 2}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {"case1": {"stop": 1, "expect": {"signals": ["ccc.v1", "ccc.i1", "ccc.i2"]}}}
  }
}
end
Flattened Source
dyad
"""
Test circuit for CCC (current-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives a 5 Ω series
resistor into the CCC input port (port 1). Since v1=0, the full source
voltage drops across the resistor, producing i1 = V_source/R_series.
A 10 Ω resistor loads the output port (port 2).
CCC gain = 3.

Expected (algebraic, holds for all t):
- v1 = 0  (zero input impedance)
- i1 = sin(2π·t)/5 = 0.2·sin(2π·t)
- i2 = gain·i1 = 0.6·sin(2π·t)
- v2 = −R_load·i2 = −6·sin(2π·t)
"""
test component CCC
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 310, "x2": 100, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  "Input voltage source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 410, "x2": 260, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Series resistor to convert voltage to current"
  r_series = ElectricalComponents.Analog.Basic.Resistor(R = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 310, "y1": 200, "x2": 410, "y2": 300, "rot": 0}
      },
      "tags": []
    }
  }
  "CCC with gain=3"
  ccc = ElectricalComponents.Analog.Basic.CCC(gain = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 510, "y1": 320, "x2": 610, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Output load resistor"
  r_load = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 790, "y1": 410, "x2": 890, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Input-side ground"
  gnd1 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 580, "x2": 260, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
  "Output-side ground"
  gnd2 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 580, "x2": 680, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.p, r_series.p) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 210, "y": 250}, {"x": 310, "y": 250}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(r_series.n, ccc.p1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 460, "y": 250}, {"x": 460, "y": 321}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(vs.n, gnd1.g) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.n, ccc.n1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 210, "y": 470},
            {"x": 450, "y": 470},
            {"x": 450, "y": 420},
            {"x": 511, "y": 420}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(ccc.p2, r_load.p) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 611, "y": 250}, {"x": 840, "y": 250}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(r_load.n, ccc.n2) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 840, "y": 470}, {"x": 631, "y": 470}, {"x": 631, "y": 420}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(gnd2.g, ccc.n2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 630, "y": 420}], "E": 2}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {"case1": {"stop": 1, "expect": {"signals": ["ccc.v1", "ccc.i1", "ccc.i2"]}}}
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt