From b01f3cbcfdbeae5dbed5f4b709b4ef05a43c4ca3 Mon Sep 17 00:00:00 2001 From: zhzhang7549 Date: Wed, 6 Nov 2024 09:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=83=A8=E5=88=86bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HTMACat/Extract_info.py | 10 ++++++---- HTMACat/model/Ads.py | 19 ++++++++----------- HTMACat/model/Species.py | 18 ++++++++++++------ HTMACat/model/Substrate.py | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/HTMACat/Extract_info.py b/HTMACat/Extract_info.py index 8d02bf1..712a511 100644 --- a/HTMACat/Extract_info.py +++ b/HTMACat/Extract_info.py @@ -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 @@ -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, @@ -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) diff --git a/HTMACat/model/Ads.py b/HTMACat/model/Ads.py index f7e5d24..be1a7eb 100644 --- a/HTMACat/model/Ads.py +++ b/HTMACat/model/Ads.py @@ -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!') @@ -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, @@ -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 @@ -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), } @@ -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, @@ -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] diff --git a/HTMACat/model/Species.py b/HTMACat/model/Species.py index 9fb7ae6..813e9eb 100644 --- a/HTMACat/model/Species.py +++ b/HTMACat/model/Species.py @@ -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: @@ -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: @@ -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) diff --git a/HTMACat/model/Substrate.py b/HTMACat/model/Substrate.py index 175a9ed..68f55d0 100644 --- a/HTMACat/model/Substrate.py +++ b/HTMACat/model/Substrate.py @@ -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: