Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
499b84c
tests on DAE sensitivities
Apr 23, 2026
022961c
Added explicit Euler solutions in DAE examples and function explicitE…
Apr 23, 2026
cce1727
Changes in daeExample_main.m
Apr 23, 2026
93b1bdb
more work on sensitivities for DAEs
May 4, 2026
fee1c43
more tests on DAE sensitivities
May 12, 2026
35e773b
Reworked DAE example with non-linear constraint
May 27, 2026
ef3d236
Reworked DAE example with non-linear constraint
May 27, 2026
e9ef514
restructured folders for DAE examples
May 28, 2026
53b0b0c
rename in bounceball example and canonical example
May 28, 2026
9811d4b
rename in bounceball
May 28, 2026
9583453
rename in coulomb example and dae Examples, added comments in explici…
May 28, 2026
20eb956
rename in White Cabbage and Predator Prey Filippov
May 28, 2026
645a3c5
Refactor bounceball and predatorprey
Jun 9, 2026
f324f7d
removed funfun from examples (already integrated in testsuite)
Jun 9, 2026
085f1d2
refactored spiral, sign
Jun 9, 2026
4cd24c3
refactor statejump, subway; removed func2str from datahandle call
Jun 9, 2026
60a6498
more work for example rename
Aug 20, 2026
412e21a
Added CI computation for WhiteCabbage and further rename in Live Exam…
Aug 27, 2026
d10e6bd
Rename in live examples and respective helpers; changes in state jump…
Aug 30, 2026
95cace9
changed comment in computeCI
Aug 31, 2026
56ad5ce
Renames in helpers for CI computation
Aug 31, 2026
b6cd1ae
hotfix sensitivity computation
Aug 31, 2026
f8cc373
integrated step size fix in FDstep computation from public
Sep 2, 2026
6b665fd
Rename in Live Scripts and respective helpers
Sep 7, 2026
ecbb632
Modified generateSensitivityFunction calls with new FDStep syntax (op…
Sep 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions toolbox/examples/bounceball/bounceball_rhs.m

This file was deleted.

36 changes: 0 additions & 36 deletions toolbox/examples/bounceball/bounceball_test.m

This file was deleted.

32 changes: 0 additions & 32 deletions toolbox/examples/canonicalExample/canonicalExampleRHS_extended.m

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
% integrate
fprintf('Integrating ...')
tic
sol = integrator(@(t,x) canonicalExampleRHS(t,x,p), tspan, y0, options);
sol = integrator(@(t,x) rhsCanonicalExample(t,x,p), tspan, y0, options);
toc
fprintf('Integrating with limited step size...')
tic
soltrue = integrator(@(t,x) canonicalExampleRHS(t,x,p), tspan, y0, optionsExact);
soltrue = integrator(@(t,x) rhsCanonicalExample(t,x,p), tspan, y0, optionsExact);
toc

% evaluate solution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [funcSolPiecewise, tSwitch, switchingFunc, varargout] = canonicalExampleAnalyticSolution()
function [funcSolPiecewise, tSwitch, switchingFunc, varargout] = rhsAnalyticSolution()
%[funcSolPiecewise, tSwitch, switchingFunc, varargout] = CANONICALEXAMPLEANALYTICSOLUTION()
%[funcSolPiecewise, tSwitch, switchingFunc, t0, y0, p] = CANONICALEXAMPLEANALYTICSOLUTION()
%
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dx = canonicalExampleRHS(t,x,p)
function dx = rhsCanonicalExample(t,x,p)

dx = zeros(2,1);
dx(1) = 0.01 * t.^2 + x(2).^3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
tPlotStep = 0.01;

%% Analytical solution
[solTrue, switches, switchingFunctions, t0, y0, p] = canonicalExampleAnalyticSolution;
[solTrue, switches, switchingFunctions, t0, y0, p] = rhsAnalyticSolution;
tspan = [t0, tf];
tPlot = t0:tPlotStep:tf;

Expand All @@ -26,7 +26,7 @@
%% Solution ifdiff
integrator = @ode45;
odeoptionsrhs_test = odeset( 'AbsTol', 1e-14,'RelTol', 1e-12);
datahandle = prepareDatahandleForIntegration('canonicalExampleRHS', 'integrator', func2str(integrator), 'options', odeoptionsrhs_test);
datahandle = prepareDatahandleForIntegration('rhsCanonicalExample', 'integrator', integrator, 'options', odeoptionsrhs_test);
sol = solveODE(datahandle, tspan, y0, p);

%% Plot analytical solution vs. ifdiff
Expand All @@ -44,7 +44,7 @@
%set(gca,'XTick',0:5:20);

%% Plot analytical solution vs ode45
canonicalExampleRHS_ode45 = @(t,y) canonicalExampleRHS(t,y,p);
canonicalExampleRHS_ode45 = @(t,y) rhsCanonicalExample(t,y,p);
sol_ode45 = ode45(canonicalExampleRHS_ode45, tspan, y0);

figure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
timeinterval = [t0,tf];
initstates = [1 0 ];
p = 5.437;
odeoptions = odeset( 'AbsTol', 1e-20, 'RelTol', 1e-12, 'MaxStep', 1000);

%%
fprintf('Integration with %s...\n ', func2str(integrator));
th = tic();
sol_matlab = integrator(@(t,x) rhsCanonicalExample(t,x,p), timeinterval, initstates, odeoptions);
time_matlab = toc(th); fprintf('Took %g seconds\n', time_matlab);

%%
fprintf('Preprocessing...\n ');
odeoptions = odeset( 'AbsTol', 1e-20, 'RelTol', 1e-12);
filename = 'canonicalExampleRHS';
filename = 'rhsCanonicalExample';
th = tic();
dhandle = prepareDatahandleForIntegration(filename, 'integrator', func2str(integrator), 'options', odeoptions);
dhandle = prepareDatahandleForIntegration(filename, 'integrator', integrator, 'options', odeoptions);
time_prepare = toc(th); fprintf('Took %g seconds\n', time_prepare);

%%
Expand All @@ -19,13 +25,6 @@
sol_ifdiff = solveODE(dhandle, timeinterval, initstates, p);
time_ifdiff = toc(th); fprintf('Took %g seconds\n', time_ifdiff);

%%
fprintf('Integration with %s...\n ', func2str(integrator));
th = tic();
sol_matlab = integrator(@(t,x) canonicalExampleRHS(t,x,p), timeinterval, initstates, odeoptions);
time_matlab = toc(th); fprintf('Took %g seconds\n', time_matlab);


%%
% do explicit euler integration
fprintf('AccurateEuler integration...\n ');
Expand All @@ -38,7 +37,7 @@
dt = (tf-t0) / N_euler; % time increment
for k = 1:N_euler
T(k+1) = t0 + k*dt;
X(:,k+1) = X(:,k) + dt * canonicalExampleRHS(T(k), X(:,k), p);
X(:,k+1) = X(:,k) + dt * rhsCanonicalExample(T(k), X(:,k), p);
end
time_euler = toc(th); fprintf('Took %g seconds\n', time_euler);
skipper = floor(N_euler/1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

integrator = @ode45;
odeoptionsrhs_test = odeset( 'AbsTol', 1e-14,'RelTol', 1e-12);
datahandle = prepareDatahandleForIntegration('canonicalExampleRHS', 'integrator', func2str(integrator), 'options', odeoptionsrhs_test);
datahandle = prepareDatahandleForIntegration('rhsCanonicalExample', 'integrator', integrator, 'options', odeoptionsrhs_test);

tspan = [0 20];
initialvalues = [1;0];
Expand Down Expand Up @@ -40,7 +40,7 @@

t_plot = 0:0.01:20;
%sensitivities_END_plot = sensitivities_function_ENDpiecewise(t_plot);
sensitivities_END_plot = sensitivities_function_VDE(t_plot);
sensitivities_END_plot = sensitivities_function_VDE(t_plot); %correct?

sensdata_y11 = arrayfun( @(x) x.Gy(1,1), sensitivities_END_plot);
sensdata_y12 = arrayfun( @(x) x.Gy(1,2), sensitivities_END_plot);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dx = coulomb_rhs(t,x,U)
function dx = rhsCoulomb(t,x,U)
% INPUT: t - time
% x - state
% U - function handle of one variable (time) [voltage]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
dt = (times.tf - times.t0) / Neuler; % time increment
for k = 1:Neuler
T(k+1) = times.t0 + k*dt;
X(:,k+1) = X(:,k) + dt * coulomb_rhs(T(k), X(:,k), Ufun);
X(:,k+1) = X(:,k) + dt * rhsCoulomb(T(k), X(:,k), Ufun);
%if k > 10; break; end
end
fprintf('Euler integration took %g seconds.\n', toc());
Expand All @@ -43,7 +43,7 @@
% try with ode-solver
odesolver = @ode15s;
tic
sol = odesolver(@(t,x) coulomb_rhs(t,x,@U_umax3), [times.t0, times.tf], x0);
sol = odesolver(@(t,x) rhsCoulomb(t,x,@U_umax3), [times.t0, times.tf], x0);
fprintf('%s integration took %g seconds.\n', func2str(odesolver), toc());
Tode = Teuler;
Xode = deval(sol, Tode);
Expand Down
26 changes: 0 additions & 26 deletions toolbox/examples/daeExample/daeExample_main.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ legend([Plain_plot_1(1), IFDIFF_plot_1(1), Switch_plot]);
hold off
```

![](plots_daeExample/plot1.png)
![](plotsDaeExample/plot1.png)

We notice that the integrator strategy results in small steps here for the plain solver as well as IFDIFF. This is standard behavior for `ode15s` which is a multi-step method; it is not a defect caused by improper treatment of switching events.
However, if we take a closer look, we see that the integration with IFDIFF is accurate around the switching point.

![](plots_daeExample/plot1_close.png)
![](plotsDaeExample/plot1_close.png)

## Additional Content

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
function f = daeExampleRHS(~, x, p)

function f = rhsDaeExample(~, x, p)
%
f = zeros(2,1);

% algebraic constraint
z = x(1) + x(2);
z = x(1) + x(2) + x(2)^3 - p;
f(2) = z;
% differential variables

% differential equation
if x(2) < p
f(1) = x(2);
else
f(1) = 0;
end
end

end
Loading