SetDirectory[$HomeDirectory<>"/Documents/handouts/math467/SolvingEllipticPDEs"]

Graphics[{EdgeForm[Black],FaceForm[],Disk[],PointSize[Large],Point[{{-1,0},{0,0},{1,0},{Cos[2π/3],Sin[2π/3]},{2/5,0},{3,0}}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["A", "TI"], TraditionalForm], "errors" -> {}, "input" -> "A", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{-1,0},{2,0}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["O", "TI"], TraditionalForm], "errors" -> {}, "input" -> "O", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{0,0},{0,3/2}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["B", "TI"], TraditionalForm], "errors" -> {}, "input" -> "B", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{1,0},{-2,3/2}],Line[{{-1,0},{3,0},{Cos[2π/3],Sin[2π/3]},{0,0}}],Line[{{Cos[2π/3],Sin[2π/3]},{2/5,0}}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["Q", "TI"], TraditionalForm], "errors" -> {}, "input" -> "Q", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{2/5,0},{0,3/2}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
SuperscriptBox[
StyleBox["Q", "TI"], "′"], TraditionalForm], "errors" -> {}, "input" -> "Q'", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{3,0},{-2,0}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["P", "TI"], TraditionalForm], "errors" -> {}, "input" -> "P", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{Cos[2π/3],Sin[2π/3]},{1,-1}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["R", "TI"], TraditionalForm], "errors" -> {}, "input" -> "R", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{Cos[2π/3],Sin[2π/3]}/2,{2,0}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["D", "TI"], TraditionalForm], "errors" -> {}, "input" -> "D", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{0,-3/4}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
RowBox[{"∂", 
StyleBox["D", "TI"]}], TraditionalForm], "errors" -> {}, "input" -> "\\partial D", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{1,-3/4}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["r", "TI"], TraditionalForm], "errors" -> {}, "input" -> "r", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",({Cos[2π/3],Sin[2π/3]}+{2/5,0})/2,{-2,-1/2}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
SuperscriptBox[
StyleBox["r", "TI"], "′"], TraditionalForm], "errors" -> {}, "input" -> "r'", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",({Cos[2π/3],Sin[2π/3]}+{3,0})/2,{0,-1}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox["ρ", TraditionalForm], "errors" -> {}, "input" -> "\\rho", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{1/5,0},{0,1/2}]},BaseStyle->FontSize->16]

Export["diskD.pdf",%,"PDF"]

Export["diskD.eps",%%,"EPS"]

greenG[x_,y_,x0_,y0_]:=Log[(((x^2)+(y^2)+(x0^2)+(y0^2)-2(x x0+y y0)))/(((x^2)+(y^2))((x0^2)+(y0^2))-2(x x0+y y0)+1)]/(4π)

ContourPlot[greenG[1/2,0,x0,y0],{x0,-1.75,2.25},{y0,-2,2},FrameTicks->None,FrameLabel->{"\!\(\*TemplateBox[<|"boxes" -> FormBox["ξ", TraditionalForm], "errors" -> {}, "input" -> "\\xi", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)","\!\(\*TemplateBox[<|"boxes" -> FormBox["η", TraditionalForm], "errors" -> {}, "input" -> "\\eta", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)"},ContourShading->None,Contours->15,Epilog->{PointSize[Large],Point[{{1/2,0},{2,0}}],Thick,Circle[],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
RowBox[{"(", 
RowBox[{
StyleBox["x", "TI"], ",", 
StyleBox["y", "TI"]}], ")"}], TraditionalForm], "errors" -> {}, "input" -> "(x, y)", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{1/2,0},{0,1}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox["⊕", TraditionalForm], "errors" -> {}, "input" -> "\\oplus", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{1/2,0},{0,-1.25}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox["⊖", TraditionalForm], "errors" -> {}, "input" -> "\\ominus", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{2,0},{0,-1.25}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
SuperscriptBox[
StyleBox["Q", "TI"], "′"], TraditionalForm], "errors" -> {}, "input" -> "Q'", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{2,0},{0,1.25}],Text["\!\(\*TemplateBox[<|"boxes" -> FormBox[
RowBox[{"∂", 
StyleBox["D", "TI"]}], TraditionalForm], "errors" -> {}, "input" -> "\\partial D", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)",{-1.15,0}]},BaseStyle->FontSize->12]

Export["greensimage.pdf",%,"PDF"]

Export["greensimage.eps",%%,"EPS"]

nsoln=First[NDSolve[{Laplacian[u[x,y],{x,y}]==1,DirichletCondition[u[x,y]==Sin[ArcTan[x,y]],True]},u,{x,y}∈Disk[]]]

ContourPlot[u[x,y]/.nsoln,{x,-1,1},{y,-1,1},Contours->Range[-0.9,0.9,0.2],RegionFunction->Function[{x,y},(x^2)+(y^2)<=1],FrameLabel->{"\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["x", "TI"], TraditionalForm], "errors" -> {}, "input" -> "x", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)","\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["y", "TI"], TraditionalForm], "errors" -> {}, "input" -> "y", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)"},BaseStyle->FontSize->12,PerformanceGoal->"Quality",Epilog->{Map[Text[#[[3]],{0,#[[2]]},Background->White]&,Table[{0,y/.FindRoot[(v==u[0,y]/.nsoln),{y,0.5}],v},{v,-0.9,0.9,0.2}]]}]

Export["exampledisk.pdf",%,"PDF"]

Export["exampledisk.eps",%%,"EPS"]

nsoln=First[NDSolve[{Laplacian[u[x,y],{x,y}]+u[x,y]==Sqrt[(x^2)+(y^2)](1-Sqrt[(x^2)+(y^2)])Sin[ArcTan[x,y]],DirichletCondition[u[x,y]==0,(x^2)+(y^2)==1]},u,{x,y}∈Disk[]]]

ContourPlot[u[x,y]/.nsoln,{x,y}∈Disk[],FrameLabel->{"\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["x", "TI"], TraditionalForm], "errors" -> {}, "input" -> "x", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)","\!\(\*TemplateBox[<|"boxes" -> FormBox[
StyleBox["y", "TI"], TraditionalForm], "errors" -> {}, "input" -> "y", "state" -> "Boxes"|>,"TeXAssistantTemplate"]\)"},PlotTheme->"Monochrome",Contours->Range[-0.016,0.016,0.004],BaseStyle->FontSize->12,Epilog->{Circle[],Text[0,{-0.5,0},Background->White],Map[Text[#,{0,y/.FindRoot[u[0,y]==#/.nsoln,{y,0.9}]},Background->White]&,{-0.016,-0.008}],Map[Text[#,{0,y/.FindRoot[u[0,y]==#/.nsoln,{y,0.3}]},Background->White]&,{-0.012,-0.004}],Map[Text[#,{0,y/.FindRoot[u[0,y]==#/.nsoln,{y,-0.3}]},Background->White]&,{0.004,0.012}],Map[Text[#,{0,y/.FindRoot[u[0,y]==#/.nsoln,{y,-0.9}]},Background->White]&,{0.008,0.016}]}]

Export["membraneexample.pdf",%,"PDF"]

Export["membraneexample.eps",%%,"EPS"]