Skip to content

Commit

Permalink
str2unicode removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkumar committed May 31, 2020
1 parent 27973b6 commit aec0004
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pycdt/core/defectsmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import abc


#from monty.string import str2unicode
from monty.serialization import dumpfn
from pymatgen.core.structure import PeriodicSite, Structure
from pymatgen.core.periodic_table import Element, Specie, get_el_sp
Expand Down Expand Up @@ -246,7 +245,7 @@ def __init__(self, structure):
self.oxi_states = {}
for key,val in oxi_states.items():
strip_key = ''.join([s for s in key if s.isalpha()])
self.oxi_states[str2unicode(strip_key)] = val
self.oxi_states[strip_key] = val

self.min_max_oxi = {}
for s in struct_species:
Expand All @@ -258,7 +257,7 @@ def __init__(self, structure):
continue
max_oxi = max(el.common_oxidation_states)
min_oxi = min(el.common_oxidation_states)
self.min_max_oxi[str2unicode(el.symbol)] = (min_oxi,max_oxi)
self.min_max_oxi[el.symbol] = (min_oxi,max_oxi)

def get_charges(self, defect_type, site_specie=None, sub_specie=None):
"""
Expand All @@ -274,7 +273,7 @@ def get_charges(self, defect_type, site_specie=None, sub_specie=None):
"""
if defect_type == 'vacancy':
vac_symbol = get_el_sp(site_specie).symbol
vac_oxi_state = self.oxi_states[str2unicode(vac_symbol)]
vac_oxi_state = self.oxi_states[vac_symbol]
if vac_oxi_state < 0:
min_oxi = max(vac_oxi_state, self.min_max_oxi[vac_symbol][0])
max_oxi = 0
Expand All @@ -289,7 +288,7 @@ def get_charges(self, defect_type, site_specie=None, sub_specie=None):

elif defect_type == 'antisite':
vac_symbol = get_el_sp(site_specie).symbol
vac_oxi_state = self.oxi_states[str2unicode(vac_symbol)]
vac_oxi_state = self.oxi_states[vac_symbol]
as_symbol = get_el_sp(sub_specie).symbol
if vac_oxi_state > 0:
oxi_max = max(self.min_max_oxi[as_symbol][1],0)
Expand All @@ -304,7 +303,7 @@ def get_charges(self, defect_type, site_specie=None, sub_specie=None):
site_specie = get_el_sp(site_specie)
sub_specie = get_el_sp(sub_specie)
vac_symbol = site_specie.symbol
vac_oxi_state = self.oxi_states[str2unicode(vac_symbol)]
vac_oxi_state = self.oxi_states[vac_symbol]

max_oxi_sub = max(sub_specie.common_oxidation_states)
min_oxi_sub = min(sub_specie.common_oxidation_states)
Expand Down Expand Up @@ -352,7 +351,7 @@ def __init__(self, structure):
self.oxi_states = {}
for key,val in oxi_states.items():
strip_key = ''.join([s for s in key if s.isalpha()])
self.oxi_states[str2unicode(strip_key)] = val
self.oxi_states[strip_key] = val

def get_charges(self, defect_type, site_specie=None, sub_specie=None):
"""
Expand All @@ -368,7 +367,7 @@ def get_charges(self, defect_type, site_specie=None, sub_specie=None):
"""
if defect_type == 'vacancy':
vac_symbol = get_el_sp(site_specie).symbol
vac_oxi_state = self.oxi_states[str2unicode(vac_symbol)]
vac_oxi_state = self.oxi_states[vac_symbol]
if vac_oxi_state == 0:
return [-1,0,1]
else:
Expand All @@ -379,9 +378,9 @@ def get_charges(self, defect_type, site_specie=None, sub_specie=None):
elif defect_type in ['antisite', 'substitution']:
#TODO: may cause some weird states for substitutions. Worth updating in future.
vac_symbol = get_el_sp(site_specie).symbol
vac_oxi_state = self.oxi_states[str2unicode(vac_symbol)]
vac_oxi_state = self.oxi_states[vac_symbol]
as_symbol = get_el_sp(sub_specie).symbol
as_oxi_state = self.oxi_states[str2unicode(as_symbol)]
as_oxi_state = self.oxi_states[as_symbol]
expected_oxi = as_oxi_state - vac_oxi_state
if expected_oxi == 0:
return [-1,0,1]
Expand Down Expand Up @@ -565,7 +564,7 @@ def __init__(self, structure, max_min_oxi=None, substitutions=None,
self.substitutions = {}
self.struct_type = struct_type
for key, val in substitutions.items():
self.substitutions[str2unicode(key)] = val
self.substitutions[key] = val

spa = SpacegroupAnalyzer(structure, symprec=1e-2)
prim_struct = spa.get_primitive_standard_structure()
Expand Down

0 comments on commit aec0004

Please sign in to comment.