How to solve this differential equation using scipy odeint?

前端 未结 2 2006
灰色年华
灰色年华 2021-01-25 02:44

I am trying to solve the following differential equation using scipy odeint without much success:

import numpy as np
from scipy.misc import derivative
from scipy         


        
相关标签:
2条回答
  • 2021-01-25 03:24

    what about using ode instead of odeint

    there is a question quite similiar to yours: How to make odeint successful?

    0 讨论(0)
  • 2021-01-25 03:40

    You have a problem with this function:

    def L(B):
        return derivative(B,Ip(t))*377.2
    

    Note that t refers to the global variable defined earlier, which is a numpy array. I think you need to rethink how you define your functions and their arguments--should t also be an argument to L? As it is, f returns a list containing an array, even when its first argument contains a single element:

    In [10]: f([1], 0)
    Out[10]: 
    [array([ -2.28644086e+10,  -2.28638809e+10,  -2.28633064e+10, ...,
            -1.80290012e+09,  -1.80271510e+09,  -1.80258446e+09])]
    

    That will cause odeint to break.

    0 讨论(0)
提交回复
热议问题