Successfully reported this slideshow.
Upcoming SlideShare
×

# Performing Iterations in EES

2,966 views

Published on

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

Published in: Engineering
• Full Name
Comment goes here.

Are you sure you want to Yes No

Are you sure you want to  Yes  No
• Thank you very much. I was looking for this example for iterations in EES for long time

Are you sure you want to  Yes  No

### Performing Iterations in EES

1. 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. 2. All the EES codes shown in the examples are available at: https://goo.gl/KExGFi 2
3. 3. A problem that doesnβt require iterative solution 3
4. 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. 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. 6. A problem that require iterative solution 6 Performing manual iteration in EES
7. 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. 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. 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. 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. 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. 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. 13. A problem that require iterative solution 13 Performing automated iteration in EES
14. 14. A problem that require iterative solution π = βπ΄ ππ  β ππ Letβs say: π = 2000π π΄ = 1π2 ππ = 25Β°πΆ β = 10π Where, π = ππ ππ  for βAirβ Find ππ ? 14 Same problem AUTOMATED
15. 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. 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. 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. 18. A problem that require iterative solution 18 Performing automated iteration in EES and getting more than single output
19. 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. 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. 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. 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. 23. A problem that require iterative solution 23 Performing automated iteration in EES and working with inputs from outside subprogram
24. 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. 25. Performing Manual and Automated Iterations in Engineering Equation Solver (EES) Examples from Heat Transfer Thank you! Naveed ur Rehman http://www.naveedurrehman.com/