Closed DianaTavares closed 1 day ago
This still happening. I think that the problem is the contact force or some objects (like the brick in the intro screen) and when that objects are in the scale, the scale lecture also have that vibration in the digits. The scale with more problems is the one that is not in the pool.
This seems related to #83, which was a bug in the stepping and force calculation specific to boat. I could see there being another awkward item like that, or something more specific to p2 itself. We'll take a look, thanks.
From https://github.com/phetsims/buoyancy/issues/157:
Some scales have fluctuating values. The gif shows some examples in Intro:
Something really interesting I noticed: This doesn't occur neither in the Lab scale (with the height slider) nor when grabbing the scale... Could suggest to me that having dynamic scale movements could be triggering this, maybe the force of the scale against the ground or something?
Edit: If you drag the scale with a block on top, there's no flicker. If you drag that scale against the ground, the flickering intensifies.
We still want to discuss this more. We want to understand world stepping enough to know why we get more noise when we reduce the fixed time step.
For this issue and mostly for https://github.com/phetsims/buoyancy/issues/140, it may be a solution to convert InterpolatedProperty usages that are only for the view into something like an averaged Property. Here is a patch for that investigation if we get to a point where we want it.
This patch averages the scale forces over all the post steps, and shows that averaging still shows high fluctuation (in the tenths place for an aluminum block in explore).
132.31159329414368
P2Engine.ts:120 132.28697419166565
P2Engine.ts:120 132.3013937473297
P2Engine.ts:120 132.3001742362976
P2Engine.ts:120 132.31159329414368
P2Engine.ts:120 132.28697419166565
P2Engine.ts:120 132.3013937473297
On further investigation, I believe @AgustinVallejo's original pull request is the right direction. Here is the experiment I ran to help me understand:
Note in the patch, I have set the dt to be very low and make sure there is no remainder in the accumulator. This helps rule out sources of problems. In Explore => aluminum, we still have this oscillation in the model:
132.33227111399174
132.26592510938644
132.3312997072935
132.27052487432957
132.33227111399174
132.26592510938644
132.3312997072935
132.27052487432957
132.33227111399174
132.26592510938644
132.3312997072935
132.27052487432957
132.33227111399174
132.26592510938644
132.3312997072935
132.27052487432957
132.33227111399174
132.26592510938644
However, I observed that the gravity force on the scale is: 132.30N
Note that averaging the values above gives nearly that: 132.299904. The effect of the pull request is averaging across (not within) time steps. We may have to take for granted that the p2 engine has instabilities and to average across them.
This patch changes the scale to be STATIC or DYNAMIC based on whether the user is dragging it:
It seems to work around the flickering problem. But also it fails the "Galileo's Leaning Tower of Pisa experiment" test where you toss a scale with a mass on it. The latest dev version correctly shows 0 for that case, whereas this patch incorrectly shows a weight on the scale. I do not know why, but if we can solve that and the heuristics for when to become static again, this may be a fair workaround.
We kept discussing this. @samreid is going to continue reading on this. I pushed my potential solution in https://github.com/phetsims/density-buoyancy-common/pull/131
Some experiments for my understanding of the interpolation
From conversations over in https://github.com/phetsims/density-buoyancy-common/issues/132. InterpolatedProperty is largely working correctly, as it pertains to the tradeoffs in the p2 engine. I believe the best path forward for this issue is to determine how we want to process that output for the best view experience.
Brainstorming postprocessing that averages values, and an optional tuning:
From the design meeting, we would like to investigate a filtering, like the Kalman filter.
I tried a variety of noise settings for the Kalman filter but can't get it to stop flickering either:
This patch is very similar to @AgustinVallejo pull request. It helps in many cases but you can still trigger fluctuations. We recalled there was another idea from @kathy-phet to show only 1 decimal place when values are over 10, which will also help, but we don't see that in another issue.
@AgustinVallejo and I reviewed the Kalman filter and agreed it doesn't seem like it will work for this context. Instead, we continued the blending approach, which has a good behavior and works well in this context. We adjusted the coefficients so that far away values favor the new value and there is more blending when the values are close. There will still be edge cases where there is flickering due to the inherent noisy nature of the model. This is ready for @DianaTavares to review. Please close if all is well.
UPDATE: Also the change in https://github.com/phetsims/buoyancy/issues/167 reduces the amount of flickering in the sim.
This issue is entangled with https://github.com/phetsims/buoyancy/issues/140, if this one is ready for closing, we should check that one as well. As the fix encompasses both visual flickers.
I see a little fluctuation only in the bottle:
and in boat in Tantalum (big density)
But I think that is good enough to go!! Then I am closing this issue.
The gif at the bottom shows the behavior of the scale in the simulation. The scale is not giving a direct value, it is fluctuating.
looks like this is not happening only with some values (probably with over 30 N)