|
[Sponsors] |
Code to obtain correct heat transfer coefficient in a cylinder wt constant heat flux |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 3, 2012, 00:20 |
Code to obtain correct heat transfer coefficient in a cylinder wt constant heat flux
|
#1 |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
num_planes = 90 #number of planes
start_surf_num = 3 #index number of plane in list of surfaces in write profile length_domain = 0.99 sh = 0.015 #position of first plane in z-direction thickness = (length_domain - sh)/num_planes #distance between each plane end_surf_num = start_surf_num + num_planes #to get last surface index plot_surfnum = 4 + num_planes JOURNAL_FILE = open('python_journal.jou','w') POINT_FILE = open('plane_loc.dat','w') temp_command = '(cx-gui-do cx-activate-item \"MenuBar*ReadSubMenu*Case & Data...\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*FilterText\" \"./directory/*.cas*\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*Apply\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*Text\" \"filename.cas\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*OK\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"MenuBar*WriteSubMenu*Stop Journal\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"MenuBar*SurfaceMenu*Plane...\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-toggle-button \"Plane Surface*Frame1*Frame1(Options)*ToggleBox1(Options) *CheckButton1(Aligned with Surface)\" #f)' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Plane Surface*Frame1*Frame1(Options)*ToggleBox1(Options) *CheckButton1(Aligned with Surface)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Plane Surface*Frame1*Frame3*List3(Surfaces)\" \'( 0))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Plane Surface*Frame1*Frame3*List3(Surfaces)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') for i in range(0,num_planes): temp_command = '(cx-gui-do cx-set-real-entry-list \"Plane Surface*Frame2(Points)*Frame1*Table1*RealEntry3(z0 )\" \'(' + str(sh) + '))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') if i <= 4: temp_command = '(cx-gui-do cx-set-text-entry \"Plane Surface*TextEntry4(New Surface Name)\" \"plane-0' + str(i+5) + '\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Plane Surface*PanelButtons*PushButton1(OK)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') POINT_FILE.write(str(sh)) POINT_FILE.write('\n') sh += thickness POINT_FILE.close() temp_command = '(cx-gui-do cx-activate-item \"Plane Surface*PanelButtons*PushButton1(Cancel)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"MenuBar*WriteSubMenu*Profile...\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame3*List3(Values)\" \'( 6))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame3*List3(Values)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame3*List3(Values)\" \'( 6 11))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame3*List3(Values)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame3*List3(Values)\" \'( 6 11 31))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame3*List3(Values)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame3*List3(Values)\" \'( 6 11 31 63))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame3*List3(Values)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame2*List2(Surfaces)\" \'(' + str(start_surf_num) + '))' #initial surface index JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame2*List2(Surfaces)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*PanelButtons*PushButton1(OK)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*FilterText\" \"*.prof\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*Apply\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*Text\" \"plan1.prof\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*OK\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') cnt = 2 #filename differential for j in range(start_surf_num + 1,end_surf_num): temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame2*List2(Surfaces)\" \'())' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame2*List2(Surfaces)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Write Profile*Frame2*List2(Surfaces)\" \'(' + str(j) + '))' #j is the kth surface index JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*Frame2*List2(Surfaces)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Write Profile*PanelButtons*PushButton1(OK)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*FilterText\" \"*.prof\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*Apply\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*Text\" \"plan' + str(cnt) + '.prof\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*OK\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') cnt += 1 temp_command = '(cx-gui-do cx-activate-item \"Write Profile*PanelButtons*PushButton1(Cancel)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"NavigationPane*Frame1*PushButton20(Plots)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Plots*Frame1*Table1*PushButton2(Set Up)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-toggle-button \"Solution XY Plot*Frame1(Options)*ToggleBox1(Options)*CheckButt on4(Write to File)\" #f)' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*Frame1(Options)*ToggleBox1(Options)*CheckButt on4(Write to File)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-toggle-button \"Solution XY Plot*Frame1(Options)*ToggleBox1(Options)*CheckButt on5(Order Points)\" #f)' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*Frame1(Options)*ToggleBox1(Options)*CheckButt on5(Order Points)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-real-entry-list \"Solution XY Plot*Frame2(Plot Direction)*ToggleBox2(Plot Direction)*RealEntry1(X)\" \'( 0))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-real-entry-list \"Solution XY Plot*Frame2(Plot Direction)*ToggleBox2(Plot Direction)*RealEntry3(Z)\" \'( 1))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Solution XY Plot*Frame7*Table7*DropDownList1(Y Axis Function)\" \'(3))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*Frame7*Table7*DropDownList1(Y Axis Function)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Solution XY Plot*Frame7*Table7*DropDownList2\" \'(0))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*Frame7*Table7*DropDownList2\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-list-selections \"Solution XY Plot*Frame9*Frame1*List1(Surfaces)\" \'( ' + str(plot_surfnum) + '))' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') #temp_command = '(cx-gui-do cx-set-list-selections \"Solution XY Plot*Frame9*Frame1*List1(Surfaces)\" \'( 1))' #JOURNAL_FILE.write(temp_command) #JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*Frame9*Frame1*List1(Surfaces)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*PanelButtons*PushButton1(OK)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*FilterText\" \"*.xy\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*Apply\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-set-text-entry \"Select File*Text\" \"temperatures.xy\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Select File*OK\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') temp_command = '(cx-gui-do cx-activate-item \"Solution XY Plot*PanelButtons*PushButton1(Cancel)\")' JOURNAL_FILE.write(temp_command) JOURNAL_FILE.write('\n') JOURNAL_FILE.close() ****************python program**************** import math import os def avgtemp(temperts): clsp_temp = [] for i in range(0,len(temperts)): temp_temp = 0 for j in range(0,len(temperts[i])): temp_temp += temperts[i][j] average = temp_temp/len(temperts[i]) clsp_temp.append(average) return clsp_temp #Get T(z) at each z position zpoints = [] inpoint = open('plane_loc.dat','r') line1 = inpoint.readlines() for line in line1: zval = float(line) zval = "%0.3f" %zval zpoints.append(zval) num_plane = len(zpoints) temp = [] intemp = open('temperatures.xy','r') templine = intemp.readlines() for pnt in zpoints: tempset = [] for line in templine: if line[0:5] == pnt: vals = line.split() tempset.append(float(vals[1])) temp.append(tempset) average_nodetemp = avgtemp(temp) #Get Tbulk at each zposition Tbulks = [] for k in range(1,num_plane+1): density = [] velocity = [] temperature = [] sp_heat =[] infile = open('plan' + str(k) + '.prof','r') lines = infile.readlines() tempref = 0 for line in lines: if line[0:5] == '(dens': tempref = 1 continue if tempref ==1: density.append(line[:-1]) if line[0:5] == '(z-ve': tempref = 2 continue if tempref == 2: velocity.append(line[:-1]) if line[0:5] == '(temp': tempref = 3 continue if tempref == 3: temperature.append(line[:-1]) if line[0:5] == '(spec': tempref = 4 continue if tempref == 4: sp_heat.append(line[:-1]) del density[-2:] del velocity[-2:] del temperature[-2:] del sp_heat[-2:] for i in range(0,len(density)): density[i] = float(density[i]) for i in range(0,len(velocity)): velocity[i] = float(velocity[i]) for i in range(0,len(temperature)): temperature[i] = float(temperature[i]) for i in range(0,len(sp_heat)): sp_heat[i] = float(sp_heat[i]) num = 0 den = 0 if len(density) == len(velocity) == len(temperature) == len(sp_heat): for j in range(0,len(density)): tempnum = density[j]*velocity[j]*temperature[j]*sp_heat[j] tempden = density[j]*velocity[j]*sp_heat[j] num += tempnum den += tempden Tbulk = num/den Tbulks.append(Tbulk) os.system('rm \'' + 'plan' + str(k) + '.prof\'') outfile = open('Nu_dpm_dia50_re3000_1percent.dat','w') tempfileout = open('Temps_dpm_dia50_re3000_1percent.dat','w') tempfileout2 = open('H_dpm_dia50_re3000_1percent.dat','w') diameter = 0.01 k_cond = 0.6 if len(Tbulks) == len(average_nodetemp) == len(zpoints): for s in range(0,len(Tbulks)): h = 500000 / (average_nodetemp[s] - Tbulks[s]) print h Nu = h*diameter / 0.6 outtemp = str(zpoints[s]) + '\t' + str(Nu) outtemp10 = str(zpoints[s]) + '\t' + str(Tbulks[s]) + '\t' + str(average_nodetemp[s]) outtemp20 = str(zpoints[s]) + '\t' + str(h) outfile.write(outtemp) outfile.write('\n') tempfileout.write(outtemp10) tempfileout.write('\n') tempfileout2.write(outtemp20) tempfileout2.write('\n') os.system('rm ' + 'temperatures.xy') outfile.close() tempfileout.close() |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Heat Flux at wall in a conjugate heat transfer problem | Chander | CFX | 2 | July 9, 2011 22:22 |
Flow around pipes - heat transfer coefficient on the wall of pipe | doodek | Main CFD Forum | 2 | November 23, 2009 08:48 |
estimating the heat transfer coefficient | ZoRbA | FLUENT | 0 | February 10, 2009 08:59 |
How can I increase Heat Transfer at Domain Interf? | B.Simon | CFX | 3 | October 28, 2008 18:53 |
Convective Heat Transfer - Heat Exchanger | Mark | CFX | 6 | November 15, 2004 15:55 |