vba functions common

7
Doc. No. Date Revision 0 Function : pressconv ( psi, upsi, upso ) Sheet No. 1 of 1 Purpose : to convert press. to diff erent unit. Variables psi Press., input upsi Press. Unit, input upso Press. Unit, output  Application kg/cm2.g bar.g Function : upsa ( upsg ) Pu rp ose : t o c onv ert pr es s. un it , ga ug e to ab sol ut e. Variables upsg Press. unit, gauge  Application kg/cm2.g Function : upsx ( upsg ) Purpose : to convert press. unit, gauge to simple expression, which can be used as unit for press. drop. Variables upsg Press. unit, gauge  Application kg/cm2.g Function : tempconv ( vi , ui , uo ) Purpose : to convert temp. to dif ferent unit. Variables vi Temp., input ui Temp. Unit, input uo Temp. Unit, output  Application   NTES Narai Thermal Engineering Services kg/cm2.a kg/cm2 100 100 " unitconversion "  VBA Functions > Module : 9.80665 10 VBA - UC - 100 2005. 4. 21.

Upload: bytejuice

Post on 18-Oct-2015

47 views

Category:

Documents


0 download

DESCRIPTION

vba common funtions

TRANSCRIPT

ucVBA Functions > Module :" unitconversion "Doc. No.VBA - UC - 100Date2005. 4. 21.Revision0Function:pressconv ( psi, upsi, upso )Sheet No.1of1Purpose:to convert press. to different unit.VariablespsiPress., inputupsiPress. Unit, inputupsoPress. Unit, outputApplication10kg/cm2.g9.80665bar.gFunction:upsa ( upsg )Purpose:to convert press. unit, gauge to absolute.VariablesupsgPress. unit, gaugeApplicationkg/cm2.gkg/cm2.aFunction:upsx ( upsg )Purpose:to convert press. unit, gauge to simple expression, which can be used as unit for press. drop.VariablesupsgPress. unit, gaugeApplicationkg/cm2.gkg/cm2Function:tempconv ( vi , ui , uo )Purpose:to convert temp. to different unit.VariablesviTemp., inputuiTemp. Unit, inputuoTemp. Unit, outputApplication100212NTESNarai Thermal Engineering Services

mathVBA Functions > Module :" mathematics "Doc. No.VBA - MATH - 100Date2006. 3. 22.Revision0Sheet No.1of1Function:yvalue ( xx, nx, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10 )Purpose:to to get Y value correspoding to X value using Lagrange interpolationVariablesxxX valuenxNo. of Data ( x, y )x1 ~ x10x axis Data Valuey1 ~ y10y axis Data ValueApplicationx:1.02.03.04.05.06.07.08.09.010.011.012.013.014.015.0y:1.02.03.04.05.06.07.08.09.010.011.012.013.014.015.0X=8Y=8NTESNarai Thermal Engineering Services

IFCVBA Functions > Module :" steamtableIFC1967 "Doc. No.VBA - IFC - 100Date2006. 3. 22.Revision0Function:ifc1967 ( psi, ups, temp, utemp, nprop )Sheet No.1of1Purpose:to obtain a steam property.VariablespsiPress.upsPress. UnittempTemp.utempTemp. UnitnpropNo. for Property to be obtained0Sat. Temp.169.7786183Sat. VaporSat. Liquid1Specific Volumem3/kg0.2439513271110.243790002210.00111417682Densitykg/m34.0991783569124.101890937422897.52358886363Enthalpykcal/kg660.97989075613660.848336650723171.52643194984Entropykcal/kg.1.5921714697141.5918745341240.48711610845Specific Heatkcal/kg.0.5940531843150.594429234251.04378383316Viscositykg/m.h0.0525906729160.0525554724260.57155003967Thermal Cond.kcal/m.h.0.0280515133170.0280435146270.58564839228Prandtl No.1.1137244657181.1140012084281.0186567555h19489.3219047009290.004532356210Sat. Press. acc.to tempkg/cm2.g7.0431570332s201.1047584258Surface tensionkg/mApplicationSteam Cond.:Press.7kg/cm2.gTemp.170Function:thfind ( psi, ups, ehi, nout )Purpose:to find temp. in case press. and enthalpy are given.VariablespsiPress.upsPress. UnitehiEnthalpykcal/kgnoutNo. for Output to be obtained0Temp.170.07861831Kind of Steam, Sat., Superheated or Subcooled.Superheated2Steam Quality, " x "1ApplicationSteam Cond.:Press.7kg/cm2.gEnthalpy661kcal/kgNTESNarai Thermal Engineering Services

f.propVBA Functions > Module :" fluidproperties "Doc. No.VBA - FPR - 100Function:prop ( ftp, fnm, temp, utemp, psi, ups, nprop )Date2006. 4. 22.Purpose:to obtain a fluid property.Revision01VariablesSheet No.1of1ftpFluid TypefnmFluid NametempTemp.utempTemp. UnitpsiPress.upsPress. UnitnpropNo. for Property to be obtained-1Sat. Temp.100* Sat. Vapor in case of Sat. Fluid0Molecular Weightkg/kmole28.96451Densitykg/Nm31.2922601804Sat. Liquid2Densitykg/m31.40371335932203Enthalpykcal/kg02304Specific Heat, Meankcal/kg.0.240735Specific Heat, Instkcal/kg.0.2412506Viscositykg/m.h0.080062607Thermal Cond.kcal/m.h.0.0272708Prandtl No.0.71460962962809h = h" - h'kcal/kg0290Surface Tensionkg/m300VcgApplicationFluid :TypeVaporTemp.100NameAirPress.0.5kg/cm2.gCalculation of Mean Specific Heat for Gas:Mole GasN2y8y9y10yInstantaneous, Cpiy6y70.28336629910.28663601970.2895078363kcal/kg.y3y4y50.27599022790.2798483966A9A10y0y1y20.26260764370.26714398920.27171186280.2511163080.25424234540.2582813564A1A2xTemp.2002803604405206006807608409201000x0x1x2x3x4x5x6x7x8x9x10Area calculation using integral, Trapezoidal RuleA=A1 + A2 + =( x1 - x0 ) xy0 + y1+( x2 - x1 ) xy1 + y2+ =216.81kcal/kg22Equal Spacing =x(y0 + 2 y1 + + 2 y9 + y10 ))=216.81kcal/kg2Mean Specific Heat, Cpm=A=A=216.81=0.2710kcal/kg.at 1000 based on 200 Tx10-x01000-200Reading from Data File-N/A-Thermodynamic BasicLiquid:Cv = Cp = CC can be taken as constant over limited temp.Definitionrange without a serious loss of accuracyh=u + p vdu=u2 - u1= C dT=C ( T2 - T1 )= 0Cv=du / dTdh=h2 - h1=du +v dp=C ( T2 - T2 ) + v ( p2 - p1 )=C ( T2 - T1 )Cp=dh / dTHeat AmountH =m dh = m ( h2 - h1 )=m x C x ( T2 - T1 )Ideal Gasdu=u2 - u1= Cv dTCv ( T2 - T1 )*Cpm = Cp dT* Cpm is particularly convenient whenT2dTCp data are available, but h data not.dh=h2 - h1=Cp dT=Cpm dT=Cpm ( T2 - T1 )T1=0.2710140213(1000-200)=216.81T2T1=Cp dT-Cp dT=Cpm2 x T2 - Cpm1 x T100=0.26666030371000-0.2493160981200=216.80Heat AmountH =m dh=m ( h2 - h1 )=m x ( Cpm2 x T2 - Cpm1 x T1 )NTESNarai Thermal Engineering Services

gmix1VBA Functions > Module :" gasmixture "Doc. No.VBA - GMX - 100Date2006. 3. 22.Revision0Sheet No.1of2Function:gmconv ( f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, pgu, no )Purpose:to convert volume% weight%.Variablesf1 ~ f10Formula of Component Mole Gasp1 ~ p10%pugUnit, volume% or weight%nono = nth mg x 10 + prop. no.0Gas MixtureM. Weightkg/kmole1Gas MixtureDensitykg/Nm3-1Dry GasM. Weightkg/kmole-2Dry GasDensitykg/Nm3no=nth mgx10+prop. No.1102M. Weightkg/kmole2203Densitykg/Nm34volume%101005weight%ApplicationGas Mixture Composition :ComponentM. Weightvolume%weight%H2O18.0152106.184CO244.00981015.106N228.01347572.117O231.998844.393SO264.058812.19900.00000.00000.00000.00000.000Total100100.00Properties :Gas MixtureM. Weight29.13309kg/kmoleGas MixtureDensity1.2997818757kg/Nm3Dry GasM. Weight30.3684111111kg/kmoleDry GasDensity1.3548961115kg/Nm3NTESNarai Thermal Engineering Services

gmix2VBA Functions > Module :" gasmixture "Doc. No.VBA - GMX - 100Date2006. 3. 22.Revision0Sheet No.2of2Function:gmprop ( temp, utemp, psi, ups,f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, pgu, no )Purpose:to obtain a gas mixture property.VariablestempTemp.utempTemp. UnitpsiPress.upsPress. Unitf1 ~ f10Formula of Component Mole Gasp1 ~ p10%pugUnit, volume% or weight%no2Densitykg/m31.1204Specific Heat, Meankcal/kg.0.2515Specific Heat, Instkcal/kg.0.2526Viscositykg/m.h0.0657Thermal Cond.kcal/m.h.0.0228Prandtl No.0.7360Gas MixtureM. Weightkg/kmole29.133091Gas MixtureDensitykg/Nm31.2997818757-1Dry GasM. Weightkg/kmole30.3684111111-3Relative Humidity%83.7-4Dew Point46.5ApplicationFluid Cond. :Temp.50Press.200mmH2OGas Mixture Composition :ComponentM. Weightvolume%weight%H2O18.0152106.184CO244.00981015.106N228.01347572.117O231.998844.393SO264.058812.19900.00000.00000.00000.00000.000Total100100.00NTESNarai Thermal Engineering Services

PVVBA Functions > Module :" propertyPV "Doc. No.VBA - PV - 100Date2006. 7. 4.Function:propcircle ( cid, h, nprop )Revision0Purpose:to calculate properties of circle.Sheet No.1of1VariablescidCircle IDmmhCord Height from Centermm+ upward, - downwardnpropNo. for Property to be obtained1Upper Sector Angledeg1802Cord Lengthmm999.999999999111Upper Segment Arc Lengthmm1570.79512Upper Segment Aream20.3926987521Lower Segment Arc Lengthmm1570.79522Lower Segment Aream20.39269875Applicationcid1,000mmh0mmFunction:proppv ( inst, hdtp, hdtp2, vid, tl, hcone, llc, nprop )Purpose:to calculate properties of PV.VariablesinstInstallation1Horizontal2VerticalhdtpHead Type12:1 Ellipsoidal210% Dished3Hemi-spherical4Conical5Flathdtp2Head Type* Other side or top head for vertical installationvidPV IDmmtlPV TL-TLmmhconeCone HeightmmllcLiquid Level from Centermm* for Both Horiz. & Vert.npropNo. for Property to be obtained1VolumeShellm30.78539752Head0.26183Vessel1.04719754Surface AreaShellm23.141595Heal2.34266Vessel5.484197Liquid Surface Aream21.396211Volumeabove Liquid Levelm30.523598333312Surface Aream22.74209521Volumebelow Liquid Levelm30.523599166722Surface Aream22.742095ApplicationinstHorizontalvid1,000mmhdtp2:1 Ellipsoidaltl1,000mmhdtp22:1 Ellipsoidalhcone0mmllc0mmFunction:partialhead ( insthd, hdtp, vid, hcone, h, nprop )Purpose:to calculate partial properties of Head.VariablesinsthdhHeightnprop11VolumeUpper Part of Head0.065449791712Surface Area21VolumeLower Part of Head0.065450208322Surface AreaApplicationinsthdVerticalhdtp2:1 Ellipsoidalh500mmNTESNarai Thermal Engineering Services