

I slightly modified the code above to be able to handle systems of ODEs, but it still includes hardcodedĬomponents (e.g. In case of system of ordinary differential equations you will faced with necessity to solveĪlgebraic system of size m*s, where m - the number of differential equations, s - the number of stages in rk-method. #diffeq = ImpRK4(func0x,t0,tf,dt,y0) # with single equations works Self.time = np.linspace(self.t0, self.tf, self.n+1 ) Here I report the whole class (I have cut the irrelevant part) in order to be testable for who want to try to give me help !įrom scipy.optimize import fsolve, newton_krylovĭef _init_(self, fun, t0, tf, dt, y0): I declare the equation inside the for loop (where else ?) because k1, k2 are function of self.time, self.u may you help me to find the right way to proceed ? but doesn't works when I deal with system of ODE. Done!')this works fine when I deal with a ODE single equations. K1, k2 = fsolve(equations,(self.u,self.u)) Yes it is an Implicit Runge Kutta method !! I've already done this ! and actually now my solve methods is this : K1,k2 = fsolve(equations,(1,1))how can I fix this mismatch ? TypeError: fsolve: there is a mismatch between the input and output shape of the 'func' argument 'equations'.Shape should be (2,) but it is (2, 1).I don't know why this mismatch and how to fix it.


K1,k2 = fsolve(equations,(5,5)) when I run the code I got :
