Exemplo n.º 1
0
        public bool PHFlash(double P, double heatDuty, MaterialObject[] feeds, out MaterialObject product)
        {
            if (feeds.Length == 0)
            {
                product = null; return(false);
            }
            product   = feeds[0].Duplicate();
            product.P = P;
            double totalFlow;
            Dictionary <string, double> composition;

            MergeInputMaterial(feeds, out totalFlow, out composition);
            product.TotalFlow   = totalFlow;
            product.Composition = composition;
            product.Enthalpy    = feeds.Sum(m => m.Enthalpy) + heatDuty;
            product.DoPHFlash();
            return(true);
        }
Exemplo n.º 2
0
        public override void Calculate()
        {
            CasterLogger.Debug("Calculate");
            //throw new ECapeUnknownException(UnitOp,"Test");

            #region Flash
            outputMaterial.T = ParamT;
            outputMaterial.P = ParamP;
            Debug.Assert(outputMaterial.DoTPFlash());
            outputMaterial.GetSinglePhasePropDouble("enthalpy", Phases.Vapor, PropertyBasis.Mole);
            outputMaterial.Enthalpy = inputMaterial.Enthalpy;
            Debug.Assert(outputMaterial.DoPHFlash());
            #endregion

            //#region Overall

            //double Tcurr = outputMaterial.T;
            //double Pcurr = outputMaterial.P;
            //var composition = outputMaterial.Composition;
            //double enthalpy = outputMaterial.Enthalpy;
            //double volume = outputMaterial.VolumeFlow;
            ////double gibbsEnergy = 0;
            ////if (outputMaterial.AvailableSinglePhaseProp.Contains("gibbsEnergy"))
            ////    gibbsEnergy = outputMaterial.GibbsEnergy;
            ////double entropy = 0;
            ////if (outputMaterial.AvailableSinglePhaseProp.Contains("entropy"))
            ////    entropy = outputMaterial.Entropy;

            //#endregion

            //#region SinglePhase

            //var fugacity = outputMaterial.GetSinglePhasePropList("logFugacityCoefficient", Phases.Vapor, PropertyBasis.Undefined);
            //var activity = outputMaterial.GetSinglePhasePropList("activityCoefficient", Phases.Liquid, PropertyBasis.Undefined);

            //#endregion

            //#region TwoPhase

            //outputMaterial.VaporFraction = 1;
            //Debug.Assert(outputMaterial.DoPVFlash());  //COFE fails
            //var kvalue = outputMaterial.KValue;

            //#endregion

            //#region Constant

            //var R = outputMaterial.GetUniversalConstProp("molarGasConstant");
            //var molecularWeight = outputMaterial.GetCompoundConstPropDouble("molecularWeight",
            //    outputMaterial.Compounds[0]);
            //var heatCapacity = outputMaterial.GetCompoundTDependentProp("heatOfVaporization",
            //    outputMaterial.Compounds[0], ParamT);

            //#endregion

            //#region Enthalpy

            //double[] idealGasEnthalpy = new double[3];
            //for (int i = 0; i < outputMaterial.CompoundNum; i++)
            //    idealGasEnthalpy[i] = outputMaterial.GetCompoundTDependentProp("idealGasEnthalpy",
            //        outputMaterial.Compounds[i], outputMaterial.T);
            //double excessH = outputMaterial.GetSinglePhasePropDouble("mixtureEnthalpyDifference", Phases.Vapor, PropertyBasis.Mole);

            //#endregion

            CasterLogger.Debug("Calculate complete");
            return;
        }