3
# Some general functions useful for parsing PSI3 output files.
8
# 1) environment must define variable $SRCDIR which points to the source directory where
9
# the input and reference output files are located
10
# 2) variable $EXECDIR can be used to specify location of Psi3 executables relative to the directory
11
# where testing is performed
19
if ($SRC_PATH eq "") {
23
$PSITEST_EXEC_PATH = "../../bin";
26
$PSITEST_EXEC_PATH = $EXECDIR;
28
$PSITEST_DEFAULT_INPUT = "input.dat";
29
$PSITEST_DEFAULT_PREFIX = "psi";
30
if ($PSITEST_INPUT eq "") {
31
$PSITEST_INPUT = $PSITEST_DEFAULT_INPUT;
33
if ($PSITEST_PREFIX eq "") {
34
$PSITEST_PREFIX = $PSITEST_DEFAULT_PREFIX;
36
$PSITEST_TARGET_SUFFIX = "test";
37
$PSITEST_TEST_SCRIPT = "runtest.pl";
39
# These are definitions that default tester knows about -- should match Psi driver!
40
@PSITEST_JOBTYPES = ("SP", "OPT", "DISP", "FREQ", "SYMM_FREQ", "OEPROP", "DBOC");
41
@PSITEST_WFNS = ("SCF", "MP2", "MP2R12", "DETCI", "DETCAS", "BCCD", "BCCD_T", "CCSD", "CCSD_T",
42
"EOM_CCSD", "LEOM_CCSD", "OOCCD", "CIS");
43
@PSITEST_REFTYPES = ("RHF", "ROHF", "UHF", "TWOCON");
44
@PSITEST_DERTYPES = ("NONE", "FIRST", "SECOND", "RESPONSE");
46
$PSITEST_DEFAULT_NSTAB = 5; # number of eigenvalues STABLE prints out
48
$PSITEST_ETOL = 10**-8; # Default test criterion for energies
49
$PSITEST_ENUCTOL = 10**-13; # Check nuclear repulsion energy tighter than other energies
50
$PSITEST_EEOMTOL = 10**-5; # Less stringent test for EOM-CC energies
51
$PSITEST_GEOMTOL = 10**-6; # Default test criterion for Cartesian geometries
52
$PSITEST_GTOL = 10**-6; # Default test criterion for gradients
53
$PSITEST_HTOL = 10**-2; # Default test criterion for Hessians
54
$PSITEST_POLARTOL = 10**-4; # Default test criterion for polarizabilities
55
$PSITEST_STABTOL = 10**-4; # Default test criterion for Hessian eigenvalues
56
$PSITEST_MPOPTOL = 10**-5; # Default test criterion for Mulliken populations
58
##################################################################
60
# This is a "smart" tester -- it parses the input and figures out
61
# what kinds of tests to run
63
##################################################################
68
($interrupted) = run_psi_command(@_);
70
# Figure out what calculation has been run -- run "psi3 -c" and get the calculation type string
77
($calctype, $wfn, $ref, $jobtype, $dertype, $direct) = get_calctype_string();
81
foreach $item (@PSITEST_JOBTYPES) {
82
if ($item eq $jobtype) {$ok = 1;}
85
fail_test("Default Psi tester do_tests does not recognize jobtype $jobtype");
86
test_finished(1,$interrupted);
90
foreach $item (@PSITEST_DERTYPES) {
91
if ($item eq $dertype) {$ok = 1;}
94
fail_test("Default Psi tester do_tests does not recognize dertype $dertype");
95
test_finished(1,$interrupted);
99
foreach $item (@PSITEST_WFNS) {
100
if ($item eq $wfn) {$ok = 1;}
103
fail_test("Default Psi tester do_tests does not recognize wfn $wfn");
104
test_finished(1,$interrupted);
108
foreach $item (@PSITEST_REFTYPES) {
109
if ($item eq $ref) {$ok = 1;}
112
fail_test("Default Psi tester do_tests does not recognize reference $ref");
113
test_finished(1,$interrupted);
121
if ($jobtype eq "OPT") {
123
if ($dertype eq "NONE" || $dertype eq "FIRST") {
124
$fail |= compare_energy_file11($wfn);
125
$fail |= compare_geom_file11($wfn);
126
$fail |= compare_grad_file11($wfn);
132
# I'll lump all single-point computations together
133
if ( $jobtype eq "SP" || $jobtype eq "FREQ" || $jobtype eq "SYMM_FREQ" || $jobtype eq "OEPROP" ||
134
$jobtype eq "DBOC" || $jobtype eq "RESPONSE" ) {
136
$fail |= compare_nuc();
137
# All computations in Psi3 start with an SCF run
138
$fail |= compare_scf_energy();
142
if ($wfn eq "CCSD") { $fail |= compare_ccsd_energy(); last SWITCH2; }
143
if ($wfn eq "CCSD_T") { $fail |= compare_ccsd_t_energy(); last SWITCH2; }
144
if ($wfn eq "EOM_CCSD") { $fail |= compare_eomccsd_energy(); last SWITCH2; }
145
if ($wfn eq "BCCD") { $fail |= compare_bccd_energy(); last SWITCH2; }
146
if ($wfn eq "BCCD_T") { $fail |= compare_bccd_t_energy(); last SWITCH2; }
147
if ($wfn eq "CASSCF") { $fail |= compare_casscf_energy(); last SWITCH2; }
148
if ($wfn eq "DETCI") { $fail |= compare_ci_energy(); last SWITCH2; }
149
if ($wfn eq "CIS") { $fail |= compare_cis_energy(); last SWITCH2; }
150
if ($wfn eq "MP2" && $direct == 1)
151
{ $fail |= compare_direct_mp2_energy(); last SWITCH2; }
152
if ($wfn eq "MP2" && $direct == 0)
153
{ $fail |= compare_mp2_energy(); last SWITCH2; }
154
if ($wfn eq "MP2R12") { $fail |= compare_mp2r12_energy(); last SWITCH2; }
158
if ($jobtype eq "SP" && $dertype eq "FIRST") {
159
$fail |= compare_energy_file11($wfn);
160
$fail |= compare_geom_file11($wfn);
161
$fail |= compare_grad_file11($wfn);
164
if ( ($jobtype eq "FREQ" || $dertype eq "SP") && $dertype eq "SECOND") {
165
$fail |= compare_harm_freq($wfn);
166
$fail |= compare_harm_intensities($wfn);
169
if ($jobtype eq "FREQ" && $dertype eq "FIRST") {
170
$fail |= compare_findif_freq($wfn);
173
if ($jobtype eq "SYMM_FREQ" && $dertype eq "FIRST") {
174
$fail |= compare_findif_symm_freq($wfn);
176
if ($jobtype eq "DBOC") {
177
$fail |= compare_dboc()
180
if ($jobtype eq "OEPROP") {
181
$fail |= compare_mulliken_orb_pops();
182
$fail |= compare_mulliken_ab_pops();
183
$fail |= compare_mulliken_ga_pops();
184
$fail |= compare_electric_dipole();
185
$fail |= compare_elec_angmom();
186
$fail |= compare_epef();
187
$fail |= compare_edens();
188
$fail |= compare_mvd();
191
if ($jobtype eq "SP" && $dertype eq "RESPONSE") {
193
$fail |= compare_cclambda_overlap($wfn);
194
$fail |= compare_ccsd_polar($wfn);
197
$fail |= compare_scf_polar();
206
test_finished($fail,$interrupted);
209
##################################################################
211
# Following are utility functions
213
##################################################################
216
printf "USAGE: $_[0] [options]\n";
217
printf " where options are:\n";
219
printf " -c do cleanup instead of testing\n";
220
printf " -u exit cleanly even if execution fails\n";
221
printf " -q run quietly, print out only the summary at the end\n";
226
$test_name = get_test_name();
227
$target = "$test_name.$PSITEST_TARGET_SUFFIX";
228
open(RE, ">$target") || die "cannot open $target $!";
235
$test_name = get_test_name();
236
$target = "$test_name.$PSITEST_TARGET_SUFFIX";
237
open(RE, ">>$target") || die "cannot open $target $!";
238
printf RE "%-70s...PASSED\n", $_[0];
244
$test_name = get_test_name();
245
$target = "$test_name.$PSITEST_TARGET_SUFFIX";
246
open(RE, ">>$target") || die "cannot open $target $!";
247
printf RE "%-70s...FAILED\n", $_[0];
251
sub print_test_header
253
$test_name = get_test_name();
254
$target = "$test_name.$PSITEST_TARGET_SUFFIX";
255
open(RE, ">>$target") || die "cannot open $target $!";
256
printf RE "$test_name:\n";
263
my $interrupted = $_[1];
265
$test_name = get_test_name();
266
$target = "$test_name.$PSITEST_TARGET_SUFFIX";
268
system("cat $target");
282
my $test_name = basename("$SRC_PATH");
283
if ($test_name eq ".") {
285
$test_name = basename($pwd);
294
my $REF_FILE = "$SRC_PATH/output.ref";
295
my $TEST_FILE = "output.dat";
297
if(abs(seek_nuc($REF_FILE) - seek_nuc($TEST_FILE)) > $PSITEST_ENUCTOL) {
298
fail_test("Nuclear repulsion energy"); $fail = 1;
301
pass_test("Nuclear repulsion energy");
307
sub compare_scf_energy
310
my $REF_FILE = "$SRC_PATH/output.ref";
311
my $TEST_FILE = "output.dat";
313
if(abs(seek_scf($REF_FILE) - seek_scf($TEST_FILE)) > $PSITEST_ETOL) {
314
fail_test("SCF energy"); $fail = 1;
317
pass_test("SCF energy");
323
sub compare_ccsd_energy
326
my $REF_FILE = "$SRC_PATH/output.ref";
327
my $TEST_FILE = "output.dat";
329
if(abs(seek_ccsd($REF_FILE) - seek_ccsd($TEST_FILE)) > $PSITEST_ETOL) {
330
fail_test("CCSD energy"); $fail = 1;
333
pass_test("CCSD energy");
339
sub compare_ccsd_t_energy
342
my $REF_FILE = "$SRC_PATH/output.ref";
343
my $TEST_FILE = "output.dat";
345
if(abs(seek_ccsd_t($REF_FILE) - seek_ccsd_t($TEST_FILE)) > $PSITEST_ETOL) {
346
fail_test("CCSD(T) energy"); $fail = 1;
349
pass_test("CCSD(T) energy");
355
sub compare_eomccsd_energy
358
my $REF_FILE = "$SRC_PATH/output.ref";
359
my $TEST_FILE = "output.dat";
361
@eom_ref = seek_eomcc($REF_FILE);
362
@eom_test = seek_eomcc($TEST_FILE);
364
if(!compare_arrays(\@eom_ref,\@eom_test,($#eom_ref+1),$PSITEST_EEOMTOL)) {
365
fail_test("EOM-CCSD energy"); $fail = 1;
368
pass_test("EOM-CCSD energy");
374
sub compare_bccd_energy
377
my $REF_FILE = "$SRC_PATH/output.ref";
378
my $TEST_FILE = "output.dat";
380
if(abs(seek_bccd($REF_FILE) - seek_bccd($TEST_FILE)) > $PSITEST_ETOL) {
381
fail_test("B-CCD energy"); $fail = 1;
384
pass_test("B-CCD energy");
390
sub compare_bccd_t_energy
393
my $REF_FILE = "$SRC_PATH/output.ref";
394
my $TEST_FILE = "output.dat";
396
if(abs(seek_ccsd_t($REF_FILE) - seek_ccsd_t($TEST_FILE)) > $PSITEST_ETOL) {
397
fail_test("CCSD(T) energy"); $fail = 1;
400
pass_test("CCSD(T) energy");
406
sub compare_cclambda_overlap
410
my $REF_FILE = "$SRC_PATH/output.ref";
411
my $TEST_FILE = "output.dat";
413
if(abs(seek_lambda($REF_FILE) - seek_lambda($TEST_FILE)) > $PSITEST_ETOL) {
414
fail_test("$wfn Lambda Overlap"); $fail = 1;
417
pass_test("$wfn Lambda Overlap");
423
sub compare_scf_polar
426
my $REF_FILE = "$SRC_PATH/output.ref";
427
my $TEST_FILE = "output.dat";
429
@polar_ref = seek_scf_polar($REF_FILE);
430
@polar_test = seek_scf_polar($TEST_FILE);
432
if(!compare_arrays(\@polar_ref,\@polar_test,($#polar_ref+1),$PSITEST_POLARTOL)) {
433
fail_test("SCF Polarizability"); $fail = 1;
436
pass_test("SCF Polarizability");
442
sub compare_ccsd_polar
446
my $REF_FILE = "$SRC_PATH/output.ref";
447
my $TEST_FILE = "output.dat";
449
@polar_ref = seek_ccsd_polar($REF_FILE);
450
@polar_test = seek_ccsd_polar($TEST_FILE);
452
if(!compare_arrays(\@polar_ref,\@polar_test,($#polar_ref+1),$PSITEST_POLARTOL)) {
453
fail_test("$wfn Polarizability"); $fail = 1;
456
pass_test("$wfn Polarizability");
462
sub compare_casscf_energy
465
my $REF_FILE = "$SRC_PATH/output.ref";
466
my $TEST_FILE = "output.dat";
468
if(abs(seek_casscf($REF_FILE) - seek_casscf($TEST_FILE)) > $PSITEST_ETOL) {
469
fail_test("CASSCF energy"); $fail = 1;
472
pass_test("CASSCF energy");
478
sub compare_cis_energy
481
my $REF_FILE = "$SRC_PATH/output.ref";
482
my $TEST_FILE = "output.dat";
484
@cis_ref = seek_cis($REF_FILE);
485
@cis_test = seek_cis($TEST_FILE);
487
if(!compare_arrays(\@cis_ref,\@cis_test,($#cis_ref+1),$PSITEST_ETOL)) {
488
fail_test("CIS Energies"); $fail = 1;
491
pass_test("CIS Energies");
497
sub compare_ci_energy
500
my $REF_FILE = "$SRC_PATH/output.ref";
501
my $TEST_FILE = "output.dat";
503
if(abs(seek_ci($REF_FILE) - seek_ci($TEST_FILE)) > $PSITEST_ETOL) {
504
fail_test("CI energy"); $fail = 1;
507
pass_test("CI energy");
516
my $REF_FILE = "$SRC_PATH/output.ref";
517
my $TEST_FILE = "output.dat";
519
if(abs(seek_dboc($REF_FILE) - seek_dboc($TEST_FILE)) > $PSITEST_ETOL) {
520
fail_test("DBOC"); $fail = 1;
529
sub compare_mp2_energy
532
my $REF_FILE = "$SRC_PATH/output.ref";
533
my $TEST_FILE = "output.dat";
535
if(abs(seek_mp2($REF_FILE) - seek_mp2($TEST_FILE)) > $PSITEST_ETOL) {
536
fail_test("MP2 Energy"); $fail = 1;
539
pass_test("MP2 Energy");
545
sub compare_direct_mp2_energy
548
my $REF_FILE = "$SRC_PATH/output.ref";
549
my $TEST_FILE = "output.dat";
551
if(abs(seek_mp2_direct($REF_FILE) - seek_mp2_direct($TEST_FILE)) > $PSITEST_ETOL) {
552
fail_test("Direct MP2 Energy"); $fail = 1;
555
pass_test("Direct MP2 Energy");
561
sub compare_mulliken_orb_pops
564
my $REF_FILE = "$SRC_PATH/output.ref";
565
my $TEST_FILE = "output.dat";
567
@gop_ref = seek_mulliken_gop($REF_FILE);
568
@gop_test = seek_mulliken_gop($TEST_FILE);
570
if(!compare_arrays(\@gop_ref,\@gop_test,($#gop_ref+1),$PSITEST_MPOPTOL)) {
571
fail_test("Gross Orbital Populations"); $fail = 1;
574
pass_test("Gross Orbital Populations");
580
sub compare_mulliken_ab_pops
583
my $REF_FILE = "$SRC_PATH/output.ref";
584
my $TEST_FILE = "output.dat";
586
@abp_ref = seek_mulliken_abp($REF_FILE);
587
@abp_test = seek_mulliken_abp($TEST_FILE);
589
if(!compare_arrays(\@abp_ref,\@abp_test,($#abp_ref+1),$PSITEST_MPOPTOL)) {
590
fail_test("Atomic Bond Populations"); $fail = 1;
593
pass_test("Atomic Bond Populations");
599
sub compare_mulliken_ga_pops
602
my $REF_FILE = "$SRC_PATH/output.ref";
603
my $TEST_FILE = "output.dat";
605
@apnc_ref = seek_mulliken_apnc($REF_FILE);
606
@apnc_test = seek_mulliken_apnc($TEST_FILE);
608
if(!compare_arrays(\@apnc_ref,\@apnc_test,($#apnc_ref+1),$PSITEST_MPOPTOL)) {
609
fail_test("Gross Atomic Populations and Net Charges"); $fail = 1;
612
pass_test("Gross Atomic Populations and Net Charges");
618
sub compare_electric_dipole
621
my $REF_FILE = "$SRC_PATH/output.ref";
622
my $TEST_FILE = "output.dat";
624
@edipole_ref = seek_dipole($REF_FILE);
625
@edipole_test = seek_dipole($TEST_FILE);
627
if(!compare_arrays(\@edipole_ref,\@edipole_test,($#edipole_ref+1),$PSITEST_MPOPTOL)) {
628
fail_test("Electric Dipole Moment"); $fail = 1;
631
pass_test("Electric Dipole Moment");
637
sub compare_elec_angmom
640
my $REF_FILE = "$SRC_PATH/output.ref";
641
my $TEST_FILE = "output.dat";
643
@eangmom_ref = seek_angmom($REF_FILE);
644
@eangmom_test = seek_angmom($TEST_FILE);
646
if(!compare_arrays(\@eangmom_ref,\@eangmom_test,($#eangmom_ref+1),$PSITEST_MPOPTOL)) {
647
fail_test("Electric Angular Momentum"); $fail = 1;
650
pass_test("Electric Angular Momentum");
659
my $REF_FILE = "$SRC_PATH/output.ref";
660
my $TEST_FILE = "output.dat";
662
@epef_ref = seek_epef($REF_FILE);
663
@epef_test = seek_epef($TEST_FILE);
665
if(!compare_arrays(\@epef_ref,\@epef_test,($#epef_ref+1),$PSITEST_MPOPTOL)) {
666
fail_test("Electrostatic Potential and Electric Field"); $fail = 1;
669
pass_test("Electrostatic Potential and Electric Field");
678
my $REF_FILE = "$SRC_PATH/output.ref";
679
my $TEST_FILE = "output.dat";
681
@edensity_ref = seek_edensity($REF_FILE);
682
@edensity_test = seek_edensity($TEST_FILE);
684
if(!compare_arrays(\@edensity_ref,\@edensity_test,($#edensity_ref+1),$PSITEST_MPOPTOL)) {
685
fail_test("Electron Density"); $fail = 1;
688
pass_test("Electron Density");
697
my $REF_FILE = "$SRC_PATH/output.ref";
698
my $TEST_FILE = "output.dat";
700
if(abs(seek_mvd($REF_FILE) - seek_mvd($TEST_FILE)) > $PSITEST_ETOL) {
701
fail_test("One-Electron Relativistic Correction (MVD)"); $fail = 1;
704
pass_test("One-Electron Relativistic Correction (MVD)");
710
sub compare_mp2r12_energy
713
my $REF_FILE = "$SRC_PATH/output.ref";
714
my $TEST_FILE = "output.dat";
716
if(abs(seek_mp2r12($REF_FILE) - seek_mp2r12($TEST_FILE)) > $PSITEST_ETOL) {
717
fail_test("MP2-R12 Energy"); $fail = 1;
720
pass_test("MP2-R12 Energy");
726
sub compare_rhf_stability
729
my $REF_FILE = "$SRC_PATH/output.ref";
730
my $TEST_FILE = "output.dat";
732
my $nirreps = seek_nirreps($REF_FILE);
733
my $label = "RHF->RHF";
734
@stab_ref = seek_stab($REF_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
735
@stab_test = seek_stab($TEST_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
737
if(!compare_arrays(\@stab_ref,\@stab_test,($#stab_ref+1),$PSITEST_STABTOL)) {
738
fail_test("$label Stability"); $fail = 1;
741
pass_test("$label Stability");
744
my $label = "RHF->UHF";
745
@stab_ref = seek_stab($REF_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
746
@stab_test = seek_stab($TEST_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
748
if(!compare_arrays(\@stab_ref,\@stab_test,($#stab_ref+1),$PSITEST_STABTOL)) {
749
fail_test("$label Stability"); $fail = 1;
752
pass_test("$label Stability");
758
sub compare_rohf_stability
761
my $REF_FILE = "$SRC_PATH/output.ref";
762
my $TEST_FILE = "output.dat";
764
my $nirreps = seek_nirreps($REF_FILE);
765
my $label = "ROHF->ROHF";
766
@stab_ref = seek_stab($REF_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
767
@stab_test = seek_stab($TEST_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
769
if(!compare_arrays(\@stab_ref,\@stab_test,($#stab_ref+1),$PSITEST_STABTOL)) {
770
fail_test("$label Stability"); $fail = 1;
773
pass_test("$label Stability");
779
sub compare_uhf_stability
782
my $REF_FILE = "$SRC_PATH/output.ref";
783
my $TEST_FILE = "output.dat";
785
my $nirreps = seek_nirreps($REF_FILE);
786
my $label = "UHF->UHF";
787
@stab_ref = seek_stab($REF_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
788
@stab_test = seek_stab($TEST_FILE, $label, $PSITEST_DEFAULT_NSTAB, $nirreps);
790
if(!compare_arrays(\@stab_ref,\@stab_test,($#stab_ref+1),$PSITEST_STABTOL)) {
791
fail_test("$label Stability"); $fail = 1;
794
pass_test("$label Stability");
800
sub compare_harm_freq
804
my $REF_FILE = "$SRC_PATH/output.ref";
805
my $TEST_FILE = "output.dat";
807
my $ndof = seek_ndof($REF_FILE);
808
@freq_ref = seek_anal_freq($REF_FILE,"Harmonic Frequency",$ndof);
809
@freq_test = seek_anal_freq($TEST_FILE,"Harmonic Frequency",$ndof);
811
if(!compare_arrays(\@freq_ref,\@freq_test,($#freq_ref+1),$PSITEST_HTOL)) {
812
fail_test("$wfn Frequencies"); $fail = 1;
815
pass_test("$wfn Frequencies");
821
sub compare_harm_intensities
825
my $REF_FILE = "$SRC_PATH/output.ref";
826
my $TEST_FILE = "output.dat";
828
my $ndof = seek_ndof($REF_FILE);
829
@int_ref = seek_int($REF_FILE,"Harmonic Frequency",$ndof);
830
@int_test = seek_int($TEST_FILE,"Harmonic Frequency",$ndof);
832
if(!compare_arrays(\@int_ref,\@int_test,($#int_ref+1),$PSITEST_HTOL)) {
833
fail_test("$wfn Intensities"); $fail = 1;
836
pass_test("$wfn Intensities");
842
sub compare_energy_file11
846
my $REF_FILE = "$SRC_PATH/file11.ref";
847
my $TEST_FILE = "$PSITEST_PREFIX.file11.dat";
849
if(abs(seek_energy_file11($REF_FILE,$wfn) - seek_energy_file11($TEST_FILE,$wfn)) > $PSITEST_ETOL) {
850
fail_test("$wfn energy"); $fail = 1;
853
pass_test("$wfn energy");
859
sub compare_geom_file11
863
my $REF_FILE = "$SRC_PATH/file11.ref";
864
my $TEST_FILE = "$PSITEST_PREFIX.file11.dat";
866
my @geom_ref = seek_geom_file11($REF_FILE, $wfn);
867
my @geom_test = seek_geom_file11($TEST_FILE, $wfn);
868
if(!compare_arrays(\@geom_ref, \@geom_test, ($#geom_ref+1), $PSITEST_GEOMTOL)) {
869
fail_test("$wfn Geometry"); $fail = 1;
872
pass_test("$wfn Geometry");
878
sub compare_grad_file11
882
my $REF_FILE = "$SRC_PATH/file11.ref";
883
my $TEST_FILE = "$PSITEST_PREFIX.file11.dat";
885
my @grad_ref = seek_grad_file11($REF_FILE, $wfn);
886
my @grad_test = seek_grad_file11($TEST_FILE, $wfn);
887
if(!compare_arrays(\@grad_ref, \@grad_test, ($#grad_ref+1), $PSITEST_GTOL)) {
888
fail_test("$wfn Gradient"); $fail = 1;
891
pass_test("$wfn Gradient");
897
sub compare_findif_freq
901
my $REF_FILE = "$SRC_PATH/output.ref";
902
my $TEST_FILE = "output.dat";
903
my $ndof = seek_ndof($REF_FILE);
905
my @freq_ref = seek_findif_freq($REF_FILE, "Harmonic Vibrational Frequencies", $ndof);
906
my @freq_test = seek_findif_freq($TEST_FILE, "Harmonic Vibrational Frequencies", $ndof);
907
if(!compare_arrays(\@freq_ref, \@freq_test, ($#freq_ref+1), $PSITEST_HTOL)) {
908
fail_test("$wfn Frequencies"); $fail = 1;
911
pass_test("$wfn Frequencies");
917
sub compare_findif_symm_freq
921
my $REF_FILE = "$SRC_PATH/output.ref";
922
my $TEST_FILE = "output.dat";
923
my $ndof = seek_ndof_symm($REF_FILE);
925
my @freq_ref = seek_findif_freq($REF_FILE, "Harmonic Vibrational Frequencies", $ndof);
926
my @freq_test = seek_findif_freq($TEST_FILE, "Harmonic Vibrational Frequencies", $ndof);
927
if(!compare_arrays(\@freq_ref, \@freq_test, ($#freq_ref+1), $PSITEST_HTOL)) {
928
fail_test("$wfn Frequencies"); $fail = 1;
931
pass_test("$wfn Frequencies");
939
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
942
if (/Number of irr. rep. =/) {
943
@data = split(/[ \t]+/, $_);
944
my $nirreps = $data[6];
950
printf "Error: Could not find number of irreducible representations in $_[0].\n";
956
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
959
if (/Number of atoms =/) {
960
@data = split(/[ \t]+/, $_);
961
my $natoms = $data[5];
967
printf "Error: Could not find number of atoms in $_[0].\n";
973
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
976
if (/ It is a linear molecule./) {
987
my $natoms = seek_natoms($_[0]);
988
my $is_linear = seek_linear($_[0]);
989
my $ndof = 3*$natoms - 6;
990
if ($is_linear == 1) {
998
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1001
if (/ salcs of this irrep/) {
1002
my @data = split(/ +/, $_);
1003
my $ndof_symm = $data[1];
1009
printf "Error: Could not find the number of symmetric degrees of freedom in $_[0].\n";
1015
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1018
if (/Nuclear Repulsion Energy \(a.u.\) =/) {
1019
@data = split(/ +/, $_);
1026
printf "Error: Could not find nuclear repulsion energy in $_[0].\n";
1032
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1035
if (/SCF total energy/) {
1036
@data = split(/ +/, $_);
1043
printf "Error: Could not find SCF energy in $_[0].\n";
1049
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1052
if (/MP2 total energy/) {
1053
@data = split(/ +/, $_);
1060
printf "Error: Could not find MP2 energy in $_[0].\n";
1066
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1070
@data = split(/ +/, $_);
1077
printf "Error: Could not find MP2 energy in $_[0].\n";
1083
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1086
if (/MBPT\(2\)-R12/) {
1087
@data = split(/ +/, $_);
1094
printf "Error: Could not find MBPT(2)-R12 energy in $_[0].\n";
1098
# find the MP2 energy in the MP2-R12 output
1101
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1104
if (/MBPT\(2\) Energy/) {
1105
@data = split(/ +/, $_);
1112
printf "Error: Could not find MBPT(2) energy in $_[0].\n";
1118
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1121
if (/Total CCSD energy/) {
1122
@data = split(/ +/, $_);
1129
printf "Error: Could not find CCSD energy in $_[0].\n";
1135
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1138
if (/Total CCSD\(T\) energy/) {
1139
@data = split(/ +/, $_);
1146
printf "Error: Could not find CCSD(T) energy in $_[0].\n";
1152
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1156
$match = "Total CCSD energy";
1160
foreach $line (@datafile) {
1161
if ($line =~ m/$match/) {
1162
$lastiter = $linenum;
1167
@line = split (/ +/, $datafile[$lastiter]);
1174
printf "Error: Could not find B-CCD energy in $_[0].\n";
1180
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1183
if (/Overlap <L|e^T> =/) {
1184
@data = split(/ +/, $_);
1191
printf "Error: Could not find CCSD Lambda Overlap in $_[0].\n";
1197
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1201
@line1 = split(/ +/, $datafile[0]);
1203
@line2 = split(/ +/, $datafile[$niter]);
1204
$casscf = $line2[5];
1206
if($casscf != 0.0) {
1210
printf "Error: Could not find CASSCF energy in $_[0].\n";
1216
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1220
@data = split(/ +/, $_);
1229
printf "Error: Could not find CI energy in $_[0].\n";
1233
sub seek_energy_file11
1235
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1243
foreach $line (@datafile) {
1244
if($line =~ m/$match/) {
1245
$lastiter = $linenum;
1250
@line = split(/ +/, $datafile[$lastiter+1]);
1253
if($energy != 0.0) {
1257
printf "Error: Could not find $_[1] energy in $_[0].\n";
1261
sub seek_natom_file11
1263
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1271
foreach $line (@datafile) {
1272
if($line =~ m/$match/) {
1273
$lastiter = $linenum;
1278
@line = split(/ +/, $datafile[$lastiter+1]);
1285
printf "Error: Could not find value of natom in $_[0].\n";
1289
sub seek_geom_file11
1291
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1300
foreach $line (@datafile) {
1301
if($line =~ m/$match/) {
1302
$lastiter = $linenum;
1308
@line = split(/ +/, $datafile[$lastiter+1]);
1311
for($i=0; $i < $natom; $i++) {
1312
@line = split(/ +/, $datafile[$lastiter+2+$i]);
1313
$geom[3*$i] = $line[2];
1314
$geom[3*$i+1] = $line[3];
1315
$geom[3*$i+2] = $line[4];
1322
printf "Error: Could not find $_[1] geom in $_[0].\n";
1326
sub seek_grad_file11
1328
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1337
foreach $line (@datafile) {
1338
if($line =~ m/$match/) {
1339
$lastiter = $linenum;
1345
@line = split(/ +/, $datafile[$lastiter+1]);
1348
for($i=0; $i < $natom; $i++) {
1349
@line = split(/ +/, $datafile[$lastiter+2+$natom+$i]);
1350
$grad[3*$i] = $line[1];
1351
$grad[3*$i+1] = $line[2];
1352
$grad[3*$i+2] = $line[3];
1359
printf "Error: Could not find $_[1] grad in $_[0].\n";
1363
sub seek_findif_freq
1365
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1373
foreach $line (@datafile) {
1375
if ($line =~ m/$match/) {
1377
@test = split (/ +/,$datafile[$linenum+$j]);
1378
$freq[$j] = $test[2];
1385
for($i=0; $i < $ndof; $i++) {
1386
# printf "%d %6.1f\n", $i, $freq[$i];
1387
if($freq[$i] == 0.0 || $freq[$i] > 6000) {
1392
if($OK && $ndof > 0) {
1396
printf "Error: Check $_[1] in $_[0].\n";
1402
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1410
foreach $line (@datafile) {
1412
if ($line =~ m/$match/) {
1414
@test = split (/ +/,$datafile[$linenum+2+$j]);
1415
$freq[$j] = $test[2];
1422
for($i=0; $i < $ndof; $i++) {
1423
# printf "%d %6.1f\n", $i, $freq[$i];
1424
if($freq[$i] < 0.0 || $freq[$i] > 6000) {
1429
if($OK && $ndof > 0) {
1433
printf "Error: Check $_[1] in $_[0].\n";
1439
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1443
# set up some initial values to be overwritten
1444
for($i=0; $i < $ndof; $i++) {
1452
foreach $line (@datafile) {
1454
if ($line =~ m/$match/) {
1456
@test = split (/ +/,$datafile[$linenum+2+$j]);
1457
$int[$j] = $test[3];
1464
for($i=0; $i < $ndof; $i++) {
1465
if($int[$i] < 0.0) {
1470
if($OK && $ndof > 0) {
1474
printf "Error: Check $_[1] in $_[0].\n";
1480
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1486
foreach $line (@datafile) {
1488
if ($line =~ m/EOM State/) {
1489
@test = split (/ +/,$datafile[$linenum-1]);
1490
$evals[$eval] = $test[6];
1499
printf "Error: Could not find EOM-CCSD energies in $_[0].\n";
1505
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1511
foreach $line (@datafile) {
1513
if ($line =~ m/CIS State/) {
1514
@test = split (/ +/,$datafile[$linenum-1]);
1515
$evals[$eval] = $test[4];
1524
printf "Error: Could not find CIS energies in $_[0].\n";
1531
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1540
foreach $line (@datafile) {
1541
if ($line =~ m/$match/) {
1547
for($i=0; $i < $num_evals; $i++) {
1548
@line = split(/ +/, $datafile[$start+4+$i]);
1549
for($j=0; $j < $num_symms; $j++) {
1550
$stab[$num_symms*$i+$j] = $line[$j+2];
1558
printf "Error: Could not find $_[1] stability eigenvalues in $_[0].\n";
1564
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1570
foreach $line (@datafile) {
1571
if ($line =~ m/Hartree-Fock Electric Polarizability Tensor/) {
1577
for($i=0; $i < 3; $i++) {
1578
@line = split(/ +/, $datafile[$start+5+$i]);
1579
for($j=0; $j < 3; $j++) {
1580
$polar[3*$i+$j] = $line[$j+2];
1588
printf "Error: Could not find SCF polarizability tensor in $_[0].\n";
1594
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1600
foreach $line (@datafile) {
1601
if ($line =~ m/CCSD Dipole Polarizability/) {
1607
for($i=0; $i < 3; $i++) {
1608
@line = split(/ +/, $datafile[$start+7+$i]);
1609
for($j=0; $j < 3; $j++) {
1610
$polar[3*$i+$j] = $line[$j+2];
1618
printf "Error: Could not find SCF polarizability tensor in $_[0].\n";
1624
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1628
@data = split(/ +/, $_);
1635
printf "Error: Could not find DBOC in $_[0].\n";
1639
sub seek_mulliken_gop
1641
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1644
if (/# of atomic orbitals/) {
1645
@data = split(/[ \t]+/, $_);
1651
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1657
foreach $line (@datafile) {
1658
if ($line =~ m/-Gross orbital populations/) {
1665
for($i=0; $i<$nao; $i++) {
1666
@line = split(/ +/, $datafile[$start+4+$i]);
1667
$mulliken[$i] = $line[4];
1674
printf "Error: Could not find Gross orbital populations in $_[0].\n";
1678
sub seek_mulliken_abp
1680
my $noa = seek_natoms($_[0]);
1682
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1688
foreach $line (@datafile) {
1689
if ($line =~ m/-Atomic bond populations/) {
1696
for($i=0; $i<$noa; $i++) {
1697
@line = split(/ +/, $datafile[$start+4+$i]);
1698
for($j=0; $j<$noa; $j++) {
1699
$mulliken[$noa*$i+$j] = $line[$j+2];
1707
printf "Error: Could not find Gross orbital populations in $_[0].\n";
1711
sub seek_mulliken_apnc
1713
my $noa = seek_natoms($_[0]);
1715
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1721
foreach $line (@datafile) {
1722
if ($line =~ m/-Gross atomic populations/) {
1729
for($i=0; $i<$noa; $i++) {
1730
@line = split(/ +/, $datafile[$start+4+$i]);
1731
for($j=0; $j<$noa; $j++) {
1732
$mulliken[$noa*$i+$j] = $line[$j+2];
1740
printf "Error: Could not find Gross atomic populations in $_[0].\n";
1746
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1752
foreach $line (@datafile) {
1753
if ($line =~ m/-Electric dipole moment/) {
1760
for($i=0; $i<4; $i++) {
1761
@line = split(/ +/, $datafile[$start+2+$i]);
1762
$dipole[$i] = $line[3];
1769
printf "Error: Could not find Electronic dipole moment in $_[0].\n";
1775
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1781
foreach $line (@datafile) {
1782
if ($line =~ m/-Electronic angular momentum/) {
1789
for($i=0; $i<3; $i++) {
1790
@line = split(/ +/, $datafile[$start+2+$i]);
1791
$angmom[$i] = $line[3];
1798
printf "Error: Could not find Electronic angular momentum in $_[0].\n";
1804
my $noa = seek_natoms($_[0]);
1806
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1812
foreach $line (@datafile) {
1813
if ($line =~ m/-Electrostatic potential/) {
1820
for($i=0; $i<$noa; $i++) {
1821
@line = split(/ +/, $datafile[$start+4+$i]);
1822
for($j=0; $j<4; $j++) {
1823
$epef[$noa*$i+$j] = $line[$j+2];
1831
printf "Error: Could not find Electrostatic potential\n";
1832
printf " and electric field in $_[0].\n";
1838
my $noa = seek_natoms($_[0]);
1840
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1846
foreach $line (@datafile) {
1847
if ($line =~ m/-Electron density/) {
1854
for($i=0; $i<$noa; $i++) {
1855
@line = split(/ +/, $datafile[$start+4+$i]);
1856
$edensity[$i] = $line[2];
1863
printf "Error: Could not find Electron density in $_[0].\n";
1869
open(OUT, "$_[0]") || die "cannot open $_[0] $!";
1872
if (/Total one-electron MVD terms/) {
1873
@data = split(/[ \t]+/, $_);
1880
printf "Error: Could not find Relativistic MVD one-electron\n";
1881
printf " corrections in $_[0].\n";
1893
for($i=0; $i < $dim; $i++) {
1894
if(abs(@$A[$i] - @$B[$i]) > $tol) {
1908
$EXTRA_ARGS = $_[4];
1912
if($EXEC_PATH ne "") {
1913
$PSICMD = "PATH=$EXEC_PATH:\$PATH;export PATH;$EXEC";
1919
if($SRC_PATH ne "") {
1920
$PSICMD = $PSICMD . " -f $SRC_PATH/$PSITEST_INPUT";
1924
$PSICMD = $PSICMD . " 1>/dev/null 2>/dev/null";
1927
if($EXTRA_ARGS ne "") {
1928
$PSICMD = $PSICMD . $EXTRA_ARGS;
1936
$test_name = get_test_name();
1937
my $target = "$test_name.$PSITEST_TARGET_SUFFIX";
1940
my $interrupted = 1;
1943
while ($ARGV = shift) {
1944
if ("$ARGV" eq "-q") { $quiet = 1; }
1945
elsif("$ARGV" eq "-c") { $clean_only = 1; }
1946
elsif("$ARGV" eq "-u") { $interrupted = 0; }
1947
elsif("$ARGV" eq "-h") { usage_notice($PSITEST_TEST_SCRIPT); exit(1); }
1951
if($clean_only == 1) {
1958
my $psicmd = build_psi_cmd($exec, $quiet, $SRC_PATH, $PSITEST_EXEC_PATH, "");
1960
my $psi_fail = system ("$psicmd");
1961
if ($clean_only == 1) {
1965
if ($psi_fail != 0) {
1966
open(RE, ">>$target") || die "cannot open $target $!";
1967
printf RE "Psi3 failed!\n";
1969
printf STDOUT "Psi3 failed!\n";
1970
my $psicmd = build_psi_cmd("psiclean", 1, $SRC_PATH, $PSITEST_EXEC_PATH, "");
1975
my @result = ($interrupted);
1979
sub get_calctype_string
1981
# It's better to use File::Temp but it doesn't seem to be installed by default
1983
use POSIX qw(tmpnam);
1985
my $tempfile = tmpnam();
1986
my $psicmd = build_psi_cmd("psi3 -c", 0, $SRC_PATH, $PSITEST_EXEC_PATH, " 1>$tempfile 2>/dev/null");
1987
my $psi_fail = system($psicmd);
1988
open(RE, "$tempfile") || die "cannot open $tempfile $!";
1997
if (/Calculation type string = /) {
1998
@data = split(/ +/, $_);
1999
$calctype = $data[4];
2000
$calctype =~ s/\n//;
2005
if (/Wavefunction = /) {
2006
@data = split(/ +/, $_);
2013
if (/Reference = /) {
2014
@data = split(/ +/, $_);
2015
$reftype = $data[2];
2022
@data = split(/ +/, $_);
2023
$jobtype = $data[2];
2030
@data = split(/ +/, $_);
2031
$dertype = $data[2];
2038
@data = split(/ +/, $_);
2041
if ($tmp eq "true") {
2044
elsif ($tmp eq "false") {
2050
system("rm -f $tempfile");
2052
return ($calctype, $wfn, $reftype, $jobtype, $dertype, $direct);