File management
Simulation data are stored in an EMode Photonix file with the extension ‘.eph’. This file is created when a simulation is initialized, and existing simulation files can be opened by EMode for further analysis.
- init
Create a simulation instance with an associated ‘.eph’ file to run the simulation and store data. This function is automatically called when the emodeconnection class is initialized.
- Parameters:
save_path (str) – path to save the simulation file relative to the current working directory, default: ‘.’
simulation_name (str) – simulation name, default: ‘emode’
- open
Open an existing simulation ‘.eph’ file. This can be used to retrieve previous simulation data or to run a simulation based on a template.
- Parameters:
save_path (str) – path to open the simulation file relative to the current working directory, default: ‘.’
simulation_name (str) – simulation name, default: ‘emode’
new_name (str) – new simulation name so the old file is not over-written, default:
simulation_name
- get
Extract data from an existing simulation to your Python environment.
- Parameters:
key (str) – name of the variable or parameter to extract. This can also be a list of fields of any combination of [
Ex,Ey,Ez,Hx,Hy,Hz,Sx,Sy,Sz]. See Variable Descriptions for a complete list and description of all available variables.label (str) – name of labeled dataset to extract the data defined by
key, default: ‘’simulation_name (str) – simulation name, default: ‘emode’
- get_fields
Extract field data from an existing simulation to your Python environment. This returns a Field object.
- Parameters:
key (str or list[str]) – name of the field to extract a list of fields of any combination of [
Ex,Ey,Ez,Hx,Hy,Hz,Sx,Sy,Sz].include_expand (bool) – whether to include the expanded region, default: True
include_pml (bool) – whether to include the PML region, default: True
unfold (bool) – whether to include the full window (unfolded) or strictly the solved window (potentially smaller due to applied symmetries), default: True
label (str) – name of labeled dataset to extract the data defined by
key, default: ‘’simulation_name (str) – simulation name, default: ‘emode’
- get_grid
Extract grid data from an existing simulation to your Python environment. This returns a Grid object.
- Parameters:
include_expand (bool) – whether to include the expanded region, default: True
include_pml (bool) – whether to include the PML region, default: True
unfold (bool) – whether to include the full window (unfolded) or strictly the solved window (potentially smaller due to applied symmetries), default: True
label (str) – name of labeled dataset to extract the data defined by
key, default: ‘’simulation_name (str) – simulation name, default: ‘emode’
- clear_field_data
Deletes the following data to reduce the ‘.eph’ file size:
Fx,Fy,Ex,Ey,Ez,Hx,Hy,Hz,Sx,Sy,Sz,x,y,permittivity,permeability.- Parameters:
simulation_name (str) – simulation name, default: ‘emode’
- save
Saves a simulation file and keeps the simulation file in the ‘open’ state. The file is saved as an EMode Photonix file (‘eph’).
- Parameters:
save_all_fields (bool) – whether all field data should be saved (so the
E,H, andSfields can be accessed without an EMode license) or just the raw field data (FxandFy), default: Falsenew_save_path (str) – if set, saves the simulation file in this new path, default: None
simulation_name (str) – simulation name, default: ‘emode’
- close
Saves or deletes a simulation file. The file is saved as an EMode Photonix file (‘eph’). This function is called through the “close” method of emodeconnection, and these optional parameters can be passed directly to the “close” method.
- Parameters:
save (bool) – saves simulation file if True and deletes the simulation file if False, default: True
save_all_fields (bool) – whether all field data should be saved (so the
E,H, andSfields can be accessed without an EMode license) or just the raw field data (FxandFy), default: Falsesimulation_name (str) – simulation name, default: ‘emode’