TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Water Bear on February 06, 2004, 08:47:20 PM
-
I came across this formula for calculating the circular equivalent of a rectangular duct and I managed to string it out so it works...here it is:
(* 1.3 (exp(/(log (/ (expt (* A B) 5) (expt (+ A B) 2)))8)))
where A and B are reals; solves for D (diameter)
I wonder if someone could rearrange this equation ,so that if I knew :
B and D I could find A or if I knew A and D I could find B
Go ahead, give it shot...I've only been on it ALL day! :oops:
-
This looks like a challenge!
Is this really what expt is?
Function EXP, EXPT
Syntax:
exp number => result
expt base-number power-number => result
Arguments and Values:
number---a number.
base-number---a number.
power-number---a number.
result---a number.
Description:
exp and expt perform exponentiation.
exp returns e raised to the power number, where e is the base of the natural logarithms. exp has no branch cut.
expt returns base-number raised to the power power-number. If the base-number is a rational and power-number is an integer, the calculation is exact and the result will be of type rational; otherwise a floating-point approximation might result. For expt of a complex rational to an integer power, the calculation must be exact and the result is of type (or rational (complex rational)).
The result of expt can be a complex, even when neither argument is a complex, if base-number is negative and power-number is not an integer. The result is always the principal complex value. For example, (expt -8 1/3) is not permitted to return -2, even though -2 is one of the cube roots of -8. The principal cube root is a complex approximately equal to #C(1.0 1.73205), not -2.
expt is defined as b^x = e^x log b. This defines the principal values precisely. The range of expt is the entire complex plane. Regarded as a function of x, with b fixed, there is no branch cut. Regarded as a function of b, with x fixed, there is in general a branch cut along the negative real axis, continuous with quadrant II. The domain excludes the origin. By definition, 0^0=1. If b=0 and the real part of x is strictly positive, then b^x=0. For all other values of x, 0^x is an error.
When power-number is an integer 0, then the result is always the value one in the type of base-number, even if the base-number is zero (of any type). That is:
(expt x 0) == (coerce 1 (type-of x))
If power-number is a zero of any other type, then the result is also the value one, in the type of the arguments after the application of the contagion rules in Section 12.1.1.2 (Contagion in Numeric Operations), with one exception: the consequences are undefined if base-number is zero when power-number is zero and not of type integer.
-
that's it... Now I've thrown down the gaunlet! :shock:
-
take a look at the brackets. one too many.
9 "(" and only 8 ")"
-
(setq b (/ (* pi (expt (/ d 2) 2)) a))
-
syntax is correct ..substitute 12.0 for all A's and B's then run it in editor should come up with 13.118
-
Good try CAB! but if you use 12.0 for both A and B, the circular equivalent is 13.118...therefore if you use these as input 13.118 as D and 12.0 as A ,you should logically derive 12.0 as B. Yours comes up with 11.2627
-
i did not get 13.118 as dia, i got 13.5406
(defun c:test()
(setq a 12.0
b 12.0
area (* a b)
)
(setq dia (* (sqrt(/ area pi)) 2))
(setq b (/ (* pi (expt (/ dia 2) 2)) a))
(princ)
)
(princ)
-
mohobrien,
your way over my head :)
CAB
-
AH! therein lies the rub! ASHRAE (american Society of heating, refrigerating and ac engineers) say that the equivalent area in sq inches is NOT the same once you changed the shape of the duct because of friction losses. That is why they use the equation I posted. :roll:
-
Oh, I see, not equivalent area but equivalent flow characteristics.
I did find the formula but the math is too much for me. Perhaps
someone can convert it.
(http://www.theswamp.org/lilly.pond/CAB/Duct%20Formula.jpg)
-
My last math class was 1969. I don't think I could have figured this one then either.
But I see why my back bedroom was so cold when the temp went to -48C last week. I used corrugated tin foil for ducting and I hear that five feet of that is like trying to push heat down 250 feet of straight pipe.
Back to topic:
I'm out of my league. All I can say is you'd have to use differential equations to figure it the other way. I'm lost.
(* 1.3
(exp (/ (log (/ (* 248832.0(* B B B B B) )
(+ 144 (* 24 B) (* B B))
)
)
8
)
)
)
-
That 's the one CAB! Don't feel bad guys..I've been on this one LONG time and haven't figured it out yet! Small minds=lower tax brackets...I'm in the lowest.
Maybe the heavy hitters like Stig or Keith, Daron or Se7en can have a go at it.... :D
-
Ok, I have looked at this and to be quite honest with you, my algebra is a little rusty.
What I have managed to decipher basically gets you down to the point where the quadratic formula "should" come into play, but after looking at it for a bit, I am confused about how to exactly get the answer to an equation that requires the variable from another equation.
For example....
X = AB^5
Y = (A+B)^2
Z = X/Y
Z is known
A is known
B is unknown
So, the problem is you must calculate X or Y before you can calculate Z
Now if anyone can solve this bit of the equasion for X and/or Y I can finish the modifications.
-
Exactly Keith...that was about as far as I got, could not figure out how to isolate A or B
Perhaps someone has an alternate way.. the problem is that this is the equation to calc a round IF you know the square size..problem is I'm starting with a round and need to go to square (or rectang) :(
-
On a different note:
If you use a math software like MathCAD, you can input the formula and define the variables.
It will then allow you assign values to some and tell you what the remaining variable needs to be to satisfy the equation.
If you can derive the Lisp equivalent, look here.
http://www.mathcad.com/products/
-
When all else fails use a Sledge Hammer. :shock:
CAB
(defun Rnd_to_Sqr(Dia ; dia of round duct
A ;; side A of square duct
/ loop fuzz B)
;; Returns Side B of square duct
(setq B A ; B is target
fuzz 0.001
loop T)
(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
)
(princ)
(defun c:test()
(setq SideA 12.0
dia 13.118
SideB (Rnd_to_Sqr dia SideA)
)
(princ)
)
-
CAB ..I wouldn't believe it if I hadn't seen it with my own eyes! Idon't quite understand HOW u made it work..but it works! :D Bravo! and thank you
-
Water Bear,
Here's your conversion formulas:
To get A, B & D known: A = (0.836812758 x D X D) / B
To get B, A & D known: B = (0.836812758 x D X D) / A
Above formulas were derived from round to square formula:
Round to Square (A=B): A = 0.914774703 x D
You can also use an iteration loop in lisp based on the
original formula (as posted by CAB).
Have fun.
Don
-
Thanx Don ..those sure make it easy
I compared various examples using a Trane ductulator with CAB's hammer, and he is VERY accurate...
thanx again, and welcome to the club. :wink:
-
Revised the routine to make sure A is a real, else it won't work.
Don you formula only works if sides are 12x12?
(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
)
(princ)
-
I've tried Don's but I get inconsistent results. Case in point:
25 inch round to something by 12
(0.836812758 x 25 X 25) / 12 = 43.58399
Trane ductulator indictates it should be 49
If I use CAB's hammer I get 48.8559 :roll: close enough for me!
That's almost a 260 sq in difference.
-
However,in all fairness to Don, using his original equation I get:
0.914774703 x 25.0 = 22.869367575
compared using ASHRAE formula:
(* 1.3 (exp(/(log (/ (expt (* 22.869367575 22.869367575) 5) (expt (+ 22.869367575 22.869367575) 2)))8)))
the answer comes up 25.0!
And plugging into CABs'hammer:
(Rnd_to_Sqr 25.0 22.869367575) you get 22.8694 :P
Q.E.D.
-
WaterBear,
In the formulas I've posted, the round to square is the
accurate one since it was derived from the ASHRAE formula.
Since you're the one in need of a shorcut, you can verify
the accuracy of the formula for all cases. I repeat, I can
vouch for the accuracy on round to square cases only. The
formulas for the rectangular duct was derived using an equal
area method using the area of the square duct equivalent of
the round duct. I've not tested the conversion formulas and
the accuracy might be questionable. Sorry for the confusion,
as I was hoping that you'll be able to see through the formulas.
-
Don't get me wrong I fully appreciate your taking time out to assist in this puzzle...
Everyone has a different angle of attack for a given problem, which is why I come here.
Just for the record, I ended up using a combination of BOTH methods!
Thanx again.... :D
-
I am not that good at math. Stig, is my algebra go to.
-
After searching and asking a lot about it I got this answer from the EFUNDA.
I had post on the lily pond at this link , it is a xls file that allow to calc the b side given the diameter and the a side.
It explain it self and give the credit to ACRODUSTER1 , a fellowmember of EFUNDA .
http://theswamp.org/lilly.pond/devitg/red2rect.xls
efunda could be found at
http://www.efunda.com/forum/forum.cfm
-
I am not that good at math. Stig, is my algebra go to.
Daron, that kinda made me feel obliged to answer! *GRRRRrrr*
But, I could only get as far as D^4/1.3^4 = (A^2.5 * B^2.5)/(A + B) ... soooo, I went to a math guy and he cracked it! Only took him a few month :)
Here's his formula written for AutoLISP:
(defun testit (s1 s2)
(* 1.3 (/ (expt (* s1 s2) 0.625)(expt (+ s1 s2) 0.25)))
)
(defun C:EQDUCT (/ a b d di x1 x2 y)
(setq di (getreal "\nEnter diameter of round duct: ")
b (getreal "\nEnter side in rectangular duct: ")
)
(setq d (/ (expt di 4.0) (expt 1.3 4.0)) ;;2.8561)
y (sqrt b)
x1 (* (expt (/ (* 2 d) (* 5 (expt y 5.0))) (/ 1.0 3.0)) 2.0)
x2 (- x1
(/ (- (* (expt y 5.0) (expt x1 5.0))
(* d (expt x1 2.0))
(* d (expt y 2.0))
)
(- (* 5.0 (expt y 5.0) (expt x1 4.0))
(* 2.0 d x1)
)
)
)
)
(setq a (expt x2 2.0))
(mapcar 'princ (list "\nMissing side = "
(fix a)
"\nTest: Input diameter: " di
"\n Calculated diam.: " (setq d (testit a b))
)
)
(princ)
)
There is a built-in deviation of 4-5% but it can be controlled by putting it into a loop like (while (< (/ (abs (- x2 x1))(abs x2)) n) ... ) where n is the allowed accuracy.