Skip to content
Snippets Groups Projects

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.

Structure

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.

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

  1. Template arguments
    • value_t: type of vector entries
  2. 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
      • 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
      • +, - with Vec2
      • All versions of op= of the above
      • [] with std::size_t
      • << with std::ostream

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

  1. 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
  2. Further developments
    • Only finding eigenvectors and -values in a certain range may be added later on

Template Type 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. 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
  3. Modifiers
    • void set_coupling_0(value_t)
      • Sets coupling 0
    • void set_coupling_1(value_t)
      • Sets coupling 1
    • void set_coupling_2(value_t)
      • Sets coupling 2
    • void set_drive(value_t)
      • Sets central electrode coupling
  4. 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. These containers may 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 deleted. It should be constructed from an object of type params_t.

Template Type Rk4Stepper (rk4_stepper.hpp), performs timesteps using rk4 scheme

  1. Template arguments
    • value_t: Scalar type
    • params_t: Drum parameters container type
    • vars_t: Drum variables container type
    • buffer_t: Stepper buffer container type
    • force_t: Force functional type
  2. Member functions
    • void step_1(force_t, std::vector<drum_t>, std::vector<std::vector<int> >, value_t dt, value_t time)
    • void step_2(force_t, std::vector<drum_t>, std::vector<std::vector<int> >, value_t dt, value_t time)
    • void step_3(force_t, std::vector<drum_t>, std::vector<std::vector<int> >, value_t dt, value_t time)
      • All of the above perform one step of a timestep, between successive steps certain other updates need to be taken care of.
      • Arguments: Force functional, Drum vector, Adjacency vector, time step, start time of current step