Skip to content
Snippets Groups Projects
README.md 19.38 KiB

RBComb simulation framework

This project aims at developing a framework that can be used to simulate any project that is to be undertaken on the RBComb platform. It is designed in modular fashion, such that it is flexible enough to adapt easily to any given situation. The list of contents is the following:

  1. RBComb simulation framework.
  2. Unit tests
  3. Implementing a new project.
  4. Classes.

Unit tests

Unit tests are available in the subfolder unit_tests. They can be run from within that directory by issuing make run. They should all compile and run fine.

Implementing a new project

In order to implement a new project, follow these steps:

  1. Create a new folder in projects.
    • Create subfolders bin, include, lib and results
    • Copy the lib contents into projects/newproj/lib
  2. Identify force on a single drum
    • Depends on static parameters (w, m, a, etc.) and dynamic parameters and variables (x, v, etc.).
    • Coupling and driving parameters are dynamic.
  3. Write custom versions of classes DrumParameters (everything that is static) and DrumVariables (everything that is dynamic) to accomodate these. Inspiration in lib/drum_variables.hpp and lib/drum_parameters.hpp.
  4. Write custom Grabber that extracts the relevant data (inspiration in include/grabber.hpp)
  5. Write custom child of Force to calculate the force.
  6. Write custom children of Coupler and Driver to correctly update the drive and couplings.
  7. If desired, write a custom child of LatticeGenerator to generate a custom lattice, or use the generator projects/braidingTightBinding/include/rbcomb_generator_braid.hpp to create the RBComb.
  8. If desired, write a child of MatrixElementCalculator to calculate matrix elements for the dynamic matrix.
  9. Check the unit tests (unit_tests) or other projects to see how a main.cpp could be constructed.

Hints for organizing, building and running simulations

  1. Use a Makefile.
    • The framework should be compiled with c++ 2a.
    • The Diagonalizer requires LAPACK to be linked.
    • Get inspiration from other projects.
  2. Organize executables in bin
  3. Store data and plots in subfolders of results

Classes

The code is structured in an object oriented approach. The classes that likely will not need to be adapted for a new situation are found in the lib folder. They are described in the following. Note that qualifiers, references and the like are discarded where it improves legibility. Consult the source files for more information.

Vec2 (vec2.hpp), 2-vector utility class

  1. Template arguments
    • value_t: type of vector entries
  2. Explicit Constructors
    • Vec2(const value_t, const value_t)
    • Vec2(const Vec2&)
    • Vec2()
    • Vec2& operator=(const Vec2&)
  3. Members
    • Access
      • value_t x()
        • returns x entry
      • value_t y()
        • returns y entry
      • Vec2 normalized()
        • returns normalized version of vector
      • value_t r()
        • returns length
      • value_t phi()
        • returns angle (std::atan2 version of it)
    • Member functions
      • value_t r_wrt(Vec2)
        • returns length with origin at argument
      • value_t phi_wrt(Vec2)
        • returns angle with origin at argument
      • value_t norm()
        • returns norm
      • value_t norm_sq()
        • returns square of norm
    • Modifiers
      • Vec2 normalize()
        • normalizes the vector and returns it
        • throws when zero-vector
      • Vec2 rotate(Vec2, value_t)
        • rotates the vector and returns it
    • Supported Operators, All of these work as one would expect
      • * with Vec2 (inner product) and value_t
      • / with value_t
        • throws upon division by zero
      • +, - with Vec2
      • All versions of op= of the above
      • [] with std::size_t
      • << with std::ostream

Diagonalizer (diagonalizer.hpp), class to diagonalize symmetric Matrices

  1. Explicit Constructors
    • Diagonalizer()
  2. Member functions
    • std::vector<double> ev(std::vector<double> mat, size_t N)
      • returns eigenvalues of the symmetric matrix mat of linear size N
      • throws upon diagonalization failure
    • std::pair<std::vector<double>, std::vector<double> > evv(std::vector<double> mat, size_t N)
      • returns pair of (eigenvalues, eigenvectors) of the symmetric matrix mat of size N
      • throws upon diagonalization failure
  3. Further developments
    • Only finding eigenvectors and -values in a certain range may be added later on

DrumParameters(drum_parameters.hpp), contains data members characterizing the static state of a drum

DrumVariables (drum_variables.hpp), contains data members characterizing the dynamic state of a drum

Drum (drum.hpp), represents a single drum top resonator

  1. Template arguments
    • value_t: Scalar type
    • params_t: Drum parameters container type
    • vars_t: Drum variables container type
    • sbuffer_t: Stepper buffer container type
  2. Explicit Constructors
    • Drum(const params_t&)
    • Drum() = delete
    • Drum(const Drum&)
    • Drum& operator=(const Drum&)
  3. Access
    • params_t get_parameters()
      • returns the parameters, const and reference versions implemented
    • vars_t get_variables()
      • returns the variables, const and reference versions implemented
    • sbuffer_t get_sbuffer()
      • returns the stepper buffer, const and reference versions implemented
  4. Modifiers
    • void set_coupling_0(value_t)
    • void set_coupling_1(value_t)
    • void set_coupling_2(value_t)
    • void set_drive(value_t)
  5. Description
    • A drum is described by a set of (static) parameters (stiffness, mass, x-y position, etc), which are to be stored in a container of type params_t. The variables (displacement, velocity, electrode charges, etc.) are stored in a container of type vars_t. Example classes for these two types are lib/drum_parameters.hpp and lib/drum_variables.hpp. However, these containers likely need to be adapted to the situation at hand. When time evolving, the stepper will use the container of type sbuffer_t to store its intermediate results. Note that the default constructor of this class is delete'd. It should be constructed from an object of type params_t.
  6. Further developments
    • Abstract interfaces for params_t and vars_t could be added, but they would be trivial.