differential-equations

Solve Lotka-Volterra model using SciPy

a 夏天 提交于 2019-12-11 02:17:24
问题 I have the following Lotka-Volterra model dN1/dt = N1(1-N1-0.7N2) dN2/dt = N2(1-N2-0.3N1) where the 1 and 2 next to N are subscripts. I want to solve this using SciPy and visualize the results. I want to make a plot with N2 on the y axis and N1 on the N1. If you set N1 to zero in the first equation, you get N2 = 1/0.7 and if you set N2 to zero in the second equation, you get N1 = 0.3/1. The two lines are suppose to intersect. How do I do this in Python? I read this tutorial (slides 6 to 16)

Can R language find a generic solution of the first order differential equation?

泪湿孤枕 提交于 2019-12-10 19:57:49
问题 Can R language find a generic solution of the first order differential equation? For example: (5x-6)^2 y' = 5(5x-6) y - 2 PS: That can be easily solved by hand, i.e. particular solution is: y = 1/(5(5x-6)) and generic C*(5x-6) I need to understand whether R can do it? 回答1: We can use the R library deSolve to obtain numerical solutions of ODEs. See ?deSolve for details. Here is a worked-through example based on your ODE. Load the R library library(deSolve); Define the differential equation #

Mathematica 2D Heat Equation Animation

空扰寡人 提交于 2019-12-10 11:06:47
问题 I'm working on mapping a temperature gradient in two dimensions and having a lot of trouble. My current approach is to define an Interpolating Function and then try to graph it a lot of times, then animate that table of graphs. Here's what I have so far: RT = 388.726919 R = 1 FUNC == NDSolve[{D[T[x, y, t], t] == RT*(D[T[x, y, t], x, x] + D[T[x, y, t], y, y]), T[x, y, 0] == 0, T[0, y, t] == R*t, T[9, y, t] == R*t, T[x, 0, t] == R*t, T[x, 9, t] == R*t}, T, {x, 0, 9}, {y, 0, 9}, {t, 0, 6}] So

Is there symbolic ODE solver in R ? (ODE = ordinary differential equation)

自作多情 提交于 2019-12-09 08:03:30
Question: Is there symbolic ODE solver in R ? (ODE = ordinary differential equation ) I am afraid there is NO... but let me confirm from experts ... For example, solve: > (5x-6)^2 y' = 5(5x-6) y - 2 Here: y - unknown function, y' - its derivative (It is easy to solve by hands: y = 1/(5(5x-6)) + C* (5x-6) , but I want to get that answer from R). What I know: 1) There are NUMERICAL (not symbolic) solvers: I know there are numerical ODE solvers like library(deSolve), see answer here: Can R language find a generic solution of the first order differential equation? 2) There are symbolic packages :

plotting orbital trajectories in python

泄露秘密 提交于 2019-12-09 00:41:18
问题 How can I setup the three body problem in python? How to I define the function to solve the ODEs? The three equations are x'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * x , y'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * y , and z'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * z . Written as 6 first order we have x' = x2 , y' = y2 , z' = z2 , x2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * x , y2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * y , and z2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2

C++ numerical integrators to solve systems of ode's

别来无恙 提交于 2019-12-08 13:31:16
问题 I recently started using C++ and I just created a class that allows the integration of a user-defined system of ode's. It uses two different integrators in order to compare its performance. Here is the general layout of the code: class integrators { private: double ti; // initial time double *xi; // initial solution double tf; // end time double dt; // time step int n; // number of ode's public: // Function prototypes double f(double, double *, double *); // function to integrate double rk4

how to solve a system of Ordinary Differential Equations (ODE's) in Matlab

守給你的承諾、 提交于 2019-12-08 09:58:36
问题 I have to solve a system of ordinary differential equations of the form: dx/ds = 1/x * [y* (g + s/y) - a*x*f(x^2,y^2)] dy/ds = 1/x * [-y * (b + y) * f()] - y/s - c where x, and y are the variables I need to find out, and s is the independent variable; the rest are constants. I've tried to solve this with ode45 with no success so far: y = ode45(@yprime, s, [1 1]); function dyds = yprime(s,y) global g a v0 d dyds_1 = 1./y(1) .*(y(2) .* (g + s ./ y(2)) - a .* y(1) .* sqrt(y(1).^2 + (v0 + y(2)).

Is there symbolic ODE solver in R ? (ODE = ordinary differential equation)

萝らか妹 提交于 2019-12-08 06:14:52
问题 Question: Is there symbolic ODE solver in R ? (ODE = ordinary differential equation) I am afraid there is NO... but let me confirm from experts ... For example, solve: > (5x-6)^2 y' = 5(5x-6) y - 2 Here: y - unknown function, y' - its derivative (It is easy to solve by hands: y = 1/(5(5x-6)) + C* (5x-6) , but I want to get that answer from R). What I know: 1) There are NUMERICAL (not symbolic) solvers: I know there are numerical ODE solvers like library(deSolve), see answer here: Can R

NaNs produced in deSolve package

狂风中的少年 提交于 2019-12-07 18:43:42
问题 I have got a system of 8 differential equations that I am trying to solve using deSolve in R. It just returns NaN after the first few steps and doesn't solve it further. I tried various differential solvers like lsoda (default), bdf , adams , rk4 etc, but it didn't help. Here is the sample R code: library(deSolve) daero = c(5.29,4.16,2.49,1.53,0.7,0.41,0.21)*10^-4 rho = rep(1.27,7) dgeo = daero * sqrt(1/rho) r0 = dgeo/2 Fr = c(0.188,0.297,0.274,0.181,0.032,0.013,0.015) X0 = Fr*200*10^-6 N0 =

How to define time-dependent, discrete parameter?

会有一股神秘感。 提交于 2019-12-07 14:30:10
问题 Recently, I have built a small model with GEKKO. It contains a Parameter which actually changes with time. How can I implement that? I tried using if3 , but it gives an error. Here's the MWE: #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Started on 10-08-2019 @author: rotton """ import numpy as np import matplotlib.pyplot as plt from gekko import GEKKO #Initialize Model m = GEKKO(remote=False) # Parameters k_1 = m.Param(value = 0.19) f_1 = m.Param(value = 29.0) V_liq = m.Param(value =