Changes
Page history
improved example
authored
Mar 14, 2020
by
joha2
Show whitespace changes
Inline
Side-by-side
Home.md
View page @
c8694071
...
...
@@ -15,30 +15,41 @@ For the underlying physical stuff, please read the fundamental manual. :-)
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 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
the
convenience functions
```
python
import
pyrateoptics
from
pyrateoptics.core.functionobject
import
FunctionObject
from
pyrateoptics.raytracer.analysis.optical_system_analysis
\
import
OpticalSystemAnalysis
components
=
[
(
{
"
shape
"
:
"
Asphere
"
,
"
curv
"
:
0.01
,
"
cc
"
:
-
1.0
,
"
coefficients
"
:
[
0.0
,
-
0.001
]},
{
"
decz
"
:
10.
},
None
,
"
s1
"
,
{
"
is_stop
"
:
True
}
{
"
decz
"
:
10.
},
1.5
,
"
s1
"
,
{
"
is_stop
"
:
True
}
),
(
{
"
shape
"
:
"
Biconic
"
,
"
curvx
"
:
0.001
,
"
curvy
"
:
-
0.01
},
{
"
decz
"
:
20
.
,
"
tiltx
"
:
0.1
},
None
,
"
s2
"
,
{}
{
"
decz
"
:
5
.
,
"
tiltx
"
:
0.1
},
None
,
"
s2
"
,
{}
),
(
{
"
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
]}),
"
coefficients
"
:
[
-
0.25
,
0.
,
0.
,
-
0.25
,
0.
,
1.
,
0.
,
0.
,
0.
]}),
(
1.0
,
{
"
shape
"
:
"
Conic
"
,
"
curv
"
:
0.01
,
"
cc
"
:
-
1
})]},
{
"
decz
"
:
20.
,
"
tiltx
"
:
0.1
},
None
,
"
s3
"
,
{
"
is_mirror
"
:
True
}
{
"
decz
"
:
35.
,
"
tiltx
"
:
0.1
},
None
,
"
s3
"
,
{
"
is_mirror
"
:
True
}
),
(
{
"
shape
"
:
"
Conic
"
,
"
curv
"
:
0.01
,
"
cc
"
:
-
1.0
},
{
"
decz
"
:
-
10.
},
None
,
"
im
"
,
{}
)
]
# Notice: Check: The Zernike Fringe power term compensates the conic
# in s3, such that there is only the AST left. The AST is symmetric
# to the y axis such that there is a straight line drawn, later.
(
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. There is also a convenience function for rotationally
...
...
@@ -46,17 +57,22 @@ components = [
tiltx_s2
=
s
.
elements
[
"
stdelem
"
].
surfaces
[
"
s2
"
].
rootcoordinatesystem
.
tiltx
tiltx_s3
=
s
.
elements
[
"
stdelem
"
].
surfaces
[
"
s3
"
].
rootcoordinatesystem
.
tiltx
tiltx_s3
.
to_pickup
((
FunctionObject
(
"
f = lambda x: -x
"
,
[
"
f
"
]),
"
f
"
),
(
tiltx_s2
,))
tiltx_s3
.
to_pickup
((
FunctionObject
(
"
f = lambda x: -x
"
,
[
"
f
"
]),
"
f
"
),
(
tiltx_s2
,))
s
.
rootcoordinatesystem
.
update
()
# Setting tiltx of s3 as -tiltx of s2 via pickup and update coordinate systems
# afterwards.
pyrateoptics
.
listOptimizableVariables
(
s
,
max_line_width
=
75
)
osa
=
OpticalSystemAnalysis
(
s
,
rt
,
name
=
"
osa
"
)
osa
.
aim
(
21
,
{
"
radius
"
:
5
})
rays
=
osa
.
trace
()
# pyrateoptics.listOptimizableVariables(s, max_line_width=75)
# Lists optimizable variables (the identifiers are keys to a dict which
# collects them all).
pyrateoptics
.
draw
(
s
)
pyrateoptics
.
draw
(
s
,
rays
)
# This function can get a list of raypath argument to draw rays.
```
...
...
...
...