Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
finesse
finesse3
Commits
bf69195b
Commit
bf69195b
authored
Jan 24, 2021
by
Daniel Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fleshing out automatic Knm handling workspace
parent
1466c237
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
21 deletions
+34
-21
src/finesse/components/modal/workspace.pxd
src/finesse/components/modal/workspace.pxd
+6
-3
src/finesse/components/modal/workspace.pyx
src/finesse/components/modal/workspace.pyx
+28
-18
No files found.
src/finesse/components/modal/workspace.pxd
View file @
bf69195b
from
finesse.components.workspace
cimport
ConnectorWorkspace
from
finesse.knm
cimport
KnmWorkspace
from
finesse.simulations.base
cimport
BaseSimulation
,
NodeBeamParam
from
finesse.cymath
cimport
complex_t
from
finesse.simulations.base
cimport
NodeBeamParam
from
finesse.simulations.basematrix
cimport
CarrierSignalMatrixSimulation
from
finesse.cymath.complex
cimport
complex_t
,
DenseZMatrix
from
cpython.ref
cimport
PyObject
import
numpy
as
np
cimport
numpy
as
np
...
...
@@ -24,6 +25,8 @@ cdef struct KnmInfo:
double
*
beta_y
double
beta_y_factor
double
beta_x_factor
# Pointer to a KnmMatrix
DenseZMatrix
*
mtx
cdef
class
KnmConnectorWorkspace
(
ConnectorWorkspace
):
# Sequence of string reprs of the optical couplings
...
...
src/finesse/components/modal/workspace.pyx
View file @
bf69195b
...
...
@@ -14,11 +14,12 @@ from finesse.knm cimport (
compute_knm_matrix_bh
,
reverse_gouy_phases
,
zero_tem00_phase
,
flip_odd_horizontal
,
)
from
finesse.cymath.gaussbeam
cimport
c_transform_q
from
finesse.components.workspace
cimport
ConnectorWorkspace
from
finesse.components.general
import
NodeType
from
finesse.simulations.base
cimport
BaseSimulation
,
NodeBeamParam
from
finesse.simulations.base
cimport
NodeBeamParam
import
finesse.components
as
components
...
...
@@ -56,9 +57,10 @@ cdef class KnmConnectorWorkspace(ConnectorWorkspace):
pass
cdef
class
KnmAutoConnectorWorkspace
(
ConnectorWorkspace
):
def
__init__
(
self
,
object
owner
,
BaseSimulation
sim
,
*
args
,
**
kwargs
):
super
().
__init__
(
owner
,
sim
,
*
args
,
**
kwargs
)
cdef
class
KnmAutoConnectorWorkspace
(
KnmConnectorWorkspace
):
def
__init__
(
self
,
object
owner
,
CarrierSignalMatrixSimulation
sim
,
*
args
,
**
kwargs
):
# Skip KnmConnectorWorkspace init call
ConnectorWorkspace
.
__init__
(
self
,
owner
,
sim
,
*
args
,
**
kwargs
)
# Here we automatically generate the coupling strings used
# for generating the Knm matricies. We use the optical to optical
...
...
@@ -90,19 +92,25 @@ cdef class KnmAutoConnectorWorkspace(ConnectorWorkspace):
# need these node ids for the simulation for indexing traces
for
i
,
p
in
enumerate
(
oports
):
self
.
onode_ids
[
2
*
i
]
=
sim
.
node_id
(
p
.
i
)
self
.
onode_ids
[
2
*
i
+
1
]
=
sim
.
node_id
(
p
.
o
)
self
.
onode_ids
[
2
*
i
]
=
sim
.
carrier
.
node_id
(
p
.
i
)
self
.
onode_ids
[
2
*
i
+
1
]
=
sim
.
carrier
.
node_id
(
p
.
o
)
str_couplings
=
[]
for
i
,
(
conn
,
(
f
,
t
))
in
enumerate
(
self
.
o2o
.
items
()):
# TODO ddb should probably use some fixed index rather than a list of the order
# they are defined in the element definition
a
=
oports
.
index
(
f
.
port
)
b
=
oports
.
index
(
t
.
port
)
str_
coupling
s
.
append
(
f
"
{
a
+
1
}{
b
+
1
}
"
)
coupling
=
f
"
{
a
+
1
}{
b
+
1
}
"
self
.
oconn_info
[
i
].
from_port_idx
=
a
self
.
oconn_info
[
i
].
to_port_idx
=
b
self
.
oconn_info
[
i
].
K_ws_x
=
&
self
.
Kws
[
2
*
i
]
self
.
oconn_info
[
i
].
K_ws_y
=
&
self
.
Kws
[
2
*
i
+
1
]
knm
=
KnmMatrix
(
self
.
sim
.
model_data
.
homs_view
,
self
.
owner
.
name
,
coupling
)
self
.
oconn_info
[
i
].
mtx
=
&
knm
.
mtx
# Create the actual Knm matrix here based on the optical
# port coupling indices
setattr
(
self
,
f
"K
{
coupling
}
"
,
knm
)
def
__dealloc__
(
self
):
if
self
.
onode_ids
:
free
(
self
.
onode_ids
)
...
...
@@ -222,17 +230,19 @@ cdef class KnmAutoConnectorWorkspace(ConnectorWorkspace):
cdef
void
compute_scattering_matrices
(
KnmAutoConnectorWorkspace
self
):
cdef
:
NodeBeamParam
*
q_from
NodeBeamParam
*
q_to
KnmInfo
*
info
complex_t
qx_o_matched_trns
,
qy_o_matched_trns
complex_t
[:,::
1
]
view
for
i
in
range
(
self
.
N_opt_conns
):
info
=
&
self
.
oconn_info
[
i
]
# Transmission
if
knm_ws_is_changing
(
info
.
K_ws_x
)
or
knm_ws_is_changing
(
info
.
K_ws_y
):
#compute_knm_matrix_bh(info.K_ws_x, info.K_ws_y, self.sim.homs_view, self.K12.data_view)
reverse_gouy_phases
(
self
.
K12
.
data_view
,
self
.
sim
.
homs_view
,
info
.
K_ws_x
,
info
.
K_ws_y
,
self
.
K12
.
data_view
)
# Can't store memoryview in struct so have to do some converting here
view
=
<
complex_t
[:
info
.
mtx
.
size1
,
:
info
.
mtx
.
size2
:
1
]
>
(
info
.
mtx
.
ptr
)
compute_knm_matrix_bh
(
info
.
K_ws_x
,
info
.
K_ws_y
,
self
.
sim
.
model_data
.
homs_view
,
view
)
reverse_gouy_phases
(
view
,
self
.
sim
.
homs_view
,
info
.
K_ws_x
,
info
.
K_ws_y
,
view
)
if
self
.
sim
.
model_data
.
zero_K00
:
zero_tem00_phase
(
view
,
view
)
#if self.sim.model_data.zero_K00:
# zero_tem00_phase(self.K12.data_view, self.K12.data_view)
\ No newline at end of file
if
not
info
.
is_transmission
:
# if reflection...
flip_odd_horizontal
(
view
,
self
.
sim
.
model_data
.
homs_view
,
view
)
\ No newline at end of file
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