1 function test_err = rb_test_error(model,detailed_data,reduced_data,M_test,...
3 %
function test_err = rb_test_error(model,detailed_data,reduced_data,M_test,...
6 %
function determining the test-errors, i.e. energy norm or l2-error given ty
7 % 'model.error_algorithm' at end time for the given set of vectors `\mu`
8 % (columns in 'M_test') of the RB simulation with corresponding RB set.
11 % M_test: matrix with column vectors of parameter tuples `\mu` for which the
12 % error between reduced and detailed simulation shall be computed.
13 % savepath: directory path where the detailed simulations shall be saved to
14 % with save_detailed_simulations().
16 % required fields of model:
17 % error_algorithm: function handle to function that computes the error
18 % `\|u_h - u_{red}\|` in some norm.
20 % optional fields of model:
21 % relative_error:
boolean indicating wether relative or absolute errors shall
22 % be computed. (Default = absolut errors)
25 % test_err: vector of errors at end time
27 % Bernard Haasdonk 6.6.2007
29 %
import model specific methods
31 nmus = size(M_test,2);
32 test_err = zeros(nmus,1);
35 error('savepath must be provided in case of error as target value!');
43 tmodel = tmodel.set_mu(model, M_test(:,i));
44 rb_sim_data = rb_simulation(tmodel,reduced_data);
48 rb_sim_data = rb_reconstruction(tmodel,detailed_data,rb_sim_data);
50 if isfield(detailed_data,'W')
51 err_par = detailed_data.W;
56 errs = tmodel.error_algorithm(tmodel.get_dofs_from_sim_data(sim_data),...
57 tmodel.get_dofs_from_sim_data(rb_sim_data),...
59 if isfield(tmodel,'relative_error') && tmodel.relative_error
60 errs = errs./tmodel.error_algorithm(tmodel.get_dofs_from_sim_data(sim_data), ...
65 % disp('warning, check monotonicity in errs!!!');
67 % if (i==2) & (mod(size(detailed_data.RB,2),30) == 0)
68 % save(['errs',num2str(size(detailed_data.RB,2))],'errs');