Skip to content

Commit

Permalink
proposed fix for incorrect EMF in State wrapper, #149
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 29, 2024
1 parent cfd3261 commit f3773ce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/transformer/model/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import RangeWithValue from '../../../../dot/js/RangeWithValue.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import optionize from '../../../../phet-core/js/optionize.js';
import ConstantDtClock from '../../common/model/ConstantDtClock.js';
import isSettingPhetioStateProperty from '../../../../tandem/js/isSettingPhetioStateProperty.js';

type SelfOptions = {
electromagnetPosition: Vector2;
Expand Down Expand Up @@ -73,9 +74,11 @@ export default class Transformer extends PhetioObject {
// 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}` );
if ( !isSettingPhetioStateProperty.value ) {
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}` );
}
} );
}

Expand Down

0 comments on commit f3773ce

Please sign in to comment.