Skip to content

Commit

Permalink
changed the code that limits the max DT to use the recently added bui…
Browse files Browse the repository at this point in the history
…lt0in support from Screen.js, see phetsims/states-of-matter-basics#16
  • Loading branch information
jbphet committed Jan 29, 2018
1 parent 8638953 commit ad63f36
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion js/atomic-interactions/AtomicInteractionsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define( function( require ) {
var Screen = require( 'JOIST/Screen' );
var statesOfMatter = require( 'STATES_OF_MATTER/statesOfMatter' );
var StatesOfMatterColorProfile = require( 'STATES_OF_MATTER/common/view/StatesOfMatterColorProfile' );
var StatesOfMatterConstants = require( 'STATES_OF_MATTER/common/StatesOfMatterConstants' );

/**
* @param {boolean} enableHeterogeneousMolecules
Expand All @@ -27,7 +28,8 @@ define( function( require ) {
var options = {
name: screenTitle,
backgroundColorProperty: StatesOfMatterColorProfile.backgroundProperty,
homeScreenIcon: new AtomicInteractionsIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE )
homeScreenIcon: new AtomicInteractionsIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE ),
maxDT: StatesOfMatterConstants.MAX_DT
};

Screen.call( this,
Expand Down
2 changes: 2 additions & 0 deletions js/common/StatesOfMatterConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ define( function( require ) {

var StatesOfMatterConstants = {

MAX_DT: 0.320, // seconds, max time step (delta time), this is 20x the nominal step 0f 16ms

SCREEN_VIEW_OPTIONS: { layoutBounds: new Bounds2( 0, 0, 834, 504 ) },

TRIPLE_POINT_MONATOMIC_MODEL_TEMPERATURE: 0.26, // empirically determined
Expand Down
6 changes: 0 additions & 6 deletions js/common/model/MultipleParticleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,6 @@ define( function( require ) {
*/
step: function( dt ) {

// If the time step is excessively large, ignore it - it probably means that the user was on another tab or that
// the browser was hidden, and they just came back to the sim.
if ( dt > 0.5 ) {
return;
}

if ( this.isPlayingProperty.get() ) {
this.stepInternal( dt );
}
Expand Down
6 changes: 3 additions & 3 deletions js/common/model/engine/AbstractVerletAlgorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ define( function( require ) {
var moleculeVelocityY = moleculeVelocity.y; // optimization
var moleculeCenterOfMassPosition = moleculeCenterOfMassPositions[ i ];

// calculate new position based on time and velocity
// calculate new position based on time, velocity, and acceleration
var xPos = moleculeCenterOfMassPosition.x +
( timeStep * moleculeVelocityX ) +
( timeStepSqrHalf * moleculeForces[ i ].x * massInverse);
( timeStepSqrHalf * moleculeForces[ i ].x * massInverse );
var yPos = moleculeCenterOfMassPosition.y +
( timeStep * moleculeVelocityY ) +
( timeStepSqrHalf * moleculeForces[ i ].y * massInverse);
( timeStepSqrHalf * moleculeForces[ i ].y * massInverse );

if ( !moleculeDataSet.insideContainer[ i ] && this.isNormalizedPositionInContainer( xPos, yPos ) ) {

Expand Down
4 changes: 3 additions & 1 deletion js/phase-changes/PhaseChangesScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define( function( require ) {
var Screen = require( 'JOIST/Screen' );
var statesOfMatter = require( 'STATES_OF_MATTER/statesOfMatter' );
var StatesOfMatterColorProfile = require( 'STATES_OF_MATTER/common/view/StatesOfMatterColorProfile' );
var StatesOfMatterConstants = require( 'STATES_OF_MATTER/common/StatesOfMatterConstants' );

// strings
var phaseChangesString = require( 'string!STATES_OF_MATTER/phaseChanges' );
Expand All @@ -30,7 +31,8 @@ define( function( require ) {
var options = {
name: phaseChangesString,
backgroundColorProperty: StatesOfMatterColorProfile.backgroundProperty,
homeScreenIcon: new PhaseChangesIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE )
homeScreenIcon: new PhaseChangesIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE ),
maxDT: StatesOfMatterConstants.MAX_DT
};

Screen.call( this,
Expand Down
4 changes: 3 additions & 1 deletion js/states/StatesScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define( function( require ) {
var StatesIcon = require( 'STATES_OF_MATTER/states/StatesIcon' );
var statesOfMatter = require( 'STATES_OF_MATTER/statesOfMatter' );
var StatesOfMatterColorProfile = require( 'STATES_OF_MATTER/common/view/StatesOfMatterColorProfile' );
var StatesOfMatterConstants = require( 'STATES_OF_MATTER/common/StatesOfMatterConstants' );
var StatesScreenView = require( 'STATES_OF_MATTER/states/view/StatesScreenView' );

// strings
Expand All @@ -29,7 +30,8 @@ define( function( require ) {
var options = {
name: statesString,
backgroundColorProperty: StatesOfMatterColorProfile.backgroundProperty,
homeScreenIcon: new StatesIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE )
homeScreenIcon: new StatesIcon( Screen.MINIMUM_HOME_SCREEN_ICON_SIZE ),
maxDT: StatesOfMatterConstants.MAX_DT
};

Screen.call( this,
Expand Down

0 comments on commit ad63f36

Please sign in to comment.