phetsims / buoyancy

"Buoyancy" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
2 stars 2 forks source link

Play/pause control #99

Closed DianaTavares closed 8 months ago

DianaTavares commented 9 months ago

This idea born from a user suggestion that explain it is difficult to place blocks in the boat that are “almost in the limit of mass” that the boat can carry. The boat sinks easily, even that they tray to place the block“very gently”.

My idea was to include a play/pause control (like in energy skate park) that stops and activates the “buoyancy physics behavior”. In that way, the user can pause the physics, place the block and, by clicking play, observe how the boat and pool now react.

During Feb/12/24 Design meeting, more teachable moments that can be beneficial from that control were mentioned. AV share that it may be as MSS, where the forces vectors modify their behavior when the user changes their positions, but only move when the user click play. He thinks that something similar can be implemented here.

MK and AV are going to see how hard it is to implement this.

AgustinVallejo commented 8 months ago

The following patch does an initial try at this. For now we're disabling friction, gravity and buoyancy, which I think is what we want, without losing contact forces and the liquid dynamics. However, I couldn't find where to stop the body from applying the velocity so it doesn't float away. Will later look more into this.

To test this I went into studio and toggled the isPlayingProperty. We can later think if this would be linked via a button or TimeControlNode.

```diff Subject: [PATCH] isPlayingProperty --- Index: js/common/model/DensityBuoyancyModel.ts IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/model/DensityBuoyancyModel.ts b/js/common/model/DensityBuoyancyModel.ts --- a/js/common/model/DensityBuoyancyModel.ts (revision f56b31f2cdadb3ea53ed0b3117098156cce882e6) +++ b/js/common/model/DensityBuoyancyModel.ts (date 1709147249732) @@ -89,6 +89,8 @@ // Scale for the pool, if we are using it private readonly scale2: Scale | null; + public readonly isPlayingProperty: Property; + public constructor( providedOptions?: DensityBuoyancyModelOptions ) { const options = optionize()( { showMassesDefault: false, @@ -324,7 +326,7 @@ // Vertical acceleration of the boat will change the buoyant force. const acceleration = gravity + ( ( boat && basin === boat.basin ) ? boatVerticalAcceleration : 0 ); const buoyantForce = new Vector2( 0, displacedMass * acceleration ); - this.engine.bodyApplyForce( mass.body, buoyantForce ); + this.isPlayingProperty.value && this.engine.bodyApplyForce( mass.body, buoyantForce ); mass.buoyancyForceInterpolatedProperty.setNextValue( buoyantForce ); // If the boat is moving, assume the liquid moves with it, and apply viscosity due to the movement of our mass @@ -340,7 +342,7 @@ const hackedViscosity = this.liquidViscosityProperty.value ? 0.03 * Math.pow( this.liquidViscosityProperty.value / 0.03, 0.8 ) : 0; const viscosityMass = Math.max( DensityBuoyancyCommonQueryParameters.viscosityMassCutoff, mass.massProperty.value ); const viscousForce = velocity.times( -hackedViscosity * viscosityMass * ratioSubmerged * 3000 * DensityBuoyancyCommonQueryParameters.viscosityMultiplier ); - this.engine.bodyApplyForce( mass.body, viscousForce ); + this.isPlayingProperty.value && this.engine.bodyApplyForce( mass.body, viscousForce ); } else { mass.buoyancyForceInterpolatedProperty.setNextValue( Vector2.ZERO ); @@ -348,7 +350,7 @@ // Gravity const gravityForce = new Vector2( 0, -mass.massProperty.value * gravity ); - this.engine.bodyApplyForce( mass.body, gravityForce ); + this.isPlayingProperty.value && this.engine.bodyApplyForce( mass.body, gravityForce ); mass.gravityForceInterpolatedProperty.setNextValue( gravityForce ); } ); } ); @@ -375,6 +377,10 @@ else { this.scale2 = null; } + + this.isPlayingProperty = new BooleanProperty( true, { + tandem: tandem.createTandem( 'isPlayingProperty' ) + } ); } /**
zepumph commented 8 months ago

Today during design meeting it was decided that the concerns about the play button outweighed the benefit. We don't want to add the play button anymore.

Some of the questions and concerns we discussed:

  1. It is easy to continue to show the buoyant and gravitational forces when paused, but much harder for the contact forces, since those are embedded into the physics sim. It would be more challenging to support those, and we are worried about the effort.
  2. The scale demonstrates strange behavior since it can show values when we drag the mass onto it, but the value doesn't stay.
  3. The notion of "play/pause" may be confusing to know if you are paused or not since you can still drag items. Students could be confused about certain cases (like a submerged mass that should be floating). A visual queue could have been needed to help with this.

Closing.