ode

how does the parallelism solve the ODE parameter sweep using matlab

China☆狼群 提交于 2019-12-11 04:07:54
问题 just want to ask some question regarding my code..got this code from internet and this might be the same example in mathworks website..i simulating this code in MATLAB and got the result which i can see that it takes less time to solve the ODE when using parallel computing (matlabpool with 2 workers) compared to serial computing.. my question is, can someone explain to me on how does the parallelism solve the ODE equation in matlab..below are the code that i use in parallel computing in

Solving ODE with SciPy gives invalid value encountered in double_scalars error

余生长醉 提交于 2019-12-11 03:38:37
问题 I'm trying to solve the Lane-Emden equation for arbitrary values of n (polytropic index). In order to use SciPy, I have represented the second-order ODE as a set of two coupled first-order ODEs. I have the following code: import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint def poly(y,xi,n): theta, phi = y dydt = [phi/(xi**2), -(xi**2)*theta**n] return dydt Here, I defined phi = theta' y0 = [1.,0.] xi = np.linspace(0., 16., 201) for n in range(0,11): sol =

solving system of ode using matlab

两盒软妹~` 提交于 2019-12-11 03:10:48
问题 I have 9 equations with a time dependent coefficient g % MY M file function dy =tarak(t,y) G= 3.16; g = 0.1*exp(-((t-200)/90).^2); dy=zeros(9,1); dy(1)=-2*2*y(1)+2*G*y(5)+2*g*y(7); dy(2)=2*y(1)-2*G*y(5); dy(3)=2*y(1)-2*g*y(7); dy(4)=-2*y(4)+g*y(9); dy(5)=-2*y(5)+G*(y(2)-y(1))+g*y(8); dy(6)=-2*y(6)-G*y(9); dy(7)=-2*y(7)+g*(y(3)-y(1))+G*y(8); dy(8)=-G*y(7)-g*y(5); dy(9)=G*y(6)-g*y(4); then in command window: [T,Y] = ode45(@tarak,[0 ,500],[0 0 1 0 0 0 0 0 0]) where coefficient G = 3.16 and g = 0

How to get Rosenbrock23 to work with ODE in ParameterizedFunctions.jl DSL?

*爱你&永不变心* 提交于 2019-12-11 02:28:04
问题 Further to this question, I have the same model implemented in ParameterizedFunctions.jl DSL. The following MWE works: using DifferentialEquations using Plots # Modeling a consecutive / parallel reaction in a CSTR # A --> 2B --> C, C --> 2B, B --> D # PETERSEN-Matrix # No. A B C D Rate # 1 -1 2 k1*A # 2 -2 1 k2*B*B # 3 2 -1 k3*C # 4 -1 1 k4*B fpr! = @ode_def ConsecutiveParallelReaction begin dA = -k_1*A + q_in/V_liq*(A_in - A) dB = 2*k_1*A - 2*k_2*B*B + 2*k_3*C - k_4*B + q_in/V_liq*(B_in - B)

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)

Scipy ode integrate to unknown limit of t, based on the size of solution

自古美人都是妖i 提交于 2019-12-11 00:33:13
问题 I am modeling charged particles moving through an electromagnetic field and am using scipy ode. The code here is simplified, obviously, but works as an example. The problem I have is that I want to end the integration after a limit on r, not on t. So, integrate dx/dt up to the point where norm(x) > r. I don't want to just change the function to integrate over r, however, because the position is a function of t. Can I do a definite integral over an unrelated variable or something? import numpy

Using dplyr and conditional formatting to construct an ordinary differential equation from strings

末鹿安然 提交于 2019-12-11 00:23:04
问题 I am trying to create is a system of equations for a specific variable using dplyr and prod from a dataframe of strings to be used in an ordinary differential solver in R ( deSolve ). The location of the variable dictates the form of the equation and therefore I am using grep , filter_at , mutate_at , and apply . Constructing the equation depends on the column of the string/variable of interest based off the following i. If a variable is ever found as a product (P1,P2,P3) then multiply: +1 *

Correct use of deSolve in ecological modelling of a predator prey system

别说谁变了你拦得住时间么 提交于 2019-12-10 19:03:05
问题 I have a predator-prey model with parameters and initial values as specified. I solve the differential equations two ways here 1. using a for loop and 2. using the deSolve package. I believe the for loop is correct, and should give output as seen in the plot below. ################## #For loop attempt ################## r=0.1; k=100; v=40; s=.1; tbeg=0; tend=1200; nints=1200 c=.06; a=.12; predator0=c(15); prey0=c(50) dt=(tend-tbeg)/nints prey=matrix(0,nints+1,length(prey0)) predator=matrix(0,

Sympy second order ode

社会主义新天地 提交于 2019-12-10 13:35:01
问题 I have a homogeneous solution to a simple second-order ODE, which when I try to solve for initial values using Sympy, returns the same solution. It should substitute for y(0) and y'(0) and yield a solution without constants, but does not. Here is the code to set up the equation (it is a spring balance equation, k = spring constant and m = mass). Some redundant symbols which I use elsewhere, sorry. %matplotlib inline from sympy import * m,k, x,t,s,T, omega,A,B = symbols('m k x t s T omega A B'

Solve ode in python with complex matrix as initial value

99封情书 提交于 2019-12-09 18:33:53
问题 I have a von Neumann equation which looks like: dr/dt = - i [H, r] , where r and H are square matricies of complex numbers and I need to find r(t) using python script. Is there any standart instruments to integrate such equations? When I was solving another aquation with a vector as initial value, like Schrodinger equation: dy/dt = - i H y , I used scipy.integrate.ode function ('zvode'), but trying to use the same function for von Neumann equation gives me the following error: **scipy