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

Chaining decay methods on Nucleus sometimes creates duplicate nucleons #16

Open
Frencil opened this issue May 11, 2015 · 0 comments
Open
Labels

Comments

@Frencil
Copy link
Owner

Frencil commented May 11, 2015

To reproduce:

var carbon9 = new Nucleus(matter.elements[6].nuclides[3]).appendTo(d3.select("svg"));
carbon9.alphaDecay().betaDecay();

Chaining alpha and beta decays together on a Carbon-9 nucleus should result in a Lithium-5 (three protons, two neutrons) and about half the time this is what happens. However, about half the time, what remains is a nucleus with four protons and two neutrons (technically a Beryllium-5). Inspecting the elements makes it clear that the daughter neutron from the beta decay is not present and one of the neutrons is duplicated. That is, the nucleus group in the SVG has two child proton groups with the same ID.

The fact that this happens intermittently could point to a race condition. Either way it's unclear how one proton would be generated twice in the SVG and the daughter neutron not at all, despite the Nucleus.particles object/array looking correct 100% of the time.

As a stopgap, the method Nucleus.prototype.restart() currently has a line that removes all child elements from the nucleon selector before redefining the child nodes:

nucleus.nucleons_selector.selectAll("g.nucleon").remove();

This is not a clean solution. It fails to reuse SVG elements efficiently and, especially for larger nuclides, can result in a momentary but visible instance of the entire nuclide disappearing in order to be redrawn.

@Frencil Frencil added the bug label May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant