Skip to content

Commit

Permalink
reset measured data counts when the measurement parameters change, see
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 15, 2025
1 parent 1763d62 commit 33c5ab2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,42 @@ class BlochSphereModel implements TModel {
// measurement that is being made.
this.timeToMeasurementProperty.link( () => this.resetCounts() );

// Change the selected preset state direction to CUSTOM when the user manually changes the angles of the Bloch Sphere.
// Update the coefficients, clear accumulated counts, and potentially change the selected preset state direction to
// CUSTOM when the user changes the angles of the Bloch Sphere.
Multilink.multilink(
[
this.preparationBlochSphere.polarAngleProperty,
this.preparationBlochSphere.azimuthalAngleProperty
],
( polarAngle, azimuthalAngle ) => {

// Update the coefficients of the state equation.
this.upCoefficientProperty.value = Math.cos( polarAngle / 2 );
this.downCoefficientProperty.value = Math.sin( polarAngle / 2 );
this.phaseFactorProperty.value = azimuthalAngle / Math.PI;

// Clear the accumulated counts.
this.resetCounts();

if ( !selectingStateDirection ) {

// Change the selected state to indicate that the user has moved away from the preset states.
this.selectedStateDirectionProperty.value = StateDirection.CUSTOM;
}
}
);

// Set the precession rate of the Bloch sphere based on the magnetic field strength and the selected scene.
Multilink.multilink(
// Set the precession rate of the Bloch sphere based on the state of the magnetic field, the selected scene, and the
// measurement state.
Multilink.lazyMultilink(
[ this.magneticFieldStrengthProperty, this.magneticFieldEnabledProperty ],
( magneticFieldStrength, showMagneticField ) => {

// Changes to the field state should clear any accumulated counts.
this.resetCounts();

// Set the precession rate of the Bloch sphere based on the state of the magnetic field.

this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = showMagneticField ?
magneticFieldStrength :
0;
Expand Down

0 comments on commit 33c5ab2

Please sign in to comment.