5

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?

Quark Soup
  • 1,610
  • 9
  • 14
  • In 12.1 Windows10, simply adding PlotPoints->10 causes Mathematica to hang. It does complete though with an undesirable result. – flinty Jun 07 '20 at 13:22
  • 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) – flinty Jun 07 '20 at 13:33
  • 2
    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. – flinty Jun 07 '20 at 13:46
  • @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. – Quark Soup Jun 07 '20 at 14:11
  • 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. – flinty Jun 07 '20 at 14:13
  • I don't know if I'd call this a bug, but it is at least a [tag:backslide]. I'd consider reporting it to WRI support. They might be able to fix it. – Michael E2 Jun 07 '20 at 20:31

1 Answers1

4

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.

Michael E2
  • 235,386
  • 17
  • 334
  • 747