2014-10-03 2 views
1

저는 파이썬에 대해 아주 익숙합니다. 그래서 저는 말씨가 의미가 있기를 바라고 있습니다. 저는 현재 플로팅으로 곱해지는 통합의 곱을 필요로하는 방정식을 모델링하려고 시도하고 있습니다. 혼자 통합 출력에서 ​​할머니 출력을 얻고 그 내 코드 왜 내가 모르는 다음과 같습니다 :파이썬에서 scipy 쿼드 통합과 관련된 문제

from __future__ import division 
import matplotlib.pylab as plt 
import numpy as np 
import scipy.special as sp 
import scipy as sci 
from scipy import integrate 
import math 
from sympy.functions import coth 
Tc = 9.25 
Tb = 7.2 
t = Tb/Tc 
Temperature = [] 
Temp1=[] 
Temp0=[] 
D=[] 
d = [] 
D1=[] 
d1 = [] 
n = 2*10**-6 
L = 100*10**-9 
W = 80*10**-9 
a = 3*10**-2 
s1 = W/ (2*n) 
y1 = (L+(W/2))/(2*n) 
x0 = 0.015 
r0 = 2*x0 
s2 = r0/n 
y0 = (x0/n)/1000000 
print x0, y0, y1 
A = ((W/n)**2) *(sp.kv(0, s1)+(math.pi/2)*sp.kv(1,s1)*coth(y1)) 
B = ((W/n)**2) *(sp.iv(0, s1)+(math.pi/2)*sp.iv(1,s1)*coth(y1)) 
print A, B 
def t1(t): 
    return (t**-1)*sp.kv(0, s2) 
def t2(t): 
    return (t**-1)*sp.iv(0, s2) 
print t2 
Fk2 =(math.pi**-2) * integrate.quad(t1, s1, s2, full_output=False)[0] 
FI2 =(math.pi**-2) * integrate.quad(t2, s1, s2, full_output=False)[0] 
print Fk2 , #FI2 
r1 = 0.0 
while r1 < y1: 
    #C0 = sp.kv(0,s2)*(1 + (A*FI2)-(B*Fk2))/A 
    #print C0 
    #D_ = 1 - B*Fk2 - A*Fk2*sp.iv(1, s1)/sp.kv(1, 1) 
    #print D_ 
    r1 += 0.0001 
    j = -1*r1 
    D.append(r1) 
    d.append(j) 
    #T = Tb + (Tc - Tb) * (sp.kv(0,s1) + (math.pi /2)* sp.kv(1, s1)*coth(r1))*(1- D_ * math.cosh(y1)) * (C0*A) 
    #Temp0.append(T) 
    #print Temp0, r1 

주요 원인이 될 것으로 보인다 방정식 FI2의 sp.iv에서 수정 된 베셀 함수 (T2는 S1) 그는 앤 값을 반환하지만, 다른 식 결과 Fk2 난 다음 오류가 발생하고 일정 시간 동안 0을 준다 :

IntegrationWarning: The occurrence of roundoff error is detected, which prevents the requested tolerance from being achieved. The error may be underestimated. warnings.warn(msg, IntegrationWarning) 

을하지만 중지 지금은 단지 0.0 낭을 얻는다. 어떤 도움이라도 정말 고맙게 여기 있습니다.

답변

1

s2의 값이 다소 큽니다 (15000.0). 당신은 당신이 제로를 얻을 s2의에서 Bessel Function을 평가할 때, :

>>> sp.kv(0, 15000.0) 
0.0 

그래서 함수의 T1은 항상 적분 영을, 0을 반환합니다.

관련 문제