5
$\begingroup$

I have the following code:

Subscript[a, 0] = 3.88/10^14; 
G = 6.67384/10^20; 
solarMass = 1.9891*10^30; 
massFunction[velocity_, radius_] := If[velocity^2 < Subscript[a, 0]*radius, 0, ((velocity^2 - Subscript[a, 0]*radius)*radius)/(G*solarMass)]; 
fundamentalPlane = Plot3D[massFunction[v, r], {v, 50, 700}, {r, 0, 1*10^19}, AxesLabel -> {Style["velocity", FontSize -> 14], Style["radius", FontSize -> 14], Null}, ImageSize -> Large]; 
maximumMass = Graphics3D[Point[Table[{v, v^2/(2*Subscript[a, 0]), 49*v^4}, {v, 50, 700}]]]; 
Show[fundamentalPlane, maximumMass]

In Mathematica 10.3, it produced this graph:

enter image description here

In Mathematica 12, it produces this graph (I haven't changed the code):

enter image description here

The problem appears to be the 'If' statement. I'm using the conditional function to crop out values that are not physical (such as negative mass). What am I doing wrong and is there a better, more supportable way of removing values from a 3D plot that are not part of the solution domain?

$\endgroup$
7
  • $\begingroup$ In 12.1 Windows10, simply adding PlotPoints->10 causes Mathematica to hang. It does complete though with an undesirable result. $\endgroup$
    – flinty
    Jun 7, 2020 at 13:22
  • $\begingroup$ It's not specific to theIf statement - you can replace it with a UnitStep and product but it's still bad: UnitStep[velocity^2 - Subscript[a,0]*radius]*((velocity^2 - Subscript[a,0]*radius)*radius)/(G*solarMass) $\endgroup$
    – flinty
    Jun 7, 2020 at 13:33
  • 2
    $\begingroup$ You can use PlotRange -> {0, Automatic} if you want to crop out negative values and this looks much better. But still it doesn't explain the regression in Plot3D behaviour. There's nothing wrong with your code in my opinion, as this looks correct: ListPointPlot3D[Flatten[Table[{v, r, massFunction[v, r]}, {v, 50, 700, 10}, {r, 0, 1*10^19, 10^17}], 1]] so I'm guessing Plot3D changed how it handled large plot ranges in v11 or 12. $\endgroup$
    – flinty
    Jun 7, 2020 at 13:46
  • $\begingroup$ @flinty - The PlotRange appears to have done the trick. I don't know if there's a more elegant way of doing this using domains, but if you'd like to post this as an answer, I'll up-vote it. $\endgroup$
    – Quark Soup
    Jun 7, 2020 at 14:11
  • $\begingroup$ I think an answer should also explain why the Plot3D plot range behaviour has changed and I don't know this. I'd prefer if somebody with deeper knowledge would answer it. $\endgroup$
    – flinty
    Jun 7, 2020 at 14:13

1 Answer 1

4
$\begingroup$

Specify Exclusions -> None:

Plot3D[massFunction[v, r], {v, 50, 700}, {r, 0, 1*10^19}, 
 AxesLabel -> {Style["velocity", FontSize -> 14], 
   Style["radius", FontSize -> 14], Null}, Exclusions -> None]

enter image description here

Exclusion processing has been made more robust over time. It seems overeager in this case.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.