MATLAB interface
To control EMode directly from a MATLAB script (version R2016b or higher), we supply a class file called emodeconnection.m
that is automatically installed alongside EMode.
For more information about MATLAB, check out this link:
Setup
Before running EMode from MATLAB, you must run the following in your MATLAB command window.
addpath(fullfile('C:', 'Program Files', 'EMode Photonix', 'EMode')); savepath;
The EMode class
- class emodeconnection(name, value)
Opens the EMode software and initializes a local simulation file. The user’s account must have an active license available to successfully run EMode. If the user has not previously logged in, this will prompt for a username and password. To reset the user profile, run
EMode Login
from the the start menu.An existing file can be opened for further analysis by specifying the input name-value pair
'open_existing', true
. This opened file can be copied to a new file name by specifying the input name-value pair'new_name', 'new_filename'
.By default, calling the close() method saves the simulation file as a MATLAB-style .mat file. Adding optional input parameters can override this behavior to either delete the simulation file or save it as a .eph file.
Note
All EMode functions are accessible as methods of this class instance using name-value pair input arguments for each funtion input parameter, in the format of (“name 1”, value_1, “name 2”, value_2, “name 3”, value_3, …).
- Parameters:
simulation_name (str) – Name of the simulation file. The extension ‘.eph’ will be added to this name. Default: ‘emode’.
license_type (str) – The requested license type, either ‘2D’, ‘3D’, or ‘default’. When running with ‘default’ license type, a ‘3D’ license will be initialized if it is available, otherwise a ‘2D’ license will be initialized if it is available. The ‘2D’ or ‘3D’ options will only request that specific license type if it is available. Default: ‘default’.
save_path (str) – Name of the path where the simulation file will be created and saved. Default: ‘.’.
verbose (bool) – Whether to run EMode in verbose mode for debugging. Default: False.
roaming (bool) – Set the license manager to roaming mode. Normal mode (roaming = False) re-checks the license connection every 30 minutes, allowing licenses to reset after 30 minutes if the internet connection fails. Roaming mode (roaming = True) can be used to extend the license re-check to 3 days to support long simulations without continuously re-checking the license. Default: False.
open_existing (bool) – Whether to open an existing file or to start a new simulation. Default: False.
new_name (bool or str) – New name of opened existing file so the original file does not get modified. If False the original name is used. The extension ‘.eph’ will be added to this name. Default: False.
priority (str) – Set the CPU process priority. ‘pH’: High; ‘pAN’: Above normal; ‘pN’: Normal; ‘pBN’: Below normal; ‘pI’: Idle. Default: ‘pN’.
Functions
The emodeconnection
package provides access to the EMode simulation files without using an active EMode license. This is helpful for analyzing simulation data without checking out an EMode license or for sharing the EMode simulation results with a collaborator who does not have an EMode license.
- static open_file(simulation_name)
Returns an EMode simulation file name with the extension “.mat” to be passed to the load() function.
- Parameters:
simulation_name (str) – Name of the simulation file. The “.mat” extension is optional to include with the name. Default: ‘emode’.
- Returns:
Name of the specified EMode simulation file if it is available.
- Return type:
char array
- static get_(variable, simulation_name)
Returns the contents of a specified variable from an EMode simulation file with the extension “.mat”.
- Parameters:
variable (str) – Name of the variable to return from EMode. Default: ‘emode’.
simulation_name (str) – Name of the simulation file. The “.mat” extension is optional to include with the name.
- Returns:
Requested item from EMode.
- Return type:
int, float, str, or array-like
- static inspect_(simulation_name)
Get the names of all variables from EMode simulation file with the extension “.mat”.
- Parameters:
simulation_name (str) – Name of the simulation file. The “.mat” extension is optional to include with the name. Default: ‘emode’.
- Returns:
List of names of all variables available in the EMode simulation file. Any of these variables can be extracted to the user with the get_() function.
- Return type:
list
File Download
The latest version of emodeconnection.m
can also be downloaded here, which can be added to the EMode directory under Program Files: emodeconnection.m
. This is not necessary to setup EMode with MATLAB, and it is only intended for updating this connection package without re-installing EMode.
C:\Program Files\EMode Photonix\EMode\emodeconnection.m