예제 #1
0
        public bool CalculatePQ(MaterialStream stream, double enthalpy)
        {
            var copy = new MaterialStream("copy", stream.System);

            copy.CopyFrom(stream);

            PrecalculateTP(copy);

            var problem2 = new EquationSystem()
            {
                Name = "PQ-Flash"
            };

            copy.GetVariable("p").IsFixed  = true;
            copy.GetVariable("T").IsFixed  = false;
            copy.GetVariable("VF").IsFixed = false;
            copy.Init("VF", stream.Vfmolar.ValueInSI);
            foreach (var comp in stream.System.Components)
            {
                copy.GetVariable("n[" + comp.ID + "]").IsFixed = true;
            }
            problem2.AddConstraints((copy.Mixed.SpecificEnthalpy * copy.Mixed.TotalMolarflow).IsEqualTo(enthalpy));
            copy.FillEquationSystem(problem2);

            var solver = new Decomposer();

            solver.Solve(problem2);

            performMassBalance(copy, copy.KValues);
            performDensityUpdate(copy);
            performEnthalpyUpdate(copy);

            stream.CopyFrom(copy);
            return(true);
        }
        EquationSystem GetEquationSystem(MaterialStream stream)
        {
            var eq = new EquationSystem();

            eq.TreatFixedVariablesAsConstants = true;
            stream.FillEquationSystem(eq);
            return(eq);
        }