Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analysis=simulator.operating_point() from voltage divider is not working #360

Closed
hebersarmiento opened this issue Nov 17, 2023 · 2 comments

Comments

@hebersarmiento
Copy link

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

Fedora 38 linux, PySpice-1.5 , libngspice-41-1.fc38.x86_64, ngspice-41,python 3.11.

I ran test.py for a voltage divider (code below):

import PySpice
import PySpice.Logging.Logging as Logging
from PySpice.Spice.Netlist import Circuit #Netlist allows us to create a circuit
from PySpice.Unit import *
import sys
logger = Logging.setup_logging()#it will output in the command line

if sys.platform=="linux" or sys.platform=="linux2":
PySpice.Spice.Simulation.CircuitSimulator.DEFAULT_SIMULATOR = 'ngspice-subprocess'
elif sys.platform=="win32":
pass

circuit = Circuit('Voltage Divider')

circuit.V('input', 'in', circuit.gnd, 10@u_V)
circuit.R(1, 'in', 'out', 9@u_kΩ)
circuit.R(2, 'out', circuit.gnd, 1@u_kΩ)

print("The circuit/Netlist:\n\n",circuit)

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
print("The simulator:\n\n",simulator)

#next line breaks!
#analysis=simulator.operating_point()

exit()

If I remove comment from the line analysis= simulator.operating_point() I get the following error:

023-11-17 11:46:08,495 - PySpice.Spice.NgSpice.Server.SpiceServer.call - INFO - Start the spice subprocess
Traceback (most recent call last):
File "/path/test.py", line 29, in
analysis=simulator.operating_point()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/Simulation.py", line 1194, in operating_point
return self._run('operating_point', *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/NgSpice/Simulation.py", line 76, in _run
raw_file = self._spice_server(spice_input=str(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/NgSpice/Server.py", line 162, in call
return RawFile(stdout, number_of_points)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/NgSpice/RawFile.py", line 170, in init
raw_data = self._read_header(stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/NgSpice/RawFile.py", line 192, in _read_header
self.circuit_name = self._read_header_field_line(header_line_iterator, 'Circuit')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/PySpice/Spice/RawFile.py", line 243, in _read_header_field_line
raise NameError("Expected label %s instead of %s" % (expected_label, label))
NameError: Expected label Circuit instead of Note

Any help is appreciated!

@cyber-g
Copy link
Contributor

cyber-g commented Nov 17, 2023

Duplicate of : #352

Fixed in : 
#353

@hebersarmiento
Copy link
Author

hebersarmiento commented Nov 17, 2023

Thank you, I am sorry for not seeing this. Now it is working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants