Skip to content

Commit

Permalink
Merge pull request #78 from zhzhang7549/dev
Browse files Browse the repository at this point in the history
修改了部分bug
  • Loading branch information
zhzhang7549 authored Nov 6, 2024
2 parents 70629be + b01f3cb commit e58925f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
10 changes: 6 additions & 4 deletions HTMACat/Extract_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def get_atom_neigh(poscar, atom):


# 8. TO get atoms binding with surface among adatoms
def get_binding_adatom(poscar):
def get_binding_adatom(poscar, layer=4):
"""Determine the adsorbed atoms and the surface atoms to which they bind.
Parameters
Expand Down Expand Up @@ -559,7 +559,9 @@ def get_binding_adatom(poscar):
struct = read(poscar, format="vasp")
else:
struct = poscar
layer = len(get_unique_coordinates(poscar, axis=2, tag=True, tol=0.01))-1
# layer = len(get_unique_coordinates(poscar, axis=2, tag=True, tol=0.01))-1
# print(f"layer {layer}")
# print(get_unique_coordinates(poscar, axis=2, tag=True, tol=0.01))
(
adatoms,
adatoms_symb,
Expand All @@ -568,8 +570,8 @@ def get_binding_adatom(poscar):
subsurfatoms,
subsurfatoms_symb,
) = distinguish_atom_binding(poscar, tol=0.05, base_layer=layer) # Changed by RxChen, 2023/06/02
# print(adatoms_symb,surfatoms_symb)
# print(struct.symbols)
# print(f"adatoms {adatoms_symb},surfatoms {surfatoms_symb}")
# print(f"struct.symbols {struct.symbols}")
cutOff = natural_cutoffs(struct, mult=1.0)
# print(cutOff)
nl = NeighborList(cutOff, self_interaction=False, bothways=True)
Expand Down
19 changes: 8 additions & 11 deletions HTMACat/model/Ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def construct(self):
else:
ele = ''.join(self.get_sites()[1:]) ### wzj 20230518
slabs_ads = self.Construct_single_adsorption(ele=ele)
elif self.get_sites()[0] == '2':
elif self.get_sites()[0] == '2': ## 使用2时有bug
slabs_ads = self.Construct_double_adsorption()
else:
raise ValueError('Supports only "1" "2" adsorption sites for ads!')
Expand All @@ -92,6 +92,7 @@ def remove_same(self, slabs_ads):
p1 = self.substrate.property["p1"]
p1_symb = self.substrate.property["p1_symb"]
slabs_ads_near = []
layer = self.substrate.get_layers()
for slb in slabs_ads:
(
bind_adatoms,
Expand All @@ -100,14 +101,9 @@ def remove_same(self, slabs_ads):
adspecie,
bind_surfatoms,
bind_surfatoms_symb,
) = get_binding_adatom(slb)
if self.get_sites() == "1" and (set(p1_symb) & set(bind_surfatoms_symb[0])):
slabs_ads_near += [slb]
elif (
self.get_sites() == "2"
and (set(p1_symb) & set(bind_surfatoms_symb[0]))
or (set(p1_symb) & set(bind_surfatoms_symb[0]))
):
) = get_binding_adatom(slb,layer)
# print(self.get_sites(), set(p1_symb), bind_surfatoms_symb,set(bind_surfatoms_symb[0]))
if (set(p1_symb) & set(bind_surfatoms_symb[0])):
slabs_ads_near += [slb]
return slabs_ads_near

Expand Down Expand Up @@ -245,7 +241,7 @@ def from_input(cls, init_list, substrates, species_dict=None):
@classmethod
def get_settings(cls,settings_dict={}):
default_settings = {'conform_rand':1,
'direction':'bond_atom',
'direction':'default',
'rotation':'vnn',
'z_bias':float(0),
}
Expand Down Expand Up @@ -290,6 +286,7 @@ def remove_same(self, slabs_ads):
p1 = self.substrate.property["p1"]
p1_symb = self.substrate.property["p1_symb"]
slabs_ads_near = []
layer = self.substrate.get_layers()
for slb in slabs_ads:
(
bind_adatoms,
Expand All @@ -298,7 +295,7 @@ def remove_same(self, slabs_ads):
adspecie,
bind_surfatoms,
bind_surfatoms_symb,
) = get_binding_adatom(slb)
) = get_binding_adatom(slb,layer)
bind_surfatoms_symb_all = sum(bind_surfatoms_symb, [])
if set(p1_symb) & set(bind_surfatoms_symb_all):
slabs_ads_near += [slb]
Expand Down
18 changes: 12 additions & 6 deletions HTMACat/model/Species.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def out_print(self):
return self.alias_name

def out_file_name(self):
return self.get_formular()
return self.alias_name

@abstractmethod
def get_molecule(self, randomSeed=0) -> Gratoms:
Expand Down Expand Up @@ -80,7 +80,10 @@ def set_filetype(self, typename):
self.filetype = typename

def out_file_name(self):
return self.alias_name
if "." in self.form:
return self.form.split(".")[0]
else:
return self.form

@property
def atoms(self) -> Atoms:
Expand Down Expand Up @@ -115,10 +118,13 @@ def __init__(self, form, formtype="sml", alias_name=None):
super().__init__(form, formtype, alias_name)

def out_file_name(self):
ads1 = self.get_formular()
mole = Chem.AddHs(Chem.MolFromSmiles(ads1))
ads1 = rdMolDescriptors.CalcMolFormula(mole)
return ads1
if self.alias_name == self.form:
ads1 = self.get_formular()
mole = Chem.AddHs(Chem.MolFromSmiles(ads1))
ads1 = rdMolDescriptors.CalcMolFormula(mole)
return ads1
else:
return self.alias_name.split("(")[0]

def get_molecule(self, randomSeed=0) -> Gratoms:
### Changed by ZhaojieWang, 20230829 (<>改进:需能处理离子键可连接的SMILES)
Expand Down
2 changes: 1 addition & 1 deletion HTMACat/model/Substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, in_bulk=Bulk(), facet="100", layers=4, layers_relax=2):
self.bulk = in_bulk
self.file = None
self.facet = facet
self.property = {}
self.property = {} #掺杂元素序号以及元素符号p1,p1_symb
self.layers = layers
self.layers_relax = layers_relax
if "p1" not in self.property or "p1_symb" not in self.property:
Expand Down

0 comments on commit e58925f

Please sign in to comment.