/// <summary> /// Do TP Flash /// I give this method some parameters, /// because I wish other block could use this method. /// May be unnecessary, you can do it your way. /// </summary> public bool TPFlash(double T, double P, MaterialObject[] feeds, out MaterialObject product) { if (feeds.Length == 0) { product = null; return(false); } product = feeds[0].Duplicate(); product.T = T; product.P = P; double totalFlow; Dictionary <string, double> composition; MergeInputMaterial(feeds, out totalFlow, out composition); product.TotalFlow = totalFlow; product.Composition = composition; product.DoTPFlash(); return(true); }
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; }