This commit is contained in:
h z
2024-06-27 22:58:30 +08:00
parent 68682f38ab
commit bf32587520
3 changed files with 17 additions and 46 deletions

View File

@@ -148,7 +148,17 @@ public abstract class BaseBond
/// </summary>
public CacheItem<LieSU3> 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;
}
}
/// <summary>

View File

@@ -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;

View File

@@ -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
/// </summary>
public double Ratio =>
Amount / (HeterogeneousMixture == HeterogeneousMixture.Null ? Amount : HeterogeneousMixture.Amount);
/// <summary>
///
/// </summary>
/// <param name="homo"></param>
public void Resolve(HomogeneousMixture homo)
{
foreach (Compound c in homo.Compounds)
Resolve(c, false);
ResetAllCache();
}
/// <summary>
///
/// </summary>
/// <param name="compound"></param>
/// <param name="resetCache"></param>
public void Resolve(Compound compound, bool resetCache = true)
{
AddCompound(compound, resetCache);
}
/// <summary>
/// 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<double, double> a = x => -Math.Tan((Math.PI * x - Math.PI) / 2);
Console.WriteLine(a(0));
Console.WriteLine(a(-1));
Console.WriteLine(a(1));
}
}