Fix PureResolve
This commit is contained in:
@@ -113,7 +113,6 @@ public class Compound
|
|||||||
Array.Empty<BaseBond>():
|
Array.Empty<BaseBond>():
|
||||||
Bonds.Where(bond => !bond.Connected && bond.Energy > bond.BondingEnergy);
|
Bonds.Where(bond => !bond.Connected && bond.Energy > bond.BondingEnergy);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// string used to save the compound
|
/// string used to save the compound
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -161,6 +160,7 @@ public class Compound
|
|||||||
.Select(group => $"{group.First().Element}"+ (group.Count() > 1 ? group.Count().ToString() : "") )
|
.Select(group => $"{group.First().Element}"+ (group.Count() > 1 ? group.Count().ToString() : "") )
|
||||||
.DefaultIfEmpty("")
|
.DefaultIfEmpty("")
|
||||||
.Aggregate((a, b) => a + b);
|
.Aggregate((a, b) => a + b);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// dump the compound into save string
|
/// dump the compound into save string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -175,7 +175,6 @@ public class Compound
|
|||||||
atomMap[atom] = $"({atom.Element}.{atomMap.Count})";
|
atomMap[atom] = $"({atom.Element}.{atomMap.Count})";
|
||||||
foreach (BaseBond bond in Bonds.Where(bond => bond.Connected))
|
foreach (BaseBond bond in Bonds.Where(bond => bond.Connected))
|
||||||
bondMap[bond] = $"<{bond.BondType}.{bondMap.Count}>";
|
bondMap[bond] = $"<{bond.BondType}.{bondMap.Count}>";
|
||||||
|
|
||||||
foreach (BaseAtom atom in Atoms)
|
foreach (BaseAtom atom in Atoms)
|
||||||
{
|
{
|
||||||
if (atom.Bonds.All(bond => !bond.Connected))
|
if (atom.Bonds.All(bond => !bond.Connected))
|
||||||
@@ -183,7 +182,6 @@ public class Compound
|
|||||||
records.Add($"{atomMap[atom]}-<xxx.0>-<xxx.0>-(xxx.0)");
|
records.Add($"{atomMap[atom]}-<xxx.0>-<xxx.0>-(xxx.0)");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (BaseBond bond in atom.Bonds.Where(bond => bond.Connected))
|
foreach (BaseBond bond in atom.Bonds.Where(bond => bond.Connected))
|
||||||
{
|
{
|
||||||
if (bond == bond.ConnectedBond)
|
if (bond == bond.ConnectedBond)
|
||||||
@@ -474,4 +472,8 @@ public class Compound
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CacheItem<double> FreeDensity { get; }
|
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();
|
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
|
/// higher level mixture can resolve lower level mixture
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double ResolveLevel => Compounds.Sum(c => c.Concentration * c.ResolveLevel);
|
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>
|
/// <summary>
|
||||||
/// ability to resolve other compound
|
/// ability to resolve other compound
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -632,10 +680,17 @@ public class HomogeneousMixture
|
|||||||
HashSet<Compound> toAbsorb = new ();
|
HashSet<Compound> toAbsorb = new ();
|
||||||
foreach (Compound c in hOther.Compounds)
|
foreach (Compound c in hOther.Compounds)
|
||||||
{
|
{
|
||||||
double maxRes = Resolvability(c);
|
double eigenRes = EigenResolvability(c);
|
||||||
|
double maxRes = Resolvability(eigenRes);
|
||||||
double oRes = hOther.Resolvability(c);
|
double oRes = hOther.Resolvability(c);
|
||||||
if(oRes < 0 || maxRes < 0 || maxRes < oRes)
|
if(oRes < 0 || maxRes < oRes)
|
||||||
continue;
|
continue;
|
||||||
|
if (eigenRes.IsEqualApprox(0))
|
||||||
|
{
|
||||||
|
toAbsorb.Add(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
double maxResAmount = Amount;
|
double maxResAmount = Amount;
|
||||||
foreach (Compound ct in Compounds)
|
foreach (Compound ct in Compounds)
|
||||||
if (ct.IsometricTo(c))
|
if (ct.IsometricTo(c))
|
||||||
@@ -652,7 +707,12 @@ public class HomogeneousMixture
|
|||||||
toAbsorb.Add(cSplit);
|
toAbsorb.Add(cSplit);
|
||||||
}
|
}
|
||||||
foreach (Compound c in toAbsorb)
|
foreach (Compound c in toAbsorb)
|
||||||
|
{
|
||||||
|
double v = c.Volume;
|
||||||
|
hOther.Volume -= v;
|
||||||
|
Volume += v;
|
||||||
AddCompound(c);
|
AddCompound(c);
|
||||||
|
}
|
||||||
if(hOther.Amount.IsEqualApprox(0))
|
if(hOther.Amount.IsEqualApprox(0))
|
||||||
HeterogeneousMixture.RemoveLayer(hOther);
|
HeterogeneousMixture.RemoveLayer(hOther);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user