2
$\begingroup$

I'm plotting a two dimensional von Mises and Tresca yield surface and got:

ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2, 
  sr == 1, st == 1, sr == -1, st == -1}, {sr, -2, 2}, {st, -2, 2}]

enter image description here

I need to cut the lines that are crossing the smooth surface. So I tried:

piece = Piecewise[{{st == 1, 0 <= sr <= 1}, {sr == 1, 
    0 <= st <= 1}, {st == 1, -1 <= sr <= 0}, {sr == 1, -1 <= st <= 0}}]
ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2, 
  piece}, {sr, -2, 2}, {st, -2, 2}]

enter image description here

What's the issue here?

$\endgroup$
1
  • 1
    $\begingroup$ Perhaps its that the theory underlying ContourPlot assumes the function is continuous. $\endgroup$ – Michael E2 Sep 29 '17 at 1:10
1
$\begingroup$

maybe this is what you are after?

ContourPlot[{
  Max[Abs[x - y], Abs[x], Abs[y]] == 1,
  Sqrt[x^2 - x y + y^2] == 1
  }, {x, -2, 2}, {y, -2, 2}, 
    PlotPoints -> 100]

enter image description here

$\endgroup$
3
$\begingroup$

The problem arises because Piecewise is evaluated sequentually. FullSimplify shows, you get False.

FullSimplify[piece]

enter image description here

You better work with Exclusions in ContourPlot

ContourPlot[{Sqrt[sr^2 - sr st + st^2] == 1, Abs[(sr - st)/2] == 1/2, 
   sr == 1, st == 1, sr == -1, st == -1}, {sr, -2, 2}, {st, -2, 2}, 
    Exclusions -> {{sr == 1, Sqrt[sr^2 - sr st + st^2] <= 1}, {sr == -1, 
    Sqrt[sr^2 - sr st + st^2] <= 1}, {st == 1, 
    Sqrt[sr^2 - sr st + st^2] <= 1}, {st == -1, 
    Sqrt[sr^2 - sr st + st^2] <= 1}}]

enter image description here

You can play with PlotPoints and MaxRecursion to fill the gaps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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