├── README.md ├── example ├── POSCAR ├── modes.npy ├── mos2_ws2.png └── out.png ├── mview └── vasp2xsf.py /README.md: -------------------------------------------------------------------------------- 1 | # Mview 2 | 3 | Mview is a 3D visulization script written in python to view the molecular 4 | structures contained in files like VASP POSCAR. The script utilizes 5 | [ASE](https://wiki.fysik.dtu.dk/ase/ase/io/io.html) to read the structural 6 | information from input files, therefore, the input file formats are not limited 7 | to VASP POSCAR. In principle, any file format that can be recognized by ASE can 8 | be used as input. For 3D visulization, it utilizes 9 | [mayavi](https://docs.enthought.com/mayavi/mayavi/) to do the plotting work. 10 | 11 | In addition, the script can also plot the vibration mode with arrows if the 12 | vibrational modes are provided. 13 | 14 | ## Prerequisites 15 | 16 | The following python library must be installed to run the script 17 | 18 | * [numpy](https://wiki.fysik.dtu.dk/ase/ase/io/io.html) 19 | * [ase](https://wiki.fysik.dtu.dk/ase/ase/io/io.html) 20 | * [mayavi](https://docs.enthought.com/mayavi/mayavi/) 21 | 22 | ## Examples 23 | 24 | For a compliete list of functions, please refer to the help message by `mview 25 | -h`. The following line shows the possible usage of the script: 26 | 27 | 1. designate the input files by `-i POSCAR` 28 | 2. make a 2x2x1 supercell by `-r 2 2 1` 29 | 3. set the background color to black by `-bg 0 0 0`, where `0 0 0` is the RGB 30 | triplet, each with value in [0,255] 31 | 4. save the figure `-o out.png`. The output image format is determined by the 32 | suffix of the output file name. use `-s width height` to change the size of 33 | the output image. 34 | 5. show the second vibration mode with arrows `-n 2`. The OUTCAR containing the 35 | normal mode should be designated by `-outcar /path/to/OUTCAR`. 36 | 6. set the azimuth and elevation view angle by `-phi` and `-theta`. 37 | 7. do not show the mayavi UI `-q` 38 | 39 | ```bash 40 | mview -i POSCAR -r 2 2 1 -bg 0 0 0 -o out.png -n 2 -phi 0 -theta 90 -q 41 | ``` 42 | 43 | The resulting image looks like this: 44 | 45 | ![mview_example](example/out.png) 46 | -------------------------------------------------------------------------------- /example/POSCAR: -------------------------------------------------------------------------------- 1 | Mo Se W 2 | 1.00000000000000 3 | 9.9600000000000009 0.0000000000000000 0.0000000000000000 4 | 0.0000000000000000 17.2512260433860192 0.0000000000000000 5 | 0.0000000000000000 0.0000000000000000 25.0000000000000000 6 | Mo Se W 7 | 18 72 18 8 | Direct 9 | 0.1666666666666305 0.0539460566489482 0.3699581719823279 10 | 0.6666666666666284 0.5539460566489507 0.3699581719823279 11 | 0.8333333333333683 0.3872793899822057 0.3699581719823279 12 | 0.0000000000000006 0.2206127233155850 0.3699581719823267 13 | 0.8333333333333719 0.0539460566489511 0.3699581719823279 14 | 0.5000000000000000 0.3872793899822114 0.3699581719823285 15 | -0.0000000000000003 0.8872793899822117 0.3699581719823282 16 | 0.6666666666666338 0.8872793899822026 0.3699581719823278 17 | 0.8333333333333668 0.7206127233155827 0.3699581719823266 18 | 0.3333333333333722 0.5539460566489508 0.3699581719823279 19 | 0.3333333333333665 0.8872793899822093 0.3699581719823276 20 | 0.1666666666666318 0.3872793899822057 0.3699581719823279 21 | -0.0000000000000005 0.5539460566489534 0.3699581719823282 22 | 0.1666666666666302 0.7206127233155796 0.3699581719823264 23 | 0.6666666666666307 0.2206127233155796 0.3699581719823266 24 | 0.4999999999999974 0.0539460566489568 0.3699581719823279 25 | 0.3333333333333690 0.2206127233155797 0.3699581719823266 26 | 0.5000000000000032 0.7206127233155813 0.3699581719823267 27 | -0.0000000000000000 0.3321983838220907 0.3034849852107872 28 | -0.0000000000000001 0.6655317171554034 0.3034849852107867 29 | -0.0000000000000006 0.9988650504887524 0.3034849852107886 30 | 0.1666666666666517 0.1655317171554041 0.3034849852107863 31 | 0.1666666666666514 0.4988650504887533 0.3034849852107886 32 | 0.1666666666666514 0.8321983838220915 0.3034849852107872 33 | 0.3333333333333486 0.3321983838220918 0.3034849852107875 34 | 0.3333333333333480 0.6655317171554039 0.3034849852107865 35 | 0.3333333333333490 0.9988650504887535 0.3034849852107883 36 | 0.5000000000000000 0.1655317171554039 0.3034849852107866 37 | 0.5000000000000000 0.4988650504887525 0.3034849852107888 38 | 0.5000000000000001 0.8321983838221024 0.3034849852107874 39 | 0.6666666666666514 0.3321983838220918 0.3034849852107875 40 | 0.6666666666666522 0.6655317171554037 0.3034849852107865 41 | 0.6666666666666516 0.9988650504887532 0.3034849852107886 42 | 0.8333333333333482 0.1655317171554040 0.3034849852107863 43 | 0.8333333333333485 0.4988650504887533 0.3034849852107886 44 | 0.8333333333333482 0.8321983838220914 0.3034849852107874 45 | 0.0000000000000001 0.6655700847066638 0.4364327075945993 46 | 0.1666666666666485 0.1655700847066651 0.4364327075946013 47 | 0.3333333333333511 0.3322367513733672 0.4364327075945986 48 | 0.3333333333333508 0.6655700847066653 0.4364327075946009 49 | 0.5000000000000000 0.1655700847066641 0.4364327075945996 50 | 0.6666666666666490 0.3322367513733671 0.4364327075945986 51 | 0.6666666666666491 0.6655700847066649 0.4364327075946011 52 | 0.8333333333333512 0.1655700847066651 0.4364327075946013 53 | 0.8333333333333507 0.8322367513733674 0.4364327075945987 54 | -0.0000000000000000 0.3322367513733649 0.4364327075946051 55 | -0.0000000000000004 0.9989034180400083 0.4364327075946146 56 | 0.1666666666666485 0.4989034180400101 0.4364327075946159 57 | 0.1666666666666495 0.8322367513733672 0.4364327075946067 58 | 0.3333333333333519 0.9989034180400109 0.4364327075946152 59 | 0.5000000000000000 0.4989034180400087 0.4364327075946146 60 | 0.4999999999999999 0.8322367513733652 0.4364327075946053 61 | 0.6666666666666488 0.9989034180400106 0.4364327075946154 62 | 0.8333333333333515 0.4989034180400101 0.4364327075946159 63 | -0.0000000000000000 0.2232998024450424 0.5634095528335981 64 | 0.0000000000000000 0.5566331357783609 0.5634095528336398 65 | -0.0000000000000022 0.8899664691117336 0.5634095528336187 66 | 0.1666666666666315 0.0566331357783785 0.5634095528336437 67 | 0.1666666666666340 0.3899664691117534 0.5634095528336229 68 | 0.1666666666666325 0.7232998024450611 0.5634095528336026 69 | 0.3333333333333672 0.2232998024450625 0.5634095528336012 70 | 0.3333333333333676 0.5566331357783794 0.5634095528336439 71 | 0.3333333333333681 0.8899664691117647 0.5634095528336239 72 | 0.5000000000000000 0.0566331357783591 0.5634095528336395 73 | 0.5000000000000000 0.3899664691117328 0.5634095528336176 74 | 0.4999999999999999 0.7232998024450417 0.5634095528335981 75 | 0.6666666666666330 0.2232998024450625 0.5634095528336012 76 | 0.6666666666666324 0.5566331357783794 0.5634095528336439 77 | 0.6666666666666342 0.8899664691117639 0.5634095528336227 78 | 0.8333333333333683 0.0566331357783786 0.5634095528336437 79 | 0.8333333333333660 0.3899664691117535 0.5634095528336229 80 | 0.8333333333333677 0.7232998024450622 0.5634095528336014 81 | -0.0000000000000000 0.5566481341397591 0.6967017605028011 82 | 0.0000000000000000 0.8899814674731452 0.6967017605028236 83 | 0.1666666666666299 0.0566481341397787 0.6967017605027945 84 | 0.1666666666666302 0.3899814674731650 0.6967017605028173 85 | 0.1666666666666310 0.7233148008064628 0.6967017605028355 86 | 0.3333333333333693 0.5566481341397786 0.6967017605027948 87 | 0.3333333333333698 0.8899814674731646 0.6967017605028174 88 | 0.5000000000000000 0.0566481341397587 0.6967017605028009 89 | 0.5000000000000000 0.3899814674731444 0.6967017605028231 90 | 0.6666666666666304 0.5566481341397786 0.6967017605027948 91 | 0.6666666666666299 0.8899814674731648 0.6967017605028173 92 | 0.8333333333333703 0.0566481341397787 0.6967017605027945 93 | 0.8333333333333700 0.3899814674731650 0.6967017605028173 94 | 0.8333333333333688 0.7233148008064628 0.6967017605028355 95 | -0.0000000000000000 0.2233148008064426 0.6967017605028510 96 | 0.3333333333333691 0.2233148008064625 0.6967017605028450 97 | 0.5000000000000000 0.7233148008064419 0.6967017605028515 98 | 0.6666666666666311 0.2233148008064625 0.6967017605028450 99 | 0.5000000000000000 0.5016708715708257 0.6300128218758497 100 | 0.1666666666656374 0.1683375382366387 0.6300128218758495 101 | 0.0000000000000001 0.0016708715708256 0.6300128218758494 102 | 0.8333333333343603 0.8350042049049480 0.6300128218758501 103 | 0.6666666666656383 0.6683375382366399 0.6300128218758501 104 | 0.3333333333343605 0.3350042049049454 0.6300128218758499 105 | 0.8333333333343628 0.1683375382366387 0.6300128218758495 106 | 0.1666666666656389 0.5016708715707957 0.6300128218758495 107 | 0.8333333333343610 0.5016708715707957 0.6300128218758495 108 | 0.0000000000000000 0.3350042049049540 0.6300128218758494 109 | 0.6666666666656393 0.3350042049049453 0.6300128218758499 110 | 0.5000000000000000 0.1683375382366724 0.6300128218758495 111 | 0.1666666666656398 0.8350042049049480 0.6300128218758495 112 | 0.6666666666656401 0.0016708715707910 0.6300128218758494 113 | 0.3333333333343618 0.6683375382366401 0.6300128218758499 114 | 0.0000000000000001 0.6683375382366458 0.6300128218758501 115 | 0.4999999999999999 0.8350042049049524 0.6300128218758494 116 | 0.3333333333343597 0.0016708715707910 0.6300128218758494 117 | 118 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 119 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 120 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 121 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 122 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 123 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 124 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 125 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 126 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 127 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 128 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 129 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 130 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 131 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 132 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 133 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 134 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 135 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 136 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 137 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 138 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 139 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 140 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 141 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 142 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 143 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 144 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 145 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 146 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 147 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 148 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 149 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 150 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 151 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 152 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 153 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 154 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 155 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 156 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 157 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 158 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 159 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 160 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 161 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 162 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 163 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 164 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 165 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 166 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 167 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 168 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 169 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 170 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 171 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 172 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 173 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 174 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 175 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 176 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 177 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 178 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 179 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 180 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 181 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 182 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 183 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 184 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 185 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 186 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 187 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 188 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 189 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 190 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 191 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 192 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 193 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 194 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 195 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 196 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 197 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 198 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 199 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 200 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 201 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 202 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 203 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 204 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 205 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 206 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 207 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 208 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 209 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 210 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 211 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 212 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 213 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 214 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 215 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 216 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 217 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 218 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 219 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 220 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 221 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 222 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 223 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 224 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 225 | 0.00000000E+00 0.00000000E+00 0.00000000E+00 226 | -------------------------------------------------------------------------------- /example/modes.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QijingZheng/VaspPoscarMayavi/b8ffc182fa9826e5c1cd497ff7071eae9b6fa794/example/modes.npy -------------------------------------------------------------------------------- /example/mos2_ws2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QijingZheng/VaspPoscarMayavi/b8ffc182fa9826e5c1cd497ff7071eae9b6fa794/example/mos2_ws2.png -------------------------------------------------------------------------------- /example/out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QijingZheng/VaspPoscarMayavi/b8ffc182fa9826e5c1cd497ff7071eae9b6fa794/example/out.png -------------------------------------------------------------------------------- /mview: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ################################################################################ 4 | # START 5 | ################################################################################ 6 | # the chemical symbol of elements in the periodic table, extracted from VESTA 7 | # configuration file. 8 | pt_atomic_name = [ 9 | "H", "D", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", 10 | "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", 11 | "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", 12 | "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", 13 | "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", 14 | "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", 15 | "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", 16 | "Np", "Pu", "Am", "XX" 17 | ] 18 | # the atomic number of elements in the periodic table, extracted from VESTA 19 | # configuration file. 20 | pt_atomic_number = [ 21 | 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22 | 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 23 | 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 24 | 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 25 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 26 | 92, 93, 94, 95, 96, 27 | ] 28 | # the radius of elements in the periodic table, extracted from VESTA 29 | # configuration file. 30 | pt_atomic_radius = [ 31 | 0.46, 0.46, 1.22, 1.57, 1.12, 0.81, 0.77, 0.74, 0.74, 0.72, 1.60, 1.91, 1.60, 32 | 1.43, 1.18, 1.10, 1.04, 0.99, 1.92, 2.35, 1.97, 1.64, 1.47, 1.35, 1.29, 1.37, 33 | 1.26, 1.25, 1.25, 1.28, 1.37, 1.53, 1.22, 1.21, 1.04, 1.14, 1.98, 2.50, 2.15, 34 | 1.82, 1.60, 1.47, 1.40, 1.35, 1.34, 1.34, 1.37, 1.44, 1.52, 1.67, 1.58, 1.41, 35 | 1.37, 1.33, 2.18, 2.72, 2.24, 1.88, 1.82, 1.82, 1.82, 1.81, 1.81, 2.06, 1.79, 36 | 1.77, 1.77, 1.76, 1.75, 1.00, 1.94, 1.72, 1.59, 1.47, 1.41, 1.37, 1.35, 1.36, 37 | 1.39, 1.44, 1.55, 1.71, 1.75, 1.82, 1.77, 0.62, 0.80, 1.00, 2.35, 2.03, 1.80, 38 | 1.63, 1.56, 1.56, 1.64, 1.73, 0.80 39 | ] 40 | # the RGB-color for elements in the periodic table, extracted from VESTA 41 | # configuration file. 42 | pt_atomic_color = [ 43 | (1.00000, 0.80000, 0.80000), (0.80000, 0.80000, 1.00000), 44 | (0.98907, 0.91312, 0.81091), (0.52731, 0.87953, 0.45670), 45 | (0.37147, 0.84590, 0.48292), (0.12490, 0.63612, 0.05948), 46 | (0.50430, 0.28659, 0.16236), (0.69139, 0.72934, 0.90280), 47 | (0.99997, 0.01328, 0.00000), (0.69139, 0.72934, 0.90280), 48 | (0.99954, 0.21788, 0.71035), (0.97955, 0.86618, 0.23787), 49 | (0.98773, 0.48452, 0.08470), (0.50718, 0.70056, 0.84062), 50 | (0.10596, 0.23226, 0.98096), (0.75557, 0.61256, 0.76425), 51 | (1.00000, 0.98071, 0.00000), (0.19583, 0.98828, 0.01167), 52 | (0.81349, 0.99731, 0.77075), (0.63255, 0.13281, 0.96858), 53 | (0.35642, 0.58863, 0.74498), (0.71209, 0.38930, 0.67279), 54 | (0.47237, 0.79393, 1.00000), (0.90000, 0.10000, 0.00000), 55 | (0.00000, 0.00000, 0.62000), (0.66148, 0.03412, 0.62036), 56 | (0.71051, 0.44662, 0.00136), (0.00000, 0.00000, 0.68666), 57 | (0.72032, 0.73631, 0.74339), (0.13390, 0.28022, 0.86606), 58 | (0.56123, 0.56445, 0.50799), (0.62292, 0.89293, 0.45486), 59 | (0.49557, 0.43499, 0.65193), (0.45814, 0.81694, 0.34249), 60 | (0.60420, 0.93874, 0.06122), (0.49645, 0.19333, 0.01076), 61 | (0.98102, 0.75805, 0.95413), (1.00000, 0.00000, 0.60000), 62 | (0.00000, 1.00000, 0.15259), (0.40259, 0.59739, 0.55813), 63 | (0.00000, 1.00000, 0.00000), (0.29992, 0.70007, 0.46459), 64 | (0.70584, 0.52602, 0.68925), (0.80574, 0.68699, 0.79478), 65 | (0.81184, 0.72113, 0.68089), (0.80748, 0.82205, 0.67068), 66 | (0.75978, 0.76818, 0.72454), (0.72032, 0.73631, 0.74339), 67 | (0.95145, 0.12102, 0.86354), (0.84378, 0.50401, 0.73483), 68 | (0.60764, 0.56052, 0.72926), (0.84627, 0.51498, 0.31315), 69 | (0.67958, 0.63586, 0.32038), (0.55914, 0.12200, 0.54453), 70 | (0.60662, 0.63218, 0.97305), (0.05872, 0.99922, 0.72578), 71 | (0.11835, 0.93959, 0.17565), (0.35340, 0.77057, 0.28737), 72 | (0.82055, 0.99071, 0.02374), (0.99130, 0.88559, 0.02315), 73 | (0.98701, 0.55560, 0.02744), (0.00000, 0.00000, 0.96000), 74 | (0.99042, 0.02403, 0.49195), (0.98367, 0.03078, 0.83615), 75 | (0.75325, 0.01445, 1.00000), (0.44315, 0.01663, 0.99782), 76 | (0.19390, 0.02374, 0.99071), (0.02837, 0.25876, 0.98608), 77 | (0.28688, 0.45071, 0.23043), (0.00000, 0.00000, 0.88000), 78 | (0.15323, 0.99165, 0.95836), (0.15097, 0.99391, 0.71032), 79 | (0.70704, 0.70552, 0.35090), (0.71952, 0.60694, 0.33841), 80 | (0.55616, 0.54257, 0.50178), (0.70294, 0.69401, 0.55789), 81 | (0.78703, 0.69512, 0.47379), (0.78975, 0.81033, 0.45049), 82 | (0.79997, 0.77511, 0.75068), (0.99628, 0.70149, 0.22106), 83 | (0.82940, 0.72125, 0.79823), (0.58798, 0.53854, 0.42649), 84 | (0.32386, 0.32592, 0.35729), (0.82428, 0.18732, 0.97211), 85 | (0.00000, 0.00000, 1.00000), (0.00000, 0.00000, 1.00000), 86 | (1.00000, 1.00000, 0.00000), (0.00000, 0.00000, 0.00000), 87 | (0.42959, 0.66659, 0.34786), (0.39344, 0.62101, 0.45034), 88 | (0.14893, 0.99596, 0.47106), (0.16101, 0.98387, 0.20855), 89 | (0.47774, 0.63362, 0.66714), (0.30000, 0.30000, 0.30000), 90 | (0.30000, 0.30000, 0.30000), (0.30000, 0.30000, 0.30000), 91 | (0.30000, 0.30000, 0.30000) 92 | ] 93 | # The bond length extracted from VESTA configuration file. 94 | pt_max_bond = { 95 | ("Ac", "O") : 2.73260, ("Ac", "F") : 2.58646, ("Ac", "Cl") : 3.08646, ("Ac", "Br") : 3.22726, 96 | ("Ag", "O") : 2.81139, ("Ag", "S") : 3.08839, ("Ag", "F") : 2.76939, ("Ag", "Cl") : 3.05939, 97 | ("Ag", "Br") : 2.37642, ("Ag", "I") : 2.53642, ("Ag", "Se") : 2.41642, ("Ag", "Te") : 2.66642, 98 | ("Ag", "N") : 2.00642, ("Ag", "P") : 2.37642, ("Ag", "As") : 2.45642, ("Ag", "H") : 1.65642, 99 | ("Al", "O") : 2.10740, ("Al", "S") : 2.66646, ("Al", "Se") : 2.72646, ("Al", "Te") : 2.93646, 100 | ("Al", "F") : 2.00146, ("Al", "Cl") : 2.48846, ("Al", "Br") : 2.65646, ("Al", "I") : 2.86646, 101 | ("Al", "N") : 2.24646, ("Al", "P") : 2.69646, ("Al", "As") : 2.75646, ("Al", "H") : 1.90646, 102 | ("Am", "O") : 2.71649, ("Am", "F") : 2.61945, ("Am", "Cl") : 3.08945, ("Am", "Br") : 3.22944, 103 | ("As", "S") : 2.84649, ("As", "Se") : 2.98649, ("As", "O") : 2.24546, ("As", "Te") : 3.10646, 104 | ("As", "F") : 2.15646, ("As", "Cl") : 2.61646, ("As", "Br") : 2.80646, ("As", "I") : 3.03646, 105 | ("As", "C") : 2.38646, ("Au", "Cl") : 2.88295, ("Au", "I") : 3.21295, ("Au", "O") : 2.34646, 106 | ("Au", "S") : 2.83260, ("Au", "F") : 2.34646, ("Au", "Br") : 2.77646, ("Au", "N") : 2.38260, 107 | ("Au", "Se") : 2.22998, ("Au", "Te") : 2.45998, ("Au", "P") : 2.18998, ("Au", "As") : 2.26998, 108 | ("Au", "H") : 1.41998, ( "B", "O") : 1.82746, ( "B", "S") : 2.27646, ( "B", "Se") : 2.40646, 109 | ( "B", "Te") : 2.65646, ( "B", "F") : 1.76646, ( "B", "Cl") : 2.19646, ( "B", "Br") : 2.33646, 110 | ( "B", "I") : 2.55646, ( "B", "N") : 1.93846, ( "B", "P") : 2.37646, ( "B", "As") : 2.42646, 111 | ( "B", "H") : 1.59646, ( "B", "B") : 1.85846, ("Ba", "O") : 3.14795, ("Ba", "S") : 3.66195, 112 | ("Ba", "Se") : 3.74295, ("Ba", "Te") : 3.94295, ("Ba", "F") : 3.05095, ("Ba", "Cl") : 3.55295, 113 | ("Ba", "Br") : 3.74295, ("Ba", "I") : 3.99295, ("Ba", "N") : 3.33295, ("Ba", "P") : 3.48295, 114 | ("Ba", "As") : 3.69000, ("Ba", "H") : 3.08295, ("Be", "O") : 1.98749, ("Be", "S") : 2.43649, 115 | ("Be", "Se") : 2.57649, ("Be", "Te") : 2.81649, ("Be", "F") : 1.88749, ("Be", "Cl") : 2.36649, 116 | ("Be", "Br") : 2.50649, ("Be", "I") : 2.70649, ("Be", "N") : 2.10649, ("Be", "P") : 2.55649, 117 | ("Be", "As") : 2.60649, ("Be", "H") : 1.71649, ("Bi", "O") : 2.66080, ("Bi", "S") : 3.13291, 118 | ("Bi", "Se") : 3.24329, ("Bi", "F") : 2.55291, ("Bi", "Cl") : 3.04291, ("Bi", "Br") : 3.17993, 119 | ("Bi", "I") : 3.38291, ("Bi", "N") : 2.56329, ("Bi", "Te") : 3.02642, ("Bi", "P") : 2.78642, 120 | ("Bi", "As") : 2.87642, ("Bi", "H") : 2.12642, ("Br", "O") : 2.35646, ("Br", "F") : 2.20646, 121 | ("Br", "Cl") : 2.33296, ( "C", "O") : 1.97249, ( "C", "Cl") : 2.11002, ( "C", "C") : 1.89002, 122 | ( "C", "S") : 2.15002, ( "C", "F") : 1.76002, ( "C", "Br") : 2.26002, ( "C", "N") : 1.79202, 123 | ( "C", "Se") : 2.01998, ( "C", "I") : 2.16998, ( "C", "Te") : 2.25998, ( "C", "P") : 1.93998, 124 | ( "C", "H") : 1.20000, ("Ca", "O") : 2.83062, ("Ca", "S") : 3.31295, ("Ca", "Se") : 3.42295, 125 | ("Ca", "Te") : 3.62295, ("Ca", "F") : 2.70495, ("Ca", "Cl") : 3.23295, ("Ca", "Br") : 3.36995, 126 | ("Ca", "I") : 3.58295, ("Ca", "N") : 3.00295, ("Ca", "P") : 3.41295, ("Ca", "As") : 3.48295, 127 | ("Ca", "H") : 2.69295, ("Cd", "O") : 2.76695, ("Cd", "S") : 3.16695, ("Cd", "Se") : 3.26295, 128 | ("Cd", "Te") : 3.45295, ("Cd", "F") : 2.67395, ("Cd", "Cl") : 3.09295, ("Cd", "Br") : 3.21295, 129 | ("Cd", "I") : 3.46295, ("Cd", "N") : 2.82295, ("Cd", "P") : 3.20295, ("Cd", "As") : 3.29295, 130 | ("Cd", "H") : 2.52295, ("Ce", "O") : 2.86393, ("Ce", "S") : 3.36293, ("Ce", "F") : 2.75452, 131 | ("Ce", "Cl") : 3.25293, ("Ce", "Br") : 3.40452, ("Ce", "I") : 3.62452, ("Ce", "N") : 2.78549, 132 | ("Ce", "Se") : 3.04644, ("Ce", "Te") : 3.22644, ("Ce", "P") : 3.00644, ("Ce", "As") : 3.08644, 133 | ("Ce", "H") : 2.34644, ("Cl", "O") : 2.16646, ("Cl", "F") : 2.14646, ("Cl", "Cl") : 2.14296, 134 | ("Co", "H") : 1.92780, ("Co", "O") : 2.40493, ("Co", "S") : 2.65293, ("Co", "F") : 2.35293, 135 | ("Co", "Cl") : 2.74593, ("Co", "N") : 2.36293, ("Co", "C") : 2.19691, ("Co", "Br") : 2.33642, 136 | ("Co", "I") : 2.52878, ("Co", "Se") : 2.39642, ("Co", "Te") : 2.61642, ("Co", "P") : 2.36642, 137 | ("Co", "As") : 2.43642, ("Cr", "O") : 2.44293, ("Cr", "F") : 2.45293, ("Cr", "Cl") : 2.80293, 138 | ("Cr", "Br") : 2.97293, ("Cr", "I") : 3.19293, ("Cr", "N") : 2.51520, ("Cr", "S") : 2.72491, 139 | ("Cr", "Se") : 2.44642, ("Cr", "Te") : 2.67642, ("Cr", "P") : 2.42642, ("Cr", "As") : 2.49642, 140 | ("Cr", "H") : 1.67642, ("Cs", "O") : 3.53642, ("Cs", "S") : 4.24942, ("Cs", "Se") : 4.21655, 141 | ("Cs", "Te") : 4.46310, ("Cs", "F") : 3.49942, ("Cs", "Cl") : 3.91042, ("Cs", "Br") : 4.06942, 142 | ("Cs", "I") : 4.40942, ("Cs", "N") : 3.94942, ("Cs", "P") : 3.64194, ("Cs", "As") : 4.15942, 143 | ("Cs", "H") : 3.55942, ("Cu", "O") : 2.47295, ("Cu", "S") : 2.76095, ("Cu", "Se") : 2.76295, 144 | ("Cu", "F") : 2.46295, ("Cu", "Cl") : 2.75295, ("Cu", "Br") : 2.89295, ("Cu", "I") : 3.01795, 145 | ("Cu", "N") : 2.49295, ("Cu", "P") : 2.65649, ("Cu", "As") : 2.71895, ("Cu", "C") : 2.32649, 146 | ("Cu", "Te") : 2.87649, ("Cu", "H") : 1.81649, ("Dy", "O") : 2.65651, ("Dy", "F") : 2.52944, 147 | ("Dy", "Cl") : 3.01945, ("Dy", "Br") : 3.16945, ("Dy", "I") : 3.39945, ("Dy", "S") : 2.82300, 148 | ("Dy", "Se") : 2.81000, ("Dy", "Te") : 3.22000, ("Dy", "N") : 2.38000, ("Dy", "P") : 2.77000, 149 | ("Dy", "As") : 3.14000, ("Dy", "H") : 2.09000, ("Er", "O") : 2.63651, ("Er", "S") : 3.27651, 150 | ("Er", "Se") : 3.18649, ("Er", "F") : 2.51049, ("Er", "Cl") : 2.99944, ("Er", "Br") : 3.14945, 151 | ("Er", "I") : 3.38945, ("Er", "Te") : 3.22000, ("Er", "N") : 2.36000, ("Er", "P") : 2.75000, 152 | ("Er", "As") : 3.18000, ("Er", "H") : 2.06000, ("Eu", "O") : 2.94249, ("Eu", "S") : 3.37949, 153 | ("Eu", "F") : 2.83549, ("Eu", "Cl") : 3.32549, ("Eu", "Br") : 3.46549, ("Eu", "I") : 3.69549, 154 | ("Eu", "N") : 2.95549, ("Eu", "Se") : 2.89898, ("Eu", "Te") : 3.08898, ("Eu", "P") : 2.85898, 155 | ("Eu", "As") : 2.93898, ("Eu", "H") : 2.18898, ("Fe", "O") : 2.44693, ("Fe", "S") : 2.83793, 156 | ("Fe", "F") : 2.36293, ("Fe", "Cl") : 2.86293, ("Fe", "Br") : 2.89520, ("Fe", "I") : 3.15520, 157 | ("Fe", "N") : 2.48193, ("Fe", "C") : 2.25191, ("Fe", "Se") : 2.43642, ("Fe", "Te") : 2.68642, 158 | ("Fe", "P") : 2.42642, ("Fe", "As") : 2.50642, ("Fe", "H") : 1.68642, ("Ga", "Se") : 3.41295, 159 | ("Ga", "O") : 2.18646, ("Ga", "S") : 2.61946, ("Ga", "F") : 2.14646, ("Ga", "Cl") : 2.52646, 160 | ("Ga", "Br") : 2.64260, ("Ga", "I") : 2.91646, ("Ga", "Te") : 2.58998, ("Ga", "N") : 1.96000, 161 | ("Ga", "P") : 2.46998, ("Ga", "As") : 2.38998, ("Ga", "H") : 1.55998, ("Gd", "O") : 2.76651, 162 | ("Gd", "F") : 3.15651, ("Gd", "S") : 3.13649, ("Gd", "Cl") : 3.06349, ("Gd", "Br") : 3.19945, 163 | ("Gd", "I") : 3.41945, ("Gd", "Se") : 2.85000, ("Gd", "Te") : 3.24000, ("Gd", "N") : 2.42000, 164 | ("Gd", "P") : 2.81000, ("Gd", "As") : 3.18000, ("Gd", "H") : 2.13000, ("Ge", "O") : 2.09802, 165 | ("Ge", "S") : 2.56702, ("Ge", "Se") : 2.70002, ("Ge", "F") : 2.01002, ("Ge", "Cl") : 2.49002, 166 | ("Ge", "Br") : 2.34998, ("Ge", "I") : 2.54998, ("Ge", "Te") : 2.60998, ("Ge", "N") : 1.92998, 167 | ("Ge", "P") : 2.36998, ("Ge", "As") : 2.47998, ("Ge", "H") : 1.59998, ("Ge", "Ge") : 2.60000, 168 | ( "O", "H") : 1.20000, ( "H", "O") : 2.10000, ( "H", "F") : 1.10000, ( "H", "Cl") : 1.50000, 169 | ( "H", "N") : 1.20000, ( "O", "D") : 1.20000, ( "D", "O") : 2.10000, ( "D", "F") : 1.10000, 170 | ( "D", "Cl") : 1.50000, ( "D", "N") : 1.20000, ("Hf", "F") : 3.18291, ("Hf", "O") : 2.37946, 171 | ("Hf", "Cl") : 2.75646, ("Hf", "Br") : 2.62642, ("Hf", "S") : 2.64642, ("Hf", "Se") : 2.67642, 172 | ("Hf", "Te") : 2.87642, ("Hf", "I") : 2.83642, ("Hf", "N") : 2.24642, ("Hf", "P") : 2.63642, 173 | ("Hf", "As") : 2.71642, ("Hf", "H") : 1.93642, ("Hg", "O") : 2.86939, ("Hg", "F") : 2.88293, 174 | ("Hg", "Cl") : 3.24939, ("Hg", "S") : 3.42093, ("Hg", "Br") : 3.09293, ("Hg", "I") : 3.33293, 175 | ("Hg", "Se") : 2.82642, ("Hg", "Te") : 2.76642, ("Hg", "N") : 2.17642, ("Hg", "P") : 2.57642, 176 | ("Hg", "As") : 2.65642, ("Hg", "H") : 1.86642, ("Hg", "Hg") : 3.19520, ("Ho", "O") : 2.67047, 177 | ("Ho", "S") : 3.13547, ("Ho", "F") : 2.56159, ("Ho", "Cl") : 3.05159, ("Ho", "Br") : 3.20159, 178 | ("Ho", "I") : 3.44159, ("Ho", "Se") : 2.84898, ("Ho", "Te") : 3.03898, ("Ho", "N") : 2.41898, 179 | ("Ho", "P") : 2.79898, ("Ho", "As") : 2.87898, ("Ho", "H") : 2.11898, ( "I", "I") : 2.40000, 180 | ( "I", "F") : 3.18295, ( "I", "Cl") : 3.33295, ( "I", "O") : 2.47646, ("In", "Cl") : 3.52939, 181 | ("In", "O") : 2.46491, ("In", "S") : 2.93291, ("In", "F") : 2.35491, ("In", "Br") : 3.05329, 182 | ("In", "I") : 3.19291, ("In", "Co") : 3.13629, ("In", "Mn") : 3.14729, ("In", "Se") : 2.62642, 183 | ("In", "Te") : 2.84642, ("In", "N") : 2.18642, ("In", "P") : 2.68642, ("In", "As") : 2.66642, 184 | ("In", "H") : 1.87642, ("Ir", "O") : 2.27746, ("Ir", "F") : 2.15002, ("Ir", "Cl") : 2.56746, 185 | ("Ir", "S") : 2.42998, ("Ir", "Se") : 2.55998, ("Ir", "Te") : 2.75998, ("Ir", "Br") : 2.49998, 186 | ("Ir", "I") : 2.70998, ("Ir", "N") : 2.10998, ("Ir", "P") : 2.50998, ("Ir", "As") : 2.58998, 187 | ("Ir", "H") : 1.80998, ( "K", "O") : 3.25142, ( "K", "S") : 3.79285, ( "K", "Se") : 4.00186, 188 | ( "K", "Te") : 4.23284, ( "K", "F") : 3.11142, ( "K", "Cl") : 3.65976, ( "K", "Br") : 3.85130, 189 | ( "K", "I") : 4.11717, ( "K", "N") : 3.41942, ( "K", "P") : 3.44942, ( "K", "As") : 3.94942, 190 | ( "K", "H") : 3.21942, ("Kr", "F") : 2.67549, ("La", "O") : 2.90983, ("La", "S") : 3.35593, 191 | ("La", "Se") : 3.45293, ("La", "Te") : 3.65293, ("La", "F") : 2.79293, ("La", "Cl") : 3.33452, 192 | ("La", "Br") : 3.43293, ("La", "I") : 3.64293, ("La", "N") : 3.05293, ("La", "P") : 3.32293, 193 | ("La", "As") : 3.51293, ("La", "H") : 2.77293, ("Li", "O") : 2.60087, ("Li", "S") : 3.02481, 194 | ("Li", "Se") : 3.24330, ("Li", "Te") : 3.42496, ("Li", "F") : 2.34276, ("Li", "Cl") : 2.91814, 195 | ("Li", "Br") : 3.11654, ("Li", "I") : 3.37676, ("Li", "N") : 2.66213, ("Lu", "O") : 2.57749, 196 | ("Lu", "S") : 3.03649, ("Lu", "Se") : 3.16649, ("Lu", "Te") : 3.35649, ("Lu", "F") : 2.48249, 197 | ("Lu", "Cl") : 2.96944, ("Lu", "Br") : 3.11945, ("Lu", "I") : 3.36945, ("Lu", "N") : 2.71649, 198 | ("Lu", "P") : 3.11649, ("Lu", "As") : 3.19649, ("Lu", "H") : 2.42649, ("Mg", "O") : 2.41824, 199 | ("Mg", "S") : 2.89293, ("Mg", "Se") : 3.03293, ("Mg", "Te") : 3.24293, ("Mg", "F") : 2.29093, 200 | ("Mg", "Cl") : 2.79293, ("Mg", "Br") : 2.99293, ("Mg", "I") : 3.17293, ("Mg", "N") : 2.56293, 201 | ("Mg", "P") : 3.00293, ("Mg", "As") : 3.09293, ("Mg", "H") : 2.24293, ("Mn", "O") : 2.51652, 202 | ("Mn", "S") : 2.93293, ("Mn", "F") : 2.41093, ("Mn", "Cl") : 2.84593, ("Mn", "Br") : 3.05293, 203 | ("Mn", "I") : 3.23293, ("Mn", "N") : 2.56193, ("Mn", "Se") : 2.47642, ("Mn", "Te") : 2.70642, 204 | ("Mn", "P") : 2.39642, ("Mn", "As") : 2.51642, ("Mn", "H") : 1.70642, ("Mo", "S") : 2.80067, 205 | ("Mo", "Cl") : 2.80447, ("Mo", "O") : 2.34750, ("Mo", "F") : 2.29980, ("Mo", "Br") : 2.85350, 206 | ("Mo", "N") : 2.47350, ("Mo", "I") : 2.74701, ("Mo", "Se") : 2.59701, ("Mo", "Te") : 2.79701, 207 | ("Mo", "P") : 2.54701, ("Mo", "As") : 2.62701, ("Mo", "H") : 1.83701, ( "N", "O") : 1.81746, 208 | ( "N", "F") : 1.82646, ( "N", "Cl") : 2.20646, ( "N", "N") : 1.88260, ("Na", "O") : 2.95693, 209 | ("Na", "S") : 3.57685, ("Na", "Se") : 3.71593, ("Na", "Te") : 3.95459, ("Na", "F") : 2.80398, 210 | ("Na", "Cl") : 3.39412, ("Na", "Br") : 3.57715, ("Na", "I") : 3.88251, ("Na", "N") : 3.12942, 211 | ("Na", "P") : 3.47942, ("Na", "As") : 3.64942, ("Na", "H") : 2.79942, ("Nb", "O") : 2.45329, 212 | ("Nb", "F") : 2.35646, ("Nb", "Cl") : 2.76291, ("Nb", "Br") : 3.07646, ("Nb", "N") : 2.46046, 213 | ("Nb", "I") : 3.14390, ("Nb", "S") : 2.74000, ("Nb", "Se") : 2.66642, ("Nb", "Te") : 2.85642, 214 | ("Nb", "P") : 2.61642, ("Nb", "As") : 2.69642, ("Nb", "H") : 1.90642, ("Nd", "O") : 2.85870, 215 | ("Nd", "S") : 3.42712, ("Nd", "Se") : 3.42293, ("Nd", "Te") : 3.60293, ("Nd", "F") : 2.73452, 216 | ("Nd", "Cl") : 3.22493, ("Nd", "Br") : 3.37293, ("Nd", "I") : 3.59452, ("Nd", "N") : 3.01293, 217 | ("Ni", "O") : 2.28149, ("Ni", "S") : 2.58649, ("Ni", "F") : 2.20249, ("Ni", "Cl") : 2.62649, 218 | ("Ni", "Br") : 2.80649, ("Ni", "I") : 3.00649, ("Ni", "N") : 2.30649, ("Ni", "Se") : 2.18998, 219 | ("Ni", "Te") : 2.47998, ("Ni", "P") : 2.31998, ("Ni", "As") : 2.28998, ("Ni", "H") : 1.44998, 220 | ("Np", "F") : 2.59233, ("Np", "Cl") : 3.07233, ("Np", "S") : 3.20000, ("Np", "Br") : 3.21233, 221 | ("Np", "I") : 3.44233, ("Np", "O") : 2.63646, ( "O", "O") : 1.70000, ("Os", "O") : 2.23000, 222 | ("Os", "S") : 2.56002, ("Os", "F") : 2.07746, ("Os", "Cl") : 2.54002, ("Os", "Br") : 2.72002, 223 | ( "P", "O") : 2.08646, ( "P", "S") : 2.57646, ( "P", "Se") : 2.69646, ( "P", "F") : 2.01002, 224 | ( "P", "Cl") : 2.28746, ( "P", "Br") : 2.44293, ( "P", "N") : 1.97146, ( "P", "I") : 2.44998, 225 | ( "P", "P") : 2.48381, ( "P", "As") : 2.29998, ( "P", "H") : 1.45998, ("Pa", "O") : 2.63383, 226 | ("Pa", "F") : 2.54437, ("Pa", "Cl") : 3.01437, ("Pa", "Br") : 3.18437, ("Pb", "O") : 3.04096, 227 | ("Pb", "S") : 3.40395, ("Pb", "Se") : 3.55295, ("Pb", "F") : 2.92045, ("Pb", "Cl") : 3.39295, 228 | ("Pb", "Br") : 3.62451, ("Pb", "I") : 3.69562, ("Pb", "N") : 3.09670, ("Pb", "Te") : 3.14644, 229 | ("Pb", "P") : 2.94644, ("Pb", "As") : 3.02644, ("Pb", "H") : 2.27644, ("Pd", "O") : 2.39849, 230 | ("Pd", "S") : 2.69649, ("Pd", "F") : 2.34649, ("Pd", "Cl") : 2.65649, ("Pd", "Br") : 2.80649, 231 | ("Pd", "I") : 2.96649, ("Pd", "N") : 2.40451, ("Pd", "C") : 2.33649, ("Pd", "Se") : 2.26998, 232 | ("Pd", "Te") : 2.52998, ("Pd", "P") : 2.46998, ("Pd", "As") : 2.34998, ("Pd", "H") : 1.51998, 233 | ("Pm", "F") : 2.55233, ("Pm", "Cl") : 3.41233, ("Pm", "Br") : 3.18233, ("Po", "O") : 2.64646, 234 | ("Po", "F") : 2.83646, ("Pr", "O") : 2.74449, ("Pr", "S") : 3.20649, ("Pr", "Se") : 3.32649, 235 | ("Pr", "Te") : 3.50649, ("Pr", "F") : 2.62945, ("Pr", "Cl") : 3.12749, ("Pr", "Br") : 3.27649, 236 | ("Pr", "I") : 3.49649, ("Pr", "N") : 2.90649, ("Pr", "P") : 3.28649, ("Pr", "As") : 3.35649, 237 | ("Pr", "H") : 2.62649, ("Pt", "O") : 2.40649, ("Pt", "S") : 2.76649, ("Pt", "F") : 2.54002, 238 | ("Pt", "Cl") : 2.75646, ("Pt", "Br") : 2.94191, ("Pt", "C") : 2.36649, ("Pt", "N") : 2.41649, 239 | ("Pt", "I") : 2.41998, ("Pt", "Se") : 2.23998, ("Pt", "Te") : 2.49998, ("Pt", "P") : 2.23998, 240 | ("Pt", "As") : 2.30998, ("Pt", "H") : 1.44998, ("Pu", "O") : 2.68329, ("Pu", "F") : 2.58233, 241 | ("Pu", "Cl") : 3.05233, ("Pu", "S") : 3.30000, ("Pu", "Br") : 3.19233, ("Pu", "I") : 3.43233, 242 | ("Rb", "O") : 3.43945, ("Rb", "S") : 3.97645, ("Rb", "Se") : 4.13773, ("Rb", "Te") : 4.28802, 243 | ("Rb", "F") : 3.37645, ("Rb", "Cl") : 3.86664, ("Rb", "Br") : 4.05498, ("Rb", "I") : 4.33462, 244 | ("Rb", "N") : 3.79645, ("Rb", "P") : 3.50645, ("Rb", "As") : 4.04645, ("Rb", "H") : 3.43645, 245 | ("Re", "Cl") : 3.44712, ("Re", "O") : 2.34260, ("Re", "F") : 2.16002, ("Re", "Br") : 2.70002, 246 | ("Re", "I") : 2.65998, ("Re", "S") : 2.61998, ("Re", "Se") : 2.54998, ("Re", "Te") : 2.74998, 247 | ("Re", "N") : 2.10998, ("Re", "P") : 2.50998, ("Re", "As") : 2.61998, ("Re", "H") : 1.79998, 248 | ("Rh", "O") : 2.24946, ("Rh", "F") : 2.16646, ("Rh", "Cl") : 2.62646, ("Rh", "Br") : 2.71260, 249 | ("Rh", "N") : 2.26260, ("Rh", "I") : 2.52998, ("Rh", "S") : 2.19998, ("Rh", "Se") : 2.37998, 250 | ("Rh", "Te") : 2.59998, ("Rh", "P") : 2.43998, ("Rh", "As") : 2.41998, ("Rh", "H") : 1.59998, 251 | ("Ru", "Se") : 2.69451, ("Ru", "F") : 2.57646, ("Ru", "O") : 2.22646, ("Ru", "S") : 2.64260, 252 | ("Ru", "Cl") : 2.70646, ("Ru", "N") : 2.26260, ("Ru", "Br") : 2.30998, ("Ru", "I") : 2.52998, 253 | ("Ru", "Te") : 2.58998, ("Ru", "P") : 2.33998, ("Ru", "As") : 2.40998, ("Ru", "H") : 1.65998, 254 | ( "S", "O") : 1.80000, ( "S", "S") : 2.20000, ( "S", "N") : 2.28849, ( "S", "F") : 1.95002, 255 | ( "S", "Cl") : 2.37002, ( "S", "Br") : 2.21998, ( "S", "I") : 2.40998, ( "S", "H") : 1.42998, 256 | ("Sb", "O") : 2.45237, ("Sb", "S") : 3.05000, ("Sb", "Se") : 3.05646, ("Sb", "F") : 2.35646, 257 | ("Sb", "Cl") : 2.80646, ("Sb", "Br") : 2.96646, ("Sb", "I") : 3.21646, ("Sb", "N") : 2.56446, 258 | ("Sb", "Te") : 2.82998, ("Sb", "P") : 2.56998, ("Sb", "As") : 2.64998, ("Sb", "H") : 2.81998, 259 | ("Sc", "O") : 2.42029, ("Sc", "S") : 2.88391, ("Sc", "Se") : 3.00291, ("Sc", "Te") : 3.20291, 260 | ("Sc", "F") : 2.32291, ("Sc", "Cl") : 2.92291, ("Sc", "Br") : 2.94291, ("Sc", "I") : 3.15291, 261 | ("Sc", "N") : 2.54291, ("Sc", "P") : 2.96291, ("Sc", "As") : 3.04291, ("Sc", "H") : 2.24291, 262 | ("Se", "S") : 2.81649, ("Se", "Se") : 2.93649, ("Se", "O") : 2.16102, ("Se", "F") : 2.08002, 263 | ("Se", "Cl") : 2.57002, ("Se", "Br") : 2.78002, ("Se", "N") : 2.10000, ("Se", "I") : 2.58998, 264 | ("Se", "H") : 1.58998, ("Si", "O") : 1.99002, ("Si", "S") : 2.47602, ("Si", "Se") : 2.61002, 265 | ("Si", "Te") : 2.84002, ("Si", "F") : 1.93002, ("Si", "Cl") : 2.38002, ("Si", "Br") : 2.55002, 266 | ("Si", "I") : 2.76002, ("Si", "C") : 2.23302, ("Si", "N") : 2.12002, ("Si", "P") : 2.58002, 267 | ("Si", "As") : 2.66002, ("Si", "H") : 1.82002, ("Si", "Si") : 2.60000, ("Sm", "O") : 2.88251, 268 | ("Sm", "N") : 3.02351, ("Sm", "S") : 3.15649, ("Sm", "Se") : 3.27649, ("Sm", "Te") : 3.46649, 269 | ("Sm", "F") : 2.60649, ("Sm", "Cl") : 3.08749, ("Sm", "Br") : 3.26649, ("Sm", "I") : 3.44649, 270 | ("Sm", "P") : 3.23649, ("Sm", "As") : 3.30649, ("Sm", "H") : 2.56649, ("Sn", "O") : 2.82146, 271 | ("Sn", "S") : 3.15293, ("Sn", "F") : 2.63793, ("Sn", "Cl") : 3.13111, ("Sn", "Br") : 3.21520, 272 | ("Sn", "I") : 3.52293, ("Sn", "N") : 2.71520, ("Sn", "Se") : 2.96646, ("Sn", "Te") : 2.91642, 273 | ("Sn", "P") : 2.60642, ("Sn", "As") : 2.77642, ("Sn", "H") : 2.00642, ("Sr", "O") : 2.98095, 274 | ("Sr", "S") : 3.51295, ("Sr", "Se") : 3.58295, ("Sr", "Te") : 3.73295, ("Sr", "F") : 2.88195, 275 | ("Sr", "Cl") : 3.37295, ("Sr", "Br") : 3.54295, ("Sr", "I") : 3.74295, ("Sr", "N") : 3.09295, 276 | ("Sr", "P") : 3.43295, ("Sr", "As") : 3.62295, ("Sr", "H") : 2.87295, ("Ta", "O") : 2.74646, 277 | ("Ta", "S") : 2.84390, ("Ta", "F") : 2.25390, ("Ta", "Cl") : 2.67390, ("Ta", "Br") : 2.60642, 278 | ("Ta", "I") : 2.81642, ("Ta", "Se") : 2.66642, ("Ta", "Te") : 2.85642, ("Ta", "N") : 2.16642, 279 | ("Ta", "P") : 2.62642, ("Ta", "As") : 2.70642, ("Ta", "H") : 1.91642, ("Tb", "O") : 2.65549, 280 | ("Tb", "S") : 3.11649, ("Tb", "Se") : 3.23649, ("Tb", "Te") : 3.42649, ("Tb", "F") : 2.54249, 281 | ("Tb", "Cl") : 3.04349, ("Tb", "Br") : 3.18649, ("Tb", "I") : 3.40945, ("Tb", "N") : 2.80649, 282 | ("Tb", "P") : 3.19649, ("Tb", "As") : 3.26649, ("Tb", "H") : 2.51649, ("Tc", "O") : 2.22446, 283 | ("Tc", "F") : 2.24219, ("Tc", "Cl") : 2.56002, ("Te", "O") : 2.33340, ("Te", "S") : 2.79002, 284 | ("Te", "F") : 2.22002, ("Te", "Cl") : 2.73906, ("Te", "Br") : 2.90002, ("Te", "I") : 3.13702, 285 | ("Te", "Se") : 2.57998, ("Te", "Te") : 2.80998, ("Te", "N") : 2.16998, ("Te", "P") : 2.56998, 286 | ("Te", "H") : 1.87998, ("Th", "O") : 2.77349, ("Th", "S") : 3.24649, ("Th", "Se") : 3.36649, 287 | ("Th", "Te") : 3.54649, ("Th", "F") : 2.68945, ("Th", "Cl") : 3.15945, ("Th", "Br") : 3.31945, 288 | ("Th", "I") : 3.56649, ("Th", "N") : 2.94649, ("Th", "P") : 3.33649, ("Th", "As") : 3.40649, 289 | ("Th", "H") : 2.67649, ("Ti", "F") : 2.86293, ("Ti", "Cl") : 3.02293, ("Ti", "Br") : 3.20293, 290 | ("Ti", "O") : 2.35391, ("Ti", "S") : 2.74646, ("Ti", "I") : 3.08291, ("Ti", "Se") : 2.53642, 291 | ("Ti", "Te") : 2.95642, ("Ti", "N") : 2.08642, ("Ti", "P") : 2.51642, ("Ti", "As") : 2.87642, 292 | ("Ti", "H") : 1.76642, ("Tl", "O") : 3.36945, ("Tl", "S") : 3.66442, ("Tl", "F") : 3.26942, 293 | ("Tl", "Cl") : 3.72942, ("Tl", "Br") : 3.80942, ("Tl", "I") : 3.94142, ("Tl", "Se") : 3.00644, 294 | ("Tl", "Te") : 3.23644, ("Tl", "N") : 2.59644, ("Tl", "P") : 3.01644, ("Tl", "As") : 3.09644, 295 | ("Tl", "H") : 2.35644, ("Tm", "O") : 2.60649, ("Tm", "S") : 3.05649, ("Tm", "Se") : 3.18649, 296 | ("Tm", "Te") : 3.37649, ("Tm", "F") : 2.51649, ("Tm", "Cl") : 2.98944, ("Tm", "Br") : 3.13945, 297 | ("Tm", "I") : 3.37945, ("Tm", "N") : 2.74649, ("Tm", "P") : 3.13649, ("Tm", "As") : 3.22649, 298 | ("Tm", "H") : 2.45649, ( "U", "O") : 2.94295, ( "U", "S") : 3.25293, ( "U", "F") : 2.80293, 299 | ( "U", "Cl") : 3.24452, ( "U", "Br") : 3.39452, ( "U", "I") : 3.62452, ( "U", "N") : 2.78649, 300 | ( "U", "Se") : 3.00644, ( "U", "Te") : 3.16644, ( "U", "P") : 2.94644, ( "U", "As") : 3.02644, 301 | ( "U", "H") : 2.27644, ( "V", "O") : 2.84939, ( "V", "Cl") : 3.15293, ( "V", "S") : 2.82293, 302 | ( "V", "F") : 2.87293, ( "V", "Br") : 2.87329, ( "V", "N") : 2.38329, ( "V", "I") : 2.66642, 303 | ( "V", "Se") : 2.48642, ( "V", "Te") : 2.72642, ( "V", "P") : 2.46642, ( "V", "As") : 2.54642, 304 | ( "V", "H") : 1.73642, ( "W", "O") : 2.20102, ( "W", "F") : 2.03000, ( "W", "Cl") : 2.47000, 305 | ( "W", "Br") : 2.49998, ( "W", "I") : 2.70998, ( "W", "S") : 2.43998, ( "W", "Se") : 2.55998, 306 | ( "W", "Te") : 2.75998, ( "W", "N") : 2.10998, ( "W", "P") : 2.50998, ( "W", "As") : 2.58998, 307 | ( "W", "H") : 1.80998, ("Xe", "O") : 2.63451, ("Xe", "F") : 2.62649, ( "Y", "O") : 2.62549, 308 | ( "Y", "S") : 3.08649, ( "Y", "Se") : 3.21649, ( "Y", "Te") : 3.40649, ( "Y", "F") : 2.51049, 309 | ( "Y", "Cl") : 3.00649, ( "Y", "Br") : 3.15649, ( "Y", "I") : 3.37649, ( "Y", "N") : 2.77649, 310 | ( "Y", "P") : 3.17649, ( "Y", "As") : 3.24649, ( "Y", "H") : 2.46649, ("Yb", "O") : 2.74551, 311 | ("Yb", "N") : 2.84851, ("Yb", "S") : 3.03649, ("Yb", "Se") : 3.16649, ("Yb", "Te") : 3.36649, 312 | ("Yb", "F") : 2.50649, ("Yb", "Cl") : 2.98249, ("Yb", "Br") : 3.12945, ("Yb", "I") : 3.37945, 313 | ("Yb", "P") : 3.13649, ("Yb", "As") : 3.19649, ("Yb", "H") : 2.42649, ("Zn", "O") : 2.41693, 314 | ("Zn", "S") : 2.80293, ("Zn", "Se") : 2.93293, ("Zn", "Te") : 3.16293, ("Zn", "F") : 2.38293, 315 | ("Zn", "Cl") : 2.72293, ("Zn", "Br") : 2.86293, ("Zn", "I") : 3.07293, ("Zn", "N") : 2.43293, 316 | ("Zn", "P") : 2.86293, ("Zn", "As") : 2.95293, ("Zn", "H") : 2.13293, ("Zr", "O") : 3.09651, 317 | ("Zr", "F") : 2.99651, ("Zr", "Cl") : 3.33651, ("Zr", "S") : 2.91004, ("Zr", "Se") : 3.03004, 318 | ("Zr", "Te") : 3.17004, ("Zr", "Br") : 2.98004, ("Zr", "I") : 3.19004, ("Zr", "N") : 2.65004, 319 | ("Zr", "P") : 3.02004, ("Zr", "As") : 3.07004, ("Zr", "H") : 2.29004 320 | } 321 | 322 | ################################################################################ 323 | # END 324 | ################################################################################ 325 | 326 | import numpy as np 327 | from mayavi import mlab 328 | from ase.io import read 329 | 330 | import time 331 | 332 | def Mview(inf, repeat=(1,1,1), 333 | figname='kaka.png', figsize=(800, 800), 334 | bgcolor=(0,0,0), 335 | # showBox=True, 336 | arrow_color=(1,1,1), 337 | quiet=False, 338 | theta=90, phi=0, 339 | vibration=None, 340 | showcell=True, 341 | singleCell=True, 342 | cell_linewidth=0.02, 343 | cell_linecolor=(1,1,1), 344 | parallel_proj=True, 345 | volume_data=None, 346 | volume_iso_color=(1,1,1), 347 | ): 348 | ''' 349 | Using the mayavi to view the molecular structure. 350 | ''' 351 | # all_times = [] 352 | 353 | # read the POSCAR 354 | poscar = read(inf, format='vasp') 355 | # store the cell in case we need to make a supercell 356 | ucell = poscar.cell.copy() 357 | 358 | # set the vibrational vector to the velocity array so that the vibrational 359 | # vector will also be repeated when making supercells 360 | if vibration is not None: 361 | sqrt_mass_norm_vib = vibration / \ 362 | np.sqrt(poscar.get_masses())[:,np.newaxis] 363 | sqrt_mass_norm_vib /= np.linalg.norm(sqrt_mass_norm_vib) 364 | poscar.set_velocities(sqrt_mass_norm_vib) 365 | # repeat is not compatible with your atoms' constraints, remove it 366 | poscar.set_constraint() 367 | # making supercells 368 | poscar = poscar * repeat 369 | 370 | nions = len(poscar) 371 | atom_chem_symb = np.array(poscar.get_chemical_symbols()) 372 | uniq_atom_chem_symb = list(set(atom_chem_symb)) 373 | ntype = len(uniq_atom_chem_symb) 374 | atom_index = np.arange(nions, dtype=int) 375 | # index of atoms for each type of elements 376 | atom_type_integerID = dict([ 377 | (uniq_atom_chem_symb[itype], atom_index[atom_chem_symb == uniq_atom_chem_symb[itype]]) 378 | for itype in range(ntype) 379 | ]) 380 | # number of atoms for each type of elements 381 | atom_type_num = [len(atom_type_integerID[k]) for k in uniq_atom_chem_symb] 382 | 383 | # initialize the figure 384 | if quiet: 385 | mlab.options.offscreen = True 386 | fig = mlab.figure(1, bgcolor=bgcolor, size=figsize) 387 | mlab.clf() 388 | 389 | # all_times.append(time.time()) 390 | 391 | ############################################################ 392 | # Draw the cell box 393 | ############################################################ 394 | # Draw the unit cell: 395 | if showcell: 396 | if singleCell: 397 | Nx, Ny, Nz = (1,1,1) 398 | else: 399 | Nx, Ny, Nz = repeat 400 | fx = range(Nx + 1) 401 | fy = range(Ny + 1) 402 | fz = range(Nz + 1) 403 | Dxyz = np.array(np.meshgrid(fx, fy, fz, indexing='ij')) 404 | Cxyz = np.array(np.tensordot(ucell, Dxyz, axes=(0,0))) 405 | Dxyz = Dxyz.reshape((3, -1)) 406 | Cxyz = Cxyz.reshape((3, -1)) 407 | 408 | conn = [] 409 | cpts = Dxyz.shape[1] 410 | for ii in range(cpts): 411 | for jj in range(ii): 412 | L = Dxyz[:,ii] - Dxyz[:,jj] 413 | # only connect the nearest cell boundary point 414 | if list(L).count(0) == 2: 415 | conn.append((ii,jj)) 416 | cell_box = mlab.plot3d(Cxyz[0], Cxyz[1], Cxyz[2], 417 | tube_radius=cell_linewidth, 418 | color=cell_linecolor, 419 | name='CellBox' 420 | ) 421 | cell_box.mlab_source.dataset.lines = np.array(conn) 422 | 423 | ############################################################ 424 | # Draw the cell box, code extracted from ASE 425 | ############################################################ 426 | # A = ucell 427 | # for i1, a in enumerate(A): 428 | # i2 = (i1 + 1) % 3 429 | # i3 = (i1 + 2) % 3 430 | # for b in [np.zeros(3), A[i2]]: 431 | # for c in [np.zeros(3), A[i3]]: 432 | # p1 = b + c 433 | # p2 = p1 + a 434 | # mlab.plot3d([p1[0], p2[0]], 435 | # [p1[1], p2[1]], 436 | # [p1[2], p2[2]], 437 | # tube_radius=cell_linewidth) 438 | 439 | # all_times.append(time.time()) 440 | ############################################################ 441 | # plot the atoms for each type 442 | ############################################################ 443 | for itype in range(ntype): 444 | # element name for this type 445 | typeName = uniq_atom_chem_symb[itype] 446 | # index for this type 447 | typeID = atom_type_integerID[typeName] 448 | # number of elements for this type 449 | typeNo = atom_type_num[itype] 450 | # the coordinates for this type 451 | typePos = poscar.positions[typeID] 452 | # the atom color for this type 453 | typeClr = pt_atomic_color[pt_atomic_name.index(typeName)] 454 | # the atom radius for this type 455 | typeRad = pt_atomic_radius[pt_atomic_name.index(typeName)] 456 | 457 | # for each type of atoms 458 | mlab.points3d(typePos[:,0], typePos[:,1], typePos[:,2], 459 | np.ones(typeNo) * typeRad, 460 | color=typeClr, resolution=60, 461 | scale_factor=1.0, 462 | name="AtomSphere_{}".format(typeName)) 463 | 464 | # Another way to plot the atoms is to iterate over the number of atoms, which is 465 | # a lot slower than iterate over the number of types. 466 | # for ii in range(nions): 467 | # atom = mlab.points3d([px[ii]], [py[ii]], [pz[ii]], 468 | # [atomsSize[ii]], 469 | # color=tuple(atomsColor[ii]), 470 | # resolution=60, 471 | # scale_factor=1.0) 472 | 473 | # all_times.append(time.time()) 474 | 475 | ############################################################ 476 | # plot the bonds 477 | ############################################################ 478 | # first, find out the possible comibnations 479 | type_of_bonds = [] 480 | bond_max_of_each_type = [] 481 | 482 | for ii in range(ntype): 483 | for jj in range(ii + 1): 484 | A = uniq_atom_chem_symb[ii] 485 | B = uniq_atom_chem_symb[jj] 486 | 487 | # check if A and B can form a bond 488 | if (A, B) in pt_max_bond: 489 | AB = (A, B) 490 | elif (B, A) in pt_max_bond: 491 | AB = (B, A) 492 | else: 493 | AB = None 494 | 495 | if AB is not None: 496 | type_of_bonds.append((A, B)) 497 | bond_max_of_each_type.append(pt_max_bond[AB]) 498 | 499 | ############################################################ 500 | # second, connect each possible bond 501 | ############################################################ 502 | 503 | # Again, iterate over the bonds is a lot slower than iterate over the types of 504 | # bonds. 505 | n_type_bonds = len(type_of_bonds) 506 | for itype in range(n_type_bonds): 507 | A, B = type_of_bonds[itype] 508 | L = bond_max_of_each_type[itype] 509 | 510 | A_ID = uniq_atom_chem_symb.index(A) 511 | B_ID = uniq_atom_chem_symb.index(B) 512 | 513 | A_atom_IDs = atom_type_integerID[A] 514 | B_atom_IDs = atom_type_integerID[B] 515 | 516 | # find out all the possible bonds: A-B 517 | ijs = [] 518 | if A == B: 519 | A_atom_Num = atom_type_num[A_ID] 520 | for ii in range(A_atom_Num): 521 | for jj in range(ii): 522 | if poscar.get_distance(A_atom_IDs[ii], B_atom_IDs[jj]) < L: 523 | ijs.append((A_atom_IDs[ii], B_atom_IDs[jj])) 524 | else: 525 | for ii in A_atom_IDs: 526 | for jj in B_atom_IDs: 527 | if poscar.get_distance(ii, jj) < L: 528 | ijs.append((ii, jj)) 529 | ijs = np.array(ijs, dtype=int) 530 | 531 | if ijs.size > 0: 532 | A_color = pt_atomic_color[pt_atomic_name.index(A)] 533 | B_color = pt_atomic_color[pt_atomic_name.index(B)] 534 | 535 | p_A = poscar.positions[ijs[:,0]] 536 | p_B = poscar.positions[ijs[:,1]] 537 | # The coordinate of the middle point in the bond A-B 538 | p_M = (p_A + p_B) / 2. 539 | p_T = np.zeros((ijs.shape[0] * 2, 3)) 540 | p_T[1::2,:] = p_M 541 | # only connect the bonds 542 | bond_connectivity = np.vstack( 543 | [range(0,2*ijs.shape[0],2), 544 | range(1,2*ijs.shape[0],2)] 545 | ).T 546 | 547 | # plot the first half of the bond: A-M 548 | p_T[0::2,:] = p_A 549 | bond_A = mlab.plot3d(p_T[:,0], p_T[:,1], p_T[:,2], 550 | tube_radius=0.1, color=A_color, 551 | name="Bonds_{}-{}".format(A,B)) 552 | bond_A.mlab_source.dataset.lines = bond_connectivity 553 | # plot the second half of the bond: M-B 554 | p_T[0::2,:] = p_B 555 | bond_B = mlab.plot3d(p_T[:,0], p_T[:,1], p_T[:,2], 556 | tube_radius=0.1, color=B_color, 557 | name="Bonds_{}-{}".format(A,B)) 558 | bond_B.mlab_source.dataset.lines = bond_connectivity 559 | 560 | ############################################################ 561 | # Show the vibration mode by arrows 562 | ############################################################ 563 | if vibration is not None: 564 | p, v = poscar.get_positions(), poscar.get_velocities() 565 | arrow = mlab.quiver3d( 566 | p[:,0], p[:,1], p[:,2], 567 | v[:,0], v[:,1], v[:,2], 568 | color=arrow_color, 569 | mode='arrow', 570 | name="VibrationMode", 571 | # scale_factor=1.0, 572 | ) 573 | arrow.glyph.glyph_source.glyph_position = 'tail' 574 | # arrow.glyph.glyph_source.glyph_source = arrow.glyph.glyph_source.glyph_dict['arrow_source'] 575 | 576 | ############################################################ 577 | # Show the volumetric data 578 | ############################################################ 579 | if volume_data is not None: 580 | Nx, Ny, Nz = volume_data.shape 581 | Cx, Cy, Cz = np.tensordot( 582 | ucell, 583 | np.mgrid[0:1:Nx*1j, 0:1:Ny*1j, 0:1:Nz*1j], 584 | axes=(0,0)) 585 | vol = mlab.contour3d( 586 | Cx, Cy, Cz, volume_data, 587 | color=volume_iso_color, 588 | transparent=True, 589 | name="VolumeData", 590 | ) 591 | 592 | # all_times.append(time.time()) 593 | # print(np.diff(all_times)) 594 | 595 | if parallel_proj: 596 | fig.scene.parallel_projection = True 597 | else: 598 | fig.scene.parallel_projection = False 599 | 600 | mlab.orientation_axes() 601 | mlab.view(azimuth=phi, elevation=theta) 602 | fig.scene.render() 603 | mlab.savefig(figname) 604 | 605 | if not quiet: 606 | mlab.show() 607 | 608 | return 609 | 610 | def load_vibmodes_from_outcar(inf='OUTCAR', include_imag=True): 611 | ''' 612 | Read vibration eigenvectors and eigenvalues from OUTCAR. 613 | ''' 614 | 615 | out = [line for line in open(inf) if line.strip()] 616 | ln = len(out) 617 | for line in out: 618 | if "NIONS =" in line: 619 | nions = int(line.split()[-1]) 620 | break 621 | 622 | THz_index = [] 623 | found_vib_mode = False 624 | for ii in range(ln-1,0,-1): 625 | if '2PiTHz' in out[ii]: 626 | THz_index.append(ii) 627 | if 'Eigenvectors and eigenvalues' in out[ii]: 628 | i_index = ii + 2 629 | found_vib_mode = True 630 | break 631 | if not found_vib_mode: 632 | raise IOError("Can not find vibration normal mode in {}.".format(inf)) 633 | 634 | j_index = THz_index[0] + nions + 2 635 | 636 | real_freq = [False if 'f/i' in line else True 637 | for line in out[i_index:j_index] 638 | if '2PiTHz' in line] 639 | 640 | omegas = [line.split()[ -4] for line in out[i_index:j_index] 641 | if '2PiTHz' in line] 642 | modes = [line.split()[3:6] for line in out[i_index:j_index] 643 | if ('dx' not in line) and ('2PiTHz' not in line)] 644 | 645 | omegas = np.array(omegas, dtype=float) 646 | modes = np.array(modes, dtype=float).reshape((-1, nions, 3)) 647 | 648 | if not include_imag: 649 | omegas = omegas[real_freq] 650 | modes = modes[real_freq] 651 | 652 | return omegas, modes 653 | 654 | def str2bool(v): 655 | if v.lower() in ('yes', 'true', 't', 'y', '1'): 656 | return True 657 | elif v.lower() in ('no', 'false', 'f', 'n', '0'): 658 | return False 659 | else: 660 | raise argparse.ArgumentTypeError('Boolean value expected.') 661 | 662 | def main(cml): 663 | import argparse, os 664 | 665 | arg = argparse.ArgumentParser() 666 | 667 | arg.add_argument('-i', action='store', dest='inf', type=str, 668 | default="POSCAR", 669 | help="File containing the molecular structure.") 670 | arg.add_argument('-r', action='store', dest='repeat', nargs=3, 671 | type=int, default=(1,1,1), 672 | help="Makding a supercell.") 673 | arg.add_argument('-o', action='store', dest='outImg', 674 | type=str, default='kaka.jpeg', 675 | help="Output image name.") 676 | arg.add_argument('-s', action='store', dest='outImgSize', nargs=2, 677 | type=int, default=(2000, 2000), 678 | help="Output image size.") 679 | arg.add_argument('-bg', action='store', dest='bgcolor', nargs=3, 680 | type=int, default=(0,0,0), 681 | help="Background Color.") 682 | arg.add_argument('-showcell', action='store', dest='showcell', type=str2bool, 683 | default=True, 684 | help='Draw a box of the cell.') 685 | arg.add_argument('-singleCell', action='store', dest='singleCell', type=str2bool, 686 | default=False, 687 | help='Draw all the cell box when making supercell.') 688 | arg.add_argument('-pp', action='store', dest='parallel_proj', type=str2bool, 689 | default=True, 690 | help='Parallel projection?') 691 | arg.add_argument('-clw', action='store', dest='cell_linewidth', 692 | type=float, default=0.05, 693 | help="Cell box line width.") 694 | arg.add_argument('-clc', action='store', dest='cell_linecolor', nargs=3, 695 | type=int, default=(255, 255, 255), 696 | help="Cell box line color.") 697 | arg.add_argument('-q', '-quiet', action='store_true', dest='quiet', 698 | default=False, 699 | help='Not show mayavi UI.') 700 | 701 | arg.add_argument('-outcar', action='store', dest='outcar', type=str, 702 | default="OUTCAR", 703 | help="OUTCAR files that contains the vibrational normal mode.") 704 | arg.add_argument('-n', action='store', dest='nvib', type=int, 705 | default=0, 706 | help="Show which normal mode.") 707 | arg.add_argument('-vcolor', action='store', dest='vcolor', nargs=3, 708 | type=int, default=(255, 255, 255), 709 | help="Vibrational arrow color.") 710 | 711 | arg.add_argument('-chgcar', action='store', dest='chgcar', type=str, 712 | default=None, 713 | help="Location of VASP CHGCAR-like files.") 714 | arg.add_argument('-isocolor', action='store', dest='volume_iso_color', nargs=3, 715 | type=int, default=(255, 255, 255), 716 | help="Color of iso-surface.") 717 | 718 | arg.add_argument('-phi', action='store', dest='phi', 719 | type=float, default=0, 720 | help="Azimuth view angle.") 721 | arg.add_argument('-theta', action='store', dest='theta', 722 | type=float, default=90, 723 | help="Elevation view angle.") 724 | p = arg.parse_args(cml) 725 | 726 | if p.nvib > 0: 727 | if os.path.isfile('modes.npy'): 728 | vmode = np.load('modes.npy')[p.nvib - 1] 729 | else: 730 | omega, modes = load_vibmodes_from_outcar(p.outcar) 731 | np.save('modes.npy', modes) 732 | vmode = modes[p.nvib - 1] 733 | else: 734 | vmode = None 735 | 736 | chg = None 737 | if p.chgcar is not None: 738 | if os.path.isfile(p.chgcar): 739 | from ase.calculators.vasp import VaspChargeDensity 740 | chg = VaspChargeDensity(p.chgcar).chg[0] 741 | 742 | Mview(p.inf, repeat=p.repeat, figname=p.outImg, figsize=p.outImgSize, 743 | bgcolor=tuple([c/255. for c in p.bgcolor]), 744 | vibration=vmode, 745 | arrow_color=tuple([c/255. for c in p.vcolor]), 746 | phi=p.phi, theta=p.theta, 747 | quiet=p.quiet, 748 | showcell=p.showcell, 749 | singleCell=p.singleCell, 750 | cell_linewidth=p.cell_linewidth, 751 | cell_linecolor=tuple([c/255. for c in p.cell_linecolor]), 752 | parallel_proj=p.parallel_proj, 753 | volume_data=chg, 754 | volume_iso_color=tuple([c/255. for c in p.volume_iso_color]), 755 | ) 756 | 757 | if __name__ == '__main__': 758 | import sys 759 | main(sys.argv[1:]) 760 | -------------------------------------------------------------------------------- /vasp2xsf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import sys 6 | import argparse 7 | import numpy as np 8 | from ase.io import read 9 | 10 | 11 | def load_vibmodes_from_outcar(inf='OUTCAR', include_imag=True): 12 | ''' 13 | Read vibration eigenvectors and eigenvalues from OUTCAR. 14 | ''' 15 | 16 | out = [line for line in open(inf) if line.strip()] 17 | ln = len(out) 18 | for line in out: 19 | if "NIONS =" in line: 20 | nions = int(line.split()[-1]) 21 | break 22 | 23 | THz_index = [] 24 | for ii in range(ln-1, 0, -1): 25 | if '2PiTHz' in out[ii]: 26 | THz_index.append(ii) 27 | if 'Eigenvectors and eigenvalues' in out[ii]: 28 | i_index = ii + 2 29 | break 30 | j_index = THz_index[0] + nions + 2 31 | 32 | real_freq = [False if 'f/i' in line else True 33 | for line in out[i_index:j_index] 34 | if '2PiTHz' in line] 35 | 36 | omegas = [line.split()[-4] for line in out[i_index:j_index] 37 | if '2PiTHz' in line] 38 | modes = [line.split()[3:6] for line in out[i_index:j_index] 39 | if ('dx' not in line) and ('2PiTHz' not in line)] 40 | 41 | omegas = np.array(omegas) 42 | modes = np.array(modes).reshape((-1, nions, 3)) 43 | 44 | if include_imag: 45 | omegas = omegas[real_freq] 46 | modes = modes[real_freq] 47 | 48 | return omegas, modes 49 | 50 | 51 | def parse_cml_args(cml): 52 | ''' 53 | CML parser. 54 | ''' 55 | arg = argparse.ArgumentParser(add_help=True) 56 | 57 | arg.add_argument('-i', dest='outcar', action='store', type=str, 58 | default='OUTCAR', 59 | help='Location of VASP OUTCAR.') 60 | arg.add_argument('-p', dest='poscar', action='store', type=str, 61 | default='POSCAR', 62 | help='Location of VASP POSCAR.') 63 | arg.add_argument('-m', dest='mode', action='store', type=int, 64 | default=0, 65 | help='Select the vibration mode, 0 for all modes.') 66 | arg.add_argument('-s', dest='scale', action='store', type=float, 67 | default=1.0, 68 | help='Scale factor of the vector field.') 69 | 70 | return arg.parse_args(cml) 71 | 72 | 73 | def write_xsf(imode, atoms, vector, scale=1.0): 74 | """ 75 | Write the position and vector field in XSF format. 76 | """ 77 | 78 | vector = np.asarray(vector, dtype=float) * scale 79 | assert vector.shape == atoms.positions.shape 80 | pos_vec = np.hstack((atoms.positions, vector)) 81 | nions = pos_vec.shape[0] 82 | chem_symbs = atoms.get_chemical_symbols() 83 | with open('mode_{:04d}.xsf'.format(imode), 'w') as out: 84 | line = "CRYSTAL\n" 85 | line += "PRIMVEC\n" 86 | line += '\n'.join([ 87 | ' '.join(['%21.16f' % a for a in vec]) 88 | for vec in atoms.cell 89 | ]) 90 | line += "\nPRIMCOORD\n" 91 | line += "{:3d} {:d}\n".format(nions, 1) 92 | line += '\n'.join([ 93 | '{:3s}'.format(chem_symbs[ii]) + 94 | ' '.join(['%21.16f' % a for a in pos_vec[ii]]) 95 | for ii in range(nions) 96 | ]) 97 | 98 | out.write(line) 99 | 100 | 101 | def main(cml): 102 | p = parse_cml_args(cml) 103 | 104 | atoms = read(p.poscar, format='vasp') 105 | assert 0 <= p.mode <= atoms.get_number_of_atoms() 106 | if not os.path.isfile('modes.npy'): 107 | omegas, modes = load_vibmodes_from_outcar(p.outcar) 108 | np.save('OMEGAS', omegas) 109 | np.save('MODES', modes) 110 | else: 111 | omegas = np.load('OMEGAS.npy') 112 | modes = np.load('MODES.npy') 113 | 114 | n_mode = len(omegas) 115 | if p.mode == 0: 116 | for ii in range(n_mode): 117 | write_xsf(ii+1, atoms, modes[ii], p.scale) 118 | else: 119 | write_xsf(p.mode, atoms, modes[p.mode - 1], p.scale) 120 | 121 | 122 | if __name__ == "__main__": 123 | main(sys.argv[1:]) 124 | --------------------------------------------------------------------------------