diff --git a/pyspice-discourse-backup/c/bug/12.html b/pyspice-discourse-backup/c/bug/12.html new file mode 100644 index 00000000..0986d313 --- /dev/null +++ b/pyspice-discourse-backup/c/bug/12.html @@ -0,0 +1,267 @@ + + + + + Latest Bug topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Bug +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 125 + + April 27, 2020 +
+ + + + + + + + + + + 2 + + 589 + + October 24, 2020 +
+ + + + + 0 + + 191 + + August 27, 2020 +
+ + + + + + + + 9 + + 302 + + July 31, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/circuit-simulation/9.html b/pyspice-discourse-backup/c/circuit-simulation/9.html new file mode 100644 index 00000000..dc1638b6 --- /dev/null +++ b/pyspice-discourse-backup/c/circuit-simulation/9.html @@ -0,0 +1,479 @@ + + + + + Latest Circuit Simulation topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Circuit Simulation +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 186 + + April 27, 2020 +
+ + + + + 1 + + 87 + + January 19, 2022 +
+ + + + + + + + 5 + + 298 + + November 28, 2021 +
+ + + + + + + + + + + + + + 5 + + 644 + + November 28, 2021 +
+ + + + + 0 + + 84 + + September 16, 2021 +
+ + + + + 0 + + 89 + + August 11, 2021 +
+ + + + + 0 + + 196 + + August 19, 2020 +
+ + + + + 0 + + 301 + + August 3, 2020 +
+ + + + + 0 + + 321 + + July 31, 2020 +
+ + + + + + + + + + + + + + 7 + + 943 + + June 17, 2020 +
+ + + + + + + + 1 + + 236 + + June 17, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/circuit-simulation/9.rss b/pyspice-discourse-backup/c/circuit-simulation/9.rss new file mode 100644 index 00000000..fe0b753e --- /dev/null +++ b/pyspice-discourse-backup/c/circuit-simulation/9.rss @@ -0,0 +1,515 @@ + + + + Circuit Simulation - PySpice + https://pyspice.discourse.group/c/circuit-simulation/9 + Topics in the 'Circuit Simulation' category + + Thu, 13 Jan 2022 03:55:35 +0000 + + + Simulating a circuit with 16 MOSFETs: True gmin stepping error + + Circuit Simulation + Hello,

+

I am trying to simulate a circuit using 16 MOSFETS.

+

The issue is that once the MOSFETS’s 15 and 16 are placed in the schematic, it results in an error: PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR

+

If the MOSFET’s 15 and 16 are commented out, then the code compiles.

+

I am using NGspice-34.dll and PySpice 1.5. Have also tested with Pyspice 1.4.3 and NGspice-32.dll.

+

Is NGSpice reaching some maximum nodes/complexity limit? OR is this an issue with mosfet model? OR it is a circuit netlist (floating node?) issue?

+

Any help or ideas would be greatly appreciated.

+

The code and error message are reproduced below.

+

Thanks

+

Kahless96

+

##***********************************************
+import math
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.widgets import Cursor
+from matplotlib.pyplot import semilogx
+from matplotlib import pyplot

+

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 Circuit
+from PySpice.Unit import *

+

from engineering_notation import EngNumber

+

##***********************************************

+

+Circuit Netlist

+

circuit = Circuit(‘MyCircuit’)

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)
+circuit.include(spice_library[‘ptm65nm_nmos’])
+circuit.include(spice_library[‘ptm65nm_pmos’])

+

+Define inputs

+

HIGH = 1@u_V
+LOW = 0@u_V
+f_D = 1@u_Hz
+f_C = f_D/2
+f_B = f_D/4
+f_A = f_D/8

+

steptime=1@u_ms
+finaltime = 8/f_D
+circuit.V(1, ‘Vdd’, circuit.gnd, HIGH@u_V)
+circuit.PulseVoltageSource(2, ‘A’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_A)/2, period=1/f_A)
+circuit.PulseVoltageSource(3, ‘B’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_B)/2, period=1/f_B)
+circuit.PulseVoltageSource(4, ‘C’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_C)/2, period=1/f_C)
+circuit.PulseVoltageSource(5, ‘D’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_D)/2, period=1/f_D)

+

+M <bulk/substrate node> +

+

circuit.MOSFET(1, ‘out1’, ‘A’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(2, ‘out1’, ‘B’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(3, ‘out1’, ‘A’, ‘temp’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(4, ‘temp’,‘B’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(5, ‘out2’, ‘out1’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(6, ‘out2’, ‘out1’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(7, ‘out3’, ‘C’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(8, ‘out3’, ‘D’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(9, ‘out3’, ‘C’, ‘temp1’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(10, ‘temp1’,‘D’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(11, ‘out4’, ‘out3’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(12, ‘out4’, ‘out3’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(13, ‘op’, ‘out2’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(14, ‘op’, ‘out4’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(15, ‘op’, ‘out2’, ‘temp2’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(16, ‘temp2’,‘out4’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)

+

##***********************************************

+

+Simulation: Transient Analysis

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=steptime, end_time=finaltime)

+

#########################

+

+PLOTTING COMMANDS

+

figure = plt.subplots(figsize=(11, 6))
+axe = plt.subplot(111)
+plt.xlabel(‘Time [s]’)
+plt.ylabel(‘Voltage [V]’)
+plt.grid()
+plot(analysis[‘op’], axis=axe, color=‘red’)
+plt.show()

+

Here is the error messages after which it fails to run:

+

2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: Starting true gmin stepping
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-03 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-04 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-05 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-06 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-07 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-08 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-09 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-10 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-11 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: True gmin stepping completed

+

I have seen this gmin stepping error in other forum posts but in those cases it was related to circuit netlist error. This does not seem to be the case here.

+

The mosfet models being used are provided with Pyspice.

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162 + Thu, 13 Jan 2022 03:55:35 +0000 + No + No + No + pyspice.discourse.group-topic-162 + Simulating a circuit with 16 MOSFETs: True gmin stepping error +
+ + How to write .func in pyspice and use it in behavioral source? + + Circuit Simulation + I want to write a .func that will help me designing a device model. I used **raw_spice=’ …’ ** but it is not working. I am new in pyspice.

+

Thank yuo

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148 + Thu, 16 Sep 2021 00:26:03 +0000 + No + No + No + pyspice.discourse.group-topic-148 + How to write .func in pyspice and use it in behavioral source? +
+ + Interrupted simulation multiple sources + + Circuit Simulation + Hi everyone,

+

for a research project I’m working on control strategies for PFC circuits and therefore I need to simulate a passive circuit in conjunction with two half bridges.
+Problem is that I need the simulation to interact with a python script since I need to calculate the control signals of the two half bridges externally and thus the simualtion flow is as follows.

+

First, I need to initialize the simulation which basically means that I need to sample the amplitude and phase of a sinusodial source representing the grid voltage and the component values and initial conditions of the passive components. Next, I need to run the simulation in chunks where I first calculate the four control signals of the half bridges based on the current and voltage signals of the passive circuit followed by a chunk of transient simulation for a given time span (sample rate of the controller).

+

I tried to implement this flow but I unfortunately I struggle with the following issues.

+

a) Phase of the AC source:
+I tired SinusoidalVoltageSource() but I failed to specify a phase offset. Altough it’s base class SinusoidalMixin() offers a delay attribute, it seems that it just enables the source after a given time and thus this isn’t the desired behaviour for my purpose. Alternatively, I defined my own grid voltage using a NgSpiceShared object according …/examples/ngspice-shared/external-source.html.
+This essential does the trick for me but leaves with the next problem.

+

b) Multiple External Sources:
+Give the simulation flow above I need to run the simulation with at least four external sources, two for every half bridge, and five if I define the grid voltage also as external source. So I wonder how I define multiple shared objects.

+

c) Setting the initial conditions
+Since I run the simulation in chunks I wonder if I have to preload the nodes with the latest values and I need to run the simulation with start_time=0 and end_time=timespan according the controller’s sample rate or are the states kept internally and I need just to run the simulation with start_time=(k-1)timespan, end_time=ktimespan in order to run the kth simulation chunk.

+

Any help is kindly appreciated!

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/interrupted-simulation-multiple-sources/144 + Wed, 11 Aug 2021 15:05:52 +0000 + No + No + No + pyspice.discourse.group-topic-144 + Interrupted simulation multiple sources +
+ + Simulating Dependent Sources (CCVS works but VCVS does not?!) + + Circuit Simulation + Hello,

+

I am trying to run the following code for the circuit:Circuit

+

###############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with VCVS’)

+

circuit.R(1, 1, circuit.gnd, 6@u_Ω)
+circuit.R(2, 2, 3, 4@u_Ω)
+circuit.R(3, 3, 4, 8@u_Ω)
+circuit.R(4, 5, circuit.gnd, 15@u_Ω)
+circuit.V(1, 2, 1, 65@u_V)
+circuit.E(1, 4, 3, 2, 3, 3)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+

When I run, it gives an error:

+

Traceback (most recent call last):
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 928, in getattr
+return self.getitem(attribute_name)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 921, in getitem
+raise IndexError(attribute_name) # KeyError
+IndexError: E

+

During handling of the above exception, another exception occurred:

+

Traceback (most recent call last):
+File “C:/Users/Desktop/PySpice/node-voltage-method-example8.py”, line 22, in
+circuit.E(1, 4, 3, 2, 3, 3)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 930, in getattr
+raise AttributeError(attribute_name)
+AttributeError: E

+

I am not sure where I am going wrong. I have been able to simulate a CCVS (part name H) but all other dependent sources seem to give an error.

+

Can anyone please point out what is wrong in the code above?

+

Thanks

+

Salman

+

6 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105 + Wed, 02 Dec 2020 01:58:43 +0000 + No + No + No + pyspice.discourse.group-topic-105 + Simulating Dependent Sources (CCVS works but VCVS does not?!) +
+ + Is there a way to manipulate parameter during the simulation + + Circuit Simulation + Hello everyone,

+

ist it possible to ‘pause’ the simulation, get values of certain voltages or currents manipulate them and put them back into the simulation?

+

For example to implement a digital controller or something like that.

+

Thank you for any help.

+

Kind regards
+RNWx

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/is-there-a-way-to-manipulate-parameter-during-the-simulation/72 + Wed, 19 Aug 2020 09:46:34 +0000 + No + No + No + pyspice.discourse.group-topic-72 + Is there a way to manipulate parameter during the simulation +
+ + Inputing data from python model into ngspice shared netlist + + Circuit Simulation + Hello,

+

I’ve been trying to simulate a model of a neuron coupled to a microelectrode in ngspice. However, while the microelectrode is easy to simulate the neuronal model is quite difficult. As such, when I found pyspice I thought maybe I could use the netlist I already have for the microelectrode and create the neuron model in python and use the output voltage of the neuron model as an input in the microelectrode model.
+I’ve read through all the examples and some documentation and even used the ngspice shared interpreter example with my microelectrode netlist but I cannot even find a way of just plotting the circuits transient analysis (without the neuron model) as I did with ngspice.

+

To summarize, my questions are:

+
    +
  1. Can I use my already written netlist of the microelectrode with the ngspice shared option ?
  2. +
  3. To interface the neuron model that I will write in python as source voltage for the microelectrode does it mean that I have to re-write the netlist into pyspyce nomenclature ?
  4. +
+

PS: I can provide my netlist if necessary.

+

Thank you for your time.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/inputing-data-from-python-model-into-ngspice-shared-netlist/66 + Mon, 03 Aug 2020 11:05:01 +0000 + No + No + No + pyspice.discourse.group-topic-66 + Inputing data from python model into ngspice shared netlist +
+ + Transistor Example + + Circuit Simulation + In the example 8.20.1 AC Coupled Amplifier, when I was trying to run the code in Jupyter Notebook

+
+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+
+

it shows:

+
+
+

OSError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Netlist.py in simulator(self, *args, **kwargs)
+1297
+1298 def simulator(self, *args, **kwargs):
+-> 1299 return CircuitSimulator.factory(self, *args, **kwargs)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117
+1118 if sub_cls is not None:
+-> 1119 return sub_cls(circuit, *args, **kwargs)
+1120 else:
+1121 raise ValueError(‘Unknown simulator type’)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 else:
+451 cls._logger.debug(“New instance for id {}”.format(ngspice_id))
+–> 452 instance = cls(ngspice_id=ngspice_id, send_data=send_data, verbose=verbose)
+453 cls._instances[ngspice_id] = instance
+454 return instance

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in init(self, ngspice_id, send_data, verbose)
+478
+479 self._library_path = None
+–> 480 self._load_library(verbose)
+481 self._init_ngspice(send_data)
+482

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in _load_library(self, verbose)
+538 if verbose:
+539 print(message)
+–> 540 self._ngspice_shared = ffi.dlopen(self.library_path)
+541
+542 # Note: cannot yet execute command

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in dlopen(self, name, flags)
+148 “or an already-opened ‘void *’ handle”)
+149 with self._lock:
+–> 150 lib, function_cache = _make_ffi_library(self, name, flags)
+151 self._function_caches.append(function_cache)
+152 self._libraries.append(lib)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _make_ffi_library(ffi, libname, flags)
+830 def _make_ffi_library(ffi, libname, flags):
+831 backend = ffi._backend
+–> 832 backendlib = _load_backend_lib(backend, libname, flags)
+833 #
+834 def accessor_function(name):

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
+825 if first_error is not None:
+826 msg = “%s. Additionally, %s” % (first_error, msg)
+–> 827 raise OSError(msg)
+828 return backend.load_library(path, flags)
+829

+

OSError: cannot load library ‘libngspice.dylib’: dlopen(libngspice.dylib, 2): image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called ‘libngspice.dylib’

+
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/transistor-example/63 + Fri, 31 Jul 2020 05:27:09 +0000 + No + No + No + pyspice.discourse.group-topic-63 + Transistor Example +
+ + XSPICE elements in PySpice + + Circuit Simulation + Good afternoon!
+I’m trying to model a simple electrical circuit with XSPICE elements. For example, the electrical circuit from Chapter 27.1 (Ngspice user manual):

+
from PySpice.Spice.Netlist import Circuit
+
+test = """XSPICE
+Vin1 1 0 DC 0V AC 1.0 SIN(0V 1V 1000Hz)
+Ccouple 1 in 0.000001
+Rzin in 0 19.35k
+Aamp in aout gain_block
+.model gain_block gain (gain=-3.9 out_offset=7.003)
+Rzout aout coll 3.9k
+Rbig coll 0 1e12
+.control
+run
+display
+tran 0.00001 0.003
+plot i(Vin1)
+.endc
+.end
+"""
+circuit = Circuit(test)
+
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)
+analysis = simulator.transient(step_time=0.00001, end_time=0.003)
+
+

When I try to run it I get an error:

+
  File ".../.local/lib/python3.7/site-packages/PySpice/Spice/RawFile.py", line 223, in _read_header_line
+    raise NameError("Unexpected line: %s" % (line))
+NameError: Unexpected line: Reducing trtol to 1 for xspice 'A' devices
+
+

So there are two questions:

+
    +
  1. If I understand correctly, the error is caused by the ngspice message “Reducing trtol to 1 for xspice ‘A’ devices”. Is it possible to avoid this error? When adding a line “option trtol=1” after the line “.control” I get the following error:
    +NameError: Expected label Title instead of No. of Data Rows +
  2. +
  3. Is it possible to set the value of trtol and other Simulator Variables by using any pyspice command?
  4. +
+

I am using Spyder 4, PySpice 1.4.3 and ngspice-30 (DEFAULT_SIMULATOR = ‘ngspice-subprocess’) in the Debian linux operating system.

+

Thank you in advance!

+


+Regards,
+Dmitriy N.

+

6 posts - 4 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/xspice-elements-in-pyspice/61 + Sat, 11 Jul 2020 16:18:54 +0000 + No + No + No + pyspice.discourse.group-topic-61 + XSPICE elements in PySpice +
+ + AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance' + + Circuit Simulation + good afternoon community among my adventure to simulate an example of the pyspice module I ran into the following error:
+---------------------------------------------------------------------------

+
AttributeError                            Traceback (most recent call last)
+
+<ipython-input-12-475d4280ae1b> in <module>()
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+      2 analysis = simulator.ac(start_frequency=1@u_Hz, stop_frequency=1@u_MHz, number_of_points=10,  variation='dec')
+
+2 frames
+
+/usr/local/lib/python3.6/dist-packages/PySpice/Spice/NgSpice/Simulation.py in __init__(self, circuit, **kwargs)
+     97         ngspice_shared = kwargs.get('ngspice_shared', None)
+     98         if ngspice_shared is None:
+---> 99             self._ngspice_shared = NgSpiceShared.new_instance()
+    100         else:
+    101             self._ngspice_shared = ngspice_shared
+
+AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance
+
+

the example link is as follows
+https://pyspice.fabrice-salvaire.fr/examples/filter/low-pass-rc-filter.html
+the characteristic of my environment are the following
+ubuntu 18.04, python 3.6.2, pyscpice 1.4.2
+To clarify I am a student of electrical engineering and I am just getting into this world of computer science, thank you very much for your help

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/attributeerror-type-object-ngspiceshared-has-no-attribute-new-instance/39 + Tue, 26 May 2020 00:40:24 +0000 + No + No + No + pyspice.discourse.group-topic-39 + AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance' +
+ + Example transistor + + Circuit Simulation + good afternoon I communicate with the community because I am not very good at programming but I am trying to learn how to simulate circuits that I need for a job, however when I try to simulate the circuit of the example of transistors I get the following error

+
Traceback (most recent call last):
+  File "polos.py", line 50, in <module>
+    circuit.include(spice_library['2n2222a'])
+  File "/usr/local/lib/python3.6/dist-packages/PySpice/Spice/Library.py", line 107, in __getitem__
+    raise KeyError(name)
+KeyError: '2n2222a'
+

8 posts - 4 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/example-transistor/36 + Fri, 22 May 2020 23:17:28 +0000 + No + No + No + pyspice.discourse.group-topic-36 + Example transistor +
+ + About the Circuit Simulation category + + Circuit Simulation + (Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-circuit-simulation-category/16 + Mon, 27 Apr 2020 19:48:21 +0000 + Yes + No + No + pyspice.discourse.group-topic-16 + About the Circuit Simulation category +
+
+
diff --git a/pyspice-discourse-backup/c/circuit-simulation/9?page=1.html b/pyspice-discourse-backup/c/circuit-simulation/9?page=1.html new file mode 100644 index 00000000..12e4e0f8 --- /dev/null +++ b/pyspice-discourse-backup/c/circuit-simulation/9?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest Circuit Simulation topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Circuit Simulation +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/data-analysis-using-python/8.html b/pyspice-discourse-backup/c/data-analysis-using-python/8.html new file mode 100644 index 00000000..faa3755b --- /dev/null +++ b/pyspice-discourse-backup/c/data-analysis-using-python/8.html @@ -0,0 +1,202 @@ + + + + + Latest Data Analysis using Python topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Data Analysis using Python +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 152 + + April 27, 2020 +
+ + + + + 0 + + 127 + + November 6, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/data-analysis-using-python/8.rss b/pyspice-discourse-backup/c/data-analysis-using-python/8.rss new file mode 100644 index 00000000..517a02b8 --- /dev/null +++ b/pyspice-discourse-backup/c/data-analysis-using-python/8.rss @@ -0,0 +1,61 @@ + + + + Data Analysis using Python - PySpice + https://pyspice.discourse.group/c/data-analysis-using-python/8 + Topics in the 'Data Analysis using Python' category + + Fri, 06 Nov 2020 15:07:46 +0000 + + + Losing units when summing a Waveform + + Data Analysis using Python + I multiplied two Waveform objects: one containing voltages and the other containing currents. Then I multiplied it by a PeriodValue. As expected, the resulting Wavform object contains numbers with the units of Joules. But when I applied the sum() method to this Waveform, I got a scalar value with no units.

+

Is there any way to do this without losing the units for the calculations that follow?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/losing-units-when-summing-a-waveform/97 + Fri, 06 Nov 2020 15:07:46 +0000 + No + No + No + pyspice.discourse.group-topic-97 + Losing units when summing a Waveform +
+ + About the Data Analysis using Python category + + Data Analysis using Python + (Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-data-analysis-using-python-category/15 + Mon, 27 Apr 2020 19:46:59 +0000 + Yes + No + No + pyspice.discourse.group-topic-15 + About the Data Analysis using Python category +
+
+
diff --git a/pyspice-discourse-backup/c/data-analysis-using-python/8?page=1.html b/pyspice-discourse-backup/c/data-analysis-using-python/8?page=1.html new file mode 100644 index 00000000..b8222a46 --- /dev/null +++ b/pyspice-discourse-backup/c/data-analysis-using-python/8?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest Data Analysis using Python topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Data Analysis using Python +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/dev/11.html b/pyspice-discourse-backup/c/dev/11.html new file mode 100644 index 00000000..a2e946e6 --- /dev/null +++ b/pyspice-discourse-backup/c/dev/11.html @@ -0,0 +1,304 @@ + + + + + Latest Dev topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Dev +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 123 + + April 27, 2020 +
+ + + + + + + + + + + 3 + + 213 + + February 3, 2022 +
+ + + + + 0 + + 22 + + January 31, 2022 +
+ + + + + + + + + + + 8 + + 274 + + June 17, 2020 +
+ + + + + + + + + + + 6 + + 314 + + June 17, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/feature/13.html b/pyspice-discourse-backup/c/feature/13.html new file mode 100644 index 00000000..708dc4bb --- /dev/null +++ b/pyspice-discourse-backup/c/feature/13.html @@ -0,0 +1,174 @@ + + + + + Latest Feature topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Feature +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 120 + + April 27, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/help/5.html b/pyspice-discourse-backup/c/help/5.html new file mode 100644 index 00000000..5c7c9c4d --- /dev/null +++ b/pyspice-discourse-backup/c/help/5.html @@ -0,0 +1,608 @@ + + + + + Latest Help topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Help +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 122 + + April 27, 2020 +
+ + + + + + + + 1 + + 223 + + May 23, 2021 +
+ + + + + 0 + + 127 + + April 30, 2021 +
+ + + + + 0 + + 133 + + March 9, 2021 +
+ + + + + + + + 1 + + 267 + + March 8, 2021 +
+ + + + + + + + 1 + + 152 + + March 8, 2021 +
+ + + + + 0 + + 115 + + March 3, 2021 +
+ + + + + + + + + + + + + + + + + 7 + + 1224 + + January 15, 2021 +
+ + + + + 0 + + 343 + + October 25, 2020 +
+ + + + + 0 + + 258 + + September 1, 2020 +
+ + + + + + + + 2 + + 281 + + August 17, 2020 +
+ + + + + + + + 1 + + 134 + + July 12, 2020 +
+ + + + + + + + + + + 2 + + 270 + + July 4, 2020 +
+ + + + + + + + 4 + + 245 + + June 22, 2020 +
+ + + + + + + + 1 + + 201 + + June 17, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/help/5.rss b/pyspice-discourse-backup/c/help/5.rss new file mode 100644 index 00000000..b1daf146 --- /dev/null +++ b/pyspice-discourse-backup/c/help/5.rss @@ -0,0 +1,388 @@ + + + + Help - PySpice + https://pyspice.discourse.group/c/help/5 + Topics in the 'Help' category The right place to get help on PySpice + + Tue, 18 May 2021 20:26:00 +0000 + + + Whats PySpice's Advantages? + + Help + Hi friends, why I have use pySpice instead of use direct spice program? Whats advantages of using pyspice? I must a homework like electronic circuits with pyspice but I didn’t find a topic. Can you help me find a topic. How can I do with pyspice?

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/whats-pyspices-advantages/135 + Tue, 18 May 2021 20:26:00 +0000 + No + No + No + pyspice.discourse.group-topic-135 + Whats PySpice's Advantages? +
+ + Can SpiceParser parse subcircuits? + + Help + We want to parse a sp file with a netlist that embeds a subcircuit definition. When we parse it with SpiceParser we noticed that the subcircuit definition is removed. Is there a way to include the subcircuit definition during the parsing process?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/can-spiceparser-parse-subcircuits/133 + Fri, 30 Apr 2021 03:23:54 +0000 + No + No + No + pyspice.discourse.group-topic-133 + Can SpiceParser parse subcircuits? +
+ + Error in running examples + + Help + I’ve just installed PySpice (on Fedora, using pip install PySpice). I’ve downloaded the examples with pyspice-post-installation --download-example and tried to run them. I get a number of errors, but the one that appears most often is:

+

pyspice-post-installation --download-example

+

I googled the problem but couldn’t fix it, grateful for suggestions.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/error-in-running-examples/127 + Tue, 09 Mar 2021 23:43:16 +0000 + No + No + No + pyspice.discourse.group-topic-127 + Error in running examples +
+ + Google COLAB + PySpice + + Help + I trying use PySpice on google Colab, but I fail…
+Some one can tell me if is possible, and how i can do?

+

Aparently… I should but i dont be able to install or reference there the “ngspice dll”

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/google-colab-pyspice/125 + Sun, 07 Mar 2021 02:56:43 +0000 + No + No + No + pyspice.discourse.group-topic-125 + Google COLAB + PySpice +
+ + Read a NgSpice rawfile using PySpice + + Help + Hello guys,

+

I am writing a python script that generates, runs and eventually will read the raw files. The command I use to run the netlist is the following: subprocess.run([path_to_ngspice_executable,'-r','rawfile.raw','-b','-i',my_netlist]) which generates my rawfile.

+

Could you please tell me what PySpice command to use so I can read the generated raw file and plot the distribution of my voltages?

+

Thanks in advance !

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/read-a-ngspice-rawfile-using-pyspice/123 + Wed, 03 Mar 2021 08:40:44 +0000 + No + No + No + pyspice.discourse.group-topic-123 + Read a NgSpice rawfile using PySpice +
+ + Trouble with Libraries + + Help + Hello!

+

To better understand PySpice, I’m working through a very simple circuit involving a voltage source, a resistor, and a 1N4148 Diode. However, I am having trouble with Python recognizing the library I need to bring in the characteristics of the diode. Here is my code:

+

'import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.ticker as ticker

+

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

+

from PySpice.Doc.ExampleTools import find_libraries
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Unit import *
+from PySpice.Physics.SemiConductor import ShockleyDiode

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)

+

circuit = Circuit(‘Diode Characteristic Curve’)

+

circuit.include(spice_library[‘1N4148’])

+

circuit.V(‘input’, ‘in’, circuit.gnd, 10@u_V)
+circuit.R(1, ‘in’, ‘out’, 1@u_Ω) # not required for simulation
+circuit.X(‘D1’, ‘1N4148’, ‘out’, circuit.gnd)’

+

And here is my result:

+

--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-5-ae802129d891> in <module> 20 circuit = Circuit('Diode Characteristic Curve') 21 ---> 22 circuit.include(spice_library['1N4148']) 23 24 circuit.V('input', 'in', circuit.gnd, 10@u_V) /usr/local/lib/python3.8/dist-packages/PySpice/Spice/Library.py in __getitem__(self, name) 105 # print('Library {} not found in {}'.format(name, self._directory)) 106 # self._logger.warn('Library {} not found in {}'.format(name, self._directory)) --> 107 raise KeyError(name) 108 109 ############################################## KeyError: '1N4148'

+

Can anyone help me understand what exactly is going wrong here and how I can correct it?

+

Thanks!

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/trouble-with-libraries/94 + Sun, 25 Oct 2020 20:45:42 +0000 + No + No + No + pyspice.discourse.group-topic-94 + Trouble with Libraries +
+ + Getting started -- RLC example + + Help + Hello everyone! I am new to pyspice and trying to run the example. The issue I’m running into is with rlc-filter.py, the bode plots aren’t working and don’t match what’s in the documentation. Here are screenshots of the plots and the output which hopefully points to the issue.
+


+
+I appreciate any advice on how to fix this!

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/getting-started-rlc-example/77 + Tue, 01 Sep 2020 16:51:09 +0000 + No + No + No + pyspice.discourse.group-topic-77 + Getting started -- RLC example +
+ + Starting with Pyspice + + Help + Hello everyone,

+

I’m very new to PySpice, but I want to learn it. The problem is that starting is complicated and I have not found any tutorials. Do you have any recommendations on how to get started with PySpice?

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/starting-with-pyspice/71 + Sun, 16 Aug 2020 18:30:48 +0000 + No + No + No + pyspice.discourse.group-topic-71 + Starting with Pyspice +
+ + Transfer function on voltage source + + Help + Hi,

+

I am new to Pyspice and I am moving our LTSpice simulations to PySpice. In that simulation we have some transfer functions defined as voltage sources with a transfer function like this:

+

I=V(A_IN) MAG FREQ=(34000.0,-0.386765E-03,-0.191481E-03)(34050.0,-0.415016E-03,-0.187603E-03)

+

Is it posible to implement this in PySpice?

+

Regards

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/transfer-function-on-voltage-source/69 + Sat, 08 Aug 2020 15:49:16 +0000 + No + No + No + pyspice.discourse.group-topic-69 + Transfer function on voltage source +
+ + Looking for two .mod files used in an example code + + Help + Hello. How are you guys doing? I am looking for the model files of the 1N5822 and the irf150 from the buck convertor example in the link below. https://pyspice.fabrice-salvaire.fr/releases/v1.4/examples/switched-power-supplies/buck-converter.html . Thanks for any help that I get.

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/looking-for-two-mod-files-used-in-an-example-code/59 + Fri, 10 Jul 2020 22:35:03 +0000 + No + No + No + pyspice.discourse.group-topic-59 + Looking for two .mod files used in an example code +
+ + Sub-circuit in library issue + + Help + Hi there !

+

I would like to use a spice circuit model (a sub-circuit in a .MOD file) in a circuit created from a spice netlist (a .net file) inside PySpice. Following is a simplistic example that shows the problem with a simple RC sub-circuit. I can’t figure out why the sub-circuit is not found although it is explicitly included with the circuit.include call as in the documentation examples…

+

The RC.py file :

+
import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Spice.Parser import SpiceParser
+from PySpice.Unit import *
+
+spice_library = SpiceLibrary('../models/')
+parser = SpiceParser(path='RC.net')
+circuit = parser.build_circuit()
+circuit.include(spice_library['RC'])
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.ac('dec', 10, 100, 100e3)
+
+

The RC.net circuit file :

+
.title RC Circuit
+V1 VIN 0 AC
+X1 VIN 0 VOUT RC
+.end
+
+

The RC.MOD model file in the ../models directory :

+
* PINOUT 1 2 3
+* PINOUT IN+ IN- OUT
+.subckt RC 1 2 3
+R1 1 3 1k
+C1 3 2 1nF
+.ends
+
+

Runing the python script gives :

+
$ python RC.py
+2020-07-06 15:12:47,850 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Error: unknown subckt: x1 vin 0 vout rc
+2020-07-06 15:12:47,851 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Error: there aren't any circuits loaded.
+Traceback (most recent call last):
+  File "RC.py", line 14, in <module>
+    analysis = simulator.ac('dec', 10, 100, 100e3)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/Simulation.py", line 1161, in ac
+    return self._run('ac', *args, **kwargs)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Simulation.py", line 118, in _run
+    self._ngspice_shared.run()
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Shared.py", line 1168, in run
+    self.exec_command(command)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Shared.py", line 842, in exec_command
+    raise NgSpiceCommandError("Command '{}' failed".format(command))
+PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command 'run' failed
+
+

8 posts - 5 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/sub-circuit-in-library-issue/56 + Mon, 06 Jul 2020 13:20:14 +0000 + No + No + No + pyspice.discourse.group-topic-56 + Sub-circuit in library issue +
+ + .cir to Python classes + + Help + I am completely new to electronics and any kind of circuit modelling. I have a .cir file that I need to turn into python classes so I can carry out precedures like chaining 2 or more subcircuits together and doing monte carlo simulation. The .cir was exported from PSpice. I was wondering, is this possible? To turn .cir to python classes? .cir has subcircuits defined.

+

3 posts - 3 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/cir-to-python-classes/54 + Thu, 02 Jul 2020 13:52:17 +0000 + No + No + No + pyspice.discourse.group-topic-54 + .cir to Python classes +
+ + .param command and formula evaluation + + Help + Hello All,
+being familiar with spice, usually prefer to create netlists in the bootstrapping way like this:

+

from PySpice.Spice.Parser import SpiceParser

+

#######################################

+

+

+

import os
+os.linesep="\n"

+

source=’’’
+.title abc

+

V1 inx 0 DC 2V
+R1 inx out 1k
+R2 out 0 2k
+.end
+‘’’

+

parser = SpiceParser(source=source)
+circuit = parser.build_circuit()

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+#analysis = simulator.dc(V1=slice(Vmin, Vmax,Vstep))
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:5.2f} V’.format(str(node), float(node)))

+

######################################

+

However in Spice Macromodels global parameters should be possible like a netlist in this way:
+######################################
+…
+source=’’’
+.title abc
+.param res=1k
+V1 inx 0 DC 2V
+R1 inx out {res}
+R2 out 0 2k
+.end
+‘’’
+… and so on…

+

Anyway, the parser does not seem to recognize neither the “.param” nor the curled braces.

+

Is there a workaround for this?

+

Kind rgs Martin

+

5 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/param-command-and-formula-evaluation/44 + Fri, 29 May 2020 13:17:57 +0000 + No + No + No + pyspice.discourse.group-topic-44 + .param command and formula evaluation +
+ + Electronic component libraries + + Help + Good afternoon everyone, I am writing to the community to consult a page to find electronic components for pyspice something similar to the page of https://www.snapeda.com/, if anyone has information you are very much appreciated

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/electronic-component-libraries/42 + Thu, 28 May 2020 17:28:43 +0000 + No + No + No + pyspice.discourse.group-topic-42 + Electronic component libraries +
+ + About the Help category + + Help + The right place to get help on PySpice

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-help-category/12 + Mon, 27 Apr 2020 19:31:11 +0000 + Yes + No + No + pyspice.discourse.group-topic-12 + About the Help category +
+
+
diff --git a/pyspice-discourse-backup/c/help/5?page=1.html b/pyspice-discourse-backup/c/help/5?page=1.html new file mode 100644 index 00000000..04deeb25 --- /dev/null +++ b/pyspice-discourse-backup/c/help/5?page=1.html @@ -0,0 +1,144 @@ + + + + + Latest Help topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Help +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/installation/10.html b/pyspice-discourse-backup/c/installation/10.html new file mode 100644 index 00000000..589f7b11 --- /dev/null +++ b/pyspice-discourse-backup/c/installation/10.html @@ -0,0 +1,380 @@ + + + + + Latest Installation topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Installation +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 164 + + April 27, 2020 +
+ + + + + 0 + + 81 + + November 11, 2021 +
+ + + + + + + + 3 + + 255 + + February 5, 2021 +
+ + + + + 0 + + 284 + + January 25, 2021 +
+ + + + + + + + 2 + + 411 + + January 25, 2021 +
+ + + + + + + + 2 + + 689 + + December 30, 2020 +
+ + + + + 1 + + 399 + + December 18, 2020 +
+ + + + + 0 + + 170 + + October 19, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/installation/10.rss b/pyspice-discourse-backup/c/installation/10.rss new file mode 100644 index 00000000..39dc5fa3 --- /dev/null +++ b/pyspice-discourse-backup/c/installation/10.rss @@ -0,0 +1,601 @@ + + + + Installation - PySpice + https://pyspice.discourse.group/c/installation/10 + Topics in the 'Installation' category + + Thu, 11 Nov 2021 13:45:39 +0000 + + + Problems with running simulator + + Installation + Hi every one!
+I am new to PySpice. I was running 1.4.3 ver with ngspice 3.2 and everything was working well.
+My computer did a usual clean up and update.

+

Now the netlist part works fine. But when I call the simulator I get a long error message (I will paste below). I was doing good progress and I am glad to share a 3 phase diode rectifier model which was working well. Until this problem arose. When I did an update I see that the cur ver is 1.5 and installs ngspice 3.4

+

Any help is appreciated. Else will have to go back to LTspice

+

Error msg attached below

+
+

TypeError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit3.simulator(temperature=25, nominal_temperature=25)
+2 simulator.initial_condition(out = 90@u_V)
+3 analysis = simulator.transient(step_time=Vac.period/1000, end_time=Vac.period*6)
+4
+5 res = format_output(analysis)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Netlist.py in simulator(self, *args, **kwargs)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117 “”" This class implements a circuit simulator. Each analysis mode is performed by a method that
+1118 return the measured probes.
+ → 1119
+1120 For ac and transient analyses, the user must specify a list of nodes using the probes key
+1121 argument.

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 cls._instances[ngspice_id] = instance
+451 return instance
+ → 452
+453 ##############################################
+454

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in init(self, ngspice_id, send_data, verbose)
+478 self._library_path = None
+479 self._load_library(verbose)
+ → 480 self._init_ngspice(send_data)
+481
+482 self._is_running = False

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in _load_library(self, verbose)
+511 if ‘SPICE_LIB_DIR’ not in os.environ:
+512 _ = str(Path(self.NGSPICE_PATH).joinpath(‘share’, ‘ngspice’))
+ → 513 os.environ[‘SPICE_LIB_DIR’] = _
+514 # self._logger.warning(‘Set SPICE_LIB_DIR = %s’, _)
+515

+

~\Anaconda3\lib\pathlib.py in new(cls, *args, **kwargs)
+1036 if cls is Path:
+1037 cls = WindowsPath if os.name == ‘nt’ else PosixPath
+ → 1038 self = cls._from_parts(args, init=False)
+1039 if not self._flavour.is_supported:
+1040 raise NotImplementedError(“cannot instantiate %r on your system”

+

~\Anaconda3\lib\pathlib.py in _from_parts(cls, args, init)
+677 # right flavour.
+678 self = object.new(cls)
+ → 679 drv, root, parts = self._parse_args(args)
+680 self._drv = drv
+681 self._root = root

+

~\Anaconda3\lib\pathlib.py in _parse_args(cls, args)
+661 parts += a._parts
+662 else:
+ → 663 a = os.fspath(a)
+664 if isinstance(a, str):
+665 # Force-cast str subclasses to str (issue #21127)

+

TypeError: expected str, bytes or os.PathLike object, not NoneType

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/problems-with-running-simulator/153 + Thu, 11 Nov 2021 13:45:39 +0000 + No + No + No + pyspice.discourse.group-topic-153 + Problems with running simulator +
+ + Getting keyerror while running example + + Installation + As i’m new to pyspice when i am running this example
+https://pyspice.fabrice-salvaire.fr/releases/v1.3/examples/diode/diode-characteristic-curve.html

+

I am getting this keyerror

+

I m using windows 10 64 bit
+Ide : Anaconda python
+Pyspice 1.4.3
+Ngspice 32

+

If any gentlemen has idea how to fix this it ll help me a lot :smiley:

+

4 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/getting-keyerror-while-running-example/119 + Sat, 30 Jan 2021 13:14:32 +0000 + No + No + No + pyspice.discourse.group-topic-119 + Getting keyerror while running example +
+ + Installation example scripts + + Installation + Dear PySpice community, I would like to share some installation example files to illustrate the installation procedure of PySpice on Linux by using apt and pip only.

+

Those files are published as Dockerfile scripts since they allow full automatic machine instantiation with docker.
+They cover both Ubuntu and Debian, using a standard approach using only apt :

+ +

One can also find a more “manual” approach to demonstrate how to properly set the PYTHONPATH and LD_LIBRARY_PATH environment variables :

+ +

The two latter should be useful for those who want to install PySpice on Google Collab.

+

If you have docker on your computer, you can also pull directly the images from Docker Hub :

+ +

Enjoy !

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/installation-example-scripts/117 + Mon, 25 Jan 2021 22:35:44 +0000 + No + No + No + pyspice.discourse.group-topic-117 + Installation example scripts +
+ + Two installation experiences on Windows + + Installation + Windows 10 +

First I tried to install in my base conda environment on Windows 10 64-bit. It could not be installed due to package conflicts and it tried many different things to resolve the conflicts, grinding away at the CPU for two hours, and eventually I killed it.

+

Then I created a new environment specifically for PySpice and installed it:

+
conda create --name pyspice
+conda activate pyspice
+conda install -c conda-forge pyspice
+pyspice-post-installation --install-ngspice-dll
+
+

This last step did not work, however, because it required the
+requests library:

+
ModuleNotFoundError: No module named 'requests'
+
+

So I then did

+
conda install requests
+pyspice-post-installation --install-ngspice-dll
+pyspice-post-installation --check-install
+
+

And it worked. I reported the dependency problem here: https://github.com/FabriceSalvaire/PySpice/issues/266

+

Windows 7

+

Now I’m doing the same procedure on a Windows 7 machine (I know, I know, it’s obsolete). The install command showed no errors on the command line, but I did get a pop up error:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

I haven’t seen this error before, but the install command worked so I’m ignoring it.

+

Then I try

+
pyspice-post-installation --install-ngspice-dll
+
+

Ah, now I’m getting the same error:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

and if I run the check:

+
pyspice-post-installation --check-install
+
+

I get the same error dialog:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

Tried System File Checker:

+
λ sfc /scannow
+
+Beginning system scan.  This process will take some time.
+
+Beginning verification phase of system scan.
+Verification 100% complete.
+
+Windows Resource Protection did not find any integrity violations.
+
+

Searching my machine, it does not have api-ms-win-core-path-l1-1-0.dll anywhere. Maybe this is a Windows 10 file only. (Nope, not present on Windows 10 machine, either.)

+

Trying to install jupyterlab also doesn’t work well. Does PySpice have some weird requirements/dependencies that prevent conda from installing it alongside other things?

+
Collecting package metadata (current_repodata.json): done
+Solving environment: failed with initial frozen solve. Retrying with flexible solve.
+Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
+Collecting package metadata (repodata.json): done
+Solving environment: failed with initial frozen solve. Retrying with flexible solve.
+
+

Oh if I do it as conda install jupyterlab voila instead of using conda-forge, it works fine

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/two-installation-experiences-on-windows/107 + Wed, 16 Dec 2020 15:28:34 +0000 + No + No + No + pyspice.discourse.group-topic-107 + Two installation experiences on Windows +
+ + Load_circuit failing for some reasons + + Installation + +
    +
  • OS: MacOS Catilina (version 10.15.7)
  • +
  • Python framework with PyCharm + Conda environment
  • +
  • PySpice installed with Conda (version 1.4.3)
  • +
  • libngspice installed with Conda
  • +
  • NGSPICE installed with homebrew (version 33) +
      +
    • location: /usr/local/bin/ngspice
    • +
    • functionality check: NGSPICE works from terminal and does simulate a circuit
    • +
    +
  • +
+
+

Hi,

+

this is my first test with the “PySpice” flow. I went through the explained installation steps:

+ + +

By running the “resistor-bridge.py” example:

+ + +

I get the following error:

+


+PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command ‘run’ failed
+…

+

By placing a breakpoint and debugging the code I see that the failing point is at (every line nested hierarchically):

+

analysis = simulator.operating_point()
+return self._run(‘operating_point’, *args, **kwargs)
+self._ngspice_shared.run()
+self.exec_command(command)
+raise NgSpiceCommandError(“Command ‘{}’ failed”.format(command))

+

And is due to stderr = ‘Error: there aren’t any circuits loaded.’

+

By debugging further I could nail down that the def run() method of the Simulation class fails because the run command after the load_circuit command complains that the circuit wasn’t loaded.

+
def _run(self, analysis_method, *args, **kwargs):
+
+    super()._run(analysis_method, *args, **kwargs)
+
+    self._ngspice_shared.destroy()
+    # Fixme: Error: circuit not parsed.
+    self._ngspice_shared.load_circuit(str(self))
+    self._ngspice_shared.run()
+    self._logger.debug(str(self._ngspice_shared.plot_names))
+    self.reset_analysis()
+
+    plot_name = self._ngspice_shared.last_plot
+    if plot_name == 'const':
+        raise NameError('Simulation failed')
+
+    return self._ngspice_shared.plot(self, plot_name).to_analysis()
+
+

So the load_circuit method seems to not load the circuit properly in the sim, any idea why? (although it does execute it and no error is raised within that method).

+

I tried also the listing() method to query the circuit description back and also doesn’t seem to provide anything back.

+

Actually the only communication with the simulator seems to be successful is the “version -f” command which returns the valuable infos from it.

+

Thanks,
+Andrea

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/load-circuit-failing-for-some-reasons/96 + Mon, 02 Nov 2020 20:14:10 +0000 + No + No + No + pyspice.discourse.group-topic-96 + Load_circuit failing for some reasons +
+ + Install Pyspice on Raspberry Pi 4 ERROR + + Installation + Hello Everyone!
+I’m running into a problem, i want to install PySpice on Raspberry Pi 4 which runs Raspbian OS. I have read the doumentation that wrote, it is supported on Linux, Windos 64 and MAC.
+I have followed the install instructions after i typed : pip3 install PySpice the following error message i got:

+

Defaulting to user installation because normal site-packages is not writeable
+Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
+Collecting PySpice
+Using cached PySpice-1.4.3-py2.py3-none-any.whl (144 kB)
+Collecting scipy>=1.4
+Downloading scipy-1.5.3.tar.gz (25.2 MB)
+|################################| 25.2 MB 28 kB/s
+Installing build dependencies … \Ledone
+Getting requirements to build wheel … done
+Preparing wheel metadata … error
+ERROR: Command errored out with exit status 1:
+command: /usr/bin/python /home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpv39ep59r
+cwd: /tmp/pip-install-_1dtpvzc/scipy
+Complete output (139 lines):
+lapack_opt_info:
+lapack_mkl_info:
+customize UnixCCompiler
+libraries mkl_rt not found in [’/usr/local/lib’, ‘/usr/lib’, ‘/usr/lib/arm-linux-gnueabihf’]
+NOT AVAILABLE

+
openblas_lapack_info:
+customize UnixCCompiler
+customize UnixCCompiler
+  libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+openblas_clapack_info:
+customize UnixCCompiler
+customize UnixCCompiler
+  libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+flame_info:
+customize UnixCCompiler
+  libraries flame not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+atlas_3_10_threads_info:
+Setting PTATLAS=ATLAS
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
+  NOT AVAILABLE
+
+atlas_3_10_info:
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_3_10_info'>
+  NOT AVAILABLE
+
+atlas_threads_info:
+Setting PTATLAS=ATLAS
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_threads_info'>
+  NOT AVAILABLE
+
+atlas_info:
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_info'>
+  NOT AVAILABLE
+
+accelerate_info:
+  NOT AVAILABLE
+
+lapack_info:
+customize UnixCCompiler
+  libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+lapack_src_info:
+  NOT AVAILABLE
+
+  NOT AVAILABLE
+
+setup.py:460: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-modern-metadata-yx7fyy34'), proceeding with generating Cython sources and expanding templates
+  warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
+Running from SciPy source directory.
+/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: UserWarning:
+    Lapack (http://www.netlib.org/lapack/) libraries not found.
+    Directories to search for the libraries can be specified in the
+    numpy/distutils/site.cfg file (section [lapack]) or by setting
+    the LAPACK environment variable.
+  if getattr(self, '_calc_info_{}'.format(lapack))():
+/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: UserWarning:
+    Lapack (http://www.netlib.org/lapack/) sources not found.
+    Directories to search for the sources can be specified in the
+    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
+    the LAPACK_SRC environment variable.
+  if getattr(self, '_calc_info_{}'.format(lapack))():
+Traceback (most recent call last):
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
+    main()
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
+    json_out['return_val'] = hook(**hook_input['kwargs'])
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
+    return hook(metadata_directory, config_settings)
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
+    self.run_setup()
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 253, in run_setup
+    super(_BuildMetaLegacyBackend,
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 145, in run_setup
+    exec(compile(code, __file__, 'exec'), locals())
+  File "setup.py", line 583, in <module>
+    setup_package()
+  File "setup.py", line 579, in setup_package
+    setup(**metadata)
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/core.py", line 137, in setup
+    config = configuration()
+  File "setup.py", line 477, in configuration
+    raise NotFoundError(msg)
+numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.
+----------------------------------------
+
+

ERROR: Command errored out with exit status 1: /usr/bin/python /home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpv39ep59r Check the logs for full command output.

+

Is it because i have ARM Cortex-A72 architecture and not x64? Or is it because Raspbian and not exactly Linux? But raspbian based on Linux…

+

Thanks for all answers!
+Best regards,
+Daniel

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/install-pyspice-on-raspberry-pi-4-error/90 + Mon, 19 Oct 2020 17:38:42 +0000 + No + No + No + pyspice.discourse.group-topic-90 + Install Pyspice on Raspberry Pi 4 ERROR +
+ + Linux installation of libngspice + + Installation + Hi,

+

Im having trouble installing libngspice on ubuntu 19.04 with anaconda v4.8.2.
+I have ngpsice installed (sudo apt-get install ngspice).
+Then I’m following instructions on pyspice install

+

Im happy to use anaconda so I skipped to section 4.2.2
+However the following commands run for many hours without success

+
+

conda install -c conda-forge ngspice-lib # optional
+conda install -c conda-forge pyspice

+
+

with messages like:

+
+

Collecting package metadata (current_repodata.json): done
+Solving environment: /
+The environment is inconsistent, please check the package plan carefully
+The following packages are causing the inconsistency:
+:::::

+
+

Trying the other command seems to work.

+
+

pip install PySpice

+
+

but this one doesn’t include libngspice.

+

Going back to step 4.2.1
+I downloaded a tar of the libngspice but it’s a tar’d directory not a shared object (.so).
+There’s no instructions in that directory on how to compile it… or where I should
+place it for pyspice?

+

I found a similar question on this pyspice forum and I tried

+
+

inv ngspice.install
+::::
+configure: error: Couldn’t find GNU readline headers.

+
+

I guess I need to do something like

+
+

sudo apt-get install lib64readline

+
+

But I’ve not been able to locate that package so far…
+Any ideas? I don’t think I’m going in the right direction?

+

A+

+

Damian

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/linux-installation-of-libngspice/84 + Fri, 25 Sep 2020 14:59:25 +0000 + No + No + No + pyspice.discourse.group-topic-84 + Linux installation of libngspice +
+ + About the Installation category + + Installation + (Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-installation-category/17 + Mon, 27 Apr 2020 19:49:08 +0000 + Yes + No + No + pyspice.discourse.group-topic-17 + About the Installation category +
+
+
diff --git a/pyspice-discourse-backup/c/installation/10?page=1.html b/pyspice-discourse-backup/c/installation/10?page=1.html new file mode 100644 index 00000000..4bf0b8a1 --- /dev/null +++ b/pyspice-discourse-backup/c/installation/10?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest Installation topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Installation +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/ngspice/6.html b/pyspice-discourse-backup/c/ngspice/6.html new file mode 100644 index 00000000..e09a1b56 --- /dev/null +++ b/pyspice-discourse-backup/c/ngspice/6.html @@ -0,0 +1,317 @@ + + + + + Latest NgSpice topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + NgSpice +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 158 + + April 27, 2020 +
+ + + + + 0 + + 90 + + August 9, 2021 +
+ + + + + 1 + + 145 + + March 24, 2021 +
+ + + + + 1 + + 257 + + September 1, 2020 +
+ + + + + 1 + + 223 + + April 30, 2020 +
+ + + + + + + + 1 + + 622 + + April 30, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/ngspice/6.rss b/pyspice-discourse-backup/c/ngspice/6.rss new file mode 100644 index 00000000..fad28d63 --- /dev/null +++ b/pyspice-discourse-backup/c/ngspice/6.rss @@ -0,0 +1,275 @@ + + + + NgSpice - PySpice + https://pyspice.discourse.group/c/ngspice/6 + Topics in the 'NgSpice' category + + Mon, 09 Aug 2021 06:01:08 +0000 + + + Library import corner analysis + + NgSpice + Hello!

+

I am not familiar with English so if there is something not clear, please ask me!!

+

I am trying to import library file using corner analysis
+The code below is what I wish to use in NgSpice text

+
.lib 'mm018.l' TT
+
+

Since there is “TT” added for typical type analysis,
+I can’t use the library import using the code below in pyspice

+
spice_library = SpiceLibrary('./library_to_add')
+
+

I have no idea how I should solve this problem, please help me

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/library-import-corner-analysis/143 + Mon, 09 Aug 2021 06:01:08 +0000 + No + No + No + pyspice.discourse.group-topic-143 + Library import corner analysis +
+ + NgSpice Options Help + + NgSpice + How do you use the simulation options in a simulation? For example how does one call up any of the options in chapter 15.1 of the NgSpice users guide.

+

Say I want to change the transient solver to METHOD=‘Gear’ how would I?

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/ngspice-options-help/131 + Sun, 21 Mar 2021 01:18:42 +0000 + No + No + No + pyspice.discourse.group-topic-131 + NgSpice Options Help +
+ + How to measure voltage and current in pyspice + + NgSpice + hi,everybody!

+

I’ve built a memristor model in Pspice,The model can run .I wanted it to run in pyspice, but there was an error.

+

In PSpice, the following statement is OK :
+Emem plus aux value={-I(Emem)V(x)(1000-10)}

+

But in pyspice,An error occurred.

+

NameError: name ‘V’ is not defined

+

The reason is that V (x) and I (EMEM) have problems.How can I solve this problem?

+

Thank you very much!

+

Environment (windows10, Python 3.2, PySpice 1.4.3, NGspice)

+

Expected Behaviour

+

Actual Behaviour

+

Steps to reproduce the behaviour

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-measure-voltage-and-current-in-pyspice/74 + Mon, 24 Aug 2020 11:59:27 +0000 + No + No + No + pyspice.discourse.group-topic-74 + How to measure voltage and current in pyspice +
+ + Relatively accurate component (and board) thermal simulations? + + NgSpice + After playing around with SkiDL+NgSpice on SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs, I wonder what’s the recommended/best/suitable way to go about simulating thermodynamics on a circuit. Talking with an expert colleague he recommended the following theoretical approach:

+

https://lpsa.swarthmore.edu/Systems/Thermal/SysThermalModel.html

+

Essentially I would like to have a way to “heat map” a circuit pretty much like a FLIR camera does but via simulation/software… is it possible with NgSpice alone? Or would this require more ammo with FEA modelling or the like?

+

I would like to know if somebody has attempted this successfully and has good experience/code to share? :slight_smile:

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/relatively-accurate-component-and-board-thermal-simulations/28 + Thu, 30 Apr 2020 22:42:47 +0000 + No + No + No + pyspice.discourse.group-topic-28 + Relatively accurate component (and board) thermal simulations? +
+ + SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs + + NgSpice + Hi folks, this seems to be the first post over this forum, hopefully it’s not too soon to start asking questions? :slight_smile:

+

I’m extending a bit one of the SKiDL simulation tutorials, as presented in this Jupyter notebook with a simple resistor (among other more complex examples):

+ + +

My intention is to extend the single resistor example with a netlist of several resistors in parallel (a 19x19 matrix), something like this:

+
#!/usr/bin/env python
+
+from skidl.pyspice import R, V, gnd, u_V
+from skidl.pyspice import u_Ohm, u_kOhm
+from skidl.pyspice import generate_netlist, reset, lib_search_paths, node
+
+reset()  # This will clear any previously defined circuitry.
+
+# Voltage Source
+vs = V(ref="VS", dc_value = 1 @ u_V)
+
+rnet = []
+
+# Create several resistors.
+rnet = 19*19*R(value = 1.7 @ u_kOhm)
+
+# Connect the nets and resistors.
+vs['p'] += [rnet[n][1] for n in range(0, 19*19)]
+gnd += [rnet[n][2] for n in range(0, 19*19)]
+gnd += vs['n']
+
+# Simulate the circuit.
+circ = generate_netlist()              # Translate the SKiDL code into a PyCircuit Circuit object.
+sim = circ.simulator()                 # Create a simulator for the Circuit object.
+dc_vals = sim.dc(VS=slice(1, 24, 1))  # Run a DC simulation where the voltage ramps from 1 to 12V by 1V increments.
+
+# Get the voltage applied to the resistor and the current coming out of the voltage source.
+voltage = dc_vals[node(vs['p'])]
+current = -dc_vals['VS']
+
+# Print a table showing the current through the resistor for the various applied voltages.
+print('{:^7s}{:^7s}{:^7s}'.format('V', ' I (A)', "P (W)"))
+print('='*25)
+for v, i, p in zip(voltage.as_ndarray(), current.as_ndarray(), voltage.as_ndarray()*current.as_ndarray()):
+    print('{:6.2f} {:6.2f} {:6.2f}'.format(v, i, p))
+
+

Unfortunately the output looks something like this:

+
$ ./skidl_sim.py
+
+No errors or warnings found during netlist generation.
+
+warning, can't find model at
+Warning: r1: resistance to low, set to 1 mOhm
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Note: Starting dynamic gmin stepping
+Trying gmin =   1.0000E-03 Note: One successful gmin step
+Trying gmin =   1.0000E-04 Note: One successful gmin step
+Trying gmin =   1.0000E-05 Note: One successful gmin step
+Trying gmin =   1.0000E-06 Note: One successful gmin step
+Trying gmin =   1.0000E-07 Note: One successful gmin step
+Trying gmin =   1.0000E-08 Note: One successful gmin step
+Trying gmin =   1.0000E-09 Note: One successful gmin step
+Trying gmin =   1.0000E-10 Note: One successful gmin step
+Trying gmin =   1.0000E-11 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: Dynamic gmin stepping failed
+Note: Starting source stepping
+Supplies reduced to   0.0000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Trying gmin =   1.0000E-02 Note: One successful gmin step
+Trying gmin =   1.0000E-03 Note: One successful gmin step
+Trying gmin =   1.0000E-04 Note: One successful gmin step
+Trying gmin =   1.0000E-05 Note: One successful gmin step
+Trying gmin =   1.0000E-06 Note: One successful gmin step
+Trying gmin =   1.0000E-07 Note: One successful gmin step
+Trying gmin =   1.0000E-08 Note: One successful gmin step
+Trying gmin =   1.0000E-09 Note: One successful gmin step
+Trying gmin =   1.0000E-10 Note: One successful gmin step
+Trying gmin =   1.0000E-11 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Note: One successful source step
+Supplies reduced to   0.1000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Supplies reduced to   0.0000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: source stepping failed
+doAnalyses: iteration limit reached
+run simulation(s) aborted
+   V    I (A)  P (W)
+=========================
+
+

Can anybody let me know what’s going on? Which syntax should I be using to define that resistor “network” so that ngspice accepts it as well-defined?

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/skidl-ngspice-via-pyspice-simulating-a-simple-parallel-resistors-circuits-power-outputs/26 + Thu, 30 Apr 2020 15:01:26 +0000 + No + No + No + pyspice.discourse.group-topic-26 + SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs +
+ + About the NgSpice category + + NgSpice + (Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-ngspice-category/13 + Mon, 27 Apr 2020 19:44:26 +0000 + Yes + No + No + pyspice.discourse.group-topic-13 + About the NgSpice category +
+
+
diff --git a/pyspice-discourse-backup/c/ngspice/6?page=1.html b/pyspice-discourse-backup/c/ngspice/6?page=1.html new file mode 100644 index 00000000..f4e0d60c --- /dev/null +++ b/pyspice-discourse-backup/c/ngspice/6?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest NgSpice topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + NgSpice +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/site-feedback/2.html b/pyspice-discourse-backup/c/site-feedback/2.html new file mode 100644 index 00000000..e06bf972 --- /dev/null +++ b/pyspice-discourse-backup/c/site-feedback/2.html @@ -0,0 +1,204 @@ + + + + + Latest Site Feedback topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Site Feedback +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 111 + + April 27, 2020 +
+ + + + + 0 + + 128 + + April 27, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/uncategorized/1.html b/pyspice-discourse-backup/c/uncategorized/1.html new file mode 100644 index 00000000..ca68b7d5 --- /dev/null +++ b/pyspice-discourse-backup/c/uncategorized/1.html @@ -0,0 +1,559 @@ + + + + + Latest Uncategorized topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Uncategorized +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 178 + + April 27, 2020 +
+ + + + + + + + 1 + + 91 + + November 11, 2021 +
+ + + + + + + + 1 + + 92 + + November 11, 2021 +
+ + + + + + + + 5 + + 117 + + October 4, 2021 +
+ + + + + + + + 2 + + 86 + + September 29, 2021 +
+ + + + + 0 + + 83 + + May 28, 2021 +
+ + + + + 0 + + 122 + + December 19, 2020 +
+ + + + + + + + 1 + + 219 + + December 2, 2020 +
+ + + + + 0 + + 227 + + November 24, 2020 +
+ + + + + 0 + + 134 + + November 16, 2020 +
+ + + + + 0 + + 175 + + September 29, 2020 +
+ + + + + 0 + + 160 + + August 7, 2020 +
+ + + + + 0 + + 167 + + August 1, 2020 +
+ + + + + + + + + + + 6 + + 763 + + June 17, 2020 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/uncategorized/1.rss b/pyspice-discourse-backup/c/uncategorized/1.rss new file mode 100644 index 00000000..6e218977 --- /dev/null +++ b/pyspice-discourse-backup/c/uncategorized/1.rss @@ -0,0 +1,371 @@ + + + + Uncategorized - PySpice + https://pyspice.discourse.group/c/uncategorized/1 + Topics in the 'Uncategorized' category + + Mon, 27 Sep 2021 20:08:15 +0000 + + + Howto: Transient analysis + + Uncategorized + I want to do a transient analysis of a square wave.

+
    +
  1. How do I do a transient analysis and plot the output?
  2. +
  3. How do I implement a square wave?
  4. +
+

I found nothing in the examples. Thanks for your help,
+Michael

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/howto-transient-analysis/150 + Mon, 27 Sep 2021 20:08:15 +0000 + No + No + No + pyspice.discourse.group-topic-150 + Howto: Transient analysis +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + Uncategorized + I am new with pyspice. I want to add a behavioral voltage source to my circuit. To write its expression we need voltage across two points x and y. For example v=2*Voltage(x,y)

+

Will anyone share the syntax in pyspice?
+Thank you.

+

6 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147 + Fri, 10 Sep 2021 13:08:01 +0000 + No + No + No + pyspice.discourse.group-topic-147 + How to get voltage acrros two points to write behavioral voltage source expression? +
+ + Divide one AC-analysis waveform by another + + Uncategorized + I have run an AC analysis in PySpice.
+I have found the waveform for input (source) voltage, and input (source) current.
+Now I would like to find the impedance waveform (voltage/current)
+How can I divide one waveform by another?

+

Thanks for your help!

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/divide-one-ac-analysis-waveform-by-another/140 + Fri, 28 May 2021 12:53:00 +0000 + No + No + No + pyspice.discourse.group-topic-140 + Divide one AC-analysis waveform by another +
+ + Extract array of complex numbers from waveform + + Uncategorized + Hi

+

I am just getting started with PySpice.

+

I have run an AC analysis on a netlist using PySpice, and have extracted my waveforms, but would like to convert these into a numpy array of complex numbers - how do I do this?

+

I want to do further mathematical analysis on the PySpice Waveform output.

+

Thanks

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/extract-array-of-complex-numbers-from-waveform/139 + Fri, 28 May 2021 12:50:00 +0000 + No + No + No + pyspice.discourse.group-topic-139 + Extract array of complex numbers from waveform +
+ + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' + + Uncategorized + Hi

+

I am just getting started with using PySpice.

+

I have extracted voltage/current values from a PySpice analysis, and would like to analyze these using other Python functions.

+

But all of my values are now of type class ‘PySpice.Unit.Unit.UnitValue’.

+

How can I remove the units, so that these are just normal float numbers?

+

Thanks

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138 + Fri, 28 May 2021 12:44:13 +0000 + No + No + No + pyspice.discourse.group-topic-138 + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' +
+ + Access to Diode Parameters + + Uncategorized + Hello,

+

when working with pyspice 1.3 it was possible for me to change device parameters in thie way described below. With 1.4 this does not seem to work any more. Is there a new or alternate syntax?

+

#############################
+import os
+os.linesep="\n"

+

source=’’’
+.title xxx

+

V1 N001 0 1 AC 1
+D1 N001 0 john

+

.model john D (Is=4.352e-9 Rs=0 N=1.906)
+.end

+

‘’’

+

parser = SpiceParser(source=source)
+circuit = parser.build_circuit()

+

circuit.john._parameters[‘Is’] = 3e-08

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.dc(V1=slice(0.1, 1,0.01))

+

#######################################

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/access-to-diode-parameters/108 + Sat, 19 Dec 2020 17:38:44 +0000 + No + No + No + pyspice.discourse.group-topic-108 + Access to Diode Parameters +
+ + Bode plot with sinusoidal Current Source + + Uncategorized + Hi,

+

I successfully ran this example: https://pyspice.fabrice-salvaire.fr/releases/v1.4/examples/filter/low-pass-rc-filter.html

+

I am however interested in replacing the voltage source with a current source and still get a bode plot that compares the output voltage to input current. Just replacing the voltage source with a current source as follows gives me an error.

+

circuit.SinusoidalCurrentSource(‘input’, ‘in’, circuit.gnd, amplitude=1@u_uA)

+

NgSpiceCommandError : Command ‘run’ failed

+

Thank you in advance

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/bode-plot-with-sinusoidal-current-source/103 + Tue, 24 Nov 2020 12:13:04 +0000 + No + No + No + pyspice.discourse.group-topic-103 + Bode plot with sinusoidal Current Source +
+ + Is PySpice 1.4.2 compatible with Ngspice 33? + + Uncategorized + Hello Community,

+

I have set up PySpice 1.4.2 through a virtual environment and brew installed Ngspice and libngspice on Mac 0S X. However, “pyspice-post-installation --check-install” tells me that Ngspice version 33 is not supported.

+

Please advise.

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/is-pyspice-1-4-2-compatible-with-ngspice-33/101 + Mon, 23 Nov 2020 02:57:05 +0000 + No + No + No + pyspice.discourse.group-topic-101 + Is PySpice 1.4.2 compatible with Ngspice 33? +
+ + Using the Skywater PDK with SKiDL/PySpice + + Uncategorized + I’ve published a Jupyter notebook of my explorations using SKiDL and PySpice with the open Skywater PDK.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/using-the-skywater-pdk-with-skidl-pyspice/98 + Mon, 16 Nov 2020 18:41:20 +0000 + No + No + No + pyspice.discourse.group-topic-98 + Using the Skywater PDK with SKiDL/PySpice +
+ + How to define multiple BJTs in the same circuit? + + Uncategorized + If I try to define a pnp and an npn BJT in the same circuit:

+
circuit.BJT(1, 'in', 'in', 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(2, 2, 'in', 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(5, 'out', 2, 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(6, 4, 5, 'out', model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(3, 'in', 4, 'in', model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'pnp', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(4, 2, 'in', 4, model='bjt') # Q is mapped to BJT !
+circuit.model('bjt', 'pnp', bf=80, cjc=pico(5), rb=100)
+
+

PySpice doesn’t allow me to call model() twice:

+
---------------------------------------------------------------------------
+NameError                                 Traceback (most recent call last)
+<ipython-input-2-c7415312c779> in <module>
+     15 
+     16 circuit.BJT(2, 2, 'in', 0, model='bjt')# Q is mapped to BJT !
+---> 17 circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+     18 
+     19 circuit.BJT(5, 'out', 2, 0, model='bjt')# Q is mapped to BJT !
+
+~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Netlist.py in model(self, name, 
+modele_type, **parameters)
+   1002             self._models[model.name] = model
+   1003         else:
+-> 1004             raise NameError("Model name {} is already defined".format(name))
+   1005 
+   1006         return model
+
+NameError: Model name bjt is already defined
+
+

What is the proper way to do this?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-define-multiple-bjts-in-the-same-circuit/86 + Tue, 29 Sep 2020 13:52:47 +0000 + No + No + No + pyspice.discourse.group-topic-86 + How to define multiple BJTs in the same circuit? +
+ + Large archive of SPICE models/subcircuits + + Uncategorized + I posted a message on the SKiDL forum about using SKiDL/PySpice with a large archive of SPICE models.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/large-archive-of-spice-models-subcircuits/67 + Fri, 07 Aug 2020 21:20:44 +0000 + No + No + No + pyspice.discourse.group-topic-67 + Large archive of SPICE models/subcircuits +
+ + How to modify a BJT's parameters? + + Uncategorized + I have checked the API documentation but didn’t find an answer or example.

+
+

circuit = Circuit(‘Transistor’)
+source = circuit.SinusoidalVoltageSource(‘in’, ‘in’, circuit.gnd, amplitude=.5@u_V, frequency=1@u_kHz)
+Vpower = circuit.V(‘power’, 5, circuit.gnd, 15@u_V)
+R1 = circuit.R(1, 5, 2, 100@u_kΩ)
+RC = circuit.R(‘C’, 5, 4, 10@u_kΩ)
+C2 = circuit.C(2, 4, ‘out’, 10@u_uF)
+C1 = circuit.C(1, ‘in’, 2, 10@u_uF)

+

Q1= circuit.BJT(1, 4, 2, 3, model=‘bjt’) # Q is mapped to BJT !
+circuit.model(‘bjt’, ‘npn’, bf=80, cjc=pico(5), rb=100) #rb: Base Resistor

+
+

How to change BJT’s rb in this case?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-modify-a-bjts-parameters/64 + Sat, 01 Aug 2020 13:19:59 +0000 + No + No + No + pyspice.discourse.group-topic-64 + How to modify a BJT's parameters? +
+ + OSError: cannot load library 'libngspice.so': + + Uncategorized + Good afternoon community, I am writing to you because I have encountered the following error trying to simulate the following filter that appears in the documentation.

+

https://pyspice.fabrice-salvaire.fr/examples/filter/low-pass-rc-filter.html

+

The error is as follows.
+2020-05-23 00:45:37,954 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.new_instance - INFO - New instance for id 0
+2020-05-23 00:45:37,955 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._load_library - WARNING - Set locale LC_NUMERIC to C

+
---------------------------------------------------------------------------
+
+OSError                                   Traceback (most recent call last)
+
+<ipython-input-6-475d4280ae1b> in <module>()
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+      2 analysis = simulator.ac(start_frequency=1@u_Hz, stop_frequency=1@u_MHz, number_of_points=10,  variation='dec')
+
+8 frames
+
+/usr/local/lib/python3.6/dist-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
+    825         if first_error is not None:
+    826             msg = "%s.  Additionally, %s" % (first_error, msg)
+--> 827         raise OSError(msg)
+    828     return backend.load_library(path, flags)
+    829 
+
+OSError: cannot load library 'libngspice.so': libngspice.so: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libngspice.so'
+
+

I have installed all the dependencies, although I have run out of ideas, I am starting in the world of programming, however, they asked me for a job to simulate filters in the university. I need your help, if possible, a lot of fat in advance

+

7 posts - 3 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/oserror-cannot-load-library-libngspice-so/37 + Sat, 23 May 2020 00:47:20 +0000 + No + No + No + pyspice.discourse.group-topic-37 + OSError: cannot load library 'libngspice.so': +
+ + Welcome to Discourse + + Uncategorized + Welcome to the PySpice Forum !

+

This forum is the right place to chat about PySpice between users and to get help.

+

This forum is provided freely by https://www.discourse.org as a part of its program to support open source projects.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/welcome-to-discourse/7 + Mon, 27 Apr 2020 09:02:31 +0000 + Yes + No + No + pyspice.discourse.group-topic-7 + Welcome to Discourse +
+
+
diff --git a/pyspice-discourse-backup/c/uncategorized/1?page=1.html b/pyspice-discourse-backup/c/uncategorized/1?page=1.html new file mode 100644 index 00000000..9bdc9878 --- /dev/null +++ b/pyspice-discourse-backup/c/uncategorized/1?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest Uncategorized topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Uncategorized +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/xyce/7.html b/pyspice-discourse-backup/c/xyce/7.html new file mode 100644 index 00000000..9be40305 --- /dev/null +++ b/pyspice-discourse-backup/c/xyce/7.html @@ -0,0 +1,205 @@ + + + + + Latest Xyce topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Xyce +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+ + + + + 0 + + 127 + + April 27, 2020 +
+ + + + + + + + 1 + + 205 + + November 26, 2021 +
+
+ +
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/c/xyce/7.rss b/pyspice-discourse-backup/c/xyce/7.rss new file mode 100644 index 00000000..f9ec1705 --- /dev/null +++ b/pyspice-discourse-backup/c/xyce/7.rss @@ -0,0 +1,67 @@ + + + + Xyce - PySpice + https://pyspice.discourse.group/c/xyce/7 + Topics in the 'Xyce' category + + Fri, 18 Sep 2020 23:01:18 +0000 + + + Looking for a Xyce Example + + Xyce + Hi, I have installed Xyce, NGSpice and PySpice and everything is almost working… except, when I run on iPython (actually Anaconda Spyder) then I stumbled into a cdef problem on duplidate definition of ngcomplex. I can see on github some discussion, but not clear to me how to move forward on it. No mater, I have Xyce. But then I was stumbling at the start [again]. The documentation says to set an attribute

+

PySpice.Spice.Xyce.Server.XyceServer.XYCE_COMMAND = “C:\Program Files\Xyce 7.1 OPENSOURCE\bin\Xyce.exe”

+

But where do I type that? It seems to be an attribute of a class or something?? So then I try
+… = simulator(xyce_command=r"C:\Program Files\Xyce 7.1 OPENSOURCE\bin\Xyce.exe", simulator=‘xyce-serial’,…)

+

and that one dies with file not found, although it is the correct command to launch Xyce.

+

What finally worked (yeh!) was to edit by hand the PySpice source code and find where XyceCommand was defined and wow. I’m amazed. Works perfectly :slight_smile:

+

But was there a cleaner way that I could have done this?

+

Thanks so much for putting this product together. I’m excited to check it out further.

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/looking-for-a-xyce-example/82 + Fri, 18 Sep 2020 23:01:18 +0000 + No + No + No + pyspice.discourse.group-topic-82 + Looking for a Xyce Example +
+ + About the Xyce category + + Xyce + (Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/about-the-xyce-category/14 + Mon, 27 Apr 2020 19:45:07 +0000 + Yes + No + No + pyspice.discourse.group-topic-14 + About the Xyce category +
+
+
diff --git a/pyspice-discourse-backup/c/xyce/7?page=1.html b/pyspice-discourse-backup/c/xyce/7?page=1.html new file mode 100644 index 00000000..18afcdef --- /dev/null +++ b/pyspice-discourse-backup/c/xyce/7?page=1.html @@ -0,0 +1,142 @@ + + + + + Latest Xyce topics - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+ + + + +

+ + + Xyce +

+
+ + +
+ + + + + + + + + + + + + + + + + +
TopicRepliesViewsActivity
+
+ + + + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/categories.html b/pyspice-discourse-backup/categories.html new file mode 100644 index 00000000..2dda5051 --- /dev/null +++ b/pyspice-discourse-backup/categories.html @@ -0,0 +1,305 @@ + + + + + PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryTopics
+
+ + +

+ + Uncategorized + +

+
+
+
+
14
+
+
+ + +

+ + Help + +

+
The right place to get help on PySpice
+
+
+
14
+
+
+ + +

+ + NgSpice + +

+
+
+
+
5
+
+
+ + +

+ + Xyce + +

+
+
+
+
1
+
+ + +
1
+
+ + +
10
+
+
+ + +

+ + Installation + +

+
+
+
+
7
+
+
+ + +

+ + Bug + +

+
+
+
+
3
+
+
+ + +

+ + Feature + +

+
+
+
+
0
+
+
+ + +

+ + Dev + +

+
+
+
+
4
+
+
+ + +

+ + Site Feedback + +

+

Discussion about this site, its organization, how it works, and how we can improve it.

+
+
+
1
+
+
+ + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/index.html b/pyspice-discourse-backup/index.html new file mode 100644 index 00000000..2bf53e2a --- /dev/null +++ b/pyspice-discourse-backup/index.html @@ -0,0 +1,305 @@ + + + + + PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryTopics
+
+ + +

+ + Uncategorized + +

+
+
+
+
14
+
+
+ + +

+ + Help + +

+
The right place to get help on PySpice
+
+
+
14
+
+
+ + +

+ + NgSpice + +

+
+
+
+
5
+
+
+ + +

+ + Xyce + +

+
+
+
+
1
+
+ + +
1
+
+ + +
10
+
+
+ + +

+ + Installation + +

+
+
+
+
7
+
+
+ + +

+ + Bug + +

+
+
+
+
3
+
+
+ + +

+ + Feature + +

+
+
+
+
0
+
+
+ + +

+ + Dev + +

+
+
+
+
4
+
+
+ + +

+ + Site Feedback + +

+

Discussion about this site, its organization, how it works, and how we can improve it.

+
+
+
1
+
+
+ + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/latest.rss b/pyspice-discourse-backup/latest.rss new file mode 100644 index 00000000..1020eeae --- /dev/null +++ b/pyspice-discourse-backup/latest.rss @@ -0,0 +1,1163 @@ + + + + PySpice - Latest topics + https://pyspice.discourse.group/latest + Latest topics + + Mon, 31 Jan 2022 19:46:50 +0000 + + + Error while using 3 terminal Resistors + + Dev + I get an error when using 3 terminal resistors from Skywater 130nm PDK. When I looked at BasicElements.py, I noticed that all resistors are defined as DipoleElements. I have added a class for 3 terminal devices and now I am able to simulate the circuit. The same is true for 3-terminal capacitors too.

+

I would like to contribute PySpice to make it compatible with Skywater 130nm PDK devices. Kindly let me know what would be best way to contribute

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/error-while-using-3-terminal-resistors/164 + Mon, 31 Jan 2022 19:46:50 +0000 + No + No + No + pyspice.discourse.group-topic-164 + Error while using 3 terminal Resistors +
+ + Simulating a circuit with 16 MOSFETs: True gmin stepping error + + Circuit Simulation + Hello,

+

I am trying to simulate a circuit using 16 MOSFETS.

+

The issue is that once the MOSFETS’s 15 and 16 are placed in the schematic, it results in an error: PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR

+

If the MOSFET’s 15 and 16 are commented out, then the code compiles.

+

I am using NGspice-34.dll and PySpice 1.5. Have also tested with Pyspice 1.4.3 and NGspice-32.dll.

+

Is NGSpice reaching some maximum nodes/complexity limit? OR is this an issue with mosfet model? OR it is a circuit netlist (floating node?) issue?

+

Any help or ideas would be greatly appreciated.

+

The code and error message are reproduced below.

+

Thanks

+

Kahless96

+

##***********************************************
+import math
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.widgets import Cursor
+from matplotlib.pyplot import semilogx
+from matplotlib import pyplot

+

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 Circuit
+from PySpice.Unit import *

+

from engineering_notation import EngNumber

+

##***********************************************

+

+Circuit Netlist

+

circuit = Circuit(‘MyCircuit’)

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)
+circuit.include(spice_library[‘ptm65nm_nmos’])
+circuit.include(spice_library[‘ptm65nm_pmos’])

+

+Define inputs

+

HIGH = 1@u_V
+LOW = 0@u_V
+f_D = 1@u_Hz
+f_C = f_D/2
+f_B = f_D/4
+f_A = f_D/8

+

steptime=1@u_ms
+finaltime = 8/f_D
+circuit.V(1, ‘Vdd’, circuit.gnd, HIGH@u_V)
+circuit.PulseVoltageSource(2, ‘A’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_A)/2, period=1/f_A)
+circuit.PulseVoltageSource(3, ‘B’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_B)/2, period=1/f_B)
+circuit.PulseVoltageSource(4, ‘C’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_C)/2, period=1/f_C)
+circuit.PulseVoltageSource(5, ‘D’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_D)/2, period=1/f_D)

+

+M <bulk/substrate node> +

+

circuit.MOSFET(1, ‘out1’, ‘A’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(2, ‘out1’, ‘B’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(3, ‘out1’, ‘A’, ‘temp’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(4, ‘temp’,‘B’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(5, ‘out2’, ‘out1’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(6, ‘out2’, ‘out1’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(7, ‘out3’, ‘C’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(8, ‘out3’, ‘D’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(9, ‘out3’, ‘C’, ‘temp1’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(10, ‘temp1’,‘D’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(11, ‘out4’, ‘out3’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(12, ‘out4’, ‘out3’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(13, ‘op’, ‘out2’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(14, ‘op’, ‘out4’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(15, ‘op’, ‘out2’, ‘temp2’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(16, ‘temp2’,‘out4’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)

+

##***********************************************

+

+Simulation: Transient Analysis

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=steptime, end_time=finaltime)

+

#########################

+

+PLOTTING COMMANDS

+

figure = plt.subplots(figsize=(11, 6))
+axe = plt.subplot(111)
+plt.xlabel(‘Time [s]’)
+plt.ylabel(‘Voltage [V]’)
+plt.grid()
+plot(analysis[‘op’], axis=axe, color=‘red’)
+plt.show()

+

Here is the error messages after which it fails to run:

+

2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: Starting true gmin stepping
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-03 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-04 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-05 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-06 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-07 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-08 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-09 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-10 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-11 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: True gmin stepping completed

+

I have seen this gmin stepping error in other forum posts but in those cases it was related to circuit netlist error. This does not seem to be the case here.

+

The mosfet models being used are provided with Pyspice.

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162 + Thu, 13 Jan 2022 03:55:35 +0000 + No + No + No + pyspice.discourse.group-topic-162 + Simulating a circuit with 16 MOSFETs: True gmin stepping error +
+ + Problems with running simulator + + Installation + Hi every one!
+I am new to PySpice. I was running 1.4.3 ver with ngspice 3.2 and everything was working well.
+My computer did a usual clean up and update.

+

Now the netlist part works fine. But when I call the simulator I get a long error message (I will paste below). I was doing good progress and I am glad to share a 3 phase diode rectifier model which was working well. Until this problem arose. When I did an update I see that the cur ver is 1.5 and installs ngspice 3.4

+

Any help is appreciated. Else will have to go back to LTspice

+

Error msg attached below

+
+

TypeError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit3.simulator(temperature=25, nominal_temperature=25)
+2 simulator.initial_condition(out = 90@u_V)
+3 analysis = simulator.transient(step_time=Vac.period/1000, end_time=Vac.period*6)
+4
+5 res = format_output(analysis)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Netlist.py in simulator(self, *args, **kwargs)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117 “”" This class implements a circuit simulator. Each analysis mode is performed by a method that
+1118 return the measured probes.
+ → 1119
+1120 For ac and transient analyses, the user must specify a list of nodes using the probes key
+1121 argument.

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 cls._instances[ngspice_id] = instance
+451 return instance
+ → 452
+453 ##############################################
+454

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in init(self, ngspice_id, send_data, verbose)
+478 self._library_path = None
+479 self._load_library(verbose)
+ → 480 self._init_ngspice(send_data)
+481
+482 self._is_running = False

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in _load_library(self, verbose)
+511 if ‘SPICE_LIB_DIR’ not in os.environ:
+512 _ = str(Path(self.NGSPICE_PATH).joinpath(‘share’, ‘ngspice’))
+ → 513 os.environ[‘SPICE_LIB_DIR’] = _
+514 # self._logger.warning(‘Set SPICE_LIB_DIR = %s’, _)
+515

+

~\Anaconda3\lib\pathlib.py in new(cls, *args, **kwargs)
+1036 if cls is Path:
+1037 cls = WindowsPath if os.name == ‘nt’ else PosixPath
+ → 1038 self = cls._from_parts(args, init=False)
+1039 if not self._flavour.is_supported:
+1040 raise NotImplementedError(“cannot instantiate %r on your system”

+

~\Anaconda3\lib\pathlib.py in _from_parts(cls, args, init)
+677 # right flavour.
+678 self = object.new(cls)
+ → 679 drv, root, parts = self._parse_args(args)
+680 self._drv = drv
+681 self._root = root

+

~\Anaconda3\lib\pathlib.py in _parse_args(cls, args)
+661 parts += a._parts
+662 else:
+ → 663 a = os.fspath(a)
+664 if isinstance(a, str):
+665 # Force-cast str subclasses to str (issue #21127)

+

TypeError: expected str, bytes or os.PathLike object, not NoneType

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/problems-with-running-simulator/153 + Thu, 11 Nov 2021 13:45:39 +0000 + No + No + No + pyspice.discourse.group-topic-153 + Problems with running simulator +
+ + Howto: Transient analysis + + Uncategorized + I want to do a transient analysis of a square wave.

+
    +
  1. How do I do a transient analysis and plot the output?
  2. +
  3. How do I implement a square wave?
  4. +
+

I found nothing in the examples. Thanks for your help,
+Michael

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/howto-transient-analysis/150 + Mon, 27 Sep 2021 20:08:15 +0000 + No + No + No + pyspice.discourse.group-topic-150 + Howto: Transient analysis +
+ + How to write .func in pyspice and use it in behavioral source? + + Circuit Simulation + I want to write a .func that will help me designing a device model. I used **raw_spice=’ …’ ** but it is not working. I am new in pyspice.

+

Thank yuo

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148 + Thu, 16 Sep 2021 00:26:03 +0000 + No + No + No + pyspice.discourse.group-topic-148 + How to write .func in pyspice and use it in behavioral source? +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + Uncategorized + I am new with pyspice. I want to add a behavioral voltage source to my circuit. To write its expression we need voltage across two points x and y. For example v=2*Voltage(x,y)

+

Will anyone share the syntax in pyspice?
+Thank you.

+

6 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147 + Fri, 10 Sep 2021 13:08:01 +0000 + No + No + No + pyspice.discourse.group-topic-147 + How to get voltage acrros two points to write behavioral voltage source expression? +
+ + Interrupted simulation multiple sources + + Circuit Simulation + Hi everyone,

+

for a research project I’m working on control strategies for PFC circuits and therefore I need to simulate a passive circuit in conjunction with two half bridges.
+Problem is that I need the simulation to interact with a python script since I need to calculate the control signals of the two half bridges externally and thus the simualtion flow is as follows.

+

First, I need to initialize the simulation which basically means that I need to sample the amplitude and phase of a sinusodial source representing the grid voltage and the component values and initial conditions of the passive components. Next, I need to run the simulation in chunks where I first calculate the four control signals of the half bridges based on the current and voltage signals of the passive circuit followed by a chunk of transient simulation for a given time span (sample rate of the controller).

+

I tried to implement this flow but I unfortunately I struggle with the following issues.

+

a) Phase of the AC source:
+I tired SinusoidalVoltageSource() but I failed to specify a phase offset. Altough it’s base class SinusoidalMixin() offers a delay attribute, it seems that it just enables the source after a given time and thus this isn’t the desired behaviour for my purpose. Alternatively, I defined my own grid voltage using a NgSpiceShared object according …/examples/ngspice-shared/external-source.html.
+This essential does the trick for me but leaves with the next problem.

+

b) Multiple External Sources:
+Give the simulation flow above I need to run the simulation with at least four external sources, two for every half bridge, and five if I define the grid voltage also as external source. So I wonder how I define multiple shared objects.

+

c) Setting the initial conditions
+Since I run the simulation in chunks I wonder if I have to preload the nodes with the latest values and I need to run the simulation with start_time=0 and end_time=timespan according the controller’s sample rate or are the states kept internally and I need just to run the simulation with start_time=(k-1)timespan, end_time=ktimespan in order to run the kth simulation chunk.

+

Any help is kindly appreciated!

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/interrupted-simulation-multiple-sources/144 + Wed, 11 Aug 2021 15:05:52 +0000 + No + No + No + pyspice.discourse.group-topic-144 + Interrupted simulation multiple sources +
+ + Library import corner analysis + + NgSpice + Hello!

+

I am not familiar with English so if there is something not clear, please ask me!!

+

I am trying to import library file using corner analysis
+The code below is what I wish to use in NgSpice text

+
.lib 'mm018.l' TT
+
+

Since there is “TT” added for typical type analysis,
+I can’t use the library import using the code below in pyspice

+
spice_library = SpiceLibrary('./library_to_add')
+
+

I have no idea how I should solve this problem, please help me

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/library-import-corner-analysis/143 + Mon, 09 Aug 2021 06:01:08 +0000 + No + No + No + pyspice.discourse.group-topic-143 + Library import corner analysis +
+ + Divide one AC-analysis waveform by another + + Uncategorized + I have run an AC analysis in PySpice.
+I have found the waveform for input (source) voltage, and input (source) current.
+Now I would like to find the impedance waveform (voltage/current)
+How can I divide one waveform by another?

+

Thanks for your help!

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/divide-one-ac-analysis-waveform-by-another/140 + Fri, 28 May 2021 12:53:00 +0000 + No + No + No + pyspice.discourse.group-topic-140 + Divide one AC-analysis waveform by another +
+ + Extract array of complex numbers from waveform + + Uncategorized + Hi

+

I am just getting started with PySpice.

+

I have run an AC analysis on a netlist using PySpice, and have extracted my waveforms, but would like to convert these into a numpy array of complex numbers - how do I do this?

+

I want to do further mathematical analysis on the PySpice Waveform output.

+

Thanks

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/extract-array-of-complex-numbers-from-waveform/139 + Fri, 28 May 2021 12:50:00 +0000 + No + No + No + pyspice.discourse.group-topic-139 + Extract array of complex numbers from waveform +
+ + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' + + Uncategorized + Hi

+

I am just getting started with using PySpice.

+

I have extracted voltage/current values from a PySpice analysis, and would like to analyze these using other Python functions.

+

But all of my values are now of type class ‘PySpice.Unit.Unit.UnitValue’.

+

How can I remove the units, so that these are just normal float numbers?

+

Thanks

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138 + Fri, 28 May 2021 12:44:13 +0000 + No + No + No + pyspice.discourse.group-topic-138 + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' +
+ + Whats PySpice's Advantages? + + Help + Hi friends, why I have use pySpice instead of use direct spice program? Whats advantages of using pyspice? I must a homework like electronic circuits with pyspice but I didn’t find a topic. Can you help me find a topic. How can I do with pyspice?

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/whats-pyspices-advantages/135 + Tue, 18 May 2021 20:26:00 +0000 + No + No + No + pyspice.discourse.group-topic-135 + Whats PySpice's Advantages? +
+ + Can SpiceParser parse subcircuits? + + Help + We want to parse a sp file with a netlist that embeds a subcircuit definition. When we parse it with SpiceParser we noticed that the subcircuit definition is removed. Is there a way to include the subcircuit definition during the parsing process?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/can-spiceparser-parse-subcircuits/133 + Fri, 30 Apr 2021 03:23:54 +0000 + No + No + No + pyspice.discourse.group-topic-133 + Can SpiceParser parse subcircuits? +
+ + NgSpice Options Help + + NgSpice + How do you use the simulation options in a simulation? For example how does one call up any of the options in chapter 15.1 of the NgSpice users guide.

+

Say I want to change the transient solver to METHOD=‘Gear’ how would I?

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/ngspice-options-help/131 + Sun, 21 Mar 2021 01:18:42 +0000 + No + No + No + pyspice.discourse.group-topic-131 + NgSpice Options Help +
+ + Error in running examples + + Help + I’ve just installed PySpice (on Fedora, using pip install PySpice). I’ve downloaded the examples with pyspice-post-installation --download-example and tried to run them. I get a number of errors, but the one that appears most often is:

+

pyspice-post-installation --download-example

+

I googled the problem but couldn’t fix it, grateful for suggestions.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/error-in-running-examples/127 + Tue, 09 Mar 2021 23:43:16 +0000 + No + No + No + pyspice.discourse.group-topic-127 + Error in running examples +
+ + Google COLAB + PySpice + + Help + I trying use PySpice on google Colab, but I fail…
+Some one can tell me if is possible, and how i can do?

+

Aparently… I should but i dont be able to install or reference there the “ngspice dll”

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/google-colab-pyspice/125 + Sun, 07 Mar 2021 02:56:43 +0000 + No + No + No + pyspice.discourse.group-topic-125 + Google COLAB + PySpice +
+ + Read a NgSpice rawfile using PySpice + + Help + Hello guys,

+

I am writing a python script that generates, runs and eventually will read the raw files. The command I use to run the netlist is the following: subprocess.run([path_to_ngspice_executable,'-r','rawfile.raw','-b','-i',my_netlist]) which generates my rawfile.

+

Could you please tell me what PySpice command to use so I can read the generated raw file and plot the distribution of my voltages?

+

Thanks in advance !

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/read-a-ngspice-rawfile-using-pyspice/123 + Wed, 03 Mar 2021 08:40:44 +0000 + No + No + No + pyspice.discourse.group-topic-123 + Read a NgSpice rawfile using PySpice +
+ + More maintainers? + + Dev + There are currently 113 open issues and 18 pull requests, including some very trivial ones from months ago, many unfinished pages in the documentation, and no changes to the repo for 7 months.

+

I know you work on this in your free time and development will be sporadic, would you be willing to add additional maintainers to help deal with the PRs, etc?

+

4 posts - 3 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/more-maintainers/120 + Tue, 09 Feb 2021 23:42:59 +0000 + No + No + No + pyspice.discourse.group-topic-120 + More maintainers? +
+ + Getting keyerror while running example + + Installation + As i’m new to pyspice when i am running this example
+https://pyspice.fabrice-salvaire.fr/releases/v1.3/examples/diode/diode-characteristic-curve.html

+

I am getting this keyerror

+

I m using windows 10 64 bit
+Ide : Anaconda python
+Pyspice 1.4.3
+Ngspice 32

+

If any gentlemen has idea how to fix this it ll help me a lot :smiley:

+

4 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/getting-keyerror-while-running-example/119 + Sat, 30 Jan 2021 13:14:32 +0000 + No + No + No + pyspice.discourse.group-topic-119 + Getting keyerror while running example +
+ + Installation example scripts + + Installation + Dear PySpice community, I would like to share some installation example files to illustrate the installation procedure of PySpice on Linux by using apt and pip only.

+

Those files are published as Dockerfile scripts since they allow full automatic machine instantiation with docker.
+They cover both Ubuntu and Debian, using a standard approach using only apt :

+ +

One can also find a more “manual” approach to demonstrate how to properly set the PYTHONPATH and LD_LIBRARY_PATH environment variables :

+ +

The two latter should be useful for those who want to install PySpice on Google Collab.

+

If you have docker on your computer, you can also pull directly the images from Docker Hub :

+ +

Enjoy !

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/installation-example-scripts/117 + Mon, 25 Jan 2021 22:35:44 +0000 + No + No + No + pyspice.discourse.group-topic-117 + Installation example scripts +
+ + Access to Diode Parameters + + Uncategorized + Hello,

+

when working with pyspice 1.3 it was possible for me to change device parameters in thie way described below. With 1.4 this does not seem to work any more. Is there a new or alternate syntax?

+

#############################
+import os
+os.linesep="\n"

+

source=’’’
+.title xxx

+

V1 N001 0 1 AC 1
+D1 N001 0 john

+

.model john D (Is=4.352e-9 Rs=0 N=1.906)
+.end

+

‘’’

+

parser = SpiceParser(source=source)
+circuit = parser.build_circuit()

+

circuit.john._parameters[‘Is’] = 3e-08

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.dc(V1=slice(0.1, 1,0.01))

+

#######################################

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/access-to-diode-parameters/108 + Sat, 19 Dec 2020 17:38:44 +0000 + No + No + No + pyspice.discourse.group-topic-108 + Access to Diode Parameters +
+ + Two installation experiences on Windows + + Installation + Windows 10 +

First I tried to install in my base conda environment on Windows 10 64-bit. It could not be installed due to package conflicts and it tried many different things to resolve the conflicts, grinding away at the CPU for two hours, and eventually I killed it.

+

Then I created a new environment specifically for PySpice and installed it:

+
conda create --name pyspice
+conda activate pyspice
+conda install -c conda-forge pyspice
+pyspice-post-installation --install-ngspice-dll
+
+

This last step did not work, however, because it required the
+requests library:

+
ModuleNotFoundError: No module named 'requests'
+
+

So I then did

+
conda install requests
+pyspice-post-installation --install-ngspice-dll
+pyspice-post-installation --check-install
+
+

And it worked. I reported the dependency problem here: https://github.com/FabriceSalvaire/PySpice/issues/266

+

Windows 7

+

Now I’m doing the same procedure on a Windows 7 machine (I know, I know, it’s obsolete). The install command showed no errors on the command line, but I did get a pop up error:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

I haven’t seen this error before, but the install command worked so I’m ignoring it.

+

Then I try

+
pyspice-post-installation --install-ngspice-dll
+
+

Ah, now I’m getting the same error:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

and if I run the check:

+
pyspice-post-installation --check-install
+
+

I get the same error dialog:

+
+

python.exe - System Error

+

The program can’t start because api-ms-win-core-path-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

+

OK

+
+

Tried System File Checker:

+
λ sfc /scannow
+
+Beginning system scan.  This process will take some time.
+
+Beginning verification phase of system scan.
+Verification 100% complete.
+
+Windows Resource Protection did not find any integrity violations.
+
+

Searching my machine, it does not have api-ms-win-core-path-l1-1-0.dll anywhere. Maybe this is a Windows 10 file only. (Nope, not present on Windows 10 machine, either.)

+

Trying to install jupyterlab also doesn’t work well. Does PySpice have some weird requirements/dependencies that prevent conda from installing it alongside other things?

+
Collecting package metadata (current_repodata.json): done
+Solving environment: failed with initial frozen solve. Retrying with flexible solve.
+Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
+Collecting package metadata (repodata.json): done
+Solving environment: failed with initial frozen solve. Retrying with flexible solve.
+
+

Oh if I do it as conda install jupyterlab voila instead of using conda-forge, it works fine

+

2 posts - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/two-installation-experiences-on-windows/107 + Wed, 16 Dec 2020 15:28:34 +0000 + No + No + No + pyspice.discourse.group-topic-107 + Two installation experiences on Windows +
+ + Simulating Dependent Sources (CCVS works but VCVS does not?!) + + Circuit Simulation + Hello,

+

I am trying to run the following code for the circuit:Circuit

+

###############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with VCVS’)

+

circuit.R(1, 1, circuit.gnd, 6@u_Ω)
+circuit.R(2, 2, 3, 4@u_Ω)
+circuit.R(3, 3, 4, 8@u_Ω)
+circuit.R(4, 5, circuit.gnd, 15@u_Ω)
+circuit.V(1, 2, 1, 65@u_V)
+circuit.E(1, 4, 3, 2, 3, 3)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+

When I run, it gives an error:

+

Traceback (most recent call last):
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 928, in getattr
+return self.getitem(attribute_name)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 921, in getitem
+raise IndexError(attribute_name) # KeyError
+IndexError: E

+

During handling of the above exception, another exception occurred:

+

Traceback (most recent call last):
+File “C:/Users/Desktop/PySpice/node-voltage-method-example8.py”, line 22, in
+circuit.E(1, 4, 3, 2, 3, 3)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 930, in getattr
+raise AttributeError(attribute_name)
+AttributeError: E

+

I am not sure where I am going wrong. I have been able to simulate a CCVS (part name H) but all other dependent sources seem to give an error.

+

Can anyone please point out what is wrong in the code above?

+

Thanks

+

Salman

+

6 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105 + Wed, 02 Dec 2020 01:58:43 +0000 + No + No + No + pyspice.discourse.group-topic-105 + Simulating Dependent Sources (CCVS works but VCVS does not?!) +
+ + Bode plot with sinusoidal Current Source + + Uncategorized + Hi,

+

I successfully ran this example: https://pyspice.fabrice-salvaire.fr/releases/v1.4/examples/filter/low-pass-rc-filter.html

+

I am however interested in replacing the voltage source with a current source and still get a bode plot that compares the output voltage to input current. Just replacing the voltage source with a current source as follows gives me an error.

+

circuit.SinusoidalCurrentSource(‘input’, ‘in’, circuit.gnd, amplitude=1@u_uA)

+

NgSpiceCommandError : Command ‘run’ failed

+

Thank you in advance

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/bode-plot-with-sinusoidal-current-source/103 + Tue, 24 Nov 2020 12:13:04 +0000 + No + No + No + pyspice.discourse.group-topic-103 + Bode plot with sinusoidal Current Source +
+ + Is PySpice 1.4.2 compatible with Ngspice 33? + + Uncategorized + Hello Community,

+

I have set up PySpice 1.4.2 through a virtual environment and brew installed Ngspice and libngspice on Mac 0S X. However, “pyspice-post-installation --check-install” tells me that Ngspice version 33 is not supported.

+

Please advise.

+

2 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/is-pyspice-1-4-2-compatible-with-ngspice-33/101 + Mon, 23 Nov 2020 02:57:05 +0000 + No + No + No + pyspice.discourse.group-topic-101 + Is PySpice 1.4.2 compatible with Ngspice 33? +
+ + Using the Skywater PDK with SKiDL/PySpice + + Uncategorized + I’ve published a Jupyter notebook of my explorations using SKiDL and PySpice with the open Skywater PDK.

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/using-the-skywater-pdk-with-skidl-pyspice/98 + Mon, 16 Nov 2020 18:41:20 +0000 + No + No + No + pyspice.discourse.group-topic-98 + Using the Skywater PDK with SKiDL/PySpice +
+ + Losing units when summing a Waveform + + Data Analysis using Python + I multiplied two Waveform objects: one containing voltages and the other containing currents. Then I multiplied it by a PeriodValue. As expected, the resulting Wavform object contains numbers with the units of Joules. But when I applied the sum() method to this Waveform, I got a scalar value with no units.

+

Is there any way to do this without losing the units for the calculations that follow?

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/losing-units-when-summing-a-waveform/97 + Fri, 06 Nov 2020 15:07:46 +0000 + No + No + No + pyspice.discourse.group-topic-97 + Losing units when summing a Waveform +
+ + Load_circuit failing for some reasons + + Installation + +
    +
  • OS: MacOS Catilina (version 10.15.7)
  • +
  • Python framework with PyCharm + Conda environment
  • +
  • PySpice installed with Conda (version 1.4.3)
  • +
  • libngspice installed with Conda
  • +
  • NGSPICE installed with homebrew (version 33) +
      +
    • location: /usr/local/bin/ngspice
    • +
    • functionality check: NGSPICE works from terminal and does simulate a circuit
    • +
    +
  • +
+
+

Hi,

+

this is my first test with the “PySpice” flow. I went through the explained installation steps:

+ + +

By running the “resistor-bridge.py” example:

+ + +

I get the following error:

+


+PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command ‘run’ failed
+…

+

By placing a breakpoint and debugging the code I see that the failing point is at (every line nested hierarchically):

+

analysis = simulator.operating_point()
+return self._run(‘operating_point’, *args, **kwargs)
+self._ngspice_shared.run()
+self.exec_command(command)
+raise NgSpiceCommandError(“Command ‘{}’ failed”.format(command))

+

And is due to stderr = ‘Error: there aren’t any circuits loaded.’

+

By debugging further I could nail down that the def run() method of the Simulation class fails because the run command after the load_circuit command complains that the circuit wasn’t loaded.

+
def _run(self, analysis_method, *args, **kwargs):
+
+    super()._run(analysis_method, *args, **kwargs)
+
+    self._ngspice_shared.destroy()
+    # Fixme: Error: circuit not parsed.
+    self._ngspice_shared.load_circuit(str(self))
+    self._ngspice_shared.run()
+    self._logger.debug(str(self._ngspice_shared.plot_names))
+    self.reset_analysis()
+
+    plot_name = self._ngspice_shared.last_plot
+    if plot_name == 'const':
+        raise NameError('Simulation failed')
+
+    return self._ngspice_shared.plot(self, plot_name).to_analysis()
+
+

So the load_circuit method seems to not load the circuit properly in the sim, any idea why? (although it does execute it and no error is raised within that method).

+

I tried also the listing() method to query the circuit description back and also doesn’t seem to provide anything back.

+

Actually the only communication with the simulator seems to be successful is the “version -f” command which returns the valuable infos from it.

+

Thanks,
+Andrea

+

3 posts - 2 participants

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/load-circuit-failing-for-some-reasons/96 + Mon, 02 Nov 2020 20:14:10 +0000 + No + No + No + pyspice.discourse.group-topic-96 + Load_circuit failing for some reasons +
+ + Trouble with Libraries + + Help + Hello!

+

To better understand PySpice, I’m working through a very simple circuit involving a voltage source, a resistor, and a 1N4148 Diode. However, I am having trouble with Python recognizing the library I need to bring in the characteristics of the diode. Here is my code:

+

'import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.ticker as ticker

+

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

+

from PySpice.Doc.ExampleTools import find_libraries
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Unit import *
+from PySpice.Physics.SemiConductor import ShockleyDiode

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)

+

circuit = Circuit(‘Diode Characteristic Curve’)

+

circuit.include(spice_library[‘1N4148’])

+

circuit.V(‘input’, ‘in’, circuit.gnd, 10@u_V)
+circuit.R(1, ‘in’, ‘out’, 1@u_Ω) # not required for simulation
+circuit.X(‘D1’, ‘1N4148’, ‘out’, circuit.gnd)’

+

And here is my result:

+

--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-5-ae802129d891> in <module> 20 circuit = Circuit('Diode Characteristic Curve') 21 ---> 22 circuit.include(spice_library['1N4148']) 23 24 circuit.V('input', 'in', circuit.gnd, 10@u_V) /usr/local/lib/python3.8/dist-packages/PySpice/Spice/Library.py in __getitem__(self, name) 105 # print('Library {} not found in {}'.format(name, self._directory)) 106 # self._logger.warn('Library {} not found in {}'.format(name, self._directory)) --> 107 raise KeyError(name) 108 109 ############################################## KeyError: '1N4148'

+

Can anyone help me understand what exactly is going wrong here and how I can correct it?

+

Thanks!

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/trouble-with-libraries/94 + Sun, 25 Oct 2020 20:45:42 +0000 + No + No + No + pyspice.discourse.group-topic-94 + Trouble with Libraries +
+ + Install Pyspice on Raspberry Pi 4 ERROR + + Installation + Hello Everyone!
+I’m running into a problem, i want to install PySpice on Raspberry Pi 4 which runs Raspbian OS. I have read the doumentation that wrote, it is supported on Linux, Windos 64 and MAC.
+I have followed the install instructions after i typed : pip3 install PySpice the following error message i got:

+

Defaulting to user installation because normal site-packages is not writeable
+Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
+Collecting PySpice
+Using cached PySpice-1.4.3-py2.py3-none-any.whl (144 kB)
+Collecting scipy>=1.4
+Downloading scipy-1.5.3.tar.gz (25.2 MB)
+|################################| 25.2 MB 28 kB/s
+Installing build dependencies … \Ledone
+Getting requirements to build wheel … done
+Preparing wheel metadata … error
+ERROR: Command errored out with exit status 1:
+command: /usr/bin/python /home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpv39ep59r
+cwd: /tmp/pip-install-_1dtpvzc/scipy
+Complete output (139 lines):
+lapack_opt_info:
+lapack_mkl_info:
+customize UnixCCompiler
+libraries mkl_rt not found in [’/usr/local/lib’, ‘/usr/lib’, ‘/usr/lib/arm-linux-gnueabihf’]
+NOT AVAILABLE

+
openblas_lapack_info:
+customize UnixCCompiler
+customize UnixCCompiler
+  libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+openblas_clapack_info:
+customize UnixCCompiler
+customize UnixCCompiler
+  libraries openblas,lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+flame_info:
+customize UnixCCompiler
+  libraries flame not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+atlas_3_10_threads_info:
+Setting PTATLAS=ATLAS
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries tatlas,tatlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
+  NOT AVAILABLE
+
+atlas_3_10_info:
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries satlas,satlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_3_10_info'>
+  NOT AVAILABLE
+
+atlas_threads_info:
+Setting PTATLAS=ATLAS
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries ptf77blas,ptcblas,atlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_threads_info'>
+  NOT AVAILABLE
+
+atlas_info:
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/local/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/lib
+customize UnixCCompiler
+  libraries lapack_atlas not found in /usr/lib/arm-linux-gnueabihf
+customize UnixCCompiler
+  libraries f77blas,cblas,atlas not found in /usr/lib/arm-linux-gnueabihf
+<class 'numpy.distutils.system_info.atlas_info'>
+  NOT AVAILABLE
+
+accelerate_info:
+  NOT AVAILABLE
+
+lapack_info:
+customize UnixCCompiler
+  libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/arm-linux-gnueabihf']
+  NOT AVAILABLE
+
+lapack_src_info:
+  NOT AVAILABLE
+
+  NOT AVAILABLE
+
+setup.py:460: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-modern-metadata-yx7fyy34'), proceeding with generating Cython sources and expanding templates
+  warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
+Running from SciPy source directory.
+/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: UserWarning:
+    Lapack (http://www.netlib.org/lapack/) libraries not found.
+    Directories to search for the libraries can be specified in the
+    numpy/distutils/site.cfg file (section [lapack]) or by setting
+    the LAPACK environment variable.
+  if getattr(self, '_calc_info_{}'.format(lapack))():
+/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: UserWarning:
+    Lapack (http://www.netlib.org/lapack/) sources not found.
+    Directories to search for the sources can be specified in the
+    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
+    the LAPACK_SRC environment variable.
+  if getattr(self, '_calc_info_{}'.format(lapack))():
+Traceback (most recent call last):
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
+    main()
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
+    json_out['return_val'] = hook(**hook_input['kwargs'])
+  File "/home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
+    return hook(metadata_directory, config_settings)
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
+    self.run_setup()
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 253, in run_setup
+    super(_BuildMetaLegacyBackend,
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 145, in run_setup
+    exec(compile(code, __file__, 'exec'), locals())
+  File "setup.py", line 583, in <module>
+    setup_package()
+  File "setup.py", line 579, in setup_package
+    setup(**metadata)
+  File "/tmp/pip-build-env-pdkw0rfi/overlay/lib/python3.8/site-packages/numpy/distutils/core.py", line 137, in setup
+    config = configuration()
+  File "setup.py", line 477, in configuration
+    raise NotFoundError(msg)
+numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.
+----------------------------------------
+
+

ERROR: Command errored out with exit status 1: /usr/bin/python /home/pi/.local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpv39ep59r Check the logs for full command output.

+

Is it because i have ARM Cortex-A72 architecture and not x64? Or is it because Raspbian and not exactly Linux? But raspbian based on Linux…

+

Thanks for all answers!
+Best regards,
+Daniel

+

1 post - 1 participant

+

Read full topic

+ ]]>
+ https://pyspice.discourse.group/t/install-pyspice-on-raspberry-pi-4-error/90 + Mon, 19 Oct 2020 17:38:42 +0000 + No + No + No + pyspice.discourse.group-topic-90 + Install Pyspice on Raspberry Pi 4 ERROR +
+
+
diff --git a/pyspice-discourse-backup/opensearch.xml b/pyspice-discourse-backup/opensearch.xml new file mode 100644 index 00000000..12d8b337 --- /dev/null +++ b/pyspice-discourse-backup/opensearch.xml @@ -0,0 +1,10 @@ + + + PySpice Search + Search for posts on PySpice + discourse forum + https://aws1.discourse-cdn.com/free1/uploads/pyspice/optimized/1X/c8a5f9e5a96fcfbc05759ee1427b85cedcb4ce5a_2_32x32.png + + + + diff --git a/pyspice-discourse-backup/posts.rss b/pyspice-discourse-backup/posts.rss new file mode 100644 index 00000000..ee6e5cf8 --- /dev/null +++ b/pyspice-discourse-backup/posts.rss @@ -0,0 +1,584 @@ + + + + PySpice - Latest posts + https://pyspice.discourse.group + Latest posts + + More maintainers? + + A better idea may be to have a dedicated track in the NGspice user group for PySpice.

]]>
+ https://pyspice.discourse.group/t/more-maintainers/120#post_4 + Thu, 03 Feb 2022 00:32:34 +0000 + pyspice.discourse.group-post-274 +
+ + Error while using 3 terminal Resistors + + I get an error when using 3 terminal resistors from Skywater 130nm PDK. When I looked at BasicElements.py, I noticed that all resistors are defined as DipoleElements. I have added a class for 3 terminal devices and now I am able to simulate the circuit. The same is true for 3-terminal capacitors too.

+

I would like to contribute PySpice to make it compatible with Skywater 130nm PDK devices. Kindly let me know what would be best way to contribute

]]>
+ https://pyspice.discourse.group/t/error-while-using-3-terminal-resistors/164#post_1 + Mon, 31 Jan 2022 19:46:50 +0000 + pyspice.discourse.group-post-273 +
+ + Simulating a circuit with 16 MOSFETs: True gmin stepping error + + The issue was the MOSFET model. I managed to solve the problem. See: Simulation of Digital Logic Gates in PySpice (Python) - YouTube

]]>
+ https://pyspice.discourse.group/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162#post_2 + Wed, 19 Jan 2022 04:02:18 +0000 + pyspice.discourse.group-post-271 +
+ + Simulating a circuit with 16 MOSFETs: True gmin stepping error + + Hello,

+

I am trying to simulate a circuit using 16 MOSFETS.

+

The issue is that once the MOSFETS’s 15 and 16 are placed in the schematic, it results in an error: PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR

+

If the MOSFET’s 15 and 16 are commented out, then the code compiles.

+

I am using NGspice-34.dll and PySpice 1.5. Have also tested with Pyspice 1.4.3 and NGspice-32.dll.

+

Is NGSpice reaching some maximum nodes/complexity limit? OR is this an issue with mosfet model? OR it is a circuit netlist (floating node?) issue?

+

Any help or ideas would be greatly appreciated.

+

The code and error message are reproduced below.

+

Thanks

+

Kahless96

+

##***********************************************
+import math
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.widgets import Cursor
+from matplotlib.pyplot import semilogx
+from matplotlib import pyplot

+

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 Circuit
+from PySpice.Unit import *

+

from engineering_notation import EngNumber

+

##***********************************************

+

+Circuit Netlist

+

circuit = Circuit(‘MyCircuit’)

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)
+circuit.include(spice_library[‘ptm65nm_nmos’])
+circuit.include(spice_library[‘ptm65nm_pmos’])

+

+Define inputs

+

HIGH = 1@u_V
+LOW = 0@u_V
+f_D = 1@u_Hz
+f_C = f_D/2
+f_B = f_D/4
+f_A = f_D/8

+

steptime=1@u_ms
+finaltime = 8/f_D
+circuit.V(1, ‘Vdd’, circuit.gnd, HIGH@u_V)
+circuit.PulseVoltageSource(2, ‘A’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_A)/2, period=1/f_A)
+circuit.PulseVoltageSource(3, ‘B’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_B)/2, period=1/f_B)
+circuit.PulseVoltageSource(4, ‘C’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_C)/2, period=1/f_C)
+circuit.PulseVoltageSource(5, ‘D’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_D)/2, period=1/f_D)

+

+M <bulk/substrate node> +

+

circuit.MOSFET(1, ‘out1’, ‘A’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(2, ‘out1’, ‘B’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(3, ‘out1’, ‘A’, ‘temp’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(4, ‘temp’,‘B’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(5, ‘out2’, ‘out1’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(6, ‘out2’, ‘out1’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(7, ‘out3’, ‘C’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(8, ‘out3’, ‘D’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(9, ‘out3’, ‘C’, ‘temp1’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(10, ‘temp1’,‘D’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(11, ‘out4’, ‘out3’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(12, ‘out4’, ‘out3’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(13, ‘op’, ‘out2’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(14, ‘op’, ‘out4’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(15, ‘op’, ‘out2’, ‘temp2’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(16, ‘temp2’,‘out4’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)

+

##***********************************************

+

+Simulation: Transient Analysis

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=steptime, end_time=finaltime)

+

#########################

+

+PLOTTING COMMANDS

+

figure = plt.subplots(figsize=(11, 6))
+axe = plt.subplot(111)
+plt.xlabel(‘Time [s]’)
+plt.ylabel(‘Voltage [V]’)
+plt.grid()
+plot(analysis[‘op’], axis=axe, color=‘red’)
+plt.show()

+

Here is the error messages after which it fails to run:

+

2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: Starting true gmin stepping
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-03 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-04 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-05 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-06 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-07 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-08 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-09 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-10 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-11 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: True gmin stepping completed

+

I have seen this gmin stepping error in other forum posts but in those cases it was related to circuit netlist error. This does not seem to be the case here.

+

The mosfet models being used are provided with Pyspice.

]]>
+ https://pyspice.discourse.group/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162#post_1 + Thu, 13 Jan 2022 03:55:35 +0000 + pyspice.discourse.group-post-270 +
+ + Simulating Dependent Sources (CCVS works but VCVS does not?!) + + Re: dsalman,

+

Thanks for your suggestions. The problem has been addressed. Yes, it was an installation issue.

]]>
+ https://pyspice.discourse.group/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105#post_6 + Sun, 28 Nov 2021 19:45:14 +0000 + pyspice.discourse.group-post-264 +
+ + Simulating Dependent Sources (CCVS works but VCVS does not?!) + + It could be an installation issue. Please see here: Introduction to PySpice (Python) for DC Circuit Analysis with Dependent Sources - YouTube

]]>
+ https://pyspice.discourse.group/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105#post_5 + Sun, 28 Nov 2021 09:05:45 +0000 + pyspice.discourse.group-post-263 +
+ + Simulating Dependent Sources (CCVS works but VCVS does not?!) + + when I run the program:
+##############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with CCVS’)

+

circuit.R(1, 1, 2, 2@u_Ω)
+circuit.R(2, 2, circuit.gnd, 20@u_Ω)
+circuit.R(3, 2, 3, 5@u_Ω)
+circuit.R(4, 4, circuit.gnd, 10@u_Ω)
+circuit.R(5, 4, 5, 2@u_Ω)
+circuit.V(1, 1, circuit.gnd, 20@u_V)
+circuit.V(‘test’, 3, 4, 0@u_V)
+circuit.H(1, 5, circuit.gnd, ‘Vtest’, 8)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+

I see an error message:
+Traceback (most recent call last):
+File “C:\PySpice\ICs\programtest.py”, line 24, in
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+

Any suggestions? Thanks in advance.

]]>
+ https://pyspice.discourse.group/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105#post_4 + Sun, 28 Nov 2021 08:09:49 +0000 + pyspice.discourse.group-post-262 +
+ + XSPICE elements in PySpice + + I always see a problem like this:
+Traceback (most recent call last):
+File “C:\PySpice\ICs\simulation.py”, line 23, in
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)

+

My program execution shows a problem at “simulator = circuit.simulator(temperature=27, nominal_temperature=27)”. Any suggestions?

+

Thanks

]]>
+ https://pyspice.discourse.group/t/xspice-elements-in-pyspice/61#post_6 + Sun, 28 Nov 2021 08:05:54 +0000 + pyspice.discourse.group-post-261 +
+ + Looking for a Xyce Example + + I would also like Xyce examples too!

+

Following the comments above, I managed to make all work in Ubuntu 20.04 here is some code:

+
import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+from PySpice.Spice.Netlist import Circuit
+
+import matplotlib.pyplot as plt
+import numpy as np
+
+pCircuit1 = Circuit('Filtro pasabajo Bessel 3er orden')
+
+pCircuit1.SinusoidalVoltageSource('input', 'in', pCircuit1.gnd, amplitude=1)
+
+pCircuit1.R('G', 'in',  1, 1)
+pCircuit1.L('1',    1,  2,  1.255 )
+pCircuit1.C('1',    2,  pCircuit1.gnd,  0.5528 )
+pCircuit1.L('2',    2,  'out', 0.1922 )
+pCircuit1.R('L','out',  pCircuit1.gnd, 1)
+
+# NGspice
+# simulation1 = pCircuit1.simulator(temperature=25, nominal_temperature=25)
+# Xyce-serial
+simulation1 = pCircuit1.simulator(simulator = 'xyce-serial', xyce_command='/home/mariano/XyceInstall/Serial/bin/Xyce', temperature=25, nominal_temperature=25)
+
+analysis1 = simulation1.ac(start_frequency=0.001, stop_frequency=100, number_of_points=100,  variation='dec')
+
+ff = 2*np.pi * np.array(analysis1.frequency.tolist())
+
+figure, (axMod, axPha) = plt.subplots(2, sharex = True, figsize=(20, 10))
+
+axMod.semilogx(ff, 20*np.log10(np.abs(analysis1['out'])))
+axMod.semilogx(True)
+axMod.grid(True)
+axMod.grid(True, which='minor')
+axMod.set_ylabel("Módulo [dB]")
+
+plt.sca(axMod)
+plt.title("Síntesis doblemente cargada: Bessel de 3er orden")
+
+phase = np.unwrap(np.angle(analysis1['out']))
+delay = - np.diff(phase) / np.diff(ff)
+delay = np.concatenate(([delay[0]], delay))
+axPha.semilogx(ff, delay)
+axPha.grid(True)
+axPha.grid(True, which='minor')
+axPha.set_xlabel("Frecuencia [rad/s]")
+axPha.set_ylabel("Retardo [s]")
+
+

As a result a plot like that should be produced:

+

+

The simulation is for this circuit

+

]]>
+ https://pyspice.discourse.group/t/looking-for-a-xyce-example/82#post_2 + Fri, 26 Nov 2021 14:51:51 +0000 + pyspice.discourse.group-post-258 +
+ + Divide one AC-analysis waveform by another + + Get result into np.array

+

V = np.array(analysis.nodes[‘none name’])
+I = np.array(analysis.branches[‘branch name’])
+Now you can try mathematical operation ion V and I as they are numpy arrays.

]]>
+ https://pyspice.discourse.group/t/divide-one-ac-analysis-waveform-by-another/140#post_2 + Thu, 11 Nov 2021 13:52:23 +0000 + pyspice.discourse.group-post-255 +
+ + Extract array of complex numbers from waveform + + If say you have
+analysis = simulator.AC(…)
+then try
+c = np.array(analysis.nodes[‘in’]) where "in’ is one of the nodes
+print(c)
+and check if it is complex

]]>
+ https://pyspice.discourse.group/t/extract-array-of-complex-numbers-from-waveform/139#post_2 + Thu, 11 Nov 2021 13:49:39 +0000 + pyspice.discourse.group-post-254 +
+ + Problems with running simulator + + Hi every one!
+I am new to PySpice. I was running 1.4.3 ver with ngspice 3.2 and everything was working well.
+My computer did a usual clean up and update.

+

Now the netlist part works fine. But when I call the simulator I get a long error message (I will paste below). I was doing good progress and I am glad to share a 3 phase diode rectifier model which was working well. Until this problem arose. When I did an update I see that the cur ver is 1.5 and installs ngspice 3.4

+

Any help is appreciated. Else will have to go back to LTspice

+

Error msg attached below

+
+

TypeError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit3.simulator(temperature=25, nominal_temperature=25)
+2 simulator.initial_condition(out = 90@u_V)
+3 analysis = simulator.transient(step_time=Vac.period/1000, end_time=Vac.period*6)
+4
+5 res = format_output(analysis)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Netlist.py in simulator(self, *args, **kwargs)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117 “”" This class implements a circuit simulator. Each analysis mode is performed by a method that
+1118 return the measured probes.
+ → 1119
+1120 For ac and transient analyses, the user must specify a list of nodes using the probes key
+1121 argument.

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 cls._instances[ngspice_id] = instance
+451 return instance
+ → 452
+453 ##############################################
+454

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in init(self, ngspice_id, send_data, verbose)
+478 self._library_path = None
+479 self._load_library(verbose)
+ → 480 self._init_ngspice(send_data)
+481
+482 self._is_running = False

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in _load_library(self, verbose)
+511 if ‘SPICE_LIB_DIR’ not in os.environ:
+512 _ = str(Path(self.NGSPICE_PATH).joinpath(‘share’, ‘ngspice’))
+ → 513 os.environ[‘SPICE_LIB_DIR’] = _
+514 # self._logger.warning(‘Set SPICE_LIB_DIR = %s’, _)
+515

+

~\Anaconda3\lib\pathlib.py in new(cls, *args, **kwargs)
+1036 if cls is Path:
+1037 cls = WindowsPath if os.name == ‘nt’ else PosixPath
+ → 1038 self = cls._from_parts(args, init=False)
+1039 if not self._flavour.is_supported:
+1040 raise NotImplementedError(“cannot instantiate %r on your system”

+

~\Anaconda3\lib\pathlib.py in _from_parts(cls, args, init)
+677 # right flavour.
+678 self = object.new(cls)
+ → 679 drv, root, parts = self._parse_args(args)
+680 self._drv = drv
+681 self._root = root

+

~\Anaconda3\lib\pathlib.py in _parse_args(cls, args)
+661 parts += a._parts
+662 else:
+ → 663 a = os.fspath(a)
+664 if isinstance(a, str):
+665 # Force-cast str subclasses to str (issue #21127)

+

TypeError: expected str, bytes or os.PathLike object, not NoneType

]]>
+ https://pyspice.discourse.group/t/problems-with-running-simulator/153#post_1 + Thu, 11 Nov 2021 13:45:39 +0000 + pyspice.discourse.group-post-253 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + Thank you. Its puzzling but the syntax does not work in Windows…

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_6 + Mon, 04 Oct 2021 10:32:08 +0000 + pyspice.discourse.group-post-251 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + I did it with ubuntu os

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_5 + Mon, 04 Oct 2021 04:18:36 +0000 + pyspice.discourse.group-post-249 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + Thank you. Is this syntax with Linux or Windows operating system.

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_4 + Sun, 03 Oct 2021 09:30:44 +0000 + pyspice.discourse.group-post-248 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + yes. Use the following .

+

circuit.B(‘name’, ‘node1’, circuit.gnd, v=‘2*V(x,y)’)

+

v----> is small and V(x,y)—> here V is capital

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_3 + Sat, 02 Oct 2021 04:42:47 +0000 + pyspice.discourse.group-post-247 +
+ + Howto: Transient analysis + + You can use circuit.PulseVoltageSource() command.

+

See example code posted in the comments here: Introduction to PySpice (Python) for Simulating Natural and Step Response of RC Circuits - YouTube

]]>
+ https://pyspice.discourse.group/t/howto-transient-analysis/150#post_3 + Wed, 29 Sep 2021 05:58:02 +0000 + pyspice.discourse.group-post-246 +
+ + Howto: Transient analysis + + Okay, now I have the following code

+

+#r# This example shows the computation of the DC biases in a resistor bridge.
+
+####################################################################################################
+
+import matplotlib.pyplot as plt
+##
+import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+####################################################################################################
+
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *
+
+####################################################################################################
+
+#f# circuit_macros('resistor-bridge.m4')
+
+circuit = Circuit('Resistor Divider')
+#circuit.PulseMixin(0@u_V, 20@u_V, 5@u_us, 10@u_us, delay_time=0) #doesn't work
+circuit.V('i', 'inp', circuit.gnd, 10@u_V) #works
+circuit.R(1, 'inp', 'out', 5@u_kΩ)
+circuit.R(2, 'out', circuit.gnd, 5@u_kΩ)
+
+
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=1@u_us, end_time=500@u_us)
+
+####################################################################################################
+
+figure1, ax = plt.subplots(figsize=(20, 10))
+ax.set_title('Voltage Divider')
+ax.set_xlabel('Time [s]')
+ax.set_ylabel('Voltage [V]')
+ax.grid()
+ax.plot(analysis.inp)
+ax.plot(analysis.out)
+ax.legend(('input', 'output'), loc=(.05,.1))
+#ax.set_ylim(float(-amplitude*1.1), float(amplitude*1.1))
+
+#plt.tight_layout()
+plt.show()
+
+

Can somebody help me please with the pulsed source?

]]>
+ https://pyspice.discourse.group/t/howto-transient-analysis/150#post_2 + Mon, 27 Sep 2021 20:26:57 +0000 + pyspice.discourse.group-post-245 +
+ + Howto: Transient analysis + + I want to do a transient analysis of a square wave.

+
    +
  1. How do I do a transient analysis and plot the output?
  2. +
  3. How do I implement a square wave?
  4. +
+

I found nothing in the examples. Thanks for your help,
+Michael

]]>
+ https://pyspice.discourse.group/t/howto-transient-analysis/150#post_1 + Mon, 27 Sep 2021 20:08:15 +0000 + pyspice.discourse.group-post-244 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + Trying to do the same. Not sure what syntax to use to access the node voltages in the circuit. @sant: Were you able to make any progress. If you can share what you tried maybe we can help each other to solve this issue.

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_2 + Fri, 24 Sep 2021 02:24:37 +0000 + pyspice.discourse.group-post-242 +
+ + How to write .func in pyspice and use it in behavioral source? + + I want to write a .func that will help me designing a device model. I used **raw_spice=’ …’ ** but it is not working. I am new in pyspice.

+

Thank yuo

]]>
+ https://pyspice.discourse.group/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148#post_1 + Thu, 16 Sep 2021 00:26:03 +0000 + pyspice.discourse.group-post-241 +
+ + How to get voltage acrros two points to write behavioral voltage source expression? + + I am new with pyspice. I want to add a behavioral voltage source to my circuit. To write its expression we need voltage across two points x and y. For example v=2*Voltage(x,y)

+

Will anyone share the syntax in pyspice?
+Thank you.

]]>
+ https://pyspice.discourse.group/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147#post_1 + Fri, 10 Sep 2021 13:08:01 +0000 + pyspice.discourse.group-post-240 +
+ + Interrupted simulation multiple sources + + Hi everyone,

+

for a research project I’m working on control strategies for PFC circuits and therefore I need to simulate a passive circuit in conjunction with two half bridges.
+Problem is that I need the simulation to interact with a python script since I need to calculate the control signals of the two half bridges externally and thus the simualtion flow is as follows.

+

First, I need to initialize the simulation which basically means that I need to sample the amplitude and phase of a sinusodial source representing the grid voltage and the component values and initial conditions of the passive components. Next, I need to run the simulation in chunks where I first calculate the four control signals of the half bridges based on the current and voltage signals of the passive circuit followed by a chunk of transient simulation for a given time span (sample rate of the controller).

+

I tried to implement this flow but I unfortunately I struggle with the following issues.

+

a) Phase of the AC source:
+I tired SinusoidalVoltageSource() but I failed to specify a phase offset. Altough it’s base class SinusoidalMixin() offers a delay attribute, it seems that it just enables the source after a given time and thus this isn’t the desired behaviour for my purpose. Alternatively, I defined my own grid voltage using a NgSpiceShared object according …/examples/ngspice-shared/external-source.html.
+This essential does the trick for me but leaves with the next problem.

+

b) Multiple External Sources:
+Give the simulation flow above I need to run the simulation with at least four external sources, two for every half bridge, and five if I define the grid voltage also as external source. So I wonder how I define multiple shared objects.

+

c) Setting the initial conditions
+Since I run the simulation in chunks I wonder if I have to preload the nodes with the latest values and I need to run the simulation with start_time=0 and end_time=timespan according the controller’s sample rate or are the states kept internally and I need just to run the simulation with start_time=(k-1)timespan, end_time=ktimespan in order to run the kth simulation chunk.

+

Any help is kindly appreciated!

]]>
+ https://pyspice.discourse.group/t/interrupted-simulation-multiple-sources/144#post_1 + Wed, 11 Aug 2021 15:05:52 +0000 + pyspice.discourse.group-post-237 +
+ + Library import corner analysis + + Hello!

+

I am not familiar with English so if there is something not clear, please ask me!!

+

I am trying to import library file using corner analysis
+The code below is what I wish to use in NgSpice text

+
.lib 'mm018.l' TT
+
+

Since there is “TT” added for typical type analysis,
+I can’t use the library import using the code below in pyspice

+
spice_library = SpiceLibrary('./library_to_add')
+
+

I have no idea how I should solve this problem, please help me

]]>
+ https://pyspice.discourse.group/t/library-import-corner-analysis/143#post_1 + Mon, 09 Aug 2021 06:01:08 +0000 + pyspice.discourse.group-post-236 +
+ + Divide one AC-analysis waveform by another + + I have run an AC analysis in PySpice.
+I have found the waveform for input (source) voltage, and input (source) current.
+Now I would like to find the impedance waveform (voltage/current)
+How can I divide one waveform by another?

+

Thanks for your help!

]]>
+ https://pyspice.discourse.group/t/divide-one-ac-analysis-waveform-by-another/140#post_1 + Fri, 28 May 2021 12:53:00 +0000 + pyspice.discourse.group-post-233 +
+ + Extract array of complex numbers from waveform + + Hi

+

I am just getting started with PySpice.

+

I have run an AC analysis on a netlist using PySpice, and have extracted my waveforms, but would like to convert these into a numpy array of complex numbers - how do I do this?

+

I want to do further mathematical analysis on the PySpice Waveform output.

+

Thanks

]]>
+ https://pyspice.discourse.group/t/extract-array-of-complex-numbers-from-waveform/139#post_1 + Fri, 28 May 2021 12:50:00 +0000 + pyspice.discourse.group-post-232 +
+ + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' + + Hi

+

I am just getting started with using PySpice.

+

I have extracted voltage/current values from a PySpice analysis, and would like to analyze these using other Python functions.

+

But all of my values are now of type class ‘PySpice.Unit.Unit.UnitValue’.

+

How can I remove the units, so that these are just normal float numbers?

+

Thanks

]]>
+ https://pyspice.discourse.group/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138#post_1 + Fri, 28 May 2021 12:44:13 +0000 + pyspice.discourse.group-post-231 +
+ + Whats PySpice's Advantages? + + Pyspice opens up the power of python for theoretical calculations, side by side with simulations. You cannot do this in any other simulator. See the videos in this playlist here which illustrate the flexibility and advantage of using Pyspice, compared to LTSPICE, PSPICE: Introduction to PySpice (Python) for DC Circuit Analysis with Dependent Sources - YouTube

]]>
+ https://pyspice.discourse.group/t/whats-pyspices-advantages/135#post_2 + Sun, 23 May 2021 11:10:07 +0000 + pyspice.discourse.group-post-229 +
+
+
diff --git a/pyspice-discourse-backup/privacy.html b/pyspice-discourse-backup/privacy.html new file mode 100644 index 00000000..ab8750db --- /dev/null +++ b/pyspice-discourse-backup/privacy.html @@ -0,0 +1,164 @@ + + + + + Privacy - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+ + + + +
+

+

What information do we collect?

+

We collect information from you when you register on our site and gather data when you participate in the forum by reading, writing, and evaluating the content shared here.

+

When registering on our site, you may be asked to enter your name and e-mail address. You may, however, visit our site without registering. Your e-mail address will be verified by an email containing a unique link. If that link is visited, we know that you control the e-mail address.

+

When registered and posting, we record the IP address that the post originated from. We also may retain server logs which include the IP address of every request to our server.

+

+

What do we use your information for?

+

Any of the information we collect from you may be used in one of the following ways:

+
    +
  • To personalize your experience — your information helps us to better respond to your individual needs.
  • +
  • To improve our site — we continually strive to improve our site offerings based on the information and feedback we receive from you.
  • +
  • To improve customer service — your information helps us to more effectively respond to your customer service requests and support needs.
  • +
  • To send periodic emails — The email address you provide may be used to send you information, notifications that you request about changes to topics or in response to your user name, respond to inquiries, and/or other requests or questions.
  • +
+

+

How do we protect your information?

+

We implement a variety of security measures to maintain the safety of your personal information when you enter, submit, or access your personal information.

+

+

What is your data retention policy?

+

We will make a good faith effort to:

+
    +
  • Retain server logs containing the IP address of all requests to this server no more than 90 days.
  • +
  • Retain the IP addresses associated with registered users and their posts no more than 5 years.
  • +
+

+

Do we use cookies?

+

Yes. Cookies are small files that a site or its service provider transfers to your computer’s hard drive through your Web browser (if you allow). These cookies enable the site to recognize your browser and, if you have a registered account, associate it with your registered account.

+

We use cookies to understand and save your preferences for future visits and compile aggregate data about site traffic and site interaction so that we can offer better site experiences and tools in the future. We may contract with third-party service providers to assist us in better understanding our site visitors. These service providers are not permitted to use the information collected on our behalf except to help us conduct and improve our business.

+

+

Do we disclose any information to outside parties?

+

We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information. This does not include trusted third parties who assist us in operating our site, conducting our business, or servicing you, so long as those parties agree to keep this information confidential. We may also release your information when we believe release is appropriate to comply with the law, enforce our site policies, or protect ours or others rights, property, or safety. However, non-personally identifiable visitor information may be provided to other parties for marketing, advertising, or other uses.

+

+

Third party links

+

Occasionally, at our discretion, we may include or offer third party products or services on our site. These third party sites have separate and independent privacy policies. We therefore have no responsibility or liability for the content and activities of these linked sites. Nonetheless, we seek to protect the integrity of our site and welcome any feedback about these sites.

+

+

Children’s Online Privacy Protection Act Compliance

+

Our site, products and services are all directed to people who are at least 13 years old or older. If this server is in the USA, and you are under the age of 13, per the requirements of COPPA (Children’s Online Privacy Protection Act), do not use this site.

+

+

Online Privacy Policy Only

+

This online privacy policy applies only to information collected through our site and not to information collected offline.

+

+

Your Consent

+

By using our site, you consent to our web site privacy policy.

+

+

Changes to our Privacy Policy

+

If we decide to change our privacy policy, we will post those changes on this page.

+

This document is CC-BY-SA. It was last updated May 31, 2013.

+
+
+ + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/robots.txt b/pyspice-discourse-backup/robots.txt new file mode 100644 index 00000000..cc5f7e2b --- /dev/null +++ b/pyspice-discourse-backup/robots.txt @@ -0,0 +1,56 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +User-agent: mauibot +Disallow: / + + +User-agent: semrushbot +Disallow: / + + +User-agent: ahrefsbot +Disallow: / + + +User-agent: blexbot +Disallow: / + + +User-agent: seo spider +Disallow: / + + +User-agent: * +Disallow: /admin/ +Disallow: /auth/ +Disallow: /assets/browser-update*.js +Disallow: /email/ +Disallow: /session +Disallow: /user-api-key +Disallow: /*?api_key* +Disallow: /*?*api_key* +Disallow: /badges +Disallow: /u/ +Disallow: /my +Disallow: /search +Disallow: /tag/*/l +Disallow: /g +Disallow: /t/*/*.rss +Disallow: /c/*.rss + + +User-agent: Googlebot +Disallow: /admin/ +Disallow: /auth/ +Disallow: /assets/browser-update*.js +Disallow: /email/ +Disallow: /session +Disallow: /user-api-key +Disallow: /*?api_key* +Disallow: /*?*api_key* + + + +Sitemap: https://pyspice.discourse.group/sitemap.xml + + diff --git a/pyspice-discourse-backup/t/about-the-circuit-simulation-category/16.html b/pyspice-discourse-backup/t/about-the-circuit-simulation-category/16.html new file mode 100644 index 00000000..2952be7e --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-circuit-simulation-category/16.html @@ -0,0 +1,191 @@ + + + + + About the Circuit Simulation category - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the Circuit Simulation category +

+ + + +
+ + + + +
+ +
+

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/about-the-data-analysis-using-python-category/15.html b/pyspice-discourse-backup/t/about-the-data-analysis-using-python-category/15.html new file mode 100644 index 00000000..1d1d3bda --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-data-analysis-using-python-category/15.html @@ -0,0 +1,191 @@ + + + + + About the Data Analysis using Python category - Data Analysis using Python - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the Data Analysis using Python category +

+ + + +
+ + + + +
+ +
+

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/about-the-help-category/12.html b/pyspice-discourse-backup/t/about-the-help-category/12.html new file mode 100644 index 00000000..b3099200 --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-help-category/12.html @@ -0,0 +1,176 @@ + + + + + About the Help category - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the Help category +

+ + + +
+ + + + +
+ +
+

The right place to get help on PySpice

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/about-the-installation-category/17.html b/pyspice-discourse-backup/t/about-the-installation-category/17.html new file mode 100644 index 00000000..c6b802dc --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-installation-category/17.html @@ -0,0 +1,191 @@ + + + + + About the Installation category - Installation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the Installation category +

+ + + +
+ + + + +
+ +
+

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/about-the-ngspice-category/13.html b/pyspice-discourse-backup/t/about-the-ngspice-category/13.html new file mode 100644 index 00000000..27167b8a --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-ngspice-category/13.html @@ -0,0 +1,191 @@ + + + + + About the NgSpice category - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the NgSpice category +

+ + + +
+ + + + +
+ +
+

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/about-the-xyce-category/14.html b/pyspice-discourse-backup/t/about-the-xyce-category/14.html new file mode 100644 index 00000000..a203e2cb --- /dev/null +++ b/pyspice-discourse-backup/t/about-the-xyce-category/14.html @@ -0,0 +1,191 @@ + + + + + About the Xyce category - Xyce - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ About the Xyce category +

+ + + +
+ + + + +
+ +
+

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.)

+

Use the following paragraphs for a longer description, or to establish category guidelines or rules:

+
    +
  • +

    Why should people use this category? What is it for?

    +
  • +
  • +

    How exactly is this different than the other categories we already have?

    +
  • +
  • +

    What should topics in this category generally contain?

    +
  • +
  • +

    Do we need this category? Can we merge with another category, or subcategory?

    +
  • +
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/access-to-diode-parameters/108.html b/pyspice-discourse-backup/t/access-to-diode-parameters/108.html new file mode 100644 index 00000000..eefc2d01 --- /dev/null +++ b/pyspice-discourse-backup/t/access-to-diode-parameters/108.html @@ -0,0 +1,184 @@ + + + + + Access to Diode Parameters - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Access to Diode Parameters +

+ + +
+ + + + +
+ +
+

Hello,

+

when working with pyspice 1.3 it was possible for me to change device parameters in thie way described below. With 1.4 this does not seem to work any more. Is there a new or alternate syntax?

+

#############################
+import os
+os.linesep="\n"

+

source=’’’
+.title xxx

+

V1 N001 0 1 AC 1
+D1 N001 0 john

+

.model john D (Is=4.352e-9 Rs=0 N=1.906)
+.end

+

‘’’

+

parser = SpiceParser(source=source)
+circuit = parser.build_circuit()

+

circuit.john._parameters[‘Is’] = 3e-08

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.dc(V1=slice(0.1, 1,0.01))

+

#######################################

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/attributeerror-type-object-ngspiceshared-has-no-attribute-new-instance/39.html b/pyspice-discourse-backup/t/attributeerror-type-object-ngspiceshared-has-no-attribute-new-instance/39.html new file mode 100644 index 00000000..ab9b1769 --- /dev/null +++ b/pyspice-discourse-backup/t/attributeerror-type-object-ngspiceshared-has-no-attribute-new-instance/39.html @@ -0,0 +1,245 @@ + + + + + AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance' - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance' +

+ + + +
+ + + + +
+ +
+

good afternoon community among my adventure to simulate an example of the pyspice module I ran into the following error:
+---------------------------------------------------------------------------

+
AttributeError                            Traceback (most recent call last)
+
+<ipython-input-12-475d4280ae1b> in <module>()
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+      2 analysis = simulator.ac(start_frequency=1@u_Hz, stop_frequency=1@u_MHz, number_of_points=10,  variation='dec')
+
+2 frames
+
+/usr/local/lib/python3.6/dist-packages/PySpice/Spice/NgSpice/Simulation.py in __init__(self, circuit, **kwargs)
+     97         ngspice_shared = kwargs.get('ngspice_shared', None)
+     98         if ngspice_shared is None:
+---> 99             self._ngspice_shared = NgSpiceShared.new_instance()
+    100         else:
+    101             self._ngspice_shared = ngspice_shared
+
+AttributeError: type object 'NgSpiceShared' has no attribute 'new_instance
+
+

the example link is as follows
+https://pyspice.fabrice-salvaire.fr/examples/filter/low-pass-rc-filter.html
+the characteristic of my environment are the following
+ubuntu 18.04, python 3.6.2, pyscpice 1.4.2
+To clarify I am a student of electrical engineering and I am just getting into this world of computer science, thank you very much for your help

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

v1.4.3 has a tool to debug installation but still fighting on some issues …

+
pyspice-post-installation --check
+
+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/bode-plot-with-sinusoidal-current-source/103.html b/pyspice-discourse-backup/t/bode-plot-with-sinusoidal-current-source/103.html new file mode 100644 index 00000000..af4028b8 --- /dev/null +++ b/pyspice-discourse-backup/t/bode-plot-with-sinusoidal-current-source/103.html @@ -0,0 +1,172 @@ + + + + + Bode plot with sinusoidal Current Source - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Bode plot with sinusoidal Current Source +

+ + +
+ + + + +
+ +
+

Hi,

+

I successfully ran this example: https://pyspice.fabrice-salvaire.fr/releases/v1.4/examples/filter/low-pass-rc-filter.html

+

I am however interested in replacing the voltage source with a current source and still get a bode plot that compares the output voltage to input current. Just replacing the voltage source with a current source as follows gives me an error.

+

circuit.SinusoidalCurrentSource(‘input’, ‘in’, circuit.gnd, amplitude=1@u_uA)

+

NgSpiceCommandError : Command ‘run’ failed

+

Thank you in advance

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/can-spiceparser-parse-subcircuits/133.html b/pyspice-discourse-backup/t/can-spiceparser-parse-subcircuits/133.html new file mode 100644 index 00000000..df9f1f54 --- /dev/null +++ b/pyspice-discourse-backup/t/can-spiceparser-parse-subcircuits/133.html @@ -0,0 +1,176 @@ + + + + + Can SpiceParser parse subcircuits? - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Can SpiceParser parse subcircuits? +

+ + + +
+ + + + +
+ +
+

We want to parse a sp file with a netlist that embeds a subcircuit definition. When we parse it with SpiceParser we noticed that the subcircuit definition is removed. Is there a way to include the subcircuit definition during the parsing process?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/cir-to-python-classes/54.html b/pyspice-discourse-backup/t/cir-to-python-classes/54.html new file mode 100644 index 00000000..6f8dd311 --- /dev/null +++ b/pyspice-discourse-backup/t/cir-to-python-classes/54.html @@ -0,0 +1,271 @@ + + + + + .cir to Python classes - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ .cir to Python classes +

+ + + +
+ + + + +
+ +
+

I am completely new to electronics and any kind of circuit modelling. I have a .cir file that I need to turn into python classes so I can carry out precedures like chaining 2 or more subcircuits together and doing monte carlo simulation. The .cir was exported from PSpice. I was wondering, is this possible? To turn .cir to python classes? .cir has subcircuits defined.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I found the .raw_spice feature helpful to convert “classical” spice Netlists to pyspice.
+It is quite easy to add Python Variables and link to external routines.

+

One of my examples:

+

from PySpice.Spice.Netlist import Circuit

+

circuit = Circuit(‘Test’)

+

circuit.raw_spice = ‘’’
+*.title rtest
+.param rdc= ‘’’+str(rdc)+’’’
+I1 1 r 0 AC 1
+R1 r 0 {rdc}
+‘’’

+

…further pyspice commands

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You can try the cir2py command (provided with PySpice) to convert netlist to Python. But parser is not complete …

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/divide-one-ac-analysis-waveform-by-another/140.html b/pyspice-discourse-backup/t/divide-one-ac-analysis-waveform-by-another/140.html new file mode 100644 index 00000000..59752199 --- /dev/null +++ b/pyspice-discourse-backup/t/divide-one-ac-analysis-waveform-by-another/140.html @@ -0,0 +1,217 @@ + + + + + Divide one AC-analysis waveform by another - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Divide one AC-analysis waveform by another +

+ + +
+ + + + +
+ +
+

I have run an AC analysis in PySpice.
+I have found the waveform for input (source) voltage, and input (source) current.
+Now I would like to find the impedance waveform (voltage/current)
+How can I divide one waveform by another?

+

Thanks for your help!

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Get result into np.array

+

V = np.array(analysis.nodes[‘none name’])
+I = np.array(analysis.branches[‘branch name’])
+Now you can try mathematical operation ion V and I as they are numpy arrays.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/electronic-component-libraries/42.html b/pyspice-discourse-backup/t/electronic-component-libraries/42.html new file mode 100644 index 00000000..982453ed --- /dev/null +++ b/pyspice-discourse-backup/t/electronic-component-libraries/42.html @@ -0,0 +1,218 @@ + + + + + Electronic component libraries - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Electronic component libraries +

+ + + +
+ + + + +
+ +
+

Good afternoon everyone, I am writing to the community to consult a page to find electronic components for pyspice something similar to the page of https://www.snapeda.com/, if anyone has information you are very much appreciated

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You have to search on manufacturer sites to find a Spice library compatible with NgSpice.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/error-in-running-examples/127.html b/pyspice-discourse-backup/t/error-in-running-examples/127.html new file mode 100644 index 00000000..d18bf463 --- /dev/null +++ b/pyspice-discourse-backup/t/error-in-running-examples/127.html @@ -0,0 +1,178 @@ + + + + + Error in running examples - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Error in running examples +

+ + + +
+ + + + +
+ +
+

I’ve just installed PySpice (on Fedora, using pip install PySpice). I’ve downloaded the examples with pyspice-post-installation --download-example and tried to run them. I get a number of errors, but the one that appears most often is:

+

pyspice-post-installation --download-example

+

I googled the problem but couldn’t fix it, grateful for suggestions.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/example-transistor/36.html b/pyspice-discourse-backup/t/example-transistor/36.html new file mode 100644 index 00000000..001f8908 --- /dev/null +++ b/pyspice-discourse-backup/t/example-transistor/36.html @@ -0,0 +1,487 @@ + + + + + Example transistor - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Example transistor +

+ + + +
+ + + + +
+ +
+

good afternoon I communicate with the community because I am not very good at programming but I am trying to learn how to simulate circuits that I need for a job, however when I try to simulate the circuit of the example of transistors I get the following error

+
Traceback (most recent call last):
+  File "polos.py", line 50, in <module>
+    circuit.include(spice_library['2n2222a'])
+  File "/usr/local/lib/python3.6/dist-packages/PySpice/Spice/Library.py", line 107, in __getitem__
+    raise KeyError(name)
+KeyError: '2n2222a'
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

It looks like you didn’t provide a spice model for the 2n2222a transistor. In general, spice models are mostly protected by copyrights so you shouldn’t expect to get models with PySpice or Ngspice (or really any other open source project for that matter). You can still find them online though. For instance, here’s a link to the model you want. That site contains tons of other useful models too. The other way I know to find them is to search the product vendor and spice. A bunch of MFGs provide spice models, but you have to download it from their site.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

thank you very much I had no idea about that

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

The 2n2222a is actually provided in the PySpice example directory (PySpice/examples/libraries/transistor/2N2222A.lib) for demonstration purpose.

+

The only “trick” is to provide the path of the library directory in your own python script.

+

The example “PySpice/examples/transistor/transistor.py” works because the library path is generated using the PySpice standard location and provided through the commands :

+
libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)
+
+

In your case, you should provide SpiceLibrary(...) with the path of your library directory.
+(Except if you exactly match the PySpice example directory architecture, you should always provide the path of your library directory. )

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

@huszaghmatt copyright issue is an important point to mention !

+

Does somebody know if we could implement a web downloader ??? What about Eagle ??? I have the feeling that on some points the electronic industry doesn’t help CAD design …

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I’m intrigued by the idea of a spice model downloader. Finding spice models is a bit time-consuming and it’s a hurdle when you first get started with simulations.

+

One nice feature would be to store a cache of models and download urls so that someone using the downloader wouldn’t need to rescrape the sites or give the downloader hints about where to find the model. I imagine this would be permissible without violating copyright since we wouldn’t store the models. The cache does of course present some additional challenges. The repo would either need frequent PRs as the model locations change, or require supporting a server to perform the scrapes.

+

I also wonder if it’s worthwhile to do this as a separate project from PySpice, since other projects might be able to leverage this functionality without requiring the full-blown simulation capability of PySpice. Just a thought.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Infineon / IRF has https://www.infineon.com/cms/en/tools/solution-finder/product-finder/simulation-model/

+

but nothing is standardized ,nor library, nor Spice dialect

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

for generic part like 2n2222a we could make a repo similar to what Kicad do

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/extract-array-of-complex-numbers-from-waveform/139.html b/pyspice-discourse-backup/t/extract-array-of-complex-numbers-from-waveform/139.html new file mode 100644 index 00000000..12394f3c --- /dev/null +++ b/pyspice-discourse-backup/t/extract-array-of-complex-numbers-from-waveform/139.html @@ -0,0 +1,218 @@ + + + + + Extract array of complex numbers from waveform - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Extract array of complex numbers from waveform +

+ + +
+ + + + +
+ +
+

Hi

+

I am just getting started with PySpice.

+

I have run an AC analysis on a netlist using PySpice, and have extracted my waveforms, but would like to convert these into a numpy array of complex numbers - how do I do this?

+

I want to do further mathematical analysis on the PySpice Waveform output.

+

Thanks

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

If say you have
+analysis = simulator.AC(…)
+then try
+c = np.array(analysis.nodes[‘in’]) where "in’ is one of the nodes
+print(c)
+and check if it is complex

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138.html b/pyspice-discourse-backup/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138.html new file mode 100644 index 00000000..6e923a55 --- /dev/null +++ b/pyspice-discourse-backup/t/extract-float-type-number-from-class-pyspice-unit-unit-unitvalue/138.html @@ -0,0 +1,173 @@ + + + + + Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Extract float-type number from class 'PySpice.Unit.Unit.UnitValue' +

+ + +
+ + + + +
+ +
+

Hi

+

I am just getting started with using PySpice.

+

I have extracted voltage/current values from a PySpice analysis, and would like to analyze these using other Python functions.

+

But all of my values are now of type class ‘PySpice.Unit.Unit.UnitValue’.

+

How can I remove the units, so that these are just normal float numbers?

+

Thanks

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/getting-keyerror-while-running-example/119.html b/pyspice-discourse-backup/t/getting-keyerror-while-running-example/119.html new file mode 100644 index 00000000..9c93c78a --- /dev/null +++ b/pyspice-discourse-backup/t/getting-keyerror-while-running-example/119.html @@ -0,0 +1,326 @@ + + + + + Getting keyerror while running example - Installation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Getting keyerror while running example +

+ + + +
+ + + + +
+ +
+

As i’m new to pyspice when i am running this example
+https://pyspice.fabrice-salvaire.fr/releases/v1.3/examples/diode/diode-characteristic-curve.html

+

I am getting this keyerror

+

I m using windows 10 64 bit
+Ide : Anaconda python
+Pyspice 1.4.3
+Ngspice 32

+

If any gentlemen has idea how to fix this it ll help me a lot :smiley:

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Its a common error. You need to make sure the 1N4148.lib file exists and its path is properly defined.

+

One way to define and handle diode models is here: Introduction to PYSPICE (Python) for Simulating a complete Regulated Power Supply Circuit - YouTube

+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+
+ +
+

Thankyou for response sir,
+i’ve downloaded 1N4148.lib from the github examples library. As i m new to pyspice can you please tell me how to define path properly ? It ll be really helpful if you explain in detail how to define path properly .I ve watched your amazing tutorials on pyspice so far.

+

May be a youtube video on this topic may help many begineers who come across this error.
+Thankyou sir.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You need to have an understanding of how paths work in python.

+

A better solution is to just define the diode model within the Python script:

+

circuit.model(‘1N4148’, ‘D’, IS = 4.352E-9, N = 1.906, BV = 110, IBV = 0.0001, RS = 0.6458, CJO = 7.048E-13, VJ = 0.869, M = 0.03, FC = 0.5, TT = 3.48E-9)

+

Modify the line in the netlist where the diode is defined to include:

+

model = ‘1N4148’

+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/getting-started-rlc-example/77.html b/pyspice-discourse-backup/t/getting-started-rlc-example/77.html new file mode 100644 index 00000000..cbd977ca --- /dev/null +++ b/pyspice-discourse-backup/t/getting-started-rlc-example/77.html @@ -0,0 +1,180 @@ + + + + + Getting started -- RLC example - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Getting started -- RLC example +

+ + + +
+ + + + +
+ +
+

Hello everyone! I am new to pyspice and trying to run the example. The issue I’m running into is with rlc-filter.py, the bode plots aren’t working and don’t match what’s in the documentation. Here are screenshots of the plots and the output which hopefully points to the issue.
+


+
+I appreciate any advice on how to fix this!

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/google-colab-pyspice/125.html b/pyspice-discourse-backup/t/google-colab-pyspice/125.html new file mode 100644 index 00000000..d6c121a4 --- /dev/null +++ b/pyspice-discourse-backup/t/google-colab-pyspice/125.html @@ -0,0 +1,222 @@ + + + + + Google COLAB + PySpice - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Google COLAB + PySpice +

+ + + +
+ + + + +
+ +
+

I trying use PySpice on google Colab, but I fail…
+Some one can tell me if is possible, and how i can do?

+

Aparently… I should but i dont be able to install or reference there the “ngspice dll”

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

The repo is currently broken: Fix ngspice download URL by endolith · Pull Request #270 · FabriceSalvaire/PySpice · GitHub

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/how-to-define-multiple-bjts-in-the-same-circuit/86.html b/pyspice-discourse-backup/t/how-to-define-multiple-bjts-in-the-same-circuit/86.html new file mode 100644 index 00000000..68659a62 --- /dev/null +++ b/pyspice-discourse-backup/t/how-to-define-multiple-bjts-in-the-same-circuit/86.html @@ -0,0 +1,208 @@ + + + + + How to define multiple BJTs in the same circuit? - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ How to define multiple BJTs in the same circuit? +

+ + +
+ + + + +
+ +
+

If I try to define a pnp and an npn BJT in the same circuit:

+
circuit.BJT(1, 'in', 'in', 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(2, 2, 'in', 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(5, 'out', 2, 0, model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(6, 4, 5, 'out', model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(3, 'in', 4, 'in', model='bjt')# Q is mapped to BJT !
+circuit.model('bjt', 'pnp', bf=80, cjc=pico(5), rb=100)
+
+circuit.BJT(4, 2, 'in', 4, model='bjt') # Q is mapped to BJT !
+circuit.model('bjt', 'pnp', bf=80, cjc=pico(5), rb=100)
+
+

PySpice doesn’t allow me to call model() twice:

+
---------------------------------------------------------------------------
+NameError                                 Traceback (most recent call last)
+<ipython-input-2-c7415312c779> in <module>
+     15 
+     16 circuit.BJT(2, 2, 'in', 0, model='bjt')# Q is mapped to BJT !
+---> 17 circuit.model('bjt', 'npn', bf=80, cjc=pico(5), rb=100)
+     18 
+     19 circuit.BJT(5, 'out', 2, 0, model='bjt')# Q is mapped to BJT !
+
+~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Netlist.py in model(self, name, 
+modele_type, **parameters)
+   1002             self._models[model.name] = model
+   1003         else:
+-> 1004             raise NameError("Model name {} is already defined".format(name))
+   1005 
+   1006         return model
+
+NameError: Model name bjt is already defined
+
+

What is the proper way to do this?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147.html b/pyspice-discourse-backup/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147.html new file mode 100644 index 00000000..0748a814 --- /dev/null +++ b/pyspice-discourse-backup/t/how-to-get-voltage-acrros-two-points-to-write-behavioral-voltage-source-expression/147.html @@ -0,0 +1,385 @@ + + + + + How to get voltage acrros two points to write behavioral voltage source expression? - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ How to get voltage acrros two points to write behavioral voltage source expression? +

+ + +
+ + + + +
+ +
+

I am new with pyspice. I want to add a behavioral voltage source to my circuit. To write its expression we need voltage across two points x and y. For example v=2*Voltage(x,y)

+

Will anyone share the syntax in pyspice?
+Thank you.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Trying to do the same. Not sure what syntax to use to access the node voltages in the circuit. @sant: Were you able to make any progress. If you can share what you tried maybe we can help each other to solve this issue.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

yes. Use the following .

+

circuit.B(‘name’, ‘node1’, circuit.gnd, v=‘2*V(x,y)’)

+

v----> is small and V(x,y)—> here V is capital

+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+
+ +
+

Thank you. Is this syntax with Linux or Windows operating system.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I did it with ubuntu os

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Thank you. Its puzzling but the syntax does not work in Windows…

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/how-to-measure-voltage-and-current-in-pyspice/74.html b/pyspice-discourse-backup/t/how-to-measure-voltage-and-current-in-pyspice/74.html new file mode 100644 index 00000000..0c64d423 --- /dev/null +++ b/pyspice-discourse-backup/t/how-to-measure-voltage-and-current-in-pyspice/74.html @@ -0,0 +1,233 @@ + + + + + How to measure voltage and current in pyspice - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ How to measure voltage and current in pyspice +

+ + + +
+ + + + +
+ +
+

hi,everybody!

+

I’ve built a memristor model in Pspice,The model can run .I wanted it to run in pyspice, but there was an error.

+

In PSpice, the following statement is OK :
+Emem plus aux value={-I(Emem)V(x)(1000-10)}

+

But in pyspice,An error occurred.

+

NameError: name ‘V’ is not defined

+

The reason is that V (x) and I (EMEM) have problems.How can I solve this problem?

+

Thank you very much!

+

Environment (windows10, Python 3.2, PySpice 1.4.3, NGspice)

+

Expected Behaviour

+

Actual Behaviour

+

Steps to reproduce the behaviour

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

@ fsalvaire

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/how-to-modify-a-bjts-parameters/64.html b/pyspice-discourse-backup/t/how-to-modify-a-bjts-parameters/64.html new file mode 100644 index 00000000..42d6c174 --- /dev/null +++ b/pyspice-discourse-backup/t/how-to-modify-a-bjts-parameters/64.html @@ -0,0 +1,181 @@ + + + + + How to modify a BJT's parameters? - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ How to modify a BJT's parameters? +

+ + +
+ + + + +
+ +
+

I have checked the API documentation but didn’t find an answer or example.

+
+

circuit = Circuit(‘Transistor’)
+source = circuit.SinusoidalVoltageSource(‘in’, ‘in’, circuit.gnd, amplitude=.5@u_V, frequency=1@u_kHz)
+Vpower = circuit.V(‘power’, 5, circuit.gnd, 15@u_V)
+R1 = circuit.R(1, 5, 2, 100@u_kΩ)
+RC = circuit.R(‘C’, 5, 4, 10@u_kΩ)
+C2 = circuit.C(2, 4, ‘out’, 10@u_uF)
+C1 = circuit.C(1, ‘in’, 2, 10@u_uF)

+

Q1= circuit.BJT(1, 4, 2, 3, model=‘bjt’) # Q is mapped to BJT !
+circuit.model(‘bjt’, ‘npn’, bf=80, cjc=pico(5), rb=100) #rb: Base Resistor

+
+

How to change BJT’s rb in this case?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148.html b/pyspice-discourse-backup/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148.html new file mode 100644 index 00000000..d762f66f --- /dev/null +++ b/pyspice-discourse-backup/t/how-to-write-func-in-pyspice-and-use-it-in-behavioral-source/148.html @@ -0,0 +1,178 @@ + + + + + How to write .func in pyspice and use it in behavioral source? - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ How to write .func in pyspice and use it in behavioral source? +

+ + + +
+ + + + +
+ +
+

I want to write a .func that will help me designing a device model. I used **raw_spice=’ …’ ** but it is not working. I am new in pyspice.

+

Thank yuo

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/howto-transient-analysis/150.html b/pyspice-discourse-backup/t/howto-transient-analysis/150.html new file mode 100644 index 00000000..0032bc88 --- /dev/null +++ b/pyspice-discourse-backup/t/howto-transient-analysis/150.html @@ -0,0 +1,307 @@ + + + + + Howto: Transient analysis - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Howto: Transient analysis +

+ + +
+ + + + +
+ +
+

I want to do a transient analysis of a square wave.

+
    +
  1. How do I do a transient analysis and plot the output?
  2. +
  3. How do I implement a square wave?
  4. +
+

I found nothing in the examples. Thanks for your help,
+Michael

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Okay, now I have the following code

+

+#r# This example shows the computation of the DC biases in a resistor bridge.
+
+####################################################################################################
+
+import matplotlib.pyplot as plt
+##
+import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+####################################################################################################
+
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *
+
+####################################################################################################
+
+#f# circuit_macros('resistor-bridge.m4')
+
+circuit = Circuit('Resistor Divider')
+#circuit.PulseMixin(0@u_V, 20@u_V, 5@u_us, 10@u_us, delay_time=0) #doesn't work
+circuit.V('i', 'inp', circuit.gnd, 10@u_V) #works
+circuit.R(1, 'inp', 'out', 5@u_kΩ)
+circuit.R(2, 'out', circuit.gnd, 5@u_kΩ)
+
+
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=1@u_us, end_time=500@u_us)
+
+####################################################################################################
+
+figure1, ax = plt.subplots(figsize=(20, 10))
+ax.set_title('Voltage Divider')
+ax.set_xlabel('Time [s]')
+ax.set_ylabel('Voltage [V]')
+ax.grid()
+ax.plot(analysis.inp)
+ax.plot(analysis.out)
+ax.legend(('input', 'output'), loc=(.05,.1))
+#ax.set_ylim(float(-amplitude*1.1), float(amplitude*1.1))
+
+#plt.tight_layout()
+plt.show()
+
+

Can somebody help me please with the pulsed source?

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You can use circuit.PulseVoltageSource() command.

+

See example code posted in the comments here: Introduction to PySpice (Python) for Simulating Natural and Step Response of RC Circuits - YouTube

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/inputing-data-from-python-model-into-ngspice-shared-netlist/66.html b/pyspice-discourse-backup/t/inputing-data-from-python-model-into-ngspice-shared-netlist/66.html new file mode 100644 index 00000000..263d71cd --- /dev/null +++ b/pyspice-discourse-backup/t/inputing-data-from-python-model-into-ngspice-shared-netlist/66.html @@ -0,0 +1,186 @@ + + + + + Inputing data from python model into ngspice shared netlist - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Inputing data from python model into ngspice shared netlist +

+ + + +
+ + + + +
+ +
+

Hello,

+

I’ve been trying to simulate a model of a neuron coupled to a microelectrode in ngspice. However, while the microelectrode is easy to simulate the neuronal model is quite difficult. As such, when I found pyspice I thought maybe I could use the netlist I already have for the microelectrode and create the neuron model in python and use the output voltage of the neuron model as an input in the microelectrode model.
+I’ve read through all the examples and some documentation and even used the ngspice shared interpreter example with my microelectrode netlist but I cannot even find a way of just plotting the circuits transient analysis (without the neuron model) as I did with ngspice.

+

To summarize, my questions are:

+
    +
  1. Can I use my already written netlist of the microelectrode with the ngspice shared option ?
  2. +
  3. To interface the neuron model that I will write in python as source voltage for the microelectrode does it mean that I have to re-write the netlist into pyspyce nomenclature ?
  4. +
+

PS: I can provide my netlist if necessary.

+

Thank you for your time.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/installation-example-scripts/117.html b/pyspice-discourse-backup/t/installation-example-scripts/117.html new file mode 100644 index 00000000..2e2f8533 --- /dev/null +++ b/pyspice-discourse-backup/t/installation-example-scripts/117.html @@ -0,0 +1,199 @@ + + + + + Installation example scripts - Installation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Installation example scripts +

+ + + +
+ + + + +
+ +
+

Dear PySpice community, I would like to share some installation example files to illustrate the installation procedure of PySpice on Linux by using apt and pip only.

+

Those files are published as Dockerfile scripts since they allow full automatic machine instantiation with docker.
+They cover both Ubuntu and Debian, using a standard approach using only apt :

+ +

One can also find a more “manual” approach to demonstrate how to properly set the PYTHONPATH and LD_LIBRARY_PATH environment variables :

+ +

The two latter should be useful for those who want to install PySpice on Google Collab.

+

If you have docker on your computer, you can also pull directly the images from Docker Hub :

+ +

Enjoy !

+
+ + + + +
+ + + 1 Like +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/interrupted-simulation-multiple-sources/144.html b/pyspice-discourse-backup/t/interrupted-simulation-multiple-sources/144.html new file mode 100644 index 00000000..98498ab1 --- /dev/null +++ b/pyspice-discourse-backup/t/interrupted-simulation-multiple-sources/144.html @@ -0,0 +1,190 @@ + + + + + Interrupted simulation multiple sources - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Interrupted simulation multiple sources +

+ + + +
+ + + + +
+ +
+

Hi everyone,

+

for a research project I’m working on control strategies for PFC circuits and therefore I need to simulate a passive circuit in conjunction with two half bridges.
+Problem is that I need the simulation to interact with a python script since I need to calculate the control signals of the two half bridges externally and thus the simualtion flow is as follows.

+

First, I need to initialize the simulation which basically means that I need to sample the amplitude and phase of a sinusodial source representing the grid voltage and the component values and initial conditions of the passive components. Next, I need to run the simulation in chunks where I first calculate the four control signals of the half bridges based on the current and voltage signals of the passive circuit followed by a chunk of transient simulation for a given time span (sample rate of the controller).

+

I tried to implement this flow but I unfortunately I struggle with the following issues.

+

a) Phase of the AC source:
+I tired SinusoidalVoltageSource() but I failed to specify a phase offset. Altough it’s base class SinusoidalMixin() offers a delay attribute, it seems that it just enables the source after a given time and thus this isn’t the desired behaviour for my purpose. Alternatively, I defined my own grid voltage using a NgSpiceShared object according …/examples/ngspice-shared/external-source.html.
+This essential does the trick for me but leaves with the next problem.

+

b) Multiple External Sources:
+Give the simulation flow above I need to run the simulation with at least four external sources, two for every half bridge, and five if I define the grid voltage also as external source. So I wonder how I define multiple shared objects.

+

c) Setting the initial conditions
+Since I run the simulation in chunks I wonder if I have to preload the nodes with the latest values and I need to run the simulation with start_time=0 and end_time=timespan according the controller’s sample rate or are the states kept internally and I need just to run the simulation with start_time=(k-1)timespan, end_time=ktimespan in order to run the kth simulation chunk.

+

Any help is kindly appreciated!

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/is-pyspice-1-4-2-compatible-with-ngspice-33/101.html b/pyspice-discourse-backup/t/is-pyspice-1-4-2-compatible-with-ngspice-33/101.html new file mode 100644 index 00000000..c268524b --- /dev/null +++ b/pyspice-discourse-backup/t/is-pyspice-1-4-2-compatible-with-ngspice-33/101.html @@ -0,0 +1,211 @@ + + + + + Is PySpice 1.4.2 compatible with Ngspice 33? - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Is PySpice 1.4.2 compatible with Ngspice 33? +

+ + +
+ + + + +
+ +
+

Hello Community,

+

I have set up PySpice 1.4.2 through a virtual environment and brew installed Ngspice and libngspice on Mac 0S X. However, “pyspice-post-installation --check-install” tells me that Ngspice version 33 is not supported.

+

Please advise.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I had the same issue. I uninstalled Python (32 bit) and installed the Python (64 bit). Reinstalled Pyspice and Ngspice and now it works.

+

Salman

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/is-there-a-way-to-manipulate-parameter-during-the-simulation/72.html b/pyspice-discourse-backup/t/is-there-a-way-to-manipulate-parameter-during-the-simulation/72.html new file mode 100644 index 00000000..235a201d --- /dev/null +++ b/pyspice-discourse-backup/t/is-there-a-way-to-manipulate-parameter-during-the-simulation/72.html @@ -0,0 +1,183 @@ + + + + + Is there a way to manipulate parameter during the simulation - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Is there a way to manipulate parameter during the simulation +

+ + + +
+ + + + +
+ +
+

Hello everyone,

+

ist it possible to ‘pause’ the simulation, get values of certain voltages or currents manipulate them and put them back into the simulation?

+

For example to implement a digital controller or something like that.

+

Thank you for any help.

+

Kind regards
+RNWx

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/large-archive-of-spice-models-subcircuits/67.html b/pyspice-discourse-backup/t/large-archive-of-spice-models-subcircuits/67.html new file mode 100644 index 00000000..6ac71357 --- /dev/null +++ b/pyspice-discourse-backup/t/large-archive-of-spice-models-subcircuits/67.html @@ -0,0 +1,165 @@ + + + + + Large archive of SPICE models/subcircuits - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Large archive of SPICE models/subcircuits +

+ + +
+ + + + +
+ +
+

I posted a message on the SKiDL forum about using SKiDL/PySpice with a large archive of SPICE models.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/library-import-corner-analysis/143.html b/pyspice-discourse-backup/t/library-import-corner-analysis/143.html new file mode 100644 index 00000000..c74fcfb4 --- /dev/null +++ b/pyspice-discourse-backup/t/library-import-corner-analysis/143.html @@ -0,0 +1,190 @@ + + + + + Library import corner analysis - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Library import corner analysis +

+ + + +
+ + + + +
+ +
+

Hello!

+

I am not familiar with English so if there is something not clear, please ask me!!

+

I am trying to import library file using corner analysis
+The code below is what I wish to use in NgSpice text

+
.lib 'mm018.l' TT
+
+

Since there is “TT” added for typical type analysis,
+I can’t use the library import using the code below in pyspice

+
spice_library = SpiceLibrary('./library_to_add')
+
+

I have no idea how I should solve this problem, please help me

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/looking-for-a-xyce-example/82.html b/pyspice-discourse-backup/t/looking-for-a-xyce-example/82.html new file mode 100644 index 00000000..61e26998 --- /dev/null +++ b/pyspice-discourse-backup/t/looking-for-a-xyce-example/82.html @@ -0,0 +1,282 @@ + + + + + Looking for a Xyce Example - Xyce - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Looking for a Xyce Example +

+ + + +
+ + + + +
+ +
+

Hi, I have installed Xyce, NGSpice and PySpice and everything is almost working… except, when I run on iPython (actually Anaconda Spyder) then I stumbled into a cdef problem on duplidate definition of ngcomplex. I can see on github some discussion, but not clear to me how to move forward on it. No mater, I have Xyce. But then I was stumbling at the start [again]. The documentation says to set an attribute

+

PySpice.Spice.Xyce.Server.XyceServer.XYCE_COMMAND = “C:\Program Files\Xyce 7.1 OPENSOURCE\bin\Xyce.exe”

+

But where do I type that? It seems to be an attribute of a class or something?? So then I try
+… = simulator(xyce_command=r"C:\Program Files\Xyce 7.1 OPENSOURCE\bin\Xyce.exe", simulator=‘xyce-serial’,…)

+

and that one dies with file not found, although it is the correct command to launch Xyce.

+

What finally worked (yeh!) was to edit by hand the PySpice source code and find where XyceCommand was defined and wow. I’m amazed. Works perfectly :slight_smile:

+

But was there a cleaner way that I could have done this?

+

Thanks so much for putting this product together. I’m excited to check it out further.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I would also like Xyce examples too!

+

Following the comments above, I managed to make all work in Ubuntu 20.04 here is some code:

+
import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+from PySpice.Spice.Netlist import Circuit
+
+import matplotlib.pyplot as plt
+import numpy as np
+
+pCircuit1 = Circuit('Filtro pasabajo Bessel 3er orden')
+
+pCircuit1.SinusoidalVoltageSource('input', 'in', pCircuit1.gnd, amplitude=1)
+
+pCircuit1.R('G', 'in',  1, 1)
+pCircuit1.L('1',    1,  2,  1.255 )
+pCircuit1.C('1',    2,  pCircuit1.gnd,  0.5528 )
+pCircuit1.L('2',    2,  'out', 0.1922 )
+pCircuit1.R('L','out',  pCircuit1.gnd, 1)
+
+# NGspice
+# simulation1 = pCircuit1.simulator(temperature=25, nominal_temperature=25)
+# Xyce-serial
+simulation1 = pCircuit1.simulator(simulator = 'xyce-serial', xyce_command='/home/mariano/XyceInstall/Serial/bin/Xyce', temperature=25, nominal_temperature=25)
+
+analysis1 = simulation1.ac(start_frequency=0.001, stop_frequency=100, number_of_points=100,  variation='dec')
+
+ff = 2*np.pi * np.array(analysis1.frequency.tolist())
+
+figure, (axMod, axPha) = plt.subplots(2, sharex = True, figsize=(20, 10))
+
+axMod.semilogx(ff, 20*np.log10(np.abs(analysis1['out'])))
+axMod.semilogx(True)
+axMod.grid(True)
+axMod.grid(True, which='minor')
+axMod.set_ylabel("Módulo [dB]")
+
+plt.sca(axMod)
+plt.title("Síntesis doblemente cargada: Bessel de 3er orden")
+
+phase = np.unwrap(np.angle(analysis1['out']))
+delay = - np.diff(phase) / np.diff(ff)
+delay = np.concatenate(([delay[0]], delay))
+axPha.semilogx(ff, delay)
+axPha.grid(True)
+axPha.grid(True, which='minor')
+axPha.set_xlabel("Frecuencia [rad/s]")
+axPha.set_ylabel("Retardo [s]")
+
+

As a result a plot like that should be produced:

+

+

The simulation is for this circuit

+

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/looking-for-two-mod-files-used-in-an-example-code/59.html b/pyspice-discourse-backup/t/looking-for-two-mod-files-used-in-an-example-code/59.html new file mode 100644 index 00000000..b273abb0 --- /dev/null +++ b/pyspice-discourse-backup/t/looking-for-two-mod-files-used-in-an-example-code/59.html @@ -0,0 +1,218 @@ + + + + + Looking for two .mod files used in an example code - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Looking for two .mod files used in an example code +

+ + + +
+ + + + +
+ +
+

Hello. How are you guys doing? I am looking for the model files of the 1N5822 and the irf150 from the buck convertor example in the link below. https://pyspice.fabrice-salvaire.fr/releases/v1.4/examples/switched-power-supplies/buck-converter.html . Thanks for any help that I get.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

There are in examples\libraries

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/losing-units-when-summing-a-waveform/97.html b/pyspice-discourse-backup/t/losing-units-when-summing-a-waveform/97.html new file mode 100644 index 00000000..0f367dd9 --- /dev/null +++ b/pyspice-discourse-backup/t/losing-units-when-summing-a-waveform/97.html @@ -0,0 +1,177 @@ + + + + + Losing units when summing a Waveform - Data Analysis using Python - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Losing units when summing a Waveform +

+ + + +
+ + + + +
+ +
+

I multiplied two Waveform objects: one containing voltages and the other containing currents. Then I multiplied it by a PeriodValue. As expected, the resulting Wavform object contains numbers with the units of Joules. But when I applied the sum() method to this Waveform, I got a scalar value with no units.

+

Is there any way to do this without losing the units for the calculations that follow?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/ngspice-options-help/131.html b/pyspice-discourse-backup/t/ngspice-options-help/131.html new file mode 100644 index 00000000..a080cf0d --- /dev/null +++ b/pyspice-discourse-backup/t/ngspice-options-help/131.html @@ -0,0 +1,229 @@ + + + + + NgSpice Options Help - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ NgSpice Options Help +

+ + + +
+ + + + +
+ +
+

How do you use the simulation options in a simulation? For example how does one call up any of the options in chapter 15.1 of the NgSpice users guide.

+

Say I want to change the transient solver to METHOD=‘Gear’ how would I?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Figured it out, plus a few other examples

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+simulator.initial_condition(node1=0.0)
+simulator.options(reltol=1e-3)
+simulator.options(‘method=gear’)
+simulator.save([‘in’, ‘out’])

+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/oserror-cannot-load-library-libngspice-so/37.html b/pyspice-discourse-backup/t/oserror-cannot-load-library-libngspice-so/37.html new file mode 100644 index 00000000..62dc0408 --- /dev/null +++ b/pyspice-discourse-backup/t/oserror-cannot-load-library-libngspice-so/37.html @@ -0,0 +1,489 @@ + + + + + OSError: cannot load library 'libngspice.so': - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ OSError: cannot load library 'libngspice.so': +

+ + +
+ + + + +
+ +
+

Good afternoon community, I am writing to you because I have encountered the following error trying to simulate the following filter that appears in the documentation.

+

https://pyspice.fabrice-salvaire.fr/examples/filter/low-pass-rc-filter.html

+

The error is as follows.
+2020-05-23 00:45:37,954 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.new_instance - INFO - New instance for id 0
+2020-05-23 00:45:37,955 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._load_library - WARNING - Set locale LC_NUMERIC to C

+
---------------------------------------------------------------------------
+
+OSError                                   Traceback (most recent call last)
+
+<ipython-input-6-475d4280ae1b> in <module>()
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+      2 analysis = simulator.ac(start_frequency=1@u_Hz, stop_frequency=1@u_MHz, number_of_points=10,  variation='dec')
+
+8 frames
+
+/usr/local/lib/python3.6/dist-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
+    825         if first_error is not None:
+    826             msg = "%s.  Additionally, %s" % (first_error, msg)
+--> 827         raise OSError(msg)
+    828     return backend.load_library(path, flags)
+    829 
+
+OSError: cannot load library 'libngspice.so': libngspice.so: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libngspice.so'
+
+

I have installed all the dependencies, although I have run out of ideas, I am starting in the world of programming, however, they asked me for a job to simulate filters in the university. I need your help, if possible, a lot of fat in advance

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Please provide infos about your environment :
+OS, Python version, PySpice version, simulator

+

From your very incomplete infos, (I guess you are on linux from what I read) :

+
    +
  1. +libngspice is not installed ; or,
  2. +
  3. +LD_LIBRARY is not properly set
  4. +
+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

pyscpice 1.4.2, python 3.6.2, Ubuntu 18.04.4 LTS, i couldn’t install libngspice

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I have tried to install the libngspice library in ubuntu but it did not succeed it tells me that it cannot find it

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

On Ubuntu, libngspice is only available for 19.10 and after :
+https://packages.ubuntu.com/search?keywords=libngspice0&searchon=names&suite=all&section=all
+That is why you cannot install it on 18.04

+

From that point, you can either

+
    +
  • compile the library by yourself (which I suspect, is beyond your knowledge) ;
  • +
  • download the package and its dependencies from packages.ubuntu.com, arrange the library and set the LD_LIBRARY_PATH (which may also be a not trivial operation for you)
  • +
  • create a virtual machine with an Ubuntu 19.10 guest (the easiest solution ; with all the drawbacks of virtual machines)
  • +
+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+
+ +
+

well it was tried, I will look for other methods to see how to install it, however I will also look for another library that will help me

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I recently added an “invoke” task to compile ngspice due to the lack of libngspice on Ubuntu Travis CI. To be documented …

+
pip install invoke
+
+
inv -l
+
+  ngspice.build
+  ngspice.clean
+  ngspice.configure
+  ngspice.get-last-release-note
+  ngspice.get-last-version
+  ngspice.get-manual
+  ngspice.get-osx
+  ngspice.get-source
+  ngspice.get-windows
+  ngspice.get-windows-dll
+  ngspice.install
+
+
inv ngspice.install
+
+
+ + + +
+ + + +
+ +
+ + +
+ + +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/param-command-and-formula-evaluation/44.html b/pyspice-discourse-backup/t/param-command-and-formula-evaluation/44.html new file mode 100644 index 00000000..acaea6f1 --- /dev/null +++ b/pyspice-discourse-backup/t/param-command-and-formula-evaluation/44.html @@ -0,0 +1,424 @@ + + + + + .param command and formula evaluation - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ .param command and formula evaluation +

+ + + +
+ + + + +
+ +
+

Hello All,
+being familiar with spice, usually prefer to create netlists in the bootstrapping way like this:

+

from PySpice.Spice.Parser import SpiceParser

+

#######################################

+

+

+

import os
+os.linesep="\n"

+

source=’’’
+.title abc

+

V1 inx 0 DC 2V
+R1 inx out 1k
+R2 out 0 2k
+.end
+‘’’

+

parser = SpiceParser(source=source)
+circuit = parser.build_circuit()

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+#analysis = simulator.dc(V1=slice(Vmin, Vmax,Vstep))
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:5.2f} V’.format(str(node), float(node)))

+

######################################

+

However in Spice Macromodels global parameters should be possible like a netlist in this way:
+######################################
+…
+source=’’’
+.title abc
+.param res=1k
+V1 inx 0 DC 2V
+R1 inx out {res}
+R2 out 0 2k
+.end
+‘’’
+… and so on…

+

Anyway, the parser does not seem to recognize neither the “.param” nor the curled braces.

+

Is there a workaround for this?

+

Kind rgs Martin

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Actually the parser is quite incomplete, there is some improvements in a PR to be merged. I think it will be hard to implement a full parser due to the lack of grammar. I am afraid we have to look in the NgSpice code to learn it.

+

However you can try the .raw feature to pass raw spice and just get outputs.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Hi, can you give me an example how this may work?

+
+ + + +
+ + + +
+ +
+ + +
+ + +
+
+ +
+

I just added an example …

+
circuit = Circuit('Test')
+
+#r# Pass raw Spice definitions to a circuit, aka netlist, content is inserted at the beginning of
+#r# the netlist.
+circuit.raw_spice = '''
+Vinput in 0 10V
+R1 in out 9kOhm
+'''
+
+#r# Pass element parameters as raw Spice, content is concatenated with `R2 out 0`
+circuit.R(2, 'out', 0, raw_spice='1k')
+
+print(circuit)
+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

This works:

+

circuit = Circuit(‘Test’)

+

circuit.raw_spice = ‘’’
+.param x=5000
+V1 in 0 10
+R1 in out 500
+R2 out 0 1000
+R3 out 0 {x}
+‘’’

+

print(circuit)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

print(analysis.branches)

+

z=analysis.branches

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/problems-with-running-simulator/153.html b/pyspice-discourse-backup/t/problems-with-running-simulator/153.html new file mode 100644 index 00000000..508f7cbb --- /dev/null +++ b/pyspice-discourse-backup/t/problems-with-running-simulator/153.html @@ -0,0 +1,242 @@ + + + + + Problems with running simulator - Installation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Problems with running simulator +

+ + + +
+ + + + +
+ +
+

Hi every one!
+I am new to PySpice. I was running 1.4.3 ver with ngspice 3.2 and everything was working well.
+My computer did a usual clean up and update.

+

Now the netlist part works fine. But when I call the simulator I get a long error message (I will paste below). I was doing good progress and I am glad to share a 3 phase diode rectifier model which was working well. Until this problem arose. When I did an update I see that the cur ver is 1.5 and installs ngspice 3.4

+

Any help is appreciated. Else will have to go back to LTspice

+

Error msg attached below

+
+

TypeError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit3.simulator(temperature=25, nominal_temperature=25)
+2 simulator.initial_condition(out = 90@u_V)
+3 analysis = simulator.transient(step_time=Vac.period/1000, end_time=Vac.period*6)
+4
+5 res = format_output(analysis)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Netlist.py in simulator(self, *args, **kwargs)

+

~\Anaconda3\lib\site-packages\PySpice\Spice\Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117 “”" This class implements a circuit simulator. Each analysis mode is performed by a method that
+1118 return the measured probes.
+ → 1119
+1120 For ac and transient analyses, the user must specify a list of nodes using the probes key
+1121 argument.

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 cls._instances[ngspice_id] = instance
+451 return instance
+ → 452
+453 ##############################################
+454

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in init(self, ngspice_id, send_data, verbose)
+478 self._library_path = None
+479 self._load_library(verbose)
+ → 480 self._init_ngspice(send_data)
+481
+482 self._is_running = False

+

~\Anaconda3\lib\site-packages\PySpice\Spice\NgSpice\Shared.py in _load_library(self, verbose)
+511 if ‘SPICE_LIB_DIR’ not in os.environ:
+512 _ = str(Path(self.NGSPICE_PATH).joinpath(‘share’, ‘ngspice’))
+ → 513 os.environ[‘SPICE_LIB_DIR’] = _
+514 # self._logger.warning(‘Set SPICE_LIB_DIR = %s’, _)
+515

+

~\Anaconda3\lib\pathlib.py in new(cls, *args, **kwargs)
+1036 if cls is Path:
+1037 cls = WindowsPath if os.name == ‘nt’ else PosixPath
+ → 1038 self = cls._from_parts(args, init=False)
+1039 if not self._flavour.is_supported:
+1040 raise NotImplementedError(“cannot instantiate %r on your system”

+

~\Anaconda3\lib\pathlib.py in _from_parts(cls, args, init)
+677 # right flavour.
+678 self = object.new(cls)
+ → 679 drv, root, parts = self._parse_args(args)
+680 self._drv = drv
+681 self._root = root

+

~\Anaconda3\lib\pathlib.py in _parse_args(cls, args)
+661 parts += a._parts
+662 else:
+ → 663 a = os.fspath(a)
+664 if isinstance(a, str):
+665 # Force-cast str subclasses to str (issue #21127)

+

TypeError: expected str, bytes or os.PathLike object, not NoneType

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/read-a-ngspice-rawfile-using-pyspice/123.html b/pyspice-discourse-backup/t/read-a-ngspice-rawfile-using-pyspice/123.html new file mode 100644 index 00000000..878ca60a --- /dev/null +++ b/pyspice-discourse-backup/t/read-a-ngspice-rawfile-using-pyspice/123.html @@ -0,0 +1,180 @@ + + + + + Read a NgSpice rawfile using PySpice - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Read a NgSpice rawfile using PySpice +

+ + + +
+ + + + +
+ +
+

Hello guys,

+

I am writing a python script that generates, runs and eventually will read the raw files. The command I use to run the netlist is the following: subprocess.run([path_to_ngspice_executable,'-r','rawfile.raw','-b','-i',my_netlist]) which generates my rawfile.

+

Could you please tell me what PySpice command to use so I can read the generated raw file and plot the distribution of my voltages?

+

Thanks in advance !

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/relatively-accurate-component-and-board-thermal-simulations/28.html b/pyspice-discourse-backup/t/relatively-accurate-component-and-board-thermal-simulations/28.html new file mode 100644 index 00000000..6c1ae932 --- /dev/null +++ b/pyspice-discourse-backup/t/relatively-accurate-component-and-board-thermal-simulations/28.html @@ -0,0 +1,222 @@ + + + + + Relatively accurate component (and board) thermal simulations? - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Relatively accurate component (and board) thermal simulations? +

+ + + +
+ + + + +
+ +
+

After playing around with SkiDL+NgSpice on SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs, I wonder what’s the recommended/best/suitable way to go about simulating thermodynamics on a circuit. Talking with an expert colleague he recommended the following theoretical approach:

+

https://lpsa.swarthmore.edu/Systems/Thermal/SysThermalModel.html

+

Essentially I would like to have a way to “heat map” a circuit pretty much like a FLIR camera does but via simulation/software… is it possible with NgSpice alone? Or would this require more ammo with FEA modelling or the like?

+

I would like to know if somebody has attempted this successfully and has good experience/code to share? :slight_smile:

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Just found this, sweet: https://forum.kicad.info/t/electro-thermal-simulation-with-ngspice/18666

+

Which goes to: http://ngspice.sourceforge.net/ngspice-electrothermal-tutorial.html

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162.html b/pyspice-discourse-backup/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162.html new file mode 100644 index 00000000..539ac91c --- /dev/null +++ b/pyspice-discourse-backup/t/simulating-a-circuit-with-16-mosfets-true-gmin-stepping-error/162.html @@ -0,0 +1,326 @@ + + + + + Simulating a circuit with 16 MOSFETs: True gmin stepping error - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Simulating a circuit with 16 MOSFETs: True gmin stepping error +

+ + + +
+ + + + +
+ +
+

Hello,

+

I am trying to simulate a circuit using 16 MOSFETS.

+

The issue is that once the MOSFETS’s 15 and 16 are placed in the schematic, it results in an error: PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR

+

If the MOSFET’s 15 and 16 are commented out, then the code compiles.

+

I am using NGspice-34.dll and PySpice 1.5. Have also tested with Pyspice 1.4.3 and NGspice-32.dll.

+

Is NGSpice reaching some maximum nodes/complexity limit? OR is this an issue with mosfet model? OR it is a circuit netlist (floating node?) issue?

+

Any help or ideas would be greatly appreciated.

+

The code and error message are reproduced below.

+

Thanks

+

Kahless96

+

##***********************************************
+import math
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.widgets import Cursor
+from matplotlib.pyplot import semilogx
+from matplotlib import pyplot

+

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 Circuit
+from PySpice.Unit import *

+

from engineering_notation import EngNumber

+

##***********************************************

+

+Circuit Netlist

+

circuit = Circuit(‘MyCircuit’)

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)
+circuit.include(spice_library[‘ptm65nm_nmos’])
+circuit.include(spice_library[‘ptm65nm_pmos’])

+

+Define inputs

+

HIGH = 1@u_V
+LOW = 0@u_V
+f_D = 1@u_Hz
+f_C = f_D/2
+f_B = f_D/4
+f_A = f_D/8

+

steptime=1@u_ms
+finaltime = 8/f_D
+circuit.V(1, ‘Vdd’, circuit.gnd, HIGH@u_V)
+circuit.PulseVoltageSource(2, ‘A’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_A)/2, period=1/f_A)
+circuit.PulseVoltageSource(3, ‘B’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_B)/2, period=1/f_B)
+circuit.PulseVoltageSource(4, ‘C’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_C)/2, period=1/f_C)
+circuit.PulseVoltageSource(5, ‘D’, circuit.gnd,
+initial_value=HIGH, pulsed_value=LOW,
+pulse_width=(1/f_D)/2, period=1/f_D)

+

+M <bulk/substrate node> +

+

circuit.MOSFET(1, ‘out1’, ‘A’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(2, ‘out1’, ‘B’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(3, ‘out1’, ‘A’, ‘temp’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(4, ‘temp’,‘B’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(5, ‘out2’, ‘out1’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(6, ‘out2’, ‘out1’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(7, ‘out3’, ‘C’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(8, ‘out3’, ‘D’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(9, ‘out3’, ‘C’, ‘temp1’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(10, ‘temp1’,‘D’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(11, ‘out4’, ‘out3’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(12, ‘out4’, ‘out3’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(13, ‘op’, ‘out2’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(14, ‘op’, ‘out4’, ‘Vdd’, ‘Vdd’, model=‘ptm65nm_pmos’)
+circuit.MOSFET(15, ‘op’, ‘out2’, ‘temp2’, circuit.gnd, model=‘ptm65nm_nmos’)
+circuit.MOSFET(16, ‘temp2’,‘out4’, circuit.gnd, circuit.gnd, model=‘ptm65nm_nmos’)

+

##***********************************************

+

+Simulation: Transient Analysis

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.transient(step_time=steptime, end_time=finaltime)

+

#########################

+

+PLOTTING COMMANDS

+

figure = plt.subplots(figsize=(11, 6))
+axe = plt.subplot(111)
+plt.xlabel(‘Time [s]’)
+plt.ylabel(‘Voltage [V]’)
+plt.grid()
+plot(analysis[‘op’], axis=axe, color=‘red’)
+plt.show()

+

Here is the error messages after which it fails to run:

+

2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: Starting true gmin stepping
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-03 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-04 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-05 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-06 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-07 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-08 Note: One successful gmin step
+2022-01-13 14:24:25,298 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-09 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-10 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-11 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Trying gmin = 1.0000E-12 Note: One successful gmin step
+2022-01-13 14:24:25,314 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Note: True gmin stepping completed

+

I have seen this gmin stepping error in other forum posts but in those cases it was related to circuit netlist error. This does not seem to be the case here.

+

The mosfet models being used are provided with Pyspice.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

The issue was the MOSFET model. I managed to solve the problem. See: Simulation of Digital Logic Gates in PySpice (Python) - YouTube

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105.html b/pyspice-discourse-backup/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105.html new file mode 100644 index 00000000..af68c8f6 --- /dev/null +++ b/pyspice-discourse-backup/t/simulating-dependent-sources-ccvs-works-but-vcvs-does-not/105.html @@ -0,0 +1,477 @@ + + + + + Simulating Dependent Sources (CCVS works but VCVS does not?!) - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Simulating Dependent Sources (CCVS works but VCVS does not?!) +

+ + + +
+ + + + +
+ +
+

Hello,

+

I am trying to run the following code for the circuit:Circuit

+

###############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with VCVS’)

+

circuit.R(1, 1, circuit.gnd, 6@u_Ω)
+circuit.R(2, 2, 3, 4@u_Ω)
+circuit.R(3, 3, 4, 8@u_Ω)
+circuit.R(4, 5, circuit.gnd, 15@u_Ω)
+circuit.V(1, 2, 1, 65@u_V)
+circuit.E(1, 4, 3, 2, 3, 3)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+

When I run, it gives an error:

+

Traceback (most recent call last):
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 928, in getattr
+return self.getitem(attribute_name)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 921, in getitem
+raise IndexError(attribute_name) # KeyError
+IndexError: E

+

During handling of the above exception, another exception occurred:

+

Traceback (most recent call last):
+File “C:/Users/Desktop/PySpice/node-voltage-method-example8.py”, line 22, in
+circuit.E(1, 4, 3, 2, 3, 3)
+File “C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\PySpice\Spice\Netlist.py”, line 930, in getattr
+raise AttributeError(attribute_name)
+AttributeError: E

+

I am not sure where I am going wrong. I have been able to simulate a CCVS (part name H) but all other dependent sources seem to give an error.

+

Can anyone please point out what is wrong in the code above?

+

Thanks

+

Salman

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

The following code for a CCVS works (part name H):
+

+

##############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with CCVS’)

+

circuit.R(1, 1, 2, 2@u_Ω)
+circuit.R(2, 2, circuit.gnd, 20@u_Ω)
+circuit.R(3, 2, 3, 5@u_Ω)
+circuit.R(4, 4, circuit.gnd, 10@u_Ω)
+circuit.R(5, 4, 5, 2@u_Ω)
+circuit.V(1, 1, circuit.gnd, 20@u_V)
+circuit.V(‘test’, 3, 4, 0@u_V)
+circuit.H(1, 5, circuit.gnd, ‘Vtest’, 8)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I figured out the problem. See here: How to simulate dependent sources in PySpice

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

when I run the program:
+##############################################################

+

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

+

################################################################

+

from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#################################################################

+

circuit = Circuit(‘Circuit with CCVS’)

+

circuit.R(1, 1, 2, 2@u_Ω)
+circuit.R(2, 2, circuit.gnd, 20@u_Ω)
+circuit.R(3, 2, 3, 5@u_Ω)
+circuit.R(4, 4, circuit.gnd, 10@u_Ω)
+circuit.R(5, 4, 5, 2@u_Ω)
+circuit.V(1, 1, circuit.gnd, 20@u_V)
+circuit.V(‘test’, 3, 4, 0@u_V)
+circuit.H(1, 5, circuit.gnd, ‘Vtest’, 8)

+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.operating_point()

+

for node in analysis.nodes.values():
+print(‘Node {}: {:4.1f} V’.format(str(node), float(node)))

+

I see an error message:
+Traceback (most recent call last):
+File “C:\PySpice\ICs\programtest.py”, line 24, in
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+

Any suggestions? Thanks in advance.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

It could be an installation issue. Please see here: Introduction to PySpice (Python) for DC Circuit Analysis with Dependent Sources - YouTube

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Re: dsalman,

+

Thanks for your suggestions. The problem has been addressed. Yes, it was an installation issue.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/skidl-ngspice-via-pyspice-simulating-a-simple-parallel-resistors-circuits-power-outputs/26.html b/pyspice-discourse-backup/t/skidl-ngspice-via-pyspice-simulating-a-simple-parallel-resistors-circuits-power-outputs/26.html new file mode 100644 index 00000000..4059b655 --- /dev/null +++ b/pyspice-discourse-backup/t/skidl-ngspice-via-pyspice-simulating-a-simple-parallel-resistors-circuits-power-outputs/26.html @@ -0,0 +1,384 @@ + + + + + SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs - NgSpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ SkiDL+NgSpice (via PySpice): simulating a simple parallel resistors circuit's power outputs +

+ + + +
+ + + + +
+ +
+

Hi folks, this seems to be the first post over this forum, hopefully it’s not too soon to start asking questions? :slight_smile:

+

I’m extending a bit one of the SKiDL simulation tutorials, as presented in this Jupyter notebook with a simple resistor (among other more complex examples):

+ + +

My intention is to extend the single resistor example with a netlist of several resistors in parallel (a 19x19 matrix), something like this:

+
#!/usr/bin/env python
+
+from skidl.pyspice import R, V, gnd, u_V
+from skidl.pyspice import u_Ohm, u_kOhm
+from skidl.pyspice import generate_netlist, reset, lib_search_paths, node
+
+reset()  # This will clear any previously defined circuitry.
+
+# Voltage Source
+vs = V(ref="VS", dc_value = 1 @ u_V)
+
+rnet = []
+
+# Create several resistors.
+rnet = 19*19*R(value = 1.7 @ u_kOhm)
+
+# Connect the nets and resistors.
+vs['p'] += [rnet[n][1] for n in range(0, 19*19)]
+gnd += [rnet[n][2] for n in range(0, 19*19)]
+gnd += vs['n']
+
+# Simulate the circuit.
+circ = generate_netlist()              # Translate the SKiDL code into a PyCircuit Circuit object.
+sim = circ.simulator()                 # Create a simulator for the Circuit object.
+dc_vals = sim.dc(VS=slice(1, 24, 1))  # Run a DC simulation where the voltage ramps from 1 to 12V by 1V increments.
+
+# Get the voltage applied to the resistor and the current coming out of the voltage source.
+voltage = dc_vals[node(vs['p'])]
+current = -dc_vals['VS']
+
+# Print a table showing the current through the resistor for the various applied voltages.
+print('{:^7s}{:^7s}{:^7s}'.format('V', ' I (A)', "P (W)"))
+print('='*25)
+for v, i, p in zip(voltage.as_ndarray(), current.as_ndarray(), voltage.as_ndarray()*current.as_ndarray()):
+    print('{:6.2f} {:6.2f} {:6.2f}'.format(v, i, p))
+
+

Unfortunately the output looks something like this:

+
$ ./skidl_sim.py
+
+No errors or warnings found during netlist generation.
+
+warning, can't find model at
+Warning: r1: resistance to low, set to 1 mOhm
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Note: Starting dynamic gmin stepping
+Trying gmin =   1.0000E-03 Note: One successful gmin step
+Trying gmin =   1.0000E-04 Note: One successful gmin step
+Trying gmin =   1.0000E-05 Note: One successful gmin step
+Trying gmin =   1.0000E-06 Note: One successful gmin step
+Trying gmin =   1.0000E-07 Note: One successful gmin step
+Trying gmin =   1.0000E-08 Note: One successful gmin step
+Trying gmin =   1.0000E-09 Note: One successful gmin step
+Trying gmin =   1.0000E-10 Note: One successful gmin step
+Trying gmin =   1.0000E-11 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: Dynamic gmin stepping failed
+Note: Starting source stepping
+Supplies reduced to   0.0000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Trying gmin =   1.0000E-02 Note: One successful gmin step
+Trying gmin =   1.0000E-03 Note: One successful gmin step
+Trying gmin =   1.0000E-04 Note: One successful gmin step
+Trying gmin =   1.0000E-05 Note: One successful gmin step
+Trying gmin =   1.0000E-06 Note: One successful gmin step
+Trying gmin =   1.0000E-07 Note: One successful gmin step
+Trying gmin =   1.0000E-08 Note: One successful gmin step
+Trying gmin =   1.0000E-09 Note: One successful gmin step
+Trying gmin =   1.0000E-10 Note: One successful gmin step
+Trying gmin =   1.0000E-11 Note: One successful gmin step
+Trying gmin =   1.0000E-12 Note: One successful gmin step
+Note: One successful source step
+Supplies reduced to   0.1000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Supplies reduced to   0.0000% Warning: singular matrix:  check nodes <skidl.part.pinnumbersearch and <skidl.part.pinnumbersearch
+Warning: source stepping failed
+doAnalyses: iteration limit reached
+run simulation(s) aborted
+   V    I (A)  P (W)
+=========================
+
+

Can anybody let me know what’s going on? Which syntax should I be using to define that resistor “network” so that ngspice accepts it as well-defined?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I edited your code. You only had a single, tiny mistake: you created an actual resistor that was added to the netlist, and then you created an additional 19*19=361 resistors from that one. This gave you a total of 362 resistors, but you only connected 361 of them. That dangling resistor seems to cause the problem.

+

By making the first resistor a TEMPLATE, then it isn’t actually added to the netlist but it can serve as a template for making other resistors. Once I did that, everything worked as expected.

+
#!/usr/bin/env python
+
+from skidl import TEMPLATE
+from skidl.pyspice import R, V, gnd, u_V
+from skidl.pyspice import u_Ohm, u_kOhm
+from skidl.pyspice import generate_netlist, reset, lib_search_paths, node
+
+reset()  # This will clear any previously defined circuitry.
+
+# Voltage Source
+vs = V(ref="VS", dc_value = 1 @ u_V)
+
+rnet = []
+
+# Create several resistors.
+# I changed it so the resistor was a template that is then replicated to create the actual resistors.
+rnet = 19*19*R(value = 1.7 @ u_kOhm, dest=TEMPLATE)
+
+# Connect the nets and resistors.
+vs['p'] += [rnet[n][1] for n in range(0, 19*19)]
+gnd += [rnet[n][2] for n in range(0, 19*19)]
+gnd += vs['n']
+
+# Simulate the circuit.
+circ = generate_netlist()              # Translate the SKiDL code into a PyCircuit Circuit object.
+sim = circ.simulator()                 # Create a simulator for the Circuit object.
+dc_vals = sim.dc(VS=slice(1, 24, 1))  # Run a DC simulation where the voltage ramps from 1 to 12V by 1V increments.
+
+# Get the voltage applied to the resistor and the current coming out of the voltage source.
+voltage = dc_vals[node(vs['p'])]
+current = -dc_vals['VS']
+
+# Print a table showing the current through the resistor for the various applied voltages.
+print('{:^7s}{:^7s}{:^7s}'.format('V', ' I (A)', "P (W)"))
+print('='*25)
+for v, i, p in zip(voltage.as_ndarray(), current.as_ndarray(), voltage.as_ndarray()*current.as_ndarray()):
+    print('{:6.2f} {:6.2f} {:6.2f}'.format(v, i, p))
+
+
+ + + +
+ + + 1 Like +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/starting-with-pyspice/71.html b/pyspice-discourse-backup/t/starting-with-pyspice/71.html new file mode 100644 index 00000000..18d74930 --- /dev/null +++ b/pyspice-discourse-backup/t/starting-with-pyspice/71.html @@ -0,0 +1,263 @@ + + + + + Starting with Pyspice - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Starting with Pyspice +

+ + + +
+ + + + +
+ +
+

Hello everyone,

+

I’m very new to PySpice, but I want to learn it. The problem is that starting is complicated and I have not found any tutorials. Do you have any recommendations on how to get started with PySpice?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Have you seen the tutorials that PySpice comes with? See here.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Thank you!

+

The problem is that although there are many exapmles, I cant find any documentation on how to use “circuit.” for example to make behavioral sources.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/sub-circuit-in-library-issue/56.html b/pyspice-discourse-backup/t/sub-circuit-in-library-issue/56.html new file mode 100644 index 00000000..83ff49b5 --- /dev/null +++ b/pyspice-discourse-backup/t/sub-circuit-in-library-issue/56.html @@ -0,0 +1,605 @@ + + + + + Sub-circuit in library issue - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Sub-circuit in library issue +

+ + + +
+ + + + +
+ +
+

Hi there !

+

I would like to use a spice circuit model (a sub-circuit in a .MOD file) in a circuit created from a spice netlist (a .net file) inside PySpice. Following is a simplistic example that shows the problem with a simple RC sub-circuit. I can’t figure out why the sub-circuit is not found although it is explicitly included with the circuit.include call as in the documentation examples…

+

The RC.py file :

+
import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+
+from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Spice.Parser import SpiceParser
+from PySpice.Unit import *
+
+spice_library = SpiceLibrary('../models/')
+parser = SpiceParser(path='RC.net')
+circuit = parser.build_circuit()
+circuit.include(spice_library['RC'])
+simulator = circuit.simulator(temperature=25, nominal_temperature=25)
+analysis = simulator.ac('dec', 10, 100, 100e3)
+
+

The RC.net circuit file :

+
.title RC Circuit
+V1 VIN 0 AC
+X1 VIN 0 VOUT RC
+.end
+
+

The RC.MOD model file in the ../models directory :

+
* PINOUT 1 2 3
+* PINOUT IN+ IN- OUT
+.subckt RC 1 2 3
+R1 1 3 1k
+C1 3 2 1nF
+.ends
+
+

Runing the python script gives :

+
$ python RC.py
+2020-07-06 15:12:47,850 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Error: unknown subckt: x1 vin 0 vout rc
+2020-07-06 15:12:47,851 - PySpice.Spice.NgSpice.Shared.NgSpiceShared - Shared.ERROR - Error: there aren't any circuits loaded.
+Traceback (most recent call last):
+  File "RC.py", line 14, in <module>
+    analysis = simulator.ac('dec', 10, 100, 100e3)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/Simulation.py", line 1161, in ac
+    return self._run('ac', *args, **kwargs)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Simulation.py", line 118, in _run
+    self._ngspice_shared.run()
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Shared.py", line 1168, in run
+    self.exec_command(command)
+  File "/usr/local/lib/python3.7/site-packages/PySpice/Spice/NgSpice/Shared.py", line 842, in exec_command
+    raise NgSpiceCommandError("Command '{}' failed".format(command))
+PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command 'run' failed
+
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

try to print(circuit) to see what is send to ngspice

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Here is the print(circuit) output :

+
.title RC Circuit
+.include /Users/{my home directory}/simulations/pyspice_models/RC.MOD
+V1 VIN 0 AC
+X1 VIN 0 VOUT RC
+
+

The directory of the .include line is an absolute path computed by pyspice from the local directory specified in SpiceLibrary. Is it then possible that the fact that there are spaces inside the {my home directory} directory name, makes ngspice not able to find the RC.MOD file ?
+It seams strange to me that nothing is complaining about not finding the RC.MOD file…

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Are you using v1.4.3 ?

+

Ngspice Manual:

+
+

2.6
+.INCLUDE
+General form:
+.INCLUDE filename
+Examples:
+.INCLUDE /users/spice/common/bsim3-param.mod
+Frequently, portions of circuit descriptions will be reused in several input files, particularly with
+common models and subcircuits. In any ngspice input file, the .INCLUDE line may be used to
+copy some other file as if that second file appeared in place of the .INCLUDE line in the original
+file.
+There is no restriction on the file name imposed by ngspice beyond those imposed by the local
+operating system.

+
+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Yes, I think I am. I installed PySpice on my mac using pip3. The libngspice was installed with brew.

+
$ python3
+Python 3.7.4 (default, Oct 12 2019, 19:06:48) 
+[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
+Type "help", "copyright", "credits" or "license" for more information.
+>>> import PySpice
+>>> print(PySpice.__version__)
+1.4.3
+>>> 
+
+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

@dlibault
+@fsalvaire

+

I am facing a similar issue, were we able to solve this in any way?
+Suba

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Hi,
+Just had this problem too, I changed my directory to something simple and everything worked.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I have the same issue with error. I have imported a library using circuit.include("foo.lib"). The import works fine, I think I connect the pins correctly, but it never works.
+Model I am importing is found here: https://www.ti.com/lit/zip/sbom310

+

+
import matplotlib.pyplot as plt
+
+

from scipy import signal
+from matplotlib.widgets import Cursor
+import numpy as np

+

import PySpice.Logging.Logging as Logging
+logger = Logging.setup_logging()
+from PySpice.Spice.Library import SpiceLibrary
+#from PySpice.Doc.ExampleTools import find_libraries
+#from PySpice.Probe.Plot import plot
+#from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Unit import *

+

#######################################################################

+

CIRCUIT NETLIST AND SIMULATION

+

circuit = Circuit(‘Circuit0’)
+circuit.include(“INA333.LIB”)

+

source = circuit.PulseVoltageSource(‘input’, ‘in’, circuit.gnd, 0, 3.3, 0.0005,0.000000001,0.000000001,0.005,0.010,0)
+ref = circuit.V(‘ref’,‘ref’,circuit.gnd,1.65@u_V)
+vcc= circuit.V(‘vcc’,‘vcc’,circuit.gnd,3.3@u_V)
+vee = circuit.gnd

+

circuit.R(1, ‘input’,‘v+’, 330@u_kOhm) #’’‘name, input node, output node, unit’’’
+circuit.R(2, ‘input’,‘v-’, 330@u_kOhm)
+circuit.R(3, ‘v-’, ‘left_cap_input’, 10@u_kOhm)
+circuit.R(4, ‘v+’,‘right_cap_input’, 100@u_kOhm)
+circuit.C(1, ‘left_cap_input’, circuit.gnd, 10@u_pF)
+circuit.C(2, ‘right_cap_input’, circuit.gnd, 100@u_pF)
+#circuit.R (5, ‘RG+’,‘RG-’, 100@u_MOhm)

+

#Setting up the INA333 subcircuit
+#IN+ IN- VCC VEE OUT REF RG+ RG-
+circuit.X(‘INA333’, ‘v-’,‘v+’, vcc, vee,‘vout’, ref,‘RG+’,‘RG-’)

+

print (circuit)

+

simulator = circuit.simulator(temperature = 25, nominal_temperature = 25)
+analysis = simulator.transient(step_time = 1@u_us, end_time = 10@u_ms)

+

PLOTTING COMMANDS

+

figure = plt.subplots(figsize=(11, 6))

+

plt.title(‘Bendlabs Circuit Simulation’)
+plt.xlabel(‘Time [s]’)
+plt.ylabel(‘Voltage [V]’)
+plt.grid()

+

plt(analysis[‘vin’],axis=axe)
+plt(analysis[‘v+’],axis=axe)
+plt(analysis[‘v-’],axis=axe)
+plt(analysis[‘vout’],axis=axe)
+plt.legend(‘vin’, ‘v+’, ‘v-’,‘vout’)

+

cursor = Cursor(axe, useblit=True, color=‘red’, linewidth=1)

+

plt.show()

+

I wonder if anyone has found a way to overcome this issue. thank you

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/transfer-function-on-voltage-source/69.html b/pyspice-discourse-backup/t/transfer-function-on-voltage-source/69.html new file mode 100644 index 00000000..f874cb49 --- /dev/null +++ b/pyspice-discourse-backup/t/transfer-function-on-voltage-source/69.html @@ -0,0 +1,224 @@ + + + + + Transfer function on voltage source - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Transfer function on voltage source +

+ + + +
+ + + + +
+ +
+

Hi,

+

I am new to Pyspice and I am moving our LTSpice simulations to PySpice. In that simulation we have some transfer functions defined as voltage sources with a transfer function like this:

+

I=V(A_IN) MAG FREQ=(34000.0,-0.386765E-03,-0.191481E-03)(34050.0,-0.415016E-03,-0.187603E-03)

+

Is it posible to implement this in PySpice?

+

Regards

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You need to upgrade your ngspice version to ver 32 from ver 31.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/transistor-example/63.html b/pyspice-discourse-backup/t/transistor-example/63.html new file mode 100644 index 00000000..b6f42d83 --- /dev/null +++ b/pyspice-discourse-backup/t/transistor-example/63.html @@ -0,0 +1,246 @@ + + + + + Transistor Example - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Transistor Example +

+ + + +
+ + + + +
+ +
+

In the example 8.20.1 AC Coupled Amplifier, when I was trying to run the code in Jupyter Notebook

+
+

simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+
+

it shows:

+
+
+

OSError Traceback (most recent call last)
+ in
+----> 1 simulator = circuit.simulator(temperature=25, nominal_temperature=25)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Netlist.py in simulator(self, *args, **kwargs)
+1297
+1298 def simulator(self, *args, **kwargs):
+-> 1299 return CircuitSimulator.factory(self, *args, **kwargs)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/Simulation.py in factory(cls, circuit, *args, **kwargs)
+1117
+1118 if sub_cls is not None:
+-> 1119 return sub_cls(circuit, *args, **kwargs)
+1120 else:
+1121 raise ValueError(‘Unknown simulator type’)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Simulation.py in init(self, circuit, **kwargs)
+97 ngspice_shared = kwargs.get(‘ngspice_shared’, None)
+98 if ngspice_shared is None:
+—> 99 self._ngspice_shared = NgSpiceShared.new_instance()
+100 else:
+101 self._ngspice_shared = ngspice_shared

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in new_instance(cls, ngspice_id, send_data, verbose)
+450 else:
+451 cls._logger.debug(“New instance for id {}”.format(ngspice_id))
+–> 452 instance = cls(ngspice_id=ngspice_id, send_data=send_data, verbose=verbose)
+453 cls._instances[ngspice_id] = instance
+454 return instance

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in init(self, ngspice_id, send_data, verbose)
+478
+479 self._library_path = None
+–> 480 self._load_library(verbose)
+481 self._init_ngspice(send_data)
+482

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/PySpice/Spice/NgSpice/Shared.py in _load_library(self, verbose)
+538 if verbose:
+539 print(message)
+–> 540 self._ngspice_shared = ffi.dlopen(self.library_path)
+541
+542 # Note: cannot yet execute command

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in dlopen(self, name, flags)
+148 “or an already-opened ‘void *’ handle”)
+149 with self._lock:
+–> 150 lib, function_cache = _make_ffi_library(self, name, flags)
+151 self._function_caches.append(function_cache)
+152 self._libraries.append(lib)

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _make_ffi_library(ffi, libname, flags)
+830 def _make_ffi_library(ffi, libname, flags):
+831 backend = ffi._backend
+–> 832 backendlib = _load_backend_lib(backend, libname, flags)
+833 #
+834 def accessor_function(name):

+

~/anaconda3/envs/Circuits/lib/python3.6/site-packages/cffi/api.py in _load_backend_lib(backend, name, flags)
+825 if first_error is not None:
+826 msg = “%s. Additionally, %s” % (first_error, msg)
+–> 827 raise OSError(msg)
+828 return backend.load_library(path, flags)
+829

+

OSError: cannot load library ‘libngspice.dylib’: dlopen(libngspice.dylib, 2): image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called ‘libngspice.dylib’

+
+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/trouble-with-libraries/94.html b/pyspice-discourse-backup/t/trouble-with-libraries/94.html new file mode 100644 index 00000000..d939ab6a --- /dev/null +++ b/pyspice-discourse-backup/t/trouble-with-libraries/94.html @@ -0,0 +1,199 @@ + + + + + Trouble with Libraries - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Trouble with Libraries +

+ + + +
+ + + + +
+ +
+

Hello!

+

To better understand PySpice, I’m working through a very simple circuit involving a voltage source, a resistor, and a 1N4148 Diode. However, I am having trouble with Python recognizing the library I need to bring in the characteristics of the diode. Here is my code:

+

'import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.ticker as ticker

+

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

+

from PySpice.Doc.ExampleTools import find_libraries
+from PySpice.Spice.Netlist import Circuit
+from PySpice.Spice.Library import SpiceLibrary
+from PySpice.Unit import *
+from PySpice.Physics.SemiConductor import ShockleyDiode

+

libraries_path = find_libraries()
+spice_library = SpiceLibrary(libraries_path)

+

circuit = Circuit(‘Diode Characteristic Curve’)

+

circuit.include(spice_library[‘1N4148’])

+

circuit.V(‘input’, ‘in’, circuit.gnd, 10@u_V)
+circuit.R(1, ‘in’, ‘out’, 1@u_Ω) # not required for simulation
+circuit.X(‘D1’, ‘1N4148’, ‘out’, circuit.gnd)’

+

And here is my result:

+

--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-5-ae802129d891> in <module> 20 circuit = Circuit('Diode Characteristic Curve') 21 ---> 22 circuit.include(spice_library['1N4148']) 23 24 circuit.V('input', 'in', circuit.gnd, 10@u_V) /usr/local/lib/python3.8/dist-packages/PySpice/Spice/Library.py in __getitem__(self, name) 105 # print('Library {} not found in {}'.format(name, self._directory)) 106 # self._logger.warn('Library {} not found in {}'.format(name, self._directory)) --> 107 raise KeyError(name) 108 109 ############################################## KeyError: '1N4148'

+

Can anyone help me understand what exactly is going wrong here and how I can correct it?

+

Thanks!

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/using-the-skywater-pdk-with-skidl-pyspice/98.html b/pyspice-discourse-backup/t/using-the-skywater-pdk-with-skidl-pyspice/98.html new file mode 100644 index 00000000..bd8ecee3 --- /dev/null +++ b/pyspice-discourse-backup/t/using-the-skywater-pdk-with-skidl-pyspice/98.html @@ -0,0 +1,165 @@ + + + + + Using the Skywater PDK with SKiDL/PySpice - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Using the Skywater PDK with SKiDL/PySpice +

+ + +
+ + + + +
+ +
+

I’ve published a Jupyter notebook of my explorations using SKiDL and PySpice with the open Skywater PDK.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/welcome-to-discourse/7.html b/pyspice-discourse-backup/t/welcome-to-discourse/7.html new file mode 100644 index 00000000..b02e63df --- /dev/null +++ b/pyspice-discourse-backup/t/welcome-to-discourse/7.html @@ -0,0 +1,169 @@ + + + + + Welcome to Discourse - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Welcome to Discourse +

+ + +
+ + + + +
+ +
+

Welcome to the PySpice Forum !

+

This forum is the right place to chat about PySpice between users and to get help.

+

This forum is provided freely by https://www.discourse.org as a part of its program to support open source projects.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/whats-pyspices-advantages/135.html b/pyspice-discourse-backup/t/whats-pyspices-advantages/135.html new file mode 100644 index 00000000..be2dec53 --- /dev/null +++ b/pyspice-discourse-backup/t/whats-pyspices-advantages/135.html @@ -0,0 +1,218 @@ + + + + + Whats PySpice's Advantages? - Help - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ Whats PySpice's Advantages? +

+ + + +
+ + + + +
+ +
+

Hi friends, why I have use pySpice instead of use direct spice program? Whats advantages of using pyspice? I must a homework like electronic circuits with pyspice but I didn’t find a topic. Can you help me find a topic. How can I do with pyspice?

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Pyspice opens up the power of python for theoretical calculations, side by side with simulations. You cannot do this in any other simulator. See the videos in this playlist here which illustrate the flexibility and advantage of using Pyspice, compared to LTSPICE, PSPICE: Introduction to PySpice (Python) for DC Circuit Analysis with Dependent Sources - YouTube

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/t/xspice-elements-in-pyspice/61.html b/pyspice-discourse-backup/t/xspice-elements-in-pyspice/61.html new file mode 100644 index 00000000..e6610d99 --- /dev/null +++ b/pyspice-discourse-backup/t/xspice-elements-in-pyspice/61.html @@ -0,0 +1,510 @@ + + + + + XSPICE elements in PySpice - Circuit Simulation - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+

+ XSPICE elements in PySpice +

+ + + +
+ + + + +
+ +
+

Good afternoon!
+I’m trying to model a simple electrical circuit with XSPICE elements. For example, the electrical circuit from Chapter 27.1 (Ngspice user manual):

+
from PySpice.Spice.Netlist import Circuit
+
+test = """XSPICE
+Vin1 1 0 DC 0V AC 1.0 SIN(0V 1V 1000Hz)
+Ccouple 1 in 0.000001
+Rzin in 0 19.35k
+Aamp in aout gain_block
+.model gain_block gain (gain=-3.9 out_offset=7.003)
+Rzout aout coll 3.9k
+Rbig coll 0 1e12
+.control
+run
+display
+tran 0.00001 0.003
+plot i(Vin1)
+.endc
+.end
+"""
+circuit = Circuit(test)
+
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)
+analysis = simulator.transient(step_time=0.00001, end_time=0.003)
+
+

When I try to run it I get an error:

+
  File ".../.local/lib/python3.7/site-packages/PySpice/Spice/RawFile.py", line 223, in _read_header_line
+    raise NameError("Unexpected line: %s" % (line))
+NameError: Unexpected line: Reducing trtol to 1 for xspice 'A' devices
+
+

So there are two questions:

+
    +
  1. If I understand correctly, the error is caused by the ngspice message “Reducing trtol to 1 for xspice ‘A’ devices”. Is it possible to avoid this error? When adding a line “option trtol=1” after the line “.control” I get the following error:
    +NameError: Expected label Title instead of No. of Data Rows +
  2. +
  3. Is it possible to set the value of trtol and other Simulator Variables by using any pyspice command?
  4. +
+

I am using Spyder 4, PySpice 1.4.3 and ngspice-30 (DEFAULT_SIMULATOR = ‘ngspice-subprocess’) in the Debian linux operating system.

+

Thank you in advance!

+


+Regards,
+Dmitriy N.

+
+ + + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

You code is wrong

+
    from PySpice.Spice.Netlist import Circuit
+
+    circuit = Circuit('XSpice Test')
+    circuit.raw_spice = """
+    Vin1 1 0 DC 0V AC 1.0 SIN(0V 1V 1000Hz)
+    Ccouple 1 in 0.000001
+    Rzin in 0 19.35k
+    Aamp in aout gain_block
+    .model gain_block gain (gain=-3.9 out_offset=7.003)
+    Rzout aout coll 3.9k
+    Rbig coll 0 1e12
+    """
+
+    print(circuit)
+
+    simulator = circuit.simulator(temperature=27, nominal_temperature=27)
+    analysis = simulator.transient(step_time=0.00001, end_time=0.003)
+
+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Thank you for your reply.
+Still, it didn’t solve the problem.

+
from PySpice.Spice.Netlist import Circuit
+
+circuit = Circuit('XSpice Test')
+circuit.raw_spice = """
+Vin1 1 0 DC 0V AC 1.0 SIN(0V 1V 1000Hz)
+Ccouple 1 in 0.000001
+Rzin in 0 19.35k
+Aamp in aout gain_block
+.model gain_block gain (gain=-3.9 out_offset=7.003)
+Rzout aout coll 3.9k
+Rbig coll 0 1e12
+
+.control
+option trtol=1
+run
+display
+tran 0.00001 0.003
+plot i(Vin1)
+.endc
+.end
+"""
+
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)
+analysis = simulator.transient(step_time=0.00001, end_time=0.003)
+
+

When I run this code the following error occurs:
+NameError: Expected label Title instead of No. of Data Rows

+

If I delete the line “option trtol=1”, another error occurs:
+NameError: Unexpected line: Reducing trtol to 1 for xspice 'A' devices

+

The same error occurs if I run the code:

+
from PySpice.Spice.Netlist import Circuit
+circuit = Circuit('XSPICE')
+
+circuit.SinusoidalVoltageSource('in1', '1', 0, amplitude=1, frequency=1000)
+circuit.C('couple', '1', 'in1', '0.000001')
+circuit.R('zin', 'in1', 0, '19.35')
+
+circuit.model('gain_block', 'gain', gain=-3.9, out_offset=7.003)
+circuit.A('amp', 'in1', 'aout', model='gain_block')
+circuit.R('zout', 'aout', 'coll', '3.9k')
+circuit.R('big', 'coll', 0, '1e12')
+
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)
+analysis = simulator.transient(step_time=0.00001, end_time=0.003)
+
+

Is this a problem with my software? Or did I do something wrong?

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Hi Dmitriy,
+I was able to run Fabrices code (Windows10/Spyder IDE/Python 3.5)
+Rgs Martin

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

Thanks for answering.
+I understood the reason for my mistake.
+When using raw SPICE commands, I excluded extra lines “.control … .endc” and left the line “.option trtol=1”.
+When using an element description of an electrical circuit, I used the following line to set the value of the trtol variable to 1:
+circuit.raw_spice = '.option trtol=1'

+


+Regards,
+Dmitriy N.

+
+ + + +
+ + + +
+ +
+ + +
+ +
+
+ +
+

I always see a problem like this:
+Traceback (most recent call last):
+File “C:\PySpice\ICs\simulation.py”, line 23, in
+simulator = circuit.simulator(temperature=27, nominal_temperature=27)

+

My program execution shows a problem at “simulator = circuit.simulator(temperature=27, nominal_temperature=27)”. Any suggestions?

+

Thanks

+
+ + + +
+ + + +
+ +
+ + +
+ +
+ + + + + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/tos.html b/pyspice-discourse-backup/tos.html new file mode 100644 index 00000000..c19d6d3b --- /dev/null +++ b/pyspice-discourse-backup/tos.html @@ -0,0 +1,263 @@ + + + + + Terms of Service - PySpice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

PySpice

+
+
+ +
+
+ + + + +
+

These terms govern use of the Internet forum at http://pyspice.discourse.group. To use the forum, you must agree to these terms with PySpice, the company that runs the forum.

+

The company may offer other products and services, under different terms. These terms apply only to use of the forum.

+

Skip to:

+ +

Important Terms

+

These terms include a number of important provisions that affect your rights and responsibilities, such as the disclaimers in Disclaimers, limits on the company’s liability to you in Limits on Liability, your agreement to cover the company for damages caused by your misuse of the forum in Responsibility for Your Use, and an agreement to arbitrate disputes in Disputes.

+

Your Permission to Use the Forum

+

Subject to these terms, the company gives you permission to use the forum. Everyone needs to agree to these terms to use the forum.

+

Conditions for Use of the Forum

+

Your permission to use the forum is subject to the following conditions:

+
    +
  1. +

    You must be at least thirteen years old.

    +
  2. +
  3. +

    You may no longer use the forum if the company contacts you directly to say that you may not.

    +
  4. +
  5. +

    You must use the forum in accordance with Acceptable Use and Content Standards.

    +
  6. +
+

Acceptable Use

+
    +
  1. +

    You may not break the law using the forum.

    +
  2. +
  3. +

    You may not use or try to use another’s account on the forum without their specific permission.

    +
  4. +
  5. +

    You may not buy, sell, or otherwise trade in user names or other unique identifiers on the forum.

    +
  6. +
  7. +

    You may not send advertisements, chain letters, or other solicitations through the forum, or use the forum to gather addresses or other personal data for commercial mailing lists or databases.

    +
  8. +
  9. +

    You may not automate access to the forum, or monitor the forum, such as with a web crawler, browser plug-in or add-on, or other computer program that is not a web browser. You may crawl the forum to index it for a publicly available search engine, if you run one.

    +
  10. +
  11. +

    You may not use the forum to send e-mail to distribution lists, newsgroups, or group mail aliases.

    +
  12. +
  13. +

    You may not falsely imply that you’re affiliated with or endorsed by the company.

    +
  14. +
  15. +

    You may not hyperlink to images or other non-hypertext content on the forum on other webpages.

    +
  16. +
  17. +

    You may not remove any marks showing proprietary ownership from materials you download from the forum.

    +
  18. +
  19. +

    You may not show any part of the forum on other websites with <iframe>.

    +
  20. +
  21. +

    You may not disable, avoid, or circumvent any security or access restrictions of the forum.

    +
  22. +
  23. +

    You may not strain infrastructure of the forum with an unreasonable volume of requests, or requests designed to impose an unreasonable load on information systems underlying the forum.

    +
  24. +
  25. +

    You may not impersonate others through the forum.

    +
  26. +
  27. +

    You may not encourage or help anyone in violation of these terms.

    +
  28. +
+

Content Standards

+
    +
  1. +

    You may not submit content to the forum that is illegal, offensive, or otherwise harmful to others. This includes content that is harassing, inappropriate, or abusive.

    +
  2. +
  3. +

    You may not submit content to the forum that violates the law, infringes anyone’s intellectual property rights, violates anyone’s privacy, or breaches agreements you have with others.

    +
  4. +
  5. +

    You may not submit content to the forum containing malicious computer code, such as computer viruses or spyware.

    +
  6. +
  7. +

    You may not submit content to the forum as a mere placeholder, to hold a particular address, user name, or other unique identifier.

    +
  8. +
  9. +

    You may not use the forum to disclose information that you don’t have the right to disclose, like others’ confidential or personal information.

    +
  10. +
+

Enforcement

+

The company may investigate and prosecute violations of these terms to the fullest legal extent. The company may notify and cooperate with law enforcement authorities in prosecuting violations of the law and these terms.

+

The company reserves the right to change, redact, and delete content on the forum for any reason. If you believe someone has submitted content to the forum in violation of these terms, contact us immediately.

+

Your Account

+

You must create and log into an account to use some features of the forum.

+

To create an account, you must provide some information about yourself. If you create an account, you agree to provide, at a minimum, a valid e-mail address, and to keep that address up-to-date. You may close your account at any time by e-mailing pyspice@fabrice-salvaire.fr.

+

You agree to be responsible for all action taken using your account, whether authorized by you or not, until you either close your account or notify the company that your account has been compromised. You agree to notify the company immediately if you suspect your account has been compromised. You agree to select a secure password for your account, and keep it secret.

+

The company may restrict, suspend, or close your account on the forum according to its policy for handling copyright-related takedown requests, or if the company reasonably believes that you’ve broken any rule in these terms.

+

Your Content

+

Nothing in these terms gives the company any ownership rights in intellectual property that you share with the forum, such as your account information, posts, or other content you submit to the forum. Nothing in these terms gives you any ownership rights in the company’s intellectual property, either.

+

Between you and the company, you remain solely responsible for content you submit to the forum. You agree not to wrongly imply that content you submit to the forum is sponsored or approved by the company. These terms do not obligate the company to store, maintain, or provide copies of content you submit, and to change it, according to these terms.

+

Content you submit to the forum belongs to you, and you decide what permission to give others for it. But at a minimum, you license the company to provide content that you submit to the forum to other users of the forum. That special license allows the company to copy, publish, and analyze content you submit to the forum.

+

When content you submit is removed from the forum, whether by you or by the company, the company’s special license ends when the last copy disappears from the company’s backups, caches, and other systems. Other licenses you apply to content you submit, such as Creative Commons licenses, may continue after your content is removed. Those licenses may give others, or the company itself, the right to share your content through the forum again.

+

Others who receive content you submit to the forum may violate the terms on which you license your content. You agree that the company will not be liable to you for those violations or their consequences.

+

Your Responsibility

+

You agree to indemnify the company from legal claims by others related to your breach of these terms, or breach of these terms by others using your account on the forum. Both you and the company agree to notify the other side of any legal claims for which you might have to indemnify the company as soon as possible. If the company fails to notify you of a legal claim promptly, you won’t have to indemnify the company for damages that you could have defended against or mitigated with prompt notice. You agree to allow the company to control investigation, defense, and settlement of legal claims for which you would have to indemnify the company, and to cooperate with those efforts. The company agrees not to agree to any settlement that admits fault for you or imposes obligations on you without your prior agreement.

+

Disclaimers

+

You accept all risk of using the forum and content on the forum. As far as the law allows, the company and its suppliers provide the forum as is, without any warranty whatsoever.

+

The forum may hyperlink to and integrate forums and services run by others. The company does not make any warranty about services run by others, or content they may provide. Use of services run by others may be governed by other terms between you and the one running service.

+

Limits on Liability

+

Neither the company nor its suppliers will be liable to you for breach-of-contract damages their personnel could not have reasonably foreseen when you agreed to these terms.

+

As far as the law allows, the total liability to you for claims of any kind that are related to the forum or content on the forum will be limited to $50.

+

Feedback

+

The company welcomes your feedback and suggestions for the forum. See the Contact section below for ways to get in touch with us.

+

You agree that the company will be free to act on feedback and suggestions you provide, and that the company won’t have to notify you that your feedback was used, get your permission to use it, or pay you. You agree not to submit feedback or suggestions that you believe might be confidential or proprietary, to you or others.

+

Termination

+

Either you or the company may end the agreement written out in these terms at any time. When our agreement ends, your permission to use the forum also ends.

+

The following provisions survive the end of our agreement: Your Content, Feedback, Your Responsibility, Disclaimers, Limits on Liability, and General Terms.

+

Disputes

+

French will govern any dispute related to these terms or your use of the forum.

+

You and the company agree to seek injunctions related to these terms only in state or federal court in Paris. Neither you nor the company will object to jurisdiction, forum, or venue in those courts.

+

Other than to seek an injunction or for claims under the Computer Fraud and Abuse Act, you and the company will resolve any dispute by binding American Arbitration Association arbitration. Arbitration will follow the AAA’s Commercial Arbitration Rules and Supplementary Procedures for Consumer Related Disputes. Arbitration will happen in Paris. You will settle any dispute as an individual, and not as part of a class action or other representative proceeding, whether as the plaintiff or a class member. No arbitrator will consolidate any dispute with any other arbitration without the company’s permission.

+

Any arbitration award will include costs of the arbitration, reasonable attorneys’ fees, and reasonable costs for witnesses. You and the company may enter arbitration awards in any court with jurisdiction.

+

General Terms

+

If a provision of these terms is unenforceable as written, but could be changed to make it enforceable, that provision should be modified to the minimum extent necessary to make it enforceable. Otherwise, that provision should be removed.

+

You may not assign your agreement with the company. The company may assign your agreement to any affiliate of the company, any other company that obtains control of the company, or any other company that buys assets of the company related to the forum. Any attempted assignment against these terms has no legal effect.

+

Neither the exercise of any right under this Agreement, nor waiver of any breach of this Agreement, waives any other breach of this Agreement.

+

These terms embody all the terms of agreement between you and the company about use of the forum. These terms entirely replace any other agreements about your use of the forum, written or not.

+

Contact

+

You may notify the company under these terms, and send questions to the company, at pyspice@fabrice-salvaire.fr.

+

The company may notify you under these terms using the e-mail address you provide for your account on the forum, or by posting a message to the homepage of the forum or your account page.

+

Changes

+

The company last updated these terms on July 12, 2018, and may update these terms again. The company will post all updates to the forum. For updates that contain substantial changes, the company agrees to e-mail you, if you’ve created an account and provided a valid e-mail address. The company may also announce updates with special messages or alerts on the forum.

+

Once you get notice of an update to these terms, you must agree to the new terms in order to keep using the forum.

+
+
+ + + +
+ + + + + + + diff --git a/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/brainstorm/25/5_2.png b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/brainstorm/25/5_2.png new file mode 100644 index 00000000..a8295c5d Binary files /dev/null and b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/brainstorm/25/5_2.png differ diff --git a/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/devbisme/25/7_2.png b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/devbisme/25/7_2.png new file mode 100644 index 00000000..b9474ebf Binary files /dev/null and b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/devbisme/25/7_2.png differ diff --git a/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/endolith/25/8_2.png b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/endolith/25/8_2.png new file mode 100644 index 00000000..b3a8fee8 Binary files /dev/null and b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/endolith/25/8_2.png differ diff --git a/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/fsalvaire/25/9_2.png b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/fsalvaire/25/9_2.png new file mode 100644 index 00000000..56ed02b6 Binary files /dev/null and b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/fsalvaire/25/9_2.png differ diff --git a/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/jimzenn/25/21_2.png b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/jimzenn/25/21_2.png new file mode 100644 index 00000000..372d996c Binary files /dev/null and b/pyspice-discourse-backup/user_avatar/pyspice.discourse.group/jimzenn/25/21_2.png differ