New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Radiation pattern of a dipole emitter does not converge with resolution in cylindrical coordinates #2489
Comments
There is an even larger disparity in the radiation pattern for Configurations 1 and 2 for a dipole source at These results seem to indicate that there is likely a bug somewhere, possibly in the near-to-far field transformation in cylindrical coordinates? Configuration 1 Configuration 2 |
Does the total LEE itself converge? If so, then you can narrow the bug down to the near2far. |
The total EE is converged as I mentioned in my first comment. The bug is likely in the near to far transformation function |
From your gist: for i in range(npts):
ff = sim.get_farfield(n2f_mon,
mp.Vector3(r*math.cos(angles[i]),
0,
r*math.sin(angles[i])))
E[i,:] = [np.conj(ff[j]) for j in range(3)]
H[i,:] = [ff[j+3] for j in range(3)]
Pr = np.real(E[:,1]*H[:,2]-E[:,2]*H[:,1])
Pz = np.real(E[:,0]*H[:,1]-E[:,1]*H[:,0])
Prz = np.sqrt(np.square(Pr)+np.square(Pz)) Note that in the far field, the solutions are plane waves, and you should simply be able to calculate the Poynting flux using Is 1000 wavelengths far enough away (should be... but still)? Also, where is the integral that computes the fractional LEE in a cone? I didn't see that in the gist. |
So I would expect a difference between configuration 1 and configuration 2 because of that vertical line monitor that changes in But that error should go away with resolution. |
It looks like the radiation pattern obtained using two different configurations of the near-field monitors converges to the same result only when the length As a demonstration, here are the radiation patterns generated from a dipole at Note 1: The size of the disc is Note 2: I verified that the results are converged with the PML thickness in 1.
2.
3.
4.
|
Hmm. I'm wondering if this is because the monitors are further away, or if it's because the fields are converging better with the larger cells? This test is turning too many knobs... it's changing the cell size, the size of the disc, and the locations of the monitors. Can we simplify the test matrix here to exactly narrow down what's going on here? For example, keep the geometry and inner monitor position at the same position, but increase the cell size (and obviously the outer monitor should move with it). Then, you can safely test two things: (1) Does the inner-monitor response change as the cell size increase? (2) does the difference between inner and outer monitor response decrease with cell size? |
There could be a bug in the near2far calculation for the radial-direction interface? In particular, the cylindrical near2far is implemented by integrating the Cartesian Green's function over φ. For the ±z surfaces, only the position of the near-field source point changes during this integral. However, for the radial surface, the normal vector Maybe there is a bug in these lines? But that would affect the ±z surface as well? It would be good to check that these lines are actually being executed — i.e. that we are passing It could also be as simple as the +r surface missing the r factor? i.e. the weight |
Checked. These lines are being executed as expected.
Tried scaling the weight |
Might be worth doing a simple test of cylindrical near2far, just like we did for Cartesian: put a source somewhere (at the center?), compute the field at some point by explicit FDTD, and then compute the field at the same point using near2far. They should match (in the limit of infinite resolution). This can be a relatively small calculation, for a single m. |
Setting up such a test involving a point source within a "disc" at a single The script used to generate to these results is here. |
After further investigation, it looks like the discrepancy between the DFT fields and the near-to-far field transformation only occurs for With the modified setup, here are the results for the radiated fields for |
The Er fields for m=0 don't make sense. (They should look similar to the m=2 case.) Can you plot the raw time-domain Er field (e.g. in a movie) for the m=0 case to see what they look like, and whether they are going to zero as r goes to zero? You could also look at other test cases, e.g. if you put an Ez point source at r=0, with m=0, it should match the field of a 3d dipole (i.e. the 3d Green's function, which we know analytically). |
If we take a snapshot of The presence of a bug is perhaps not surprising since currently there is no unit test for the (Note: the time-domain results are consistent with the DFT fields above which also show a non-zero The peak in the second plot is the position of the point source. Note that the fields are decaying to zero in the PML region. Script used to generate these results is here. |
Can you try a really old version of Meep (e.g. via a C++ simulation) and see if it ever worked? |
Looks like the bug is due to the change to |
It seems like we really want an void step_update_EDHB0(RPR f, component fc, const grid_volume &gv, const ivec is, const ivec ie,
const RPR g, const RPR u, ptrdiff_t s, const RPR chi2,
const RPR chi3, RPR fw, direction dsigw, const RPR sigw, const RPR kapw) {
(void)fc; // currently unused
if (!f) return;
// 1. check that is is cylindrical and starts at r=0, otherwise return
// 2. change ie.set_direction(R) = is.set_direction(R) ... this way it will only loop over r=0
if (dsigw != NO_DIRECTION) { //////// PML case (with fw) /////////////
KSTRIDE_DEF(dsigw, kw, is, gv);
{ // diagonal u
if (chi3) {
{
PLOOP_OVER_IVECS(gv, is, ie, i) {
realnum gs = g[i];
realnum us = u[i];
DEF_kw;
realnum fwprev = fw[i], kapwkw = kapw[kw], sigwkw = sigw[kw];
fw[i] = (gs * us) * calc_nonlinear_u(gs * gs, gs, us, chi2[i], chi3[i]);
f[i] += (kapwkw + sigwkw) * fw[i] - (kapwkw - sigwkw) * fwprev;
}
}
}
else if (u) {
PLOOP_OVER_IVECS(gv, is, ie, i) {
realnum gs = g[i];
realnum us = u[i];
DEF_kw;
realnum fwprev = fw[i], kapwkw = kapw[kw], sigwkw = sigw[kw];
fw[i] = (gs * us);
f[i] += (kapwkw + sigwkw) * fw[i] - (kapwkw - sigwkw) * fwprev;
}
}
else {
PLOOP_OVER_IVECS(gv, is, ie, i) {
DEF_kw;
realnum fwprev = fw[i], kapwkw = kapw[kw], sigwkw = sigw[kw];
fw[i] = g[i];
f[i] += (kapwkw + sigwkw) * fw[i] - (kapwkw - sigwkw) * fwprev;
}
}
}
}
else { /////////////// no PML (no fw) ///////////////////
{ // diagonal u
if (chi3) {
{
PLOOP_OVER_IVECS(gv, is, ie, i) {
realnum gs = g[i];
realnum us = u[i];
f[i] = (gs * us) * calc_nonlinear_u(gs * gs, gs, us, chi2[i], chi3[i]);
}
}
}
else if (u) {
PLOOP_OVER_IVECS(gv, is, ie, i) {
realnum gs = g[i];
realnum us = u[i];
f[i] = (gs * us);
}
}
else
PLOOP_OVER_IVECS(gv, is, ie, i) { f[i] = g[i]; }
}
}
} |
As part of a convergence analysis of the radiation pattern of a dipole emitter in cylindrical coordinates (based on the calculation procedure described in #2472), it seems the results do not converge with resolution. Not sure whether this is an indication of a bug somewhere or the way the calculation has been set up.
The test structure involves a point source at$r = 0$ in a finite-size "disc" (a modification of the structure in the LED tutorial which is infinitely extended). There are two different configurations of the closed box of near-field monitors (see schematics below). By Poynting's theorem, the two monitor configurations should produce identical results in the limit of infinite resolution.
While the extraction efficiency over all angles computed using the Poynting flux is in fact identical (= 1.0), there are small but noticeable differences in the radiation pattern computed using a near-to-far field transformation. These discrepancies do not go away with increasing resolution. The script used to generate the results is here.
Here is a side-by-side comparison of the extraction efficiency (really the fractional flux$P_\theta$ in the far field) within four angular cones at a resolution of 200. The final column is the absolute difference in the results (i.e., a measure of the error).
Same results at a resolution of 400. The difference in the results (final column) is not decreasing as would be expected.
Configuration 1
resolution = 200
resolution = 400
Configuration 2
resolution = 200
resolution = 400
The text was updated successfully, but these errors were encountered: