help-octave
[Top][All Lists]

## Modelling questions

 From: И Страшко Subject: Modelling questions Date: Thu, 23 Jun 2011 06:55:02 -0700

Sorry about my last post.  Question 1 was really whether this way of iterating was applicable.  I forgot to ask that, and pushed "send" before realizing I didn't ask it.

Yes, I used fsolve.  Let me ask my question more simply.

I took my pde, for which dt (really deltat) and T_e are constants,

k * del2 T = dT/dt - T_e, and rewrote it in a form,

0 = k * del2(T) - dT/dt + T_e

dT/dt is approximated using

dT/dt = (T(i) - T(i-1)) / dt, which is a kind of forward derivative.

so

0 = k * del2(T(i)) - (T(i) - T(i-1)) / dt + T_e

Next, I prepared a function, called heat.  The variable x here is T(i) above,
the variable Tlast is T(i-1), and Te is T_e.

function y=heat(x)
global K dx dy dz dt Te Tlast
[xl,yl,zl]=size(x);
z = K*del2(x,dx,dy,dz);
z = z + Te*ones(xl,yl,zl);
z = z-(x-Tlast)/dt;
y = z;
endfunction

I then use this in fsolve.

Then I advance from one time to the next.  It seems to work, it looks physical, and it converges well.

The question is... Is this mathematically correct?  (BTW, why should one write a second order routine when Octave supplies del2?)

(My second question seems to be an adaptation of the FEM, so I will pursue that analysis as described in Wikipedia.)

Thanks for the help.