odeint

Stop integration in odeint with stiff ode

六月ゝ 毕业季﹏ 提交于 2019-12-12 09:12:15
问题 I want to solve a stiff ode with odeint. I was following this (rosenbrock4_dense_output stepper) but, my function can grow pretty quickly so I want to stop the integration if x(t)>xMAX. In this question, they have a solution for it but since I'm new with c++ I don't know how to implement this when using a rosenbrock4_dense_output stepper. I would like to see how to write this specifically for rosenbrock4_dense_output stepper. 回答1: Currently, this is not easily possible with odeint. If you can

scipy.integrate.odeint fails depending on time steps

拥有回忆 提交于 2019-12-12 05:48:30
问题 I use python for scientific applications, esp. for solving differential equations. I´ve already used the odeint function successfully on simple equation systems. Right now my goal is to solve a rather complex system of over 300 equations. At this point the odeint functions give me reasonable results as long as the time steps in the t-array are equal or smaller than 1e-3. But I need bigger time steps since the system has to be integrated over several thousand seconds. Bigger time steps yield

using ODEINT to solve two coupled systems of N differential equations ( each ) , how to fit initial conditions?

霸气de小男生 提交于 2019-12-11 23:37:28
问题 I am trying to solve numerically a system composed of two systems which is coupled. The general instructions are detailed in this picture. So far I have written the following code: import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt %matplotlib inline ep=0.1 a=0.2 N = 200 T=0.001 i = np.arange(N) theta = (2*np.pi)*i/N I0 = 0.2 J0 = 0 J1 = 2.5 delta_theta = np.subtract.outer(theta, theta) J = (J0 + J1*np.cos(delta_theta)+J1*ep*np.sin(delta_theta))/(2*N) t = np

Converting odeint system to solve_ivp, dimensions problem

久未见 提交于 2019-12-11 16:44:28
问题 I use solve_ivp to solve a system of differential equations (6 x 6). The system reads 4 arrays (with shape (8000, ) ) as inputs and saves the results in arrays with the same shape (8000, ). I want to repeat a part of the same system (only the last 2 equations). The problem is that, when I was doing the same with odeint the length of my final results (theta_i and theta_deg_i) was 8000. Now, because the arguments are written with the opposite order in solve_ivp, the length of my results is 6.

How to combine boost odeint with OpenMP and boost multiprecision?

六眼飞鱼酱① 提交于 2019-12-11 16:39:22
问题 I am asking a question, which is related to the last comments in this post: Using openmp with odeint and adaptative step sizes In the end, the original poster asked whether or not OpenMP is compatible with boost multiprecision. I guess this problem has been solved in the meanwhile but I could not find the answer. Hence, I tried to figure it out on my own and implemented some coupled ODEs. #include <iostream> #include <vector> #include <omp.h> #include <boost/numeric/odeint.hpp> #include

Boost odeint: Is it possible to perform an adaptive integration with multiprecision complex datatypes?

大城市里の小女人 提交于 2019-12-11 16:28:43
问题 In my last question I asked whether it is possible or not to use the adaptive integrators from boost odeint together with complex datatypes. Do controlled error steppers in boost odeint support complex data types? The answer worked with double precision. Now I am highly interested in the same calculation with multiprecision complex numbers. I already managed to implement this over the reals but not in the complex numbers. I tried this piece of code: #include <iostream> #include <complex>

Use numpy arrays as arguments in odeint

左心房为你撑大大i 提交于 2019-12-11 15:37:46
问题 I am trying to solve a system with differential equations using odeint. I have 4 txt files (that look like the picture below). I read them and I save them in numpy arrays (length:8000) (maby not with the most effective way, but anyway...). I want to pass these 4 arrays as arguments in my odeint and solve the system. For example, at every time step the odeint takes (one from the 8000) to solve the system, I want it to use a different value from these arrays. Is there any way to do it

using odeint & odeintw for complex equations when initial conditions are real

爱⌒轻易说出口 提交于 2019-12-11 12:16:08
问题 scipy.integrate.odeint does not handle complex values. Warren Weckesser has created a wrapper odeintw which converts a complex system into real systems. In line 176 of _odeintw.py, it checks to see whether there really are complex numbers, by checking if the initial condition is complex. But there are other ways that the equations might end up being complex. This has caused some bugs for me, and so I have changed line 176 to simply be if False: so that it uses the complex version. So - is

Scipy optimize error

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:46:24
问题 I have a fairly simply parameter estimation problem with ODEs I want to solve in Python. I have been using the odeint function for solving the ODEs and the scipy.optimize library for finding the parameter. When I use the odeint function by itself I get no problems but via the scipy.optimize it gives me an error RuntimeError: The array return by func must be one-dimensional, but got ndim=2. I do not think it is a duplicate with How to fix the error: The array return by func must be one

passed parameters to boost odeint in C++

有些话、适合烂在心里 提交于 2019-12-10 17:53:49
问题 This answer is helpful, but I would like to know how to pass multiple parameters of different types to the ODE model, perhaps in a struct. For my immediate use case, I need to be able to pass one std::array<double, 6> , two std::vector<std::vector<double>> and two two double scalars for a total of four parameters to be passed. In the linked example, as well as in harmonic_oscillator.cpp, there is only a single double passed parameter. Thanks. Here's an example of the struct I would need