phetsims / circuit-construction-kit-dc

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

A 0 resistance light bulb should have 0 power #126

Closed samreid closed 7 years ago

samreid commented 7 years ago

image

A 0 resistance light bulb should have 0 power and hence no brightness lines. @arouinfar can you please confirm this?

samreid commented 7 years ago

Dragging a light bulb out of the toolbox caused an ammeter reading to fluctuate and the brightness rays to flicker and go off. Could this be related to #125 ?

samreid commented 7 years ago

There is some noise in the solver: image

samreid commented 7 years ago

P=iir will be better because it can use the user-set resistance.

samreid commented 7 years ago

image

samreid commented 7 years ago

I published a proposed fix here that uses P=iir instead of P=iv. @arouinfar can you please take a look? http://www.colorado.edu/physics/phet/dev/html/circuit-construction-kit-dc/1.0.0-dev.132/circuit-construction-kit-dc_en.html

The circuit solver adds an equation for 0 resistance components that their v1=v2, but I think there is numerical error in the solution. I wonder if 1E-10 is too low of a resistivity?

arouinfar commented 7 years ago

A 0 resistance light bulb should have 0 power and hence no brightness lines. @arouinfar can you please confirm this?

That's correct @samreid.

The circuit solver adds an equation for 0 resistance components that their v1=v2, but I think there is numerical error in the solution. I wonder if 1E-10 is too low of a resistivity?

This may be a naive approach, but can you instead check the resistance of the bulb, and if it is zero, set the brightness to zero?

arouinfar commented 7 years ago

This looks a bit off...

image

samreid commented 7 years ago

but can you instead check the resistance of the bulb, and if it is zero, set the brightness to zero?

Since the resistance value has no noise and can be exactly zero, it seems best to use P=i*i*r. An additional check would provide no additional value (unless I'm misunderstanding something).

arouinfar commented 7 years ago

@samreid I guess I misunderstood this statement to mean there's a numerical error when checking if v1=v2 to determine if R=0. Instead, you're verifying R=0, then setting v1=v2?

The circuit solver adds an equation for 0 resistance components that their v1=v2, but I think there is numerical error in the solution. I wonder if 1E-10 is too low of a resistivity?

samreid commented 7 years ago

Correct, here is the code:

      // If resistor has no resistance, node0 and node1 should have same voltage
      for ( i = 0; i < this.resistors.length; i++ ) {
        var resistor = this.resistors[ i ];
        if ( resistor.resistance === 0 ) {
          equations.push( new Equation( 0, [
            new Term( 1, new UnknownVoltage( resistor.node0 ) ),
            new Term( -1, new UnknownVoltage( resistor.node1 ) )
          ] ) );
        }
      }

However, an ill conditioned system can still lead to v1 differing from v2 (but r will still be 0 and P=i*i*r will still be right.). Adding more wire resistivity can lead to a better conditioned matrix system.

Another approach we could investigate to address https://github.com/phetsims/circuit-construction-kit-dc/issues/126#issuecomment-319422746 would be to run the solver on disjoint subcircuits. Currently all circuit elements are solved in one big matrix.

samreid commented 7 years ago

I think I'll close this issue since 0 resistance bulbs will always be unlit now. I'll move https://github.com/phetsims/circuit-construction-kit-dc/issues/126#issuecomment-319422746 over to #125

arouinfar commented 7 years ago

Sounds good @samreid. The 0-resistance bulbs in dev.132 looked good to me.