discretizing once again but with a lot more progress...
- To: mathgroup at smc.vnet.net
- Subject: [mg40329] discretizing once again but with a lot more progress...
- From: john boy <johnboyincali at yahoo.com>
- Date: Tue, 1 Apr 2003 04:54:09 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
hello fellow mathgroupers. I sincerely appreciate past comments I have received regarding my last post.( thank you Dr. Hollis) Frankly though, myself being a biology grad student, this task, which might take a mathematician or a programmer a day's work, has taken large part of past three weeks. So I would like to share with you all a problem I have. and hopefully some of you will be helpful to suggest the next course of action. Please do consider with me, the diffusion equation in the form of D[u, t] == D[u, x, x]( from the help browser). Now also consider the following solution that is given which does wonderfully to plot and show the behaviour that particular equation over the range of x and t given. In[143]:= Clear[c, x, t, u, xmax, xmin, nbins, npoints, dx]; u = y[x, t]; v6 = NDSolve[{D[u, t] == D[u, x, x], y[x, 0] == If[Abs[x] < 2.99, E^(-x^2), 0], y[-10, t] == 0, y[10, t] == 0}, y, {x, -10, 10}, {t, 0, 20}] Plot3D[ Evaluate[y[x, t] /. v6 [[1]]], {x, -10, 10}, {t, 0, 20}, PlotPoints -> 30, PlotRange -> {0, 1}] which gives the correct output along with a plot, Out[145]= {{y -> InterpolatingFunction[{{-10., 10.}, {0., 20.}}, "<>"]}} now please consider my attempt( and incorrect apparently) at the discretization of the second order spatial derivative as follows... In[226]:= Clear[c, x, t, u, xmax, xmin, nbins, npoints, dx]; c = .1; eq1 = D[u, t] == D[u, x, x]; xmin = -3; xmax = 3; nbins = 2; npoints = nbins + 1; dx = Abs[(xmax - xmin)/(nbins)]; eq2 = Table[ D[y[i][t], t] == (y[i + 1][t] - 2y[i][t] + y[i - 1][t])/(dx^2) + c y[i][t]^2 - c y[i][t], {i, 1, nbins}]; ic = Table[ y[i][0] == N[E^(-x^2) /. {x -> xmin + (i - 1)(xmax - xmin)/nbins}], {i, 1, nbins}]; vbls = Table[y[i][t], {i, 1, nbins}]; list = Join[eq2, ic]; NDSolve[list, vbls, {t, 0, 20}] which then gives the errorneous output of, NDSolve::"ndnum": "Encountered non-numerical value for a derivative at t == 5.285630387377673`*^180." Out[234]= {{y[1][t] -> InterpolatingFunction[{{0., 0.}}, "<>"][t], y[2][t] -> InterpolatingFunction[{{0., 0.}}, "<>"][t]}} I have chosen only 2 bins because I wanted to make it as simple as possible so i can figure out what was going on. And not much good that has done. If anyone out there has a way or an idea to try in order for me to get a plot that is similar to the original solution that is given in the help browser, I would be most appreciative in hearing about it. any and all comments are welcome. thank you all very much in advance, (I didn't want to post a long message but looks like I dont have a choice. ) john __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://platinum.yahoo.com