Time-dependent boundary condition in PDE Toolbox
25 views (last 30 days)
Show older comments
Hello ! I'm facing some issues with PDE Toolbox in Matlab, indeed I'm trying to solve the heat diffusion equation in a plate of Phase Change Material . So I've got a Temperature-dependent capacity , but I need to solve the equation in a sinusoidal state , I mean with a sin boundary condition. But today, when I specify 'sin(t)' as 'u' condition, it gives me back an error. I don't know very well the PDE toolbox app and I think i did something wrong, could you help me please ? Thanks a lot !
Error using pde.internal.pde2DBCImpl/getBCMatrices (line 50)
The "u" parameter of a pde.BoundaryCondition entity has more entries, 1001, than the number of equations, 1.
This error occurred in the definition of a pde.BoundaryCondition entity on edge 4.
Error in pde.internal.pde2DBCImpl>@(varargin)self.getBCMatrices(varargin{:}) (line 23)
fh = @self.getBCMatrices;
Error in pdeefxpd (line 9)
[q,g,h,r]=feval(bl,p,e,u,time);
Error in pdeexpd (line 39)
[q,g,h,r]=pdeefxpd(p,e,u,time,bl);
Error in assemb (line 164)
[q,g,h,r]=pdeexpd(p,e,u,time,bl);
Error in pdeODEInfo/getMats (line 165)
[Q,G,H,R]=assemb(self.b,self.p,self.e,u,time);
Error in pdeODEInfo/checkFuncDepen (line 61)
[MM0,K0,M0,F0,Q0,G0,H0,R0] = self.getMats(u0, t0);
Error in pdeParabolicInfo (line 13)
obj=obj.checkFuncDepen(u0, tlist);
Error in parabolic (line 109)
pdeprb=pdeParabolicInfo(u0,tlist,b,p,e,t,c,a,f,d);
Error in diffusionMCP (line 52)
u = parabolic(u0, tlist, pdem, c, a, f, d);
Here is the code I wrote !
%%DIFFUSION DANS UN MCP EN 1D
% Ecrit par Alexis CAILLON ### Dernière version : 11/03/2016
%%CREATION D'UN MODELE de PDE Toolbox
numberOfPDE = 1;
pdem = createpde(numberOfPDE);
%%Geometrie de la plaque / Geometry
%Definition de la plaque
hauteur = 0.005;
largeur = 0.005;
gdm = [3 4 0 largeur largeur 0 0 0 hauteur hauteur]';
g = decsg(gdm, 'S1', ('S1')');
geometryFromEdges(pdem,g);
%Tracé et affichage / Plot
figure;
pdegplot(pdem,'edgeLabels','on');
axis equal
title 'Plaque (vue en coupe) avec légende';
%Maillage de la plaque / Mesh
hmax = 0.005/10; %taille d'un element fini
msh=generateMesh(pdem,'Hmax', hmax);
figure;
pdeplot(pdem);
axis equal
title 'Plaque avec maillage triangulaire'
%%Conditions aux limites / Boundary coundition
% 50° sur le bord gauche
Tgauche = applyBoundaryCondition(pdem,'Edge',4, 'u', sin(350*t).^2);
%%Définition des coefficients
d = '500.*(4250 +(15000-4250).*exp(-((22.3-u)./3).^2))'; %capacité calorifique*rho
c = 0.25; % conductivité thermique
a = 0;
f = 0;
%%Solution en régime transitoire
tlist = 0:1:1000;
u0 = 15;
u = parabolic(u0, tlist, pdem, c, a, f, d);
getClosestNode = @(p,x,y) min((p(1,:) - x).^2 + (p(2,:) - y).^2);
% Call this function to get a node near the center of the right edge.
[~,nid] = getClosestNode( msh.Nodes, 1, 0 );
h = figure;
h.Position = [1 1 2 1].*h.Position;
subplot(1,2,1);
axis equal
pdeplot(pdem, 'xydata', u(:,end), 'contour', 'on', 'colormap', 'hot');
axis equal
title 'Temperature, Temps final, solution transitoire'
subplot(1,2,2);
axis equal
plot(tlist, u(nid,:));
grid on
title 'Temperature sur le bords droit a t final';
xlabel 'Temps, secondes'
ylabel 'Temperature, degrées-Celsius'
0 Comments
Accepted Answer
Ravi Kumar
on 6 Apr 2016
Edited: madhan ravi
on 23 Nov 2018
Hi Alexis,
Replace the BC assignment line:
Tgauche = applyBoundaryCondition(pdem,'Edge',4, 'u', sin(350*t).^2);
with
mybc = @(region,state) sin(350*state.time).^2;
Tgauche = applyBoundaryCondition(pdem,'Edge',4, 'u', mybc);
Refer to the following documentation for additional details on specifying non-constant BC: http://www.mathworks.com/help/pde/ug/nonconstant-boundary-object-specification.html
Hope this helps!
Ravi
0 Comments
More Answers (0)
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!