odeint

Using openmp with odeint and adaptative step sizes

人走茶凉 提交于 2019-12-23 11:31:10
问题 I am trying to use openmp to parallelize my code. Everything works just fine when I use constant step sizes, however when I run the same code using an adaptative stepper I get errors that I don't understand. Here are the essential parts of the code : using namespace std; using namespace boost::numeric::odeint; const int jmax = 10; typedef double value_type; typedef boost::array<value_type ,2*(jmax+1) > state_type; //The step function void rhs( const state_type A , state_type &dAdt , const

using several eigen matrices as statetypes in boost/odeint

可紊 提交于 2019-12-22 12:14:25
问题 I am working on a physics problem for which I have to evolve parameters according to ODEs. From time to time they have to manipulated so that I would like to have a data type that can be used with routines such as diagonalisation,... Therefore, I implemented a class with eigen::Matrix as members and want to perform the integration with odeint. For a single eigen::matrix this worked fine. I made a minimal example: #include <iostream> #include <fstream> #include <cmath> #include <string>

How to specify numba jitclass when the class's attribute contains another class instance?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 05:22:09
问题 I'm trying to use numba to boost the python performance of scipy.integrate.odeint. To this end, I have to use @nb.jit(nopython=True) for the function defining the ODE system. However, this function has to take another python-class instance as an argument in my program. I had to jit the class also with @nb.jitclass(spec) with appropriate specs. This worked fine, until I found a serious issue when the specs of the class includes another type of class instance as its method. My code is following

Scipy odeint giving lsoda warning

五迷三道 提交于 2019-12-19 04:09:30
问题 I am totally new to coding and I want to solve these 5 differential equations numerically. I took a python template and applied it to my case. Here's the simplified version of what I wrote: import numpy as np from math import * from matplotlib import rc, font_manager import matplotlib.pyplot as plt from scipy.integrate import odeint #Constants and parameters alpha=1/137. k=1.e-9 T=40. V= 6.e-6 r = 6.9673e12 u = 1.51856e7 #defining dy/dt's def f(y, t): A = y[0] B = y[1] C = y[2] D = y[3] E = y

How to pass a vector to the constructor of a thrust-based odeint observer, such that it can be read within the functor

落花浮王杯 提交于 2019-12-19 03:22:17
问题 I am extending the parameter study example from boost's odeint used with thrust, and I do not know how to pass a vector of values to the constructor of the observer, such that those values can be accessed (read-only) from within the observer's functor. The following is the code just for the observer. //// Observes the system, comparing the current state to //// values in unchangingVector struct minimum_perturbation_observer { struct minPerturbFunctor { template< class T > __host__ __device__

Pass args for solve_ivp (new SciPy ODE API)

亡梦爱人 提交于 2019-12-18 12:55:29
问题 For solving simple ODEs using SciPy, I used to use the odeint function, with form: scipy.integrate.odeint(func, y0, t, args=(), Dfun=None, col_deriv=0, full_output=0, ml=None, mu=None, rtol=None, atol=None, tcrit=None, h0=0.0, hmax=0.0, hmin=0.0, ixpr=0, mxstep=0, mxhnil=0, mxordn=12, mxords=5, printmessg=0)[source] where a simple function to be integrated could include additional arguments of the form: def dy_dt(t, y, arg1, arg2): # processing code here In SciPy 1.0, it seems the ode and

Optimize constants in differential equations in Python

假装没事ソ 提交于 2019-12-18 03:01:07
问题 Okay so how would i approach to writing a code to optimize the constants a and b in a differential equation, like dy/dt = a*y^2 + b, using curve_fit? I would be using odeint to solve the ODE and then curve_fit to optimize a and b. If you could please provide input on this situation i would greatly appreciate it! 回答1: You might be better served by looking at ODEs with Sympy. Scipy/Numpy are fundamentally numerical packages and aren't really set up to do algebraic/symbolic operations. 回答2: You

How to solve a system of differential equations using scipy.odeint

此生再无相见时 提交于 2019-12-14 03:24:11
问题 I want to solve a system of equations using odeint and I get the following error: File "C:", line 45, in <module> C_B = odeint(dC_Bdt,C_B0,t) File "C:\Anaconda3\envs\ChemEng\lib\site-packages\scipy\integrate\odepack.py", line 233, in odeint int(bool(tfirst))) RuntimeError: The array return by func must be one-dimensional, but got ndim=2. My code is: import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint # Create time domain t = np.linspace(0,100,100) #

ValueError and odepack.error using integrate.odeint()

岁酱吖の 提交于 2019-12-12 12:34:29
问题 I'm trying to write an equation to model and then plot an integral control system (specifically regarding cruise control). However I'm receiving two errors whenever I run it: ValueError: object too deep for desired array odepack.error: Result from function call is not a proper array of floats. I've read these questions: scipy curve_fit error: Result from function call is not a proper array of floats How to solve this differential equation using scipy odeint? Object Too Deep for Desired Array

Do controlled error steppers in boost odeint support complex data types?

六月ゝ 毕业季﹏ 提交于 2019-12-12 11:53:09
问题 I encountered a problem with the odeint library using a controlled error stepper together with a complex state type. The code from the example with the complex stuart landau equation, I modified such that it includes an adaptive integrator. The code looks like this now: #include <iostream> #include <complex> #include <boost/array.hpp> #include <boost/numeric/odeint.hpp> using namespace std; using namespace boost::numeric::odeint; //[ stuart_landau_system_function typedef complex< double >