Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Piggybacking on thisthis, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my calculations again.

I ask because I use NDSolve for 4th order non linear PDEs and sometimes I need to run it for really large times (in excess of a few hours, yes that sounds crazy but I am just trying to get results for a fluid dynamics problem here and I am not all that interested in being a computer scientist to reduce run times).

So after reading the linked article, I did this for an example problem:

sol = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
   u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}]

DumpSave["pde0.mx", sol]

Then I quit mathematica and relaunch it and load pde0.mx with Get

Get["pde0.mx"]

And when I plot,

Plot3D[Evaluate[u[t, x] /. sol], {t, 0, 10}, {x, 0, 5}, 
 PlotRange -> All]

Voila, I get the plot as if I had run the simulation.

So.. did I run the simulation again by invoking sol through Get or was my kernel state saved?

Piggybacking on this, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my calculations again.

I ask because I use NDSolve for 4th order non linear PDEs and sometimes I need to run it for really large times (in excess of a few hours, yes that sounds crazy but I am just trying to get results for a fluid dynamics problem here and I am not all that interested in being a computer scientist to reduce run times).

So after reading the linked article, I did this for an example problem:

sol = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
   u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}]

DumpSave["pde0.mx", sol]

Then I quit mathematica and relaunch it and load pde0.mx with Get

Get["pde0.mx"]

And when I plot,

Plot3D[Evaluate[u[t, x] /. sol], {t, 0, 10}, {x, 0, 5}, 
 PlotRange -> All]

Voila, I get the plot as if I had run the simulation.

So.. did I run the simulation again by invoking sol through Get or was my kernel state saved?

Piggybacking on this, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my calculations again.

I ask because I use NDSolve for 4th order non linear PDEs and sometimes I need to run it for really large times (in excess of a few hours, yes that sounds crazy but I am just trying to get results for a fluid dynamics problem here and I am not all that interested in being a computer scientist to reduce run times).

So after reading the linked article, I did this for an example problem:

sol = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
   u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}]

DumpSave["pde0.mx", sol]

Then I quit mathematica and relaunch it and load pde0.mx with Get

Get["pde0.mx"]

And when I plot,

Plot3D[Evaluate[u[t, x] /. sol], {t, 0, 10}, {x, 0, 5}, 
 PlotRange -> All]

Voila, I get the plot as if I had run the simulation.

So.. did I run the simulation again by invoking sol through Get or was my kernel state saved?

tags
Link
acl
  • 19.9k
  • 3
  • 66
  • 94
Tweeted twitter.com/#!/StackMma/status/205346374831710208
Source Link
dearN
  • 5.4k
  • 3
  • 35
  • 77

Saving data inside a notebook so that I don't have to run it again?

Piggybacking on this, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my calculations again.

I ask because I use NDSolve for 4th order non linear PDEs and sometimes I need to run it for really large times (in excess of a few hours, yes that sounds crazy but I am just trying to get results for a fluid dynamics problem here and I am not all that interested in being a computer scientist to reduce run times).

So after reading the linked article, I did this for an example problem:

sol = NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, 
   u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}]

DumpSave["pde0.mx", sol]

Then I quit mathematica and relaunch it and load pde0.mx with Get

Get["pde0.mx"]

And when I plot,

Plot3D[Evaluate[u[t, x] /. sol], {t, 0, 10}, {x, 0, 5}, 
 PlotRange -> All]

Voila, I get the plot as if I had run the simulation.

So.. did I run the simulation again by invoking sol through Get or was my kernel state saved?