Implementing Neumann and Dirichlet boundary conditions on a disk
    10 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Dear matlab community,
I try to solve the Helmholtz equation on a disk with a small part of the boundary where I have Neumann boundary conditions and Dirichlet boundary conditions elsewhere. 
The Neumann boundary conditions (which I simulated with inhomogeneous Dirichlet boundary conditions u = 1) should be valid  for all x with  - R*cos(pi/2 - theta0) < x < R*cos(pi/2 - theta0). 
The following code I created does however fully igonore the Neumann boundary conditions and just gives me the solution for the Dirichlet boundary condition on the full circle
model = createpde;
R = 1;
disk = [1, 0, 0, R]';
gm = decsg(disk);
geometryFromEdges(model, gm);
theta0 = pi/4;
BCFunc = @(location,state)  -heaviside(location.x - R*cos(pi/2 - theta0)) + heaviside(location.x + R*cos(pi/2 - theta0)); 
b1 = applyBoundaryCondition(model, 'dirichlet', Edge=(1:4), u = BCFunc);
specifyCoefficients(model,m=0,d=1,c=1,a=0,f=0);
r = [0,10];
generateMesh(model,Hmax=0.05);
results = solvepdeeig(model,r);
l = sqrt(results.Eigenvalues)
u = results.Eigenvectors;
figure
pdeplot(model,XYData=u(:,1),Contour="on",Colormap="default");
xlim([-1,1])
ylim([-1,1])
As a workaround I tried to model the disk as a polygon such that the boundary conditions can be implemented without BCFunc by solely calling the edges. But when I applied it for a polygon with more than 10 corners matlab started to label the whole edge of the polygon as one connected edge again. 
Does anyone have an idea why matlab is ignoring the Neumann part of the boundary conditions and/or is there a workaroung to this problem? 
0 件のコメント
採用された回答
  Drishti
 2025 年 3 月 6 日
        Hi Jannik,
I understand you are trying to implement both the Neumann boundary conditions and the Dirichlet boundary conditions while solving the Helmholtz equation on a disk.
One workaround you can follow is first applying the the Dirichlet boundary conditions on the entire boundary and then applying the Neumann boundary on the specific edge.
You can refer to the code snippet below to understand the same:
% Apply Dirichlet boundary condition to the entire boundary initially
applyBoundaryCondition(model, 'dirichlet', 'Edge', (1:4), 'u', 0);
% Assume edge 2 is the correct edge for Neumann conditions as an example
neumann_edge = 2; 
% Apply Neumann condition to the specific edge
applyBoundaryCondition(model, 'neumann', 'Edge', neumann_edge, 'g', 1, 'q', 0);
For more information, refer to the MATLAB Documentation of 'applyBoundaryCondition' function provided below:
I hope this helps!
2 件のコメント
  Star Strider
      
      
 2025 年 3 月 10 日
				@Jannik — It is important to Accept (and preferably also vote for) an answer that solves your problem.  This notifies others that the solution worked, and gives reputation points to the person who provided the answer.  
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Boundary Conditions についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


