Author Topic: Mechanical help...  (Read 10116 times)

0 Members and 1 Guest are viewing this topic.

Water Bear

  • Guest
Mechanical help...
« Reply #15 on: February 24, 2004, 11:45:49 PM »
No I haven't seen any, but  I'll ask around the office.
Is there a formula with that excerpt?
The one I've got is from 1977 chapter 31 ! :roll: And they reference a computer algorthim which I have not been able to find:
H.F. Behls:Computerized Calculation of duct friction (U.S. Bureau of standards, Building Science Series 39, October 1971, p. 363

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Mechanical help...
« Reply #16 on: February 25, 2004, 12:08:06 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Mechanical help...
« Reply #17 on: February 25, 2004, 11:27:33 AM »
Good find CAB! that 37_444.html had the perfect equation...I did away with that Reynolds no. & Darcey equations (too theoretical!)
This one works just fine Pd = (0.109136 x q^1.9)/ d^5.02
Got a couple of hiccups though
*it computes the friction value correctly, but it does not display it correctly
*and the other is that if you enter a diameter and volume it computes everything properly, but if you use the square duct size you just got and the same volume , there is a discrepancy in the velocity--I think it has something to do with the computation of the area_sqft (there is a .91 difference when u convert back and forth from round to square)
*I could probably get rid of the pressure calc, it was needed for Reynold's
Code: [Select]
(defun duct_calc (/) ;     friction volume   pressure
;;;  velocity   diam rey_no   fric_fac
;;;  width     depth area_sqft
;;;  )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                          
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
(/ (log (/ (expt (* square square) 5.0)
   (expt (+ square square) 2.0)
   )
)
   8.0
   )
)
       )
    ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    (* dia 0.914774703)
    )

  ;;  given the diameter returns the area in sq ft
  (defun dia2area (dia)
    (/ (* 0.7854 (expt dia 2.0)) 144.0)
    )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
    )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
    )

  ;;  calc friction
  (defun find_fric ()
    (setq friction (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02)))
    )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                          
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
 depth (getreal "\nEnter duct depth: ")
 )
    )
  (setq volume (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
    )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  depth     width
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  depth     width
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  velocity  (/ volume area_sqft);<==try multiplying area_sqft(0.914774703)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
  diam     (area2dia area_sqft)
  width     (dia2sq diam)
  depth     width
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
(prompt
 "\nYou must enter diameter or Width x Depth ..."
 )
)
       (t
(prompt "\nYou must indicate CFMs or FPM..")
)
       )
     )
    ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x) (prompt (strcat "\n" (car x) (rtos (cdr x) 2 3))))
 (list (cons "Diameter " diam)
(cons "Width    " width)
(cons "Depth    " depth)
(cons "Volume   " volume)
(cons "Velocity " velocity)
(cons "Friction " friction)
)
 )
  (princ)

  ) ; end defun



(defun c:test (/ friction)
  (while (null (setq friction (duct_calc))))
  (print friction)
  (princ)
  )

Water Bear

  • Guest
Mechanical help...
« Reply #18 on: February 25, 2004, 01:17:29 PM »
I corrected the friction display, although now it displays everything to 3 places :shock:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Mechanical help...
« Reply #19 on: February 25, 2004, 01:34:50 PM »
I revised the routine, bring the sledg hammer back.

Altered the
Code: [Select]
(rtos (cdr x) 2 8) to return 8 decimal points
Conversion from sq to rnd to sq works
Velocity is in error due to area formula.
the rnd duct area is ok for velocity but the sq area must be equevalent area.

This is what I came up with... :?


Code: [Select]
(defun duct_calc (/          friction   volume     pressure
                  velocity   diam       rey_no     fric_fac
                  width      depth      area_sqft
                 )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                            
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
                     a ; side A of square duct
                     / loop fuzz b)
    (if (= (type a) 'int); make sure A is a REAL
      (setq a (* a 1.0))
    )
    (setq b    a ; B is target
          fuzz 0.001
          loop t
    )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
             (* 1.3
                (exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
             )
      )
      (if (equal dia2 dia fuzz)
        (setq loop nil) ; done
        (setq b (* b (/ dia dia2)))
      )
    )
    (princ)
    b
  ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
         (/ (log (/ (expt (* square square) 5.0)
                    (expt (+ square square) 2.0)
                 )
            )
            8.0
         )
       )
    )
  ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
  )

;;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
  )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
  )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
  )

  ;;  calc friction
  (defun find_fric ()
    (setq friction (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02)))
  )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                            
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
          depth (getreal "\nEnter duct depth: ")
    )
  )
  (setq volume (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
  )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           ;;depth     width
           velocity  (/ volume area_sqft)
           pressure  (veloc2press velocity)
     )
     (find_fric)
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           ;;depth     width
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
     )
     (find_fric)
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           ;;velocity  (/ volume area_sqft)dia2area
           velocity  (/ volume (dia2area diam))
           pressure  (veloc2press velocity)
     )
     (find_fric)
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
     )
     (find_fric)
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
           diam      (area2dia area_sqft)
           width     (dia2sq diam)
           ;;depth     width
           pressure  (veloc2press velocity)
     )
     (find_fric)
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
        (prompt
          "\nYou must enter diameter or Width x Depth ..."
        )
       )
       (t
        (prompt "\nYou must indicate CFMs or FPM..")
       )
     )
    )
  ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x) (prompt (strcat "\n" (car x) (rtos (cdr x) 2 8))))
          (list (cons "Diameter " diam)
                (cons "Width    " width)
                (cons "Depth    " depth)
                (cons "Volume   " volume)
                (cons "Velocity " velocity)
                (cons "Friction " friction)
                (cons "Area     " area_sqft)
          )
  )
  (princ)
  friction ; return flag, nil if failed
) ; end defun



(defun c:test (/ friction)
  (while (null (setq friction (duct_calc))))
  (print friction)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Mechanical help...
« Reply #20 on: February 25, 2004, 02:00:59 PM »
Good one! ...and suppose that the only values we know are the volume and desired maximum friction?
Code: [Select]
(defun duct_calc (/     friction volume   pressure
 velocity   diam rey_no   fric_fac
 width     depth area_sqft
 )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                          
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
    a ; side A of square duct
    / loop fuzz b)
    (if (= (type a) 'int) ; make sure A is a REAL
      (setq a (* a 1.0))
      )
    (setq b    a ; B is target
 fuzz 0.001
 loop t
 )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
    (* 1.3
(exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
)
   )
      (if (equal dia2 dia fuzz)
(setq loop nil) ; done
(setq b (* b (/ dia dia2)))
)
      )
    (princ)
    b
    ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
(/ (log (/ (expt (* square square) 5.0)
   (expt (+ square square) 2.0)
   )
)
   8.0
   )
)
       )
    ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
    )

;;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
    )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
    )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
    )

  ;;  calc friction
  (defun find_fric ()
    (setq friction (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02)))
    )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                          
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
 depth (getreal "\nEnter duct depth: ")
 )
    )
  (setq volume (getreal "\nEnter total CFM'S: ")
friction (getreal "\nEnter FRICTION value: ")
)
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
    )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction volume)
     (setq diam     (exp
      (/ (log (/ (* 0.109136 (expt volume 1.9)) friction)) 5.02)
      )
  area_sqft (dia2area diam)
  width     (dia2sq diam)
  depth     width
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  ;;depth     width
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  ;;depth     width
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  ;;velocity  (/ volume area_sqft)dia2area
  velocity  (/ volume (dia2area diam))
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
  diam     (area2dia area_sqft)
  width     (dia2sq diam)
  ;;depth     width
  pressure  (veloc2press velocity)
  )
     (find_fric)
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
(prompt
 "\nYou must enter diameter or Width x Depth ..."
 )
)
       (t
(prompt "\nYou must indicate CFMs or FPM..")
)
       )
     )
    ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x)
    (prompt (strcat "\n" (car x) (rtos (cdr x) 2 8)))
    )
 (list (cons "Diameter " diam)
(cons "Width    " width)
(cons "Depth    " depth)
(cons "Volume   " volume)
(cons "Velocity " velocity)
(cons "Friction " friction)
(cons "Area     " area_sqft)
)
 )
  (princ)
  friction ; return flag, nil if failed
  ) ; end defun



(defun c:test (/ friction)
  (while (null (setq friction (duct_calc))))
  (print friction)
  (princ)
  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Mechanical help...
« Reply #21 on: February 25, 2004, 02:19:13 PM »
Cleaned it up a bit.
Adjusted the input filter logic.

Code: [Select]
(defun duct_calc (/          friction   volume     pressure
                  velocity   diam       rey_no     fric_fac
                  width      depth      area_sqft
                 )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                            
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
                     a ; side A of square duct
                     / loop fuzz b)
    (if (= (type a) 'int) ; make sure A is a REAL
      (setq a (* a 1.0))
    )
    (setq b    a ; B is target
          fuzz 0.001
          loop t
    )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
             (* 1.3
                (exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
             )
      )
      (if (equal dia2 dia fuzz)
        (setq loop nil) ; done
        (setq b (* b (/ dia dia2)))
      )
    )
    (princ)
    b
  ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
         (/ (log (/ (expt (* square square) 5.0)
                    (expt (+ square square) 2.0)
                 )
            )
            8.0
         )
       )
    )
  ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
  )

  ;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
  )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
  )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
  )

  ;;  calc friction
  (defun find_fric ()
    (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02))
  )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                            
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
          depth (getreal "\nEnter duct depth: ")
    )
  )
  (setq volume   (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq friction (getreal "\nEnter FRICTION value: "))
  )
  (if (null (and (or diam (and width depth)) volume friction))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
  )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction volume)
     (setq diam      (exp
                       (/ (log (/ (* 0.109136 (expt volume 1.9)) friction)) 5.02)
                     )
           area_sqft (dia2area diam)
           width     (dia2sq diam)
           velocity  (/ volume area_sqft)
           pressure  (veloc2press velocity)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           velocity  (/ volume area_sqft)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
     
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           velocity  (/ volume (dia2area diam))
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
           diam      (area2dia area_sqft)
           width     (dia2sq diam)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
        (prompt
          "\nYou must enter diameter or Width x Depth ..."
        )
       )
       (t
        (prompt "\nYou must indicate CFMs or FPM..")
       )
     )
    )
  ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x)
             (prompt (strcat "\n" (car x) (rtos (cdr x) 2 8)))
           )
          (list (cons "Diameter " diam)
                (cons "Width    " width)
                (cons "Depth    " depth)
                (cons "Volume   " volume)
                (cons "Velocity " velocity)
                (cons "Friction " friction)
          )
  )
  (princ)
  friction ; return flag, nil if failed
) ; end defun



(defun c:test (/ friction)
  (while (null (setq friction (duct_calc))))
  (print friction)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Mechanical help...
« Reply #22 on: February 25, 2004, 02:31:08 PM »
Excellent stuff CAB! Now I've got something usable! The only thing I think I need is to make it loop while trying different square size combinations. Thanx, I really appreciate all your help... :D

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Mechanical help...
« Reply #23 on: February 25, 2004, 03:10:59 PM »
Any time...

Changed the print function to allow nil in case you pressed Enter to all prompts.

This TEST routine will loop until Escape or Enter to all.

Code: [Select]
(defun duct_calc (/          friction   volume     pressure
                  velocity   diam       rey_no     fric_fac
                  width      depth      area_sqft
                 )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                            
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
                     a ; side A of square duct
                     / loop fuzz b)
    (if (= (type a) 'int) ; make sure A is a REAL
      (setq a (* a 1.0))
    )
    (setq b    a ; B is target
          fuzz 0.001
          loop t
    )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
             (* 1.3
                (exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
             )
      )
      (if (equal dia2 dia fuzz)
        (setq loop nil) ; done
        (setq b (* b (/ dia dia2)))
      )
    )
    (princ)
    b
  ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
         (/ (log (/ (expt (* square square) 5.0)
                    (expt (+ square square) 2.0)
                 )
            )
            8.0
         )
       )
    )
  ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
  )

  ;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
  )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
  )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
  )

  ;;  calc friction
  (defun find_fric ()
    (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02))
  )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                            
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
          depth (getreal "\nEnter duct depth: ")
    )
  )
  (setq volume (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq friction (getreal "\nEnter FRICTION value: "))
  )
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
  )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                          
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction volume)
     (setq diam      (exp
                       (/ (log (/ (* 0.109136 (expt volume 1.9)) friction)) 5.02)
                     )
           area_sqft (dia2area diam)
           width     (dia2sq diam)
           velocity  (/ volume area_sqft)
           pressure  (veloc2press velocity)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           velocity  (/ volume area_sqft)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )

    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
           width     (dia2sq diam)
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           velocity  (/ volume (dia2area diam))
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
           diam      (area2dia area_sqft)
           volume    (* area_sqft velocity)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
           diam      (area2dia area_sqft)
           width     (dia2sq diam)
           pressure  (veloc2press velocity)
           friction  (find_fric)
     )
    )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
        (prompt
          "\nYou must enter diameter or Width x Depth ..."
        )
       )
       (t
        (prompt "\nYou must indicate CFMs or FPM..")
       )
     )
    )
  ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x)
             (prompt (strcat "\n"
                             (car x)
                             (if (cdr x)
                               (rtos (cdr x) 2 8)
                               "X"
                             )
                     )
             )
           )
          (list (cons "Diameter " diam)
                (cons "Width    " width)
                (cons "Depth    " depth)
                (cons "Volume   " volume)
                (cons "Velocity " velocity)
                (cons "Friction " friction)
          )
  )
  (princ)
  friction ; return flag, nil if failed
) ; end defun



(defun c:test (/ friction)
  (while (setq friction (duct_calc)))
  (print friction)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Water Bear

  • Guest
Mechanical help...
« Reply #24 on: February 25, 2004, 04:30:51 PM »
added for known diameter and friction, compute volume, velocity and square
Code: [Select]
(defun duct_calc (/     friction volume   pressure
 velocity   diam rey_no   fric_fac
 width     depth area_sqft
 )

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                          
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
    a ; side A of square duct
    / loop fuzz b)
    (if (= (type a) 'int) ; make sure A is a REAL
      (setq a (* a 1.0))
      )
    (setq b    a ; B is target
 fuzz 0.001
 loop t
 )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
    (* 1.3
(exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
)
   )
      (if (equal dia2 dia fuzz)
(setq loop nil) ; done
(setq b (* b (/ dia dia2)))
)
      )
    (princ)
    b
    ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
(/ (log (/ (expt (* square square) 5.0)
   (expt (+ square square) 2.0)
   )
)
   8.0
   )
)
       )
    ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
    )

  ;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
    )

  ;;  given the sides returns the area in sq ft
  (defun rec2area (w d) ; retangle to area
    ;;(* (/ (* w d) 144.0) 0.914774703);<=changed
    (/ (* w d) 144.0)
    )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
    )

  ;;  calc friction
  (defun find_fric ()
    (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02))
    )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                          
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
 depth (getreal "\nEnter duct depth: ")
 )
    )
  (setq volume (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq friction (getreal "\nEnter FRICTION value: "))
    )
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
    )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction diam)
     (setq volume    (exp
      (/ (log (/ (* friction (expt diam 5.02)) 0.109136)) 1.9)
      )
  area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction volume)
     (setq diam     (exp
      (/ (log (/ (* 0.109136 (expt volume 1.9)) friction)) 5.02)
      )
  area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  pressure  (veloc2press velocity)
  friction  (find_fric)
  )

     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  velocity  (/ volume (dia2area diam))
  pressure  (veloc2press velocity)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq area_sqft (rec2area width depth)
  diam     (area2dia area_sqft)
  volume    (* area_sqft velocity)
  pressure  (veloc2press velocity)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
  diam     (area2dia area_sqft)
  width     (dia2sq diam)
  pressure  (veloc2press velocity)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
(prompt
 "\nYou must enter diameter or Width x Depth ..."
 )
)
       (t
(prompt "\nYou must indicate CFMs or FPM..")
)
       )
     )
    ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x)
    (prompt (strcat "\n"
    (car x)
    (if (cdr x)
      (rtos (cdr x) 2 8)
      "X"
      )
    )
    )
    )
 (list (cons "Diameter " diam)
(cons "Width    " width)
(cons "Depth    " depth)
(cons "Volume   " volume)
(cons "Velocity " velocity)
(cons "Friction " friction)
)
 )
  (princ)
  friction ; return flag, nil if failed
  ) ; end defun



(defun c:test (/ friction)
  (while (setq friction (duct_calc)))
  (print friction)
  (princ)
  )
Did I cover all possibilities?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Mechanical help...
« Reply #25 on: February 25, 2004, 04:51:23 PM »
All you need now is a DCL version. :D

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

DEVITG

  • Bull Frog
  • Posts: 479
Mechanical help...
« Reply #26 on: February 25, 2004, 05:03:19 PM »
Hi all you, you did a very good program in only two days. :lol:  :D

As a user of ductwork normally the duct are rectangular and often one side is keep constant , just as a matter to suit the space in the ceiling.
Guess you have a free space of 2' the  constant side must be less than 2'  
to allow the isolation and frame space.
Of course that when the side ratio is to big the constant side shall be changed.

Thanks againg..
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Water Bear

  • Guest
Mechanical help...
« Reply #27 on: February 25, 2004, 05:10:59 PM »
Whaaa! :shock:  :shock:

DEVITG

  • Bull Frog
  • Posts: 479
Mechanical help...
« Reply #28 on: February 25, 2004, 06:03:20 PM »
Water Bear, please apologize me.
I just try to express a wish as a user of duct work.

Normally I used a duct calculator rule , the same it had been used since 40 years or more back  from now.

This rule work on the same friction loos expresed on inch of water column by 100 ft  
Usually a fixed valued is used as per economic reazon and the allowable presure to be suited by the fan.
A normal value is set from 0.1 to 0.25 inch water column by 100'
This system allow an easy way to know the total pressure  loos of a system.
Hope you understand me , my english is poor , because I'm not in USA and it is my second language.
 :oops:  :oops:
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Water Bear

  • Guest
Mechanical help...
« Reply #29 on: February 26, 2004, 09:37:52 AM »
OK..I found inconsistencies when square duct sizes were input..corrected that new:
Code: [Select]
(defun duct_calc
       (/ friction volume velocity diam width depth area_sqft)

;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;                      Local Functions                          
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;
  ;;  returns the square side dimension equivelant of rnd duct
  (defun rnd_to_sqr (dia ; dia of round duct
    a ; side A of square duct
    / loop fuzz b)
    (if (= (type a) 'int) ; make sure A is a REAL
      (setq a (* a 1.0))
      )
    (setq b    a ; B is target
 fuzz 0.001
 loop t
 )

    ;;  Returns Side B of square duct
    (while loop
      (setq dia2
    (* 1.3
(exp (/ (log (/ (expt (* a b) 5) (expt (+ a b) 2))) 8))
)
   )
      (if (equal dia2 dia fuzz)
(setq loop nil) ; done
(setq b (* b (/ dia dia2)))
)
      )
    (princ)
    b
    ) ; end defun

  ;;  given the area in square feet returns the diameter
  (defun area2dia (sf_area / square)
    (setq square (sqrt (* sf_area 144.0)))
    (* 1.3
       (exp
(/ (log (/ (expt (* square square) 5.0)
   (expt (+ square square) 2.0)
   )
)
   8.0
   )
)
       )
    ) ; end defun

  ;;  given diameter returns the side dimension
  (defun dia2sq (dia)
    ;;(* dia 0.914774703)
    ;;(*(sqrt area_sqft)12)
    (setq depth (* (sqrt area_sqft) 12)) ; CAB
    (rnd_to_sqr dia depth) ; CAB
    )

  ;; given the diameter returns the area in sq ft
  (defun dia2area (dia)
    ;;(/ (* 0.7854 (expt dia 2.0)) 144.0)
    (/ (* pi (expt (/ dia 2.0) 2.0)) 144.0) ; CAB
    )

  ;;given a square duct, make it round<=====added this
  (defun make_round (w d)
    (* 1.3
       (exp
(/ (log (/ (expt (* w d) 5.0)
   (expt (+ w d) 2.0)
   )
)
   8.0
   )
)
       )
    )

  ;;  given the diameter returns the area in sq ft
  (defun veloc2press (vel)
    (expt (/ vel 4005.00) 2)
    )

  ;;  calc friction
  (defun find_fric ()
    (/ (* 0.109136 (expt volume 1.9)) (expt diam 5.02))
    )


;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
;;;================================================================
;;;                    Start of Routine                          
;;;================================================================
;;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-


  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                    Get User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (prompt "\nEnter known values. Press Enter if not known. ")
  (setq diam (getreal "\nEnter duct diameter: "))
  (if (null diam) ; skip if diameter entered
    (setq width (getreal "\nEnter duct width: ")
 depth (getreal "\nEnter duct depth: ")
 )
    )
  (setq volume (getreal "\nEnter total CFM'S: "))
  (if (null (and (or diam (and width depth)) volume))
    (setq friction (getreal "\nEnter FRICTION value: "))
    )
  (if (null (and (or diam (and width depth)) volume))
    (setq velocity (getreal "\nEnter Velocity in FPM: "))
    )

  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  ;;                Process User Input                        
  ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  (cond
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction diam)
     (setq volume    (exp
      (/ (log (/ (* friction (expt diam 5.02)) 0.109136)) 1.9)
      )
  area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and friction volume)
     (setq diam     (exp
      (/ (log (/ (* 0.109136 (expt volume 1.9)) friction)) 5.02)
      )
  area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam volume)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  velocity  (/ volume area_sqft)
  friction  (find_fric)
  )

     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and diam velocity)
     (setq area_sqft (dia2area diam)
  width     (dia2sq diam)
  volume    (* area_sqft velocity)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth friction)
     (setq diam    (make_round width depth)
  volume   (exp
     (/ (log (/ (* friction (expt diam 5.02)) 0.109136))
1.9
)
     )
  velocity (/ volume (dia2area diam))
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth volume)
     (setq diam    (make_round width depth)
  velocity (/ volume (dia2area diam))
  friction (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and width depth velocity)
     (setq diam    (make_round width depth)
  volume   (* (dia2area diam) velocity)
  friction (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ((and volume velocity)
     (setq area_sqft (/ (/ volume velocity) 0.914774703)
  diam     (area2dia area_sqft)
  width     (dia2sq diam)
  friction  (find_fric)
  )
     )
    ;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    (t
     (cond
       ((or volume velocity)
(prompt
 "\nYou must enter diameter or Width x Depth ..."
 )
)
       (t
(prompt "\nYou must indicate CFMs or FPM..")
)
       )
     )
    ) ; end cond stmt
  (textscr)
  (mapcar '(lambda (x)
    (prompt (strcat "\n"
    (car x)
    (if (cdr x)
      (rtos (cdr x) 2 2)
      "X"
      )
    )
    )
    )
 (list (cons "Diameter " diam)
(cons "Width    " width)
(cons "Depth    " depth)
(cons "Volume   " volume)
(cons "Velocity " velocity)
(cons "Friction " friction)
)
 )
  (princ)
;friction ; return flag, nil if failed
  ) ; end defun



(defun c:test (/ friction)
  (while (setq friction (duct_calc)))
  (print friction)
  (princ)
  )