96 lines
3.3 KiB
C#
96 lines
3.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Skeleton.Algebra.Extensions;
|
|
using VirtualChemistry.Chemistry.Atoms.Implements;
|
|
using VirtualChemistry.Chemistry.Atoms.Resolver;
|
|
using VirtualChemistry.Chemistry.Bonds.Implements;
|
|
using VirtualChemistry.Chemistry.Compounds.Implements;
|
|
using VirtualChemistry.Chemistry.Containers;
|
|
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
|
|
|
namespace VirtualChemistry.Test;
|
|
|
|
public static class BondConnectionTest
|
|
{
|
|
private class Container : IChemicalContainer
|
|
{
|
|
public Container(HeterogeneousMixture h) => Content = h;
|
|
public double Volume() => 200;
|
|
public HeterogeneousMixture Content { get; set; }
|
|
public double EnvironmentPressure { get; set; }
|
|
public double EnvironmentTemperature { get; set; }
|
|
}
|
|
|
|
[Test]
|
|
public static void Test()
|
|
{
|
|
HeterogeneousMixture h = new ();
|
|
h.Container = new Container(h);
|
|
HomogeneousMixture m = new();
|
|
|
|
QAtom q1 = new ();
|
|
QAtom q2 = new();
|
|
q1.C();
|
|
q2.C();
|
|
BaseBond b1 = q1.NextUnconnected("m");
|
|
BaseBond b2 = q2.NextUnconnected("m");
|
|
b1.Connect(b2);
|
|
Compound c = q1.GrabCompound;
|
|
c.Amount = 1;
|
|
m.AddCompound(c);
|
|
h.AddLayer(m);
|
|
|
|
Assert.IsTrue(h.Amount.IsEqualApprox(1));
|
|
Assert.That(h.Layers.Count, Is.EqualTo(1));
|
|
Assert.IsTrue(h.Layers.First().Amount.IsEqualApprox(1));
|
|
Assert.IsTrue(h.Layers.First().Ratio.IsEqualApprox(1));
|
|
Assert.IsTrue(c.Concentration.IsEqualApprox(1));
|
|
Console.WriteLine(c.IsoRepresentation);
|
|
QAtom q3 = new();
|
|
QAtom q4 = new();
|
|
q3.C();
|
|
q4.C();
|
|
q3.NextUnconnected("m").Connect(q4.NextUnconnected("m"));
|
|
Compound cx = q3.GrabCompound;
|
|
Console.WriteLine(cx.IsoRepresentation);
|
|
Assert.IsTrue(c.IsometricTo(cx));
|
|
Console.WriteLine(h.Dump());
|
|
Console.WriteLine($"T: {m.Temperature} FD:{m.FreeDensity.Get} FV:{m.FreeVolume}");
|
|
h.Container.EnvironmentTemperature = 1;
|
|
for(int i = 0;i<10;i++)
|
|
{
|
|
m.HeatExchange();
|
|
Console.WriteLine($"P: {m.Phase} T: {m.Temperature} FD:{m.FreeDensity.Get} FV:{m.FreeVolume}");
|
|
//Console.WriteLine($"\t\t{c.CompressionBias.Get} {c.CompressionElasticity.Get} {c.CompressionStiffness}");
|
|
Console.WriteLine($"\t{b1.AntiBondingEnergy} - {b1.Energy}");
|
|
Console.WriteLine($"\t{b2.AntiBondingEnergy} - {b2.Energy}");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public static void ReactionTest()
|
|
{
|
|
HeterogeneousMixture h = new ();
|
|
h.Container = new Container(h);
|
|
HomogeneousMixture m = new();
|
|
h.AddLayer(m);
|
|
BaseAtom a = AtomResolver.Resolve(1);
|
|
Compound c = a.GrabCompound;
|
|
a.Compound = c;
|
|
c.Amount = 2;
|
|
m.AddCompound(c);
|
|
h.Container.EnvironmentTemperature = 9;
|
|
for(int i = 1; i < 10; i++)
|
|
h.OneStep();
|
|
foreach (HomogeneousMixture mx in h.Layers)
|
|
{
|
|
Console.WriteLine(mx.Temperature);
|
|
foreach (Compound cx in mx.Compounds)
|
|
{
|
|
var b = cx.Atoms.First().NextUnconnected("m");
|
|
Console.WriteLine($"{cx.Expression} {cx.Amount} {b.BondingEnergy} {b.Energy}");
|
|
}
|
|
}
|
|
|
|
}
|
|
} |