# 11.1.9.10. Simulation¶

This modules implements classes to perform simulations.

class PySpice.Spice.Simulation.ACAnalysisParameters(variation, number_of_points, start_frequency, stop_frequency)[source]

This class defines analysis parameters for AC analysis.

number_of_points
start_frequency
stop_frequencyr
to_list()[source]
variation
class PySpice.Spice.Simulation.AcSensitivityAnalysisParameters(output_variable, variation, number_of_points, start_frequency, stop_frequency)[source]

This class defines analysis parameters for AC sensitivity analysis.

number_of_points
output_variable
start_frequency
stop_frequencyr
to_list()[source]
variation
class PySpice.Spice.Simulation.AnalysisParameters[source]

Bases: object

Base class for analysis parameters

analysis_name
to_list()[source]
class PySpice.Spice.Simulation.CircuitSimulation(circuit, **kwargs)[source]

Bases: object

Define and generate the spice instruction to perform a circuit simulation.

Warning

In some cases NgSpice can perform several analyses one after the other. This case is partially supported.

ac(variation, number_of_points, start_frequency, stop_frequency)[source]

Perform a small-signal AC analysis of the circuit where all non-linear devices are linearized around their actual DC operating point.

Examples of usage:

analysis = simulator.ac(start_frequency=10@u_kHz, stop_frequency=1@u_GHz, number_of_points=10,  variation='dec')


Note that in order for this analysis to be meaningful, at least one independent source must have been specified with an AC value. Typically it does not make much sense to specify more than one AC source. If you do, the result will be a superposition of all sources, thus difficult to interpret.

Spice examples:

.ac dec nd fstart fstop
.ac oct no fstart fstop
.ac lin np fstart fstop


The parameter variation must be either dec, oct or lin.

ac_sensitivity(output_variable, variation, number_of_points, start_frequency, stop_frequency)[source]

Compute the sensitivity of the AC values of a node voltage or voltage-source branch current to all non-zero device parameters.

Examples of usage:

analysis = simulator.ac_sensitivity(...)


Spice syntax:

.sens outvar ac dec nd fstart fstop
.sens outvar ac oct no fstart fstop
.sens outvar ac lin np fstart fstop


Spice examples:

.sens V(OUT) AC DEC 10 100 100 k

analysis_iter()[source]
circuit
dc(**kwargs)[source]

Compute the DC transfer fonction of the circuit with capacitors open and inductors shorted.

Examples of usage:

analysis = simulator.dc(Vinput=slice(-2, 5, .01))
analysis = simulator.dc(Ibase=slice(0, 100e-6, 10e-6))
analysis = simulator.dc(Vcollector=slice(0, 5, .1), Ibase=slice(micro(10), micro(100), micro(10))) # broken ???


Spice syntax:

src_name is the name of an independent voltage or a current source, a resistor or the circuit temperature.

vstart, vstop, and vincr are the starting, final, and incrementing values respectively.

A second source (src2) may optionally be specified with associated sweep parameters. In this case, the first source is swept over its range for each value of the second source.

Spice examples:

dc_sensitivity(output_variable)[source]

Compute the sensitivity of the DC operating point of a node voltage or voltage-source branch current to all non-zero device parameters.

Examples of usage:

analysis = simulator.dc_sensitivity('v(out)')


Spice syntax:

Examples:

initial_condition(**kwargs)[source]

Set initial condition for voltage nodes.

Usage:

simulator.initial_condition(node_name1=value, ...)

nominal_temperature
operating_point()[source]

Compute the operating point of the circuit with capacitors open and inductors shorted.

options(*args, **kwargs)[source]
reset_analysis()[source]
save(*args)[source]

Set the list of saved vectors.

If no .save line is given, then the default set of vectors is saved (node voltages and voltage source branch currents). If .save lines are given, only those vectors specified are saved.

Node voltages may be saved by giving the node_name or v(node_name). Currents through an independent voltage source (including inductor) are given by i(source_name) or source_name#branch. Internal device data are accepted as @dev[param].

If you want to save internal data in addition to the default vector set, add the parameter all to the additional vectors to be saved.

save_currents

Save all currents.

save_internal_parameters(*args)[source]

This method is similar tosave but assume all.

str_options(unit=True)[source]
temperature
transient(step_time, end_time, start_time=0, max_time=None, use_initial_condition=False)[source]

Perform a transient analysis of the circuit.

Examples of usage:

analysis = simulator.transient(step_time=1@u_us, end_time=500@u_us)
analysis = simulator.transient(step_time=source.period/200, end_time=source.period*2)


Spice syntax:

class PySpice.Spice.Simulation.CircuitSimulator(circuit, **kwargs)[source]

This class implements a circuit simulator. Each analysis mode is performed by a method that return the measured probes.

For ac and transient analyses, the user must specify a list of nodes using the probes key argument.

DEFAULT_SIMULATOR = 'ngspice-shared'
ac(*args, **kwargs)[source]

Perform a small-signal AC analysis of the circuit where all non-linear devices are linearized around their actual DC operating point.

Examples of usage:

analysis = simulator.ac(start_frequency=10@u_kHz, stop_frequency=1@u_GHz, number_of_points=10,  variation='dec')


Note that in order for this analysis to be meaningful, at least one independent source must have been specified with an AC value. Typically it does not make much sense to specify more than one AC source. If you do, the result will be a superposition of all sources, thus difficult to interpret.

Spice examples:

.ac dec nd fstart fstop
.ac oct no fstart fstop
.ac lin np fstart fstop


The parameter variation must be either dec, oct or lin.

dc(*args, **kwargs)[source]

Compute the DC transfer fonction of the circuit with capacitors open and inductors shorted.

Examples of usage:

analysis = simulator.dc(Vinput=slice(-2, 5, .01))
analysis = simulator.dc(Ibase=slice(0, 100e-6, 10e-6))
analysis = simulator.dc(Vcollector=slice(0, 5, .1), Ibase=slice(micro(10), micro(100), micro(10))) # broken ???


Spice syntax:

src_name is the name of an independent voltage or a current source, a resistor or the circuit temperature.

vstart, vstop, and vincr are the starting, final, and incrementing values respectively.

A second source (src2) may optionally be specified with associated sweep parameters. In this case, the first source is swept over its range for each value of the second source.

Spice examples:

dc_sensitivity(*args, **kwargs)[source]

Compute the sensitivity of the DC operating point of a node voltage or voltage-source branch current to all non-zero device parameters.

Examples of usage:

analysis = simulator.dc_sensitivity('v(out)')


Spice syntax:

Examples:

classmethod factory(circuit, *args, **kwargs)[source]

Return a PySpice.Spice.Simulation.SubprocessCircuitSimulator or PySpice.Spice.Simulation.NgSpiceSharedCircuitSimulator instance depending of the value of the simulator parameter: subprocess or shared, respectively. If this parameter is not specified then a subprocess simulator is returned.

operating_point(*args, **kwargs)[source]

Compute the operating point of the circuit with capacitors open and inductors shorted.

transient(*args, **kwargs)[source]

Perform a transient analysis of the circuit.

Examples of usage:

analysis = simulator.transient(step_time=1@u_us, end_time=500@u_us)
analysis = simulator.transient(step_time=source.period/200, end_time=source.period*2)


Spice syntax:

class PySpice.Spice.Simulation.DCAnalysisParameters(**kwargs)[source]

This class defines analysis parameters for DC analysis.

parameters
to_list()[source]
class PySpice.Spice.Simulation.DcSensitivityAnalysisParameters(output_variable)[source]

This class defines analysis parameters for DC sensitivity analysis.

output_variable
to_list()[source]
class PySpice.Spice.Simulation.OperatingPointAnalysisParameters[source]

This class defines analysis parameters for operating point analysis.

class PySpice.Spice.Simulation.TransientAnalysisParameters(step_time, end_time, start_time=0, max_time=None, use_initial_condition=False)[source]

This class defines analysis parameters for transient analysis.

end_time
max_time
start_time
step_time
to_list()[source]
use_initial_condition