Pteros  2.0
Molecular modeling library for human beings!
force_field.h
1 /*
2  * This file is a part of
3  *
4  * ============================================
5  * ### Pteros molecular modeling library ###
6  * ============================================
7  *
8  * https://github.com/yesint/pteros
9  *
10  * (C) 2009-2021, Semen Yesylevskyy
11  *
12  * All works, which use Pteros, should cite the following papers:
13  *
14  * 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
15  * molecular analysis library for C++ and python",
16  * Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
17  * doi: 10.1002/jcc.23943.
18  *
19  * 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
20  * library for molecular analysis",
21  * Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
22  * doi: 10.1002/jcc.22989.
23  *
24  * This is free software distributed under Artistic License:
25  * http://www.opensource.org/licenses/artistic-license-2.0.php
26  *
27 */
28 
29 
30 #pragma once
31 
32 #include <vector>
33 #include <unordered_set>
34 #include <unordered_map>
35 #include <Eigen/Core>
36 
37 namespace pteros {
38 
53 class ForceField {
54 public:
55  int natoms;
60  std::vector<std::unordered_set<int> > exclusions;
61 
66  Eigen::MatrixXf LJ_C6, LJ_C12;
67 
69  std::vector<Eigen::Vector2f> LJ14_interactions;
70 
74  std::unordered_map<int,int> LJ14_pairs;
75 
77  float fudgeQQ;
78 
79  float rcoulomb, epsilon_r, epsilon_rf, rcoulomb_switch, rvdw_switch, rvdw;
80  std::string coulomb_type, coulomb_modifier, vdw_type, vdw_modifier;
81 
83  std::vector<Eigen::Vector2i> bonds;
84 
85  // Molecules
86  std::vector<Eigen::Vector2i> molecules;
87 
89  bool ready;
90 
92  float (*coulomb_kernel_ptr)(float,float,float,const ForceField&);
93 
95  float (*LJ_kernel_ptr)(float,float,float,const ForceField&);
96 
97  // Aux constants to be precomputed by set_kernels()
98  float coulomb_prefactor, k_rf, c_rf;
99  // potential shift constants
100  Eigen::Vector3f shift_1, shift_6, shift_12;
101 
103  ForceField();
104 
106  ForceField(const ForceField& other);
107 
110 
111  // Clear ff
112  void clear();
113 
114  // Setup coulomb and VDW kernel pointers
115  void setup_kernels();
116 
117  // Computes energy of atom pair at given distance
118  // Returns {Coulomb_en,LJ_en}
119  Eigen::Vector2f pair_energy(int at1, int at2, float r, float q1, float q2, int type1, int type2);
120 
122  float get_cutoff();
123 };
124 
125 }
126 
127 
128 
129 
pteros::ForceField::LJ_kernel_ptr
float(* LJ_kernel_ptr)(float, float, float, const ForceField &)
Pointer to chosen VDW kernel.
Definition: force_field.h:95
pteros::ForceField::fudgeQQ
float fudgeQQ
Scaling factor of 1-4 Coulomb interactions.
Definition: force_field.h:77
pteros::ForceField::LJ14_interactions
std::vector< Eigen::Vector2f > LJ14_interactions
The list of distinct types of LJ14 interactions in the format [C6,C12].
Definition: force_field.h:69
pteros::ForceField::exclusions
std::vector< std::unordered_set< int > > exclusions
Exclusions.
Definition: force_field.h:60
pteros::ForceField::ForceField
ForceField()
Constructor.
Definition: force_field.cpp:213
pteros::ForceField::operator=
ForceField & operator=(ForceField other)
Assignment operator.
Definition: force_field.cpp:241
pteros::ForceField::bonds
std::vector< Eigen::Vector2i > bonds
Bonds.
Definition: force_field.h:83
pteros::ForceField
Force field parameters of the system.
Definition: force_field.h:53
pteros::ForceField::coulomb_kernel_ptr
float(* coulomb_kernel_ptr)(float, float, float, const ForceField &)
Pointer to chosen coulomb kernel.
Definition: force_field.h:92
pteros::ForceField::LJ_C6
Eigen::MatrixXf LJ_C6
Matrices of normal (not excluded, not 1-4) LJ interactions.
Definition: force_field.h:66
pteros::ForceField::get_cutoff
float get_cutoff()
Returns "natural" cutoff (currenly min of rcoulomb and rvdw)
Definition: force_field.cpp:209
pteros::ForceField::LJ14_pairs
std::unordered_map< int, int > LJ14_pairs
The list of LJ14 pairs.
Definition: force_field.h:74
pteros::ForceField::ready
bool ready
Is the force field properly set up?
Definition: force_field.h:89