Solve ODE with function dependent parameters
이전 댓글 표시
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
darova
2020년 5월 3일
Can you attach something more?
Simon Lawton
2020년 5월 4일
darova
2020년 5월 4일
Can you show original formulas?
Simon Lawton
2020년 5월 4일
darova
2020년 5월 4일
Where is
boundary condition (initial)
Simon Lawton
2020년 5월 5일
답변 (1개)
darova
2020년 5월 5일
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

카테고리
도움말 센터 및 File Exchange에서 Structural Mechanics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
