-
Notifications
You must be signed in to change notification settings - Fork 0
/
RUN_lamaGOET_release.sh
executable file
·1751 lines (1703 loc) · 76.7 KB
/
RUN_lamaGOET_release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
export LC_NUMERIC="en_US.UTF-8"
source job_options.txt
GAMESS_ELMODB_OLD_PDB(){
I=$[ $I + 1 ]
PDB=$( echo $CIF | awk -F "/" '{print $NF}' )
echo "title" > $JOBNAME.gamess.inp
echo "prova $JOBNAME - $BASISSETG - closed shell SCF" >> $JOBNAME.gamess.inp
echo "charge $CHARGE " >> $JOBNAME.gamess.inp
if [ "$MULTIPLICITY" != "1" ]; then
echo "multiplicity $MULTIPLICITY" >> $JOBNAME.gamess.inp
fi
echo "adapt off" >> $JOBNAME.gamess.inp
echo "nosym" >> $JOBNAME.gamess.inp
echo "geometry angstrom" >> $JOBNAME.gamess.inp
if [ "$I" = "1" ]; then
awk '$1 ~ /ATOM/ {printf "%f\t %f\t %f\t %s\t %s\n", $6, $7, $8, "carga", $3}' $CIF > atoms
else
awk 'NR > 2 {printf "%f\t %f\t %f\t %s\t %s\n", $2, $3, $4, "carga", $1}' $JOBNAME.xyz > atoms
fi
awk '{print $5}' atoms | gawk 'BEGIN { FS = "" } {print $1}' | awk '{ if ($1 == "N") print "7.0"; else if ($1 == "H") print "1.0"; else if ($1 == "O") print "8.0"; else if ($1 == "C") print "6.0"; else if ($1 == "S") print "16.0"; }' > atoms_Z
awk '{print $5}' atoms | gawk 'BEGIN { FS = "" } {print $1}' > atoms_names
awk 'FNR==NR{a[NR]=$1;next}{$4=a[FNR]}1' atoms_Z atoms > full
cp full atoms
awk 'FNR==NR{a[NR]=$1;next}{$5=a[FNR]}1' atoms_names atoms > full
awk '{printf "%f\t %f\t %f\t %s\t %s\n", $1, $2, $3, $4, $5}' full >> $JOBNAME.gamess.inp
rm atoms
rm atoms_Z
rm full
rm atoms_names
echo "end" >> $JOBNAME.gamess.inp
case "6-31g(d,p)" in
$BASISSETG ) echo "basis 6-31G**" >> $JOBNAME.gamess.inp;;
*) case "6-311g(d,p)" in
$BASISSETG ) echo "basis 6-311G**" >> $JOBNAME.gamess.inp;;
*) echo "basis $BASISSETG" >> $JOBNAME.gamess.inp;;
esac;;
esac
echo "runtype scf" >> $JOBNAME.gamess.inp
echo "scftype rhf" >> $JOBNAME.gamess.inp
echo "enter " >> $JOBNAME.gamess.inp
echo "Calculating overlap integrals with gamessus, cycle number $I"
$GAMESS < $JOBNAME.gamess.inp > $JOBNAME.gamess.out
echo "Gamess cycle number $I ended"
mkdir $I.$SCFCALCPROG.cycle.$JOBNAME
cp $JOBNAME.gamess.inp $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.gamess.inp
cp $JOBNAME.gamess.out $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.gamess.out
cp sao $I.$SCFCALCPROG.cycle.$JOBNAME/$I.sao
rm ed*
rm gamess_input*
if ! grep -q 'OVERLAP INTEGRALS WRITTEN ON FILE sao' "$JOBNAME.gamess.out"; then
echo "ERROR: Calculation of overlap integrals with gamessus finished with error, please check the $I.th gamess.out file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
else
echo "Calculation of overlap integrals with gamess done, writing elmodb input files"
if [[ ! -f "$( echo $SCFCALC_BIN | awk -F "/" '{print $NF}' )" ]]; then
cp $SCFCALC_BIN .
fi
if [ "$I" = "1" ]; then
BASISSETDIR=$( echo "$(dirname $BASISSETDIR)/" )
ELMOLIB=$( echo "$(dirname $ELMOLIB)/" )
#this is correct but until the elmo problem is solved I will keep it commented
# if [[ "$INITADP" == "true" ]];then
# echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' cif=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
# else
echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
# fi
# if [[ "$INITADP" == "true" ]];then
# echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' cif_file='$INITADPFILE' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
# else
echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
# fi
if [[ "$NTAIL" != "0" ]]; then
echo "$MANUALRESIDUE" >> $JOBNAME.elmodb.inp
fi
if [[ "$NSSBOND" != "0" ]]; then
echo "$SSBONDATOMS" >> $JOBNAME.elmodb.inp
fi
else
#there is a problem with the conversion from fractional to cartesian inside the elmodb program, saving example files in the aga folder 4cut and changing back to always use the xyz. The elmo cannot read the cartesian cif
# echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' cif=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. comp_sao=.false. "'$END'" " > $JOBNAME.elmodb.inp
echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' xyz=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. comp_sao=.false. "'$END'" " > $JOBNAME.elmodb.inp
echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' xyz_file='$JOBNAME.xyz' ntail=$NTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
if [[ "$NTAIL" != "0" ]]; then
echo "$MANUALRESIDUE" >> $JOBNAME.elmodb.inp
fi
if [[ "$NSSBOND" != "0" ]]; then
echo "$SSBONDATOMS" >> $JOBNAME.elmodb.inp
fi
fi
echo "Running elmodb"
./$( echo $SCFCALC_BIN | awk -F "/" '{print $NF}' ) < $JOBNAME.elmodb.inp > $JOBNAME.elmodb.out
if ! grep -q 'CONGRATULATIONS: THE ELMO-TRANSFERs ENDED GRACEFULLY!!!' "$JOBNAME.elmodb.out"; then
echo "ERROR: elmodb finished with error, please check the $I.th elmodb.out file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
else
echo "elmodb job finish correctly."
cp $JOBNAME.elmodb.out $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.out
cp $JOBNAME.elmodb.inp $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.inp
cp $JOBNAME.fchk $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.fchk
if [ "$I" != "1" ]; then
cp $JOBNAME.xyz $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.xyz
fi
fi
fi
}
ELMODB(){
I=$[ $I + 1 ]
if [[ ! -f "$( echo $SCFCALC_BIN | awk -F "/" '{print $NF}' )" ]]; then
cp $SCFCALC_BIN .
fi
if [ "$I" = "1" ]; then
BASISSETDIR=$( echo "$(dirname $BASISSETDIR)/" )
ELMOLIB=$( echo "$(dirname $ELMOLIB)/" )
#this is correct but until the elmo problem is solved I will keep it commented
# if [[ "$INITADP" == "true" ]];then
# echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' cif=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
# else
echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
# fi
# if [[ "$INITADP" == "true" ]];then
# echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' cif_file='$INITADPFILE' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
# else
echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
# fi
if [[ "$NTAIL" != "0" ]]; then
echo "$MANUALRESIDUE" >> $JOBNAME.elmodb.inp
fi
if [[ "$NSSBOND" != "0" ]]; then
echo "$SSBONDATOMS" >> $JOBNAME.elmodb.inp
fi
else
#there is a problem with the conversion from fractional to cartesian inside the elmodb program, saving example files in the aga folder 4cut and changing back to always use the xyz. The elmo cannot read the cartesian cif
# echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' cif=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
echo " "'$INPUT_METHOD'" job_title='$JOBNAME' basis_set='$BASISSETG' xyz=.true. iprint_level=1 ncpus=$NUMPROC alloc_mem=$MEM bset_path='$BASISSETDIR' lib_path='$ELMOLIB' nci=.true. "'$END'" " > $JOBNAME.elmodb.inp
if [[ "$NTAIL" != "0" ]]; then
# echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' cif_file='$JOBNAME.fractional.cif1' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' xyz_file='$JOBNAME.xyz' ntail=$NTAIL max_atail=$ATAIL max_frtail=$FRTAIL nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
echo "$MANUALRESIDUE" >> $JOBNAME.elmodb.inp
else
# echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' cif_file='$JOBNAME.fractional.cif1' nssbond=$NSSBOND "'$END'" " >>
echo " "'$INPUT_STRUCTURE'" pdb_file='$PDB' xyz_file='$JOBNAME.xyz' nssbond=$NSSBOND "'$END'" " >> $JOBNAME.elmodb.inp
fi
if [[ "$NSSBOND" != "0" ]]; then
echo "$SSBONDATOMS" >> $JOBNAME.elmodb.inp
fi
fi
echo "Running elmodb"
./$( echo $SCFCALC_BIN | awk -F "/" '{print $NF}' ) < $JOBNAME.elmodb.inp > $JOBNAME.elmodb.out
if ! grep -q 'CONGRATULATIONS: THE ELMO-TRANSFERs ENDED GRACEFULLY!!!' "$JOBNAME.elmodb.out"; then
echo "ERROR: elmodb finished with error, please check the $I.th elmodb.out file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
else
echo "elmodb job finish correctly."
mkdir $I.$SCFCALCPROG.cycle.$JOBNAME
cp $JOBNAME.elmodb.out $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.out
cp $JOBNAME.elmodb.inp $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.inp
cp $JOBNAME.fchk $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.elmodb.fchk
if [ "$I" != "1" ]; then
cp $JOBNAME.xyz $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.xyz
fi
fi
}
TONTO_TO_ORCA(){
I=$[ $I + 1 ]
echo "Extracting XYZ for Orca cycle number $I"
if [ "$METHOD" = "rks" ]; then
echo "! blyp $BASISSETG" > $JOBNAME.inp
else
if [ "$METHOD" = "uks" ]; then
echo "! ublyp $BASISSETG" > $JOBNAME.inp
else
echo "! $METHOD $BASISSETG" > $JOBNAME.inp
fi
fi
echo "" >> $JOBNAME.inp
echo "%output" >> $JOBNAME.inp
echo " PrintLevel=Normal" >> $JOBNAME.inp
echo " Print[ P_Basis ] 2" >> $JOBNAME.inp
echo " Print[ P_GuessOrb ] 1" >> $JOBNAME.inp
echo " Print[ P_MOs ] 1" >> $JOBNAME.inp
echo " Print[ P_Density ] 1" >> $JOBNAME.inp
echo " Print[ P_SpinDensity ] 1" >> $JOBNAME.inp
echo "end" >> $JOBNAME.inp
echo "" >> $JOBNAME.inp
echo "* xyz $CHARGE $MULTIPLICITY" >> $JOBNAME.inp
awk 'NR>2' $JOBNAME.xyz >> $JOBNAME.inp
if [ "$SCCHARGES" = "true" ]; then
if [ ! -f gaussian-point-charges ]; then
echo "" > gaussian-point-charges
awk '/Cluster monopole charges and positions/{print p; f=1} {p=$0} /------------------------------------------------------------------------/{c=1} f; c--==0{f=0}' stdout >> gaussian-point-charges
fi
echo "" >> $JOBNAME.inp
awk '{a[NR]=$0}{b=12}/^------------------------------------------------------------------------/{c=NR}END{for(d=b;d<=c-1;++d)print a[d]}' gaussian-point-charges | awk '{printf "%s\t %s\t %s\t %s\t \n", $1, $2, $3, $4 }' >> $JOBNAME.inp
echo "" >> $JOBNAME.inp
# rm gaussian-point-charges
fi
echo "*" >> $JOBNAME.inp
echo "Running Orca, cycle number $I"
$SCFCALC_BIN $JOBNAME.inp > $JOBNAME.log
echo "Orca cycle number $I ended"
if ! grep -q '****ORCA TERMINATED NORMALLY****' "$JOBNAME.out"; then
echo "ERROR: Orca job finished with error, please check the $I.th out file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
echo "Generation molden file for Orca cycle number $I"
orca_2mkl $JOBNAME -molden
echo "Orca cycle number $I, final energy is: $ENERGIA, RMSD is: $RMSD "
mkdir $I.$SCFCALCPROG.cycle.$JOBNAME
cp $JOBNAME.inp $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.inp
cp $JOBNAME.molden.input $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.molden.input
cp $JOBNAME.log $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.log
}
TONTO_HEADER(){
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > stdin
echo "!!! !!!" >> stdin
echo "!!! This stdin was written with lamaGOET !!!" >> stdin
echo "!!! !!!" >> stdin
echo "!!! script written by Lorraine Andrade Malaspina !!!" >> stdin
echo "!!! contact: [email protected] !!!" >> stdin
echo "!!! !!!" >> stdin
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> stdin
echo "{ " >> stdin
echo "" >> stdin
echo " keyword_echo_on" >> stdin
echo "" >> stdin
}
READ_ELMO_FCHK(){
echo " name= $JOBNAME" >> stdin
echo "" >> stdin
echo " read_g09_fchk_file $JOBNAME.fchk" >> stdin
echo "" >> stdin
}
READ_GAUSSIAN_FCHK(){
echo " name= $JOBNAME" >> stdin
echo "" >> stdin
echo " read_g09_fchk_file $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.fchk" >> stdin
echo "" >> stdin
}
READ_ORCA_FCHK(){
echo " name= $JOBNAME" >> stdin
echo "" >> stdin
echo " read_molden_file $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.molden.input" >> stdin
echo "" >> stdin
}
DEFINE_JOB_NAME(){
echo " name= $JOBNAME" >> stdin
echo "" >> stdin
}
CHANGE_JOB_NAME(){
echo " name= $JOBNAME.XCW" >> stdin
echo "" >> stdin
}
PROCESS_CIF(){
echo " ! Process the CIF" >> stdin
echo " CIF= {" >> stdin
if [ $J = 0 ]; then
if [[ "$COMPLETESTRUCT" == "true" && "$SCFCALCPROG" != "Tonto" ]]; then
echo " file_name= $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2" >> stdin
else
echo " file_name= $CIF" >> stdin
fi
if [ "$XHALONG" = "true" ]; then
if [[ ! -z "$BHBOND" ]]; then
echo " BH_bond_length= $BHBOND angstrom" >> stdin
fi
if [[ ! -z "$CHBOND" ]]; then
echo " CH_bond_length= $CHBOND angstrom" >> stdin
fi
if [[ ! -z "$NHBOND" ]]; then
echo " NH_bond_length= $NHBOND angstrom" >> stdin
fi
if [[ ! -z "$OHBOND" ]]; then
echo " OH_bond_length= $OHBOND angstrom" >> stdin
fi
fi
elif [ $J = 1 ]; then
if [[ "$SCCHARGES" == "true" && ("$SCFCALCPROG" == "Gaussian" || "$SCFCALCPROG" == "Orca") ]]; then
# if [[ "$SCFCALCPROG" == "Gaussian" || "$SCFCALCPROG" == "Orca" ]]; then
if [[ "$COMPLETESTRUCT" == "true" ]]; then
echo " file_name= 0.tonto_cycle.$JOBNAME/0.$JOBNAME.cartesian.cif2" >> stdin
else
echo " file_name= $CIF" >> stdin
fi
else
echo " file_name= $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2" >> stdin
fi
else
echo " file_name= $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2" >> stdin
fi
echo " }" >> stdin
echo "" >> stdin
echo " process_CIF" >> stdin
echo "" >> stdin
}
TONTO_BASIS_SET(){
echo " basis_directory= $BASISSETDIR" >> stdin
echo " basis_name= $BASISSETT" >> stdin
echo "" >> stdin
}
DISPERSION_COEF(){
echo " dispersion_coefficients= {" >> stdin
echo " $(cat DISP_inst.txt)" >> stdin
echo " }" >> stdin
echo "" >> stdin
}
CHARGE_MULT(){
echo " charge= $CHARGE" >> stdin
echo " multiplicity= $MULTIPLICITY" >> stdin
echo "" >> stdin
}
TONTO_IAM_BLOCK(){
echo ""
echo " crystal= { " >> stdin
if [[ "$SCFCALCPROG" = "elmodb" && "$INITADP" == "false" ]]; then
echo " REDIRECT tonto.cell" >> stdin
fi
echo " xray_data= { " >> stdin
echo " optimise_extinction= false" >> stdin
echo " correct_dispersion= $DISP" >> stdin
echo " wavelength= $WAVE Angstrom" >> stdin
if [ "$REFANHARM" == "true" ]; then
if [[ "$THIRDORD" == "false" && "$FOURTHORD" == "true" ]]; then
echo " refine_4th_order_only= true " >> stdin
echo " refine_4th_order_for_atoms= { $ANHARMATOMS } " >> stdin
elif [[ "$THIRDORD" == "true" && "$FOURTHORD" == "true" ]]; then
echo " refine_4th_order_for_atoms= { $ANHARMATOMS } " >> stdin
elif [[ "$THIRDORD" == "true" && "$FOURTHORD" == "false" ]]; then
echo " refine_3rd_order_for_atoms= { $ANHARMATOMS } " >> stdin
else
echo "ERROR: Please select at least one of the anharmonic terms to refine" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
fi
echo " REDIRECT $HKL" >> stdin
if [[ "$FCUT" != "0" ]]; then
echo " f_sigma_cutoff= $FCUT" >> stdin
fi
if [[ "$MINCORCOEF" != "" ]]; then
echo " min_correlation= $MINCORCOEF" >> stdin
fi
echo " tol_for_shift_on_esd= $CONVTOL" >> stdin
echo " refine_H_U_iso= yes" >> stdin
echo "" >> stdin
echo " show_fit_output= true" >> stdin
echo " show_fit_results= true" >> stdin
echo "" >> stdin
echo " } " >> stdin
echo " } " >> stdin
echo "" >> stdin
echo " ! Geometry " >> stdin
echo " put" >> stdin
echo "" >> stdin
echo " IAM_refinement" >> stdin
echo "" >> stdin
}
CRYSTAL_BLOCK(){
echo "" >> stdin
echo " crystal= { " >> stdin
if [[ "$SCFCALCPROG" == "elmodb" && $J == 0 && "$INITADP" == "false" ]]; then
echo " REDIRECT tonto.cell" >> stdin
fi
if [[ "$SCFCALCPROG" == "optgaussian" ]]; then
echo " REDIRECT tonto.cell" >> stdin
fi
if [[ "$SCFCALCPROG" != "optgaussian" ]]; then
echo " xray_data= { " >> stdin
echo " thermal_smearing_model= hirshfeld" >> stdin
echo " partition_model= mulliken" >> stdin
if [[ "$PLOT_TONTO" == "false" ]]; then
echo " optimise_extinction= false" >> stdin
echo " correct_dispersion= $DISP" >> stdin
echo " optimise_scale_factor= true" >> stdin
fi
echo " wavelength= $WAVE Angstrom" >> stdin
if [[ "$REFANHARM" == "true" && "$PLOT_TONTO" == "false" ]]; then
if [[ "$THIRDORD" == "false" && "$FOURTHORD" == "true" ]]; then
echo " refine_4th_order_only= true " >> stdin
echo " refine_4th_order_for_atoms= { $ANHARMATOMS } " >> stdin
elif [[ "$THIRDORD" == "true" && "$FOURTHORD" == "true" ]]; then
echo " refine_4th_order_for_atoms= { $ANHARMATOMS } " >> stdin
elif [[ "$THIRDORD" == "true" && "$FOURTHORD" == "false" ]]; then
echo " refine_3rd_order_for_atoms= { $ANHARMATOMS } " >> stdin
else
echo "ERROR: Please select at least one of the anharmonic terms to refine" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
fi
echo " REDIRECT $HKL" >> stdin
if [[ "$FCUT" != "0" ]]; then
echo " f_sigma_cutoff= $FCUT" >> stdin
fi
if [[ "$PLOT_TONTO" == "false" ]]; then
if [ "$MINCORCOEF" != "" ]; then
echo " min_correlation= $MINCORCOEF" >> stdin
fi
echo " tol_for_shift_on_esd= $CONVTOL" >> stdin
echo " refine_H_U_iso= $HADP" >> stdin
if [[ "$SCFCALCPROG" = "Tonto" && "$IAMTONTO" = "true" ]]; then
echo "" >> stdin
echo " show_fit_output= false" >> stdin
echo " show_fit_results= false" >> stdin
fi
echo "" >> stdin
if [ "$SCFCALCPROG" != "Tonto" ]; then
echo " show_fit_output= TRUE" >> stdin
echo " show_fit_results= TRUE" >> stdin
echo "" >> stdin
fi
if [ "$POSONLY" = "true" ]; then
echo " refine_positions_only= $POSONLY" >> stdin
fi
if [ "$ADPSONLY" = "true" ]; then
echo " refine_ADPs_only= $ADPSONLY" >> stdin
fi
if [ "$REFHADP" = "false" ]; then
if [ "$ADPSONLY" != "true" ]; then
echo " refine_H_ADPs= $REFHADP" >> stdin
fi
fi
if [ "$REFHPOS" = "false" ]; then
if [ "$ADPSONLY" != "true" ]; then
echo " refine_H_positions= $REFHPOS" >> stdin
fi
fi
if [ "$REFNOTHING" = "true" ]; then
echo " refine_nothing_for_atoms= { $ATOMLIST }" >> stdin
fi
if [ "$REFUISO" = "true" ]; then
echo " refine_u_iso_for_atoms= { $ATOMUISOLIST }" >> stdin
fi
if [[ "$MAXLSCYCLE" != "" ]]; then
echo " max_iterations= $MAXLSCYCLE" >> stdin
fi
fi
echo " } " >> stdin
fi
echo " } " >> stdin
echo "" >> stdin
}
SET_H_ISO(){
echo " set_isotropic_h_adps" >> stdin
echo "" >> stdin
}
PUT_GEOM(){
echo " ! Geometry " >> stdin
echo " put" >> stdin
echo "" >> stdin
}
BECKE_GRID(){
echo " !Tight grid" >> stdin
echo " becke_grid = {" >> stdin
echo " set_defaults" >> stdin
echo " accuracy= $ACCURACY" >> stdin
echo " pruning_scheme= $BECKEPRUNINGSCHEME" >> stdin
echo " }" >> stdin
echo "" >> stdin
}
SCF_BLOCK_NOT_TONTO(){
if [[ "$SCCHARGES" == "true" && "$SCFCALCPROG" != "elmodb" ]]; then
echo " ! SC cluster charge SCF" >> stdin
echo " scfdata= {" >> stdin
echo " initial_MOs= restricted " >> stdin # Only for new tonto may 2020
# echo " initial_MOs= existing" >> stdin
if [[ "$METHOD" != "rks" && "$METHOD" != "rhf" && "$METHOD" != "uhf" && "$METHOD" != "uks" ]]; then
echo " kind= rks " >> stdin
echo " output= true " >> stdin
echo " dft_exchange_functional= b3lypgx" >> stdin
echo " dft_correlation_functional= b3lypgc" >> stdin
else
echo " kind= $METHOD" >> stdin
echo " output= true " >> stdin
fi
echo " use_SC_cluster_charges= TRUE" >> stdin
echo " cluster_radius= $SCCRADIUS angstrom" >> stdin
echo " defragment= $DEFRAG" >> stdin
echo " save_cluster_charges= true" >> stdin
echo " convergence= 0.001" >> stdin
echo " diis= { convergence_tolerance= 0.0002 }" >> stdin
echo " output= YES" >> stdin
echo " output_results= YES" >> stdin
echo " }" >> stdin
echo "" >> stdin
echo " make_scf_density_matrix" >> stdin
echo " make_hirshfeld_inputs" >> stdin
echo " make_fock_matrix" >> stdin
echo "" >> stdin
echo " ! SC cluster charge SCF" >> stdin
echo " scfdata= {" >> stdin
echo " initial_density= promolecule" >> stdin
echo " initial_MOs= restricted " >> stdin # Only for new tonto may 2020
# echo " initial_MOs= existing" >> stdin
if [[ "$METHOD" != "rks" && "$METHOD" != "rhf" && "$METHOD" != "uhf" && "$METHOD" != "uks" ]]; then
echo " kind= rks " >> stdin
echo " output= true " >> stdin
echo " dft_exchange_functional= b3lypgx" >> stdin
echo " dft_correlation_functional= b3lypgc" >> stdin
else
echo " kind= $METHOD" >> stdin
echo " output= true " >> stdin
fi
echo " use_SC_cluster_charges= TRUE" >> stdin
echo " cluster_radius= $SCCRADIUS angstrom" >> stdin
echo " defragment= $DEFRAG" >> stdin
echo " put_cluster" >> stdin
echo " put_cluster_charges" >> stdin
echo "" >> stdin
echo " }" >> stdin
echo "" >> stdin
if [[ "$SCFCALCPROG" != "optgaussian" && "$J" != "0" ]]; then
echo " ! Make Hirshfeld structure factors" >> stdin
echo " fit_hirshfeld_atoms" >> stdin
echo "" >> stdin
fi
echo " write_xyz_file" >> stdin
if [[ "$SCFCALCPROG" == "optgaussian" ]]; then
echo "" >> stdin
echo " put_grown_cif" >> stdin
fi
else
if [[ "$SCFCALCPROG" != "optgaussian" ]]; then
echo " ! Make Hirshfeld structure factors" >> stdin
echo " fit_hirshfeld_atoms" >> stdin
echo "" >> stdin
fi
echo " write_xyz_file" >> stdin
if [[ "$SCFCALCPROG" == "optgaussian" ]]; then
echo "" >> stdin
echo " put_grown_cif" >> stdin
fi
fi
}
SCF_BLOCK_PROM_TONTO(){
echo " ! Normal SCF" >> stdin
echo " scfdata= {" >> stdin
echo " initial_density= promolecule " >> stdin
echo " kind= rhf" >> stdin # this is the promolecule guess, should be always rhf
echo " output= true " >> stdin
echo " use_SC_cluster_charges= FALSE" >> stdin
echo " convergence= 0.001" >> stdin
echo " diis= { convergence_tolerance= 0.0002 }" >> stdin
echo " }" >> stdin
echo "" >> stdin
echo " scf" >> stdin
echo "" >> stdin
}
SCF_BLOCK_REST_TONTO(){
echo " ! SC cluster charge SCF" >> stdin
echo " scfdata= {" >> stdin
echo " initial_MOs= restricted" >> stdin
if [[ "$METHOD" == "b3lyp" || "$METHOD" == "rks" ]]; then
echo " kind= rks" >> stdin
echo " output= true " >> stdin
echo " dft_exchange_functional= b3lypgx" >> stdin
echo " dft_correlation_functional= b3lypgc" >> stdin
else
echo " kind= $METHOD" >> stdin
echo " output= true " >> stdin
fi
if [[ "$SCCHARGES" == "true" ]]; then
echo " use_SC_cluster_charges= TRUE" >> stdin
echo " cluster_radius= $SCCRADIUS angstrom" >> stdin
echo " defragment= $DEFRAG" >> stdin
else
echo " use_SC_cluster_charges= FALSE" >> stdin
fi
if [[ "$PLOT_TONTO" == "false" ]]; then
echo " convergence= 0.001" >> stdin
echo " diis= { convergence_tolerance= 0.0002 }" >> stdin
fi
echo " }" >> stdin
echo "" >> stdin
echo " scf" >> stdin
echo "" >> stdin
if [[ "$XCWONLY" != "true" && "$PLOT_TONTO" == "false" ]]; then
echo " ! Make Hirshfeld structure factors" >> stdin
echo " refine_hirshfeld_atoms" >> stdin
echo "" >> stdin
fi
}
SCF_TO_TONTO(){
TONTO_HEADER
if [ "$SCFCALCPROG" = "elmodb" ]; then
READ_ELMO_FCHK
fi
if [[ "$SCFCALCPROG" == "Gaussian" || "$SCFCALCPROG" == "optgaussian" ]]; then
READ_GAUSSIAN_FCHK
elif [ "$SCFCALCPROG" = "Orca" ]; then
READ_ORCA_FCHK
else
DEFINE_JOB_NAME
fi
echo "" >> stdin
if [[ "$SCFCALCPROG" != "elmodb" && "$SCFCALCPROG" != "optgaussian" ]]; then
PROCESS_CIF
DEFINE_JOB_NAME
fi
if [[ $J -gt 0 && "$SCFCALCPROG" == "elmodb" ]]; then
PROCESS_CIF
DEFINE_JOB_NAME
fi
if [[ $J -eq 0 && "$SCFCALCPROG" == "elmodb" && "$INITADP" == "true" ]]; then
echo " ! Process the CIF" >> stdin
echo " CIF= {" >> stdin
echo " file_name= $INITADPFILE" >> stdin
echo " }" >> stdin
echo "" >> stdin
echo " process_CIF" >> stdin
echo "" >> stdin
echo " name= $JOBNAME" >> stdin
echo "" >> stdin
fi
if [[ "$SCFCALCPROG" == "Tonto" ]]; then
TONTO_BASIS_SET
if [[ "$COMPLETESTRUCT" == "true" ]]; then
COMPLETECIFBLOCK
fi
fi
if [[ "$DISP" == "yes" ]]; then
DISPERSION_COEF
fi
CHARGE_MULT
if [[ $J == 0 && "$IAMTONTO" == "true" ]]; then
TONTO_IAM_BLOCK
fi
CRYSTAL_BLOCK
if [[ "$HADP" == "yes" ]]; then
SET_H_ISO
fi
PUT_GEOM
if [[ "$USEBECKE" == "true" ]]; then
BECKE_GRID
fi
if [[ "$SCFCALCPROG" != "Tonto" ]]; then
SCF_BLOCK_NOT_TONTO
fi
if [[ "$SCFCALCPROG" == "Tonto" ]]; then
SCF_BLOCK_PROM_TONTO
SCF_BLOCK_REST_TONTO
fi
echo "" >> stdin
echo "}" >> stdin
J=$[ $J + 1 ]
echo "Running Tonto, cycle number $J"
if [[ "$NUMPROC" != "1" ]]; then
mpirun -n $NUMPROC $TONTO
else
$TONTO
fi
if [[ "$SCFCALCPROG" == "Tonto" ]]; then
mkdir $J.tonto_cycle.$JOBNAME
sed -i '/# NOTE: Cartesian 9Nx9N covariance matrix in BOHR units/,/# ===========/d' $JOBNAME.cartesian.cif2
cp $JOBNAME'.cartesian.cif2' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2
cp $JOBNAME'.archive.cif' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.cif
cp $JOBNAME'.archive.fco' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fco
cp $JOBNAME'.archive.fcf' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fcf
cp stdin $J.tonto_cycle.$JOBNAME/$J.stdin
cp stdout $J.tonto_cycle.$JOBNAME/$J.stdout
cp $JOBNAME.residual_density_map,cell.cube $J.tonto_cycle.$JOBNAME/$J.residual_density_map,cell.cube
fi
INITIALCHI=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR}END {print a[b+10]}' stdout | awk '{print $2}')
# MAXSHIFT=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk -v max=0 '{if($5>max){shift=$5; atom=$6; param=$7; max=$5}}END{print shift}')
# MAXSHIFTATOM=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk -v max=0 '{if($5>max){shift=$5; atom=$6; param=$7; max=$5}}END{print atom}')
# MAXSHIFTPARAM=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk -v max=0 '{if($5>max){shift=$5; atom=$6; param=$7; max=$5}}END{print param}')
MAXSHIFT=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk '{ gsub("-","",$0); print $0 }' | awk -v max=0 '{if($5>max){shift=$5; atom=$7; param=$8; max=$5}}END{print shift}')
MAXSHIFTATOM=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk '{ gsub("-","",$0); print $0 }' | awk -v max=0 '{if($5>max){shift=$5; atom=$7; param=$8; max=$5}}END{print atom}')
MAXSHIFTPARAM=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR+10}/^Rigid-atom fit results/{c=NR-4}END {for(d=b;d<=c;++d)print a[d]}' stdout | awk '{ gsub("-","",$0); print $0 }' |awk -v max=0 '{if($5>max){shift=$5; atom=$7; param=$8; max=$5}}END{print param}')
if [[ "$SCFCALCPROG" != "Tonto" && "$SCFCALCPROG" != "elmodb" ]]; then
sed -i 's/(//g' $JOBNAME.xyz
sed -i 's/)//g' $JOBNAME.xyz
fi
echo "Tonto cycle number $J ended"
sed -i 's/D[0-9]/H(iso=2)/g' $JOBNAME.xyz
if ! grep -q 'Wall-clock time taken' "stdout"; then
echo "ERROR: problems in fit cycle, please check the $J.th stdout file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
if [ $J = 1 ]; then
echo "====================" >> $JOBNAME.lst
echo "Begin rigid-atom fit" >> $JOBNAME.lst
echo "====================" >> $JOBNAME.lst
echo "" >> $JOBNAME.lst
echo "__________________________________________________________________________________________________________________________________________________________________" >> $JOBNAME.lst
echo "" >> $JOBNAME.lst
echo "Cycle Fit initial final R R_w Max. Max. No. of No. of Energy RMSD Delta " >> $JOBNAME.lst
echo " Iter chi2 chi2 Shift Shift params eig's at final at final Energy " >> $JOBNAME.lst
echo " /esd param near 0 Geom. Geom. " >> $JOBNAME.lst
echo "" >> $JOBNAME.lst
echo "__________________________________________________________________________________________________________________________________________________________________" >> $JOBNAME.lst
echo "" >> $JOBNAME.lst
fi
if [[ "$SCFCALCPROG" != "Gaussian" && "$SCFCALCPROG" != "Orca" ]]; then
echo -e " $J\t$(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print $1}' )\t$INITIALCHI\t$(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print $2"\t"$3"\t"$4"\t"}') $MAXSHIFT\t$MAXSHIFTATOM $MAXSHIFTPARAM $(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print "\t"" "$9" \t"$10 }' ) " >> $JOBNAME.lst
fi
if [[ "$SCFCALCPROG" != "Tonto" ]]; then
mkdir $J.tonto_cycle.$JOBNAME
cp $JOBNAME.xyz $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.xyz
cp stdin $J.tonto_cycle.$JOBNAME/$J.stdin
cp stdout $J.tonto_cycle.$JOBNAME/$J.stdout
if [[ "$SCFCALCPROG" != "optgaussian" ]]; then
if [ -f $JOBNAME.cartesian.cif2 ]; then
sed -i '/# NOTE: Cartesian 9Nx9N covariance matrix in BOHR units/,/# ===========/d' $JOBNAME.cartesian.cif2
cp $JOBNAME'.cartesian.cif2' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2
cp $JOBNAME'.archive.cif' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.cif
cp $JOBNAME'.archive.fco' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fco
cp $JOBNAME'.archive.fcf' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fcf
fi
fi
if [[ "$SCFCALCPROG" != "elmodb" && "$SCCHARGES" == "true" ]]; then
cp cluster_charges $J.tonto_cycle.$JOBNAME/$J.cluster_charges
cp gaussian-point-charges $J.tonto_cycle.$JOBNAME/$J.gaussian-point-charges
# cp gaussian-point-charges $J.tonto_cycle.$JOBNAME/$J.gaussian-point-charges
fi
fi
}
TONTO_TO_GAUSSIAN(){
I=$[ $I + 1 ]
echo "Extracting XYZ for Gaussian cycle number $I"
echo "%rwf=./$JOBNAME.rwf" >> $JOBNAME.com
echo "%int=./$JOBNAME.int" >> $JOBNAME.com
echo "%NoSave" >> $JOBNAME.com
echo "%chk=./$JOBNAME.chk" > $JOBNAME.com
echo "%mem=$MEM" >> $JOBNAME.com
echo "%nprocshared=$NUMPROC" >> $JOBNAME.com
if [ "$METHOD" = "rks" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "#$OPT blyp/$BASISSETG Charge nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "#$OPT blyp/$BASISSETG nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
elif [ "$METHOD" = "uks" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "#$OPT ublyp/$BASISSETG Charge nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "#$OPT ublyp/$BASISSETG nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
elif [ "$METHOD" = "rhf" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "#$OPT rhf/$BASISSETG Charge nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "#$OPT rhf/$BASISSETG nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
else
if [ "$SCCHARGES" = "true" ]; then
echo "#$OPT $METHOD/$BASISSETG Charge nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "#$OPT $METHOD/$BASISSETG nosymm $EXTRAKEY output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
fi
echo "" >> $JOBNAME.com
echo "$JOBNAME" >> $JOBNAME.com
echo "" >> $JOBNAME.com
echo "$CHARGE $MULTIPLICITY" >> $JOBNAME.com
awk 'NR>2' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.xyz >> $JOBNAME.com
if [ "$SCCHARGES" = "true" ]; then
if [ ! -f gaussian-point-charges ]; then
echo "" > gaussian-point-charges
awk '/Cluster monopole charges and positions/{print p; f=1} {p=$0} /------------------------------------------------------------------------/{c=1} f; c--==0{f=0}' stdout >> gaussian-point-charges
fi
echo "" >> $JOBNAME.com
awk '{a[NR]=$0}{b=12}/^------------------------------------------------------------------------/{c=NR}END{for(d=b;d<=c-1;++d)print a[d]}' gaussian-point-charges | awk '{printf "%s\t %s\t %s\t %s\t \n", $1, $2, $3, $4 }' >> $JOBNAME.com
echo "" >> $JOBNAME.com
# rm gaussian-point-charges
fi
if [ "$GAUSGEN" = "true" ]; then
cat basis_gen.txt >> $JOBNAME.com
echo "" >> $JOBNAME.com
fi
echo "./$JOBNAME.wfn" >> $JOBNAME.com
echo "" >> $JOBNAME.com
echo "Running Gaussian, cycle number $I"
$SCFCALC_BIN $JOBNAME.com
echo "Gaussian cycle number $I ended"
if ! grep -q 'Normal termination of Gaussian' "$JOBNAME.log"; then
echo "ERROR: Gaussian job finished with error, please check the $I.th log file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
echo "Generation fcheck file for Gaussian cycle number $I"
mkdir $I.$SCFCALCPROG.cycle.$JOBNAME
cp $JOBNAME.com $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.com
cp Test.FChk $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.fchk
cp $JOBNAME.log $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.log
}
GET_FREQ(){
I=$[ $I + 1 ]
echo "Extrating XYZ for Gaussian cycle number $I"
echo "%rwf=./$JOBNAME.rwf" >> $JOBNAME.com
echo "%int=./$JOBNAME.int" >> $JOBNAME.com
echo "%NoSave" >> $JOBNAME.com
echo "%chk=./$JOBNAME.chk" > $JOBNAME.com
echo "%mem=$MEM" >> $JOBNAME.com
echo "%nprocshared=$NUMPROC" >> $JOBNAME.com
#echo "# rb3lyp/$BASISSETG output=wfn" >> $JOBNAME.com
if [ "$METHOD" = "rks" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "# $ONLY_ONE blyp/$BASISSETG freq=noraman Charge nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "# $ONLY_ONE blyp/$BASISSETG freq=noraman nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
elif [ "$METHOD" = "uks" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "# $ONLY_ONE ublyp/$BASISSETG freq=noraman Charge nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "# $ONLY_ONE ublyp/$BASISSETG freq=noraman nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
elif [ "$METHOD" = "rhf" ]; then
if [ "$SCCHARGES" = "true" ]; then
echo "# $ONLY_ONE rhf/$BASISSETG freq=noraman Charge nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "# $ONLY_ONE rhf/$BASISSETG freq=noraman nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
else
if [ "$SCCHARGES" = "true" ]; then
echo "# $ONLY_ONE $METHOD/$BASISSETG freq=noraman Charge nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
else
echo "# $ONLY_ONE $METHOD/$BASISSETG freq=noraman nosymm output=wfn 6D 10F Fchk $INT $GAUSSEMPDISPKEY" >> $JOBNAME.com
fi
fi
echo "" >> $JOBNAME.com
echo "$JOBNAME" >> $JOBNAME.com
echo "" >> $JOBNAME.com
echo "$CHARGE $MULTIPLICITY" >> $JOBNAME.com
awk 'NR>2' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.xyz >> $JOBNAME.com
if [ "$SCCHARGES" = "true" ]; then
if [ ! -f gaussian-point-charges ]; then
echo "" > gaussian-point-charges
awk '/Cluster monopole charges and positions/{print p; f=1} {p=$0} /------------------------------------------------------------------------/{c=1} f; c--==0{f=0}' stdout >> gaussian-point-charges
fi
echo "" >> $JOBNAME.com
awk '{a[NR]=$0}{b=12}/^------------------------------------------------------------------------/{c=NR}END{for(d=b;d<=c-1;++d)print a[d]}' gaussian-point-charges | awk '{printf "%s\t %s\t %s\t %s\t \n", $1, $2, $3, $4 }' >> $JOBNAME.com
echo "" >> $JOBNAME.com
# rm gaussian-point-charges
fi
if [ "$GAUSGEN" = "true" ]; then
cat basis_gen.txt >> $JOBNAME.com
echo "" >> $JOBNAME.com
fi
echo "./$JOBNAME.wfn" >> $JOBNAME.com
echo "" >> $JOBNAME.com
echo "Running Gaussian, cycle number $I"
$SCFCALC_BIN $JOBNAME.com
echo "Gaussian cycle number $I ended"
if ! grep -q 'Normal termination of Gaussian' "$JOBNAME.log"; then
echo "ERROR: Gaussian job finished with error, please check the $I.th log file for more details" | tee -a $JOBNAME.lst
unset MAIN_DIALOG
exit 0
fi
echo "Generation fcheck file for Gaussian cycle number $I"
mkdir $I.$SCFCALCPROG.cycle.$JOBNAME
cp $JOBNAME.com $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.com
cp Test.FChk $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.fchk
cp $JOBNAME.log $I.$SCFCALCPROG.cycle.$JOBNAME/$I.$JOBNAME.log
}
CHECK_ENERGY(){
if [[ "$SCFCALCPROG" == "Gaussian" || "$SCFCALCPROG" == "optgaussian" ]]; then
ENERGIA2=$(sed -n '/Population analysis/,/Writing a WFN file/p' $JOBNAME.log | sed 's/^ //' | sed ':begin;$!N;s/\n//;tbegin' | awk '!f && sub(/.*HF=/,""){f=1} f' | awk -F '\' '{ print $1}' | tr -d '\r')
RMSD2=$(sed -n '/Population analysis/,/Writing a WFN file/p' $JOBNAME.log | sed 's/^ //' | sed ':begin;$!N;s/\n//;tbegin' | awk '!f && sub(/.*RMSD=/,""){f=1} f' | awk -F '\' '{ print $1}' | tr -d '\r')
# ENERGIA2=$(sed 's/^ //' $JOBNAME.log | sed 'N;s/\n//' | sed 'N;s/\n//' | sed 'N;s/\n//' | sed 'N;s/\n//' | sed -n '/HF=/{N;p;}' | sed 's/^.*HF=//' | sed 'N;s/\n//' | sed '2d' | sed 's/RMSD=//g' | awk -F '\' '{ print $1}' | tr -d '\r')
# RMSD2=$(sed 's/^ //' $JOBNAME.log | sed 'N;s/\n//' | sed 'N;s/\n//' | sed 'N;s/\n//'| sed -n '/RMSD=/{N;p;}' | sed 's/^.*RMSD=//' | sed 'N;s/\n//' | sed '2d' | sed 's/RMSD=//g' | awk -F '\' '{ print $1}'| tr -d '\r')
echo "Gaussian cycle number $I, final energy is: $ENERGIA2, RMSD is: $RMSD2 "
elif [ "$SCFCALCPROG" = "Orca" ]; then
ENERGIA2=$(sed -n '/Total Energy :/p' $JOBNAME.log | awk '{print $4}' | tr -d '\r')
RMSD2=$(sed -n '/Last RMS-Density change/p' $JOBNAME.log | awk '{print $5}' | tr -d '\r')
echo "Orca cycle number $I, final energy is: $ENERGIA2, RMSD is: $RMSD2 "
fi
DE=$(awk "BEGIN {print $ENERGIA2 - $ENERGIA}")
DE=$(printf '%.12f' $DE)
echo -e " $J\t$(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print $1}' )\t$INITIALCHI\t$(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print $2"\t"$3"\t"$4"\t"}') $MAXSHIFT\t$MAXSHIFTATOM $MAXSHIFTPARAM $(awk '{a[NR]=$0}/^Rigid-atom fit results/{b=NR}END {print a[b-4]}' stdout | awk '{print " "$9" \t"$10 }' ) $ENERGIA2 $RMSD2 \t$DE" >> $JOBNAME.lst
ENERGIA=$ENERGIA2
RMSD=$RMSD2
echo "Delta E (cycle $I - $[ I - 1 ]): $DE "
}
CHECKCONV(){
FINALPARAMESD=$(awk '{a[NR]=$0}/^Begin rigid-atom fit/{b=NR}END {print a[b+10]}' stdout | awk '{print $5}')
}
GET_RESIDUALS(){
TONTO_HEADER
DEFINE_JOB_NAME
if [ "$SCFCALCPROG" = "elmodb" ]; then
READ_ELMO_FCHK
fi
if [ "$SCFCALCPROG" = "Gaussian" ]; then
READ_GAUSSIAN_FCHK
elif [ "$SCFCALCPROG" = "Orca" ]; then
READ_ORCA_FCHK
else
DEFINE_JOB_NAME
fi
echo "" >> stdin
PROCESS_CIF
DEFINE_JOB_NAME
if [ "$SCFCALCPROG" = "Tonto" ]; then
TONTO_BASIS_SET
fi
if [ "$DISP" = "yes" ]; then
DISPERSION_COEF
fi
CHARGE_MULT
CRYSTAL_BLOCK
echo " scfdata= {" >> stdin
echo " initial_MOs= restricted" >> stdin #Only for new tonto may 2020
# echo " initial_MOs= existing" >> stdin
if [[ "$METHOD" != "rks" && "$METHOD" != "rhf" && "$METHOD" != "uhf" && "$METHOD" != "uks" ]]; then
echo " kind= rks " >> stdin
echo " dft_exchange_functional= b3lypgx" >> stdin
echo " dft_correlation_functional= b3lypgc" >> stdin
else
echo " kind= $METHOD" >> stdin
fi
echo " use_SC_cluster_charges= $SCCHARGES" >> stdin
if [ "$SCCHARGES" == "true" ]; then
echo " cluster_radius= $SCCRADIUS angstrom" >> stdin
echo " defragment= $DEFRAG" >> stdin
echo " save_cluster_charges= true" >> stdin
fi
echo " convergence= 0.001" >> stdin
echo " diis= { convergence_tolerance= 0.0002 }" >> stdin
echo " }" >> stdin
echo "" >> stdin
echo " make_scf_density_matrix" >> stdin
echo " make_structure_factors" >> stdin
echo "" >> stdin
echo " put_minmax_residual_density" >> stdin
echo "" >> stdin
# echo " plot_grid= { " >> stdin
# echo "" >> stdin
# echo " kind= residual_density_map" >> stdin
# echo " use_unit_cell_as_bbox" >> stdin
# echo " desired_separation= 0.1 angstrom" >> stdin
# echo " plot_format= cell.cube" >> stdin
# echo " plot_units= angstrom^-3" >> stdin
# echo "" >> stdin
# echo " }" >> stdin
# echo "" >> stdin
# echo " plot" >> stdin
echo " put_fitting_plots" >> stdin
# echo " normal_mode_analysis" >> stdin
echo "" >> stdin
echo "}" >> stdin
echo "Calculating residual density at final geometry"
J=$[ $J + 1 ]
if [[ "$NUMPROC" != "1" ]]; then
mpirun -n $NUMPROC $TONTO
else
$TONTO
fi
mkdir $J.tonto_cycle.$JOBNAME
cp stdin $J.tonto_cycle.$JOBNAME/$J.stdin
cp stdout $J.tonto_cycle.$JOBNAME/$J.stdout
cp $JOBNAME'.cartesian.cif2' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.cartesian.cif2
cp $JOBNAME'.archive.cif' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.cif
cp $JOBNAME'.archive.fcf' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fcf
cp $JOBNAME'.archive.fco' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.archive.fco
cp $JOBNAME'.residual_density_map,cell.cube' $J.tonto_cycle.$JOBNAME/$J.$JOBNAME.residual_density_map,cell.cube
}
XCW_SCF_BLOCK(){
echo " ! More accuracy" >> stdin
echo " output_style_options= {" >> stdin
echo " real_precision= 8" >> stdin
echo " real_width= 20" >> stdin
echo " }" >> stdin
echo " " >> stdin
SCF_BLOCK_PROM_TONTO