Performing Manual and Automated Iterations in Engineering Equation Solver (EES) - Examples from Heat Transfer.
All the EES codes shown in the examples are available at: https://goo.gl/KExGFi
1. Performing
Manual and Automated Iterations
in
Engineering Equation Solver (EES)
Examples from Heat Transfer
Naveed ur Rehman
http://www.naveedurrehman.com/
4th June, 2018
2. All the EES codes shown in the
examples are available at:
https://goo.gl/KExGFi
2
4. A problem that doesn’t require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑎 for ‘Air’
Find 𝑇𝑠?
Note: The Prandtl number, which is a
material property, is required at a known
temperature (Ta=25⁰C).
No iteration is needed!
4
5. A problem that doesn’t require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑎 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
P = prandtl(Air,T=Ta)
EES Codes (Code-1.EES)
5
6. A problem that require iterative
solution
6
Performing manual iteration in EES
7. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Note: The Prandtl number, which is a material
property, is required at an unknown temperature!
This problem can not be solved without performing
iteration.
7
MANUAL
8. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
P = prandtl(Air,T=Ts)
EES Codes (Code-2.EES) Wrong approach!
8
MANUAL
9. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
Ts_guess = 100 [C]
check = Ts_guess - Ts
P = prandtl(Air,T=Ts_guess)
EES Codes (Code-3.EES) Right approach!
Assume some ‘guess’ value of
the unknown variable. Your
guess will correct only when
the difference between the
solution and your guess will
be ‘0’ i.e. check = 0
Evaluate
material
property at
guess value.
9
MANUAL
10. Check is not ‘0’ so
an iteration is
required.
Set the guess
variable value to the
current solution.
A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
Ts_guess = 305.9 [C]
check = Ts_guess - Ts
P = prandtl(Air,T=Ts_guess)
EES Codes (Code-3.EES) Right approach!
10
MANUAL
11. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
Ts_guess = 313.3 [C]
check = Ts_guess - Ts
P = prandtl(Air,T=Ts_guess)
EES Codes (Code-3.EES) Right approach!
11
Check is still not ‘0’
so another iteration
is required.
Set the guess
variable value to the
current solution.
MANUAL
12. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
Ts_guess = 313.3 [C]
check = Ts_guess - Ts
P = prandtl(Air,T=Ts_guess)
EES Codes (Code-3.EES) Right approach!
Check is approx. ‘0’
so no further
iteration is required.
The current solution
(or guess) is the final
answer.
12
MANUAL
13. A problem that require iterative
solution
13
Performing automated iteration in EES
14. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠?
14
Same problem
AUTOMATED
15. A problem that require iterative solution
15
Subprogram solver(Ts_guess : Ts)
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
P = prandtl(Air,T=Ts_guess)
End
EES Codes (Code-4.EES) Step #1
Create a ‘solver ‘ subprogram as
shown containing the original
codes of your main problem.
Make sure that you are
evaluating the material
properties at the guess value.
AUTOMATED
16. Procedure control(Ts_guess : Ts)
nmax = 100
dTmin = 0.001
n:=0
Ts := Ts_guess
Repeat
T = Ts
Call solver(T : Ts)
n := n +1
dT = abs(T-Ts)
Until ( (n=nmax) or (dT < dTmin))
End
A problem that require iterative solution
16
EES Codes (Code-4.EES) Step #2
Create a ‘control‘ procedure to
control the flow of iterations.
There is no need to change
anything else in this procedure.
‘nmax’ is the maximum number of iterations (100 is
more than enough!)
dTmin is the stopping condition, similar to ‘check’. If
you want to be super precise, use dTmin=0
AUTOMATED
17. Ts_guess = 100 [C]
Call control(Ts_guess : Ts)
A problem that require iterative solution
17
EES Codes (Code-4.EES) Step #3
Write these codes outside any
procedure or subprogram.
Yes, this is the initial guess.
AUTOMATED
18. A problem that require iterative
solution
18
Performing automated iteration in EES
and getting more than single output
19. A problem that require iterative solution
𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠, P and ℎ?
19
Same problem but
required variables
are more than
single.
AUTOMATED
Multiple outputs
20. Subprogram solver(Ts_guess : Ts, P, h)
Q = h*A*(Ts-Ta)
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P
P = prandtl(Air,T=Ts_guess)
End
A problem that require iterative solution
20
EES Codes (Code-5.EES) Step #1
More variables at output
AUTOMATED
Multiple outputs
21. Procedure control(Ts_guess : Ts, P, h)
nmax = 100
dTmin = 0.001
n:=0
Ts := Ts_guess
Repeat
T = Ts
Call solver(T : Ts, P, h)
n := n +1
dT = abs(T-Ts)
Until ( (n=nmax) or (dT < dTmin))
End
A problem that require iterative solution
21
EES Codes (Code-5.EES) Step #2
More variables at output
AUTOMATED
Multiple outputs
22. Ts_guess = 100 [C]
Call control(Ts_guess : Ts, P, h)
A problem that require iterative solution
22
EES Codes (Code-5.EES) Step #3
More variables at output
AUTOMATED
Multiple outputs
23. A problem that require iterative
solution
23
Performing automated iteration in EES
and working with inputs from outside
subprogram
24. A problem that require iterative solution
24
EES Codes (Code-6.EES)
Subprogram solver(Ts_guess, Q, A, Ta : Ts, P, h)
Q = h*A*(Ts-Ta)
h = 10*P
P = prandtl(Air,T=Ts_guess)
End
Procedure control(Ts_guess, Q, A, Ta : Ts, P, h)
nmax = 100
dTmin = 0.001
n:=0
Ts := Ts_guess
Repeat
T = Ts
Call solver(T, Q, A, Ta : Ts, P, h)
n := n +1
dT = abs(T-Ts)
Until ( (n=nmax) or (dT < dTmin))
End
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
Ts_guess = 100 [C]
Call control(Ts_guess, Q, A, Ta : Ts, P, h)
Step #1 Step #2 Step #3
AUTOMATED
Multiple inputs and outputs
25. Performing
Manual and Automated Iterations
in
Engineering Equation Solver (EES)
Examples from Heat Transfer
Thank you! Naveed ur Rehman
http://www.naveedurrehman.com/