Exemple #1
0
        public void TestReactions3()
        {
            Model model = new Model("Test Model", Guid.NewGuid());
            BasicReactionSupporter brs = new BasicReactionSupporter();

            InitializeForTesting(brs);

            MaterialType potassiumSulfateType = (MaterialType)brs.MyMaterialCatalog["Potassium Sulfate"];
            MaterialType acetoneType          = (MaterialType)brs.MyMaterialCatalog["Acetone"];
            MaterialType hexaneType           = (MaterialType)brs.MyMaterialCatalog["Hexane"];


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

            r1.AddReactant(potassiumSulfateType, 1.0);
            r1.AddReactant(acetoneType, 2.5);
            r1.AddProduct(hexaneType, 3.0);
            r1.AddProduct(acetoneType, 0.5);
            r1.HeatOfReaction = 0;

            brs.MyReactionProcessor.AddReaction(r1);

            Mixture m       = new Mixture(model, "Mixture");
            string  results = "";

            r1.ReactionGoingToHappenEvent += new ReactionGoingToHappenEvent(delegate(Reaction reaction, Mixture mixture) {
                results += ("\r\nBefore = " + m.ToString("F2", "F4"));
            });
            r1.ReactionHappenedEvent += new ReactionHappenedEvent(delegate(ReactionInstance reactionInstance) {
                results += ("\r\nAfter = " + m.ToString("F2", "F4") + "\r\n");
            });


            brs.MyReactionProcessor.Watch(m);

            Console.WriteLine(r1.ToString());

            m.AddMaterial(potassiumSulfateType.CreateMass(100, 37));
            m.AddMaterial(acetoneType.CreateMass(100, 37));

            Console.WriteLine(results);
            Assert.AreEqual(results, EXPECTED_3);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new instance of this class.
 /// </summary>
 public ReactionDefinitionException(Reaction reaction) : base(string.Format("{0} is not valid.", reaction.ToString()))
 {
     m_reaction = reaction;
 }