Home > Archive > Matlab > April 2005 > 1D Time Dependent Heat Conduction
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
1D Time Dependent Heat Conduction
|
|
| Stephens 2005-04-24, 8:59 pm |
| I do I set up a finite difference code to solve a 1D time dependent
Heat Conduction problem with convective boundary conditions?
| |
| Paul Skoczylas 2005-04-25, 4:02 pm |
| "Stephens" <danzig@unm.edu> wrote in message news:ef03d2d.-1@webx.raydaftYaTP...
> I do I set up a finite difference code to solve a 1D time dependent
> Heat Conduction problem with convective boundary conditions?
Is this homework?
I'd suggest looking at Section 5.9 of Incropera & DeWitt's "Introduction to Heat Transfer", 2nd edition. Heck, Eqns 5.73 and 5.77
pretty much spell it out for you! (The section/equation numbers might be different in a newer edition.) Probably any other heat
transfer text will have a similar section.
This is about the easiest finite difference problem there is. (The only thing easier would be if you had constant T boundary
conditions.) Spend a few minutes reading up on it, and post back with specific questions or problems you're having implementing it.
I'll be happy to help you solve specific problems, but I'm not going to do your work for you.
-Paul
| |
|
| This is what I have so far for solving my equation. The system
equation is u(j), where all u's are dimensionless temperatures. I
have another file to input the initial and boundary conditions, but I
think it might be a bunch of garbage. I'll post it after this one.
Thanks
function [usve] = diff_fd(dx,dt,k,ui,u1,um,N,M,nsve);
% Step 1: initialize variables and set values for first
time step only
usve = zeros(floor(N/nsve),M); % Initialize usve matrix
[N/nsve X M] to save
output profiles
uold = ui; % uold - corresponds to u^n
cnt = 1; % cnt - counter to keep track of
number of saved profiles.
usve(cnt,:) = ui; % Saves output at specified time-steps
% Step 2: Loop over time timesteps, initialize variables,
set BCs
for i = 1: N-1; % Loop over time steps
u = zeros(1,M); % Initialize current time-step
vector: u^(n+1)
u(1) = u1(i); % Assign first boundary condition
u(M) = um(i); % Assign second boundary condition
% Step 3: Loop over grid points, calculating u^(n+1)_j at
each grid point.
for j = 2:M-1 % Loop over grid points omitting end
points where BC's are set.
% Next line is the Heat Conduction finite
diff. eqn.
u(j) = dt*((uold(j-1) - 2*uold(j) + uold(j+1))/dx^2) +
((uold(j+1)-uold(j-1))/2*dx)+uold(j);
end % end for loop over grid points
% Step 4: Save profile at specified time-steps
if (mod(i,nsve)==0) % if this time-step is a multiple
of nsve, save profile
cnt = cnt + 1; % increment counter by 1
usve(cnt,:) = u; % assign profile value to column
of usve
end
% Step 5: current time-step solution becomes I.C. for next
time-step
uold = u; % u becomes initial condition for
next time-step
end % end for loop over time steps
| |
| Paul Skoczylas 2005-04-25, 8:59 pm |
| Forgive the top-posting.
I see a few issues here.
1. How are you non-dimensionalizing T into u? There are a couple of ways you can do this, but I don't see an obvious one here.
Let's clarify that first. (Why are you non-dimensionalizing, anyway? There's no real need to.)
2. u1 and um aren't appling convective boundary conditions--you're fixing the temperatures at those nodes. With convective BCs the
outside nodes will change in temperature with time, but they won't in your code.
3. Your heat conduction eqn doesn't appear to be correct to me. There are three terms on the right side. Since u and uold are
nondimensionalized, they have no units. But the first term has units of dt/dx^2, and the second has units of 1/dx. When adding
terms, all must have the same units. If dt and dx are also nondimensionalised, please share how you did that, too. I can't make
sense of it as written.
4. I won't even go into other issues (like stability, and efficient Matlab programming) until these others are resolved! But let
me mention stability: If your time step is too large, your results will diverge. It will be really obvious when this happens! But
it's easy to either know what the maximum step to use is, or to write the problem so that stability is not an issue. But hold off
on that for now!
-Paul
"S" <danzig@unm.edu> wrote in message news:ef03d2d.1@webx.raydaftYaTP...
> This is what I have so far for solving my equation. The system
> equation is u(j), where all u's are dimensionless temperatures. I
> have another file to input the initial and boundary conditions, but I
> think it might be a bunch of garbage. I'll post it after this one.
>
> Thanks
>
> function [usve] = diff_fd(dx,dt,k,ui,u1,um,N,M,nsve);
>
> % Step 1: initialize variables and set values for first
> time step only
>
> usve = zeros(floor(N/nsve),M); % Initialize usve matrix
> [N/nsve X M] to save
> output profiles
> uold = ui; % uold - corresponds to u^n
> cnt = 1; % cnt - counter to keep track of
> number of saved profiles.
> usve(cnt,:) = ui; % Saves output at specified time-steps
>
> % Step 2: Loop over time timesteps, initialize variables,
> set BCs
>
> for i = 1: N-1; % Loop over time steps
> u = zeros(1,M); % Initialize current time-step
> vector: u^(n+1)
> u(1) = u1(i); % Assign first boundary condition
> u(M) = um(i); % Assign second boundary condition
>
> % Step 3: Loop over grid points, calculating u^(n+1)_j at
> each grid point.
>
> for j = 2:M-1 % Loop over grid points omitting end
> points where BC's are set.
> % Next line is the Heat Conduction finite
> diff. eqn.
> u(j) = dt*((uold(j-1) - 2*uold(j) + uold(j+1))/dx^2) +
> ((uold(j+1)-uold(j-1))/2*dx)+uold(j);
> end % end for loop over grid points
>
> % Step 4: Save profile at specified time-steps
>
> if (mod(i,nsve)==0) % if this time-step is a multiple
> of nsve, save profile
> cnt = cnt + 1; % increment counter by 1
> usve(cnt,:) = u; % assign profile value to column
> of usve
> end
>
> % Step 5: current time-step solution becomes I.C. for next
> time-step
>
> uold = u; % u becomes initial condition for
> next time-step
> end % end for loop over time steps
| |
|
| I'm going to email you my equation and boundary conditions because
they look super ugly when trying to write them out without a math
editor.
| |
|
| You're posted email seems to be incorrect. Do you have a functional
one that you can post, or can you email me one?
Thank You
| |
| Paul Skoczylas 2005-04-26, 4:04 pm |
| "s" <samuel.stephens@kirtland.af.mil> wrote in message news:ef03d2d.4@webx.raydaftYaTP...
> You're posted email seems to be incorrect. Do you have a functional
> one that you can post, or can you email me one?
>
> Thank You
It should work if you delete the "DELETE"! But I'll send you an email as well (you've used two addresses, so I'll send to both.)
-Paul
|
|
|
|
|