Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model and decimals in sim screens #57

Closed
kathy-phet opened this issue Jun 13, 2018 · 53 comments
Closed

Model and decimals in sim screens #57

kathy-phet opened this issue Jun 13, 2018 · 53 comments

Comments

@kathy-phet
Copy link

kathy-phet commented Jun 13, 2018

This issue is broken off for a separate discussion reflecting on Hooke's law screens. Below is the initial context that initiated the discussion. But in the next comment I will try to summarize what I am seeing as the differences in the screens and the place value needs.

@kathy-phet wrote:

(Question for Amy): Re significant digits. In playing with this screen and thinking about taking data, I think we need to look even deeper at the significant digits. I like the new snappiness of the position control. Does it need to have 3 digits in this control? Also an issue with three digits in this control is that force is only read out to two digits - so it does not have enough sig figs to register the change from 0.350 to 0.351 or 0.034 in position. There is a fundamental change in this particular screen because we are now adjusting position, not force as in the prior screens.

@pixelzoom replied:

The number of decimal places was carefully chose so that no controls or interactions feel to “coarse”. If you reduce the number of decimal places in displacement (for example), the applied force is going to move in big jumps in some of the screens. Also beware that this sim allows changing all 3 variables in the equation F = kx. So the number of decimal places need to be compatible across all quantities, or we will end up with loops in the model — which I spent 8+ hours investigating and fixing for displacement only today. And “loops” were never an issue until we had to consider the PhET-iO data stream. Which is related to your next bullet.

@pixelzoom
Copy link
Contributor

Specifically, this issue was broken off from https://github.com/phetsims/phet-io-wrapper-hookes-law-energy/issues/2#issuecomment-396770874.

@pixelzoom
Copy link
Contributor

@kathy-phet also note that there's a more general issue that discusses the topic of "number of decimal places" as related to the PhET-iO message stream. See https://github.com/phetsims/phet-io/issues/1332.

@kathy-phet
Copy link
Author

Here is a summary of how I am thinking about these screens.

Screen 1:
Here the primary controls are F and k. Displacement is the responding to these slider values.
F is constrained to an integer (1,2,3,.... )
k is constrained to the tens value (100, 110, 120, ...)
Displacement should be the calculated value from x = F/k. And x value needs 3 decimal places because these nice F and k values can divide in such that 3 decimals are needed to capture the value well enough to graph and show the relationship.
Model value will have many decimal places ... displayed value will have 3 decimal places.

One model complication I don't fully follow on this screen is that position is adjustable with the arm, but F should always be the exact integer value shown since it is on the slider and that is exact. So I am not sure how the model is working here.

Screen 2:
Similar behavior and decimal needs as to Screen 1.

Screen 3:
Here we are controlling different parameters, and so what is the dependent and independent variables have changed.
x is now determined by our control all the time (whether slider or arm), and is constrained to be nice steps so as to make it easy to do a controlled experiment (this is pedagogically very useful). It should never need to be anything other than what it is set at and should not be calculated from F and k.
x really only needs 2 decimal places here 0.20. (snappy by 0.05, tweaky by 0.01)
x in the display can be 0.20. x in the model is set to be exactly 0.2000000 (or however many digits there are), but it is not calculated and cannot change.

k is also similarly defined with a set number of digits (100, 110) should not need to be calculated.

F is now the dependent term and should be directly calculated from k and x.
F=kx.
If k can be 110 and x can be 0.21, F is not expected to be a "nice integer number" and it would be best if it is displayed with 3 digits.
F=XX.X in the display. F in the model has many digits.

I guess I am seeing 2 different model variants depending on the screen - one where x=F/k and one where F=kx. How does the third screen work right now? where F is now the calculated value, not the controlled/set value?

Apologies for not having much bandwidth to discuss this today - but I wanted to put these thoughts down for Amy and Christ to look over.

@arouinfar
Copy link
Contributor

arouinfar commented Jun 13, 2018

Displacement definitely needs three decimal places on all three screens, otherwise some interactions will feel coarse, as @pixelzoom described.

We consistently display the same number of decimal places across all screens. I believe we made the decision of how many decimals to display was based on the interaction pattern of the first two screens (user-controlled F and k).

@kathy-phet raises some really great points about the third screen. I do not think there is any pedagogical advantage to controlling x in 0.001 m steps. We could kill the third decimal place altogether, and have the thumb/arm snap to 0.05 m steps, and use the tweaker to adjust by 0.01 m.

When x is small, increasing k results in F increasing in jumps, regardless of whether x has two or three decimals. Since F is the derived quantity on this screen, it would benefit from an additional digit.

I would vote for:

  • Leave sig figs on Intro & Systems as they are
  • On Energy, reduce displacement to two decimals. The thumb/arm snaps to the nearest 0.05 m, and the tweaker adjusts in 0.01 m steps.
  • On Energy, display Applied Force to the nearest tenths place.

@pixelzoom I'd m also curious about this question:

I guess I am seeing 2 different model variants depending on the screen - one where x=F/k and one where F=kx. How does the third screen work right now? where F is now the calculated value, not the controlled/set value?

On the Energy screen, does the model calculate F from the user-controlled x and k?

@arouinfar arouinfar removed their assignment Jun 13, 2018
@pixelzoom
Copy link
Contributor

@arouinfar asked:

On the Energy screen, does the model calculate F from the user-controlled x and k?

Intro and Systems screens: Changing x solves for F. Changing F or k solves for x.
Energy screen: Changing x or k solves for F. Changing F solves for x.

@pixelzoom
Copy link
Contributor

pixelzoom commented Jun 13, 2018

@arouinfar wrote:

• Leave sig figs on Intro & Systems as they are

The current implementation uses the same sig figs throughout all screens. Changing so that one screen (Energy) can be different will be nontrivial.

• On Energy, reduce displacement to two decimals.
• On Energy, display Applied Force to the nearest tenths place.

As written, this seems to suggest that we constrain displacement in the model, but constrain applied force only in the view ("display"). Is that what you intended? I want to be very clear that model vs view constraint are very different things. Constraining anything in the model typically leads to more floating-point errors.

@kathy-phet
Copy link
Author

kathy-phet commented Jun 13, 2018

Energy screen: Changing x or k solves for F. Changing F solves for x.

Why do you need a changing F solves for x on this screen? x is fixed by the slider/model value?

@arouinfar
Copy link
Contributor

Energy screen: Changing x or k solves for F. Changing F solves for x.

@pixelzoom it's unclear to me how a user could directly change F. The user can move the arm (which changes x) or adjust the k or x sliders.

The current implementation uses the same sig figs throughout all screens. Changing so that one screen (Energy) can be different will be nontrivial.

An alternative would be:

  • Displacement always has three decimal places. On the Energy screen, the 3rd decimal place would be 0 because the thumb/arm snaps to 0.05 m steps, and the tweaker would adjust in steps of 0.01 m.
  • Applied Force always has one decimal place. On Intro & Systems, the decimal would be 0 because F is adjusted in 1 N increments.
  • Spring Force would also need one decimal place to match Applied Force, otherwise things look strange.

As written, this seems to suggest that we constrain displacement in the model, but constrain applied force only in the view ("display"). Is that what you intended?

I'm not sure I completely follow @pixelzoom. Doesn't the Displacement slider set the value of the x in the model? The Applied Force is then calculated, and its displayed value is rounded to the nearest tenths place.

@pixelzoom
Copy link
Contributor

pixelzoom commented Jun 15, 2018

About the Energy screen...

@kathy-phet asked:

Why do you need a changing F solves for x on this screen? x is fixed by the slider/model value?

@arouinfar said:

I'm not sure I completely follow @pixelzoom. ...

Sorry, let me try explaining again.

All screens use the same model code. In the model, changing x computes F; changing F computes x. The model has an option that indicates which parameter is computed when k changes. In the first 2 screens, changing k computes x. In the Energy screen, changing k computes F.

In the Energy screen, there is no direct control of F, so the "changing F computes x" part of the model is not exercised. But it's still part of the model code.

@pixelzoom pixelzoom assigned kathy-phet and arouinfar and unassigned pixelzoom Jun 15, 2018
@pixelzoom
Copy link
Contributor

pixelzoom commented Jun 15, 2018

@arouinfar asked:

I'm not sure I completely follow @pixelzoom. Doesn't the Displacement slider set the value of the x in the model? The Applied Force is then calculated, and its displayed value is rounded to the nearest tenths place.

Correct, the displacement slider and robotic arm are both constrained to set x to values with at most 3 decimal places. So when interacting with the displacement slider or robotic arm, x values will have 3 decimal places in the model.

But values computed by the model (e.g. F is computed when dragging the robot arm changes x) are not similarly constrained to any number of decimal places, and computed values may contain floating-point error. If you want to constrain all model values to the same number of decimal places shown in the view, that is different (and more difficult) than simply controlling the number of decimal places used by view components to control and display values.

@kathy-phet
Copy link
Author

kathy-phet commented Jun 18, 2018 via email

@pixelzoom
Copy link
Contributor

pixelzoom commented Jun 18, 2018

I don’t want the model to display fewer decimals nor for PhET-io model values to be fewer decimals, but when the slider is set to 0.130, can you not have that set the model to 0.130000000 exactly?

UI controls do set their associated Properties to exact values. But as I stated above: ... values computed by the model (e.g. F is computed when dragging the robot arm changes x) are not similarly constrained to any number of decimal places, and computed values may contain floating-point error.

I agree F would have some non zeros down at the smallest decimals because of calculations, but not sure why x would need to.

If you drag a control that changes F, x will be computed. And depending on the values of F and k, x may contain some floating point error.

In Javascript:
0.1 + 0.2 = 0.30000000000000004
0.05 + 0.01 = 0.060000000000000005
Really.

@kathy-phet
Copy link
Author

kathy-phet commented Jun 18, 2018 via email

@pixelzoom
Copy link
Contributor

In case anyone is interested in where Javascript floating-point error comes from... This is the simplest explanation that I've been able to find: https://modernweb.com/what-every-javascript-developer-should-know-about-floating-points/.

@pixelzoom
Copy link
Contributor

@kathy-phet I'm not at all clear on what problem (specifically) you're trying to solve.

pixelzoom added a commit that referenced this issue Jun 19, 2018
Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
@pixelzoom
Copy link
Contributor

pixelzoom commented Jun 19, 2018

When a NumberProperty value in the model changes, its value is now printed to the browser console if you use the ?log query parameter.

There are 2 NumberProperties that (when computed) contain floating-point error that makes them have more decimal places than desired. Those 2 Properties are appliedForceProperty (F) and leftProperty (position of the left end of the robotic arm). So I'm perplexed about why we need to "disable the recalculation of x" in the Energy screen when I see no such recalculation of displacement occurring (that was addressed in #52 (comment)) and all values for displacement (in all screens) appear to have the desired number of decimal places (max 3).

pixelzoom added a commit that referenced this issue Jun 19, 2018
Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
pixelzoom added a commit that referenced this issue Jun 19, 2018
Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
pixelzoom added a commit that referenced this issue Jun 19, 2018
Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
@kathy-phet
Copy link
Author

kathy-phet commented Jun 19, 2018 via email

@pixelzoom
Copy link
Contributor

I really think we should table this issue until we can have a real discussion. Getting fragmented/unclear feedback based on no specific version is making me a little crazy and does not feel productive.

@pixelzoom pixelzoom removed their assignment Jul 18, 2018
@pixelzoom
Copy link
Contributor

Unassigning until we resume work on Hooke's Law.

@pixelzoom
Copy link
Contributor

8/16/18 design meeting:

We met about this. I'm going to undo the constraints on the model, and revisit this.

@pixelzoom pixelzoom assigned pixelzoom and unassigned kathy-phet Aug 16, 2018
@pixelzoom pixelzoom mentioned this issue Aug 16, 2018
7 tasks
@pixelzoom
Copy link
Contributor

In 8/16/18 design meeting, we decided that it unnecessary to constrain the number of decimal places in the model, and that it was OK to show model values (including possible floating point errors) in the PhET-iO data stream. To that end, I removed such constrains in #52 (comment). This addresses the problems that @arouinfar reported in #57 (comment).

In #60, we revised the intervals for slider thumbs and tweakers, the number of decimal places shown for values and tick marks, etc. Since this issue was originally about that topic, and has now been addressed, I'm going to close this issue.

@pixelzoom pixelzoom reopened this Aug 18, 2018
@pixelzoom
Copy link
Contributor

Reopening. There are still some problems here. For example, we added a decimal place to Spring Force. Shouldn't we then add an additional decimal place to Spring Force components for the parallel system?

pixelzoom added a commit that referenced this issue Aug 18, 2018
…ceDelta, #57

Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
pixelzoom added a commit that referenced this issue Aug 18, 2018
…57

Signed-off-by: Chris Malley <cmalley@pixelzoom.com>
@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 18, 2018

Model value constraints have been removed, the number of decimals for displayed values has been revised, and the slider/tweaker intervals have been revised.

Here are the current values, as implemented in HookesLawConstants:

    // number of decimal places for displayed values
    APPLIED_FORCE_DECIMAL_PLACES: 1,
    SPRING_FORCE_DECIMAL_PLACES: 1,
    SERIES_SPRING_FORCE_COMPONENTS_DECIMAL_PLACES: 1, // series system
    PARALLEL_SPRING_FORCE_COMPONENTS_DECIMAL_PLACES: 2, // parallel system
    SPRING_CONSTANT_DECIMAL_PLACES: 0,
    DISPLACEMENT_DECIMAL_PLACES: 3,
    ENERGY_DECIMAL_PLACES: 1,

    // slider thumb intervals
    APPLIED_FORCE_THUMB_INTERVAL: 5, // N
    SPRING_CONSTANT_THUMB_INTERVAL: 10, // N/m
    DISPLACEMENT_THUMB_INTERVAL: 0.05, // m

    // tweaker intervals
    APPLIED_FORCE_TWEAKER_INTERVAL: 1, // N
    SPRING_CONSTANT_TWEAKER_INTERVAL: 1, // N/m
    DISPLACEMENT_TWEAKER_INTERVAL: 0.01, // m

    // drag intervals
    ROBOTIC_ARM_DISPLACEMENT_INTERVAL: 0.05, // m, Energy screen only, see #54

These changes are present in 1.1.0-dev.12. @arouinfar please review.

Here's a scenario that feels a little weird, but is not incorrect based on the number of decimal places that we've chosen. Verify that you're OK with this.

  1. Go to Intro screen.
  2. Check the "Displacement" and "Values" checkboxes.
  3. Set Spring Constant to 300 N/m.
  4. Drag robotic arm as far to the right as possible, 0.333m.
  5. Note that Applied Force is 99.9 N (300 * 0.333 = 99.9)
  6. Press the right tweaker for Applied Force, setting it to 100 N.
  7. Note that Displacement does not change. (100 / 300 = 0.33333333... = 0.333)

@arouinfar arouinfar self-assigned this Aug 20, 2018
@arouinfar
Copy link
Contributor

@pixelzoom the updated thumb/tweaker intervals all look good to me. Agreed that PARALLEL_SPRING_FORCE_COMPONENTS_DECIMAL_PLACES should be 2.

Here's a scenario that feels a little weird, but is not incorrect based on the number of decimal places that we've chosen. Verify that you're OK with this.

This is OK with me. It's a consequence of the precision limits, and the values are being correctly rounded. Thanks for checking!

@pixelzoom
Copy link
Contributor

OK, we're done here. In summary, the model is unconstrained, and we revised the view.

@pixelzoom
Copy link
Contributor

This change has not been published. So reopening and labeling with "fixed-awaiting-deploy".

@pixelzoom
Copy link
Contributor

pixelzoom commented May 12, 2021

To summarize, there were 4 categories of things that were adjusted:

(1) the number of decimal places for quantities that are displayed
(2) the drag interval for slider thumbs
(3) the intervals for arrow buttons (aka tweakers)
(4) the drag interval for the robotic arm

For QA verification... Unless otherwise noted, verify the following on all 3 screens. Check the "Values" check box in each screen's control panel to see numeric values.

Intro Screen

Verify that number of decimal places is as follows:

  • Spring Constant: 0
  • Applied Force: 1
  • Displacement: 3
  • Spring Force: 1

Verify that dragging the slider thumb changes the associated value in these increments:

  • Spring Constant: 10 N/m
  • Applied Force: 5 N

Verify that pressing tweakers (aka, arrow buttons) changes the associated value in these increments:

  • Spring Constant: 1 N/m
  • Applied Force: 1 N

Finally, verify dragging the robotic arm:

  • Dragging the robotic arm on the Intro screen is continuous.

Systems Screen

Verify that number of decimal places is as follows:

  • Top Spring, Bottom Spring: 0
  • Applied Force: 1
  • Displacement: 3
  • Spring Force (Total radio button): 1
  • Spring Force (Components radio button) for the parallel system: 2
  • Spring Force (Components radio button) for the series system: 1

Verify that dragging the slider thumb changes the associated value in these increments:

  • Top Spring, Bottom Spring: 10 N/m
  • Applied Force: 5 N

Verify that pressing tweakers (aka, arrow buttons) changes the associated value in these increments:

  • Top Spring, Bottom Spring: 1 N/m
  • Applied Force: 1 N

Finally, verify dragging the robotic arm:

  • Dragging the robotic arm on the Systems screen is continuous.

Energy Screen

Verify that number of decimal places is as follows:

  • Spring Constant: 0
  • Applied Force: 1
  • Displacement: 3
  • Potential Energy: 1

Verify that dragging the slider thumb changes the associated value in these increments:

  • Spring Constant: 10 N/m
  • Displacement: 0.05 m

Verify that pressing tweakers (aka, arrow buttons) changes the associated value in these increments:

  • Spring Constants: 1 N/m
  • Displacement: 0.01 m

Finally, verify dragging the robotic arm:

  • Dragging the robotic arm on the Energy screen changes the displacement by increments of 0.05 m.

@liammulh
Copy link
Member

See the above checklist for what's been verified. Reassigning @pixelzoom.

@pixelzoom
Copy link
Contributor

Looks like everything passed, thanks @liam-mulhall. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants