I have a physical problem simulation that generates this data set in the two cylindrical coordinates $(r,z)$ (doesn't include $\phi$ dependence). The data set (see .wdx file) is in the flattened form $(r, z, \textrm{value})$. The set represents the 3D field inside a cavity, basically a function or coordinates $E_{r}(r,z)$. We only know that roughly the dependence of $E_{r}$ on radius $r$ should be some Bessel function of the first kind in low orders, such as $aJ_{0}[k r]$ or $aJ_{1}[k r]$, or their first derivative with respect to their argument, such as $aJ'_{0}[k r]$ or $aJ'_{1}[k r]$. And the dependence on $z$ should be a sinusoidal function, such as $b\cos[d z]$ or $b\sin[d z]$. We don't know the parameters $a,k,b,d$.
Two questions:
(1) With this little prior knowledge, how can we find a model that fits this field in 3D using Mathematica? Naturally, the model should match the data at every cross section in $r$ or $z$. I have failed in finding a model using Fit
, FindFit
and NonlinearModelFit
(but maybe because I am a novice in Mathematica). Is there a procedure that can fit arbitrary functions with little or no prior knowledge/hints given to Mathematica?
(2) I interpolated the data and got a fairly close file see .wdx file. However, I needed to calculate the partial derivative $(\partial/\partial z)$ of the interpolated field. The derivative comes out overall correctly, but its local shape is choppy and wiggly (see below). How can I smooth out this curve? Note that I have tried the Method of "Splines" but it gave worse results than the default/Hermite one.
InterpEr=Interpolation[DataEr]
Erp1=Plot[InterpEr[0.01,zz],{zz,0.0,1.6},PlotStyle->{Dashed,Black}];
Erp2=Plot[100*GetFields[1,zz,0.01][[1]],{zz,0.0,1.6},PlotStyle->Green];
Show[Erp2,Erp1]
This is the data closely fitted by the Interpolation "InterpEr" (drawn along $z$ for a given $r$ value):
zDerivativeInterpEr=Derivative[0,1][InterpEr]
Plot[{InterpEr[0.01,zz],zDerivativeInterpEr[0.01,zz]},{zz,0.0,1.6},PlotStyle->{Dashed,Black},ImageSize->Large,PlotRange->All]
This is the resulting (wiggly) derivative produced at the same instance in $r$:
I understand this wiggly shape may be a result of the data resolution due to meshing, etc, from simulation. But it would nice if I could extract the smooth shape somehow.
Plot[a E^(-b (x - c)^2) (x - c) /. {a -> 15000, b -> 20, c -> 0.8}, {x, 0, 1.6}, PlotRange -> All]
.a1 E^(-b1 (x - c1)^2) (x - c1) *a2 E^(-b2 (y - c2)^2) (y - c2)
might work for the 3D case. The functional form is just the first derivative of some that looks like a normal distribution shape or for the 3D case partial derivatives of a bivariate normal shape. $\endgroup$Mathematica
. $\endgroup$