VBA for MEP Calculations

12
Tuesday, June 23, 2009 VBA for MEP Calculations Application တြထ Programming အမ းမ သံ းလ ရပါတယ္။ အထ သံ းတတ္ရင္ အခ န္က န္ သက္သာေစတ VBA (Visual Basics for Application) က သံ းၿပ Engineering Formula Functions တြ ရးတာ က တ္ဆက္ေပး ရည္ရြယ္ထားပါတယ္။ အဓ က သံ းမ နရာ က တာ့ spread sheet (Microsoft Excel) အတြက္ ပါ။ တကယ္ေတာ့ VBA က MS Offices တြ၊ Web Script တြ အတြက္ သာ မက AutoCad ® ာလည္း အသံ းျပ ကာင္းတ programming တစ္ခ ပါ။ AutoCad ® က သံ းတ ေတြ အတြက္ AutoLisp, vBA, Diesel, Script စတ programming အခ ႕က နားလည္ရင္ ထပ္တလ ပ္ရတ process တြ က အခ န္က န္ သက္သာစြာ ပ္ေဆာင္ င္ပါတယ္။ ရႈတ္ရႈတ္ေထြးေထြး တြက္ခ က္ဘ အပ္တာေတြ၊ Trial and error Loop ႔တြက္ရတာေတြ အတြက္လည္း တစ္ႀက မ္ စနစ္တက ခါင္းရႈတ္ခံ က္ရင္ နာက္တစ္ခါ သံ းဘ အဆင္သင္ဖစ္ေစပါမယ္။ Contents I. Basic of Programming II. VBA for Excel III. Developing Programming Flowcharts for HVAC Air-Side Circular Duct Sizing Calculations (SI Units) IV. VBA Codes for Air Duct (SI Units) V. Screenshots: Adding VBA Codes in Excel VI. Screenshots: Use of VBA Functions in Excel Worksheet VII. Html Color Coding by VBA VIII. References I. Basic of Programming Programming Languages အလ က္ Detail အမ းမ ဖစ္ႏ င္ေပမ basic instructions အခ ကေတာ့ Languages င္းလ ာပါဝင္ေနတာ တြ႕ရပါမယ္။ input: Get data from the keyboard, a file, or some other device. output: Display data on the screen or send data to a file or other device. Math / Operation : Perform basic mathematical operations like addition and multiplication. conditional execution: Check for certain conditions and execute the appropriate sequence of statements. repetition: Perform some action repeatedly, usually with some variation. ဒါေတြရ အေျခခံ တြ က Algorithm (or) Pseudocode and Program Flow Chart တြန ပလ ရပါတယ္။ Modular programming ႔ေခၚတ Program အေသးေလး တြ အပ င္းလ က္ အကန္႔လ က္ အစ တ္စ တ္ းျခားခြ ရးၿပ ပါင္းစပ္ သံ းတ အခါ ရးရတာေရာ၊ debug ပ္ရတာေရာ လြယ္က လာပါတယ္။ Program ရးတ အခါ စနစ္ တက Planning ပ္ထားခ ့ဘ အပ္ပါတယ္။ မဟ တ္ရင္ အမ ားရ ာရ ပင္ရ စတ Debugging ပ္ရတာ က ရးရတာထက္ အဆေပါင္း ားစြာ ခက္ေစရံ သာမက Crush ဖစ္တ နာ တြက ပါ ထပ္ရ င္း နရပါလ မ္အံ းမယ္။ Programming Flowchart ပတ္သက္ၿပ http://www.nos.org/htm/basic2.htm သြား ရာက္ လ့လာ င္ပါတယ္။ အဓ က သင့္တာ ကေတာ့ Start / End : အစ အဆံ (Programming င္းမ အစ (Start) အဆံ (End) ပါဝင္ရပါမယ္။) ႕ရ ပံ က ထာင့္က လံ းထားတ စတ ဂံ ပံ ပါ။ Process : Computational steps or processing function of a programပံ က းရ စတ ဂံပံ ပါ။ Decision Making and Branching႐ြမ္းဗတ္ ပံ ...Back to Top .... II. VBA for Excel Excel အတြက္ VBA Application က ေလ့လာတ အခါ သင့္တာေတြ ကေတာ့၊ VB for Application VB for Excel Application Download Zawgyi-One Font Content (မာတ ကာ) CAD & Design Tools Singapore: M&E and AutoCAD Revit MEP 2010 MEP Systems M&E Systems vs Buildings M&E Systems တာ ဘာေတြလ Scope of M&E Systems M&E: နရာ ာထားသတ္မ တ္ျခင္း M&E Architectural င္း M&E က န္က စရ တ္ M&E Design: High-Rise Buildings Testing & Commissioning Process HVAC HVAC: Introduction to Design HVAC: Building in Hot & Humid Climate M&E Basics: Pipe & Duct Sizing HVAC: Duct Sizing with VBA HVAC: Duct Sizing Automatic Control Systems HVAC Control (01) : FCU Plumbing Sanitary Plumbing: Introduction Domestic Water Supply: Introduction Water Tanks ( ရကန္ ား ) Swimming Pools Swimming Pools (ရက းကန္ ား) Fire Protection Fire Protection : Introduction Smoke Control: Pressurization Systems Fire Sprinkler (Wet) System, S'pore မန္မာျပည္ ၿမ ့ေတာ္ းမ ား ဘးကာကြယ္ေရး။ Electrical Electrical Power Distribution Sustainable, Green and Environment Green Buildings: USGBC's LEED/    S'pore GreenMark Understanding LEED Green Energy Clean Air: လေကာင္းေလသန္႕ Clean Water: ရေကာင္းေရသန္႔ 0 More Next Blog» Create Blog Sign In

description

VBA for MEP

Transcript of VBA for MEP Calculations

Page 1: VBA for MEP Calculations

Tuesday, June 23, 2009

VBA for MEP Calculations

Application ေတြထ မာ Programming အမးမး သးလ႔ ရပါတယ။ ဒအထ မာ သးတတရင အခနကန သကသာေစတ VBA (VisualBasics for Application) ကသးၿပး Engineering Formula Functions ေတြ ေရးတာ က မတဆကေပး ဘ႔ ရညရြယထားပါတယ။အဓက သးမ ေနရာ က ေတာ spread sheet (Microsoft Excel) အတြက ပါ။ တကယေတာ VBA က MS Offices ေတြ၊ WebScript ေတြ အတြက သာ မက AutoCad ® မာလညး အသးျပလ႔ ေကာငးတ programming တစခပါ။ AutoCad ® ကသးတသေတြ အတြက AutoLisp, vBA, Diesel, Script စတ programming အခ႕က နားလညရင ထပတလလ လပရတ process ေတြက အခနကန သကသာစြာ န႔ လပေဆာင ႏငပါတယ။ ရႈတရႈတေထြးေထြး တြကခကဘ႔ လအပတာေတြ၊ Trial and error Loopန႔တြကရတာေတြ အတြကလညး တစႀကမ စနစတက ေခါငးရႈတခ လကရင ေနာကတစခါ သးဘ႔ အဆငသင ျဖစေစပါမယ။

ContentsI. Basic of Programming

II. VBA for ExcelIII. Developing Programming Flowcharts for HVAC Air-Side Circular Duct Sizing Calculations (SI

Units)IV. VBA Codes for Air Duct (SI Units)V. Screenshots: Adding VBA Codes in Excel

VI. Screenshots: Use of VBA Functions in Excel WorksheetVII. Html Color Coding by VBA

VIII. References

I. Basic of ProgrammingProgramming Languages အလက Detail အမးမး ျဖစႏငေပမ basic instructions အခ႕ ကေတာ Languagesတငးလလ မာပါဝငေနတာ ေတြ႕ရပါမယ။

input: Get data from the keyboard, a file, or some other device.output: Display data on the screen or send data to a file or other device.Math / Operation : Perform basic mathematical operations like addition and multiplication.conditional execution: Check for certain conditions and execute the appropriate sequence ofstatements.repetition: Perform some action repeatedly, usually with some variation.

ဒါေတြရ အေျခခ ေတြ က Algorithm (or) Pseudocode and Program Flow Chart ေတြန႔ ျပလ႔ ရပါတယ။ Modularprogramming လ႔ေခၚတ Program အေသးေလး ေတြ အပငးလက အကန႔လက အစတစတ သးျခားခြ ေရးၿပး မ ေပါငးစပသးတ အခါ ေရးရတာေရာ၊ debug လပရတာေရာ လြယကလာပါတယ။Program ေရးတ အခါ စနစ တက Planning လပထားခဘ႔ လအပပါတယ။ မဟတရင အမားရာရ ျပငရ စတ Debuggingလပရတာ က ေရးရတာထက အဆေပါငး မားစြာ ပခကေစရ သာမက Crush ျဖစတ ျပနာ ေတြကပါ ထပရငး ေနရပါလမအးမယ။

Programming Flowchart န႔ ပတသကၿပး http://www.nos.org/htm/basic2.htm မာ သြား ေရာက ေလလာႏငပါတယ။ အဓက သသငတာ ကေတာ

Start / End : အစ န႔ အဆး (Programming တငးမာ အစ (Start) န႔ အဆး (End) ပါဝငရပါမယ။) သ႕ရ ပကေထာငက လးထားတ စတဂ ပပါ။Process : Computational steps or processing function of a program၊ ပက ရးရး စတဂပပါ။Decision Making and Branching၊ ႐ြမးဗတ ပ။

...Back to Top ....

II. VBA for ExcelExcel အတြက VBA Application ကေလလာတ အခါ သသငတာေတြ ကေတာ၊

VB for ApplicationVB for Excel Application

Download Zawgyi-One Font

Content (မာတကာ)CAD & Design Tools

Singapore: M&E and AutoCADRevit MEP 2010

MEP SystemsM&E Systems vs BuildingsM&E Systems ဆတာ ဘာေတြလ။Scope of M&E SystemsM&E: ေနရာ လာထားသတမတျခငးM&E န႔ Architectural ဒဇငးM&E န႔ ကနကစရတM&E Design: High-Rise BuildingsTesting & Commissioning Process

HVACHVAC: Introduction to DesignHVAC: Building in Hot & Humid ClimateM&E Basics: Pipe & Duct SizingHVAC: Duct Sizing with VBAHVAC: Duct Sizing

Automatic Control SystemsHVAC Control (01) : FCU

PlumbingSanitary Plumbing: Introduction

Domestic Water Supply: Introduction

Water Tanks ( ေရကန မား )

Swimming PoolsSwimming Pools (ေရကးကန မား)

Fire ProtectionFire Protection : IntroductionSmoke Control: Pressurization SystemsFire Sprinkler (Wet) System, S'poreျမနမာျပည ၿမေတာ ေစးမား န႔ မး ေဘးကာကြယေရး။

ElectricalElectrical Power Distribution

Sustainable, Green and EnvironmentGreen Buildings: USGBC's LEED/

   S'pore GreenMarkUnderstanding LEEDGreen EnergyClean Air: ေလေကာငးေလသန႕Clean Water: ေရေကာငးေရသန႔

0 More Next Blog» Create Blog Sign In

Page 2: VBA for MEP Calculations

Files (personal.xls or add-in ".xla", Newer version ".xlsx")Excel VBA Object Model: Excel, Word, AutoCad ® သာမက VBA သးႏငတ Applications ေတြ မာ ObjectModel ေတြရပါတယ။ ဒါမ VBA ကေန လပေဆာငရမ၊ လပေဆာငႏငတ နညးလမးေတြ က ရာေဖြ ႏငဘ႔ပါ။Macro SecurityFunction and Sub: Sub ဆတာ ကေတာ macro အေနန႔ တကရက run လ႔ရတ processes ေတြပါ။ ပါဝငတ နညးလမးအခ႕ က modify လပဘ႔ လတ အခါ macro record လပၿပး မျငမးေလလာႏငပါတယ။ Form ေတြပါ ဒဇငးလပၿပးGraphical User Interface န႔ သးစြႏငပါတယ။ အခတငျပမာ ကေတာ ဒ Sub အေၾကာငး မဟတပါဘး။ Excel SpreadSheet ထမာ Function အေနန႔ တကရက Insert လပ သးႏငမ Function ေတြအေၾကာငးပါ။

...Back to Top ....

III. Developing Programming Flowcharts for HVAC Air-Side Circular Duct Sizing Calculations (SI Units)Cold Air Standard အတြက သးရမ Duct အရြယအစား ေရြးခယတ နညးပါ။ ဒနညး န႔ Pressure Loss က တြကထတ ရငရမ Duct Pressure Loss အေျဖက ± 5% အတြငးမာ ရပါတယ။ သ႕က သးႏငတ Conditions ေတြကေတာ။

Temperature: 5 to 35 °CElevation: 0 to 500mDuct Pressure: -5 to 5 kPa relative to ambient pressure

ဒ အေျခအေန ေတြ က ပမန HVAC အတြက လေလာကပါတယ။အမားအားျဖင Constraints ႏစခရပါတယ။ Velocity န႔ Friction Loss ပါ။ ဒါေၾကာင Duct Size လပတ အခါ Velocityကပ သးရင မားတတပါတယ။Velocity Limits ေတြ န႔ပတသကၿပး Basic Duct Sizing Consideration ေတြက M&E Basics: Pipe & Duct Sizingမာေလလာပါ။ (မတခက၊ ၊ Ducting န႔ Piping က သးသန႔ျပနခြ ဘ႔ စစဥေနပါတယ။)ပထမဆး Circular Duct Size က တြကဘ႔ Function ကေရးရပါမယ။အသးျပမ Calculation Formulae ေတြက ေတာ ASHRAE Handbook: Fundamental ထကေန မျငမးထားပါတယ။

တြကနညး အဆငဆင ကေတာ၊သတမတထားတ Velocity အတြငးဝငတ Duct Size ကတြကမယ။ဒ Duct Size န႔ တြကရင ရမ Pressure Loss ကတြကၿပး သတမတထားတ Limit အတြငးရမရ ၾကညမယ။ဝငေနတယ ဆရင အေျဖရပါၿပ။Limit အတြငး မဟတေသး ရငေတာ သတမတထားတ Pressure Loss Limit အတြငး မဝငမခငး Duct Sizeကျပနေရြး၊ ျပနတြက လပရပါမယ။

ဒ Function ကေရးတ အခါ တြကရ ပၿပးလြယ ကေအာင အက Functions ခြႏစခ ပါ ထညေရးထားပါတယ။ ဒ Functionsသးခ ေပါငးမ အလပ လပပါလမမယ။

i. DuctSize_Cir_mm : Circular Duct Size က တြကထတဘ႔ပါ။ii. DuctFrictionLoss_Pa: Circular Duct Frictioin Loss က တြကထတဘ႔ပါ။iii. f_Colebrook: Colebrook's Friction Factor က တြကထတဘ႔ပါ။

Flowcharts ေတြ က ေရးမယဆရင ဒလေတြ႕ရပါမယ။i. DuctSize_Cir_mm

Engineering ExamsUSA: EIT and FE Exam

------------------------------------Recently Updated

HVAC: Duct Sizing with VBASwimming Pools (ေရကးကန မား)

------------------------------------

mail me: [email protected]

P Please consider the environment before printing.

LabelsAutoCAD (1)CAD (2)Control (2)Electrical (1)Environment (8)Fire Protection (5)General (1)HVAC (10)MEP Design (7)MEP Systems (12)Myanmar (2)Sanitary (1)Singapore (3)Swimming Pools (1)Testing and Commissioning (1)USA-EIT/PE (1)VBA (1)Water Supply (4)

About Me

View my complete profile

Page 3: VBA for MEP Calculations

ii. DuctFrictionLoss_Pa

iii. f_Colebrook

Circular Duct မဟတတ အျခား Duct ေတြ က သးတ အခါ အသငေတာဆး ကေတာ Equivalent Circular Duct ကရာၿပး

Page 4: VBA for MEP Calculations

တြကတ နညးပါ။ HVAC Air-Side မာသးေလ ရတ Air Duct အမးအစား သးခ န႔ သကဆငတ Conversion Formula ေတြ က ေအာကမာေဖာျပထားပါတယ။

ဒ Conversion Formula ေတြ က အသးခထားတ VBA Code ေတြကပါ ထညသြငး ေဖာျပေပးမာ ျဖစပါတယ။ဒ တြကနညး ေတြ က Numerical Programming န႔တြကဘ႔ VBA Code က ေရးရပါတယ။ Excel ထက Visual BasicEditor ေအာကမာပါ။ သးသန႔ ".xla" အျဖစန႔ ထားၿပး Excel အစမာ တကဘ႔ ထားထားတ XLStart ဆတ Folder ကရာၿပးထညခငထည၊ “personal.xls” ဆတ File ထမာပ ျဖစျဖစ ထားလ႔ရပါတယ။ VBA က Macro Security Level ေပၚမတည ၿပး အလပလပခြင ေပးရပါတယ။ Powerful Operation ေတြမ႔ MacroSecurity အေၾကာငးက ေသေသခာခာ ေလလာ သရထားဘ႔ လအပပါတယ။"personal.xls" ဆတာ မရေသးရငေတာ ပထမ Record New Macro လပ၊ စာတစလး ႏစလးရက၊ ဟႏပဒႏပ လပၿပးStop Macro ကႏပ၊ ၿပးလ႔ Visual Basic Editor က ဖြငလကရင "personal.xls" တကလာတာ ေတြ႕ရပါလမမယ။

ေအာကဆး ပငး မာ Excel 2003 န႔ Excel 2007 က Screenshots အခ႕က ထညသြငး ေပးထားပါတယ။

...Back to Top ....

IV. VBA Codes for Air Duct (SI Units)Air Duct Sizing တြကခကရမာ သးနငဘ႔ အတြက VBA Functions ေတြ က ေရးထား ေပးပါတယ။ ေရးထားတFunctions ေတြ ကေတာ။

1. DuctSize_Cir_mm(Air_cmh, Optional dP_Pa = 1, Optional V_mps = 8, Optional e_mm = 0.09)Circular Duct Size က တြကထတဘ႔ပါ။

2. DuctFrictionLoss_Pa(Air_cmh, DuctDia_mm, Optional e_mm = 0.09)Circular Duct Frictioin Loss က တြကထတဘ႔ပါ။

3. f_Colebrook(e_by_D, Re)Colebrook's Friction Factor က တြကထတဘ႔ပါ။

4. DuctR2C(dH, dW)Rectangular Duct ရ Equivalent Circular Duct Diameter က ရာေပးမ Function ျဖစပါတယ။

5. DuctO2C(dH, dW)Oval Duct ရ Equivalent Circular Duct Diameter က ရာေပးမ Function ျဖစပါတယ။

6. DuctC2R(dD, Optional dH = 0)Circular Duct တစခ ရ Equivalent Rectangular Duct Dimension က ရာေပးမ Function ျဖစပါတယ။dH=0 ထားရင Square Duct က ရာေပးပါလမမယ။

7. DuctC2O_Width(dD, Optional dH = 0)Circular Duct တစခ ရ Equivalent Oval Duct Dimension က ရာေပးမ Function ျဖစပါတယ။ dH=0

Page 5: VBA for MEP Calculations

ထားရငေတာ Square duct က round Duct ရထားတ အရြယအစား က ရရပါမယ။ ( ie, a = 2 * b )

8. Function DuctAirFlow_Cir_cmh(dD_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optionale_mm = 0.09)Circular Duct တစခရ Allowable Air Flow (cmh) က တြကထတဘ႔ ျဖစပါတယ။

9. DuctAirFlow_Rec_cmh(dW_mm, dH_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optionale_mm = 0.09)Rectangular Duct တစခရ Allowable Air Flow (cmh) က တြကထတဘ႔ ျဖစပါတယ။

10. DuctAirFlow_Oval_cmh(dW_mm, dH_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optionale_mm = 0.09)Oval Duct တစခရ Allowable Air Flow (cmh) က တြကထတဘ႔ ျဖစပါတယ။

Visual Basic Editor ကဖြငၿပးတ အခါ VBAProject(PERSONAL.XLS) ေအာကမာ Module တစခ က ထညသြငးၿပးကယႏစသကသလ နာမညေပး ရပါမယ။ e.g. AirDuct ၿပးရင Code ေနရာမာ ေအာကက VBA Codes ေတြက Copy &Paste လပဘ႔ပါ။ (Screenshots: No.2 က မျငမး ၾကညပါ။)

'General Section DeclarationOption Base 0 'array baseOption Compare Text Private Const atm As Double = 101.325 ' Atmospheric pressure in kPAPublic Const pi As Double = 3.14159265358979

'Function No. 01: to calculate Circular Duct SizeFunction DuctSize_Cir_mm(Air_cmh, Optional dP_Pa = 1, Optional V_mps = 8, Optional e_mm = 0.09)'Calculate Circular Duct Size, Default for 1Pa/m, 8 m/s and Medium Surface Roughness 0.09mm    Dim dV As Double, dD As Double, dA As Double    Dim dP As Double

    'calc Area which satisfy the velocity limits    dV = V_mps    dA = Air_cmh / (3600# * dV)    dD = (4 * dA / pi) ^ 0.5 * 1000

    'call function for Friction Loss    dP = DuctFrictionLoss_Pa(Air_cmh, dD, e_mm)

    If dP > dP_Pa Then        Do            'Use Power rule estimation for iteration            dD = dD * (dP / dP_Pa) ^ 0.25            dP = DuctFrictionLoss_Pa(Air_cmh, dD, e_mm)            'exit error 1%            If Abs((dP - dP_Pa) / dP_Pa) < 0.01 Then Exit Do        Loop    End If    DuctSize_Cir_mm = dDEnd Function

'Function No. 02: to calculate duct friction lossFunction DuctFrictionLoss_Pa(Air_cmh, DuctDia_mm, Optional e_mm = 0.09)    'Calculate Friction Loss    Dim dQ As Double, dD As Double 'flowrate (m3/s), diameter(mm)    Dim dV As Double, dF As Double 'velocity (m/s), friction factor    Dim dM As Double, dE As Double 'density (kg/m3), surface roughness    Dim Re As Double, dA As Double

    'For Cold Air Standard at density=1.2kg/m3    If Air_cmh * DuctDia_mm > 0 Then

Page 6: VBA for MEP Calculations

        dQ = Air_cmh / 3600# 'convert air flowrate to m3/s        dD = DuctDia_mm        dM = 1.2 'kg/m3 for cold air std        dA = 0.25 * pi * (dD / 1000#) ^ 2        dV = dQ / dA 'v=Q/A        Re = 66.4 * dD * dV 'Ref ASHRAE: or use Re = V * d / nu        dF = f_Colebrook(e_mm / dD, Re)        DuctFrictionLoss_Pa = 500 * dF * dM * dV * dV / dD    Else        DuctFrictionLoss_Pa = 0    End IfEnd Function

'Function No. 03: to calculate Colebrook Friction FactorFunction f_Colebrook(e_by_D, Re) 'e_by_D Relative roughness; Dh: Hydraulic Dia, Re: Reynold number    'Calculate Colebrook friction Factor

    Dim f As Double, root_f As Double, root_f1 As Double

    'Start with Tsal's estimation    f = 0.11 * (e_by_D + 68 / Re) ^ 0.25    If f < 0.018 Then        f = 0.85 * f + 0.0028    End If

    root_f = f ^ 0.5    Do        root_f1 = -0.5 * Log(10) / Log(e_by_D / 3.7 + 2.51 / (root_f * Re))        'check if error is less than 0.5%        If Abs((root_f1 - root_f) / root_f) < 0.005 Then Exit Do        root_f = 0.5 * (root_f + root_f1) 'Use binary approach iteration    Loop    f_Colebrook = root_f ^ 2End Function

'Function No. 04: Equivalent Circular Duct Size of a Rectangular DuctFunction DuctR2C(dH, dW) As Double    'Rectangular Duct to Circular Duct    If dW * dH > 0 Then        DuctR2C = 1.3 * ((dH * dW) ^ 0.625) / ((dH + dW) ^ 0.25)    Else        DuctR2C = 0    End IfEnd Function

'Function No. 05: Equivalent Circular Duct Size of an Oval DuctFunction DuctO2C(dH, dW) As Double    'Oval Duct to Circular Duct    Dim dA As Double, P As Double    If dW * dH > 0 Then        dA = (pi * dH ^ 2 / 4) + dH * (dW - dH)        P = pi * dH + 2 * (dW - dH)        DuctO2C = 1.55 * (dA ^ 0.625) / (P ^ 0.25)    Else        DuctO2C = 0    End IfEnd Function

'Function No. 06: Equivalent Rectangular Duct Dimension of a Circular Duct

Page 7: VBA for MEP Calculations

Function DuctC2R(dD, Optional dH = 0) As Double    'Circular Duct to Rectangular Duct    'if Dimension (dH) is zero, square duct    'dH could be either dimension: "Width" or "Height"    Dim dW As Double, dW1 As Double    Dim dD1 As Double

    If dH > 0 Then        'Estimate dH        dW = 0.25 * pi * dD * dD / dH        Do            dD1 = 1.3 * ((dH * dW) ^ 0.625) / ((dH + dW) ^ 0.25)            dW = dW * (dD / dD1) ^ 2            If Abs((dD1 - dD) / dD) < 0.005 Then Exit Do        Loop    Else        dW = dD * 0.9148    End If    DuctC2R = dWEnd Function

'Function No. 07: Equivalent Oval Duct Dimension of a Circular Duct Function DuctC2O_Width(dD, Optional dH = 0) As Double    'Circular Duct to Rectangular Duct    'if Dimension (dH) is zero, square duct + round, ie, a = 2 * b    'dH is dimension b for "Height", dW is dimension a for "Width"    'As nature, dH < dD    Dim dW As Double, dW1 As Double    Dim dD1 As Double    Dim dA As Double, P As Double

   If dH > 0 Then        'Estimate dH        dW = 0.25 * pi * (dD * dD - dH * dH) / dH        Do            dA = (pi * dH ^ 2 / 4) + dH * (dW - dH)            P = pi * dH + 2 * (dW - dH)            dD1 = 1.55 * (dA ^ 0.625) / (P ^ 0.25)            dW = dW * (dD / dD1) ^ 2            If Abs((dD1 - dD) / dD) < 0.005 Then Exit Do        Loop    Else        dW = dD / 1.5234    End If    DuctC2O_Width = dWEnd Function

'Function No. 08: To Calculate Allowable Air Flow from a Circular Duct.Function DuctAirFlow_Cir_cmh(dD_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optional e_mm = 0.09)    Dim cmh As Double, dP As Double    Dim dD As Double, dV As Double

    dV = dV_mps    dD = dD_mm    cmh = 0.0009 * pi * dD * dD * dV '0.0009 <- 0.25*3600/1000000    dP = DuctFrictionLoss_Pa(cmh, dD, e_mm)    If dP > dP_Pa Then        Do            dV = dV * (dP_Pa / dP) ^ 0.5            cmh = 0.0009 * pi * dD * dD * dV            dP = DuctFrictionLoss_Pa(cmh, dD, e_mm)

Page 8: VBA for MEP Calculations

            If Abs(dP - dP_Pa) / dP_Pa < 0.01 Then Exit Do        Loop    End If    DuctAirFlow_Cir_cmh = cmhEnd Function

'Function No. 09: To Calculate Allowable Air Flow from a Rectangular Duct.Function DuctAirFlow_Rec_cmh(dW_mm, dH_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optionale_mm = 0.09)    Dim dD As Double, dV As Double    dV = dV_mps    dD = DuctR2C(dW_mm, dH_mm)    DuctAirFlow_Rec_cmh = DuctAirFlow_Cir_cmh(dD, dP_Pa, dV_mps, e_mm)End Function

'Function No. 10: To Calculate Allowable Air Flow from an Oval Duct.Function DuctAirFlow_Oval_cmh(dW_mm, dH_mm, Optional dP_Pa = 1, Optional dV_mps = 9, Optionale_mm = 0.09)    Dim dD As Double, dV As Double    dV = dV_mps    dD = DuctO2C(dW_mm, dH_mm)    DuctAirFlow_Oval_cmh = DuctAirFlow_Cir_cmh(dD, dP_Pa, dV_mps, e_mm)End Function

...Back to Top ....

V. Screenshots: Adding VBA Codes in Excel Excel 2002-2003 (or Earlier)

Screenshot No. 1: နမနာ အေနန႔ Microsoft Excel 2002-2003 မာဆရငေတာ ဒလေတြ႕ရပါလမမယ။

Screenshot No. 2: Visual Basic Editor ဆတာ က ႏပလကရင ေအာကက ပစ ေပၚလာပါလမမယ။ အထမာ VBACode ေတြ က ကးယၿပးရင ဒလ ေတြ႔ႏငပါတယ။

Page 9: VBA for MEP Calculations

Excel 2007Screenshot No. 3: 2007 အထက ဆရငေတာ Tools အစား Developer Tab အေနန႔ ဝငလာပါတယ။

Screenshot No. 4: တစခါတစရ Developer Tab က ေဖာက ထားတတပါေသးတယ။ ဒါဆရင ေတာ excel optionေအာကကေန သြားရာ ရပါလမမယ။ (မေသခာ ရင Help မာ ရာၾကညပါ။)

Screenshot No. 5:

အထကမာ ေျပာခတ အတငး VBA က Macro Security Level ေပၚမတည ၿပး အလပလပခြင ေပးရပါတယ။ PowerfulOperation ေတြမ႔ Macro Security အေၾကာငးက ေသေသခာခာ ေလလာ သရထားဘ႔ လအပပါတယ။ Screenshot No.6:

Page 10: VBA for MEP Calculations

Screenshot No. 7:Developer Tab ေအာက က Code ေနရာ မာ လညး Macro Security ဆတာ ရပါတယ။ ထြကလာမScreen ကေတာ။

...Back to Top ....

VI. Screenshots: Use of VBA Functions in Excel Worksheetၿပးရငေတာ ဒ Function ေတြက Excel Spreadsheet မာ အသငသးႏငပါၿပ။ပထမ Insert function ကသြားၿပး select a category မာ User Defined ကေရြးလကရင ဒ Function ေတြေပၚလာပါလမမယ။

ၿပးရငေတာ Excel Formula သးေနက အတငးသးရပါပ။

Page 11: VBA for MEP Calculations

ဒအထ မာ Air_cmh ဆတ ကြကလပကေတာ ျဖညက ျဖညရပါမယ။ အျခား ကြကလပေတြ က Function မာထ ကOptional အေနန႔ ေရြးၿပး Assign လပထားတာမ႔ မျဖညလညး ရပါတယ။ Assigned လပခတ value ေတြကေတာအသးမားတ

dP_Pa = 1V_mps = 8E_mm = 0.09

ၿပး Excel Style: Drag-Coppy လပလကရင ရမ အေျဖကေတာ၊

ဒကရတ အေျဖက Chart ကေနၾကညလ႔ ရတ အေျဖန႔ အတတေလာကပါပ။ တကယ အေသးစတ တြကလ႔ ရမ အေျဖရ ±1% အတြငးမာ ရတာမ႔ safety factor ထညယေလရတ အငဂငနယာ ေတြအတြက လေလာကပါတယ။မတခက။ ။ Excel Calculation Sheet File ေတြ က အျခားသေတြ ဆ ပ႔ေပးရတ အခါမာေတာ ဒ Function VBA Codesေတြ အဒ file ထမာ မပါရင အလပလပ မာ မဟတပါဘး။ အရငးဆး နညးလမးကေတာ Function VBA Codes ေတြထညမေပး ပ Function ေတြ န႔တြက ၿပး ရလာတ အေျဖ ရတ Cell ေတြက အေျဖ က Copy ကး၊ ၿပး Paste Special မာvalues က ေရြးၿပး ျပနထညလကပါ။ Chart ၾကညၿပး Manually ရကထည ထားသလ မးေပါ။

...Back to Top ....

VII. Html Color Coding by VBAအေပၚက VBA code ေတြမာ အေရာငေတြ ခြေပးထားတာ က လညး VBA က သးၿပး html format က ေပးထားလ႔ပါ။ဒါကေတာ MS Word ေအာကမာ ေရးၿပးသးပါတယ။ အပ သပမပါပ ရငးရငးလငးလငး ျမငရေအာင format လပဘ႔က htmlမာ သပ မလြယက လပါဘး။ အခနလညး အရမးကနပါတယ။ သ႕ရ VBA Code ကေတာ ရႈတေထြးတာ မ႔ မေဖာျပေတာပါဘး။

...Back to Top ....

VIII. References1. "Duct Design", Chapter 21, ASHRAE Handbook: Fundamentals, 2009.2. Visual Basic for Applications 3. Using Flow Chart - Flowcharting[ http://www.nos.org/htm/basic2.htm ]4. HVAC Duct Sizing[ http://chawlwin.blogspot.com/2009/07/hvac-duct-sizing.html ]

Page 12: VBA for MEP Calculations

Newer Post Older Post

Disclaimer

Programming န႔ သးလ႔ရတယ ဆတာ က မတဆက ေပးခင လ႔ပါ။ ၿပးေတာ အခနကန သကသာ ေစခငတာလညး ပါပါတယ။ အတတႏငဆး ႀကးစားထားေပမ အမား လးဝကငးပါတယ လ႔ အာမ မခႏငပါဘး။ စာဖတသ ကယတင သးစြၿပး ၾကညၿပး အေျဖမန ေပးႏငေၾကာငး ေသခာမ သးစြပါလ႔ အသေပးလပါတယ။

...Back to Top ....

Posted by Ko Chaw - ကေခာ at 9:53 PM

Labels: HVAC, MEP Design, VBA

NO COMMENTS:

Post a Comment

Home

Subscribe to: Post Comments (Atom)

 

အသေပးခက၊

Construction Industry မာ ဆယစႏစ တစခေကာ အတြငး ရ႐ခ တ အေတြ႕အႀက အခ႔ န႔ လက႐ နညးပညာ အေျခခ ေတြ က မးဆကသစေတြ ဆ လကဆငကမးေပး ႏငဘ႔ န႔ မတဆကေပး ႏငဘ႔ အတြက ပ ရည႐ြယပါတယ။ Blog မာ အခကအလက ေတြ က အတတႏငဆး တကေအာင ေဖာျပထား ေပမ အမားေတြ ပါႏငပါတယ။ အသးခ ႏငဘ႔ကေတာ ကယတင ေလလာ၊ ဆနးစစ ေသေသခာခာ နားလညၿပး တာဝနယႏငမ လပပါ လ႔ တကတြနး လပါတယ။ အမားေတြ႔ရင လညး ျပငဆငခြင႔ ရေအာင [email protected] က အသေပးပါ။ ေကးဇးတငပါတယ။