conda-forge / pyspice-feedstock

A conda-smithy repository for pyspice.
BSD 3-Clause "New" or "Revised" License
1 stars 5 forks source link

examples/operational-amplifier/astable.py don't simulate (on Linux) #18

Open FabriceSalvaire opened 4 years ago

FabriceSalvaire commented 4 years ago

All tests work excepted this one on my conda

2020-06-05 20:41:54,044 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Note: can't find init file.
2020-06-05 20:41:54,053 - PySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char - ERROR - Error: circuit not parsed.

But desk simulates and it works on my venv

stuarteberg commented 4 years ago

Does PySpice/Scripts/pyspice_post_installation.py --check-install verify proper setup of the spinit file? If not, it would be good to add that. Our recipe build will run that as a test.

FabriceSalvaire commented 4 years ago

No it doesn't check it. I believe ngspice binary provide one on windows, but not sure ???

Something is different with ngspice conda because I have an empty $HOME/.spiceinit and this failure is very strange. Is it the same Ngspice 32 (git sha) ? I believe there is voodoo somewhere ...


16.6 User defined configuration file .spiceinit
In addition to spinit you may define a (personal) file .spiceinit and put it into the current di-
rectory or in your home directory. The typical search sequence for .spiceinit is: current di-
rectory, HOME (Linux) and then USERPROFILE (Windows). USERPROFILE is typically
C:\Users\<User name>. This file will be read in and executed after spinit, but before any
other input file is read. It may contain further scripts, set variables, or issue commands from
Chapt.17.5 to override commands given in spinit. For example set filetype=ascii will
yield ASCII output in the output data file (rawfile), instead of the compact binary format that is
used by default. set ngdebug will yield a lot of additional debug output. Any other contents
of the script, e.g. plotting preferences, may be included here also. If the command line option
-n is used upon ngspice start up, this file will be ignored.
.spiceinit may contain:
* User defined ngspice init file
set filetype=ascii
*set ngdebug
set numthreads = 8
*set outputpath=C:\Spice64\out
``
stuarteberg commented 4 years ago

Is it the same Ngspice 32 (git sha) ? The ngspice source download url is shown here. I don't know the git SHA.

To see exactly what is installed when a user installs ngspice-lib from conda-forge, you can browse the package files for ngspice-lib here.

In that tarball, we include share/ngspice/scripts/spinit. Here's the directory structure:

image

These two comments in the ngspice source code explain how spinit is located, and how to make sure the build is configured properly:

https://github.com/stuarteberg/ngspice/blob/master/src/frontend/cpitf.c#L251-L254 https://github.com/stuarteberg/ngspice/blob/master/src/misc/ivars.c#L36-L50

The comments explain that one can set NGSPICEDATADIR in config.h, but that seemed unnecessary to me because the default value appears to be correct:

https://github.com/stuarteberg/ngspice/blob/master/visualc/src/include/ngspice/config.h#L439-L440

But if something is going wrong there, we can try setting the SPICE_LIB_DIR environment variable at runtime, to see if that makes a difference.

FabriceSalvaire commented 4 years ago

There is two different things here:

FabriceSalvaire commented 4 years ago

ngspice conda reports but not Fedora one

.title Astable Multivibrator
Vcc vcc 0 15V
R1 output comparator 1kOhm
C1 comparator 0 100nF
R2 output reference 100kOhm
R3 vcc reference 100kOhm
R4 reference 0 100kOhm
E1 output 0 TABLE {V(reference, comparator)} = (-1u, 0) (1u, 15V)
.options TEMP = 25°C
.options TNOM = 25°C
.ic V(comparator)=0
.tran 1us 500us 0s
.end
Circuit: Astable Multivibrator

Error on line 0 :
  ae1 %v(e1_int2) %v(e1_int1) xfer_e1
 MIF-ERROR - unable to find definition of model xfer_e1
    Simulation interrupted due to error!
FabriceSalvaire commented 4 years ago

conda

** CIDER 1.b1 (CODECS simulator) included
** XSPICE extensions included
** Relevant compilation options (refer to user's manual):
** OpenMP multithreading for BSIM3, BSIM4 enabled

Fedora

** CIDER 1.b1 (CODECS simulator) included
** XSPICE extensions included
** Relevant compilation options (refer to user's manual):
** Adms interface enabled
** OpenMP multithreading for BSIM3, BSIM4 enabled
** --enable-predictor
FabriceSalvaire commented 4 years ago

-> https://github.com/conda-forge/ngspice-feedstock/issues/10