public AtomWithOrbitals(int protons, int neutrons) : base(protons, neutrons) { Orbitals = OrbitalGenerator.Generate(this, Period + 1); FormalCharge = (Protons - Electrons.Count()) * PhysicalConstants.ElementaryCharge; EffectiveCharge = FormalCharge; PopulateOrbitalsInGroundState(); ExcitateForMaximalBondAvailability(); }
public void AddBondElectron(Electron electron) { if (IsFull) { throw new ChemistryException("Adding a third electron to an orbital is forbidden"); } if (IsEmpty) { throw new ChemistryException("Adding a bond electron to an empty orbital sounds like an error..."); } var existingElectron = Electrons[0]; if (existingElectron.Spin == electron.Spin) { electron.Spin = existingElectron.Spin.Invert(); } Electrons.Add(electron); }
public Electron RemoveElectron() { if (!Electrons.Any()) { throw new ChemistryException("Cannot remove electron from empty orbital"); } var downSpinElectron = Electrons.SingleOrDefault(e => e.Spin == SpinType.Down); if (downSpinElectron != null) { Electrons.Remove(downSpinElectron); downSpinElectron.AssociatedOrbital = null; return(downSpinElectron); } var upSpinElectron = Electrons[0]; Electrons.Remove(upSpinElectron); upSpinElectron.AssociatedOrbital = null; return(upSpinElectron); }
public void AddElectron(Electron electron) { if (IsFull) { throw new ChemistryException("Adding a third electron to an orbital is forbidden"); } if (electron.AssociatedOrbital != null) { throw new ChemistryException("Cannot add electron to orbital which is already associated to another orbital"); } if (!IsEmpty) { var existingElectron = Electrons[0]; if (existingElectron.Spin == electron.Spin) { electron.Spin = existingElectron.Spin.Invert(); } } Electrons.Add(electron); electron.AssociatedOrbital = this; }
public void BreakBond() { Electrons.RemoveAll(electron => !ReferenceEquals(electron.AssociatedOrbital, this)); Electrons.ForEach(e => e.AssociatedBond = null); AssociatedBond = null; }