Guest User

Untitled

a guest
Sep 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. from sympy import *
  2. def GLA(i,j,a):
  3.  
  4. theta = Symbol('theta')
  5. chy = Symbol('chy')
  6. sy = Symbol('sy')
  7. t = Symbol('t')
  8. temp1 = 0
  9. temp2 = 0
  10. temp3 = 0
  11. sumTialpha = 0
  12. sumTjalpha = 0
  13.  
  14. if a == 1:
  15. xa = 'theta'
  16. elif a == 2:
  17. xa = 'sy'
  18. elif a == 3:
  19. xa = 'chy'
  20. elif a == 4:
  21. xa = 't'
  22.  
  23. csc = exp(-log(sin(theta)))
  24.  
  25. gl = [ [-exp(4*t), 0, 0, 0],[0, -exp(4*t)*sin(theta)**2-exp(6*t)*cos(theta)**2, -exp(6*t)*cos(theta), 0],[0,-exp(6*t)*cos(theta),-exp(6*t),0],[0, 0, 0, 1]]
  26.  
  27. #gl = [ [-exp(4*t), 0, 0, 0],[0, -exp(4*t) -exp(6*t)*(theta**2), -exp(6*t)*(theta), 0],[0,-exp(6*t)*(theta),-exp(6*t),0],[0, 0, 0, 1]]
  28.  
  29. gL = [[-1, 0, 0 , 0],[0,-1*(1/(sin(theta))*sin(theta)),cos(theta)/(sin(theta)*sin(theta)),0],[0,cos(theta)/(sin(theta)*sin(theta)),-1*(1/(sin(theta)*sin(theta))),0],[0,0,0,1]]
  30.  
  31. #gL = [[-1/exp(2*t), 0, 0 , 0],[0,-1/exp(2*t),theta/exp(2*t),0],[0,theta/exp(2*t),-(theta**2)/exp(2*t) - 1/exp(3*t),0],[0,0,0,1]]
  32.  
  33. T = [[[0,0,0,0],[0,0,sin(theta)*0.5,0],[0,sin(theta)*0.5,0,0],[0,0,0,0]],[[0,0.5*cot(theta),-0.5*csc,0],[0.5*cot(theta),0,0,0],[-0.5*csc,0,0,0],[0,0,0,0]],[[0,-0.5*csc,0.5*cot(theta),0],[-0.5*csc,0,0,0],[0.5*cot(theta),0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]]
  34.  
  35. #T = [[[0,0,0,0],[0,-theta,-0.5,0],[0,-0.5,0,0],[0,0,0,0]],[[0,theta*0.5,0.5,0],[theta*0.5,0,0,0],[0.5,0,0,0],[0,0,0,0]],[[0,(1-theta**2)*0.5,-theta*0.5,0],[(1-theta**2)*0.5,0,0,0],[-theta*0.5,0,0,0],[0,0,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]]
  36.  
  37. k = diff(gl[i-1][j-1],xa)
  38.  
  39. while temp1 < 4:
  40. sumTialpha = sumTialpha + T[temp1][i-1][a-1]*gl[temp1][i-1]
  41. temp1 = temp1 + 1
  42.  
  43. while temp2 < 4:
  44. sumTjalpha = sumTjalpha + T[temp2][j-1][a-1]*gl[temp2][j-1]
  45. temp2 = temp2 + 1
  46.  
  47. return simplify(k - sumTialpha - sumTjalpha,ratio = 1.7)
  48.  
  49. def glab(i,j,a,b):
  50.  
  51. theta = Symbol('theta')
  52. chy = Symbol('chy')
  53. sy = Symbol('sy')
  54. t = Symbol('t')
  55. temp1 = 0
  56. temp2 = 0
  57. temp3 = 0
  58. sumTibeta = 0
  59. sumTjbeta = 0
  60.  
  61. if a == 1:
  62. xa = 'theta'
  63. elif a == 2:
  64. xa = 'sy'
  65. elif a == 3:
  66. xa = 'chy'
  67. elif a == 4:
  68. xa = 't'
  69.  
  70. #gl = [ [-1, 0, 0, 0],[0, -1, -cos(theta), 0],[0,-cos(theta),-1,0],[0, 0, 0, 1]]
  71.  
  72. gl = [ [-exp(2*t), 0, 0, 0],[0, -exp(2*t) -exp(3*t)*(theta**2), -exp(3*t)*(theta), 0],[0,-exp(3*t)*(theta),-exp(3*t),0],[0, 0, 0, 1]]
  73.  
  74. #gL = [[-1, 0, 0 , 0],[0,-1*(1/(sin(theta))*sin(theta)),cos(theta)/(sin(theta)*sin(theta)),0],[0,cos(theta)/(sin(theta)*sin(theta)),-1*(1/(sin(theta)*sin(theta))),0],[0,0,0,1]]
  75.  
  76. gL = [[-1/exp(2*t), 0, 0 , 0],[0,-1/exp(2*t),theta/exp(2*t),0],[0,theta/exp(2*t),-(theta**2)/exp(2*t) - 1/exp(3*t),0],[0,0,0,1]]
  77.  
  78. #T = [[[0,0,0],[0,0,sin(theta)/2],[0,0,0]],[[0,cos(theta)/(2*sin(theta)),-1/sin(theta)],[0,0,0],[0,0,0]],[[0,cos(theta)/(2*sin(theta)),-1/sin(theta)],[0,0,0],[0,0,0]]]
  79.  
  80. T = [[[0,0,0],[0,-theta,-1/2],[0,-1/2,0]],[[0,theta/2,1/2],[theta/2,0,0],[1/2,0,0]],[[0,1/2 - (theta**2)/2,-(theta/2)],[1/2 - (theta**2)/2,0,0],[-theta/2,0,0]],[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]]
  81.  
  82. gla = GLA(i,j,a)
  83.  
  84. k = diff(gla,xa)
  85.  
  86. while temp1 < 4:
  87. sumTibeta = sumTibeta + T[i-1][b-1][temp1-1]
  88. temp1 = temp1+1
  89.  
  90. while temp2 < 4:
  91. sumTjbeta = sumTjbeta + T[j-1][b-1][temp2-1]
  92. temp2 = temp2+1
  93.  
  94. return k - sumTibeta*gla - sumTjbeta*gla
Add Comment
Please, Sign In to add comment