System commands
newproject - Script command
FDTD MODE DGTD CHARGE HEAT FEEM
Creates a new simulation project file. If there is an existing project file in the GUI, the old project file will not be saved.
Syntax | Description |
---|---|
newproject; | Creates a new layout environment. This function does not return any data. |
Examples
Creates a new project with the newproject command.
newproject;
However, for FDTD and MODE, users can have more choices:
For MODE, it can have numerical variables:
Syntax | Description |
---|---|
newproject(option); | The options are
The default option is 1. |
Examples
Creates a new project with the newproject command.
newproject; newproject(2); # open a template using current file and material database
For FDTD, the variables can be either numerical, or string:
Syntax | Description |
---|---|
newproject(option); | The options can be number or string: 1 or 'default': use default file and material database as template 2 or 'RF': use default RF template 3 or 'current': use current file and material database as template 4 or 'existing': open a file browser to select and existing file as a template The default option is 1. Since most material data in the Material Database is for optical frequencies, open a RF project will not modify the original material data in the material database. |
Examples
Creates a new project with the newproject command.
newproject; # open a template for optical frequency simulation newproject('RF');# open a template for RF simulation newproject(2); # open a template for RF simulation
new - Script command
Same as newproject. It creates a new simulation project file. If there is an existing project file in the GUI, the old project file will not be saved.
Syntax | Description |
---|---|
new; | Creates a new project file. |
Examples
Creates a new project with the newcommand.
new;
save - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Saves a simulation project file. If the simulation has been run, the file will also contain the simulation results, such as sweep and optimization data.
Syntax | Description |
---|---|
save; | Open a file browser to save the file. This function does not return any data. |
save(filename); | Save with the specified name to the current working directory. A path can be specified. |
Examples
Saves the current profile file
save("project_name"); # saves the file in the current working directory save("C:\Downloads\project_name.fsp") # saves the file in a path specified
load - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Loads a simulation project file. If the simulation has been run, the file will also contain the simulation results.
Syntax | Description |
---|---|
load(filename); | Loads the simulation file. This function does not return any data. |
Examples
Loads a simulation project file.
filename="simulation.fsp"; load(filename); # load the file in the current working directory load("C:\Downloads\project_name.fsp") # load the file in a path specified
del - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Deletes a file. A path can be specified.
Syntax | Description |
---|---|
del("filename"); rm("filename"); | Deletes the file "filename". This function does not return any data. |
Examples
Deletes a file.
del("project_name.fsp") # deletes the file in the current working directory del("C:\Downloads\project_name.fsp") # deletes the file in a path specified
rm - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Deletes a file. A path can be specified.
Syntax | Description |
---|---|
del("filename"); rm("filename"); | Deletes the file "filename". This function does not return any data. |
Examples
Deletes a file.
del("project_name.fsp") # deletes the file in the current working directory del("C:\Downloads\project_name.fsp") # deletes the file in a path specified
ls - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Lists files in a directory. Files other than Lumerical project files are also listed.
Syntax | Description |
---|---|
out = dir; out = ls; | The output is a string. Use ?dir; to write the value to the screen. |
out = dir("directory"); out = ls("directory"); | Lists the files in the specified directory. For example, ?ls("C:\Downloads"); |
Example
Uses the splitstring command to get the contents of a directory in a cell (ie. string) array. Then loop through the array looking for all FDTD project files (.fsp).
files = splitstring(dir,endl); # directory contents in a cell(string) array for(i=1:length(files)) { # loop over all files if (findstring(files{i},"fsp") != -1) { # look for 'fsp' files if (fileexists(files{i})) { # check if the file exists ?files{i}; # output file name load(files{i}); # load file } } }
dir - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Lists files in a directory. Files other than Lumerical project files are also listed.
Syntax | Description |
---|---|
out = dir; out = ls; | The output is a string. Use ?dir; to write the value to the screen. |
out = dir("directory"); out = ls("directory"); | Lists the files in the specified directory. For example, ?ls("C:\Downloads"); |
Example
Uses the splitstring command to get the contents of a directory in a cell (ie. string) array. Then loop through the array looking for all FDTD project files (.fsp).
files = splitstring(dir,endl); # directory contents in a cell(string) array for(i=1:length(files)) { # loop over all files if (findstring(files{i},"fsp") != -1) { # look for 'fsp' files if (fileexists(files{i})) { # check if the file exists ?files{i}; # output file name load(files{i}); # load file } } }
cd - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Changes the directory. The directory is where the file is saved by default.
Syntax | Description |
---|---|
cd; | Opens a window to browse to a directory. This function does not return any data. |
cd("directory"); | Changes the working directory to "directory". Whenever you open an fsp file or run a script file, it will set the working directory to the directory of the file opened. |
Examples
Moves to the subdirectory "data".
?pwd; C:\demo path=pwd; cd(path+"\data"); ?pwd; C:\demo\data
pwd - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the current working directory.
Syntax | Description |
---|---|
out = pwd; | Returns the current working directory as a string. |
Examples
Prints the current working directory to the screen.
?path=pwd; C:\demo
cp - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Copies a file. The copy can be created in a specified path.
Syntax | Description |
---|---|
cp("file1","file2"); | Makes a copy of file1 called file2. This function does not return any data. |
cp("path1\file1","path2\file2"); | Copies file1 in path1 to file2 in path2. |
Examples
Makes a copy of "myscript.lsf" in c:\working called "temp.lsf".
cp("c:\myscript.lsf","c:\working\temp.lsf");
mv - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Moves a file to a new location. Path can be specified.
Syntax | Description |
---|---|
mv("file1","file2"); | Moves file1 to file2. This function does not return any data. |
mv("path1\file1","path2\file2"); | Moves file1 in path1 to file2 in path2. |
Examples
Moves "myscript.lsf" to c:\working and renames it "temp.lsf".
mv("c:\myscript.lsf","c:\working\temp.lsf");
exit - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Exits the application.
Syntax | Description |
---|---|
exit; | Exits the application. Same as exit(1); This function does not return any data. |
exit(option); | Exits the application. The option can be
The default option is 1. |
Examples
Exits the application, and prompt user to save data.
exit(1);
system - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The system command allows you to have the operating system (OS) execute a command, rather than the Lumerical Script Prompt.
Syntax | Description |
---|---|
system("command"); | Run "command" at the OS command prompt. The system command does not return any data. |
Examples
Opens the text editor Notepad in windows.
system("notepad");
The following example demonstrates how the system command can be used to get the computer's date and time settings (wall-clock time), for example, to time stamp your files. It is necessary to run a system command because the Lumerical script language does not currently have a getDateAndTime scriptcommand. This example shows how to get the time on a Windows machine, but it could easily be modified for other OS. The system command is used to save the current time from the system clock into a file. The read command is then used to read the time from the file.
fname="cur_time.txt"; # file name to store current time cmd="echo %time% >>" + fname; # system command to get current time and write to fname rm(fname); # delete time file system(cmd); # run command to get time and save to file cur_time=read(fname); # read time from file ?cur_time; # current time: Hr, Min, Sec
This example shows how to start a new instance of the Lumerical GUI from a script file on a Windows computer. For example, if you have multiple Lumerical products, you may find it useful to have one product (eg. CHARGE) be able to start a second product (eg. FDTD). The following example will start a new instance of FDTD that runs the script file runAnalysis.lsf.
Two variations of the command are provided. In the first, a new instance of FDTD Solution is started and will run the script file runAnalysis.lsf. When this is executed, the initial instance of the GUI (the one running the system command) will be frozen while the new instance is running. The first instance will continue running once the second instance is closed. Tip: you should add an 'exit' command to the end of the runAnalysis.lsf script so the new instance automatically closes when it reaches the end of the script.
The second variation allows the first instance of the GUI to continue running while the second instance is open.
system('""C:\Program files\Lumerical\v232\bin\fdtd-solutions.exe" -run "C:\temp\runAnalysis.lsf""'); system('start "name" /B "C:\Program files\Lumerical\v232\bin\fdtd-solutions.exe" -run "C:\temp\runAnalysis.lsf"');
The following code can be used on Windows OS to launch an FDTD simulation from the terminal and then immediately close the graphical interface.
# specify command to run from the terminal save; MPICMD = '"C:\Program Files\Lumerical\MPICH2\mpiexec.exe" -n 2'; engineCMD = '"C:\Program files\Lumerical\v232\bin\fdtd-engine.exe"'; simulationCMD = '"' + currentfilename + '"'; ?fullCMD = MPICMD + " " + engineCMD + " " + simulationCMD; # run from terminal system('start "name" /B ' + fullCMD); # exit CAD exit;
fileexists - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Checks if a file exists. The file extension (ie, .fsp, .lms, etc) must be specified. By default, the entire path will be searched.
Syntax | Description |
---|---|
out = fileexists("filename"); | Returns 1 if the file exists Returns 0 if the file does not exist. |
out = fileexists("c:\temp\file.txt"); | Search for a file not in the path |
Examples
Checks if a file exists before opening it.
filename="simulation.fsp"; if (fileexists(filename)) { load(filename); }
Load a simulation project file, if it exists. First check current directory, then check up one directory.
filename="simulation.fsp"; if (fileexists(file)) { load(filename); } else { file = "../"+file; if (fileexists(file)) { load(filename); } else { ?"File not found."; } }
currentfilename - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the current project filename and directory.
Syntax | Description |
---|---|
out = currentfilename; | Returns the current filename as a string. If the current filename is not defined, this function returns an empty string "". |
Examples
Gets the current filename.
?out=currentfilename; C:/Users/myname/Documents/FDTD/myfile.fsp
currentscriptname - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the current script filename and directory.
Syntax | Description |
---|---|
out = currentscriptname; | Returns the current script filename as a string. If entered in the script prompt, this function returns the string "prompt". |
Examples
Gets the current script filename.
?out=currentscriptname; C:/Users/myname/Documents/FDTD/myfile.lsf
filebasename - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Gets the file basename from a string.
Syntax | Description |
---|---|
out = filebasename( "location/filename.ext" ); | Returns the file basename as a string. |
Examples
Isolates the file basename from the full filename.
?filebasename("C:\Users\myname\Documents\FDTD Files\test.fsp"); test
filedirectory - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Gets the file directory from a string.
Syntax | Description |
---|---|
out = filedirectory( "location/filename.ext" ); | Returns the file directory as a string. |
Examples
Isolates the file directory from the full filename.
?filedirectory("C:\Users\myname\Documents\FDTD Files\test.fsp"); C:/Users/myname/Documents/FDTD Files
fileextension - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Gets the file extension from a string.
Syntax | Description |
---|---|
out = fileextension( "name.ext"); | Returns the file extension as a string. |
Examples
Isolates the file extension from the full filename.
?fileextension("C:/Users/myname/Documents/FDTD/myfile.fsp"); fsp
Uses the following code to check with product you are using. This can be helpful if you are trying to write scripts that will be shared between multiple products.
save("myfile"); if(fileextension(currentfilename)=="fsp") { ?"Using FDTD"; } if(fileextension(currentfilename)=="lms") { ?"Using MODE"; } if(fileextension(currentfilename)=="ldev") { ?"Using Finite Element IDE"; } if(fileextension(currentfilename)=="icp") { ?"Using INTERCONNECT"; }
copytoclipboard - Script command
FDTD MODE DGTD CHARGE HEAT FEEM
Copies the selected objects into the system clipboard. Equivalent to 'Ctrl-C'.
Syntax | Description |
---|---|
copytoclipboard; | Copies selected objects to the system clipboard |
Examples
This example shows how to use the copy/paste to clipboard functions to copy an object from a different simulation file into the current simulation file.
# specify file and object names current_file = currentfilename; template_file = "C:\temp\myObjects.fsp"; object_name = "my_grating"; save; #save current file; # save current file load(template_file); # load template file select(object_name); # select object copytoclipboard; # copy object to clipboard load(current_file); # load original file pastefromclipboard; # paste object into file
pastefromclipboard - Script command
FDTD MODE DGTD CHARGE HEAT FEEM
Pastes the contents of the system clipboard into the layout environment. Equivalent to 'Ctrl-V'.
Syntax | Description |
---|---|
pastefromclipboard; | Paste contents of system clipboard |
Examples
See example in copytoclipboard function.
hide - Script command
Hides the graphical user interface, can be used with the show command.
Syntax | Description |
---|---|
hide; | hides the GUI. |
show - Script command
Shows the graphical user interface, can be used with the hide command.
Syntax | Description |
---|---|
show; | shows the GUI. |
cls/clc (Ctrl+L) - Script command
FDTD MODE DGTD CHARGE HEAT FEEM
The clc and cls script commands clear the Script Prompt and optionally clear the Script Prompt history.
If focus is on the Script Prompt, a similar function can be performed with Ctrl+L (clears the Script Prompt but not the Script Prompt history) and Ctrl+Shift+L (clears the Script Prompt as well as the Script Prompt history).
Syntax | Description |
---|---|
clc; cls; Ctrl+L | Clears the Script Prompt, but does not clear the Script Prompt history. This function does not return any data. |
clc(true); cls(true); Ctrl+Shift+L | Clears the Script Prompt, and also clears the Script Prompt history. This function does not return any data. |
Example
The following script commands will create a variable "x", clear the Script Prompt, and display the Script Prompt history.
x=1; clc; # Script Prompt will clear ?history; # display Script Prompt history result: x=1; clc; ?history;
The following script commands will create a variable "x", clear the Script Prompt and Script Prompt history, and display the Script Prompt history.
x=1; clc(true); # Script Prompt will clear and Script Prompt history will be deleted ?history; # display Script Prompt history result: ?history;
clearlogwindow - Script command
Clears the log output log window.
Syntax | Description |
---|---|
clearlogwindow; | clears output log window. |
version - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the current version of the application.
Syntax | Description |
---|---|
out = version; | Returns the version of the application. |
versionfile - Script command
Returns the current version of the file loaded by the application.
Syntax | Description |
---|---|
out = versionfile; | Returns the version of the file loaded by the application. |
fileexpand - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Expands a file name by replacing any environmental variables.
Syntax | Description |
---|---|
fileexpand(filename); | Expands a file name by replacing any environmental variables (defined by setsetting). |
Example
Expand a filename containing the variable LOCAL
?getsetting; LOCAL=C:\Users ?fileexpand("$LOCAL\data.txt");
autosaveon - Script command
This command turns on the feature to automatically save the current project before running a simulation.
Note that this only applies to simulations, not sweeps. Running a sweep will always save the project file before the sweep is run, regardless of the autosave setting.
Syntax | Description |
---|---|
autosaveon; | Automatically saves current project before running a simulation. |
autosaveoff - Script command
This command turns off the feature to automatically save the current project before running a simulation.
Syntax | Description |
---|---|
autosaveoff; | The project will not be saved automatically before running a simulation (default). |
read - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Reads data from a text file as a string. The supported file format is ASCII.
Syntax | Description |
---|---|
read(filename, size); | Read a text file as a string for the user defined size 'size'. The default value for size is 1e+6, if not specified. Note: This function will check for the file in the current working directory. If the file to read from is in a different directory, either specify the full path or change the current working directory. |
Examples
If you have a text file called testfile.txt with the following strings:
String saved in text file
M=read("testfile.txt");
?M; String saved in text file
exist - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns a number based on type of the string used in the command.
Syntax | Description |
---|---|
exist("x") | Returns 0 if there is no variable, operator, built-in function or script file (x.lsf) in the current script path 1 if x is a variable, example: x=5; ?exist(“x”); 2 if x is an operator or built in keyword, example: ?exist(“*”) or ?exist(“for”); 3 if x is a script file in the current script path, called “x.lsf” |
Examples
The following simple examples show the usage of the exist command
a = 1:10; ?exist("a"); result: 1 ?exist("farfield3d"); result: 2
exporthtml - Script command
Generates an html file describing an element.
Syntax | Description |
---|---|
exporthtml (element_name) | Generates an html file describing a custom element. The file lists the element type, symbol, and the list of properties. This command works only for elements in the Custom folder or its sub-folders. |
Example
addelement("CW Laser"); # add element to the Custom folder addtolibrary; # add element to the sub folder "test_folder" of Custom folder addtolibrary("test_folder"); # export html page the CW Laser element in Custom exporthtml("CWL_1"); # export html page of the CW Laser element in "test_folder" exporthtml("test_folder::CWL_1"); # export html pages of all elements in the "test folder" exporthtml("test_folder");
help - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Opens the Lumerical Knowledge Base using the default web browser.
Syntax | Description |
---|---|
help(argument=””); | Opens the Lumerical knowledge base using the default web browser. If no arguments are provided the web browser will open the page with the alphabetical list of all script commands, otherwise it will run a search using the ‘argument’ parameter and open the page with the search results for the ‘argument’ parameter. |
Example
>help; >help("setsparameter");
logmessage - Script command
This function sends messages from scripted elements to the INTERCONNECT output window.
Syntax | Description |
---|---|
logmessage; | This function sends messages from scripted elements to the INTERCONNECT output window. It is specially useful to debug scripted elements. |
operatingsystem - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the current operating system.
Syntax | Description |
---|---|
operatingsystem; | Returns the current operating system. Valid return values are “windows”, “apple” or “linux”. |
Example
>?operatingsystem; windows
setconnectionrouting - Script command
This command sets the connection routing for a given connection.
Syntax | Description |
---|---|
setconnectionrouting (element, port, type); setconnectionrouting (element, type); | This command sets the connection routing for a given connection. If only the element and the type are provided, all connections to the element port will have the same type. If element name, port and type are provided, only the specific element port connection will be affected. type = "direct" or "manhattan". |
findproperty - Script command
This command returns a cell containing all elements in the circuit that have a certain property.
Syntax | Description |
---|---|
findproperty (property, recursive); | Returns a cell containing all elements in the circuit that have property ‘property’. If recursive is true, it will return a flat list (hierarchical) with all the elements in the current scope. The default value for recursive is false. |
findpropertyvalue - Script command
This command returns a cell containing all elements in the circuit that have a certain property with a certain value.
Syntax | Description |
---|---|
findpropertyvalue (property, value, recursive); | Returns a cell containing all elements in the circuit that have property ‘property’ with value ‘value’, if recursive is true, it will return a flat list (hierarchical) with all the elements in the current scope. The default value for recursive is false. |
refresh - Script command
This command reloads the current project.
Syntax | Description |
---|---|
refresh; | Reloads the current project. This is particularly useful when changing the ‘library’ property of a reference element. Reference elements must be manually ‘refreshed’ or reloaded if the ‘library’ property is modified – otherwise the use will have to save and reload the current project. |
Example
>setnamed("WG_1","library","::design kits::pdaflow"); >refresh;
runinitialize - Script command
This script command initializes a step by step simulation.
Syntax | Description |
---|---|
runinitialize; | Initialize a step by step simulation, different from ‘run’ the simulation is only initialized. This command should be used in combination with runstep and runfinalize, and it is typically used for co-simulations. |
runstep - Script command
This script command runs a single simulation step.
Syntax | Description |
---|---|
runstep; | Runs a single simulation step. This command should be used in combination with runinitialize and runfinalize, and it is typically used for co-simulations. |
runfinalize - Script command
This script command finalizes a step by step simulation.
Syntax | Description |
---|---|
runfinalize; | Finalizes a step by step simulation. This command should be used in combination with runinitialize and runstep, and it is typically used for co-simulations. |
waituntildone - Script command
This function only returns after the current simulation is done.
Syntax | Description |
---|---|
waituntildone; | This function only returns after the current simulation is done. It allows to wait for the simulation before performing any other tasks that depends on simulation completion. |
runstartupscripts - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Runs the start-up scripts.
Syntax | Description |
---|---|
runstartupscripts; | Runs the start-up scripts in the order of:
|
Examples
The following examples runs the "runstartupscripts" in INTERCONNECT with the scripts in "Shared Startup.lsf" and "INTERCONNECT Startup.lsf" as below, respectively:
# Shared Startup.lsf clear; ?a = 1; # INTERCONNECT Startup.lsf clear; ?b = 2;
The output result:
runstartupscripts; Shared Startup; result: 1 Running script: /Users/$(Username)/.config/Lumerical/INTERCONNECT Startup.lsf INTERCONNECT Startup; result: 2
Encrypt script commands
encryptscript - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Save a copy of the specified script file in an encrypted format. The new file will have a .lsfx file extension. Encrypting a script allows a script to be shared with others, without allowing them to see the contents of the script.
Syntax | Description |
---|---|
encryptscript("filename.lsf"); | Recommended: Encrypt a copy of the script, not compatible with earlier versions. The new file will be named "filename.lsfx". |
encryptscript("filename.lsf", 1); | Legacy: Encrypt a copy of the script, compatible with earlier versions. |
encryptscript("filename.lsf", "new_filename"); | Specify an alternate file name, not compatible with earlier versions. The new file will be named "filename.lsfx". |
encryptscript("filename.lsf", "new_filename", 1); | Specify an alternate file name, compatible with earlier versions. The new file will be named "filename.lsfx". |
Scripts encrypted with 2020B will not be compatible with 2020A and earlier, unless the additional argument (1) is passed to encryptscript specifying legacy compatibility. Scripts encrypted with 2020A and earlier will continue to be compatible with later versions.
Example
If the script file is already encrypted, user can run the script file by entering the name of the file in the Script Prompt. However, user will not be able to see the content of the file.
filename # it will run the encrypted script file filename.lsfx
List of script commands
getcommands - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the list of available script commands in the current script workspace.
Syntax | Description |
---|---|
?getcommands; | Returns a list of available script commands |
Examples
Returns the list of available script commands in the current script workspace.
?getcommands; + - * / ^ == != =
Starting and stopping scripts
scriptautorun - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Disable or enable running script files automatically by typing the script name.
Syntax | Description |
---|---|
scriptautorun(option); | The options are
|
Examples
The following examples assume you have created a script file called hello_world.lsf that prints the message "hello". You will get the error message "Error: prompt line 3: hello_world is not a valid function or variable name" when running the following commands because scriptautorun is disabled.
clear; scriptautorun(0); #disable autorun hello_world;
When you enable scriptautorun the script file is executed and the message "hello" will appear in the script prompt.
clear; scriptautorun(1); #enable autorun hello_world;
If scriptautorun is disabled you can still run script files using the function feval.
clear; scriptautorun(0); #disable autorun feval("hello_world");
getpath - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Gets the current path. By default, the current working directory and the script sub-directory of the installation directory are in the path. Typically the path is important for setting the location of your script files.
Syntax | Description |
---|---|
out = getpath; | Returns the current path as a string. Use ?getpath; to print it to the screen. |
Examples
Gets the current path.
?getpath; ./ C:/Program Files/Lumerical/2020a/scripts
addpath - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Adds a directory to the path.
This can be helpful when your script and simulation files are located in different directories. Your current working directory will typically be set to the location of your simulation files. addpath can be used to add the location of your script files to the path, which makes it possible to call those scripts without providing the full path each time.
Syntax | Description |
---|---|
addpath("directory"); | Adds a directory to the path. This function does not return any data. |
Examples
Adds a second directory to the path.
?getpath; ./ C:/Program Files/Lumerical/2020a/scripts addpath("C:/demo"); ?getpath; ./ C:/Program Files/Lumerical/2020a/scripts C:/demo
Clears the path.
clearpath; ?getpath; ./
clearpath - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Removes all directories from the script path, except "./".
Syntax | Description |
---|---|
clearpath("directory"); | Remove"directory" from the script path if it is there. |
Examples
See addpath.
which - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Returns the full file pathname for the specified file.
This function can be helpful when you have added several directories to the Lumerical path variable and you want to check which files are being accessed.
Syntax | Description |
---|---|
out = which("filename"); | Returns the pathname of the file "filename" as a string. Use ?which("filename"); to display the result to the screen. |
Examples
Gets the full path and filename of the file results.txt.
file = "results.txt"; # set file name write(file,"my data file"); # create file ?fullPath = which(file); # get full name and path C:/Program Files/Lumerical/FDTD/scripts/results.txt
pause - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Pauses program for a time.
Syntax | Description |
---|---|
pause(time); | Pauses script for time, measured in seconds. Hit the space bar to force the script to continue. Hit the ESCAPE key to break the script at this point. This function does not return any data. |
Examples
Pauses for 5 seconds.
pause(5);
Pauses until user clicks space bar.
?"Part 1 complete. Hit space bar to proceed with part 2."; pause(10000);
break - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Stops a script from executing.
Syntax | Description |
---|---|
break; | Will stop a script file from executing at that line. A warning will be generated. This function does not return any data. |
Examples
The script will stop at this line.
for (i=1:100) { pause(1); break; } Warning: prompt line 3: break command
Escape key to interrupt running Lumerical script
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Interrupts a script or long block of commands.
Syntax | Description |
---|---|
ESCAPE key | To interrupt a script file from running or a long block of commands from executing. A warning will be generated. Sometimes you may need to press escape several times or hold it down to interrupt the script. |
Checking status
issweep - Script command
The script command checks if the simulation is in sweep mode.
Syntax | Description |
---|---|
out = issweep; | Returns true (1 or 0) if the simulation is currently in sweep mode. |
isstruct - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The script command checks whether input is a structure.
Syntax | Description |
---|---|
value= isstruct(input); | Determine whether ‘input’ is a structure. It returns logical 1 (true) if ‘input’ is a structure and logical 0 (false) otherwise. |
Example
>x=struct; >?isstruct(x); result: 1
iscell - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The script command checks whether input is a cell.
Syntax | Description |
---|---|
value= iscell(input); | Determine whether ‘input is a cell. It returns logical 1 (true) if ‘input’ is a cell and logical 0 (false) otherwise. |
Example
>x=cell(3); >?iscell(x); result: 1
isfield - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The script command checks whether input is a field.
Syntax | Description |
---|---|
value= isfield(input, field); | Determine whether ‘input contains filed name ‘field’. It returns logical 1 (true) if ‘input contains ‘field’, and logical 0 (false) otherwise. |
Example
>x=struct; >x.t=10; >?isfield(x,'t'); result: 1
getfield - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The script command returns the value of a field from structure input.
Syntax | Description |
---|---|
value= getfield(input, field); | Returns the value of a ‘field’ from structure ‘input’. |
Example
>x=struct; >x.t=10; >?getfield(x,'t'); result: 10
setfield - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
The script command assigns a value to a structure input field.
Syntax | Description |
---|---|
output= setfield(input, field,value); | Assigns a ‘value’ to a structure ‘input’ ‘field’. |
Example
>x=struct; >x=setfield(x,'t',10); >?x.t; result: 10
Debugging
debug - Script command
FDTD MODE DGTD CHARGE HEAT FEEM INTERCONNECT
Opens the debug utility window. This command is useful for debugging purposes. When this command is used, script will run to the line before the debug command. Then user can start to call other commands to test commands that have been run. Once the utility window is closed, the script lines will continue to run. Multiple debug commands are allowed.
Syntax | Description |
---|---|
debug; | Opens the debug utility window. This command can also be used in the analysis script. |
Examples
This example shows how to use the debug command. This below example shows an error on line 3.
x=linspace(1,10,10); y=linspace(1,10,5); ?x*y; Error: prompt line 3: matrix arguments of * are not the same size x=linspace(1,10,10); y=linspace(1,10,5); debug; # opens the debug utility window. ?x*y;