Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
from pymatgen.core.structure import Structure
from pymatgen.core.periodic_table import Element
from pymatgen.analysis.structure_analyzer import oxide_type
s = Structure.from_file('POSCAR')
print(isinstance(s.composition.elements[0], Element))
oxide_type(s)
-----------POSCAR--------
K1 H85 Pb18 C17 I54 N34
1.0
8.660300 0.000000 0.000000
-12.990450 22.500120 0.000000
0.000000 0.000000 23.706601
K H Pb C I N
1 85 18 17 54 34
direct
0.666670 0.444440 0.551640 K
0.402160 0.199747 0.051643 H
0.402160 0.199747 0.384977 H
0.402160 0.199747 0.718310 H
0.402160 0.533080 0.051643 H
0.402160 0.533080 0.384977 H
0.402160 0.533080 0.718310 H
0.402160 0.866413 0.051643 H
0.402160 0.866413 0.384977 H
0.402160 0.866413 0.718310 H
0.350040 0.298137 0.051747 H
0.350040 0.298137 0.385080 H
0.350040 0.298137 0.718413 H
0.350040 0.631470 0.051747 H
0.350040 0.631470 0.385080 H
0.350040 0.631470 0.718413 H
0.350040 0.964803 0.051747 H
0.350040 0.964803 0.385080 H
0.350040 0.964803 0.718413 H
0.541210 0.299360 0.051827 H
0.541210 0.299360 0.385160 H
0.541210 0.299360 0.718493 H
0.541210 0.632693 0.051827 H
0.541210 0.632693 0.385160 H
0.541210 0.632693 0.718493 H
0.541210 0.966027 0.051827 H
0.541210 0.966027 0.385160 H
0.541210 0.966027 0.718493 H
0.103410 0.153050 0.051643 H
0.103410 0.153050 0.384977 H
0.103410 0.153050 0.718310 H
0.103410 0.486383 0.051643 H
0.103410 0.486383 0.384977 H
0.103410 0.486383 0.718310 H
0.103410 0.819717 0.051643 H
0.103410 0.819717 0.384977 H
0.103410 0.819717 0.718310 H
0.106100 0.216643 0.051643 H
0.106100 0.216643 0.384977 H
0.106100 0.216643 0.718310 H
0.106100 0.549977 0.051643 H
0.106100 0.549977 0.384977 H
0.106100 0.549977 0.718310 H
0.106100 0.883310 0.051643 H
0.106100 0.883310 0.384977 H
0.106100 0.883310 0.718310 H
0.801750 0.133250 0.218310 H
0.801750 0.133250 0.551643 H
0.801750 0.133250 0.884977 H
0.801750 0.466583 0.218310 H
0.801750 0.466583 0.884977 H
0.801750 0.799917 0.218310 H
0.801750 0.799917 0.551643 H
0.801750 0.799917 0.884977 H
0.455720 0.116923 0.218247 H
0.455720 0.116923 0.551580 H
0.455720 0.116923 0.884913 H
0.455720 0.450257 0.218247 H
0.455720 0.450257 0.884913 H
0.455720 0.783590 0.218247 H
0.455720 0.783590 0.551580 H
0.455720 0.783590 0.884913 H
0.645180 0.180123 0.218267 H
0.645180 0.180123 0.551600 H
0.645180 0.180123 0.884933 H
0.645180 0.513457 0.218267 H
0.645180 0.513457 0.884933 H
0.645180 0.846790 0.218267 H
0.645180 0.846790 0.551600 H
0.645180 0.846790 0.884933 H
0.643380 0.034047 0.218310 H
0.643380 0.034047 0.551643 H
0.643380 0.034047 0.884977 H
0.643380 0.367380 0.218310 H
0.643380 0.367380 0.884977 H
0.643380 0.700713 0.218310 H
0.643380 0.700713 0.551643 H
0.643380 0.700713 0.884977 H
0.455780 0.034807 0.218310 H
0.455780 0.034807 0.551643 H
0.455780 0.034807 0.884977 H
0.455780 0.368140 0.218310 H
0.455780 0.368140 0.884977 H
0.455780 0.701473 0.218310 H
0.455780 0.701473 0.551643 H
0.455780 0.701473 0.884977 H
0.000000 0.000000 0.002000 Pb
0.000000 0.000000 0.335333 Pb
0.000000 0.000000 0.668667 Pb
0.000000 0.333333 0.002000 Pb
0.000000 0.333333 0.335333 Pb
0.000000 0.333333 0.668667 Pb
0.000000 0.666667 0.002000 Pb
0.000000 0.666667 0.335333 Pb
0.000000 0.666667 0.668667 Pb
0.000000 0.000000 0.168667 Pb
0.000000 0.000000 0.502000 Pb
0.000000 0.000000 0.835333 Pb
0.000000 0.333333 0.168667 Pb
0.000000 0.333333 0.502000 Pb
0.000000 0.333333 0.835333 Pb
0.000000 0.666667 0.168667 Pb
0.000000 0.666667 0.502000 Pb
0.000000 0.666667 0.835333 Pb
0.333333 0.222222 0.051643 C
0.333333 0.222222 0.384977 C
0.333333 0.222222 0.718310 C
0.333333 0.555556 0.051643 C
0.333333 0.555556 0.384977 C
0.333333 0.555556 0.718310 C
0.333333 0.888889 0.051643 C
0.333333 0.888889 0.384977 C
0.333333 0.888889 0.718310 C
0.666667 0.111111 0.218310 C
0.666667 0.111111 0.551643 C
0.666667 0.111111 0.884977 C
0.666667 0.444444 0.218310 C
0.666667 0.444444 0.884977 C
0.666667 0.777778 0.218310 C
0.666667 0.777778 0.551643 C
0.666667 0.777778 0.884977 C
0.831170 0.056277 0.083667 I
0.831170 0.056277 0.417000 I
0.831170 0.056277 0.750333 I
0.831170 0.389610 0.083667 I
0.831170 0.389610 0.417000 I
0.831170 0.389610 0.750333 I
0.831170 0.722943 0.083667 I
0.831170 0.722943 0.417000 I
0.831170 0.722943 0.750333 I
0.831170 0.220780 0.083667 I
0.831170 0.220780 0.417000 I
0.831170 0.220780 0.750333 I
0.831170 0.554113 0.083667 I
0.831170 0.554113 0.417000 I
0.831170 0.554113 0.750333 I
0.831170 0.887447 0.083667 I
0.831170 0.887447 0.417000 I
0.831170 0.887447 0.750333 I
0.337660 0.056277 0.083667 I
0.337660 0.056277 0.417000 I
0.337660 0.056277 0.750333 I
0.337660 0.389610 0.083667 I
0.337660 0.389610 0.417000 I
0.337660 0.389610 0.750333 I
0.337660 0.722943 0.083667 I
0.337660 0.722943 0.417000 I
0.337660 0.722943 0.750333 I
0.168830 0.277057 0.250333 I
0.168830 0.277057 0.583667 I
0.168830 0.277057 0.917000 I
0.168830 0.610390 0.250333 I
0.168830 0.610390 0.583667 I
0.168830 0.610390 0.917000 I
0.168830 0.943723 0.250333 I
0.168830 0.943723 0.583667 I
0.168830 0.943723 0.917000 I
0.168830 0.112553 0.250333 I
0.168830 0.112553 0.583667 I
0.168830 0.112553 0.917000 I
0.168830 0.445887 0.250333 I
0.168830 0.445887 0.583667 I
0.168830 0.445887 0.917000 I
0.168830 0.779220 0.250333 I
0.168830 0.779220 0.583667 I
0.168830 0.779220 0.917000 I
0.662340 0.277057 0.250333 I
0.662340 0.277057 0.583667 I
0.662340 0.277057 0.917000 I
0.662340 0.610390 0.250333 I
0.662340 0.610390 0.583667 I
0.662340 0.610390 0.917000 I
0.662340 0.943723 0.250333 I
0.662340 0.943723 0.583667 I
0.662340 0.943723 0.917000 I
0.171210 0.195707 0.051643 N
0.171210 0.195707 0.384977 N
0.171210 0.195707 0.718310 N
0.171210 0.529040 0.051643 N
0.171210 0.529040 0.384977 N
0.171210 0.529040 0.718310 N
0.171210 0.862373 0.051643 N
0.171210 0.862373 0.384977 N
0.171210 0.862373 0.718310 N
0.412460 0.276360 0.051657 N
0.412460 0.276360 0.384990 N
0.412460 0.276360 0.718323 N
0.412460 0.609693 0.051657 N
0.412460 0.609693 0.384990 N
0.412460 0.609693 0.718323 N
0.412460 0.943027 0.051657 N
0.412460 0.943027 0.384990 N
0.412460 0.943027 0.718323 N
0.581900 0.056433 0.218310 N
0.581900 0.056433 0.551643 N
0.581900 0.056433 0.884977 N
0.581900 0.389767 0.218310 N
0.581900 0.389767 0.884977 N
0.581900 0.723100 0.218310 N
0.581900 0.723100 0.551643 N
0.581900 0.723100 0.884977 N
0.583020 0.137447 0.218420 N
0.583020 0.137447 0.551753 N
0.583020 0.137447 0.885087 N
0.583020 0.470780 0.218420 N
0.583020 0.470780 0.885087 N
0.583020 0.804113 0.218420 N
0.583020 0.804113 0.551753 N
0.583020 0.804113 0.885087 N
<Example code generating error>
Error message
<Error message>
ERROR:mpworks.drones.mp_vaspdrone:can get oxide_type
Suggested solution (if any)
<If you have a suggestion on how to solve the issue, you may write it
here.>
Files (if any)
<If input files are needed to reproduce the error, please provide
either links (e.g., Dropbox or GDrive) for large files or simply paste
the file below for small files.>
<When reporting bugs/issues, please supply the following information. If this is a feature request, please simply state the requested feature.>
System
Summary
There are some issues on the determination of oxide state when running a mpworks workflow.Some cases are fine,while some will fail,the main problem may occurs here https://github.com/materialsproject/pymatgen/blob/master/pymatgen/analysis/structure_analyzer.py#L718L727
Example code
from pymatgen.core.structure import Structure from pymatgen.core.periodic_table import Element from pymatgen.analysis.structure_analyzer import oxide_type s = Structure.from_file('POSCAR') print(isinstance(s.composition.elements[0], Element)) oxide_type(s) -----------POSCAR-------- K1 H85 Pb18 C17 I54 N34 1.0 8.660300 0.000000 0.000000 -12.990450 22.500120 0.000000 0.000000 0.000000 23.706601 K H Pb C I N 1 85 18 17 54 34 direct 0.666670 0.444440 0.551640 K 0.402160 0.199747 0.051643 H 0.402160 0.199747 0.384977 H 0.402160 0.199747 0.718310 H 0.402160 0.533080 0.051643 H 0.402160 0.533080 0.384977 H 0.402160 0.533080 0.718310 H 0.402160 0.866413 0.051643 H 0.402160 0.866413 0.384977 H 0.402160 0.866413 0.718310 H 0.350040 0.298137 0.051747 H 0.350040 0.298137 0.385080 H 0.350040 0.298137 0.718413 H 0.350040 0.631470 0.051747 H 0.350040 0.631470 0.385080 H 0.350040 0.631470 0.718413 H 0.350040 0.964803 0.051747 H 0.350040 0.964803 0.385080 H 0.350040 0.964803 0.718413 H 0.541210 0.299360 0.051827 H 0.541210 0.299360 0.385160 H 0.541210 0.299360 0.718493 H 0.541210 0.632693 0.051827 H 0.541210 0.632693 0.385160 H 0.541210 0.632693 0.718493 H 0.541210 0.966027 0.051827 H 0.541210 0.966027 0.385160 H 0.541210 0.966027 0.718493 H 0.103410 0.153050 0.051643 H 0.103410 0.153050 0.384977 H 0.103410 0.153050 0.718310 H 0.103410 0.486383 0.051643 H 0.103410 0.486383 0.384977 H 0.103410 0.486383 0.718310 H 0.103410 0.819717 0.051643 H 0.103410 0.819717 0.384977 H 0.103410 0.819717 0.718310 H 0.106100 0.216643 0.051643 H 0.106100 0.216643 0.384977 H 0.106100 0.216643 0.718310 H 0.106100 0.549977 0.051643 H 0.106100 0.549977 0.384977 H 0.106100 0.549977 0.718310 H 0.106100 0.883310 0.051643 H 0.106100 0.883310 0.384977 H 0.106100 0.883310 0.718310 H 0.801750 0.133250 0.218310 H 0.801750 0.133250 0.551643 H 0.801750 0.133250 0.884977 H 0.801750 0.466583 0.218310 H 0.801750 0.466583 0.884977 H 0.801750 0.799917 0.218310 H 0.801750 0.799917 0.551643 H 0.801750 0.799917 0.884977 H 0.455720 0.116923 0.218247 H 0.455720 0.116923 0.551580 H 0.455720 0.116923 0.884913 H 0.455720 0.450257 0.218247 H 0.455720 0.450257 0.884913 H 0.455720 0.783590 0.218247 H 0.455720 0.783590 0.551580 H 0.455720 0.783590 0.884913 H 0.645180 0.180123 0.218267 H 0.645180 0.180123 0.551600 H 0.645180 0.180123 0.884933 H 0.645180 0.513457 0.218267 H 0.645180 0.513457 0.884933 H 0.645180 0.846790 0.218267 H 0.645180 0.846790 0.551600 H 0.645180 0.846790 0.884933 H 0.643380 0.034047 0.218310 H 0.643380 0.034047 0.551643 H 0.643380 0.034047 0.884977 H 0.643380 0.367380 0.218310 H 0.643380 0.367380 0.884977 H 0.643380 0.700713 0.218310 H 0.643380 0.700713 0.551643 H 0.643380 0.700713 0.884977 H 0.455780 0.034807 0.218310 H 0.455780 0.034807 0.551643 H 0.455780 0.034807 0.884977 H 0.455780 0.368140 0.218310 H 0.455780 0.368140 0.884977 H 0.455780 0.701473 0.218310 H 0.455780 0.701473 0.551643 H 0.455780 0.701473 0.884977 H 0.000000 0.000000 0.002000 Pb 0.000000 0.000000 0.335333 Pb 0.000000 0.000000 0.668667 Pb 0.000000 0.333333 0.002000 Pb 0.000000 0.333333 0.335333 Pb 0.000000 0.333333 0.668667 Pb 0.000000 0.666667 0.002000 Pb 0.000000 0.666667 0.335333 Pb 0.000000 0.666667 0.668667 Pb 0.000000 0.000000 0.168667 Pb 0.000000 0.000000 0.502000 Pb 0.000000 0.000000 0.835333 Pb 0.000000 0.333333 0.168667 Pb 0.000000 0.333333 0.502000 Pb 0.000000 0.333333 0.835333 Pb 0.000000 0.666667 0.168667 Pb 0.000000 0.666667 0.502000 Pb 0.000000 0.666667 0.835333 Pb 0.333333 0.222222 0.051643 C 0.333333 0.222222 0.384977 C 0.333333 0.222222 0.718310 C 0.333333 0.555556 0.051643 C 0.333333 0.555556 0.384977 C 0.333333 0.555556 0.718310 C 0.333333 0.888889 0.051643 C 0.333333 0.888889 0.384977 C 0.333333 0.888889 0.718310 C 0.666667 0.111111 0.218310 C 0.666667 0.111111 0.551643 C 0.666667 0.111111 0.884977 C 0.666667 0.444444 0.218310 C 0.666667 0.444444 0.884977 C 0.666667 0.777778 0.218310 C 0.666667 0.777778 0.551643 C 0.666667 0.777778 0.884977 C 0.831170 0.056277 0.083667 I 0.831170 0.056277 0.417000 I 0.831170 0.056277 0.750333 I 0.831170 0.389610 0.083667 I 0.831170 0.389610 0.417000 I 0.831170 0.389610 0.750333 I 0.831170 0.722943 0.083667 I 0.831170 0.722943 0.417000 I 0.831170 0.722943 0.750333 I 0.831170 0.220780 0.083667 I 0.831170 0.220780 0.417000 I 0.831170 0.220780 0.750333 I 0.831170 0.554113 0.083667 I 0.831170 0.554113 0.417000 I 0.831170 0.554113 0.750333 I 0.831170 0.887447 0.083667 I 0.831170 0.887447 0.417000 I 0.831170 0.887447 0.750333 I 0.337660 0.056277 0.083667 I 0.337660 0.056277 0.417000 I 0.337660 0.056277 0.750333 I 0.337660 0.389610 0.083667 I 0.337660 0.389610 0.417000 I 0.337660 0.389610 0.750333 I 0.337660 0.722943 0.083667 I 0.337660 0.722943 0.417000 I 0.337660 0.722943 0.750333 I 0.168830 0.277057 0.250333 I 0.168830 0.277057 0.583667 I 0.168830 0.277057 0.917000 I 0.168830 0.610390 0.250333 I 0.168830 0.610390 0.583667 I 0.168830 0.610390 0.917000 I 0.168830 0.943723 0.250333 I 0.168830 0.943723 0.583667 I 0.168830 0.943723 0.917000 I 0.168830 0.112553 0.250333 I 0.168830 0.112553 0.583667 I 0.168830 0.112553 0.917000 I 0.168830 0.445887 0.250333 I 0.168830 0.445887 0.583667 I 0.168830 0.445887 0.917000 I 0.168830 0.779220 0.250333 I 0.168830 0.779220 0.583667 I 0.168830 0.779220 0.917000 I 0.662340 0.277057 0.250333 I 0.662340 0.277057 0.583667 I 0.662340 0.277057 0.917000 I 0.662340 0.610390 0.250333 I 0.662340 0.610390 0.583667 I 0.662340 0.610390 0.917000 I 0.662340 0.943723 0.250333 I 0.662340 0.943723 0.583667 I 0.662340 0.943723 0.917000 I 0.171210 0.195707 0.051643 N 0.171210 0.195707 0.384977 N 0.171210 0.195707 0.718310 N 0.171210 0.529040 0.051643 N 0.171210 0.529040 0.384977 N 0.171210 0.529040 0.718310 N 0.171210 0.862373 0.051643 N 0.171210 0.862373 0.384977 N 0.171210 0.862373 0.718310 N 0.412460 0.276360 0.051657 N 0.412460 0.276360 0.384990 N 0.412460 0.276360 0.718323 N 0.412460 0.609693 0.051657 N 0.412460 0.609693 0.384990 N 0.412460 0.609693 0.718323 N 0.412460 0.943027 0.051657 N 0.412460 0.943027 0.384990 N 0.412460 0.943027 0.718323 N 0.581900 0.056433 0.218310 N 0.581900 0.056433 0.551643 N 0.581900 0.056433 0.884977 N 0.581900 0.389767 0.218310 N 0.581900 0.389767 0.884977 N 0.581900 0.723100 0.218310 N 0.581900 0.723100 0.551643 N 0.581900 0.723100 0.884977 N 0.583020 0.137447 0.218420 N 0.583020 0.137447 0.551753 N 0.583020 0.137447 0.885087 N 0.583020 0.470780 0.218420 N 0.583020 0.470780 0.885087 N 0.583020 0.804113 0.218420 N 0.583020 0.804113 0.551753 N 0.583020 0.804113 0.885087 N
Error message
ERROR:mpworks.drones.mp_vaspdrone:can get oxide_type
Suggested solution (if any)
Files (if any)
<If input files are needed to reproduce the error, please provide either links (e.g., Dropbox or GDrive) for large files or simply paste the file below for small files.>