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 42c39d3 commit d05e956
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
8 changes: 3 additions & 5 deletions cell2mol/new_cell_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,29 +595,27 @@ def reconstuct (refcell, newcell, sym_ops, debug: int=0):
print("reconstructed_molecules", len(reconstructed_molecules), [mol.formula for mol in reconstructed_molecules])

if len(all_found) == len(cell_pos):
newcell.error_get_fragments = False
num_rem_frags = 0
for rem_frag_list in remaining_fragments:
num_rem_frags += len(rem_frag_list)

if num_rem_frags == 0 :
print("All fragments are reconstructed successfully")
newcell.is_fragmented = False
newcell.error_reconstruction = False
else:
print(f"There are {num_rem_frags} remaining fragments.")
final_remaining_fragments, reconstructed_molecules = final_remaining_reconstruction(remaining_fragments, newcell, cell_vector, reconstructed_molecules, debug=0)
if len(final_remaining_fragments) == 0:
print("All fragments are reconstructed successfully")
newcell.is_fragmented = False
newcell.error_reconstruction = False
else :
print("Error in reconstruction!!")
newcell.is_fragmented = True
newcell.error_reconstruction = True
print("final remaining fragments", len(final_remaining_fragments), [mol.formula for mol in final_remaining_fragments])
else:
print("Error in reconstruction!!")
newcell.is_fragmented = True
print("Error in getting fragments and reconstruction!!")
newcell.error_get_fragments = True
newcell.error_reconstruction = True
for i, pos in enumerate(cell_pos):
if i not in all_found:
Expand Down
2 changes: 1 addition & 1 deletion cell2mol/read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def parse_formula_with_quantity(formula: str):
######################################################
def print_output(moleclist):

print(moleclist[0].refcode)
print(moleclist[0].get_parent("reference").name)
for idx, mol in enumerate(moleclist):
if mol.iscomplex:
if hasattr(mol, "totcharge") and hasattr(mol, "spin"):
Expand Down
37 changes: 10 additions & 27 deletions cell2mol/test/check_Cell_object.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand All @@ -11,7 +11,7 @@
"'2023.09.6'"
]
},
"execution_count": 30,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -48,50 +48,33 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"name = \"ZURVIR\"\n",
"name = \"ACEYOW\"\n",
"refcell = np.load(f\"{name}/Ref_Cell_{name}.cell\", allow_pickle=True)\n",
"# cell = np.load(f\"{name}/Cell_{name}.cell\", allow_pickle=True)"
"cell = np.load(f\"{name}/Cell_{name}.cell\", allow_pickle=True)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"------------- Cell2mol CELL Object ----------------\n",
" Version = 2.0\n",
" Type = cell\n",
" Sub-Type = reference\n",
" Name (Refcode) = ZURVIR\n",
" Num Atoms = 167\n",
" Cell Parameters a:c = [20.504, 12.347, 22.524]\n",
" Cell Parameters al:ga = [90.0, 94.56, 90.0]\n",
"---------------------------------------------------\n",
" # of Ref Molecules: = 7\n",
" With Formulae: \n",
" 0: H8-C4-O \n",
" 1: H8-C4-O \n",
" 2: H8-C4-O \n",
" 3: H8-C4-O \n",
" 4: H64-C44-N4-Cr \n",
" 5: Li \n",
" 6: Li "
"'ACEYOW'"
]
},
"execution_count": 45,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"refcell"
"refcell.refmoleclist[0].get_parent(\"reference\").name"
]
},
{
Expand Down

0 comments on commit d05e956

Please sign in to comment.