# VirtualChemistry VirtualChemistry is a simulation framework. It is designed to model a fictional chemical reaction mechanism, including concepts analogous to atoms, bond structures, and homogeneous/heterogeneous mixtures in real chemistry. ## Table of Contents - [Features](#features) - [Current Features](#current-features) - [Planned Features](#planned-features) - [Prerequisites](#prerequisites) - [Usage](#usage) - [Installation](#installation) - [Examples](#examples) - [License](#license) ## Features ### Current Features - Methods to manipulate bonds, atoms, compounds (molecules), homogeneous mixtures, and heterogeneous mixtures. - Methods to manipulate environments (e.g., temperature, container volume). ### Planned Features - A fast mode for reactions to improve computation speed by discarding structural information of compounds. - Support for custom reaction mechanisms and chemistry systems. - Meta-reaction mode (discard the process of heat exchange and volume updates of reactions; reactions no longer need an environment or a container, just input mixtures). ## Prerequisites - **.NET SDK 6.0 or 8.0** - [Skeleton][sk] ## Usage ### Installation Clone the repository to your local machine: ```bash git clone https://git.hangman-lab.top/hzhang/VirtualChemistry.git cd VirtualChemistry ``` Build the project using the .NET CLI: ```bash dotnet build ``` This command compiles the source code and restores dependencies, preparing the project for execution. Alternatively, use the NuGet package manager to add the repository source: ```bash dotnet nuget add source --name hangman-lab https://git.hangman-lab.top/api/packages/hzhang/nuget/index.json ``` After adding the source, install the package: ```bash dotnet add package VirtualChemistry ``` ### Examples #### Manually Build a Compound You can build a compound by manually connecting bonds of atoms: ```csharp Compound Q2() { 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; return c; } ``` #### Manually Build a Mixture ##### Build Homogeneous Mixture by Compounds ```csharp HomogeneousMixture Mix(params Compound[] compounds) { HomogeneousMixture res = new(); foreach (Compound c in compounds) res.AddCompound(c); return res; } ``` ##### Build Heterogeneous Mixture by Homogeneous Mixtures ```csharp HeterogeneousMixture Mix(params HomogeneousMixture[] layers) { HeterogeneousMixture res = new(); foreach (HomogeneousMixture layer in layers) res.AddLayer(layer); return res; } ``` #### Process Reaction of Mixture To process a reaction for a heterogeneous mixture `h`, it needs to be in a container to provide its environment: ```csharp 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; } } h.Container = new Container(h); h.Container.EnvironmentTemperature = 4.4; ``` Pressure will be updated automatically by compression stiffness and volume of the container: ```csharp h.OneStep(); ``` This represents reacting `h` for $1dt$. ## License [MIT][license] © [hzhang][author] [author]: https://hangman-lab.top [license]: license [sk]: https://git.hangman-lab.top/hzhang/Skeleton