Giter Club home page Giter Club logo

Comments (4)

pfalstad avatar pfalstad commented on August 22, 2024

Yes, this is exactly the problem with trapezoidal approximation, and why there's a checkbox to turn it off. Trapezoidal is more accurate for circuits without analog switches (or the equivalent), and I thought those would be more common, so that's why I made it the default. The accuracy difference is pretty small though, so maybe I should turn it off by default.

from circuitjs1.

ericfont avatar ericfont commented on August 22, 2024

Ah. Well I'm thinking the type of glitch I experienced from trapezoidal is a dramatically greater "inaccuracy", even though it only occurs with circuits with the equivalent of analog switches. (Now that you mention that, I recall seeing a similar glitches in other circuits with similar types of switching...)

It took me a while to ponder this strange behavior and to take a guess to turn off trapezoidal, but an electronics beginner would be even more confused by it and might misinterpret the circuit functionality. I consider circuitjs to be more suited for getting reasonable behavior rather than most accurate (users can use spice if accuracy is most desired, or even protype it is real world behavior is desired), so I would suggest to disable trapezoidal by default. But you are the maintainer, so you be the judge.

from circuitjs1.

ericfont avatar ericfont commented on August 22, 2024

I'm also observing that the glitch with trapezoidal decreases as the simulator's time step size is decreased, such that when reduced to 100 ns, then it is just a one pixel difference in the scope. So maybe as an alternative solution would be for the simulator to automatically detect if this glitch is going to be noticeable and to automatically decrease the time step size...but that might be too involved of a solution.

from circuitjs1.

ericfont avatar ericfont commented on August 22, 2024

I'm noting the glitch also happens with a regular mechanical switch (in addition to the "analog switch"), for instance with the following circuit:

circuit-20240307-1839

If I repeatedly toggle the switch with my mouse, the capacitor's voltage will randomly jump up either to 10 V or down to 0 V, when it should always just remain at the voltage it was at when the switch was closed:

image

I can't quite figure out the pattern of whether it jumps up or down, but I'm guessing the direction it jumps may be due to the exact time that the switch toggling in relation to the simulator tick.

I am also noting that I can produce the glitch while the simulator is running by manually removing the wire between the voltage source and the capacitor:

circuit-20240307-1847

...for instance when deleting it:

circuit-20240307-1847 (1)

or also by dragging the wire away to disconnect the capacitor:

circuit-20240307-1849

I think this was how I've experienced the glitch before.

Anyway I'm more and more thinking that the trapezoidal approximation should be disabled by default. And then only if the user deliberately knows what they are doing, then they can manually enable the approximation.

from circuitjs1.

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.