Commit 5667adec authored by Samuel Rowlinson's avatar Samuel Rowlinson
Browse files

Minor renaming for clarity

parent 89b56567
......@@ -186,12 +186,11 @@ cdef class BeamsplitterWorkspace(KnmConnectorWorkspace):
cpdef compile_abcd_cy_exprs(self)
cpdef update_parameter_values(self)
cdef void initialise_knm_workspaces(BeamsplitterWorkspace ws) nogil
cdef void free_knm_workspaces(BeamsplitterWorkspace ws) nogil
cdef void flag_changing_knm_workspaces(BeamsplitterWorkspace ws)
cdef void update_changing_knm_workspaces(BeamsplitterWorkspace ws) nogil
cdef void compute_scattering_matrices(BeamsplitterWorkspace ws)
cdef void initialise_knm_workspaces(self) nogil
cdef void free_knm_workspaces(self) nogil
cdef void flag_changing_knm_workspaces(self)
cdef void update_changing_knm_workspaces(self) nogil
cdef void compute_scattering_matrices(self)
cdef object c_beamsplitter_fill(ConnectorWorkspace cws)
......@@ -55,8 +55,8 @@ cdef class IsolatorWorkspace(KnmConnectorWorkspace):
KnmWorkspace K21_ws_y
cdef void initialise_knm_workspaces(IsolatorWorkspace ws) nogil
cdef void free_knm_workspaces(IsolatorWorkspace ws) nogil
cdef void flag_changing_knm_workspaces(IsolatorWorkspace ws)
cdef void update_changing_knm_workspaces(IsolatorWorkspace ws) nogil
cdef void compute_scattering_matrices(IsolatorWorkspace ws)
cdef void initialise_knm_workspaces(self) nogil
cdef void free_knm_workspaces(self) nogil
cdef void flag_changing_knm_workspaces(self)
cdef void update_changing_knm_workspaces(self) nogil
cdef void compute_scattering_matrices(self)
......@@ -56,107 +56,106 @@ cdef class IsolatorWorkspace(KnmConnectorWorkspace):
self.P2i_id = sim.node_id(owner.p2.i)
self.P2o_id = sim.node_id(owner.p2.o)
cdef void initialise_knm_workspaces(IsolatorWorkspace ws) nogil:
cdef void initialise_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
# Beam parameters for matched propagation of inputs
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
double lambda0 = ws.sim.model_data.lambda0
int maxtem = ws.sim.model_data.maxtem
double lambda0 = self.sim.model_data.lambda0
int maxtem = self.sim.model_data.maxtem
# Transmission at port p1 -> p2
qx_p2o_matched_trns = q_p1i.qx
knm_ws_init(
&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, self.nr2, lambda0, maxtem,
)
qy_p2o_matched_trns = q_p1i.qy
knm_ws_init(
&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, self.nr2, lambda0, maxtem,
)
# Transmission at port p2 -> p1
qx_p1o_matched_trns = q_p2i.qx
knm_ws_init(
&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, self.nr1, lambda0, maxtem,
)
qy_p1o_matched_trns = q_p2i.qy
knm_ws_init(
&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, self.nr1, lambda0, maxtem,
)
cdef void free_knm_workspaces(IsolatorWorkspace ws) nogil:
knm_ws_free(&ws.K12_ws_x)
knm_ws_free(&ws.K12_ws_y)
knm_ws_free(&ws.K21_ws_x)
knm_ws_free(&ws.K21_ws_y)
cdef void free_knm_workspaces(self) nogil:
knm_ws_free(&self.K12_ws_x)
knm_ws_free(&self.K12_ws_y)
knm_ws_free(&self.K21_ws_x)
knm_ws_free(&self.K21_ws_y)
cdef void flag_changing_knm_workspaces(IsolatorWorkspace ws):
cdef void flag_changing_knm_workspaces(self):
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
bint is_changing = q_p1i.is_changing or q_p2i.is_changing
# Transmission at port p1 -> p2
ws.K12_ws_x.is_mm_changing = is_changing
ws.K12_ws_y.is_mm_changing = is_changing
self.K12_ws_x.is_mm_changing = is_changing
self.K12_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K12_ws_x) or knm_ws_is_changing(&ws.K12_ws_y):
LOGGER.info("%s.K12 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K12_ws_x) or knm_ws_is_changing(&self.K12_ws_y):
LOGGER.info("%s.K12 is changing", self.owner.name)
# Transmission at port p2 -> p1
ws.K21_ws_x.is_mm_changing = is_changing
ws.K21_ws_y.is_mm_changing = is_changing
self.K21_ws_x.is_mm_changing = is_changing
self.K21_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K21_ws_x) or knm_ws_is_changing(&ws.K21_ws_y):
LOGGER.info("%s.K21 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K21_ws_x) or knm_ws_is_changing(&self.K21_ws_y):
LOGGER.info("%s.K21 is changing", self.owner.name)
cdef void update_changing_knm_workspaces(IsolatorWorkspace ws) nogil:
cdef void update_changing_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
if ws.K12_ws_x.is_mm_changing:
if self.K12_ws_x.is_mm_changing:
qx_p2o_matched_trns = q_p1i.qx
knm_ws_recompute_mismatch(&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
knm_ws_recompute_mismatch(&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
if ws.K12_ws_y.is_mm_changing:
if self.K12_ws_y.is_mm_changing:
qy_p2o_matched_trns = q_p1i.qy
knm_ws_recompute_mismatch(&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
knm_ws_recompute_mismatch(&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
if ws.K21_ws_x.is_mm_changing:
if self.K21_ws_x.is_mm_changing:
qx_p1o_matched_trns = q_p2i.qx
knm_ws_recompute_mismatch(&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
knm_ws_recompute_mismatch(&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
if ws.K21_ws_y.is_mm_changing:
if self.K21_ws_y.is_mm_changing:
qy_p1o_matched_trns = q_p2i.qy
knm_ws_recompute_mismatch(&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
knm_ws_recompute_mismatch(&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
cdef void compute_scattering_matrices(IsolatorWorkspace ws):
cdef void compute_scattering_matrices(self):
# Transmission p1 -> p2
if knm_ws_is_changing(&ws.K12_ws_x) or knm_ws_is_changing(&ws.K12_ws_y):
compute_knm_matrix_bh(&ws.K12_ws_x, &ws.K12_ws_y, ws.sim.homs_view, ws.K12.data_view)
reverse_gouy_phases(ws.K12.data_view, ws.sim.homs_view, &ws.K12_ws_x, &ws.K12_ws_y, ws.K12.data_view)
if knm_ws_is_changing(&self.K12_ws_x) or knm_ws_is_changing(&self.K12_ws_y):
compute_knm_matrix_bh(&self.K12_ws_x, &self.K12_ws_y, self.sim.homs_view, self.K12.data_view)
reverse_gouy_phases(self.K12.data_view, self.sim.homs_view, &self.K12_ws_x, &self.K12_ws_y, self.K12.data_view)
if ws.sim.model_data.zero_K00:
zero_tem00_phase(ws.K12.data_view, ws.K12.data_view)
if self.sim.model_data.zero_K00:
zero_tem00_phase(self.K12.data_view, self.K12.data_view)
# Transmission p2 -> p1
if knm_ws_is_changing(&ws.K21_ws_x) or knm_ws_is_changing(&ws.K21_ws_y):
compute_knm_matrix_bh(&ws.K21_ws_x, &ws.K21_ws_y, ws.sim.homs_view, ws.K21.data_view)
reverse_gouy_phases(ws.K21.data_view, ws.sim.homs_view, &ws.K21_ws_x, &ws.K21_ws_y, ws.K21.data_view)
if knm_ws_is_changing(&self.K21_ws_x) or knm_ws_is_changing(&self.K21_ws_y):
compute_knm_matrix_bh(&self.K21_ws_x, &self.K21_ws_y, self.sim.homs_view, self.K21.data_view)
reverse_gouy_phases(self.K21.data_view, self.sim.homs_view, &self.K21_ws_x, &self.K21_ws_y, self.K21.data_view)
if ws.sim.model_data.zero_K00:
zero_tem00_phase(ws.K21.data_view, ws.K21.data_view)
if self.sim.model_data.zero_K00:
zero_tem00_phase(self.K21.data_view, self.K21.data_view)
......@@ -74,8 +74,8 @@ cdef class LensWorkspace(KnmConnectorWorkspace):
cpdef compile_abcd_cy_exprs(self)
cpdef update_parameter_values(self)
cdef void initialise_knm_workspaces(LensWorkspace ws) nogil
cdef void free_knm_workspaces(LensWorkspace ws) nogil
cdef void flag_changing_knm_workspaces(LensWorkspace ws)
cdef void update_changing_knm_workspaces(LensWorkspace ws) nogil
cdef void compute_scattering_matrices(LensWorkspace ws)
cdef void initialise_knm_workspaces(self) nogil
cdef void free_knm_workspaces(self) nogil
cdef void flag_changing_knm_workspaces(self)
cdef void update_changing_knm_workspaces(self) nogil
cdef void compute_scattering_matrices(self)
......@@ -103,111 +103,110 @@ cdef class LensWorkspace(KnmConnectorWorkspace):
if self.sym_abcd_Cy != NULL:
self.abcd_y[1][0] = cy_expr_eval(self.sym_abcd_Cy)
cdef void initialise_knm_workspaces(LensWorkspace ws) nogil:
cdef void initialise_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
# Beam parameters for matched propagation of inputs
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
double lambda0 = ws.sim.model_data.lambda0
int maxtem = ws.sim.model_data.maxtem
double lambda0 = self.sim.model_data.lambda0
int maxtem = self.sim.model_data.maxtem
# Transmission at port p1 -> p2
qx_p2o_matched_trns = transform_q(ws.abcd_x, q_p1i.qx, ws.nr1, ws.nr2)
qx_p2o_matched_trns = transform_q(self.abcd_x, q_p1i.qx, self.nr1, self.nr2)
knm_ws_init(
&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, self.nr2, lambda0, maxtem,
)
qy_p2o_matched_trns = transform_q(ws.abcd_y, q_p1i.qy, ws.nr1, ws.nr2)
qy_p2o_matched_trns = transform_q(self.abcd_y, q_p1i.qy, self.nr1, self.nr2)
knm_ws_init(
&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, self.nr2, lambda0, maxtem,
)
# Transmission at port p2 -> p1
qx_p1o_matched_trns = transform_q(ws.abcd_x, q_p2i.qx, ws.nr2, ws.nr1)
qx_p1o_matched_trns = transform_q(self.abcd_x, q_p2i.qx, self.nr2, self.nr1)
knm_ws_init(
&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, self.nr1, lambda0, maxtem,
)
qy_p1o_matched_trns = transform_q(ws.abcd_y, q_p2i.qy, ws.nr2, ws.nr1)
qy_p1o_matched_trns = transform_q(self.abcd_y, q_p2i.qy, self.nr2, self.nr1)
knm_ws_init(
&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, self.nr1, lambda0, maxtem,
)
cdef void free_knm_workspaces(LensWorkspace ws) nogil:
knm_ws_free(&ws.K12_ws_x)
knm_ws_free(&ws.K12_ws_y)
knm_ws_free(&ws.K21_ws_x)
knm_ws_free(&ws.K21_ws_y)
cdef void free_knm_workspaces(self) nogil:
knm_ws_free(&self.K12_ws_x)
knm_ws_free(&self.K12_ws_y)
knm_ws_free(&self.K21_ws_x)
knm_ws_free(&self.K21_ws_y)
cdef void flag_changing_knm_workspaces(LensWorkspace ws):
cdef void flag_changing_knm_workspaces(self):
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
bint is_changing = q_p1i.is_changing or q_p2i.is_changing
# Transmission at port p1 -> p2
ws.K12_ws_x.is_mm_changing = is_changing
ws.K12_ws_y.is_mm_changing = is_changing
self.K12_ws_x.is_mm_changing = is_changing
self.K12_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K12_ws_x) or knm_ws_is_changing(&ws.K12_ws_y):
LOGGER.info("%s.K12 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K12_ws_x) or knm_ws_is_changing(&self.K12_ws_y):
LOGGER.info("%s.K12 is changing", self.owner.name)
# Transmission at port p2 -> p1
ws.K21_ws_x.is_mm_changing = is_changing
ws.K21_ws_y.is_mm_changing = is_changing
self.K21_ws_x.is_mm_changing = is_changing
self.K21_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K21_ws_x) or knm_ws_is_changing(&ws.K21_ws_y):
LOGGER.info("%s.K21 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K21_ws_x) or knm_ws_is_changing(&self.K21_ws_y):
LOGGER.info("%s.K21 is changing", self.owner.name)
cdef void update_changing_knm_workspaces(LensWorkspace ws) nogil:
cdef void update_changing_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
if ws.K12_ws_x.is_mm_changing:
qx_p2o_matched_trns = transform_q(ws.abcd_x, q_p1i.qx, ws.nr1, ws.nr2)
knm_ws_recompute_mismatch(&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
if self.K12_ws_x.is_mm_changing:
qx_p2o_matched_trns = transform_q(self.abcd_x, q_p1i.qx, self.nr1, self.nr2)
knm_ws_recompute_mismatch(&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
if ws.K12_ws_y.is_mm_changing:
qy_p2o_matched_trns = transform_q(ws.abcd_y, q_p1i.qy, ws.nr1, ws.nr2)
knm_ws_recompute_mismatch(&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
if self.K12_ws_y.is_mm_changing:
qy_p2o_matched_trns = transform_q(self.abcd_y, q_p1i.qy, self.nr1, self.nr2)
knm_ws_recompute_mismatch(&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
if ws.K21_ws_x.is_mm_changing:
qx_p1o_matched_trns = transform_q(ws.abcd_x, q_p2i.qx, ws.nr2, ws.nr1)
knm_ws_recompute_mismatch(&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
if self.K21_ws_x.is_mm_changing:
qx_p1o_matched_trns = transform_q(self.abcd_x, q_p2i.qx, self.nr2, self.nr1)
knm_ws_recompute_mismatch(&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
if ws.K21_ws_y.is_mm_changing:
qy_p1o_matched_trns = transform_q(ws.abcd_y, q_p2i.qy, ws.nr2, ws.nr1)
knm_ws_recompute_mismatch(&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
if self.K21_ws_y.is_mm_changing:
qy_p1o_matched_trns = transform_q(self.abcd_y, q_p2i.qy, self.nr2, self.nr1)
knm_ws_recompute_mismatch(&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
cdef void compute_scattering_matrices(LensWorkspace ws):
cdef void compute_scattering_matrices(self):
# Transmission p1 -> p2
if knm_ws_is_changing(&ws.K12_ws_x) or knm_ws_is_changing(&ws.K12_ws_y):
compute_knm_matrix_bh(&ws.K12_ws_x, &ws.K12_ws_y, ws.sim.homs_view, ws.K12.data_view)
reverse_gouy_phases(ws.K12.data_view, ws.sim.homs_view, &ws.K12_ws_x, &ws.K12_ws_y, ws.K12.data_view)
if knm_ws_is_changing(&self.K12_ws_x) or knm_ws_is_changing(&self.K12_ws_y):
compute_knm_matrix_bh(&self.K12_ws_x, &self.K12_ws_y, self.sim.homs_view, self.K12.data_view)
reverse_gouy_phases(self.K12.data_view, self.sim.homs_view, &self.K12_ws_x, &self.K12_ws_y, self.K12.data_view)
if ws.sim.model_data.zero_K00:
zero_tem00_phase(ws.K12.data_view, ws.K12.data_view)
if self.sim.model_data.zero_K00:
zero_tem00_phase(self.K12.data_view, self.K12.data_view)
# Transmission p2 -> p1
if knm_ws_is_changing(&ws.K21_ws_x) or knm_ws_is_changing(&ws.K21_ws_y):
compute_knm_matrix_bh(&ws.K21_ws_x, &ws.K21_ws_y, ws.sim.homs_view, ws.K21.data_view)
reverse_gouy_phases(ws.K21.data_view, ws.sim.homs_view, &ws.K21_ws_x, &ws.K21_ws_y, ws.K21.data_view)
if knm_ws_is_changing(&self.K21_ws_x) or knm_ws_is_changing(&self.K21_ws_y):
compute_knm_matrix_bh(&self.K21_ws_x, &self.K21_ws_y, self.sim.homs_view, self.K21.data_view)
reverse_gouy_phases(self.K21.data_view, self.sim.homs_view, &self.K21_ws_x, &self.K21_ws_y, self.K21.data_view)
if ws.sim.model_data.zero_K00:
zero_tem00_phase(ws.K21.data_view, ws.K21.data_view)
if self.sim.model_data.zero_K00:
zero_tem00_phase(self.K21.data_view, self.K21.data_view)
# TODO (sjr) make c_lens_fill function?
......@@ -141,9 +141,9 @@ cdef class MirrorWorkspace(KnmConnectorWorkspace):
cpdef compile_abcd_cy_exprs(self)
cpdef update_parameter_values(self)
cdef void free_knm_workspaces(MirrorWorkspace self) nogil
cdef void initialise_knm_workspaces(MirrorWorkspace self) nogil
cdef void flag_changing_knm_workspaces(MirrorWorkspace self)
cdef void update_changing_knm_workspaces(MirrorWorkspace self) nogil
cdef void compute_scattering_matrices(MirrorWorkspace self)
cdef void free_knm_workspaces(self) nogil
cdef void initialise_knm_workspaces(self) nogil
cdef void flag_changing_knm_workspaces(self)
cdef void update_changing_knm_workspaces(self) nogil
cdef void compute_scattering_matrices(self)
This diff is collapsed.
......@@ -33,9 +33,8 @@ cdef class ModulatorWorkspace(KnmConnectorWorkspace):
KnmWorkspace K21_ws_x
KnmWorkspace K21_ws_y
cdef void initialise_knm_workspaces(ModulatorWorkspace ws) nogil
cdef void free_knm_workspaces(ModulatorWorkspace ws) nogil
cdef void flag_changing_knm_workspaces(ModulatorWorkspace ws)
cdef void update_changing_knm_workspaces(ModulatorWorkspace ws) nogil
cdef void compute_scattering_matrices(ModulatorWorkspace ws)
cdef void initialise_knm_workspaces(self) nogil
cdef void free_knm_workspaces(self) nogil
cdef void flag_changing_knm_workspaces(self)
cdef void update_changing_knm_workspaces(self) nogil
cdef void compute_scattering_matrices(self)
......@@ -41,110 +41,109 @@ cdef class ModulatorWorkspace(KnmConnectorWorkspace):
self.P2i_id = sim.node_id(owner.p2.i)
self.P2o_id = sim.node_id(owner.p2.o)
cdef void initialise_knm_workspaces(ModulatorWorkspace ws) nogil:
cdef void initialise_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
# Beam parameters for matched propagation of inputs
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
double lambda0 = ws.sim.model_data.lambda0
int maxtem = ws.sim.model_data.maxtem
double lambda0 = self.sim.model_data.lambda0
int maxtem = self.sim.model_data.maxtem
# Transmission at port p1 -> p2
qx_p2o_matched_trns = q_p1i.qx
knm_ws_init(
&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx, 0, 0, self.nr2, lambda0, maxtem,
)
qy_p2o_matched_trns = q_p1i.qy
knm_ws_init(
&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, ws.nr2, lambda0, maxtem,
&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy, 0, 0, self.nr2, lambda0, maxtem,
)
# Transmission at port p2 -> p1
qx_p1o_matched_trns = q_p2i.qx
knm_ws_init(
&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx, 0, 0, self.nr1, lambda0, maxtem,
)
qy_p1o_matched_trns = q_p2i.qy
knm_ws_init(
&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, ws.nr1, lambda0, maxtem,
&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy, 0, 0, self.nr1, lambda0, maxtem,
)
cdef void free_knm_workspaces(ModulatorWorkspace ws) nogil:
knm_ws_free(&ws.K12_ws_x)
knm_ws_free(&ws.K12_ws_y)
knm_ws_free(&ws.K21_ws_x)
knm_ws_free(&ws.K21_ws_y)
cdef void free_knm_workspaces(self) nogil:
knm_ws_free(&self.K12_ws_x)
knm_ws_free(&self.K12_ws_y)
knm_ws_free(&self.K21_ws_x)
knm_ws_free(&self.K21_ws_y)
cdef void flag_changing_knm_workspaces(ModulatorWorkspace ws):
cdef void flag_changing_knm_workspaces(self):
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
bint is_changing = q_p1i.is_changing or q_p2i.is_changing
# Transmission at port p1 -> p2
ws.K12_ws_x.is_mm_changing = is_changing
ws.K12_ws_y.is_mm_changing = is_changing
self.K12_ws_x.is_mm_changing = is_changing
self.K12_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K12_ws_x) or knm_ws_is_changing(&ws.K12_ws_y):
LOGGER.info("%s.K12 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K12_ws_x) or knm_ws_is_changing(&self.K12_ws_y):
LOGGER.info("%s.K12 is changing", self.owner.name)
# Transmission at port p2 -> p1
ws.K21_ws_x.is_mm_changing = is_changing
ws.K21_ws_y.is_mm_changing = is_changing
self.K21_ws_x.is_mm_changing = is_changing
self.K21_ws_y.is_mm_changing = is_changing
if knm_ws_is_changing(&ws.K21_ws_x) or knm_ws_is_changing(&ws.K21_ws_y):
LOGGER.info("%s.K21 is changing", ws.owner.name)
if knm_ws_is_changing(&self.K21_ws_x) or knm_ws_is_changing(&self.K21_ws_y):
LOGGER.info("%s.K21 is changing", self.owner.name)
cdef void update_changing_knm_workspaces(ModulatorWorkspace ws) nogil:
cdef void update_changing_knm_workspaces(self) nogil:
cdef:
NodeBeamParam q_p1i = ws.sim.trace[ws.P1i_id]
NodeBeamParam q_p1o = ws.sim.trace[ws.P1o_id]
NodeBeamParam q_p2i = ws.sim.trace[ws.P2i_id]
NodeBeamParam q_p2o = ws.sim.trace[ws.P2o_id]
NodeBeamParam q_p1i = self.sim.trace[self.P1i_id]
NodeBeamParam q_p1o = self.sim.trace[self.P1o_id]
NodeBeamParam q_p2i = self.sim.trace[self.P2i_id]
NodeBeamParam q_p2o = self.sim.trace[self.P2o_id]
complex_t qx_p1o_matched_trns, qy_p1o_matched_trns
complex_t qx_p2o_matched_trns, qy_p2o_matched_trns
if ws.K12_ws_x.is_mm_changing:
if self.K12_ws_x.is_mm_changing:
qx_p2o_matched_trns = q_p1i.qx
knm_ws_recompute_mismatch(&ws.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
knm_ws_recompute_mismatch(&self.K12_ws_x, qx_p2o_matched_trns, q_p2o.qx)
if ws.K12_ws_y.is_mm_changing:
if self.K12_ws_y.is_mm_changing:
qy_p2o_matched_trns = q_p1i.qy
knm_ws_recompute_mismatch(&ws.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
knm_ws_recompute_mismatch(&self.K12_ws_y, qy_p2o_matched_trns, q_p2o.qy)
if ws.K21_ws_x.is_mm_changing:
if self.K21_ws_x.is_mm_changing:
qx_p1o_matched_trns = q_p2i.qx
knm_ws_recompute_mismatch(&ws.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
knm_ws_recompute_mismatch(&self.K21_ws_x, qx_p1o_matched_trns, q_p1o.qx)
if ws.K21_ws_y.is_mm_changing:
if self.K21_ws_y.is_mm_changing:
qy_p1o_matched_trns = q_p2i.qy
knm_ws_recompute_mismatch(&ws.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
knm_ws_recompute_mismatch(&self.K21_ws_y, qy_p1o_matched_trns, q_p1o.qy)
cdef void compute_scattering_matrices(ModulatorWorkspace ws):
cdef void compute_scattering_matrices(self):