Skip to content

Commit

Permalink
Rewrite calibration in terms of CALIBRATION_SCALE, see #315
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jan 15, 2019
1 parent a1802d2 commit c2e1ec8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions js/common/WaveInterferenceConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ define( require => {
const MAJOR_TICK_LENGTH = 12;
const LATTICE_PADDING = 20;

// the simulation was initially calibrated at a lattice size of 101-20x2. This scale factor maintains the same
// calibrated behavior for differing lattice sizes.
const CALIBRATION_SCALE = ( WaveInterferenceQueryParameters.latticeSize - LATTICE_PADDING * 2 ) / ( 101 - 20 * 2 );

const WaveInterferenceConstants = {
WAVE_AREA_WIDTH: 500,
MAJOR_TICK_LENGTH: MAJOR_TICK_LENGTH,
Expand Down Expand Up @@ -72,10 +76,7 @@ define( require => {
FEMTO: 1E-15,

// Cell that oscillates, specified as an offset from the origin of the lattice (includes damping region).
POINT_SOURCE_HORIZONTAL_COORDINATE:
Util.roundSymmetric(
3 / 61 * ( WaveInterferenceQueryParameters.latticeSize - LATTICE_PADDING * 2 ) + LATTICE_PADDING
) + 1,
POINT_SOURCE_HORIZONTAL_COORDINATE: Util.roundSymmetric( 3 * CALIBRATION_SCALE ) + LATTICE_PADDING,

// The lattice must have an odd dimension, so that there can be a cell exactly in the middle (for a single-cell
// oscillator), symmetry for the two oscillator screen, and so the 1-cell wide barrier can appear directly in the
Expand All @@ -95,10 +96,8 @@ define( require => {
// rest of the texts
TIME_AND_LENGTH_SCALE_INDICATOR_FONT: new PhetFont( DEFAULT_FONT_SIZE - 1 ),

// tuned so that the time for the wave to pass across the lattice is the same as pre-1.0. If the lattice size is
// changed, this can be re-tuned by computing the time it takes a sound wave to cross the new lattice size and
// dividing by the prior time.
SCALE_FACTOR: 54.176 / 20
// see above
CALIBRATION_SCALE: CALIBRATION_SCALE
};

assert && assert( WaveInterferenceConstants.LATTICE_DIMENSION % 2 === 1, 'lattice dimension must be odd' );
Expand Down
4 changes: 2 additions & 2 deletions js/common/model/SoundScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ define( require => {
const fy = gradientY * k;
if ( !isNaN( fx ) && !isNaN( fy ) ) {
soundParticle.applyForce(
fx * WaveInterferenceConstants.SCALE_FACTOR,
fy * WaveInterferenceConstants.SCALE_FACTOR,
fx * WaveInterferenceConstants.CALIBRATION_SCALE,
fy * WaveInterferenceConstants.CALIBRATION_SCALE,
dt, this
);
}
Expand Down
2 changes: 1 addition & 1 deletion js/waves/model/WavesModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ define( require => {
// This simulation uses EventTimer, which provides exactly the same model behavior on very slow and very fast
// platforms. Here we define the frequency of events in Hz, which has been tuned so that iPad2 has enough time to run
// model computations.
const EVENT_RATE = 20 * WaveInterferenceConstants.SCALE_FACTOR;
const EVENT_RATE = 20 * WaveInterferenceConstants.CALIBRATION_SCALE;
const toFemto = WaveInterferenceUtils.toFemto;

class WavesModel {
Expand Down

0 comments on commit c2e1ec8

Please sign in to comment.