I have some trouble understanding the RegionPlot command. I have defined the following input


volume[R_, d_] := Pi R^2 d

atomNumber[R_, d_, n_] := 2*n*volume[R, d]

\[Gamma]Fn[x_] := 
 2/x^2 (1 - Exp[-x^2] (BesselI[0, x^2] + BesselI[1, x^2]))

\[Eta]Eval[\[Lambda]_, d_, R_, rc_, n_] := 
 UnitConvert[\[Lambda]*((atomNumber[R, d, n])^2/d^2) \[Gamma]Fn[
    R/(Sqrt[2] rc)] (1 - Exp[-d^2/(4*rc^2)])]

\[Del]Fn[\[Omega]_, m_] := 

coherence[\[Omega]_, d_, R_, rc_, \[Lambda]_, n_, T_, m_] := 
  4*\[Eta]Eval[\[Lambda], d, R, rc, n]*T*(\[Del]Fn[\[Omega], m])^2]

with units

Subscript[m, 0] = Quantity[1, "AtomicMassUnit"]
R = Quantity[3.6, "Micrometers"]
d = Quantity[0.25, "Millimeters"]
n = Quantity[176.2 * 10^(27), "Meters"^(-3)]
rc = Quantity[10^(-7), "Meters"]
\[Lambda] = Quantity[10^(-17), "Seconds"^(-1)]
T = Quantity[350, "Femtoseconds"]
m = Quantity[6, "AtomicMassUnit"]
\[Omega]Paper = Quantity[40, "Terahertz"]

I simply want to make a plot that

  • calculates the value of coherence for all tuples $(\lambda, r_c)$ within a certain range
  • compares that function value against a threshold that is $1$
  • colors all points for which this inequality is true

For that, I use the following RegionPlot command:

 Evaluate[coherence[\[Omega]Paper Quantity[40, "Terahertz"], 
    d Quantity[1/4, "Millimeters"], R Quantity[18/5, "Micrometers"], 
    rc, \[Lambda], n Quantity[1762*10^(26), "Meters"^(-3)], 
    T Quantity[350, "Femtoseconds"], 
    m Quantity[6, "AtomicMassUnit"]] < 1], {rc, 
  Quantity[10^-9, "Meters"], Quantity[10^-1, "Meters"]}, {\[Lambda], 
  Quantity[10^-10, ("Seconds")^-1], Quantity[10^-1, ("Seconds")^-1]}, 
 PlotPoints -> 75, MaxRecursion -> 3, PlotRange -> All]

However, the code doesn't even run and the notebook stops after a while. What is the issue with this code?

My thoughts:

  • the numbers are too small (I can't change the numbers -> are there alternative programs to plot?)
  • there is some issue with my Mathematica version
  • $\begingroup$ One problem is that your coherence function does not evaluate to a numerical quantity, so it cannot be compared to "1". $\endgroup$
    – bill s
    Apr 9, 2022 at 20:22
  • $\begingroup$ @bills But it does evaluate to a numerical quantity if I calculate it separately? $\endgroup$ Apr 25, 2022 at 7:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.