0
$\begingroup$

I have a function f that is dependent on three parameters ω, κ2 and x:

f[ω_, κ2_, 
x_] := (384000.` x κ2 Sqrt[κ2^2])/(1600000000 x^2 \
κ2^2 (1/100000000 + 4 ω^2) + (κ2^2 + 
    4 ω^2) (16 + 
    8 (1/10000 - 4 ω^2) + (1/100000000 + 
       4 ω^2) (1 + 4 ω^2)) + 
 80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 + 
       4 ω^2) + 
    4 (κ2/10000 + 4 ω^2))) + (9.6` (κ2^2 + 
   4 ω^2))/(1600000000 x^2 κ2^2 (1/100000000 + 
    4 ω^2) + (κ2^2 + 4 ω^2) (16 + 
    8 (1/10000 - 4 ω^2) + (1/100000000 + 
       4 ω^2) (1 + 4 ω^2)) + 
 80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 + 
       4 ω^2) + 
    4 (κ2/10000 + 
       4 ω^2))) + (0.0122` (1600000000 x^2 κ2^2 + 
   80000 x κ2 (κ2 - 4 ω^2) + (1 + 
      4 ω^2) (κ2^2 + 
      4 ω^2)))/(1600000000 x^2 κ2^2 (1/100000000 + 
    4 ω^2) + (κ2^2 + 4 ω^2) (16 + 
    8 (1/10000 - 4 ω^2) + (1/100000000 + 
       4 ω^2) (1 + 4 ω^2)) + 
 80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 + 
       4 ω^2) + 4 (κ2/10000 + 4 ω^2)))

As you can see, the function is long but nonetheless dependent on those three paramters (I apologize if the symbols are hard to see, I copied and replaced the raw symbols with unicode glyphs from the add-on).

Now I intend to plot a density plot with the x-axis as κ2, y-axis as x, and the z-axis as the Difference in the maxima of the function at each κ2 and x value as a function of ω. I tried really hard to do all of this in one line through a double loop (because my computer has a hard time allocating memory). My attempt is of the following:

ωarr = 
Table[{i, j, 
Max[ω /. 
   NSolve[(D[f[ω, i, j], ω]) == 0 && 
     D[f[ω, i, j], {ω, 2}] < 0, Reals]] - 
 Min[ω /. 
   NSolve[(D[f[ω, i, j], ω]) == 0 && 
     D[f[ω, i, j], {ω, 2}] < 0, Reals]]}, {i, 0, 
100, 1}, {j, 0, 10^-3, 10^-4}];

From what I can tell, the code works and it spits out a really long nested list, each containing three elements: {i, j, maxima difference} - That's my x, y and z coordinate right there. I proceed to plot a density plot like so:

ListDensityPlot[ωarr]

But nothing comes out on the plot. I feel like I'm missing out on something trivial (I apologize since I'm a new user). I could really use any help that I can get.

Thank you in advance!

$\endgroup$
1
$\begingroup$

The dimensions of ωarr are wrong. You perhaps want to Flatten[ωarr,1].

ωarr // Dimensions

gives {101,11,3} while ListDensityPlot expects {1111,3}.

$\endgroup$
  • $\begingroup$ I checked my dimensions for j and indeed it was of length 11 whereas my index i is of length 101. I corrected this by changing the increments of the index j from 10^-4 to 10^-5 (you can check that the length of both i and j are now the same). I then did ListDensityPlot[Flatten[[Omega]arr]] which gave me some density plot, however it has plenty of white spaces. Shouldn't the regions with a maxima difference of 0 gives a blue contour? Where are the white spaces coming from? $\endgroup$ – kowalski Mar 2 '18 at 9:17
  • $\begingroup$ Length of i and j do not need to be the same, but the dataset has to have 2 dimensions instead of 3. About the whitespace you should ask a new question after you have checked for existing answers in other topics. $\endgroup$ – Johu Mar 2 '18 at 9:31
  • $\begingroup$ I think the whitespaces are there due to your definition of f and not due to plotting. $\endgroup$ – Johu Mar 2 '18 at 9:32
  • $\begingroup$ I meant f actually gives you 0 for many values. $\endgroup$ – Johu Mar 2 '18 at 9:40
  • $\begingroup$ you must Flatten[ warr , 1] The one here is important so that you just flatten by one list level. $\endgroup$ – george2079 Mar 2 '18 at 14:36

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.