phetsims / pendulum-lab

"Pendulum Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
4 stars 10 forks source link

Period length inconsistent #94

Closed phet-steele closed 8 years ago

phet-steele commented 9 years ago

Between multiple trials in the Lab screen using the period timer, the length of the period should be the same each time if conditions are not changed. However, each trial performed in 1.0.0-dev.4 returns a different period length.

1st Trial: period trial 1

2nd Trial: period trial 2

Additionally, under the same conditions as a trial in the flash version, the HTML5 version should match the flash's period time, but there are variations between the two.

Flash (with same conditions as above): flash period

Tested on Win 8.1 browsers Troubleshooting information: Name: Pendulum Lab URL: http://www.colorado.edu/physics/phet/dev/html/pendulum-lab/1.0.0-dev.4/pendulum-lab_en.html Version: 1.0.0-dev.4 2015-06-04 17:46:07 UTC Features missing: touch User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0 Language: en-US Window: 1366x633 Pixel Ratio: 1/1 WebGL: WebGL 1.0 GLSL: WebGL GLSL ES 1.0 Vendor: Mozilla (Mozilla) Vertex: attribs: 16 varying: 28 uniform: 1024 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 32767x32767 OES_texture_float: true Dependencies JSON: {"comment":"# pendulum-lab 1.0.0-dev.4 Thu Jun 04 2015 11:46:00 GMT-0600 (MDT)","assert":{"sha":"903564a25a0f26acdbd334d3e104039864b405ef","branch":"master"},"axon":{"sha":"7de4a27be4b322b71c5f5046df193a03ccf0f161","branch":"master"},"babel":{"sha":"8725cd18114c1307057c465a0762a3cf8f1cb1b9","branch":"master"},"brand":{"sha":"b3362651f1d7eddb7f8697d02400472f97f9d140","branch":"master"},"chipper":{"sha":"c7d6ea5f9bef6e3882309af56ad409908dd28878","branch":"master"},"dot":{"sha":"a6a50c92c4cda5f8a3371d8c357ea565b7e7bd6c","branch":"master"},"joist":{"sha":"55fd6884039c5ef2f2145093c8530beab5490233","branch":"master"},"kite":{"sha":"b915f3b160744e4833d177dc38e74e4cbc912883","branch":"master"},"pendulum-lab":{"sha":"2b4cf70e4a8a88b37882b1643d44155a806508ab","branch":"master"},"phet-core":{"sha":"23834d107dc1cb368c00901c76927b712b9caa10","branch":"master"},"phetcommon":{"sha":"bb92c52cd90fdaa0c2a746fea82594afd439b4db","branch":"master"},"scenery":{"sha":"f09eddb7393946fcbedb63ebf6b88d1785c91bfc","branch":"master"},"scenery-phet":{"sha":"7ffc5a1a36e0afe36d035d0367078b3558fd157f","branch":"master"},"sherpa":{"sha":"ae2168a85ceb4094c23cd47ba5fe8145375448eb","branch":"master"},"sun":{"sha":"c9087fbb0cdd83f79452330fec3b83f809e2c0d8","branch":"master"}}

andrey-zelenkov commented 9 years ago

All animation updates (including pendulum motion and timer tick) made through special "step" function. Precision of timer tick directly depend on frequency of "step" function calls. For my pc this precision can hesitate from 0.012s to 0.05s and it leads to different measurement results. For #93 same situation. We can try to split this tick into many small ticks within sim to increase precision (like it was made for gravity-and-orbits) but it probably kill performance, that critical for tablets. Should it be implemented?

arouinfar commented 9 years ago

Thanks for your input, @andrey-zelenkov. @ariel-phet, can you please take a look at this issue and comment? Would it be possible to split the tick in half rather than many small ticks? Perhaps that would improve the precision of the period timer without tanking performance.

jonathanolson commented 8 years ago

After rewriting the core model, it's much much more consistent, but is still occasionally off. I haven't touched the period-recording code, so I'll take a look there next.

jonathanolson commented 8 years ago

This is also super-obvious if you use the step button to move the model forwards.

jonathanolson commented 8 years ago

Will plan to add precise emitted events from the pendulum model for when it crosses the 0-angle AND when it turns around (with computed timestamps and direction information).

PeriodTrace will be mostly rewritten to take those as input, storing the proper maximum angles.

jonathanolson commented 8 years ago

Period testing with new method:

normal: (steps ~16ms, e.g. runge-kutta every 1.6ms) 2.5001977142680523 2.500197713160823 2.5001977164903697 2.500197714112651 2.500197714225982 2.5001977136204485

step button: (steps 250ms, runge-kutta steps 25ms at a time + interpolation of crossing time) 2.5001980285900767 2.5001980172768867 2.500198002549144 2.5001979917706394 2.5001979812211825 2.5001979709007127 2.5001979608091704

slow motion: (steps 2ms, runge-kutta every 0.2ms) 2.5001976759436797 2.5001976759447038 2.5001976759323385 2.50019767595233 2.5001976759450577

Thus even with 500ms (maximum step size, double the 'step button' size), it looks like we'll get acceptable consistency for the period trace to always report the same number (e.g. 2.5002 in this case).

jonathanolson commented 8 years ago

Fixed, as described above.