1. 19 Jan, 2021 1 commit
  2. 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.
  3. 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.
  4. 18 Dec, 2020 1 commit
  5. 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.
  6. 21 Oct, 2020 1 commit
    • 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.
  7. 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.
  8. 18 Aug, 2020 1 commit
  9. 01 Jul, 2020 1 commit
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 29 Apr, 2020 1 commit
  15. 20 Apr, 2020 1 commit
  16. 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
  17. 11 Apr, 2020 1 commit
    • Daniel Brown's avatar
      Performance tuning. I've refactored a bunch of code for the eval_parameters.... · 9b013833
      Daniel Brown authored
      Performance tuning. I've refactored a bunch of code for the eval_parameters. is_changing was taking up way to much CPU time. is_changing should be called in on_build and the result cached. This happens now in Element._setup_changing_params. is_changing is now a Set(Parameters). Simulations.any_frequencies_changing is now an attribute to save that getting recalled again and again. Shaved 0.7s off of a 2s simulation.
  18. 10 Apr, 2020 1 commit
  19. 08 Apr, 2020 1 commit
  20. 06 Apr, 2020 2 commits
  21. 05 Apr, 2020 1 commit
  22. 30 Mar, 2020 1 commit
  23. 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.
  24. 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.
  25. 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.
  26. 11 Mar, 2020 1 commit
    • Samuel Rowlinson's avatar
      Restructuring how scattering matrices are stored via new KnmMatrix class · 0e53745a
      Samuel Rowlinson authored
      The KnmMatrix acts as a convenient wrapper around a 2D NumPy array, offering methods
      for retrieving specific couplings (with `__getitem__` specialisations), a nicely
      formatted string representation and a method for plotting the matrix on a colormesh.
      All components (with HOM couplings) have now been modified slightly to store KnmMatrix
      instances in a knm_matrices dict - rather than using dataclasses as before. The complete
      scattering matrix object for a certain coupling can be accessed with, e.g. `ifo.ITM.K11`
      to get the coupling coefficient matrix on reflection from the first surface of a mirror.
      This can then be plotted with ``ifo.ITM.K11.plot()`` or a specific nm -> n'm' coupling
      can be retrieved with ``ifo.ITM.K11[(n1, m1, n2, m2)]``.
  27. 04 Mar, 2020 1 commit
    • Phil Jones's avatar
      Correct beamsplitter backside alpha calculations. · 17c190ba
      Phil Jones authored
      The angle of incidence for the back side of a beamsplitter is now
      calculated correctly for filling the matrix. In addition, if there was
      no space attached at ports 1 or 3, the IoR for those ports would default
      to 1, rather than first checking ports 2 & 4. The check is now performed
  28. 16 Feb, 2020 1 commit
  29. 13 Feb, 2020 1 commit
    • Samuel Rowlinson's avatar
      Implementing symbolic calculations for ABCD matrices · 5fe5dfe1
      Samuel Rowlinson authored
      All component ABCD methods can now return symbolic ABCD matrices where
      each of the elements is a `finesse.element.Operation` (or a base of this
      if the expression is simple). The ABCD method of the Model (and, thus, the
      `finesse.analysis.abcd` function too) can now use this functionality to
      yield composite symbolic ABCDs for each plane.
      Evaluation of parameters has been changed to allow optional substitutions
      of parameter values (similar to Sympy's subs function but faster) where these
      values can also be array-like. This is very powerful as one can now, for example,
      compute a combined ABCD along a path of the model, transform an arbitrary beam
      parameter with it and then compute this new beam parameter expression on a grid.
      More work remains to be done here as currently Operation objects can only be evaluated
      as scalars, 1D arrays or grids. The function `finesse.utilities.misc.construct_grid` will
      need to be expanded upon to allow N-dimensional grid construction for parameter
      evaluation. Another thing which would be good to implement / test now is using symbolic
      beam parameters (from a symbolic ABCD applied to a q) in the BeamParam class so that its
      properties can be evaluated separately in a convenient way.
  30. 20 Jan, 2020 1 commit
    • Samuel Rowlinson's avatar
      Modifying finesse.knm extension API to be more NumPy like · 3eb3a2ed
      Samuel Rowlinson authored
      I wasn't too happy with the current interface of some of the functions in the
      knm Cython extension, so the following changes have been made:
      - Each function with a Python API (i.e. all def and cpdef functions) now has
        an optional `out` argument (None by default) which is a memory view.
      - If this is not specified then a new np.ndarray is returned by the function,
        otherwise the array pointed to by the out memory view will be modified.
      - This mimicks the NumPy API for all ufuncs except for one difference: if `out`
        is specified then the function return type is effectively void. I can probably
        change this to just return the memory view itself if needs be, though I would need
        to test how this works with C -> Python interaction.
      - The function `run_bayer_helms` has been renamed to `compute_knm_matrix_bh` for clarity.
  31. 16 Dec, 2019 1 commit
  32. 08 Nov, 2019 1 commit
  33. 07 Nov, 2019 1 commit
    • Samuel Rowlinson's avatar
      Implemented missing knm matrix calculations in Isolator · 8f24d774
      Samuel Rowlinson authored
      Fixed bug in angle coefficient for misalignment for beam splitters. Changed
      threshold for parallel for-loops in run_bayer_helms to Nfields > 75 so that
      maxtem 12 is the minimum for multi-threaded knm matrix computations. Removed
      duplication of modal simulation checks in component _compute_knm_matrices methods.
  34. 01 Oct, 2019 1 commit
  35. 02 Sep, 2019 1 commit
  36. 30 Aug, 2019 1 commit
  37. 16 Aug, 2019 1 commit
  38. 08 Jul, 2019 1 commit
    • Samuel Rowlinson's avatar
      Changed np.matrix to np.array for ABCD matrices, trying new structure for · d54ae79b
      Samuel Rowlinson authored
      coupling coefficient calculations (only in Mirror currently).
      Using np.array instead of np.matrix is advised by the numpy/scipy developers as
      the latter could be deprecated/removed eventually; and the former has support for
      convenient matrix multiplication as of Python 3.5.
      Adding a new code structure for computing coupling coefficient matrices (in Mirror) which
      should make it easier to fit together once we have knm_map and knm_aperture matrix fields
      in this class. It may also make sense to add symbolic knm fields to the new MirrorKnmMatrices
      data class when attempting to implement analytic coupling coefficient computations via sympy
      (or otherwise) in the near future.
  39. 01 Jul, 2019 1 commit