phetsims / neuron

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

Clearing potential chart after rewind produces strange repeating plot. #92

Closed orejolaphet closed 8 years ago

orejolaphet commented 9 years ago

Possibly related to issue https://github.com/phetsims/neuron/issues/91 Occurs on FF, Safari, and Chrome If you stimulate the neuron, then pause immediately when the "ring" hits the membrane and rewind to the state right before the neuron is stimulated. Clearing the Potential Chart then hitting play returns the potential chart to plot the the state immediately after you paused then draws as if it was stimulated again. The sim also displayed all of the charged particles moving through the membrane after play even though you rewound to the state prior to stimulation.

To reproduce: -Open sim -Stimulate Neuron -Pause at this point

screen shot 2015-10-13 at 11 16 44 am

-Rewind simulation (click back about 15 times) -Open Potential Chart -Clear Potential Chart -Play simulation

The potential plot looks like this:

screen shot 2015-10-13 at 11 07 47 am
jbphet commented 8 years ago

I just tested this scenario against the Java version of the simulation, and that version also exhibits the behavior described by this issue.

jbphet commented 8 years ago

The basic problem that caused this issue was that the code was written assuming that the simulation would eventually resume running from the place where it had been paused and stepped back from. The use case of pausing, stepping back, and then clearing the chart (which also clears the recorded data) was never really considered. In order to handle this case, I needed to add the ability to capture and the state of the underlying Hodgkin-Huxley model, capture more complete state information from the membrane channels, use events to signal changes in the traveling action potential rather than toggling properties (which wasn't a good idea anyway), and clear out cached particle data if and when recorded history is cleared. In the process of doing this, I did some additional code cleanup. I've done a fairly extensive amount of testing for this issue and regression testing of the sim in general, and so far all looks good.

ariel-phet commented 8 years ago

Appears fixed in 1.0.0-rc.1. Closing