Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ENH: Add basic Windows support #7

Merged
merged 14 commits into from Feb 12, 2017
Merged

ENH: Add basic Windows support #7

merged 14 commits into from Feb 12, 2017

Conversation

endolith
Copy link
Collaborator

@endolith endolith commented Feb 4, 2017

This assumes a particular directory structure (but then again, so does
ngspice's spinit file).

It changes working directory to load the DLL and dependencies without
problems. This might not be optimal, but it works.

I tried to add some guessing of 32-bit and 64-bit, and in case system drive is not C:\ but I didn't test anything except 64-bit C:\

Fixes #5

Center the cutoff frequency
Magnitude and phase plots in normal Bode plot layout on top of each
other with same freq axis instead of side by side

also PEP8 fixes
I was getting something like "1.200000000002" in my graph

also PEP8 fixes to all examples
This assumes a particular directory structure (but then again, so does
ngspice's spinit file).

It changes working directory to load the DLL and dependencies without
problems.  This might not be optimal, but it works.
Add grids, sharex

Change x margins to 0 for MPL 2.0

Updated image with all changes

Use Pythonic ac() command instead of cmd()
This was not working intermittently because
ngspyce.vectors(['Vcos', 'Vsin', 'time'])
is a dictionary and the outputs aren't in random order.
Includes backwards incompatible change: vectorNames -> vector_names

"Function names should be lowercase, with words separated by underscores
as necessary to improve readability.

mixedCase is allowed only in contexts where that's already the
prevailing style (e.g. threading.py), to retain backwards
compatibility."
"Avoid raising a generic Exception, to catch it, you'll have to catch
all other more specific exceptions that subclass it."

Also reword error message for ac sweep validation
Add tests for ac(), cmd(), model_parameters(), linear_sweep()
to improve test coverage
Make sure that spinit and default *.cm files are being loaded.

These include spice2poly which is required for most vendor op-amp
models, etc.
@endolith
Copy link
Collaborator Author

endolith commented Feb 9, 2017

Hmm I guess this is including all changes I've made to my master branch. Not sure how best to handle that.

Change examples to use it instead of cmd()

Add a test for it
# Conflicts:
#	examples/lowpass/lowpass.py
#	examples/npn/npn.py
#	examples/quadrature_oscillator/quadosc.py
@ignamv
Copy link
Owner

ignamv commented Feb 11, 2017

Looks good. Do the tests pass on Linux?

@endolith
Copy link
Collaborator Author

I'll try to compile ngspice for Linux, never tried that before

@endolith
Copy link
Collaborator Author

endolith commented Feb 11, 2017

Hmm, I cloned the ngspice git repo (git clone https://git.code.sf.net/p/ngspice/ngspice ngspice ) and tried ./configure --with-ngshared but that doesn't work. there's a configure.ac, though. Did this change or am I using the wrong repo?

@endolith
Copy link
Collaborator Author

Ok I got ngspice-26.tar.gz instead and the instructions worked this time. /usr/local/lib/libngspice.so exists now, but I still get OSError: libngspice.so: cannot open shared object file: No such file or directory

@endolith
Copy link
Collaborator Author

endolith commented Feb 11, 2017

If I edit /usr/local/lib/python3.5/dist-packages/ngspyce/ngspyce.py and change the line to spice = CDLL('/usr/local/lib/libngspice.so') then ngspyce works, but the tests for the .cm files don't work. So I guess they're not enabled by default? So

  • if those are optional to ngspyce, change the tests into warnings
  • if those are required for ngspyce, change the build instructions to enable them

In my testing, many spice models require the spice2poly.cm to be enabled, and they weren't working in Windows until I figured out the paths, etc. so I wrote test for them.

@ignamv
Copy link
Owner

ignamv commented Feb 11, 2017 via email

@ignamv ignamv merged commit 668c51d into ignamv:master Feb 12, 2017
@ignamv
Copy link
Owner

ignamv commented Feb 12, 2017

Thank you!

@endolith
Copy link
Collaborator Author

So are there things you'd be ok with me merging directly, or should I always file pull requests? Unfinished stuff is in https://github.com/endolith/ngspyce/tree/experimenting

@ignamv
Copy link
Owner

ignamv commented Feb 12, 2017

I'd prefer to look at any changes that might break something, and at least run the tests on Linux.

By the way, what are you using ngspyce for?

@endolith
Copy link
Collaborator Author

Ok I'll just file PRs. :)

I've only done some experiments so far, but I'd like to automate some circuit design stuff, like optimizing resistor values to maximize THD+noise for a circuit, etc.

condenser mic capsule noise vs bias resistor ngspyce

bc547 mpl2

2n2222 220 ohm

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

Successfully merging this pull request may close these issues.

None yet

2 participants