phetsims / build-a-nucleus

"Build a Nucleus" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 5 forks source link

He-4 forms after an alpha decay on Be-6 #210

Closed Luisav1 closed 1 year ago

Luisav1 commented 1 year ago

While working on making Be-6 have an alpha decay as the most likely decay in #208, I noticed that He-4 automatically forms after Be-6 alpha decays. Since Be-6 alpha decaying leaves 2 protons (He-2) which doesn't exist so those protons are then emitted.

Sometimes, after these 2 protons are emitted the sim reforms He-4, trying to fix the "bad state". I couldn't get a video but here's a screenshot of 2 mini protons still leaving and He-4 is already formed: Screenshot 2023-10-10 155917

This happens on both screens. The most likely way to reproduce it is by doing an alpha decay on Be-6, then making Be-6 again and alpha decaying again. The second alpha decay on Be-6 is where He-4 automatically forms.

Luisav1 commented 1 year ago

After investigating with @zepumph, we realized the reason this is happening is because in the step() in BANScreenView here we rearrange particles back to the old state. The cases where the particle does rearrange is when this BANConstants.TIME_TO_SHOW_DOES_NOT_EXIST is shorter than the time the alpha particle takes to be removed off the screen. https://github.com/phetsims/build-a-nucleus/blob/bbd8605b90cd1f8e88e7afc9f262ff8d43d90951/js/common/view/BANScreenView.ts#L381-L387

The solution we are going for is to add a boolean flag that would prevent this portion in the step function from running if you're in the He-2 case after an alpha decay on Be-6.

zepumph commented 1 year ago

I believe this is the last issue left before next RC. @Luisav1 has a working copy with some good stuff in it. I'll assign her. Let me know if you want to talk through any part of it.

Luisav1 commented 1 year ago

This is now fixed in the commit above which was copied over to the RC branch 1.1 too. Keeping it open so QA can verify this is fixed in the next RC.

zepumph commented 1 year ago

For QA:

This bug was specific to Beryllium 6 on the first screen (because you need to alpha decay the nuclide into a non-existent atom). It was a race condition when an alpha particle decayed and was disposed before the other two protons split away.

The bug is fixed now because no matter what, we will dispose the alpha particle and the two other protons correctly. But do let us know if you see any trouble! Feel free to close.

KatieWoe commented 1 year ago

I haven't been able to reproduce this bug in rc.2