Message Boards Message Boards

GROUPS:

Modifying Boundary Conditions of Working Code Gives Error

Posted 6 years ago
6203 Views
|
1 Reply
|
0 Total Likes
|

For a class I was asked to modify the boundary conditions of the given code. Here is the code.

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]
Needs["NDSolve`FEM`"]
length = 50; height = 5;
\[CapitalOmega] = 
  ImplicitRegion[True, {{x, 0, length}, {y, 0, height}}];
RegionPlot[\[CapitalOmega], AspectRatio -> 1/4] // Inactivate;
\[Alpha] = 1; uinf = 1; c = \[Alpha]/uinf;
cellmeasure = 1/10;
iorder = 2;
Tin = 30;
Tbot = 100;
Ttop = 30;
uvalue = NDSolveValue[{D[u[x, y], x] == c D[u[x, y], y, y], 
    u[0, y] == Tin, u[x, 0] == Tbot, u[x, height] == Ttop}, 
   u, {x, y} \[Element] \[CapitalOmega] , 
   Method -> {"PDEDiscretization" -> {"FiniteElement", 
       "MeshOptions" -> {"MaxCellMeasure" -> cellmeasure}, 
       "IntegrationOrder" -> iorder}}];
{meshu} = InterpolatingFunctionCoordinates[uvalue]
meshu["Wireframe"]
Export["meshu10.png", meshu["Wireframe"], ImageResolution -> 600]
conPlot = 
 Show[ContourPlot[uvalue[x, y], {x, y} \[Element] \[CapitalOmega], 
   ColorFunction -> "Temperature", Contours -> 25, 
   PlotLegends -> Automatic], AspectRatio -> 1/4]
Export["meshu10_cplot.png", conPlot, ImageResolution -> 600]
px01 = Plot[uvalue[x, height/5],
  {x, 0, length}, PlotRange -> All
  ]

So I need to modify the boundary condition so that the derivative of u with respect to y at y equals height is zero. Here is my edited code:

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]
Needs["NDSolve`FEM`"]
Needs["NumericalCalculus`"]
length = 50; height = 5;
\[CapitalOmega] = 
  ImplicitRegion[True, {{x, 0, length}, {y, 0, height}}];
RegionPlot[\[CapitalOmega], AspectRatio -> 1/4] // Inactivate;
\[Alpha] = 1; uinf = 1; c = \[Alpha]/uinf;
cellmeasure = 1/10;
iorder = 2;
Tin = 30;
Tbot = 100;
(*Ttop=30;*)
Qtop = 0;
uvalue = NDSolveValue[{
    D[u[x, y], x] == c D[u[x, y], y, y],
    u[0, y] == Tin,
    u[x, 0] == Tbot,
    (D[u[x, y], y] /. y -> height) == Qtop},
     u, {x, y} \[Element] \[CapitalOmega] , 
   Method -> {"PDEDiscretization" -> {"FiniteElement", 
       "MeshOptions" -> {"MaxCellMeasure" -> cellmeasure}, 
       "IntegrationOrder" -> iorder}}];
{meshu} = InterpolatingFunctionCoordinates[uvalue]
meshu["Wireframe"]
Export["meshu10.png", meshu["Wireframe"], ImageResolution -> 600]
conPlot = 
 Show[ContourPlot[uvalue[x, y], {x, y} \[Element] \[CapitalOmega], 
   ColorFunction -> "Temperature", Contours -> 25, 
   PlotLegends -> Automatic], AspectRatio -> 1/4]
Export["meshu10_cplot.png", conPlot, ImageResolution -> 600]
px01 = Plot[uvalue[x, height/5],
  {x, 0, length}, PlotRange -> All
  ]

Where did I go wrong?

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]
Needs["NDSolve`FEM`"] Needs["NumericalCalculus`"]
length = 50; height = 5;
\[CapitalOmega] = 
  ImplicitRegion[True, {{x, 0, length}, {y, 0, height}}];
RegionPlot[\[CapitalOmega], AspectRatio -> 1/4] // Inactivate;
\[Alpha] = 1; uinf = 1; c = \[Alpha]/uinf;
cellmeasure = 1/10;
iorder = 2;
Tin = 30;
Tbot = 100;
Ttop = 0;
uvalue = NDSolveValue[{D[u[x, y], x] == c D[u[x, y], y, y], 
    u[0, y] == Tin, u[x, 0] == Tbot, u[x, height] == Ttop}, 
   u, {x, y} \[Element] \[CapitalOmega], 
   Method -> {"PDEDiscretization" -> {"FiniteElement", 
       "MeshOptions" -> {"MaxCellMeasure" -> cellmeasure}, 
       "IntegrationOrder" -> iorder}}];
{meshu} = InterpolatingFunctionCoordinates[uvalue]
meshu["Wireframe"]
Export["meshu10.png", meshu["Wireframe"], ImageResolution -> 600]
conPlot = 
 Show[ContourPlot[uvalue[x, y], {x, y} \[Element] \[CapitalOmega], 
   ColorFunction -> "Temperature", Contours -> 25, 
   PlotLegends -> Automatic], AspectRatio -> 1/4]
Export["meshu10_cplot.png", conPlot, ImageResolution -> 600]
px01 = Plot[uvalue[x, height/5], {x, 0, length}, PlotRange -> All]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract