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

Better error for missing ground #56

Open
endolith opened this issue Feb 27, 2017 · 1 comment
Open

Better error for missing ground #56

endolith opened this issue Feb 27, 2017 · 1 comment
Assignees
Labels

Comments

@endolith
Copy link
Contributor

import ahkab

mycir = ahkab.Circuit('Simple Example Circuit')
mycir.add_isource('Isource', 'nA', 'nD', dc_value=1)
mycir.add_resistor('Rad', 'nA', 'nD', value=5)

opa = ahkab.new_op()
r = ahkab.run(mycir, opa)['op']

produces error:

  File "C:\Anaconda3\lib\site-packages\ahkab\dc_analysis.py", line 1007, in generate_mna_and_N
    N[elem.n2, 0] = N[elem.n2, 0] - elem.I()

IndexError: index 2 is out of bounds for axis 0 with size 2

Adding a ground makes it work:

import ahkab

mycir = ahkab.Circuit('Simple Example Circuit')
mycir.add_isource('Isource', 'nA', 'nD', dc_value=1)
mycir.add_resistor('Rad', 'nA', 'nD', value=5)
mycir.add_vsource('Vgnd', mycir.gnd, 'nC', dc_value=0)

opa = ahkab.new_op()
r = ahkab.run(mycir, opa)['op']

Is it possible to make this error more helpful?

@itdaniher
Copy link
Contributor

itdaniher commented Feb 27, 2017

Yes! This should totally be caught by a pre-check, well before generate_mna_and_N. I'm actually on vacation this week(!) but I'll be sure to fix this when I get a chance.

Thanks!

edit:markdown

@itdaniher itdaniher self-assigned this Feb 27, 2017
@itdaniher itdaniher added the bug label Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants