For solvability my problem needs to have at least a single boundary node set as Dirichlet. From the image attached, I would like to place u=0 at vertex 1. I have tried (and it worked) to use a miniscule edge near that vertex and place Diriclet conditions on it. What I don't like about that approach is that since it was more than a single node involved in the tiny edge, I was concerned that it could impact the results.
The two edges (edge 1 and 4) adjacent to vertex 1 should have a homogeneous Neumann condition (u'=0).
Is there a way to use a function and logic (example below) to have the code use Neumann on edges 1 & 4 but when x=xmax and y=ymin if uses Dirichlet?
Somewhat like this:
myPhantomFuncArgs= @(location,state) myPhantomFunc_Q(location,state,xmax,ymin);
applyBoundaryCondition(model,"neumann","Edge",[EdgeBotNotAnode EdgeRightWall],"q",myPhantomFuncArgs,"g",0);
function funcQ = myPhantomFunc_Q(location,state,xmax,ymin)
if (location.x < xmax || location.y > ymin) % Defines NOT vertex 1
funcQ = 0;
else
funcQ = 1; % Condition when at vertex 1.
end
end
This does not work since when funcQ is 1, there is still the gradient portion of the Neumann BC expression!
Thanks for any input.
Paul

 채택된 답변

Torsten
Torsten 2025년 4월 16일

0 개 추천

Is there a way to use a function and logic (example below) to have the code use Neumann on edges 1 & 4 but when x=xmax and y=ymin if uses Dirichlet?
No. Boundary conditions have to be set on objects one dimension lower than the region where the PDEs are defined. Since you work in 2d, these boundary objects must be 1d, thus edges.

댓글 수: 6

Paul Safier
Paul Safier 2025년 4월 16일
Is there a way to tweak/trick the "mixed" BC option along with the logic above to force a Neumann everywhere except at the location.x=xmax & location.y=ymin?
When location.x=xmax & location.y=ymin
h = 1; r = 0; q = 0; g = 0;
else
h = 0; r = 0; q = 0; g = 0;
end
Torsten
Torsten 2025년 4월 16일
편집: Torsten 2025년 4월 16일
As said, it is not possible to set isolated boundary conditions in points for a 2d-problem. A boundary condition in a 2d-domain must be set on an 1d-object. The reason is that a boundary condition is always associated with the area of the object on which it is defined. Loosely speaking, if the area is 0, you get a 0*boundary condition = 0 contribution of it in the numerical equations to be solved.
Paul Safier
Paul Safier 2025년 4월 16일
OK, thanks for the input @Torsten. I suppose I will go the route of editing the H and R matrices for that single node.
Torsten
Torsten 2025년 4월 16일
편집: Torsten 2025년 4월 16일
A boundary condition is always associated with the lengths of the cell edges to which it belongs. So if you edit the H and R matrices of a single node, the lengths of the sides of the neighbouring cell will be used as areas in the computation. Thus results will depend on the grid you use for edges 1 and 4 near the corner points - it comes out the same as you did with the tiny edge on which you imposed the Dirichlet condition.
Paul Safier
Paul Safier 2025년 4월 16일
And that's fine, but it would allow me to insure that just a single node is set as Dirichlet. When I used the tiny edge method, I wasn't sure how to get just a single node in that little edge. Do you know how to push for that?
Torsten
Torsten 2025년 4월 17일
I have no experience with the PDE Toolbox in particular, but usually, gridding praeprocessors allow to mesh the edges first and then to use this boundary mesh as starting point to measure the interior of the domain. Maybe the User Guide or Support can answer if and how this can be done.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2023b

질문:

2025년 4월 16일

댓글:

2025년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by