API Reference
CircuitSim.ACAnalysis — Type
ACAnalysis(; start, stop, points, sweep_type=LOGARITHMIC, name="AC1")
ACAnalysis(; values, sweep_type=LIST, name="AC1")AC small-signal frequency sweep analysis.
Computes the small-signal AC response over a frequency range.
Parameters
For LINEAR or LOGARITHMIC sweeps:
start::Real: Start frequency in Hzstop::Real: Stop frequency in Hzpoints::Int: Number of frequency pointssweep_type::String: "lin"/"linear" or "log"/"logarithmic" (default: "log")
For LIST sweeps:
values::Vector{<:Real}: List of frequency points in Hzsweep_type::String: Must be "list"
For CONSTANT sweeps:
values::Real: Single frequency value in Hzsweep_type::String: Must be "const" or "constant"
Common parameters:
name::String: Analysis name (default: "AC1")
Example
# Logarithmic sweep from 1Hz to 1MHz with 101 points
analysis = ACAnalysis(start=1.0, stop=1e6, points=101)
# Linear sweep
analysis = ACAnalysis(start=100.0, stop=10e3, points=100, sweep_type="lin")
# List of specific frequencies
analysis = ACAnalysis(values=[1e3, 10e3, 100e3, 1e6], sweep_type="list")
# Single frequency
analysis = ACAnalysis(values=1e6, sweep_type="const")CircuitSim.ACCurrentSource — Type
ACCurrentSource <: AbstractACCurrentSourceAC current source with two terminals. Current flows from nminus to nplus (into nplus).
For AC analysis, provides a sinusoidal current source.
dc: DC offset (default 0)ac_mag: AC magnitude for small-signal analysisac_phase: AC phase in degrees (default 0)freq: Frequency in Hz (for transient analysis)
Fields
name::String: Component identifiernplus::Int: Positive terminal node numbernminus::Int: Negative terminal node numberdc::Real: DC offset currentac_mag::Real: AC magnitude in Amperesac_phase::Real: AC phase in degreesfreq::Real: Frequency in Hz
Example
# 1mA AC source at 1kHz
I1 = ACCurrentSource("I1", 0.001, freq=1e3)
# 10mA AC with 5mA DC offset
I2 = ACCurrentSource("I2", 0.01, dc=0.005, freq=50.0)CircuitSim.ACPowerSource — Type
AC Power Source component for S-parameter and frequency-domain analysis.
This is a generic power source with specified impedance, used as a port for S-parameter, AC, and harmonic balance analyses. In Qucsator netlists, this becomes a "Pac" component.
CircuitSim.ACResult — Type
ACResultAC analysis results (frequency sweep).
Fields
frequencies_Hz::Vector{Float64}: Frequency pointsvoltages::Dict{String,Vector{ComplexF64}}: Node voltages vs frequencycurrents::Dict{String,Vector{ComplexF64}}: Branch currents vs frequency
CircuitSim.ACVoltageSource — Type
ACVoltageSource <: AbstractACVoltageSourceAC voltage source with two terminals.
For AC analysis, provides a sinusoidal voltage source.
dc: DC offset (default 0)ac_mag: AC magnitude for small-signal analysisac_phase: AC phase in degrees (default 0)freq: Frequency in Hz (for transient analysis)
Note: For AC analysis (.AC), only acmag and acphase are used. For transient analysis, all parameters define a sinusoid: V(t) = dc + acmag * sin(2πfreqt + acphase)
Fields
name::String: Component identifiernplus::Int: Positive terminal node numbernminus::Int: Negative terminal node numberdc::Real: DC offset voltageac_mag::Real: AC magnitude in Voltsac_phase::Real: AC phase in degreesfreq::Real: Frequency in Hz
Example
# 1V AC source at 1kHz
V1 = ACVoltageSource("V1", 1.0, freq=1e3)
# 5V AC with 2V DC offset
V2 = ACVoltageSource("V2", 5.0, dc=2.0, freq=1e6)CircuitSim.AbstractAnalysis — Type
AbstractAnalysisAbstract base type for all circuit analysis.
CircuitSim.AbstractSweepAnalysis — Type
AbstractSweepAnalysis <: AbstractAnalysisAbstract type for sweep-based analyses (AC, SP, parameter sweeps).
CircuitSim.Amplifier — Type
Amplifier <: AbstractPowerAmplifierRF/microwave amplifier with gain and noise figure.
This is a simplified amplifier model suitable for system-level simulations.
Fields
name::String: Component identifierinput::Int: Input terminal node numberoutput::Int: Output terminal node numbergain::Real: Linear voltage gain. For 20 dB gain, use gain=10.0nf::Real: Noise figure (linear). For 3 dB NF, use nf=2.0. Default: 1.0 (noiseless)z_in::Real: Input impedance in Ohms (default: 50)z_out::Real: Output impedance in Ohms (default: 50)
CircuitSim.Attenuator — Type
Attenuator <: AbstractAttenuatorRF attenuator for signal level control.
An attenuator reduces signal power by a specified amount while maintaining impedance matching.
Fields
name::String: Component identifiern1::Int: Input terminal node numbern2::Int: Output terminal node numberattenuation::Real: Attenuation in linear scalez0::Real: Reference impedance in Ohms (default: 50)temp::Real: Temperature in Celsius (default: 26.85)
CircuitSim.BiasTee — Type
BiasTee <: AbstractBiasTeeBias tee for combining DC bias and RF signals.
A bias tee has three ports:
- RF port: AC coupled (passes RF, blocks DC)
- DC port: DC coupled (passes DC, blocks RF)
- Combined port: Both DC and RF
Fields
name::String: Component identifiern_rf::Int: RF input port node numbern_dc::Int: DC input port node numbern_out::Int: Combined output port node numbercapacitance::Real: DC blocking capacitance (default: 1 μF)inductance::Real: RF choke inductance (default: 1 mH)
Example
using CircuitSim
# Standard bias tee
BT1 = BiasTee("BT1")
# Custom component values
BT2 = BiasTee("BT2", capacitance=10e-6, inductance=10e-3)CircuitSim.BondWire — Type
BondWire <: AbstractBondWireA bond wire connection for chip interconnects.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (output)l::Real: Wire length (m)d::Real: Wire diameter (m)h::Real: Wire height above substrate (m)rho::Real: Resistivity relative to copper
Example
wire = BondWire("BW1", l=1e-3, d=25e-6, h=0.3e-3)Qucs Format
BONDWIRE:Name Node1 Node2 L="length" D="diameter" H="height" rho="resistivity"
CircuitSim.Capacitor — Type
Capacitor <: AbstractCapacitorIdeal capacitor with two terminals.
Fields
name::String: Component identifiern1::Int: First terminal node number (assigned during circuit analysis)n2::Int: Second terminal node number (assigned during circuit analysis)capacitance::Real: Capacitance in Faradsinitial_voltage::Real: Initial voltage across the capacitor (default: 0.0)
Example
C1 = Capacitor("C1", capacitance=100e-9) # 100nF capacitor
C2 = Capacitor("C2", capacitance=10e-6, initial_voltage=5.0) # 10µF capacitor with 5V initial voltageCircuitSim.CapacitorQ — Type
CapacitorQ <: AbstractCapacitorCapacitor with quality factor for RF simulations.
Fields
name::String: Component identifiern1::Int: First terminal node numbern2::Int: Second terminal node numbercapacitance::Real: Capacitance in Faradsq::Real: Quality factor (Q) at the specified frequencyfrequency::Real: frequency in Hz where Q is specified (default: 1 GHz)mode::String: Q frequency dependency mode - "Linear", "SquareRoot", or "Constant" (default: "Linear")temp::Real: Temperature in Celsius for noise calculations (default: 26.85°C)
Example
using CircuitSim
C1 = CapacitorQ("C1", capacitance=10e-12, q=50.0) # 10pF capacitor with Q=50
C2 = CapacitorQ("C2", capacitance=100e-12, q=100.0, frequency=2.4e9, mode="SquareRoot") # 100pF, Q=100 at 2.4 GHzCircuitSim.Circuit — Type
Circuit representation: collection of components and connections
CircuitSim.CircularLoop — Type
CircularLoop <: AbstractCircularLoopA single-turn circular loop inductor.
Fields
name::String: Component identifiern1::Int: Node 1n2::Int: Node 2r::Real: Loop radius (m)w::Real: Wire/trace width (m)
Example
loop = CircularLoop("CL1", r=5e-3, w=0.5e-3)Qucs Format
Approximated using standard inductor with calculated value
CircuitSim.Circulator — Type
Circulator <: AbstractCirculator3-port RF circulator.
A circulator routes signals in one direction: port 1→2, 2→3, 3→1. Commonly used for isolating transmitter and receiver sharing an antenna.
Fields
name::String: Component identifiern1::Int: Port 1 node numbern2::Int: Port 2 node numbern3::Int: Port 3 node numberinsertion_loss::Real: Loss through forward path (dB) (default: 0.5)isolation::Real: Isolation to reverse path (dB) (default: 20)z0::Real: Reference impedance in Ohms (default: 50)
Example
using CircuitSim
# Standard circulator
CIRC1 = Circulator("CIRC1")
# Custom circulator with better isolation
CIRC2 = Circulator("CIRC2", isolation=30.0)CircuitSim.CoaxialLine — Type
CoaxialLine <: AbstractComponentCoaxial transmission line with physical parameters.
Fields
name::String: Component identifierer::Float64: Relative permittivity (default: 2.3)mur::Float64: Relative permeability (default: 1.0)length_m::Float64: Physical length in metersd_mm::Float64: Inner conductor diameter in mmd_outer_mm::Float64: Outer conductor diameter in mmn1::Int: Input port positive noden2::Int: Input port negative noden3::Int: Output port positive noden4::Int: Output port negative node
Pins
:n1,:n2: Input port:n3,:n4: Output port
Example
julia> coax = CoaxialLine("COAX1", er=2.3, length_m=0.1, d_mm=0.5, d_outer_mm=3.0)
CoaxialLine("COAX1", 0, 0, 2.3, 1.0, 0.1, 0.5, 3.0, 0.0004, 2.2e-8)CircuitSim.Coupler — Type
Coupler <: AbstractCouplerDirectional coupler (4-port device).
A directional coupler splits power with specified coupling factor. Ports: 1=input, 2=through, 3=coupled, 4=isolated
Fields
name::String: Component identifiern1::Int: Port 1 (input) node numbern2::Int: Port 2 (through) node numbern3::Int: Port 3 (coupled) node numbern4::Int: Port 4 (isolated) node numbercoupling::Real: Coupling factor in dB (e.g., 3 for 3 dB coupler, 10 for 10 dB coupler)isolation::Real: Isolation in dB (default: 20)insertion_loss::Real: Insertion loss (through path) in dB (default: 0.5)z0::Real: Reference impedance in Ohms (default: 50)
Example
using CircuitSim
# 3 dB (50/50) directional coupler
DC1 = Coupler("DC1", coupling=3.0)
# 10 dB directional coupler (10% coupling)
DC2 = Coupler("DC2", coupling=10.0)
# 20 dB directional coupler with high isolation
DC3 = Coupler("DC3", coupling=20.0, isolation=30.0)CircuitSim.CurrentControlledCurrentSource — Type
CurrentControlledCurrentSource(name::String; g::Real=1.0, t::Real=0.0)Create a current-controlled current source with 4-port configuration.
Arguments
name::String: Component identifierg::Real: Current gain (dimensionless) (default 1.0)t::Real: Time delay in seconds (default 0.0)
Fields
n1::Int: Positive input node (where current is sensed)n2::Int: Negative input node (where current is sensed)n3::Int: Positive output noden4::Int: Negative output node
CircuitSim.CurrentControlledVoltageSource — Type
Current-Controlled Voltage Source (CCVS).
A voltage source whose output voltage is controlled by the current through another element.
CircuitSim.CurrentCurrentNoiseSource — Type
CurrentCurrentNoiseSource(name::String; i1::Real=1e-6, i2::Real=1e-6, c_corr::Real=0.0, a::Real=0.0, c::Real=1.0, e::Real=0.0)Create correlated current-current noise sources with 4-port configuration.
Arguments
name::String: Component identifieri1::Real: RMS current of first source in A (default 1e-6)i2::Real: RMS current of second source in A (default 1e-6)c_corr::Real: Correlation coefficient -1 to 1 (default 0.0)a::Real: Flicker noise exponent (default 0.0)c::Real: Flicker noise coefficient (default 1.0)e::Real: Flicker noise frequency exponent (default 0.0)
Fields
i1plus::Int: Positive node of first current sourcei1minus::Int: Negative node of first current sourcei2plus::Int: Positive node of second current sourcei2minus::Int: Negative node of second current source
CircuitSim.CurrentExponentialSource — Type
CurrentExponentialSource <: AbstractCurrentSourceExponential rise/fall current source for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberi1::Real: Initial current level (A)i2::Real: Final current level (A)t1::Real: Rise delay time (s)t2::Real: Fall delay time (s)tr::Real: Rise time constant (s, optional, default 1ns)tf::Real: Fall time constant (s, optional, default 1ns)
Example
isrc = CurrentExponentialSource("Iexp1", i1=0.0, i2=10e-3, t1=1e-9, t2=10e-9)CircuitSim.CurrentNoiseSource — Type
CurrentNoiseSource <: AbstractCurrentSourceCurrent noise source for noise analysis with frequency-dependent PSD.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberi::Real: Noise power spectral density (A²/Hz)a::Real: Frequency offset parameter (optional, default 0)c::Real: Frequency coefficient (optional, default 1)e::Real: Frequency exponent (optional, default 0)
Noise PSD formula: PSD(f) = i / (a + c * f^e)
Example
isrc = CurrentNoiseSource("Inoise1", i=1e-12, e=0) # White noiseCircuitSim.CurrentProbe — Type
Current probe for measuring current in AC, DC, and transient analyses.
The probe is inserted in series with a circuit element and measures current. It acts as a short circuit (zero impedance).
CircuitSim.CurrentPulseSource — Type
CurrentPulseSource <: AbstractSourceCurrent source with pulse waveform for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberi1::Real: Initial current level (A)i2::Real: Pulsed current level (A)t1::Real: Start time of pulse (s)t2::Real: End time of pulse (s)tr::Real: Rise time (s, optional, default 1ns)tf::Real: Fall time (s, optional, default 1ns)
Example
isrc = CurrentPulseSource("Ipulse1", i1=0.0, i2=10e-3, t1=1e-9, t2=10e-9)CircuitSim.CurrentRectangularSource — Type
CurrentRectangularSource <: AbstractCurrentSourcePeriodic rectangular pulse current source for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberi::Real: Pulse current level (A)th::Real: High time duration (s)tl::Real: Low time duration (s)tr::Real: Rise time (s, optional, default 1ns)tf::Real: Fall time (s, optional, default 1ns)td::Real: Delay time (s, optional, default 0)
Example
isrc = CurrentRectangularSource("Irect1", i=10e-3, th=1e-6, tl=1e-6)CircuitSim.CurrentVoltageNoiseSource — Type
CurrentVoltageNoiseSource(name::String; i1::Real=1e-6, v2::Real=1e-6, c_corr::Real=0.0, a::Real=0.0, c::Real=1.0, e::Real=0.0)Create correlated current-voltage noise sources with 4-port configuration.
Arguments
name::String: Component identifieri1::Real: RMS current in A (default 1e-6)v2::Real: RMS voltage in V (default 1e-6)c_corr::Real: Correlation coefficient -1 to 1 (default 0.0)a::Real: Flicker noise exponent (default 0.0)c::Real: Flicker noise coefficient (default 1.0)e::Real: Flicker noise frequency exponent (default 0.0)
Fields
i1plus::Int: Positive node of current sourcei1minus::Int: Negative node of current sourcev2plus::Int: Positive node of voltage sourcev2minus::Int: Negative node of voltage source
CircuitSim.DCAnalysis — Type
DCAnalysis(; save_ops=true, temp=26.85, save_all=false)DC operating point analysis.
Computes the DC operating point of the circuit.
Parameters
save_ops::Bool: Save operating points of nonlinear devices (default: true)temp::Real: Simulation temperature in °C (default: 26.85)save_all::Bool: Save all node voltages and branch currents (default: false)name::String: Analysis name (default: "DC1")
Example
analysis = DCAnalysis()
result = simulate_qucsator(circuit, analysis)
# With custom temperature
analysis = DCAnalysis(temp=85.0)CircuitSim.DCBlock — Type
DCBlock <: AbstractDCBlockDC blocking capacitor for RF applications.
This is essentially a large capacitor that passes AC signals while blocking DC. Typically used to isolate DC bias points between stages.
Fields
name::String: Component identifiern1::Int: First terminal node numbern2::Int: Second terminal node numbercapacitance::Real: Capacitance in Farads (default: 1 μF for near-ideal blocking)
Example
using CircuitSim
# Default DC block (1 μF)
DCB1 = DCBlock("DCB1")
# Custom capacitance
DCB2 = DCBlock("DCB2", capacitance=10e-6) # 10 μFCircuitSim.DCCurrentSource — Type
DCCurrentSource <: AbstractDCCurrentSourceDC current source with two terminals. Current flows from nminus to nplus (into nplus).
Fields
name::String: Component identifiernplus::Int: Positive terminal node numbernminus::Int: Negative terminal node numbercurrent::Real: DC current in Amperes
Example
I1 = DCCurrentSource("I1", current=0.001) # 1mA DC sourceCircuitSim.DCFeed — Type
DCFeed <: AbstractDCFeedDC feed (RF choke) for providing DC bias while blocking RF.
This component passes DC current while presenting high impedance to RF signals. Typically implemented as a large inductor.
Fields
name::String: Component identifiern1::Int: First terminal node numbern2::Int: Second terminal node numberinductance::Real: Inductance in Henries (default: 1 mH for good RF blocking)
Example
using CircuitSim
# Default DC feed (1 mH)
DCF1 = DCFeed("DCF1")
# Custom inductance
DCF2 = DCFeed("DCF2", inductance=10e-3) # 10 mHCircuitSim.DCResult — Type
DCResultDC operating point results.
Fields
voltages::Dict{String,Float64}: Node voltages (node_name => voltage)currents::Dict{String,Float64}: Branch currents (component_name => current)
CircuitSim.DCVoltageSource — Type
DCVoltageSource <: AbstractDCVoltageSourceDC voltage source with two terminals.
Fields
name::String: Component identifiernplus::Int: Positive terminal node numbernminus::Int: Negative terminal node numbervoltage::Real: DC voltage in Volts
Example
V1 = DCVoltageSource("V1", voltage=12.0) # 12V DC sourceCircuitSim.DataVector — Type
DataVectorRepresents a data vector from simulation output.
Fields
name::String: Vector namevalues::Vector{ComplexF64}: Data valuesdependencies::Vector{String}: Names of independent variables this depends onis_independent::Bool: Whether this is an independent variable
CircuitSim.FileCurrentSource — Type
FileCurrentSource <: AbstractSourceFile-based current source for transient analysis.
This component can operate in two modes:
- File mode: Reads current vs. time data from an external file
- Vector mode: Accepts Julia vectors and automatically creates temporary file
The data consists of time-current pairs that are interpolated during simulation.
Fields
name::String: Component identifiernplus::Int: Positive terminal node number (current flows from nplus to nminus)nminus::Int: Negative terminal node numberfile::Union{String,Nothing}: Path to data file (nothing for vector mode)time_vector::Union{AbstractVector,Nothing}: Time values for vector modecurrent_vector::Union{AbstractVector,Nothing}: Current values for vector modeinterpolator::String: Interpolation method ("linear", "cubic", or "hold")repeat::Bool: Whether to repeat the waveformgain::Real: Gain factor (multiplier for current values)delay::Real: Time delay in secondsformat::Symbol: File format (:csv or :qucs_dataset, default :csv)
Supported File Formats
CSV Format (default, recommended)
Two columns: time, current (comma or semicolon separated) Optional header row with column names
Example:
time,current
0.0,0.0
1e-9,0.001
2e-9,0.001Qucs Dataset Format
Native qucsator format with indep/dep blocks
Example:
<Qucs Dataset 1.0.0>
<indep time 3>
0.0
1e-9
2e-9
</indep>
<dep I1 3>
0.0
0.001
0.001
</dep>Example
using CircuitSim
# Vector mode - creates a temporary csv file and passes to qucsator.
time = [0.0, 1e-9, 2e-9, 3e-9, 4e-9]
current = [0.0, 0.001, 0.001, 0.0, 0.0]
I1 = FileCurrentSource("I1", time, current)
# Vector mode with Qucs Dataset format
I2 = FileCurrentSource("I2", time, current, format=:qucs_dataset)
# File mode - read from existing file
I3 = FileCurrentSource("I3", "my_current.csv")
# With cubic interpolation and repeating waveform
I4 = FileCurrentSource("I4", time, current, interpolator="cubic", repeat=true)CircuitSim.FileVoltageSource — Type
FileVoltageSource <: AbstractSourceFile-based voltage source for transient analysis.
This component can operate in two modes:
- File mode: Reads voltage vs. time data from an external file
- Vector mode: Accepts Julia vectors and automatically creates temporary file
The data consists of time-voltage pairs that are interpolated during simulation.
Fields
name::String: Component identifiernplus::Int: Positive terminal node numbernminus::Int: Negative terminal node numberfile::Union{String,Nothing}: Path to data file (nothing for vector mode)time_vector::Union{AbstractVector,Nothing}: Time values for vector modevoltage_vector::Union{AbstractVector,Nothing}: Voltage values for vector modeinterpolator::String: Interpolation method ("linear", "cubic", or "hold")repeat::Bool: Whether to repeat the waveformgain::Real: Gain factor (multiplier for voltage values)delay::Real: Time delay in secondsformat::Symbol: File format (:csv or :qucs_dataset, default :csv)
Supported File Formats
CSV Format (default, recommended)
Two columns: time, voltage (comma or semicolon separated) Optional header row with column names
Example:
time,voltage
0.0,0.0
1e-9,1.0
2e-9,0.5Qucs Dataset Format
Native qucsator format with indep/dep blocks
Example:
<Qucs Dataset 1.0.0>
<indep time 4>
0.0
1e-9
2e-9
3e-9
</indep>
<dep V1 4>
0.0
1.0
0.5
0.0
</dep>Example
using CircuitSim
# Vector mode - creates a temporary csv file and passes to qucsator.
time = [0.0, 1e-9, 2e-9, 3e-9]
voltage = [0.0, 1.0, 1.0, 0.0]
V1 = FileVoltageSource("V1", time, voltage)
# Vector mode with Qucs Dataset format
V2 = FileVoltageSource("V2", time, voltage, format=:qucs_dataset)
# File mode - read from existing file
V3 = FileVoltageSource("V3", "my_waveform.csv")
# With interpolation and gain
V4 = FileVoltageSource("V4", time, voltage, interpolator="cubic", gain=2.0)CircuitSim.Ground — Type
Ground <: AbstractGroundGround reference node (single pin). Maps to node 0.
Fields
name::String: Component identifiern::Int: Terminal node number (always 0 for ground)
Example
GND = Ground("GND")CircuitSim.Gyrator — Type
Gyrator <: AbstractComponentGyrator converts impedance (e.g., capacitor ↔ inductor).
Fields
name::String: Component identifierr::Float64: Gyration resistance in Ω (default: 50.0)zref::Float64: Reference impedance in Ω (default: 50.0)n1::Int: Port 1 positive noden2::Int: Port 1 negative noden3::Int: Port 2 positive noden4::Int: Port 2 negative node
Pins
:n1,:n2: Port 1:n3,:n4: Port 2
Example
julia> gyr = Gyrator("GYR1", r=100.0)
Gyrator("GYR1", 0, 0, 0, 0, 100.0, 50.0)CircuitSim.HarmonicBalanceAnalysis — Type
HarmonicBalanceAnalysis(; harmonics, frequency=1e9, name="HB1", iabstol=1e-12, vabstol=1e-6, reltol=1e-3, max_iterations=150)Harmonic balance analysis for steady-state analysis of nonlinear circuits with periodic excitation.
Parameters
harmonics::Int: Number of harmonics to include (required)frequency::Real: Fundamental frequency in Hz (default: 1e9)name::String: Analysis name (default: "HB1")iabstol::Real: Current absolute tolerance (default: 1e-12)vabstol::Real: Voltage absolute tolerance (default: 1e-6)reltol::Real: Relative tolerance (default: 1e-3)max_iterations::Int: Maximum number of iterations (default: 150)
Example
# Harmonic balance at 1GHz with 7 harmonics
analysis = HarmonicBalanceAnalysis(harmonics=7, frequency=1e9)
# RF mixer analysis at 100MHz with custom tolerances
analysis = HarmonicBalanceAnalysis(harmonics=11, frequency=100e6, reltol=1e-4)CircuitSim.Hybrid — Type
Hybrid <: AbstractHybridCouplerHybrid coupler (90° or 180° 3dB power splitter/combiner).
A hybrid coupler is a specialized 4-port device that splits power equally between two ports with a specific phase relationship.
Fields
name::String: Component identifiern1::Int: Port 1 (sum) node numbern2::Int: Port 2 (difference/isolated) node numbern3::Int: Port 3 (output 1) node numbern4::Int: Port 4 (output 2) node numberphase::Real: Phase difference in degrees (90 or 180) (default: 90)insertion_loss::Real: Insertion loss in dB (default: 0.5)isolation::Real: Isolation between ports in dB (default: 20)z0::Real: Reference impedance in Ohms (default: 50)
Example
using CircuitSim
# 90 degree hybrid (quadrature hybrid)
HYB1 = Hybrid("HYB1")
# 180 degree hybrid (rat-race, magic-T)
HYB2 = Hybrid("HYB2", phase=180.0)
# Low-loss 90 degree hybrid
HYB3 = Hybrid("HYB3", insertion_loss=0.2, isolation=30.0)CircuitSim.IdealTransformer — Type
IdealTransformer <: AbstractComponentIdeal transformer with specified turns ratio.
Fields
name::String: Component identifiern1::Int: Primary winding positive noden2::Int: Primary winding negative noden3::Int: Secondary winding positive noden4::Int: Secondary winding negative nodet::Float64: Turns ratio N2/N1 (default: 1.0)
Pins
:n1,:n2: Primary winding:n3,:n4: Secondary winding
Example
julia> trafo = IdealTransformer("TR1", t=2.0)
IdealTransformer("TR1", 0, 0, 0, 0, 2.0)CircuitSim.Inductor — Type
Inductor <: AbstractInductorIdeal inductor with two terminals.
Fields
name::String: Component identifiern1::Int: First terminal node number (assigned during circuit analysis)n2::Int: Second terminal node number (assigned during circuit analysis)inductance::Real: Inductance in Henriesinitial_current::Real: Initial current through the inductor in Amperes (for transient analysis)
Example
L1 = Inductor("L1", inductance=10e-6) # 10μH inductor
L2 = Inductor("L2", inductance=1e-3, initial_current=0.1) # 1mH inductor with 100mA initial currentCircuitSim.InductorQ — Type
InductorQ <: AbstractInductorInductor with quality factor for RF simulations.
Fields
name::String: Component identifiern1::Int: First terminal node numbern2::Int: Second terminal node numberinductance::Real: Inductance in Henriesq::Real: Quality factor (Q) at the specified frequencyfreq::Real: Frequency in Hz where Q is specified (default: 1 GHz)mode::String: Q frequency dependency mode - "Linear", "SquareRoot", or "Constant" (default: "Linear")temp::Real: Temperature in Celsius for noise calculations (default: 26.85°C)
Example
using CircuitSim
L1 = InductorQ("L1", inductance=10e-9, q=30.0) # 10nH inductor with Q=30
L2 = InductorQ("L2", inductance=100e-9, q=50.0, freq=2.4e9, mode="SquareRoot") # 100nH, Q=50 at 2.4 GHzCircuitSim.Isolator — Type
Isolator <: AbstractIsolatorRF isolator (unidirectional component).
An isolator allows signals to pass in one direction (forward) while blocking signals in the reverse direction. Commonly used to protect sources from reflections.
Fields
name::String: Component identifiern1::Int: Input terminal node numbern2::Int: Output terminal node numberforward_loss::Real: Insertion loss in forward direction (dB) (default: 0.5)reverse_loss::Real: Isolation in reverse direction (dB) (default: 20)z0::Real: Reference impedance in Ohms (default: 50)
Example
using CircuitSim
# Standard isolator: 0.5 dB forward loss, 20 dB isolation
ISO1 = Isolator("ISO1")
# Custom isolator: 1 dB forward loss, 30 dB isolation
ISO2 = Isolator("ISO2", forward_loss=1.0, reverse_loss=30.0)CircuitSim.MicrostripCorner — Type
MicrostripCorner <: AbstractMicrostripCornerA 90° microstrip corner/bend.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (output)substrate::Substrate: Substrate definition referencew::Real: Line width (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
corner = MicrostripCorner("MC1", sub, w=3.0e-3)Qucs Format
MCORN:Name Node1 Node2 Subst="SubstName" W="width"
CircuitSim.MicrostripCoupled — Type
MicrostripCoupled <: AbstractMicrostripCoupledA pair of microstrip coupled transmission lines (4-port).
Fields
name::String: Component identifiern1::Int: Node 1 (line 1 input)n2::Int: Node 2 (line 1 output)n3::Int: Node 3 (line 2 input)n4::Int: Node 4 (line 2 output)substrate::Substrate: Substrate definition referencew::Real: Line width (m)l::Real: Line length (m)s::Real: Line spacing (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
coupled = MicrostripCoupled("MCPL1", sub, w=1.0e-3, l=20e-3, s=0.2e-3)Qucs Format
MCOUPLED:Name Node1 Node2 Node3 Node4 Subst="SubstName" W="width" L="length" S="spacing"
CircuitSim.MicrostripCross — Type
MicrostripCross <: AbstractMicrostripCrossA microstrip cross-junction (4-port).
Fields
name::String: Component identifiern1::Int: Node 1 (port 1)n2::Int: Node 2 (port 2)n3::Int: Node 3 (port 3)n4::Int: Node 4 (port 4)substrate::Substrate: Substrate definition referencew1::Real: Port 1 width (m)w2::Real: Port 2 width (m)w3::Real: Port 3 width (m)w4::Real: Port 4 width (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
cross = MicrostripCross("MX1", sub, w1=3.0e-3, w2=3.0e-3, w3=3.0e-3, w4=3.0e-3)Qucs Format
MCROSS:Name Node1 Node2 Node3 Node4 Subst="SubstName" W1="w1" W2="w2" W3="w3" W4="w4"
CircuitSim.MicrostripGap — Type
MicrostripGap <: AbstractMicrostripGapA microstrip series gap discontinuity providing capacitive coupling.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (output)substrate::Substrate: Substrate definition referencew1::Real: Width at port 1 (m)w2::Real: Width at port 2 (m)s::Real: Gap spacing (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
gap = MicrostripGap("MG1", sub, w1=3.0e-3, w2=3.0e-3, s=0.2e-3)Qucs Format
MGAP:Name Node1 Node2 Subst="SubstName" W1="width1" W2="width2" S="spacing"
CircuitSim.MicrostripLange — Type
MicrostripLange <: AbstractMicrostripLangeA Lange coupler - an interdigitated microstrip directional coupler providing tight coupling.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (through)n3::Int: Node 3 (coupled)n4::Int: Node 4 (isolated)substrate::Substrate: Substrate definition referencew::Real: Finger width (m)l::Real: Finger length (m)s::Real: Finger spacing (m)n::Int: Number of fingers
Example
sub = Substrate("RO4003C", er=3.55, h=0.508e-3)
lange = MicrostripLange("LC1", sub, w=0.15e-3, l=10e-3, s=0.1e-3, n=4)Qucs Format
MLANGE:Name Node1 Node2 Node3 Node4 Subst="SubstName" W="width" L="length" S="spacing" N="fingers"
CircuitSim.MicrostripLine — Type
MicrostripLine <: AbstractMicrostripLineA microstrip transmission line segment.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (output)substrate::Substrate: Substrate definition referencew::Real: Line width (m)l::Real: Line length (m)model::String: Optional SPICE model nametemp::Real: Temperature (K)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
line = MicrostripLine("MS1", sub, w=3.0e-3, l=20e-3)Qucs Format
MLIN:Name Node1 Node2 Subst="SubstName" W="width" L="length" Temp="temp"
CircuitSim.MicrostripMiteredBend — Type
MicrostripMiteredBend <: AbstractMicrostripMiteredBendA mitered microstrip 90° bend with corner cut for improved performance.
Fields
name::String: Component identifiern1::Int: Node 1 (input)n2::Int: Node 2 (output)substrate::Substrate: Substrate definition referencew::Real: Line width (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
bend = MicrostripMiteredBend("MB1", sub, w=3.0e-3)Qucs Format
MBEND:Name Node1 Node2 Subst="SubstName" W="width"
CircuitSim.MicrostripOpen — Type
MicrostripOpen <: AbstractMicrostripOpenA microstrip open-circuit termination with end-effect modeling.
Fields
name::String: Component identifiern1::Int: Node 1 (input)substrate::Substrate: Substrate definition referencew::Real: Line width (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
open_end = MicrostripOpen("MO1", sub, w=3.0e-3)Qucs Format
MOPEN:Name Node1 Subst="SubstName" W="width"
CircuitSim.MicrostripRadialStub — Type
MicrostripRadialStub <: AbstractMicrostripRadialStubA microstrip radial (butterfly) stub for wideband matching.
Fields
name::String: Component identifiern1::Int: Node (connection point)substrate::Substrate: Substrate definition referenceri::Real: Inner radius (m)ro::Real: Outer radius (m)wf::Real: Feedline width (m)alpha::Real: Stub angle (degrees)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
stub = MicrostripRadialStub("RS1", sub, ri=0.5e-3, ro=5.0e-3, wf=1.0e-3, alpha=60.0)Qucs Format
MRSTUB:Name Node1 Subst="SubstName" ri="inner" ro="outer" Wf="width" alpha="angle" EffDimens="OldQucsNoCorrection" Model="OldQucsModel"
CircuitSim.MicrostripStep — Type
MicrostripStep <: AbstractMicrostripStepA microstrip width step/discontinuity.
Fields
name::String: Component identifiern1::Int: Node 1 (input, wider/narrower side)n2::Int: Node 2 (output, other side)substrate::Substrate: Substrate definition referencew1::Real: Width at port 1 (m)w2::Real: Width at port 2 (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
step = MicrostripStep("MSTEP1", sub, w1=3.0e-3, w2=1.5e-3)Qucs Format
MSTEP:Name Node1 Node2 Subst="SubstName" W1="width1" W2="width2"
CircuitSim.MicrostripTee — Type
MicrostripTee <: AbstractMicrostripTeeA microstrip T-junction (3-port).
Fields
name::String: Component identifiern1::Int: Node 1 (main line input)n2::Int: Node 2 (main line output)n3::Int: Node 3 (branch)substrate::Substrate: Substrate definition referencew1::Real: Main line width (m)w2::Real: Branch width (m)
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
tee = MicrostripTee("MTEE1", sub, w1=3.0e-3, w2=1.5e-3)Qucs Format
MTEE:Name Node1 Node2 Node3 Subst="SubstName" W1="width1" W2="width2" W3="width3"
CircuitSim.MicrostripVia — Type
MicrostripVia <: AbstractMicrostripViaA microstrip via hole connecting to ground plane.
Fields
name::String: Component identifiern1::Int: Node (top connection)substrate::Substrate: Substrate definition referenced::Real: Via hole diameter (m)t::Real: Metal thickness (m), uses substrate if 0
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
via = MicrostripVia("VIA1", sub, d=0.3e-3)Qucs Format
MVIA:Name Node1 gnd Subst="SubstName" D="diameter"
CircuitSim.MultiAnalysisResult — Type
MultiAnalysisResultResults from multiple analyses run simultaneously.
Contains the raw QucsatorDataset plus typed results for each analysis type found.
Fields
dataset::QucsatorDataset: Raw parsed dataset with all vectorsdc::Union{Nothing,DCResult}: DC analysis results (if DC analysis was run)ac::Union{Nothing,ACResult}: AC analysis results (if AC analysis was run)transient::Union{Nothing,TransientResult}: Transient analysis results (if transient analysis was run)sparameter::Union{Nothing,SParameterResult}: S-parameter results (if S-parameter analysis was run)
Example
# Run DC + S-parameter analysis together
results = simulate_qucsator(circ, [DCAnalysis(), SParameterAnalysis(1e9, 10e9, 101)])
# Access DC results
if !isnothing(results.dc)
v_node = results.dc.voltages["_net1"]
end
# Access S-parameter results
if !isnothing(results.sparameter)
s21 = results.sparameter.s_matrix[(2,1)]
endCircuitSim.MultiAnalysisResult — Method
MultiAnalysisResult(dataset::QucsatorDataset, analyses::Vector{<:AbstractAnalysis})Create a MultiAnalysisResult by extracting typed results for each analysis type.
Arguments
dataset::QucsatorDataset: Parsed simulation outputanalyses::Vector{<:AbstractAnalysis}: List of analyses that were run
Returns
MultiAnalysisResultwith typed results for each analysis found
CircuitSim.MutualInductor — Type
MutualInductor <: AbstractComponentTwo coupled inductors with mutual inductance.
Fields
name::String: Component identifiern1::Int: First inductor node 1n2::Int: First inductor node 2n3::Int: Second inductor node 1n4::Int: Second inductor node 2l1::Float64: Inductance of first coil in Hl2::Float64: Inductance of second coil in Hk::Float64: Coupling coefficient (0 to 1, default: 0.9)
Pins
:n1,:n2: First inductor:n3,:n4: Second inductor
Example
julia> mut = MutualInductor("MUT1", l1=1e-6, l2=1e-6, k=0.95)
MutualInductor("MUT1", 0, 0, 0, 0, 1.0e-6, 1.0e-6, 0.95)CircuitSim.NoiseAnalysis — Type
NoiseAnalysis(; start, stop, points, output_node, source, sweep_type="log", name="Noise1")Noise analysis over a frequency range.
Computes noise contributions from all noise sources in the circuit.
Parameters
start::Real: Start frequency in Hz (required)stop::Real: Stop frequency in Hz (required)points::Int: Number of frequency points (required)output_node::String: Output node name for noise measurement (required)source::String: Input source name for noise reference (required)sweep_type::String: "lin"/"linear" or "log"/"logarithmic" (default: "log")name::String: Analysis name (default: "Noise1")
Example
# Noise analysis from 10Hz to 100kHz
analysis = NoiseAnalysis(start=10.0, stop=100e3, points=101, output_node="_net1", source="V1")
# Linear frequency sweep for noise
analysis = NoiseAnalysis(start=1e3, stop=10e3, points=100, output_node="_net2", source="V_in", sweep_type="lin")CircuitSim.OpAmp — Type
OpAmp <: AbstractComponentOperational amplifier with ideal characteristics.
Fields
name::String: Component identifierninp::Int: Non-inverting input nodeninn::Int: Inverting input nodenout::Int: Output nodeg::Float64: Open-loop voltage gain (default: 1e6)umax::Float64: Maximum output voltage (default: 15.0 V)
Pins
:ninp: Non-inverting input (+):ninn: Inverting input (-):nout: Output
Example
julia> opamp = OpAmp("OP1", g=1e5, umax=12.0)
OpAmp("OP1", 0, 0, 0, 100000.0, 12.0)CircuitSim.Open — Type
Open <: AbstractOpenCircuitOpen circuit (infinite resistance between two nodes).
Fields
name::String: Component identifiern1::Int: First terminal noden2::Int: Second terminal node
Pins
:n1,:n2: Two-terminal open circuit
Example
julia> open_ckt = Open("Open1")
Open("Open1", 0, 0)CircuitSim.ParameterSweep — Type
ParameterSweep(; param, start, stop, points, inner_analysis, sweep_type="lin", name="SW1")Parameter sweep analysis.
Sweeps a component parameter and runs an inner analysis at each point.
Parameters
param::String: Parameter name to sweep (e.g., "R1.R" for resistor R1's resistance) (required)start::Real: Start value (required)stop::Real: Stop value (required)points::Int: Number of sweep points (required)inner_analysis::AbstractAnalysis: Analysis to run at each sweep point (required)sweep_type::String: "lin"/"linear" or "log"/"logarithmic" (default: "lin")name::String: Analysis name (default: "SW1")
Example
# Sweep R1 from 1kΩ to 10kΩ and run DC analysis at each point
dc = DCAnalysis()
sweep = ParameterSweep(param="R1.R", start=1e3, stop=10e3, points=10, inner_analysis=dc)
result = simulate_qucsator(circuit, sweep)
# Logarithmic parameter sweep with AC inner analysis
ac = ACAnalysis(start=1.0, stop=1e6, points=101)
sweep = ParameterSweep(param="C1.C", start=1e-12, stop=1e-9, points=20, inner_analysis=ac, sweep_type="log")CircuitSim.PhaseShifter — Type
PhaseShifter <: AbstractPhaseShifterRF phase shifter.
A phase shifter introduces a specified phase shift to the signal while maintaining amplitude (ideally).
Fields
name::String: Component identifiern1::Int: Input terminal node numbern2::Int: Output terminal node numberphase::Real: Phase shift in degreesz0::Real: Reference impedance in Ohms (default: 50)insertion_loss::Real: Insertion loss in dB (default: 0 for ideal)
Example
using CircuitSim
# 90 degree phase shifter
PS1 = PhaseShifter("PS1", 90.0)
# 180 degree phase shifter with 0.5 dB loss
PS2 = PhaseShifter("PS2", 180.0, insertion_loss=0.5)CircuitSim.Pin — Type
Pin representation: (component, fieldname)
CircuitSim.PowerProbe — Type
Power probe for measuring power flow in circuits.
The probe measures power between two differential ports (4 terminals total).
CircuitSim.QucsatorDataset — Type
QucsatorDatasetParsed simulation result containing all vectors and metadata.
Fields
status::SimulationStatus: Status of the simulationversion::String: Qucs dataset versionindependent_vars::Dict{String,DataVector}: Independent variables (e.g., frequency, time)dependent_vars::Dict{String,DataVector}: Dependent variables (e.g., voltages, currents)errors::Vector{String}: Error messageswarnings::Vector{String}: Warning messagesraw_output::String: Raw simulator output
Typed Result Extraction
Use extract_dc_result(), extract_ac_result(), extract_transient_result(), or extract_sparameter_result() to get typed data structures.
CircuitSim.Resistor — Type
Resistor <: AbstractResistorIdeal resistor with two terminals.
Fields
name::String: Component identifiern1::Int: First terminal node number (assigned during circuit analysis)n2::Int: Second terminal node number (assigned during circuit analysis)resistance::Real: Resistance in Ohmstemp::Real: Operating temperature in Kelvin (default: 26.85)tc1::Real: First order temperature coefficient (default: 0.0)tc2::Real: Second order temperature coefficient (default: 0.0)tnom::Real: Nominal temperature in Kelvin (default: 26.85)
Example
R1 = Resistor("R1", resistance=1000.0) # 1kΩ resistor
R2 = Resistor("R2", resistance=2200.0, temp=85.0, tc1=0.001, tc2=0.0, tnom=25.0) # 2.2kΩ resistor with temperature coefficientsCircuitSim.SParameterAnalysis — Type
SParameterAnalysis(; start, stop, points, sweep_type=LOGARITHMIC, name="SP1", z0=50.0, noise=false)
SParameterAnalysis(; values, sweep_type=LIST, name="SP1", z0=50.0, noise=false)S-parameter frequency sweep analysis.
Computes S-parameters over a frequency range. Optionally compute noise parameters.
Parameters
For LINEAR or LOGARITHMIC sweeps:
start::Real: Start frequency in Hzstop::Real: Stop frequency in Hzpoints::Int: Number of frequency pointssweep_type::String: "lin"/"linear" or "log"/"logarithmic" (default: "log")
For LIST sweeps:
values::Vector{<:Real}: List of frequency points in Hzsweep_type::String: Must be "list"
For CONSTANT sweeps:
values::Real: Single frequency value in Hzsweep_type::String: Must be "const" or "constant"
Common parameters:
name::String: Analysis name (default: "SP1")z0::Real: Reference impedance in Ohms (default: 50.0)noise::Bool: Enable noise parameter calculation (default: false)noise_input_port::Int: Input port for noise parameters (default: 1)noise_output_port::Int: Output port for noise parameters (default: 2)
Example
# S-parameter analysis from 1MHz to 1GHz
analysis = SParameterAnalysis(start=1e6, stop=1e9, points=201)
# With 75Ω reference impedance
analysis = SParameterAnalysis(start=1e6, stop=1e9, points=201, z0=75.0)
# With noise parameters (F, Fmin, Sopt, Rn)
analysis = SParameterAnalysis(start=1e6, stop=1e9, points=201, noise=true)
# List of specific frequencies
analysis = SParameterAnalysis(values=[1e6, 10e6, 100e6, 1e9], sweep_type="list")CircuitSim.SParameterResult — Type
SParameterResultS-parameter analysis results.
Fields
frequencies_Hz::Vector{Float64}: Frequency pointsnum_ports::Int: Number of portss_matrix::Dict{Tuple{Int,Int},Vector{ComplexF64}}: S[i,j] vs frequencyz0_Ohm::Float64: Reference impedanceF::Union{Nothing,Vector{Float64}}: Noise figure (linear, not dB) vs frequency (if noise analysis enabled)Fmin::Union{Nothing,Vector{Float64}}: Minimum noise figure (linear) vs frequency (if noise analysis enabled)Sopt::Union{Nothing,Vector{ComplexF64}}: Optimal source reflection coefficient vs frequency (if noise analysis enabled)Rn_Ohm::Union{Nothing,Vector{Float64}}: Equivalent noise resistance in Ohms vs frequency (if noise analysis enabled)
CircuitSim.SPfile — Type
SPfile <: AbstractSParameterFileS-parameter file (Touchstone format) component.
Loads S-parameters from a Touchstone file and uses them as a black-box frequency-domain model. The number of ports is automatically detected from the file extension.
Port Structure
For an N-port S-parameter file, the component has N+1 nodes:
n1,n2, ...,nN: Port terminal nodesref: Ground reference node (always the last node)
Fields
name::String: Component identifiernodes::Vector{Int}: Port terminal nodes (N+1 total: N ports + ground)file::String: Path to Touchstone filenum_ports::Int: Number of portsdata_format::String: Data format ("rectangular" or "polar")interpolator::String: Interpolation method ("linear" or "cubic")temp::Real: Temperature in Kelvin (default 293.15K = 20°C)during_dc::String: DC behavior ("open", "short", or "unspecified")
Example
# Load a 1-port S-parameter file (antenna)
antenna = SPfile("ANT1", "antenna.s1p")
@connect circ source.nplus antenna.n1
@connect circ antenna.ref ground
# Load a 2-port S-parameter file (amplifier)
amp = SPfile("AMP1", "amplifier.s2p")
@connect circ input.nplus amp.n1
@connect circ output.nplus amp.n2
@connect circ amp.ref ground
# Manually specify port count if filename doesn't follow .sNp convention
custom = SPfile("DEV", "data.txt", num_ports=3)
# Custom options
filter_sp = SPfile("FILT1", "filter.s2p",
data_format="polar",
interpolator="cubic",
temp=298.15)Notes
- File path can be absolute or relative to netlist location
- Supports Touchstone v1.0, v1.1, v2.0 formats
- Number of ports detected from .sNp filename (e.g., .s1p = 1-port, .s2p = 2-port)
- Can be overridden with
num_portsparameter - Always connect the
refnode to circuit ground
CircuitSim.SimulationStatus — Type
SimulationStatusResult status from a simulation run.
Values:
SIM_SUCCESS: Simulation completed successfullySIM_ERROR: Simulation encountered an errorSIM_PARSE_ERROR: Output parsing failedSIM_NOT_RUN: Simulation has not been run
CircuitSim.SpiralInductor — Type
SpiralInductor <: AbstractSpiralInductorA planar spiral inductor on a substrate.
Fields
name::String: Component identifiern1::Int: Node 1 (outer terminal)n2::Int: Node 2 (inner terminal)substrate::Substrate: Substrate definition referencegeometry::String: Inductor geometry ("Circular", "Square", "Hexagonal", "Octogonal")w::Real: Track width (m)s::Real: Track spacing (m)di::Real: Inner diameter (m)turns::Real: Number of turns
Example
sub = Substrate("FR4", er=4.5, h=1.6e-3)
spiral = SpiralInductor("L1", sub, geometry="Circular", w=0.2e-3, s=0.15e-3, di=1e-3, turns=5.5)CircuitSim.Substrate — Type
SubstrateDefines the substrate properties for microstrip and planar components.
Fields
name::String: Substrate identifierer::Real: Relative permittivity (dielectric constant)h::Real: Substrate height/thickness in meterst::Real: Metal thickness in meterstand::Real: Loss tangent (tan δ)rho::Real: Metal resistivity in Ω·m (Copper ≈ 0.022e-6)rough::Real: Surface roughness in meters
Example
# Standard FR4 substrate
fr4 = Substrate("FR4", er=4.5, h=1.6e-3, t=35e-6, tand=0.02)
# Rogers RO4003C
ro4003c = Substrate("RO4003C", er=3.55, h=0.508e-3, t=17e-6, tand=0.0027)
# Low-loss Rogers RT/duroid
duroid = Substrate("Duroid", er=2.2, h=0.787e-3, t=35e-6, tand=0.0009)CircuitSim.TransientAnalysis — Type
TransientAnalysis(; stop, start=0.0, points=nothing, step=nothing, name="TR1", integration_method="trapezoidal", order=2, initial_dc=true, reltol=1e-3, vabstol=1e-6, iabstol=1e-12, maxstep=nothing, minstep=nothing, max_iterations=150)Time-domain transient analysis.
Simulates the circuit behavior over time.
Parameters
stop::Real: Stop time in seconds (required)start::Real: Start time in seconds (default: 0.0)points::Int: Number of time points (specify either points or step)step::Real: Time step in seconds (specify either points or step)name::String: Analysis name (default: "TR1")integration_method::String: Integration method (default: "trapezoidal")- "euler" - Backward Euler (order 1)
- "trapezoidal" - Trapezoidal/Bilinear (order 2)
- "gear" - Gear (order 1-6)
- "adamsmoulton" - Adams-Moulton (order 1-6)
order::Int: Integration order for Gear and Adams-Moulton (default: 2, range: 1-6)initial_dc::Bool: Compute initial DC operating point (default: true)reltol::Real: Relative tolerance for error control (default: 1e-3)vabstol::Real: Voltage absolute tolerance in V (default: 1e-6)iabstol::Real: Current absolute tolerance in A (default: 1e-12)maxstep::Union{Real,Nothing}: Maximum time step in seconds (default: nothing, auto-calculated)minstep::Union{Real,Nothing}: Minimum time step in seconds (default: nothing, auto-calculated)max_iterations::Int: Maximum Newton-Raphson iterations (default: 150)
Example
# Simulate for 1ms with 1001 points using trapezoidal
analysis = TransientAnalysis(stop=1e-3, points=1001)
# Simulate for 10μs with 10ns step using Gear order 4
analysis = TransientAnalysis(stop=10e-6, step=10e-9, integration_method="gear", order=4)
# Using backward Euler with custom tolerances
analysis = TransientAnalysis(stop=1e-3, points=501, integration_method="euler", reltol=1e-4, vabstol=1e-7)
# With explicit time step control
analysis = TransientAnalysis(stop=1e-3, points=1001, maxstep=1e-6, minstep=1e-12)CircuitSim.TransientResult — Type
TransientResultTransient analysis results (time domain).
Fields
time_s::Vector{Float64}: Time pointsvoltages::Dict{String,Vector{Float64}}: Node voltages vs timecurrents::Dict{String,Vector{Float64}}: Branch currents vs time
CircuitSim.TransmissionLine — Type
TransmissionLine <: AbstractComponentSimple lossless transmission line.
Fields
name::String: Component identifierz0::Float64: Characteristic impedance in Ω (default: 50.0)length_m::Float64: Physical length in metersalpha::Float64: Attenuation constant in 1/m (default: 0.0)n1::Int: Input port positive noden2::Int: Input port negative noden3::Int: Output port positive noden4::Int: Output port negative node
Pins
:n1,:n2: Input port:n3,:n4: Output port
Example
julia> tline = TransmissionLine("TL1", z0=75.0, length_m=0.1)
TransmissionLine("TL1", 0, 0, 0, 0, 75.0, 0.1, 0.0)CircuitSim.VoltageAMSource — Type
VoltageAMSource(name::String; u::Real=1.0, f::Real=1e9, m::Real=1.0, phase::Real=0.0)Create an amplitude modulated voltage source with 3-port configuration.
Arguments
name::String: Component identifieru::Real: Carrier amplitude in Volts (default 1.0)f::Real: Carrier frequency in Hz (default 1e9)m::Real: Modulation index 0 to 1 (default 1.0)phase::Real: Phase in degrees -360 to 360 (default 0.0)
Fields
nplus::Int: Positive output nodenminus::Int: Negative output nodenmod::Int: Modulation input node
CircuitSim.VoltageControlledCurrentSource — Type
VoltageControlledCurrentSource(name::String; g::Real=1.0, t::Real=0.0)Create a voltage-controlled current source with 4-port configuration.
Arguments
name::String: Component identifierg::Real: Transconductance in Siemens (A/V) (default 1.0)t::Real: Time delay in seconds (default 0.0)
Fields
n1::Int: Positive input control noden2::Int: Negative input control noden3::Int: Positive output noden4::Int: Negative output node
CircuitSim.VoltageControlledVoltageSource — Type
VoltageControlledVoltageSource(name::String; g::Real=1.0, t::Real=0.0)Create a voltage-controlled voltage source with 4-port configuration.
Arguments
name::String: Component identifierg::Real: Voltage gain (default 1.0)t::Real: Time delay in seconds (default 0.0)
Fields
n1::Int: Positive input control noden2::Int: Negative input control noden3::Int: Positive output noden4::Int: Negative output node
CircuitSim.VoltageExponentialSource — Type
VoltageExponentialSource <: AbstractVoltageSourceExponential rise/fall voltage source for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberu1::Real: Initial voltage level (V)u2::Real: Final voltage level (V)t1::Real: Rise delay time (s)t2::Real: Fall delay time (s)tr::Real: Rise time constant (s, optional, default 1ns)tf::Real: Fall time constant (s, optional, default 1ns)
Example
vsrc = VoltageExponentialSource("Vexp1", u1=0.0, u2=5.0, t1=1e-9, t2=10e-9)CircuitSim.VoltageNoiseSource — Type
VoltageNoiseSource <: AbstractVoltageSourceVoltage noise source for noise analysis with frequency-dependent PSD.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberu::Real: Noise power spectral density (V²/Hz)a::Real: Frequency offset parameter (optional, default 0)c::Real: Frequency coefficient (optional, default 1)e::Real: Frequency exponent (optional, default 0)
Noise PSD formula: PSD(f) = u / (a + c * f^e)
Example
vsrc = VoltageNoiseSource("Vnoise1", u=1e-6, e=0) # White noiseCircuitSim.VoltagePMSource — Type
VoltagePMSource(name::String; u::Real=1.0, f::Real=1e9, m::Real=1.0, phase::Real=0.0)Create a phase modulated voltage source with 3-port configuration.
Arguments
name::String: Component identifieru::Real: Carrier amplitude in Volts (default 1.0)f::Real: Carrier frequency in Hz (default 1e9)m::Real: Modulation index 0 to 1 (default 1.0)phase::Real: Base phase in degrees -360 to 360 (default 0.0)
Fields
nplus::Int: Positive output nodenminus::Int: Negative output nodenmod::Int: Modulation input node
CircuitSim.VoltageProbe — Type
Voltage probe for measuring voltages in AC, DC, and transient analyses.
The probe connects between two nodes and measures the voltage difference. It has infinite input impedance (does not affect the circuit).
CircuitSim.VoltagePulseSource — Type
VoltagePulseSource <: AbstractVoltageSourceVoltage source with pulse waveform for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberu1::Real: Initial voltage level (V)u2::Real: Pulsed voltage level (V)t1::Real: Start time of pulse (s)t2::Real: End time of pulse (s)tr::Real: Rise time (s, optional, default 1ns)tf::Real: Fall time (s, optional, default 1ns)
Example
vsrc = VoltagePulseSource("Vpulse1", u1=0.0, u2=5.0, t1=1e-9, t2=10e-9, tr=1e-10, tf=1e-10)CircuitSim.VoltageRectangularSource — Type
VoltageRectangularSource <: AbstractVoltageSourcePeriodic rectangular pulse voltage source for transient analysis.
Fields
name::String: Component identifiern1::Int: Positive terminal node numbern2::Int: Negative terminal node numberu::Real: Pulse voltage level (V)th::Real: High time duration (s)tl::Real: Low time duration (s)tr::Real: Rise time (s, optional, default 1ns)tf::Real: Fall time (s, optional, default 1ns)td::Real: Delay time (s, optional, default 0)
Example
vsrc = VoltageRectangularSource("Vrect1", u=5.0, th=1e-6, tl=1e-6)Qucs Format
Vrect:Name Node+ Node- U="u" TH="th" TL="tl" Tr="tr" Tf="tf" Td="td"
CircuitSim.VoltageVoltageNoiseSource — Type
VoltageVoltageNoiseSource(name::String; v1::Real=1e-6, v2::Real=1e-6, c_corr::Real=0.0, a::Real=0.0, c::Real=1.0, e::Real=0.0)Create correlated voltage-voltage noise sources with 4-port configuration.
Arguments
name::String: Component identifierv1::Real: RMS voltage of first source in V (default 1e-6)v2::Real: RMS voltage of second source in V (default 1e-6)c_corr::Real: Correlation coefficient -1 to 1 (default 0.0)a::Real: Flicker noise exponent (default 0.0)c::Real: Flicker noise coefficient (default 1.0)e::Real: Flicker noise frequency exponent (default 0.0)
Fields
v1plus::Int: Positive node of first voltage sourcev1minus::Int: Negative node of first voltage sourcev2plus::Int: Positive node of second voltage sourcev2minus::Int: Negative node of second voltage source
CircuitSim.add_component! — Method
Add a component to the circuit (if not already added)
CircuitSim.assign_nodes! — Method
Walk all components, examine their integer fields (node fields), and assign canonical node numbers (small consecutive integers). Ground is node 0. After calling assign_nodes!, the components' node fields are filled with integers suitable for netlisting.
Node fields are identified by name pattern: n, n1, n2, nplus, nminus, etc. Other Int fields (like port numbers) are left unchanged.
CircuitSim.check_ngspice — Method
check_ngspice() -> (Bool, String, String)Check if ngspice is installed and available in PATH.
Returns
is_installed::Bool: Whether ngspice is availableversion::String: Version string if availablepath::String: Path to the executable
CircuitSim.check_qucsator — Method
check_qucsator() -> (Bool, String, String)Check if qucsator_rf is installed and available in PATH.
Returns
is_installed::Bool: Whether qucsator_rf is availableversion::String: Version string if availablepath::String: Path to the executable
CircuitSim.connect! — Method
A convenience overload that accepts component + symbol pairs:
CircuitSim.connect! — Method
Connect two pins in the circuit. The components will be added if not present.
CircuitSim.detect_format — Method
detect_format(filepath::String) -> SymbolDetect file format by examining file content.
CircuitSim.detect_touchstone_ports — Method
detect_touchstone_ports(filepath::String) -> IntDetect the number of ports from Touchstone file extension using regex.
Matches filenames ending in .sNp where N is 1 or more digits (e.g., .s1p, .s2p, .s12p).
Throws an error if pattern doesn't match.
Examples
julia> detect_touchstone_ports("antenna.s1p")
1
julia> detect_touchstone_ports("amplifier.s2p")
2
julia> detect_touchstone_ports("complex_device.txt")
ERROR: ArgumentError: Could not detect number of ports from filename 'complex_device.txt'. Expected Touchstone format: .sNp (e.g., .s1p, .s2p). Provide num_ports parameter as override.CircuitSim.extract_ac_result — Method
extract_ac_result(dataset::QucsatorDataset) -> ACResultExtract AC analysis results from dataset.
Returns
ACResultwith frequency sweep data
Example
ac_data = extract_ac_result(dataset)
freqs = ac_data.frequencies_Hz
v_out = ac_data.voltages["_net1"] # ComplexF64 vector vs frequencyCircuitSim.extract_dc_result — Method
extract_dc_result(dataset::QucsatorDataset) -> DCResultExtract DC operating point results from dataset.
Returns
DCResultwith voltages and currents dictionaries
Example
dc_data = extract_dc_result(dataset)
v_out = dc_data.voltages["_net1"]
i_supply = dc_data.currents["V1"]CircuitSim.extract_sparameter_result — Method
extract_sparameter_result(dataset::QucsatorDataset; z0::Real=50.0) -> SParameterResultExtract S-parameter analysis results from dataset.
Arguments
dataset::QucsatorDataset: Parsed simulation outputz0::Real=50.0: Reference impedance in Ohms
Returns
SParameterResultwith S-parameter matrix data and noise parameters (if noise analysis was enabled)
Example
sp_data = extract_sparameter_result(dataset)
freqs = sp_data.frequencies_Hz
s21 = sp_data.s_matrix[(2,1)] # Forward transmission vs frequency
# Noise parameters (if available)
if !isnothing(sp_data.F)
nf_db = 10 * log10.(sp_data.F) # Convert to dB
fmin_db = 10 * log10.(sp_data.Fmin) # Minimum NF in dB
gamma_opt = sp_data.Sopt # Optimal source reflection coefficient
rn = sp_data.Rn_Ohm # Equivalent noise resistance
endCircuitSim.extract_transient_result — Method
extract_transient_result(dataset::QucsatorDataset) -> TransientResultExtract transient analysis results from dataset.
Returns
TransientResultwith time domain data
Example
tran_data = extract_transient_result(dataset)
times = tran_data.time_s
v_out = tran_data.voltages["_net1"] # Float64 vector vs timeCircuitSim.format_capacitance — Method
Format capacitance values for circuit netlists
CircuitSim.format_inductance — Method
Format inductance values for circuit netlists
CircuitSim.format_value — Method
Simple formatting helper for numeric values
CircuitSim.get_complex_vector — Method
get_complex_vector(dataset::QucsatorDataset, name::String) -> Vector{ComplexF64}Get the complex values of a named vector from the dataset.
CircuitSim.get_component_current — Method
get_component_current(result, component_name::String)Get current through a component from simulation results.
Note: Current direction follows passive sign convention - positive current flows from the first pin (e.g., nplus, n1) to the second pin (e.g., nminus, n2) internally.
Arguments
result: DCResult, ACResult, or TransientResultcomponent_name::String: Component name (e.g., "V1", "R1")
Returns
- For DC: Float64 current
- For AC: Vector{ComplexF64} current vs frequency
- For Transient: Vector{Float64} current vs time
Example
dc = simulate_qucsator(circ, DCAnalysis())
i_source = get_component_current(dc, "V1")CircuitSim.get_component_power — Method
get_component_power(result::DCResult, component, pin_pos::Symbol, pin_neg::Symbol)Calculate power dissipated in a component for DC analysis (P = V × I).
Arguments
result::DCResult: DC analysis resultcomponent: Component instancepin_pos::Symbol: Positive pin namepin_neg::Symbol: Negative pin name
Returns
- Float64: Power in watts (positive = dissipated, negative = generated)
Example
R1 = Resistor("R1", 100.0)
# ... build and simulate circuit ...
dc = simulate_qucsator(circ, DCAnalysis())
power = get_component_power(dc, R1, :n1, :n2)CircuitSim.get_frequency — Method
get_frequency(dataset::QucsatorDataset) -> Vector{Float64}Get the frequency vector for S-parameter, AC, or other frequency-domain analyses. Looks for 'frequency', 'acfrequency', or 'hbfrequency' (for HB analysis, returns unique frequencies).
Returns
- Vector of frequency values in Hz
Throws
- ErrorException if no frequency vector found
CircuitSim.get_imag_vector — Method
get_imag_vector(dataset::QucsatorDataset, name::String) -> Vector{Float64}Extract imaginary parts of a named vector from the dataset.
CircuitSim.get_node_voltage — Method
get_node_voltage(dataset::QucsatorDataset, node_name::String) -> Vector{ComplexF64}Get voltage at a named node.
Arguments
dataset::QucsatorDataset: The simulation resultsnode_name::String: Node name (e.g., "net1", "vout")
Returns
- Vector of complex voltage values
Example
v_out = get_node_voltage(result, "net5")CircuitSim.get_node_voltage — Method
get_node_voltage(result, node_name::String)Get voltage at a specific node from simulation results.
Arguments
result: DCResult, ACResult, or TransientResultnode_name::String: Node name (e.g., "net1", "net2")
Returns
- For DC: Float64 voltage
- For AC: Vector{ComplexF64} voltage vs frequency
- For Transient: Vector{Float64} voltage vs time
Example
dc = simulate_qucsator(circ, DCAnalysis())
v_out = get_node_voltage(dc, "_net1")CircuitSim.get_pin_current — Method
get_pin_current(result, component, pin::Symbol)Get current flowing INTO a specific pin of a component from the external circuit.
Current direction convention:
- Positive current = current flowing INTO the pin (from external circuit)
- Negative current = current flowing OUT of the pin (to external circuit)
For a voltage source delivering power:
- Current OUT of nplus (to circuit) → getpincurrent returns NEGATIVE
- Current INTO nminus (from circuit) → getpincurrent returns POSITIVE
This follows standard node current convention where currents entering a node are positive.
Arguments
result: DCResult, ACResult, or TransientResultcomponent: Component instance (must be a voltage or current source)pin::Symbol: Pin name (e.g., :nplus, :nminus, :n1, :n2)
Returns
- For DC: Float64 current (in amperes)
- For AC: Vector{ComplexF64} current vs frequency
- For Transient: Vector{Float64} current vs time
Example
V = DCVoltageSource("V1", 10.0)
R = Resistor("R", 100.0)
# ... build circuit: V.nplus -> R -> GND, V.nminus -> GND ...
dc = simulate_qucsator(circ, DCAnalysis())
# For a source delivering 100mA:
i_nplus = get_pin_current(dc, V, :nplus) # -100mA (current OUT of source)
i_nminus = get_pin_current(dc, V, :nminus) # +100mA (current INTO source)
# Kirchhoff's current law: i_nplus + i_nminus = 0Note
Only voltage and current sources report currents in qucsator. For other components, current can be calculated using Ohm's law with voltage and component parameters.
CircuitSim.get_pin_voltage — Method
get_pin_voltage(result, component, pin::Symbol)Get voltage at a specific pin of a component.
Arguments
result: DCResult, ACResult, or TransientResultcomponent: Component instance (e.g., R1, C1)pin::Symbol: Pin name (e.g., :n1, :n2, :nplus, :nminus)
Returns
- For DC: Float64 voltage
- For AC: Vector{ComplexF64} voltage
- For Transient: Vector{Float64} voltage vs time
Example
R1 = Resistor("R1", 100.0)
# ... build and simulate circuit ...
dc = simulate_qucsator(circ, DCAnalysis())
v_r1_input = get_pin_voltage(dc, R1, :n1)
v_r1_output = get_pin_voltage(dc, R1, :n2)
v_across_r1 = v_r1_input - v_r1_outputCircuitSim.get_probe_current — Method
get_probe_current(result, probe)Get current measured by a CurrentProbe.
Arguments
result: DCResult, ACResult, or TransientResultprobe: CurrentProbe instance or probe name as String
Returns
- For DC: Float64 current
- For AC: Vector{ComplexF64} current vs frequency
- For Transient: Vector{Float64} current vs time
Example
IP = CurrentProbe("IP1")
# ... build circuit with probe ...
dc = simulate_qucsator(circ, DCAnalysis())
i_measured = get_probe_current(dc, IP)CircuitSim.get_probe_voltage — Method
get_probe_voltage(result, probe)Get voltage measured by a VoltageProbe.
Arguments
result: DCResult, ACResult, or TransientResultprobe: VoltageProbe instance or probe name as String
Returns
- For DC: Float64 voltage
- For AC: Vector{ComplexF64} voltage vs frequency
- For Transient: Vector{Float64} voltage vs time
Example
VP = VoltageProbe("VP1")
# ... build circuit with probe ...
dc = simulate_qucsator(circ, DCAnalysis())
v_measured = get_probe_voltage(dc, VP)CircuitSim.get_real_vector — Method
get_real_vector(dataset::QucsatorDataset, name::String) -> Vector{Float64}Extract real parts of a named vector from the dataset.
CircuitSim.get_s_matrix_size — Method
get_s_matrix_size(dataset::QucsatorDataset) -> IntDetermine the size of the S-parameter matrix (number of ports).
Returns
- Number of ports in the S-parameter matrix
Example
n_ports = get_s_matrix_size(result) # Returns 2 for a 2-port networkCircuitSim.get_sparameter — Method
get_sparameter(dataset::QucsatorDataset, i::Int, j::Int) -> Vector{ComplexF64}Get S-parameter S[i,j] from dataset.
Arguments
dataset::QucsatorDataset: The simulation resultsi::Int: Output port number (1-indexed)j::Int: Input port number (1-indexed)
Returns
- Vector of complex S-parameter values
Example
s21 = get_sparameter(result, 2, 1) # Forward transmission
s11 = get_sparameter(result, 1, 1) # Input reflectionCircuitSim.get_time — Method
get_time(dataset::QucsatorDataset) -> Vector{Float64}Get the time vector for transient analyses.
Returns
- Vector of time values in seconds
Throws
- ErrorException if no time vector found
CircuitSim.get_voltage_across — Method
get_voltage_across(result, component, pin_pos::Symbol, pin_neg::Symbol)Get voltage difference across a component (Vpos - Vneg).
Arguments
result: DCResult, ACResult, or TransientResultcomponent: Component instancepin_pos::Symbol: Positive pin namepin_neg::Symbol: Negative pin name
Returns
- For DC: Float64 voltage difference
- For AC: Vector{ComplexF64} voltage
- For Transient: Vector{Float64} voltage difference vs time
Example
R1 = Resistor("R1", 100.0)
# ... build and simulate circuit ...
dc = simulate_qucsator(circ, DCAnalysis())
v_across_r1 = get_voltage_across(dc, R1, :n1, :n2)CircuitSim.has_errors — Method
has_errors(dataset::QucsatorDataset) -> BoolCheck if the simulation had any errors.
CircuitSim.list_vectors — Method
list_vectors(dataset::QucsatorDataset) -> Vector{String}List all vector names in the dataset.
CircuitSim.load_csv — Method
load_csv(filepath::String) -> FileDataLoad CSV file with two columns: time, value. First row may be header with column names.
CircuitSim.load_file_data — Method
load_file_data(filepath::String; format::Symbol=:auto) -> FileDataLoad time-series data from CSV or Qucs Dataset file.
Arguments
filepath: Path to data fileformat: Format hint (:auto, :csv, :qucs_dataset)
Returns
FileDatastruct with times, samples, and metadata
Supported Formats
CSV Format
Two columns: time, value (comma or semicolon separated) Optional header row with column names
Example:
time,voltage
0.0,0.0
1e-9,1.0
2e-9,0.5Qucs Dataset Format
Native qucsator format with indep/dep blocks
Example:
<Qucs Dataset 1.0.0>
<indep time 4>
0.0
1e-9
2e-9
3e-9
</indep>
<dep V1 4>
0.0
1.0
0.5
0.0
</dep>CircuitSim.load_qucs_dataset — Method
load_qucs_dataset(filepath::String) -> FileDataLoad Qucs Dataset format file.
Format:
<Qucs Dataset VERSION>
<indep TIME_NAME N>
time1
time2
...
</indep>
<dep VAR_NAME N>
value1
value2
...
</dep>CircuitSim.netlist_ngspice — Method
netlist_ngspice(c::Circuit) -> StringGenerate a complete SPICE netlist for ngspice simulator.
CircuitSim.netlist_qucs — Method
netlist_qucs(c::Circuit) -> StringGenerate a complete Qucs netlist for the circuit.
CircuitSim.parse_qucs_dataset — Method
parse_qucs_dataset(output::AbstractString) -> QucsatorDatasetParse the Qucs dataset format output from qucsator_rf. Returns a QucsatorDataset containing all parsed vectors and status information.
CircuitSim.parse_qucs_value — Method
parse_qucs_value(s::AbstractString) -> ComplexF64Parse a single value from Qucs dataset format. Handles real values like +1.234e+00 and complex values like +1.234e+00+j5.678e-01
CircuitSim.pinid — Method
unique pin id used in union-find:
hash( (objectid(comp), field) )CircuitSim.prepare_external_files! — Method
prepare_external_files!(comp::AbstractCircuitComponent, netlist_dir::String)Prepare external files (S-parameters, data files, etc.) for a component before simulation. Default implementation does nothing. Components that need external files should implement this method.
CircuitSim.prepare_external_files! — Method
prepare_external_files!(comp::FileCurrentSource, netlist_dir::String)Create data file for FileCurrentSource in the netlist directory when using vector mode. Called by the backend before running qucsator.
CircuitSim.prepare_external_files! — Method
prepare_external_files!(comp::FileVoltageSource, netlist_dir::String)Create data file for FileVoltageSource in the netlist directory when using vector mode. Called by the backend before running qucsator.
CircuitSim.prepare_external_files! — Method
prepare_external_files!(comp::SPfile, netlist_dir::String)Copy S-parameter file to the netlist directory. Called by the backend before running qucsator.
CircuitSim.print_summary — Method
print_summary(dataset::QucsatorDataset)Print a summary of the dataset contents.
CircuitSim.run_ngspice — Method
run_ngspice(c::Circuit, analysis::AbstractAnalysis; output_file::String="")Run ngspice simulation with the given circuit and analysis.
Arguments
c::Circuit: The circuit to simulateanalysis::AbstractAnalysis: Analysis type (DCAnalysis, ACAnalysis, etc.)output_file::String="": Optional output file path. If empty, uses a temporary file.
Returns
(success::Bool, output::String, netlist::String)
Example
success, output, netlist = run_ngspice(c, DCAnalysis())CircuitSim.run_ngspice — Method
run_ngspice(c::Circuit, analyses::Vector{<:AbstractAnalysis}; output_file::String="")Run ngspice simulation with multiple analysis types.
CircuitSim.run_qucsator — Method
run_qucsator(c::Circuit, analysis::AbstractAnalysis; output_file::String="", suppress_warnings::Bool=false)Run qucsator simulation with the given circuit and analysis.
Arguments
c::Circuit: The circuit to simulateanalysis::AbstractAnalysis: Analysis type (DCAnalysis, ACAnalysis, etc.)output_file::String="": Optional output file path. If empty, uses a temporary file.suppress_warnings::Bool=false: If true, suppress qucsator warnings by redirecting stderr
Returns
(success::Bool, output::String, netlist::String)
Example
success, output, netlist = run_qucsator(c, DCAnalysis())
success, output, netlist = run_qucsator(c, ACAnalysis(1.0, 1e6, 101), suppress_warnings=true)CircuitSim.run_qucsator — Method
run_qucsator(c::Circuit, analyses::Vector{<:AbstractAnalysis}; output_file::String="", suppress_warnings::Bool=false)Run qucsator simulation with multiple analysis types.
CircuitSim.s2z — Function
s2z(S::Matrix, z0=50.0) -> MatrixConvert S-parameter matrix to Z-parameter matrix for a two-port network.
Arguments
S: 2x2 S-parameter matrixz0: Reference impedance (default: 50.0 Ω)
Returns
- 2x2 Z-parameter matrix
Note
This conversion uses the standard formula Z = z0(I+S)(I-S)⁻¹. For certain ideal passive networks (e.g., perfect series elements at DC), the matrix (I-S) becomes singular, making Z-parameters undefined. This is a fundamental limitation of the parameter representation, not a numerical issue.
Examples
julia> using CircuitSim
julia> z_load = 75.0 + 0.0im; # 75 Ω resistive load
julia> z0 = 50.0;
julia> gamma = (z_load - z0) / (z_load + z0); # Reflection coefficient
julia> S = [gamma 0.0; 0.0 0.0]; # One-port (shunt load)
julia> Z = s2z(S, z0);
julia> abs(Z[1,1] - z_load) < 1e-10 # Verify Z11 matches load impedance
trueCircuitSim.s2z_series — Function
s2z_series(S::Matrix, z0=50.0) -> ComplexF64Extract series impedance from S-parameter matrix for a symmetric two-port network.
This function uses the S→ABCD conversion approach, which is more robust for series elements than the direct Z-parameter conversion. For a series element, the impedance is the B parameter of the ABCD matrix.
Arguments
S: 2x2 S-parameter matrixz0: Reference impedance (default: 50.0 Ω)
Returns
- Series impedance (complex number)
Note
For a perfect open circuit (S21 = 0), this function returns Inf+0im, representing infinite impedance. This avoids singularity issues that occur with direct Z-parameter conversion for open circuits.
Examples
julia> using CircuitSim
julia> z0 = 50.0;
julia> z_series = 0.0 - 100.0im; # 100 Ω capacitive reactance
julia> A, B, C, D = 1.0+0.0im, z_series, 0.0+0.0im, 1.0+0.0im; # ABCD for series element
julia> denom = A + B/z0 + C*z0 + D;
julia> s11 = (A + B/z0 - C*z0 - D) / denom;
julia> s21 = 2.0 / denom;
julia> S = [s11 s21; s21 s11]; # Symmetric
julia> z_extracted = s2z_series(S, z0);
julia> abs(z_extracted - z_series) < 1e-10 # Verify extracted impedance matches original
trueCircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analysis::ACAnalysis; suppress_warnings::Bool=false) -> ACResultRun qucsator AC simulation and return typed AC results.
Example
ac_result = simulate_qucsator(circ, ACAnalysis(1e6, 1e9, 101))
freqs = ac_result.frequencies_Hz
v_out = ac_result.voltages["_net1"]CircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analysis::AbstractAnalysis; suppress_warnings::Bool=false) -> QucsatorDatasetFallback for other analysis types - returns raw QucsatorDataset.
Example
dataset = simulate_qucsator(circ, HarmonicBalanceAnalysis(1e9))
dataset = simulate_qucsator(circ, NoiseAnalysis(1e6, 1e9, 101, "out", "V1"))CircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analysis::DCAnalysis; suppress_warnings::Bool=false) -> DCResultrnings::Bool=false) -> DCResultRun qucsator DC simulation and return typed DC results.
Example
dc_result = simulate_qucsator(circ, DCAnalysis())
v_node = dc_result.voltages["_net1"]
i_source = dc_result.currents["V1"]CircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analysis::SParameterAnalysis; suppress_warnings::Bool=false) -> SParameterResultRun qucsator S-parameter simulation and return typed S-parameter results.
Example
sp_result = simulate_qucsator(circ, SParameterAnalysis(1e9, 10e9, 101))
freqs = sp_result.frequencies_Hz
s21 = sp_result.s_matrix[(2,1)]CircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analysis::TransientAnalysis; suppress_warnings::Bool=false) -> TransientResultRun qucsator transient simulation and return typed transient results.
Example
tran_result = simulate_qucsator(circ, TransientAnalysis(1e-3, points=1001))
times = tran_result.time_s
v_out = tran_result.voltages["_net1"]CircuitSim.simulate_qucsator — Method
simulate_qucsator(c::Circuit, analyses::Vector{<:AbstractAnalysis}; suppress_warnings::Bool=false) -> MultiAnalysisResultRun qucsator simulation with multiple analysis types and return typed results.
Returns a MultiAnalysisResult containing typed results for each analysis that was run.
Example
# Run DC + S-parameter analysis together (DC provides operating point for nonlinear components)
results = simulate_qucsator(circ, [DCAnalysis(), SParameterAnalysis(1e9, 10e9, 101)])
# Access DC results
v_node = results.dc.voltages["_net1"]
i_source = results.dc.currents["V1"]
# Access S-parameter results
freqs = results.sparameter.frequencies_Hz
s21 = results.sparameter.s_matrix[(2,1)]
# Raw dataset still available if needed
dataset = results.datasetCircuitSim.to_qucs_analysis — Function
to_qucs_analysis(analysis::AbstractAnalysis) -> StringConvert an analysis struct to a Qucs netlist analysis command string. Must be implemented for each concrete analysis type.
CircuitSim.to_qucs_netlist — Function
to_qucs_netlist(comp::AbstractCircuitComponent) -> StringGenerate a Qucs netlist line for a component. Must be implemented for each component type in the component's file.
CircuitSim.to_spice_analysis — Function
to_spice_analysis(analysis::AbstractAnalysis) -> StringConvert an analysis struct to a SPICE netlist analysis command string. Must be implemented for each concrete analysis type.
CircuitSim.to_spice_netlist — Function
to_spice_netlist(comp::AbstractCircuitComponent) -> StringGenerate a SPICE netlist line for a component. Must be implemented for each component type in the component's file.
CircuitSim.write_csv — Method
write_csv(filepath::String, times::AbstractVector, samples::AbstractVector;
time_name="time", var_name="data")Write data to CSV format file (two columns with header).
CircuitSim.write_qucs_dataset — Method
write_qucs_dataset(filepath::String, times::AbstractVector, samples::AbstractVector;
time_name="time", var_name="data")Write data to Qucs Dataset format file.
CircuitSim.@connect — Macro
Macro to connect using dot syntax: @connect circ a.pin b.pin