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?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Zakaria OUAOUJA
le 29 Mai 2023
Commenté : Zakaria OUAOUJA
le 8 Juin 2023
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.
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 commentaires
Réponse acceptée
Torsten
le 29 Mai 2023
Déplacé(e) : Torsten
le 29 Mai 2023
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 commentaires
Torsten
le 30 Mai 2023
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
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!