diff --git a/js/bloch-sphere/model/BlochSphereModel.ts b/js/bloch-sphere/model/BlochSphereModel.ts index 681a361..256070c 100644 --- a/js/bloch-sphere/model/BlochSphereModel.ts +++ b/js/bloch-sphere/model/BlochSphereModel.ts @@ -5,6 +5,7 @@ * measurements, equations and rotation under magnetic field. * * @author Agustín Vallejo (PhET Interactive Simulations) + * @author John Blanco (PhET Interactive Simulations) */ import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; @@ -31,7 +32,7 @@ type QuantumMeasurementModelOptions = SelfOptions & PickRequired { - blochSphere.measure( this.measurementBasisProperty.value, this.upMeasurementCountProperty, this.downMeasurementCountProperty ); - } ); - } + assert && assert( + this.measurementStateProperty.value === 'prepared' || this.measurementStateProperty.value === 'timingObservation', + 'The model is not in state where a new observation can be made.' + ); - // Update the measurement state. - this.measurementStateProperty.value = 'observed'; + if ( this.isSingleMeasurementModeProperty.value ) { + this.singleMeasurementBlochSphere.measure( + this.measurementBasisProperty.value, + this.upMeasurementCountProperty, + this.downMeasurementCountProperty + ); } + else { + this.multiMeasurementBlochSpheres.forEach( blochSphere => { + blochSphere.measure( + this.measurementBasisProperty.value, + this.upMeasurementCountProperty, + this.downMeasurementCountProperty + ); + } ); + } + + // Update the measurement state. + this.measurementStateProperty.value = 'observed'; } /** @@ -245,7 +257,10 @@ export default class BlochSphereModel implements TModel { */ public initiateObservation(): void { - this.reprepare(); + assert && assert( + this.measurementStateProperty.value === 'prepared', + 'The model should be prepared for measurement prior to calling this method.' + ); if ( this.showMagneticFieldProperty.value ) { @@ -264,7 +279,6 @@ export default class BlochSphereModel implements TModel { * Reprepare the model for a new observation. */ public reprepare(): void { - this.measurementStateProperty.value = 'prepared'; // Copy the settings from the preparation bloch sphere this.singleMeasurementBlochSphere.setDirection( @@ -278,6 +292,9 @@ export default class BlochSphereModel implements TModel { this.preparationBlochSphere.azimuthalAngleProperty.value ); } ); + + this.measurementTimeProperty.value = 0; + this.measurementStateProperty.value = 'prepared'; } /** @@ -299,6 +316,7 @@ export default class BlochSphereModel implements TModel { this.magneticFieldStrengthProperty.reset(); this.measurementBasisProperty.reset(); this.isSingleMeasurementModeProperty.reset(); + this.timeToMeasurementProperty.reset(); this.measurementTimeProperty.reset(); } @@ -315,11 +333,14 @@ export default class BlochSphereModel implements TModel { if ( this.measurementStateProperty.value === 'timingObservation' ) { this.measurementTimeProperty.value = this.measurementTimeProperty.value + dt; if ( this.measurementTimeProperty.value > this.timeToMeasurementProperty.value ) { - this.reprepare(); + + // The time when the observation should be made has been reached. Make the observation. this.observe(); } } } } -quantumMeasurement.register( 'BlochSphereModel', BlochSphereModel ); \ No newline at end of file +quantumMeasurement.register( 'BlochSphereModel', BlochSphereModel ); + +export default BlochSphereModel; \ No newline at end of file diff --git a/js/bloch-sphere/view/MeasurementTimerControl.ts b/js/bloch-sphere/view/MeasurementTimerControl.ts index 4384dc6..c7efb76 100644 --- a/js/bloch-sphere/view/MeasurementTimerControl.ts +++ b/js/bloch-sphere/view/MeasurementTimerControl.ts @@ -84,6 +84,8 @@ export default class MeasurementTimerControl extends Node { lineWidth: 2 } ); + // TODO: Can the measurement symbol be a common code item? See https://github.com/phetsims/quantum-measurement/issues/54. + const measurementSymbol = new Node( { scale: 0.8, children: [