The properties of the elements in your library are determined by the element’s source data. The element source data is stored in a JSON file in the element’s folder in the source folder. For more information on the element source data files, see Model Source Data.
At the moment, the element source data can’t be edited in the CML Compiler graphical user interface (GUI). To make small changes to the source data, the source data files can be opened in a JSON or text editor to make the updates directly in the source data file. To make more significant changes to the source data, we recommend using Lumerical’s scripting language to edit the source data files.
Editing Element Source Data with Lumerical Script
Data in the JSON format can be imported into the Script Workspace of Lumerical software using the jsonload script command. This command will import the data in the JSON file into struct variables. The struct can be edited using dot notation to contain the new element source data. The structs can be exported into new JSON file with the jsonsave script command. This new JSON file can then be used as the new source data file for your element.
As a simple example of this approach, here is a script that loads the source data from the Photodetector Lumfoundry Template source data file “pd_c.json”, edits the data, then saves it in a new JSON file:
jsonload("pd_c.json"); # load data into script workspace
model_data.saturation_power_data = 0.2; # update source data
jsonsave("new_pd_c.json", general, ports, parameters, model_data, QA); # export data to new JSON file
Alternatively, instead of importing, editing, then exporting the data, a script can be used to create a new source data file from scratch. This approach is used to generate the CML Compiler source data files in these Application Gallery examples:
- Grating Coupler
- PN Depletion Phase Shifter
- Waveguide (FDE)
- Multimode Interference (MMI) Coupler
- Ring Modulator
- Vertical Photodetector
The toscript script command can be useful for creating scripts to write the source data files from scratch. This command generates a script that creates an existing variable in the Script Workspace. This can be used to generate scripts to create the source data structs that can be exported to the source data JSON files. Here is a script that takes an existing source data file (most likely from a Lumfoundry Template element) and creates a script file that generates that source data file from scratch:
clear; # clear existing variables
source_filepath = "pd_c.json";
output_filename = "create_pd_c_source_data" + ".lsf";
jsonload(source_filepath); # load in existing source data
write(output_filename, "", "overwrite"); # overwrite output file
# write scripts to generate data structs to output file
if (exist("general")) {
write(output_filename, toscript(general));
}
if (exist("ports")) {
write(output_filename, toscript(ports));
}
if (exist("parameters")) {
write(output_filename, toscript(parameters));
}
if (exist("model_data")) {
write(output_filename, toscript(model_data));
}
if (exist("QA")) {
write(output_filename, toscript(QA));
}
if (exist("statistical")) {
write(output_filename, toscript(statistical));
}
if (exist("FOMs")) {
write(output_filename, toscript(FOMs));
}