def bssn_puncture_gauge(eta_damp, isStaged=False, prefix=""): if (not isStaged): C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() C2_spatial = dendro.get_complete_christoffel(chi) [R, Rt, Rphi, CalGt] = dendro.compute_ricci(Gt, chi) a_rhs = l1 * dendro.lie(b, a) - 2 * a * K b_rhs = [(Rational(3, 4) * (lf0 + lf1 * a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i])) for i in dendro.e_i] gt_rhs = dendro.lie(b, gt, weight) - 2 * a * At chi_rhs = dendro.lie(b, chi, weight) + Rational(2, 3) * (chi * a * K) AikAkj = Matrix([ sum([ At[i, k] * sum([dendro.inv_metric[k, l] * At[l, j] for l in dendro.e_i]) for k in dendro.e_i ]) for i, j in dendro.e_ij ]) At_rhs = dendro.lie(b, At, weight) + chi * dendro.trace_free( a * R - dendro.DiDj(a)) + a * (K * At - 2 * AikAkj.reshape(3, 3)) K_rhs = dendro.lie(b, K) - dendro.laplacian( a, chi) + a * (K * K / 3 + dendro.sqr(At)) At_UU = dendro.up_up(At) Gt_rhs = Matrix([sum(b[j]*ad(j,Gt[i]) for j in dendro.e_i) for i in dendro.e_i]) - \ Matrix([sum(CalGt[j]*d(j,b[i]) for j in dendro.e_i) for i in dendro.e_i]) + \ Rational(2,3)*Matrix([ CalGt[i] * sum(d(j,b[j]) for j in dendro.e_i) for i in dendro.e_i ]) + \ Matrix([sum([igt[j, k] * d2(j, k, b[i]) + igt[i, j] * d2(j, k, b[k])/3 for j, k in dendro.e_ij]) for i in dendro.e_i]) - \ Matrix([sum([2*At_UU[i, j]*d(j, a) for j in dendro.e_i]) for i in dendro.e_i]) + \ Matrix([sum([2*a*dendro.C2[i, j, k]*At_UU[j, k] for j,k in dendro.e_ij]) for i in dendro.e_i]) - \ Matrix([sum([a*(3/chi*At_UU[i,j]*d(j, chi) + Rational(4,3)*dendro.inv_metric[i, j]*d(j, K)) for j in dendro.e_i]) for i in dendro.e_i]) Gt_rhs = [item for sublist in Gt_rhs.tolist() for item in sublist] B_rhs = [ (Gt_rhs[i] - eta_damp * B[i] + l3 * dendro.vec_j_ad_j(b, B[i]) - l4 * dendro.vec_j_ad_j(b, Gt[i])) for i in dendro.e_i ] ################################################################### # generate code ################################################################### outs = [a_rhs, b_rhs, gt_rhs, chi_rhs, At_rhs, K_rhs, Gt_rhs, B_rhs] vnames = [ 'a_rhs', 'b_rhs', 'gt_rhs', 'chi_rhs', 'At_rhs', 'K_rhs', 'Gt_rhs', 'B_rhs' ] dendro.generate_cpu(outs, vnames, '[pp]') else: # note: these are just the symbolic vars that is being used to generate the # Gt_rhs by satges _Gt_rhs_s1 = dendro.vec3("Gt_rhs_s1_", "[pp]") _Gt_rhs_s2 = dendro.vec3("Gt_rhs_s2_", "[pp]") _Gt_rhs_s3 = dendro.vec3("Gt_rhs_s3_", "[pp]") _Gt_rhs_s4 = dendro.vec3("Gt_rhs_s4_", "[pp]") _Gt_rhs_s5 = dendro.vec3("Gt_rhs_s5_", "[pp]") _Gt_rhs_s6 = dendro.vec3("Gt_rhs_s6_", "[pp]") _Gt_rhs_s7 = dendro.vec3("Gt_rhs_s7_", "[pp]") _CalGt = dendro.vec3("CalGt", "[pp]") _Gt_rhs = dendro.vec3("Gt_rhs", "[pp]") # Gt_rhs staged vars that is being used to generate the code. At_UU = dendro.sym_3x3("At_UU", "[pp]") CalGt = dendro.vec3("CalGt", "[pp]") Gt_rhs_s1 = dendro.vec3("Gt_rhs_s1_", "[pp]") Gt_rhs_s2 = dendro.vec3("Gt_rhs_s2_", "[pp]") Gt_rhs_s3 = dendro.vec3("Gt_rhs_s3_", "[pp]") Gt_rhs_s4 = dendro.vec3("Gt_rhs_s4_", "[pp]") Gt_rhs_s5 = dendro.vec3("Gt_rhs_s5_", "[pp]") Gt_rhs_s6 = dendro.vec3("Gt_rhs_s6_", "[pp]") Gt_rhs_s7 = dendro.vec3("Gt_rhs_s7_", "[pp]") C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() C2_spatial = dendro.get_complete_christoffel(chi) [R, Rt, Rphi, CalGt] = dendro.compute_ricci(Gt, chi) a_rhs = l1 * dendro.lie(b, a) - 2 * a * K b_rhs = [(Rational(3, 4) * (lf0 + lf1 * a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i])) for i in dendro.e_i] gt_rhs = dendro.lie(b, gt, weight) - 2 * a * At chi_rhs = dendro.lie(b, chi, weight) + Rational(2, 3) * (chi * a * K) AikAkj = Matrix([ sum([ At[i, k] * sum([dendro.inv_metric[k, l] * At[l, j] for l in dendro.e_i]) for k in dendro.e_i ]) for i, j in dendro.e_ij ]) At_rhs = dendro.lie(b, At, weight) + chi * dendro.trace_free( a * R - dendro.DiDj(a)) + a * (K * At - 2 * AikAkj.reshape(3, 3)) K_rhs = dendro.lie(b, K) - dendro.laplacian( a, chi) + a * (K * K / 3 + dendro.sqr(At)) At_UU = dendro.up_up(At) Gt_rhs_s1 = ([ sum(b[j] * ad(j, Gt[i]) for j in dendro.e_i) for i in dendro.e_i ]) Gt_rhs_s2 = ([ sum(_CalGt[j] * d(j, b[i]) for j in dendro.e_i) for i in dendro.e_i ]) Gt_rhs_s3 = ([ _CalGt[i] * sum(d(j, b[j]) for j in dendro.e_i) for i in dendro.e_i ]) Gt_rhs_s4 = ([ sum([ igt[j, k] * d2(j, k, b[i]) + igt[i, j] * d2(j, k, b[k]) / 3 for j, k in dendro.e_ij ]) for i in dendro.e_i ]) Gt_rhs_s5 = ([ sum([2 * At_UU[i, j] * d(j, a) for j in dendro.e_i]) for i in dendro.e_i ]) Gt_rhs_s6 = ([ sum([ 2 * a * dendro.C2[i, j, k] * At_UU[j, k] for j, k in dendro.e_ij ]) for i in dendro.e_i ]) Gt_rhs_s7 = ([ sum([ a * (3 / chi * At_UU[i, j] * d(j, chi) + Rational(4, 3) * dendro.inv_metric[i, j] * d(j, K)) for j in dendro.e_i ]) for i in dendro.e_i ]) Gt_rhs = Matrix(_Gt_rhs_s1) - \ Matrix(_Gt_rhs_s2) + \ Rational(2,3)*Matrix(_Gt_rhs_s3) + \ Matrix(_Gt_rhs_s4) - \ Matrix(_Gt_rhs_s5) + \ Matrix(_Gt_rhs_s6) - \ Matrix(_Gt_rhs_s7) Gt_rhs = [item for sublist in Gt_rhs.tolist() for item in sublist] B_rhs = [ (Gt_rhs[i] - eta_damp * B[i] + l3 * dendro.vec_j_ad_j(b, B[i]) - l4 * dendro.vec_j_ad_j(b, Gt[i])) for i in dendro.e_i ] outs = [ a_rhs, b_rhs, gt_rhs, chi_rhs, At_rhs, K_rhs, CalGt, Gt_rhs_s1, Gt_rhs_s2, Gt_rhs_s3, Gt_rhs_s4, Gt_rhs_s5, Gt_rhs_s6, Gt_rhs_s7, Gt_rhs, B_rhs ] vnames = [ 'a_rhs', 'b_rhs', 'gt_rhs', 'chi_rhs', 'At_rhs', 'K_rhs', 'CalGt', 'Gt_rhs_s1_', 'Gt_rhs_s2_', 'Gt_rhs_s3_', 'Gt_rhs_s4_', 'Gt_rhs_s5_', 'Gt_rhs_s6_', 'Gt_rhs_s7_', 'Gt_rhs', 'B_rhs' ] ################################################################### # generate code ################################################################### numVars = len(outs) for i in range(0, numVars): dendro.generate_separate([outs[i]], [vnames[i]], '[pp]')
C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() #what's this...tried to comment it out and python compilation fails C2_spatial = dendro.get_complete_christoffel(chi) R, Rt, Rphi, CalGt = dendro.compute_ricci(Gt, chi) ################################################################### # evolution equations ################################################################### a_rhs = l1 * dendro.lie(b, a) - 2 * a * K + 0 * dendro.kodiss(a) #[ewh] In the had code, this is treated as an advective derivative. # I think this should be: # l2 * dendro.vec_j_del_j(b, b[i]) b_rhs = [ S(3) / 4 * (lf0 + lf1 * a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i]) for i in dendro.e_i ] + dendro.kodiss(b) gt_rhs = dendro.lie(b, gt, weight) - 2 * a * At + 0 * dendro.kodiss(gt) chi_rhs = dendro.lie( b, chi, weight) + Rational(2, 3) * (chi * a * K) + 0 * dendro.kodiss(chi) AikAkj = Matrix([ sum([ At[i, k] * sum([dendro.inv_metric[k, l] * At[l, j] for l in dendro.e_i]) for k in dendro.e_i ]) for i, j in dendro.e_ij ])
C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() #what's this...tried to comment it out and python compilation fails C2_spatial = dendro.get_complete_christoffel(chi) R, Rt, Rphi, CalGt = dendro.compute_ricci(Gt, chi) ################################################################### # evolution equations ################################################################### a_rhs = l1*dendro.lie(b, a) - 2*a*K + 0*dendro.kodiss(a) #[ewh] In the had code, this is treated as an advective derivative. # I think this should be: # l2 * dendro.vec_j_del_j(b, b[i]) b_rhs = [ S(3)/4 * (lf0 + lf1*a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i]) for i in dendro.e_i ] + dendro.kodiss(b) gt_rhs = dendro.lie(b, gt, weight) - 2*a*At + 0*dendro.kodiss(gt) chi_rhs = dendro.lie(b, chi, weight) + Rational(2,3) * (chi*a*K) + 0*dendro.kodiss(chi) AikAkj = Matrix([sum([At[i, k] * sum([dendro.inv_metric[k, l]*At[l, j] for l in dendro.e_i]) for k in dendro.e_i]) for i, j in dendro.e_ij]) #ewh2 At_rhs = dendro.lie(b, At, weight) + dendro.trace_free(chi*(dendro.DiDj(a) + a*R)) + a*(K*At - 2*AikAkj.reshape(3, 3)) At_rhs = dendro.lie(b, At, weight) + chi*dendro.trace_free( a*R - dendro.DiDj(a)) + a*(K*At - 2*AikAkj.reshape(3, 3)) + 0*dendro.kodiss(At) #K_rhs = dendro.vec_k_del_k(b, K) - dendro.laplacian(a) + a*(1/3*K*K + dendro.sqr(At)) K_rhs = dendro.lie(b, K) - dendro.laplacian(a,chi) + a*(K*K/3 + dendro.sqr(At)) + 0*dendro.kodiss(K) At_UU = dendro.up_up(At)
C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() #what's this...tried to comment it out and python compilation fails C2_spatial = dendro.get_complete_christoffel(chi) R, Rt, Rphi, CalGt = dendro.compute_ricci(Gt, chi) ################################################################### # evolution equations ################################################################### a_rhs = l1 * dendro.lie(b, a) - 2 * a * K #[ewh] In the had code, this is treated as an advective derivative. # I think this should be: # l2 * dendro.vec_j_del_j(b, b[i]) b_rhs = [(3 / 4) * (lf0 + lf1 * a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i]) for i in dendro.e_i] gt_rhs = dendro.lie(b, gt, weight) - 2 * a * At chi_rhs = dendro.lie(b, chi, weight) + (2 / 3) * (chi * a * K) AikAkj = Matrix([ sum([ At[i, k] * sum([dendro.inv_metric[k, l] * At[l, j] for l in dendro.e_i]) for k in dendro.e_i ]) for i, j in dendro.e_ij ]) #ewh2 At_rhs = dendro.lie(b, At, weight) + dendro.trace_free(chi*(dendro.DiDj(a) + a*R)) + a*(K*At - 2*AikAkj.reshape(3, 3))
# generate metric related quantities dendro.set_metric(gt) igt = dendro.get_inverse_metric() C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() #what's this...tried to comment it out and python compilation fails C2_spatial = dendro.get_complete_christoffel(chi) R, Rt, Rphi, CalGt = dendro.compute_ricci(Gt, chi) ################################################################### # evolution equations ################################################################### a_rhs = l1*dendro.lie(b, a) - 2*a*K b_rhs = [ S(3)/4 * (lf0 + lf1*a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i]) for i in dendro.e_i ] gt_rhs = dendro.lie(b, gt, weight) - 2*a*At chi_rhs = dendro.lie(b, chi, weight) + Rational(2,3) * (chi*a*K) AikAkj = Matrix([sum([At[i, k] * sum([dendro.inv_metric[k, l]*At[l, j] for l in dendro.e_i]) for k in dendro.e_i]) for i, j in dendro.e_ij]) At_rhs = dendro.lie(b, At, weight) + chi*dendro.trace_free( a*R - dendro.DiDj(a)) + a*(K*At - 2*AikAkj.reshape(3, 3)) K_rhs = dendro.lie(b, K) - dendro.laplacian(a,chi) + a*(K*K/3 + dendro.sqr(At)) At_UU = dendro.up_up(At) Gt_rhs_s1= ([sum(b[j]*ad(j,Gt[i]) for j in dendro.e_i) for i in dendro.e_i]) Gt_rhs_s2= ([sum(_CalGt[j]*d(j,b[i]) for j in dendro.e_i) for i in dendro.e_i])
dendro.set_metric(gt) igt = dendro.get_inverse_metric() eta_func = R0 * sqrt( sum([igt[i, j] * d(i, chi) * d(j, chi) for i, j in dendro.e_ij])) / ((1 - chi**ep1)**ep2) C1 = dendro.get_first_christoffel() C2 = dendro.get_second_christoffel() C2_spatial = dendro.get_complete_christoffel(chi) [R, Rt, Rphi, CalGt] = dendro.compute_ricci(Gt, chi) a_rhs = l1 * dendro.lie(b, a) - 2 * a * K b_rhs = [ (Rational(3, 4) * (lf0 + lf1 * a) * B[i] + l2 * dendro.vec_j_ad_j(b, b[i])) for i in dendro.e_i ] gt_rhs = dendro.lie(b, gt, weight) - 2 * a * At chi_rhs = dendro.lie(b, chi, weight) + Rational(2, 3) * (chi * a * K) AikAkj = Matrix([ sum([ At[i, k] * sum([dendro.inv_metric[k, l] * At[l, j] for l in dendro.e_i]) for k in dendro.e_i ]) for i, j in dendro.e_ij ])