Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Steinlechner
pykat
Commits
452ab9f9
Commit
452ab9f9
authored
11 years ago
by
Daniel Brown
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitmaster.atlas.aei.uni-hannover.de:pykat/pykat
parents
ba219bcc
0a7dda36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pykat/components.py
+49
-91
49 additions, 91 deletions
pykat/components.py
with
49 additions
and
91 deletions
pykat/components.py
+
49
−
91
View file @
452ab9f9
...
...
@@ -9,6 +9,7 @@ import pykat.exceptions as pkex
import
pykat
from
pykat.node_network
import
*
from
pykat.exceptions
import
*
import
abc
import
pykat.gui.resources
import
pykat.gui.graphics
...
...
@@ -49,6 +50,8 @@ class NodeGaussSetter(object):
self
.
__node
.
setGauss
(
self
.
__comp
,
self
.
qx
,
complex
(
value
))
class
Component
(
object
):
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
name
):
self
.
__name
=
name
self
.
_svgItem
=
None
...
...
@@ -117,11 +120,15 @@ class Component(object) :
return
getattr
(
self
,
'
__nodesetter_
'
+
name
)
@staticmethod
@abc.abstractmethod
def
parseFinesseText
(
text
):
"""
Parses Finesse syntax
"""
raise
NotImplementedError
(
"
This function is not implemented
"
)
@staticmethod
@abc.abstractmethod
def
getFinesseText
(
self
):
"""
Base class for individual
f
inesse optical components
"""
"""
Base class for individual
F
inesse optical components
"""
raise
NotImplementedError
(
"
This function is not implemented
"
)
def
getQGraphicsItem
(
self
):
...
...
@@ -136,8 +143,6 @@ class Component(object) :
@property
def
id
(
self
):
return
self
.
__id
class
Param
(
float
):
def
__new__
(
self
,
name
,
value
):
return
float
.
__new__
(
self
,
SIfloat
(
value
))
...
...
@@ -147,17 +152,12 @@ class Param(float):
name
=
property
(
lambda
self
:
self
.
__name
)
class
mirror
(
Component
):
def
__init__
(
self
,
name
,
node1
,
node2
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
Component
.
__init__
(
self
,
name
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
class
AbstractMirrorComponent
(
Component
):
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
name
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
super
(
AbstractMirrorComponent
,
self
).
__init__
(
name
)
self
.
__r_ap
=
SIfloat
(
r_ap
)
self
.
__mass
=
SIfloat
(
mass
)
self
.
__R
=
SIfloat
(
R
)
self
.
__T
=
SIfloat
(
T
)
self
.
__phi
=
SIfloat
(
phi
)
...
...
@@ -165,6 +165,20 @@ class mirror(Component):
self
.
__Rcy
=
SIfloat
(
Rcy
)
self
.
__xbeta
=
SIfloat
(
xbeta
)
self
.
__ybeta
=
SIfloat
(
ybeta
)
self
.
__mass
=
SIfloat
(
mass
)
self
.
__r_ap
=
SIfloat
(
r_ap
)
def
getAttributeText
(
self
):
rtn
=
[]
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"
attr {0} Rcx {1}
"
.
format
(
self
.
name
,
self
.
__Rcx
))
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"
attr {0} Rcy {1}
"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"
attr {0} xbeta {1}
"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"
attr {0} ybeta {1}
"
.
format
(
self
.
name
,
self
.
__ybeta
))
if
self
.
mass
!=
0
:
rtn
.
append
(
"
attr {0} mass {1}
"
.
format
(
self
.
name
,
self
.
__mass
))
if
self
.
r_ap
!=
0
:
rtn
.
append
(
"
attr {0} r_ap {1}
"
.
format
(
self
.
name
,
self
.
__r_ap
))
return
rtn
@property
def
r_ap
(
self
):
return
Param
(
'
r_ap
'
,
self
.
__r_ap
)
...
...
@@ -223,6 +237,13 @@ class mirror(Component):
self
.
Rcx
=
SIfloat
(
value
)
self
.
Rcy
=
SIfloat
(
value
)
class
mirror
(
AbstractMirrorComponent
):
def
__init__
(
self
,
name
,
node1
,
node2
,
R
=
0
,
T
=
0
,
phi
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
super
(
mirror
,
self
).
__init__
(
name
,
R
,
T
,
phi
,
Rcx
,
Rcy
,
xbeta
,
ybeta
,
mass
,
r_ap
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
(
"
"
)
...
...
@@ -244,20 +265,14 @@ class mirror(Component):
values
.
pop
(
0
)
# remove initial value
return
mirror
(
values
[
0
],
values
[
4
],
values
[
5
],
R
=
values
[
1
],
T
=
1.0
-
SIfloat
(
values
[
1
])
-
SIfloat
(
values
[
2
]),
phi
=
values
[
3
])
def
getFinesseText
(
self
):
rtn
=
[]
rtn
.
append
(
'
m {0} {1} {2} {3} {4} {5}
'
.
format
(
self
.
name
,
self
.
__
R
,
self
.
__
T
,
self
.
__
phi
,
self
.
name
,
self
.
R
,
self
.
T
,
self
.
phi
,
self
.
nodes
[
0
].
name
,
self
.
nodes
[
1
].
name
))
if
self
.
r_ap
!=
0
:
rtn
.
append
(
"
attr {0} r_ap {1}
"
.
format
(
self
.
name
,
self
.
__r_ap
))
if
self
.
mass
!=
0
:
rtn
.
append
(
"
attr {0} mass {1}
"
.
format
(
self
.
name
,
self
.
__mass
))
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"
attr {0} Rcx {1}
"
.
format
(
self
.
name
,
self
.
__Rcx
))
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"
attr {0} Rcy {1}
"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"
attr {0} xbeta {1}
"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"
attr {0} ybeta {1}
"
.
format
(
self
.
name
,
self
.
__ybeta
))
rtn
.
append
(
super
(
mirror
,
self
).
getAttributeText
())
return
rtn
...
...
@@ -267,76 +282,22 @@ class mirror(Component):
return
self
.
_svgItem
class
beamSplitter
(
Component
):
def
__init__
(
self
,
name
,
node1
,
node2
,
node3
,
node4
,
R
=
0
,
T
=
0
,
phi
=
0
,
alpha
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
):
Component
.
__init__
(
self
,
name
)
class
beamSplitter
(
AbstractMirror
Component
):
def
__init__
(
self
,
name
,
node1
,
node2
,
node3
,
node4
,
R
=
0
,
T
=
0
,
phi
=
0
,
alpha
=
0
,
Rcx
=
0
,
Rcy
=
0
,
xbeta
=
0
,
ybeta
=
0
,
mass
=
0
,
r_ap
=
0
):
super
(
beamSplitter
,
self
).
__init__
(
name
,
R
,
T
,
phi
,
Rcx
,
Rcy
,
xbeta
,
ybeta
,
mass
,
r_ap
)
self
.
_requested_node_names
.
append
(
node1
)
self
.
_requested_node_names
.
append
(
node2
)
self
.
_requested_node_names
.
append
(
node3
)
self
.
_requested_node_names
.
append
(
node4
)
self
.
__R
=
SIfloat
(
R
)
self
.
__T
=
SIfloat
(
T
)
self
.
__alpha
=
SIfloat
(
alpha
)
self
.
__phi
=
SIfloat
(
phi
)
self
.
__Rcx
=
SIfloat
(
Rcx
)
self
.
__Rcy
=
SIfloat
(
Rcy
)
self
.
__xbeta
=
SIfloat
(
xbeta
)
self
.
__ybeta
=
SIfloat
(
ybeta
)
@property
def
R
(
self
):
return
Param
(
'
R
'
,
self
.
__R
)
@R.setter
def
R
(
self
,
value
):
self
.
__R
=
SIfloat
(
value
)
@property
def
T
(
self
):
return
Param
(
'
T
'
,
self
.
__T
)
@T.setter
def
T
(
self
,
value
):
self
.
__T
=
SIfloat
(
value
)
@property
def
phi
(
self
):
return
Param
(
'
phi
'
,
self
.
__phi
)
@phi.setter
def
phi
(
self
,
value
):
self
.
__phi
=
SIfloat
(
value
)
@property
def
alpha
(
self
):
return
Param
(
'
alpha
'
,
self
.
__alpha
)
@alpha.setter
def
alpha
(
self
,
value
):
self
.
__alpha
=
SIfloat
(
value
)
@property
def
Rcx
(
self
):
return
Param
(
'
Rcx
'
,
self
.
__Rcx
)
@Rcx.setter
def
Rcx
(
self
,
value
):
self
.
__Rcx
=
SIfloat
(
value
)
@property
def
Rcy
(
self
):
return
Param
(
'
Rcy
'
,
self
.
__Rcy
)
@Rcy.setter
def
Rcy
(
self
,
value
):
self
.
__Rcy
=
SIfloat
(
value
)
@property
def
xbeta
(
self
):
return
Param
(
'
xbeta
'
,
self
.
__xbeta
)
@xbeta.setter
def
xbeta
(
self
,
value
):
self
.
__xbeta
=
SIfloat
(
value
)
@property
def
ybeta
(
self
):
return
Param
(
'
ybeta
'
,
self
.
__ybeta
)
@ybeta.setter
def
ybeta
(
self
,
value
):
self
.
__ybeta
=
SIfloat
(
value
)
@property
def
Rc
(
self
):
if
self
.
Rcx
==
self
.
Rcy
:
return
self
.
Rcx
else
:
return
[
self
.
Rcx
,
self
.
Rcy
]
@Rc.setter
def
Rc
(
self
,
value
):
self
.
Rcx
=
SIfloat
(
value
)
self
.
Rcy
=
SIfloat
(
value
)
@staticmethod
def
parseFinesseText
(
text
):
values
=
text
.
split
(
"
"
)
...
...
@@ -362,15 +323,12 @@ class beamSplitter(Component):
rtn
=
[]
rtn
.
append
(
'
bs {0} {1} {2} {3} {4} {5} {6} {7} {8}
'
.
format
(
self
.
name
,
self
.
__
R
,
self
.
__
T
,
self
.
__
phi
,
self
.
__
alpha
,
self
.
nodes
[
0
].
name
,
self
.
name
,
self
.
R
,
self
.
T
,
self
.
phi
,
self
.
alpha
,
self
.
nodes
[
0
].
name
,
self
.
nodes
[
1
].
name
,
self
.
nodes
[
2
].
name
,
self
.
nodes
[
3
].
name
))
if
self
.
Rcx
!=
0
:
rtn
.
append
(
"
attr {0} Rcx {1}
"
.
format
(
self
.
name
,
self
.
__Rcx
))
if
self
.
Rcy
!=
0
:
rtn
.
append
(
"
attr {0} Rcy {1}
"
.
format
(
self
.
name
,
self
.
__Rcy
))
if
self
.
xbeta
!=
0
:
rtn
.
append
(
"
attr {0} xbeta {1}
"
.
format
(
self
.
name
,
self
.
__xbeta
))
if
self
.
ybeta
!=
0
:
rtn
.
append
(
"
attr {0} ybeta {1}
"
.
format
(
self
.
name
,
self
.
__ybeta
))
rtn
.
append
(
super
(
beamSplitter
,
self
).
getAttributeText
())
return
rtn
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment