source: ThirdParty/mpqc_open/lib/perl/AtomicBases.pm@ 220d2c

Action_Thermostats Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_Verbose_Codepatterns ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps
Last change on this file since 220d2c 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: 8.5 KB
Line 
1#
2eval 'exec perl $0 $*'
3 if 0;
4
5require AtomicBasis;
6
7package AtomicBases;
8
9$symbol_to_name{"H"}="hydrogen";
10$symbol_to_name{"He"}="helium";
11$symbol_to_name{"Li"}="lithium";
12$symbol_to_name{"Be"}="beryllium";
13$symbol_to_name{"B"}="boron";
14$symbol_to_name{"C"}="carbon";
15$symbol_to_name{"N"}="nitrogen";
16$symbol_to_name{"O"}="oxygen";
17$symbol_to_name{"F"}="fluorine";
18$symbol_to_name{"Ne"}="neon";
19$symbol_to_name{"Na"}="sodium";
20$symbol_to_name{"Mg"}="magnesium";
21$symbol_to_name{"Al"}="aluminum";
22$symbol_to_name{"Si"}="silicon";
23$symbol_to_name{"P"}="phosphorus";
24$symbol_to_name{"S"}="sulfur";
25$symbol_to_name{"Cl"}="chlorine";
26$symbol_to_name{"Ar"}="argon";
27$symbol_to_name{"K"}="potassium";
28$symbol_to_name{"Ca"}="calcium";
29$symbol_to_name{"Sc"}="scandium";
30$symbol_to_name{"Ti"}="titanium";
31$symbol_to_name{"V"}="vanadium";
32$symbol_to_name{"Cr"}="chromium";
33$symbol_to_name{"Mn"}="manganese";
34$symbol_to_name{"Fe"}="iron";
35$symbol_to_name{"Co"}="cobalt";
36$symbol_to_name{"Ni"}="nickel";
37$symbol_to_name{"Cu"}="copper";
38$symbol_to_name{"Zn"}="zinc";
39$symbol_to_name{"Ga"}="gallium";
40$symbol_to_name{"Ge"}="germanium";
41$symbol_to_name{"As"}="arsenic";
42$symbol_to_name{"Se"}="selenium";
43$symbol_to_name{"Br"}="bromine";
44$symbol_to_name{"Kr"}="krypton";
45$symbol_to_name{"Rb"}="rubidium";
46$symbol_to_name{"Sr"}="strontium";
47$symbol_to_name{"Y"}="yttrium";
48$symbol_to_name{"Zr"}="zirconium";
49$symbol_to_name{"Nb"}="niobium";
50$symbol_to_name{"Mo"}="molybdenum";
51$symbol_to_name{"Tc"}="technetium";
52$symbol_to_name{"Ru"}="ruthenium";
53$symbol_to_name{"Rh"}="rhodium";
54$symbol_to_name{"Pd"}="palladium";
55$symbol_to_name{"Ag"}="silver";
56$symbol_to_name{"Cd"}="cadminium";
57$symbol_to_name{"In"}="indium";
58$symbol_to_name{"Sn"}="tin";
59$symbol_to_name{"Sb"}="antimony";
60$symbol_to_name{"Te"}="tellurium";
61$symbol_to_name{"I"}="iodine";
62$symbol_to_name{"Xe"}="xenon";
63$symbol_to_name{"Cs"}="cesium";
64$symbol_to_name{"Ba"}="barium";
65$symbol_to_name{"La"}="lanthanium";
66$symbol_to_name{"Ce"}="cerium";
67$symbol_to_name{"Pr"}="praseodymium";
68$symbol_to_name{"Nd"}="neodymium";
69$symbol_to_name{"Pm"}="promethium";
70$symbol_to_name{"Sm"}="samarium";
71$symbol_to_name{"Eu"}="europium";
72$symbol_to_name{"Gd"}="gadolinium";
73$symbol_to_name{"Tb"}="terbium";
74$symbol_to_name{"Dy"}="dysprosium";
75$symbol_to_name{"Ho"}="holmium";
76$symbol_to_name{"Er"}="erbium";
77$symbol_to_name{"Tm"}="thulium";
78$symbol_to_name{"Yb"}="ytterbium";
79$symbol_to_name{"Lu"}="lutetium";
80$symbol_to_name{"Hf"}="hafnium";
81$symbol_to_name{"Ta"}="tantalum";
82$symbol_to_name{"W"}="tungsten";
83$symbol_to_name{"Re"}="rhenium";
84$symbol_to_name{"Os"}="osmium";
85$symbol_to_name{"Ir"}="iridium";
86$symbol_to_name{"Pt"}="platinum";
87$symbol_to_name{"Au"}="gold";
88$symbol_to_name{"Hg"}="mercury";
89$symbol_to_name{"Tl"}="thallium";
90$symbol_to_name{"Pb"}="lead";
91$symbol_to_name{"Bi"}="bismuth";
92$symbol_to_name{"Po"}="polonium";
93$symbol_to_name{"At"}="astatine";
94$symbol_to_name{"Rn"}="radon";
95$symbol_to_name{"Fr"}="francium";
96$symbol_to_name{"Ra"}="radium";
97$symbol_to_name{"Ac"}="actinium";
98$symbol_to_name{"Th"}="thorium";
99$symbol_to_name{"Pa"}="protactinium";
100$symbol_to_name{"U"}="uranium";
101$symbol_to_name{"Np"}="neptunium";
102$symbol_to_name{"Pu"}="plutonium";
103$symbol_to_name{"Am"}="americium";
104$symbol_to_name{"Cm"}="curium";
105$symbol_to_name{"Bk"}="berkelium";
106$symbol_to_name{"Cf"}="californium";
107$symbol_to_name{"Es"}="einsteinum";
108$symbol_to_name{"Fm"}="fermium";
109$symbol_to_name{"Md"}="mendelevium";
110$symbol_to_name{"No"}="nobelium";
111$symbol_to_name{"Lr"}="lawrencium";
112
113@number_to_symbol = ();
114$number_to_symbol[1] = "H";
115$number_to_symbol[2] = "He";
116$number_to_symbol[3] = "Li";
117$number_to_symbol[4] = "Be";
118$number_to_symbol[5] = "B";
119$number_to_symbol[6] = "C";
120$number_to_symbol[7] = "N";
121$number_to_symbol[8] = "O";
122$number_to_symbol[9] = "F";
123$number_to_symbol[10] = "Ne";
124$number_to_symbol[11] = "Na";
125$number_to_symbol[12] = "Mg";
126$number_to_symbol[13] = "Al";
127$number_to_symbol[14] = "Si";
128$number_to_symbol[15] = "P";
129$number_to_symbol[16] = "S";
130$number_to_symbol[17] = "Cl";
131$number_to_symbol[18] = "Ar";
132$number_to_symbol[19] = "K";
133$number_to_symbol[20] = "Ca";
134$number_to_symbol[21] = "Sc";
135$number_to_symbol[22] = "Ti";
136$number_to_symbol[23] = "V";
137$number_to_symbol[24] = "Cr";
138$number_to_symbol[25] = "Mn";
139$number_to_symbol[26] = "Fe";
140$number_to_symbol[27] = "Co";
141$number_to_symbol[28] = "Ni";
142$number_to_symbol[29] = "Cu";
143$number_to_symbol[30] = "Zn";
144$number_to_symbol[31] = "Ga";
145$number_to_symbol[32] = "Ge";
146$number_to_symbol[33] = "As";
147$number_to_symbol[34] = "Se";
148$number_to_symbol[35] = "Br";
149$number_to_symbol[36] = "Kr";
150$number_to_symbol[37] = "Rb";
151$number_to_symbol[38] = "Sr";
152$number_to_symbol[39] = "Y";
153$number_to_symbol[40] = "Zr";
154$number_to_symbol[41] = "Nb";
155$number_to_symbol[42] = "Mo";
156$number_to_symbol[43] = "Tc";
157$number_to_symbol[44] = "Ru";
158$number_to_symbol[45] = "Rh";
159$number_to_symbol[46] = "Pd";
160$number_to_symbol[47] = "Ag";
161$number_to_symbol[48] = "Cd";
162$number_to_symbol[49] = "In";
163$number_to_symbol[50] = "Sn";
164$number_to_symbol[51] = "Sb";
165$number_to_symbol[52] = "Te";
166$number_to_symbol[53] = "I";
167$number_to_symbol[54] = "Xe";
168$number_to_symbol[55] = "Cs";
169$number_to_symbol[56] = "Ba";
170$number_to_symbol[57] = "La";
171$number_to_symbol[58] = "Ce";
172$number_to_symbol[59] = "Pr";
173$number_to_symbol[60] = "Nd";
174$number_to_symbol[61] = "Pm";
175$number_to_symbol[62] = "Sm";
176$number_to_symbol[63] = "Eu";
177$number_to_symbol[64] = "Gd";
178$number_to_symbol[65] = "Tb";
179$number_to_symbol[66] = "Dy";
180$number_to_symbol[67] = "Ho";
181$number_to_symbol[68] = "Er";
182$number_to_symbol[69] = "Tm";
183$number_to_symbol[70] = "Yb";
184$number_to_symbol[71] = "Lu";
185$number_to_symbol[72] = "Hf";
186$number_to_symbol[73] = "Ta";
187$number_to_symbol[74] = "W";
188$number_to_symbol[75] = "Re";
189$number_to_symbol[76] = "Os";
190$number_to_symbol[77] = "Ir";
191$number_to_symbol[78] = "Pt";
192$number_to_symbol[79] = "Au";
193$number_to_symbol[80] = "Hg";
194$number_to_symbol[81] = "Tl";
195$number_to_symbol[82] = "Pb";
196$number_to_symbol[83] = "Bi";
197$number_to_symbol[84] = "Po";
198$number_to_symbol[85] = "At";
199$number_to_symbol[86] = "Rn";
200$number_to_symbol[87] = "Fr";
201$number_to_symbol[88] = "Ra";
202$number_to_symbol[89] = "Ac";
203$number_to_symbol[90] = "Th";
204$number_to_symbol[91] = "Pa";
205$number_to_symbol[92] = "U";
206$number_to_symbol[93] = "Np";
207$number_to_symbol[94] = "Pu";
208$number_to_symbol[95] = "Am";
209$number_to_symbol[96] = "Cm";
210$number_to_symbol[97] = "Bk";
211$number_to_symbol[98] = "Cf";
212$number_to_symbol[99] = "Es";
213$number_to_symbol[100] = "Fm";
214$number_to_symbol[101] = "Md";
215$number_to_symbol[102] = "No";
216$number_to_symbol[103] = "Lr";
217$number_to_symbol[104] = "Rf";
218$number_to_symbol[105] = "Ha";
219
220%symbol_to_number = {};
221foreach my $i (1..105) {
222 $symbol_to_number{$number_to_symbol[$i]} = $i;
223}
224
225sub new {
226 my $this = shift;
227 my $class = ref($this) || $this;
228 my $self = {};
229 bless $self, $class;
230 $self->initialize(@_);
231 return $self;
232}
233
234sub initialize {
235 my $self = shift;
236
237 $self->{"name"} = "";
238 $self->{"atoms"} = {};
239 $self->{"comment"} = {};
240}
241
242sub name {
243 my $self = shift;
244 return $self->{"name"};
245}
246
247sub set_name {
248 my $self = shift;
249 my $name = shift;
250 $self->{"name"} = $name;
251}
252
253sub read_gaussian_file {
254 my $self = shift;
255 my $filename = shift;
256 open(FILE,"<$filename");
257 $self->read_gaussian(*FILE);
258 close(FILE);
259}
260
261
262sub read_gaussian {
263 my $self = shift;
264 my $file = shift;
265 while (<$file>) {
266 if (/([A-Za-z]+)/) {
267 my $sym = canonical_symbol($1);
268 if (!exists($symbol_to_name{$sym})) {
269 die "bad atomic symbol \"$sym\"";
270 }
271 $self->{"atoms"}->{$sym} = new AtomicBasis();
272 $self->{"atoms"}->{$sym}->read_gaussian($file);
273 }
274 }
275}
276
277sub atoms {
278 my $self = shift;
279 return keys(%{$self->{"atoms"}});
280}
281
282sub comment {
283 my $self = shift;
284 return $self->{"comment"};
285}
286
287sub atom {
288 my $self = shift;
289 my $sym = canonical_symbol(shift);
290 return $self->{"atoms"}->{$sym};
291}
292
293sub canonical_symbol {
294 my $sym = shift;
295 return uc(substr($sym,0,1)) . lc(substr($sym,1,length($sym)));
296}
297
298sub write_keyval_file {
299 my $self = shift;
300 my $filename = shift;
301 open(FILE,">$filename");
302 $self->write_keyval(*FILE);
303 close(FILE);
304};
305
306sub write_keyval {
307 my $self = shift;
308 my $file = shift;
309 my @atoms = $self->atoms();
310 print $file "basis: (\n";
311 foreach my $atom (sort { $symbol_to_number{$a} <=> $symbol_to_number{$b} }
312 @atoms) {
313 printf $file " %s: \"%s\": [\n", $symbol_to_name{$atom}, $self->name();
314 $self->atom($atom)->write_keyval($file);
315 print $file " ]\n";
316 }
317 print $file ")\n";
318}
319
3201;
Note: See TracBrowser for help on using the repository browser.