def pb_t1a1(m=6, t_order_max=20, isDouble=False, isPrint=True): """ """ from pyranha.math import cos, sin, degree, ldegree, t_degree, t_ldegree, t_order, t_lorder, truncate_degree PATH_CHN = PREFIX + 'HDM/CHN1/H1/' PATH_EQN = PREFIX + 'HDM/EQN1/H1/' (c, one, max_m, type2, pt2, epst2) = (0.5, 1., m, 'd', pd, epsd) if isDouble else (F(1, 2), 1, F(m), 't', pt, epst) for i in range(len(pq_list)): if pq_list[i][0] != 'L': for file1 in os.listdir(PATH_CHN + qp_list[i]): diff1 = epst(0) lf(diff1, PATH_CHN + qp_list[i] + '/' + file1, df.boost_portable, cf.bzip2) diff1 = truncate_degree(diff1, F(m), pq_list[8:]) new_diff1 = epst2(0) for item1 in diff1.list: if t_order(item1[1]) <= t_order_max: new_diff1 += one * (item1[0] * item1[1]) if isPrint: print file1[:-16] + ':', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff1.list] ]), len(new_diff1.list) for file2 in os.listdir(PATH_EQN + pq_list[i]): start = time.time() diff2 = epst(0) lf(diff2, PATH_EQN + pq_list[i] + '/' + file2, df.boost_portable, cf.bzip2) diff2 = one * diff2 if isPrint: print file2[:-16] + ':', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in diff2.list] ]), len(diff2.list) pt2.set_auto_truncate_degree(max_m, pq_list[8:]) result = c * new_diff1 * diff2 if ( pq_list[i][0] in 'qyv') else -c * new_diff1 * diff2 pt2.unset_auto_truncate_degree() if isPrint: print 'result:', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in result.list] ]), len(result.list) if result != epst2(0): PATH_SAVE = PREFIX + 'HDM/PHI2/T1A1_TOR' + str( t_order_max).rjust( 2, '0' ) + '/' + pq_list[i] + '_' + qp_list[i] + '/' if not os.path.exists(PATH_SAVE): os.makedirs(PATH_SAVE) sf( result.trim(), PATH_SAVE + '/p2' + '_' + file1[3:5] + '_' + file2[3:5] + '.eps' + type2 + '.boostp.bz2', df.boost_portable, cf.bzip2) print 'bracket:', pq_list[i] + '_' + qp_list[ i], file1[:-16], file2[:-16], str( '%.1f' % (time.time() - start)).rjust(4, ' '), 's'
def pb_t1t1f1(f=0, m=4, num_br=0, num_subr=0, t_order_max=20, in1_post='', in2_post='', out_post='', isAver=True, isDouble=False, isPrint=True): """ Poisson brackets {T_1, {T_1, H_1}} and {T_1, {T_1, A_1}}. """ from pyranha.math import cos, sin, degree, ldegree, t_degree, t_ldegree, t_order, t_lorder, partial, truncate_degree in1_post = in1_post if in1_post == '' else '_' + in1_post in2_post = in2_post if in2_post == '' else '_' + in2_post out_post = out_post if out_post == '' else '_' + out_post if f == 0: c = -1. / 6. if isDouble else F(-1, 6) if f == 1: c = 1. / 6. if isDouble else F(1, 6) TYPE2 = 'A' if f == 0 else 'H' PATH_CHN = PREFIX + 'HDM/CHN1/H1' + in1_post + '/' PATH_BRA = PREFIX + 'HDM/PHI2/T1' + TYPE2 + '1' + in2_post + '_TOR' + str( t_order_max).rjust(2, '0') + '/' (one, max_m, type2, pt2, epst2) = (1., m, 'd', pd, epsd) if isDouble else (1, F(m), 't', pt, epst) for i in range(len(pq_list))[num_bracket:num_bracket + 1]: TYPE = 'HAM' if isAver else 'PHI' PATH_SAVE = PREFIX + 'HDM/' + TYPE + '3/T1T1' + TYPE2 + '1' + out_post + '_TOR' + str( t_order_max).rjust(2, '0') + '/' + pq_list[i] + '_' + qp_list[i] + '/' for file1 in os.listdir(PATH_CHN + qp_list[i]): # diff L,q (chn q,L) diff1 = epst(0) lf(diff1, PATH_CHN + qp_list[i] + '/' + file1, df.boost_portable, cf.bzip2) diff1 = truncate_degree(diff1, F(m), pq_list[8:]) new_diff1 = epst2(0) for item1 in diff1.list: if t_order(item1[1]) <= t_order_max: new_diff1 += one * (item1[0] * item1[1]) #new_diff1 = epst(0) #lf(new_diff1, PATH_CHN + qp_list[i]+'/'+file1, df.boost_portable, cf.bzip2) #new_diff1 = truncate_degree(new_diff1, F(m), pq_list[8:]) if isPrint: print file1[: -16] #+':', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff1.list]]), len(new_diff1.list) for subdir in os.listdir(PATH_BRA)[num_subr:num_subr + 1]: for file2 in os.listdir(PATH_BRA + subdir + '/'): CHECK_FILE = PATH_SAVE + '/' + TYPE[0].lower( ) + '3_' + file1[3:5] + '_(' + subdir + '_' + file2[ 3:8] + ').eps' + type2 + '.boostp.bz2' if not os.path.isfile(CHECK_FILE): if '44' in file2[3:8]: num_list = range(1, 5) else: num_list = range(int(file2[4:5]), int(file2[3:4]) + 1) num_list += range(int(file2[7:8]), int(file2[6:7]) + 1) if int(pq_list[i][1]) in num_list: start = time.time() diff2 = epst(0) lf(diff2, PATH_BRA + subdir + '/' + file2, df.boost_portable, cf.bzip2) diff2 = truncate_degree(diff2, F(m), pq_list[8:]) new_diff2 = epst2(0) for item1 in diff2.list: if t_order(item1[1]) <= t_order_max: new_diff2 += one * (item1[0] * item1[1]) #new_diff2 = epst(0) #lf(new_diff2, PATH_BRA + subdir+'/'+file2, df.boost_portable, cf.bzip2) #new_diff2 = truncate_degree(new_diff2, F(m), pq_list[8:]) if i in range(4, 8): s_prev = epst2('s' + str(i - 4)) if i != 4 else 1 part_diff_nu = -3 * epst2('K0')**2 * ( epst2('m' + str(i - 4 + 1))**3 * s_prev * epst2('s' + str(i - 4 + 1))** -1) * epst2('L' + str(i - 4 + 1))**-4 epst2.register_custom_derivative( qp_list[i], lambda temp: temp.partial(qp_list[ i]) + temp.partial(r'\nu_{' + pq_list[ i] + r'}') * part_diff_nu) new_diff2 = partial(new_diff2, qp_list[i]) epst2.unregister_all_custom_derivatives() else: new_diff2 = partial(new_diff2, qp_list[i]) if isPrint: print subdir, file2[: -16] #+':', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff2.list]]), len(new_diff2.list) pt2.set_auto_truncate_degree(max_m, pq_list[8:]) if isAver: count = 0 new_result = epst2(0) for item in new_diff1.list: for jtem in new_diff2.list: trig = item[1] * jtem[1] for ktem in trig.list: if ktem[1] == 1: temp_result = c * (item[0] * jtem[0] * ktem[0]) new_result = new_result + temp_result print c, item[1] count += 1 else: result = c * new_diff1 * new_diff2 pt2.unset_auto_truncate_degree() if not isAver: new_result = epst2(0) for item1 in result.list: if t_order(item1[1]) <= t_order_max: new_result += item1[0] * item1[1] if new_result != epst2(0): if not os.path.exists(PATH_SAVE): os.makedirs(PATH_SAVE) sf( new_result.trim(), PATH_SAVE + '/' + TYPE[0].lower() + '3_' + file1[3:5] + '_(' + subdir + '_' + file2[3:8] + ').eps' + type2 + '.boostp.bz2', df.boost_portable, cf.bzip2) print 'bracket:', pq_list[i] + '_' + qp_list[ i], file1[:-16], file2[:-16], str( '%.1f' % (time.time() - start)).rjust( 4, ' '), 's'
def pb_t2h1(m=4, type_br=0, num_br=0, num_subr=0, t_order_max=20, in1_post='', in2_post='', out_post='', isAver=True, isDouble=False, isPrint=True): """ Poisson bracket {T_2, H_1}. """ from pyranha.math import cos, sin, degree, ldegree, t_degree, t_ldegree, t_order, t_lorder, truncate_degree in1_post = in1_post if in1_post == '' else '_' + in1_post in2_post = in2_post if in2_post == '' else '_' + in2_post out_post = out_post if out_post == '' else '_' + out_post PBRACKETS = [ 'H2', 'T1H1_TOR' + str(t_order_max).rjust(2, '0'), 'T1A1_TOR' + str(t_order_max).rjust(2, '0') ] PATHS_CHN = [ PREFIX + 'HDM/CHN2/' + ITEM + in1_post + '/' for ITEM in PBRACKETS ] PATH_PHI = PREFIX + 'HDM/D_PHI1/H1' + in2_post + '/' (c, one, max_m, type2, pt2, epst2) = (0.5, 1., m, 'd', pd, epsd) if isDouble else (F(1, 2), 1, F(m), 't', pt, epst) for j in range(len(PATHS_CHN))[type_br:type_br + 1]: for i in range(len(pq_list))[num_br:num_br + 1]: listdir = os.listdir(PATHS_CHN[j] + qp_list[i] + '/') if not ('H2' in PATHS_CHN[j]) else [''] TYPE = 'HAM' if isAver else 'PHI' PATH_SAVE = PREFIX + 'HDM/' + TYPE + '3/T2H1_' + PBRACKETS[ j] + out_post + '/' + pq_list[i] + '_' + qp_list[i] + '/' for subdir in listdir[num_subracket:num_subracket + 1]: for file1 in os.listdir(PATHS_CHN[j] + qp_list[i] + '/' + subdir + '/'): #diff1 = epst2(0) #lf(diff1, PATHS_CHN[j] + qp_list[i]+'/'+subdir+'/'+file1, df.boost_portable, cf.bzip2) #diff1 = truncate_degree(diff1, F(m), pq_list[8:]) #new_diff1 = epst2(0) #for item1 in diff1.list: # if t_order(item1[1]) <= t_order_max: # new_diff1 += one*(item1[0]*item1[1]) new_diff1 = epst2(0) lf(new_diff1, PATHS_CHN[j] + qp_list[i] + '/' + subdir + '/' + file1, df.boost_portable, cf.bzip2) new_diff1 = truncate_degree(new_diff1, F(m), pq_list[8:]) if isPrint: print file1[: -16] #, '->', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff1.list]]), len(new_diff1.list) for file2 in os.listdir(PATH_PHI + qp_list[i] + '/'): FILE_CHECK = PATH_SAVE + '/' + TYPE[0].lower( ) + '3_(' + subdir + ')_(' + file1[3:8] + ')_' + file2[ 3:5] + '.eps' + type2 + '.boostp.bz2' if not os.path.isfile(FILE_CHECK): start = time.time() #diff2 = epst2(0) #lf(diff2, PATH_PHI + qp_list[i]+'/'+file2, df.boost_portable, cf.bzip2) #diff2 = truncate_degree(diff2, F(m), pq_list[8:]) #new_diff2 = epst2(0) #for item1 in diff2.list: #if t_order(item1[1]) <= t_order_max: #new_diff2 += one*(item1[0]*item1[1]) new_diff2 = epst2(0) lf(new_diff2, PATH_PHI + qp_list[i] + '/' + file2, df.boost_portable, cf.bzip2) new_diff2 = truncate_degree( new_diff2, F(m), pq_list[8:]) if isPrint: print file2[: -16] #, '->', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff2.list]]), len(new_diff2.list) pt2.set_auto_truncate_degree(max_m, pq_list[8:]) if isAver: count = 0 new_result = epst2(0) for item in new_diff1.list: for jtem in new_diff2.list: trig = item[1] * jtem[1] for ktem in trig.list: if ktem[1] == 1: new_result = new_result + c * item[ 0] * jtem[0] * ktem[0] count += 1 print count, item[1] else: result = c * new_diff1 * new_diff2 pt2.unset_auto_truncate_degree() if not isAver: new_result = epst2(0) for item1 in result.list: if t_order(item1[1]) <= t_order_max: new_result += item1[0] * item1[1] if isPrint: print 'done' #, '->', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_result.list]]), len(new_result.list) if new_result != epst2(0): if not os.path.exists(PATH_SAVE): os.makedirs(PATH_SAVE) sf( new_result.trim(), PATH_SAVE + '/' + TYPE[0].lower() + '3_(' + subdir + ')_(' + file1[3:8] + ')_' + file2[3:5] + '.eps' + type2 + '.boostp.bz2', df.boost_portable, cf.bzip2) print 'bracket:', pq_list[i] + '_' + qp_list[ i], file1[:-16], file2[:-16], str( '%.1f' % (time.time() - start)).rjust( 4, ' '), 's'
def pb_t1hN(N=1, m=6, pqi=0, t_order_max=40, in1_post='', in2_post='', out_post='', isAver=True, isDouble=False, isPrint=True): """ Poisson brackets {T_1, H_1} and {T_1, H_2}. """ from pyranha.math import cos, sin, degree, ldegree, t_degree, t_ldegree, t_order, t_lorder, truncate_degree in1_post = in1_post if in1_post == '' else '_' + in1_post in2_post = in2_post if in2_post == '' else '_' + in2_post out_post = out_post if out_post == '' else '_' + out_post PATH_CHN = PREFIX + 'HDM/CHN1/H1' + in1_post + '/' PATH_PHI = PREFIX + 'HDM/D_PHI' + str(N) + '/H' + str(N) + in2_post + '/' (c, one, max_m, type2, pt2, epst2) = (0.5, 1., m, 'd', pd, epsd) if isDouble else (F(1, 2), 1, F(m), 't', pt, epst) pairs = [['21_31', '31_21', '21_41', '41_21', '31_41', '41_31'], ['21_32', '32_21', '21_42', '42_21', '32_42', '42_32'],\ ['31_32', '32_31', '31_43', '43_31', '32_43', '43_32'], ['41_42', '42_41', '41_43', '43_41', '42_43', '43_42']] for i in range(len(pq_list))[pqi:pqi + 1]: for file1 in os.listdir(PATH_CHN + qp_list[i]): diff1 = epst(0) lf(diff1, PATH_CHN + qp_list[i] + '/' + file1, df.boost_portable, cf.bzip2) diff1 = truncate_degree(diff1, F(m), pq_list[8:]) new_diff1 = epst2(0) for item1 in diff1.list: if t_order(item1[1]) <= t_order_max: new_diff1 += one * (item1[0] * item1[1]) if isPrint: print file1[: -16] #, '->', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff1.list]]), len(new_diff1.list) for file2 in os.listdir(PATH_PHI + qp_list[i]): TYPE = 'HAM' if isAver else 'PHI' PATH_SAVE = PREFIX + 'HDM/' + TYPE + str(N + 1) + '/T1H' + str( N) + out_post + '_TOR' + str(t_order_max).rjust( 2, '0') + '/' + pq_list[i] + '_' + qp_list[i] + '/' FILE_SAVE = '/' + TYPE[0].lower() + str(N + 1) + '_' + file1[ 3:5] + '_' + file2[3:5] + '.eps' + type2 + '.boostp.bz2' start = time.time() if not os.path.exists(PATH_SAVE + FILE_SAVE): diff2 = epst(0) lf(diff2, PATH_PHI + qp_list[i] + '/' + file2, df.boost_portable, cf.bzip2) diff2 = truncate_degree(diff2, F(m), pq_list[8:]) new_diff2 = epst2(0) for item1 in diff2.list: if t_order(item1[1]) <= t_order_max: new_diff2 += one * (item1[0] * item1[1]) if isPrint: print file2[: -16] #, '->', sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff2.list]]), len(new_diff2.list) if isAver: count = 0 new_result = epst2(0) pt2.set_auto_truncate_degree(max_m, pq_list[8:]) for item in new_diff1.list: for jtem in new_diff2.list: trig = item[1] * jtem[1] for ktem in trig.list: if ktem[1] == 1: new_result = new_result + c * item[ 0] * jtem[0] * ktem[0] count += 1 print count, item[1] pt2.unset_auto_truncate_degree() else: #count = 0 #result = epst2(0) #pt2.set_auto_truncate_degree(max_m, pq_list[8:]) #for item in new_diff1.list: #temp = c*item[0]*item[1]*new_diff2 #new_temp = epst2(0) #for item1 in temp.list: #if t_order(item1[1]) <= t_order_max: #new_temp += item1[0]*item1[1] #result = result + new_temp #count += 1 #print count, item[1] result = c * new_diff1 * new_diff2 pt2.unset_auto_truncate_degree() if not isAver: new_result = epst2(0) for item1 in result.list: if t_order(item1[1]) <= t_order_max: new_result += item1[0] * item1[1] if isPrint: print 'done' #, '->", sum([len(item.list) for item in [jtem[0].list[0][0] for jtem in new_result.list]]), len(new_result.list) if new_result != epst2(0): if not os.path.exists(PATH_SAVE): os.makedirs(PATH_SAVE) sf(new_result.trim(), PATH_SAVE + FILE_SAVE, df.boost_portable, cf.bzip2) print 'bracket:', pq_list[i] + '_' + qp_list[ i], file1[:-16], file2[:-16], str( '%.1f' % (time.time() - start)).rjust(4, ' '), 's'
def pb_t1hN(N=1, m=6, t_order_max=20, isAver=True, isDouble=False, isPrint=True): """ """ from pyranha.math import cos, sin, degree, ldegree, t_degree, t_ldegree, t_order, t_lorder, truncate_degree PATH_CHN = PREFIX + 'HDM/CHN1/H1/' PATH_PHI = PREFIX + 'HDM/DIF1/PHI' + str(N) + '/H' + str(N) + '/' if N == 1: c = 0.5 if isDouble else F(1, 2) if N == 2: c = -0.5 if isDouble else F(-1, 2) (one, max_m, type2, pt2, epst2) = (1., m, 'd', pd, epsd) if isDouble else (1, F(m), 't', pt, epst) for i in range(len(pq_list)): for file1 in os.listdir(PATH_CHN + qp_list[i]): diff1 = epst(0) lf(diff1, PATH_CHN + qp_list[i] + '/' + file1, df.boost_portable, cf.bzip2) diff1 = truncate_degree(diff1, F(m), pq_list[8:]) new_diff1 = epst2(0) for item1 in diff1.list: if t_order(item1[1]) <= t_order_max: new_diff1 += one * (item1[0] * item1[1]) if isPrint: print file1[:-16] + ':', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff1.list] ]), len(new_diff1.list) for file2 in os.listdir(PATH_PHI + qp_list[i]): start = time.time() diff2 = epst(0) lf(diff2, PATH_PHI + qp_list[i] + '/' + file2, df.boost_portable, cf.bzip2) diff2 = truncate_degree(diff2, F(m), pq_list[8:]) new_diff2 = epst2(0) for item1 in diff2.list: if t_order(item1[1]) <= t_order_max: new_diff2 += one * (item1[0] * item1[1]) if isPrint: print file2[:-16] + ':', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in new_diff2.list] ]), len(new_diff2.list) if isAver: count = 0 new_result = epst2(0) pt2.set_auto_truncate_degree(max_m, pq_list[8:]) for item in new_diff1.list: for jtem in new_diff2.list: trig = item[1] * jtem[1] for ktem in trig.list: if ktem[1] == 1: new_result = new_result + c * item[ 0] * jtem[0] * ktem[0] count += 1 print count, item[1] pt2.unset_auto_truncate_degree() else: pt2.set_auto_truncate_degree(max_m, pq_list[8:]) result = c * new_diff1 * new_diff2 pt2.unset_auto_truncate_degree() if not isAver: new_result = epst2(0) for item1 in result.list: if t_order(item1[1]) <= t_order_max: new_result += item1[0] * item1[1] if isPrint: print 'result:', sum([ len(item.list) for item in [jtem[0].list[0][0] for jtem in new_result.list] ]), len(new_result.list) if new_result != epst2(0): TYPE = 'HAM' if isAver else 'PHI' PATH_SAVE = PREFIX + 'HDM/' + TYPE + str( N + 1) + '/T1H' + str(N) + '_TOR' + str(t_order_max).rjust( 2, '0') + '/' + pq_list[i] + '_' + qp_list[i] + '/' if not os.path.exists(PATH_SAVE): os.makedirs(PATH_SAVE) sf( new_result.trim(), PATH_SAVE + '/' + TYPE[0].lower() + str(N + 1) + '_' + file1[3:5] + '_' + file2[3:5] + '.eps' + type2 + '.boostp.bz2', df.boost_portable, cf.bzip2) print 'bracket:', pq_list[i] + '_' + qp_list[ i], file1[:-16], file2[:-16], str( '%.1f' % (time.time() - start)).rjust(4, ' '), 's'