ElectroStatic To Wolfram.nb
M. Weinberg 10/28/18
5/23/21
​
The repeating boundary conditions correctly do P and dp/dy but do not do dp/dx correctly.
An example from the NDSolve documentation is enclosed and shows the same error.
In[]:=
$HistoryLength=1
Out[]=
1
In[]:=
<<NDSolve`FEM`(*AddtoinstallFEMpackage*)
In[]:=
eq1=D[p[x,y],{x,2},{y,0}]+D[p[x,y],{x,0},{y,2}]0(*Diff.equationsforElectrostatics*)
Out[]=
(0,2)
p
[x,y]+
(2,0)
p
[x,y]0
In[]:=
data={w->600,gs200,x1150,dx0,hc200.,dy0,ϵo8.854*^-12}
Out[]=
{w600,gs200,x1150,dx0,hc200.,dy0,ϵo8.854×
-12
10
}
In[]:=
h=gs+2*hc+dy
Out[]=
dy+gs+2hc
In[]:=
top=Line[{{0,h},{x1+0.5*w+dx,h},{x1+0.5*w+dx,h-hc},{x1+1.5*w+dx,h-hc},​​{x1+1.5*w+dx,h},{2*w,h}}/.data]
Out[]=
Line[{{0,600.},{450.,600.},{450.,400.},{1050.,400.},{1050.,600.},{1200,600.}}]
In[]:=
left=Line[{{0,0},{0,h}}/.data]
Out[]=
Line[{{0,0},{0,600.}}]
In[]:=
right=Line[{{2*w,0},{2*w,h}}/.data]
Out[]=
Line[{{1200,0},{1200,600.}}]
In[]:=
bottom=Line[{{0,0},{x1,0},{x1,hc},{x1+w,hc},{x1+w,0},{2*w,0}}/.data]
Out[]=
Line[{{0,0},{150,0},{150,200.},{750,200.},{750,0},{1200,0}}]
In[]:=
outline=RegionUnion[left,top,right,bottom];
In[]:=
Marc3=ToElementMesh[
outline
,MaxCellMeasure500];(*Onecanconvertoutlinetoameshregion,butnotanarearegion*)​​Marc3["Wireframe"]
Out[]=
In[]:=
V=NDSolveValue[
(0,2)
p
[x,y]+
(2,0)
p
[x,y]0,​​PeriodicBoundaryCondition[p[x,y],x1200&&0<=y≤600,Function[x,x+{-1200,0}]],​​DirichletCondition[p[x,y]0,((yh)&&(0<x≤x1+0.5*w+dx))||((yh)&&(x1+1.5*w+dx<=x<2*w))||​​((yh-hc)&&(x1+0.5w+dx<=x<=x1+1.5w+dx))||​​xx1+0.5*w+dx&&(h-hc<y<h)||xx1+1.5*w+dx&&(h-hc<y<h)/.data],DirichletCondition[p[x,y]1,((y0)&&(0<x<2*w))||((yhc)&&(x1≤x≤x1+w))||​​((xx1)&&(0<y<hc))||((xx1+w)&&(0<y<hc))/.data],​​p,{x,y}∈
Marc3
](*Boundaryat0issettoboundaryat1200.Resultdiffersfromboundaryatx=1200issettoboundaryatx=0.*)
Out[]=
InterpolatingFunction
Domain: 0.,1.20×
3
10
,{0.,600.}
Output: scalar

In[]:=
ContourPlot[V[x,y],{x,y}∈Marc3,FrameLabel{x,y},PlotRangeFull,LabelStyle{FontFamily"Arial",FontSize14},PlotLegendsAutomatic,AspectRatioAutomatic,Contours9]
Out[]=
In[]:=
V=NDSolveValue[
(0,2)
p
[x,y]+
(2,0)
p
[x,y]0,​​PeriodicBoundaryCondition[p[x,y],x0,TranslationTransform[{1200,0}]],​​DirichletCondition[p[x,y]0,((yh)&&(0<x≤x1+0.5*w+dx))||((yh)&&(x1+1.5*w+dx<=x<2*w))||​​((yh-hc)&&(x1+0.5w+dx<=x<=x1+1.5w+dx))||​​xx1+0.5*w+dx&&(h-hc<y<h)||xx1+1.5*w+dx&&(h-hc<y<h)/.data],DirichletCondition[p[x,y]1,((y0)&&(0<x<2*w))||((yhc)&&(x1≤x≤x1+w))||​​((xx1)&&(0<y<hc))||((xx1+w)&&(0<y<hc))/.data],​​p,{x,y}∈
Marc3
]
Out[]=
InterpolatingFunction
Domain: 0.,1.20×
3
10
,{0.,600.}
Output: scalar

In[]:=
ContourPlot[V[x,y],{x,y}∈Marc3,FrameLabel{x,y},PlotRangeFull,LabelStyle{FontFamily"Arial",FontSize14},PlotLegendsAutomatic,AspectRatioAutomatic,Contours9]
Out[]=
In[]:=
V=NDSolveValue[
(0,2)
p
[x,y]+
(2,0)
p
[x,y]0,​​PeriodicBoundaryCondition[p[x,y],x0&&0<=y≤600,Function[x,x+{1200,0}]],​​DirichletCondition[p[x,y]0,((yh)&&(0<x≤x1+0.5*w+dx))||((yh)&&(x1+1.5*w+dx<=x<2*w))||​​((yh-hc)&&(x1+0.5w+dx<=x<=x1+1.5w+dx))||​​xx1+0.5*w+dx&&(h-hc<y<h)||xx1+1.5*w+dx&&(h-hc<y<h)/.data],DirichletCondition[p[x,y]1,((y0)&&(0<x<2*w))||((yhc)&&(x1≤x≤x1+w))||​​((xx1)&&(0<y<hc))||((xx1+w)&&(0<y<hc))/.data],​​p,{x,y}∈
Marc3
,MaxStepFraction->0.001]
Out[]=
InterpolatingFunction
Domain: 0.,1.20×
3
10
,{0.,600.}
Output: scalar

In[]:=
ContourPlot[V[x,y],{x,y}∈Marc3,FrameLabel{x,y},PlotRangeFull,LabelStyle{FontFamily"Arial",FontSize14},PlotLegendsAutomatic,AspectRatioAutomatic,Contours9]
Out[]=
In[]:=
sam=Evaluate[-
∂
x
V[x,y]/
∂
y
V[x,y]](*TheslopeforaconstantV.*)
Out[]=
-
InterpolatingFunction
Domain: 0.,1.20×
3
10
,{0.,600.}
Output: scalar
[x,y]
InterpolatingFunction
Domain: 0.,1.20×
3
10
,{0.,600.}
Output: scalar
[x,y]
In[]:=
Plot[{sam/.x0.001,sam/.x1200-0.001},{y,0,h/.data},AxesLabel{"y","
∂
x
V[x,y]"},PlotRangeFull,GridLinesAutomatic,LabelStyle{FontFamily"Arial",FontSize14},PlotLegends{"x = 0","x = 1200","diff"}]
Out[]=
x = 0
x = 1200
******************************************************************************
From Mathematica help file on Periodic Boundary Conditions
Looks good
****************************************************
Switch the repeated boundaries. Different answer from above and sample case below.
Example from NDSolve documentation - (version 12.1.1 )