/// <summary>
        /// Loads the reaction processor in the model with sample reactions.
        /// </summary>
        /// <param name="brs">The instance of ISupportsReactions that we will load..</param>
        private static void LoadSampleReactions(BasicReactionSupporter brs)
        {
            Reaction r1 = new Reaction(null, "Reaction 1", Guid.NewGuid());

            r1.AddReactant(brs.MyMaterialCatalog["Caustic Soda"], 0.5231);
            r1.AddReactant(brs.MyMaterialCatalog["Hydrochloric Acid"], 0.4769);
            r1.AddProduct(brs.MyMaterialCatalog["Water"], 0.2356);
            r1.AddProduct(brs.MyMaterialCatalog["Sodium Chloride"], 0.7644);
            brs.MyReactionProcessor.AddReaction(r1);

            Reaction r2 = new Reaction(null, "Reaction 2", Guid.NewGuid());

            r2.AddReactant(brs.MyMaterialCatalog["Sulfuric Acid"], 0.533622);
            r2.AddReactant(brs.MyMaterialCatalog["Potassium Hydroxide"], 0.466378);
            r2.AddProduct(brs.MyMaterialCatalog["Water"], 0.171333);
            r2.AddProduct(brs.MyMaterialCatalog["Potassium Sulfate"], 0.828667);
            brs.MyReactionProcessor.AddReaction(r2);

            Reaction r3 = new Reaction(null, "Reaction 3", Guid.NewGuid());

            r3.AddReactant(brs.MyMaterialCatalog["Caustic Soda"], 0.459681368);
            r3.AddReactant(brs.MyMaterialCatalog["Nitrous Acid"], 0.540318632);
            r3.AddProduct(brs.MyMaterialCatalog["Water"], 0.207047552);
            r3.AddProduct(brs.MyMaterialCatalog["Sodium Nitrite"], 0.792952448);
            brs.MyReactionProcessor.AddReaction(r3);

            Reaction r4 = new Reaction(null, "Reaction 4", Guid.NewGuid());

            r4.AddReactant(brs.MyMaterialCatalog["Potassium Hydroxide"], 0.544102);
            r4.AddReactant(brs.MyMaterialCatalog["Nitrous Acid"], 0.455898);
            r4.AddProduct(brs.MyMaterialCatalog["Water"], 0.174698);
            r4.AddProduct(brs.MyMaterialCatalog["Potassium Nitrite"], 0.825302);
            brs.MyReactionProcessor.AddReaction(r4);
        }
예제 #2
0
        public void TestSerializationEmptyReaction()
        {
            Reaction        x1     = CreateObject <Reaction>().WithName("Regina").WithDimension(DimensionLength);
            IContainer      c1     = CreateObject <Container>().WithName("Conrad");
            IMoleculeAmount educt1 = CreateObject <MoleculeAmount>().WithName("Eduard").WithParentContainer(c1);
            IMoleculeAmount educt2 = CreateObject <MoleculeAmount>().WithName("Edward").WithParentContainer(c1);

            x1.AddEduct(new ReactionPartner(1.1, educt1));
            x1.AddEduct(new ReactionPartner(1.2, educt2));

            IMoleculeAmount product1 = CreateObject <MoleculeAmount>().WithName("Proton").WithParentContainer(c1);
            IMoleculeAmount product2 = CreateObject <MoleculeAmount>().WithName("Prosit").WithParentContainer(c1);

            x1.AddProduct(new ReactionPartner(1.1, product1));
            x1.AddProduct(new ReactionPartner(1.2, product2));
            x1.AddModifier("mod");

            var cont1 = new Container {
                c1, x1
            }.WithId("toto");
            var cont2 = SerializeAndDeserialize(cont1);
            var x2    = cont2.FindByName(x1.Name).DowncastTo <Reaction>();

            AssertForSpecs.AreEqualReaction(x2, x1);
        }
            private void Initialize(BasicReactionSupporter brs)
            {
                MaterialCatalog   mcat = brs.MyMaterialCatalog;
                ReactionProcessor rp   = brs.MyReactionProcessor;

                //                        Model  Name    Guid           SpecGrav SpecHeat
                mcat.Add(new MaterialType(null, "Water", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Hydrochloric Acid", Guid.NewGuid(), 1.1890, 2.5500, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Caustic Soda", Guid.NewGuid(), 2.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sodium Chloride", Guid.NewGuid(), 2.1650, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sulfuric Acid 98%", Guid.NewGuid(), 1.8420, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Hydroxide", Guid.NewGuid(), 1.3000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Sulfate", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Nitrous Acid", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Sodium Nitrite", Guid.NewGuid(), 2.3800, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Potassium Nitrite", Guid.NewGuid(), 1.9150, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Aluminum Hydroxide", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Ammonia", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Ammonium Hydroxide", Guid.NewGuid(), 1.0000, 4.1800, MaterialState.Liquid));
                mcat.Add(new MaterialType(null, "Bromine", Guid.NewGuid(), 3.1200, 4.1800, MaterialState.Liquid));

                Reaction r1 = new Reaction(null, "Reaction 1", Guid.NewGuid());

                r1.AddReactant(mcat["Caustic Soda"], 0.5231);
                r1.AddReactant(mcat["Hydrochloric Acid"], 0.4769);
                r1.AddProduct(mcat["Water"], 0.2356);
                r1.AddProduct(mcat["Sodium Chloride"], 0.7644);
                rp.AddReaction(r1);

                Reaction r2 = new Reaction(null, "Reaction 2", Guid.NewGuid());

                r2.AddReactant(mcat["Sulfuric Acid 98%"], 0.533622);
                r2.AddReactant(mcat["Potassium Hydroxide"], 0.466378);
                r2.AddProduct(mcat["Water"], 0.171333);
                r2.AddProduct(mcat["Potassium Sulfate"], 0.828667);
                rp.AddReaction(r2);

                Reaction r3 = new Reaction(null, "Reaction 3", Guid.NewGuid());

                r3.AddReactant(mcat["Caustic Soda"], 0.459681368);
                r3.AddReactant(mcat["Nitrous Acid"], 0.540318632);
                r3.AddProduct(mcat["Water"], 0.207047552);
                r3.AddProduct(mcat["Sodium Nitrite"], 0.792952448);
                rp.AddReaction(r3);

                Reaction r4 = new Reaction(null, "Reaction 4", Guid.NewGuid());

                r4.AddReactant(mcat["Potassium Hydroxide"], 0.544102);
                r4.AddReactant(mcat["Nitrous Acid"], 0.455898);
                r4.AddProduct(mcat["Water"], 0.174698);
                r4.AddProduct(mcat["Potassium Nitrite"], 0.825302);
                rp.AddReaction(r4);
            }