-
Notifications
You must be signed in to change notification settings - Fork 0
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
Error: Assertion failed: unexpected emfProperty.value #149
Comments
This is also occurring on CT |
Assertion message changed in the above commit, and updated in the issue title. Reproduced in my working copy with http://localhost:8080/phet-io-wrappers/state/?sim=faradays-electromagnetic-lab&locales=*&phetioWrapperDebug=true&fuzz&phetioDebug=true&audio=disabled This is related to #124, the workaround for zeroing out EMF when switching power supplies. The relevant code in Transformer.ts is: // Workaround for https://github.com/phetsims/faradays-electromagnetic-lab/issues/92, to ignore the EMF induced
// by switching power supplies. Step the pickup coil twice, so that there is effectively no induced EMF.
this.electromagnet.currentSourceProperty.lazyLink( () => {
this.pickupCoil.step( ConstantDtClock.DT ); // EMF may be induced by changing from oldCurrentSource to newCurrentSource.
this.pickupCoil.step( ConstantDtClock.DT ); // No EMF is induced because there is no flux change in newCurrentSource.
assert && assert( this.pickupCoil.emfProperty.value === 0, `unexpected emfProperty.value: ${this.pickupCoil.emfProperty.value}` );
} ); I'm glad I added this assertion, because something is clearly not right when state is restored. Maybe I need to add an |
That's what I did in f3773ce. It seems to resolve the problem in my working copy, and we'll see what CT has to say. But I don't understand why it's necessary, or why it's even effective. And I'm concerned that it may result in incorrect behavior when switching power supplies. |
The code identified in #149 (comment) has been replaced by a new implementation for avoiding induced EMF when changing power supplies -- see #124. So I've removed the |
Still occurring in CT, most recently:
|
Meeting with @zepumph scheduled for Tue 4/9 @ 11AM MT. |
The reason that clearEMF fails is that Property changes made while setting state are silently (!) ignored. In ReadOnlyProperty.ts: protected set( value: T ): void {
// state is managed by the PhetioStateEngine.
// We still want to set Properties when clearing dynamic elements, see https://github.com/phetsims/phet-io/issues/1906
const setManagedByPhetioState = isPhetioStateEngineManagingPropertyValuesProperty.value &&
!isClearingPhetioDynamicElementsProperty.value &&
this.isPhetioInstrumented() && this.phetioState &&
// However, DerivedProperty should be able to update during PhET-iO state set
this.isSettable();
if ( !setManagedByPhetioState ) {
this.unguardedSet( value );
}
} So in 8e7ada8, it's necessary to short-circuit the call to // Ignore the EMF induced by switching power supplies. Do not do this when setting PhET-iO state because Property
// changes made by clearEMF will be ignored, resulting in failure of clearEMF.
// See https://github.com/phetsims/faradays-electromagnetic-lab/issues/149.
this.electromagnet.currentSourceProperty.lazyLink( () => {
if ( !isSettingPhetioStateProperty.value ) {
this.pickupCoil.clearEMF();
}
} ); I'll leave this open for a few CT cycles to confirm that this resolves the problem. |
CT is happy. Closing. |
Discovered while working on #103, while testing the state wrapper on macbook air m1 chrome, I believe I changed to the AC source right before this happened:
I confirmed that these steps reproduce the problem:
The text was updated successfully, but these errors were encountered: