1,983 questions
1
vote
0
answers
107
views
TypeError: 'Symbol' object cannot be interpreted as an integer, when using x**k in differential equation
Any idea why dsolve in sympy 1.14 when given this ode Eq(x**a * y(x) + Derivative(y(x), (x, 2)),0) gives error TypeError: 'Symbol' object cannot be interpreted as an integer
code
from sympy import *
x ...
2
votes
2
answers
179
views
How to implement Paris’ law crack growth simulation in Python?
I am trying to model a fatigue crack growth in Python using Paris’ law :
da / dN = C ( DeltaK ) ^ m
where :
a = crack length
N = load cycles
C, m = material constants
( DeltaK ) = Y.( DeltaSigma ).( ...
0
votes
0
answers
119
views
How to apply the method of lines (MOL) with scipy odeint function with Danckwerts boundary conditions?
I am trying to solve a convection-diffusion-reaction problem for a tubular reactor. The reaction governing the process is as follows:
The method I chose to solve it is the line method, which consists ...
2
votes
2
answers
118
views
Differentiating OdeSolution object
I would like to compute the residual of the numerical solution to an ordinary differential equation.
Here is the code
import numpy as np
from scipy.integrate import solve_ivp
def f(t, x):
return ...
2
votes
0
answers
65
views
Implementation of Implicit Runge–Kutta
I’ve written a MATLAB implementation of an implicit Runge–Kutta method (Radau IIA). It behaves well on most test problems, but it refuses to converge on the following very stiff equation like
y' = y^2 ...
1
vote
2
answers
62
views
Adding a Legend to each plot output using plot.deSolve and legend
I am trying to add a legend to each plot output of the ccl4model(ODE model) in the deSolve package using plot.deSolve and the legend method but it only appears on the last plot output of the model. I ...
0
votes
1
answer
89
views
Follow up: building a for-loop to run ODE simulation through different parameter sets in R
I ended up trying to build a for-loop to achieve my end goal (running an ODE function modeling disease transmission through different scenarios/parameter sets in the most transparent way possible) but ...
0
votes
0
answers
29
views
Error in ode45 and 'Events' of a Satellite Tracking Radar Model (MATLAB)
I'm trying to simulate a satellite tracker. With ode45 I have de state of the satellite for each time and then convert position to Azimuth-Elevation local coordinates. If the object enters in the ...
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 ...
0
votes
1
answer
56
views
Plotting multiple plots for different initial conditions in one graph
I am using the following code. How can I plot time (x-axis) vs C_WT (y-axis) line plots for different C_WT values as in vectorC_WT in a single graph in R ?
kon_WT = 1
koff_WT = 10
R_WT = 20
...
3
votes
2
answers
101
views
How to loop differential equations through multiple parameter sets in R?
I'm modeling the spread of an infectious disease in R, and I need to loop the model through multiple sets of parameters. I have a working model so far (a dummy version is below), but only for a single ...
1
vote
1
answer
85
views
Unexplained gain in my code when solving coupled differential equations using solve_ivp() in python
I am trying to solve two coupled differential equations in python using the solve:ivp() function from scipy.integrate but I get an unexplained gain on one of my terms that breaks the equation. It is ...
0
votes
1
answer
37
views
Parameter that has been provided "undefined"
I composed the following ODE file:
function [dndt,dmdt,dhdt,dVdt]=hh(n,m,h,V)
C=1; GK=36; GNa=120; GL=0.3; EK=-72; ENa=55; EL=-49.4;
dndt=(1-n)*alphan(V)-n*betan(V);
dmdt=(1-m)*alpham(V)-m*...
0
votes
1
answer
63
views
Solving a system of ODEs using sympy
Let us consider the following code:
import sympy as sy
import scipy as sc
from sympy.physics.units.quantities import Quantity
from sympy.solvers.ode.systems import dsolve_system
from IPython.display ...
0
votes
0
answers
49
views
How to Finish Shooting Method for the ODE Problem?
I am now struggling with a shooting method using python.
The original question is
ODE, with m=0
Here's my code, and I wonder why the graph would become flatter if the tolerence gets smaller.
import ...
0
votes
0
answers
30
views
Combining the Adams-Bashforth-Method with Richardson-Extrapolation
I am experimenting with an N-Body-Simulation with the goal to be efficient with a large number of particles. That means, the most costly thing will be calls to the ODE-function. Adams-Bashforth only ...
0
votes
1
answer
79
views
Issue solving differential equation with solve_ivp depending on t_span
I'm using solve_ivp but I'm getting strange results depending on the settings of the problem, though i think it's more an issue with the implementation of the solver than a coding issue, but I'd love ...
0
votes
1
answer
51
views
Is there a way to improve the parallel process described below to solve an ODE equation?
I am trying to solve coupled ODEs, but I present a small part of the problem here. I have tried to solve for R along the entire grid. The grid size is too big to run conventional methods, hence I am ...
0
votes
0
answers
80
views
Solve_ivp initial condition set up for 2D problem/issue
So I am trying to solve a project from MIT Numerical Methods course, basically need to solve a now uncoupled equation for supersonic flow over an airfoil which is just a parabolic shape.but for some ...
1
vote
2
answers
120
views
Simple 1 D dispersion equation numerical solution
I am new to coding and trying to solve a simple 1D dispersion equation.
The equation and boundary conditions:
adC/dx = bd^2C/dx^2
x = hj, C = C0; x = - inf, C =0
The analytical solution is
C = C0 * ...
1
vote
1
answer
75
views
"Int64" error message during Julia Optimisation script
I am trying to find multiple parameters for the optimized system which is governed by a system of equations.
In my code, I need to be able to use 4 or 5 equations and determine the parameters for the ...
1
vote
1
answer
89
views
What can I do about if the output of optimization function is not a scalar?
I am using this Optimisation script:
using DifferentialEquations, Optimization, OptimizationPolyalgorithms, OptimizationOptimJL, Plots, SciMLSensitivity, Zygote
parameters = []
function ...
1
vote
0
answers
38
views
Time dependant ODE parameters / varaibles in PyMC and Sunode
I have an ODE function ode(y,t,theta, influent) where influent is an array of values at different times (experimental data for input to system).
I have this in my main ode function (not as important):
...
2
votes
1
answer
56
views
No solution found in GEKKO when modelling a tank level
I'm trying to simulate the level of a tank that has two inlet flows and one outlet. The idea is that after this will be used in a control problem. However, I can't get it to work with gekko but it did ...
0
votes
1
answer
55
views
Manually discretized ODE using PYOMO
I am trying to solve an ode within the pyomo framework, using the forward euler method. I wrote down the discretization scheme explicitly but the result is not as expected. From the pyomo model the ...
1
vote
0
answers
60
views
Using conditions inside events with solve_ivp triggers the event at the wrong time
I'm trying to plot the dynamics of a particle moving through several cylindrical magnetic elements.
I'm using solve_ivp to integrate the ODE, but I'm having trouble obtaining the expected behavior ...
0
votes
1
answer
69
views
How to get all solutions of a nonlinear system equations
I am trying to obtain the steady state points of the following ODE system for a SIR model (steady state points are the solutions when the equations of the system equal zero):
import sympy as sp
S, I, ...
-1
votes
1
answer
104
views
How to best solve partial differential equations in Python accurately but quickly
I am trying to reproduce 4.1.3 Emission from Solid Materials as per this PDF.
https://www.rivm.nl/bibliotheek/rapporten/2017-0197.pdf
Produced this version of the model and this is the best I have ...
1
vote
1
answer
155
views
Solving a set of coupled ordinary differential equation representing the coupled Chua oscillator with solve_ivp
I am trying to write a python code to solve the ODE representing a coupled Chua oscillators. The set of ODEs can be found here.
The non-linear term is defined as f(x)
And the possible solution is ...
0
votes
1
answer
67
views
Issue Using NIntegrate Function in NDSolve
I am stuck in an attempt to pass an interpolating function that was generated from a PDE solved using NDSolveValue to a second call to NDSolveValue for a solution to a simple ODE. Here is my code for ...
2
votes
1
answer
86
views
Fitting multidimensional data with Python symfit ODEModel
I am trying to fit the parameters of an ODE to data with two dimensions, which should generally be possible, according to the example Fitting multidimensional datasets.
This is my failed attempt so ...
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
0
answers
131
views
Is there a way to solve system of ODEs with scipy solve_ivp introducing delay to one of the components?
I would be really thankful for some suggestions how to introduce a delay in one of my ODE in the system and solve it with solve_ivp scipy.
So, I have a system of equations with some analytical ...
0
votes
0
answers
46
views
Force zero when conditions are met in a ODE [duplicate]
I'm working on a model that simulates pesticide dynamics in a rice field using a system of differential equations. One of the compartments in my model is the mass of pesticide in the water (mw). ...
0
votes
1
answer
35
views
Parameters not changing while applying Pytorch Minimization fucntion
Code for getting the data:
import pandas as pd
import torch
dataset = pd.read_csv('/kaggle/input/fish-bear/population_data.csv')
years = torch.tensor(dataset['year'], dtype = torch.float64)
fish_pop =...
-1
votes
2
answers
174
views
Runge-Kutta-Fehlberg Method to Solve 3rd Order ODE in Fortran 95
I need help to build Fortran 95 code that solves 3rd order ODE using Runge-Kutta-Fehlberg method. I am trying to solve y''' = -2y''+y'+2y with y(0)=3, y'(0)=-2, and y''(0)=6. The exact solution should ...
0
votes
1
answer
179
views
Why is my solve_ivp stuck in an infinite loop?
I'm trying to solve a problem involving a fixed-bed reactor that uses a system of ordinary differential equations, but for some reason it gets stuck in an infinite loop. Here's the code:
import numpy ...
0
votes
1
answer
132
views
Solve 2d heat equation using solve_ivp
I'm trying to solve the 2D heat equation using the finite difference method as a filtering technique for an image using the solve_ivp method. My code is shown which gives an error message "y0 ...
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}=...
0
votes
0
answers
89
views
Generate Hopf bifurcation diagram for 3D system in Matlab
Hello I want to plot the Hopf bifurcation diagram for the 3D system.
I have this code but I'm getting nothing other than straight lines.
How would I fix this? Any help is appreciated. The parameter ...
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
58
views
Unique solution to ODE
There is a basic ODE - Differential Equation.
y' = 2x , solution is f(x) = x²
Code:
def deriv (y,x) :
return 2 * x
# time points
x = np.linspace ( 0 , 10)
# initial condition
y0 = 1
# solve ...
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 ...
2
votes
1
answer
99
views
How to fix Gekko's `@error: Solution not found`
I want to perform parameter inference for an ODE model (m.options.IMODE = 5). I have 2 models in Gekko. First, I generate model data from each model, and perform parameter inference directly on 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 ...
2
votes
1
answer
91
views
Why is my basic Gekko ODE solver much slower than Scipy?
In this minimal example I want to solve the basic integrator ODE dT/dt = k[F(t) - T(t)] where F(t) is a forcing vector, which is selected to be a square wave. I have implemented two procedures to ...
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%...
1
vote
1
answer
43
views
Graph of system of linear differential equations solution in python
I need to plot the function f(k) which is defined as a square root of the time integral of the square of the Euclidean norm of the system state vector x(t) during the first 10 seconds after the start ...
3
votes
1
answer
106
views
Specify Mass Matrix in ode45() MATLAB
I have the following nonlinear system and accompanying ODE:
My solution in MATLAB:
% Solving with ODE45
dt = 10^-1; % [s]
T = 100; % [s]
N = 2; % number of masses
X_0 = zeros(2*N,1);
t_span = [0:dt:T];...
0
votes
0
answers
127
views
Fit ode in R with multiple time series simultaneously
I am a biology student and I am recently learning how to fit ode with observed data in R. I cultivate a microbe under a given condition but with two different initial densities (N0=5 and N0=100), I ...