From 0e881376a152a3377aaaa0b01b8d160febf87b09 Mon Sep 17 00:00:00 2001 From: chrisklus Date: Tue, 4 Aug 2020 00:59:11 -0400 Subject: [PATCH] Use the heater value for preloading tea kettle chunks if the heater is on, see https://github.com/phetsims/energy-forms-and-changes/issues/336 --- js/systems/model/TeaKettle.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/systems/model/TeaKettle.js b/js/systems/model/TeaKettle.js index 6220ac72..a6c4283d 100644 --- a/js/systems/model/TeaKettle.js +++ b/js/systems/model/TeaKettle.js @@ -16,8 +16,8 @@ import TEAPOT_ICON from '../../../images/tea_kettle_icon_png.js'; import EFACConstants from '../../common/EFACConstants.js'; import EnergyChunk from '../../common/model/EnergyChunk.js'; import EnergyType from '../../common/model/EnergyType.js'; -import energyFormsAndChangesStrings from '../../energyFormsAndChangesStrings.js'; import energyFormsAndChanges from '../../energyFormsAndChanges.js'; +import energyFormsAndChangesStrings from '../../energyFormsAndChangesStrings.js'; import Energy from './Energy.js'; import EnergyChunkPathMover from './EnergyChunkPathMover.js'; import EnergySource from './EnergySource.js'; @@ -219,7 +219,7 @@ class TeaKettle extends EnergySource { this.transferNextAvailableChunk = false; } - // Don't transfer this chunk. + // Don't transfer this chunk. // Set up to transfer the next one. else { this.exemptFromTransferEnergyChunks.push( chunk ); @@ -228,7 +228,7 @@ class TeaKettle extends EnergySource { } } - // if a chunk has reached the position where it should transfer to the next system, but no steam powerable + // if a chunk has reached the position where it should transfer to the next system, but no steam powerable // element is in place, add the chunk to the list of non transfers else if ( !this.steamPowerableElementInPlaceProperty.get() && ENERGY_CHUNK_TRANSFER_DISTANCE_RANGE.contains( @@ -260,7 +260,14 @@ class TeaKettle extends EnergySource { // Simulate energy chunks moving through the system. while ( !preloadComplete ) { - energySinceLastChunk += this.energyProductionRateProperty.get() * dt; + if ( this.heatProportionProperty.value > 0 ) { + // if the heater is on, determine the rate of chunk release by its level + energySinceLastChunk += this.heatProportionProperty.value * EFACConstants.MAX_ENERGY_PRODUCTION_RATE * dt; + } + else { + // otherwise, determine by the existing energy in the kettle + energySinceLastChunk += this.energyProductionRateProperty.get() * dt; + } if ( energySinceLastChunk >= EFACConstants.ENERGY_PER_CHUNK ) { let initialPosition;