You are on page 1of 25

Performing

Manual and Automated Iterations


in
Engineering Equation Solver (EES)
Examples from Heat Transfer

Naveed ur Rehman
http://www.naveedurrehman.com/
4th June, 2018
All the EES codes shown in the
examples are available at:
https://goo.gl/KExGFi

2
A problem that doesn’t require
iterative solution

3
A problem that doesn’t require iterative solution

𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2 Note: The Prandtl number, which is a
𝑇𝑎 = 25°𝐶 material property, is required at a known
ℎ = 10𝑃 temperature (Ta=25⁰C).
Where, No iteration is needed!

𝑃 = 𝑃𝑟 𝑇𝑎 for ‘Air’
Find 𝑇𝑠 ?

4
A problem that doesn’t require iterative solution

𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-1.EES)

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2]
𝑇𝑎 = 25°𝐶 Ta = 25 [C]
h = 10*P
ℎ = 10𝑃
Where, P = prandtl(Air,T=Ta)

𝑃 = 𝑃𝑟 𝑇𝑎 for ‘Air’
Find 𝑇𝑠 ?

5
A problem that require iterative
solution
Performing manual iteration in EES

6
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2 Note: The Prandtl number, which is a material
𝑇𝑎 = 25°𝐶 property, is required at an unknown temperature!
ℎ = 10𝑃 This problem can not be solved without performing
Where, iteration.
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠 ?

7
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-2.EES) Wrong approach!

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2]
𝑇𝑎 = 25°𝐶 Ta = 25 [C]
h = 10*P
ℎ = 10𝑃
Where, P = prandtl(Air,T=Ts)

𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠 ?

8
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-3.EES) Right approach!

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2] Assume some ‘guess’ value of
Ta = 25 [C] the unknown variable. Your
𝑇𝑎 = 25°𝐶 guess will correct only when
h = 10*P
ℎ = 10𝑃 the difference between the
solution and your guess will
Where, Ts_guess = 100 [C]
be ‘0’ i.e. check = 0
check = Ts_guess - Ts
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
P = prandtl(Air,T=Ts_guess) Evaluate
Find 𝑇𝑠 ? material
property at
guess value.
9
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-3.EES) Right approach!

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2]
𝑇𝑎 = 25°𝐶 Ta = 25 [C]
h = 10*P
ℎ = 10𝑃
Where, Ts_guess = 305.9 [C]
Check is not ‘0’ so
check = Ts_guess - Ts
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’ an iteration is
P = prandtl(Air,T=Ts_guess) required.
Find 𝑇𝑠 ? Set the guess
variable value to the
current solution.
10
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-3.EES) Right approach!

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2]
𝑇𝑎 = 25°𝐶 Ta = 25 [C]
h = 10*P
ℎ = 10𝑃
Where, Ts_guess = 313.3 [C]
Check is still not ‘0’
check = Ts_guess - Ts
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’ so another iteration
P = prandtl(Air,T=Ts_guess) is required.
Find 𝑇𝑠 ? Set the guess
variable value to the
current solution.
11
MANUAL

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎 EES Codes (Code-3.EES) Right approach!

Q = h*A*(Ts-Ta)
Let’s say:
𝑄 = 2000𝑊 Q = 2000 [W]
𝐴 = 1𝑚2 A = 1 [m^2]
𝑇𝑎 = 25°𝐶 Ta = 25 [C]
h = 10*P
ℎ = 10𝑃
Where, Ts_guess = 313.3 [C]
Check is approx. ‘0’
check = Ts_guess - Ts
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’ so no further
P = prandtl(Air,T=Ts_guess) iteration is required.
Find 𝑇𝑠 ? The current solution
(or guess) is the final
answer.
12
A problem that require iterative
solution
Performing automated iteration in EES

13
AUTOMATED

A problem that require iterative solution


𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶 Same problem
ℎ = 10𝑃
Where,
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’
Find 𝑇𝑠 ?

14
AUTOMATED

A problem that require iterative solution


EES Codes (Code-4.EES) Step #1

Subprogram solver(Ts_guess : Ts)

Q = h*A*(Ts-Ta)
Create a ‘solver ‘ subprogram as
Q = 2000 [W] shown containing the original
A = 1 [m^2] codes of your main problem.
Ta = 25 [C]
h = 10*P

P = prandtl(Air,T=Ts_guess)
Make sure that you are
End
evaluating the material
properties at the guess value.

15
AUTOMATED

A problem that require iterative solution


EES Codes (Code-4.EES) Step #2

Procedure control(Ts_guess : Ts) Create a ‘control‘ procedure to


nmax = 100 control the flow of iterations.
dTmin = 0.001
n:=0 ‘nmax’ is the maximum number of iterations (100 is
Ts := Ts_guess more than enough!)
Repeat dTmin is the stopping condition, similar to ‘check’. If
T = Ts you want to be super precise, use dTmin=0
Call solver(T : Ts)
n := n +1
dT = abs(T-Ts)
Until ( (n=nmax) or (dT < dTmin))
There is no need to change
anything else in this procedure.
End

16
AUTOMATED

A problem that require iterative solution


EES Codes (Code-4.EES) Step #3

Ts_guess = 100 [C] Write these codes outside any


procedure or subprogram.
Call control(Ts_guess : Ts)
Yes, this is the initial guess.

17
A problem that require iterative
solution
Performing automated iteration in EES
and getting more than single output
18
AUTOMATED

A problem that require iterative solution


Multiple outputs

𝑄 = ℎ𝐴 𝑇𝑠 − 𝑇𝑎
Let’s say:
𝑄 = 2000𝑊
𝐴 = 1𝑚2
𝑇𝑎 = 25°𝐶 Same problem but
ℎ = 10𝑃 required variables
Where, are more than
𝑃 = 𝑃𝑟 𝑇𝑠 for ‘Air’ single.
Find 𝑇𝑠 , P and ℎ?

19
AUTOMATED

A problem that require iterative solution


Multiple outputs

EES Codes (Code-5.EES) Step #1

Subprogram solver(Ts_guess : Ts, P, h)

Q = h*A*(Ts-Ta)
More variables at output
Q = 2000 [W]
A = 1 [m^2]
Ta = 25 [C]
h = 10*P

P = prandtl(Air,T=Ts_guess)

End

20
AUTOMATED

A problem that require iterative solution


Multiple outputs

EES Codes (Code-5.EES) Step #2

Procedure control(Ts_guess : Ts, P, h)


nmax = 100
dTmin = 0.001 More variables at output
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

21
AUTOMATED

A problem that require iterative solution


Multiple outputs

EES Codes (Code-5.EES) Step #3

Ts_guess = 100 [C]

Call control(Ts_guess : Ts, P, h)


More variables at output

22
A problem that require iterative
solution
Performing automated iteration in EES
and working with inputs from outside
subprogram 23
AUTOMATED

A problem that require iterative solution


Multiple inputs and outputs

EES Codes (Code-6.EES)

Step #1 Step #2 Step #3


Subprogram solver(Ts_guess, Q, A, Ta : Ts, P, h) Procedure control(Ts_guess, Q, A, Ta : Ts, P, h) Q = 2000 [W]
A = 1 [m^2]
Q = h*A*(Ts-Ta) nmax = 100 Ta = 25 [C]
dTmin = 0.001
h = 10*P Ts_guess = 100 [C]
P = prandtl(Air,T=Ts_guess) n:=0
Ts := Ts_guess Call control(Ts_guess, Q, A, Ta : Ts, P, h)
End
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

24
Performing
Manual and Automated Iterations
in
Engineering Equation Solver (EES)
Examples from Heat Transfer

Thank you! Naveed ur Rehman


http://www.naveedurrehman.com/

You might also like