Commit c9dd962e authored by Daniel Brown's avatar Daniel Brown
Browse files

ss cache not working as intended...

parent 1cbf83d7
...@@ -100,10 +100,9 @@ class LIGOQuadSuspension(Connector): ...@@ -100,10 +100,9 @@ class LIGOQuadSuspension(Connector):
>>> }, f, protocol=3) >>> }, f, protocol=3)
""" """
__QUAD_ss_cache = {}
def __init__(self, name, connect_to): def __init__(self, name, connect_to):
super().__init__(name) super().__init__(name)
mech_port = get_mechanical_port(connect_to) mech_port = get_mechanical_port(connect_to)
# Add motion and force nodes to mech port. # Add motion and force nodes to mech port.
# Here we duplicate the already created mechanical # Here we duplicate the already created mechanical
...@@ -226,6 +225,7 @@ class LIGOQuadSuspension(Connector): ...@@ -226,6 +225,7 @@ class LIGOQuadSuspension(Connector):
if N > 0: if N > 0:
ws = MIMOSSWorkspace(self, sim) ws = MIMOSSWorkspace(self, sim)
ws.QUAD_ss_cache = {}
ws.signal.add_fill_function(self._signal_fill, refill) ws.signal.add_fill_function(self._signal_fill, refill)
ws.N = N ws.N = N
ws.iselect = tuple(set(idxs)) ws.iselect = tuple(set(idxs))
...@@ -260,14 +260,7 @@ class LIGOQuadSuspension(Connector): ...@@ -260,14 +260,7 @@ class LIGOQuadSuspension(Connector):
of the proposed algorithm. of the proposed algorithm.
""" """
s = 2j * np.pi * ws.sim.model_data.fsig s = 2j * np.pi * ws.sim.model_data.fsig
# This is a fairly slow process, however, we keep evaluating the same H = ws.ss(s)
# state space over and over again, so just cache it in a dict then
# allow multiple quad sus models to call from it. Obviously breaks if
# someone changes the ABCD values
H = self.__QUAD_ss_cache.get(s)
if H is None:
H = ws.ss(s)
self.__QUAD_ss_cache[s] = H
for i in range(ws.N): for i in range(ws.N):
with ws.sim.signal.component_edge_fill3(ws.owner_id, i, 0, 0) as mat: with ws.sim.signal.component_edge_fill3(ws.owner_id, i, 0, 0) as mat:
......
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