From 0692231d07e8550040bb9950e7d6ef4777dd446a Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Tue, 15 Oct 2024 14:37:28 -0700 Subject: [PATCH] add debug asserts --- pynta/coveragedependence.py | 13 ++++++++++++- pynta/tasks.py | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pynta/coveragedependence.py b/pynta/coveragedependence.py index 16ed790d..44389ae5 100644 --- a/pynta/coveragedependence.py +++ b/pynta/coveragedependence.py @@ -2212,22 +2212,30 @@ def mol_to_atoms(admol,slab,sites,metal,partial_atoms=None,partial_admol=None): Returns: _type_: Atoms object corresponding to the admol 2D configuration """ + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" if partial_atoms and partial_admol: atoms = deepcopy(partial_atoms) gpartial_admol = partial_admol.to_group() admol_atom_order = admol.atoms[:] gpartial_admol_order = gpartial_admol.atoms[:] + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" try: subisos = admol.find_subgraph_isomorphisms(gpartial_admol,save_order=True) except ValueError: subisos = admol.find_subgraph_isomorphisms(gpartial_admol) admol.atoms = admol_atom_order gpartial_admol.atoms = gpartial_admol_order + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" if len(subisos) == 0: raise ValueError("partial_admol is not subgraph isomorphic to admol: {0}, {1}".format(gpartial_admol.to_adjacency_list(),admol.to_adjacency_list())) subiso = subisos[0] atoms_in_partial = [a for a in subiso.keys() if not a.is_surface_site()] split_structs,adsorbed_atom_dict = split_adsorbed_structures(admol,clear_site_info=False,adsorption_info=True,atoms_to_skip=atoms_in_partial) + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" elif partial_atoms is None and partial_admol is None: atoms = deepcopy(slab) split_structs,adsorbed_atom_dict = split_adsorbed_structures(admol,clear_site_info=False,adsorption_info=True) @@ -2249,7 +2257,8 @@ def mol_to_atoms(admol,slab,sites,metal,partial_atoms=None,partial_admol=None): ad.rotate(rot_vec,[0.0,0.0,1.0]) #rotate bonds toward the +z-axis else: adatom_molind = st.atoms.index([a for a in st.atoms if not a.is_surface_site()][0]) - + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" atom_surf_inds = [] ad_sites = [] for a,sind in adsorbed_atom_dict.items(): @@ -2258,4 +2267,6 @@ def mol_to_atoms(admol,slab,sites,metal,partial_atoms=None,partial_admol=None): atom_surf_inds.append(mol_to_atoms_map[adatom_molind]) ad_sites.append(sites[sind]) atoms,_,_ = place_adsorbate(ad,atoms,atom_surf_inds,ad_sites,metal) + assert admol.atoms[1].site == "bridge" + assert partial_admol.atoms[1].site == "bridge" return atoms \ No newline at end of file diff --git a/pynta/tasks.py b/pynta/tasks.py index d881ac35..a7e03c8a 100644 --- a/pynta/tasks.py +++ b/pynta/tasks.py @@ -1242,6 +1242,7 @@ def run_task(self, fw_spec): sample_fws = [] calculation_directories = [] for i,config in enumerate(configs_for_calculation): + assert config.atoms[1].site == "bridge" adname = None for admol_name,config_list in admol_to_config_for_calculation.items(): if config in config_list: @@ -1249,7 +1250,10 @@ def run_task(self, fw_spec): break else: raise ValueError + assert config.atoms[1].site == "bridge" + partial_admol = admol_name_structure_dict[adname] + assert partial_admol.atoms[1].site == "bridge" admol_path = admol_name_path_dict[adname] partial_atoms = read(admol_path) init_atoms = mol_to_atoms(config,slab,sites,metal,partial_atoms=partial_atoms,partial_admol=partial_admol)