-
Pascal Engeler authoredPascal Engeler authored
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:
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:
- Create a new folder in
projects
.- Create subfolders
bin
,include
,lib
andresults
- Copy the
lib
contents intoprojects/newproj/lib
- Create subfolders
- 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.
- Write custom versions of classes
DrumParameters
(everything that is static) andDrumVariables
(everything that is dynamic) to accomodate these. Inspiration inlib/drum_variables.hpp
andlib/drum_parameters.hpp
. - Write custom
Grabber
that extracts the relevant data (inspiration ininclude/grabber.hpp
) - Write custom child of
Force
to calculate the force. - Write custom children of
Coupler
andDriver
to correctly update the drive and couplings. - If desired, write a custom child of
LatticeGenerator
to generate a custom lattice, or use the generatorprojects/braidingTightBinding/include/rbcomb_generator_braid.hpp
to create the RBComb. - If desired, write a child of
MatrixElementCalculator
to calculate matrix elements for the dynamic matrix. - Check the unit tests (
unit_tests
) or other projects to see how amain.cpp
could be constructed.
Hints for organizing, building and running simulations
- Use a Makefile.
- The framework should be compiled with c++ 2a.
- The
Diagonalizer
requires LAPACK to be linked. - Get inspiration from other projects.
- Organize executables in
bin
- 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
- Template arguments
-
value_t
: type of vector entries
-
- Explicit Constructors
Vec2(const value_t, const value_t)
Vec2(const Vec2&)
Vec2()
Vec2& operator=(const Vec2&)
- 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
- 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
-
*
withVec2
(inner product) andvalue_t
-
/
withvalue_t
- throws upon division by zero
-
+, -
withVec2
- All versions of
op=
of the above -
[]
withstd::size_t
-
<<
withstd::ostream
-
- Access
Diagonalizer
(diagonalizer.hpp), class to diagonalize symmetric Matrices
- Explicit Constructors
Diagonalizer()
- 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
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
- Respect the constraints given by this issue.
Drum
(drum.hpp), represents a single drum top resonator
- Template arguments
-
value_t
: Scalar type -
params_t
: Drum parameters container type -
vars_t
: Drum variables container type -
sbuffer_t
: Stepper buffer container type
-
- Explicit Constructors
Drum(const params_t&)
Drum() = delete
Drum(const Drum&)
Drum& operator=(const Drum&)
- 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
- deprecated
-
void set_coupling_1(value_t)
- Sets coupling 1
- deprecated
-
void set_coupling_2(value_t)
- Sets coupling 2
- deprecated
-
void set_drive(value_t)
- Sets central electrode coupling
- deprecated
-
- 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
. Example classes for these two types arelib/drum_parameters.hpp
andlib/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 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
.
- 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
- Further developments
- Abstract interfaces for
params_t
andvars_t
could be added, but they would be trivial.
- Abstract interfaces for