Skip to content

Commit

Permalink
use magnet.intersectsHorizontalPlane in flux area model, recalibrate …
Browse files Browse the repository at this point in the history
…maxEMF, #166
  • Loading branch information
pixelzoom committed May 20, 2024
1 parent fade6bb commit 07620a8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
13 changes: 12 additions & 1 deletion js/common/model/Magnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export default abstract class Magnet extends FELMovable {
return this.localBounds.containsPoint( this.globalToLocalPosition( position, this.reusablePosition ) );
}

/**
* Does the magnet intersect a horizontal plane at the specific y-coordinate?
*/
public intersectsHorizontalPlane( y: number ): boolean {
return this.localBounds.containsPoint( this.globalToLocalXY( this.positionProperty.value.x, y, this.reusablePosition ) );
}

/**
* Gets the B-field vector at the specified point in the global coordinate frame.
*
Expand Down Expand Up @@ -182,8 +189,12 @@ export default abstract class Magnet extends FELMovable {
* because our B-field model is in the magnet's local coordinate frame.
*/
private globalToLocalPosition( globalPosition: Vector2, returnVector?: Vector2 ): Vector2 {
return this.globalToLocalXY( globalPosition.x, globalPosition.y, returnVector );
}

private globalToLocalXY( globalX: number, globalY: number, returnVector?: Vector2 ): Vector2 {
returnVector = returnVector || new Vector2( 0, 0 );
returnVector.set( globalPosition );
returnVector.setXY( globalX, globalY );
returnVector.rotateAboutPoint( this.positionProperty.value, -this.rotationProperty.value );
returnVector.subtract( this.positionProperty.value );
return returnVector;
Expand Down
14 changes: 5 additions & 9 deletions js/common/model/PickupCoil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ export default class PickupCoil extends FELMovable {
}

this.maxEMFProperty = new NumberProperty( options.maxEMF, {
//TODO https://github.com/phetsims/faradays-electromagnetic-lab/issues/156 This range makes Developer control unusable.
range: new Range( 1E5, 1E7 )
range: new Range( 1E5, 3E6 )
// Do not instrument. This is a PhET developer Property.
} );

Expand Down Expand Up @@ -347,10 +346,8 @@ export default class PickupCoil extends FELMovable {
*/
public getSamplePointAreaDimensions( samplePoint: Vector2, reusableDimension: Dimension2 ): Dimension2 {

// Position of samplePoint in global coordinates.
const x = this.positionProperty.value.x + samplePoint.x;
// Position of samplePoint.y in global coordinates.
const y = this.positionProperty.value.y + samplePoint.y;
this.reusablePosition.setXY( x, y );

// Use the algorithm for distance from the center of a circle to a chord to compute the length of the chord
// that is perpendicular to the vertical line and goes through the sample point. If you're unfamiliar with
Expand All @@ -359,11 +356,10 @@ export default class PickupCoil extends FELMovable {
const d = samplePoint.y; // distance from center of the circle (loop) to the chord
let chordLength = 2 * Math.sqrt( Math.abs( R * R - d * d ) );

// If the sample point is inside the magnet, using the chord length computed above would exaggerate the
// sample point's contribution to flux. So use the magnet's thickness (depth). The field outside the magnet
// is relatively weak, so ignore its contribution.
// If the sample point is in the same horizontal plane as the magnet, using the chord length computed above would
// exaggerate the sample point's contribution to flux. So use the magnet's thickness (depth).
const magnetThickness = this.magnet.size.depth;
if ( magnetThickness < chordLength && this.magnet.isInside( this.reusablePosition ) ) {
if ( magnetThickness < chordLength && this.magnet.intersectsHorizontalPlane( y ) ) {
chordLength = magnetThickness;
}
assert && assert( chordLength !== 0 );
Expand Down
2 changes: 1 addition & 1 deletion js/generator/model/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class Generator extends PhetioObject {
// Disable voltmeter kinematics for the generator. Immediate response is needed, due to the cyclic nature.
kinematicsEnabledProperty: new BooleanProperty( false )
},
maxEMF: 240000, // see PickupCoil.calibrateMaxEMF
maxEMF: 110000, // see PickupCoil.calibrateMaxEMF
transitionSmoothingScale: 1, // see PickupCoil.transitionSmoothingScaleProperty
samplePointsSpacing: this.turbine.barMagnet.size.height / 10, // similar to PickupCoilScreenModel
tandem: options.tandem.createTandem( 'pickupCoil' )
Expand Down
2 changes: 1 addition & 1 deletion js/pickup-coil/model/PickupCoilScreenModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class PickupCoilScreenModel extends FELScreenModel {

this.pickupCoil = new PickupCoil( barMagnet, preferences.currentFlowProperty, {
position: PICKUP_COIL_POSITION,
maxEMF: 8000000, // see PickupCoil.calibrateMaxEMF
maxEMF: 1000000, // see PickupCoil.calibrateMaxEMF
transitionSmoothingScale: 0.77, // see PickupCoil.transitionSmoothingScaleProperty

// To avoid inducing significant (incorrect) EMF when the magnet is moved vertically when inside the coil,
Expand Down
2 changes: 1 addition & 1 deletion js/transformer/model/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Transformer extends PhetioObject {

this.pickupCoil = new PickupCoil( this.electromagnet, currentFlowProperty, {
position: options.pickupCoilPosition,
maxEMF: 3000000, // see PickupCoil.calibrateMaxEMF
maxEMF: 1000000, // see PickupCoil.calibrateMaxEMF
transitionSmoothingScale: 0.56, // see PickupCoil.transitionSmoothingScaleProperty

// To avoid inducing significant (incorrect) EMF when the magnet is moved vertically when inside the coil,
Expand Down

2 comments on commit 07620a8

@pixelzoom
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pixelzoom
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#66

Please sign in to comment.