PySpice-org / PySpice

Simulate electronic circuit using Python and the Ngspice / Xyce simulators
https://pyspice.fabrice-salvaire.fr
GNU General Public License v3.0
652 stars 171 forks source link

Xyce: Branches not showing #133

Closed cespedal closed 5 years ago

cespedal commented 5 years ago

Environment (OS, Python version, PySpice version, simulator)

I am using Windows 10 Python 3.6.5 :: Anaconda Inc. PySpice 1.2.0 installed from pip install git+https://github.com/FabriceSalvaire/PySpice

Expected Behaviour

When I run analysis.branches.values() after doing an operating point analysis using Xyce-serial, it returns an empty dictionary. It works fine for nodes.

Steps to reproduce the behaviour

Here is the code I am running

import matplotlib.pyplot as plt

import PySpice.Logging.Logging as Logging
logger = Logging.setup_logging()

from PySpice.Doc.ExampleTools import find_libraries
from PySpice.Probe.Plot import plot
from PySpice.Spice.Library import SpiceLibrary
from PySpice.Spice.Netlist import SubCircuitFactory
from PySpice.Spice.Parser import SpiceParser
from PySpice.Unit import *

libraries_path = find_libraries()
spice_library = SpiceLibrary(libraries_path)

import numpy as np

circuit = Circuit('test')

R1 = circuit.R(1,'p1','p2',4@u_kΩ)
R2 = circuit.R(2,'p2','p6',1@u_kΩ)
R3 = circuit.R(3,'p1','p5',1@u_kΩ)
R4 = circuit.R(4,'p5','p6',1@u_kΩ)
R5 = circuit.R(5,'p6',0,1e-9@u_Ω)

I1 = circuit.I(1,0,'p1',1@u_A)

V1 = circuit.V(1,'p1','p4',-10@u_V)
V2 = circuit.V(2,'p2','p3',-10@u_V)

print(str(circuit))

simulator = circuit.simulator(simulator='xyce-serial')

analysis = simulator.operating_point()

for node in analysis.nodes.values():
    print('Node {}: {:5.2f} V'.format(str(node), float(node)))
for node in analysis.branches.values():
    print('Node {}: {:5.2f} A'.format(str(node), float(node)))
FabriceSalvaire commented 5 years ago

It works on v1.3.2