-
Notifications
You must be signed in to change notification settings - Fork 6
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
PhET-iO instrumentation for particles #231
Comments
In the above commits, I instrumented the arrays of particles for the particle systems. The state of particles looks pretty good in the State wrapper - positions and velocities are tracked by the downstream sim. But I'm not convinced that this is totally correct -- sometimes the downstream sim seems to deviate. So there's likely more work to do here. I'd also like to take a stab at factoring a |
@zepumph noted that I should consider making Particle implement TPoolable. Since Particle is a base class that cannot be instantiated directly, this would require implementing TPoolable for its subclasses: HeavyParticle, LightParticle, DiffusionParticle1, DiffusionParticle2. |
Above I said:
Since there is randomness in the sim, it makes sense that there the downstream sim would deviated from the upstream sim when as they continue to run. They will be the same only at the moment when state is set in the downstream sim. |
To get the state of all particles for a specific screen, replace
For example, for the Ideal screen:
In Studio, see |
This is looking pretty good. I still have some questions for the PDL team (@samreid and @matthew-blackman) and @zepumph . But in the meantime, here's a dev version: |
In 5/13/24 discussion with PDL team, I noted that in the State wrapper, the Downstream sim pauses slightly each time that state is set. PDL exhibits this same behavior. I asked if the PDL team considered pooling for Projectiles, and @samreid said that they did not optimize for that. @samreid also did a quick test with GP in the State wrapper. GC doe not appear to be the issue. Most of the time is spent in Compared to other things that implement TPoolable (Vector2, Bounds2, Matrix3,...) GP has relatively few instances: 400 particles max in the Diffusion screen, 2000 particles max in the other screens. So... I'm not going to pursue pooling for particles. |
Design meeting 5/20/24 @arouinfar @kathy-phet @Nancy-Salpepi @matthew-blackman @pixelzoom We decided not to add a
Particles are already separated by type in the PhET-iO state. Adding a As @matthew-blackman demonstrated in #244, a wrapper can add type information if needed. For example in particleDataWrapper.html: const simulationReadings = {
'Particle speed': speedForParticle( particleData ),
'Particle KE': kineticEnergyForParticle( particleData ),
'Particle type': 'heavy',
'Stopwatch reading': stopwatchReading
}; |
Reviewed with @Nancy-Salpepi and the Particle arrays look good in the console and state appears to be restoring correctly. Closing. |
Reopening, I forgot to respond to @pixelzoom's question about
Let's feature |
|
Thanks @pixelzoom, looks good on main. Closing. |
Reopening because there is a TODO marked for this issue. |
Use the same approach as projectile-data-lab, see: Projectile, ProjectileIO, Field, FieldIO. Check in with them to confirm how I apply this pattern.
Replace Particle's
Vector2
fields (position, previousPositive, velocity) withnumber
x,y fields, so that ParticleIO will be a flat data structure.Add ParticleIO, IdealGasLawParticleSystemIO, and DiffusionParticleSystemlO to handle serialization.
Identify other places where Particle serialization is needed.
Since this work requires fundamental chances to Particle, there is high risk for introducing regressions. For reference, 1.1.0-dev.12 was published on 5/1, before this work was started:
The text was updated successfully, but these errors were encountered: