|
[Date Index]
[Thread Index]
[Author Index]
Re: NDSolve in matrix form
- To: mathgroup at smc.vnet.net
- Subject: [mg120473] Re: NDSolve in matrix form
- From: Glenn Carlson <g.crlsn at gmail.com>
- Date: Mon, 25 Jul 2011 07:27:29 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Thanks for your response, Kevin.
I figured out how to do this late last night. I attribute differences between the solution in terms of f[1][t], f[2][t], and f[3][t] and the solution from the tutorial in terms of x[t], y[t], and z[t] to be due to internal numerics in solving the nonlinear system.
Applying either approach to the differential-algebraic system in the tutorial gives the same result.
Thanks again very much.
Glenn
------------
(* System of ordinary differential equations.
http://reference.wolfram.com/mathematica/tutorial/NumericalSolutionOfDifferentialEquations.html *)
n := 3
fInit := {0, 2, 0}
mat[t_] = {-3 (f[1][t] - f[2][t]), -f[1][t] f[3][t] + 26.5 f[1][t] - f[2][t], f[1][t] f[2][t] - f[3][t]};
(* Create a list of the solution functions excl. the argument t. *)
fsol = Table[f[i], {i, 1, n}];
(* Create a list of ODEs and ICs for NDSolve. *)
sys = Join[Table[fsol[[i]]'[t] == mat[t][[i]], {i, 1, n}], Table[fsol[[i]][0] == fInit[[i]], {i, 1, n}]];
solution1 = NDSolve[sys, fsol, {t, 0, 200}, MaxSteps -> Infinity]
(* Create a list of solution functions incl. the argument t for ParametricPlot3D. *)
fsolt = Table[f[i][t], {i, 1, n}]
ParametricPlot3D[Evaluate[fsolt /. solution1], {t, 0, 200}, PlotPoints -> 10000, ColorFunction ->(ColorData["Rainbow"][#4] &)]
(* Plot solutions as functions of time. *)
Plot[Evaluate[f[1][t] /. solution1], {t, 0, 200}]
Plot[Evaluate[f[2][t] /. solution1], {t, 0, 200}]
Plot[Evaluate[f[3][t] /. solution1], {t, 0, 200}]
Plot[Evaluate[fsolt /. solution1], {t, 0, 200}]
Prev by Date:
Re: NDSolve in matrix form
Next by Date:
default font
Previous by thread:
Re: NDSolve in matrix form
Next by thread:
Re: NDSolve in matrix form
|