Fix PureResolve
This commit is contained in:
@@ -113,7 +113,6 @@ public class Compound
|
||||
Array.Empty<BaseBond>():
|
||||
Bonds.Where(bond => !bond.Connected && bond.Energy > bond.BondingEnergy);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// string used to save the compound
|
||||
/// </summary>
|
||||
@@ -161,6 +160,7 @@ public class Compound
|
||||
.Select(group => $"{group.First().Element}"+ (group.Count() > 1 ? group.Count().ToString() : "") )
|
||||
.DefaultIfEmpty("")
|
||||
.Aggregate((a, b) => a + b);
|
||||
|
||||
/// <summary>
|
||||
/// dump the compound into save string
|
||||
/// </summary>
|
||||
@@ -175,7 +175,6 @@ public class Compound
|
||||
atomMap[atom] = $"({atom.Element}.{atomMap.Count})";
|
||||
foreach (BaseBond bond in Bonds.Where(bond => bond.Connected))
|
||||
bondMap[bond] = $"<{bond.BondType}.{bondMap.Count}>";
|
||||
|
||||
foreach (BaseAtom atom in Atoms)
|
||||
{
|
||||
if (atom.Bonds.All(bond => !bond.Connected))
|
||||
@@ -183,7 +182,6 @@ public class Compound
|
||||
records.Add($"{atomMap[atom]}-<xxx.0>-<xxx.0>-(xxx.0)");
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (BaseBond bond in atom.Bonds.Where(bond => bond.Connected))
|
||||
{
|
||||
if (bond == bond.ConnectedBond)
|
||||
@@ -474,4 +472,8 @@ public class Compound
|
||||
///
|
||||
/// </summary>
|
||||
public CacheItem<double> FreeDensity { get; }
|
||||
|
||||
public double FreeVolume => Amount / FreeDensity.Get;
|
||||
|
||||
public double Volume => HomogeneousMixture.Volume * Concentration;
|
||||
}
|
||||
@@ -154,5 +154,22 @@ public class HeterogeneousMixture
|
||||
h.HeatExchange();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveTop()
|
||||
{
|
||||
if (Layers.Count == 0)
|
||||
return;
|
||||
HomogeneousMixture x = LayerOrder.First.Value;
|
||||
RemoveLayer(x);
|
||||
|
||||
}
|
||||
|
||||
public void RemoveBottom()
|
||||
{
|
||||
if (Layers.Count == 0)
|
||||
return;
|
||||
HomogeneousMixture x = LayerOrder.Last.Value;
|
||||
RemoveLayer(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -564,6 +564,54 @@ public class HomogeneousMixture
|
||||
/// higher level mixture can resolve lower level mixture
|
||||
/// </summary>
|
||||
public double ResolveLevel => Compounds.Sum(c => c.Concentration * c.ResolveLevel);
|
||||
/// <summary>
|
||||
/// eigen resolvability of other mixture
|
||||
/// </summary>
|
||||
/// <param name="oth"></param>
|
||||
/// <returns></returns>
|
||||
public double EigenResolvability(HomogeneousMixture oth)
|
||||
{
|
||||
LieSU3 s = oth.LogStateMatrix.Get ^ LogStateMatrix.Get;
|
||||
C3 a = new(1, 0.5, 1);
|
||||
C3 b = new(0.5, 1, 0.5);
|
||||
Complex w = a * s * b;
|
||||
ComplexFieldStructure.Structure.Fix(w);
|
||||
double res = w.Phase;
|
||||
if (res > Math.PI)
|
||||
res = 2 * Math.PI - res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// eigen resolvability from -pi to pi
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public double EigenResolvability(Compound c)
|
||||
{
|
||||
LieSU3 s = c.LogStateMatrix.Get ^ LogStateMatrix.Get;
|
||||
C3 a = new(1, 0.5, 1);
|
||||
C3 b = new(0.5, 1, 0.5);
|
||||
Complex w = a * s * b;
|
||||
w = ComplexFieldStructure.Structure.Fix(w);
|
||||
double res = w.Phase;
|
||||
if (res > Math.PI)
|
||||
res = 2 * Math.PI - res;
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// calculate resolvability from eigen resolvability
|
||||
/// </summary>
|
||||
/// <param name="eigenRes"></param>
|
||||
/// <returns></returns>
|
||||
public double Resolvability(double eigenRes)
|
||||
{
|
||||
double res = -Math.Tan((Math.Sin(eigenRes) * Math.PI - Math.PI) / 2);
|
||||
if (Math.Abs(res) < 1E-6)
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ability to resolve other compound
|
||||
/// </summary>
|
||||
@@ -632,10 +680,17 @@ public class HomogeneousMixture
|
||||
HashSet<Compound> toAbsorb = new ();
|
||||
foreach (Compound c in hOther.Compounds)
|
||||
{
|
||||
double maxRes = Resolvability(c);
|
||||
double eigenRes = EigenResolvability(c);
|
||||
double maxRes = Resolvability(eigenRes);
|
||||
double oRes = hOther.Resolvability(c);
|
||||
if(oRes < 0 || maxRes < 0 || maxRes < oRes)
|
||||
if(oRes < 0 || maxRes < oRes)
|
||||
continue;
|
||||
if (eigenRes.IsEqualApprox(0))
|
||||
{
|
||||
toAbsorb.Add(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
double maxResAmount = Amount;
|
||||
foreach (Compound ct in Compounds)
|
||||
if (ct.IsometricTo(c))
|
||||
@@ -652,7 +707,12 @@ public class HomogeneousMixture
|
||||
toAbsorb.Add(cSplit);
|
||||
}
|
||||
foreach (Compound c in toAbsorb)
|
||||
{
|
||||
double v = c.Volume;
|
||||
hOther.Volume -= v;
|
||||
Volume += v;
|
||||
AddCompound(c);
|
||||
}
|
||||
if(hOther.Amount.IsEqualApprox(0))
|
||||
HeterogeneousMixture.RemoveLayer(hOther);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user