コード例 #1
0
        public EquationSystem Decompose(Flowsheet flowsheet)
        {
            var equationSystem = new EquationSystem();

            equationSystem.Name = flowsheet.Name;
            flowsheet.FillEquationSystem(equationSystem);
            decomp.Solve(equationSystem);
            return(equationSystem);
        }
コード例 #2
0
ファイル: FlashRoutines.cs プロジェクト: shao130/OpenFMSL
        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);
        }
コード例 #3
0
ファイル: ProcessUnit.cs プロジェクト: shao130/OpenFMSL
        /// <summary>
        /// Solves the unit together with the output material streams as a single flowsheet. When using this method, the unit has to be specified fully.
        /// </summary>
        public virtual ProcessUnit Solve()
        {
            var decomp = new Decomposer();

            var flowsheet = new Flowsheet(Name);

            flowsheet.AddUnit(this);
            foreach (var stream in MaterialPorts.Where(p => p.Direction == PortDirection.Out && p.IsConnected).Select(p => p.Streams.ToArray()))
            {
                flowsheet.AddMaterialStreams(stream);
            }
            var problem = new EquationSystem();

            flowsheet.FillEquationSystem(problem);
            decomp.Solve(problem);

            return(this);
        }