Analysis
Analysis is an extension function for three basic solvers. In this section, we will introduce the coding method of analysis corresponding to FDE, FDTD and EME. The types of the analysis are 'fde_analysis', 'eme_analysis', 'overlap', 'far_field', 'mode_expansion'.
7.1 FDE Analysis
In FDE analysis, different modes supported by the structure can be calculated, bent waveguides can also be analyzed, and the evolution of mode characteristics with wavelength can be studied.The properties of FDE analysis are as follows。
add_analysis(
name: str,
type: Literal["fde_analysis"],
property: dict,
)
7.1.1 Workflow id
The name of the result folder generated by the simulation solver, which can be obtained when the simulation solver is completed. The script for obtaining the workflow id is shown below.
workflow_id_name = simu_res.workflow_id
7.1.2 Modal Analysis
Parameter | Type | Default | Description |
---|---|---|---|
calculate_modes | boolean | False | The eigenmode supported by the structure will be solved. |
mesh_structure | boolean | False | Generate an images of mesh structure , which is very useful for checking material settings. |
wavelength | number | 1.55 | The wavelength used to solve the modes. |
wavelength_offset | number | 0 | The wavelength offset used to solve the modes. |
number_of_trial_modes | integer | 10 | The maximum number of modes stored in the mode list. |
search | string | max_index | Select 'max_index' or 'near_n' to define the effective index for mode calculation. |
n | number | 1 | Specify the value of effective index for mode calculation, when 'serach' selects 'near_n '. |
calculate_group_index | boolean | False | Calculate the group index of the mode. |
bent_waveguide: the setting of the bending attribute is only valid when the bending waveguide is enabled.
Parameter | Type | Default | Description |
---|---|---|---|
bent_waveguide | boolean | False | Choose whether the waveguide is bent. |
radius | number | 1e6 | The curvature radius of the bend waveguide. |
orientation | number | 0 | The direction of the bent waveguide is defined by angle, measured in degrees. |
location | string | simulation_center | Calculate the position of waveguide bending, options is 'simulation_center'. |
7.1.3 Frequency Analysis
Parameter | Type | Default | Description |
---|---|---|---|
frequency_analysis | boolean | False | Choose whether to calculate the frequency sweep analysis results of the modes. |
start_wavelength | number | 1.55 | The start wavelength for the calculation modes. |
stop_wavelength | number | 1.499 | The stop wavelength for the calculation modes. |
number_of_points | integer | 10 | The number of points to be calculated within the range. |
effective_index | number | 1 | Specify the value of effective index for mode calculation. Valid when not tracking a selected mode. |
number_of_trial_modes | number | 1 | Sets the maximum number of modes to use for the frequency sweep. |
Example: The following script demonstrates how to add FDE analysis and set mode analysis and frequency analysis for it. This script assumes that the FDE solver has already been setup, and the pj is an instance of the Project.
analysis_name = "FDE_Analysis"
analysis = pj.Analysis()
analysis.add_analysis(name=analysis_name, type="fde_analysis",
property={"workflow_id": simu_res.workflow_id,
"modal_analysis": {"calculate_modes": True, "mesh_structure": True,
"wavelength": 1.55, "number_of_trial_modes": 20,
"search": "max_index",
"calculate_group_index": False,
"bent_waveguide": {"bent_waveguide": False, "radius": 1, "orientation": 0, "location": "simulation_center", }
},
"frequency_analysis": {"frequency_analysis": False,
"start_wavelength": 1.50, "stop_wavelength": 1.60, "number_of_points": 3,
"effective_index": 1, "detailed_dispersion_calculation": False,
}})
result_fde = analysis[analysis_name].run()
7.2 EMEAnalysis
7.1.1 Workflow id
The name of the result folder generated by the simulation solver, which can be obtained when the simulation solver is completed. The script for obtaining the workflow id is shown below.
workflow_id_name = simu_res.workflow_id
7.2.2 EME propagate
eme_propagate: Choose whether to calculation structure S-matrix using all EME solver settings.
override_group_spans: Choose whether to override the group spans settings in EME solver and reset them.
cell_group_settings: In each cell group, the parameters that are allowed to be changed are "span" and "sc".
7.2.3 Periodicity
periodicity: Calculate the results of the periodic structure. periodic_group_definition
Parameter | Type | Default | Description |
---|---|---|---|
start_cell_group | string | - | The cell group at the starting of the periodic structure, 'group_stpan_1' represents the first group, and so on. |
end_cell_group | string | - | The cell group at the ending of the periodic structure, 'group_stpan_1' represents the first group, and so on. |
periods | integer | - | The number of periodic structural regions. |
7.2.4 Group span sweep
Allow setting the length range of group span to obtain transmission results without recalculating the mode of each cell.
Parameter | Type | Default | Description |
---|---|---|---|
group_span_sweep | boolean | False | Calculate the S-matrix as a function of a group span. |
parameter | string | group_span_1 | Select the cell group to sweep, 'group_span_1' represents the first group, and so on |
start | number | 0 | The start length of a cell group span. |
stop | number | 1 | The start length of a cell group span. |
number_of_points | integer | 3 | The number of points to be scanned within the range. |
7.2.5 Wavelength sweep
Using perturbation method to calculate the S-matrix of the structure as a function of wavelength, it assumes that the mode profile does not significantly change with wavelength. It is suitable for devices with significant changes in phase rather than mode distribution within the studied wavelength range, such as MMI and Waveguide Bragg gratings.
Parameter | Type | Default | Description |
---|---|---|---|
wavelength_sweep | boolean | False | Calculate the S-matrix as a function of wavelength. |
start | number | 1.5 | The start wavelength of wavelength sweep. |
stop | number | 1.6 | The end wavelength of wavelength sweep. |
number_of_wavelength_points | integer | 3 | The number of points to be scanned within the range. |
7.2.6 Select source
The following settings affect the results of the profile monitor and do not affect the calculation results of the s matrix.
Parameter | Type | Default | Description |
---|---|---|---|
source_port | object | - | Select the port of the input source in the simulation region. |
select_mode | string | TE | Select the injection mode for the port. |
7.2.7 Override wavelength
wavelength: Override the wavelength used to calculate modes in the EME solver and use to calculate the s-matrix. This parameter takes effect when 'use_wavelength_sweep' of EME solver is true.
Example:
Here is an example of adding EME analysis.
analysis = pj.Analysis()
analysis.add(name="eme_propagate", type="eme_analysis",
property={"workflow_id": eme_base_res.workflow_id, "eme_propagate": True,
"periodicity": {"periodicity": True,
"periodic_group_definition": [{"start_cell_group": "group_span_1",
"end_cell_group": "group_span_1",
"periods": 80}]},
"group_span_sweep": {"group_span_sweep": False,
"parameter": "group_span_1", "start": 41, "stop": 61, "number_of_points": 11},
"wavelength_sweep": {"wavelength_sweep": False,
"start": 1.5, "stop": 1.6, "number_of_wavelength_points": 11},
"select_source": {"source_name": "port_1", "select_mode": "TE"}})
eme_res = analysis["eme_propagate"].run()
7.3 ModeExpansion
7.3.1 Workflow id
The name of the result folder generated by the simulation solver,which can be obtained when the simulation solver is completed. The script for obtaining the workflow id is shown below.
workflow_id_name = simu_res.workflow_id
7.3.2 Mode expansion
direction: Selections are 'positive', 'negative'.
monitors_for_expansion: The name of the power monitor needs to analyze mode expansion.
mode_calculation:
Parameter | Type | Default | Description |
---|---|---|---|
mode_selection | string | - | Selections are 'fundamental', 'fundamental_TE', 'fundamental_TM' 'fundamental_TE_and_TM' and 'user_select'. |
number_of_trial_modes | integer | 20 | The maximum number of modes to search for. |
override_global_monitor_setting | boolean | False | Selects the override settings of the monitor. |
use_source_limits | boolean | False | Choose whether to use light source limits to set the wavelength/frequency range for recording data. |
spacing_type | string | wavelength | Selects are "wavelength" or "frequency" to control the interval at which data is recorded. |
spacing_limit | string | min_max | Selects "min_max" or "center_span" to control of spacing limit setting. |
sample_spacing | string | uniform | Choose whether to record data at uniform intervals. |
use_wavelength_spacing | boolean | True | Choose to use wavelength or frequency to separate data. |
wavelength_min | number | - | Sets frequency or wavelength span for recording data. |
frequency_points | integer | 5 | Sets the number of frequency points for recording data. |
bent_waveguide | boolean | False | Choose to study bent structure. |
Example:
The following script is an example of calculating waveguide mode expansion. This script assumes that FDTD solver and the power monitor have already been set up.
fdtd_res = simu[simu_name].run(
# resources={"compute_resources": "gpu", "gpu_devices": [{"id": 0}]}
)
analysis = pj.Analysis()
analysis.add(name="me_through", type="mode_expansion",
property={"workflow_id": fdtd_res.workflow_id,
"mode_expansion": {"direction": "positive",
"monitors_for_expansion": [{"frequency_monitor": "through"}],
"mode_calculation": {"mode_selection": "user_select", "mode_index": [0, 1, 2, 3],
"override_global_monitor_setting": {"wavelength_center": wavelength, "wavelength_span": 0.1, "frequency_points": 11}}}})
me_res = analysis["me_through"].run()
7.4 Far field
7.4.1 workflow_id
The name of the result folder generated by the simulation solver,which can be obtained when the simulation solver is completed. The script for obtaining the workflow id is shown below.
workflow_id_name = fde_res.workflow_id
7.4.2 huygens_source
You can choose 'from_dataspace' or 'from_monitor' as the data sources for far-field calculation.
7.4.2 field_data
monitor_name: The monitor name was added in the simulation. Only valid when the huygens source selects 'from _monitor'.
data: Use field data from the dataset to calculate the far field. only valid when the huygens source selects 'from _dataspace'.
7.4.3 far_field_settings
Parameter | Type | Default | Description |
---|---|---|---|
projection_method | string | - | Selects 'planar' or 'angular' to calculate far field projection. |
material_index | number | - | The refractive index of the medium to use for far field projection. |
farfield_filter | number | - | The far field filter alpha parameter. |
projection_distance | number | - | The distance is used for far field projection. |
points_in_x | integer | - | The resolution of the far field in the x-direction. |
points_in_y | integer | - | The resolution of the far field in the y-direction. |
farfield_x_span | number | - | The x span of the far field. |
farfield_y_span | number | - | The x span of the far field. |
farfield_x | number | - | The x center position of the far field. |
farfield_y | number | - | The y center position of the far field. |
Example: The following script is an example of calculating the far-field projection of FDE analysis results.
ds = pj.DataSpace()
data_path = f'{os.path.dirname(__file__)}\\projects\\{project_name}\\{far_field_base_workflow_id}\\fde_ana_0.out\\fde_ana_0_fde.modex'
ds.import_data(name= 'fde_mode_0',type = 'field_2d',
property={'path':data_path, 'mode_id':0})
analysis.add(name="Far_Field", type="far_field",
property={
'huygens_source': 'from_dataspace', # selections are ['from_dataspace','from_monitor']
'workflow_id': far_field_base_workflow_id,
'field_data': {"data": ds['fde_mode_0']},
'far_field_settings': {'projection_method': 'planar', # selections are ['planar','angular']
'material_index': 3.7,
'farfield_filter': 0,
'projection_distance': 8000,
'points_in_x': 50,
'points_in_y': 50,
'farfield_x_span': 40,
'farfield_y_span': 40,
'farfield_x': 0,
'farfield_y': 0,}}
)
far_field_res = analysis["Far_Field"].run()
7.4 Overlap
Calculating overlap requires specifying two fields using 'Field_1' and 'Field_2'.
Example: The following script is an example of calculating the overlap between gaussian beam and mode profile.
beam_res = simu[simu_name].run_fde_beam_and_extract(
property={"define_gaussian_beam_by": "waist_size_and_position", # [waist_size_and_position,beam_size_and_divergence],
"waist_radius": 5.2, "distance_from_waist": 1.5, "refractive_index": 1.45, "theta": 0, "phi": 0,
"polarization_angle": 90, "sample_span": 6, "sample_resolution": 200},
savepath=plot_path + "beam_heatmap")
analysis.add(name="overlap", type="overlap",
property={"field_1": {"workflow_id": beam_res.workflow_id, "mode": 0},
"field_2": {"workflow_id": fde_res.workflow_id, "mode": 0},
"optimize_position": True})
overlap_res = analysis["overlap"].run()
overlap_res.extract(
export_csv=True, savepath=plot_path + "overlap")
if not run_options.run_beam:
overlap_res = simu[simu_name].run_fde_overlap_and_extract(
property={"add_global_mode": {"workflow_id": 291, "mode": 0},
"workflow_id": 291, "mode": 0, "optimize_position": True},
export_csv=True, savepath=plot_path + "overlap")
7.5 Generation Rate
Feature Description: The user can use the Power monitor simulation objects to extract the distribution of photogeneration rates in the device.
Example:
if run_options.run:
result_fdtd = simu[simu_name].run(
# resources={"compute_resources": "gpu", "gpu_devices": [{"id": 0}]}
)
""" Analysis """
analysis = pj.Analysis()
analysis.add(name="generation_rate", type="generation_rate",
property={"power_monitor": "power_monitor", "average_dimension": "x", "light_power": 1, "workflow_id": result_fdtd.workflow_id})
gen_res = analysis["generation_rate"].run()
# endregion
# region --- 5. Extract ---
export_options = {"export_csv": True,
"export_mat": True, "export_zbf": True}
gen_res.extract(data="fdtd:generation_rate", savepath=f"{plot_path}genrate", generation_rate_name="generation_rate",
target="intensity", attribute="G", real=True, imag=False, **export_options, show=False)
gen_res.extract(data="fdtd:generation_rate", savepath=f"{plot_path}pabs_total", generation_rate_name="generation_rate",
target="line", attribute="Pabs_total", plot_x="frequency", real=True, imag=False, show=False, export_csv=True)
gen_res.extract(data="fdtd:generation_rate", savepath=f"{plot_path}jsc", generation_rate_name="generation_rate",
target="line", attribute="Jsc", plot_x="frequency", real=True, imag=False, show=False, export_csv=True)
Import Data:
1) Power Monitor: Choice 3D power monitor from Monitors of Simulations.
2) Average Dimension: Choice one’s average dimension of “X”,”Y” or “Z” for 2D simulation of power monitor. Choice the travels through injection plane of optical generation in source injuction direction.
3) Light Power: Define the amount of source power injected into the simulation.