PDE toolbox pulse source term in heat equation

4 views (last 30 days)
Hi,
I would like to implement a source that is time dependent in the heat equation that I model with the pdetoolbox. Typically I am considering a very simple case described below. I consider a circle on a square and I wish to put a sinusoidal like source in this circle.
Can you tell ma what I am doing wrong? The error logs are below as well
R1 = [3;4;-1;1;1;-1;-1;-1;1;1];
C1 = [1;0;0;0.4];
C1 = [C1;zeros(length(R1) - length(C1),1)];
gd = [R1,C1];
sf = 'R1+C1';
ns = char('R1','C1')';
g = decsg(gd,sf,ns);
numberOfPDE = 1;
pdem = createpde(numberOfPDE);
geo = geometryFromEdges(pdem,g);
mysource = @(region,state) sin(350*state.time).^2;
% Specify PDE Coefficients: m*d^2u/dt^2 + d*du/dt - div(c*grad(u)) + a*u = f
applyBoundaryCondition(pdem,'dirichlet','Edge',[(1:4)],'u',293);
specifyCoefficients(pdem,'m',0,'d',1,'c',1,'a',0,'f',mysource,'face',2);
specifyCoefficients(pdem,'m',0,'d',1,'c',1,'a',0,'f',0,'face',1);
msh = generateMesh(pdem);
p = msh.Nodes;
endTime = 5000;
tlist = 0:50:endTime;
numNodes = size(p,2);
setInitialConditions(pdem,300);
R = solvepde(pdem,tlist);
Error logs
Error in pde.DynamicDiscretizedPDEModel (line 27)
obj=obj@pde.DiscretizedPDEModel(thePde,p,e,t,coefstruct,u0);
Error in pde.EquationModel/solveTimeDependent (line 20)
femodel=pde.DynamicDiscretizedPDEModel(self,p,e,t,coefstruct,u0,tlist,tsecondOrder);
Error in pde.PDEModel/solvepde (line 54)
[u,dudt] = self.solveTimeDependent(coefstruct, u0, ut0, tlist, ...
Error in Heat_2D (line 61)
R = solvepde(pdem,tlist);

Answers (2)

Ravi Kumar
Ravi Kumar on 8 Jun 2018
Hi Nicolas,
What version of MATLAB are you running? I can run you code in R2018a, which produced the temperature distribution as shown in the figure.

nicolas bachelard
nicolas bachelard on 8 Jun 2018
I am running a 2017a license. Do you think this is the issue?
Best

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!