1. 26 Dec, 2020 1 commit
    • Samuel Rowlinson's avatar
      Moving knm matrix initialisation to general ConnectorWorkspace method - removes duplication · df700147
      Samuel Rowlinson authored
      Also improved KnmMatrix constructor by removing need for pre-constructed buffer. By default,
      an identity matrix (of complex values) is allocated in KnmMatrix.__init__ now. To make
      a KnmMatrix from a pre-existing array, one can now use KnmMatrix.from_buffer.
      Other minor changes include stripping whitespace from possible str keys passed to
      KnmMatrix.__getitem__ and added a log option for plotting KnmMatrix objects in
      amplitude mode.
  2. 23 Dec, 2020 1 commit
    • Daniel Brown's avatar
      A mix of changes that started whilst trying to fix issue #151, but then wanted... · d48aba1f
      Daniel Brown authored
      A mix of changes that started whilst trying to fix issue #151, but then wanted to tidy various parts of the code up.
      - Removed connections_type for Connector constructor. No other code uses it and it means the general component constructor needs to have some knowledge of the type of connections that will exist before anything is constructed, which doesn't make sense.
      - Removing all the type checking/specific code for knm methods. These are just now in the KnmConnectorWorkspace class. We shouldn't need to hard code specfic components into the BaseSimulation logic.
  3. 18 Dec, 2020 1 commit
  4. 16 Dec, 2020 3 commits
  5. 05 Dec, 2020 1 commit
    • Samuel Rowlinson's avatar
      Changing Connector.ABCD method to return copy by default for safety · 3cf38aa4
      Samuel Rowlinson authored
      Adds a `copy` flag to Connector.ABCD which is true by default. This prevents accidental
      modifying of the internal ABCD matrix / matrices of a component. Switching off this flag
      allows direct access to the underlying arrays - this is typically used internally for
      setting memory-views in the trace trees and connector workspaces.
  6. 16 Nov, 2020 1 commit
  7. 02 Nov, 2020 1 commit
    • Samuel Rowlinson's avatar
      Adding convenience properties to connectors for retrieving specific ABCD matrices · 7b4314a9
      Samuel Rowlinson authored
      This saves needing to do, e.g., space.ABCD(1, 2) and instead allows just space.abcd
      (particularly useful in this case as all couplings are equivalent for Spaces).
      Each abcd property of the relevant Connector classes returns a copy of the numeric
      ABCD matrix for the corresponding coupling. This should be a preferred way of (the user)
      accessing these matrices.
      Also improved the docstrings for Connector ABCD methods in this commit.
  8. 01 Nov, 2020 1 commit
    • Samuel Rowlinson's avatar
      Cleaning up some scattering matrix allocation code · 9319cce0
      Samuel Rowlinson authored
      Removed knm_matrices dicts from Mirror and Beamsplitter Workspace objects, these
      are not used anymore (a legacy from an earlier version of the code).
      Added some notes in the above Workspace pxd files about storing KnmMatrix objects
      for separate scattering matrices (i.e. map, aperture Knm matrices) in the near
      Only allocating new memory for scattering matrices when the simulation object
      is non-audio (i.e. carrier sim). If the carrier is audio (i.e. signal), then
      the scattering matrices of each workspace will be set to the corresponding
      DC workspace matrices in the _get_workspace method of the relevant connector.
      Also now pointing audio simulation `trace` data to the carrier sim `trace` array,
      ensuring correct beam parameters are obtained from audio simulation workspaces
      if accessed.
  9. 25 Oct, 2020 1 commit
    • Samuel Rowlinson's avatar
      Improving storage of changing ABCD expressions in workspaces, fixing final known cy_expr bugs · d9411b07
      Samuel Rowlinson authored
      Now storing changing ABCD element expressions in relevant workspaces based on apriori
      knowledge. For example, we know that only the C element of Mirror ABCD matrices can
      change so only the C element changing expressions are stored and updated (if they
      are indeed changing).
      Cleaned up the way ABCD matrices get stored in the components themselves. Now only keeping
      a single reference to each numpy array where relevant - e.g. Lens now stores just has
      directions as keys in its _abcd_matrices dict as both forward & backward propagations
      give the same matrix. This just makes dealing with this stuff easier in the C code when
      considering views and pointers to each matrix.
  10. 23 Oct, 2020 1 commit
    • Samuel Rowlinson's avatar
      Using cy_expr for fast evaluation of changing symbolic ABCD matrix elements · 96392eaf
      Samuel Rowlinson authored
      Each relevant ConnectorWorkspace now stores an array of pointers to cy_expr
      containing the changing symbolic ABCD matrix elements (NULL if not changing).
      These are evaluated (with direct pointer access) during the update_parameter_values
      routine of each of these workspaces.
      This optimisation also allows for a cleaner API for ABCD methods of components,
      removing the _sim_cache argument and now just storing the full symbolic and
      corresponding numeric matrix in _abcd_matrices dict rather than a bunch of simulation
      stuff that needed to be reset / cleared on simulation completion. The method for
      updating ABCD matrices outside of simulations remains the same.
      Also fixed a bug in cy_expr_init which resulted in inconsistency between changing
      parameter target pointers used due to an incorrect method for finding the index.
  11. 21 Oct, 2020 2 commits
    • Samuel Rowlinson's avatar
      Refactored finesse.element into three separate cython extensions · 2231a158
      Samuel Rowlinson authored
      As mentioned in the Alpha 1 milestone, finesse.element was in quite a bloated
      state so it needed refactoring. This commit refactored it into finesse.element
      (containing ModelElement, ElementWorkspace), finesse.symbols (containing all
      the symbol classes and relevant functions, dicts) and finesse.parameters which
      holds the Parameter, ParameterRef, etc. classes and the model_parameter, info_parameter
      decorator funcs.
    • Sean Leavey's avatar
      Fix lots of documentation warnings · e035bade
      Sean Leavey authored
  12. 20 Oct, 2020 1 commit
    • Samuel Rowlinson's avatar
      Refactoring components/matrixfill extension code into separate, sensible locations · 4913e79e
      Samuel Rowlinson authored
      As noted in the Alpha 1 milestone, the matrixfill extension was bloated with code
      from several iterations of development. This has now been refactored into relevant
      component and detector workspace extensions, with the ElementWorkspace and BaseCValues
      structures now sitting in finesse.element. The matrixfill extension has been removed
      now that its code has been distributed to better locations.
  13. 08 Oct, 2020 1 commit
    • Sean Leavey's avatar
      Expand @model_parameter decorator to allow descriptions, add support for @info_parameter decorator · 89b497f4
      Sean Leavey authored
      This adds a decorator for registering "info parameters" on model elements,
      which can be used to define the attribute name of useful properties of the
      element alongside a description.
      It also expands the @model_parameter decorator to add a description
      These descriptions are used to summarise the model and info parameters of
      each element in tables when the method `info()` is called that element.
  14. 06 Oct, 2020 1 commit
  15. 05 Oct, 2020 1 commit
    • Samuel Rowlinson's avatar
      Implementing GeometricParameter class for efficient updating of ABCD matrices · 6bd96f79
      Samuel Rowlinson authored
      Connector ABCD matrices were previously getting updated when a dependent parameter
      changed via the post_set handle passed to the model_parameter decorator; where this
      post_set method was Connector._evaluate_abcd_matrices. This meant that a Python call
      had to be performed whenever changing a geometric type parameter.
      As this method was getting the devil beaten out of it during any simulation where a
      RoC, focal length, etc. was changing, having this as a Python call was not ideal.
      A new GeometricParameter class (deriving from Parameter) has been created to fix this
      inefficiency. Now the GeometricParameter.update_abcd_matrices method (a C function) is
      called whenever the value of the parameter changes.
  16. 18 Aug, 2020 1 commit
  17. 20 Jul, 2020 1 commit
    • Samuel Rowlinson's avatar
      Optimisation enhancement for changing ABCD matrices during simulation · 84edaebb
      Samuel Rowlinson authored
      Each component now stores another element in the _abcd_matrices dict mapping containing
      an optimised version of the full symbolic matrix for the associated coupling. This matrix
      is obtained by eval'ing the symbolic matrix in the _get_workspace method of the component
      and only keeping the changing symbols - all constant Operations / Symbols in the matrix
      are then only evaluated once. The _evaluate_abcd_matrices method of Connector has been changed
      to use this optimised symbolic matrix for significant speed-ups in low-maxtem HOM simulations
      where some geometric parameter is changing over lots of points.
  18. 01 Jul, 2020 1 commit
  19. 09 Jun, 2020 1 commit
    • Samuel Rowlinson's avatar
      Improving refill flag determination for some components · 7e867800
      Samuel Rowlinson authored
      Refill only gets set to true in mirror, beamsplitter, lens, space, isolator now
      when the component is in the set of changing components of the simulation trace_forest
      (or if any of the other conditions already coded in are true). This avoids unnecessary
      refill operations when retraces are ocurring but the component is not in a changing
      trace tree.
  20. 05 Jun, 2020 1 commit
    • Samuel Rowlinson's avatar
      Complete re-factor of beam tracing · 893ea540
      Samuel Rowlinson authored
      Beam tracing has been re-factored for performance and functionality into a binary-tree
      based data structure and algorithm. The model now stores a `TraceForest` instance which
      contains all the `TraceTree` objects generated from the network. These trace trees store
      the `OpticalNode`, left, right and parent sub-trees and memoryviews on ABCD matrices for
      the left and right sub-trees; the `TraceTree` is implemented as a cdef (Cython extension)
      class so that all these attributed can be typed and all methods which involve walking the
      tree use recursive C function calls for much better performance over Python recursion.
      Model beam tracing is performed via the `TraceForest.full_beam_trace` call - here all
      trees in the forest are propagated / walked and the beam parameters at each node are
      set based on the ABCD memoryviews of each tree node and the beam parameter of the parent
      node in the tree.
      Re-tracing during a simulation is much smarter now. On initialisation of the simulation, the
      broadest changing trees are determined and stored as a `TraceForest` instance in the
      `BaseSimulation` class. Node indexes for these sub-trees are set and the simulation then
      uses an optimised tracer to walk through just these changing trees to set the beam parameters
      of the `BaseSimulation.trace` C array using the node indexes at each tree. All of the node
      beam param entries of the `trace` array associated with the changing trees are flagged as
      changing so that only the scattering matrices which need re-computation on each data point
      get re-computed.
      These changes reduce the beam tracing execution time to effectively negligible durations (when
      compared to solving the matrix and computing scattering matrices) for most configurations,
      including when re-tracing is performed. The main time-sink involved with this code is now
      the initial planting of the `TraceForest` (only happens once) at approx. 35 ms for an aLIGO
      size file - the actual beam tracing for the full file is then only 5 ms on top of this.
  21. 19 May, 2020 1 commit
    • Samuel Rowlinson's avatar
      Switched last remaining mode scattering component (isolator) over to new knm... · 28c4ddf3
      Samuel Rowlinson authored
      Switched last remaining mode scattering component (isolator) over to new knm computing pattern, minor bug fixes
      All components (Mirror, Beamsplitter, Lens, Modulator, Isolator) now use the new scattering matrix
      Cythonised pattern. Isolator knm code was all commented out Python code before this commit, it has
      now been converted to using the same Cython code style for these calculations as the above objects.
      Removed the Is attributes from the above object workspaces as it is no longer required.
      Fixed an incorrect beam parameter being used in the Modulator update_changing_knm_workspaces function.
  22. 13 May, 2020 1 commit
    • Samuel Rowlinson's avatar
      Significant re-factoring of scattering matrix code (WIP) · 37d28645
      Samuel Rowlinson authored
      Moved all knm matrix related code to Cython with v. little Python interaction.
      Added a `trace` array to `BaseSimulation` which stores the beam parameters at nodes
      for fast C access.
      Still very much WIP so best not to try running any HOM models here yet.
  23. 12 May, 2020 1 commit
    • Samuel Rowlinson's avatar
      Re-factoring how ABCD matrices are stored · 1d6f8352
      Samuel Rowlinson authored
      The `Connector._abcd_matrices` dict now stores tuples of M_symbolic and M_numeric
      matrices as values. M_symbolic is created on construction of the component (or
      on connection in the case of Spaces) whilst M_numeric is computed from M_symbolic
      also as construction time as well as whenever a dependent parameter changes.
      Each of the relevant connector workspaces now store memoryviews on the numeric
      ABCD matrices - initialised in the `_get_workspace` method of each Connector.
  24. 29 Apr, 2020 1 commit
  25. 18 Apr, 2020 1 commit
  26. 17 Apr, 2020 1 commit
    • Daniel Brown's avatar
      A lot of changes: · 575fb211
      Daniel Brown authored
      Changing on_build to on_init for elements, as this gets called before the matrix is fully built
      Matrix views are now handling the maxtrix filling and conjugation.
      SubCCSView1DArray is a new wrapper around PyObject* array which lets c code directly access cdefs and functions without having to ref count. So now we can iterate over matrix views with no python calls
  27. 12 Apr, 2020 1 commit
  28. 10 Apr, 2020 1 commit
  29. 08 Apr, 2020 2 commits
  30. 07 Apr, 2020 1 commit
  31. 06 Apr, 2020 1 commit
  32. 05 Apr, 2020 1 commit
  33. 30 Mar, 2020 1 commit
  34. 29 Mar, 2020 1 commit
    • Samuel Rowlinson's avatar
      Fixing a few bugs · 07504182
      Samuel Rowlinson authored
      - Adding check that node arg is None or of type Node to `Detector.__init__`.
      - Only adding a beam trace analysis to CLI kat object when trace flag is true
        and the model is modal.
      - Fix to `OpticalPath.length` property
      - Fixed an issue where an invalid beam trace for initial state of model in a
        simulation gave an unclear internal error.
  35. 26 Mar, 2020 1 commit
    • Samuel Rowlinson's avatar
      Added KnmDetector, cythonising Modulator fill_matrix · d918d6bd
      Samuel Rowlinson authored
      KnmDetector allows direct probing of specific elements of scattering matrices
      of a component (simply using the `KnmMatrix.__getitem__` method).
      The fill_matrix method of the Modulator component has been transferred to the
      matrixfill Cython extension, and additional optimisations have been made to
      space_fill to avoid multiple Python (numpy) calls and instead compute the couplings in
      one go via a pure C loop.
      Todo markers have been added to all places where scattering matrices are multiplied
      by component sub-matrices (in fill_matrix functions) to remind where transposes
      may need to be added or removed.
  36. 20 Mar, 2020 1 commit
    • Samuel Rowlinson's avatar
      Restructuring of attributes in BaseSimulation · ed9222e1
      Samuel Rowlinson authored
      Removed most properties in favour of readonly cdef attributes and improved
      how mode indices are stored and accessed through a simulation (via a readonly
      memory-view on the models' homs array)
      Documenting laser_fill_rhs function in matrixfill extension.
      Added a batch file (make.bat) for more convenient building of Cython extensions on Windows.