View Javadoc
1   // ******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2024.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
36  //
37  // ******************************************************************************
38  package ffx.crystal;
39  
40  /**
41   * Enumeration of the different Laue systems. Some are only used for nonstandard cells.
42   *
43   * @author Michael J. Schnieders
44   * @since 1.0
45   */
46  public enum LaueSystem {
47    L111, L112, L121, L211, L21U, L21V, L21W, L21X, L21Y, L21Z, L222, L22U, L22V, L22W, L114, L141,
48    L411, L224, L242, L422, L113, L131, L311, L11T, L1T1, LT11, L31A, L31B, L31C, L31D, L223, L232,
49    L322, L32A, L32B, L32C, L32D, L32U, L32V, L32W, L32X, L32Y, L32Z, LM3B, LM3M;
50  
51    /**
52     * Check the given HKL is valid given the Laue system.
53     *
54     * @param h an int.
55     * @param k an int.
56     * @param l an int.
57     * @return True if the reflection is valid, false otherwise.
58     */
59    public boolean checkRestrictions(int h, int k, int l) {
60      switch (this) {
61        case L111 -> {
62          return (l > 0 || (l == 0 && (h > 0 || (h == 0 && k >= 0))));
63        }
64        case L112 -> {
65          return (l >= 0 && (h > 0 || (h == 0 && k >= 0)));
66        }
67        case L121 -> {
68          return (k >= 0 && (l > 0 || (l == 0 && h >= 0)));
69        }
70        case L211 -> {
71          return (h >= 0 && (k > 0 || (k == 0 && l >= 0)));
72        }
73        case L21U -> {
74          return (h + k >= 0 && (l > 0 || (l == 0 && h - k >= 0)));
75        }
76        case L21V -> {
77          return (l + h >= 0 && (k > 0 || (k == 0 && l - h >= 0)));
78        }
79        case L21W -> {
80          return (k + l >= 0 && (h > 0 || (h == 0 && k - l >= 0)));
81        }
82        case L21X -> {
83          return (h - k >= 0 && (l > 0 || (l == 0 && h + k >= 0)));
84        }
85        case L21Y -> {
86          return (l - h >= 0 && (k > 0 || (k == 0 && l + h >= 0)));
87        }
88        case L21Z -> {
89          return (k - l >= 0 && (h > 0 || (h == 0 && k + l >= 0)));
90        }
91        case L222 -> {
92          return (h >= 0 && k >= 0 && l >= 0);
93        }
94        case L22U -> {
95          return (h <= k && h >= -k && l >= 0);
96        }
97        case L22V -> {
98          return (l <= h && l >= -h && k >= 0);
99        }
100       case L22W -> {
101         return (k <= l && k >= -l && h >= 0);
102       }
103       case L114 -> {
104         return (l >= 0 && ((h >= 0 && k > 0) || (h == 0 && k == 0)));
105       }
106       case L141 -> {
107         return (k >= 0 && ((l >= 0 && h > 0) || (l == 0 && h == 0)));
108       }
109       case L411 -> {
110         return (h >= 0 && ((k >= 0 && l > 0) || (k == 0 && l == 0)));
111       }
112       case L224 -> {
113         return (h >= k && k >= 0 && l >= 0);
114       }
115       case L242 -> {
116         return (l >= h && h >= 0 && k >= 0);
117       }
118       case L422 -> {
119         return (k >= l && l >= 0 && h >= 0);
120       }
121       case L113 -> {
122         return (h >= 0 && k > 0) || (h == 0 && k == 0 && l >= 0);
123       }
124       case L131 -> {
125         return (l >= 0 && h > 0) || (l == 0 && h == 0 && k >= 0);
126       }
127       case L311 -> {
128         return (k >= 0 && l > 0) || (k == 0 && l == 0 && h >= 0);
129       }
130       case L11T -> {
131         return (h <= 0 && k > 0) || (h == 0 && k == 0 && l >= 0);
132       }
133       case L1T1 -> {
134         return (l <= 0 && h > 0) || (l == 0 && h == 0 && k >= 0);
135       }
136       case LT11 -> {
137         return (k <= 0 && l > 0) || (k == 0 && l == 0 && h >= 0);
138       }
139       case L31A -> {
140         return (k - l >= 0 && l - h > 0) || (h == l && k == l && h + k + l >= 0);
141       }
142       case L31B -> {
143         return (k - l >= 0 && l + h > 0) || (-h == l && k == l && -h + k + l >= 0);
144       }
145       case L31C -> {
146         return (-k - l >= 0 && l - h > 0) || (h == l && -k == l && h - k + l >= 0);
147       }
148       case L31D -> {
149         return (k + l >= 0 && -l - h > 0) || (h == -l && k == -l && h + k - l >= 0);
150       }
151       case L223 -> {
152         return (h >= k && k >= 0 && (k > 0 || l >= 0));
153       }
154       case L232 -> {
155         return (l >= h && h >= 0 && (h > 0 || k >= 0));
156       }
157       case L322 -> {
158         return (k >= l && l >= 0 && (l > 0 || h >= 0));
159       }
160       case L32A -> {
161         return (h >= k && k + l >= h + h && (k + l > h + h || h + k + l >= 0));
162       }
163       case L32B -> {
164         return (-h >= k && k + l >= -h - h && (k + l > -h - h || -h + k + l >= 0));
165       }
166       case L32C -> {
167         return (h >= -k && -k + l >= h + h && (-k + l > h + h || h - k + l >= 0));
168       }
169       case L32D -> {
170         return (h >= k && k - l >= h + h && (k - l > h + h || h + k - l >= 0));
171       }
172       case L32U -> {
173         return (h >= k && k >= 0 && (h > k || l >= 0));
174       }
175       case L32V -> {
176         return (k >= l && l >= 0 && (k > l || h >= 0));
177       }
178       case L32W -> {
179         return (l >= h && h >= 0 && (l > h || k >= 0));
180       }
181       case L32X -> {
182         return (-h >= k && k >= 0 && (-h > k || l >= 0));
183       }
184       case L32Y -> {
185         return (-k >= l && l >= 0 && (-k > l || h >= 0));
186       }
187       case L32Z -> {
188         return (-l >= h && h >= 0 && (-l > h || k >= 0));
189       }
190       case LM3B -> {
191         return (h >= 0 && ((l >= h && k > h) || (l == h && k == h)));
192       }
193       case LM3M -> {
194         return (k >= l && l >= h && h >= 0);
195       }
196       default -> {
197         assert (2 != 2);
198         return false;
199       }
200     }
201   }
202 }