File management
Simulation data is 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’ or ‘.mat’ 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 or MATLAB 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’
- 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_edge
,y_edge
,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 can be saved as an EMode Photonix file (‘eph’) or as a MATLAB-style file (‘.mat’).
- Parameters:
save_all_fields (bool) – whether all field data should be saved (so the
E
,H
, andS
fields can be accessed without an EMode license) or just the raw field data (Fx
andFy
), default: Falsefile_type (str) – file type to save simulation file (‘eph’ or ‘mat’), default: ‘eph’
new_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 can be saved as an EMode Photonix file (‘eph’) or as a MATLAB-style file (‘.mat’). 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
, andS
fields can be accessed without an EMode license) or just the raw field data (Fx
andFy
), default: Falsefile_type (str) – file type to save simulation file (‘eph’ or ‘mat’), default: ‘eph’ for Python connections and ‘mat’ for MATLAB connections
simulation_name (str) – simulation name, default: ‘emode’