From 4021da83c391684b3ed748b79f9e29d6a150cf49 Mon Sep 17 00:00:00 2001 From: hzhang Date: Sat, 22 Jun 2024 02:28:37 +0800 Subject: [PATCH] Construct Compound --- src/Chemistry/Bonds/Implements/BaseBond.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Chemistry/Bonds/Implements/BaseBond.cs b/src/Chemistry/Bonds/Implements/BaseBond.cs index ac8a135..aa34878 100644 --- a/src/Chemistry/Bonds/Implements/BaseBond.cs +++ b/src/Chemistry/Bonds/Implements/BaseBond.cs @@ -171,14 +171,16 @@ public abstract class BaseBond bond.StructureChanged(); if (Atom.Compound.Atoms.Contains(bond.Atom)) return; - bond.Atom.HomogeneousMixture.Compounds.Remove(bond.Atom.Compound); - bond.Atom.Compound.Amount = 0d; + Compound r = bond.Atom.Compound; foreach (BaseAtom atom in bond.Atom.Compound.Atoms.ToHashSet()) { Atom.Compound.Atoms.Add(atom); atom.Compound = Atom.Compound; } + + r.Amount = 0d; + r.HomogeneousMixture.Compounds.Remove(r); } /// /// disconnect with connected bond