get_adjoint_fields#

PortFom.get_adjoint_fields(fdtd_session, entry)#

Extract and scale adjoint fields for port-based simulation, one per wavelength.

Convenience single-call wrapper that runs the forward-side read (_collect_fwd_side_aux()) immediately followed by the adjoint-side compute (_compute_adjoint_fields_phased()). Provided so external callers and tests can ask for the scaled adjoint fields without having to drive the two phases manually; calculate_gradient_fields() invokes the two helpers directly to keep all forward reads in phase 1 and all adjoint reads in phase 2.

For port-based simulations the adjoint simulation is set with unit amplitude and 0 phase, so the adjoint fields need to be scaled appropriately. The mode profiles (em, hm) and spatial coordinates (x, y, z) are wavelength-independent; all other quantities (e, h, Nm, freq, phase corrections) are extracted at each requested wavelength.

Parameters:
fdtd_sessionFdtdSession

FDTD session providing access to simulation data and parameters.

entrydict

Dictionary containing filenames and simulation results for the current entry.

Returns:
list of np.ndarray

Scaled adjoint electric field data, one array per wavelength in entry['sim_result'].wavelengths.