1 / 22

Assignment

Assignment. Colebrook Formula:. Source Code. PROGRAM colebrook !e = pipe roughness (mm) !d = pipe inside diameter (in) !relruff = relative roughness (dim) !re = Reynolds Number (dim) !f = Darcy-Weisbach Friction Factor (dim) IMPLICIT NONE REAL :: f, f0, f1, re, e, d, relruff

lacey
Download Presentation

Assignment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment • Colebrook Formula:

  2. Source Code • PROGRAM colebrook • !e = pipe roughness (mm) • !d = pipe inside diameter (in) • !relruff = relative roughness (dim) • !re = Reynolds Number (dim) • !f = Darcy-Weisbach Friction Factor (dim) • IMPLICIT NONE • REAL:: f, f0, f1, re, e, d, relruff • INTEGER:: k • WRITE(*,*)'Enter e in mm & D in inches' • READ(*,*) e, d • WRITE(*,*)'Pipe Roughness, e =',e,'mm ','Pipe Diameter, D =',d,'inches' • relruff = e/(d*25.4) • WRITE(*,*)'relative roughness =', relruff • WRITE(*,*)'Enter Reynolds No' • DO k = 1, 6 • READ(*,*) re • f0 = .25*((LOG10((relruff/3.7)+(5.74/(re**.9))))**(-2)) • f1 = (-2.)*LOG10(((relruff/3.7)+(2.51/(re*(f0**.5))))) • f = (1./f1)**2 • WRITE(*,*)'For Reynolds No =',re,'Darcy-Weisbach Friction Factor =',f • END DO • END

  3. Output #1 • c:\FortranSources>colebrook • Enter e in mm & D in inches • .26,.622 • Pipe Roughness, e = 0.26 mm Pipe Diameter, D = 0.622 inches • relative roughness = 1.6456947E-02 • Enter Reynolds No • 3000 • For Reynolds No = 3000.00 D-W Friction Factor = 5.6546558E-02 • 10000 • For Reynolds No = 10000.00 D-W Friction Factor = 4.9191877E-02 • 100000 • For Reynolds No = 100000.0 D-W Friction Factor = 4.5635339E-02 • 1.e06 • For Reynolds No = 1000000. D-W Friction Factor = 4.5242310E-02 • 1.e07 • For Reynolds No = 1.000E+07 D-W Friction Factor = 4.5202494E-02 • 1.e08 • For Reynolds No = 1.000E+08 D-W Friction Factor = 4.5198508E-02

  4. Output #2 • c:\FortranSources>colebrook • Enter e in mm & D in inches • .26,2.067 • Pipe Roughness, e = 0.26 mm Pipe Diameter, D = 2.067 inches • relative roughness = 4.9522114E-03 • Enter Reynolds No • 3000 • For Reynolds No = 3000.000 D-W Friction Factor = 4.7594767E-02 • 10000 • For Reynolds No = 10000.00 D-W Friction Factor = 3.7515681E-02 • 100000 • For Reynolds No = 100000.0 D-W Friction Factor = 3.1220451E-02 • 1.e6 • For Reynolds No = 1000000. D-W Friction Factor = 3.0377490E-02 • 1.e7 • For Reynolds No = 1.000E+07 D-W Friction Factor = 3.0289246E-02 • 1.e8 • For Reynolds No = 1.000E+08 D-W Friction Factor = 3.0280370E-02

  5. Moody Chart

  6. Good Practice Summary • Use meaningful variable names whenever possible. • Always use the IMPLICIT NONE statement. • Create a data dictionary. • Use a consistent number of significant digits in constants. • Specify all constants with as much precision as your computer will support. • Use integer arithmetic only for things that are intrinsically integer, such as indexes and counters. • Avoid mixed-mode arithmetic except for exponentiation. • Use extra parentheses whenever necessary. • Always echo ( i.e. Print) variables you enter into a program. • Initialize all variables in a program before using them. • Always print the physical units associated with any value being written out.

  7. Scientific Programming More & More Basics

  8. New Input Instruction • To input values into a program during execution: • WRITE (*,*) ‘Input a,b,c,etc.’ • READ (*,*) a,b,c,…..

  9. Top Down Program Design

  10. Top Down Program Design An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al-Khwarizmi's work is the likely source for the word algebra as well.

  11. Programming Aids • Flowcharts • Pseudocode

  12. Flowchart Symbols

  13. Flowchart Example

  14. Pseudocode Write each Fortran instruction in the language of your choice • i.e., for the flowchart example: • Prompt user to enter temperature in oF • Read this temperature input • Calculate temperature in K • Write temperature in K

  15. Program Design Summary • I’m going to suggest a less structured approach: • Flowcharting is useful but don’t get stressed trying to use the conventional symbols – the important thing in flowcharting is developing the proper sequence of operations • Use pseudocode to annotate (fill in) the flowchart

  16. Logical Constants & Variables • Logical Constants • C1 = .TRUE. or, C2 = .FALSE. • Logical Variables • a1, a2, a3 – values, .TRUE. or .FALSE., may vary as a result of operation of the program • i.e. – a1 = (logical expression) • LOGICAL:: a1, a2, a3, etc – include with INTEGER:: & REAL:: type statements • READ(*,*) a1, a2, a3 – The input value must begin w/ T or F

  17. Relational Operators • Relational Operators • == Equal To (Note doubling - ==) • /= Not Equal To • > Greater Than • >= Greater Than or Equal To • < Less Than • <= Less Than or Equal To • Examples • 6<8 .TRUE. , 6>8 .FALSE., 6==8 .FALSE. • 6<=8 .TRUE., 6>=8 .FALSE., 6>=6 .TRUE.

  18. Combinational Operators • L1.AND.L2 • .TRUE. If both are .TRUE. • L1.OR.L2 • .TRUE. If either or both are .TRUE. • L1.EQV.L2 • .TRUE. If L1 & L2 are the same • L1.NEQV.L2 • .TRUE. If L1 & L2 are different • .NOT.L1 • Opposite L1

  19. Combinational Operators • Hierarchy of Operations • Arithmetic • Relational L to R • .NOT. • .AND. L to R • .OR. L to R • .EQV. & .NEQV. L to R • Use ( ) to control the order

  20. In-Class Exercise • Given: • REAL:: a=-10., b=.1, c=2.1 • LOGICAL:: L1=.TRUE., L2=.FALSE., L3=.FALSE. • a>b.OR.b>c • (.NOT.a).OR.L1 • L1.AND..NOT.L2 • a<b.EQV.b<c • L1.OR.L2.AND.L3. • L1.OR.(L2.AND.L3) • (L1.OR.L2).AND.L3 • a.OR.b.AND.L1

  21. In-Class Exercise • Given: • REAL:: a=-10., b=.1, c=2.1 • LOGICAL:: L1=.TRUE., L2=.FALSE., L3=.FALSE. • a>b.OR.b>c FALSE • (.NOT.a).OR.L1 INVALID • L1.AND..NOT.L2 TRUE • a<b.EQV.b<c TRUE • L1.OR.L2.AND.L3. TRUE • L1.OR.(L2.AND.L3) TRUE • (L1.OR.L2).AND.L3 FALSE • a.OR.b.AND.L1 INVALID

  22. Assignment • Read & Understand The Material In This Slide Set • Construct A Flowchart w/ Pseudocode To Evaluate The Roots Of A Quadratic Equation, Including Complex Roots

More Related