3
def function(phi_0, phi_x, phi_y, phi_xy,
4
f_sin_x, f_cos_x, f_sin_y, f_cos_y, f_sin_xy, f_cos_xy,
5
alpha_x, alpha_y, alpha_xy):
8
f_x = phi_x*(f_sin_x*sin(alpha_x*x) + f_cos_x*cos(alpha_x*x))
9
f_y = phi_y*(f_sin_y*sin(alpha_y*y) + f_cos_y*cos(alpha_y*y))
10
f_xy = phi_xy*(f_sin_xy*sin(alpha_xy*x*y/pi) + f_cos_xy*cos(alpha_xy*x*y/pi))
11
f = f_0 + f_x + f_y + f_xy
14
p = function(-1.0, 1.0, 1.0, 1.0,
15
1.0, 0.0, 0.0, 1.0, 1.0, 0.0,
19
u1 = 0.25*cos(x)*cos(y) - x*cos(y)
22
v2 = sin(y)*sin(x) - cos(x)*sin(y)
24
vfrac1 = 0.8 #0.1 + y/20.0
25
vfrac2 = 1.0 - vfrac1 #1.0 - vfrac1
27
#print "DIVERGENCE = ", diff(vfrac1*u1,x) + diff(vfrac1*v1,y) + diff(vfrac2*u2,x) + diff(vfrac2*v2,y)
31
tau_xx1 = 2*nu*diff(u1,x) - (2.0/3.0)*nu*(diff(u1,x) + diff(v1,y))
32
tau_xy1 = nu*(diff(u1,y) + diff(v1,x))
33
tau_yy1 = 2*nu*diff(v1,y) - (2.0/3.0)*nu*(diff(u1,x) + diff(v1,y))
34
tau_yx1 = nu*(diff(u1,y) + diff(v1,x))
36
tau_xx2 = 2*nu*diff(u2,x) - (2.0/3.0)*nu*(diff(u2,x) + diff(v2,y))
37
tau_xy2 = nu*(diff(u2,y) + diff(v2,x))
38
tau_yy2 = 2*nu*diff(v2,y) - (2.0/3.0)*nu*(diff(u2,x) + diff(v2,y))
39
tau_yx2 = nu*(diff(u2,y) + diff(v2,x))
41
Su1 = vfrac1*rho1*u1*diff(u1,x) + vfrac1*rho1*v1*diff(u1,y) - diff(vfrac1*tau_xx1, x) - diff(vfrac1*tau_xy1, y) + vfrac1*diff(p,x)
42
Sv1 = vfrac1*rho1*u1*diff(v1,x) + vfrac1*rho1*v1*diff(v1,y) - diff(vfrac1*tau_yx1, x) - diff(vfrac1*tau_yy1, y) + vfrac1*diff(p,y)
43
Su2 = vfrac2*rho2*u2*diff(u2,x) + vfrac2*rho2*v2*diff(u2,y) - diff(vfrac2*tau_xx2, x) - diff(vfrac2*tau_xy2, y) + vfrac2*diff(p,x)
44
Sv2 = vfrac2*rho2*u2*diff(v2,x) + vfrac2*rho2*v2*diff(v2,y) - diff(vfrac2*tau_yx2, x) - diff(vfrac2*tau_yy2, y) + vfrac2*diff(p,y)
46
print 'from math import sin, cos, tanh, pi'
49
print ' return', str(u1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
52
print ' return', str(v1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
55
print ' return', str(u2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
58
print ' return', str(v2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
60
print 'def vfrac1(X):'
61
print ' return', str(vfrac1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
63
print 'def vfrac2(X):'
64
print ' return', str(vfrac2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
67
print ' return', str(p).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
70
print ' return', str(rho1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
73
print ' return', str(rho2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
75
print 'def forcing_u1(X):'
76
print ' return', str(Su1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
78
print 'def forcing_v1(X):'
79
print ' return', str(Sv1).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
81
print 'def forcing_u2(X):'
82
print ' return', str(Su2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
84
print 'def forcing_v2(X):'
85
print ' return', str(Sv2).replace('e^', 'exp').replace('^', '**').replace('000000000000', '').replace('x', 'X[0]').replace('y', 'X[1]')
87
print 'def velocity1(X):'
88
print ' return [u1(X), v1(X)]'
90
print 'def velocity2(X):'
91
print ' return [u2(X), v2(X)]'
93
print 'def forcing_velocity1(X):'
94
print ' return [forcing_u1(X), forcing_v1(X)]'
96
print 'def forcing_velocity2(X):'
97
print ' return [forcing_u2(X), forcing_v2(X)]'