diff --git a/doc/implementation-notes.md b/doc/implementation-notes.md index 65c79722..41f0ba68 100644 --- a/doc/implementation-notes.md +++ b/doc/implementation-notes.md @@ -2,6 +2,6 @@ Friction is a one-screen simulation that depicts a draggable Chemistry book on t part of the play area is the MagnifierNode, which shows the zoomed in part of the simulation. Canvas is used to render the atoms in attempt to improve performance. The main property modeled by the simulation and depicted in the thermometer is FrictionModel.vibrationAmplitudeProperty, which indicates how much the atoms are oscillating. If an atom meets the threshold, -it evaporates. +it shears off. Model and screen coordinates are the same in this sim, so no model-view transform is needed. \ No newline at end of file diff --git a/doc/model.md b/doc/model.md index cf279213..b1a62a44 100644 --- a/doc/model.md +++ b/doc/model.md @@ -1,3 +1,3 @@ The Friction model is qualitative. The main property modeled by the simulation and depicted in the thermometer is the -amplitude of oscillation of the atoms. If an atom meets the threshold, it evaporates. As each atom evaporates, a bit +amplitude of oscillation of the atoms. If an atom meets the threshold, it shears off. As each atom shears off, a bit of cooling occurs. \ No newline at end of file diff --git a/js/friction/model/Atom.js b/js/friction/model/Atom.js index ff7818f5..e20eb18e 100644 --- a/js/friction/model/Atom.js +++ b/js/friction/model/Atom.js @@ -20,7 +20,7 @@ import IOType from '../../../../tandem/js/types/IOType.js'; import friction from '../../friction.js'; // constants -const EVAPORATED_SPEED = 400; // speed that particles travel during evaporation, in model units per second +const SHEAR_OFF_SPEED = 400; // speed that particles travel during shearing, in model units per second let uniqueID = 0; @@ -57,8 +57,8 @@ class Atom extends PhetioObject { // @public (read-only) {boolean} - flag that indicates whether this atom is part of the top book this.isTopAtom = isTopAtom; - // @private - marked as true when the atom is evaporated - this.isEvaporated = false; + // @private - marked as true when the atom is sheared off + this.isShearedOff = false; // @public - the position of the atom this.positionProperty = new Vector2Property( initialPosition, { @@ -70,14 +70,14 @@ class Atom extends PhetioObject { // @private {Vector2} - the center position, around which oscillations occur this.centerPosition = new Vector2( initialPosition.x, initialPosition.y ); - // @private {Vector2} - velocity vector for evaporation - this.evaporationVelocity = new Vector2( 0, 0 ); + // @private {Vector2} - velocity vector for shearing + this.shearingVelocity = new Vector2( 0, 0 ); if ( this.isTopAtom ) { // move the atom's center position as the top book moves model.topBookPositionProperty.lazyLink( ( newPosition, oldPosition ) => { - if ( !this.isEvaporated && !phet.joist.sim.isSettingPhetioStateProperty.value ) { + if ( !this.isShearedOff && !phet.joist.sim.isSettingPhetioStateProperty.value ) { const deltaX = newPosition.x - oldPosition.x; const deltaY = newPosition.y - oldPosition.y; this.centerPosition.setXY( this.centerPosition.x + deltaX, this.centerPosition.y + deltaY ); @@ -95,29 +95,29 @@ class Atom extends PhetioObject { return { initialPosition: Vector2.Vector2IO, isTopAtom: BooleanIO, - isEvaporated: BooleanIO, + isShearedOff: BooleanIO, centerPosition: Vector2.Vector2IO, - evaporationVelocity: Vector2.Vector2IO + shearingVelocity: Vector2.Vector2IO }; } /** * when the oscillation has exceeded the threshold, the atom breaks off, animates to one side of the screen, and - * disappears + * disappears. * @public */ - evaporate() { - assert && assert( !this.isEvaporated, 'Atom was already evaporated' ); + shearOff() { + assert && assert( !this.isShearedOff, 'Atom already sheared off' ); - this.isEvaporated = true; - const evaporationDestinationX = this.model.width * ( dotRandom.nextBoolean() ? 1 : -1 ); - const evaporationDestinationY = this.positionProperty.get().y - + this.isShearedOff = true; + const shearingDestinationX = this.model.width * ( dotRandom.nextBoolean() ? 1 : -1 ); + const shearingDestinationY = this.positionProperty.get().y - this.model.distanceBetweenBooksProperty.get() * dotRandom.nextDouble(); - this.evaporationVelocity.setXY( - evaporationDestinationX - this.positionProperty.get().x, - evaporationDestinationY - this.positionProperty.get().y - ).setMagnitude( EVAPORATED_SPEED ); + this.shearingVelocity.setXY( + shearingDestinationX - this.positionProperty.get().x, + shearingDestinationY - this.positionProperty.get().y + ).setMagnitude( SHEAR_OFF_SPEED ); } /** @@ -126,7 +126,7 @@ class Atom extends PhetioObject { */ reset() { this.centerPosition.set( this.initialPosition ); - this.isEvaporated = false; + this.isShearedOff = false; } /** @@ -143,11 +143,11 @@ class Atom extends PhetioObject { ); this.positionProperty.set( newPosition ); - // if evaporated, move away (but don't bother continuing once the atom is out of view) - if ( this.isEvaporated && Math.abs( this.centerPosition.x ) < 4 * this.model.width ) { + // if sheared off, move away (but don't bother continuing once the atom is out of view) + if ( this.isShearedOff && Math.abs( this.centerPosition.x ) < 4 * this.model.width ) { this.centerPosition.setXY( - this.centerPosition.x + this.evaporationVelocity.x * dt, - this.centerPosition.y + this.evaporationVelocity.y * dt + this.centerPosition.x + this.shearingVelocity.x * dt, + this.centerPosition.y + this.shearingVelocity.y * dt ); } } diff --git a/js/friction/model/FrictionModel.js b/js/friction/model/FrictionModel.js index eddaf181..f5130c21 100644 --- a/js/friction/model/FrictionModel.js +++ b/js/friction/model/FrictionModel.js @@ -30,23 +30,23 @@ const ATOM_RADIUS = FrictionConstants.ATOM_RADIUS; // radius of single atom const ATOM_SPACING_Y = 20; // y-distance between neighbors (atoms) const INITIAL_ATOM_SPACING_Y = 25; // initial distance between top and bottom atoms const VIBRATION_AMPLITUDE_MIN = 1; // min amplitude for an atom -const AMPLITUDE_EVAPORATE = 7; // evaporation amplitude for an atom +const AMPLITUDE_SHEAR_OFF = 7; // amplitude for an atom to shear off const VIBRATION_AMPLITUDE_MAX = 12; // atom's max amplitude const TOP_BOOK_ATOMS_COLOR = FrictionConstants.TOP_BOOK_ATOMS_COLOR; // color of top book const BOTTOM_BOOK_ATOMS_COLOR = FrictionConstants.BOTTOM_BOOK_ATOMS_COLOR; // color of bottom const COOLING_RATE = 0.2; // proportion per second; adjust in order to change the cooling rate const HEATING_MULTIPLIER = 0.0075; // multiplied by distance moved while in contact to control heating rate -const EVAPORATION_AMPLITUDE_REDUCTION = 0.01; // decrease in amplitude (a.k.a. temperature) when an atom evaporates +const SHEAR_OFF_AMPLITUDE_REDUCTION = 0.01; // decrease in amplitude (a.k.a. temperature) when an atom shears off const MAX_X_DISPLACEMENT = 600; // max allowed distance from center x const MIN_Y_POSITION = -70; // empirically determined such that top book can't be completely dragged out of frame const DEFAULT_ROW_START_X_POSITION = 50; -// atoms of top book, contains 5 rows, 4 of which can evaporate and 1 that can't +// atoms of top book, contains 5 rows, 4 of which can shear off and 1 that can't const TOP_BOOK_ATOM_STRUCTURE = [ /* * First row: - * contains 30 atoms that can not evaporate. + * contains 30 atoms that can not shear off. */ [ { num: 30 } @@ -54,53 +54,53 @@ const TOP_BOOK_ATOM_STRUCTURE = [ /* * Second row: - * contains 29 atoms that can evaporate. + * contains 29 atoms that can shear off. * Have additional offset 0.5 of x-distance between atoms (to make the lattice of atoms). */ [ - { offset: 0.5, num: 29, canEvaporate: true } + { offset: 0.5, num: 29, canShearOff: true } ], /* * Third row: - * contains 29 atoms that can evaporate. + * contains 29 atoms that can shear off. */ [ - { num: 29, canEvaporate: true } + { num: 29, canShearOff: true } ], /* * Fourth row: - * contains 24 atoms, separated into 5 groups that can evaporate. + * contains 24 atoms, separated into 5 groups that can shear off. * Have additional offset 0.5 of x-distance between atoms (to make the lattice of atoms). */ [ - { offset: 0.5, num: 5, canEvaporate: true }, - { offset: 6.5, num: 8, canEvaporate: true }, - { offset: 15.5, num: 5, canEvaporate: true }, - { offset: 21.5, num: 5, canEvaporate: true }, - { offset: 27.5, num: 1, canEvaporate: true } + { offset: 0.5, num: 5, canShearOff: true }, + { offset: 6.5, num: 8, canShearOff: true }, + { offset: 15.5, num: 5, canShearOff: true }, + { offset: 21.5, num: 5, canShearOff: true }, + { offset: 27.5, num: 1, canShearOff: true } ], /* * Fifth row: - * contains 9 atoms, separated into 5 groups that can evaporate. + * contains 9 atoms, separated into 5 groups that can shear off. */ [ - { offset: 3, num: 2, canEvaporate: true }, - { offset: 8, num: 1, canEvaporate: true }, - { offset: 12, num: 2, canEvaporate: true }, - { offset: 17, num: 2, canEvaporate: true }, - { offset: 24, num: 2, canEvaporate: true } + { offset: 3, num: 2, canShearOff: true }, + { offset: 8, num: 1, canShearOff: true }, + { offset: 12, num: 2, canShearOff: true }, + { offset: 17, num: 2, canShearOff: true }, + { offset: 24, num: 2, canShearOff: true } ] ]; -// atoms of bottom book (contains 3 rows that can not evaporate) +// atoms of bottom book (contains 3 rows that can not shear off) const BOTTOM_BOOK_ATOM_STRUCTURE = [ /* * First row: - * contains 29 atoms that can not evaporate. + * contains 29 atoms that can not shear off. */ [ { num: 29 } @@ -108,7 +108,7 @@ const BOTTOM_BOOK_ATOM_STRUCTURE = [ /* * Second row: - * contains 28 atoms that can not evaporate. + * contains 28 atoms that can not shear off. * Have additional offset 0.5 of x-distance between atoms (to make the lattice of atoms). */ [ @@ -117,7 +117,7 @@ const BOTTOM_BOOK_ATOM_STRUCTURE = [ /* * Third row: - * contains 29 atoms that can not evaporate. + * contains 29 atoms that can not shear off. */ [ { num: 29 } @@ -126,18 +126,18 @@ const BOTTOM_BOOK_ATOM_STRUCTURE = [ // pdom -// iterate through the constant to determine the number of atoms that can evaporate from the top book structure +// iterate through the constant to determine the number of atoms that can shear off from the top book structure let atoms = 0; TOP_BOOK_ATOM_STRUCTURE.forEach( row => { row.forEach( schema => { - if ( schema.canEvaporate ) { + if ( schema.canShearOff ) { atoms += schema.num; } } ); } ); -// the number of evaporable atoms in the top book -const NUMBER_OF_EVAPORABLE_ATOMS = atoms; +// the number of shearable atoms in the top book +const NUMBER_OF_SHEARABLE_ATOMS = atoms; // information about the nature of the atoms that will be shown in the magnifier window const MAGNIFIED_ATOMS_INFO = { @@ -146,7 +146,7 @@ const MAGNIFIED_ATOMS_INFO = { distanceY: FrictionConstants.INITIAL_ATOM_SPACING_Y, distance: INITIAL_ATOM_SPACING_Y, vibrationAmplitude: new Range( VIBRATION_AMPLITUDE_MIN, VIBRATION_AMPLITUDE_MAX ), - evaporationLimit: AMPLITUDE_EVAPORATE, + shearingLimit: AMPLITUDE_SHEAR_OFF, top: { color: TOP_BOOK_ATOMS_COLOR, layerDescriptions: TOP_BOOK_ATOM_STRUCTURE @@ -177,19 +177,19 @@ class FrictionModel extends PhetioObject { // @public (read-only) {Number} - the height for the model in model coordinates this.height = height; - // @private {Number} - track how much to evaporate in step() to prevent a Property loop - this.scheduledEvaporationAmount = 0; + // @private {Number} - track how much to shear off in step() to prevent a Property loop + this.scheduledShearingAmount = 0; - // @public (phet-io) - Instrumented so that PhET-iO clients can get a message when an atom evaporates - this.evaporationEmitter = new Emitter( { - tandem: tandem.createTandem( 'evaporationEmitter' ), - phetioDocumentation: 'Emits when atoms evaporate from the top book', + // @public (phet-io) - Instrumented so that PhET-iO clients can get a message when an atom shears off + this.shearingEmitter = new Emitter( { + tandem: tandem.createTandem( 'shearingEmitter' ), + phetioDocumentation: 'Emits when atoms shear off from the top book', phetioReadOnly: true } ); - // @public (read-only) {Atom[][]}- array of all atoms which are able to evaporate organized by row such that the - // last rows should be evaporated first - this.evaporableAtomsByRow = []; + // @public (read-only) {Atom[][]}- array of all atoms which are able to shear off organized by row such that the + // last rows should be sheared off first + this.shearableAtomsByRow = []; // @public (read-only) {NumberProperty} - atoms temperature = amplitude of oscillation this.vibrationAmplitudeProperty = new NumberProperty( MAGNIFIED_ATOMS_INFO.vibrationAmplitude.min, { @@ -218,9 +218,9 @@ class FrictionModel extends PhetioObject { tandem: tandem.createTandem( 'bottomOffsetProperty' ) } ); - // @public (read-only) {NumberProperty} - number of rows of atoms available to evaporate, goes down as book wears away - this.atomRowsToEvaporateProperty = new NumberProperty( TOP_BOOK_ATOM_STRUCTURE.length - 1, { - tandem: tandem.createTandem( 'atomRowsToEvaporateProperty' ) + // @public (read-only) {NumberProperty} - number of rows of atoms available to shear off, goes down as book wears away + this.atomRowsToShearOffProperty = new NumberProperty( TOP_BOOK_ATOM_STRUCTURE.length - 1, { + tandem: tandem.createTandem( 'atomRowsToShearOffProperty' ) } ); // @private - are books in contact? @@ -245,11 +245,11 @@ class FrictionModel extends PhetioObject { this.atoms = []; // @public (read-only) - // {number} the count of how many atoms have been evaporated - this.numberOfAtomsEvaporated = 0; + // {number} the count of how many atoms have been sheared off + this.numberOfAtomsShearedOff = 0; - this.evaporationEmitter.addListener( () => { - this.numberOfAtomsEvaporated += 1; + this.shearingEmitter.addListener( () => { + this.numberOfAtomsShearedOff += 1; } ); // @public (read-only) @@ -315,10 +315,10 @@ class FrictionModel extends PhetioObject { } } ); - // evaporation check + // shearing check this.vibrationAmplitudeProperty.link( amplitude => { - if ( amplitude > MAGNIFIED_ATOMS_INFO.evaporationLimit && !phet.joist.sim.isSettingPhetioStateProperty.value ) { - this.tryToEvaporate(); + if ( amplitude > MAGNIFIED_ATOMS_INFO.shearingLimit && !phet.joist.sim.isSettingPhetioStateProperty.value ) { + this.tryToShearOff(); } } ); } @@ -333,10 +333,10 @@ class FrictionModel extends PhetioObject { width: NumberIO, height: NumberIO, bookDraggingScaleFactor: NumberIO, - scheduledEvaporationAmount: NumberIO, - evaporableAtomsByRow: ArrayIO( ArrayIO( ReferenceIO( Atom.AtomIO ) ) ), + scheduledShearingAmount: NumberIO, + shearableAtomsByRow: ArrayIO( ArrayIO( ReferenceIO( Atom.AtomIO ) ) ), atoms: ArrayIO( ReferenceIO( Atom.AtomIO ) ), - numberOfAtomsEvaporated: NumberIO + numberOfAtomsShearedOff: NumberIO }; } @@ -348,17 +348,17 @@ class FrictionModel extends PhetioObject { */ step( dt ) { - // step the atoms, which is how they vibrate and move away if they evaporate + // step the atoms, which is how they vibrate and move away if they shear off for ( let i = 0; i < this.atoms.length; i++ ) { this.atoms[ i ].step( dt ); } // cool the atoms - let amplitude = this.vibrationAmplitudeProperty.get() - this.scheduledEvaporationAmount; + let amplitude = this.vibrationAmplitudeProperty.get() - this.scheduledShearingAmount; amplitude = Math.max( MAGNIFIED_ATOMS_INFO.vibrationAmplitude.min, amplitude * ( 1 - dt * COOLING_RATE ) ); this.vibrationAmplitudeProperty.set( amplitude ); - this.scheduledEvaporationAmount = 0; + this.scheduledShearingAmount = 0; } /** @@ -370,13 +370,13 @@ class FrictionModel extends PhetioObject { this.topBookPositionProperty.reset(); this.distanceBetweenBooksProperty.reset(); this.bottomOffsetProperty.reset(); - this.atomRowsToEvaporateProperty.reset(); + this.atomRowsToShearOffProperty.reset(); this.contactProperty.reset(); this.hintProperty.reset(); this.atoms.forEach( atom => { atom.reset(); } ); - this.numberOfAtomsEvaporated = 0; + this.numberOfAtomsShearedOff = 0; } /** @@ -415,46 +415,46 @@ class FrictionModel extends PhetioObject { } /** - * determine whether an atom is available to be evaporated and, if so, evaporate it + * determine whether an atom is available to be sheared off and, if so, shear off it * @private */ - tryToEvaporate() { + tryToShearOff() { - // only if this value points to a proper index in evaporableAtomsByRow. If negative, there are likely no more evaporable rows - if ( this.atomRowsToEvaporateProperty.get() > 0 ) { + // only if this value points to a proper index in shearableAtomsByRow. If negative, there are likely no more shearable rows + if ( this.atomRowsToShearOffProperty.get() > 0 ) { - // determine whether the current row is fully evaporated and, if so, move to the next row - const currentRowOfEvaporableAtoms = this.evaporableAtomsByRow[ this.atomRowsToEvaporateProperty.get() - 1 ]; + // determine whether the current row is fully sheared off and, if so, move to the next row + const currentRowOfShearableAtoms = this.shearableAtomsByRow[ this.atomRowsToShearOffProperty.get() - 1 ]; - // if there are any rows of evaporable atoms left, evaporate one - if ( currentRowOfEvaporableAtoms.length > 0 ) { + // if there are any rows of shearable atoms left, shear off one + if ( currentRowOfShearableAtoms.length > 0 ) { - // make a list of all atoms in this row that have not yet evaporated - const unevaporatedAtoms = currentRowOfEvaporableAtoms.filter( atom => !atom.isEvaporated ); + // make a list of all atoms in this row that have not yet sheared off + const notYetShearedAtoms = currentRowOfShearableAtoms.filter( atom => !atom.isShearedOff ); assert && assert( - unevaporatedAtoms.length > 0, + notYetShearedAtoms.length > 0, 'should never encounter this case, if we do, something is wrong in logic above' ); - // randomly choose an unevaporated atom and evaporate it - const atomToEvaporate = dotRandom.sample( unevaporatedAtoms ); - atomToEvaporate.evaporate(); - this.evaporationEmitter.emit(); + // randomly choose an non-sheared-off atom and shear off it + const atomsToShearOff = dotRandom.sample( notYetShearedAtoms ); + atomsToShearOff.shearOff(); + this.shearingEmitter.emit(); - // cause some cooling due to evaporation - this.scheduledEvaporationAmount = this.scheduledEvaporationAmount + EVAPORATION_AMPLITUDE_REDUCTION; + // cause some cooling due to shearing + this.scheduledShearingAmount = this.scheduledShearingAmount + SHEAR_OFF_AMPLITUDE_REDUCTION; } - const isCurrentRowFullyEvaporated = _.every( currentRowOfEvaporableAtoms, atom => atom.isEvaporated ); + const isCurrentRowFullyShearedOff = _.every( currentRowOfShearableAtoms, atom => atom.isShearedOff ); - // if all atoms in this row are evaporated, move on to the next row - if ( isCurrentRowFullyEvaporated ) { + // if all atoms in this row are sheared off, move on to the next row + if ( isCurrentRowFullyShearedOff ) { - // point one row higher because all of the previous row is evaporated - this.atomRowsToEvaporateProperty.set( this.atomRowsToEvaporateProperty.get() - 1 ); + // point one row higher because all of the previous row is sheared off + this.atomRowsToShearOffProperty.set( this.atomRowsToShearOffProperty.get() - 1 ); - // the current row is totally evaporated, so the distance between the books just increased "one row" worth. + // the current row is totally sheared off, so the distance between the books just increased "one row" worth. this.distanceBetweenBooksProperty.set( this.distanceBetweenBooksProperty.get() + MAGNIFIED_ATOMS_INFO.distanceY ); } @@ -466,14 +466,14 @@ class FrictionModel extends PhetioObject { // statics FrictionModel.MAGNIFIED_ATOMS_INFO = MAGNIFIED_ATOMS_INFO; FrictionModel.THERMOMETER_MIN_TEMP = MAGNIFIED_ATOMS_INFO.vibrationAmplitude.min - 1.05; // about 0 -FrictionModel.THERMOMETER_MAX_TEMP = MAGNIFIED_ATOMS_INFO.evaporationLimit * 1.1; // ~7.7 +FrictionModel.THERMOMETER_MAX_TEMP = MAGNIFIED_ATOMS_INFO.shearingLimit * 1.1; // ~7.7 // pdom - needed to get bounds for the keyboard drag handler, see https://github.com/phetsims/friction/issues/46 FrictionModel.MAX_X_DISPLACEMENT = MAX_X_DISPLACEMENT; FrictionModel.MIN_Y_POSITION = MIN_Y_POSITION; // pdom -FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS = NUMBER_OF_EVAPORABLE_ATOMS; +FrictionModel.NUMBER_OF_SHEARABLE_ATOMS = NUMBER_OF_SHEARABLE_ATOMS; // pdom FrictionModel.VIBRATION_AMPLITUDE_MIN = VIBRATION_AMPLITUDE_MIN; @@ -496,12 +496,12 @@ FrictionModel.FrictionModelIO = IOType.fromCoreType( 'FrictionModelIO', Friction // helper function to add a layer of atoms to the model function addAtomRow( frictionModel, layerDescription, rowStartXPos, rowYPos, isTopAtom, parentTandem ) { - let canEvaporate; - const evaporableAtomsRow = []; + let canShearOff; + const shearableAtomsRow = []; for ( let i = 0; i < layerDescription.length; i++ ) { const offset = layerDescription[ i ].offset || 0; - canEvaporate = layerDescription[ i ].canEvaporate || false; + canShearOff = layerDescription[ i ].canShearOff || false; for ( let n = 0; n < layerDescription[ i ].num; n++ ) { const atom = new Atom( new Vector2( rowStartXPos + ( offset + n ) * MAGNIFIED_ATOMS_INFO.distanceX, rowYPos ), @@ -511,13 +511,13 @@ function addAtomRow( frictionModel, layerDescription, rowStartXPos, rowYPos, isT } ); frictionModel.atoms.push( atom ); - if ( canEvaporate ) { - evaporableAtomsRow.push( atom ); + if ( canShearOff ) { + shearableAtomsRow.push( atom ); } } } - if ( canEvaporate ) { - frictionModel.evaporableAtomsByRow.push( evaporableAtomsRow ); + if ( canShearOff ) { + frictionModel.shearableAtomsByRow.push( shearableAtomsRow ); } } diff --git a/js/friction/view/BreakAwayAlerter.js b/js/friction/view/BreakAwayAlerter.js index 343edf2a..ca2ba486 100644 --- a/js/friction/view/BreakAwayAlerter.js +++ b/js/friction/view/BreakAwayAlerter.js @@ -1,7 +1,7 @@ // Copyright 2018-2021, University of Colorado Boulder /** - * Describer responsible for handling the appropriate alert when atoms evaporate, or "break away" from the top book. + * Describer responsible for handling the appropriate alert when atoms shear off, or "break away" from the top book. * @author Michael Kauzmann (PhET Interactive Simulations) */ @@ -31,7 +31,7 @@ const BREAK_AWAY_NONE_LEFT = StringUtils.fillIn( breakAwayNoneLeftString, { temp // time in between "break away sessions". This is the minimum amount of time to wait before hearing a subsequent break // away alert const ALERT_TIME_DELAY = 2000; -const EVAPORATION_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.evaporationLimit; +const SHEARING_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.shearingLimit; class BreakAwayAlerter extends Alerter { @@ -64,10 +64,10 @@ class BreakAwayAlerter extends Alerter { // @private this.amplitudeListener = ( amplitude, oldAmplitude ) => { - // Handle the alert when amplitude is high enough to begin evaporating + // Handle the alert when amplitude is high enough to begin shearing if ( !this.tooSoonForNextAlert && // alert only separate "break away events" - amplitude > EVAPORATION_LIMIT && oldAmplitude < EVAPORATION_LIMIT ) { // just hit evaporation limit - this.alertAtEvaporationThreshold(); + amplitude > SHEARING_LIMIT && oldAmplitude < SHEARING_LIMIT ) { // just hit shearing limit + this.alertAtShearingThreshold(); } }; @@ -80,11 +80,11 @@ class BreakAwayAlerter extends Alerter { * Alert when the temperature has just reached the point where atoms begin to break away * @public */ - alertAtEvaporationThreshold() { + alertAtShearingThreshold() { let alertContent = null; // If there aren't any more atoms to break away, but don't let this be the first alert we hear - if ( this.alertedBreakAwayProperty.value && this.model.numberOfAtomsEvaporated >= FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS ) { + if ( this.alertedBreakAwayProperty.value && this.model.numberOfAtomsShearedOff >= FrictionModel.NUMBER_OF_SHEARABLE_ATOMS ) { alertContent = BREAK_AWAY_NONE_LEFT; } else { diff --git a/js/friction/view/FrictionScreenSummaryNode.js b/js/friction/view/FrictionScreenSummaryNode.js index 7744945b..e6e7a256 100644 --- a/js/friction/view/FrictionScreenSummaryNode.js +++ b/js/friction/view/FrictionScreenSummaryNode.js @@ -92,24 +92,24 @@ class FrictionScreenSummaryNode extends Node { /** - * Given the number of atoms that have evaporated from the model so far, get the first screen summary sentence, + * Given the number of atoms that have sheared off from the model so far, get the first screen summary sentence, * describing the chemistry book. - * @param {number} atomsEvaporated + * @param {number} numberAtomsShearedOff * @returns {string} the first sentence of the screen summary * @private */ - getFirstSummarySentence( atomsEvaporated ) { + getFirstSummarySentence( numberAtomsShearedOff ) { - // There are three ranges based on how many atoms have evaporated + // There are three ranges based on how many atoms have sheared off let relativeChemistryBookSentence = null; - // "no evaporated atoms" - if ( atomsEvaporated === 0 ) { + // "no shearable atoms" + if ( numberAtomsShearedOff === 0 ) { relativeChemistryBookSentence = ''; // blank initial sentence of "First Sentence" } - // some evaporated atoms, describe the chemistry book with some atoms "broken away" - else if ( atomsEvaporated < FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS ) { + // some atoms have sheared off, describe the chemistry book with some atoms "broken away" + else if ( numberAtomsShearedOff < FrictionModel.NUMBER_OF_SHEARABLE_ATOMS ) { relativeChemistryBookSentence = StringUtils.fillIn( amountOfAtomsString, { comparisonAmount: fewerString, breakAwayAmount: someString, @@ -117,7 +117,7 @@ class FrictionScreenSummaryNode extends Node { } ); } - // lots of evaporated atoms, describe many missing atoms + // lots of atoms sheared off, describe many missing atoms else { relativeChemistryBookSentence = StringUtils.fillIn( amountOfAtomsString, { comparisonAmount: farFewerString, @@ -224,13 +224,13 @@ class FrictionScreenSummaryNode extends Node { /** * @private - * @param {number} numberOfAtomsEvaporated + * @param {number} numberOfAtomsShearedOff * @returns {string} */ - getThirdSupplementarySentence( numberOfAtomsEvaporated ) { + getThirdSupplementarySentence( numberOfAtomsShearedOff ) { - // Queue moving the book if there are still many atoms left, queue reset if there are many evaporated atoms - return numberOfAtomsEvaporated === FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS ? + // Queue moving the book if there are still many atoms left, queue reset if there are many atoms sheared off + return numberOfAtomsShearedOff === FrictionModel.NUMBER_OF_SHEARABLE_ATOMS ? resetSimMoreObservationSentenceString : grabChemistryBookPlayString; } @@ -254,7 +254,7 @@ class FrictionScreenSummaryNode extends Node { getCurrentDetailsString() { // FIRST SENTENCE - const chemistryBookString = this.getFirstSummarySentence( this.model.numberOfAtomsEvaporated ); + const chemistryBookString = this.getFirstSummarySentence( this.model.numberOfAtomsShearedOff ); // SECOND SENTENCE (ZOOMED-IN) const jiggleTempSentence = this.getSecondSummarySentence( this.model.vibrationAmplitudeProperty ); @@ -270,7 +270,7 @@ class FrictionScreenSummaryNode extends Node { * @returns {string} */ getHintString() { - return this.model.numberOfAtomsEvaporated === FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS ? resetSimMoreObservationSentenceString : + return this.model.numberOfAtomsShearedOff === FrictionModel.NUMBER_OF_SHEARABLE_ATOMS ? resetSimMoreObservationSentenceString : this.model.contactProperty.value ? frictionStrings.a11y.screenSummary.continueRubbing : frictionStrings.a11y.screenSummary.grabChemistryBookPlay; } diff --git a/js/friction/view/FrictionScreenView.js b/js/friction/view/FrictionScreenView.js index 71b806e4..ee9993f9 100644 --- a/js/friction/view/FrictionScreenView.js +++ b/js/friction/view/FrictionScreenView.js @@ -89,7 +89,7 @@ class FrictionScreenView extends ScreenView { const alertSettledAndCool = () => { // only add "reset sim" hint when all atoms have sheared off. - atomsJiggleTinyBitUtterance.alert.hintResponse = model.numberOfAtomsEvaporated === FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS ? + atomsJiggleTinyBitUtterance.alert.hintResponse = model.numberOfAtomsShearedOff === FrictionModel.NUMBER_OF_SHEARABLE_ATOMS ? frictionStrings.a11y.resetSimMoreObservationSentence : null; this.alertDescriptionUtterance( atomsJiggleTinyBitUtterance ); @@ -226,10 +226,10 @@ class FrictionScreenView extends ScreenView { rateChangesAffectPlayingSounds: false } ); soundManager.addSoundGenerator( moleculeBreakOffSoundClip ); - model.evaporationEmitter.addListener( () => { + model.shearingEmitter.addListener( () => { - // don't play for every evaporated molecule or it's too noisy - if ( model.numberOfAtomsEvaporated % 4 === 0 ) { + // don't play for every sheared off atom or it's too noisy + if ( model.numberOfAtomsShearedOff % 4 === 0 ) { // set a random playback rate moleculeBreakOffSoundClip.setPlaybackRate( FrictionConstants.GET_RANDOM_PENTATONIC_PLAYBACK_RATE(), 0 ); diff --git a/js/friction/view/TemperatureDecreasingAlerter.js b/js/friction/view/TemperatureDecreasingAlerter.js index 7691cf51..a6ef3f1e 100644 --- a/js/friction/view/TemperatureDecreasingAlerter.js +++ b/js/friction/view/TemperatureDecreasingAlerter.js @@ -42,8 +42,8 @@ const DECREASING = [ } ]; -// From model, the amplitude value when the atoms evaporate -const EVAPORATION_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.evaporationLimit; +// From model, the amplitude value when the atoms shear off +const SHEARING_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.shearingLimit; // How long in between each subsequent decreasing alert const ALERT_TIME_DELAY = 3000; @@ -107,7 +107,7 @@ class TemperatureDecreasingAlerter extends Alerter { // If we meet criteria, then alert that temp/amplitude is decreasing if ( this.tempDecreasing && // only if the temperature is decreasing amplitude > FrictionModel.AMPLITUDE_SETTLED_THRESHOLD && // when amplitude is close enough to its settled state, don't alert anymore\ - amplitude < EVAPORATION_LIMIT && // don't alert cooling unless cooler than evaporation limit + amplitude < SHEARING_LIMIT && // don't alert cooling unless cooler than shearing limit phet.joist.elapsedTime - this.timeOfLastAlert > ALERT_TIME_DELAY ) { // If we have waited long enough this.alertDecrease(); } diff --git a/js/friction/view/TemperatureIncreasingAlerter.js b/js/friction/view/TemperatureIncreasingAlerter.js index 7df6b69a..68115e38 100644 --- a/js/friction/view/TemperatureIncreasingAlerter.js +++ b/js/friction/view/TemperatureIncreasingAlerter.js @@ -66,8 +66,8 @@ const INCREASING = [ } ]; -// From model, the amplitude value when the atoms evaporate -const EVAPORATION_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.evaporationLimit; +// From model, the amplitude value when the atoms shear off +const SHEARING_LIMIT = FrictionModel.MAGNIFIED_ATOMS_INFO.shearingLimit; // how long to wait until we consider this newest drag of a different "drag session", such // that the warming alert progression will start over back at "warmer" alerts. @@ -148,7 +148,7 @@ class TemperatureIncreasingAlerter extends Alerter { this.amplitudeIncreasing = !( localMaxima - amplitude > AMPLITUDE_DECREASING_THRESHOLD ); // the difference in amplitude has to be greater than the threshold to alert - if ( !this.tooSoonForNextWarmingAlert && amplitude < EVAPORATION_LIMIT && amplitude - this.initialAmplitude > TEMPERATURE_ALERT_THRESHOLD ) { + if ( !this.tooSoonForNextWarmingAlert && amplitude < SHEARING_LIMIT && amplitude - this.initialAmplitude > TEMPERATURE_ALERT_THRESHOLD ) { this.alertIncrease(); } else if ( !this.tooSoonForNextMaxTempAlert && amplitude >= FrictionModel.THERMOMETER_MAX_TEMP ) { diff --git a/js/friction/view/book/BookMovementAlerter.js b/js/friction/view/book/BookMovementAlerter.js index 8f0098b1..fd8d4932 100644 --- a/js/friction/view/book/BookMovementAlerter.js +++ b/js/friction/view/book/BookMovementAlerter.js @@ -106,7 +106,7 @@ class BookMovementAlerter extends MovementAlerter { } // Once touching, speak the alert - if ( !wasTouching && isTouching && model.numberOfAtomsEvaporated === 0 ) { + if ( !wasTouching && isTouching && model.numberOfAtomsShearedOff === 0 ) { this.alert( this.bottomDescriptionUtterance ); voicingUtteranceQueue.addToBack( this.bottomVoicingUtterance ); } @@ -145,7 +145,7 @@ class BookMovementAlerter extends MovementAlerter { this.separatedAlertPair.updateFromDirection( direction ); } - else if ( this.model.numberOfAtomsEvaporated < FrictionModel.NUMBER_OF_EVAPORABLE_ATOMS / 4 ) { + else if ( this.model.numberOfAtomsShearedOff < FrictionModel.NUMBER_OF_SHEARABLE_ATOMS / 4 ) { // 1/4 of atoms still covers the first two sparse rows that get sheared off. // If they "bothAlerted" meaning that the user went left and right without contacting the bottom boot, then // cue a movement and reset the alertPair. Only until enough atoms shear off that the user is "trained." diff --git a/js/friction/view/magnifier/MagnifierNode.js b/js/friction/view/magnifier/MagnifierNode.js index d555002c..b3a13cb0 100644 --- a/js/friction/view/magnifier/MagnifierNode.js +++ b/js/friction/view/magnifier/MagnifierNode.js @@ -205,7 +205,7 @@ class MagnifierNode extends Node { } ); - // a11y - Custom shape highlights, shape will change with atomRowsToEvaporateProperty. Focus and Interactive + // a11y - Custom shape highlights, shape will change with atomRowsToShearOffProperty. Focus and Interactive // highlights are identical, but we need two different Nodes because GrabDragInteraction adds children to the // focus highlight that are specific to the keyboard interaction. const focusHighlightPath = new FocusHighlightPath( getFocusHighlightShape( dragArea ) ); @@ -342,9 +342,9 @@ class MagnifierNode extends Node { model.topBookPositionProperty.linkAttribute( this.topBookBackground, 'translation' ); model.topBookPositionProperty.linkAttribute( this.topAtomsLayer, 'translation' ); - model.atomRowsToEvaporateProperty.link( number => { + model.atomRowsToShearOffProperty.link( number => { - // Adjust the drag area as the number of rows of atoms evaporates. + // Adjust the drag area as the number of rows of atoms shears off. dragArea.setRectHeight( ( number + 2 ) * FrictionModel.MAGNIFIED_ATOMS_INFO.distanceY ); // Update the size of the highlights accordingly