Skip to content

Commit

Permalink
add initial beam splitter, flesh out Photons model a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Oct 9, 2024
1 parent a12f441 commit 662ff96
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 6 deletions.
2 changes: 0 additions & 2 deletions js/photons/model/PhotonDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import quantumMeasurement from '../../quantumMeasurement.js';

type SelfOptions = EmptySelfOptions;
type PhotonDetectorOptions = SelfOptions & PickRequired<PhetioObjectOptions, 'tandem'>;

// constants
export type DetectionDirection = ( [ 'up', 'down' ] )[number];

export default class PhotonDetector {
Expand Down
19 changes: 15 additions & 4 deletions js/photons/model/PhotonsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@
* PhotonsModel is the primary model class for the Photons screen. It manages the general model state and behavior for
* the photons that travel from the source to the detectors.
*
* Part of what this model does is position photons in two-dimensional space. This space is set up to center on the
* Part of what this model does is move photons in two-dimensional space. This space is set up to center on the
* polarizing beam splitter, which is at the center of the screen. The x-axis is horizontal and the y-axis is vertical.
* Units are in meters.
* Units are in meters. The photons are emitted from a source, travel to the polarizing beam splitter, and then are
* either reflected or transmitted. The photons are then detected by two photon detectors.
*
* @author John Blanco, PhET Interactive Simulations
*/

import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Range from '../../../../dot/js/Range.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import TModel from '../../../../joist/js/TModel.js';
import { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import PhotonDetector from './PhotonDetector.js';
import PolarizingBeamSplitter from './PolarizingBeamSplitter.js';

type SelfOptions = EmptySelfOptions;
type QuantumMeasurementModelOptions = SelfOptions & PickRequired<PhetioObjectOptions, 'tandem'>;

export default class PhotonsModel implements TModel {

// The angle of polarization for the polarizing beam splitter.
// The polarizing beam splitter that the photons will encounter.
public readonly polarizingBeamSplitter: PolarizingBeamSplitter;

// The angle of polarization for the polarizing beam splitter, in degrees. Zero is horizontal and 90 is vertical.
public readonly photonPolarizationAngleProperty: NumberProperty;

// photon detectors
Expand All @@ -34,7 +40,12 @@ export default class PhotonsModel implements TModel {

public constructor( providedOptions: QuantumMeasurementModelOptions ) {

this.photonPolarizationAngleProperty = new NumberProperty( 0, {
this.polarizingBeamSplitter = new PolarizingBeamSplitter( new Vector2( 0, 0 ), {
tandem: providedOptions.tandem.createTandem( 'polarizingBeamSplitter' )
} );

this.photonPolarizationAngleProperty = new NumberProperty( 45, {
range: new Range( 0, 90 ),
tandem: providedOptions.tandem.createTandem( 'photonPolarizationAngleProperty' )
} );

Expand Down
61 changes: 61 additions & 0 deletions js/photons/model/PolarizingBeamSplitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2024, University of Colorado Boulder

/**
* PolarizingBeamSplitter is a model element that represents a device that splits a beam of photons into two beams based
* on the polarization of the photons.
*
* @author John Blanco, PhET Interactive Simulations
*/

import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import { Line } from '../../../../kite/js/imports.js';
import { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import quantumMeasurement from '../../quantumMeasurement.js';

type SelfOptions = EmptySelfOptions;
type PolarizingBeamSplitterOptions = SelfOptions & PickRequired<PhetioObjectOptions, 'tandem'>;

export type PresetPolarizationDirections = ( [ 'vertical', 'horizontal', 'fortyFiveDegrees', 'custom' ] )[number];

// constants
const WIDTH = 0.1; // the width, in meters, of the beam splitter
const ROTATIONAL_ANGLE = Math.PI / 4; // the angle at which the beam splitter is rotated, in radians, zero is horizontal

export default class PolarizingBeamSplitter {

// The position of the center of the beam splitter in two-dimensional space. Units are in meters.
public readonly centerPosition: Vector2;

// A line in model space that represents the position of the beam splitter.
public readonly positionalLine: Line;

// The direction of polarization that the beam splitter is set to. This can be one of the preset directions or a
// custom angle.
public readonly presetPolarizationDirectionProperty: Property<PresetPolarizationDirections>;

// The custom angle at which the beam splitter is set, in degrees. This is only used when the preset direction is
// "custom".
public readonly customPolarizationAngleProperty: NumberProperty;

public constructor( centerPosition: Vector2, providedOptions: PolarizingBeamSplitterOptions ) {
this.centerPosition = centerPosition;

// Initialize the line that represents the position of the beam splitter in the model.
const endpoint1 = centerPosition.plusXY( WIDTH / 2, 0 ).rotated( ROTATIONAL_ANGLE );
const endpoint2 = centerPosition.plusXY( -WIDTH / 2, 0 ).rotated( ROTATIONAL_ANGLE );
this.positionalLine = new Line( endpoint1, endpoint2 );

this.presetPolarizationDirectionProperty = new Property<PresetPolarizationDirections>( 'fortyFiveDegrees', {
tandem: providedOptions.tandem.createTandem( 'presetPolarizationDirectionProperty' )
} );
this.customPolarizationAngleProperty = new NumberProperty( 45, {
tandem: providedOptions.tandem.createTandem( 'customPolarizationAngleProperty' )
} );
}
}

quantumMeasurement.register( 'PolarizingBeamSplitter', PolarizingBeamSplitter );

0 comments on commit 662ff96

Please sign in to comment.