Re: NDSolve memory management problem
- To: mathgroup at smc.vnet.net
- Subject: [mg102339] Re: NDSolve memory management problem
- From: schochet123 <schochet123 at gmail.com>
- Date: Thu, 6 Aug 2009 06:30:00 -0400 (EDT)
- References: <h41f71$rjo$1@smc.vnet.net>
Ignore my other post in this thread (if it shows up). I forgot that Daniel from Wolfram once showed a much easier way: simply set the range of the time variable inside the NDSolve command to {t,100,100} instead of {t,0,100}. Since the initial value is given at time zero, NDSolve still calculates the solution from time 0 to 100, but it only remembers the values for t in the "interval" from 100 to 100, and so uses only a small amount of memory. My first post gave the older method I used before I read about the method above. A variant of it may still be useful if you want to save as much of the solution as you have memory for. Steve On Jul 20, 1:00 pm, David Szekely <dr.szek... at gmail.com> wrote: > Hi there! > I'm currently trying to run a simulation in Mathematica usingNDSolvein se= veral dimensions. However, it tends to chew up system memory very quickly a= nd give the standard: > "No more memory available. > Mathematica kernel has shut down. > Try quitting other applications and then retry." > message. > Here's some code for the heat equation in 4 dimensions over relatively sm= all ranges to show what I mean: > i = 0; > sol =NDSolve[{D[u[t, x, y, z], t] == > D[u[t, x, y, z], x, x] + D[u[t, x, y, z], y, y] + > D[u[t, x, y, z], z, z], > u[0, x, y, z] == 0, > u[t, 0, y, z] == Sin[t], > u[t, 40, y, z] == 0, > u[t, x, 0, z] == Sin[t], > u[t, x, 40, z] == 0, > u[t, x, y, 0] == Sin[t], > u[t, x, y, 40] == 0}, > {u}, {t, 0, 100}, {x, 0, 40}, {y, 0, 40}, {z, 0, 40}, > MaxSteps -> Infinity, MaxStepSize -> 1, > > EvaluationMonitor :> If[t > i, > Print[{t, MemoryInUse[]/1024^2 // N}]; > i += 10;] > > ] > MemoryInUse[]/1024^2 // N > > The only solutions I need are at t = 0, 5, 10, 15 etc.. Ideally, what i= 'd like to be able to do is add a function in "EvaluationMonitor" which rem= oves all values of t other than the ones that I need *as it solves the syst= em*. This would significantly reduce the strain on system memory. I would g= reatly appreciate help on this problem! Adding more memory is not a good so= lution since my actual problem kills a system with 12 Gb of memory :(