0
$\begingroup$

I have the following long function

j = (64 g1^2 g2^2 (0.5 + n2) Sqrt[κ2^2])/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (16 g1^2 (0.5 + n1) Sqrt[κ1^2] (κ2^2 + 4 ω^2))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (4 (0.5 + nm) Γ (16 g2^4 + 8 g2^2 (κ1 κ2 - 4 ω^2) + (κ1^2 + 4 ω^2) (κ2^2 + 4 ω^2)))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2)))

I wish to integrate j numerically:

intj = Table[{g1, g2, 1/(2 π)*NIntegrate[Evaluate[j /. {nm -> 300, n1 -> 1/10, n2 -> 1/10, Γ -> 1/100, κ1 -> 1, κ2 -> 20}], {ω, -150, 150}]}, {g1, 0, 40}, {g2, 0, 30}];

And doing a density plot with x = g1, y = g2 and z = "the integral":

dj = ListDensityPlot[Flatten[intj, 1], PlotRange -> All, ScalingFunctions -> {"Log", "Log", "Log"}, PlotLegends -> Automatic, ColorFunction -> "SunsetColors", PlotRangePadding -> None, FrameTicksStyle -> Directive[Thick, Black]]    

I am returned with

enter image description here

Notice that my plot range for x and y starts from zero but given that I've Log-ed all the axes, the x and y axes both starts at 1 on the density plot. I presume this is because Mathematica can't take the Log of zero. It is crucial for me to show the density at the origin. How should I go about doing this in a proper way?

Edit: I've tried starting g1 and g2 from 0.01 instead of 0 but the default step size is 1 so doing this shows an inhomogeneous disconnect in density colors going from 0.01 to 1. Increasing the step size to 0.01 becomes intractably long for my computer since it is a Table with two-loops and the process is computationally expensive. How should I go about doing this?

$\endgroup$
  • $\begingroup$ Since you're using ListDensityPlot, I like to do something like: table1 = Flatten[Table[{10^g1, 10^g2, func[10^g1,10^g2]}, {g1, 0, 2}, {g2, 0, 2}],1] And then for your 0 points you'd do Join[Table[{0, 10^g2, func[10^g1,10^g2]}, {g2, 0, 2}], table1] ... join another table for g2, then overwrite your tick labels, and don't use log scaling $\endgroup$ – Eric William Smith Nov 13 '18 at 19:38
  • $\begingroup$ @EricWilliamSmith Could you show me a working example of what you're saying? $\endgroup$ – kowalski Nov 13 '18 at 19:40
  • $\begingroup$ @EricWilliamSmith Edit: Tried what you were saying but I don't know why you're joining the table with just g2 with table1 that has g1 and g2. I am unable to replicate what you said. Could you elaborate? $\endgroup$ – kowalski Nov 13 '18 at 19:57
1
$\begingroup$
j = (64 g1^2 g2^2 (0.5 + n2) Sqrt[κ2^2])/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (16 g1^2 (1/2 + n1) Sqrt[κ1^2] (κ2^2 + 4 ω^2))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2))) + (4 (1/2 + nm) Γ (16 g2^4 + 8 g2^2 (κ1 κ2 - 4 ω^2) + (κ1^2 + 4 ω^2) (κ2^2 + 4 ω^2)))/(16 g2^4 (Γ^2 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (Γ κ1 - 4 ω^2) + (Γ^2 + 4 ω^2) (κ1^2 + 4 ω^2)) + 8 g2^2 ((κ1 κ2 - 4 ω^2) (Γ^2 + 4 ω^2) + 4 g1^2 (Γ κ2 + 4 ω^2)));
intj1 = Table[{g1, g2, 
     1/(2 π)*
      NIntegrate[
       Evaluate[
        j /. {nm -> 300, n1 -> 1/10, 
          n2 -> 1/10, Γ -> 1/100, κ1 -> 
           1, κ2 -> 20}], {ω, -150, 150}]}, {g1, 1/100, 
     4, 1/10}, {g2, 1/100, 3, 1/10}]; // Quiet

intj2 = Table[{g1, g2, 
     1/(2 π)*
      NIntegrate[
       Evaluate[
        j /. {nm -> 300, n1 -> 1/10, 
          n2 -> 1/10, Γ -> 1/100, κ1 -> 
           1, κ2 -> 20}], {ω, -150, 150}]}, {g1, 4, 40, 
     1}, {g2, 3, 30, 1}]; // Quiet
intj12 = Table[{g1, g2, 
     1/(2 π)*
      NIntegrate[
       Evaluate[
        j /. {nm -> 300, n1 -> 1/10, 

          n2 -> 1/10, Γ -> 1/100, κ1 -> 
           1, κ2 -> 20}], {ω, -150, 150}]}, {g1, 1/100, 
     4, 1/10}, {g2, 3, 30, 1}]; // Quiet
intj21 = Table[{g1, g2, 
     1/(2 π)*
      NIntegrate[
       Evaluate[
        j /. {nm -> 300, n1 -> 1/10, 
          n2 -> 1/10, Γ -> 1/100, κ1 -> 
           1, κ2 -> 20}], {ω, -150, 150}]}, {g1, 4, 40, 
     1}, {g2, 1/100, 3, 1/10}]; // Quiet

ListDensityPlot[Flatten[Join[intj1, intj2, intj12, intj21], 1], 
 PlotRange -> All, ScalingFunctions -> {"Log", "Log", "Log"}, 
 PlotLegends -> Automatic, ColorFunction -> "SunsetColors", 
 PlotRangePadding -> None, FrameTicksStyle -> Directive[Thick, Black]]

fig1

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