User Guides Read Functions
molecule_lib Read Functions
These functions will read a file and return the respective object if the file fufills the filetype requirements. See the Reference/Functions page for more detail.
molecule_lib Functions that return...
ABCMolecule objects:
XYZMolecule objects:
Animation objects that are returned:
- read_xdatcar returns ABCAnimation
- read_xyz_animation returns XYZAnimation
Example Usage
read_functions_example.py
from molecule_lib import *
# example usage of reading a .vasp file, converting to .xyz and saving the .xyz file
vasp_file = read_vasp(filepath="test_files/slabs/a-001.vasp") # reading vasp slab
print("read_vasp() ABCMolecule Info:")
vasp_file.info() # prints out information of Molecule object
xyz_file = vasp_file.convert() # converting slab in vasp format to xyz format
print("read_xyz() XYZMolecule Info:")
xyz_file.info() # prints out information of Molecule object
xyz_file.to_xyz(filename="a-001.xyz") # saving converted object to xyz file
Terminal Output from read_functions_example.py
read_vasp() ABCMolecule Info:
type: ABCMolecule
filetype: .vasp
total atoms: 96
species info: {'Al': '24', 'O': '48', 'H': '24'}
comment line: '3_OPT_cell (Generated by CrystalMaker X for Windows)'
lattice constant: 1.0
lattice matrix:
[8.7807035882, 0.1780459095, 3.7774054998]
[-1.0698364258, 0.1158044938, -9.5608328356]
[-0.9853331692, 23.1955056605, -0.2016342785]
positional: True
read_xyz() XYZMolecule Info:
type: XYZMolecule
filetype: .vasp
total atoms: 96
species info: {'Al': '24', 'O': '48', 'H': '24'}
comment line: '3_OPT_cell (Generated by CrystalMaker X for Windows)'
Initial Vasp File
a-001.vasp
3_OPT_cell (Generated by CrystalMaker X for Windows)
1.0
8.7807035882 0.1780459095 3.7774054998
-1.0698364258 0.1158044938 -9.5608328356
-0.9853331692 23.1955056605 -0.2016342785
Al O H
24 48 24
Direct
0.4883770000 0.4991110000 0.4120980000
0.4883770000 0.9991110000 0.4120980000
0.9883770000 0.4991110000 0.4120980000
0.9883770000 0.9991110000 0.4120980000
0.4937535000 0.4900390000 0.5858550000
0.4937535000 0.9900390000 0.5858550000
0.9937535000 0.4900390000 0.5858550000
0.9937535000 0.9900390000 0.5858550000
0.3246275000 0.1543390000 0.6004500000
0.3246275000 0.6543390000 0.6004500000
0.8246275000 0.1543390000 0.6004500000
0.8246275000 0.6543390000 0.6004500000
0.3233475000 0.1606580000 0.4875070000
0.3233475000 0.6606580000 0.4875070000
0.8233475000 0.1606580000 0.4875070000
0.8233475000 0.6606580000 0.4875070000
0.1541040000 0.3308545000 0.3982010000
0.1541040000 0.8308545000 0.3982010000
0.6541040000 0.3308545000 0.3982010000
0.6541040000 0.8308545000 0.3982010000
0.1568155000 0.3269960000 0.5109870000
0.1568155000 0.8269960000 0.5109870000
0.6568155000 0.3269960000 0.5109870000
0.6568155000 0.8269960000 0.5109870000
0.4993540000 0.3291830000 0.4519950000
0.4993540000 0.8291830000 0.4519950000
0.9993540000 0.3291830000 0.4519950000
0.9993540000 0.8291830000 0.4519950000
0.1540070000 0.1732485000 0.4520950000
0.1540070000 0.6732485000 0.4520950000
0.6540070000 0.1732485000 0.4520950000
0.6540070000 0.6732485000 0.4520950000
0.3118170000 0.4852300000 0.4521950000
0.3118170000 0.9852300000 0.4521950000
0.8118170000 0.4852300000 0.4521950000
0.8118170000 0.9852300000 0.4521950000
0.4798760000 0.1573710000 0.5458360000
0.4798760000 0.6573710000 0.5458360000
0.9798760000 0.1573710000 0.5458360000
0.9798760000 0.6573710000 0.5458360000
0.3260795000 0.3148100000 0.5463350000
0.3260795000 0.8148100000 0.5463350000
0.8260795000 0.3148100000 0.5463350000
0.8260795000 0.8148100000 0.5463350000
0.1698015000 0.0035290000 0.5457890000
0.1698015000 0.5035290000 0.5457890000
0.6698015000 0.0035290000 0.5457890000
0.6698015000 0.5035290000 0.5457890000
0.1374020000 0.4910515000 0.3597130000
0.1374020000 0.9910515000 0.3597130000
0.6374020000 0.4910515000 0.3597130000
0.6374020000 0.9910515000 0.3597130000
0.4842285000 0.1648825000 0.3593080000
0.4842285000 0.6648825000 0.3593080000
0.9842285000 0.1648825000 0.3593080000
0.9842285000 0.6648825000 0.3593080000
0.3274385000 0.3526040000 0.3600150000
0.3274385000 0.8526040000 0.3600150000
0.8274385000 0.3526040000 0.3600150000
0.8274385000 0.8526040000 0.3600150000
0.3351940000 0.4891400000 0.6387780000
0.3351940000 0.9891400000 0.6387780000
0.8351940000 0.4891400000 0.6387780000
0.8351940000 0.9891400000 0.6387780000
0.4949070000 0.3255040000 0.6355830000
0.4949070000 0.8255040000 0.6355830000
0.9949070000 0.3255040000 0.6355830000
0.9949070000 0.8255040000 0.6355830000
0.1539585000 0.1412000000 0.6386320000
0.1539585000 0.6412000000 0.6386320000
0.6539585000 0.1412000000 0.6386320000
0.6539585000 0.6412000000 0.6386320000
0.2489850000 0.5742065000 0.3541710000
0.2489850000 0.0742065000 0.3541710000
0.7489850000 0.0742065000 0.3541710000
0.7489850000 0.5742065000 0.3541710000
0.0105670000 0.1420440000 0.3218080000
0.0105670000 0.6420440000 0.3218080000
0.5105670000 0.1420440000 0.3218080000
0.5105670000 0.6420440000 0.3218080000
0.3593145000 0.2727825000 0.3528190000
0.3593145000 0.7727825000 0.3528190000
0.8593145000 0.2727825000 0.3528190000
0.8593145000 0.7727825000 0.3528190000
0.3919260000 0.0214090000 0.6755300000
0.3919260000 0.5214090000 0.6755300000
0.8919260000 0.0214090000 0.6755300000
0.8919260000 0.5214090000 0.6755300000
0.0152975000 0.3539400000 0.6757480000
0.0152975000 0.8539400000 0.6757480000
0.5152975000 0.3539400000 0.6757480000
0.5152975000 0.8539400000 0.6757480000
0.1588230000 0.2458695000 0.6383440000
0.1588230000 0.7458695000 0.6383440000
0.6588230000 0.2458695000 0.6383440000
0.6588230000 0.7458695000 0.6383440000
Converted XYZ File
a-001.xyz
96
3_OPT_cell (Generated by CrystalMaker X for Windows)
Al 1.741640 4.323477 8.312563
Al -0.637363 8.504651 8.312563
Al 6.521840 4.323477 8.312563
Al 4.142837 8.504651 8.312563
Al 1.836206 4.310749 11.817471
Al -0.542797 8.491923 11.817471
Al 6.616406 4.310749 11.817471
Al 4.237403 8.491923 11.817471
Al 1.816557 1.508812 12.111872
Al -0.562446 5.689986 12.111872
Al 6.596757 1.508812 12.111872
Al 4.217754 5.689986 12.111872
Al 1.774254 1.520616 9.833662
Al -0.604749 5.701790 9.833662
Al 6.554454 1.520616 9.833662
Al 4.175451 5.701790 9.833662
Al -0.653578 2.911408 8.032242
Al -3.032581 7.092582 8.032242
Al 4.126622 2.911408 8.032242
Al 1.747619 7.092582 8.032242
Al -0.609296 2.920124 10.307285
Al -2.988299 7.101298 10.307285
Al 4.170904 2.920124 10.307285
Al 1.791901 7.101298 10.307285
O 2.655103 2.916977 9.117338
O 0.276100 7.098151 9.117338
O 7.435303 2.916977 9.117338
O 5.056300 7.098151 9.117338
O 0.095385 1.613035 9.119355
O -2.283618 5.794209 9.119355
O 4.875585 1.613035 9.119355
O 2.496582 5.794209 9.119355
O 0.119702 4.221969 9.121372
O -2.259301 8.403143 9.121372
O 4.899902 4.221969 9.121372
O 2.520899 8.403143 9.121372
O 3.286368 1.514323 11.010235
O 0.907365 5.695497 11.010235
O 8.066568 1.514323 11.010235
O 5.687565 5.695497 11.010235
O 1.066917 2.831064 11.020301
O -1.312086 7.012238 11.020301
O 5.847117 2.831064 11.020301
O 3.468114 7.012238 11.020301
O 1.053913 0.227825 11.009287
O -1.325090 4.408999 11.009287
O 5.834113 0.227825 11.009287
O 3.455110 4.408999 11.009287
O -1.575474 4.237047 7.255888
O -3.954477 8.418221 7.255888
O 3.204726 4.237047 7.255888
O 0.825723 8.418221 7.255888
O 3.292240 1.509361 7.247718
O 0.913237 5.690535 7.247718
O 8.072440 1.509361 7.247718
O 5.693437 5.690535 7.247718
O 0.900085 3.079410 7.261979
O -1.478918 7.260584 7.261979
O 5.680285 3.079410 7.261979
O 3.301282 7.260584 7.261979
O 0.324592 4.322461 12.884998
O -2.054411 8.503635 12.884998
O 5.104792 4.322461 12.884998
O 2.725789 8.503635 12.884998
O 2.630093 2.952919 12.820551
O 0.251090 7.134093 12.820551
O 7.410293 2.952919 12.820551
O 5.031290 7.134093 12.820551
O 0.247408 1.412813 12.882053
O -2.131595 5.593987 12.882053
O 5.027608 1.412813 12.882053
O 2.648605 5.593987 12.882053
H -0.904348 4.930404 7.144098
H 1.474655 0.749230 7.144098
H 6.254855 0.749230 7.144098
H 3.875852 4.930404 7.144098
H -1.127487 1.304752 6.491294
H -3.506490 5.485926 6.491294
H 3.652713 1.304752 6.491294
H 1.273710 5.485926 6.491294
H 1.584624 2.409300 7.116827
H -0.794379 6.590474 7.116827
H 6.364824 2.409300 7.116827
H 3.985821 6.590474 7.116827
H 3.092439 0.424486 13.626335
H 0.713436 4.605660 13.626335
H 7.872639 0.424486 13.626335
H 5.493636 4.605660 13.626335
H -2.090464 3.205305 13.630732
H -4.469467 7.386479 13.630732
H 2.689736 3.205305 13.630732
H 0.310733 7.386479 13.630732
H -0.204103 2.287991 12.876244
H -2.583106 6.469165 12.876244
H 4.576097 2.287991 12.876244
H 2.197094 6.469165 12.876244