Solver Functions#
The functions within this category are related to the optimization aspects within Zemax.
- skZemax.skZemax_subfunctions._solver_functions.Solver_GetNamesOfAllSolveTypes(self, print_to_console: bool = False, in_surface: int | ZOSAPI_Editors_LDE_ILDERow = None) list | dict[list][source]#
This function builds a list of all the solve type settings in Zemax. This can be useful to look up what one may want to code as input to functions like
Solver_LDESurfaceProperty_ForValue().There are many combinations so it is recommended that a user see the Zemax decimation first (the ISolve interfaces in the ZOS-API help and the main help PDF section 2.3.1.4. Solve Types).
If one just wants to see the solve types only, this function will run very quickly and can be called with in_surface=None.
If in_surface is not None, then this function will look up all possible solves and the parameters which can be set for the given surface. This is not recommended as it may take time on the order of minutes to execute, but it is here if you can find it helpful.
- Parameters:
print_to_console (bool, optional) – If True will print to console, defaults to False
in_surface (Union[int, ZOSAPI_Editors_LDE_ILDERow], optional) – If a surface (index or object) if given, will look up all solves/parameters of the surface, defaults to None
- Returns:
If in_surface=None, then a list is returned with only the names of the solve types. If a surface is given, then the information is returned as dict of lists formatted as: dict[solve_type][‘surface_property’] = [parameters]
- Return type:
Union[list, dict]
- skZemax.skZemax_subfunctions._solver_functions.Solver_HammerOptimization(self, secondsRunning: float = 10.0)[source]#
This feature automates the repetitive optimization of a design to escape local minima in the merit function.
The Hammer Optimization algorithm can also be used effectively on partially optimized designs that were not generated with Global Optimization.
- Parameters:
secondsRunning (float, optional) – The seconds to run the optimization for, defaults to 10.0
- skZemax.skZemax_subfunctions._solver_functions.Solver_LDEMakeSurfacePropertyFixed(self, in_surface: int | ZOSAPI_Editors_LDE_ILDERow, propty: str)[source]#
Sets the property of the surface to be fixed.
- Parameters:
in_surface (Union[int, ZOSAPI_Editors_LDE_ILDERow]) – The surface to set - either an index or object.
propty (str) – A string identifying the property to make variable - this will be one of the object’s column properties (keys in dict of
LDE_GetAllColumnDataOfSurface()).
- skZemax.skZemax_subfunctions._solver_functions.Solver_LDEMakeSurfacePropertyVariable(self, in_surface: int | ZOSAPI_Editors_LDE_ILDERow, property: str)[source]#
Sets the property of the surface variable.
- Parameters:
in_surface (Union[int, ZOSAPI_Editors_LDE_ILDERow]) – The surface to set - either an index or object.
property (str) – A string identifying the property to make variable - this will be one of the object’s column properties (keys in dict of
LDE_GetAllColumnDataOfSurface()).
- skZemax.skZemax_subfunctions._solver_functions.Solver_LDESurfaceProperty_ForValue(self, in_surface: int | ZOSAPI_Editors_LDE_ILDERow, property: str | int, solve_type: str, params: dict)[source]#
Solves the property of the surface for a the parameters of the solve type.
There are a fair number of combinations/settings which this function can implement. It is recommended that the user refer to the documentation of Zemax (the ISolve interfaces in the ZOS-API help and the main help PDF section 2.3.1.4. Solve Types). However, to compliment this, skZemax provides
Solver_GetNamesOfAllSolveTypes()to help one look up the information in python - but this is not recommend over reading the documentation.- Parameters:
in_surface (Union[int, ZOSAPI_Editors_LDE_ILDERow]) – The surface to set - either an index or object.
property (Union[str,int]) – A string identifying the property to make variable - this will be one of the object’s column properties (keys in dict of
LDE_GetAllColumnDataOfSurface()).solve_type (str) – the solve type to use. See output of
Solver_GetNamesOfAllSolveTypes()with in_surface=None.params (dict) – The dict of params should have the properties and values for this solve. See
Solver_GetNamesOfAllSolveTypes()with in_surface=in_surface.
- skZemax.skZemax_subfunctions._solver_functions.Solver_LocalOptimization(self, use_DampedLeastSquares: bool = True, numCores: int | None = None) None[source]#
Runs local optimization based on the merit functions.
This function assumes the merits are already set up.
- Parameters:
use_DampedLeastSquares (bool, optional) – If should use DLS - which is recommended. If false will use Othogonal Descent (OD), which for systems with inherently noisy merit functions, such as non-sequential systems. OD will usually outperform DLS. defaults to True
numCores (int, optional) – Number of computer cores to use, defaults to None (will use all)
- skZemax.skZemax_subfunctions._solver_functions.Solver_MCEMakeConfigOpVariable(self, in_op: int | ZOSAPI_Editors_MCE_IMCERow, config_number: int) ZOSAPI_Editors_MCE_IMCERow[source]#
Sets the property of the ZOSAPI_Editors_MCE_IMCERow (MCE operand) for the configuration number to a variable solve.
In more plane terms, this will apply an MCE operand to different (multi-)configuration numbers of Zemax.
- Parameters:
in_op (Union[int, ZOSAPI_Editors_MCE_IMCERow]) – the MCR operand (either index or object)
config_number (int) – The Zemax (multi-)configuration number.
- Returns:
The operand object.
- Return type:
ZOSAPI_Editors_MCE_IMCERow
- skZemax.skZemax_subfunctions._solver_functions.Solver_MCEMakeConfigOp_ForValue(self, in_op: int | ZOSAPI_Editors_MCE_IMCERow, config_number: int, solve_type: str, params: dict) ZOSAPI_Editors_MCE_IMCERow[source]#
Sets the property property of the ZOSAPI_Editors_MCE_IMCERow (MCE operand) for the configuration number to a solve for value.
This is the Zemax (multi-)configuration version of
Solver_LDESurfaceProperty_ForValue(). So see that function for more detail.- Parameters:
in_op (Union[int, ZOSAPI_Editors_MCE_IMCERow]) – the MCR operand (either index or object)
config_number (int) – The Zemax (multi-)configuration number.
solve_type – the solve type to use.
params (dict) – The dict of params should have the properties and values for this solve.
- Returns:
The MCR operand object.
- Return type:
ZOSAPI_Editors_MCE_IMCERow