Reputation:
I would like to pass a matrix as initial condition for scipy.integrate.solve_ivp
.
With odeInt this was possible by flattening the matrix as:
Result = odeint(myfunction, myMatrix.ravel(),myTimeVector )
Inside the function myFunction
, the matrix is reshaped into a 3x3 matrix for some calculations.
If I try to use solve_ivp(myfunction, myTimeVector,myMatrix.ravel() )
, I get the following error:
ValueError: cannot reshape array of size 1 into shape (3,3)
because it only passes the first element of the array, instead of the whole array. Is it possible pass the matrix as initial condition as was withodeint
?
Best Regards
Upvotes: 0
Views: 841
Reputation:
Well... Solved it in the following manner:
Changed the entries in myFunction(y,t)
to myFunction(t,y)
Result=solve_ivp(myfunction, (myTimeVector[0], myTimeVector[-1]), myMatrix.ravel(), t_eval=myTimeVector)
Upvotes: 1