Skip to content
AmplifierWithOpAmpDetailed.md

AmplifierWithOpAmpDetailed

Inverting operational amplifier circuit built using a detailed op-amp model.

This circuit implements an inverting amplifier configuration utilizing an OpAmpDetailed component. An input signal, generated by input_signal1 (a sine wave with 12V amplitude, 1kHz frequency) and conditioned by voltage_source_1, is applied to the inverting input terminal of the operational amplifier via the input resistor (R_in = 10kΩ). The non-inverting input of the op-amp is connected to the circuit ground. The operational amplifier is powered by voltage_source_2(+15V) andvoltage_source_3(-15V), which are driven byinput_signal2andinput_signal3respectively. The output of the amplifier is connected to a loadresistor2(10kΩ). The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback resistorresistor1 (R_f = 20kΩ) to the input resistor. Given the component values Rin=10kΩ (parameter R of resistor) and Rf=20kΩ (parameter R of resistor1), the ideal gain is -2. The behavior of OpAmpDetailed will introduce non-ideal characteristics.

Usage

AmplifierWithOpAmpDetailed()

Behavior

[input_signal1.y(t)=voltage_source_1.V(t)input_signal2.y(t)=voltage_source_2.V(t)input_signal3.y(t)=voltage_source_3.V(t)connect(ground+g,voltagesource_1+n,opamp+p,resistor2+n,voltagesource_3+n,voltagesource_2+n)connect(resistor+n,opamp+n,resistor1+p)connect(resistor1+n,opamp+outp,resistor2+p)connect(resistor+p,voltagesource_1+p)connect(opamp+p_supply,voltagesource_2+p)connect(opamp+n_supply,voltagesource_3+p)op_amp.v_pos(t)=op_amp.p_supply.v(t)op_amp.v_neg(t)=op_amp.n_supply.v(t)op_amp.p.i(t)=op_amp.i_vos(t)op_amp.n.i(t)=op_amp.i_c3(t)op_amp.i_r2(t)+op_amp.i_4(t)0=op_amp.i_3(t)+op_amp.i_c3(t)op_amp.i_vos(t)+op_amp.i_r2(t)op_amp.p.v(t)op_amp.n.v(t)=op_amp.v_vos(t)+op_amp.v_in(t)op_amp.v_4(t)=op_amp.n.v(t)op_amp.v_3(t)=op_amp.p.v(t)op_amp.v_vos(t)op_amp.v_vos(t)=op_amp.Vosop_amp.i_3(t)=op_amp.I1+op_amp.v_3(t)op_amp.Rcmop_amp.v_in(t)=op_amp.Rdmop_amp.i_r2(t)op_amp.i_c3(t)=op_amp.Cindop_amp.v_in(t)dtop_amp.i_4(t)=op_amp.I2+op_amp.v_4(t)op_amp.Rcmdop_amp.q_fr1(t)dt=6.2832op_amp.fp2(op_amp.q_fr1(t)+op_amp.v_in(t))dop_amp.q_fr2(t)dt6.2832op_amp.fp3+op_amp.q_fr2(t)=dop_amp.q_fr1(t)dt6.2832op_amp.fz+op_amp.q_fr1(t)dop_amp.q_fr3(t)dt=6.2832op_amp.fp4(op_amp.q_fr3(t)+op_amp.q_fr2(t))op_amp.q_sum(t)=op_amp.Avcm_val(op_amp.v_4(t)+op_amp.v_3(t))+op_amp.Avd0_valop_amp.q_fr3(t)op_amp.q_sum_help(t)=ifelse((op_amp.q_sum(t)>op_amp.vcp_abs+op_amp.v_pos(t))(op_amp.q_fp1(t)op_amp.vcp_abs+op_amp.v_pos(t)),op_amp.vcp_abs+op_amp.v_pos(t),ifelse((op_amp.q_sum(t)<op_amp.vcm_abs+op_amp.v_neg(t))(op_amp.q_fp1(t)op_amp.vcm_abs+op_amp.v_neg(t)),op_amp.vcm_abs+op_amp.v_neg(t),op_amp.q_sum(t)))dop_amp.q_fp1(t)dt=6.2832op_amp.fp1(op_amp.q_fp1(t)+op_amp.q_sum_help(t))dop_amp.x(t)dt=op_amp.v_source(t)+op_amp.q_fp1(t)op_amp.Tsdop_amp.v_source(t)dt=ifelse(dop_amp.x(t)dt>op_amp.sr_p_val,op_amp.sr_p_val,ifelse(dop_amp.x(t)dt<op_amp.sr_m_val,op_amp.sr_m_val,dop_amp.x(t)dt))op_amp.v_out(t)=op_amp.outp.v(t)op_amp.i_out(t)=op_amp.outp.i(t)op_amp.i_out(t)=ifelse(op_amp.v_out(t)>op_amp.v_source(t)+op_amp.Imaxsi_valop_amp.Rout,op_amp.Imaxsi_val,ifelse(op_amp.v_out(t)<op_amp.v_source(t)op_amp.Imaxso_valop_amp.Rout,op_amp.Imaxso_val,op_amp.v_source(t)+op_amp.v_out(t)op_amp.Rout))op_amp.p_supply.i(t)=0op_amp.n_supply.i(t)=0resistor.v(t)=resistor.n.v(t)+resistor.p.v(t)resistor.i(t)=resistor.p.i(t)resistor.p.i(t)+resistor.n.i(t)=0resistor.v(t)=resistor.Rresistor.i(t)resistor1.v(t)=resistor1.n.v(t)+resistor1.p.v(t)resistor1.i(t)=resistor1.p.i(t)resistor1.n.i(t)+resistor1.p.i(t)=0resistor1.v(t)=resistor1.Rresistor1.i(t)resistor2.v(t)=resistor2.n.v(t)+resistor2.p.v(t)resistor2.i(t)=resistor2.p.i(t)resistor2.p.i(t)+resistor2.n.i(t)=0resistor2.v(t)=resistor2.Rresistor2.i(t)voltage_source_1.v(t)=voltage_source_1.n.v(t)+voltage_source_1.p.v(t)voltage_source_1.i(t)=voltage_source_1.p.i(t)voltage_source_1.p.i(t)+voltage_source_1.n.i(t)=0voltage_source_1.v(t)=voltage_source_1.uVvoltage_source_1.V(t)voltage_source_2.v(t)=voltage_source_2.n.v(t)+voltage_source_2.p.v(t)voltage_source_2.i(t)=voltage_source_2.p.i(t)voltage_source_2.n.i(t)+voltage_source_2.p.i(t)=0voltage_source_2.v(t)=voltage_source_2.uVvoltage_source_2.V(t)voltage_source_3.v(t)=voltage_source_3.n.v(t)+voltage_source_3.p.v(t)voltage_source_3.i(t)=voltage_source_3.p.i(t)voltage_source_3.p.i(t)+voltage_source_3.n.i(t)=0voltage_source_3.v(t)=voltage_source_3.uVvoltage_source_3.V(t)input_signal1.y(t)=ifelse(input_signal1.start_time<t,input_signal1.offset+input_signal1.amplitudesin(input_signal1.phase+6.2832input_signal1.frequency(input_signal1.start_time+t)),input_signal1.offset)input_signal2.y(t)=input_signal2.kinput_signal3.y(t)=input_signal3.kground.g.v(t)=0]

Source

dyad
# Inverting operational amplifier circuit built using a detailed op-amp model.
#
# This circuit implements an inverting amplifier configuration utilizing an `OpAmpDetailed` component.
# An input signal, generated by `input_signal1` (a sine wave with 12V amplitude, 1kHz frequency)
# and conditioned by `voltage_source_1`, is applied to the inverting input terminal of the operational
# amplifier via the input `resistor` (R_in = 10kΩ). The non-inverting input of the op-amp is
# connected to the circuit ground. The operational amplifier is powered by `voltage_source_2` (+15V)
# and `voltage_source_3` (-15V), which are driven by `input_signal2` and `input_signal3` respectively.
# The output of the amplifier is connected to a load `resistor2` (10kΩ).
# The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback
# resistor `resistor1` (R_f = 20kΩ) to the input `resistor`.
# Given the component values $R_{in} = 10k\Omega$ (parameter `R` of `resistor`) and
# $R_f = 20k\Omega$ (parameter `R` of `resistor1`), the ideal gain is -2.
# The behavior of `OpAmpDetailed` will introduce non-ideal characteristics.
test component AmplifierWithOpAmpDetailed
  # Detailed operational amplifier model instance, forming the core of the amplifier.
  op_amp = OpAmpDetailed() [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}}
  }]
  # Input resistor (R_in), value 10kOhm, connecting the input signal to the op-amp's inverting input.
  resistor = Resistor(R=10000) [{
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}}
  }]
  # Feedback resistor (R_f), value 20kOhm, from op-amp output to inverting input, sets gain.
  resistor1 = Resistor(R=20000) [{
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}}
  }]
  # Load resistor, value 10kOhm, connected from the op-amp output to ground.
  resistor2 = Resistor(R=10000) [{
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}}
    }
  }]
  # Ideal voltage source component for applying the input AC signal.
  voltage_source_1 = VoltageSource() [{
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}}
  }]
  # Ideal voltage source component for the positive power supply (+15V).
  voltage_source_2 = VoltageSource() [{
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}}
  }]
  # Ideal voltage source component for the negative power supply (-15V).
  voltage_source_3 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}}
    }
  }]
  # Sine wave signal generator (12V amplitude, 1kHz) for the amplifier's input.
  input_signal1 = BlockComponents.Sine(amplitude=12, frequency=1000, offset=0) [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}}
    }
  }]
  # Constant signal generator providing +15V for the positive op-amp supply.
  input_signal2 = BlockComponents.Constant(k=15) [{
    "Dyad": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}}
  }]
  # Constant signal generator providing -15V for the negative op-amp supply.
  input_signal3 = BlockComponents.Constant(k=-15) [{
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}}
    }
  }]
  # Electrical ground reference component for the circuit.
  ground = Ground() [{
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}}
    }
  }]
relations
  connect(input_signal1.y, voltage_source_1.V) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(input_signal2.y, voltage_source_2.V) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 1200, "y": 250}, {"x": 1200, "y": 550}, {"x": 650, "y": 550}],
          "E": 2
        }
      ]
    }
  }]
  connect(input_signal3.y, voltage_source_3.V) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 650, "y": 1300},
            {"x": 650, "y": 1150},
            {"x": 500, "y": 1150},
            {"x": 500, "y": 950}
          ],
          "E": 2
        }
      ]
    }
  }]
  initial resistor2.i = 0
  initial op_amp.q_fp1 = 0
  initial op_amp.q_fr1 = 0
  initial op_amp.q_fr2 = 0
  initial op_amp.q_fr3 = 0
  connect(ground.g, voltage_source_1.n, op_amp.p, resistor2.n, voltage_source_3.n, voltage_source_2.n) [{
    "Dyad": {
      "edges": [
        {"S": 1, "E": -2},
        {"S": -3, "E": 2},
        {"S": -3, "M": [{"x": 350, "y": 690}], "E": 3},
        {"S": -2, "E": 4},
        {"S": -1, "E": 5},
        {"S": -2, "M": [{"x": 1050, "y": 1100}, {"x": 1050, "y": 400}], "E": 6},
        {"S": -1, "E": -2},
        {"S": -1, "M": [{"x": 350, "y": 1100}], "E": -3}
      ],
      "junctions": [{"x": 650, "y": 1100}, {"x": 900, "y": 1100}, {"x": 350, "y": 950}]
    }
  }]
  connect(resistor.n, op_amp.n, resistor1.p) [{
    "Dyad": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": 350, "y": 100}], "E": 3}
      ],
      "junctions": [{"x": 350, "y": 610}]
    }
  }]
  connect(resistor1.n, op_amp.outp, resistor2.p) [{
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 900, "y": 100}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 650}]
    }
  }]
  connect(resistor.p, voltage_source_1.p) [{
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]}
  }]
  connect(op_amp.p_supply, voltage_source_2.p) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}]
  connect(op_amp.n_supply, voltage_source_3.p) [{
    "Dyad": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]}
  }]
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 0.1,
        "atol": {"op_amp.outp.v": 0.4},
        "expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]}
      }
    }
  }
}
end
Flattened Source
dyad
# Inverting operational amplifier circuit built using a detailed op-amp model.
#
# This circuit implements an inverting amplifier configuration utilizing an `OpAmpDetailed` component.
# An input signal, generated by `input_signal1` (a sine wave with 12V amplitude, 1kHz frequency)
# and conditioned by `voltage_source_1`, is applied to the inverting input terminal of the operational
# amplifier via the input `resistor` (R_in = 10kΩ). The non-inverting input of the op-amp is
# connected to the circuit ground. The operational amplifier is powered by `voltage_source_2` (+15V)
# and `voltage_source_3` (-15V), which are driven by `input_signal2` and `input_signal3` respectively.
# The output of the amplifier is connected to a load `resistor2` (10kΩ).
# The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback
# resistor `resistor1` (R_f = 20kΩ) to the input `resistor`.
# Given the component values $R_{in} = 10k\Omega$ (parameter `R` of `resistor`) and
# $R_f = 20k\Omega$ (parameter `R` of `resistor1`), the ideal gain is -2.
# The behavior of `OpAmpDetailed` will introduce non-ideal characteristics.
test component AmplifierWithOpAmpDetailed
  # Detailed operational amplifier model instance, forming the core of the amplifier.
  op_amp = OpAmpDetailed() [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}}
  }]
  # Input resistor (R_in), value 10kOhm, connecting the input signal to the op-amp's inverting input.
  resistor = Resistor(R=10000) [{
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}}
  }]
  # Feedback resistor (R_f), value 20kOhm, from op-amp output to inverting input, sets gain.
  resistor1 = Resistor(R=20000) [{
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}}
  }]
  # Load resistor, value 10kOhm, connected from the op-amp output to ground.
  resistor2 = Resistor(R=10000) [{
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}}
    }
  }]
  # Ideal voltage source component for applying the input AC signal.
  voltage_source_1 = VoltageSource() [{
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}}
  }]
  # Ideal voltage source component for the positive power supply (+15V).
  voltage_source_2 = VoltageSource() [{
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}}
  }]
  # Ideal voltage source component for the negative power supply (-15V).
  voltage_source_3 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}}
    }
  }]
  # Sine wave signal generator (12V amplitude, 1kHz) for the amplifier's input.
  input_signal1 = BlockComponents.Sine(amplitude=12, frequency=1000, offset=0) [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}}
    }
  }]
  # Constant signal generator providing +15V for the positive op-amp supply.
  input_signal2 = BlockComponents.Constant(k=15) [{
    "Dyad": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}}
  }]
  # Constant signal generator providing -15V for the negative op-amp supply.
  input_signal3 = BlockComponents.Constant(k=-15) [{
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}}
    }
  }]
  # Electrical ground reference component for the circuit.
  ground = Ground() [{
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}}
    }
  }]
relations
  connect(input_signal1.y, voltage_source_1.V) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(input_signal2.y, voltage_source_2.V) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 1200, "y": 250}, {"x": 1200, "y": 550}, {"x": 650, "y": 550}],
          "E": 2
        }
      ]
    }
  }]
  connect(input_signal3.y, voltage_source_3.V) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 650, "y": 1300},
            {"x": 650, "y": 1150},
            {"x": 500, "y": 1150},
            {"x": 500, "y": 950}
          ],
          "E": 2
        }
      ]
    }
  }]
  initial resistor2.i = 0
  initial op_amp.q_fp1 = 0
  initial op_amp.q_fr1 = 0
  initial op_amp.q_fr2 = 0
  initial op_amp.q_fr3 = 0
  connect(ground.g, voltage_source_1.n, op_amp.p, resistor2.n, voltage_source_3.n, voltage_source_2.n) [{
    "Dyad": {
      "edges": [
        {"S": 1, "E": -2},
        {"S": -3, "E": 2},
        {"S": -3, "M": [{"x": 350, "y": 690}], "E": 3},
        {"S": -2, "E": 4},
        {"S": -1, "E": 5},
        {"S": -2, "M": [{"x": 1050, "y": 1100}, {"x": 1050, "y": 400}], "E": 6},
        {"S": -1, "E": -2},
        {"S": -1, "M": [{"x": 350, "y": 1100}], "E": -3}
      ],
      "junctions": [{"x": 650, "y": 1100}, {"x": 900, "y": 1100}, {"x": 350, "y": 950}]
    }
  }]
  connect(resistor.n, op_amp.n, resistor1.p) [{
    "Dyad": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": 350, "y": 100}], "E": 3}
      ],
      "junctions": [{"x": 350, "y": 610}]
    }
  }]
  connect(resistor1.n, op_amp.outp, resistor2.p) [{
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 900, "y": 100}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 650}]
    }
  }]
  connect(resistor.p, voltage_source_1.p) [{
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]}
  }]
  connect(op_amp.p_supply, voltage_source_2.p) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}]
  connect(op_amp.n_supply, voltage_source_3.p) [{
    "Dyad": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]}
  }]
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 0.1,
        "atol": {"op_amp.outp.v": 0.4},
        "expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt