/usr/share/octave/site/m/sundialsTB/cvodes/examples_ser/mcvsDiscSOL_dns.m is in octave-sundials 2.5.0-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | function mcvsDiscSOL_dns()
%mcvsDiscSOL_dns - CVODES example with solution discontinuity
% Trivial CVODES example to illustrate the use of
% CVodeReInit to integrate over a discontinuity in
% the solution:
% y' = -y ; y(0) = 1 ; t = [0,1]
% y' = -y ; y(1) = 1 ; t = [1,2]
%
% Radu Serban <radu@llnl.gov>
% Copyright (c) 2005, The Regents of the University of California.
% $Revision: 1.1 $
t0 = 0.0;
t1 = 1.0;
t2 = 2.0;
% Initialize solver
y = 1.0;
options = CVodeSetOptions('RelTol',1.e-3,...
'AbsTol',1.e-4,...
'StopTime',t1,...
'LinearSolver','Dense');
CVodeInit(@rhsfn,'BDF','Newton',t0,y,options);
% Integrate to the point of discontinuity
t = t0;
i = 1;
tt(i) = t0; yy(i) = y;
while t < t1
[status, t, y] = CVode(t1,'OneStep');
i = i+1;
tt(i) = t;
yy(i) = y;
end
% Add discontinuity and reinitialize solver
y = 1.0;
options = CVodeSetOptions(options,'StopTime',t2);
CVodeReInit(t1,y,options);
% Integrate from discontinuity to final time
t = t1;
i = i+1;
tt(i) = t1; yy(i) = y;
while t < t2
[status, t, y] = CVode(t2,'OneStep');
i = i+1;
tt(i) = t;
yy(i) = y;
end
% Plot solution
figure
plot(tt,yy)
title('Discontinuity in solution');
xlabel('time');
ylabel('y');
% Free memory
CVodeFree;
return
% ===========================================================================
function [yd, flag] = rhsfn(t, y)
% Right-hand side function
yd(1) = -y(1);
flag = 0;
return
|