Re: NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg59643] Re: NDSolve
- From: "James Gilmore" <james.gilmore at yale.edu>
- Date: Mon, 15 Aug 2005 06:50:34 -0400 (EDT)
- Organization: Yale University
- References: <ddn16r$cvq$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, The first thing I noticed in your code was that if I reduce "dn" from 10 -> 4 -> 2, I get different solutions, c.f. {e1[z], l1[z]} plot. The below options give an accurate solution. \[Gamma] = 6*^3; g = 8*^17; \[Rho] = 89.08; cl = 2.5*^4; \[Lambda] = 90.9; t0 = 300; amp = 1*^23; \[Tau] = 150*^-15; id = 100*^-9; dn = 3; tn = 10; \!\(\* RowBox[{ RowBox[{"sol", "=", RowBox[{"Flatten", "[", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{"{", RowBox[{\(\[Gamma]\ e[z, t]\ \[PartialD]\_t e[z, t] == \(-g\)\ \((e[z, t] - l[z, t])\) + If[0 <= t <= \[Tau] && 0 <= z <= id, amp, 0]\), ",", \(\[Rho]\ cl\ \[PartialD]\_t l[z, t] == \[Lambda]\ \[PartialD]\_\(z, z\)l[z, t] - g\ \((l[z, t] - e[z, t])\)\), ",", \(e[z, 0] == t0\), ",", \(l[z, 0] == t0\), ",", \(e[dn\ id, t] == t0\), ",", \(l[dn\ id, t] == t0\), ",", RowBox[{ RowBox[{ SuperscriptBox["l", TagBox[\((1, 0)\), Derivative], MultilineFunction->None], "[", \(0, t\), "]"}], "==", "0"}]}], "}"}], ",", \({e, l}\), ",", \({z, 0, dn\ id}\), ",", \({t, 0, tn\ \[Tau]}\), ",", \("\<AccuracyGoal\>" -> 3\), ",", \("\<PrecisionGoal\>" -> 3\), ",", \(MaxStepSize -> {1\/10\^7, Automatic}\), ",", \(StartingStepSize -> {1\/10\^9, 1\/10\^16}\)}], "]"}], "]"}]}], ";"}]\) Further, you are relying on NDSolve to solve your equation over approximately 8 orders of magnitude in 't'. This is unstable. Why not split up the problem into managable portions, say 2 orders of magnitude each? NDSolve will easily return an accurate solution over such a range. Then piece the solutions together at the end of the calculation. The code in your earlier message can be easily extended in this manner, for example \!\(\* RowBox[{\(maxTime = tn\ \[Tau]\ 100; \), "\n", RowBox[{ RowBox[{"sol2", "=", RowBox[{"Flatten", "[", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{"{", RowBox[{\(\[Gamma]\ e[z, t]\ \[PartialD]\_t e[z, t] == \(-g\)\ \((e[z, t] - l[z, t])\)\), ",", \(\[Rho]\ cl\ \[PartialD]\_t l[z, t] == \[Lambda]\ \[PartialD]\_\(z, z\)l[z, t] - g\ \((l[z, t] - e[z, t])\)\), ",", \(e[z, tn\ \[Tau]] == e1[z, tn\ \[Tau]]\), ",", \(l[z, tn\ \[Tau]] == l1[z, tn\ \[Tau]]\), ",", \(e[dn\ id, t] == t0\), ",", \(l[dn\ id, t] == t0\), ",", RowBox[{ RowBox[{ SuperscriptBox["l", TagBox[\((1, 0)\), Derivative], MultilineFunction->None], "[", \(0, t\), "]"}], "==", "0"}]}], "}"}], ",", \({e, l}\), ",", \({z, 0, dn\ id}\), ",", \({t, tn\ \[Tau], maxTime}\), ",", \("\<AccuracyGoal\>" -> 2\), ",", \("\<PrecisionGoal\>" -> 2\), ",", \(MaxStepSize -> {1\/10\^7, maxTime\/10}\)}], "]"}], "]"}]}], ";"}]}]\) This, plus similar extensions work on my machine, Mathematica 5.0 Win XP. James Gilmore Graduate Student Deparment of Physics Yale University "Daniel Grady" <d.c.grady at gmail.com> wrote in message news:ddn16r$cvq$1 at smc.vnet.net... > I've been having some trouble using NDSolve with a problem I've been > working on. I'm trying to simulate the temperature change in a solid > when it's hit by a laser pulse. The theory is that you keep track of > two different temperatures; one for the electron 'soup' in the > material, and another for the lattice in which the electrons are > embedded. When a laser pulse hits the material, all the energy goes > into the electrons, whose temperature rises very quickly, and then is > transferred to the lattice, and the heat then diffuses throughout the > lattice. The problems I've been running in to appear to be related to > the fact that the timescales that the laser pulse and diffusion > operate on are quite different; the duration of one laser pulse is > about 150 femtoseconds, and I'm interested in looking at the effects > of diffusion over the course of a millisecond or so. > > Below I've pasted the model I've been using. There are two partial > differential equations; the first one is for the electrons and says > that electron specific heat times derivative of electron temperature > with respect to time equals the electron/lattice coupling term plus > the laser source term; the second one is for the lattice, and says > lattice specific heat time the derivative of lattice temperature with > respect to time equals the lattice diffusion term plus the > electron/lattice coupling constant. I'm only considering diffusion in > one dimension for the time being, as it's turned out to be plenty > complicated. > > Because of the huge difference in timescales, the way I've been trying > to set this up is to first get a solution over a duration that's about > three times as long as the pulse itself; I then pull out the final > temperature profiles for the electrons and lattice, and use those as > initial conditions for another instance of NDSolve that gets a > solution over a millisecond duration. > > Using the numbers included below, Mathematica will give me a precision > warning when it executes the first NDSolve command, although the > graphs it returns look very reasonable. However, when trying to > execute the second NDSolve command, it gives me precision warnings, > says boundary/initial conditions are inconsistent, and returns some > graphs that are clearly not accurate. I'm puzzled by this, since once > the pulse has ended, the temperature functions for both the electrons > and lattice shouldn't be behaving strangely at all; it should be a > smooth decrease. In addition, I'm pretty confident that the model > itself is good, as I have tried using smaller numbers for all of the > constants and everything works out beautifully. > > I apologize for the length of this question, but this problem has been > driving me crazy for the last week or so, and no one on my campus uses > Mathematica. If anyone has any suggestions at all, I would greatly > appreciate them. > > -D. Grady > >