# CodeWalrus

## Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: APoloG13 on March 30, 2017, 09:54:08 pm

Title: Kern method program - TI Nspire CX CAS
Post by: APoloG13 on March 30, 2017, 09:54:08 pm
Hi everyone

I open this topic because i want to share with you my Kern program for heat exchanger design, is very intuitive to use so I hope you can get a good use of it.

Also i want to ask if someone can help me to make it better, i want it to look like te FormulaPro and have similar functionality.

As I don't know how to do for post the code or the progam in use, I uploaded some screenshoots with all the code, my first time so, i hope i get better with this xD

Code: [Select]
`:Request "T_in hot [ºC]",b2:Request "T_out hot [ºC]",b3:Request "P_in [bar]",b4:Request "Cabal hot [kg/s]",b5:Request "Rho hot [kg/m3]",b6:Request "Cp hot [kJ/kg K]",b7:Request "k hot [W/m K]",b8:Request "Viscositat hot [Pa·s]",b9::Request "T_in cold [ºC]",c2:Request "P_in cold [bar]",c4:Request "Cabal cold [kg/s]",h4:Request "Rho cold [kg/m3]",c6:Request "Cp cold [kJ/kg K]",c7:Request "k cold[W/m K]",c8:Request "Viscositat cold [Pa·s]",c9:Disp "1. BE y estimacion Area":Request "Q procés [kW]",f8:2.−4→b10:2.−4→c10:b2→f2:b5→f4:b7→f5:f4*f5→f6:c2→h2:((f8)/(h6))+h2→h3:c7→h5:h4*h5→h6:b2-((f8)/(f6))→f3:Disp "T_out cold=",h3,"ºC":Disp "T_out hot real=",f3,"ºC"::((f2-h3-(f3-h2))/(ln(((f2-h3)/(f3-h2)))))→f9:Disp "∆Tlm=",f9,"ºC"::Request "U [W/m2*K]",f10:::((f3-f2)/(h2-f2))→f17:((h2-h3)/(f3-f2))→f18:((2)/(f17))-1-f18→f19:((2)/(f17))*√((1-f17)*(1-f17*f18))→f20::Disp "P=",f17:Disp "R=",f18:Disp "A=",f19:Disp "B=",f20::Request "Numero de pasos por carcasa",f16:If f16=1 Then:((((√(f18^(2)+1))/(f18-1))*ln(((1-f17)/(1-f17*f18))))/(ln(((f19+√(f18^(2)+1))/(f19-√(f18^(2)+1))))))→f11:EndIf:If f16=2 Then::((((√(f18^(2)+1))/(2*(f18-1)))*ln(((1-f17)/(1-f17*f18))))/(ln(((f19+f20+√(f18^(2)+1))/(f19+f20-√(f18^(2)+1))))))→f11:EndIf::Disp "F utilitzada=",f10::((f8*1000)/(f10*f9*f11))→f12::Disp "A_estimada=",f12,"m2"::Disp "2. Tipus de tub i carcasa"::Request "D_in [m]",l2:Request "D_out [m]",l4:Request "L_rub [m]",l6::((l4-l2)/(2))→l3:π*l4→l5:Disp "Espessor paret tub=",l3,"[m]":((f12)/(l6*l5))→l8:Disp "n_tubs=",l8:1.25*l4→l12:Request "Disposició tubs 1:∆ 2:▫",a:If a=1 Then:((4*(l12^(2)-((π*l4^(2))/(4))))/(π*l4))→l16:EndIf:If a=2 Then:((4*(((l12)/(2))*0.86*l12-0.5*π*((l4^(2))/(4))))/(((π*l4)/(2))))→l16:EndIf:Request "n_tubs real",l20:Request "D_carcasa real",l19:Request "n_pasos tub",l9:l20*l6*l5→l21:Disp "A_real=",l21,"m2"::Disp "3. Calcul d'energia i ΔP":f16→l10:h4→c5:((l20*π*((l2^(2))/(4)))/(l9))→q2:((b5)/(b6*q2))→q3:((q3*l2*b6)/(b9))→q5:Request "Se el Pr? 1:Si 2:No",c:If c=1 Then:Request "Pr=",q6:EndIf:If c=2 Then:((1000*b7*b9)/(b8))→q6:EndIf:((((q11)/(8))*q5*q6)/(1.07+((900)/(q5))-((0.63)/(1+10*q6))+12.7*(((q11)/(8)))^(0.5)*(q6^(((2)/(3)))-1)))→q7:((q7*b8)/(l2))→q8:q8*((l2)/(l4))→q9:(0.79*ln(q5)-1.64)^(−2)→q11:((q11*l6*l9*b6*q3^(2))/(l2*(((b9)/(8.365−4)))^(0.14)*2))→q12:((4*l9*b6*q3^(2))/(2))→q13:q13+q12→q14:Disp "Re_tub=",q5:Disp "Pr_tub=",q6:Disp "Nu=",q7:Disp "h tub=",q8,"W/m2 K":Disp "h_tub out=",q9,"W/m2 K":Disp "ΔPtub=",q12,"Pa":Disp "ΔP canvi pas=",q13,"Pa":Disp "ΔPtub total=",q14,"Pa"::Disp "4. Càlcul d'energia i pèrdua de càrrega per carcassa":Request "k1 =",u3:Request "a=",u4:Request "B: Separació baffles [m]",u5:Request "Z: Densitat baffles",u6:h3→c3:l4*(((l20)/(u3)))^(((1)/(u4)))→u2:(((l12-l4)*l19*u5)/(l12*l10))→u7:l12-l4→u8:((l19)/(l12))→u9:l16→u10::((c5)/(c6*u7))→u12:Disp "V_carcassa=",u12,"m/s":((u12*u10*c6)/(c9))→u13:((1000*c7*c9)/(c8))→u14:0.36*u13^(0.55)*u14^(((1)/(3)))*(((c9)/(8.365−4)))^(0.14)→u15:((u15*c8)/(u10))→u16:((b2+b3)/(2))+((u16)/(u16+q9))*(((c2+c3)/(2))-((b2+b3)/(2)))→u17:((l6)/(u5))→u22:((0.5)/(u13^(0.2)))→u21:((4*u21*l19*u22*c6*u12^(2))/(u10*(((c9)/(8.905−4)))^(0.14)*2))→u19::Disp "Re_carcassa=",u13:Disp "Pr_carcassa=",u14:Disp "Nu=",u15:Disp "h carcassa=",u16,"W/m2 K":Disp "ΔP carcassa=",u19,"Pa"::Disp "5. Càlcul resistencies ":((1)/(π*l2*l6*q8))→ab12:((b10)/(π*l2*l6))→ab13:((ln(((l4)/(l2))))/(2*π*l6*52.5))→ab14:((c10)/(π*l4*l6))→ab15:((1)/(π*l4*l6*u16))→ab16::ab12+ab13+ab14+ab15+ab16→ab17:((1)/(π*l4*l6*(ab12+ab14+ab16)))→ab3:((1)/(π*l4*l6*ab17))→ab4::((1000*f8)/(f11*f9*ab4))→ab6::Disp "U net",ab3,"W/m2 K":Disp "U servei",ab4,"W/m2 K":Disp "Area requerida=",ab6,"m2"`
Title: Re: Kern method program - TI Nspire CX CAS
Post by: p2 on March 30, 2017, 09:57:27 pm
since not everyone has the same calc, it's common practice to share screenshots. You should probably do the same in order to get feedback :)
Title: Re: Kern method program - TI Nspire CX CAS
Post by: APoloG13 on March 30, 2017, 09:58:31 pm
Of the code or the program in use??
Title: Re: Kern method program - TI Nspire CX CAS
Post by: aeTIos on March 30, 2017, 09:59:25 pm
The program while in use. Source code is always appreciated, too :)
Title: Re: Kern method program - TI Nspire CX CAS
Post by: p2 on March 30, 2017, 10:02:15 pm
You should always attach the files (the code) and also give screenshots of the running program, how it looks like on the calc.
For sourcecode, put the code inside a [code] ..... [/code] tag :)

Anyways, welcome to the forum :)
If you feel like doing it, u can introduce yourself here: I am a link, click me! (https://codewalr.us/32/54239) :)
Title: Re: Kern method program - TI Nspire CX CAS
Post by: xlibman on March 30, 2017, 10:18:32 pm
Heya and welcome here :). Does this program require one of those TI-Nspire add-on devices (I forgot the names, but I think one of them was from Vernier)?
Title: Re: Kern method program - TI Nspire CX CAS
Post by: APoloG13 on March 30, 2017, 10:26:58 pm
No, I don't have any of those things (I didn't know that those even exist). My TI Nspire only have the Ndless, and the program is in the lenguage of the Nspire cause i don't know how to code xD
Title: Re: Kern method program - TI Nspire CX CAS
Post by: p2 on March 30, 2017, 10:29:05 pm
You came to the right place if you want to learn some more and share your progress with others (and love walruses) ;)

Can you maybe describe for us what it's supposed to do and if possible how it works? :)
Title: Re: Kern method program - TI Nspire CX CAS
Post by: APoloG13 on March 30, 2017, 10:38:04 pm
This program is based on the Kern method for shell and tube heat exchangers design. You have to input the propierties of  the hot stream and the cold stream and the program makes all the calculation and shows the "princial" results, such as the pressure drop, condictivities, heat transfer area...