Simpatico  v1.10
Linear.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "Linear.h"
9 
10 #include <sstream>
11 
12 namespace Simp
13 {
14 
15  using namespace Util;
16 
17  /*
18  * Constructor.
19  */
21  : Species()
22  #ifdef SIMP_ANGLE
23  , hasAngles_(0)
24  #endif
25  #ifdef SIMP_DIHEDRAL
26  , hasDihedrals_(0)
27  #endif
28  {}
29 
30  /*
31  * Destructor.
32  */
34  {}
35 
36  /*
37  * Build the chemical structure of a flexible chain molecule.
38  */
40  {
41 
42  // Preconditions
43  if (nAtom() < 2) {
44  UTIL_THROW("nAtom < 2");
45  }
46  if (nBond() != nAtom() - 1) {
47  UTIL_THROW("nBond != nAtom - 1");
48  }
49  #ifdef SIMP_ANGLE
50  if (hasAngles_) {
51  if (nAngle() != nAtom() - 2) {
52  UTIL_THROW("nAngle != nAtom - 2");
53  }
54  }
55  #endif
56  #ifdef SIMP_DIHEDRAL
57  if (hasDihedrals_) {
58  if (nAtom() > 3) {
59  if (nDihedral() != nAtom() - 3) {
60  UTIL_THROW("nDihedral != nAtom - 3");
61  }
62  } else {
63  if (nDihedral() != 0) {
64  UTIL_THROW("nDihedral != 0 when nAtom < 4");
65  }
66  }
67  }
68  #endif
69 
70  int i;
71 
72  allocate();
73 
74  // Set Atom Type Ids
75  for (i = 0; i < nAtom(); ++i) {
77  }
78 
79  // Build Bonds
80  for (i = 0; i < nBond(); ++i) {
81  makeBond(i, i, i+1, calculateBondTypeId(i));
82  }
83 
84  #ifdef SIMP_ANGLE
85  // Build Angles
86  if (hasAngles_) {
87  for (i = 0; i < nAngle(); ++i) {
88  makeAngle(i, i, i+1, i+2, calculateAngleTypeId(i));
89  }
90  }
91  #endif
92 
93  #ifdef SIMP_DIHEDRAL
94  // Build Dihedrals.
95  if (hasDihedrals_) {
96  for (i = 0; i < nDihedral(); ++i) {
97  makeDihedral(i, i, i+1, i+2, i+3, calculateDihedralTypeId(i));
98  }
99  }
100  #endif
101 
102  }
103 
104 }
void setAtomType(int atomId, int atomType)
Set the type for one atom in a generic molecule of this Species.
virtual int calculateDihedralTypeId(int index) const =0
Return the dihedral type id for a specific dihedral.
int nAtom() const
Get number of atoms per molecule for this Species.
virtual int calculateAngleTypeId(int index) const =0
Return the angle type id for a specific angle.
Classes used by all simpatico molecular simulations.
Linear()
Constructor.
Definition: Linear.cpp:20
virtual int calculateBondTypeId(int index) const =0
Return the bond type id for a specific bond.
int hasAngles_
Does this chain have angle potentials (0 = false, 1 = true).
Definition: Linear.h:57
int nDihedral() const
Get number of dihedrals per molecule for this Species.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
void makeDihedral(int dihedralId, int atomId1, int atomId2, int atomId3, int atomId4, int dihedralType)
Add a dihedral to the chemical structure of a generic molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
void makeBond(int bondId, int atomId1, int atomId2, int bondType)
Add a bond to the chemical structure of a generic molecule.
void makeAngle(int angleId, int atomId1, int atomId2, int atomId3, int angleType)
Add an angle to the chemical structure of a generic molecule.
int hasDihedrals_
Does this chain have dihedral potentials (0 = false, 1 = true).
Definition: Linear.h:64
void buildLinear()
Build the chemical structure for a linear molecule.
Definition: Linear.cpp:39
virtual int calculateAtomTypeId(int index) const =0
Return the atom type id for a specific atom.
void allocate()
Allocate chemical structure arrays.
A Species represents a set of chemically similar molecules.
int nBond() const
Get number of bonds per molecule for this Species.
int nAngle() const
Get number of angles per molecule for this Species.
virtual ~Linear()
Destructor.
Definition: Linear.cpp:33