2 eqns in 2D with different BCs applied to each variable on the same edge? On E1, u1=0 and du2/dn=0, on E2 u2=1 and =du1/dn=0. The solution is all zeros. Example code is below

2 次查看(过去 30 天)
% Create a PDE model with a system of two equations
model = createpde (2);
% Use a Rectanglar geometry
R1 = [3, 4, -1, 1, 1, -1, -.4, -.4, .4, .4]';
g = decsg (R1);
geometryFromEdges (model, g);
pdegplot (model, 'EdgeLabels', 'on')
% Apply Dirichlet type boundary condition to u1 and u2 on E1 and E3
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'u', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'u', 1, 'EquationIndex', 2);
% Apply Neumann type boundary condition to u1 and u2 on E3 and E1
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'g', 0, 'q', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'g', 0, 'q', 0, 'EquationIndex', 2);
% Generate the mesh
generateMesh (model);
% Setup the PDE
specifyCoefficients (model, 'm', 0, 'd', 0, 'c', 1, 'a', [-1;-1; 1; 1], 'f', [0; 0]);
% Solve the PDE
result = solvepde (model)
result =
StationaryResults with properties:
NodalSolution: [1001×2 double]
XGradients: [1001×2 double]
YGradients: [1001×2 double]
ZGradients: [0×2 double]
Mesh: [1×1 FEMesh]
The Nodal solution is all zeros. I realize that the PDE setup does not support Dirichlet and Neumann BCs for the same variable on the same edge. I'm applying different BCs to different variable on the same edge. Is there a bug, or am I doing something wrong?

采纳的回答

Torsten
Torsten 2025-5-6
编辑:Torsten 2025-5-6
I think
applyBoundaryCondition (model, "mixed", Edge=1, u=0, EquationIndex=1,q=[0 0;0 0],g=[0;0]);
applyBoundaryCondition (model, "mixed", Edge=3, u=1, EquationIndex=2,q=[0 0;0 0],g=[0;0]);
instead of
% Apply Dirichlet type boundary condition to u1 and u2 on E1 and E3
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'u', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'u', 1, 'EquationIndex', 2);
% Apply Neumann type boundary condition to u1 and u2 on E3 and E1
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'g', 0, 'q', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'g', 0, 'q', 0, 'EquationIndex', 2);
is the correct setting.
You could also use
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'u', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'u', 1, 'EquationIndex', 2);
alone, but with the additional lines
applyBoundaryCondition (model, 'mixed', 'Edge', 3, 'g', 0, 'q', 0, 'EquationIndex', 1);
applyBoundaryCondition (model, 'mixed', 'Edge', 1, 'g', 0, 'q', 0, 'EquationIndex', 2);
you overwrite these settings and solve the problem with boundary conditions du1/dn = du2/dn = 0 on both edges (because du/dn = 0 is the default setting). This gives u1 = u2 = 0 identically as solution.
  4 个评论
Torsten
Torsten 2025-5-6
编辑:Torsten 2025-5-6
The portion following EquationIndex=#, implicitly applies to setdiff(1:N,#), where N is the number of equations (2 in this case)? Is that correct, or at least consistent with your understanding?
Yes.
Or is a slope of zero being applied to both the 1st and 2nd variable on both Edge=1 and Edge=3?
No.
You set the conditions for equation 2 on Edge 1 after EquationIndex=1 when you use
applyBoundaryCondition (model, "mixed", Edge=1, u=0, EquationIndex=1,q=[0 0;0 0],g=[0;0]);
and you set the conditions for equation 1 on Edge 3 after EquationIndex=2 when you use
applyBoundaryCondition (model, "mixed", Edge=3, u=1, EquationIndex=2,q=[0 0;0 0],g=[0;0]);
Maybe
applyBoundaryCondition (model, "mixed", Edge=1, u=0, EquationIndex=1, q=0, g=0);
applyBoundaryCondition (model, "mixed", Edge=3, u=1, EquationIndex=2, q=0, g=0);
also works, and the settings for q and g automatically apply to the remaining equation. Test whether you get the same results.
Ben Abbott
Ben Abbott 2025-5-6
Ok. When I looked at the solution, I misinterpreted what I was looking at. I've plotted it now and see that all BCs are being met.
Thanks

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by