How can we define the initial conditions u0 at time t+1 as a vector that is equal to the previous initial conditions u0 at time t?
2 次查看(过去 30 天)
显示 更早的评论
Hello community,
I am currently working on a co-simulation problem that uses PDEPE toolbox to solve heat conduction.
I am utilizing EnergyPlus to simulate a cold room for a 24-hour period = endtime. The model calculates the internal temperature at each timestep, which is set to 60 seconds. This internal temperature is then employed to determine the product's temperature every minute using a 1D heat transfer approach with Robin boundary conditions (convective heat flux). Subsequently, this information is used to calculate the thermal load of the product, which is then transmitted to EnergyPlus for further analysis and processing.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1398444/image.png)
And since PDEPE tool needs time span of integration, specified as a vector specifying the points at which a solution is requested, I created an array tspan_pde = 0:60:endtime to match the EnergyPlus simulation runtime.
The problem is at each EnergyPlus timestep the PDEPE tool is called and solves the conduction problem for the whole tspan_pde.
My idea is instead of solving the PDE equation for the whole tspan_pde = 0:60:endtime, I should solve it only for [0s 30s 60s] :
Tprod = Tprod0;
(1) u0 = Tprod; Q = h*s*(Tprod-Tw); will be send to EnergyPlus;
(2) EnergyPlus calculates the internal temperature Tw;
(3) Tw is used to calculate Tprod by solving PDEPE for tspan_pde = [0s 30s 60s] ==> u = [u(0) u(30) u(60)]; store Tprod = u(60)
(4) Update the initial condition u0 = u(60); Q = h*s*(Tprod-Tw); will be send to EnergyPlus;
(5) Increment t; go to (2);
So that is why I need to assign the initial conditions u0 at time t+1 to be equal to the temperature u at time t.
global rho Cp k
rho = 1000;
Cp = 888;
k = 20;
L = 1;
x = linspace(0,L,10);
endt = 4*3600;
t = linspace(0,endt,20);
m = 0;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t);
figure
plot(t,sol(:,2),t,sol(:,5),t,sol(:,8))
function [c,f,s] = heatpde(x,t,u,dudx)
global rho Cp k
c = rho*Cp;
f = k*dudx;
s = 0;
end
function u0 = heatic(x)
u0 = 20;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = ur - 1;
qr = 0;
end
0 个评论
采纳的回答
Torsten
2023-5-29
移动:Torsten
2023-5-29
In order to proceed, I need to assign the initial conditions u0 at time t+1 to be equal to the previous initial conditions u0 at time t.
You won't proceed this way because the solution will always remain the same as at time t=0.
4 个评论
Torsten
2023-5-30
Something like this (where sol_old is the pdepe solution of the last 1-minute timestep) ?
function [sol_new] = pdepe_application(T_wall,sol_old)
rho = 1000;
Cp = 888;
k = 20;
L = 1;
x = linspace(0,L,10);
t = linspace(0,60,3);
heatic = @(xp)interp1(x(:),sol_old(end,:,1),xp);
m = 0;
sol_new = pdepe(m,@heatpde,heatic,@(xl,ul,xr,ur,t)heatbc(xl,ul,xr,ur,t,T_wall),x,t);
function [c,f,s] = heatpde(x,t,u,dudx)
c = rho*Cp;
f = k*dudx;
s = 0;
end
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ...;
ql = ...;
pr = ...;
qr = ...;
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Eigenvalue Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!