2017-12-09 23 views
0

분기 다이어그램의 데이터, 즉 [N]의 정상 상태 (nullcline) 값을 제공하는 trigger [A] (Aspace의 linspace로 지정) 값을 얻으려고합니다. 미분 방정식의 세트에서 : 방정식의 집합을 다시 배열로 nullclines을 얻기 위해 시도하는 데 시간이 너무 오래있는 그대로 enter image description hereodeint를 사용하여 분기를 결정합니다.

, 나는 주어진 시간이 지남에 통합 할 수 odeint를 사용하여 모든의 값을 얻기 위해 노력하고 있어요 d [x]/d (t)를 0으로 설정하고 해당 nullclines의 [A] 및 [N]의 값을 반환합니다. 이론적으로이 코드는 예상 값을 반환해야하지만 더 이상 설명하지 않고 커널을 죽인 것처럼 보이므로 문제를 추적 할 수 없습니다. 아래 코드를 찾으십시오 (두려워하지 말고, 대부분 변수 값을 나타냅니다).

내 코드 : 이제

#basic conditions as specified in the material 
OS = 0 
O = 0 
S= 0 
N = 0 
B = 0 

n1 = 1*(10**-4) 
a1 = 1 
a2 = 0.01 
a3 = 0.2 
n2 = 1*(10**-7) 
b1 = 0.0011 
b2 = 0.001 
b3 = 0.0007 
n3 = 1*(10**-4) 
c1 = 1 
c2 = 0.01 
c3 = 0.2 
n4 = 1*(10**-7) 
d1 = 0.0011 
d2 = 0.001 
d3 = 0.0007 
n5 = 1*(10**-4) 
e1 = 0.005 
e2 = 0.1 
n6 = 1*(10**-7) 
f1 =0.001 
f2 = 9.95*(10**-4) 
f3 = 0.01 
k1c = 0.05 
k2c = 0.001 
k3c = 5 
g1 = 1 
g2 = 1 
g3 = 1 
def differential_eq(y, t, A, B): 
    O, S, OS, N = y 
    dydt = np.empty(4) 
    dydt[0] = ((n1 + a1*A + a2*OS + a3*OS*N)/(1 + n2 + b1*A + b2*OS + b3*OS*N)) - g1*O - k1c*O*S + k2c*OS 
    dydt[1] = (n3 + c1*A + c2*OS + c3*OS*N)/(1 + n4 + d1*A + d2*OS + d3*OS*N) - g2*S - k1c*O*S + k2c*OS 
    dydt[2] = k1c*O*S -k2c*OS - k3c*OS 
    dydt[3] = ((n5 + e1*OS + e2*OS*N)/(1 + n6 +f1*OS + f2*OS*N + f3*B)) - g3*N 
    return dydt 

timepool =np.linspace(0,100,10) 

def simulate(A): 
A = A 
y = (0,0,0,0) 
B =0 
solution = sp.odeint (differential_eq(y, timepool, A, B), (A, B), timepool) 
    solution = sp.odeint (differential_eq, initial, timepool) 
    if dydt[0] == 0 and dydt[1] ==0 and dydt[2] ==0 and dydt[3] ==0: 
     print (A,N, solution) 
     return (A, N) 

Aspace = np.linspace(0,150,150) 
for A in Aspace: 
    simulate(A) 

이 작동하지 않는 것, 내가의 징후를 볼 이유는, 그냥 커널을 죽이고 같이 사람이이 경우에 왜 어떤 생각이있는 경우, 저에게 알려주세요.

+0

에서 [odeint''의 문서화 문자열]을 읽어 보시기 바랍니다 (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.odeint.html). 방정식을 정의하는 함수의 처음 두 인수 ('differential_eq')는'y, t'이어야합니다. 여기서'y'는 상태 변수를 포함하는 배열입니다 ('[O, S, OS, N]', in 너의 경우). docstring에는 예제가 있습니다. [튜토리얼] (https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html#ordinary-differential-equations-odeint) 및 [scipy cookbook] (http : //scipy-cookbook.readthedocs.io/). –

+0

'[scipy] odeint '를 검색하면 더 많은 예제를 stackoverflow에서 찾을 수 있습니다. –

+0

함수를 differential_eq (A, B, O, S, OS, N)로 정의하고 Aspace 범위에있는 A를 제외하고 odeint에 대해 'initial'내의 모든 것을 0으로 지정하더라도 커널을 죽이는 것처럼 보입니다. . 나는 문서화 문자열에 무엇이 기록되어 있는지 이해하지 못하거나 문제가 다른 곳에서 발생합니다. –

답변

1

(단축)이 의견의 발언 일부는 더, 당신의 simulate 기능은 결과를 제공

def simulate(A): 
    y = (0,0,0,0) 
    B =0 
    # parameter for the accuracy level 
    eps = 1e-9 
    # pass the correct arguments: first the function reference, then 
    # initial point and sample times, the additional arguments and 
    # the absolute and relative tolerances (they are combined as atol+rtol*(norm(y)) 
    solution = sp.odeint (differential_eq,y, timepool, args = (A, B), atol=1e-4*eps, rtol=1e-3*eps) 
    y, t = solution[-1], timepool[-1] 
    # compute the slopes at the last sample point by calling the ODE function 
    dydt = differential_eq(y,t,A,B) 
    # variables not explicitly declared global are local to the ODE function, 
    # they do not influence the global variables. 
    O, S, OS, N = y 
    # never compare floating point numbers with "==" in numerics 
    # always account for the floating point noise accumulated in the computation 
    if max(abs(dydt)) < eps : 
     #here print only the last sample point 
     print "%6.2f, %16.12f, %s"%(A, N, y) 

    return (A, N) 

과 같아야을 결합하면

0.00, 0.000099999991, [ 9.99994911e-05 9.99994911e-05 9.99789864e-11 9.99999905e-05] 
10.00, 0.002883872464, [ 7.25813895e+00 7.25813895e+00 5.26700470e-01 2.88387246e-03] 
20.00, 0.008780897525, [ 1.21628435e+01 1.21628435e+01 1.47905181e+00 8.78089753e-03] 
30.00, 0.017500871488, [ 16.0785845 16.0785845 2.58469186 0.01750087] 
40.00, 0.030166487759, [ 19.40580443 19.40580443 3.76509943 0.03016649] 
50.00, 0.049390699930, [ 22.32996985 22.32996985 4.98527848 0.0493907 ] 
60.00, 0.081339098240, [ 24.95672023 24.95672023 6.22713342 0.0813391 ] 
70.00, 0.144113671629, [ 27.35699725 27.35699725 7.48255648 0.14411367] 
100.00, 63.103453906658, [ 52.49789017 52.49789017 27.55477377 63.10345391] 
110.00, 64.363708289042, [ 53.43024046 53.43024046 28.54219752 64.36370829] 
120.00, 65.425943398185, [ 54.25586731 54.25586731 29.43110515 65.4259434 ] 
130.00, 66.343605498371, [ 55.00078061 55.00078061 30.24480971 66.3436055 ] 
140.00, 67.150809538919, [ 55.68201657 55.68201657 30.99866996 67.15080954] 
150.00, 67.870747329663, [ 56.31143752 56.31143752 31.70343926 67.87074733]