I am trying to modify some code of mine to change where the final evaluation of a function is performed, as a way to not generate massive tables of data. The code is working fine, until I have started to try make this change.
I have a compiled function
EOutCompiled =
Compile[{{r, _Real}, {\[Phi], _Real}, {z, _Real}, {\[Lambda], \
_Real}, {radius, _Real}, {n1, _Real}, {n2, _Real}, {khat, _Integer}, \
{pol, _Integer}, {l, _Integer}, {m, _Integer}, {P, _Real}, \
{\[Epsilon]0, _Real}, {\[Beta], _Real}},
EFieldOut[r, \[Phi], z, \[Lambda], radius, n1, n2, khat, pol, l, m,
P, \[Epsilon]0, \[Beta]], {{EFieldOut[_, _, _, _, _, _, _, _, _, \
_, _, _, _, _], _Complex, 1}}, CompilationTarget -> "C",
RuntimeAttributes -> {Listable},
CompilationOptions -> {"InlineExternalDefinitions" -> True},
RuntimeOptions -> "Speed"];
That evaluates correctly when calling
In:= EOutCompiled[1000 10^-9,
ArcTan[1000 10^-9,0],0,\[Lambda],radius,n1,n2,khat,pol,l1,m1,P1,\[Epsilon]0,\[Beta]]
Out:= {0. + 0.0087877 I, -0.00662499 + 0. I, 0.00610164 + 0. I}
However when I try and use the ReplaceAll
such as in DensityPlot
as follows
DensityPlot[ Norm[EOutCompiled[r,\[Phi],0,\[Lambda],radius,n1,n2,khat,pol,l1,m1,P1,\[Epsilon]0,\[Beta]]]
/. {r -> (x^2 + y^2)^(1/2),\[Phi]->ArcTan[x, y],z ->0},{y, xmin, xmax}, {x, xmin, xmax},
PlotRange -> Full, ColorFunction -> CoolToWarm,
ColorFunctionScaling -> True, Epilog -> Circle[{0, 0}, radius],
PlotPoints -> 100]
The function only returns Null
for every single evaluation despite the values I input being identical