Help with errors - Unable to meet integration tolerances, Time integration failed, Attempted to access u(5), index out of bounds because numel (u)=4
4 views (last 30 days)
Show older comments
Hello,
I am trying to use some code to solve an advection diffusion equation which then plots the predicted data curve versus my data curve. The code works with the initial conditions that was used to test the code (1.4 input concentration) but when I change the input concentration (needs to be 5) or to a longer experimental run (more data points) then I get the following error:
Warning: Failure at t=9.431708e+02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.818989e-12) at time t. > In ode15s at 669 In pdepe at 317 In adv_diff_calibrate>objective at 61 In fminsearch at 312 In adv_diff_calibrate at 27 Warning: Time integration has failed. Solution is available at requested time points up to t=9.000000e+02. > In pdepe at 323 In adv_diff_calibrate>objective at 61 In fminsearch at 312 In adv_diff_calibrate at 27 Attempted to access u(5); index out of bounds because numel(u)=4.
Error in adv_diff_calibrate>objective (line 65) sum = sum + (u(i) - obs(i))^2;
Error in fminsearch (line 312) x(:) = xe; fxe = funfcn(x,varargin{:});
Error in adv_diff_calibrate (line 27) x = fminsearch(@objective,x0,[],k,pulse_length,input_conc, tspan, xmesh, obs, U);
65 sum = sum + (u(i) - obs(i))^2; K>> i
i =
5
K>> u
u =
1.0e+286 *
0
-0.0000
-0.0000
-1.1369
An error occurs at line 27 and the piece of code and description is as follows:
x0 = [D k]
(Line 27) x = fminsearch(@objective,x0,[],k,pulse_length,input_conc, tspan, xmesh, obs, U);
D = x(1);
k = x(2);
set up the functional coefficients in pdefun and boundary conditions in % bcfun and initial conditions in icfun for a generic diffusion equation
As well as line 65 in which the code is:
function object = objective(x,k,pulse_length,input_conc, tspan, xmesh, obs, U);
D = x(1);
k = x(2); m =0;
sol = pdepe(m,@pdefun,@icfun,@bcfun,xmesh,tspan,[],D,U,k,pulse_length,input_conc);
u = sol(:,100,1);
sum = 0;
for i = 1:length(obs)
(Line 65) sum = sum + (u(i) - obs(i))^2;
end
object = sum
end
I am mainly concerned with the breakthrough curve and this piece of code (with line 65) I think is for another graph so when I deleted that part I get this error:
Undefined function 'objective' for input arguments of type 'double'.
Error in fminsearch (line 191) fv(:,1) = funfcn(x,varargin{:});
Error in adv_diff_calibrate (line 27) x = fminsearch(@objective,x0,[],k,pulse_length,input_conc, tspan, xmesh, obs, U);
Is there a simple fix for any of this? Please let me know if more information is needed. If someone could please explain what is happening and if there is something I can do to fix it, in layman's terms, if possible, I would be very appreciative. (Sorry a bit over my head as my non-responsive supervisor wrote the code and its my first time using Matlab)
Cheers for any help!
2 Comments
Babak
on 7 May 2013
The error says that your PDE is singular at that point that the integration stops.
Accepted Answer
Babak
on 7 May 2013
As far as for a PDE, if you want to make sure that this singularity is something related to your numerical integration method or it's innate in the system of equations, you need to find a length scale and a time scale and write the equations in the dimension-less form so you won't get very huge and very small numbers at the same time. Then try to integrate with different time steps and length steps and if the singularity didn't change then you can conclude that it is innate to your system of equations, otherwise your numerical integrator fails integrating the set of equations and spits out the singularity.
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!