Exemplo n.º 1
0
 public override double DW_CalcCv_ISOL(PropertyPackages.Phase Phase1, double T, double P)
 {
     if (Phase1 == Phase.Vapor)
     {
         return(CalcCp(RET_VMOL(Phase1), T, P, State.Vapor));
     }
     else
     {
         return(CalcCp(RET_VMOL(Phase1), T, P, State.Liquid));
     }
 }
Exemplo n.º 2
0
 public override void DW_CalcCompPartialVolume(PropertyPackages.Phase phase, double T, double P)
 {
     //do nothing
 }
Exemplo n.º 3
0
        public override void DW_CalcProp(string property, PropertyPackages.Phase phase)
        {
            double result  = 0.0d;
            int    phaseID = -1;
            string state   = "";
            State  pstate  = default(State);

            double T = 0d;
            double P = 0d;

            T = this.CurrentMaterialStream.Phases[0].Properties.temperature.GetValueOrDefault();
            P = this.CurrentMaterialStream.Phases[0].Properties.pressure.GetValueOrDefault();

            switch (phase)
            {
            case Phase.Vapor:
                state  = "V";
                pstate = PropertyPackages.State.Vapor;
                break;

            case Phase.Liquid:
            case Phase.Liquid1:
            case Phase.Liquid2:
            case Phase.Liquid3:
            case Phase.Aqueous:
                state  = "L";
                pstate = PropertyPackages.State.Liquid;
                break;

            case Phase.Solid:
                state  = "S";
                pstate = PropertyPackages.State.Solid;
                break;
            }

            switch (phase)
            {
            case PropertyPackages.Phase.Mixture:
                phaseID = 0;
                break;

            case PropertyPackages.Phase.Vapor:
                phaseID = 2;
                break;

            case PropertyPackages.Phase.Liquid1:
                phaseID = 3;
                break;

            case PropertyPackages.Phase.Liquid2:
                phaseID = 4;
                break;

            case PropertyPackages.Phase.Liquid3:
                phaseID = 5;
                break;

            case PropertyPackages.Phase.Liquid:
                phaseID = 1;
                break;

            case PropertyPackages.Phase.Aqueous:
                phaseID = 6;
                break;

            case PropertyPackages.Phase.Solid:
                phaseID = 7;
                break;
            }

            this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = this.AUX_MMM(phase);

            switch (property.ToLower())
            {
            case "compressibilityfactor":
                result = (double)CalculateProperty(ThermoProperty.CompressibilityCoeff, RET_VMOL(phase), state, T, P, 0, 0);
                this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = result;
                break;

            case "heatcapacity":
            case "heatcapacitycp":
            case "heatcapacitycv":
                if (state == "V")
                {
                    result = this.CalcCp(RET_VMOL(phase), T, P, State.Vapor);
                }
                else
                {
                    result = this.CalcCp(RET_VMOL(phase), T, P, State.Liquid);
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = result;
                break;

            case "enthalpy":
            case "enthalpynf":
                result = this.DW_CalcEnthalpy(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = result;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = result;
                break;

            case "entropy":
            case "entropynf":
                result = this.DW_CalcEntropy(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.entropy = result;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = result;
                break;

            case "excessenthalpy":
                result = this.DW_CalcEnthalpyDeparture(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.excessEnthalpy = result;
                break;

            case "excessentropy":
                result = this.DW_CalcEntropyDeparture(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.excessEntropy = result;
                break;

            case "enthalpyf":
                double entF = this.AUX_HFm25(phase);
                result = this.DW_CalcEnthalpy(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpyF = result + entF;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpyF.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpyF = result;
                break;

            case "entropyf":
                entF   = this.AUX_SFm25(phase);
                result = this.DW_CalcEntropy(RET_VMOL(phase), T, P, pstate);
                this.CurrentMaterialStream.Phases[phaseID].Properties.entropyF = result + entF;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.entropyF.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropyF = result;
                break;

            case "viscosity":
                if (state == "L")
                {
                    result = this.AUX_LIQVISCm(T);
                }
                else
                {
                    result = this.AUX_VAPVISCm(T, this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault(), this.AUX_MMM(phase));
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity = result;
                break;

            case "thermalconductivity":
                if (state == "L")
                {
                    result = this.AUX_CONDTL(T);
                }
                else
                {
                    result = this.AUX_CONDTG(T, P);
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = result;
                break;

            case "fugacity":
            case "fugacitycoefficient":
            case "logfugacitycoefficient":
            case "activity":
            case "activitycoefficient":
                this.DW_CalcCompFugCoeff(phase);
                break;

            case "volume":
            case "density":
                if (state == "L")
                {
                    result = this.AUX_LIQDENS(T, P, 0.0, phaseID, false);
                }
                else
                {
                    result = this.AUX_VAPDENS(T, P);
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.density = result;
                break;

            case "surfacetension":
                this.CurrentMaterialStream.Phases[0].Properties.surfaceTension = this.AUX_SURFTM(T);
                break;

            default:
                throw new CapeOpen.CapeThrmPropertyNotAvailableException();
            }
        }
Exemplo n.º 4
0
        public override void DW_CalcPhaseProps(PropertyPackages.Phase Phase)
        {
            double result = 0d;
            Phase  dwpl   = default(Phase);

            double T = 0d;
            double P = 0d;
            double phasemolarfrac   = 0d;
            double overallmolarflow = 0d;

            int phaseID = 0;

            T = this.CurrentMaterialStream.Phases[0].Properties.temperature.GetValueOrDefault();
            P = this.CurrentMaterialStream.Phases[0].Properties.pressure.GetValueOrDefault();

            switch (Phase)
            {
            case PropertyPackages.Phase.Mixture:
                phaseID = 0;
                dwpl    = PropertyPackages.Phase.Mixture;
                break;

            case PropertyPackages.Phase.Vapor:
                phaseID = 2;
                dwpl    = PropertyPackages.Phase.Vapor;
                break;

            case PropertyPackages.Phase.Liquid1:
                phaseID = 3;
                dwpl    = PropertyPackages.Phase.Liquid1;
                break;

            case PropertyPackages.Phase.Liquid2:
                phaseID = 4;
                dwpl    = PropertyPackages.Phase.Liquid2;
                break;

            case PropertyPackages.Phase.Liquid3:
                phaseID = 5;
                dwpl    = PropertyPackages.Phase.Liquid3;
                break;

            case PropertyPackages.Phase.Liquid:
                phaseID = 1;
                dwpl    = PropertyPackages.Phase.Liquid;
                break;

            case PropertyPackages.Phase.Aqueous:
                phaseID = 6;
                dwpl    = PropertyPackages.Phase.Aqueous;
                break;

            case PropertyPackages.Phase.Solid:
                phaseID = 7;
                dwpl    = PropertyPackages.Phase.Solid;
                break;
            }

            if (phaseID > 0)
            {
                overallmolarflow = this.CurrentMaterialStream.Phases[0].Properties.molarflow.GetValueOrDefault();
                phasemolarfrac   = this.CurrentMaterialStream.Phases[phaseID].Properties.molarfraction.GetValueOrDefault();
                result           = overallmolarflow * phasemolarfrac;
                this.CurrentMaterialStream.Phases[phaseID].Properties.molarflow = result;
                result = result * this.AUX_MMM(Phase) / 1000;
                this.CurrentMaterialStream.Phases[phaseID].Properties.massflow = result;
                if (this.CurrentMaterialStream.Phases[0].Properties.massflow.GetValueOrDefault() > 0)
                {
                    result = phasemolarfrac * overallmolarflow * this.AUX_MMM(Phase) / 1000 / this.CurrentMaterialStream.Phases[0].Properties.massflow.GetValueOrDefault();
                }
                else
                {
                    result = 0;
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.massfraction = result;
                this.DW_CalcCompVolFlow(phaseID);
                this.DW_CalcCompFugCoeff(Phase);
            }


            if (phaseID == 3 | phaseID == 4 | phaseID == 5 | phaseID == 6)
            {
                if (!GlobalSettings.Settings.EnableParallelProcessing)
                {
                    result = this.AUX_LIQDENS(T, RET_VMOL(dwpl), P);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.density = result;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = P / result * AUX_MMM(dwpl) / 1000 / 8.314 / T;

                    this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = this.DW_CalcEnthalpy(RET_VMOL(dwpl), T, P, State.Liquid);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.entropy  = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() / T;

                    result = this.CalcCp(RET_VMOL(dwpl), T, P, State.Liquid);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = result;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCv = result;

                    result = this.AUX_MMM(Phase);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = result;

                    result = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = result;

                    result = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = result;

                    result = this.AUX_CONDTL(T);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = result;

                    result = this.AUX_LIQVISCm(T);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity           = result;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.kinematic_viscosity = result / this.CurrentMaterialStream.Phases[phaseID].Properties.density.Value;
                }
                else
                {
                    result = this.AUX_MMM(Phase);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = result;

                    Task t1, t2, t3, t4;
                    t1 = Task.Factory.StartNew(() =>
                    {
                        var res = this.AUX_LIQDENS(T, P, 0.0, phaseID, false);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.density = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = P / res * AUX_MMM(dwpl) / 1000 / 8.314 / T;
                        res = this.AUX_LIQVISCm(T);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity           = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.kinematic_viscosity = res / this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault();
                    });
                    t2 = Task.Factory.StartNew(() =>
                    {
                        this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = this.DW_CalcEnthalpy(RET_VMOL(dwpl), T, P, State.Liquid);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.entropy  = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() / T;
                        var res = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                        this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = res;
                        res = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                        this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = res;
                    });
                    t3 = Task.Factory.StartNew(() =>
                    {
                        var res = this.CalcCp(RET_VMOL(dwpl), T, P, State.Liquid);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCv = res;
                    });
                    t4 = Task.Factory.StartNew(() =>
                    {
                        var res = this.AUX_CONDTL(T);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = res;
                    });
                    Task.WaitAll(t1, t2, t3, t4);
                }
            }
            else if (phaseID == 2)
            {
                if (!GlobalSettings.Settings.EnableParallelProcessing)
                {
                    result = this.AUX_VAPDENS(T, P);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.density  = result;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = this.DW_CalcEnthalpy(RET_VMOL(dwpl), T, P, State.Vapor);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.entropy  = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() / T;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = P / result * AUX_MMM(dwpl) / 1000 / 8.314 / T;
                    result = this.CalcCp(RET_VMOL(dwpl), T, P, State.Vapor);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = AUX_CPm(PropertyPackages.Phase.Vapor, T);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCv = AUX_CPm(PropertyPackages.Phase.Vapor, T);
                    result = this.AUX_MMM(Phase);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = result;
                    result = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = result;
                    result = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = result;
                    result = this.AUX_CONDTG(T, P);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = result;
                    result = this.AUX_VAPVISCm(T, this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault(), this.AUX_MMM(Phase));
                    this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity           = result;
                    this.CurrentMaterialStream.Phases[phaseID].Properties.kinematic_viscosity = result / this.CurrentMaterialStream.Phases[phaseID].Properties.density.Value;
                }
                else
                {
                    result = this.AUX_MMM(Phase);
                    this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = result;

                    Task t1, t2, t3, t4;
                    t1 = Task.Factory.StartNew(() =>
                    {
                        var res = this.AUX_VAPDENS(T, P);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.density = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = P / res * AUX_MMM(dwpl) / 1000 / 8.314 / T;
                        res = this.AUX_VAPVISCm(T, this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault(), this.AUX_MMM(Phase));
                        this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity           = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.kinematic_viscosity = res / this.CurrentMaterialStream.Phases[phaseID].Properties.density.Value;
                    });
                    t2 = Task.Factory.StartNew(() =>
                    {
                        this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = this.DW_CalcEnthalpy(RET_VMOL(dwpl), T, P, State.Vapor);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.entropy  = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() / T;
                        var res = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                        this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = res;
                        res = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                        this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = res;
                    });
                    t3 = Task.Factory.StartNew(() =>
                    {
                        var res = this.CalcCp(RET_VMOL(dwpl), T, P, State.Vapor);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = res;
                        this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCv = res;
                    });
                    t4 = Task.Factory.StartNew(() =>
                    {
                        var res = this.AUX_CONDTG(T, P);
                        this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = res;
                    });
                    Task.WaitAll(t1, t2, t3, t4, t4);
                }
            }
            else if (phaseID == 7)
            {
                result = this.AUX_SOLIDDENS();
                this.CurrentMaterialStream.Phases[phaseID].Properties.density = result;
                List <Interfaces.ICompoundConstantProperties> constprops = new List <Interfaces.ICompoundConstantProperties>();
                foreach (Interfaces.ICompound su in this.CurrentMaterialStream.Phases[0].Compounds.Values)
                {
                    constprops.Add(su.ConstantProperties);
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy = this.DW_CalcEnthalpy(RET_VMOL(dwpl), T, P, State.Solid);
                this.CurrentMaterialStream.Phases[phaseID].Properties.entropy  = this.DW_CalcEntropy(RET_VMOL(dwpl), T, P, State.Solid);
                this.CurrentMaterialStream.Phases[phaseID].Properties.compressibilityFactor = 0.0;
                //result
                result = this.DW_CalcSolidHeatCapacityCp(T, RET_VMOL(PropertyPackages.Phase.Solid), constprops);
                this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCp = result;
                this.CurrentMaterialStream.Phases[phaseID].Properties.heatCapacityCv = result;
                result = this.AUX_MMM(Phase);
                this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight = result;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.enthalpy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_enthalpy = result;
                result = this.CurrentMaterialStream.Phases[phaseID].Properties.entropy.GetValueOrDefault() * this.CurrentMaterialStream.Phases[phaseID].Properties.molecularWeight.GetValueOrDefault();
                this.CurrentMaterialStream.Phases[phaseID].Properties.molar_entropy = result;
                result = this.AUX_CONDTG(T, P);
                this.CurrentMaterialStream.Phases[phaseID].Properties.thermalConductivity = 0.0;
                //result
                this.CurrentMaterialStream.Phases[phaseID].Properties.viscosity           = 1E+20;
                this.CurrentMaterialStream.Phases[phaseID].Properties.kinematic_viscosity = 1E+20;
            }
            else if (phaseID == 1)
            {
                DW_CalcLiqMixtureProps();
            }
            else
            {
                DW_CalcOverallProps();
            }

            if (phaseID > 0)
            {
                if (this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault() > 0 & overallmolarflow > 0)
                {
                    result = overallmolarflow * phasemolarfrac * this.AUX_MMM(Phase) / 1000 / this.CurrentMaterialStream.Phases[phaseID].Properties.density.GetValueOrDefault();
                }
                else
                {
                    result = 0;
                }
                this.CurrentMaterialStream.Phases[phaseID].Properties.volumetric_flow = result;
            }
        }
Exemplo n.º 5
0
 public override double DW_CalcViscosidadeDinamica_ISOL(PropertyPackages.Phase Phase1, double T, double P)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public override double DW_CalcTensaoSuperficial_ISOL(PropertyPackages.Phase Phase1, double T, double P)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public override double DW_CalcMassaEspecifica_ISOL(PropertyPackages.Phase Phase1, double T, double P, double Pvp = 0)
 {
     throw new NotImplementedException();
 }