# Why RegionPlot does not work in this example?

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

Clear["Global*"]

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_] :=
UnitConvert[Sqrt[Quantity["ReducedPlanckConstant"]/(\[Omega]*m)]]

coherence[\[Omega]_, d_, R_, rc_, \[Lambda]_, n_, T_, m_] :=
UnitConvert[
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:

RegionPlot[
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
• One problem is that your coherence function does not evaluate to a numerical quantity, so it cannot be compared to "1". Commented Apr 9, 2022 at 20:22
• @bills But it does evaluate to a numerical quantity if I calculate it separately? Commented Apr 25, 2022 at 7:01