Improve reactor controls, reactions, and maintenance UI

This commit is contained in:
Codex Agent
2025-11-22 18:04:36 +01:00
parent d37620ccc1
commit 863060ee78
15 changed files with 447 additions and 14 deletions

54
tests/test_atomic.py Normal file
View File

@@ -0,0 +1,54 @@
from reactor_sim.atomic import AtomicPhysics, make_atom
def test_alpha_decay_reduces_mass_and_charge():
physics = AtomicPhysics(seed=1)
parent = make_atom(92, 143)
event = physics.alpha_decay(parent)
daughter, alpha = event.products
assert daughter.protons == 90
assert daughter.neutrons == 141
assert alpha.protons == 2 and alpha.neutrons == 2
assert "alpha" in event.emitted_particles
assert event.energy_mev > 0
def test_beta_minus_conserves_mass_number():
physics = AtomicPhysics(seed=2)
parent = make_atom(26, 30)
event = physics.beta_minus_decay(parent)
(daughter,) = event.products
assert daughter.mass_number == parent.mass_number
assert daughter.protons == parent.protons + 1
assert "beta-" in event.emitted_particles
def test_beta_plus_and_electron_capture_lower_proton_count():
physics = AtomicPhysics(seed=3)
parent = make_atom(15, 16)
beta_plus = physics.beta_plus_decay(parent)
capture = physics.electron_capture(parent)
assert beta_plus.products[0].protons == parent.protons - 1
assert capture.products[0].protons == parent.protons - 1
assert "beta+" in beta_plus.emitted_particles
assert "gamma" in capture.emitted_particles
def test_gamma_emission_keeps_nuclide_same():
physics = AtomicPhysics(seed=4)
parent = make_atom(8, 8)
event = physics.gamma_emission(parent, energy_mev=0.3)
(product,) = event.products
assert product == parent
assert "gamma" in event.emitted_particles
assert event.energy_mev == 0.3
def test_spontaneous_fission_creates_two_fragments():
physics = AtomicPhysics(seed=5)
parent = make_atom(92, 143)
event = physics.spontaneous_fission(parent)
assert len(event.products) == 2
total_mass = sum(atom.mass_number for atom in event.products)
assert total_mass <= parent.mass_number
assert event.energy_mev > 0