1 function sim_data = t_part_detailed_simulation(model, model_data)
2 %
function sim_data = t_part_detailed_simulation(model, model_data)
4 %
function performing a t-partition detailed simulation
for the underlying
5 %base model. In
case that no t-partition indication is given in params a
6 %simulation is performed
for the whole time domain. If a special
7 %t-partition is indicated a simulation
for this partition is performed
8 %
using precomputed parameter solutions as initial conditions
if they have
11 % changes in
this function must be done when
using higher order time
12 % integration methods.
14 % Generated fields of sim_data:
16 % y: output
if available
17 % sim_data_t: cell array where the results from the several time
18 % partitions are saved.
20 % Markus Dihlmann 11.02.11
24 partial_simulation = 0; %sim_data only
for one specific part or not
26 base_model = model.base_model;
28 nr_t_parts = length(model.t_part_range);
29 sim_data_t = cell(1,nr_t_parts);
31 if (isfield(model,
't_part_for_simulation'))
32 stop_part = model.t_part_for_simulation;
33 partial_simulation = 1 ;
35 stop_part = nr_t_parts;
38 for t_part_ind = 1:stop_part
39 base_model.starting_time_step = model.t_part_range{t_part_ind}(1);
40 base_model.stopping_time_step = model.t_part_range{t_part_ind}(2); %must be changed
for higher order time integrations
43 base_model.starting_time_step = model.t_part_range{t_part_ind}(1);
44 temp = sim_data_t{t_part_ind-1}.U(:,end);
45 base_model.init_values_algorithm = @(mod,mod_data)temp;
48 sim_data_t{t_part_ind} = detailed_simulation(base_model, model_data);
49 %sim_data_t{t_part_ind} =
filecache_function(@detailed_simulation,base_model, model_data);
53 %construct output
struct sim_data
56 sim_data_t_fields = fieldnames(sim_data_t{i});
57 for j=1:length(sim_data_t_fields)
58 if isnumeric(getfield(sim_data_t{i},sim_data_t_fields{j}))
59 if ~isfield(sim_data,sim_data_t_fields{j})
60 sim_data = setfield(sim_data,sim_data_t_fields{j},getfield(sim_data_t{i},sim_data_t_fields{j}));
62 sim_data = setfield(sim_data,sim_data_t_fields{j},[getfield(sim_data,sim_data_t_fields{j}),getfield(sim_data_t{i},sim_data_t_fields{j})]);
67 %glue all infomation fields from sim_data_t together
68 for i = 1: length(sim_data_t)
69 sim_data_t_fields = fieldnames(sim_data_t{i});
70 for j=1:length(sim_data_t_fields)
71 if isnumeric(getfield(sim_data_t{i},sim_data_t_fields{j}))
72 if ~isfield(sim_data,sim_data_t_fields{j})
73 sim_data = setfield(sim_data,sim_data_t_fields{j},getfield(sim_data_t{i},sim_data_t_fields{j}));
75 len=size(getfield(sim_data_t{i},sim_data_t_fields{j}),2);
77 extension_vec = getfield(sim_data_t{i},sim_data_t_fields{j});
78 sim_data = setfield(sim_data,sim_data_t_fields{j},[getfield(sim_data,sim_data_t_fields{j}),extension_vec(:,2:len)]);
80 sim_data = setfield(sim_data,sim_data_t_fields{j},[getfield(sim_data,sim_data_t_fields{j}),getfield(sim_data_t{i},sim_data_t_fields{j})]);
89 sim_data.sim_data_t = sim_data_t;
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.