| 1 | 
/* | 
| 2 | 
 * Copyright (c) 2013 The University of Notre Dame. All Rights Reserved. | 
| 3 | 
 * | 
| 4 | 
 * The University of Notre Dame grants you ("Licensee") a | 
| 5 | 
 * non-exclusive, royalty free, license to use, modify and | 
| 6 | 
 * redistribute this software in source and binary code form, provided | 
| 7 | 
 * that the following conditions are met: | 
| 8 | 
 * | 
| 9 | 
 * 1. Redistributions of source code must retain the above copyright | 
| 10 | 
 *    notice, this list of conditions and the following disclaimer. | 
| 11 | 
 * | 
| 12 | 
 * 2. Redistributions in binary form must reproduce the above copyright | 
| 13 | 
 *    notice, this list of conditions and the following disclaimer in the | 
| 14 | 
 *    documentation and/or other materials provided with the | 
| 15 | 
 *    distribution. | 
| 16 | 
 * | 
| 17 | 
 * This software is provided "AS IS," without a warranty of any | 
| 18 | 
 * kind. All express or implied conditions, representations and | 
| 19 | 
 * warranties, including any implied warranty of merchantability, | 
| 20 | 
 * fitness for a particular purpose or non-infringement, are hereby | 
| 21 | 
 * excluded.  The University of Notre Dame and its licensors shall not | 
| 22 | 
 * be liable for any damages suffered by licensee as a result of | 
| 23 | 
 * using, modifying or distributing the software or its | 
| 24 | 
 * derivatives. In no event will the University of Notre Dame or its | 
| 25 | 
 * licensors be liable for any lost revenue, profit or data, or for | 
| 26 | 
 * direct, indirect, special, consequential, incidental or punitive | 
| 27 | 
 * damages, however caused and regardless of the theory of liability, | 
| 28 | 
 * arising out of the use of or inability to use software, even if the | 
| 29 | 
 * University of Notre Dame has been advised of the possibility of | 
| 30 | 
 * such damages. | 
| 31 | 
 * | 
| 32 | 
 * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your | 
| 33 | 
 * research, please cite the appropriate papers when you publish your | 
| 34 | 
 * work.  Good starting points are: | 
| 35 | 
 *                                                                       | 
| 36 | 
 * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).              | 
| 37 | 
 * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).           | 
| 38 | 
 * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).           | 
| 39 | 
 * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010). | 
| 40 | 
 * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). | 
| 41 | 
 */ | 
| 42 | 
 | 
| 43 | 
#include "clusters/Decahedron.hpp" | 
| 44 | 
#include <math.h> | 
| 45 | 
 | 
| 46 | 
using namespace std; | 
| 47 | 
 | 
| 48 | 
namespace OpenMD { | 
| 49 | 
 | 
| 50 | 
  Decahedron::Decahedron(int columnAtoms, int shells, int twinAtoms) :  | 
| 51 | 
    N_(columnAtoms), M_(shells), K_(twinAtoms) { | 
| 52 | 
     | 
| 53 | 
    Basis.clear(); | 
| 54 | 
    Points.clear(); | 
| 55 | 
     | 
| 56 | 
    // | 
| 57 | 
    // Initialize Basis vectors. | 
| 58 | 
    // | 
| 59 | 
    const RealType phi = 2.0 * M_PI / 5.0;  // 72 degrees | 
| 60 | 
    const RealType r3o2 = 0.5 * sqrt(3.0); | 
| 61 | 
     | 
| 62 | 
    Basis.push_back( Vector3d(  r3o2*cos(0.0*phi), r3o2*sin(0.0*phi),  0.0 )); | 
| 63 | 
    Basis.push_back( Vector3d(  r3o2*cos(1.0*phi), r3o2*sin(1.0*phi),  0.0 )); | 
| 64 | 
    Basis.push_back( Vector3d(  r3o2*cos(2.0*phi), r3o2*sin(2.0*phi),  0.0 )); | 
| 65 | 
    Basis.push_back( Vector3d(  r3o2*cos(3.0*phi), r3o2*sin(3.0*phi),  0.0 )); | 
| 66 | 
    Basis.push_back( Vector3d(  r3o2*cos(4.0*phi), r3o2*sin(4.0*phi),  0.0 )); | 
| 67 | 
  } | 
| 68 | 
   | 
| 69 | 
  Decahedron::~Decahedron() { | 
| 70 | 
    Basis.clear(); | 
| 71 | 
    Points.clear(); | 
| 72 | 
  } | 
| 73 | 
   | 
| 74 | 
  vector<Vector3d> Decahedron::getPoints() { | 
| 75 | 
    // Generate central column of Decahedron | 
| 76 | 
 | 
| 77 | 
    for (int i = 0; i < N_; i++) { | 
| 78 | 
      Points.push_back( Vector3d( 0.0, 0.0, RealType(i) - 0.5 * (N_ - 1) ) ); | 
| 79 | 
    } | 
| 80 | 
     | 
| 81 | 
    for (int i = 1; i < M_ + 1; i++) { | 
| 82 | 
      // generate the shells of the decahedron: | 
| 83 | 
       | 
| 84 | 
      vector<Vector3d> ring; | 
| 85 | 
         | 
| 86 | 
      if (i > K_ - 1) { | 
| 87 | 
        ring = truncatedRing(i, i - K_ + 1); | 
| 88 | 
      } else { | 
| 89 | 
        ring = truncatedRing(i, 0); | 
| 90 | 
      } | 
| 91 | 
 | 
| 92 | 
      // shift the rings in the z-direction (along the shell) | 
| 93 | 
       | 
| 94 | 
      for (int j = 0; j < N_ - i; j++) {        | 
| 95 | 
        Vector3d shift = Vector3d(0, 0, -0.5 * RealType((N_-i)-1) + RealType(j)); | 
| 96 | 
         | 
| 97 | 
        for (vector<Vector3d>::iterator k = ring.begin();  | 
| 98 | 
             k != ring.end(); ++k) { | 
| 99 | 
 | 
| 100 | 
          Points.push_back( (*k) + shift); | 
| 101 | 
 | 
| 102 | 
        } | 
| 103 | 
      } | 
| 104 | 
    } | 
| 105 | 
    return Points; | 
| 106 | 
  } | 
| 107 | 
 | 
| 108 | 
  vector<Vector3d> Decahedron::truncatedRing( int n, int k ) { | 
| 109 | 
    // This function generates the rings of a Decahedron | 
| 110 | 
    // n: index of shell (order of ring) | 
| 111 | 
    // k: how many atoms are missing from both ends of one side of | 
| 112 | 
    //    pentagon ring | 
| 113 | 
 | 
| 114 | 
    vector<Vector3d> ring; | 
| 115 | 
     | 
| 116 | 
    // Generate atomic coordinates along each side of pentagonal ring | 
| 117 | 
    for (int i = 0; i < 5; i++) { | 
| 118 | 
 | 
| 119 | 
      Vector3d b1 = Basis[i]; | 
| 120 | 
      Vector3d b2 = Basis[(i + 1) % 5]; | 
| 121 | 
 | 
| 122 | 
      if (k == 0) { | 
| 123 | 
        // without truncation  | 
| 124 | 
        for (int j = 0; j < n; j++) { | 
| 125 | 
          ring.push_back( RealType(n) * b1 + RealType(j) * (b2-b1)); | 
| 126 | 
        } | 
| 127 | 
         | 
| 128 | 
      } else { | 
| 129 | 
        for (int j = k; j <= n - k; j++) { | 
| 130 | 
          // with truncation         | 
| 131 | 
          ring.push_back( RealType(n) * b1 + RealType(j) * (b2-b1)); | 
| 132 | 
        } | 
| 133 | 
      } | 
| 134 | 
    } | 
| 135 | 
    return ring; | 
| 136 | 
  } | 
| 137 | 
 | 
| 138 | 
  CurlingStoneDecahedron::CurlingStoneDecahedron(int columnAtoms, int shells, | 
| 139 | 
                                                 int twinAtoms,  | 
| 140 | 
                                                 int truncatedPlanes) : | 
| 141 | 
    Decahedron(columnAtoms, shells, twinAtoms), T_(truncatedPlanes) {} | 
| 142 | 
     | 
| 143 | 
  vector<Vector3d> CurlingStoneDecahedron::getPoints() { | 
| 144 | 
 | 
| 145 | 
    vector<Vector3d> raw = Decahedron::getPoints(); | 
| 146 | 
    vector<Vector3d> snipped; | 
| 147 | 
    RealType maxZ, minZ;    | 
| 148 | 
 | 
| 149 | 
    maxZ = raw.begin()->z(); | 
| 150 | 
    minZ = raw.begin()->z(); | 
| 151 | 
 | 
| 152 | 
    for (vector<Vector3d>::iterator i = raw.begin(); i != raw.end(); ++i) { | 
| 153 | 
      maxZ = max(maxZ, (*i).z()); | 
| 154 | 
      minZ = min(minZ, (*i).z()); | 
| 155 | 
    } | 
| 156 | 
     | 
| 157 | 
    for (vector<Vector3d>::iterator i = raw.begin(); i != raw.end(); ++i) { | 
| 158 | 
      if ( ((*i).z() < maxZ - 0.995 * (T_ / 2.0) ) &&  | 
| 159 | 
           ((*i).z() > minZ + 0.995 * (T_ / 2.0) ) ){ | 
| 160 | 
        snipped.push_back( (*i) ); | 
| 161 | 
      } | 
| 162 | 
    } | 
| 163 | 
    return snipped; | 
| 164 | 
  } | 
| 165 | 
 | 
| 166 | 
} |