Commit 1cbf83d7 authored by Daniel Brown's avatar Daniel Brown
Browse files

remove profile flag, small changes to refill flagging for mirror/bs

parent 48da51fc
# cython: profile=True
# cython: profile=False
import logging
......
# cython: profile=True
# cython: profile=False
"""
Sparse matrix objects with factorisation and solving routines performed via KLU.
"""
......
......@@ -572,17 +572,21 @@ class Beamsplitter(Surface):
_, is_changing = self._eval_parameters()
misaligned = self.xbeta.value != 0 or self.ybeta.value != 0
refill = (
(sim.signal and sim.model.fsig.f.is_changing)
or sim.is_component_in_mismatch_couplings(self)
carrier_refill = (
sim.is_component_in_mismatch_couplings(self)
or (misaligned and sim.trace_forest.contains_comp(self))
or sim.carrier.any_frequencies_changing
or (len(is_changing) and is_changing.issubset(self.__changing_check))
)
ws = BeamsplitterWorkspace(self, sim)
ws.carrier.add_fill_function(beamsplitter_carrier_fill, refill)
ws.signal.add_fill_function(beamsplitter_signal_fill, refill)
ws.carrier.add_fill_function(beamsplitter_carrier_fill, carrier_refill)
if sim.signal:
signal_refill = sim.model.fsig.f.is_changing
ws.signal.add_fill_function(
beamsplitter_signal_fill, carrier_refill or signal_refill
)
# Initialise the ABCD matrix memory-views
if sim.is_modal:
......
......@@ -355,7 +355,8 @@ class Mirror(Surface):
if isinstance(sim, CarrierSignalMatrixSimulation):
from finesse.components.modal.mirror import (
mirror_carrier_fill,
mirror_signal_fill,
mirror_signal_opt_fill,
mirror_signal_mech_fill,
mirror_fill_qnoise,
MirrorWorkspace,
)
......@@ -363,11 +364,10 @@ class Mirror(Surface):
_, is_changing = self._eval_parameters()
misaligned = self.xbeta.value != 0 or self.ybeta.value != 0
refill = (
carrier_refill = (
sim.is_component_in_mismatch_couplings(self)
or (misaligned and sim.trace_forest.contains_comp(self))
or sim.carrier.any_frequencies_changing
or (sim.signal.any_frequencies_changing if sim.signal else False)
or len(is_changing)
)
......@@ -376,8 +376,17 @@ class Mirror(Surface):
ws.nr1 = refractive_index(self.p1)
ws.nr2 = refractive_index(self.p2)
ws.carrier.add_fill_function(mirror_carrier_fill, refill)
ws.signal.add_fill_function(mirror_signal_fill, refill)
ws.carrier.add_fill_function(mirror_carrier_fill, carrier_refill)
if sim.signal:
signal_refill = carrier_refill or (
sim.model.fsig.f.is_changing
and not (self.phi.value == 0 and self.phi.is_changing)
)
ws.signal.add_fill_function(mirror_signal_opt_fill, signal_refill)
signal_refill = carrier_refill or (sim.model.fsig.f.is_changing)
ws.signal.add_fill_function(mirror_signal_mech_fill, signal_refill)
# Initialise the ABCD matrix memory-views
if sim.is_modal:
......
#cython: boundscheck=False, wraparound=False, initializedcheck=False, profile=True
#cython: boundscheck=False, wraparound=False, initializedcheck=False, profile=False
cimport numpy as np
import numpy as np
......@@ -56,6 +56,7 @@ cdef class BeamsplitterOpticalConnections:
self.opt_conn_ptrs.P2i_P4o = <PyObject**>self.P2i_P4o.views
self.opt_conn_ptrs.P4i_P2o = <PyObject**>self.P4i_P2o.views
cdef class BeamsplitterSignalConnections(BeamsplitterOpticalConnections):
def __cinit__(self, object bs, MatrixSystemSolver mtx):
cdef:
......@@ -151,6 +152,7 @@ cdef class BeamsplitterValues(BaseCValues):
cdef tuple params = ("R","T","L","phi","Rcx","Rcy","xbeta","ybeta","alpha")
self.setup(params, sizeof(ptr), <double**>&ptr)
cdef class BeamsplitterWorkspace(KnmConnectorWorkspace):
def __init__(self, owner, CarrierSignalMatrixSimulation sim):
cdef FrequencyContainer fcnt
......
# cython: boundscheck=False, wraparound=False, initializedcheck=False, profile=True
# cython: boundscheck=False, wraparound=False, initializedcheck=False, profile=False
cimport cython
cimport numpy as np
......@@ -334,8 +334,8 @@ cdef object c_mirror_carrier_fill(ConnectorWorkspace cws):
mirror_fill_optical_2_optical(conn, ws, &(frequencies[i]), r, t, phi)
mirror_signal_fill = FillFuncWrapper.make_from_ptr(c_mirror_signal_fill)
cdef object c_mirror_signal_fill(ConnectorWorkspace cws):
mirror_signal_opt_fill = FillFuncWrapper.make_from_ptr(c_mirror_signal_opt_fill)
cdef object c_mirror_signal_opt_fill(ConnectorWorkspace cws):
cdef:
MirrorWorkspace ws = <MirrorWorkspace>cws
double t = sqrt(ws.mv.T)
......@@ -345,7 +345,6 @@ cdef object c_mirror_signal_fill(ConnectorWorkspace cws):
mirror_optical_connections *car_conn = &ws.mcc.opt_conn_ptrs
mirror_optical_connections *conn = &ws.mcs.opt_conn_ptrs
mirror_signal_connections *sconn = &ws.mcs.sig_conn_ptrs
frequency_info_t *freq
frequency_info_t *frequencies
size = ws.sim.signal.optical_frequencies.size
......@@ -356,6 +355,26 @@ cdef object c_mirror_signal_fill(ConnectorWorkspace cws):
for i in range(size):
mirror_fill_optical_2_optical(conn, ws, &(frequencies[i]), r, t, phi)
mirror_signal_mech_fill = FillFuncWrapper.make_from_ptr(c_mirror_signal_mech_fill)
cdef object c_mirror_signal_mech_fill(ConnectorWorkspace cws):
cdef:
MirrorWorkspace ws = <MirrorWorkspace>cws
double t = sqrt(ws.mv.T)
double r = sqrt(ws.mv.R)
double phi = radians(ws.mv.phi)
Py_ssize_t i, size
mirror_optical_connections *car_conn = &ws.mcc.opt_conn_ptrs
mirror_optical_connections *conn = &ws.mcs.opt_conn_ptrs
mirror_signal_connections *sconn = &ws.mcs.sig_conn_ptrs
frequency_info_t *freq
frequency_info_t *frequencies
size = ws.sim.signal.optical_frequencies.size
frequencies = ws.sim.signal.optical_frequencies.frequency_info
ws.z_to_field = 1j * ws.sim.model_data.k0 * ws.sim.model_data.x_scale
ws.field_to_F = 1 / (C_LIGHT * ws.sim.model_data.x_scale)
if ws.z_signal_enabled:
for i in range(size):
freq = &(frequencies[i])
......
# cython: profile=True
# cython: profile=False
from finesse.cymath cimport complex_t
from finesse.cymath.complex cimport conj, cexp, ceq, creal, cimag, cabs
......
# cython: profile=True
# cython: profile=False
"""Sparse matrix math tools.
"""
......
# cython: profile=True
# cython: profile=False
import logging
import numpy as np
......
# cython: profile=True
# cython: profile=False
import contextlib
import logging
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment