| 1 |
gezelter |
2029 |
/* |
| 2 |
|
|
* Copyright (c) 2005 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 <algorithm> |
| 44 |
|
|
#include <functional> |
| 45 |
|
|
#include "applications/sequentialProps/ContactAngle1.hpp" |
| 46 |
|
|
#include "utils/simError.h" |
| 47 |
|
|
#include "io/DumpReader.hpp" |
| 48 |
|
|
#include "primitives/Molecule.hpp" |
| 49 |
|
|
#include "utils/NumericConstant.hpp" |
| 50 |
|
|
#include "math/Polynomial.hpp" |
| 51 |
|
|
|
| 52 |
|
|
namespace OpenMD { |
| 53 |
|
|
|
| 54 |
|
|
ContactAngle1::ContactAngle1(SimInfo* info, const std::string& filename, |
| 55 |
|
|
const std::string& sele, RealType solidZ, |
| 56 |
|
|
RealType dropletRadius) |
| 57 |
|
|
: SequentialAnalyzer(info, filename), selectionScript_(sele), |
| 58 |
|
|
evaluator_(info), seleMan_(info), solidZ_(solidZ), |
| 59 |
|
|
dropletRadius_(dropletRadius) { |
| 60 |
|
|
|
| 61 |
|
|
setOutputName(getPrefix(filename) + ".ca1"); |
| 62 |
|
|
|
| 63 |
|
|
evaluator_.loadScriptString(sele); |
| 64 |
|
|
|
| 65 |
|
|
if (!evaluator_.isDynamic()) { |
| 66 |
|
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
| 67 |
|
|
} |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
void ContactAngle1::doFrame() { |
| 71 |
|
|
StuntDouble* sd; |
| 72 |
|
|
int i; |
| 73 |
|
|
|
| 74 |
|
|
if (evaluator_.isDynamic()) { |
| 75 |
|
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
| 76 |
|
|
} |
| 77 |
|
|
|
| 78 |
|
|
|
| 79 |
|
|
RealType mtot = 0.0; |
| 80 |
|
|
Vector3d com(V3Zero); |
| 81 |
|
|
RealType mass; |
| 82 |
|
|
|
| 83 |
|
|
for (sd = seleMan_.beginSelected(i); sd != NULL; |
| 84 |
|
|
sd = seleMan_.nextSelected(i)) { |
| 85 |
|
|
mass = sd->getMass(); |
| 86 |
|
|
mtot += mass; |
| 87 |
|
|
com += sd->getPos() * mass; |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
com /= mtot; |
| 91 |
|
|
|
| 92 |
|
|
RealType dz = com.z() - solidZ_; |
| 93 |
|
|
|
| 94 |
|
|
if (dz < 0.0) { |
| 95 |
|
|
sprintf(painCave.errMsg, |
| 96 |
|
|
"ContactAngle1: Z-center of mass of selection, %lf, was\n" |
| 97 |
|
|
"\tlocated below the solid reference plane, %lf\n", |
| 98 |
|
|
com.z(), solidZ_); |
| 99 |
|
|
painCave.isFatal = 1; |
| 100 |
|
|
painCave.severity = OPENMD_ERROR; |
| 101 |
|
|
simError(); |
| 102 |
|
|
} |
| 103 |
|
|
|
| 104 |
|
|
if (dz > dropletRadius_) { |
| 105 |
|
|
values_.push_back(180.0); |
| 106 |
|
|
} else { |
| 107 |
|
|
|
| 108 |
|
|
RealType k = pow(2.0, -4.0/3.0) * dropletRadius_; |
| 109 |
|
|
|
| 110 |
|
|
RealType z2 = dz*dz; |
| 111 |
|
|
RealType z3 = z2 * dz; |
| 112 |
|
|
RealType k2 = k*k; |
| 113 |
|
|
RealType k3 = k2*k; |
| 114 |
|
|
|
| 115 |
|
|
Polynomial<RealType> poly; |
| 116 |
|
|
poly.setCoefficient(4, z3 + k3); |
| 117 |
|
|
poly.setCoefficient(3, 8.0*z3 + 8.0*k3); |
| 118 |
|
|
poly.setCoefficient(2, 24.0*z3 + 18.0*k3); |
| 119 |
|
|
poly.setCoefficient(1, 32.0*z3 ); |
| 120 |
|
|
poly.setCoefficient(0, 16.0*z3 - 27.0*k3); |
| 121 |
|
|
vector<RealType> realRoots = poly.FindRealRoots(); |
| 122 |
|
|
|
| 123 |
|
|
RealType ct; |
| 124 |
|
|
|
| 125 |
|
|
vector<RealType>::iterator ri; |
| 126 |
gezelter |
2030 |
|
| 127 |
|
|
|
| 128 |
|
|
RealType maxct = -1.0; |
| 129 |
gezelter |
2029 |
for (ri = realRoots.begin(); ri !=realRoots.end(); ++ri) { |
| 130 |
|
|
ct = *ri; |
| 131 |
|
|
if (ct > 1.0) ct = 1.0; |
| 132 |
|
|
if (ct < -1.0) ct = -1.0; |
| 133 |
gezelter |
2030 |
|
| 134 |
|
|
// use the largest magnitude of ct that it finds: |
| 135 |
|
|
if (ct > maxct) { |
| 136 |
|
|
maxct = ct; |
| 137 |
|
|
} |
| 138 |
gezelter |
2029 |
} |
| 139 |
|
|
|
| 140 |
gezelter |
2030 |
values_.push_back( acos(maxct)*(180.0/M_PI) ); |
| 141 |
gezelter |
2029 |
} |
| 142 |
|
|
} |
| 143 |
|
|
} |
| 144 |
|
|
|
| 145 |
|
|
|