I am trying to plot an integral that is in spherical coordinates, but I am a bit lost. I think that my only issue is converting to cartesian, everything I have seen on how to do this has gone a bit over my head. Here is my code (sorry about the formatting):
$$ \vec{E}=\sigma k \int_0^R\int_0^{2\pi}[\frac{(r\sin\theta\cos\phi-r'\cos\phi')\textbf{i} +(r\sin\theta\sin\phi-r'\sin\phi')\textbf{j}+(r\cos\theta)\textbf{k}}{(r^2+r'^2-2rr'\cos\phi\cos\phi'\sin\theta-2rr'\sin\theta\sin\phi\sin\phi')^{3/2}}]r'd\phi'dr' $$
\[ScriptR][ϕ_, r_, θ_, ϕ1_,
r1_] := {r*Sin[θ]*Cos[ϕ] - r1*Cos[ϕ1],
r*Sin[θ]*Sin[ϕ] - r1*Sin[ϕ1], r*Cos[θ]};
\[ScriptR]Norm[ϕ_, r_, θ_, ϕ1_, r1_] :=
Sqrt[(r*Sin[θ]*Cos[ϕ] -
r1*Cos[ϕ1])^2 + (r*Sin[θ]*Sin[ϕ] -
r1*Sin[ϕ1])^2 + (r*Cos[θ])^2] // Simplify;
ele[ϕ_?NumericQ, r_?NumericQ, θ_?NumericQ] := σ*k*
NIntegrate[(\[ScriptR][ϕ, r, θ, ϕ1,
r1]/\[ScriptR]Norm[ϕ, r, θ, ϕ1, r1]^3)*
r1, {ϕ1, 0, 2*π}, {r1, 0, R}];
VectorPlot3D[
ele[ϕ, r, θ] /. {σ -> 200, k -> 9*10^9, R -> 0.5,
r*Sin[θ]*Cos[ϕ] -> x, r*Sin[θ]*Sin[ϕ] -> y,
r*Cos[θ] -> z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]
I am worried part of my issue is in the function that I made, but I am most certain that calling replace all like this is not a viable way to transform coordinates.
Edit: added the integral I am trying to solve. The \[ScriptR]
is the vector in the numerator, and \[ScriptR]Norm
is the cube root of the denominator