ConfigMap#

class lumopt2.utils.config_map.ConfigMap(sim_results: list, project_name: str = None)#

Organises simulation results into per-configuration groups and manages filenames.

Accepts a list of simulation result objects and groups them by their associated Config instance (currently always None until multi-config support is added). For each group it generates:

  • a forward simulation filename (fwd_<config>.fsp)

  • per-result adjoint simulation filenames (adj_<config>_<monitor>.fsp)

It also determines the project folder name — either from an explicit project_name argument or by auto-generating a timestamped name — and exposes helpers to retrieve results, filenames, and FOM values in the exact positional order expected by the user-defined fct in Fom.

Parameters:
sim_resultslist

Simulation result objects to organise. Each must expose a config attribute (None for the default single-config workflow) and a monitor_name attribute used to build adjoint filenames.

project_namestr, optional

Name to use for the project folder. If None, a name of the form lumopt2_project_YYYYMMDD_HHMMSS is generated automatically.

Attributes:
config_mapdict

Dictionary keyed by Config instance (or None for the default config). Each value is a dict with:

  • 'config': the Config instance for this group.

  • 'sources': None placeholder, populated later when the FDTD session is available.

  • 'fwd_filename': forward simulation filename string.

  • 'adjoints': list of dicts, each with 'sim_result' and 'adj_filename' for one result in this group.

sim_results_orderedlist

Simulation results in the exact order supplied to the constructor. This order must match the positional arguments of the user-defined fct in Fom (e.g. custom_fct(int_red, int_green, ...)).

project_folderstr

Path/name of the project folder where simulation files are written.

Methods

ConfigMap.get_filenames_in_order()

Return filenames for each simulation result in the order matching the custom_fct arguments.

ConfigMap.get_sim_results()

Return simulation results in the original order matching the custom_fct arguments.

ConfigMap.get_values_in_order()

Return the .values of each simulation result in the order matching the custom_fct arguments.

ConfigMap.set_filename_iteration(iteration)

Update all forward and adjoint filenames to include an iteration suffix.