Skip to content
Snippets Groups Projects
Commit 902139a1 authored by Pascal Engeler's avatar Pascal Engeler
Browse files

indentation changes etc.

parent 92fc03a4
No related branches found
No related tags found
No related merge requests found
Showing
with 740 additions and 691 deletions
...@@ -6,55 +6,57 @@ ...@@ -6,55 +6,57 @@
template <typename value_t, typename drum_t, typename params_t> template <typename value_t, typename drum_t, typename params_t>
class CouplerBraid: public Coupler<value_t, drum_t>{ class CouplerBraid: public Coupler<value_t, drum_t>{
public: public:
//constructors //constructors
CouplerBraid(const std::vector<Vortex<value_t> >& vortices): vortices_(vortices) {} CouplerBraid(const std::vector<Vortex<value_t> >& vortices): vortices_(vortices) {}
~CouplerBraid() = default; ~CouplerBraid() = default;
void precompute(const value_t t_end, const value_t dt, const std::vector<drum_t>& drum_vec) noexcept final override void precompute(const value_t t_end, const value_t dt, const std::vector<drum_t>& drum_vec) noexcept final override
{ {
//we need the drum parameters later on, so extract it //we need the drum parameters later on, so extract it
params_.reserve(drum_vec.size()); params_.reserve(drum_vec.size());
for(auto d: drum_vec) for(auto d: drum_vec){
params_.push_back(d.get_parameters()); params_.push_back(d.get_parameters());
}
//we also need the neighbour vectors nicely indexed
for(auto d: drum_vec){ //we also need the neighbour vectors nicely indexed
if(d.get_parameters().sublattice == 'A'){ for(auto d: drum_vec){
n_vecs_.push_back(d.get_parameters().s0); if(d.get_parameters().sublattice == 'A'){
n_vecs_.push_back(d.get_parameters().s1); n_vecs_.push_back(d.get_parameters().s0);
n_vecs_.push_back(d.get_parameters().s2); n_vecs_.push_back(d.get_parameters().s1);
break; n_vecs_.push_back(d.get_parameters().s2);
} break;
} }
} }
void step(value_t dt) noexcept final }
{ void step(value_t dt) noexcept final
//move vortices or alpha here {
} //move vortices or alpha here
value_t operator()(const size_t drum_index, const size_t neighbour_index) const noexcept final override }
{ value_t operator()(const size_t drum_index, const size_t neighbour_index) const noexcept final override
Vec2<value_t> v = params_[drum_index].position; {
Vec2<value_t> s = n_vecs_[neighbour_index]; Vec2<value_t> v = params_[drum_index].position;
Vec2<value_t> s = n_vecs_[neighbour_index];
//the formula is only valid on the 'A' sublattice
if(params_[drum_index].sublattice == 'B') //the formula is only valid on the 'A' sublattice
v = v - s; if(params_[drum_index].sublattice == 'B'){
v = v - s;
std::complex<value_t> ret_val = 1.; //vortices are multiplicative }
for(auto tex: vortices_){
ret_val *= tex.distortion(v); std::complex<value_t> ret_val = 1.; //vortices are multiplicative
} for(auto tex: vortices_){
//add kekule ret_val *= tex.distortion(v);
ret_val *= vortices_.begin()->kekule(v, s); }
//add kekule
return 1. + std::real<value_t>(ret_val); //return with added offset, as in eliska's code ret_val *= vortices_.begin()->kekule(v, s);
}
return 1. + std::real<value_t>(ret_val); //return with added offset, as in eliska's code
private: }
std::vector<Vortex<value_t> > vortices_;
std::vector<params_t> params_; private:
std::vector<Vec2<value_t> > n_vecs_; std::vector<Vortex<value_t> > vortices_;
std::vector<params_t> params_;
std::vector<Vec2<value_t> > n_vecs_;
}; };
#endif #endif
#ifndef COUPLER_CONST_HPP_INCLUDED
#define COUPLER_CONST_HPP_INCLUDED
#include <vector>
#include <coupler.hpp>
template <typename value_t, typename drum_t, typename params_t>
class CouplerConst: public Coupler<value_t, drum_t>{
public:
//constructors
CouplerConst(value_t value): value_(value) {}
~CouplerConst() = default;
void precompute(const value_t t_end, const value_t dt, const std::vector<drum_t>& drum_vec) noexcept final override
{
//nothing to do
}
void step(value_t dt) noexcept final
{
//nothing to do
}
value_t operator()(const size_t drum_index, const size_t neighbour_index) const noexcept final override
{
return value_;
}
private:
value_t value_;
};
#endif
...@@ -5,23 +5,23 @@ ...@@ -5,23 +5,23 @@
template <typename value_t, typename drum_t> template <typename value_t, typename drum_t>
class DriverBraid: public Driver<value_t, drum_t>{ class DriverBraid: public Driver<value_t, drum_t>{
public: public:
//constructors //constructors
DriverBraid() = default; DriverBraid() = default;
~DriverBraid() = default; ~DriverBraid() = default;
void precompute(const value_t t_end, const value_t dt, const std::vector<drum_t>& drum_vec) noexcept final override void precompute(const value_t t_end, const value_t dt, const std::vector<drum_t>& drum_vec) noexcept final override
{ {
} }
void step(value_t dt) noexcept final void step(value_t dt) noexcept final
{ {
} }
value_t operator()(const size_t drum_index) const noexcept final override value_t operator()(const size_t drum_index) const noexcept final override
{ {
return 0; return 0;
} }
}; };
#endif #endif
...@@ -7,58 +7,59 @@ ...@@ -7,58 +7,59 @@
//TODO: Create an interface. It would be a trivial one, though. //TODO: Create an interface. It would be a trivial one, though.
template <typename value_t> template <typename value_t>
class DrumParametersBraid{ class DrumParametersBraid{
public: public:
/* Arguments: /* Arguments:
* k0: diagonal matrix element * k0: diagonal matrix element
* k1: coupling matrix element prefactor 1 * k1: coupling matrix element prefactor 1
* k2: coupling matrix element prefactor 2 * k2: coupling matrix element prefactor 2
* c: damping coefficient * c: damping coefficient
* position: position of the drum in real space * position: position of the drum in real space
* sublattice: 'A'/'a' or 'B'/'b', identifies sublattice drum is part of * sublattice: 'A'/'a' or 'B'/'b', identifies sublattice drum is part of
*/ */
DrumParametersBraid(const value_t k0, const value_t k1, const value_t k2, const value_t c, const Vec2<value_t>& position, char sublattice) noexcept DrumParametersBraid(const value_t k0, const value_t k1, const value_t k2, const value_t c, const Vec2<value_t>& position, char sublattice) noexcept
: k0(k0), k1(k1), k2(k2), c(c), position(position), sublattice(sublattice) : k0(k0), k1(k1), k2(k2), c(c), position(position), sublattice(sublattice)
{ {
generate_sublattice(sublattice, value_t(1.)); generate_sublattice(sublattice, value_t(1.));
} }
DrumParametersBraid() = delete; //no default initialization allowed DrumParametersBraid() = delete; //no default initialization allowed
DrumParametersBraid(const DrumParametersBraid&) = default; DrumParametersBraid(const DrumParametersBraid&) = default;
DrumParametersBraid& operator=(const DrumParametersBraid&) = default; DrumParametersBraid& operator=(const DrumParametersBraid&) = default;
~DrumParametersBraid() = default; ~DrumParametersBraid() = default;
private: private:
int generate_sublattice(char sublattice, value_t lc) noexcept{ int generate_sublattice(char sublattice, value_t lc) noexcept{
if(sublattice == 'A' or sublattice == 'a'){ if(sublattice == 'A' or sublattice == 'a'){
s0 = Vec2<value_t> (0, -lc); s0 = Vec2<value_t> (0, -lc);
s1 = Vec2<value_t> (-std::sqrt(3)*lc/2., lc/2.); s1 = Vec2<value_t> (-std::sqrt(3)*lc/2., lc/2.);
s2 = Vec2<value_t> (std::sqrt(3)*lc/2., lc/2.); s2 = Vec2<value_t> (std::sqrt(3)*lc/2., lc/2.);
return 0; return 0;
} }
else if(sublattice == 'B' or sublattice == 'b'){ else if(sublattice == 'B' or sublattice == 'b'){
s0 = -1*(Vec2<value_t> (0, -lc)); s0 = -1*(Vec2<value_t> (0, -lc));
s1 = -1*(Vec2<value_t> (-std::sqrt(3)*lc/2., lc/2.)); s1 = -1*(Vec2<value_t> (-std::sqrt(3)*lc/2., lc/2.));
s2 = -1*(Vec2<value_t> (std::sqrt(3)*lc/2., lc/2.)); s2 = -1*(Vec2<value_t> (std::sqrt(3)*lc/2., lc/2.));
return 0; return 0;
} }
else else{
return -1; //invalid sublattice identifier return -1; //invalid sublattice identifier
} }
}
public: public:
value_t k0; //onsite prefactor value_t k0; //onsite prefactor
value_t k1; //coupling prefactor 1 value_t k1; //coupling prefactor 1
value_t k2; //coupling prefactor 2 value_t k2; //coupling prefactor 2
value_t c; //damping coefficient value_t c; //damping coefficient
char sublattice; //sublattice the drum is part of (governs electrode geometry) char sublattice; //sublattice the drum is part of (governs electrode geometry)
Vec2<value_t> s0, s1, s2; //vectors connecting to neighbours, ordered according to drum.hpp Vec2<value_t> s0, s1, s2; //vectors connecting to neighbours, ordered according to drum.hpp
Vec2<value_t> position; //position of the drum in real space Vec2<value_t> position; //position of the drum in real space
}; };
template<typename value_t> template<typename value_t>
std::ostream& operator<<(std::ostream& os, const DrumParametersBraid<value_t>& dp) std::ostream& operator<<(std::ostream& os, const DrumParametersBraid<value_t>& dp)
{ {
return os << "Sublattice: " << dp.sublattice << ", k0: " << dp.k0 << ", k1: " << dp.k1 << ", k2: " << dp.k2 << std::endl << "s0: " << dp.s0 << ", s1: " << dp.s1 << ", s2: " << dp.s2; return os << "Sublattice: " << dp.sublattice << ", k0: " << dp.k0 << ", k1: " << dp.k1 << ", k2: " << dp.k2 << std::endl << "s0: " << dp.s0 << ", s1: " << dp.s1 << ", s2: " << dp.s2;
} }
......
...@@ -8,16 +8,16 @@ ...@@ -8,16 +8,16 @@
//TODO: Generate an interface. It would be trivial, though. //TODO: Generate an interface. It would be trivial, though.
template <typename value_t> template <typename value_t>
class DrumVariablesBraid{ class DrumVariablesBraid{
public: public:
//constructors //constructors
DrumVariablesBraid() = default; DrumVariablesBraid() = default;
DrumVariablesBraid& operator=(const DrumVariablesBraid&) = default; DrumVariablesBraid& operator=(const DrumVariablesBraid&) = default;
~DrumVariablesBraid() = default; ~DrumVariablesBraid() = default;
value_t t0, t1, t2; //t + dt, i.e. baseline plus vortices along bond 0,1,2 value_t t0, t1, t2; //t + dt, i.e. baseline plus vortices along bond 0,1,2
value_t V; //Coupling to central electrode value_t V; //Coupling to central electrode
value_t x, xdot; //Current Elongation (position) and velocity value_t x, xdot; //Current Elongation (position) and velocity
value_t x_temp, xdot_temp; //used as calculation arguments in rk steps value_t x_temp, xdot_temp; //used as calculation arguments in rk steps
}; };
#endif #endif
...@@ -9,35 +9,35 @@ ...@@ -9,35 +9,35 @@
template <typename value_t, typename params_t, typename vars_t, typename buffer_t> template <typename value_t, typename params_t, typename vars_t, typename buffer_t>
class ForceBraid: public Force<value_t, params_t, vars_t, buffer_t>{ class ForceBraid: public Force<value_t, params_t, vars_t, buffer_t>{
public: public:
ForceBraid() = default; ForceBraid() = default;
~ForceBraid() = default; ~ForceBraid() = default;
value_t operator()( value_t operator()(
const Drum<value_t, params_t, vars_t, buffer_t>& drum, //Drum we're calculating the force on const Drum<value_t, params_t, vars_t, buffer_t>& drum, //Drum we're calculating the force on
const Drum<value_t, params_t, vars_t, buffer_t>& neighbour0, //Neighbour 0 const Drum<value_t, params_t, vars_t, buffer_t>& neighbour0, //Neighbour 0
const Drum<value_t, params_t, vars_t, buffer_t>& neighbour1, //Neighbour 1 const Drum<value_t, params_t, vars_t, buffer_t>& neighbour1, //Neighbour 1
const Drum<value_t, params_t, vars_t, buffer_t>& neighbour2, //Neighbour 2 const Drum<value_t, params_t, vars_t, buffer_t>& neighbour2, //Neighbour 2
const value_t time) const noexcept final override const value_t time) const noexcept final override
{ {
//fetch data //fetch data
//note that no copying is done here, these are all references //note that no copying is done here, these are all references
//TODO: implement drive //TODO: implement drive
const params_t& drum_params = drum.get_parameters(); //parameters of drum const params_t& drum_params = drum.get_parameters(); //parameters of drum
const vars_t& drum_vars = drum.get_variables(); //variables of drum const vars_t& drum_vars = drum.get_variables(); //variables of drum
const vars_t& n0_vars = neighbour0.get_variables(); //variables of neighbour 0 const vars_t& n0_vars = neighbour0.get_variables(); //variables of neighbour 0
const vars_t& n1_vars = neighbour1.get_variables(); //variables of neighbour 1 const vars_t& n1_vars = neighbour1.get_variables(); //variables of neighbour 1
const vars_t& n2_vars = neighbour2.get_variables(); //variables of neighbour 2 const vars_t& n2_vars = neighbour2.get_variables(); //variables of neighbour 2
value_t part1 = - drum_params.k0 * drum_vars.x_temp; value_t part1 = - drum_params.k0 * drum_vars.x_temp;
value_t part2 = - drum_params.c * drum_vars.xdot_temp; value_t part2 = - drum_params.c * drum_vars.xdot_temp;
value_t part3 = 0.; value_t part3 = 0.;
part3 -= drum_params.k1 + drum_params.k2 * n0_vars.t0 * n0_vars.x_temp; part3 -= drum_params.k1 + drum_params.k2 * n0_vars.t0 * n0_vars.x_temp;
part3 -= drum_params.k1 + drum_params.k2 * n1_vars.t1 * n1_vars.x_temp; part3 -= drum_params.k1 + drum_params.k2 * n1_vars.t1 * n1_vars.x_temp;
part3 -= drum_params.k1 + drum_params.k2 * n2_vars.t2 * n2_vars.x_temp; part3 -= drum_params.k1 + drum_params.k2 * n2_vars.t2 * n2_vars.x_temp;
return part1 + part2 + part3; return part1 + part2 + part3;
} }
}; };
......
...@@ -7,134 +7,137 @@ ...@@ -7,134 +7,137 @@
template<typename value_t> template<typename value_t>
struct DataStorage{ struct DataStorage{
DataStorage(const size_t num_drums) DataStorage(const size_t num_drums)
{ {
x.reserve(num_drums); x.reserve(num_drums);
xdot.reserve(num_drums); xdot.reserve(num_drums);
t0.reserve(num_drums); t0.reserve(num_drums);
t1.reserve(num_drums); t1.reserve(num_drums);
t2.reserve(num_drums); t2.reserve(num_drums);
drive.reserve(num_drums); drive.reserve(num_drums);
} }
~DataStorage() = default; ~DataStorage() = default;
value_t time; value_t time;
std::vector<value_t> x; std::vector<value_t> x;
std::vector<value_t> xdot; std::vector<value_t> xdot;
std::vector<value_t> t0; std::vector<value_t> t0;
std::vector<value_t> t1; std::vector<value_t> t1;
std::vector<value_t> t2; std::vector<value_t> t2;
std::vector<value_t> drive; std::vector<value_t> drive;
}; };
template <typename value_t, typename drum_t> template <typename value_t, typename drum_t>
class Grabber{ class Grabber{
public: public:
Grabber(const size_t grab_every, const std::string params_file, const std::string adjacency_file, const std::string dynamic_file) Grabber(const size_t grab_every, const std::string params_file, const std::string adjacency_file, const std::string dynamic_file)
: grab_every_(grab_every), grab_cnt_(0), par_f_(params_file), adj_f_(adjacency_file), dyn_f_(dynamic_file) {} : grab_every_(grab_every), grab_cnt_(0), par_f_(params_file), adj_f_(adjacency_file), dyn_f_(dynamic_file) {}
Grabber() = delete; //no default initialization Grabber() = delete; //no default initialization
Grabber(const Grabber&) = default; Grabber(const Grabber&) = default;
~Grabber() = default; ~Grabber() = default;
//call in system constructor //call in system constructor
void init(const value_t t_end, const value_t dt, const std::vector<drum_t>& drums, const std::vector<std::vector<int> >& adjacency) noexcept void init(const value_t t_end, const value_t dt, const std::vector<drum_t>& drums, const std::vector<std::vector<int> >& adjacency) noexcept
{ {
drums_ = drums; drums_ = drums;
adjacency_ = adjacency; adjacency_ = adjacency;
t_end_ = t_end; t_end_ = t_end;
dt_ = dt; dt_ = dt;
} }
//call after each simulation step, checks itself if it should save //call after each simulation step, checks itself if it should save
bool grab(const std::vector<drum_t>& drums, const value_t time) bool grab(const std::vector<drum_t>& drums, const value_t time)
{ {
if(grab_cnt_++ % grab_every_ == 0){ if(grab_cnt_++ % grab_every_ == 0){
data_.push_back(DataStorage<value_t>(drums_.size())); data_.push_back(DataStorage<value_t>(drums_.size()));
data_.back().time = time; data_.back().time = time;
for(auto d: drums){ for(auto d: drums){
data_.back().x.push_back(d.get_variables().x); data_.back().x.push_back(d.get_variables().x);
data_.back().xdot.push_back(d.get_variables().xdot); data_.back().xdot.push_back(d.get_variables().xdot);
data_.back().t0.push_back(d.get_variables().t0); data_.back().t0.push_back(d.get_variables().t0);
data_.back().t1.push_back(d.get_variables().t1); data_.back().t1.push_back(d.get_variables().t1);
data_.back().t2.push_back(d.get_variables().t2); data_.back().t2.push_back(d.get_variables().t2);
data_.back().drive.push_back(d.get_variables().V); data_.back().drive.push_back(d.get_variables().V);
} }
return true; return true;
} }
else else{
return false; return false;
} }
}
//prints the data out. call at end of it all. //prints the data out. call at end of it all.
bool save(){ bool save(){
//TODO: Check for file open //TODO: Check for file open
//TODO: Overload operator<< for DrumParameters and DataStorage. //TODO: Overload operator<< for DrumParameters and DataStorage.
//print parameters //print parameters
std::fstream par (par_f_, par.out); std::fstream par (par_f_, par.out);
par << "# The last drum is to be ignored\n"; par << "# The last drum is to be ignored\n";
par << "# k0 \t k1 \t k2 \t c \t pos_x \t pos_y \t sublattice\n"; par << "# k0 \t k1 \t k2 \t c \t pos_x \t pos_y \t sublattice\n";
for(auto d: drums_){ for(auto d: drums_){
par << d.get_parameters().k0 << " \t"; par << d.get_parameters().k0 << " \t";
par << d.get_parameters().k1 << " \t"; par << d.get_parameters().k1 << " \t";
par << d.get_parameters().k2 << " \t"; par << d.get_parameters().k2 << " \t";
par << d.get_parameters().c << " \t"; par << d.get_parameters().c << " \t";
par << d.get_parameters().position.x() << " \t"; par << d.get_parameters().position.x() << " \t";
par << d.get_parameters().position.y() << " \t"; par << d.get_parameters().position.y() << " \t";
par << d.get_parameters().sublattice << "\n"; par << d.get_parameters().sublattice << "\n";
} }
par.close(); par.close();
//print adjacency vectors //print adjacency vectors
std::fstream adj (adj_f_, adj.out); std::fstream adj (adj_f_, adj.out);
adj << "# <-1> means <no neighbour here>\n"; adj << "# <-1> means <no neighbour here>\n";
adj << "# The last drum is to be ignored\n"; adj << "# The last drum is to be ignored\n";
adj << "# n0 \t n1 \t n2\n"; adj << "# n0 \t n1 \t n2\n";
for(auto v: adjacency_){ for(auto v: adjacency_){
for(auto i: v){ for(auto i: v){
if(i == drums_.size()-1) if(i == drums_.size()-1){
adj << -1 << " \t"; //no neighbour present adj << -1 << " \t"; //no neighbour present
else }
adj << i << " \t"; //neighbour else{
} adj << i << " \t"; //neighbour
adj << "\n"; }
} }
adj.close(); adj << "\n";
}
adj.close();
std::fstream dyn (dyn_f_, dyn.out); std::fstream dyn (dyn_f_, dyn.out);
dyn << "# If adjacency of a bond is -1 in " << adj_f_; dyn << "# If adjacency of a bond is -1 in " << adj_f_;
dyn << ", the coupling is to be ignored\n"; dyn << ", the coupling is to be ignored\n";
dyn << "# The last drum is to be ignored\n"; dyn << "# The last drum is to be ignored\n";
dyn << "# Number of drums : " << drums_.size() << "\n"; dyn << "# Number of drums : " << drums_.size() << "\n";
dyn << "# t \t drum_index \t x \t xdot \t t0 \t t1 \t t2 \t drive\n"; dyn << "# t \t drum_index \t x \t xdot \t t0 \t t1 \t t2 \t drive\n";
for(auto entry: data_){ for(auto entry: data_){
for(size_t i = 0; i < entry.x.size(); ++i){ for(size_t i = 0; i < entry.x.size(); ++i){
dyn << entry.time << " \t"; dyn << entry.time << " \t";
dyn << i << " \t"; dyn << i << " \t";
dyn << entry.x[i] << " \t"; dyn << entry.x[i] << " \t";
dyn << entry.xdot[i] << " \t"; dyn << entry.xdot[i] << " \t";
dyn << entry.t0[i] << " \t"; dyn << entry.t0[i] << " \t";
dyn << entry.t1[i] << " \t"; dyn << entry.t1[i] << " \t";
dyn << entry.t2[i] << " \t"; dyn << entry.t2[i] << " \t";
dyn << entry.drive[i] << "\n"; dyn << entry.drive[i] << "\n";
} }
} }
dyn.close(); dyn.close();
return true; return true;
} }
private: private:
size_t grab_every_; //grab data every grab_every_ steps size_t grab_every_; //grab data every grab_every_ steps
size_t grab_cnt_; //grab count size_t grab_cnt_; //grab count
value_t t_end_, dt_; //maximal simulation time and timestep value_t t_end_, dt_; //maximal simulation time and timestep
std::vector<std::vector<int> > adjacency_; //adjacency vector std::vector<std::vector<int> > adjacency_; //adjacency vector
std::vector<drum_t> drums_; //drums in initial configuration, grab params from here std::vector<drum_t> drums_; //drums in initial configuration, grab params from here
std::list<DataStorage<value_t> > data_; //here goes the dynamical data std::list<DataStorage<value_t> > data_; //here goes the dynamical data
//filenames //filenames
std::string par_f_; //parameters file std::string par_f_; //parameters file
std::string adj_f_; //adjacency file std::string adj_f_; //adjacency file
std::string dyn_f_; //dynamics file (this is the gold) std::string dyn_f_; //dynamics file (this is the gold)
}; };
#endif #endif
...@@ -4,32 +4,32 @@ ...@@ -4,32 +4,32 @@
template <typename value_t, typename params_t, typename vars_t, typename drum_t> template <typename value_t, typename params_t, typename vars_t, typename drum_t>
class MatrixElementCalculatorBraid: public MatrixElementCalculator<value_t, params_t, vars_t, drum_t>{ class MatrixElementCalculatorBraid: public MatrixElementCalculator<value_t, params_t, vars_t, drum_t>{
public: public:
MatrixElementCalculatorBraid() = default; MatrixElementCalculatorBraid() = default;
~MatrixElementCalculatorBraid() = default; ~MatrixElementCalculatorBraid() = default;
//diagonal element at (index, index) //diagonal element at (index, index)
value_t operator()(const size_t index, const std::vector<drum_t>& drums) const noexcept final override value_t operator()(const size_t index, const std::vector<drum_t>& drums) const noexcept final override
{ {
return drums[index].get_parameters().k0; return drums[index].get_parameters().k0;
} }
//coupling elements at (index1, index2) //coupling elements at (index1, index2)
//for neighbour 0 //for neighbour 0
value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums) const noexcept final override value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums) const noexcept final override
{ {
return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t0; return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t0;
} }
//for neighbour 1 //for neighbour 1
value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums, const int) const noexcept final override value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums, const int) const noexcept final override
{ {
return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t1; return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t1;
} }
//for neighbour 2 //for neighbour 2
value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums, const int, const int) const noexcept final override value_t operator()(const size_t index1, const size_t index2, const std::vector<drum_t>& drums, const int, const int) const noexcept final override
{ {
return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t2; return drums[index1].get_parameters().k1 + drums[index1].get_parameters().k2 * drums[index2].get_variables().t2;
} }
}; };
#endif #endif
...@@ -6,43 +6,43 @@ ...@@ -6,43 +6,43 @@
template <typename value_t> template <typename value_t>
class Vortex{ class Vortex{
public: public:
//constructors //constructors
Vortex(const Vec2<value_t> position, const value_t l0, const value_t alpha, const value_t delta, const value_t a) noexcept: position_(position), l0_(l0), alpha_(alpha), delta_(delta), K_(value_t(4.*3.141592653589793/(3.*std::sqrt(3)*a)), value_t(0.)) {} Vortex(const Vec2<value_t> position, const value_t l0, const value_t alpha, const value_t delta, const value_t a) noexcept: position_(position), l0_(l0), alpha_(alpha), delta_(delta), K_(value_t(4.*3.141592653589793/(3.*std::sqrt(3)*a)), value_t(0.)) {}
Vortex(const Vec2<value_t> position, const Vortex& o) noexcept: position_(position), l0_(o.l0_), alpha_(o.alpha_), delta_(o.delta_), K_(o.K_) {} Vortex(const Vec2<value_t> position, const Vortex& o) noexcept: position_(position), l0_(o.l0_), alpha_(o.alpha_), delta_(o.delta_), K_(o.K_) {}
Vortex() = default; Vortex() = default;
Vortex(const Vortex&) = default; Vortex(const Vortex&) = default;
Vortex& operator=(const Vortex&) = default; Vortex& operator=(const Vortex&) = default;
~Vortex() = default; ~Vortex() = default;
//access //access
value_t l0() const noexcept { return l0_; } value_t l0() const noexcept { return l0_; }
value_t alpha() const noexcept { return alpha_; } value_t alpha() const noexcept { return alpha_; }
value_t delta() const noexcept { return delta_; } value_t delta() const noexcept { return delta_; }
Vec2<value_t>& position() noexcept { return position_; } Vec2<value_t>& position() noexcept { return position_; }
const Vec2<value_t>& position() const noexcept { return position_; } const Vec2<value_t>& position() const noexcept { return position_; }
//modifiers //modifiers
void set_l0(value_t l0) noexcept { l0_ = l0; } void set_l0(value_t l0) noexcept { l0_ = l0; }
void set_alpha(value_t alpha) noexcept { alpha_ = alpha; } void set_alpha(value_t alpha) noexcept { alpha_ = alpha; }
void set_delta(value_t delta) noexcept { delta_ = delta; } void set_delta(value_t delta) noexcept { delta_ = delta; }
void set_position(const Vec2<value_t>& position) noexcept { position_ = position; } void set_position(const Vec2<value_t>& position) noexcept { position_ = position; }
void move_by(const Vec2<value_t>& translation) noexcept { position_ += translation; } void move_by(const Vec2<value_t>& translation) noexcept { position_ += translation; }
void move_to(const Vec2<value_t>& position) noexcept { position_ = position; } void move_to(const Vec2<value_t>& position) noexcept { position_ = position; }
//functional //functional
//there is no divide_by_zero check for efficiency reasons. l0_ can not be zero upon call. //there is no divide_by_zero check for efficiency reasons. l0_ can not be zero upon call.
std::complex<value_t> distortion(const Vec2<value_t>& v) const std::complex<value_t> distortion(const Vec2<value_t>& v) const
{ {
return std::polar<value_t>(delta_*std::tanh(v.r_wrt(position_)/l0_), alpha_ - v.phi_wrt(position_)); return std::polar<value_t>(delta_*std::tanh(v.r_wrt(position_)/l0_), alpha_ - v.phi_wrt(position_));
} }
std::complex<value_t> kekule(const Vec2<value_t>& v, const Vec2<value_t>& s) const{ std::complex<value_t> kekule(const Vec2<value_t>& v, const Vec2<value_t>& s) const{
return std::polar<value_t>(1., K_*(s + 2.*(v - position_))); return std::polar<value_t>(1., K_*(s + 2.*(v - position_)));
} }
private: private:
Vec2<value_t> position_; Vec2<value_t> position_;
const Vec2<value_t> K_; const Vec2<value_t> K_;
value_t l0_, alpha_, delta_; value_t l0_, alpha_, delta_;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment