3 % This script creates the data needed
for a detailed and reduced simulation
4 % of the Comsol-2D-Thermal-Block model.
5 % It can be used
for testing or just
for gettin an overview of the comsol
11 fprintf(
'loading comsol_thermal_block_model...\n')
12 model = comsol_thermal_block_model;
15 %create the data needed for simulation
16 fprintf('generating model_data...\n')
17 model_data=gen_model_data(model);
20 %after generation of model data all the needed matrices are stored in
21 %model_data --> now Comsol is only needed for plotting the results but no
22 %longer for calculating! Using Matlab instead of Comsol for the calculation
23 %speeds up things (really much, especially on a Mac!!!)
26 fprintf('generating detailed_data...\n')
27 detailed_data = gen_detailed_data(model,model_data);
30 fprintf('generating reduced_data...\n')
31 reduced_data = gen_reduced_data(model,detailed_data);
33 %decide whether 1x2 or 2x2 or 3x3 block is chosen!
34 mu_old = get_mu(model);
41 mu = [5,3,1,5,3,1,5,3,1]
43 error('length of mu doesnt fit to this script!')
45 model=set_mu(model,mu);
47 %run a reduced Simulation
48 fprintf(['calculating reduced solution for mu = ' num2str(mu),'...\n']);
49 rb_sim_data=rb_simulation(model,reduced_data);
50 rb_sim_data=rb_reconstruction(model,detailed_data,rb_sim_data);
54 title('reduced solution');
56 %run a detailled solution
57 fprintf(['calculating detailed solution for mu = ' num2str(mu),'...\n']);
58 sim_data=detailed_simulation(model,model_data);
62 title('detailed solution')
65 fprintf('comparing the L2-error Udet - Ured.\n')
68 U_diff = abs(Udet-Ured);
69 L2_error = sqrt(U_diff' * model_data.inner_product_matrices.L2 * U_diff);
70 fprintf(['\n\nL2-Error is: ', num2str(L2_error),'\n'])
function comsol_thermal_block_script()
comsol_thermal_block_script
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.