19#ifndef VOTCA_CSG_INTERACTION_H
20#define VOTCA_CSG_INTERACTION_H
54 assert(
group_.compare(
"") != 0);
88 assert(bead > -1 && boost::lexical_cast<size_t>(bead) <
beads_.size());
107 s <<
"molecule " <<
mol_;
136 assert(beads.size() >= 2);
138 for (
Index i = 0; i < 2; ++i) {
139 beads_[i] = beads.front();
161 assert(beads.size() >= 3);
163 for (
Index i = 0; i < 3; ++i) {
164 beads_[i] = beads.front();
188 assert(beads.size() >= 4);
190 for (
Index i = 0; i < 4; ++i) {
191 beads_[i] = beads.front();
209 return (bead == 0) ? -r : r;
215 return std::acos(v1.dot(v2) / sqrt(v1.squaredNorm() * v2.squaredNorm()));
223 1.0 / (sqrt(1 - std::pow(v1.dot(v2), 2) /
224 (v1.squaredNorm() * v2.squaredNorm())));
228 (-v2 / (v1.norm() * v2.norm()) +
229 (v1.dot(v2) * v1) / (v1.squaredNorm() * v2.squaredNorm()));
233 ((v1 + v2) / (v1.norm() * v2.norm()) -
234 (v1.dot(v2)) * (v2.squaredNorm() * v1 + v1.squaredNorm() * v2) /
235 (std::pow(v1.norm(), 3) * std::pow(v2.norm(), 3)));
238 return acos_prime * (-v1 / (v1.norm() * v2.norm())) +
239 (v1.dot(v2) * v2 / (v1.norm() * std::pow(v2.norm(), 3)));
244 return Eigen::Vector3d::Zero();
251 Eigen::Vector3d n1 = v1.cross(v2);
252 Eigen::Vector3d n2 = v2.cross(v3);
253 double sign = (v1.dot(n2) < 0) ? -1 : 1;
255 std::acos(n1.dot(n2) / sqrt(n1.squaredNorm() * n2.squaredNorm()));
262 Eigen::Vector3d n1, n2;
265 double sign = (v1.dot(n2) < 0) ? -1 : 1;
266 Eigen::Vector3d returnvec;
268 Eigen::Matrix3d
e = Eigen::Matrix3d::Identity();
271 sign * (-1.0 / (sqrt(1 - std::pow(n1.dot(n2), 2) /
272 (n1.squaredNorm() * n2.squaredNorm()))));
275 for (
Index i = 0; i < 3; i++) {
276 returnvec[i] = n2.dot(v2.cross(
e.col(i))) / (n1.norm() * n2.norm()) -
277 n1.dot(n2) * n1.dot(v2.cross(
e.col(i))) /
278 (n2.norm() * std::pow(n1.norm(), 3));
280 return acos_prime * returnvec;
284 for (
Index i = 0; i < 3; i++) {
286 (n1.dot(v3.cross(
e.col(i))) +
287 n2.dot(
e.col(i).cross(v1) +
e.col(i).cross(v2))) /
288 (n1.norm() * n2.norm()) -
289 n1.dot(n2) * ((n1.dot(
e.col(i).cross(v1) +
e.col(i).cross(v2))) /
290 (n2.norm() * std::pow(n1.norm(), 3)) +
291 n2.dot(v3.cross(
e.col(i))) /
292 (n1.norm() * std::pow(n2.norm(), 3)));
294 return acos_prime * returnvec;
298 for (
Index i = 0; i < 3; i++) {
300 (n1.dot(
e.col(i).cross(v2) +
e.col(i).cross(v3)) +
301 n2.dot(v1.cross(
e.col(i)))) /
302 (n1.norm() * n2.norm()) -
303 n1.dot(n2) * (n1.dot(v1.cross(
e.col(i))) /
304 (n2.norm() * std::pow(n1.norm(), 3)) +
305 (n2.dot(
e.col(i).cross(v2) +
e.col(i).cross(v3))) /
306 (n1.norm() * std::pow(n2.norm(), 3)));
308 return acos_prime * returnvec;
312 for (
Index i = 0; i < 3; i++) {
313 returnvec[i] = n1.dot(v2.cross(
e.col(i))) / (n1.norm() * n2.norm()) -
314 n1.dot(n2) * n2.dot(v2.cross(
e.col(i))) /
315 (n1.norm() * std::pow(n2.norm(), 3));
317 return acos_prime * returnvec;
323 return Eigen::Vector3d::Zero();
Eigen::Vector3d Grad(const Topology &top, Index bead) override
double EvaluateVar(const Topology &top) override
IAngle(Index bead1, Index bead2, Index bead3)
IAngle(std::list< Index > &beads)
IBond(Index bead1, Index bead2)
IBond(std::list< Index > &beads)
Eigen::Vector3d Grad(const Topology &top, Index bead) override
double EvaluateVar(const Topology &top) override
IDihedral(std::list< Index > &beads)
double EvaluateVar(const Topology &top) override
Eigen::Vector3d Grad(const Topology &top, Index bead) override
IDihedral(Index bead1, Index bead2, Index bead3, Index bead4)
base class for all interactions
const std::string & getGroup() const
const Index & getIndex() const
Index getBeadId(Index bead) const
void setGroup(const std::string &group)
const Index & getMolecule() const
virtual Eigen::Vector3d Grad(const Topology &top, Index bead)=0
void setGroupId(Index id)
virtual double EvaluateVar(const Topology &top)=0
void setIndex(const Index &index)
std::vector< Index > beads_
void setMolecule(const Index &mol)
virtual ~Interaction()=default
std::string getName() const
topology of the whole system
Eigen::Vector3d getDist(Index bead1, Index bead2) const
pbc correct distance of two beads
base class for all analysis tools