Skip to content

Commit

Permalink
resolve merge conflicts, #259
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
  • Loading branch information
pixelzoom committed Dec 18, 2018
2 parents c8fb3fd + 28cf8e7 commit b698e4e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
28 changes: 18 additions & 10 deletions doc/implementation-notes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Wave Interference - implementation notes

This document contains notes related to the implementation of Wave Interference. The audience for this document is software developers who are familiar with JavaScript and PhET simulation development, as described in [PhET Development Overview](http://bit.ly/phet-html5-development-overview).
This document contains notes related to the implementation of Wave Interference. The audience for this document is
software developers who are familiar with JavaScript and PhET simulation development, as described in
[PhET Development Overview](http://bit.ly/phet-html5-development-overview).

Before reading this document, see [model.md](https://github.com/phetsims/wave-interference/blob/master/doc/model.md), which provides a high-level description of the simulation model.
Before reading this document, see [model.md](https://github.com/phetsims/wave-interference/blob/master/doc/model.md),
which provides a high-level description of the simulation model.

## Overview

Expand All @@ -11,7 +14,8 @@ The first 3 screens show a 2D lattice and time-based wave propagation, while the
pattern from a slit with a given 2d shape, which is instantly updated.

The query string `?log` can be used to output the selected frequency and wavelenth, for debugging.
Other sim-specific query parameters are described in [WaveInterferenceQueryParameters](https://github.com/phetsims/wave-interference/blob/master/js/common/WaveInterferenceQueryParameters.js).
Other sim-specific query parameters are described in
[WaveInterferenceQueryParameters](https://github.com/phetsims/wave-interference/blob/master/js/common/WaveInterferenceQueryParameters.js).

There are no dynamically created/destroyed user interface components or model elements in the simulation, so the
simulation doesn't require dispose calls.
Expand All @@ -20,10 +24,14 @@ simulation doesn't require dispose calls.

The first three screens are mainly implemented in js/common.

`WavesScreenModel` is the main model for these screens. Each `WavesScreenModel` contains 3 `Scene` instances, one for
[WavesScreenModel](https://github.com/phetsims/wave-interference/blob/master/js/waves/model/WavesScreenModel.js) is the
main model for these screens.
Each [WavesScreenModel](https://github.com/phetsims/wave-interference/blob/master/js/waves/model/WavesScreenModel.js)
contains 3 [Scene](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Scene.js) instances, one for
each of water, sound and light. Most settings (such as whether the waves are turned on or off) are independent for each
`Scene`, and each `Scene` has its own physical model and `Lattice`. The tools which appear in the toolbox are shared
across Scenes.
[Scene](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Scene.js), and each [Scene](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Scene.js) has its own physical model and [Lattice.js](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Lattice.js).
The tools which appear in the toolbox are shared
across each [Scene](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Scene.js).

There are 3 coordinate frames:
* view coordinates
Expand All @@ -36,7 +44,7 @@ described in http://www.mtnmath.com/whatth/node47.html and known as a finite dif
```
f(x,y,t+1) = c*c(f(x+1,y,t) + f(x-1,y,t) + f(x,y-1,t) + f(x,y+1,t) - 4*f(x,y,t)) - f(x,y,t-1) + 2*f(x,y,t)
```
The description for the wave speed `c` is given in Lattice.js.
The description for the wave speed `c` is given in [Lattice.js](https://github.com/phetsims/wave-interference/blob/master/js/common/model/Lattice.js)

The lattice extends beyond the visible region, and damping is applied near the boundaries to minimize the effects of
reflection and artifacts around the edges.
Expand All @@ -46,7 +54,7 @@ wave speed) for each scene. Run the simulation with `?dev` to get corresponding
and sim play/pause feature to record one cycle. To measure the wave speed, let the light propagate to the edge of the
boundary, then use the measuring tape to measure distance and divide by the elapsed time on the stopwatch.

The time constants have been tuned in `WavesScreenModel` so that the observed Wavelength and Oscillation Time are
The time constants have been tuned in [WavesScreenModel](https://github.com/phetsims/wave-interference/blob/master/js/waves/model/WavesScreenModel.js) so that the observed wavelength and oscillation time are
correct.

The following values can also be reported by running with`?log`.
Expand All @@ -73,13 +81,13 @@ is a reasonable wave speed for a wave pool, even though it doesn't match wave sp
| Violet (VisibleColor max) | 788.93 | 380.00 |

For green light, measuring the distance traveled by a wavefront and dividing by time gives 2807.3E-9/9.75E-15 = 287928205 m/s, which is about 4% off of the true speed of light. Measuring the colored wavefront for green, I see a deviation of < 1%. Since the distance and wave propagation speeds are independent of frequency, measurements for different colors will
give the same speed of light. See also `WavesScreenModel` usage of `timeScaleFactor` for how the model is calibrated.
give the same speed of light. See also [WavesScreenModel](https://github.com/phetsims/wave-interference/blob/master/js/waves/model/WavesScreenModel.js) usage of `timeScaleFactor` for how the model is calibrated.

### Slits Screen
Here is a schematic for the two-slit dimensions:
![schematic for the two-slit dimensions](images/slitDimensions.jpg?raw=true "Two-Slit Dimensions")

By using `?dev`, you can show the IdealInterferenceOverlay, which depicts `d sin(θ) = mλ` (theoretical maxima) and `d sin(θ) = (m+1/2)λ` (theoretical minima). See https://github.com/phetsims/wave-interference/issues/74
By using `?dev`, you can show the [TheoryInterferenceOverlay](https://github.com/phetsims/wave-interference/blob/master/js/slits/view/TheoryInterferenceOverlay.js), which depicts `d sin(θ) = mλ` (theoretical maxima) and `d sin(θ) = (m+1/2)λ` (theoretical minima). See https://github.com/phetsims/wave-interference/issues/74

## The Final Screen: Diffraction
In the fourth screen, we use a Fast Fourier Transform (FFT) in order to compute the diffraction pattern, see
Expand Down
2 changes: 1 addition & 1 deletion images/license.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
"projectURL": "http://phet.colorado.edu",
"license": "contact phethelp@colorado.edu",
"notes": "Copied and cropped from States of Matter on Aug 3, 2018. Originally created by Mariah, see water_drop.ai"
"notes": "Copied and cropped from States of Matter on Aug 3, 2018. Originally created by Mariah Hermsmeyer, see water_drop.ai"
},
"waves_screen_icon.png": {
"text": [
Expand Down
8 changes: 4 additions & 4 deletions js/common/model/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ define( require => {

const centerFrequency = ( config.minimumFrequency + config.maximumFrequency ) / 2;

// @public {Property.<number>} - the frequency in the appropriate units for the scene
// @public the frequency in the appropriate units for the scene
this.frequencyProperty = new NumberProperty( centerFrequency, {
range: new Range( config.minimumFrequency, config.maximumFrequency )
} );
Expand All @@ -122,7 +122,7 @@ define( require => {
} );

//REVIEW add value validation?
// @public {Property.<Number>} - distance between the sources in the units of the scene, or 0 if there is only one
// @public distance between the sources in the units of the scene, or 0 if there is only one
// source initialized to match the initial slit separation,
// see https://github.com/phetsims/wave-interference/issues/87
this.sourceSeparationProperty = new NumberProperty(
Expand All @@ -143,7 +143,7 @@ define( require => {
// start slightly left of 50.5 so it will round to 50 instead of 51
this.barrierLocationProperty = new Property( new Vector2( this.lattice.width / 2 - 1E-6, 0 ) );

// @public {Property.<number>} - the floor of the continuous barrier location (x coordinate only)
// @public {DerivedProperty.<number>} - the floor of the continuous barrier location (x coordinate only)
this.barrierLatticeCoordinateProperty = new DerivedProperty(
[ this.barrierLocationProperty ],
barrierLocation => Math.round( barrierLocation.x )
Expand All @@ -154,7 +154,7 @@ define( require => {
units: this.positionUnits
} );

// @public {Property.<Number>} - distance between the center of the slits, in the units for this scene
// @public distance between the center of the slits, in the units for this scene
this.slitSeparationProperty = new NumberProperty( config.initialSlitSeparation, {
units: this.positionUnits
} );
Expand Down
3 changes: 1 addition & 2 deletions js/common/model/SoundScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ define( require => {
// on the Slits screen, see https://github.com/phetsims/wave-interference/issues/109
this.showSoundParticles = showSoundParticles;

//REVIEW {Property.<SoundViewType>}?
// @public {Property.<string>} - indicates the selected view for sound
// @public {Property.<SoundViewType>} - indicates the selected view for sound
this.viewSelectionProperty = new Property( SoundViewType.WAVES, {
validValues: SoundViewType.VALUES
} );
Expand Down
9 changes: 4 additions & 5 deletions js/diffraction/model/DiffractionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,22 @@ define( require => {
this.onProperty = new BooleanProperty( true );

//REVIEW add value validation. These presumably have ranges and must be > 0.
// @public {Property.<number>} dimensions of the square aperture
// @public dimensions of the square aperture
this.squareWidthProperty = new NumberProperty( 16 );
this.squareHeightProperty = new NumberProperty( 16 );

//REVIEW add value validation
// @public {Property.<number>} dimensions of the elliptical aperture
// @public dimensions of the elliptical aperture
this.sigmaXProperty = new NumberProperty( 10 );
this.sigmaYProperty = new NumberProperty( 10 );
this.gaussianMagnitudeProperty = new NumberProperty( 400 );

//REVIEW add value validation
// @public {Property.<number>} characteristics of the grating
// @public characteristics of the grating
this.numberOfLinesProperty = new NumberProperty( 10 );
this.angleProperty = new NumberProperty( 0 );

//REVIEW {Property.<ApertureType>}
// @public {Property.<string>} selected scene
// @public {Property.<ApertureType>} selected scene
this.sceneProperty = new Property( ApertureType.CIRCLE );
}

Expand Down
13 changes: 7 additions & 6 deletions js/waves/model/WavesScreenModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ define( require => {
'Model only supports 1 or 2 sources'
);

// @public {Property.<ViewType>}
this.viewTypeProperty = new Property( ViewType.TOP, {
validValues: ViewType.VALUES
} );

// Instantiate the Scenes. Parameters are declared here to make it easier to compare options
// and see them in the same file.

Expand Down Expand Up @@ -194,6 +189,11 @@ define( require => {
// @public (read-only) {Scene[]} - the Scene instances as an array
this.scenes = [ this.waterScene, this.soundScene, this.lightScene ];

// @public {Property.<ViewType>} - indicates the user selection for side view or top view
this.viewTypeProperty = new Property( ViewType.TOP, {
validValues: ViewType.VALUES
} );

// @public {Property.<PlaySpeedEnum>} - the speed at which the simulation is playing
this.playSpeedProperty = new Property( PlaySpeedEnum.NORMAL, {
validValues: PlaySpeedEnum.VALUES
Expand Down Expand Up @@ -251,8 +251,9 @@ define( require => {
// @public
this.isWaveMeterInPlayAreaProperty = new BooleanProperty( false );

// @public {Property.<number>} - amount the 3d view is rotated. 0 means top view, 1 means side view.
const rotationRange = new Range( 0, 1 );

// @public - amount the 3d view is rotated. 0 means top view, 1 means side view.
this.rotationAmountProperty = new NumberProperty( 0, {
range: rotationRange
} );
Expand Down

0 comments on commit b698e4e

Please sign in to comment.