add: measurements
This commit is contained in:
43
src/HeterogeneousMixture.cs
Normal file
43
src/HeterogeneousMixture.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Skeleton.DataStructure.Link;
|
||||
|
||||
namespace Hermeteus;
|
||||
|
||||
public class HeterogeneousMixture
|
||||
{
|
||||
public HeterogeneousMixture()
|
||||
{
|
||||
Layers = new Link<HomogeneousMixture>();
|
||||
}
|
||||
|
||||
internal Link<HomogeneousMixture> Layers { get; }
|
||||
public double ExternalTemperature { get; internal set; }
|
||||
|
||||
|
||||
public void React()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void HeatExchange()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Precipitate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Stand()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal void Add(HeterogeneousMixture m)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Hermeteus.Measurements;
|
||||
|
||||
namespace Hermeteus;
|
||||
|
||||
public class HomogeneousMixture
|
||||
@@ -5,6 +7,7 @@ public class HomogeneousMixture
|
||||
public HomogeneousMixture()
|
||||
{
|
||||
Components = new Dictionary<Molecule, double>();
|
||||
Energy = 0;
|
||||
}
|
||||
|
||||
internal Dictionary<Molecule, double> Components { get; }
|
||||
@@ -14,12 +17,17 @@ public class HomogeneousMixture
|
||||
.Aggregate((a, b) => a + b)
|
||||
.Exp();
|
||||
|
||||
public double Amount => Components.Sum(p => p.Value);
|
||||
|
||||
public double Ratio(Molecule m) => Amount == 0
|
||||
public double Ratio(Molecule m) => this.Amount() == 0
|
||||
? 0
|
||||
: Components.GetValueOrDefault(m, 0) / Amount;
|
||||
: Components.GetValueOrDefault(m, 0) / this.Amount();
|
||||
|
||||
public double Energy { get; internal set; }
|
||||
|
||||
public double Temperature
|
||||
{
|
||||
get => Energy / this.Amount();
|
||||
internal set => Energy = value * this.Amount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,22 @@ public static partial class Measurement
|
||||
.Select(p => p.Key.MolecularMass() * p.Value)
|
||||
.Sum();
|
||||
|
||||
public static double Density(this HomogeneousMixture h) =>
|
||||
public static double MolecularDensity(this HomogeneousMixture h) =>
|
||||
h.Components.Keys
|
||||
.Select(x => x.MolecularDensity() * h.Ratio(x))
|
||||
.Sum();
|
||||
|
||||
public static double Amount(this HomogeneousMixture h) =>
|
||||
h.Components.Sum(x => x.Value);
|
||||
|
||||
public static double IntrinsicDensity(this HomogeneousMixture h)
|
||||
{
|
||||
H3 w = (BlueFilter * h.EigenState * OpacityFilter).ConjugateOn(new DiagR3(
|
||||
Math.E / 8, Math.E, Math.E * 2
|
||||
));
|
||||
return w.Rayleigh(w.ColumnAverage + h.EigenState.ColumnAverage);
|
||||
}
|
||||
|
||||
public static double IntrinsicVolume(this HomogeneousMixture h) =>
|
||||
h.Mass() / h.IntrinsicDensity();
|
||||
}
|
||||
|
||||
15
src/Measurements/Energy.cs
Normal file
15
src/Measurements/Energy.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Hermeteus.Measurements;
|
||||
|
||||
public static partial class Measurements
|
||||
{
|
||||
public static double HeatCapacity(this HomogeneousMixture m)
|
||||
{
|
||||
H3 w = m.EigenState.Log().CayleyNegative().ConjugateOn(new DiagR3(0d, 0.5d, 1d));
|
||||
return w.Rayleigh(m.EigenState.ColumnAverageBivariant);
|
||||
}
|
||||
|
||||
public static double Phase(this HomogeneousMixture m) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user