Ejemplo n.º 1
0
###############################################################
#  initialize
###############################################################

r = symbols('r')

# declare functions
chi = dendro.scalar("chi", "[pp]")
phi = dendro.scalar("phi", "[pp]")

d = dendro.set_first_derivative('grad')  # first argument is direction
d2s = dendro.set_second_derivative('grad2')  # first 2 arguments are directions
d2 = dendro.d2

###############################################################
#  evolution equations
###############################################################

phi_rhs = sum(d2(i, i, chi) for i in dendro.e_i) - sin(2 * chi) / r**2

chi_rhs = phi

###############################################################
#  evolution equations
###############################################################

outs = [phi_rhs, chi_rhs]
vnames = ['phi_rhs', 'chi_rhs']

dendro.generate(outs, vnames, '[pp]')
Ejemplo n.º 2
0
         Matrix([sum(CalGt[j]*d(j,b[i]) for j in dendro.e_i) for i in dendro.e_i]) + \
         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) + (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 * 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
]

#_I = gt*igt
#print(simplify(_I))

#_I = gt*dendro.inv_metric
#print(simplify(_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_debug(outs, vnames)
dendro.generate(outs, vnames)