Exports RCWA engine grating characterization data to a JSON or LSWM file for use in the Lumerical Sub-Wavelength Model.
Starting in 2026 R1, the Lumerical Sub-Wavelength Model supports two different file formats, a new LSWM format (.lswm) and the legacy JSON format (.json). The options are different for the new format and the legacy format. Options for this script command mirrors options available in the GUI.
For further information on the Lumerical Sub-Wavelength Model, please see the Knowledge Base article on Lumerical Sub-Wavelength Model plugin: Introduction and data Generation.
| Syntax | Description |
|---|---|
| lswmexport(data_source, “file_name.lswm",options); |
Only applicable when exporting to the .lswm format. The script command has the following arguments:
This function does not return any data. |
| lswmexport("RCWA","file_name.json",options); |
Only applicable when exporting to the .json format. Exports RCWA engine grating characterization data to the data.json file. The script command has the following arguments:
This function does not return any data. |
Data source and options for the .lswm format
The following table describes required fields in a struct to use as a data source. Additional fields in the struct is ignored.
| Field | Description |
|---|---|
| grating_characterization | A dataset with the same fields as the grating_characterization result from an RCWA solver. You can add parameters from a sweep to this structure as well. |
| substrate | A dataset with the same fields as substrate from the RCWA solver. You can add parameters from a sweep to this structure as well. |
| span | The span of the RCWA solver used for to obtain the grating characterization and substrate results. This field is an array consisting of [x_span, y_span, z_span].
|
| mirror_k_vector | Required. Whether the source propagation is set to “mirror k vector”. Set to 1 if it is set to “mirror k vector”, set to 0 if it is set to “reverse k vector”. |
| lattice_angle | The angle between lattice vectors of the RCWA unit cell. You can obtain this from the RCWA solver object used to obtain the grating characterization and substrate results. |
The following table describes the fields in the options struct. All fields are optional.
| Field | Description |
|---|---|
| lossless | Defaults to false. Enable this option if the cladding or substrate materials is lossless. |
| interpolate_over_incident_angles | Defaults to false. Enable this option to enable linear interpolation of responses for when incident rays are between angles defined in the RCWA solver. |
| interpolate_over_wavelengths | Defaults to false. Enable this option to enable linear interpolation of responses for when incident rays have a wavelength between the wavelength points from the RCWA solver. |
| truncate_order | Defaults to false. Enable this option to enable truncation of grating orders. When this is set to false, all orders are kept. If this option is enabled, you must provide the minimum and maximum orders as seen below. |
| truncate_order_min | The minimum grating order to keep (inclusive). |
| truncate_order_max | The maximum grating order to keep (inclusive). |
| polarization_interpolation_basis | Defaults to “SP”. Set the basis for interpolating the polarization when the LSWM file is imported, either “SP”, “XY” or “Auto” |
| resample_theta |
If no resample parameter is provided, no resampling is done. Number of points to resample to for the incident angle theta for RCWA sweeps, must be an integer value greater than 2. Out of all the resample options, you can only select one parameter to resample. |
| resample_phi |
If no resample parameter is provided, no resampling is done. Number of points to resample to for the incident angle phi for RCWA sweeps, must be an integer value greater than 2. Out of all the resample options, you can only select one parameter to resample. |
| resample_wavelength |
If no resample parameter is provided, no resampling is done. Number of points to resample to for the incident wavelength for RCWA sweeps, must be an integer value greater than 2. Out of all the resample options, you can only select one parameter to resample. |
Data source and options for the .json format
| Field | Description |
|---|---|
| grating_results_upper |
A struct with the following fields:
|
| grating_results_lower |
A struct with the following fields:
|
Example – .lswm format
Export as a .lswm file with default options from the RCWA solver.
lswmexport("RCWA","rcwa_no_options.lswm");Export as a .lswm file from a dataset constructed from an RCWA solver object.
span = [getnamed("RCWA","x span"), getnamed("RCWA","y span"),getnamed("RCWA","z span")];
latticeVectorAngle = getnamed("RCWA","lattice vector angle");
grating_characterization = getresult("RCWA","grating_characterization");
substrate = getresult("RCWA","substrate");
lswmexport({"grating_characterization":grating_characterization, "substrate":substrate, "lattice_angle":latticeVectorAngle, "mirror_k_vector":1,"span":span},"lswm_from_input_struct.lswm");
Export with options set.
lswmexport("RCWA","rcwa_options.lswm",{"resample_theta":20,"truncate_order":true, "truncate_order_min":0, "truncate_order_max":0, “lossless” :1, “interpolate_over_incident_angles”:1});Example – .json format
Export as a .json file with default options from the RCWA solver.
lswmexport("RCWA","rcwa_no_options.json");Export as a .json file with upper and lower layer lossless options set.
options = {"grating_results_upper": {"lossless": false}, "grating_results_lower": {"lossless": false}};
lswmexport("RCWA", "filename.json", options);
See Also