22#ifndef SCRIPT_INTERFACE_COLLISION_DETECTION_COLLISION_DETECTION_HPP
23#define SCRIPT_INTERFACE_COLLISION_DETECTION_COLLISION_DETECTION_HPP
27#ifdef COLLISION_DETECTION
38#include <unordered_map>
45 std::unordered_map<CollisionModeType, std::string>
const cd_mode_to_name = {
52 std::unordered_map<std::string, CollisionModeType> cd_name_to_mode;
54 std::vector<std::string>>
const cd_mode_to_parameters = {
58 {
"mode",
"bond_centers",
"bond_vs",
"part_type_vs",
"distance",
61 {
"mode",
"bond_centers",
"bond_vs",
"part_type_vs",
62 "part_type_to_be_glued",
"part_type_to_attach_vs_to",
63 "part_type_after_glueing",
"distance",
64 "distance_glued_particle_to_vs"}},
66 {
"mode",
"bond_centers",
"distance",
"bond_three_particles",
67 "three_particle_binding_angle_resolution"}},
72 for (
auto const &kv : cd_mode_to_name) {
73 cd_name_to_mode[kv.second] = kv.first;
78 auto const name = get_value<std::string>(v);
79 check_mode_name(
name);
87 {
"three_particle_binding_angle_resolution",
91 {
"distance_glued_particle_to_vs",
97 {
"part_type_to_attach_vs_to",
99 {
"part_type_after_glueing",
105 if (
name ==
"instantiate") {
110 check_input_parameters(
params);
113 for (
auto const &kv :
params) {
126 if (
name ==
"params_for_mode") {
127 auto const name = get_value<std::string>(
params,
"mode");
128 check_mode_name(
name);
129 auto const mode = cd_name_to_mode.at(
name);
136 void check_mode_name(std::string
const &
name)
const {
137 if (cd_name_to_mode.count(
name) == 0) {
138 throw std::invalid_argument(
"Unknown collision mode '" +
name +
"'");
143 auto const name = get_value<std::string>(
params,
"mode");
144 check_mode_name(
name);
145 auto const mode = cd_name_to_mode.at(
name);
146 auto const expected_params = cd_mode_to_parameters.at(mode);
147 auto const expected_param_names =
148 std::set<std::string>{expected_params.begin(), expected_params.end()};
149 std::set<std::string> input_parameter_names = {};
150 for (
auto const &kv :
params) {
151 auto const param_name = get_value<std::string>(kv.first);
152 if (expected_param_names.count(param_name) == 0) {
156 throw std::runtime_error(
"Parameter '" + param_name +
"' is not " +
157 "required for mode '" +
name +
"'");
159 input_parameter_names.insert(param_name);
161 for (
auto const ¶m_name : expected_param_names) {
162 if (input_parameter_names.count(param_name) == 0) {
163 throw std::runtime_error(
"Parameter '" + param_name +
"' is " +
164 "required for mode '" +
name +
"'");
int part_type_after_glueing
Particle type to which the newly glued particle is converted.
void initialize()
Validates parameters and creates particle types if needed.
int part_type_to_be_glued
For mode "glue to surface": The particle type being glued.
double vs_placement
Placement of virtual sites for MODE_VS.
int bond_centers
bond type used between centers of colliding particles
CollisionModeType mode
collision protocol
int three_particle_angle_resolution
Number of angle bonds to use (angular resolution) different angle bonds with different equilibrium an...
int part_type_to_attach_vs_to
For mode "glue to surface": The particle type to which the virtual site is attached.
double dist_glued_part_to_vs
For mode "glue to surface": The distance from the particle which is to be glued to the new virtual si...
int bond_three_particles
First bond type (for zero degrees) used for the three-particle bond (angle potential)
double distance
distance at which particles are bound
int bond_vs
bond type used between virtual sites
int vs_particle_type
particle type for virtual sites created on collision
Bind parameters in the script interface.
void do_set_parameter(const std::string &name, const Variant &value) final
Variant get_parameter(const std::string &name) const final
void add_parameters(std::vector< AutoParameter > &¶ms)
Variant do_call_method(const std::string &name, const VariantMap ¶ms) override
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
boost::string_ref name() const
Context * context() const
Responsible context.
Collision_parameters collision_params
Parameters for collision detection.
CollisionModeType
Protocols for collision handling.
@ BIND_CENTERS
Create bond between centers of colliding particles.
@ GLUE_TO_SURF
Glue a particle to a specific spot on another particle.
@ OFF
Deactivate collision detection.
@ BIND_THREE_PARTICLES
Three particle binding mode.
@ BIND_VS
Create a bond between the centers of the colliding particles, plus two virtual sites at the point of ...
This file contains the defaults for ESPResSo.
std::unordered_map< std::string, Variant > VariantMap
auto make_vector_of_variants(std::vector< T > const &v)
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
constexpr const None none
None-"literal".
static SteepestDescentParameters params
Currently active steepest descent instance.