OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
SelectionToken.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef SELECTION_TOKEN_HPP
49#define SELECTION_TOKEN_HPP
50
51#include <any>
52
53namespace OpenMD {
54
55 /**
56 * @class Token
57 * @todo document
58 * @note translate from jmol
59 */
60 class Token {
61 public:
62 int tok {unknown};
63 int intValue {};
64 std::any value {};
65
66 Token() = default;
67 explicit Token(int myTok) : tok {myTok} {}
68 Token(int myTok, int myIntValue) : tok {myTok}, intValue {myIntValue} {}
69 Token(int myTok, const std::any& myValue) : tok {myTok}, value {myValue} {}
70 Token(int MyTok, int myIntValue, const std::any& myValue) :
71 tok {MyTok}, intValue {myIntValue}, value {myValue} {}
72
73 static constexpr int nada = 0;
74 static constexpr int identifier = 1;
75 static constexpr int integer = 2;
76 static constexpr int decimal = 3;
77 static constexpr int string = 4;
78 static constexpr int unknown = 5;
79 static constexpr int keyword = 6;
80 static constexpr int whitespace = 7;
81 static constexpr int comment = 8;
82 static constexpr int endofline = 9;
83 static constexpr int endofstatement = 10;
84
85 static constexpr int command = (1 << 8);
86 static constexpr int expressionCommand = (1 << 9); // expression command
87 static constexpr int expression = (1 << 10); /// expression term
88
89 // generally, the minus sign is used to denote atom ranges
90 // this property is used for the few commands which allow negative integers
91 static constexpr int negnums = (1 << 11);
92
93 // expression involves coordinates which will change every frame, such as
94 // withins
95 static constexpr int dynamic = (1 << 12);
96
97 // every property is also valid in an expression context
98 static constexpr int atomproperty = (1 << 12) | expression | negnums;
99 // every predefined is also valid in an expression context
100 static constexpr int comparator = (1 << 13) | expression;
101 static constexpr int predefinedset = (1 << 14) | expression;
102 static constexpr int embeddedExpression = (1 << 15); // embedded expression
103 static constexpr int index = (1 << 16) | expression;
104 // rasmol commands
105 static constexpr int define = command | expressionCommand | 1;
106 static constexpr int select = command | expressionCommand | 2;
107
108 // predefine
109 // static constexpr int selected = predefinedset |0;
110
111 // atom expression operators
112 static constexpr int leftparen = expression | 0;
113 static constexpr int rightparen = expression | 1;
114 static constexpr int to = expression | 2;
115 static constexpr int opAnd = expression | 3;
116 static constexpr int opOr = expression | 4;
117 static constexpr int opNot = expression | 5;
118 static constexpr int within = expression | dynamic | 6;
119 static constexpr int asterisk = expression | 7;
120 static constexpr int dot = expression | 8;
121 static constexpr int all = expression | 9;
122 static constexpr int none = expression | 10;
123 static constexpr int name = expression | 11;
124 static constexpr int hull = expression | dynamic | 12;
125 static constexpr int alphahull = expression | dynamic | 13;
126
127 // miguel 2005 01 01
128 // these are used to demark the beginning and end of expressions
129 // they do not exist in the source code, but are emitted by the
130 // expression compiler
131 static constexpr int expressionBegin = expression | 100;
132 static constexpr int expressionEnd = expression | 101;
133
134 static constexpr int mass = atomproperty | 0;
135 static constexpr int charge = atomproperty | dynamic | 1;
136 static constexpr int x = atomproperty | dynamic | 2;
137 static constexpr int y = atomproperty | dynamic | 3;
138 static constexpr int z = atomproperty | dynamic | 4;
139 static constexpr int r = atomproperty | dynamic | 5;
140 static constexpr int wrappedX = atomproperty | dynamic | 6;
141 static constexpr int wrappedY = atomproperty | dynamic | 7;
142 static constexpr int wrappedZ = atomproperty | dynamic | 8;
143 static constexpr int atomno = atomproperty | 9;
144
145 static constexpr int opGT = comparator | dynamic | 0;
146 static constexpr int opGE = comparator | dynamic | 1;
147 static constexpr int opLE = comparator | dynamic | 2;
148 static constexpr int opLT = comparator | dynamic | 3;
149 static constexpr int opEQ = comparator | dynamic | 4;
150 static constexpr int opNE = comparator | dynamic | 5;
151
152 static Token tokenExpressionBegin;
153 static Token tokenExpressionEnd;
154 };
155} // namespace OpenMD
156
157#endif
static constexpr int negnums
expression term
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.