ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/constraints/ShapeBasedConstraint.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "BoxGeometry.hpp"
23#include "Constraint.hpp"
24#include "Observable_stat.hpp"
25#include "Particle.hpp"
26#include "ParticleRange.hpp"
28
29#include <shapes/NoWhere.hpp>
30#include <shapes/Shape.hpp>
31
32#include <utils/Vector.hpp>
33
34#include <memory>
35#include <utility>
36
37namespace System {
38class System;
39}
40
41namespace Constraints {
42
44public:
46 : part_rep{}, m_shape{std::make_shared<Shapes::NoWhere>()},
47 m_penetrable{false}, m_only_positive{false}, m_local_force{},
48 m_outer_normal_force{}, m_system{} {}
49
50 void add_energy(const Particle &p, const Utils::Vector3d &folded_pos,
51 double time, Observable_stat &energy) const override;
52
53 ParticleForce force(const Particle &p, const Utils::Vector3d &folded_pos,
54 double time) override;
55
56 bool fits_in_box(Utils::Vector3d const &) const override { return true; }
57
58 /** @brief Calculate the minimum distance between all particle pairs. */
59 double min_dist(BoxGeometry const &box_geo,
60 ParticleRange const &particles) const;
61
62 /** @brief Calculate distance from the constraint */
63 void calc_dist(Utils::Vector3d const &pos, double &dist,
64 Utils::Vector3d &vec) const {
65 m_shape->calculate_dist(pos, dist, vec);
66 }
67
68 void set_shape(std::shared_ptr<Shapes::Shape> const &shape) {
69 m_shape = shape;
70 }
71
72 Shapes::Shape const &shape() const { return *m_shape; }
73
74 void reset_force() override {
75 m_local_force = Utils::Vector3d{0, 0, 0};
76 m_outer_normal_force = 0.0;
77 }
78
79 bool &only_positive() { return m_only_positive; }
80 bool &penetrable() { return m_penetrable; }
81 int &type() { return part_rep.type(); }
82 Utils::Vector3d &velocity() { return part_rep.v(); }
83
84 void set_type(int type);
85
87 double total_normal_force() const;
88 void bind_system(std::shared_ptr<System::System const> const &system) {
89 m_system = system;
90 }
91
92private:
93 Particle part_rep;
94 std::shared_ptr<Shapes::Shape> m_shape;
95 bool m_penetrable;
96 bool m_only_positive;
97 Utils::Vector3d m_local_force;
98 double m_outer_normal_force;
99 std::weak_ptr<System::System const> m_system;
100
101 IA_parameters const &get_ia_param(int type) const;
102};
103
104} // namespace Constraints
Vector implementation and trait types for boost qvm interoperability.
void calc_dist(Utils::Vector3d const &pos, double &dist, Utils::Vector3d &vec) const
Calculate distance from the constraint.
bool fits_in_box(Utils::Vector3d const &) const override
void bind_system(std::shared_ptr< System::System const > const &system)
double min_dist(BoxGeometry const &box_geo, ParticleRange const &particles) const
Calculate the minimum distance between all particle pairs.
void add_energy(const Particle &p, const Utils::Vector3d &folded_pos, double time, Observable_stat &energy) const override
ParticleForce force(const Particle &p, const Utils::Vector3d &folded_pos, double time) override
void set_shape(std::shared_ptr< Shapes::Shape > const &shape)
Observable for the pressure and energy.
A range of particles.
Various procedures concerning interactions between particles.
Parameters for non-bonded interactions.
Force information on a particle.
Definition Particle.hpp:290
Struct holding all information for one particle.
Definition Particle.hpp:395
auto const & v() const
Definition Particle.hpp:433
auto const & type() const
Definition Particle.hpp:418