diff --git a/src/Chemistry/Bonds/Implements/BaseBond.cs b/src/Chemistry/Bonds/Implements/BaseBond.cs index aa34878..11a1d50 100644 --- a/src/Chemistry/Bonds/Implements/BaseBond.cs +++ b/src/Chemistry/Bonds/Implements/BaseBond.cs @@ -148,7 +148,17 @@ public abstract class BaseBond /// public CacheItem LogState { get; } - + public bool DisconnectCondition + { + get + { + SU3 x = Compound.HomogeneousMixture.StateMatrix.Get * StateMatrix.Get.Hermitian(); + DiagR3 w = new DiagR3(-Math.PI, 1, Math.E); + double y = x.ConjugateOn(w).Rayleigh((x + LogKernel.Get).ColumnAverageBivariant); + double z = StateMatrix.Get.ConjugateOn(w).Rayleigh(LogKernel.Get.ColumnAverageBivariant); + return y > z; + } + } /// diff --git a/src/Chemistry/Mixtures/Implements/HeterogeneousMixture.cs b/src/Chemistry/Mixtures/Implements/HeterogeneousMixture.cs index 90eb146..23e49d1 100644 --- a/src/Chemistry/Mixtures/Implements/HeterogeneousMixture.cs +++ b/src/Chemistry/Mixtures/Implements/HeterogeneousMixture.cs @@ -155,7 +155,7 @@ public class HeterogeneousMixture } } - public void RemoveTop() + public void RemoveBottom() { if (Layers.Count == 0) return; @@ -164,7 +164,7 @@ public class HeterogeneousMixture } - public void RemoveBottom() + public void RemoveTop() { if (Layers.Count == 0) return; diff --git a/src/Chemistry/Mixtures/Implements/HomogeneousMixture.cs b/src/Chemistry/Mixtures/Implements/HomogeneousMixture.cs index 3bfea10..1d7b8d2 100644 --- a/src/Chemistry/Mixtures/Implements/HomogeneousMixture.cs +++ b/src/Chemistry/Mixtures/Implements/HomogeneousMixture.cs @@ -88,11 +88,6 @@ public class HomogeneousMixture foreach (BaseBond b in c.Bonds) { - if (b.Compound.Amount.IsEqualApprox(0)) - throw new Exception("P??"); - - if (b.Compound != c) - throw new Exception("??!!?"); if ( b.Connected && b.Energy > b.AntiBondingEnergy && @@ -388,29 +383,7 @@ public class HomogeneousMixture /// public double Ratio => Amount / (HeterogeneousMixture == HeterogeneousMixture.Null ? Amount : HeterogeneousMixture.Amount); - - /// - /// - /// - /// - public void Resolve(HomogeneousMixture homo) - { - foreach (Compound c in homo.Compounds) - Resolve(c, false); - ResetAllCache(); - - } - - /// - /// - /// - /// - /// - public void Resolve(Compound compound, bool resetCache = true) - { - AddCompound(compound, resetCache); - } /// /// density of the mixture, amount of molecular per volume @@ -504,16 +477,12 @@ public class HomogeneousMixture Compound oth = xb2.Compound.Split(amountDiff); xb2.HomogeneousMixture.AddCompound(oth); } - - string log = $"From Composite React of {xb1.Compound.Amount}*{xb1.Compound.Expression} and {xb2.Compound.Amount}*{xb2.Compound.Expression}"; - xb1.Connect(xb2); - xb1.Compound.TraceLog.Add(log); } private int ReactionType() { - Complex d = LogStateMatrix.Get.CayleyPositive().Det(); + Complex d = StateMatrix.Get.Trace(); return d.Phase switch { > 7 * Math.PI / 4 or < Math.PI / 4 => 0, @@ -535,7 +504,9 @@ public class HomogeneousMixture continue; if ( bond.Energy > bond.AntiBondingEnergy && - bond.ConnectedBond.Energy > bond.ConnectedBond.AntiBondingEnergy + bond.ConnectedBond.Energy > bond.ConnectedBond.AntiBondingEnergy && + bond.DisconnectCondition && + bond.ConnectedBond.DisconnectCondition ) { bond.Disconnect(); @@ -704,7 +675,6 @@ public class HomogeneousMixture toAbsorb.Add((c, c.Amount)); continue; } - double maxResAmount = Amount; foreach (Compound ct in Compounds) if (ct.IsometricTo(c)) @@ -716,8 +686,6 @@ public class HomogeneousMixture if(splitAmount.IsEqualApprox(0)) continue; toAbsorb.Add((c, splitAmount)); - //Compound cSplit = c.Split(splitAmount); - //toAbsorb.Add(cSplit); } foreach ((Compound c, double a) in toAbsorb) { @@ -841,11 +809,4 @@ public class HomogeneousMixture } } - public static void Test() - { - Func a = x => -Math.Tan((Math.PI * x - Math.PI) / 2); - Console.WriteLine(a(0)); - Console.WriteLine(a(-1)); - Console.WriteLine(a(1)); - } }