Skip to content

API/code issues #4

@QuentinWach

Description

@QuentinWach

The _rust.py type hints are wrong. Both solve_diagonal_sparse and solve_tensorial_sparse are annotated as returning two values, but they return three: n_complex, fields, and solver_info.

Fix:

) -> tuple[np.ndarray, list[np.ndarray], dict[str, object]]:

Result.to_hdf5() JSON-serializes complex solver diagnostics as {"real": ..., "imag": ...}, but from_hdf5() does not restore them to complex numbers. The loaded solver_info is therefore not type-equivalent to the saved one.

Sweep._reorder_result_modes() drops solver_info, so overlap-tracked sweep results lose diagnostics.

k_eff is currently just n_complex.imag, not a propagation constant. That name will confuse photonics users because k_eff often means β or complex wavenumber. Either rename it to n_imag/n_eff_imag, or document very explicitly that k_eff is the imaginary part of effective index.

plot_field() uses imshow with extents derived from coordinate centers, not cell edges. For nonuniform grids, this misrepresents geometry; even for uniform grids, it clips half a cell at each boundary. Use stored width coordinates and pcolormesh/edges instead.

The native shift-invert fallback truncates candidates but does not check that it actually found num_modes; the ARPACK paths do check this. I would mirror the ARPACK behavior and raise if too few usable eigenpairs are returned.

The public Materials validation checks finite tensors, but the solver later divides by eps_zz and mu_zz. Add explicit nonzero checks for those diagonal components, or raise a clear error before Rust operator assembly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions