Defining non constant coefficients for solvepde (thermal simulation)

1 view (last 30 days)
Hello,
for defining coefficients for solvepde the structs "region" and "state" are given as input to the functions. In both structs x- and y-Coords can be found. Both Coord-matrices have the length of the number of triangles of the mesh. Q1: What are the Coordinates in "region", and the Coordinates in "state" standing for? Do both represent the centers of the triangles of the mesh? Q2: Do I have to define the coefficients for the points in "region" or the points in "state", when the function is called by the solver?
Thank you in advance for help LF

Answers (2)

Vaidyanathan Thiagarajan
Vaidyanathan Thiagarajan on 4 Oct 2017
Hello LittlFren,
I believe you are talking about the 'region' and 'state' objects that are passed as input to the 'applyBoundaryCondition' function as illustrated in the script that is attached with this post. The 'x' and 'y' fields in the 'region' object correspond to the coordinates of the (mesh) nodes lying on the boundary (edge in 2D or Face in 3D) where the boundary condition is applied. 'state' has the field 'u' in it (in addition to 'time'). 'state.u' is useful in specifying non-constant boundary condition over an edge or face as illustrated in the following link :
Please note that there is a one-to-one correspondence between the elements of region.x, region.y, and region.u i.e. region.u(i) is the field value (such as temperature) corresponding to the boundary point [region.x(i), region.y(i)] for some integer i.
Also note that you only have to specify this when you have non-constant 'Dirichlet' or 'Neumann' boundary conditions. For constant boundary conditions you can follow the examples in this link :
Vaidyanathan
  1 Comment
MarionJ
MarionJ on 13 Oct 2017
Edited: MarionJ on 13 Oct 2017
Hello
Thank you very much for your answer. Actually I am talking about the 'region' and 'state' objects that are passed as input to the functions I wrote to define the coefficients c,d and f in a parabolic PDE (more precisely for the heat conduction equation):
%Define PDE coefficients
m=0;
d=@(region,state) dcoefffunc(region,state);
c=@(region,state) ccoefffunc(region,state);
a=0;
f=@(region,state) fcoefffunc(region,state);
specifyCoefficients(model,'m',m,'d',d,'c',c,'a',a,'f',f);
Nr=length(region.x) is 0,1 or the number of triangles of my mesh, curiously not the number of nodes. I specify c and d in dependence on the coordinates of region.y in the respective function, for example:
for i=1:Nr
for j=size(yCoord,2):-1:2
if (yCoord(1,j)<= region.y(1,i))&&(region.y(1,i) <yCoord(1,j-1))
d(1,i)=HeatCap(j-1);
end
end
end
For f it did not work, so I defined it in dependence on the actual active mesh points defined in cpp, as follows:
for i=1:Nr
if isempty(find([cpp{:}]==i))==0
for iA = 1:numel(cpp)
if isempty(find(cpp{iA} == i))==0
f(1,i)=PState*Pdensity(1,iA);
end
end
else
f(1,i)=PState*0;
end
end
Pdensity is state-dependent and calculated as such precedingly. This finally worked, and I got the same nodal results with the simulation by solvepde and the simulation with parabolic. Though it works I still do not understand what the region and state object is and especially why Nr= number of triangles? Do both represent the centers of the triangles of the mesh? Do I have to define the coefficients for the points in "region" or the points in "state", when the function is called by the solver?
I hoped I made myself clearer
LF

Sign in to comment.


MarionJ
MarionJ on 13 Oct 2017
Hello
Thank you very much for your answer. Actually I am talking about the 'region' and 'state' objects that are passed as input to the functions I wrote to define the coefficients c,d and f in a parabolic PDE (more precisely for the heat conduction equation):
%Define PDE coefficients
m=0;
d=@(region,state) dcoefffunc(region,state);
c=@(region,state) ccoefffunc(region,state);
a=0;
f=@(region,state) fcoefffunc(region,state);
specifyCoefficients(model,'m',m,'d',d,'c',c,'a',a,'f',f);
Nr=length(region.x) is 0,1 or the number of triangles of my mesh, curiously not the number of nodes. I specify c and d in dependence on the coordinates of region.y in the respective function, for example:
for i=1:Nr
for j=size(yCoord,2):-1:2
if (yCoord(1,j)<= region.y(1,i))&&(region.y(1,i) <yCoord(1,j-1))
d(1,i)=HeatCap(j-1);
end
end
end
For f it did not work, so I defined it in dependence on the actual active mesh points defined in cpp, as follows:
for i=1:Nr
if isempty(find([cpp{:}]==i))==0
for iA = 1:numel(cpp)
if isempty(find(cpp{iA} == i))==0
f(1,i)=PState*Pdensity(1,iA);
end
end
else
f(1,i)=PState*0;
end
end
Pdensity is state-dependent and calculated as such precedingly. This finally worked, and I got the same nodal results with the simulation by solvepde and the simulation with parabolic. Though it works I still do not understand what the region and state object is and especially why Nr= number of triangles? Do both represent the centers of the triangles of the mesh? Do I have to define the coefficients for the points in "region" or the points in "state", when the function is called by the solver?
I hoped I made myself clearer LF

Community Treasure Hunt

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

Start Hunting!