Solve ODE with function dependent parameters
Mostrar comentarios más antiguos
Hi,
I consider my self a relative novice with MATLAB, but am trying to use it to solve a coupled heat and mass transfer problem using the method of lines, to model drying processes - I expect that as the solution progresses - the "crust" will have different propoerties to the "core" but this isn't happening.
IWhat I hoped would happed is that the physical property functions (which do vary significantly over the course of the solution), would be continuously re-evaluated during the course of the solution (eg varying as the solution progresses), but some basic diagnostics suggest that this is not the case - can you help me see where I'm going wrong?
Many Thanks
Simon
Extract from the ODE function that I'm solving using ode15s - the code runs d=fine, but the solution is suspect.
for i=n:-1:1
% Symmetry Boundary Conditions
if(i==1)
Tt(i) = 2*(T(i+1) - T(i)) * dx2; % HT Boundary condition at x=xl, central symmetry
CWat(i)= 2*(CWa(i+1) - CWa(i)) * dx2; % MT boundary condition free water at x=xl, central symmetry
% Surface Boundary Conditions
elseif(i==n) % add sorption isotherm here Xgamma as a function of moisture in solid
Aw = GAB_solve(CWa(n),T(n));
PSat = AntoineW(T(n)); % Calculate water vapour pressure
%Mass fluxes at the interface
Jwat = (-kmWat * (18.01 / R)) * ( ( (Aw * PSat) / (T(n) - 273.15) ) - (RH / (Tinf - 273.15)) ) ;
% Boundary condition at x=xu, convective heat transfer at the surface
Tt(i) = ((-(h /(lambda(CWa(i-1),T(i-1)))) * (T(i)- Tinf)) - (lambdaW * Jwat) ) * dx2; % heat transfer boundary condition
CWat(i) = Jwat; % Boundary condition at x=xu, convective heat transfer t=at the surface % MT boundary condition at x=xu, convective mass transfer at the surface
% Body terms
else
kpot(i) = lambda(CWa(i-1),T(i-1)); % Thermal conductivity as function of composition and Temperature
rho(i) = density(CWa(i-1),T(i-1)); % Density as function of composition of composition and temperature
CP(i) = Cp(CWa(i-1),T(i-1)); % Specific Heat Capacity as function of composition and temperature
alphaT = kpot ./ (rho .* CP); % Thermal diffusivity as function of composition and temperature
Tt(i) = alphaT(i) * (T(i+1) - 2 * T(i) + T(i-1)) * dx2; % Diffusive heat transfer
D = Diffusivity(CWa(i-1),T(i)); % Moisture diffusivity as function of composition and temperature
CWat(i) = (D * (CWa(i+1) - 2.0 * CWa(i) + CWa(i-1)) * dx2 ); % Diffusive Mass transfer and starch gelatinisation
end
6 comentarios
darova
el 3 de Mayo de 2020
Can you attach something more?
Simon Lawton
el 4 de Mayo de 2020
darova
el 4 de Mayo de 2020
Can you show original formulas?
Simon Lawton
el 4 de Mayo de 2020
darova
el 4 de Mayo de 2020
Where is
boundary condition (initial)
Simon Lawton
el 5 de Mayo de 2020
Respuestas (1)
darova
el 5 de Mayo de 2020
Try this simple example
a = 1/pi^2;
x = linspace(0,1,50)';
T0 = 1-(1/2-x).^2; % initial condition t=0 (start time)
dx = x(2)-x(1);
% left boundary T=0
% right boundary T=0
f = @(t,T) [0; a*diff(T(1:50),2)/dx^2; 0];
[t,T] = ode45(f,[0 3], T0);
[xx,tt] = meshgrid(x,t);
surf(tt,xx,T,'edgecolor','none')
axis vis3d

Categorías
Más información sobre Structural Mechanics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
