differential-equations

Solving a large (150 variable) system of linear, ordinary differential equations; running into floating point rounding and/or stiffness problems

Solving a large (150 variable) system of linear, ordinary differential equations; running into floating point rounding and/or stiffness problems Question: EDIT: Original post too vague. I am looking for an algorithm to solve a large-system, solvable, linear IVP that can handle very small floating point values. Solving for the eigenvectors and eigenvalues is impossible with …

Total answers: 1

NotImplementedError: Initial conditions produced too many solutions for constants [SymPy]

NotImplementedError: Initial conditions produced too many solutions for constants [SymPy] Question: I attempted to solve this differential equation by adapting the code found here. import sympy as sp t = sp.symbols(‘t’, real=True) x = sp.Function(‘x’, real=True) diffeq = sp.Eq(x(t).diff(t), sp.sqrt(1 – x(t)**2)) res = sp.dsolve(diffeq, ics={x(0): 0}) The math.se post suggests that a piecewise function …

Total answers: 1

Unable to reproduce simple figure from textbook (possible numerical instability)

Unable to reproduce simple figure from textbook (possible numerical instability) Question: I am trying to reproduce figure 5.6 (attached) from the textbook "Modeling Infectious Diseases in Humans and Animals (official code repo)" (Keeling 2008) to verify whether my implementation of a seasonally forced SEIR (epidemiological model) is correct. An official program from the textbook that …

Total answers: 1

Unaccurate solve_ivp solution to non-homogeneous ODE (Python)

Unaccurate solve_ivp solution to non-homogeneous ODE (Python) Question: Today, I started working for the first time with solve_ivp. My problem is the following: I have data from an accelerometer and speedometer ( variables a and v in the code), which correspond to the motion data of a body under a fluid. The governing equation of …

Total answers: 2

Logistic growth curve using scipy is not quite right

Logistic growth curve using scipy is not quite right Question: I’m trying to fit a simple logistic growth model to dummy data using Python’s Scipy package. The code is shown below, along with the output that I get. The correct output is shown below it. I’m not quite sure what’s going wrong here. import scipy.optimize …

Total answers: 3

Multigrid Poisson Solver

Multigrid Poisson Solver Question: I am trying to make my own CFD solver and one of the most computationally expensive parts is solving for the pressure term. One way to solve Poisson differential equations faster is by using a multigrid method. The basic recursive algorithm for this is: function phi = V_Cycle(phi,f,h) % Recursive V-Cycle …

Total answers: 2

Python implementation of n-body problem issue

Python implementation of n-body problem issue Question: I am currently trying to implement the N-body problem using Euler’s method for solving differential equations. However, the graphical outputs do not seem correct, and I’m not sure where the issue in my code is after a while of testing. I’m currently using approximate values for Alpha Centauri …

Total answers: 1

Using Runge-Kutta to solve coupled differential equations

Using Runge-Kutta to solve coupled differential equations Question: I have a system of coupled equations: the hydrostatic equilibrium equation, the mass continuity equation, and an equation of state of the ideal gas. These are, in mathematical grammer, frac{dP}{dr}=- rho*g, where rho is the density and g is the gravitational acceleration. frac{dM}{dr}=4*pi* r^2*rho and p=rho* k_B* …

Total answers: 3

Errors while solving ODE's python

Errors while solving ODE's python Question: I have a university project in which we are asked to simulate a satellite approach to Mars using ODE’s and SciPy’s odeint function. I manage to simulate it in 2D by making a second-order ODE into two first-order ODE’s. However I am stuck in the time limitation because my …

Total answers: 1