简体   繁体   English

微分方程 BVP

[英]differential equations BVP

#including the differential equations and parameters 

def model(x,dydx,p): 
    s=p[0]  #first parameter 
    a=p[1]   #second parameter 

    dydx[0] = -2*(s+a)*y[0]+2*s*y[1]+s/2*y[2] 
    dydx[1] = +2*(s+a)*y[1]-2*s*y[0]-s/2*y[2] 
    dydx[2] = -(s+a)*y[2] 

    return np.vstack(dydx[0],dydx[1],dydx[2]) 

# boundary conditions

def bc(ya, yb,yc, p): 
    s=p[0]  
    a=p[1] 
    I0=1 

    return np.array(([ya[0], yb[0],yc[0],a,s])) 
#x values 
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])   
y = np.zeros((3, x.size)) 
#p=  np.zeros((3, d.size)) 
#y initial values 
y[0]=3 
y[1]=3 
y[2]=2 

I0 = 1 

sol = solve_bvp(model, bc,x,y, p=[1,1]) 

I do not know how can I write the boundary conditions to solve the three differential equations我不知道如何写边界条件来求解三个微分方程

I want to solve the equations and have the y values and parameters values我想解方程并获得y值和参数值

Per the other question you have fixed parameters and 3 boundary conditions.根据另一个问题,您有固定参数和 3 个边界条件。 This needs to be encoded as这需要编码为

# boundary conditions
def bc(y0, yd, I0): 
    return np.array([y0[0], y0[2]-I0, yd[1]]) 

Then the initial x array needs to be bounded by the boundary points那么初始x数组需要以边界点为界

x = np.linspace(0,d,9)   
y = np.zeros((3, x.size)) 
#y initial values 
y[0]=3 
y[1]=3 
y[2]=2 

and the solver needs to be called without variable parameters, fixing them all to their constant values via wrappers/partial evaluation并且需要在没有可变参数的情况下调用求解器,通过包装器/部分评估将它们全部固定为其常量值

sol = solve_bvp(lambda t,y:model(t,y,[s,a]), lambda y0,yd: bc(y0,yd,I0), x,y) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM