Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
choglass committed Jun 2, 2024
1 parent d05e956 commit 7a07737
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
11 changes: 10 additions & 1 deletion cell2mol/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1880,14 +1880,23 @@ def assess_errors(self, mode):
if self.has_isolated_H: case = 1
elif self.has_missing_H: case = 2
else : case = 0
elif mode == "unit_cell":
elif mode == "reconstruction":
print("-------------------------------")
print("Errors in Reference Molecules")
print("-------------------------------")
if self.has_isolated_H: case = 1
elif self.has_missing_H: case = 2
elif self.error_get_fragments: case = 3
elif self.error_reconstruction: case = 4
else : case = 0
elif mode == "charge_assignment":
print("-------------------------------")
print("Errors in charge assignment")
print("-------------------------------")
if self.has_isolated_H: case = 1
elif self.has_missing_H: case = 2
elif self.error_get_fragments: case = 3
elif self.error_reconstruction: case = 4
elif self.error_empty_poscharges : case = 5
elif self.error_multiple_distrib : case = 6
elif self.error_empty_distrib : case = 7
Expand Down
45 changes: 28 additions & 17 deletions cell2mol/new_c2m_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@
error.close()
sys.stdout = stdout


output = open(output_fname, "a")
sys.stdout = error
##########################################
if refcell.error_case != 0:
sys.exit(1)
else:
reconstruction = True
charge_assignment = True
spin_assignment = True
charge_assignment = False
spin_assignment = False

# Define new cell object for the unit cell
newcell = cell(name, cell_labels, cell_pos, cell_fracs, cell_vector, cell_param)
Expand All @@ -143,24 +144,34 @@
newcell.assess_errors(mode="hydrogens")

print(f"ENTERING cell2mol with {debug=}")
print(f"with mode {reconstruction=} {charge_assignment=} {spin_assignment=}")

newcell = cell2mol(newcell, refcell, sym_ops, reconstruction, charge_assignment, spin_assignment, debug=debug)
newcell.assess_errors(mode="unit_cell")

# Save cell object
newcell.assess_errors(mode="reconstruction")
"""
if newcell.error_case == 0 and reconstruction :
reconstruction = False
charge_assignment = True
newcell = cell2mol(newcell, refcell, sym_ops, reconstruction, charge_assignment, spin_assignment, debug=debug)
newcell.assess_errors(mode="charge_assignment")
if newcell.error_case == 0 and charge_assignment :
reconstruction = False
charge_assignment = False
spin_assignment = True
newcell = cell2mol(newcell, refcell, sym_ops, reconstruction, charge_assignment, spin_assignment, debug=debug)
final_charge_distribution, final_charges = balance_charge(newcell.unique_indices, refcell.unique_species, debug=debug)
refcell.unique_species = assign_charge_state_for_unique_species(refcell.unique_species, final_charges[0], debug=debug)
refcell.assign_charges_for_refcell(debug=debug)
refcell.assign_spin(debug=debug)
refcell.create_bonds(debug=debug)
# Update reference cell object
refcell.save(ref_cell_fname)
"""
# Save unit cell object
newcell.save(cell_fname)

if newcell.error_case == 0 and charge_assignment :
final_charge_distribution, final_charges = balance_charge(newcell.unique_indices, refcell.unique_species, debug=debug)
refcell.unique_species = assign_charge_state_for_unique_species(refcell.unique_species, final_charges[0], debug=debug)
refcell.assign_charges_for_refcell(debug=debug)
refcell.assign_spin(debug=debug)
refcell.create_bonds(debug=debug)

# Update reference cell object
refcell.save(ref_cell_fname)

output.close()
sys.stdout = stdout

Expand Down

0 comments on commit 7a07737

Please sign in to comment.