Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
pygwinc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
30
Issues
30
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gwinc
pygwinc
Commits
cc89719d
Commit
cc89719d
authored
Aug 17, 2018
by
Christopher Wipf
Committed by
Christopher Wipf
Aug 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up quad sus tf calculation 10x, by pre-solving the system symbolically
parent
ea42d0c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
68 deletions
+45
-68
gwinc/suspension.py
gwinc/suspension.py
+45
-68
No files found.
gwinc/suspension.py
View file @
cc89719d
...
...
@@ -15,43 +15,37 @@ FIBER_TYPES = [
]
def
construct_eom_matrix
(
k
,
m
,
f
):
"""construct matrix for equations of motion.
`k` is the array for the spring constants and `f` is the freq
vector.
# quad pendulum equation of motion matrix A =
# [[k0+k1-m0*w**2, -k1, 0, 0],
# [ -k1, k1+k2-m1*w**2, -k2, 0],
# [ 0, -k2, k2+k3-m2*w**2, -k3],
# [ 0, 0, -k3, k3-m3*w**2]])
# diagonal elements: mass and restoring forces
# off-diagonal: coupling to stages above and below
# want TM equations of motion, so index 4
# b = [[0], [0], [0], [1]]
# sympy.linsolve((A, b), x) yields the following two functions
def
tst_force_to_tst_displ
(
k
,
m
,
f
):
"""transfer function for quad pendulum
"""
w
=
2
*
pi
*
f
nstages
=
m
.
size
A
=
zeros
((
nstages
,
nstages
,
f
.
size
),
dtype
=
complex
)
for
n
in
range
(
nstages
-
1
):
# mass and restoring forces (diagonal elements)
A
[
n
,
n
,
:]
=
k
[
n
,
:]
+
k
[
n
+
1
,
:]
-
m
[
n
]
*
w
**
2
# couplings to stages above and below
A
[
n
,
n
+
1
,
:]
=
-
k
[
n
+
1
,
:]
A
[
n
+
1
,
n
,
:]
=
-
k
[
n
+
1
,
:]
# mass and restoring force of bottom stage
A
[
-
1
,
-
1
,
:]
=
k
[
-
1
,
:]
-
m
[
-
1
]
*
w
**
2
return
A
def
calc_transfer_functions
(
A
,
B
,
k
,
f
):
"""calculate transfer function from A/B matrices
k0
,
k1
,
k2
,
k3
=
k
m0
,
m1
,
m2
,
m3
=
m
w
=
2
*
pi
*
f
X3
=
(
k2
**
2
*
(
k0
+
k1
-
m0
*
w
**
2
)
+
(
k1
**
2
-
(
k0
+
k1
-
m0
*
w
**
2
)
*
(
k1
+
k2
-
m1
*
w
**
2
))
*
(
k2
+
k3
-
m2
*
w
**
2
))
/
(
-
k3
**
2
*
(
k1
**
2
-
(
k0
+
k1
-
m0
*
w
**
2
)
*
(
k1
+
k2
-
m1
*
w
**
2
))
+
(
k3
-
m3
*
w
**
2
)
*
(
k2
**
2
*
(
k0
+
k1
-
m0
*
w
**
2
)
-
(
-
k1
**
2
+
(
k0
+
k1
-
m0
*
w
**
2
)
*
(
k1
+
k2
-
m1
*
w
**
2
))
*
(
k2
+
k3
-
m2
*
w
**
2
)))
return
X3
def
top_displ_to_tst_displ
(
k
,
m
,
f
):
"""transfer function for quad pendulum
"""
vlen
=
A
[
0
,
0
,
:].
size
X
=
zeros
([
B
.
size
,
vlen
],
dtype
=
complex
)
for
j
in
range
(
vlen
):
X
[:,
j
]
=
np
.
linalg
.
solve
(
A
[:,
:,
j
],
B
)
# transfer function from the force on the TM to TM motion
hForce
=
zeros
(
f
.
shape
,
dtype
=
complex
)
hForce
[:]
=
X
[
-
1
,
:]
# transfer function from the table motion to TM motion
hTable
=
zeros
(
f
.
shape
,
dtype
=
complex
)
hTable
[:]
=
X
[
0
,
:]
hTable
=
hTable
*
k
[
0
,
:]
return
hForce
,
hTable
k0
,
k1
,
k2
,
k3
=
k
m0
,
m1
,
m2
,
m3
=
m
w
=
2
*
pi
*
f
X0
=
k1
*
k2
*
k3
/
(
k3
**
2
*
(
k1
**
2
-
(
k0
+
k1
-
m0
*
w
**
2
)
*
(
k1
+
k2
-
m1
*
w
**
2
))
-
(
k3
-
m3
*
w
**
2
)
*
(
k2
**
2
*
(
k0
+
k1
-
m0
*
w
**
2
)
+
(
k1
**
2
-
(
k0
+
k1
-
m0
*
w
**
2
)
*
(
k1
+
k2
-
m1
*
w
**
2
))
*
(
k2
+
k3
-
m2
*
w
**
2
)))
return
X0
*
k0
def
suspQuad
(
f
,
ifo
,
material
=
'Silica'
):
...
...
@@ -367,57 +361,40 @@ def suspQuad(f, ifo, material='Silica'):
# Equations of motion for the system
###############################################################
# want TM equations of motion, so index 4
B
=
np
.
array
([
0
,
0
,
0
,
1
])
m_list
=
mass
kh_list
=
kh
kv_list
=
kv
#m_list=[m1 m2 m3 m4]; # array of the mass
#kh_list=[kh1; kh2; kh3; kh4]; # array of the horiz spring constants
#kv_list=[kv1; kv2; kv3; kv4]; # array of the vert spring constants
# Calculate TFs turning on the loss of each stage one by one
hForce
=
Struct
()
vForce
=
Struct
()
hForce
.
singlylossy
=
np
.
zeros
([
len
(
sus
.
Stage
),
len
(
w
)],
dtype
=
complex
)
vForce
.
singlylossy
=
np
.
zeros
([
len
(
sus
.
Stage
),
len
(
w
)],
dtype
=
complex
)
for
n
in
range
(
len
(
m
_list
)):
for
n
in
range
(
len
(
m
ass
)):
# horizontal
k_list
=
kh_list
# only the imaginary part of the specified stage is used.
k_list
=
real
(
k_list
)
+
1j
*
imag
([
k_list
[
0
,:]
*
(
n
==
0
),
k_list
[
1
,:]
*
(
n
==
1
),
k_list
[
2
,:]
*
(
n
==
2
),
k_list
[
3
,:]
*
(
n
==
3
)])
# construct Eq of motion matrix
Ah
=
construct_eom_matrix
(
k_list
,
m_list
,
f
)
k
=
real
(
kh
)
+
1j
*
imag
([
kh
[
0
,:]
*
(
n
==
0
),
kh
[
1
,:]
*
(
n
==
1
),
kh
[
2
,:]
*
(
n
==
2
),
kh
[
3
,:]
*
(
n
==
3
)])
# calculate TFs
hForce
.
singlylossy
[
n
,:]
=
calc_transfer_functions
(
Ah
,
B
,
k_list
,
f
)[
0
]
hForce
.
singlylossy
[
n
,:]
=
tst_force_to_tst_displ
(
k
,
mass
,
f
)
# vertical
k_list
=
kv_list
# only the imaginary part of the specified stage is used
k_list
=
real
(
k_list
)
+
1j
*
imag
([
k_list
[
0
,:]
*
(
n
==
0
),
k_list
[
1
,:]
*
(
n
==
1
),
k_list
[
2
,:]
*
(
n
==
2
),
k_list
[
3
,:]
*
(
n
==
3
)])
# construct Eq of motion matrix
Av
=
construct_eom_matrix
(
k_list
,
m_list
,
f
)
k
=
real
(
kv
)
+
1j
*
imag
([
kv
[
0
,:]
*
(
n
==
0
),
kv
[
1
,:]
*
(
n
==
1
),
kv
[
2
,:]
*
(
n
==
2
),
kv
[
3
,:]
*
(
n
==
3
)])
# calculate TFs
vForce
.
singlylossy
[
n
,:]
=
calc_transfer_functions
(
Av
,
B
,
k_list
,
f
)[
0
]
vForce
.
singlylossy
[
n
,:]
=
tst_force_to_tst_displ
(
k
,
mass
,
f
)
# calculate horizontal TFs with all losses on
Ah
=
construct_eom_matrix
(
kh_list
,
m_list
,
f
)
h
Force
.
fullylossy
,
hTable
=
calc_transfer_functions
(
Ah
,
B
,
kh_list
,
f
)
hForce
.
fullylossy
=
tst_force_to_tst_displ
(
kh
,
mass
,
f
)
h
Table
=
top_displ_to_tst_displ
(
kh
,
mass
,
f
)
# calculate vertical TFs with all losses on
Av
=
construct_eom_matrix
(
kv_list
,
m_list
,
f
)
v
Force
.
fullylossy
,
vTable
=
calc_transfer_functions
(
Av
,
B
,
kv_list
,
f
)
vForce
.
fullylossy
=
tst_force_to_tst_displ
(
kv
,
mass
,
f
)
v
Table
=
top_displ_to_tst_displ
(
kv
,
mass
,
f
)
return
hForce
,
vForce
,
hTable
,
vTable
#, Ah, Av
return
hForce
,
vForce
,
hTable
,
vTable
def
suspBQuad
(
f
,
ifo
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment