1,544 questions
1
vote
0
answers
162
views
What does np.ones_like represent in a quiver plot of a differential equation?
I found some similar questions about quiver plots and direction fields, but I’m still confused about the meaning of these two lines in many examples:
What do dx = np.ones_like(f) and dy = f mean in a ...
-2
votes
1
answer
72
views
Trying to solve a satellite equation, but I'm getting an empty plot
I'm trying to numerically integrate the equations of motion for a satellite moving about a spheroidal Earth using Heun's method, but I get a RuntimeWarning: invalid value encountered in scalar divide, ...
1
vote
1
answer
171
views
FitzHugh–Nagumo model output not resembling what is shown on Wikipedia
First off, I just want to mention that I am a biology researcher not trained in differential equations or dynamical systems. I am doing this as an exercise to get a bit of intuitive understanding of ...
2
votes
1
answer
105
views
1D Poisson equation in MATLAB
I'm solving Poisson equation and I've come across a problem that I cannot understand.
All methods I'm using give a different result than the algebraic solution, which I believe is correct. Everything ...
0
votes
1
answer
100
views
How to python code a distributed delayed differential system in python?
Already tried with ddeint, does not yield good results. I have an equivalent PDE system that works just fine and I can compare results. The key of the problem is that the system is coupled, so I ...
0
votes
1
answer
163
views
One adaptive-time-step solution for ODE
I want to solve some ODE just for one time step. The time step is decided internally by the solver, not by me. Is there a python adaptive-time-step ode solver which could do this? For illustration the ...
0
votes
0
answers
63
views
Phase Portrait of Coupled ODEs Not Matching Expected Graph in Python (SciPy)
I’m trying to generate a phase portrait for a system of coupled ordinary differential equations (ODEs) using Python’s scipy.integrate.solve_ivp. The system models the frequency of cooperators (x) and ...
1
vote
2
answers
123
views
graphing nonlinear systems of ODEs in python
the model Im trying to graph this model however I am just not sure whether my code is leading me to a reasonable solution:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate ...
1
vote
2
answers
109
views
deviation in solutions (differential equations) using odeint vs runge-kutta-4th
I am modelling a Coupled Spring-Mass-System: Two objects with masses m1 and m2, and are coupled through springs with spring constants k1 and k2, with damping d1 and d2.
Method 1: taking a cookbook-...
1
vote
1
answer
517
views
Why is the accuracy of scipy.integrate.solve_ivp (RK45) extremely poor compared to my homemade RK4 implementation?
What I want to solve
I solved a system of ordinary differential equations using scipy.integrate.solve_ivp and compared the results with my homemade 4th-order Runge-Kutta (RK4) implementation.
...
0
votes
0
answers
57
views
Solving differential equations with ode solvers and finite difference in Matlab
I have implemented following equations both with the Matlab own ODE solvers and with a very simple finite difference scheme. The latter works properly, while the ODE code does not produce suitable ...
0
votes
0
answers
69
views
Negative Eigenvalues of the Woods-Saxon Nuclear Potential for Oxygen ND Eigensystem
I am trying to use ND Eigensystem to find the eigenvalues of the Woods-Saxon Potential Schroedinger Equation for Oxygen. I've defined the potential and operator, but I know the functions given are ...
0
votes
0
answers
56
views
Matlab error solving symbolic systems of equations as functions of time
I have the following system of differential equations that arose form circuit analysis where the following simplification was made.
Simplification of equations
The systems of equations is as follows:
...
0
votes
1
answer
129
views
Solving non-linear ODE system with boundary conditions in Python
I am trying to solve this system of differential equations:
The functions should behave like this, as r-> infinity (F = g = lambda = const.):
A while ago I had a similar problem and a user was ...
1
vote
0
answers
91
views
Solving Nonlinear Boundary Value Problem with Constraints
I want to solve the following boundary value problem
where S, k_i, x_f, α_1, and θ are known parameters. We are trying to solve for h(x), p, and θ_d.
My idea was to use finite differences to create a ...
1
vote
1
answer
107
views
Why does my planetary orbit simulation produce a straight line instead of an elliptical orbit?
I'm trying to simulate the orbit of a planet using the compute_orbit method, but when I plot the resulting positions, I get a straight line instead of an expected elliptical orbit. Below are the ...
2
votes
1
answer
99
views
Media Library, Failed to reduce the DAE index
I tried to develop a model of an Organic Rankine Cycle from scratch. The heat exchanger is the only dynamic submodel of the cycle, and it runs perfectly whenever I use water as the medium (both in ...
0
votes
0
answers
93
views
SymPy not finding solution for differential equation with at least one known trivial solution
I was following the tutorial at SymPy site on how to solve differential equations, and started with the classic case of finding a function that equals its own derivative, as shown bellow:
from sympy ...
2
votes
1
answer
187
views
How do I solve this differential equation (1-x^2)y'=x^2-xy-1 in SymPy as expected?
I want to solve (1-x^2)y'=x^2-xy-1 with Sympy, but I cannot solve it as expected.
I expect to get the following solution.
-1<x<1:y(x)=-sqrt(1-x**2)*asin(x)+C1*sqrt(1-x**2)
x<-1,x>1:y(x)=-...
0
votes
1
answer
49
views
Returning additional values from scipy.odeint
I want to solve an ordinary differential equation in Python using scipy.odeint while returning some values from a defined function, which are not differentials.
I tried storing the additional values ...
0
votes
1
answer
111
views
Non linear differential equation (Korteweg–De Vries) becomes unstable with time
I would like to solve the Korteweg-De Vries equation with the initial conditions U(x,0) = n(n+1)/cosh^2(x). However, my system becomes numerically unstable for n>1 (n is an integer), what could be ...
0
votes
0
answers
127
views
How to vectorize Jacobi elliptic function calls in python with negative arguments
I've got a differential equation which I have solved exactly in terms of Jacobi elliptic functions. Now I'd like to efficiently evaluate the (exact) solution numerically for the sake of plotting and ...
1
vote
1
answer
111
views
Struggling to get mathematical model to work
I am trying to mimic a mathematical model based on the following model documentation.
4.1.1.4 Exposure to Vapour: Evaporation
https://www.rivm.nl/bibliotheek/rapporten/2017-0197.pdf
Python script:
...
0
votes
1
answer
207
views
How to solve three coupled differential equations in python using RK-4 and shooting method? or using solve_bvp?
I am trying to solve three coupled differential equations in Python. I am using RK-4 techniques with Shooting method. I am trying to plot the f and N functions.
import numpy as np
import matplotlib....
0
votes
0
answers
33
views
SageMATH failed to solve ODE with Symbolic Integration
I'm trying to solve an exact integration of a nonlinear ODE using SageMath.
I'm trying to find time function $x = x(t)$ integrating ODE $\dot{x} = b(2+\sqrt(1-x^2))(1-x^2)$ with SAGEMATH code below:
t ...
1
vote
0
answers
27
views
"No gradients were provided for any variables" while making an mse+round+rescale loss function
Problem Statement
I have a TensorFlow machine learning model that should learn to mimic a digital result [0, 1], the output of the model is a float number, so I have used a MeanSquaredError and ...
0
votes
2
answers
85
views
SymPy - plot differential equation graph
I get error when trying to plot a graph : TypeError: Cannot convert expression to float
I also get empty graph:
from sympy import *
from IPython.display import display
init_printing()
import ...
0
votes
1
answer
327
views
Using `solve_ivp` and `LSODA` to solve a complex ODE
I am trying to solve a complex system of differential equations. The equations are stiff so I need to need to use a method which can handle both complex ODEs and stiffness switching. I have landed on ...
0
votes
1
answer
57
views
DifferentialEquations.jl - Spring mass damper system ODE
Is this the right way to write a spring mass damper system in julia using DifferentialEquations.jl?
function smd(du, u, p, t)
c, k, m = p
du[1] = dx = u[2]
du[2] = dv = -(c/m)*u[2] - (k/m)*...
2
votes
1
answer
72
views
What is the problem with my R code for solving and plotting a coupled system of ODE's?
I'm reasonably new to R and have this system of ODEs
\frac{dS}{dT} = -\beta(1-\mu)S(t)\frac{I(t))}{1-D(t))}
\frac{dI}{dT} = -\beta(1-\mu)S(t)\frac{I(t))}{1-D(t))}-\delta I(t))-\phi I(t))
\frac{dR}{dT}=...
1
vote
1
answer
64
views
Wrong function call when solving for steady state using julia's NonlinearSolve
I am using NonlinearSolve to solve a steady state problem. When I do
prob = SteadyStateProblem(eoms!, σ₀, p)
sol = solve(
prob,
SSRootfind(),
abstol = slv.abstol,
reltol = slv.reltol,
)...
1
vote
1
answer
159
views
TensorFlow second derivative calculation always returns zero in Quantum PINN solver
I'm attempting to implement a simple Physics-Informed Neural Network (PINN) for Solving the time-independent Schrödinger equation given an arbitrary scalar potential. The details aren't, I think, ...
1
vote
0
answers
43
views
Four 1st order IVP ODE by Runge-Kutta 4th order scheme in C getting damped
I am currently working on a simulation project involving a two-degree-of-freedom (2DOF) airfoil. The motion of this airfoil is governed by the following equations of motion:
To numerically solve ...
-1
votes
1
answer
135
views
Fitting curve where each point is the solution of an ODE
I have the following code:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import random
def dose(y, t, b, s, c, p, i):
target, infectious, virus = y
...
0
votes
1
answer
107
views
Runge-Kutta Behaving Strangely When Initial Value Is Negative
I have the following RK4 algorithm in C++ for solving first-order differential equations:
using ODE_Function = std::function<double/*dy/dx*/(double/*x*/, double/*y*/)>;
template<int length&...
1
vote
1
answer
168
views
MATLAB Plotting solution to second order differential equation Error
I have a questions very similar to this post. Unfortunately there is no answer for the question and I have additional questions.
I am trying to generate a solve for the current in an RLC circuit and ...
0
votes
0
answers
96
views
solve_ivp gets "stuck" at incredibly small "time" step
I'm trying to solve a problem of filling and emptying of a retention behind a dam. What I've got are: 1) a function that relates the elevation of the water in the retention with the volume of the ...
2
votes
1
answer
90
views
Dirichlet boundary conditions using odeint
I am trying to edit the Gray-Scott 1D equation example (last example on the page) in the odeint documentation.
I have the code below and it works for the Neumann boundary conditions but I want a ...
0
votes
1
answer
292
views
Fitting a set of data to a second order kinetic rate scheme in Python
I am working with a set of data
Time = [1, 1.25, 2.5, 3.75, 5, 6.25, 7.5, 8.75, 10]
AB = [0.041355887, 0.228856274, 0.283712222, 0.401528071, 0.450842768, 0.514348728, 0.550876642, 0.61845291, 0....
0
votes
1
answer
137
views
How to evaluating solutions to Coupled Nonlinear Elliptic ODEs with Relaxation Method?
I would like to determine the following system of coupled, nonlinear, elliptic ODEs of second order with boundary conditions f(0) = h(0) = 0, f(1) = h(1) = 1.
I used a relaxation method to solve the ...
2
votes
1
answer
103
views
Python code for second order non linear differetial equation
To find the deformations on the quarter of a ring I found the following formulations:
ϵ=(θ′−1/R)∗t/2, θ(s)′′=−F4EI∗cosθ, θ(0)=π/2, θ(L/4)=0
Being L the medimum circumference, R the medium radius, t ...
1
vote
0
answers
86
views
Complex boundary conditions implementation using neurodiffeq
Relatively recently, as part of my research work, I had to numerically solve a system of differential equations, and instead of using ready-made programs written in Fortran, I decided to write my own ...
0
votes
1
answer
224
views
Trying to solve a large system of highly stiff differential equations in JULIA language
I have a system of differential equations containing 62500 simultaneous equations. The system dynamics are linear and of the form:
[dU/dt] = [Jacobian]x[U].
The jacobian is sparse (non-zero vals ~ 0.6%...
2
votes
1
answer
699
views
Solving coupled 2nd order ODE, numerical in Python
I would like to solve the following DGL system numerically in python:
The procedure should be the same as always. I have 2 coupled differential equations of the 2nd order and I use the substitution g'...
4
votes
1
answer
80
views
Problems to solve non-linear coupled dgl in python (numerical)
I have the following problem. I would like to solve the following DGL system numerically in python:
$$
\begin{align*}
&g'' + \frac{2}{r} g' - \frac{2}{r^2} g - \frac{3}{r} e g^2 - e^2 g^3 - \frac{...
0
votes
0
answers
720
views
Scipy solve_ivp requests time out of bounds
My code solves a 1st order differential equation using Scipy's solve_ivp function and the standard RK45 solver. The code itself is reasonably large, and I will certainly attempt to produce a minimal ...
0
votes
2
answers
74
views
Generate variables through a loop in Python
I'm trying to solve multiple ordinary differential equations in Python using odeint. A simple version would look like:
import numpy as np
from scipy.integrate import odeint
def lotka_volterra(xy, t):
...
0
votes
0
answers
280
views
Explicit & implicit Euler and trapezoid method of ODE solving in Python
I have a question regarding my code. I have to solve an ODE: [y′(t)=(0.5−t)(y(t) + 1), y(0) = 1], numerically (and approximate), using the explicit and implicit Euler as well as the trapezoid method ...
0
votes
0
answers
100
views
What's the easiest way to solve complex valued coupled differential equations in Python using SciPy?
I'm struggling to find a solution for these coupled differential equations:
dz1/dt = z1(t) H11(t) + z2(t) H12(t)
dz2/dt = z2(t) H22(t) + z1(t) H21(t)
Here, z1(t) and z2(t) are unknown functions that ...
0
votes
0
answers
51
views
how to solve a differential equation with a prameters that depends of time without knowing the explicit expression of this parameter
i'm working on resolving this differential equation :
z" + w0²z=w0²zeq + a(t)
for this i'm now using odeint or solve_ivp from module scipy.integrate in Python and it seems to work well if i give ...