Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 26527

problem in initial value in matlab

$
0
0
Hi

I'm simulating a model in matlab for a sampling time 3 s. After this i use the last simulation as initial condition for the next iteration. I use the following code (as the tutorial):

for k = 1:nit
model.study('std1').run;
temp = mpheval(model,'T','edim','edge','selection',3);


% update initial time for next iteration
t0 = mphglobal(model,'t','solnum','end');
model.param.set('t0',t0);

% initial condition for the next iteration
model.physics('nipfl').feature('init1').set('p', 1, 'p');
model.physics('nipfl').feature('init1').set('u', 1, 'u');
model.physics('nipfl').feature('init1').set('T', 1, 'T');
model.physics('ge').feature('init1').set('Tm',1, 'Tm');
v1 = model.sol('sol1').feature('v1');
v1.set('initsol', 'sol1');

data = [data;temp.d1(end,3)]; % store in a vector the output

end


My dependent variables are p, u, T and Tm, as can be seen. But when I plot the temperature i have a wrong result (blue line).

I compare this result with other simulation, without use a loop 'for' (in red line). For this case I run the model from time = 0 to time final, don't using the interpolation.

The image is in attach.

Anyone have the same problem?

best regards

Geovani

Viewing all articles
Browse latest Browse all 26527

Trending Articles