Angular emission of incoherent dipoles#

An emitter such as an LED active region radiates incoherent light. Reproducing that in FDTD means simulating its dipoles individually: dipoles placed in the same run would interfere with each other, so each position and each orientation needs its own simulation, with an incoherent sum of the resulting far fields. The cost therefore grows with the number of emitters sampled, which is what makes a well sampled active region expensive, as illustrated in the Blue micro-LEDs with inclined sidewalls example.

With DipoleEmissionStudy the cost is set by the observation angle grid instead: one simulation per angle handles an arbitrary number of dipole positions, chosen by the user, so sampling ten thousand emitters costs the same as sampling five.

This notebook covers two cases:

  1. A small LED-like die, where the plugin is validated point by point against explicit dipole simulations (5 positions, \(\phi = 0\), \(\theta\) from \(0^\circ\) to \(110^\circ\)), including how to set the angles correctly beyond the reach of a single collection face.

  2. A larger die, where 5 positions are visibly too few, while the plugin averages 10,000 positions at the same simulation cost.

Note: the total cost of running the entire notebook is about 28 FlexCredits.

Schematic

[1]:
import numpy as np
import matplotlib.pyplot as plt
import tidy3d as td
import tidy3d.web as web
from tidy3d.constants import C_0, MU_0, ETA_0
from tidy3d.plugins.dipole_emission import DipoleEmissionStudy, EmissionAnalysisRegion

td.config.logging.warn_once = True  # the probe simulations repeat the same setup warnings

lda0 = 0.45  # um
freq0 = C_0 / lda0
n_GaN = 2.45
dl = lda0 / n_GaN / 15
source_time = td.GaussianPulse(freq0=freq0, fwidth=freq0 / 10)

Small Die: Validation Against One Dipole at a Time#

The die is a GaN mesa (\(n = 2.45\), \(1.2 \times 1.2 \times 0.3\ \mu\text{m}\)) on a sapphire substrate (\(n = 1.75\)), with 5 dipole positions in an X pattern on the mesa mid-plane. The substrate is kept inside the analysis region, so that both collection faces of the region still sit in the uniform air background, as the plugin requires.

The fixed-angle plane wave probes used by a study are limited to \(|\theta| \le \pi/2 - 0.1\) rad \(\approx 84.3^\circ\) from the collection normal, and each study collects one half-space. Covering up to \(110^\circ\) from vertical therefore takes two studies:

  • Top collection (normal_axis=2, direction="+") covers \(\theta = 0\) to \(84^\circ\) from vertical, with angle pairs \((\theta,\ \phi)\).

  • Lateral collection (normal_axis=0, direction="+") covers \(\theta = 84^\circ\) to \(110^\circ\), including directions below the horizon. Its angles are measured from the \(+x\) axis, and the pair that probes the direction \(\theta\) from vertical in the \(xz\) plane is

\[(\texttt{theta},\ \texttt{phi}) = (90^\circ - \theta,\ -90^\circ)\]

The sign of \(\phi\) matters. The direction field only selects which side of the collection axis the probe comes from, while the transverse tilt is set by \(\phi\) as given. With \(\phi = -90^\circ\) the observation direction tilts toward \(+z\), as intended. With \(\phi = +90^\circ\) it tilts toward \(-z\), so the study would sample the direction mirrored through the horizon (\(180^\circ - \theta\)) while labeling it \(\theta\). In general, for an observation direction \(\hat{n}\) collected through the \(+a\) face, with transverse axes \(t_1 < t_2\):

\[\texttt{theta} = \arccos(\hat{n}_a), \qquad \texttt{phi} = \mathrm{atan2}(-\hat{n}_{t_2},\ -\hat{n}_{t_1})\]

Two practical points. Skip \(\theta = 90^\circ\) exactly, where the probe reaches the collection face at normal incidence and the polarization label becomes degenerate, and bracket that direction with \(88^\circ\) and \(92^\circ\) instead. Measure a few angles with both faces (here \(72^\circ\), \(78^\circ\) and \(84^\circ\)) to check that the two studies agree where they overlap.

The Simulation of the Device#

A study takes a source-free Simulation of the passive device and generates its own probe simulations from it. Everything that describes the device goes here: structures, medium, grid, boundaries and run time.

[2]:
gan = td.Medium.from_nk(n=n_GaN, k=0, freq=freq0)
sapphire = td.Medium.from_nk(n=1.75, k=0, freq=freq0)

mesa = td.Structure(geometry=td.Box(center=(0, 0, 0), size=(1.2, 1.2, 0.3)), medium=gan, name="mesa")
substrate = td.Structure(geometry=td.Box(center=(0, 0, -0.25), size=(1.6, 1.6, 0.2)),
                         medium=sapphire, name="substrate")

sim_small = td.Simulation(
    center=(0, 0, 0),
    size=(3, 3, 2.0),
    grid_spec=td.GridSpec.uniform(dl=dl),  # the probes require a uniform grid transverse to the injection axis
    structures=[substrate, mesa],
    run_time=4e-12,
)
sim_small.plot(y=0)
plt.show()
../_images/notebooks_IncoherentDipoleEmission_3_0.png

The Study#

Main arguments of DipoleEmissionStudy:

  • base_sim: the source-free simulation above.

  • analysis_region: an EmissionAnalysisRegion enclosing the emitters and the part of the device that shapes their radiation. Its normal_axis and direction select the collection half-space, while dl sets the resolution of the probe fields in the plane transverse to the collection direction.

  • positions: the dipole locations, as a PointDataArray. Any number of positions can be listed, and the cost does not depend on it.

  • source_time: the spectral envelope of the emission, a GaussianPulse here, which is divided out again by angular_radiation_transfer.

  • freqs: the frequencies at which the emission is evaluated.

  • angles: the observation directions, as (theta, phi) pairs measured from the collection normal.

  • polarizations: which far-field polarizations to evaluate, "p" (in the plane of the observation direction and the collection normal) and/or "s". Each angle and polarization pair is one simulation.

Two studies are built, one per collection face, sharing the same device, positions and source.

[3]:
pts = [(0.0, 0.0, 0.0), (0.3, 0.3, 0.0), (-0.3, 0.3, 0.0), (-0.3, -0.3, 0.0), (0.3, -0.3, 0.0)]
positions = td.PointDataArray(pts, coords=dict(index=np.arange(len(pts)), axis=np.arange(3)))

theta_top = np.arange(0, 85, 6, dtype=float)                                     # from vertical, top collection
theta_lat = np.array([72.0, 78.0, 84.0, 88.0, 92.0, 96.0, 100.0, 105.0, 110.0])  # from vertical, lateral collection

def make_study(normal_axis, angle_pairs):
    region = EmissionAnalysisRegion(center=(0, 0, -0.1), size=(1.8, 1.8, 1.0),
                                    normal_axis=normal_axis, direction="+", dl=dl)
    angles = td.SphericalAngleDataArray(
        [(np.deg2rad(t), p) for t, p in angle_pairs],
        coords=dict(index=np.arange(len(angle_pairs)), spherical_coordinate=["theta", "phi"]),
    )
    return DipoleEmissionStudy(base_sim=sim_small, analysis_region=region, positions=positions,
                               source_time=source_time, freqs=[freq0], angles=angles, polarizations=("p",))

study_top = make_study(2, [(t, 0.0) for t in theta_top])                 # angles from +z
study_lat = make_study(0, [(90 - t, -np.pi / 2) for t in theta_lat])     # angles from +x, phi = -90 deg

print(f"{len(study_top.to_simulations())} probe simulations for the top collection, "
      f"{len(study_lat.to_simulations())} for the lateral one, {len(pts)} dipole positions in both")
17:01:55 UTC WARNING: Override structures take no effect along x-axis. If
             intending to apply override structures to this axis, use 'AutoGrid'
             or 'QuasiUniformGrid'.
             WARNING: Override structures take no effect along y-axis. If
             intending to apply override structures to this axis, use 'AutoGrid'
             or 'QuasiUniformGrid'.
             WARNING: TFSF source at index '0' uses 'FixedAngleSpec' with
             angle_theta=0. At normal incidence the default 'FixedInPlaneKSpec'
             (Bloch TFSF) is physically equivalent and runs faster. Consider
             switching unless you specifically need the fixed-angle path.
             WARNING: Override structures take no effect along z-axis. If
             intending to apply override structures to this axis, use 'AutoGrid'
             or 'QuasiUniformGrid'.
15 probe simulations for the top collection, 9 for the lateral one, 5 dipole positions in both

Reference: Explicit Dipole Simulations#

Each position needs three orthogonal orientations, so the 5 positions cost 15 simulations, each with a single PointDipole. A closed FieldProjectionAngleMonitor box around the die gives the far field, and the incoherent average adds \(|E_\theta|^2\) over the runs. Dividing by the analytic bulk power \(\omega^2\mu_0 n/(12\pi c)\) of one dipole makes the result directly comparable with the transfer reported by the plugin.

[4]:
theta_ref = np.deg2rad(np.arange(0, 111.5, 1.0))
proj_small = td.FieldProjectionAngleMonitor(center=(0, 0, -0.1), size=(1.8, 1.8, 1.0), freqs=[freq0],
                                            theta=theta_ref, phi=[0.0], far_field_approx=True, name="ff")

sims_expl_small = {
    f"p{i}_{pol}": sim_small.updated_copy(
        sources=[td.PointDipole(center=pt, polarization=pol, source_time=source_time)],
        monitors=[proj_small],
    )
    for i, pt in enumerate(pts)
    for pol in ("Ex", "Ey", "Ez")
}
print(f"{len(sims_expl_small)} simulations for the reference ({len(pts)} positions x 3 orientations)")
15 simulations for the reference (5 positions x 3 orientations)
[5]:
data_top = study_top.run(folder_name="dipole_emission_example", path_dir="example_small_top")
data_lat = study_lat.run(folder_name="dipole_emission_example", path_dir="example_small_lat")
batch_expl_small = web.Batch(simulations=sims_expl_small,
                             folder_name="dipole_emission_example").run(path_dir="example_small_explicit")
Uploading data for 15 tasks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:06

17:02:04 UTC Started working on Batch containing 15 tasks.
17:02:17 UTC Maximum FlexCredit cost: 13.326 for the whole batch.
             Use 'Batch.real_cost()' to get the billed FlexCredit cost after
             completion.
17:03:56 UTC Batch complete.
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:35
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:35
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:35
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:48
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:10
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:10
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:10
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:35
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:35
_dipole_emission_angle01... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23
_dipole_emission_angle01... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:18
_dipole_emission_angle01... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:19
_dipole_emission_angle01... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:31
_dipole_emission_angle01... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:29

             WARNING: Warning messages were found in the solver log. For more
             information, check 'SimulationData.log' or use
             'web.download_log(task_id)'.
Uploading data for 9 tasks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:04

17:04:01 UTC Started working on Batch containing 9 tasks.
17:04:09 UTC Maximum FlexCredit cost: 7.996 for the whole batch.
             Use 'Batch.real_cost()' to get the billed FlexCredit cost after
             completion.
17:05:39 UTC Batch complete.
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:27
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:17
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:17
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:26
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:13
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:10
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:17
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:18
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23

Uploading data for 15 tasks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:06

17:05:47 UTC Started working on Batch containing 15 tasks.
17:06:00 UTC Maximum FlexCredit cost: 10.711 for the whole batch.
             Use 'Batch.real_cost()' to get the billed FlexCredit cost after
             completion.
17:07:06 UTC Batch complete.
p0_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:03
p0_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:44
p0_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:03
p1_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p1_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p1_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:51
p2_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p2_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p2_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:57
p3_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p3_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:00
p3_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:57
p4_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:57
p4_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:59
p4_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:51
[6]:
def explicit_transfer(batch_data, proj, npos, n_medium):
    """Incoherent average of the p-polarized far field of ``npos`` dipoles, per bulk emitted power."""
    p_bulk = (2 * np.pi * freq0) ** 2 * MU_0 * n_medium / (12 * np.pi * C_0)
    intensity = 0
    for i in range(npos):
        for pol in ("Ex", "Ey", "Ez"):
            e_theta = batch_data[f"p{i}_{pol}"]["ff"].Etheta.squeeze(drop=True).values
            intensity = intensity + np.abs(e_theta) ** 2 / (2 * ETA_0) * proj.proj_distance ** 2
    return intensity / npos / p_bulk


transfer_top = data_top.angular_radiation_transfer(n_GaN).sel(f=freq0, polarization="p").sum("dipole_axis").values
transfer_lat = data_lat.angular_radiation_transfer(n_GaN).sel(f=freq0, polarization="p").sum("dipole_axis").values
transfer_ref = explicit_transfer(batch_expl_small, proj_small, len(pts), n_GaN)

theta_ref_deg = np.rad2deg(theta_ref)
ref_at_top = np.interp(theta_top, theta_ref_deg, transfer_ref)
ref_at_lat = np.interp(theta_lat, theta_ref_deg, transfer_ref)
print(f"plugin / reference:  top collection {np.min(transfer_top / ref_at_top):.3f} - {np.max(transfer_top / ref_at_top):.3f}, "
      f"lateral collection {np.min(transfer_lat / ref_at_lat):.3f} - {np.max(transfer_lat / ref_at_lat):.3f}")
plugin / reference:  top collection 1.000 - 1.009, lateral collection 1.000 - 1.006
[7]:
def mirrored(theta_deg, values):
    """The die is mirror-symmetric in x, so the phi = 0 cut is drawn reflected to negative angles."""
    return np.deg2rad(np.concatenate([-theta_deg[::-1], theta_deg])), np.concatenate([values[::-1], values])

fig = plt.figure(figsize=(9, 7))
ax = fig.add_axes([0.06, 0.34, 0.88, 0.62], projection="polar")
ax.plot(*mirrored(theta_ref_deg, transfer_ref), "-", color="gray", lw=1.4,
        label=f"explicit dipoles ({len(sims_expl_small)} simulations)")
ax.plot(*mirrored(theta_top, transfer_top), "s", color="tab:blue", ms=7, fillstyle="none", mew=1.8,
        label="plugin, top collection")
ax.plot(*mirrored(theta_lat, transfer_lat), "D", color="tab:red", ms=7, fillstyle="none", mew=1.8,
        label="plugin, lateral collection")
ax.set_theta_zero_location("N")
ax.set_thetamin(-110)
ax.set_thetamax(110)
ax.set_xticks(np.deg2rad(np.arange(-105, 106, 15)))
ax.set_rticks([0.05, 0.10, 0.15])
ax.set_rlabel_position(90)
plt.setp(ax.get_yticklabels(), color="gray", fontsize=8)
ax.set_title("Small die: p-pol transfer (1/sr) at phi = 0", pad=18)
ax.grid(True, alpha=0.4)
ax.legend(fontsize=8, loc="lower center", bbox_to_anchor=(0.5, 0.02))

ax2 = fig.add_axes([0.1, 0.07, 0.84, 0.2])
ax2.axhline(1, color="k", lw=0.8)
ax2.plot(theta_top, transfer_top / ref_at_top, "s-", color="tab:blue", fillstyle="none", mew=1.8, label="top")
ax2.plot(theta_lat, transfer_lat / ref_at_lat, "D-", color="tab:red", fillstyle="none", mew=1.8, label="lateral")
ax2.set_xlabel("theta from vertical (degree)")
ax2.set_ylabel("plugin / reference")
ax2.set_xlim(0, 112)
ax2.set_ylim(0.8, 1.2)
ax2.grid(True, alpha=0.3)
ax2.legend(fontsize=8, ncol=2)
plt.show()
../_images/notebooks_IncoherentDipoleEmission_10_0.png

The two collection faces agree with the reference and with each other, including at the three angles measured twice and in the range beyond the horizon, which only the lateral study can reach.

Larger Die: Five Positions Are Not Enough#

A larger GaN die (\(4 \times 1.1 \times 1.5\ \mu\text{m}\)) on its sapphire substrate, both with a small loss \(k = 10^{-3}\) so that the runs decay quickly, with the emission evaluated at \(\theta = 0\) to \(50^\circ\) from vertical over 10 angles, using top collection only. The explicit reference keeps 5 positions and 15 simulations, while the study samples 10,000 positions over the active plane with 10 simulations, one per angle.

[8]:
gan_lossy = td.Medium.from_nk(n=n_GaN, k=1e-3, freq=freq0)
sapphire_lossy = td.Medium.from_nk(n=1.75, k=1e-3, freq=freq0)

die = td.Structure(geometry=td.Box(center=(0, 0, 0), size=(4, 1.1, 1.5)), medium=gan_lossy, name="die")
substrate_large = td.Structure(geometry=td.Box(center=(0, 0, -1.0), size=(4.5, 1.6, 0.5)),
                               medium=sapphire_lossy, name="substrate")

sim_large = td.Simulation(
    center=(0, 0, 0),
    size=(6.5, 3.6, 3.5),
    grid_spec=td.GridSpec.uniform(dl=dl),
    structures=[substrate_large, die],
    run_time=4e-12,
)
sim_large.plot(y=0)
plt.show()
../_images/notebooks_IncoherentDipoleEmission_12_0.png
[9]:
rng = np.random.default_rng(0)
pts_10k = [(x, y, 0.0) for x, y in zip(rng.uniform(-1.6, 1.6, 10000), rng.uniform(-0.4, 0.4, 10000))]
positions_10k = td.PointDataArray(pts_10k, coords=dict(index=np.arange(len(pts_10k)), axis=np.arange(3)))

theta_large = np.linspace(0, 50, 10)
region_large = EmissionAnalysisRegion(center=(0, 0, -0.15), size=(5.0, 2.1, 2.9),
                                      normal_axis=2, direction="+", dl=dl)
angles_large = td.SphericalAngleDataArray(
    [(np.deg2rad(t), 0.0) for t in theta_large],
    coords=dict(index=np.arange(len(theta_large)), spherical_coordinate=["theta", "phi"]),
)
study_large = DipoleEmissionStudy(base_sim=sim_large, analysis_region=region_large, positions=positions_10k,
                                  source_time=source_time, freqs=[freq0], angles=angles_large,
                                  polarizations=("p",),
                                  store_position_indexes=tuple(range(len(pts_10k))))

pts_5 = [(0.0, 0.0, 0.0), (1.0, 0.25, 0.0), (-1.0, 0.25, 0.0), (-1.0, -0.25, 0.0), (1.0, -0.25, 0.0)]
theta_ref_large = np.deg2rad(np.arange(0, 52.5, 1.0))
proj_large = td.FieldProjectionAngleMonitor(center=(0, 0, -0.15), size=(5.0, 2.1, 2.9), freqs=[freq0],
                                            theta=theta_ref_large, phi=[0.0], far_field_approx=True, name="ff")
sims_expl_large = {
    f"p{i}_{pol}": sim_large.updated_copy(
        sources=[td.PointDipole(center=pt, polarization=pol, source_time=source_time)],
        monitors=[proj_large],
    )
    for i, pt in enumerate(pts_5)
    for pol in ("Ex", "Ey", "Ez")
}
print(f"{len(study_large.to_simulations())} probe simulations for {len(pts_10k)} dipole positions, "
      f"{len(sims_expl_large)} explicit dipole simulations for {len(pts_5)} positions")
10 probe simulations for 10000 dipole positions, 15 explicit dipole simulations for 5 positions
[10]:
data_large = study_large.run(folder_name="dipole_emission_example", path_dir="example_large_plugin")
batch_expl_large = web.Batch(simulations=sims_expl_large,
                             folder_name="dipole_emission_example").run(path_dir="example_large_explicit")
Uploading data for 10 tasks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:08

17:07:17 UTC Started working on Batch containing 10 tasks.
17:07:27 UTC Maximum FlexCredit cost: 35.261 for the whole batch.
             Use 'Batch.real_cost()' to get the billed FlexCredit cost after
             completion.
17:18:04 UTC Batch complete.
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:09:57
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:03:31
_dipole_emission_angle00... β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:10:34

Uploading data for 15 tasks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:06

17:18:13 UTC Started working on Batch containing 15 tasks.
17:18:26 UTC Maximum FlexCredit cost: 41.793 for the whole batch.
             Use 'Batch.real_cost()' to get the billed FlexCredit cost after
             completion.
17:27:29 UTC Batch complete.
p0_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:58
p0_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:58
p0_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:58
p1_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:27
p1_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:02:28
p1_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:58
p2_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:27
p2_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:02:28
p2_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:03:02
p3_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:30
p3_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:21
p3_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:54
p4_Ex           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:26
p4_Ey           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:02:28
p4_Ez           β†’ success ━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:08:55
[11]:
transfer_10k = data_large.angular_radiation_transfer(n_GaN).sel(f=freq0, polarization="p").sum("dipole_axis").values
transfer_ref_large = explicit_transfer(batch_expl_large, proj_large, len(pts_5), n_GaN)
[12]:
fig = plt.figure(figsize=(8, 5.5))
ax = fig.add_subplot(111, projection="polar")
ax.plot(*mirrored(np.rad2deg(theta_ref_large), transfer_ref_large), "-", color="gray", lw=1.5,
        label=f"explicit dipoles, {len(pts_5)} positions ({len(sims_expl_large)} simulations)")
ax.plot(*mirrored(theta_large, transfer_10k), "o-", color="tab:blue", ms=6,
        label=f"plugin, {len(pts_10k)} positions ({len(study_large.to_simulations())} simulations)")
ax.set_theta_zero_location("N")
ax.set_thetamin(-52)
ax.set_thetamax(52)
ax.set_xticks(np.deg2rad(np.arange(-50, 51, 10)))
ax.set_rticks([0.04, 0.08, 0.12])
ax.set_rlabel_position(90)
plt.setp(ax.get_yticklabels(), color="gray", fontsize=8)
ax.set_title("Large die: p-pol transfer (1/sr) at phi = 0", pad=18)
ax.grid(True, alpha=0.4)
ax.legend(fontsize=9, loc="lower center", bbox_to_anchor=(0.5, -0.12))
plt.show()
../_images/notebooks_IncoherentDipoleEmission_16_0.png

Five positions leave strong interference lobes from the sparse sample, while ten thousand positions, at the cost of one simulation per angle, give the smooth pattern expected of a genuinely incoherent source.

Convergence With the Number of Dipoles#

store_position_indexes keeps the radiation intensity of each sampled position, so the average over any subset of the 10,000 positions is available in post-processing, from the same 10 simulations. Averaging over the first \(N\) positions and comparing with the full average shows how many positions the incoherent sum needs.

[13]:
per_position = data_large.angular_radiation_transfer_at_positions(n_GaN).sel(f=freq0, polarization="p").sum("dipole_axis")

subsets = [5, 20, 100, 500, 2000, 10000]
curves = {n: per_position.isel(index=slice(0, n)).mean("index").values for n in subsets}
reference = curves[max(subsets)]
for n in subsets:
    deviation = np.max(np.abs(curves[n] - reference)) / reference.max()
    print(f"{n:>6} positions: max deviation from the {max(subsets)}-position average = {100 * deviation:5.1f} %")

fig, ax = plt.subplots(figsize=(8, 4.8))
colors = plt.cm.viridis(np.linspace(0, 0.85, len(subsets)))
for n, color in zip(subsets, colors):
    ax.plot(theta_large, curves[n], "o-", ms=4, color=color, label=f"{n} positions")
ax.set_xlabel("theta from vertical (degree)")
ax.set_ylabel("p-pol transfer at phi = 0 (1/sr)")
ax.set_title("Incoherent average over the first N of the 10,000 sampled positions")
ax.set_ylim(bottom=0)
ax.grid(True, alpha=0.3)
ax.legend(fontsize=8)
plt.show()
     5 positions: max deviation from the 10000-position average =  29.0 %
    20 positions: max deviation from the 10000-position average =  17.7 %
   100 positions: max deviation from the 10000-position average =  10.9 %
   500 positions: max deviation from the 10000-position average =   5.7 %
  2000 positions: max deviation from the 10000-position average =   2.6 %
 10000 positions: max deviation from the 10000-position average =   0.0 %
../_images/notebooks_IncoherentDipoleEmission_18_1.png

A single subset is one particular draw of emitters, so the curves above still depend on which positions were picked. Repeating the draw many times at one angle, here \(\theta = 0\), separates the bias from the scatter: each point below is the mean over 20 random subsets of a given size, and the error bar is their standard deviation, which is the uncertainty a study of that size carries.

[14]:
spread_at_0 = per_position.isel(angle=0).values
sizes = [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]
rng_subsets = np.random.default_rng(1)
draws = {n: [spread_at_0[rng_subsets.choice(len(spread_at_0), size=n, replace=False)].mean() for _ in range(20)]
         for n in sizes}
mean_n = np.array([np.mean(draws[n]) for n in sizes])
std_n = np.array([np.std(draws[n]) for n in sizes])
for n, m, s in zip(sizes, mean_n, std_n):
    print(f"{n:>5} positions: {m:.4f} +/- {s:.4f} 1/sr ({100 * s / m:4.1f} %)")

fig, ax = plt.subplots(figsize=(8, 4.8))
ax.errorbar(sizes, mean_n, yerr=std_n, fmt="o-", ms=5, capsize=3, color="tab:blue",
            label="random subsets (mean +/- standard deviation over 20 draws)")
ax.axhline(spread_at_0.mean(), color="k", ls=":", lw=1.2, label="all 10,000 positions")
ax.set_xscale("log")
ax.set_xlabel("number of dipole positions in the incoherent sum")
ax.set_ylabel("p-pol transfer at theta = 0 (1/sr)")
ax.set_title("Spread of the incoherent average at theta = 0")
ax.grid(alpha=0.3)
ax.legend(fontsize=9)
plt.show()
    5 positions: 0.0751 +/- 0.0275 1/sr (36.6 %)
   10 positions: 0.0729 +/- 0.0167 1/sr (22.9 %)
   20 positions: 0.0668 +/- 0.0101 1/sr (15.1 %)
   50 positions: 0.0727 +/- 0.0073 1/sr (10.1 %)
  100 positions: 0.0730 +/- 0.0057 1/sr ( 7.9 %)
  200 positions: 0.0714 +/- 0.0038 1/sr ( 5.3 %)
  500 positions: 0.0718 +/- 0.0030 1/sr ( 4.1 %)
 1000 positions: 0.0710 +/- 0.0016 1/sr ( 2.2 %)
 2000 positions: 0.0712 +/- 0.0008 1/sr ( 1.1 %)
 5000 positions: 0.0710 +/- 0.0007 1/sr ( 1.0 %)
../_images/notebooks_IncoherentDipoleEmission_20_1.png