def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''2. Solvng System''' start1 = timer() # '''calculate dt''' # Vn_conv = vn_conv_max(set, sol, coef) # Vb_conv = vb_conv_max(set, sol, coef) # print 'V_max', V_conv # dt_conv_n = set['h']/(2*Vn_conv) # dt_conv_b = set['h']/(2*Vb_conv) # dt_diff_n = (set['h'])**2/(2*coef['D_n']) # dt_diff_b = (set['h'])**2/(2*coef['D_b']) # dt_diff_c = (set['h'])**2/(2*coef['D_c']) # # set['dt'] = 0.001 # set['dt'] = min(dt_diff_n, dt_diff_b, dt_diff_c , dt_conv_n, dt_conv_b) # set['t'] += set['dt'] # sol['time'].append(set['t']) # print 'dt', set['dt'] sol['age'] += set['dt'] if set['Dimension'] == '1D': sol = system_1d(coef, set, sol) #2.3 elif set['Dimension'] == '2D': sol = system_2d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2 - start1 return sol
def boolean_1_iter(coef, set, sol, check = 'out'): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: start1 = timer() # Solving X1,X2,X3,X4 continuously sol = c_f_T(coef, set, sol) #2.3 start2 = timer() # Movement of X4 sol = hybrid_tech_c(coef, set, sol) #2.2 start3 = timer() ''' if len(sol['matrix_tip']) == 0: sol['stop_iter'] = 100000 print 'all is absorbed' check == 'in' else: start1 = timer() # Solving X1,X2,X3,X4 continuously sol = c_f_T(coef, set, sol) #2.3 start2 = timer() # Movement of X4 sol = hybrid_tech(coef, set, sol) #2.2 start3 = timer() ''' if not check == 'in': print 'Hybrid for X4 time', start2-start1 print 'Solve X1,X2,X3 time', start3-start2 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 sol['time'] = [0] else: '''2. Solvng System''' start1 = timer() '''calculate dt''' V_conv = v_conv_max(set, sol, coef) print 'V_max', V_conv dt_conv = set['h']/(2*V_conv) dt_diff = (set['h'])**2/(2*coef['D_n']) # set['dt'] = 0.001 set['dt'] = min(dt_diff,dt_conv) set['t'] += set['dt'] sol['time'].append(set['t']) print 'dt', set['dt'] '''Solve system''' sol = system_1d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2-start1 return sol
def boolean_1_iter(coef, set, sol, check='out'): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: start1 = timer() # Solving X1,X2,X3,X4 continuously sol = c_f_T(coef, set, sol) #2.3 start2 = timer() # Movement of X4 sol = hybrid_tech_c(coef, set, sol) #2.2 start3 = timer() ''' if len(sol['matrix_tip']) == 0: sol['stop_iter'] = 100000 print 'all is absorbed' check == 'in' else: start1 = timer() # Solving X1,X2,X3,X4 continuously sol = c_f_T(coef, set, sol) #2.3 start2 = timer() # Movement of X4 sol = hybrid_tech(coef, set, sol) #2.2 start3 = timer() ''' if not check == 'in': print 'Hybrid for X4 time', start2 - start1 print 'Solve X1,X2,X3 time', start3 - start2 return sol
def boolean_1_iter(coef, set, sol, check='out'): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: if len(sol['sp_stop']) == len(sol['matrix_tip']): sol['stop_iter'] = 100000 #sp_stop harus dicek di setiap movement and branching. karena sudah tidak bergerak lagi yang ada di list ini. print 'all looping itself or anastomosis' check = 'in' else: '''2. Branching and Movement''' start1 = timer() if set['layout'] == '2D': sol = hybrid_tech_c(coef, set, sol) #2.2 if set['layout'] == '3D': sol = hybrid_tech_c_3d(coef, set, sol) start2 = timer() '''1. Anastomosis & Tip Cell''' #sol = check_anastomosis(sol) start3 = timer() '''Solving c,f,T''' if set['layout'] == '2D': sol = c_f_T(coef, set, sol) #2.3 if set['layout'] == '3D': sol = c_f_T_3d(coef, set, sol) start4 = timer() if not check == 'in': print 'Check Anastomosis Time', start3 - start2 print 'Hybrid for n time', start2 - start1 print 'Solve c,f,T time', start4 - start3 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''2. Solvng System''' start1 = timer() # sol['age'] += set['dt'] '''calculate dt''' V_1 = v_1_max(set, sol) V_2 = v_2_max(set, sol, coef) dt_1 = set['h']/V_1 dt_2 = set['h']/V_2 dt_3 = (set['h'])**2/(2*coef['D_n']) set['dt'] = min(dt_1,dt_2,dt_3) set['t'] += set['dt'] print 'dt', set['dt'] '''Solve system''' if set['Dimension'] == '1D': sol = system_1d(coef, set, sol) #2.3 elif set['Dimension'] == '2D': sol = system_2d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2-start1 return sol
def boolean_1_iter(coef, set, sol, check = 'out'): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) else: if len(sol['sp_stop']) == len(sol['matrix_tip']): sol['stop_iter'] = 100000 #sp_stop harus dicek di setiap movement and branching. karena sudah tidak bergerak lagi yang ada di list ini. print 'all looping itself or anastomosis' check = 'in' else: '''2. Branching and Movement''' start1 = timer() if set['layout'] == '2D': sol, n_o = hybrid_tech_c(coef, set, sol) if set['layout'] == '3D': sol = hybrid_tech_c_3d(coef, set, sol) start2 = timer() '''1. Anastomosis & Tip Cell''' #sol = check_anastomosis(sol) start3 = timer() '''Solving c,f,T''' if set['layout'] == '2D': sol = c_f_T(coef, set, sol) # sol = system_2d(coef, set, sol, n_o) #2.3 if set['layout'] == '3D': sol = c_f_T_3d(coef, set, sol) start4 = timer() if not check == 'in': print 'Check Anastomosis Time', start3-start2 print 'Hybrid for n time', start2-start1 print 'Solve c,f,T time', start4-start3 return sol
def continuous_iter(coef, set, sol): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''Solving X1,X2,X3,X4''' start1 = timer() sol = c_f_T(coef, set, sol) #2.3 start2 = timer() print 'Solve X1,X2,X3,X4 time', start2-start1 return sol
def continuous_iter(coef, set, sol): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''Solving X1,X2,X3,X4''' start1 = timer() sol = c_f_T(coef, set, sol) #2.3 start2 = timer() print 'Solve X1,X2,X3,X4 time', start2 - start1 return sol
def continuous_iter(coef, set, sol): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''Solving c,b,n''' n_o = 0 if set['layout'] == '2D': start1 = timer() sol = c_f_T(coef, set, sol, n_o) #2.3 start2 = timer() print 'Solve c,f,T time', start2 - start1 return sol
def continuous_iter(coef, set, sol): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''Solving c,b,n''' n_o = 0 if set['layout'] == '2D': start1 = timer() sol = c_f_T(coef, set, sol, n_o) #2.3 start2 = timer() print 'Solve c,f,T time', start2-start1 return sol
def con_(coef, set, sol, check = 'out'): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) else: '''Solving n''' sol = continuous_n_(coef, set, sol) '''Solving c,f,T''' if set['layout'] == '2D': sol = c_f_T(coef, set, sol) if set['layout'] == '3D': sol = c_f_T_3d(coef, set, sol) return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''Solving c,f,T''' start1 = timer() sol = system_3d(coef, set, sol) #2.3 start2 = timer() '''2. Branching and Movement''' sol = hybrid_tech(coef, set, sol) #2.2 start3 = timer() print 'Solve c,f,T time', start2-start1 print 'Hybrid for n time', start3-start2 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: start1 = timer() '''Solving c''' sol = system_2d(coef, set, sol) #2.3 start2 = timer() '''2. Branching and Movement''' sol = hybrid_tech(coef, set, sol) #2.2 start3 = timer() print 'Hybrid for n time', start2 - start1 print 'Solving c time', start3 - start2 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''2. Branching and Movement''' start1 = timer() sol, n_o = hybrid_tech(coef, set, sol) #2.2 start2 = timer() '''Solving c,f,T''' sol = c_f_T(coef, set, sol, n_o) #2.3 start3 = timer() print 'Hybrid for n time', start2 - start1 print 'Solve c,f,T time', start3 - start2 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 sol['time'] = [0] else: start1 = timer() set['t'] += set['dt'] sol['time'].append(set['t']) print 'time', set['t'] '''Solve system''' sol = system_1d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2-start1 return sol
def boolean_1_iter(coef, set, sol, check = 'out'): if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) sol = init_m(coef,set,sol) else: if len(sol['sp_stop']) == len(sol['matrix_tip']): sol['stop_iter'] = 100000 #sp_stop harus dicek di setiap movement and branching. karena sudah tidak bergerak lagi yang ada di list ini. print 'all looping itself or anastomosis' check = 'in' else: '''2. Branching and Movement''' start1 = timer() sol = hybrid_tech_c(coef, set, sol) start2 = timer() '''1. Anastomosis & Tip Cell''' sol = check_anastomosis(sol) start3 = timer() if not coef['Mic'] == 0 or not coef['Kappa'] == 0: #print set['tm'], set['t'] if set['t'] >= set['tm']: #print sol['kk'] if sol['kk'] == 1: #sol = init_m(coef,set,sol) sol['kk']+= 1 else: sol['kk'] = 10 #print 'enter here' sol = hybrid_tech_m(coef, set, sol) start4 = timer() '''Solving c,f,T''' sol = c_f_T(coef, set, sol) start5 = timer() if not check == 'in': print 'Check Anastomosis Time', start3-start2 print 'Hybrid for n time', start2-start1 if not coef['Mic'] == 0 or not coef['Kappa'] == 0: if sol['kk'] > 2: print 'Hybrid for m time', start4-start3 print 'Solve c,f,T time', start5-start4 else: print 'Solve c,f,T time', start5-start3 else: print 'Solve c,f,T time', start5-start3 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''2. Solvng System''' start1 = timer() '''calculate dt''' V_1 = v_1_max(set, sol) dt_1 = set['h'] / V_1 dt_3 = (set['h'])**2 / (2 * coef['D_n']) set['dt'] = 0.001 #min(dt_1,dt_3) set['t'] += set['dt'] print 'dt', set['dt'] '''Solve system''' sol = system_1d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2 - start1 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 else: '''2. Solvng System''' start1 = timer() '''calculate dt''' V_1 = v_1_max(set, sol) dt_1 = set['h']/V_1 dt_3 = (set['h'])**2/(2*coef['D_n']) set['dt'] = 0.001#min(dt_1,dt_3) set['t'] += set['dt'] print 'dt', set['dt'] '''Solve system''' sol = system_1d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2-start1 return sol
def boolean_1_iter(coef, set, sol): #2 if set['k'] == 0: '''Initial Profile''' sol = initial_prof(coef, set, sol) #2.1 sol['time'] = [0] else: start1 = timer() # '''calculate dt''' # V_conv = v_conv_max(set, sol, coef) # print 'V_max', V_conv # dt_conv = set['h']/(2*V_conv) # dt_diff = (set['h'])**2/(2*coef['D_n']) # # set['dt'] = 0.001 # set['dt'] = min(dt_diff,dt_conv) set['t'] += set['dt'] sol['time'].append(set['t']) print 'time', set['t'] '''Solve system''' sol = system_1d(coef, set, sol) #2.3 start2 = timer() print 'Solve system time', start2 - start1 return sol
'''Import all files. We run all the files through run_main_code.py''' from coef_setting import declare_coef #Ref.1 from initial_conditions import initial_prof #Ref.2 import main_code as main #Ref.4 import picture_2d as pic #Ref.5 '''Import additional functions to support calculation and graphics''' import numpy from timeit import default_timer as timer import time import matplotlib.pyplot as plt plt.ion() #to plot interactively '''declare coefficients & initial settings''' coef, set, sol = declare_coef() #Ref.1 '''Initialize functions for k=0 (first iteration), t=0 (initial time)''' sol = initial_prof(coef, set, sol) #Ref.2 pic.pic_2d(coef, set, sol) #to generate the picture of initial condition #Ref.5 print '''All Coefficients:''' print coef print '''All Set''' print set '''PRINTING RESULT AS CONTROL''' print 'at Time', set['t'] print 'Total Tips:', len(sol['matrix_tip']) print 'Total Stop Tips:', len(sol['sp_stop']) print 'Tip Stop:', sol['sp_stop'] print 'Tip Cell Pos:', sol['tip_cell'] print 'Max Value of c, f', sol['c'].max(), ',', sol['f'].max() print 'Min Value of c, f', sol['c'].min(), ',', sol['f'].min() '''Main part of the Hybrid calculation'''