source: ThirdParty/mpqc_open/src/lib/math/symmetry/pointgrp.cc@ b7e5b0

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since b7e5b0 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 6.1 KB
Line 
1//
2// pointgrp.cc
3//
4// Modifications are
5// Copyright (C) 1996 Limit Point Systems, Inc.
6//
7// Author: Edward Seidl <seidl@janed.com>
8// Maintainer: LPS
9//
10// This file is part of the SC Toolkit.
11//
12// The SC Toolkit is free software; you can redistribute it and/or modify
13// it under the terms of the GNU Library General Public License as published by
14// the Free Software Foundation; either version 2, or (at your option)
15// any later version.
16//
17// The SC Toolkit is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Library General Public License for more details.
21//
22// You should have received a copy of the GNU Library General Public License
23// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
24// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25//
26// The U.S. Government is granted a limited license as per AL 91-7.
27//
28
29/* pointgrp.cc -- implementation of the point group classes
30 *
31 * THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
32 * "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
33 * AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
34 * CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
35 * PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
36 * RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
37 *
38 * Author:
39 * E. T. Seidl
40 * Bldg. 12A, Rm. 2033
41 * Computer Systems Laboratory
42 * Division of Computer Research and Technology
43 * National Institutes of Health
44 * Bethesda, Maryland 20892
45 * Internet: seidl@alw.nih.gov
46 * June, 1993
47 */
48
49#ifdef __GNUC__
50#pragma implementation
51#endif
52
53#include <stdlib.h>
54#include <string.h>
55#include <ctype.h>
56#include <math.h>
57
58#include <util/misc/formio.h>
59#include <util/state/stateio.h>
60#include <math/symmetry/pointgrp.h>
61
62using namespace std;
63using namespace sc;
64
65////////////////////////////////////////////////////////////////////////
66
67static ClassDesc PointGroup_cd(
68 typeid(PointGroup),"PointGroup",2,"public SavableState",
69 create<PointGroup>, create<PointGroup>, create<PointGroup>);
70
71PointGroup::PointGroup()
72 : symb(0)
73{
74 set_symbol("c1");
75 frame(0,0) = frame(1,1) = frame(2,2) = 1;
76 origin_[0] = origin_[1] = origin_[2] =0;
77}
78
79PointGroup::PointGroup(const char *s)
80 : symb(0)
81{
82 set_symbol(s);
83 frame(0,0) = frame(1,1) = frame(2,2) = 1;
84 origin_[0] = origin_[1] = origin_[2] =0;
85}
86
87PointGroup::PointGroup(const char *s, SymmetryOperation& so)
88 : symb(0)
89{
90 set_symbol(s);
91 frame = so;
92 origin_[0] = origin_[1] = origin_[2] =0;
93}
94
95PointGroup::PointGroup(const char *s, SymmetryOperation& so,
96 const SCVector3& origin)
97 : symb(0)
98{
99 set_symbol(s);
100 frame = so;
101 origin_ = origin;
102}
103
104PointGroup::PointGroup(const Ref<KeyVal>& kv)
105 : symb(0)
106{
107 if (kv->exists("symmetry")) {
108 char *tmp = kv->pcharvalue("symmetry");
109 set_symbol(tmp);
110 delete[] tmp;
111 }
112 else
113 set_symbol("c1");
114
115 if (kv->exists("symmetry_frame")) {
116 for (int i=0; i < 3; i++)
117 for (int j=0; j < 3; j++)
118 frame(i,j) = kv->doublevalue("symmetry_frame",i,j);
119 } else {
120 frame(0,0) = frame(1,1) = frame(2,2) = 1;
121 }
122
123 if (kv->exists("origin")) {
124 for (int i=0; i < 3; i++)
125 origin_[i] = kv->doublevalue("origin",i);
126 } else {
127 origin_[0] = origin_[1] = origin_[2] =0;
128 }
129}
130
131PointGroup::PointGroup(StateIn& si) :
132 SavableState(si),
133 symb(0)
134{
135 int i;
136 if (si.version(::class_desc<PointGroup>()) < 2) {
137 ExEnv::errn() << "PointGroup: checkpoint file is too old: cannot read"
138 << endl;
139 abort();
140 }
141 else {
142 for (i=0; i<3; i++) si.get(origin_[i]);
143 }
144
145 si.getstring(symb);
146 for (i=0; i < 3; i++)
147 for (int j=0; j < 3; j++)
148 si.get(frame(i,j));
149}
150
151PointGroup::PointGroup(const PointGroup& pg)
152 : symb(0)
153{
154 *this = pg;
155}
156
157PointGroup::PointGroup(const Ref<PointGroup>& pg)
158 : symb(0)
159{
160 *this = *pg.pointer();
161}
162
163PointGroup::~PointGroup()
164{
165 if (symb) { delete[] symb; symb=0; }
166}
167
168PointGroup&
169PointGroup::operator=(const PointGroup& pg)
170{
171 set_symbol(pg.symb);
172 frame = pg.frame;
173 origin_ = pg.origin_;
174 return *this;
175}
176
177void
178PointGroup::set_symbol(const char *sym)
179{
180 if (sym) {
181 if (symb) delete[] symb;
182 int len;
183 symb = new char[(len=strlen(sym))+1];
184 for (int i=0; i<len; i++) symb[i] = (char) tolower(sym[i]);
185 symb[len] = '\0';
186 } else {
187 set_symbol("c1");
188 }
189}
190
191void
192PointGroup::save_data_state(StateOut& so)
193{
194 int i;
195 for (i=0; i<3; i++) so.put(origin_[i]);
196
197 so.putstring(symb);
198
199 for (i=0; i < 3; i++)
200 for (int j=0; j < 3; j++)
201 so.put(frame(i,j));
202}
203
204CharacterTable
205PointGroup::char_table() const
206{
207 CharacterTable ret(symb,frame);
208 return ret;
209}
210
211int
212PointGroup::equiv(const Ref<PointGroup> &grp, double tol) const
213{
214 if (strcmp(symb,grp->symb)) return 0;
215
216 for (int i=0; i < 3; i++) {
217 // origin isn't realy used, so don't check
218 //if (fabs(origin_[i] - grp->origin_[i]) > tol) return 0;
219 for (int j=0; j < 3; j++) {
220 if (fabs(frame(i,j) - grp->frame(i,j)) > tol) return 0;
221 }
222 }
223
224 return 1;
225}
226
227void
228PointGroup::print(ostream &o) const
229{
230 int i,j;
231
232 o << indent << "symmetry = " << symb << endl;
233
234 int unit_frame = 1;
235 int zero_origin = 1;
236 for (i=0; i<3; i++) {
237 for (j=0; j<3; j++) {
238 if (i==j && fabs(frame(i,j)-1.0) > 1.0e-10) unit_frame = 0;
239 else if (i != j && fabs(frame(i,j)) > 1.0e-10) unit_frame = 0;
240 }
241 if (fabs(origin_[i]) > 1.0e-10) zero_origin = 0;
242 }
243
244 if (!unit_frame) {
245 o << indent << "symmetry_frame = [";
246 o << incindent;
247 for (i=0; i<3; i++) {
248 o << endl << indent;
249 o << "[";
250 for (j=0; j<3; j++) {
251 o << scprintf(" % 18.16f", frame(i,j));
252 }
253 o << "]";
254 }
255 o << "]" << endl;
256 o << decindent;
257 }
258
259 if (!zero_origin) {
260 o << indent << "origin = [";
261 for (i=0; i<3; i++) {
262 o << scprintf(" % 18.16f", origin_[i]);
263 }
264 o << "]" << endl;
265 }
266}
267
268/////////////////////////////////////////////////////////////////////////////
269
270// Local Variables:
271// mode: c++
272// c-file-style: "ETS"
273// End:
Note: See TracBrowser for help on using the repository browser.