UNPKG

3.22 kBtext/coffeescriptView Raw
1# mini test for distribution builds
2
3mini_test = ->
4
5 run_test [
6 # static spherical metric
7
8 "clearall",
9 "",
10
11 "gdd=[[-exp(2*Phi(r)),0,0,0],[0,exp(2*Lambda(r)),0,0],[0,0,r^2,0],[0,0,0,r^2*sin(theta)^2]]",
12 "",
13
14 "X=[t,r,theta,phi]",
15 "",
16
17 "guu=inv(gdd)",
18 "",
19
20 "gddd=d(gdd,X)",
21 "",
22
23 "GAMDDD=1/2*(gddd+transpose(gddd,2,3)-transpose(transpose(gddd,2,3),1,2))",
24 "",
25
26 "GAMUDD=contract(outer(guu,GAMDDD),2,3)",
27 "",
28
29 "T1=d(GAMUDD,X)",
30 "",
31
32 "T2=contract(outer(GAMUDD,GAMUDD),2,4)",
33 "",
34
35 "RUDDD=transpose(T1,3,4)-T1+transpose(T2,2,3)-transpose(transpose(T2,2,3),3,4)",
36 "",
37
38 "RDD=contract(RUDDD,1,3)",
39 "",
40
41 "R=contract(contract(outer(guu,RDD),2,3),1,2)",
42 "",
43
44 "GDD=RDD-1/2*gdd*R",
45 "",
46
47 "Gtt=1/r^2*exp(2 Phi(r)) d(r*(1 - exp(-2 Lambda(r))),r)",
48 "",
49
50 "Grr=-1/r^2*exp(2*Lambda(r))*(1-exp(-2*Lambda(r)))+2/r*d(Phi(r),r)",
51 "",
52
53 "Gthetatheta=r^2*exp(-2*Lambda(r))*(d(d(Phi(r),r),r)+d(Phi(r),r)^2+d(Phi(r),r)/r-d(Phi(r),r)*d(Lambda(r),r)-d(Lambda(r),r)/r)",
54 "",
55
56 "Gphiphi=sin(theta)^2*Gthetatheta",
57 "",
58
59 "T=[[Gtt,0,0,0],[0,Grr,0,0],[0,0,Gthetatheta,0],[0,0,0,Gphiphi]]",
60 "",
61
62 "GDD-T",
63 "[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]",
64
65 # surface integral example from the manual
66
67 "clearall",
68 "",
69
70 "z=1-x^2-y^2",
71 "",
72
73 "F=[x*y^2*z,-2*x^3,y*z^2]",
74 "",
75
76 "S=[x,y,z]",
77 "",
78
79 "s=dot(F,cross(d(S,x),d(S,y)))",
80 "",
81
82 "defint(s,y,-sqrt(1-x^2),sqrt(1-x^2),x,-1,1)",
83 "1/48*pi",
84
85 # hydrogen wavefunction example
86
87 "clearall",
88 "",
89
90 "laplacian(f)=1/r^2*d(r^2*d(f,r),r)+1/(r^2*sin(theta))*d(sin(theta)*d(f,theta),theta)+1/(r*sin(theta))^2*d(f,phi,phi)",
91 "",
92
93 "n=7",
94 "",
95
96 "l=3",
97 "",
98
99 "m=1",
100 "",
101
102 "R=r^l*exp(-r/n)*laguerre(2*r/n,n-l-1,2*l+1)",
103 "",
104
105 "Y=legendre(cos(theta),l,abs(m))*exp(i*m*phi)",
106 "",
107
108 "psi=R*Y",
109 "",
110
111 "E=psi/n^2",
112 "",
113
114 "K=laplacian(psi)",
115 "",
116
117 "V=2*psi/r",
118 "",
119
120 # after the changes to abs and mag of Jan 2017
121 # , some abs/mag are introduced in the results of legendre
122 # (correctly, I believe),
123 # which makes this expression != 0.
124 # TODO this can work only after all the absolute values
125 # have been removed
126 #"circexp(sin(theta)*(E-K-V))",
127 #"0",
128
129 # Green's theorem (surface integral)
130
131 "clearall",
132 "",
133
134 "P=2x^3-y^3",
135 "",
136
137 "Q=x^3+y^3",
138 "",
139
140 "f=d(Q,x)-d(P,y)",
141 "",
142
143 "x=r*cos(theta)",
144 "",
145
146 "y=r*sin(theta)",
147 "",
148
149 "defint(f*r,r,0,1,theta,0,2pi)",
150 "3/2*pi",
151
152 # Green's theorem (line integral)
153
154 "clearall",
155 "",
156
157 "x=cos(t)",
158 "",
159
160 "y=sin(t)",
161 "",
162
163 "P=2x^3-y^3",
164 "",
165
166 "Q=x^3+y^3",
167 "",
168
169 "f=P*d(x,t)+Q*d(y,t)",
170 "",
171
172 "f=circexp(f)",
173 "",
174
175 "defint(f,t,0,2pi)",
176 "3/2*pi",
177
178 # Stokes' theorem (surface integral)
179
180 "clearall",
181 "",
182
183 "z=9-x^2-y^2",
184 "",
185
186 "F=[3y,4z,-6x]",
187 "",
188
189 "S=[x,y,z]",
190 "",
191
192 "f=dot(curl(F),cross(d(S,x),d(S,y)))",
193 "",
194
195 "x=r*cos(theta)",
196 "",
197
198 "y=r*sin(theta)",
199 "",
200
201 "defint(f*r,r,0,3,theta,0,2pi)",
202 "-27*pi",
203
204 # Stokes' theorem (line integral)
205
206 "clearall",
207 "",
208
209 "x=3*cos(t)",
210 "",
211
212 "y=3*sin(t)",
213 "",
214
215 "z=9-x^2-y^2",
216 "",
217
218 "P=3y",
219 "",
220
221 "Q=4z",
222 "",
223
224 "R=-6x",
225 "",
226
227 "f=P*d(x,t)+Q*d(y,t)+R*d(z,t)",
228 "",
229
230 "f=circexp(f)",
231 "",
232
233 "defint(f,t,0,2pi)",
234 "-27*pi",
235 ]
236