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

Non-Ideal Wires Causing Errors #3

Closed
Krb686 opened this issue May 19, 2014 · 3 comments
Closed

Non-Ideal Wires Causing Errors #3

Krb686 opened this issue May 19, 2014 · 3 comments

Comments

@Krb686
Copy link

Krb686 commented May 19, 2014

Unfortunately I think the sections of code written to use realistic wires are still causing quite a few errors.

I noticed this problem when one of my circuits ran fine on Falstad's original, but yet fails to converge in this version. Setting the boolean ideal to true inside WireElm allows the circuit to run properly on this version.

Rather difficult to debug, but so far I have traced the error to the program attempting to set one of the nodes to a voltage of 2.6 billion volts.

hausen_error_1

The value of 2.6 billion volts is inserted into the array called "volts". Inside of MosfetElm, this causes execution to run inside one of these if-statements, replacing the value with lastv2 + 0.5.

hausen_error_2

After that, the convergence is set to false, here:

hausen_error_3

This repeats until it has looped the maximum of 5,000 times, where it then fails. Each time the large value of 2.6 billion alternates between being in volts[1] or volts[2]

Now trying to trace this backwards, that result of 2.6 Billion is computed inside lu_solve in the matrix called b. Harder to trace at this point because I don't know which value is incorrect.

It comes from the statement:

b[i] = tot / a[i][i]

tot = -2.6*10^21

hausen_error_4

And a[i][i] = -1*10^12, (in this case i=29)

hausen_error_5

This may or may not be of any help. At this point it becomes much harder because this is getting into all of the matrix calculations

@hausen
Copy link
Owner

hausen commented May 19, 2014

Is the circuit the same one in #1 ?

@Krb686
Copy link
Author

Krb686 commented May 19, 2014

No, it is a different one. It appears to be happening any time I connect op-amps with no feedback loop directly to the base of p or n MOSFETs.

Here is one such circuit.

$ 1 5.0E-6 10.20027730826997 50 5.0 43
R 464 208 464 96 0 1 40.0 5.0 0.0 0.0 0.5
f 400 224 464 224 0 1.5
f 400 288 464 288 1 1.5
w 464 240 464 272 0
g 464 304 464 352 0
a 336 224 400 224 0 15.0 -15.0 1000000.0
a 336 288 400 288 0 15.0 -15.0 1000000.0
w 336 240 304 240 0
w 304 240 304 256 0
w 304 256 304 272 0
w 304 272 336 272 0
g 304 256 272 256 0
w 336 208 240 208 0
w 336 304 240 304 0
w 240 304 240 256 0
w 240 208 240 256 0
w 240 256 192 256 0
R 192 256 144 256 0 1 40.0 5.0 0.0 0.0 0.5

@hausen
Copy link
Owner

hausen commented Aug 11, 2016

After more than 2 years, I realized that the default wire resistance was too low. I have increased it from 1pΩ to 1µΩ. It may not fix the problem entirely, but this seems to be an issue with the original simulation algorithm; if you use Paul Falstad's original version and replace the wires with 1pΩ resistors, you'll get the same error.

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

No branches or pull requests

2 participants