fixed some minor issues in script authored by joha2's avatar joha2
...@@ -13,50 +13,52 @@ Due to our last refactor the GUI functionality is broken at the moment. ...@@ -13,50 +13,52 @@ Due to our last refactor the GUI functionality is broken at the moment.
For the underlying physical stuff, please read the fundamental manual. :-) For the underlying physical stuff, please read the fundamental manual. :-)
To reproduce some of the following screenshots you may just play around a bit To reproduce some of the following screenshots you may just play around a bit
with the demo files in the ~~main~~ demos directory: `~/pyrate$ python -m demos.demo_optimize`. with the demo files in the ~~main~~ demos directory: `~/pyrate$ python demos/demo_optimize.py`.
For setting up your own system, you may use one of our convenience functions For setting up your own system, you may use one of our convenience functions
```python ```python
import pyrateoptics import pyrateoptics
from pyrateoptics.core.functionobject import FunctionObject
components = [ components = [
( (
{"shape": "Asphere", "curv": 0.01, "cc": -1.0, "coefficients": [0.0, -0.001]},\ {"shape": "Asphere", "curv": 0.01, "cc": -1.0,
"coefficients": [0.0, -0.001]},
{"decz": 10.}, None, "s1", {"is_stop": True} {"decz": 10.}, None, "s1", {"is_stop": True}
), ),
( (
{"shape": "Biconic", "curvx": 0.001, "curvy": -0.01},\ {"shape": "Biconic", "curvx": 0.001, "curvy": -0.01},
{"decz": 20., "tiltx": 0.1}, None, "s2", {} {"decz": 20., "tiltx": 0.1}, None, "s2", {}
), ),
( (
{"shape": "LinearCombination", "list_of_coefficients_and_shapes": {"shape": "LinearCombination", "list_of_coefficients_and_shapes":
[(1.0, {"shape": "ZernikeFringe", "normradius": 10, "coefficients":[0., 0., 0., 0., 0.0, 0.0, 0, 0, 0.0]}),\ [(1.0, {"shape": "ZernikeFringe", "normradius": 10,
(1.0, {"shape": "Conic", "curv": 0.01, "cc": -1})]\ "coefficients": [0., 0., 0., 0., 0.0, 0.0, 0, 0, 0.0]}),
},\ (1.0, {"shape": "Conic", "curv": 0.01, "cc": -1})]},
{"decz": 20., "tiltx": 0.1}, None, "s3", {"is_mirror": True} {"decz": 20., "tiltx": 0.1}, None, "s3", {"is_mirror": True}
) )
] ]
(s, rt) = pyrateoptics.build_simple_optical_system(components, name="s") (s, rt) = pyrateoptics.build_simple_optical_system(components, name="s")
# Notice: It is always a good idea to provide names for systems, elements and components. # Notice: It is always a good idea to provide names for systems, elements
# There is also a convenience function for rotationally symmetric systems `build_rotationally_symmetric_system`. # and components. There is also a convenience function for rotationally
# symmetric systems `build_rotationally_symmetric_system`.
tiltx_s2 = s.elements["stdelem"].surfaces["s2"].rootcoordinatesystem.tiltx tiltx_s2 = s.elements["stdelem"].surfaces["s2"].rootcoordinatesystem.tiltx
tiltx_s3 = s.elements["stdelem"].surfaces["s3"].rootcoordinatesystem.tiltx tiltx_s3 = s.elements["stdelem"].surfaces["s3"].rootcoordinatesystem.tiltx
tiltx_s3.changetype("pickup", tiltx_s3.changetype("pickup",
functionobject=( functionobject=(
FunctionObject("f = function=(lambda x: -x)", ["f"]), FunctionObject("f = lambda x: -x", ["f"]),
"f"), "f"),
args=(tiltx_s2,)) args=(tiltx_s2,))
s.rootcoordinatesystem.update() s.rootcoordinatesystem.update()
# Setting tiltx of s3 as -tiltx of s2 via pickup and update coordinate systems afterwards. # Setting tiltx of s3 as -tiltx of s2 via pickup and update coordinate systems
# Notice that the FunctionObject needs two arguments: the source code and the list of functions # afterwards.
# to be read from dict, while functionobject keyword needs a tuple where the FunctionObject is
# refered together with the function used for the pickup. There you have the opportunity to define
# one FunctionObject for several pickups or other things were functions are needed (i.e. GRIN media). pyrateoptics.listOptimizableVariables(s, max_line_width=75)
# Lists optimizable variables (the identifiers are keys to a dict which
pyrateoptics.listOptimizableVariables(s, maxcol=30) # collects them all).
# Lists optimizable variables (the identifiers are keys to a dict which collects them all).
pyrateoptics.draw(s) pyrateoptics.draw(s)
# This function can get a list of raypath argument to draw rays. # This function can get a list of raypath argument to draw rays.
... ...
......