I’m having a hard time eliminating some moiré-like artifacts from the 3D output of ListDensityPlot3D
.
Here is an example:
n = 1.5;
ρCore = 166;
bdElectronDensityConversion = 5.25*^23*ρCore;
ξCore = $MachineEpsilon;
R = 8.26*^9*Quantity["cm"];
M = 0.04*Quantity["SolarMass"];
K = (M^(1/3)*R*Quantity["GravitationalConstant"])/2.3573;
a = Sqrt[((n + 1)*(K*(ρCore*Quantity["g/cc"])^((1 - n)/n)))
/(4*Pi*Quantity["GravitationalConstant"])];
ξRadius = (QuantityMagnitude[UnitConvert[R]]
/QuantityMagnitude[UnitConvert[a]]);
system = {Dt[ξ^2*Derivative[1][θ][ξ], {ξ}]/ξ^2 == -θ[ξ]^n,
θ[ξCore] == 1,
Derivative[1][θ][ξCore] == 0};
sol = NDSolve[system, θ, {ξ, ξCore, ξRadius}][[1]];
Rkm = QuantityMagnitude@UnitConvert[R, "km"];
Show[DensityPlot3D[
(bdElectronDensityConversion*θ[Sqrt[(x*ξRadius/Rkm)^2
+ (y*ξRadius/Rkm)^2 + (z*ξRadius/Rkm)^2]]^n /. sol),
{x, y, z} ∈ RegionDifference[
Ball[{0, 0, 0}, Rkm], Cuboid[{0, -Rkm, 0}, {Rkm, Rkm, Rkm}]],
PerformanceGoal -> "Quality", PlotPoints -> 100,
OpacityFunction -> None,
ColorFunction -> ColorData[{"SolarColors", {1*^25, 8*^25}}],
ColorFunctionScaling -> False], ImageSize -> Large]
When I run this code, I see this:
Sadly, moiré artifacts run throughout the cutaway faces of the ball, giving the false impression that a non-spherically-symmetric structure exists in the solution. This could mislead anyone hoping to interpret the plot!
I’d greatly appreciate any advice on eliminating these artifacts. I’ve tried increasing PlotPoints
, to no avail.
Thanks!
ListDensityPlot
if you're only going to show a cutaway? You can speed this plot by orders of magnitude by just plotting on the sphere surface and cutting planes. $\endgroup$PlotPoints
to 100 in the example, since this still exhibits the moiré artifacts. It takes about 1 min 40 s to run on my machine. $\endgroup$ListDensityPlot3D
displaying data, which exhibits the same moiré artifacts. If you know of a comparable workaround for that case, however, it could be very helpful indeed. $\endgroup$