1
$\begingroup$

I am using a manipulate on a ContourPlot and a NSolve, the code is the following

BRfunction[MUU_, Mss_, AU_, As_, AUs_] := 
  1.84692*10^8 (((0.000249253 - 0.0893089 Mss^2 + 15 Mss^4) As)/(4 Mss^8) + 
    (0.198094 (-0.0334908 + 10 Mss^2) AUs)/(Mss^4 MUU^2) + (0.392411 AU)/MUU^4)

Manipulate[
  Column[
    ContourPlot[
      BRfunction[MUU, MYy, AU, As, AUs] == 10^-8, 
      {MUU, 1000, 30000}, 
      {MYy, 1000, 30000}, 
      FrameLabel -> {"MUU", "Mss"}, 
      MaxRecursion -> 6],
    NSolve[
      VU1x1^2*(VU1x2^2 + VU2x1^2) == AU && 
      Oss1x1^2*(Oss1x2^2 + Oss2x1^2) == As && 
      VU1x1*Oss1x1*(VU1x2*Oss1x2 + VU2x1*Oss2x1) == AUs && 
      VU1x1 < 1 && VU1x1 > -1 && VU1x2 < 1 && VU1x2 > -1 && 
      VU2x1 < 1 && VU2x1 > -1 &&
      Oss1x1 < 1 && Oss1x1 > -1 && Oss1x2 < 1 && Oss1x2 > -1 && 
      Oss2x1 < 1 && Oss2x1 > -1, 
      {VU1x1, VU1x2, VU2x1, Oss1x1, Oss1x2, Oss2x1}]], 
  {AU, 0, 0.5}, 
  {As, 0, 2}, 
  {AUs, -1, 1}]

The problem is that the conditions within NSolve not always have a solution and result in errors. Because of this (I think) something superposed and unreadable appears in the output box as appears below.

enter image description here

If I run both commands in separate Manipulates the ContourPlot comes out perfectly and the NSolve works as it is supposed to. How can the same be done inside a single manipulate?

$\endgroup$
4
  • 1
    $\begingroup$ Can you provide a screenshot of the issue? Or better yet, the full code required to reproduce the issue? $\endgroup$ – Lukas Lang Sep 16 '20 at 21:24
  • $\begingroup$ @LukasLang Thank you for your suggestion! I have updated the question accordingly. $\endgroup$ – GaloisFan Sep 17 '20 at 10:45
  • $\begingroup$ Your code makes no sense. It has the form: Manipulate[Column[ ContourPlot[...], NSolve[...]], ... ] . Column should have the form: Column[{content1, content2,..}, options]. NSolve[..] returns replacement rules, but there is nothing to replace. $\endgroup$ – Daniel Huber Sep 17 '20 at 18:07
  • $\begingroup$ @DanielHuber Thank you for pointing out the syntax error (missing brackets). This should solve the problem if I keep using NSolve. $\endgroup$ – GaloisFan Sep 17 '20 at 18:22
1
$\begingroup$

Because your equations seem to mostly have no solution or an infinite number of solutions, I think FindInstance will work better in your situation than NSolve. So you might try

BRfunction[MUU_, Mss_, AU_, As_, AUs_] := 
  1.84692*10^8 (((0.000249253 - 0.0893089 Mss^2 + 
    15 Mss^4) As)/(4 Mss^8) + 
    (0.198094 (-0.0334908 + 10 Mss^2) AUs)/(Mss^4 MUU^2) + 
    (0.392411 AU)/MUU^4)

Manipulate[
  Column[
    {ContourPlot[
       BRfunction[MUU, MYy, AU, As, AUs] == 10^-8, {MUU, 1000, 30000}, {MYy, 1000, 30000},
       FrameLabel -> {"MUU", "Mss"},
       MaxRecursion -> 6,
       ImageSize -> Medium],
     FindInstance[
       VU1x1^2*(VU1x2^2 + VU2x1^2) == AU &&
       Oss1x1^2*(Oss1x2^2 + Oss2x1^2) == As && 
       VU1x1*Oss1x1*(VU1x2*Oss1x2 + VU2x1*Oss2x1) == AUs &&
       -1 < VU1x1 < 1 && -1 < VU1x2 < 1 && -1 < VU2x1 < 1 &&
       -1 < Oss1x1 < 1 && -1 < Oss1x2 < 1 && -1 < Oss2x1 < 1,
      {VU1x1, VU1x2, VU2x1, Oss1x1, Oss1x2, Oss2x1},
      Reals]}],
  {AU, 0, 1/2, 1/20, Appearance -> "Labeled"},
  {As, 0, 2, 1/20, Appearance -> "Labeled"},
  {AUs, -1, 1, 1/20, Appearance -> "Labeled"}]

manip

$\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.