add more motions
This commit is contained in:
@ -19,5 +19,7 @@ add_library(
|
||||
bimodalangle.h
|
||||
sixsitejump.cpp
|
||||
sixsitejump.h
|
||||
nsiteconejump.cpp
|
||||
nsiteconejump.h
|
||||
)
|
||||
|
||||
|
@ -1,14 +1,20 @@
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "coordinates.h"
|
||||
#include "bimodalangle.h"
|
||||
#include "isosmallangle.h"
|
||||
#include "random.h"
|
||||
#include "foursitejump.h"
|
||||
#include "nsiteconejump.h"
|
||||
#include "sixsitejump.h"
|
||||
#include "rjoac.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "sixsitejump.h"
|
||||
|
||||
|
||||
namespace motions {
|
||||
BaseMotion::BaseMotion(std::string name, const double delta, const double eta, std::mt19937_64& rng) : m_name(std::move(name)), m_delta(delta), m_eta(eta), m_rng(rng) {
|
||||
@ -43,8 +49,8 @@ namespace motions {
|
||||
if (input == "FourSiteTetrahedral")
|
||||
return new FourSiteTetrahedron(rng);
|
||||
|
||||
if (input == "SixSiteOctahedral")
|
||||
return new SixSiteOctahedron(rng);
|
||||
if (input == "SixSiteOctahedralC3")
|
||||
return new SixSiteOctahedronC3(rng);
|
||||
|
||||
if (input == "IsotropicAngle")
|
||||
return new SmallAngle(rng);
|
||||
@ -55,6 +61,12 @@ namespace motions {
|
||||
if (input == "BimodalAngle")
|
||||
return new BimodalAngle(rng);
|
||||
|
||||
if (input == "NSiteConeJump")
|
||||
return new NSiteJumpOnCone(rng);
|
||||
|
||||
if (input == "RandomJumpOnCone")
|
||||
return new RandomJumpOnCone(rng);
|
||||
|
||||
throw std::invalid_argument("Invalid input " + input);
|
||||
}
|
||||
|
||||
@ -74,4 +86,4 @@ namespace motions {
|
||||
os << m.getName();
|
||||
return os;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace motions {
|
||||
[[nodiscard]] double getEta() const { return m_eta; }
|
||||
void setEta(const double eta) { m_eta = eta; }
|
||||
[[nodiscard]] std::string getName() const { return m_name; }
|
||||
[[nodiscard]] double getInitOmega() const { return m_initial_omega; };
|
||||
[[nodiscard]] double getInitOmega() const { return m_initial_omega; }
|
||||
|
||||
[[nodiscard]] virtual std::string toString() const = 0;
|
||||
|
||||
|
@ -8,18 +8,18 @@ namespace motions {
|
||||
BaseMotion(std::string("BimodalAngle"), delta, eta, rng),
|
||||
m_angle1(angle1 * M_PI / 180.0),
|
||||
m_angle2(angle2 * M_PI / 180.0),
|
||||
m_prob(prob) {};
|
||||
m_prob(prob) {}
|
||||
BimodalAngle::BimodalAngle(std::mt19937_64 &rng) : BaseMotion(std::string("BimodalAngle"), rng) {}
|
||||
|
||||
void BimodalAngle::initialize() {
|
||||
m_prev_pos = draw_position();
|
||||
m_initial_omega = omega_q(m_prev_pos);
|
||||
};
|
||||
}
|
||||
|
||||
double BimodalAngle::jump() {
|
||||
const double angle = m_uni_dist(m_rng) < m_prob ? m_angle1 : m_angle2;
|
||||
const double gamma{2 * M_PI * m_uni_dist(m_rng)};
|
||||
m_prev_pos = coordinates::rotate(m_prev_pos, angle, gamma);
|
||||
m_prev_pos = rotate(m_prev_pos, angle, gamma);
|
||||
|
||||
return omega_q(m_prev_pos);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "coordinates.h"
|
||||
|
||||
namespace motions {
|
||||
class BimodalAngle : public BaseMotion {
|
||||
class BimodalAngle final : public BaseMotion {
|
||||
public:
|
||||
BimodalAngle(double, double, double, double, double, std::mt19937_64& );
|
||||
explicit BimodalAngle(std::mt19937_64&);
|
||||
|
@ -16,7 +16,7 @@ namespace motions {
|
||||
double WobbleCone::jump() {
|
||||
const double real_angle = m_uni_dist(m_rng) * m_angle;
|
||||
const double phi = 2 * M_PI * m_uni_dist(m_rng);
|
||||
return omega_q(coordinates::rotate(m_axis, real_angle, phi));
|
||||
return omega_q(rotate(m_axis, real_angle, phi));
|
||||
}
|
||||
|
||||
void WobbleCone::setParameters(const std::unordered_map<std::string, double> ¶meters) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <random>
|
||||
|
||||
namespace motions {
|
||||
class WobbleCone: public BaseMotion {
|
||||
class WobbleCone final: public BaseMotion {
|
||||
public:
|
||||
WobbleCone(double, double, double, std::mt19937_64&);
|
||||
explicit WobbleCone(std::mt19937_64&);
|
||||
|
@ -22,9 +22,9 @@ namespace coordinates {
|
||||
auto [x, y , z] = spherical_to_xyz(old_pos);
|
||||
|
||||
const auto new_pos = CartesianPos{
|
||||
cos_alpha * x + sin_alpha * (-x * z * sin_beta - y * cos_beta) / norm,
|
||||
cos_alpha * y + sin_alpha * (-y * z * sin_beta + x * cos_beta) / norm,
|
||||
cos_alpha * z + sin_alpha * norm * sin_beta
|
||||
cos_alpha * x + sin_alpha * (-cos_beta * y - sin_beta * x * z) / norm,
|
||||
cos_alpha * y + sin_alpha * (cos_beta * x - sin_beta * y * z) / norm,
|
||||
cos_alpha * z + sin_alpha * sin_beta * norm,
|
||||
};
|
||||
|
||||
return xyz_to_spherical(new_pos);
|
||||
|
@ -16,7 +16,7 @@ namespace motions {
|
||||
const double alpha = 2. * M_PI * m_uni_dist(m_rng);
|
||||
|
||||
for (int i = 1; i<4; i++) {
|
||||
auto corner_pos = coordinates::rotate(pos, m_beta, alpha + (i-1) * 2*M_PI/3.);
|
||||
auto corner_pos = rotate(pos, m_beta, alpha + (i-1) * 2*M_PI/3.);
|
||||
m_corners[i] = omega_q(corner_pos);
|
||||
}
|
||||
m_initial_omega = FourSiteTetrahedron::jump();
|
||||
|
@ -6,17 +6,17 @@
|
||||
|
||||
namespace motions {
|
||||
SmallAngle::SmallAngle(const double delta, const double eta, const double chi, std::mt19937_64 &rng) :
|
||||
BaseMotion(std::string("IsotropicAngle"), delta, eta, rng), m_chi(chi * M_PI / 180.0) {};
|
||||
BaseMotion(std::string("IsotropicAngle"), delta, eta, rng), m_chi(chi * M_PI / 180.0) {}
|
||||
SmallAngle::SmallAngle(std::mt19937_64 &rng) : BaseMotion(std::string("IsotropicAngle"), rng) {}
|
||||
|
||||
void SmallAngle::initialize() {
|
||||
m_prev_pos = draw_position();
|
||||
m_initial_omega = omega_q(m_prev_pos);
|
||||
};
|
||||
}
|
||||
|
||||
double SmallAngle::jump() {
|
||||
const double gamma{2 * M_PI * m_uni_dist(m_rng)};
|
||||
m_prev_pos = coordinates::rotate(m_prev_pos, m_chi, gamma);
|
||||
m_prev_pos = rotate(m_prev_pos, m_chi, gamma);
|
||||
|
||||
return omega_q(m_prev_pos);
|
||||
}
|
||||
|
59
src/motions/nsiteconejump.cpp
Normal file
59
src/motions/nsiteconejump.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Created by dominik on 12/14/24.
|
||||
//
|
||||
|
||||
#include "nsiteconejump.h"
|
||||
#include "coordinates.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
namespace motions {
|
||||
NSiteJumpOnCone::NSiteJumpOnCone(const double delta, const double eta, const int num_sites, const double chi, std::mt19937_64 &rng) :
|
||||
BaseMotion("NSiteJumpOnCone", delta, eta, rng),
|
||||
m_num_sites(num_sites),
|
||||
m_chi(chi*M_PI/180.) {}
|
||||
|
||||
NSiteJumpOnCone::NSiteJumpOnCone(std::mt19937_64 &rng) : BaseMotion("NSiteJumpOnCone", rng) { }
|
||||
|
||||
void NSiteJumpOnCone::initialize() {
|
||||
m_sites = std::vector<double>(m_num_sites);
|
||||
m_chooser = std::uniform_int_distribution<>{1, m_num_sites - 1};
|
||||
|
||||
m_axis = draw_position();
|
||||
|
||||
const double alpha = m_uni_dist(m_rng) * 2 * M_PI;
|
||||
const double steps = 2*M_PI / m_num_sites;
|
||||
for (int i = 0; i < m_num_sites; i++) {
|
||||
m_sites[i] = omega_q(rotate(m_axis, m_chi, i * steps + alpha));
|
||||
}
|
||||
}
|
||||
|
||||
double NSiteJumpOnCone::jump() {
|
||||
m_cone_idx += m_chooser(m_rng);
|
||||
m_cone_idx %= m_num_sites;
|
||||
|
||||
return m_sites[m_cone_idx];
|
||||
}
|
||||
|
||||
void NSiteJumpOnCone::setParameters(const std::unordered_map<std::string, double> ¶meters) {
|
||||
BaseMotion::setParameters(parameters);
|
||||
m_num_sites = static_cast<int>(parameters.at("num_sites"));
|
||||
m_chi = parameters.at("chi") * M_PI/180.;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, double> NSiteJumpOnCone::getParameters() const {
|
||||
auto parameter = BaseMotion::getParameters();
|
||||
parameter["num_sites"] = m_num_sites;
|
||||
parameter["chi"] = m_chi * 180. / M_PI;
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
std::string NSiteJumpOnCone::toString() const {
|
||||
return std::to_string(m_num_sites) + "SiteJumpOnCone/angle=" + std::to_string(m_chi*180/M_PI);
|
||||
}
|
||||
|
||||
} // motions
|
33
src/motions/nsiteconejump.h
Normal file
33
src/motions/nsiteconejump.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef NSITEJUMPONCONE_H
|
||||
#define NSITEJUMPONCONE_H
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
namespace motions {
|
||||
class NSiteJumpOnCone final : public BaseMotion {
|
||||
public:
|
||||
NSiteJumpOnCone(double, double, int, double, std::mt19937_64&);
|
||||
explicit NSiteJumpOnCone(std::mt19937_64&);
|
||||
|
||||
void initialize() override;
|
||||
double jump() override;
|
||||
|
||||
[[nodiscard]] std::string toString() const override;
|
||||
|
||||
void setParameters(const std::unordered_map<std::string, double> &) override;
|
||||
[[nodiscard]] std::unordered_map<std::string, double> getParameters() const override;
|
||||
|
||||
private:
|
||||
int m_num_sites{2};
|
||||
std::vector<double> m_sites{};
|
||||
double m_chi{1./2.};
|
||||
int m_cone_idx = 0;
|
||||
coordinates::SphericalPos m_axis{1, 0};
|
||||
std::uniform_int_distribution<> m_chooser;
|
||||
};
|
||||
} // motions
|
||||
|
||||
#endif //NSITEJUMPONCONE_H
|
@ -11,7 +11,7 @@ namespace motions {
|
||||
|
||||
double RandomJumpOnCone::jump() {
|
||||
const double phi = 2 * M_PI * m_uni_dist(m_rng);
|
||||
return omega_q(coordinates::rotate(m_axis, m_angle, phi));
|
||||
return omega_q(rotate(m_axis, m_angle, phi));
|
||||
}
|
||||
|
||||
void RandomJumpOnCone::setParameters(const std::unordered_map<std::string, double> ¶meters) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <random>
|
||||
|
||||
namespace motions {
|
||||
class RandomJumpOnCone: public BaseMotion {
|
||||
class RandomJumpOnCone final: public BaseMotion {
|
||||
public:
|
||||
RandomJumpOnCone(double, double, double, std::mt19937_64&);
|
||||
explicit RandomJumpOnCone(std::mt19937_64&);
|
||||
|
@ -1,34 +1,41 @@
|
||||
#include "sixsitejump.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include "coordinates.h"
|
||||
|
||||
namespace motions {
|
||||
SixSiteOctahedron::SixSiteOctahedron(const double delta, const double eta, std::mt19937_64& rng) :
|
||||
SixSiteOctahedronC3::SixSiteOctahedronC3(const double delta, const double eta, const double chi, std::mt19937_64& rng) :
|
||||
m_chi{chi*M_PI/180.},
|
||||
BaseMotion(std::string{"SixSiteOctahedral"}, delta, eta, rng) {}
|
||||
|
||||
SixSiteOctahedron::SixSiteOctahedron(std::mt19937_64& rng) : BaseMotion(std::string{"SixSiteOctahedral"}, rng) {}
|
||||
|
||||
void SixSiteOctahedron::initialize() {
|
||||
const auto pos = draw_position();
|
||||
m_corners[0] = omega_q(pos);
|
||||
m_corners[1] = omega_q(rotate(pos, M_PI, 0));
|
||||
SixSiteOctahedronC3::SixSiteOctahedronC3(std::mt19937_64& rng) : BaseMotion(std::string{"SixSiteOctahedralC3"}, rng) {}
|
||||
|
||||
void SixSiteOctahedronC3::initialize() {
|
||||
const coordinates::SphericalPos c3_axis = draw_position();
|
||||
const auto [x, y, z] = spherical_to_xyz(c3_axis);
|
||||
const double alpha = 2. * M_PI * m_uni_dist(m_rng);
|
||||
|
||||
for (int i = 2; i<6; i++) {
|
||||
auto corner_pos = coordinates::rotate(pos, M_PI_2, alpha + (i-2) * M_PI_2);
|
||||
m_corners[i] = omega_q(corner_pos);
|
||||
const double m_chi_opposite = M_PI - m_chi;
|
||||
|
||||
for (int i = 0; i<3; i++) {
|
||||
m_corners[2*i] = omega_q(rotate(c3_axis, m_chi, alpha + i * 2./3.*M_PI));
|
||||
m_corners[2*i+1] = omega_q(rotate(c3_axis, m_chi_opposite, alpha + i * 2./3.*M_PI + M_PI/3.));
|
||||
}
|
||||
m_initial_omega = SixSiteOctahedron::jump();
|
||||
|
||||
m_initial_omega = SixSiteOctahedronC3::jump();
|
||||
}
|
||||
|
||||
double SixSiteOctahedron::jump() {
|
||||
|
||||
double SixSiteOctahedronC3::jump() {
|
||||
m_corner_idx += m_chooser(m_rng);
|
||||
m_corner_idx %= 6;
|
||||
|
||||
return m_corners[m_corner_idx];
|
||||
}
|
||||
|
||||
std::string SixSiteOctahedron::toString() const {
|
||||
return {"SixSiteOctahedral"};
|
||||
std::string SixSiteOctahedronC3::toString() const {
|
||||
return {"SixSiteOctahedral/angle=" + std::to_string(m_chi / M_PI * 180.)};
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include <array>
|
||||
|
||||
namespace motions {
|
||||
class SixSiteOctahedron final : public BaseMotion {
|
||||
class SixSiteOctahedronC3 final : public BaseMotion {
|
||||
public:
|
||||
SixSiteOctahedron(double, double, std::mt19937_64&);
|
||||
explicit SixSiteOctahedron(std::mt19937_64&);
|
||||
SixSiteOctahedronC3(double, double, double, std::mt19937_64&);
|
||||
explicit SixSiteOctahedronC3(std::mt19937_64&);
|
||||
|
||||
void initialize() override;
|
||||
double jump() override;
|
||||
@ -20,7 +20,7 @@ namespace motions {
|
||||
[[nodiscard]] std::string toString() const override;
|
||||
|
||||
private:
|
||||
const double m_beta{std::acos(-1/3.)};
|
||||
const double m_chi{0.95531661812450927816385710251575775424341469501000549095969812932191204590}; // 54.74 deg
|
||||
|
||||
std::array<double, 6> m_corners{};
|
||||
int m_corner_idx{0};
|
||||
|
Reference in New Issue
Block a user