Giter Site home page Giter Site logo

SpiceParser problem about pyspice HOT 11 CLOSED

pyspice-org avatar pyspice-org commented on June 12, 2024
SpiceParser problem

from pyspice.

Comments (11)

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

I guess ngspice cannot simulate your circuit because the netlist is wrong.

Print the netlist to check it is right. PySpice don't check the netlist, it just make it and pass it to ngspice.

from pyspice.

IgnacioRubioScola avatar IgnacioRubioScola commented on June 12, 2024

This is the netlist:
2017-09-15 13:00:59,898 - PySpice.Spice.Simulation.NgSpiceSharedCircuitSimulator._run - DEBUG - desk
.title None
.subckt Fonte input output
Vin input output 10V
.ends Fonte
X1 2 1 Fonte
R1 3 1 1K
R2 2 3 2K
.options TEMP = 25°C
.options TNOM = 25°C
.ic
.tran 100us 3ms 0s
.end

from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

Your code works on my environment ! But I don't get theses errors which are in fact warnings ???

You should use 0 for ground and an Operational Point analysis but ...

Notice you can always run a netlist generated by PySpice with the ngspice executable. If it fails then the netlist is wrong or ngspice fails to simulate it.

What is your platform ?

from pyspice.

IgnacioRubioScola avatar IgnacioRubioScola commented on June 12, 2024

I am using Ubuntu 17.04, python 3.6.2 and ngspice 26, here the full output:

$ python Divisor_circuit.py

2017-09-15 14:13:15,188 - PySpice.Spice.Parser.Element.__init__ - DEBUG - 
Element X 1 ['2', '1'] ['Fonte'] {}
2017-09-15 14:13:15,189 - PySpice.Spice.Parser.Element.__init__ - DEBUG - 
Element R 1 ['3', '1'] ['1K'] {}
2017-09-15 14:13:15,190 - PySpice.Spice.Parser.Element.__init__ - DEBUG - 
Element R 2 ['2', '3'] ['2K'] {}
2017-09-15 14:13:15,191 - PySpice.Spice.Parser.Element.build - DEBUG - X 1 ['2', '1'] ['Fonte'] {}
2017-09-15 14:13:15,191 - PySpice.Spice.Parser.Element.build - DEBUG - R 1 ['3', '1'] ['1K'] {}
2017-09-15 14:13:15,192 - PySpice.Spice.Parser.Element.build - DEBUG - R 2 ['2', '3'] ['2K'] {}
.title None
.subckt Fonte input output 
Vin input output 10V
.ends Fonte
X1 2 1 Fonte
R1 3 1 1K
R2 2 3 2K

2017-09-15 14:13:15,196 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.new_instance - INFO - New instance for id 0
2017-09-15 14:13:15,715 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.exec_command - DEBUG - Execute command: set nomoremode
2017-09-15 14:13:15,718 - PySpice.Spice.Simulation.NgSpiceSharedCircuitSimulator._run - DEBUG - desk
.title None
.subckt Fonte input output 
Vin input output 10V
.ends Fonte
X1 2 1 Fonte
R1 3 1 1K
R2 2 3 2K
.options TEMP = 25°C
.options TNOM = 25°C
.ic 
.tran 100us 3ms 0s
.end

2017-09-15 14:13:15,718 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.exec_command - DEBUG - Execute command: destroy all
2017-09-15 14:13:15,770 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.send_stat - DEBUG - ngspice-0 send_stat Prepare Deck
2017-09-15 14:13:15,771 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.send_stat - DEBUG - ngspice-0 send_stat Circuit2
2017-09-15 14:13:15,771 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.send_stat - DEBUG - ngspice-0 send_stat Device Setup
2017-09-15 14:13:15,772 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG - ngspice_id-0 send_init_data
2017-09-15 14:13:15,772 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG -   Vector: v.x1.vin#branch
2017-09-15 14:13:15,773 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG -   Vector: V(3)
2017-09-15 14:13:15,773 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG -   Vector: V(1)
2017-09-15 14:13:15,773 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG -   Vector: V(2)
2017-09-15 14:13:15,774 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_init_data - DEBUG -   Vector: time
2017-09-15 14:13:15,774 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.send_stat - DEBUG - ngspice-0 send_stat op
2017-09-15 14:13:15,774 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Warning: singular matrix:  check nodes 1 and 1
2017-09-15 14:13:15,775 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Note: Starting dynamic gmin stepping
2017-09-15 14:13:15,775 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-03 Note: One successful gmin step
2017-09-15 14:13:15,776 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-04 Note: One successful gmin step
2017-09-15 14:13:15,776 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-05 Note: One successful gmin step
2017-09-15 14:13:15,777 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-06 Note: One successful gmin step
2017-09-15 14:13:15,777 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-07 Note: One successful gmin step
2017-09-15 14:13:15,778 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-08 Note: One successful gmin step
2017-09-15 14:13:15,778 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-09 Note: One successful gmin step
2017-09-15 14:13:15,779 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-10 Note: One successful gmin step
2017-09-15 14:13:15,779 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-11 Note: One successful gmin step
2017-09-15 14:13:15,780 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-12 Note: One successful gmin step
2017-09-15 14:13:15,780 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-12 Note: One successful gmin step
2017-09-15 14:13:15,781 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Warning: singular matrix:  check nodes 1 and 1
2017-09-15 14:13:15,781 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Warning: Dynamic gmin stepping failed
2017-09-15 14:13:15,781 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Note: Starting source stepping
2017-09-15 14:13:15,782 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Supplies reduced to   0.0000% Warning: singular matrix:  check nodes 1 and 1
2017-09-15 14:13:15,782 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-02 Note: One successful gmin step
2017-09-15 14:13:15,783 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-03 Note: One successful gmin step
2017-09-15 14:13:15,783 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-04 Note: One successful gmin step
2017-09-15 14:13:15,784 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-05 Note: One successful gmin step
2017-09-15 14:13:15,784 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-06 Note: One successful gmin step
2017-09-15 14:13:15,785 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-07 Note: One successful gmin step
2017-09-15 14:13:15,785 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-08 Note: One successful gmin step
2017-09-15 14:13:15,786 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-09 Note: One successful gmin step
2017-09-15 14:13:15,786 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-10 Note: One successful gmin step
2017-09-15 14:13:15,786 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-11 Note: One successful gmin step
2017-09-15 14:13:15,787 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Trying gmin =   1.0000E-12 Note: One successful gmin step
2017-09-15 14:13:15,787 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Note: One successful source step
2017-09-15 14:13:15,788 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Supplies reduced to   0.1000% Warning: singular matrix:  check nodes 1 and 1
2017-09-15 14:13:15,788 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Supplies reduced to   0.0000% Warning: singular matrix:  check nodes 1 and 1
2017-09-15 14:13:15,789 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Warning: source stepping failed
2017-09-15 14:13:15,790 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - doAnalyses: iteration limit reached
2017-09-15 14:13:15,790 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - run simulation(s) aborted
2017-09-15 14:13:15,791 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.run - DEBUG - Simulation is done
2017-09-15 14:13:15,791 - PySpice.Spice.Simulation.NgSpiceSharedCircuitSimulator._run - DEBUG - ['tran1', 'const']
2017-09-15 14:13:15,794 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.plot - DEBUG - vector[0] v.x1.vin#branch type current flags real length 0
2017-09-15 14:13:15,794 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.plot - DEBUG - vector[1] V(3) type voltage flags real length 0
2017-09-15 14:13:15,795 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.plot - DEBUG - vector[2] V(1) type voltage flags real length 0
2017-09-15 14:13:15,796 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.plot - DEBUG - vector[3] V(2) type voltage flags real length 0
2017-09-15 14:13:15,796 - PySpice.Spice.NgSpice.Shared.NgSpiceShared.plot - DEBUG - vector[4] time type time flags real length 0



from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

Do you have custom spice init file ?

I am aware some stupid package maintainers compile ngspice with all the experimental features enabled ... Fedora was concerned by this issue

Try to run on console > ngspice netlist.cir to be sure. I did both : PySpice and ngspice are all ok for me.

If you cannot figure out how to run your netlist, and if you want to do serious simulation, I recommend to you to either recompile ngspice or check what they did on Ubuntu ...

from pyspice.

IgnacioRubioScola avatar IgnacioRubioScola commented on June 12, 2024

With the Ubuntu version I was having the error:

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'
so I had compiled from source using:

./configure --with-ngshared
make
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

The funny thing is that the example: "7.13.2. Kicad Netlist Parser Example" is perfectly working!!

from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

Maybe the Ubuntu package doesn't provide the shared library. You can check the content of the package or run locate ngspice | grep so. I am interested by this info, because Ubuntu is a large audience distribution.

I don't understand what happen. Did you try to run ngspice executable ?

I doubt, but try to bless the ground as 0
singular matrix: check nodes 1 and 1 suggests a netlist issue

from pyspice.

IgnacioRubioScola avatar IgnacioRubioScola commented on June 12, 2024

I managed to run all the code, it was the 0 node, I thought that the function:
circuit = parser.build_circuit(ground=0)
should create the ground node from any number as the example 7.13.2.

Exactly the Ubuntu package doesn't provide the shared library!
locate ngspice | grep so return nothing but the location were I compiled the ngspice.

$ ngspice Divisor.cir 
******
** ngspice-26 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Fri May  6 11:16:28 UTC 2016
******

Circuit: x1  1 0 fonte

ngspice 1 -> 

Apparently the ngspice is not given any error, I don't know how to use it yet.

from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

You have to enter run in the interpreter and then plot v(3), look at ngspice manual.

Well I don't understand why your code works for me and not for you. Is there a compilation option that do magic ??? I think no, I used for ngspice 26

  --enable-xspice \
  --disable-debug \
  --enable-cider \
  --with-readline=yes \
  --enable-openmp \
  --with-ngshared

Anyway, I am pretty sure there is an issue in build(self, circuit, ground=0)

        for node in self._nodes:
            if str(node) == ground:
                node = 0
            nodes.append(node)

It should be int and not str. Could you try ground='1' instead ?

from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

God!

From Ngspice manual p47:

The ground node must be named “0” (zero). For compatibility reason “gnd” is accepted as ground node, and will internally be treated as a global node and be converted to “0”. Each circuit has to have a ground node (gnd or 0)!

But

.title None
.subckt Fonte input output 
Vin input output 10V
.ends Fonte
X1 2 1 Fonte
R1 3 1 1K
R2 2 3 2K
.options TEMP = 25°C
.options TNOM = 25°C
.ic 
.tran 100us 3ms 0s
.end

works for me ???

does xspice or cider relax this constrain ???

from pyspice.

FabriceSalvaire avatar FabriceSalvaire commented on June 12, 2024

This bug was introduced in ce75026

fixed in c6dfb0a

from pyspice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.