diff --git a/js/spin/model/ParticleSystem.ts b/js/spin/model/ParticleSystem.ts index ec3cc9e..ae3490c 100644 --- a/js/spin/model/ParticleSystem.ts +++ b/js/spin/model/ParticleSystem.ts @@ -9,6 +9,7 @@ import dotRandom from '../../../../dot/js/dotRandom.js'; import Vector2 from '../../../../dot/js/Vector2.js'; +import Tandem from '../../../../tandem/js/Tandem.js'; import quantumMeasurement from '../../quantumMeasurement.js'; import { BlockingMode } from './BlockingMode.js'; import { ParticleWithSpin } from './ParticleWithSpin.js'; @@ -37,18 +38,23 @@ export class ParticleSystem { private fractionalEmissionAccumulator = 0; public constructor( - model: SpinModel + model: SpinModel, + tandem: Tandem ) { this.model = model; // Create all particles that will be used in the experiment. It works better for phet-io if these are created at // construction time and activated and deactivated as needed, rather than creating and destroying them. - this.singleParticles = _.times( MAX_NUMBER_OF_SINGLE_PARTICLES, () => { - return new ParticleWithSpin( Vector2.ZERO ); + const singleParticlesTandem = tandem.createTandem( 'singleParticles' ); + const multipleParticlesTandem = tandem.createTandem( 'multipleParticles' ); + this.singleParticles = _.times( MAX_NUMBER_OF_SINGLE_PARTICLES, index => { + const particleTandem = singleParticlesTandem.createTandem( 'particle' + index ); + return new ParticleWithSpin( Vector2.ZERO, particleTandem ); } ); - this.multipleParticles = _.times( MAX_NUMBER_OF_MULTIPLE_PARTICLES, () => { - return new ParticleWithSpin( new Vector2( PARTICLE_RAY_WIDTH * ( dotRandom.nextDouble() * 2 - 1 ), PARTICLE_RAY_WIDTH * ( dotRandom.nextDouble() * 2 - 1 ) ) ); + this.multipleParticles = _.times( MAX_NUMBER_OF_MULTIPLE_PARTICLES, index => { + const particleTandem = multipleParticlesTandem.createTandem( 'particle' + index ); + return new ParticleWithSpin( new Vector2( PARTICLE_RAY_WIDTH * ( dotRandom.nextDouble() * 2 - 1 ), PARTICLE_RAY_WIDTH * ( dotRandom.nextDouble() * 2 - 1 ) ), particleTandem ); } ); } diff --git a/js/spin/model/ParticleWithSpin.ts b/js/spin/model/ParticleWithSpin.ts index 745eee0..e00ab2a 100644 --- a/js/spin/model/ParticleWithSpin.ts +++ b/js/spin/model/ParticleWithSpin.ts @@ -10,6 +10,7 @@ import BooleanProperty from '../../../../axon/js/BooleanProperty.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import Vector2Property from '../../../../dot/js/Vector2Property.js'; +import Tandem from '../../../../tandem/js/Tandem.js'; import quantumMeasurement from '../../quantumMeasurement.js'; export class ParticleWithSpin { @@ -34,10 +35,16 @@ export class ParticleWithSpin { public velocityProperty: Vector2Property; public speed = 1; - public constructor( private readonly offset: Vector2 ) { - this.activeProperty = new BooleanProperty( false ); - this.positionProperty = new Vector2Property( Vector2.ZERO ); - this.velocityProperty = new Vector2Property( Vector2.ZERO ); + public constructor( private readonly offset: Vector2, tandem: Tandem ) { + this.activeProperty = new BooleanProperty( false, { + tandem: tandem.createTandem( 'activeProperty' ) + } ); + this.positionProperty = new Vector2Property( Vector2.ZERO, { + tandem: tandem.createTandem( 'positionProperty' ) + } ); + this.velocityProperty = new Vector2Property( Vector2.ZERO, { + tandem: tandem.createTandem( 'velocityProperty' ) + } ); this.startPosition = Vector2.ZERO; this.endPosition = new Vector2( 1, 0 ); diff --git a/js/spin/model/SpinModel.ts b/js/spin/model/SpinModel.ts index 11315a7..e24704f 100644 --- a/js/spin/model/SpinModel.ts +++ b/js/spin/model/SpinModel.ts @@ -89,7 +89,7 @@ export default class SpinModel implements TModel { this.particleSourceModel = new ParticleSourceModel( new Vector2( -0.5, 0 ), providedOptions.tandem.createTandem( 'particleSourceModel' ) ); - this.particleSystem = new ParticleSystem( this ); + this.particleSystem = new ParticleSystem( this, providedOptions.tandem ); this.derivedSpinStateProperty = new DerivedProperty( [