phetsims / circuit-construction-kit-common

"Circuit Construction Kit: Basics" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
10 stars 10 forks source link

infinite voltage in inductor when circuit is broken #570

Closed arouinfar closed 2 years ago

arouinfar commented 4 years ago

@samreid can you investigate this? This also happens in AC and DC RL circuits in both HTML5 and Java.

A user emailed phethelp:

Test device Lenovo Notebook Operating System Win 10 64 bit Browser Mozilla Forefox Problem description Infinite voltage oscillation induced after breaking L circuit . Same happends in AC circuit LAB Steps to reproduce Switch of the voltage and observe oscilloscope readings (voltage chart) Visuals Screenshot attached. I know this is prototype, so wanted to inform you. Unfortunately I need it badly for tomorrow morning ... ;-) All the best! image

Troubleshooting information: !!!!! DO NOT EDIT !!!!! Name: ‪Circuit Construction Kit: AC‬ URL: http://phet.colorado.edu/sims/html/circuit-construction-kit-ac/latest/circuit-construction-kit-ac_en.html Version: 1.0.0-dev.9 2020-01-24 14:20:57 UTC Features missing: touch User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0 Language: pl Window: 1353x640 Pixel Ratio: 1/1 WebGL: WebGL 1.0 GLSL: WebGL GLSL ES 1.0 Vendor: Mozilla (Mozilla) Vertex: attribs: 16 varying: 30 uniform: 4096 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 32767x32767 OES_texture_float: true Dependencies JSON: {}

samreid commented 3 years ago

There is an explanation at https://jmanton.wordpress.com/2018/08/03/does-the-voltage-across-an-inductor-immediately-reverse-if-the-inductor-is-suddenly-disconnected/

It says an ideal inductor suddenly disconnected will oscillate. For this reason, real inductors are often modeled as an ideal inductor in series with an ideal capacitor and ideal resistor.

samreid commented 3 years ago

Proposal: add a listener so that when the circuit topology changes (vertices disconnected or switch opened), any inductors that are no longer in a loop are cleared.

@ariel-phet and/or @arouinfar do you think this will work?

ariel-phet commented 3 years ago

@samreid yes I think that would be a reasonable solution. An ideal inductor would indeed oscillate (which is not realistic). In general the field decays quite quickly, so I think clearing the inductor when disconnected is very reasonable.

For example, an incandescent bulb has a fading glow when turned off since it take a moment for the filament to cool but we clear the light bulb rays instantly when the current drops to zero across the bulb, which is a completely reasonable simplification, I feel like the same logic applies here.

samreid commented 3 years ago

Checking for whether an inductor is in a loop is complicated, since we would need to consider insulators, open switches, etc. Instead, it is straightforward to detect when the inductor oscillates, like so:

    this.voltageDifferenceProperty.link( ( newValue, oldValue ) => {

      // If the voltage switched sign to a value with a similar magnitude, it is probably oscillating and should be
      // cleared
      if ( oldValue * newValue < 0 && Math.abs( oldValue ) > 1 ) {
        const diff = Math.abs( Math.abs( oldValue ) - Math.abs( newValue ) );

        if ( diff < 1 ) {
          this.clear();
        }
      }
    } );

With this code, there is a single spike in the voltage when the circuit is disconnected:

Is this acceptable? Or should I investigate alternatives?

image

ariel-phet commented 3 years ago

@samreid I do not think that is an acceptable solution. There are many situations in which the inductor voltage should oscillate (such as when driven by an oscillating source or when setting up an RLC circuit).

Perhaps you and I should have a zoom chat and discuss some possibilities.

samreid commented 3 years ago

To be more specific, the detection code in https://github.com/phetsims/circuit-construction-kit-common/issues/570#issuecomment-711249184 only detects the erratic cases like when voltage jumps from -28V to +28V in 1/60th of a second, and would not be triggered by normal oscillatory behavior. I'm not opposed to a more robust solution, but should make sure it is warranted. Please reach out to me on slack if you'd like to schedule a zoom chat.

samreid commented 3 years ago

@ariel-phet and I discussed a more robust algorithm that clears the inductor if its neighboring circuit elements have no current. I committed it and it looks like this:

image

@ariel-phet can you please test in master?

UPDATE: Also, can you please comment on whether it will be problematic if the circuit goes through a transient state where the neighboring currents are temporarily 0? Will it be detrimental to clear the inductor in that case?

ariel-phet commented 3 years ago

@samreid so far this solution seems to be working well. In places where the circuit goes through a transient "zero" state it does not seem to be causing problems (for instance just driving with an AC source, or setting up an RLC circuit and having it oscillate.

Overall this solution seems to be working well. We still do get a very large spike on the graph. It might be worth bringing to design meeting. I would be tempted to stop the spike potentially from going over a certain voltage so it looks more like a feature than a glitch. That would be nice for showing how something like the ignition coil in a car works, but if just spikes "infinitely" it is a bit tougher to interpret.

pixelzoom commented 3 years ago

@samreid You asked @ariel-phet to review, he commented, but did not assign back to you. So back to you to decide what's next.

samreid commented 3 years ago

@arouinfar can you please review this issue, and see if any more work is warranted, or if another design meeting is warranted?

samreid commented 3 years ago

At today's design meeting, @kathy-phet recommended that @arouinfar could meet with MD to discuss this topic.

samreid commented 3 years ago

At today's design meeting, we agreed it would be good for @arouinfar to discuss this with MD. Increasing priority since we are getting closer to publication.

@ariel-phet pointed out this is OK as long as it is non-infinite. I'll measure it and report here.

I'll create side issues for the new issues discovered during the meeting.

samreid commented 3 years ago

From today's design meeting. This issue is on hold until the rest of the model settles down. I measured the value and found it was non-infinite, had something like 500V or 500A?

samreid commented 3 years ago

This no longer demonstrates the spike after the new voltage solution in #738, @arouinfar can you please test/verify in https://phet-dev.colorado.edu/html/circuit-construction-kit-ac/1.0.0-dev.25/phet/circuit-construction-kit-ac_en_phet.html. Can this issue be closed?

image

ariel-phet commented 3 years ago

@samreid @arouinfar this behavior is certainly clean but I think some issues are present.

The inductor does not seem to "hold" any energy if hooked up in an isolated manner to a battery, charged, and then hooked up to another part of the circuit (and disconnected from the battery. In the same way I can "charge up a capacitor" I should be able to "Charge up an inductor" and then introduce it to an LC circuit. In dev.25 if I build the following test circuit I see several pieces of odd behavior:

test circuit

  1. I should be able to engage the top switch, energize the inductor, then isolate it, and fairly quickly flip the LC circuit switch and see an oscillating behavior. If you try that, you will see no oscillation

  2. Alternatively with the top switch open, I should be able to close the bottom switch, charge the capacitor, isolate it, and then engage the switch for the LC circuit and see and oscillating behavior. If I try that the sim basically freezes (it will begin to show correct behavior, but quickly something goes very awry (the capacitor appears to start to gain more charge than it began with)

However, if I try this simple test circuit (where I can first charge the capacitor, and no other wires come off the inductor, I can get the correct LC oscillating behavior (note there is a switch next to the inductor) test circuit 2

samreid commented 3 years ago

In today's meeting, we tested the circuit above, and the behavior seemed much better--perhaps due to the fixes in https://github.com/phetsims/circuit-construction-kit-common/issues/693 and current conversation.

We temporarily reverted the commit https://github.com/phetsims/circuit-construction-kit-common/commit/dd6743b3756102f8015b47fd70c0a4414f0461d0 and saw that the energy was stored properly in the inductor.

We discussed the "clear an inductor when it is disconnected", and decided to keep this behavior (to avoid other unexpected behavior, such as looking like perpetual motion for a resistor-less loop), but it needs to be mentioned in the teacher tips for https://github.com/phetsims/circuit-construction-kit-ac/issues/9.

@ariel-phet would like to test this further after we have fixes from #693 in a dev version.

samreid commented 3 years ago

Even though #693 still has some corner cases, I think the behavior is steady enough to test this issue in https://phet-dev.colorado.edu/html/circuit-construction-kit-ac/1.0.0-dev.28/phet/circuit-construction-kit-ac_en_phet.html. But please send it back to me if any corner case like #693 interferes with testing this issue.

UPDATE: Let's use https://phet-dev.colorado.edu/html/circuit-construction-kit-ac/1.0.0-dev.31/phet/circuit-construction-kit-ac_en_phet.html as it is a bit newer.

samreid commented 3 years ago

From today's design meeting:

@ariel-phet: This should be on hold until we have determined the inductance ranges in https://github.com/phetsims/circuit-construction-kit-common/issues/590 and address the conditioning problems in https://github.com/phetsims/circuit-construction-kit-common/issues/744

UPDATE: #744 seems like it may be good, but we can still wait for progress in #590 before working on this issue.

samreid commented 2 years ago

We reviewed this behavior after https://github.com/phetsims/circuit-construction-kit-common/issues/590. There is no longer any spike. The downside is that we aren't showing the inductor taking time to dissipate its energy. But trying to model that behavior would introduce other problems and potential bugs. @ariel-phet thinks @arouinfar may have already noted this behavior in the teacher tips. The current behavior is the same as in the Java sim.

We talked about ignition coils, putting a low resistance in series with an inductor. Then toggling a voltage source quickly and disconnecting quickly, causes a voltage spike. We aren't modeling this in the simulation. But maybe this would be done in an inductor-specific sim in the future.

We agreed this can be closed.

samreid commented 2 years ago

Today @ariel-phet and I considered that clearing the inductor when its neighboring currents go to zero may lead to problems in an AC circuit, where it goes to 0 current once per cycle. We haven't seen symptoms of this problem that we are aware of but it's possible.

ariel-phet commented 2 years ago

So far in my testing I think we are safe closing this issue. Considering this behavior matches Java and does not seem to be causing bugs, I think we are good to go.