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

Opening and closing switch while paused causes current to jump from negative to positive #778

Closed
stemilymill opened this issue Nov 11, 2021 · 23 comments
Assignees

Comments

@stemilymill
Copy link

For phetsims/qa#736, also may be related to #770.
When opening and closing a switch while sim is paused, current in one part of a circuit jumps to zero and back to the original value, but current in another part of a circuit jumps from its original (negative) value to zero and then to a positive value.

play.pause.behavior.2.inductors.2.resistors.1.capacitor.1.battery.1.ac.source.mp4
@KatieWoe
Copy link
Contributor

I was able to reproduce this with a fairly simple circuit. If the current was positive when the switch turned off, it will be positive again when turned on and the curve looks smooth. If it was negative however, it is positive when turned back on.
simplecircuitsignchange

@KatieWoe
Copy link
Contributor

May be related to #606

@KatieWoe
Copy link
Contributor

@samreid I also noticed that the sign the current reads depends on when the first ammeter was dragged out.

  1. Build a circuit with a battery, lightbulb, and wires.
  2. Pull out an ammeter and look at the current
  3. Switch the battery around and observe the negative current.
  4. Hit reset all
  5. Build the circuit from step 3
  6. Pull out the ammeter and observe

@samreid samreid added this to the AC 1.0 milestone Nov 12, 2021
@samreid
Copy link
Member

samreid commented Nov 12, 2021

For #778 (comment), I think the behavior is as expected, please see #770 (comment)

For #778 (comment), there is a rule that the first reading from a completed circuit should be positive. I think that explains the sign change.

For #778 (comment), I am seeing the expected behavior, that the current is positive on the first reading on a completed circuit. Are you seeing something different?

Also assigning @arouinfar to review these reports.

@samreid samreid assigned arouinfar, KatieWoe and stemilymill and unassigned samreid Nov 12, 2021
@samreid
Copy link
Member

samreid commented Nov 15, 2021

@arouinfar and I reviewed the 3 cases above and all the behavior seems to be expected. @arouinfar will check the teacher tips to make sure it discusses that the initial currents are always positive (no matter the direction of the battery). You will see the polarity flip if you flip the battery after connection, but not before.

@KatieWoe
Copy link
Contributor

@samreid this is what I'm seeing. I can get it to read negative first, but it might be explained by what you said in #778 (comment)
contradiction

@samreid
Copy link
Member

samreid commented Nov 15, 2021

@arouinfar and I reviewed the behavior, and agreed it is the expected behavior. The current directionality is selected to make initial currents positive at the time the circuit is completed..

@samreid
Copy link
Member

samreid commented Nov 18, 2021

At today's design meeting, we discussed that it is confusing for the current to change direction when a switch is opened then closed. @kathy-phet asked if I could investigate that. Fixing this is not critical for 1.0, but I'll investigate.

The current (pun!) rule is:

// Disconnected circuits have a current of exactly 0, so we can use that to determine when to clear the sense
    const isReadyToClear = current === 0;

We could change the rule to "current is zero and it is not in a loop with an open switch". We would at least like to try that much before 1.0.

@samreid samreid self-assigned this Nov 18, 2021
@samreid
Copy link
Member

samreid commented Nov 23, 2021

@kathy-phet asked if I could investigate that. Fixing this is not critical for 1.0, but I'll investigate.

The existing depth-first search algorithms have special handling around switches (to not traverse them) and do not track which elements were traversed, so it would take 2-4 hours to write out this new algorithm and test it thoroughly. I'm not sure whether this is acceptable, especially if it's on the longer side. @arouinfar @kathy-phet @ariel-phet want me to keep working on this for 1.0?

UPDATE: This also feels like something that could be layered in efficiently after 1.0 is published, since the proposed algorithm is orthogonal to the existing implementation.

@samreid samreid assigned ariel-phet and kathy-phet and unassigned samreid Nov 23, 2021
@kathy-phet
Copy link

I vote for deferring this exploration until after 1.0 is published. When we do PhET-iO, we can revisit this issue, but proceed with with publishing the current behavior.

@kathy-phet kathy-phet removed their assignment Nov 23, 2021
@ariel-phet ariel-phet removed their assignment Nov 24, 2021
@samreid
Copy link
Member

samreid commented Feb 18, 2022

@kathy-phet recommends the design team reviews the current algorithm before @samreid rewrites anything.

@arouinfar how should we accomplish that step?

@arouinfar
Copy link
Contributor

@samreid let's evaluate at design meeting and decide next steps.

@arouinfar arouinfar removed their assignment Feb 19, 2022
@arouinfar arouinfar self-assigned this Nov 30, 2022
@arouinfar
Copy link
Contributor

Self-assigning to understand the current behavior.

@matthew-blackman
Copy link

matthew-blackman commented Dec 15, 2022

12/15/22 Design Meeting

We agree that this is an issue worth spending about 4-8 hours working on since it is related to pedagogical needs. It is not a top priority for this Initial PhET-iO DC release milestone, but should be moved to the Initial PhET-iO AC release milestone.

The behavior of the non-contact ammeter is consistent and described within documentation, but this is still worth a couple hours of investigation for the AC edge cases.

@matthew-blackman and @samreid will investigate if there are remaining edge cases within DC that could have pedagogical ramifications.

@matthew-blackman
Copy link

@samreid and I implemented a possible fix by having circuit components remember their 'currentSense' even when disconnected. This fixes the issue, but could have potential drawbacks. For example, if a new set of students sat down to a sim that was already open, they could be confused as to why the initial current reading was negative. We will also need to check for issues with taking components from one circuit and placing them in another.

@samreid
Copy link
Member

samreid commented Feb 13, 2023

@arouinfar can you please review and advise?

@matthew-blackman
Copy link

@samreid and I agree that this behavior is acceptable, but should be clearly documented. We will look into the documentation files that are presented to the user and how this can be best communicated through those files.

@arouinfar can you advise the appropriate place to document this?

@arouinfar
Copy link
Contributor

I agree that the behavior is acceptable. It is well-documented in the Teacher Tips, but I did make some updates to the AC Tips and the DC Tips (will upload in #886). I think we can go ahead and close this issue. Short of moving to ngspice (#228), I don't think we'll make any further major changes to the circuit dynamics.

@arouinfar arouinfar removed this from the Full initial PhET-iO release: AC milestone Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants