Re: trouble with NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg63642] Re: [mg63590] trouble with NDSolve
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Sun, 8 Jan 2006 03:33:08 -0500 (EST)
- References: <200601061024.FAA14623@smc.vnet.net> <43BF47B5.2040003@umbc.edu>
- Sender: owner-wri-mathgroup at wolfram.com
Pratik Desai wrote: > lahm wrote: > >> i have trouble with solving a diffusion problem with NDSolve. I would >> like to get a 2D concentration profile using second Fick's law >> dc/dt=d2c/dx2 + d2c/dy2. c is concentration and is function of t,x >> and y. The initial condition is concentration=1 everywhere. The >> boundary conditions are c=1 for x=1, y=1 and y=-1. On x=0, however, >> the concentration is 0, but only for -0.01<y<0.01, the other part of >> x=0 acts neutral, is neither a sink nor an inlet, concentration >> therefore is determined by the sink and the boundaries. Now when I >> try to imput that c=0 only at a part of x=0, I get the message that >> boundary condition is not specified on a single edge of the boundary >> of the computational domain. NDSolve::bcedge: I tried several >> different approaches, but all of them have failed. There's always >> something wrong so mathematica always encounters some problem. I >> can't make only one part of the boundary work as a sink an the other >> to be neutral. Please help! >> >> >> > One of the reasons, if I am not mistaken, the 2- D laplacian term in > your PDE is notoriously problemetic for a finite difference schema > (NDsolve uses quite a bit of FD schemes). There was a thread regarding > a similar issue a heat equation for a square plate...last year. Here > is the link anyway > http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_frm/thread/5fc408a259b51a90/4138f70b28bf6a78?lnk=st&q=Heat+equation%2C+NDSolve%2C+Nasser&rnum=1#4138f70b28bf6a78 > > > Hope this helps > > Pratik > > Actually one can solve this problem (I think) , I apologize for not reading your post thoroughly. Anyway here is my attempt Just copy the stuff that appears after this line in your note book, should work fine....Pratik (************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.1' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info at wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 3175, 82]*) (*NotebookOutlinePosition[ 3819, 104]*) (* CellTagsIndexPosition[ 3775, 100]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[{ \(Clear[u]\), "\[IndentingNewLine]", \(c = 1\), "\[IndentingNewLine]", \(<< Graphics`Legend`\), "\[IndentingNewLine]", \(u[t, 1, 1] := 1\), "\[IndentingNewLine]", \(u[t, \(-1\), \(-1\)] := 1\), "\[IndentingNewLine]", \(diffusion\ = Apply[Sequence, {{\[PartialD]\_t u[t, x, y] \[Equal] c*\[PartialD]\_\(x, x\)u[t, x, y] + c*\[PartialD]\_\(y, y\)u[t, x, y], u[t, 1, y] == u[t, \(-1\), y], u[t, x, 1] \[Equal] u[t, x, \(-1\)], u[0, x, y] \[Equal] 1 - DiscreteDelta[x, y]}, u, {t, 0, 100}, {x, \(-1\), 1}, {y, \(-1\), 1}}]\), "\[IndentingNewLine]", \(solution = NDSolve[diffusion]\), "\[IndentingNewLine]", \(ShowLegend[ DensityPlot[ Evaluate[u[0, x, y] /. solution[\([1]\)]], {x, \(-1\), 1}, {y, \(-1\), 1}, ColorFunction -> \((GrayLevel[#] &)\), Mesh \[Rule] False], {GrayLevel[#] &, 10, "\< 1\>", "\<-1\>", LegendPosition \[Rule] {1.1, \(- .4\)}}]\), "\[IndentingNewLine]", \(\(ShowLegend[ DensityPlot[ Evaluate[u[1, x, y] /. solution[\([1]\)]], {x, \(-1\), 1}, {y, \(-1\), 1}, ColorFunction -> \((Hue[#] &)\), Mesh \[Rule] False], {Hue[#] &, 10, "\< 1\>", "\<-1\>", LegendPosition \[Rule] {1.1, \(- .4\)}}];\)\), \ "\[IndentingNewLine]", \(\)}], "Input"] }, FrontEndVersion->"5.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 681}}, WindowSize->{1016, 647}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 1417, 29, 290, "Input"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)
- References:
- trouble with NDSolve
- From: lahm <mifdavid@yahoo.com>
- trouble with NDSolve