This library allows users to run optical systems from VirtualLab Fusion directly from a Python script. The results then can be processed with all capabilities that Python offers.
File > Export > Export as XMLpip install -r requirements.txt[paths]
virtuallab = C:\Program Files\Wyrowski Photonics GmbH\VirtualLab Fusion 2023
This enumeration determines what the physical property of a physical value is, e.g. length, time, percentage etc.
Base class for storage of physical values.
physical_property: PhysicalProperty the physical property of the physical valuecomment: str a comment specifying what the physical value actually isClass for storage of real physical values. Inherits from PhysicalValueBase.
value: float the numerical value of the physical valuephysical_property: PhysicalProperty the physical property of the physical valuecomment: str a comment specifying what the physical value actually isThe numerical value needs to be set in the base unit for the according physical property, e.g. length in [m].
Class for storage of complex physical values. Inherits from PhysicalValueBase.
value: Complex the numerical value of the physical valuephysical_property: PhysicalProperty the physical property of the physical valuecomment: str a comment specifying what the physical value actually isThe numerical value needs to be set in the base unit for the according physical property, e.g. length in [m]. The Complex data type is a VL data type. The full name is VirtualLabAPI.Core.Numerics.Complex.
Class for storage of VL IDocument data types, e.g. DataArray2D.
save(path: str, file_name: str) saves the Document
path : locationfile_name : name of the file w/o extension; extension is determined automaticallyClass for parameter definition for parameter runs / scans.
...
<LightPathElement Index="1" Name="Rectangular Grating">
...
<Parameter>
<Name>Stack #2 (Rectangular Grating) | Surface #1 (Rectangular Grating Interface) | Modulation Depth</Name>
<ID>Stack2.LayersAsArray[0].Interface.ModulationDepth</ID>
<ShortName>Modulation Depth</ShortName>
<Value>1.8500000000000001e-06</Value>
<Unit>m</Unit>
<Min>1E-13</Min>
<Max>1.0000000000000001E+300</Max>
</Parameter>
...
</LightPathElement>
...
lpe_index: int index of the LightPathElement (1 for Rectangular Grating in XML)param_name: str name (ID) of the Parameter (Stack2.LayersAsArray[0].Interface.ModulationDepth in XML)values: List[float] the values to be varied in parameter run, in XML:
So in this example the value for the Modulation Depth has to be passed in [m] and has to be in the range of min & max values.
Class holding the results of a detector.
description: str the name of the detectordata: List[List[PhysicalValueBase] or Document] the results, each entry in the list is the result for one runClass holding the optical setup.
change_parameter(lpe_index: int, param_name: str, value: float) changes a parameter of the optical system
lpe_index: int index of the LightPathElementparam_name: str name (ID) of the parametervalue: float the numerical value of the parameterperform(results: List[DetectorResultCollection] = None) -> List[DetectorResultCollection] simulates the optical setup
results: List[DetectorResultCollection] optional parameter, if passed the results will be extendedList[DetectorResultCollection]parameter_scan_1D()
optical_setup: OpticalSetup the optical setup to be scannedparams: ParameterSet the information for the parameter variationList[DetectorResultCollection] the results of the parameter scan for each detectorparameter_scan_2D()
optical_setup: OpticalSetup the optical setup to be scannedparams_1: ParameterSet the information for the parameter variation of the first parameterparams_2: ParameterSet the information for the parameter variation of the second parameterList[DetectorResultCollection] the results of the parameter scan for each detectorOS_PATH = r'resources\GratingEfficiency.os'
Here only one optical setup will be used for demonstration, thus the path is defined as a constant. The path can be either set relative or absolute. For relative paths it's recommended to use the resources folder for storing the os files.
There are 3 predefined methods for simulation. All of them print the results and the simulation time to the console. The parameter scans also provide plotting using the module matplotlib.pyplot.
single_run() simulates the optical setupparameter_scanning_1D() performs a 1D parameter scan varying the modulation depth of the rectangular gratingparameter_scanning_2D() performs a 2D parameter scan varying the modulation depth and the relative slit width of the rectangular gratingif __name__ == '__main__':
#single_run()
parameter_scanning_1D()
#parameter_scanning_2D()
Simply uncomment one of the methods and run the main.py file. Here the 1D parameter scan will be performed.