Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

NDSolve and differential equation system

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53944] NDSolve and differential equation system
  • From: Christian Moosmann <some@Adress>
  • Date: Sat, 5 Feb 2005 03:14:56 -0500 (EST)
  • Organization: Rechenzentrum der Universitaet Freiburg, Germany
  • Sender: owner-wri-mathgroup at wolfram.com

Hi MathGroup

I have a question concerning NDSolve and a system of differential equations.

consider an equation system A x'[t] + (K1 + v[t] * K2).x[t]=B, where 
A,K1,K2 are Matrices, B and x are vectors and v[t] is a defined skalar 
function. I want to compute this system with NDSolve, however, it takes 
a very long time.

To try it you should use Theodor Gray's ShowStatus function in the frontend.

ShowStatus[status_] :=
     LinkWrite[$ParentLink,
       SetNotebookStatusLine[FrontEnd`EvaluationNotebook[],
         ToString[ status ] ] ];

Dim = 40;

I use random Matrices here. They show the same basic behaviour as the 
matrices I usually use (those are also dense), so this problem should 
not be related directly to the matrices.

K1 = Table[Random[], {i, Dim}, {j, Dim}];
K2 = Table[Random[], {i, Dim}, {j, Dim}];
Ainv = Inverse[Table[Random[], {i, Dim}, {j, Dim}]];
B = Table[Random[], {i, Dim}];

tStart = 0.;
tEnd = 1;

At first we solve without the function v[t]:

Timing[NDSolve[{D[ x[t], t] + Ainv.( K1 + K2).x[t] == B  ,
       x[tStart] == Table[0. , {Dim}]} , x , { t, tStart, tEnd },
     SolveDelayed -> True, StepMonitor :> ShowStatus[t] ] ]

{0.080987 Second, {{x -> InterpolatingFunction[{{0., 1.}}, <>]}}}

is quite fast, now we would like to include the function:

v[t_] := UnitStep[t - 0.2]*4*(t - 0.2) - UnitStep[t - 0.45]*4*(t - 0.45);

Timing[NDSolve[{D[ x[t], t] + Ainv.( K1 + v[t]*K2).x[t] == B  ,
       x[tStart] == Table[0. , {Dim}]} , x , { t, tStart, tEnd },
     SolveDelayed -> True, StepMonitor :> ShowStatus[t] ] ]

{137.341 Second, {{x -> InterpolatingFunction[{{0., 1.}}, <>]}}}

Well, this is a factor of > 1000, and what I would like to compute is at 
least Dimension 100. If you use the stepmonitor you also may notice, 
that the time counts up, then stops for some time, counts up again...


Does anyone have any suggestions how to deal with that?

Thanks in advance

Christian


  • Prev by Date: Re: Product {for p=2 to infinity} (p^2+1)/(p^2-1)
  • Next by Date: Re: multiprocessor vs cache/memory
  • Previous by thread: Re: Product {for p=2 to infinity} (p^2+1)/(p^2-1) version=3.0.2
  • Next by thread: Re: NDSolve and differential equation system