source: ThirdParty/mpqc_open/bin/parsenwbas.pl@ d192142

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open 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 d192142 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

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

  • Property mode set to 100755
File size: 8.2 KB
Line 
1#!/usr/bin/perl
2
3$basisname = $ARGV[0];
4$basisname =~ s/.nw$//;
5
6$name{"H"}="hydrogen";
7$name{"He"}="helium";
8$name{"Li"}="lithium";
9$name{"Be"}="beryllium";
10$name{"B"}="boron";
11$name{"C"}="carbon";
12$name{"N"}="nitrogen";
13$name{"O"}="oxygen";
14$name{"F"}="fluorine";
15$name{"Ne"}="neon";
16$name{"Na"}="sodium";
17$name{"Mg"}="magnesium";
18$name{"Al"}="aluminum";
19$name{"Si"}="silicon";
20$name{"P"}="phosphorus";
21$name{"S"}="sulfur";
22$name{"Cl"}="chlorine";
23$name{"Ar"}="argon";
24$name{"K"}="potassium";
25$name{"Ca"}="calcium";
26$name{"Sc"}="scandium";
27$name{"Ti"}="titanium";
28$name{"V"}="vanadium";
29$name{"Cr"}="chromium";
30$name{"Mn"}="manganese";
31$name{"Fe"}="iron";
32$name{"Co"}="cobalt";
33$name{"Ni"}="nickel";
34$name{"Cu"}="copper";
35$name{"Zn"}="zinc";
36$name{"Ga"}="gallium";
37$name{"Ge"}="germanium";
38$name{"As"}="arsenic";
39$name{"Se"}="selenium";
40$name{"Br"}="bromine";
41$name{"Kr"}="krypton";
42$name{"Rb"}="rubidium";
43$name{"Sr"}="strontium";
44$name{"Y"}="yttrium";
45$name{"Zr"}="zirconium";
46$name{"Nb"}="niobium";
47$name{"Mo"}="molybdenum";
48$name{"Tc"}="technetium";
49$name{"Ru"}="ruthenium";
50$name{"Rh"}="rhodium";
51$name{"Pd"}="palladium";
52$name{"Ag"}="silver";
53$name{"Cd"}="cadminium";
54$name{"In"}="indium";
55$name{"Sn"}="tin";
56$name{"Sb"}="antimony";
57$name{"Te"}="tellurium";
58$name{"I"}="iodine";
59$name{"Xe"}="xenon";
60$name{"Cs"}="cesium";
61$name{"Ba"}="barium";
62$name{"La"}="lanthanium";
63$name{"Ce"}="cerium";
64$name{"Pr"}="praseodymium";
65$name{"Nd"}="neodymium";
66$name{"Pm"}="promethium";
67$name{"Sm"}="samarium";
68$name{"Eu"}="europium";
69$name{"Gd"}="gadolinium";
70$name{"Tb"}="terbium";
71$name{"Dy"}="dysprosium";
72$name{"Ho"}="holmium";
73$name{"Er"}="erbium";
74$name{"Tm"}="thulium";
75$name{"Yb"}="ytterbium";
76$name{"Lu"}="lutetium";
77$name{"Hf"}="hafnium";
78$name{"Ta"}="tantalum";
79$name{"W"}="tungsten";
80$name{"Re"}="rhenium";
81$name{"Os"}="osmium";
82$name{"Ir"}="iridium";
83$name{"Pt"}="platinum";
84$name{"Au"}="gold";
85$name{"Hg"}="mercury";
86$name{"Tl"}="thallium";
87$name{"Pb"}="lead";
88$name{"Bi"}="bismuth";
89$name{"Po"}="polonium";
90$name{"At"}="astatine";
91$name{"Rn"}="radon";
92$name{"Fr"}="francium";
93$name{"Ra"}="radium";
94$name{"Ac"}="actinium";
95$name{"Th"}="thorium";
96$name{"Pa"}="protactinium";
97$name{"U"}="uranium";
98$name{"Np"}="neptunium";
99$name{"Pu"}="plutonium";
100$name{"Am"}="americium";
101$name{"Cm"}="curium";
102$name{"Bk"}="berkelium";
103$name{"Cf"}="californium";
104$name{"Es"}="einsteinum";
105$name{"Fm"}="fermium";
106$name{"Md"}="mendelevium";
107$name{"No"}="nobelium";
108$name{"Lr"}="lawrencium";
109
110$atom = none;
111$retrieve = 0;
112$pure = 0;
113$pured = 0; # if $pure or $pured d's are pure
114$puref = 1; # if $pure or $puref f's are pure; by default all f's are pure
115# make sure puream is 1 for correlation consistent and ano basis sets
116# and 6-311g and sto-ng
117if ($basisname =~ /cc-p/ || $basisname =~ /ANO/
118 || $basisname =~ /^6-311G/
119 || $basisname =~ /^6-311\+/
120 || $basisname =~ /^STO-[1-9]G/
121 ) {
122 $pure = 1;
123}
124$basisname =~ tr/A-Z/a-z/;
125$basisname =~ tr/+/P/;
126$basisname =~ tr/\*/S/;
127$basisname =~ tr/\(/L/;
128$basisname =~ tr/\)/R/;
129$basisname =~ tr/,/_/;
130$basisname =~ tr/ /_/;
131printf "Reading NWChem basis from %s.nw\n", $basisname;
132printf "Writing MPQC basis to %s.kv\n", $basisname;
133open(NWCHEMBASIS, "<$basisname.nw");
134open(MPQCBASIS, ">$basisname.kv");
135#open(MPQCBASIS, "|cat");
136$firstatom=1;
137$savedcomments="";
138while (<NWCHEMBASIS>) {
139 # print;
140 # next;
141 GOTLINE:
142 #printf "-----> %s\n", $_;
143 if (/^ *(BASIS.* +[^ ]* +)([A-Z]*)/) {
144 $retrieve = 1;
145 $spherical_option = $2;
146 $basis = $1;
147 $line = "$1$2";
148 $basis =~ s/^[^\"]*\"//; #"
149 $basis =~ s/\"[^\"]*$//; #"
150 printf "Basis = %s\n", $basis;
151 if ($spherical_option eq "SPHERICAL") {
152 $pure = 1;
153 }
154 #printf "%s\n", $line;
155 printf MPQCBASIS "%%%s\n", $line;
156 }
157 elsif (/^ *END/) {
158 $retrieve = 0;
159 }
160 elsif (/^ *\#(.*)/) {
161 my $comment = $1;
162 $comment =~ s/ *$//;
163 $savedcomments = sprintf("%s%%%s\n", $savedcomments, $comment);
164 }
165 elsif ($retrieve == 1) {
166 /^(.*)/;
167 $_ = $1;
168 #printf "%s\n", $_;
169 if (/^ *([A-Z][a-z]*) +([A-Za-z]+)/) {
170 if (!($1 eq $atom)) {
171 if ($atom eq none) {
172 $atom = $1;
173 my $am = $2;
174 print "first shell: atom = $atom am = $am\n";
175 &start_atom;
176 &start_shell($am);
177 }
178 else {
179 &finish_shell;
180 &finish_atom;
181 $atom = $1;
182 my $am = $2;
183 print "new atom: atom = $atom am = $am\n";
184 &start_atom;
185 &start_shell($am);
186 }
187 }
188 else {
189 &finish_shell;
190 my $am = $2;
191 print "new shell on old atom: atom = $atom am = $am\n";
192 &start_shell($am);
193 }
194 goto GOTLINE;
195 }
196 else {
197 $exp_coef_lines[$#exp_coef_lines+1] = $1;
198 }
199 }
200}
201if (!($atom eq none)) {
202 &finish_shell;
203 &finish_atom;
204}
205printf MPQCBASIS "%s", $savedcomments;
206$savedcomments = "";
207printf MPQCBASIS ")\n";
208close(MPQCBASIS);
209close(NWCHEMBASIS);
210
211
212sub start_atom {
213 if ($firstatom) {
214 print MPQCBASIS "basis:(\n";
215 $firstatom=0;
216 }
217 printf MPQCBASIS "%s", $savedcomments;
218 $savedcomments = "";
219 printf MPQCBASIS " %s: \"%s\": [\n", $name{$atom}, $basis;
220}
221
222sub finish_atom {
223 printf MPQCBASIS " ]\n";
224}
225
226sub start_shell {
227 my $am = shift;
228
229 printf MPQCBASIS "%s", $savedcomments;
230 $savedcomments = "";
231 while (<NWCHEMBASIS>) {
232 last;
233 }
234 @coefandexp = split;
235 $ncoef = $#coefandexp;
236 my $amlower = $am;
237 $amlower =~ tr/A-Z/a-z/;
238 printf MPQCBASIS " (type:";
239 if ($amlower eq "sp") {
240 printf MPQCBASIS " [am = p am = s]\n";
241 }
242 else {
243 printf MPQCBASIS " [", $amlower;
244 $icoef = 0;
245 while ($icoef < $ncoef) {
246 if ($icoef != 0) {
247 printf MPQCBASIS " ";
248 }
249 if ((($amlower eq "d") && $pured) || (($amlower eq "f") && $puref)) {
250 printf MPQCBASIS "(am = %s puream = 1)", $amlower;
251 }
252 elsif ($amlower eq "s" || $amlower eq "p" || !$pure) {
253 printf MPQCBASIS "am = %s", $amlower;
254 }
255 else {
256 printf MPQCBASIS "(am = %s puream = 1)", $amlower;
257 }
258 $icoef++;
259 }
260 printf MPQCBASIS "]\n", $amlower;
261 }
262 printf MPQCBASIS " {exp";
263 if ($amlower eq "sp") {
264 printf MPQCBASIS " coef:1 coef:0";
265 }
266 else {
267 $icoef = 0;
268 while ($icoef < $ncoef) {
269 printf MPQCBASIS " coef:%d", $icoef;
270 $icoef++;
271 }
272 }
273 printf MPQCBASIS "} = {\n";
274}
275
276# This does the formatting of the exponent/coefficient lines in a way to
277# make the lines the same as the original format, if possible. This has
278# the advantage making easier to examine diffs of the basis sets to check
279# for problems.
280sub print_lines_1 {
281 my $i;
282
283 foreach $i (0..$#exp_coef_lines) {
284 $exp_coef_lines[$i] =~ s/^ +//;
285 $exp_coef_lines[$i] =~ s/ +$//;
286 }
287
288 my $remove_last_digit_from_exponent = 1;
289 foreach $i (0..$#exp_coef_lines) {
290 my $line = $exp_coef_lines[$i];
291 @fields = split(/ +/,$line);
292 my $exponent = $fields[0];
293 if (!($exponent =~ /0$/)) {
294 $remove_last_digit_from_exponent = 0;
295 }
296 if (&nright($exponent) == 8) {
297 $remove_last_digit_from_exponent = 0;
298 }
299 }
300
301 foreach $i (0..$#exp_coef_lines) {
302 my $line = $exp_coef_lines[$i];
303 @fields = split(/ +/,$line);
304 my $exponent = $fields[0];
305 if ($remove_last_digit_from_exponent == 1) {
306 $exponent =~ s/0$//;
307 }
308 printf MPQCBASIS " %s%s", &space(5,$exponent), $exponent;
309 foreach $i (1..$#fields) {
310 my $coef = $fields[$i];
311 if (!($coef =~ /^-/)) {
312 $coef = " $coef";
313 }
314 printf MPQCBASIS " %s%s", &space(5,$coef), $coef;
315 }
316 print MPQCBASIS "\n";
317 }
318}
319
320# This is a very simple printout of the lines.
321sub print_lines_2 {
322 my $i;
323 foreach $i (0..$#exp_coef_lines) {
324 printf MPQCBASIS "%s\n", $exp_coef_lines[$i];
325 }
326}
327
328sub finish_shell {
329 &print_lines_2();
330
331 $#exp_coef_lines = -1;
332 printf MPQCBASIS " })\n";
333}
334
335sub space {
336 my $n = shift;
337 my $f = shift;
338
339 my $left_digits = $f;
340 $left_digits =~ s/\..*//;
341 my $nleft = length($left_digits);
342
343 my $nspace = $n - $nleft;
344
345 my $i;
346 my $res = "";
347 foreach $i (0..$nspace-1) {
348 $res = " $res";
349 }
350
351 return $res;
352}
353
354sub nright {
355 my $f = shift;
356
357 my $right_digits = $f;
358 $right_digits =~ s/.*\.//;
359 return length($right_digits);
360}
Note: See TracBrowser for help on using the repository browser.