質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -215,3 +215,217 @@
|
|
215
215
|
ValueError: x and y must have same first dimension, but have shapes (10000,) and (1,)
|
216
216
|
|
217
217
|
```
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
書き換えてみたけど別のエラーが出る。
|
222
|
+
|
223
|
+
```python
|
224
|
+
|
225
|
+
from scipy.special import kv
|
226
|
+
|
227
|
+
import matplotlib.pyplot as plt
|
228
|
+
|
229
|
+
from scipy.integrate import quad
|
230
|
+
|
231
|
+
import numpy as np
|
232
|
+
|
233
|
+
import math
|
234
|
+
|
235
|
+
from math import gamma
|
236
|
+
|
237
|
+
from sympy import *
|
238
|
+
|
239
|
+
import os
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
xs=np.logspace(-4, 2, 10000)
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
m=9.10938356*1e-31
|
250
|
+
|
251
|
+
c=2.99792458*1e+8
|
252
|
+
|
253
|
+
q=1.6021766208*1e-19
|
254
|
+
|
255
|
+
pa=np.pi/2
|
256
|
+
|
257
|
+
sin_pa=math.sin(pa)
|
258
|
+
|
259
|
+
B1=100*1e-6*1e-4
|
260
|
+
|
261
|
+
a = gamma(1/3)
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
f = lambda z: kv(5/3,z)
|
266
|
+
|
267
|
+
F = [quad(f,x,np.inf)[0]*x for x in xs]
|
268
|
+
|
269
|
+
G = [(4*np.pi/np.sqrt(3)/a)*(x/2)**(1/3) for x in xs]
|
270
|
+
|
271
|
+
H = [((np.pi/2)**(1/2))*(x**(1/2))*(np.exp(-x))for x in xs]
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
def A(x,F,G,H):
|
276
|
+
|
277
|
+
if x <= 5.0*1e-3:
|
278
|
+
|
279
|
+
return G(x,y)
|
280
|
+
|
281
|
+
elif 5.0*1e-3 < x < 30:
|
282
|
+
|
283
|
+
return F(x,y)
|
284
|
+
|
285
|
+
elif 30 <= x:
|
286
|
+
|
287
|
+
return H(x,y)
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
vec_A = np.vectorize(A)
|
292
|
+
|
293
|
+
def L(x):
|
294
|
+
|
295
|
+
return vec_A(xs,F,G,H)
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
def P(v,y):
|
300
|
+
|
301
|
+
return (math.sqrt(3)*q**3*B1*sin_pa/(m*c**2))*L(v/v_c)
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
gmin=1
|
306
|
+
|
307
|
+
gmax=10**5
|
308
|
+
|
309
|
+
N=10/(10**5-1)
|
310
|
+
|
311
|
+
p=-2
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
def s(x):
|
318
|
+
|
319
|
+
b=L*x**(-1/2)
|
320
|
+
|
321
|
+
return b
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
def x1(v):
|
326
|
+
|
327
|
+
return 4*np.pi*m*c*v/(3*q*B1*sin_pa*gmin**2)
|
328
|
+
|
329
|
+
def x2(v):
|
330
|
+
|
331
|
+
return 4*np.pi*m*c*v/(3*q*B1*sin_pa*gmax**2)
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
def b(v):
|
336
|
+
|
337
|
+
b1=-1/math.sqrt(v)
|
338
|
+
|
339
|
+
b2=(math.sqrt(3)*q**3*B1*sin_pa/(2*m*c**2))
|
340
|
+
|
341
|
+
b3=math.sqrt(3*q*B1*sin_pa/(4*np.pi*m*c))
|
342
|
+
|
343
|
+
return b1*b2*b3*N
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
def Pt(v):
|
348
|
+
|
349
|
+
a=[quad(s,x1(v),x2(v))[0] for x in xs]
|
350
|
+
|
351
|
+
return b*a[0]
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
v=np.logspace(-4,2,10000)
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
plt.plot(v,Pt(v))
|
360
|
+
|
361
|
+
plt.show()
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
```
|
366
|
+
|
367
|
+
エラー
|
368
|
+
|
369
|
+
```python
|
370
|
+
|
371
|
+
ValueError Traceback (most recent call last)
|
372
|
+
|
373
|
+
<ipython-input-14-4d47f52aab3a> in <module>
|
374
|
+
|
375
|
+
66 v=np.logspace(-4,2,10000)
|
376
|
+
|
377
|
+
67
|
378
|
+
|
379
|
+
---> 68 plt.plot(v,Pt(v))
|
380
|
+
|
381
|
+
69 plt.show()
|
382
|
+
|
383
|
+
70
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
<ipython-input-14-4d47f52aab3a> in Pt(v)
|
388
|
+
|
389
|
+
61
|
390
|
+
|
391
|
+
62 def Pt(v):
|
392
|
+
|
393
|
+
---> 63 a=[quad(s,x1(v),x2(v))[0] for x in xs]
|
394
|
+
|
395
|
+
64 return b*a[0]
|
396
|
+
|
397
|
+
65
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
<ipython-input-14-4d47f52aab3a> in <listcomp>(.0)
|
402
|
+
|
403
|
+
61
|
404
|
+
|
405
|
+
62 def Pt(v):
|
406
|
+
|
407
|
+
---> 63 a=[quad(s,x1(v),x2(v))[0] for x in xs]
|
408
|
+
|
409
|
+
64 return b*a[0]
|
410
|
+
|
411
|
+
65
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
C:\ProgramData\Anaconda3\lib\site-packages\scipy\integrate\quadpack.py in quad(func, a, b, args, full_output, epsabs, epsrel, limit, points, weight, wvar, wopts, maxp1, limlst)
|
416
|
+
|
417
|
+
336
|
418
|
+
|
419
|
+
337 # check the limits of integration: \int_a^b, expect a < b
|
420
|
+
|
421
|
+
--> 338 flip, a, b = b < a, min(a, b), max(a, b)
|
422
|
+
|
423
|
+
339
|
424
|
+
|
425
|
+
340 if weight is None:
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
|
430
|
+
|
431
|
+
```
|
2
文字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
v-Ptグラフをプロットしたいがx and y must have same first dimension, but have shapes (10000,) and (1,)のエラーが出る
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -28,6 +28,10 @@
|
|
28
28
|
|
29
29
|
ys=np.logspace(0, 5, 10000)
|
30
30
|
|
31
|
+
vs=np.logspace(0,5,10000)
|
32
|
+
|
33
|
+
|
34
|
+
|
31
35
|
m=9.10938356*1e-31
|
32
36
|
|
33
37
|
c=2.99792458*1e+8
|
@@ -100,7 +104,7 @@
|
|
100
104
|
|
101
105
|
|
102
106
|
|
103
|
-
def R(y):
|
107
|
+
def R(v,y):
|
104
108
|
|
105
109
|
return N*y**-p*P
|
106
110
|
|
@@ -108,7 +112,7 @@
|
|
108
112
|
|
109
113
|
def Pt(v):
|
110
114
|
|
111
|
-
return [quad(R, gmin, gmax)[0] for y in ys]
|
115
|
+
return [quad(lambda y:R, gmin, gmax)[0] for y in ys]
|
112
116
|
|
113
117
|
|
114
118
|
|
@@ -124,7 +128,7 @@
|
|
124
128
|
|
125
129
|
ax.set_xscale('log')
|
126
130
|
|
127
|
-
ax.plot(
|
131
|
+
ax.plot(vs,Pt)
|
128
132
|
|
129
133
|
|
130
134
|
|
@@ -138,17 +142,17 @@
|
|
138
142
|
|
139
143
|
ValueError Traceback (most recent call last)
|
140
144
|
|
141
|
-
<ipython-input-
|
145
|
+
<ipython-input-5-33ed3b99f09b> in <module>
|
142
|
-
|
146
|
+
|
143
|
-
|
147
|
+
60 ax.set_yscale('log')
|
144
|
-
|
148
|
+
|
145
|
-
|
149
|
+
61 ax.set_xscale('log')
|
146
|
-
|
150
|
+
|
147
|
-
---> 6
|
151
|
+
---> 62 ax.plot(vs,Pt)
|
148
|
-
|
152
|
+
|
149
|
-
6
|
153
|
+
63
|
150
|
-
|
154
|
+
|
151
|
-
6
|
155
|
+
64 plt.show()
|
152
156
|
|
153
157
|
|
154
158
|
|
1
文字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
q=1.6021766208*1e-19
|
36
36
|
|
37
|
-
pa=np.pi/2
|
37
|
+
pa=np.pi/2#ピッチ角#
|
38
38
|
|
39
39
|
sin_pa=math.sin(pa)
|
40
40
|
|
@@ -56,29 +56,37 @@
|
|
56
56
|
|
57
57
|
H = [((np.pi/2)**(1/2))*(x**(1/2))*(np.exp(-x))for x in xs]
|
58
58
|
|
59
|
+
|
60
|
+
|
59
|
-
def A(x,F,G,H):
|
61
|
+
def A(x,y,F,G,H):
|
60
62
|
|
61
63
|
if x <= 5.0*1e-3:
|
62
64
|
|
63
|
-
|
65
|
+
return G(x,y)
|
64
66
|
|
65
67
|
elif 5.0*1e-3 < x < 30:
|
66
68
|
|
67
|
-
|
69
|
+
return F(x,y)
|
68
70
|
|
69
71
|
elif 30 <= x:
|
70
72
|
|
71
|
-
g =H
|
72
|
-
|
73
|
-
return
|
73
|
+
return H(x,y)
|
74
|
+
|
75
|
+
|
74
76
|
|
75
77
|
vec_A = np.vectorize(A)
|
76
78
|
|
79
|
+
def L(x,y):
|
80
|
+
|
77
|
-
|
81
|
+
return vec_A(xs,ys,F,G,H)
|
82
|
+
|
83
|
+
|
84
|
+
|
78
|
-
|
85
|
+
def P(v,y):
|
86
|
+
|
79
|
-
|
87
|
+
x=v/v_c
|
80
|
-
|
88
|
+
|
81
|
-
|
89
|
+
return (math.sqrt(3)*q**3*B1*sin_pa/(m*c**2))*L(v/v_c)
|
82
90
|
|
83
91
|
|
84
92
|
|
@@ -104,6 +112,8 @@
|
|
104
112
|
|
105
113
|
|
106
114
|
|
115
|
+
|
116
|
+
|
107
117
|
fig = plt.figure()
|
108
118
|
|
109
119
|
ax = fig.add_subplot(1,1,1)
|
@@ -128,17 +138,17 @@
|
|
128
138
|
|
129
139
|
ValueError Traceback (most recent call last)
|
130
140
|
|
131
|
-
<ipython-input-
|
141
|
+
<ipython-input-9-c903738de0cc> in <module>
|
132
|
-
|
142
|
+
|
133
|
-
5
|
143
|
+
58 ax.set_yscale('log')
|
134
|
-
|
144
|
+
|
135
|
-
5
|
145
|
+
59 ax.set_xscale('log')
|
136
|
-
|
146
|
+
|
137
|
-
--->
|
147
|
+
---> 60 ax.plot(xs,Pt)
|
138
|
-
|
148
|
+
|
139
|
-
|
149
|
+
61
|
140
|
-
|
150
|
+
|
141
|
-
|
151
|
+
62 plt.show()
|
142
152
|
|
143
153
|
|
144
154
|
|