Message Boards Message Boards

Avoid the following density plot artifacts?

GROUPS:

Please run the attached code. The density plot has some artifacts on it (The light blue parts around the circle) Is there a way to resolve this issue. The density plot is showing velocity of a liquid passing through the channel. Regards.

[CapitalOmega] = ImplicitRegion[ 0 <= x <= 2.0 && 0 <= y <= 0.48208 && ! (x >= 1.0 && y <= 0.19) && ! (x >= 1.0 && y >= 0.31) && ! ((x - 0.76)^2 + (y - 0.24104)^2 <= 0.238125^2), {x, y}]; RegionPlot[[CapitalOmega], AspectRatio -> Automatic, ImageSize -> 300] stokesFlowOperator = {Div[({{-1, 0}, {0, -1}}.Grad[ u[x, y], {x, y}]), {x, y}] + \!(*SuperscriptBox[(w), TagBox[ RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}], Derivative], MultilineFunction->None])[x, y], Div[({{-1, 0}, {0, -1}}.Grad[v[x, y], {x, y}]), {x, y}] + \!(*SuperscriptBox[(w), TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction->None])[x, y],

\!(*SuperscriptBox[(v), TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction->None])[x, y] + \!(*SuperscriptBox[(u), TagBox[ RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}], Derivative], MultilineFunction->None])[x, y]}; Subscript[[CapitalGamma], D] = {DirichletCondition[{u[x, y] == -1, v[x, y] == 0}, x == 0.], DirichletCondition[{u[x, y] == 1., v[x, y] == 0}, 0 < x < 2.0], DirichletCondition[w[x, y] == 0.1, x == 2.0]}; {xVel, yVel, pressure} = NDSolveValue[{stokesFlowOperator == {0, 0, 0}, Subscript[[CapitalGamma], D]}, {u, v, w}, {x, y} [Element] [CapitalOmega], Method -> {"FiniteElement", "InterpolationOrder" -> {u -> 2, v -> 2, w -> 1}}]; rmf = RegionMember[[CapitalOmega]]; Show[BoundaryDiscretizeRegion[[CapitalOmega]], DensityPlot[{xVel[x, y], yVel[x, y]}, {x, 0, 2.0}, {y, 0, 0.48208}, RegionFunction -> Function[{x, y}, rmf[{x, y}]], AspectRatio -> Automatic, PlotLegends -> Automatic, ColorFunction -> ColorData["BlueGreenYellow"], PlotPoints -> 20], ImageSize -> 1000]

Attachments:
POSTED BY: cmutlu
Answer
12 days ago

You can set PlotRange -> All in the density plot, but that will flatten most of the picture. It is like taking a photograph of a scene which is low-lit except for a very bright detail. You may try rescaling the ColorFunction, like this:

DensityPlot[{xVel[x, y], yVel[x, y]}, {x, 0, 2.0}, {y, 0, 0.48208}, 
 RegionFunction -> Function[{x, y}, rmf[{x, y}]], 
 AspectRatio -> Automatic, PlotLegends -> Automatic, 
 ColorFunction -> 
  Function[z, 
   ColorData["BlueGreenYellow"][Rescale[ArcTan[z/5], Pi/2 {-1, 1}]]], 
 PlotPoints -> 40, PlotRange -> All, ColorFunctionScaling -> False]
POSTED BY: Gianluca Gorni
Answer
12 days ago

The artifacts are probably due to clipping. Compare:

Plot3D[{xVel[x, y], yVel[x, y]}, {x, 0, 2.0}, {y, 0, 0.48208}, 
 RegionFunction -> Function[{x, y}, rmf[{x, y}]], 
 AspectRatio -> Automatic, PlotLegends -> Automatic, 
 ColorFunction -> ColorData["BlueGreenYellow"], PlotPoints -> 40, 
 PlotRange -> All]
Plot3D[{xVel[x, y], yVel[x, y]}, {x, 0, 2.0}, {y, 0, 0.48208}, 
 RegionFunction -> Function[{x, y}, rmf[{x, y}]], 
 AspectRatio -> Automatic, PlotLegends -> Automatic, 
 ColorFunction -> ColorData["BlueGreenYellow"], PlotPoints -> 40]

You may try a rescaling of your velocity field to help visualization.

POSTED BY: Gianluca Gorni
Answer
12 days ago

You are using DensityPlot with two functions. This is not documented, and I don't know what gets plotted this way. If what you are trying to plot is the scalar velocity field, you may try this:

DensityPlot[
 Norm@{xVel[x, y], yVel[x, y]}, {x, 0, 2.0}, {y, 0, 0.48208}, 
 RegionFunction -> Function[{x, y}, rmf[{x, y}]], 
 AspectRatio -> Automatic, PlotLegends -> Automatic, 
 ColorFunction -> 
  Function[z, 
   ColorData["BlueGreenYellow"][Rescale[ArcTan[z/2], Pi/2 {-1, 1}]]], 
 PlotPoints -> 80, PlotRange -> All, ColorFunctionScaling -> False]

The ArcTan[z/2] part is meant to somehow equalize the wild variations in the velocity field. Changing the parameters, for example with ArcTan[z/5] will move the focus to slightly higher velocity ranges. You may want to experiment with that. A Plot3D may help visualization too.

POSTED BY: Gianluca Gorni
Answer
9 days ago

Thanks for helping. What is the first thing to carry out which will be a remedy for this. So does the 3D plots show the function is actually calculated at the points where artifacts appear so should I infer that those regions are not properly displayed by the density plot?

POSTED BY: cmutlu
Answer
12 days ago

Your code works. Thanks!

POSTED BY: cmutlu
Answer
11 days ago

May you please check the following word file? I marked 3 different regions on the graph. The density plot shows the velocity of the liquid Passing through the region. Region 1 shows high velocity values. Region 2 shows almost 0 velocity value within a relatively similar channel width of region 1 and then Region 3 shows moderate velocity values due to channel width becoming wider. While regions 1 and 3 are consistent. Region 2 seems to display an irrelevant velocity which is not in agreement with the Regions 1 and 3. Do you have an explanation for this? I have also attached the Mathematica Code. Regards.

Attachments:
POSTED BY: cmutlu
Answer
10 days ago

Thanks and Best regards

POSTED BY: cmutlu
Answer
9 days ago

Hi Gianluca, May you please check the following file, inquiry 2 and let me know. I calculated magnitude of velocity at different points within the channel at the right side and found that the velocities at the boundary of the channel (Region 2) is greater than in the middle (Region 1). However it is expected to have a lower velocity at the boundary (Region 2) than at the middle (Region 1). Do you have an explanation for this? Also the channel on the left side (Region 3) displays the right velocities. Lower at the boundary and higher in the middle. Furthermore Region 4, 5 and 6 is unexpectedly displaying almost 0 velocity after a relatively large flow velocities. Please send help regarding this issue. Regards.

Attachments:
POSTED BY: cmutlu
Answer
4 days ago

Hi Gianluca, May you please check the following file, inquiry 2 and let me know. I calculated magnitude of velocity at different points within the channel at the right side and found that the velocities at the boundary of the channel (Region 2) is greater than in the middle (Region 1). However it is expected to have a lower velocity at the boundary (Region 2) than at the middle (Region 1). Do you have an explanation for this? Also the channel on the left side (Region 3) displays the right velocities. Lower at the boundary and higher in the middle. Furthermore Region 4, 5 and 6 is unexpectedly displaying almost 0 velocity after a relatively large flow velocities. Please send help regarding this issue. Regards.

Attachments:
POSTED BY: cmutlu
Answer
4 days ago

Hi Gianluca, May you please check the following file, inquiry 2 and let me know. I calculated magnitude of velocity at different points within the channel at the right side and found that the velocities at the boundary of the channel (Region 2) is greater than in the middle (Region 1). However it is expected to have a lower velocity at the boundary (Region 2) than at the middle (Region 1). Do you have an explanation for this? Also the channel on the left side (Region 3) displays the right velocities. Lower at the boundary and higher in the middle. Furthermore Region 4, 5 and 6 is unexpectedly displaying almost 0 velocity after a relatively large flow velocities. Please send help regarding this issue. Regards.

Attachments:
POSTED BY: cmutlu
Answer
4 days ago

The result seems a bit unintuitive to me too, but I have no expertise in fluid mechanics, where intuition fails a lot.

POSTED BY: Gianluca Gorni
Answer
4 days ago

Group Abstract Group Abstract