Beispiel #1
0
        public FeedStage(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Flash";
            Icon.IconType = IconTypes.FeedStage;

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("VIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("VOut", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LOut", PortDirection.Out, 1));

            dp = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p  = system.VariableFactory.CreateVariable("P", "Pressure in flash", PhysicalDimension.Pressure);
            T  = system.VariableFactory.CreateVariable("T", "Temperature in flash", PhysicalDimension.Temperature);
            Q  = system.VariableFactory.CreateVariable("Q", "Heat Duty", PhysicalDimension.HeatFlow);

            K = new Variable[system.Components.Count];
            for (int i = 0; i < system.Components.Count; i++)
            {
                K[i]           = system.VariableFactory.CreateVariable("K", "Equilibrium partition coefficient", PhysicalDimension.Dimensionless);
                K[i].Subscript = system.Components[i].ID;
                K[i].ValueInSI = 1.2;
            }
            dp.LowerBound = -1e10;
            dp.ValueInSI  = 0;

            AddVariable(p);
            AddVariable(T);
            AddVariable(Q);

            AddVariable(dp);
            AddVariables(K);
        }
Beispiel #2
0
        public Heater(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Heater";
            Icon.IconType = IconTypes.Heater;

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out", PortDirection.Out, 1));
            HeatPorts.Add(new Port <HeatStream>("Duty", PortDirection.In, 1));

            dp            = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p             = system.VariableFactory.CreateVariable("P", "Pressure in heater outlet", PhysicalDimension.Pressure);
            T             = system.VariableFactory.CreateVariable("T", "Temperature in heater outlet", PhysicalDimension.Temperature);
            VF            = system.VariableFactory.CreateVariable("VF", "Vapor fraction in heater outlet", PhysicalDimension.MolarFraction);
            Q             = system.VariableFactory.CreateVariable("Q", "Heat Duty", PhysicalDimension.HeatFlow);
            dp.LowerBound = 0;
            dp.ValueInSI  = 0;



            AddVariable(dp);
            AddVariable(p);
            AddVariable(T);
            AddVariable(VF);
            AddVariable(Q);
        }
Beispiel #3
0
        public BlackBoxReactor(string name, ThermodynamicSystem system, int numberOfReactions) : base(name, system)
        {
            Class = "Reactor";
            _numberOfReactions = numberOfReactions;

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out", PortDirection.Out, 1));

            R             = new Variable[_numberOfReactions];
            DHR           = new Variable[_numberOfReactions];
            _stochiometry = new double[_numberOfReactions, System.Components.Count];

            for (int i = 0; i < _numberOfReactions; i++)
            {
                R[i]             = system.VariableFactory.CreateVariable("R", (i + 1).ToString(), "Converted Molar Flow for reaction " + (i + 1).ToString(), PhysicalDimension.MolarFlow);
                DHR[i]           = system.VariableFactory.CreateVariable("DHR", (i + 1).ToString(), "Reaction enthalpy", PhysicalDimension.SpecificMolarEnthalpy);
                DHR[i].ValueInSI = 0;
                DHR[i].IsFixed   = true;
            }

            dp = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p  = system.VariableFactory.CreateVariable("P", "Pressure in heater outlet", PhysicalDimension.Pressure);
            T  = system.VariableFactory.CreateVariable("T", "Temperature in heater outlet", PhysicalDimension.Temperature);
            Q  = system.VariableFactory.CreateVariable("Q", "Heat Duty", PhysicalDimension.HeatFlow);


            dp.LowerBound = -1e9;
            dp.ValueInSI  = 0;
            AddVariable(dp);
            AddVariable(p);
            AddVariable(T);
            AddVariables(R);
            AddVariable(Q);
            AddVariables(DHR);
        }
Beispiel #4
0
        public Valve(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Valve";
            Icon.IconType = IconTypes.Valve;
            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out", PortDirection.Out, 1));

            dp = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p1 = system.VariableFactory.CreateVariable("P1", "Pressure in valve inlet", PhysicalDimension.Pressure);
            p2 = system.VariableFactory.CreateVariable("P2", "Pressure in valve outlet", PhysicalDimension.Pressure);

            KVS = new Variable("KVS", 10, 0, 1e6, SI.cum / SI.h / METRIC.bar, "Nominal valve coefficient");
            KV  = new Variable("KV", 10, 0, 1e6, SI.cum / SI.h / METRIC.bar, "Effective valve coefficient");

            Opening  = new Variable("Open", 50, 0, 100, SI.nil, "Valve opening in %");
            Position = new Variable("Pos", 50, 0, 100, SI.nil, "Valve position in %");

            dp.LowerBound = 0;
            dp.ValueInSI  = 0;
            AddVariable(dp);
            AddVariable(KVS);
            AddVariable(KV);
            AddVariable(Opening);
            AddVariable(Position);
            AddVariable(p1);
            AddVariable(p2);
        }
Beispiel #5
0
        public Mixer(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Mixer";
            Icon.IconType = IconTypes.Mixer;

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, -1));
            MaterialPorts.Add(new Port <MaterialStream>("Out", PortDirection.Out, 1));

            dp            = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p             = system.VariableFactory.CreateVariable("P", "Pressure in mixer", PhysicalDimension.Pressure);
            dp.LowerBound = -1e8;
            dp.ValueInSI  = 0;
            AddVariable(dp);
            AddVariable(p);
        }
Beispiel #6
0
        public Splitter(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Splitter";
            Icon.IconType = IconTypes.Splitter;
            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out1", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out2", PortDirection.Out, 1));

            dp            = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p             = system.VariableFactory.CreateVariable("P", "Pressure in splitter", PhysicalDimension.Pressure);
            SplitFactor   = system.VariableFactory.CreateVariable("K", "Split factor (molar)", PhysicalDimension.MolarFraction);
            dp.LowerBound = 0;
            AddVariable(dp);
            AddVariable(SplitFactor);
            AddVariable(p);
        }
        public ShellAndTubeHeatExchanger(string name, ThermodynamicSystem system, int passes, int discretization) : base(name, system)
        {
            Class           = "Shell&Tube";
            Icon.IconType   = IconTypes.HeatExchanger;
            _numberOfPasses = passes;
            _discretization = discretization;

            MaterialPorts.Add(new Port <MaterialStream>("ShellIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("ShellOut", PortDirection.Out, 1));

            MaterialPorts.Add(new Port <MaterialStream>("TubeIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("TubeOut", PortDirection.Out, 1));

            _area     = system.VariableFactory.CreateVariable("A", "Area", PhysicalDimension.Area);
            _koverall = system.VariableFactory.CreateVariable("k", "Effective Heat Transfer Coefficient", PhysicalDimension.HeatTransferCoefficient);
            AddVariables(_area, _koverall);
        }
Beispiel #8
0
        public Decanter(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class         = "Decanter";
            Icon.IconType = IconTypes.ThreePhaseFlash;

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Vap", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Liq1", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Liq2", PortDirection.Out, 1));

            dp = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p  = system.VariableFactory.CreateVariable("P", "Pressure in flash", PhysicalDimension.Pressure);
            T  = system.VariableFactory.CreateVariable("T", "Temperature in flash", PhysicalDimension.Temperature);
            Q  = system.VariableFactory.CreateVariable("Q", "Heat Duty", PhysicalDimension.HeatFlow);
            VF = system.VariableFactory.CreateVariable("VF", "Vapor Fraction", PhysicalDimension.MolarFraction);

            KLL = new Variable[system.Components.Count];
            S   = new Variable[system.Components.Count];

            for (int i = 0; i < system.Components.Count; i++)
            {
                KLL[i]            = system.VariableFactory.CreateVariable("KLL", "Equilibrium partition coefficient (LLE)", PhysicalDimension.Dimensionless);
                KLL[i].Subscript  = system.Components[i].ID;
                KLL[i].ValueInSI  = 1.2;
                KLL[i].UpperBound = 1e6;

                S[i]            = system.VariableFactory.CreateVariable("S", "Split fraction between Liquid Phases)", PhysicalDimension.Dimensionless);
                S[i].Subscript  = system.Components[i].ID;
                S[i].ValueInSI  = 0.5;
                S[i].UpperBound = 1;
            }
            dp.LowerBound = -1e10;
            dp.ValueInSI  = 0;

            AddVariable(p);
            AddVariable(T);
            AddVariable(Q);
            AddVariable(VF);
            AddVariable(dp);
            AddVariables(KLL);
            AddVariables(S);
        }
Beispiel #9
0
        public ComponentSplitter(string name, ThermodynamicSystem system) : base(name, system)
        {
            Class = "CSplitter";

            MaterialPorts.Add(new Port <MaterialStream>("In", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out1", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Out2", PortDirection.Out, 1));

            dp = system.VariableFactory.CreateVariable("DP", "Pressure Drop", PhysicalDimension.Pressure);
            p  = system.VariableFactory.CreateVariable("P", "Pressure in splitter", PhysicalDimension.Pressure);

            SplitFactors = new Variable[system.Components.Count];
            for (int i = 0; i < system.Components.Count; i++)
            {
                SplitFactors[i]           = system.VariableFactory.CreateVariable("K", "Component Split factor (molar)", PhysicalDimension.MolarFraction);
                SplitFactors[i].Subscript = system.Components[i].ID;
            }
            dp.LowerBound = 0;
            AddVariable(dp);
            AddVariables(SplitFactors);
            AddVariable(p);
        }
Beispiel #10
0
        public RateBasedSection(string name, ThermodynamicSystem system, int numberOfElements) : base(name, system)
        {
            Class            = "RateSection";
            NumberOfElements = numberOfElements;
            Icon.IconType    = IconTypes.RateBasedSection;
            var NC = system.Components.Count;

            MaterialPorts.Add(new Port <MaterialStream>("VIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("VOut", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LOut", PortDirection.Out, 1));


            for (int i = 0; i < NumberOfElements; i++)
            {
                var tray = new NonEquilibriumTray(i + 1, system);
                _trays.Add(tray);
            }

            AddVariables(_trays.Select(t => t.TL).ToArray());
            AddVariables(_trays.Select(t => t.TI).ToArray());
            AddVariables(_trays.Select(t => t.TV).ToArray());

            AddVariables(_trays.Select(t => t.p).ToArray());
            AddVariables(_trays.Select(t => t.DP).ToArray());
            AddVariables(_trays.Select(t => t.Q).ToArray());
            AddVariables(_trays.Select(t => t.E).ToArray());
            AddVariables(_trays.Select(t => t.L).ToArray());
            AddVariables(_trays.Select(t => t.V).ToArray());

            AddVariables(_trays.Select(t => t.HL).ToArray());
            AddVariables(_trays.Select(t => t.HV).ToArray());
            AddVariables(_trays.Select(t => t.aeff).ToArray());

            AddVariables(_trays.Select(t => t.aspez).ToArray());
            AddVariables(_trays.Select(t => t.d).ToArray());
            AddVariables(_trays.Select(t => t.h).ToArray());
            AddVariables(_trays.Select(t => t.dhyd).ToArray());

            AddVariables(_trays.Select(t => t.ReV).ToArray());
            AddVariables(_trays.Select(t => t.uV).ToArray());

            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].K);
            }
            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].x);
            }

            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].xI);
            }

            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].y);
            }

            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].yI);
            }

            for (int i = 0; i < NumberOfElements; i++)
            {
                AddVariables(_trays[i].N);
            }

            for (int n = 0; n < NumberOfElements; n++)
            {
                for (int i = 0; i < NC; i++)
                {
                    for (int j = 0; j < NC; j++)
                    {
                        AddVariables(_trays[n].BetaV[i, j]);
                    }
                }
            }
        }
Beispiel #11
0
        public TraySection(string name, ThermodynamicSystem system, int numberOfTrays) : base(name, system)
        {
            Class         = "TraySection";
            NumberOfTrays = numberOfTrays;
            Icon.IconType = IconTypes.ColumnSection;

            MaterialPorts.Add(new Port <MaterialStream>("Feeds", PortDirection.In, -1));
            MaterialPorts.Add(new Port <MaterialStream>("VIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LIn", PortDirection.In, 1));
            MaterialPorts.Add(new Port <MaterialStream>("VOut", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("LOut", PortDirection.Out, 1));
            MaterialPorts.Add(new Port <MaterialStream>("Sidestreams", PortDirection.Out, -1));

            for (int i = 0; i < NumberOfTrays; i++)
            {
                var tray = new EquilibriumTray(i + 1, system);
                _trays.Add(tray);
            }

            AddVariables(_trays.Select(t => t.T).ToArray());
            AddVariables(_trays.Select(t => t.TV).ToArray());

            AddVariables(_trays.Select(t => t.p).ToArray());
            AddVariables(_trays.Select(t => t.DP).ToArray());
            AddVariables(_trays.Select(t => t.Q).ToArray());
            AddVariables(_trays.Select(t => t.F).ToArray());
            AddVariables(_trays.Select(t => t.L).ToArray());
            AddVariables(_trays.Select(t => t.V).ToArray());
            AddVariables(_trays.Select(t => t.U).ToArray());
            AddVariables(_trays.Select(t => t.W).ToArray());
            AddVariables(_trays.Select(t => t.RL).ToArray());
            AddVariables(_trays.Select(t => t.RV).ToArray());
            AddVariables(_trays.Select(t => t.eps).ToArray());
            AddVariables(_trays.Select(t => t.HF).ToArray());
            AddVariables(_trays.Select(t => t.HL).ToArray());
            AddVariables(_trays.Select(t => t.HV).ToArray());

            for (int i = 0; i < NumberOfTrays; i++)
            {
                AddVariables(_trays[i].K);
            }
            for (int i = 0; i < NumberOfTrays; i++)
            {
                AddVariables(_trays[i].x);
            }
            for (int i = 0; i < NumberOfTrays; i++)
            {
                AddVariables(_trays[i].y);
            }
            for (int i = 0; i < NumberOfTrays; i++)
            {
                AddVariables(_trays[i].yeq);
            }

            for (int i = 0; i < NumberOfTrays; i++)
            {
                AddVariables(_trays[i].z);
            }


            int NC = System.Components.Count;

            for (var tray = 0; tray < NumberOfTrays; tray++)
            {
                _trays[tray].U.FixValue(0);
                _trays[tray].W.FixValue(0);
                _trays[tray].RL.FixValue(0);
                _trays[tray].RV.FixValue(0);
                _trays[tray].F.FixValue(0);
                _trays[tray].HF.FixValue(0);

                /*     _trays[tray].U.IsConstant = true;
                 *   _trays[tray].W.IsConstant = true;
                 *   _trays[tray].RL.IsConstant = true;
                 *   _trays[tray].RV.IsConstant = true;
                 *   _trays[tray].F.IsConstant = true;
                 *    _trays[tray].HF.IsConstant = true;*/

                for (var comp = 0; comp < NC; comp++)
                {
                    _trays[tray].z[comp].FixValue(0);
                    //  _trays[tray].z[comp].IsConstant = true;
                }
            }
        }