Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
choglass committed Apr 25, 2024
1 parent f787a69 commit f4d3f99
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions cell2mol/c2m_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def cell2mol(newcell: object, reconstruction: bool=True, charge_assignment: bool
else:
tend = time.time()
if debug >= 1: print(f"\nCell Reconstruction Finished Normally. Total execution time: {tend - tini:.2f} seconds")

else:
return newcell

if charge_assignment:
tini = time.time()

Expand All @@ -36,12 +38,15 @@ def cell2mol(newcell: object, reconstruction: bool=True, charge_assignment: bool
tend = time.time()
if debug >= 1: print(f"Charge Assignment Finished Normally. Total execution time: {tend - tini:.2f} seconds")
# newcell.predict_metal_ox(debug=debug) # predict metal oxidation state using Random Forest model
else:
return newcell

if spin_assignment:
if not newcell.error_prepare_mols:
tini = time.time()
newcell.assign_spin(debug=debug)
tend = time.time()
if debug >= 1: print(f"\nTotal execution time for Spin Assignment: {tend - tini:.2f} seconds")

else:
return newcell
return newcell
10 changes: 5 additions & 5 deletions cell2mol/charge_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def get_protonation_states_specie(specie: object, debug: int=0) -> list:
addedlist[idx] = 1
else:
mol = ligand.get_parent("molecule")
iscarbene, tmp_element, tmp_added, tmp_metal = check_carbenes(a, ligand, mol)
iscarbene, tmp_element, tmp_added, tmp_metal = check_carbenes(a, ligand)
if debug >= 2: print(f" GET_PROTONATION_STATES: Evaluating as carbene and {iscarbene}")
if iscarbene:
# Carbene identified
Expand Down Expand Up @@ -698,7 +698,7 @@ def eval_chargelist(atom_charges: list, debug: int=0) -> Tuple[np.ndarray, np.nd
return abstotal, abs_atcharge, zwitt

#######################################################
def check_carbenes(atom: object, ligand: object, molecule: object, debug: int=0) -> Tuple[bool, str, int, int]:
def check_carbenes(atom: object, ligand: object, debug: int=0) -> Tuple[bool, str, int, int]:
# Function that determines whether a given connected "atom" of a "ligand" of a "molecule" is a carbene
# This function is in progress. Ideally, should be able to identify Fischer, Schrock and N-Heterocyclic Carbenes
# The former two cases probably require rules that involve other ligands in the molecule, hence why the "molecule" is provided
Expand All @@ -709,7 +709,7 @@ def check_carbenes(atom: object, ligand: object, molecule: object, debug: int=0)

# about Metal electrons: This variable is a way to contemplate cases in which the metal atom is actually contributing with electrons to the metal-ligand bond.
# about Metal electrons: In reality, I'm not sure about how to use it correctly, and now is used without much chemical sense

iscarbene = False
element = "H"
addedlist = 0
Expand All @@ -718,8 +718,8 @@ def check_carbenes(atom: object, ligand: object, molecule: object, debug: int=0)
# Initial attempt with Carbenes, but they are much more complex
# Looks for Neighbouring N atoms
list_of_coord_atoms = []
for i in atom.adjacency:
list_of_coord_atoms.append(ligand.labels[i])
for adj in atom.adjacency:
list_of_coord_atoms.append(ligand.get_parent("molecule").labels[adj])
numN = list_of_coord_atoms.count("N")

if numN == 2: # it is an N-Heterocyclic carbenes
Expand Down
2 changes: 1 addition & 1 deletion cell2mol/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,9 @@ def get_moleclist(self, blocklist=None, debug: int=0):
cov_factor = 1.3

if blocklist is None: blocklist = split_species(self.labels, self.coord, cov_factor=cov_factor, debug=debug)
if blocklist is None: return None
if debug > 0: print(f"CELL.MOLECLIST: found {len(blocklist)} blocks")
if debug > 0: print(f"CELL.MOLECLIST: {blocklist=}")
if blocklist is None: return None

self.moleclist = []
for b in blocklist:
Expand Down

0 comments on commit f4d3f99

Please sign in to comment.