Re: Problems in Nintegrate
- To: mathgroup at smc.vnet.net
- Subject: [mg121376] Re: Problems in Nintegrate
- From: Andrew Moylan <amoylan at wolfram.com>
- Date: Tue, 13 Sep 2011 07:18:22 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi, These are difficult numerical integrations. You could spend some time tuning NIntegrate (and your set-up code including NDSolve) to get faster / more accurate results (starting with: manually splitting the integration range at trouble points and/or using EvaluationMonitor to see where NIntegrate is struggling). But here is a quick and dirty solution: * Increase the PrecisionGoal and AccuracyGoal for NDSolve since you will be reusing the result in another numerical function * Method -> {"SymbolicPreprocessing", "InterpolationPointsSubdivision" -> False} speeds things up a bit in this case * Crank up the MaxRecursion and let NIntegrate grind out a satisfactory solution: MaxRecursion -> 20 Your code, modified: Remove["Global`*"]; \[Rho] = 8910;(*mass density:kg/m^3*)v = 4.08;(*sound \ velocity:nm/ps*)\[Beta] = 1.3 10^-5;(*linear expansion: /K*)B = 1.8 10^11;(*bulk modulus:Pa*)c = 3 10^5;(*light speed:nm/ps*)\[Lambda] = 800; \[Omega] = 2 \[Pi] c/\[Lambda];(*light wavelength:nm*)Ce = 1.065 10^3;(*electron heat cap.at 300 K:3.19 10^5 J/m^3K*)Cl = 3.95 10^6;(*lattice heat cap. :J/m^3K=26.1 J/mol.K*)g = 4.4 10^5;(*coupling constant:4.4 10^17 W/m^3.K*)K = 91 10^6;(*thermal conductivity:91 W/m.K->91 10^18*)\[Xi]1 = \ 13.5;(*pump absorption depth:nm*)\[Xi]2 = 14.5;(*probe absorption \ depth:nm*)Dl = 2.3 10^-5;(*diffusivity:m^2/s*)R = 0.4;(*reflection at interface*)I0 \ = 1.05 10^10;(*2.77 10^13 J/m^2.pulse (ps)->2.77 10^22*)PulseWidth = \ 0.2;(*200 fs*)S[t_] := I0 Exp[-t^2/(2 PulseWidth)^2]; pow[z_, t_] := 1/\[Xi]1 S[ t] Exp[-z/\[Xi]1];(*W/m^3*)L = 1000;(*sample \ thickness:nm*)solution = NDSolve[{Ce Te[z, t] D[Te[z, t], t] == K D[Te[z, t], z, z] - g (Te[z, t] - Tl[z, t]) + pow[z, t], Cl D[Tl[z, t], t] == g (Te[z, t] - Tl[z, t]), Te[z, -100] == Tl[z, -100] == 300, Te[L, t] == 300, (D[Te[z, t], z] /. z -> 0) == 0}, {Te, Tl}, {z, 0, L}, {t, -100, 100}, MaxSteps -> Infinity, MaxStepSize -> {1, 0.1}, PrecisionGoal -> 10, AccuracyGoal -> 10][[ 1]] solz = {Te[z, t], Tl[z, t]} /. solution /. z -> 0; Plot[solz /. t -> tau, {tau, -2, 100}, PlotRange -> All] dTl = (D[Tl[z, t] /. solution, t] /. {z -> Abs[zz - v (t1 - t2)], t -> t2}); \[Eta][z_, t_] := -((3 B \[Beta])/(2 \[Rho] v^2)) NIntegrate[ Evaluate[ Sign[zz - v (t1 - t2)] dTl /. {zz -> z, t1 -> t}], {t2, -100, 100}, AccuracyGoal -> 4, Exclusions -> {t2 == 0}, PrecisionGoal -> 4, MaxRecursion -> 20, Method -> {"SymbolicPreprocessing", "InterpolationPointsSubdivision" -> False}]; vals = Table[{t, \[Eta][1, t]}, {t, 1, 20, 0.5}] ListPlot[vals] I hope this helps, Cheers, Andrew Moylan Wolfram Research ----- Original Message ----- > From: "Jiwan Kim" <hwoarang.kim at gmail.com> > To: mathgroup at smc.vnet.net > Sent: Monday, September 12, 2011 1:21:38 AM > Subject: Problems in Nintegrate > > Hello, Mathgroup. > > By solving the coupled differential equation, I got Te[z,t] and > Tl[z,t] > solution in the following code. > Then, I wanted to get the Eta[z,t] using NIntegrate function. > I am using the ver. 7.0 and AMD dual core, 2GB memory. > I confirmed that the my code below is working for higher version or a > better > computer. > But it is not working with my computer and program ver. > I have no idea for these errors... > The representative error messages are like followings: > > * Solve::ifun: Inverse functions are being used by Solve, so some > solutions > may not be found; use Reduce for complete solution information. >> > * NIntegrate::ncvb: NIntegrate failed to converge to prescribed > accuracy > after 9 recursive bisections in t2 near {t2} = {-0.69605}. NIntegrate > obtained -8.17582 and 0.0012150431662771995` for the integral and > error > estimates. >> > > Is there anything wrong? could you help me ? > Thank you in advance. > > Jiwan. > _________________________________________________________ > Remove["Global`*"]; > \[Rho] = 8910;(* mass density : kg/m^3 *) > v = 4.08;(* sound velocity : nm/ps *) > \[Beta] = 1.3 10^-5;(* linear expansion : /K *) > B = 1.8 10^11; (* bulk modulus : Pa *) > c = 3 10^5; (* light speed : nm/ps *) > \[Lambda] = 800; \[Omega] = > 2 \[Pi] c/\[Lambda]; (* light wavelength : nm *) > Ce = 1.065 10^3; (* electron heat cap. at 300 K : 3.19 10^5 J/m^3K *) > Cl = 3.95 10^6; (* lattice heat cap. : J/m^3K = 26.1 J/mol.K *) > g = 4.4 10^5; (* coupling constant : 4.4 10^17 W/m^3.K *) > K = 91 10^6; (* thermal conductivity : 91 W/m.K -> 91 10^18 *) > \[Xi]1 = 13.5; (* pump absorption depth: nm *) > \[Xi]2 = 14.5; (* probe absorption depth: nm *) > Dl = 2.3 10^-5; (* diffusivity : m^2/s *) > R = 0.4; (* reflection at interface *) > I0 = 1.05 10^10; (* 2.77 10^13 J/m^2.pulse(ps) -> 2.77 10^22 *) > PulseWidth = 0.2 ; (* 200 fs *) > S[t_] := I0 Exp[-t^2/(2 PulseWidth)^2]; > pow[z_, t_] := 1/\[Xi]1 S[t] Exp[-z/\[Xi]1]; (* W/m^3 *) > L = 1000; (* sample thickness : nm *) > solution = > NDSolve[{Ce Te[z, t] D[Te[z, t], t] == > K D[Te[z, t], z, z] - g (Te[z, t] - Tl[z, t]) + pow[z, t], > Cl D[Tl[z, t], t] == g (Te[z, t] - Tl[z, t]), > Te[z, -100] == Tl[z, -100] == 300, > Te[L, t] == 300, (D[Te[z, t], z] /. z -> 0) == 0}, {Te, Tl}, {z, > 0, L}, {t, -100, 100}, MaxSteps -> Infinity, > MaxStepSize -> {1, 0.1}][[1]] > solz = {Te[z, t], Tl[z, t]} /. solution /. z -> 0; > Plot[solz /. t -> tau, {tau, -2, 100}, PlotRange -> All] > dTl = (D[Tl[z, t] /. solution, t] /. {z -> Abs[zz - v (t1 - t2)], > t -> t2}); > \[Eta][z_, > t_] := -((3 B \[Beta])/(2 \[Rho] v^2)) NIntegrate[ > Evaluate[ > Sign[zz - v (t1 - t2)] dTl /. {zz -> z, t1 -> t}], {t2, -100, > 100}, AccuracyGoal -> 4, Exclusions -> {t2 == 0}]; > vals = Table[{t, \[Eta][1, t]}, {t, 1, 20, 0.5}] > ListPlot[vals] > ------------------------------------------------------------------------------ > > > ----------------------------------------------------------------------------- > Institute of Physics and Chemistry of Materials Strasbourg (IPCMS) > Department of Ultrafast Optics and Nanophotonics (DON) > 23 rue du Loess, B.P. 43, > 67034 STRASBOURG Cedex 2, France >