Implementing Neumann and Dirichlet boundary conditions on a disk
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Boundary Conditions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!