Electron microscopy
 
NgSpice/PySpice for Electrical Circuit Analysis
- Integrated Circuits -
- An Online Book -
Integrated Circuits                                                                                   http://www.globalsino.com/ICs/        


=================================================================================

 

SPICE stands for “Simulation Program with Integrated Circuit Emphasis”, which is a program used in ICs and board-level design to check the integrity of circuit designs and to predict circuit behavior. NgSpice is an open-source SPICE simulator for electric and electronic circuits and is compatible with Windows and Linux. Xyce is a SPICE compatible simulator developed by the Sandia National Laboratories. PySpice is a free and open source Python module which interface Python to the NgSpice and Xyce circuit simulators. Its simulation output is converted to Numpy arrays for convenience.

Code 1:
Wheatstone bridge: Introduction and code.

Code 2:
Input voltage:
       circuit.V('input', 1, circuit.gnd, 10@u_V)

Code 3:
Input current:
       circuit.I('input', 1, circuit.gnd, 1@u_A)

Code 3: Linear Voltage-Controlled Current Sources
Input current:
       circuit.VCCS(m, x node, y node, coefficient)

Code 3: Linear Voltage-Controlled Voltage Sources
Input current:
       circuit.VCVS(m, x node, y node, control node x, control node y, coefficient)

Code 4: Linear Current-Controlled Current Sources
       circuit.F(m current source, x node, y node, 'Vtest', coefficient)
or:
       circuit.CCCS(m current source, x node, y node, 'Vtest', coefficient)

Code 5: Linear Current-Controlled Voltage Sources
Input:
       circuit.H('test', 1, circuit.gnd, 8) # "8"here is a coefficient.
or:       
       circuit.CCVS('test', 1, circuit.gnd, 8) # "8"here is a coefficient.

Code 6: Output the controlling currents of the branches which do not contain resistors:
       for node in analysis.branches.values():
              print('Node {}: {:5.2f} A'.format(str(node), float(node)))

=================================================

NgSpice simulation on circuits with diodes

Switch-like diodes and NgSpice simulations

=================================================

Wheatstone bridge: circuit and code:
        Wheatstone bridge
Output:        
        Wheatstone bridge

=================================================

Voltage divider: circuit and code:
        Wheatstone bridge
Output:        
        Wheatstone bridge                
        Wheatstone bridge         
                

 

=================================================================================