-
Notifications
You must be signed in to change notification settings - Fork 0
/
omxtool
4184 lines (4172 loc) · 145 KB
/
omxtool
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/sh
#@(#) OMXTool Ver. beta-2 - graphical utility tool for OpenMX.
#@(#) Copyright (C), 2015-2017, Naoya Yamaguchi.
#@(#) This software includes the work that is distributed
#@(#) in version 3 of the GPL (GPLv3).
#@(#)
#@(#) Log:
#@(#) 2015/07/10 Ver. alpha-1 Written by Naoya Yamaguchi.
#@(#) 2015/07/13 Ver. alpha-2 Written by Naoya Yamaguchi.
#@(#) 2015/07/15 Ver. alpha-3 Written by Naoya Yamaguchi.
#@(#) 2015/07/16 Ver. alpha-4 Written by Naoya Yamaguchi.
#@(#) 2015/08/24 Ver. alpha-5 Written by Naoya Yamaguchi.
#@(#) 2015/11/12 Ver. beta-1 Written by Naoya Yamaguchi.
#@(#) 2016/03/17 Ver. alpha-6 Written by Naoya Yamaguchi.
#@(#) 2016/06/11 Ver. 1.0 Released by Naoya Yamaguchi.
#@(#) 2016/08/19 Ver. 1.1 Released by Naoya Yamaguchi.
#@(#) 2016/09/23 Ver. 1.2 Released by Naoya Yamaguchi.
#@(#) 2016/10/01 Ver. 1.2.1 Modified by Naoya Yamaguchi.
#@(#) 2016/10/04 Ver. 1.2.2 Modified by Naoya Yamaguchi.
#@(#) 2016/10/18 Ver. 1.2.3 Modified by Naoya Yamaguchi.
#@(#) 2016/12/09 Ver. 1.2.4 Modified by Naoya Yamaguchi.
#@(#) 2016/12/17 Ver. 1.3 Released by Naoya Yamaguchi.
#@(#) 2016/12/18 Ver. 1.3.1 Modified by Naoya Yamaguchi.
#@(#) 2017/01/02 Ver. 1.3.2 Modified by Naoya Yamaguchi.
#@(#) 2017/01/15 Ver. 1.4 Released by Naoya Yamaguchi.
#@(#) (renaming 'openmx.tcl' 'OMXTool.tcl')
#@(#) 2017/02/11 Ver. 1.4.1 Modified by Naoya Yamaguchi.
#@(#) 2017/02/13 Ver. 1.4.2 Modified by Naoya Yamaguchi.
#@(#) (renaming 'OMXTool.tcl' 'omxtool')
#@(#) 2017/03/04 Ver. 1.4.3 Modified by Naoya Yamaguchi.
#@(#) 2017/03/09 Ver. 1.5 Released by Naoya Yamaguchi.
#@(#) 2017/03/09 Ver. 1.5.1 Modified by Naoya Yamaguchi.
#@(#) 2017/03/13 Ver. 1.5.2 Modified by Naoya Yamaguchi.
#@(#) 2017/03/13 Ver. 1.5.3 Modified by Naoya Yamaguchi.
#@(#) 2017/03/13 Ver. 1.5.4 Modified by Naoya Yamaguchi.
#@(#) 2017/03/30 Ver. 1.5.5 Modified by Naoya Yamaguchi.
#@(#) 2017/06/18 Ver. 1.5.6 Modified by Naoya Yamaguchi.
#@(#) 2017/08/11 Ver. 1.5.7 Modified by Naoya Yamaguchi.
#@(#) 2017/08/20 Ver. 1.5.8 Modified by Naoya Yamaguchi.
#@(#) 2017/09/26 Ver. 1.5.9 Modified by Naoya Yamaguchi.
#@(#) 2017/11/18 Ver. beta-2 Written by Naoya Yamaguchi.
#@(#)
#@(#) Usage:
#@(#) ./omxtool (&)
#@(#)
#@(#) Description:
#@(#) This script provides graphical utilities for OpenMX.
#@(#)
#\
case `ps -o stat= -p $$` in
#\
*+*) ;;
#\
*) exec wish "$0" "wish" ${2+"$@"};;
#\
esac
#\
if which expect > /dev/null 2>&1 && which screen > /dev/null 2>&1
#\
then
#\
exec expect "$0" "expect" ${2+"$@"}
#\
fi
#\
exec wish "$0" "wish" ${2+"$@"}
package require Tk
set tclsh [lindex $argv 0]
if {$tclsh eq "expect"} {
package require Expect
}
proc clear {} {
puts "\x1b\[2J"
}
proc what {fname} {
set fp [open $fname r]
set mark @(#)
while {[gets $fp data]>=0} {
set first 0
set last1 0
set last2 0
set length [string length $data]
while {$first!=-1} {
set first [string first $mark $data $first]
if {$last1!=-1} {
set last1 [string first \" $data $first]
}
if {$last2!=-1} {
set last2 [string first > $data $first]
}
if {$last1==-1} {
set last1 $length
}
if {$last2==-1} {
set last2 $length
}
set last [expr $last1<$last2 ? $last1 : $last2]
if {$first!=-1} {
append buffer "\n[string range $data [expr $first+4] [expr $last-1]]"
}
if {$first!=-1} {
set first [expr $last+1]
}
}
}
return $buffer
}
proc quit {} {
global tclsh
if {$tclsh eq "expect"} {
clear
}
exit
}
proc trimControl {arg} {
if {[string is graph -failindex pos $arg]} {
return $arg
} else {
return [string range $arg 0 [expr {$pos-1}]]
}
}
proc tildeSlash2Home {path} {
global env
if {[string first ~/ $path] == 0} {
set path $env(HOME)/[string range $path 2 end]
}
return $path
}
proc getpage {keyword} {
scan $keyword {%[^.].%[^.]} p1 p2
switch -nocase $p1 {
System -
DATA -
level {
return System
}
Species -
Definition {
return Species
}
Atoms {
if {[string equal -nocase $p2 Cont]} {
return OrbitalOpt
} else {
return Atoms
}
}
scf {
if {[string equal -nocase $p2 restart]} {
return Other
} else {
return SCF
}
}
ESM -
Hubbard {
return SCF
}
1DFFT {
return 1DFFT
}
orbitalOpt -
CntOrb -
Num {
if {[string equal -nocase $p2 CntOrb]} {
return OrbitalOpt
} else {
return MO
}
}
orderN {
return OrderN
}
MD -
NH {
return MD
}
Band {
return Band
}
MO {
return MO
}
Dos {
return DOS
}
HS {
return Other
}
Voronoi {
return Voronoi
}
}
}
proc PAOVPS {species} {
switch $species {
H {return "H6.0-s2p1 H_PBE13 1.0"}
He {return "He8.0-s2p1 He_PBE13 2.0"}
Li {return "Li8.0-s3p2 Li_PBE13 3.0"}
Be {return "Be7.0-s3p2 Be_PBE13 2.0"}
B {return "B7.0-s2p2d1 B_PBE13 3.0"}
C {return "C6.0-s2p2d1 C_PBE13 4.0"}
N {return "N6.0-s2p2d1 N_PBE13 5.0"}
O {return "O6.0-s2p2d1 O_PBE13 6.0"}
F {return "F6.0-s2p2d1 F_PBE13 7.0"}
Ne {return "Ne9.0-s2p2d1 Ne_PBE13 8.0"}
Na {return "Na9.0-s3p2d1 Na_PBE13 9.0"}
Mg {return "Mg9.0-s3p2d2 Mg_PBE13 8.0"}
Al {return "Al7.0-s2p2d1 Al_PBE13 3.0"}
Si {return "Si7.0-s2p2d1 Si_PBE13 4.0"}
P {return "P7.0-s2p2d1f1 P_PBE13 5.0"}
S {return "S7.0-s2p2d1f1 S_PBE13 6.0"}
Cl {return "Cl7.0-s2p2d1f1 Cl_PBE13 7.0"}
Ar {return "Ar9.0-s2p2d1f1 Ar_PBE13 8.0"}
K {return "K10.0-s3p2d1 K_PBE13 9.0"}
Ca {return "Ca9.0-s3p2d1 Ca_PBE13 10.0"}
Sc {return "Sc9.0-s3p2d1 Sc_PBE13 11.0"}
Ti {return "Ti7.0-s3p2d1 Ti_PBE13 12.0"}
V {return "V6.0-s3p2d1 V_PBE13 13.0"}
Cr {return "Cr6.0-s3p2d1 Cr_PBE13 14.0"}
Mn {return "Mn6.0-s3p2d1 Mn_PBE13 15.0"}
Fe {return "Fe6.0H-s3p2d1 Fe_PBE13H 16.0"}
Co {return "Co6.0H-s3p2d1 Co_PBE13H 17.0"}
Ni {return "Ni6.0H-s3p2d1 Ni_PBE13H 18.0"}
Cu {return "Cu6.0H-s3p2d1 Cu_PBE13H 19.0"}
Zn {return "Zn6.0H-s3p2d1 Zn_PBE13H 20.0"}
Ga {return "Ga7.0-s3p2d2 Ga_PBE13 13.0"}
Ge {return "Ge7.0-s3p2d2 Ge_PBE13 4.0"}
As {return "As7.0-s3p2d2 As_PBE13 15.0"}
Se {return "Se7.0-s3p2d2 Se_PBE13 6.0"}
Br {return "Br7.0-s3p2d2 Br_PBE13 7.0"}
Kr {return "Kr10.0-s3p2d2 Kr_PBE13 8.0"}
Rb {return "Rb11.0-s3p2d2 Rb_PBE13 9.0"}
Sr {return "Sr10.0-s3p2d2 Sr_PBE13 10.0"}
Y {return "Y10.0-s3p2d2 Y_PBE13 11.0"}
Zr {return "Zr7.0-s3p2d2 Zr_PBE13 12.0"}
Nb {return "Nb7.0-s3p2d2 Nb_PBE13 13.0"}
Mo {return "Mo7.0-s3p2d2 Mo_PBE13 14.0"}
Tc {return "Tc7.0-s3p2d2 Tc_PBE13 15.0"}
Ru {return "Ru7.0-s3p2d2 Ru_PBE13 14.0"}
Rh {return "Rh7.0-s3p2d2 Rh_PBE13 15.0"}
Pd {return "Pd7.0-s3p2d2 Pd_PBE13 16.0"}
Ag {return "Ag7.0-s3p2d2 Ag_PBE13 17.0"}
Cd {return "Cd7.0-s3p2d2 Cd_PBE13 12.0"}
In {return "In7.0-s3p2d2 In_PBE13 13.0"}
Sn {return "Sn7.0-s3p2d2 Sn_PBE13 14.0"}
Sb {return "Sb7.0-s3p2d2 Sb_PBE13 15.0"}
Te {return "Te7.0-s3p2d2f1 Te_PBE13 16.0"}
I {return "I7.0-s3p2d2f1 I_PBE13 7.0"}
Xe {return "Xe11.0-s3p2d2 Xe_PBE13 8.0"}
Cs {return "Cs12.0-s3p2d2 Cs_PBE13 9.0"}
Ba {return "Ba10.0-s3p2d2 Ba_PBE13 10.0"}
La {return "La8.0-s3p2d2f1 La_PBE13 11.0"}
Ce {return "Ce8.0-s3p2d2f1 Ce_PBE13 12.0"}
Pr {return "Pr8.0-s3p2d2f1 Pr_PBE13 13.0"}
Nd {return "Nd8.0-s3p2d2f1 Nd_PBE13 14.0"}
Pm {return "Pm8.0-s3p2d2f1 Pm_PBE13 15.0"}
Sm {return "Sm8.0-s3p2d2f1 Sm_PBE13 16.0"}
Eu {return "Eu8.0-s3p2d2f1 Eu_PBE13 17.0"}
Gd {return "Gd8.0-s3p2d2f1 Gd_PBE13 18.0"}
Tb {return "Tb8.0-s3p2d2f1 Tb_PBE13 19.0"}
Dy {return "Dy8.0-s3p2d2f1 Dy_PBE13 20.0"}
Ho {return "Ho8.0-s3p2d2f1 Ho_PBE13 21.0"}
Er {return "Er8.0-s3p2d2f1 Er_PBE13 22.0"}
Tm {return "Tm8.0-s3p2d2f1 Tm_PBE13 23.0"}
Yb {return "Yb8.0-s3p2d2f1 Yb_PBE13 24.0"}
Lu {return "Lu8.0-s3p2d2f1 Lu_PBE13 11.0"}
Hf {return "Hf9.0-s3p2d2 Hf_PBE13 12.0"}
Ta {return "Ta7.0-s3p2d2 Ta_PBE13 13.0"}
W {return "W7.0-s3p2d2 W_PBE13 12.0"}
Re {return "Re7.0-s3p2d2 Re_PBE13 15.0"}
Os {return "Os7.0-s3p2d2 Os_PBE13 14.0"}
Ir {return "Ir7.0-s3p2d2 Ir_PBE13 15.0"}
Pt {return "Pt7.0-s3p2d2 Pt_PBE13 16.0"}
Au {return "Au7.0-s3p2d2 Au_PBE13 17.0"}
Hg {return "Hg8.0-s3p2d2f1 Hg_PBE13 18.0"}
Tl {return "Tl8.0-s3p2d2f1 Tl_PBE13 19.0"}
Pb {return "Pb8.0-s3p2d2f1 Pb_PBE13 14.0"}
Bi {return "Bi8.0-s3p2d2f1 Bi_PBE13 15.0"}
84 {return "undefined 0.0"}
85 {return "undefined 0.0"}
86 {return "undefined 0.0"}
87 {return "undefined 0.0"}
88 {return "undefined 0.0"}
89 {return "undefined 0.0"}
90 {return "undefined 0.0"}
91 {return "undefined 0.0"}
92 {return "undefined 0.0"}
93 {return "undefined 0.0"}
94 {return "undefined 0.0"}
95 {return "undefined 0.0"}
96 {return "undefined 0.0"}
97 {return "undefined 0.0"}
98 {return "undefined 0.0"}
99 {return "undefined 0.0"}
100 {return "undefined 0.0"}
101 {return "undefined 0.0"}
102 {return "undefined 0.0"}
103 {return "undefined 0.0"}
}
}
proc speciesColor {species} {
switch $species {
H {return #FAF0E6}
He {return #F0E68C}
Li {return #EE82EE}
Be {return #DB7093}
B {return #4B0082}
C {return #778899}
N {return #0000FF}
O {return #FC0000}
F {return #00FF00}
Ne {return #FF00FF}
Na {return #48D1CC}
Mg {return #8B008B}
Al {return #D8BFD8}
Si {return #00CED1}
P {return #DC143C}
S {return #FFFF00}
Cl {return #66CDAA}
Ar {return #FF69B4}
K {return #ADD8E6}
Ca {return #2F4F4F}
Sc {return #483D8B}
Ti {return #8B708B}
V {return #008080}
Cr {return #B22222}
Mn {return #800080}
Fe {return #BC8F8F}
Co {return #40E0D0}
Ni {return #66CDAA}
Cu {return #D2691E}
Zn {return #BC8F8F}
Ga {return #F08080}
Ge {return #E6E6FA}
As {return #DAA520}
Se {return #c4a3bf}
Br {return #b44c97}
Kr {return #00a497}
Rb {return #b77b57}
Sr {return #006e54}
Y {return #d69090}
Zr {return #634950}
Nb {return #44617b}
Mo {return #E9967A}
Tc {return #FF7F50}
Ru {return #FFA07A}
Rh {return #A0522D}
Pd {return #FFE4C4}
Ag {return #C0C0C0}
Cd {return #BDB76B}
In {return #6B8E23}
Sn {return #556B2F}
Sb {return #ADFF2F}
Te {return #008000}
I {return #40E0D0}
Xe {return #7FFFD4}
Cs {return #008080}
Ba {return #00FFFF}
La {return #999900}
Ce {return #4682B4}
Pr {return #4169E1}
Nd {return #7B68EE}
Pm {return #8A2BE2}
Sm {return #BA55D3}
Eu {return #800080}
Gd {return #FF1493}
Tb {return #c89932}
Dy {return #5c9291}
Ho {return #9d5b8b}
Er {return #eeeaec}
Tm {return #e29676}
Yb {return #5f6527}
Lu {return #c70067}
Hf {return #e9dacb}
Ta {return #28ff93}
W {return #0582ff}
Re {return #baff75}
Os {return #43676b}
Ir {return #47585c}
Pt {return #c4a3bf}
Au {return #FFD700}
Hg {return #dcd6d9}
Tl {return #bf794e}
Pb {return #f5b1aa}
Bi {return #cd5e3c}
Po {return #95859c}
At {return #71686c}
Rn {return #203744}
Fr {return #ec6d71}
Ra {return #b55233}
Ac {return #a19361}
Th {return #cc3399}
Pa {return #3399cc}
U {return #339966}
Np {return #ffff00}
Pu {return #ccff33}
Am {return #cc3300}
Cm {return #cc6600}
Bk {return #ff0033}
Cf {return #660066}
Es {return #006666}
Fm {return #ffcc00}
Md {return #33cccc}
No {return #99ffff}
Lr {return #ff6666}
}
}
proc speciesRadius {species} {
switch $species {
H {return "0.53 0.25"}
He {return "0.31 0.31"}
Li {return "1.67 1.45"}
Be {return "1.12 1.05"}
B {return "0.87 0.85"}
C {return "0.67 0.70"}
N {return "0.56 0.65"}
O {return "0.48 0.60"}
F {return "0.42 0.50"}
Ne {return "0.38 0.38"}
Na {return "1.90 1.80"}
Mg {return "1.45 1.50"}
Al {return "1.18 1.25"}
Si {return "1.11 1.10"}
P {return "0.98 1.00"}
S {return "0.88 1.00"}
Cl {return "0.79 1.00"}
Ar {return "0.71 0.71"}
K {return "2.43 2.20"}
Ca {return "1.94 1.80"}
Sc {return "1.84 1.60"}
Ti {return "1.76 1.40"}
V {return "1.71 1.35"}
Cr {return "1.66 1.40"}
Mn {return "1.61 1.40"}
Fe {return "1.56 1.40"}
Co {return "1.52 1.35"}
Ni {return "1.49 1.35"}
Cu {return "1.45 1.35"}
Zn {return "1.42 1.35"}
Ga {return "1.36 1.30"}
Ge {return "1.25 1.25"}
As {return "1.14 1.15"}
Se {return "1.03 1.15"}
Br {return "0.94 1.15"}
Kr {return "0.88 0.88"}
Rb {return "2.65 2.35"}
Sr {return "2.19 2.00"}
Y {return "2.12 1.85"}
Zr {return "2.06 1.55"}
Nb {return "1.98 1.45"}
Mo {return "1.90 1.45"}
Tc {return "1.83 1.35"}
Ru {return "1.78 1.30"}
Rh {return "1.73 1.35"}
Pd {return "1.69 1.40"}
Ag {return "1.65 1.60"}
Cd {return "1.61 1.55"}
In {return "1.56 1.55"}
Sn {return "1.45 1.45"}
Sb {return "1.33 1.45"}
Te {return "1.23 1.40"}
I {return "1.15 1.40"}
Xe {return "1.08 1.08"}
Cs {return "2.98 2.60"}
Ba {return "2.53 2.15"}
La {return "1.95 1.95"}
Ce {return "1.85 1.85"}
Pr {return "2.47 1.85"}
Nd {return "2.06 1.85"}
Pm {return "2.05 1.85"}
Sm {return "2.38 1.85"}
Eu {return "2.31 1.85"}
Gd {return "2.33 1.80"}
Tb {return "2.25 1.75"}
Dy {return "2.28 1.75"}
Ho {return "2.26 1.75"}
Er {return "2.26 1.75"}
Tm {return "2.22 1.75"}
Yb {return "2.22 1.75"}
Lu {return "2.17 1.75"}
Hf {return "2.08 1.55"}
Ta {return "2.00 1.45"}
W {return "1.93 1.35"}
Re {return "1.88 1.35"}
Os {return "1.85 1.30"}
Ir {return "1.80 1.35"}
Pt {return "1.77 1.35"}
Au {return "1.74 1.35"}
Hg {return "1.71 1.50"}
Tl {return "1.56 1.90"}
Pb {return "1.54 1.80"}
Bi {return "1.43 1.60"}
Po {return "1.35 1.90"}
At {return "1.27 1.27"}
Rn {return "1.20 1.20"}
default {return "1.0 1.0"}
}
}
proc convpath {path} {
set pathtype relative
if {$pathtype == "relative"} {
set target [file split $path]
set workdir [file split [pwd]]
foreach telement $target welement $workdir {
if {$telement != $welement} {
regsub .* $welement .. welement
lappend split $telement
set split [linsert $split 0 $welement]
}
}
if {![info exists split]} {
set split ./
}
set split [eval concat $split]
return [join $split /]
}
return $path
}
proc getpath {value} {
set path [tk_chooseDirectory -initialdir $::WD -title "Select Directory"]
if {$path != ""} {
return [convpath $path]
}
return $value
}
proc descendant {parent} {
while 1 {
set children [winfo children $parent]
set numChildren [llength $children]
if {$numChildren} {
set parent [lindex $children 0]
} else {
return $parent
break
}
}
}
proc import_cif {argv} {
set fp [open [lindex $argv 0] r]
set is_there_cif_tag no
set loop_mode off
set loop_list ""
set loop2_mode off
while {[gets $fp data]>=0} {
if {![string length $data]} {
set loop_list ""
set loop_mode off
continue
}
if {[string equal _ [string index [lindex $data 0] 0]]} {
if {$loop2_mode} {
set loop_list ""
set loop_mode off
set loop2_mode off
}
set is_there_cif_tag yes
set cif_tag [lindex $data 0]
}
regsub {'.*'} $data {{&}} data
if {[string equal loop_ [lindex $data 0]]} {
if {$loop2_mode} {
set loop_list ""
set loop_mode off
set loop2_mode off
}
set loop_mode on
set loop_list ""
continue
}
if {$is_there_cif_tag} {
global $cif_tag
if {!$loop_mode} {
set $cif_tag [lrange $data 1 end]
set loop_list ""
} else {
set $cif_tag ""
lappend loop_list $cif_tag
}
set is_there_cif_tag no
} elseif {$loop_mode} {
foreach cif_tag $loop_list cif_val $data {
lappend $cif_tag $cif_val
}
set loop2_mode on
}
}
}
proc compareCmd {a b} {
set ax [lindex $a 1]
set ay [lindex $a 2]
set az [lindex $a 3]
set bx [lindex $b 1]
set by [lindex $b 2]
set bz [lindex $b 3]
set dx [expr $ax-$bx]
set dy [expr $ay-$by]
set dz [expr $az-$bz]
if {$dx*$dx+$dy*$dy+$dz*$dz<=1e-6} {
return 0
} elseif {$az>=$bz} {
return 1
} else {
return -1
}
}
proc cif2dat {argv} {
import_cif $argv
set deg2rad [expr {atan2(1, 1)/45}]
set alpha [expr {$::_cell_angle_alpha*$deg2rad}]
set beta [expr {$::_cell_angle_beta*$deg2rad}]
set gamma [expr {$::_cell_angle_gamma*$deg2rad}]
set ax $::_cell_length_a
set bx [expr {$::_cell_length_b*cos($gamma)}]
set by [expr {$::_cell_length_b*sin($gamma)}]
set cx [expr {$::_cell_length_c*cos($beta)}]
set cy [expr {($::_cell_length_b*$::_cell_length_c*cos($alpha)-$bx*$cx)/$by}]
set cz [expr {sqrt($::_cell_length_c*$::_cell_length_c-$cx*$cx-$cy*$cy)}]
set ::Atoms.UnitVectors ""
lappend ::Atoms.UnitVectors [format "%s %11.6f %11.6f %11.6f" a $ax 0 0]
lappend ::Atoms.UnitVectors [format "%s %11.6f %11.6f %11.6f" b $bx $by 0]
lappend ::Atoms.UnitVectors [format "%s %11.6f %11.6f %11.6f" c $cx $cy $cz]
foreach atom $::_atom_site_type_symbol x $::_atom_site_fract_x y $::_atom_site_fract_y z $::_atom_site_fract_z {
foreach symm $::_symmetry_equiv_pos_as_xyz {
regsub '(.*)' $symm {\1} symm
set symm [split [string trim [string map {x $x y $y z $z / ./ " " ""} $symm]] ,]
foreach "xpos ypos zpos" $symm {
set xt [expr $xpos]
set yt [expr $ypos]
set zt [expr $zpos]
set xt [expr {$xt-floor($xt)}]
set yt [expr {$yt-floor($yt)}]
set zt [expr {$zt-floor($zt)}]
lappend ::Atoms.SpeciesAndCoordinates [format "%4s %11.6f %11.6f %11.6f" $atom $xt $yt $zt]
}
}
}
set ::Atoms.SpeciesAndCoordinates [lsort -index 1 [lsort -unique -command compareCmd ${::Atoms.SpeciesAndCoordinates}]]
}
proc gradient {image relief light source R G B} {
set sunken [string match sun* $relief]
set light [expr {$light*96+32}]
set source [expr {0.5+$source/2.0}]
set D [image width $image]
set r [expr {$D/2}]
set r2 [expr {$r*$r}]
for {set y 0} {$y<$D} {incr y} {
set Dy [expr {$y-$r}]
set Dy2 [expr {$Dy*$Dy}]
set dy [expr {$y*$source-$r}]
set dy2 [expr {$dy * $dy}]
for {set x 0} {$x<$D} {incr x} {
set Dx [expr {$x-$r}]
set Dx2 [expr {$Dx*$Dx}]
set Dxy [expr {$Dx2+$Dy2}]
if {$Dxy<=$r2} {
set dx [expr {$x*$source-$r}]
set dx2 [expr {$dx*$dx}]
set dz2 [expr {$r2-$dx2-$dy2}]
set color [expr {int(127+$light*$dz2/$r2)}]
if {$sunken} {
set color [expr {int(127+$light*2-$color)}]
}
set Rtmp [expr {int($color*$R/255)}]
set Gtmp [expr {int($color*$G/255)}]
set Btmp [expr {int($color*$B/255)}]
set afterglow 0
if {$Rtmp>255} {
incr afterglow [expr {$Rtmp-255}]
set Rtmp 255
}
if {$Gtmp>255} {
incr afterglow [expr {$Gtmp-255}]
set Gtmp 255
}
if {$Btmp>255} {
incr afterglow [expr {$Btmp-255}]
set Btmp 255
}
while {$afterglow>0 && ($Rtmp!=255 || $Gtmp!=255 || $Btmp!=255)} {
set afterglow [expr {$afterglow/3}]
incr Rtmp $afterglow
incr Gtmp $afterglow
incr Btmp $afterglow
set afterglow 0
if {$Rtmp>255} {
incr afterglow [expr {$Rtmp-255}]
set Rtmp 255
}
if {$Gtmp>255} {
incr afterglow [expr {$Gtmp-255}]
set Gtmp 255
}
if {$Btmp>255} {
incr afterglow [expr {$Btmp-255}]
set Btmp 255
}
}
set color [format "#%02x%02x%02x" $Rtmp $Gtmp $Btmp]
$image put $color -to [expr {$D-$x}] [expr {$D-$y}]
}
}
}
}
proc drawXyzv {length WH WHHalf imageSize thetaY thetaX} {
set atomList ""
set xvSum 0
set yvSum 0
set i 0
foreach item [$::Atoms_SpeciesAndCoordinates.tv children ""] {
incr i
set asac [$::Atoms_SpeciesAndCoordinates.tv set $item]
# [format "%4d %s %11.6f %11.6f %11.6f %g %g" [lindex $asac 1] [lindex $asac 3] [lindex $asac 5] [lindex $asac 7] [lindex $asac 9] [lindex $asac 11] [lindex $asac 13]]
set xv [expr {[lindex ${::Atoms.UnitVectors} 0 1]*[lindex $asac 5]+[lindex ${::Atoms.UnitVectors} 1 1]*[lindex $asac 7]+[lindex ${::Atoms.UnitVectors} 2 1]*[lindex $asac 9]}]
set yv [expr {[lindex ${::Atoms.UnitVectors} 0 2]*[lindex $asac 5]+[lindex ${::Atoms.UnitVectors} 1 2]*[lindex $asac 7]+[lindex ${::Atoms.UnitVectors} 2 2]*[lindex $asac 9]}]
set zv [expr {[lindex ${::Atoms.UnitVectors} 0 3]*[lindex $asac 5]+[lindex ${::Atoms.UnitVectors} 1 3]*[lindex $asac 7]+[lindex ${::Atoms.UnitVectors} 2 3]*[lindex $asac 9]}]
set xv2 [expr {$xv*cos($thetaY)-$zv*sin($thetaY)}]
set zv2 [expr {$xv*sin($thetaY)+$zv*cos($thetaY)}]
set xv $xv2
set zv $zv2
set yv2 [expr {$yv*cos($thetaX)+$zv*sin($thetaX)}]
set zv2 [expr {-$yv*sin($thetaX)+$zv*cos($thetaX)}]
set yv $yv2
set zv $zv2
if {$::perspective} {
set xv [expr {$xv/(1+$zv/100.0)/$length*$WH}]
} else {
set xv [expr {$xv/$length*$WH}]
}
set xvSum [expr {$xvSum+$xv}]
if {$::perspective} {
set yv [expr {$yv/(1+$zv/100.0)/$length*$WH}]
} else {
set yv [expr {$yv/$length*$WH}]
}
set yvSum [expr {$yvSum+$yv}]
lappend atomList "[lindex $asac 1] [lindex $asac 3] $xv $yv $zv"
}
set atomList [lsort -real -decreasing -index 4 $atomList]
foreach item $atomList {
set xv [expr {[lindex $item 2]-$xvSum/${::Atoms.Number}+$WHHalf}]
set yv [expr {[lindex $item 3]-$yvSum/${::Atoms.Number}+$WHHalf}]
image create photo atom[lindex $item 0] -width $imageSize -height $imageSize
image create photo tmpImage -width [expr {$imageSize*$::magnification}] -height [expr {$imageSize*$::magnification}]
tmpImage copy [lindex $item 1] -zoom $::magnification
atom[lindex $item 0] copy tmpImage -shrink -subsample [expr {int($length)}]
.tInput.tView.c create image $xv $yv -image atom[lindex $item 0] -anchor nw
}
}
proc input {} {
toplevel .tInput
ttk::notebook .tInput.nb
frame .tInput.fb
button .tInput.fb.bCreate -text Create -command {
set dst [tk_getSaveFile -initialfile [file tail $::rPath].dat -filetypes {{{OpenMX Input File} {*.dat}}} -title "Save As"]
if {$dst eq ""} {
return
}
set fp [open $dst w]
foreach keyword $::keywords {
if {$keyword eq "Definition.of.Atomic.Species"} {
puts $fp <Definition.of.Atomic.Species
foreach item [::$Definition_of_Atomic_Species.tv children ""] {
set doas [::$Definition_of_Atomic_Species.tv set $item]
puts $fp [format "%s %s %s" [lindex $doas 1] [lindex $doas 3] [lindex $doas 5]]
}
puts $fp Definition.of.Atomic.Species>
continue
}
if {$keyword eq "Atoms.SpeciesAndCoordinates"} {
puts $fp <Atoms.SpeciesAndCoordinates
foreach item [::$Atoms_SpeciesAndCoordinates.tv children ""] {
set asac [::$Atoms_SpeciesAndCoordinates.tv set $item]
puts $fp [format "%4d %s %11.6f %11.6f %11.6f %g %g" [lindex $asac 1] [lindex $asac 3] [lindex $asac 5] [lindex $asac 7] [lindex $asac 9] [lindex $asac 11] [lindex $asac 13]]
}
puts $fp Atoms.SpeciesAndCoordinates>
continue
}
if {$keyword eq "Atoms.UnitVectors"} {
puts $fp <Atoms.UnitVectors
foreach vector ${::Atoms.UnitVectors} {
puts $fp [format "%11.6f %11.6f %11.6f" [lindex $vector 1] [lindex $vector 2] [lindex $vector 3]]
}
puts $fp Atoms.UnitVectors>
continue
}
if {$keyword eq "Hubbard.U.values"} {
continue
}
if {$keyword eq "scf.Ngrid"} {
puts $fp "scf.Ngrid ${::scf.Ngrid(1)} ${::scf.Ngrid(2)} ${::scf.Ngrid(3)}"
continue
}
if {$keyword eq "scf.Kgrid"} {
puts $fp "scf.Kgrid ${::scf.Kgrid(1)} ${::scf.Kgrid(2)} ${::scf.Kgrid(3)}"
continue
}
if {$keyword eq "scf.Electric.Field"} {
puts $fp "scf.Electric.Field ${::scf.Electric.Field(1)} ${::scf.Electric.Field(2)} ${::scf.Electric.Field(3)}"
continue
}
eval puts $fp \"$keyword\ \$\{$keyword\}\"
}
close $fp
}
button .tInput.fb.bImport -text Import -command {
set path [tk_getOpenFile -initialdir $::WD -title "Import a CIF file" -filetypes {{{CIF (Crystallographic Information File)} {*.cif}}}]
if {$path ne ""} {
toplevel .tInput.tSC
grab set .tInput.tSC
entry .tInput.tSC.eX -textvariable SCX
entry .tInput.tSC.eY -textvariable SCY
entry .tInput.tSC.eZ -textvariable SCZ
set SCX 1
set SCY 1
set SCZ 1
button .tInput.tSC.bSubmit -text Submit -command {
destroy .tInput.tSC
set ::Atoms.SpeciesAndCoordinates ""
set speciesList ""
::$Atoms_SpeciesAndCoordinates.tv delete [::$Atoms_SpeciesAndCoordinates.tv children ""]
::$Definition_of_Atomic_Species.tv delete [::$Definition_of_Atomic_Species.tv children ""]
::$Atoms_UnitVectors.tv delete [::$Atoms_UnitVectors.tv children ""]
cif2dat $path
set ::Atoms.Number 0
foreach asac ${::Atoms.SpeciesAndCoordinates} {
set species [lindex $asac 0]
set x [lindex $asac 1]
set y [lindex $asac 2]
set z [lindex $asac 3]
set numEle [lindex [PAOVPS $species] 2]
set halfNumEle [expr {$numEle*0.5}]
lappend speciesList $species
for {set i 0} {$i<$SCX} {incr i} {
for {set j 0} {$j<$SCY} {incr j} {
for {set k 0} {$k<$SCZ} {incr k} {
incr ::Atoms.Number
::$Atoms_SpeciesAndCoordinates.tv insert "" end -values [format "%4d %s %s %s %s %s %s" ${::Atoms.Number} $species [expr {($x+$i)/$SCX}] [expr {($y+$j)/$SCY}] [expr {($z+$k)/$SCZ}] $halfNumEle $halfNumEle]
}
}
}
}
set speciesList [lsort -unique $speciesList]
set ::Species.Number [llength $speciesList]
foreach species $speciesList {
::$Definition_of_Atomic_Species.tv insert "" end -values "$species [lrange [PAOVPS $species] 0 1]"
}
::${Atoms_Number}.l2 configure -text ${::Atoms.Number}
::${Species_Number}.l2 configure -text ${::Species.Number}
set ::Atoms.SpeciesAndCoordinates.Unit FRAC
lset ::Atoms.UnitVectors 0 1 [expr {[lindex ${::Atoms.UnitVectors} 0 1]*$SCX}]
lset ::Atoms.UnitVectors 0 2 [expr {[lindex ${::Atoms.UnitVectors} 0 2]*$SCX}]
lset ::Atoms.UnitVectors 0 3 [expr {[lindex ${::Atoms.UnitVectors} 0 3]*$SCX}]
lset ::Atoms.UnitVectors 1 1 [expr {[lindex ${::Atoms.UnitVectors} 1 1]*$SCY}]
lset ::Atoms.UnitVectors 1 2 [expr {[lindex ${::Atoms.UnitVectors} 1 2]*$SCY}]
lset ::Atoms.UnitVectors 1 3 [expr {[lindex ${::Atoms.UnitVectors} 1 3]*$SCY}]
lset ::Atoms.UnitVectors 2 1 [expr {[lindex ${::Atoms.UnitVectors} 2 1]*$SCZ}]
lset ::Atoms.UnitVectors 2 2 [expr {[lindex ${::Atoms.UnitVectors} 2 2]*$SCZ}]
lset ::Atoms.UnitVectors 2 3 [expr {[lindex ${::Atoms.UnitVectors} 2 3]*$SCZ}]
foreach vector ${::Atoms.UnitVectors} {
::$Atoms_UnitVectors.tv insert "" end -values $vector
}
set ::rPath [file rootname $path]
set ::System.Name [file tail $::rPath]
}
pack .tInput.tSC.eX .tInput.tSC.eY .tInput.tSC.eZ .tInput.tSC.bSubmit -side left
}
}
button .tInput.fb.bCheck -text Check -command {
}
button .tInput.fb.bView -text View -command {
toplevel .tInput.tView
grab set .tInput.tView
set WH 500
set WHHalf [expr {$WH/2}]
set imageSize 100
canvas .tInput.tView.c -background black -width $WH -height $WH
checkbutton .tInput.tView.cbPerspective -text Perspective -variable ::perspective -offvalue no -onvalue yes
set ::perspective yes
.tInput.tView.cbPerspective select
set xmax 0.0
set xmin 0.0
if {[lindex ${::Atoms.UnitVectors} 0 1]>$xmax} {
set xmax [lindex ${::Atoms.UnitVectors} 0 1]
} elseif {[lindex ${::Atoms.UnitVectors} 0 1]<$xmin} {
set xmin [lindex ${::Atoms.UnitVectors} 0 1]
}
if {[lindex ${::Atoms.UnitVectors} 1 1]>$xmax} {
set xmax [lindex ${::Atoms.UnitVectors} 1 1]
} elseif {[lindex ${::Atoms.UnitVectors} 1 1]<$xmin} {
set xmin [lindex ${::Atoms.UnitVectors} 1 1]
}
if {[lindex ${::Atoms.UnitVectors} 2 1]>$xmax} {
set xmax [lindex ${::Atoms.UnitVectors} 2 1]
} elseif {[lindex ${::Atoms.UnitVectors} 2 1]<$xmin} {
set xmin [lindex ${::Atoms.UnitVectors} 2 1]
}
set ymax 0.0
set ymin 0.0
if {[lindex ${::Atoms.UnitVectors} 0 2]>$ymax} {
set ymax [lindex ${::Atoms.UnitVectors} 0 2]
} elseif {[lindex ${::Atoms.UnitVectors} 0 2]<$ymin} {
set ymin [lindex ${::Atoms.UnitVectors} 0 2]
}
if {[lindex ${::Atoms.UnitVectors} 1 2]>$ymax} {
set ymax [lindex ${::Atoms.UnitVectors} 1 2]
} elseif {[lindex ${::Atoms.UnitVectors} 1 2]<$ymin} {
set ymin [lindex ${::Atoms.UnitVectors} 1 2]
}
if {[lindex ${::Atoms.UnitVectors} 2 2]>$ymax} {
set ymax [lindex ${::Atoms.UnitVectors} 2 2]
} elseif {[lindex ${::Atoms.UnitVectors} 2 2]<$ymin} {
set ymin [lindex ${::Atoms.UnitVectors} 2 2]
}
set zmax 0.0
set zmin 0.0
if {[lindex ${::Atoms.UnitVectors} 0 3]>$zmax} {
set zmax [lindex ${::Atoms.UnitVectors} 0 3]
} elseif {[lindex ${::Atoms.UnitVectors} 0 3]<$zmin} {
set zmin [lindex ${::Atoms.UnitVectors} 0 3]
}
if {[lindex ${::Atoms.UnitVectors} 1 3]>$zmax} {
set zmax [lindex ${::Atoms.UnitVectors} 1 3]
} elseif {[lindex ${::Atoms.UnitVectors} 1 3]<$zmin} {
set zmin [lindex ${::Atoms.UnitVectors} 1 3]
}
if {[lindex ${::Atoms.UnitVectors} 2 3]>$zmax} {
set zmax [lindex ${::Atoms.UnitVectors} 2 3]
} elseif {[lindex ${::Atoms.UnitVectors} 2 3]<$zmin} {
set zmin [lindex ${::Atoms.UnitVectors} 2 3]
}
set viewLength [expr {max($xmax-$xmin, $ymax-$ymin)}]
set ::magnification 5
foreach item [::$Definition_of_Atomic_Species.tv children ""] {
set doas [::$Definition_of_Atomic_Species.tv set $item]
set element [lindex $doas 1]
scan [speciesColor $element] "#%02x%02x%02x" R G B
set scaledIS [expr {int($imageSize*[lindex [speciesRadius $element] 1]/3.0)}]
puts $scaledIS
image create photo $element -width $scaledIS -height $scaledIS
gradient $element raised 2 1 $R $G $B
}
set thetaY [expr {3.14159265358979*0.5}]
set thetaX 0.0
drawXyzv $viewLength $WH $WHHalf $imageSize $thetaY $thetaX
set dragFlag3 false
bind .tInput.tView.c <ButtonPress-3> {
set dragFlag3 true
set X0 %X
set Y0 %Y
%W configure -cursor exchange
}
bind .tInput.tView.c <Motion> {
if {$dragFlag3} {
%W delete all
drawXyzv $viewLength $WH $WHHalf $imageSize [expr {$thetaY+(%X-$X0)*0.015}] [expr {$thetaX+(%Y-$Y0)*0.015}]
}
}
bind .tInput.tView.c <ButtonRelease-3> {
set dragFlag3 false
set thetaY [expr {$thetaY+(%X-$X0)*0.015}]
set thetaX [expr {$thetaX+(%Y-$Y0)*0.015}]
%W configure -cursor left_ptr
}
bind .tInput.tView.c <Button-4> {
if {[info exists afterID]} {
after cancel $afterID
}
set viewLength [expr {max($viewLength-1, $::magnification)}]
%W configure -cursor sizing
set afterID [after 1 {
%W delete all
drawXyzv $viewLength $WH $WHHalf $imageSize $thetaY $thetaX
%W configure -cursor left_ptr
}]
}
bind .tInput.tView.c <Button-5> {
if {[info exists afterID]} {
after cancel $afterID
}
set viewLength [expr {$viewLength+1}]
%W configure -cursor sizing
set afterID [after 1 {
%W delete all
%W configure -cursor left_ptr
drawXyzv $viewLength $WH $WHHalf $imageSize $thetaY $thetaX
}]
}
pack .tInput.tView.c
pack .tInput.tView.cbPerspective
button .tInput.tView.bClose -text Close -command {
destroy .tInput.tView
}
pack .tInput.tView.bClose
}
button .tInput.fb.bClose -text Close -command {
destroy .tInput