Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5978
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Clean up code to run faster |
| Date | 2011-10-29 11:12 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j8gn2o$58e$1@smc.vnet.net> (permalink) |
| References | <j7u4rb$t67$1@smc.vnet.net> |
Hi,
> I am new to Mathematica and I have learned that it is a steep learning
> curve, I've spent a week trying to program an example problem from a
> heat transfer book. I need it to solve for several hundred time steps
> and my computer is only allowing me to do about 15 in an hour of
> solving. How can I clean up my code and what are some general tips
> that you can give me for the future when I need to do more hard core
> iteration problems and stuff? PS, I'm a mechanical engineer so I'm
> not very good at understanding how Mathematica thinks in computer
> language (anything is helpful).
I think you got some hints about how to speed up your actual
calculation. I just wanted to make sure you understand that there is
actually no need to solve such a simple problem with such a low level
approach: Mathematica can solve many partial differential equations out
of the box. Only if you are taking advantage of those feature you will
find Mathematica to be a powerful tool once you have learned how to use
it. Here is an example which solves a 1d heat transfer problem with
NDSolve, straight from the documentation of NDSolve:
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}]
Plot3D[Evaluate[u[t, x] /. %], {t, 0, 10}, {x, 0, 5},
PlotRange -> All]
Of course you would have to adopt the boundary condition to your case.
If you are just using this as an example for learning Mathematica, you
might want to use such a solution to check your results...
hth,
albert
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Clean up code to run faster Michelle Maul <michellemaul312@gmail.com> - 2011-10-22 10:10 +0000 Re: Clean up code to run faster Ray Koopman <koopman@sfu.ca> - 2011-10-28 09:43 +0000 Re: Clean up code to run faster A Retey <awnl@gmx-topmail.de> - 2011-10-29 11:12 +0000
csiph-web