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.
Vec2
(vec2.hpp
), 2-vector utility class
Template Type - Template arguments
-
value_t
: type of vector entries
-
- 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)
- returns angle (
-
- 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
-
*
withVec2
(inner product) andvalue_t
-
/
withvalue_t
-
+, -
withVec2
- All versions of
op=
of the above -
[]
withstd::size_t
-
<<
withstd::ostream
-
- Access
Diagonalizer
(diagonalizer.hpp
), class to diagonalize symmetric Matrices
Type - 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
-
- Further developments
- Only finding eigenvectors and -values in a certain range may be added later on
Drum
(drum.hpp
), represents a single drum top resonator
Template Type - Template arguments
-
value_t
: Scalar type -
params_t
: Drum parameters container type -
vars_t
: Drum variables container type -
sbuffer_t
: Stepper buffer container type
-
- 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
-
- 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
-
- 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 typevars_t
. These containers may need to be adapted to the situation at hand. When time evolving, the stepper will use the container of typesbuffer_t
to store its intermediate results. Note that the default constructor of this class isdelete
d. It should be constructed from an object of typeparams_t
.
Rk4Stepper
(rk4_stepper.hpp
), performs timesteps using rk4 scheme
Template Type - 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
-
- 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