37 st_sizes = 1:size(QFull,2);
41 stn = length(st_sizes);
45 pi =
ProcessIndicator(
" Computing approximated log norms for %d full jacobians and %d sim. trans. orders ",...
48 J = f.getStateJacobian(jtd.xi(:,nr),jtd.ti(nr),jtd.mui(:,nr));
50 Qk = QFull(:,1:st_sizes(snr));
53 times(snr,nr) = toc(
t);
59 testing.DEIM.compareSimTransJac_FullJac_plots(m, aln, times, st_sizes);
91 jstd = m.Data.JacSimTransData;
92 pm.nextPlot(
" correct_ln ",sprintf(
" Full logarithmic norms\nJacobian full dimension %dx%d ",...
93 m.System.f.fDim,m.System.f.xDim));
97 [
X,
Y] = meshgrid(1:size(aln,2),st_sizes);
98 LN = repmat(jstd.LogNorms,size(aln,1),1);
102 h = pm.nextPlot(
" approx_ln ",...
103 sprintf(
" Approx logarithmic norms\nSimilarity transformation size %d ",...
107 h = pm.nextPlot(
" approx_ln ",
" Approx logarithmic norms ",...
108 " training sample ",
" similarity transform size ");
112 h = pm.nextPlot(
" rel_err ",
" Relative error ",
" training sample ",...
113 " similarity transform size ");
116 sv = m.ErrorEstimator.QSingVals;
117 s = m.ErrorEstimator.JacSimTransMaxSize;
118 h = pm.nextPlot(
" sing_vals ",...
119 sprintf(
" Singular values of SVD of eigenvector matrix\nBlack line: Max size of sim. trans., singular value= %g ",...
120 sv(s)),
" POD Modes ",
" Singular values ");
123 plot(h,[s s+eps],[min(sv) max(sv)],
" k ");
126 h = pm.nextPlot(
" comp_times ",...
127 sprintf(
" Average computation times (over %d values)\nfor log norms of similarity transformed matrices ",...
128 size(times,2)),
" similarity transformation size ",
" mean computation time ");
130 semilogy(h,st_sizes,me,
" -s ");
147 st_sizes = [1:e.JacSimTransMaxSize 0];
149 deim_orders = 1:jd.MaxOrder;
154 stn = length(st_sizes);
156 no = length(deim_orders);
158 aln = zeros(no,stn,n);
161 pi =
ProcessIndicator(
" Computing approximated log norms over %d DEIM orders and %d sim. trans. sizes on %d training values ",...
162 numel(aln),
false,no,stn,n);
164 jd.Order= deim_orders(onr);
166 jd.setSimilarityTransform(e.QFull(:,1:st_sizes(snr)));
169 J = jd.evaluate(jtd.xi(:,nr),jtd.ti(nr),jtd.mui(:,nr));
170 jtimes(onr,snr,nr) = toc(t);
173 times(onr,snr,nr) = toc(t);
216 jstd = m.Data.JacSimTransData;
218 ln = reshape(jstd.LogNorms,1,1,[]);
219 ln = repmat(ln,[length(deim_orders), length(st_sizes), 1]);
221 abserr = abs(aln-ln);
222 relerr = abs(abserr ./ ln);
223 relerr(isnan(relerr)) = 0;
227 abserr = mean(abserr,3);
228 relerr = mean(relerr,3);
231 ttimes = times + jtimes;
232 times = mean(times,3);
233 jtimes = mean(jtimes,3);
234 ttimes = mean(ttimes,3);
236 [
X,
Y] = meshgrid(st_sizes,deim_orders);
238 h = pm.nextPlot(
" abs_err ",sprintf(
" Mean absolute approximation error over %d samples ",n),...
239 " Similarity transformation size ",
" DEIM order ");
242 h = pm.nextPlot(
" rel_err ",sprintf(
" Mean relative approximation error over %d samples ",n),...
243 " Similarity transformation size ",
" DEIM order ");
246 h = pm.nextPlot(
" comp_times_j ",...
247 sprintf(
" Average computation times over %d values\nfor matrix DEIM jacobian evaluation ",...
248 n),
" Similarity transformation size ",
" DEIM order ");
251 h = pm.nextPlot(
" comp_times ",...
252 sprintf(
" Average computation times over %d values\nfor log norm computation of sim.trans. matrix DEIM jacobian ",...
253 n),
" Similarity transformation size ",
" DEIM order ");
256 h = pm.nextPlot(
" comp_times_total ",...
257 sprintf(
" Average total computation times over %d values\n(jac comp + log norm comp) ",...
258 n),
" Similarity transformation size ",
" DEIM order ");
281 if isa(mo,
" models.ReducedModel ")
290 mui = fm.Data.ParamSamples;
298 elseif length(t) ~= n
299 error(
" Size of t vector must match column count of x ");
306 pi =
ProcessIndicator(
" Computing approximated log norms for %d parameter values at %d locations ",n*m,
false,m,n);
310 J = jd.evaluate(x(:,i),
t(i),mui(:,j));
311 jtimes(i,j) = toc(tc);
314 times(i,j) = toc(tc);
322 res.mJ= e.JacMatDEIMOrder;
323 res.k= e.JacSimTransSize;
355 str = sprintf(
" \nm_J = %d, k=%d, %d locations ",res.mJ, res.k, size(res.aln,1));
356 if size(res.mui,1) == 1
357 if size(res.aln,1) == 1
358 h = pm.nextPlot(
" aln_min ",[
" Log norms at given location " str],res.munames[1]);
361 [
X,
Y] = meshgrid(res.mui,1:size(res.aln,1));
362 h = pm.nextPlot(
" aln_min ",[
" Log norms over all locations " str],res.munames[1],
" location nr ");
363 surf(h,
X,
Y,res.aln,
" EdgeColor ",
" none ",
" FaceColor ",
" interp ");
365 elseif size(res.mui,1) == 2
366 tri = delaunay(res.mui(1,:),res.mui(2,:));
367 if size(res.aln,1) == 1
368 h = pm.nextPlot(
" aln_min ",[
" Log norms at given location " str],res.munames[:]);
369 trisurf(tri,res.mui(1,:),res.mui(2,:),res.aln,...
370 " EdgeColor ",
" none ",
" FaceColor ",
" interp ",
" Parent ",h);
382 alnmin = min(res.aln,[],1);
383 alnmax = max(res.aln,[],1);
384 h = pm.nextPlot(
" aln_min ",[
" Minimum log norms over all locations " str],res.munames[:]);
385 trisurf(tri,res.mui(1,:),res.mui(2,:),alnmin,...
386 " EdgeColor ",
" none ",
" FaceColor ",
" interp ",
" Parent ",h);
387 h = pm.nextPlot(
" aln_min ",[
" Max log norms over all locations " str],res.munames[:]);
388 trisurf(tri,res.mui(1,:),res.mui(2,:),alnmax,...
389 " EdgeColor ",
" none ",
" FaceColor ",
" interp ",
" Parent ",h);
390 h = pm.nextPlot(
" aln_min ",[
" Max-Min log norms over all locations " str],res.munames[:]);
391 trisurf(tri,res.mui(1,:),res.mui(2,:),alnmax-alnmin,...
392 " EdgeColor ",
" none ",
" FaceColor ",
" interp ",
" Parent ",h);
395 error(
" Cannot plot results for more than two parameters ");
400 static function [res , mScale , MScale , pos , l , sel , seli ] =
CompLogNorms(m,numt) {
403 atd = m.Data.ApproxTrainData;
419 r = RandStream(
" mt19937ar ",
" Seed ",seed);
423 seli = unique(r.randi(N,1,numt));
426 pi =
ProcessIndicator(
" Computing %d local log norms, maxed over %d training points ",n,
false,n,length(sel));
436 fxi = atd.fxi(:,sel);
445 [xinsq sortidx] = sort(xinsq);
447 fxi = fxi(:,sortidx);
450 xifxi = sum(xi.*fxi);
460 zi = W^
t*atd.xi(:,seli);
461 MU = atd.mui(:,seli);
462 fVzi = m.System.f.evaluate(V*zi,atd.ti(seli),MU);
471 nom = xifxi - z
" *Vfxi + z "*(V^
t*fz);
473 denom = xinsq - 2*z
" *Vxi + z "*(VV*z);
480 [~, idx] = sort(denom);
486 [ln(i), pos(i)] = max(Ln);
491 ti = sprintf(
" Idx %d: loc Lip const %g, loc log norm %g ",seli(i),
l(i),ln(i));
492 ax = pm.nextPlot(
" blah ",ti,
" training point ",
" local [lip const (b), log norm (g)] ");
513 res = data.ApproxTrainData(zi,[],[]);
515 res = data.ApproxTrainData.makeUniqueXi(res);
516 [res, mScale, MScale] = data.ApproxTrainData.scaleXiZeroOne(res);
Collection of generally useful functions.
static function pm = compareSimTransDEIMJac_FullJac_plots(m, aln, times, jtimes, deim_orders, st_sizes, pm)
See WSH12 tests_burgers for likely better plot routine.
LogPlot: Class with static functions for logarithmic plotting.
Params
The parameters usable for the dynamical system.
error.BaseEstimator ErrorEstimator
The associated error estimator for this model.
The base class for any KerMor detailed model.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
static function [ aln , times , rowvec< integer > st_sizes ] = compareSimTransJac_FullJac(models.BaseFullModel m,rowvec< integer > st_sizes)
% Comparison of similarity transformed jacobian log norms to full log norms Computes logarithmic norm...
static function [ res , mScale , MScale , pos , l , sel , seli ] = CompLogNorms(m, numt)
LogNorm:
static function pm = compareSimTransJac_FullJac_plots(m, aln, times, st_sizes, pm)
PlotManager: Small class that allows the same plots generated by some script to be either organized a...
static function handle p = logsurf(handle h,matrix< double > X,matrix< double > Y,matrix< double > Z, varargin)
Creates a nice surface plot in a logarithmic scale with the given data.
static function handle p = cleverPlot(handle ax,rowvec< double > x,rowvec< double > y, varargin)
Calls corresponding plot routines depending on the scale of data.
static function struct res = getApproxLogNormsAtPos(models.BaseFullModel mo,colvec< double > x,double t,matrix< double > mui)
Computes logarithmic norms of similarity transformed AND matrix DEIM approximated jacobians at the po...
static function [ aln , times , jtimes , rowvec< integer > deim_orders , rowvec< integer > st_sizes ] = compareSimTransDEIMJac_FullJac(models.BaseFullModel m,rowvec< integer > deim_orders,rowvec< integer > st_sizes)
% Comparison of similarity transformed DEIM-approximated jacobian log norms to full log norms Compute...
data.ModelData Data
The full model's data container. Defaults to an empty container.
static function handle p = nicesurf(handle h,matrix< double > X,matrix< double > Y,matrix< double > Z, varargin)
Creates a nice surface plot with the given data.
dscomponents.ACoreFun f
The core f function from the dynamical system.
data.ApproxTrainData JacobianTrainData
Training data for the jacobian approximation.
static function getApproxLogNormsAtPos_plots(res, pm)
static function [ double ln , colvec< double > v ] = logNorm(matrix< double > A,matrix< double > G,colvec< double > v0)
Computes the logarithmic norm of a matrix , optionally using a positive definite symmetric matrix in...
ProcessIndicator: A simple class that indicates process either via waitbar or text output...