Skip to content

Commit ae1511f

Browse files
fixed xyce/ngspice path and doc
1 parent f7156fd commit ae1511f

File tree

6 files changed

+38
-19
lines changed

6 files changed

+38
-19
lines changed

PySpice/Spice/NgSpice/Server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class SpiceServer:
7979

8080
def __init__(self, **kwargs):
8181

82-
self._spice_command = kwargs.get('spice_command', self.SPICE_COMMAND)
82+
self._spice_command = kwargs.get('spice_command') or self.SPICE_COMMAND
8383

8484
##############################################
8585

PySpice/Spice/Xyce/Server.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
import subprocess
3232
import tempfile
3333

34-
####################################################################################################
35-
34+
from PySpice.Config import ConfigInstall
3635
from .RawFile import RawFile
3736

3837
####################################################################################################
@@ -43,7 +42,7 @@
4342

4443
class XyceServer:
4544

46-
"""This class wraps the execution of xyce and convert the output to a Python data structure.
45+
"""This class wraps the execution of Xyce and convert the output to a Python data structure.
4746
4847
Example of usage::
4948
@@ -52,17 +51,26 @@ class XyceServer:
5251
5352
It returns a :obj:`PySpice.Spice.RawFile` instance.
5453
54+
Default Xyce path is set in `XyceServer.XYCE_COMMAND`.
55+
5556
"""
5657

57-
_logger = _module_logger.getChild('XyceServer')
58+
if ConfigInstall.OS.on_linux:
59+
XYCE_COMMAND = 'Xyce'
60+
elif ConfigInstall.OS.on_osx:
61+
XYCE_COMMAND = 'Xyce'
62+
elif ConfigInstall.OS.on_windows:
63+
XYCE_COMMAND = 'C:\\Program Files\\Xyce 6.10 OPENSOURCE\\bin\\Xyce.exe'
64+
else:
65+
raise NotImplementedError
5866

59-
XYCE_COMMAND = 'Xyce'
67+
_logger = _module_logger.getChild('XyceServer')
6068

6169
##############################################
6270

6371
def __init__(self, **kwargs):
6472

65-
self._xyce_command = kwargs.get('xyce_command', self.XYCE_COMMAND)
73+
self._xyce_command = kwargs.get('xyce_command') or self.XYCE_COMMAND
6674

6775
##############################################
6876

PySpice/Spice/Xyce/Simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, circuit, **kwargs):
4949
super().__init__(circuit, **kwargs)
5050

5151
xyce_command = kwargs.get('xyce_command', None)
52-
self._spice_server = XyceServer(spice_command=xyce_command)
52+
self._xyce_server = XyceServer(xyce_command=xyce_command)
5353

5454
##############################################
5555

@@ -63,7 +63,7 @@ def _run(self, analysis_method, *args, **kwargs):
6363

6464
super()._run(analysis_method, *args, **kwargs)
6565

66-
raw_file = self._spice_server(spice_input=str(self))
66+
raw_file = self._xyce_server(spice_input=str(self))
6767
self.reset_analysis()
6868
raw_file.simulation = self
6969

doc/sphinx/source/faq.rst

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,29 @@ and raw parameters using:
9292
How to set the Ngspice library path ?
9393
-------------------------------------
9494

95-
If the setting doesn't match your environment, then you have to set manually the attribute
95+
If the default setting doesn't match your environment, then you have to fix globally the attribute
9696
:attr:`PySpice.Spice.NgSpice.Shared.NgSpiceShared.LIBRARY_PATH`. Note you have to place a brace pair
97-
just before the extension, for example "C:\...\ngspice{}.dll". You can also fix the value of
98-
:attr:`PySpice.Spice.NgSpice.Shared.NgSpiceShared.NGSPICE_PATH`.
97+
just before the extension, for example :file:`C:\\...\\ngspice{}.dll`.
9998

100-
How to set the Ngspice path ?
101-
-----------------------------
99+
You can also fix the value of :attr:`PySpice.Spice.NgSpice.Shared.NgSpiceShared.NGSPICE_PATH`.
102100

103-
If the setting doesn't match your environment, then you have to set manually the attribute
104-
:attr:`PySpice.Spice.Server.SpiceServer.SPICE_COMMAND`. This value can be passed as argument as
105-
well, see API documentation.
101+
How to set the Ngspice executable path ?
102+
----------------------------------------
103+
104+
If the default setting doesn't match your environment, then you can fix globally the Ngspice executable
105+
path using the attribute :attr:`PySpice.Spice.NgSpice.Server.SpiceServer.SPICE_COMMAND`, you can also
106+
pass the executable path to the simulator using::
107+
108+
simulator = circuit.simulator(spice_command='...')
109+
110+
How to set the Xyce path ?
111+
--------------------------
112+
113+
If the default setting doesn't match your environment, then you can fix globally the Xyce executable
114+
path using the attribute :attr:`PySpice.Spice.Xyce.Server.XyceServer.XYCE_COMMAND`, you can also
115+
pass the executable path to the simulator using::
116+
117+
simulator = circuit.simulator(xyce_command='...')
106118

107119
How to set the simulator ?
108120
--------------------------

issues/issue-133.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
print(str(circuit))
3434

3535
simulator = circuit.simulator(simulator='xyce-serial')
36-
3736
analysis = simulator.operating_point()
3837

3938
for node in analysis.nodes.values():

issues/issue-150.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
thevenin_circuit.R('load', 'load', thevenin_circuit.gnd, 1@u_kΩ)
1818

1919
simulator = thevenin_circuit.simulator(simulator='xyce-serial', temperature=25, nominal_temperature=25)
20-
# simulator._spice_server._xyce_command = "C:\\progs\\Xyce 6.10 OPENSOURCE\\bin\\Xyce.exe"
20+
# simulator._spice_server._xyce_command = "C:\\Program Files\\Xyce 6.10 OPENSOURCE\\bin\\Xyce.exe"
2121
analysis = simulator.operating_point()
2222

2323
load_node = analysis.load

0 commit comments

Comments
 (0)