All Questions
27 questions
0
votes
0
answers
53
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 ...
0
votes
1
answer
35
views
Steps approximation for time series scatter with mean changing every K number of steps using BIC
First, the synthetic data used is generated the following the way:
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
import random
import math
np.random.seed(2)
n_samples = 180
...
0
votes
1
answer
422
views
Attempt to solve the nonlinear pendulum 2nd order differential equation using 4th order Runge-Kutta method, not getting expected result
I am new to Python, so I have restricted the process to matplotlib only, not going into NumPy.
I followed the book "Scientific Computing in Python" by Abhijit Kar Gupta, to write the Python ...
0
votes
0
answers
90
views
How to plot different curve in same polar coordinates
I tried to plot the paths of particle of different sizes in the same polar coordinate using the code given below using matplotlib. The expected plot should be somewhat like this:
Instead I got this ...
1
vote
1
answer
417
views
Unable to reproduce simple figure from textbook (possible numerical instability)
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 ...
1
vote
1
answer
167
views
Make a model in Python using the Forward Euler scheme (FTCS)
Solve the 1-dimensional advection equation ∂θ/dt = -c dθ/dx by using centered differences in space and forward differences in time. Apply a periodic boundary condition θ^(n) (J) = θ^(n) (0). J = 100 ...
0
votes
0
answers
191
views
animated plot over static plot
I am trying to animate the processes of dekker's method of root finding
Here's my code
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
from IPython import display
...
2
votes
1
answer
160
views
Error in computing differential equations using the forward euler method in python [closed]
I am doing a project to which I predict the behaviour of COVID using a SEIRDV model. I have created the differential equations and have set initial parameters. I am solving these ODE's using the ...
0
votes
1
answer
5k
views
How to plot a line in 3 dimensional space
I have two 3D-points, for example a = (100, 100, 10) and b = (0, 100, 60), and would like to fit a line through those points.
I know, the 3D line equation can have different shapes:
Vector-form:
(x,...
2
votes
1
answer
264
views
Phase space trajectories for Hindmarsh-Rose model
I am trying to plot the phase space trajectories for the Hindmarsh-Rose model. I have implemented an RK4 integrator to solve the following set of equations:
The code that I have written so far is ...
0
votes
3
answers
7k
views
IndexError: index x is out of bounds for axis 0 with size x
I am going to plot the velocity function of time, when I have gathered acceleration function of time.
However, I get an error code, IndexError: index 51 is out of bounds for axis 0 with size 51, 51 is ...
0
votes
0
answers
318
views
How to get the time series of the Duffing oscillator to plot the Poincare section?
I have used the 4th Order Runge-Kutta method in order to estimate the values in which the Duffing Oscillator is chaotic. According to Wikipedia, the Duffing Oscillator is chaotic for values of alpha =...
0
votes
1
answer
56
views
Overflow and Invalid Values encountered in double scalars - Nonlinear PDE Solving
I am seeking to find a finite difference solution to the 1D Nonlinear PDE
u_t = u_xx + u(u_x)^2
Code:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from ...
1
vote
1
answer
316
views
Plot multiple curves of one changing value in Python Matplotlib
I'm coding an Euler method and I would like to plot in one figure different curves when "h" or step size changes its value, without making new variables for each h. Is there an easy way to ...
0
votes
1
answer
133
views
How to turn this plot into an animation? I have a plot but would like to turn this into an animation somehow
I've been struggling for the last few nights how to turn my waves in the graph here into some sort of animation after each time step or after each x step. How can I modify and write the code so that ...