AndreiVoicuT commited on
Commit
ed75869
1 Parent(s): 881d4bc

Update interface_connection/latmatcher_interface.py

Browse files
interface_connection/latmatcher_interface.py CHANGED
@@ -6,6 +6,8 @@ from backend.latmathcher import PipelineLatMatch
6
  from backend.db_utils.utils import structure_ato_list
7
  from backend.db_utils.parse_c2db import from_c2db_structure, read_c2db_json
8
  from backend.db_utils.structure_database import DBInstance
 
 
9
 
10
 
11
  import matplotlib.pyplot as plt
@@ -49,6 +51,11 @@ def compute_supercell_a(file_material_a, file_material_b, file_source_a, file_so
49
  file2 = process_file(file_material_b, path_to_move+"/")
50
 
51
 
 
 
 
 
 
52
  if file_source_a == "c2db.json":
53
  A_structure = from_c2db_structure(read_c2db_json(file1))
54
  A_cell=A_structure["cell"]
@@ -164,32 +171,19 @@ def extract_from_xyz(file):
164
  'positions':[],
165
  "pbc":[ True, True, False] }
166
 
167
- with open(file, 'r') as xyz_file:
168
- lines = xyz_file.readlines()[4:] # Skipping the first two line
169
-
170
- with open(file, 'r') as xyz_file:
171
- dict_string = xyz_file.readlines()[:1][0]
172
- print(dict_string)
173
-
174
 
175
- lattice = ast.literal_eval(dict_string)['lattice_vectors']
176
 
 
 
 
 
177
 
178
- structure["cell"]=np.array([[lattice[0][0], lattice[0][1], 0],
179
- [lattice[1][0], lattice[1][1], 0],
180
  [0,0,1]])
181
-
182
-
183
- atom_xyz=np.array([line.split()[1:4] for line in lines], dtype=float)
184
-
185
- atomic_symbols = []
186
- for line in lines:
187
- atomic_symbols.append(line.split()[0])
188
- structure['atoms']=[get_atomic_number(element_symbol) for element_symbol in atomic_symbols]
189
-
190
- structure['positions']=atom_xyz
191
-
192
-
193
 
194
  return structure
195
 
 
6
  from backend.db_utils.utils import structure_ato_list
7
  from backend.db_utils.parse_c2db import from_c2db_structure, read_c2db_json
8
  from backend.db_utils.structure_database import DBInstance
9
+ from ase.io import read
10
+ from CifFile import ReadCif
11
 
12
 
13
  import matplotlib.pyplot as plt
 
51
  file2 = process_file(file_material_b, path_to_move+"/")
52
 
53
 
54
+
55
+ file_source_a="."+file1.split(".")[-1]
56
+ file_source_b = "."+file2.split(".")[-1]
57
+ print("fa, fb:",file_source_a, file_source_b)
58
+
59
  if file_source_a == "c2db.json":
60
  A_structure = from_c2db_structure(read_c2db_json(file1))
61
  A_cell=A_structure["cell"]
 
171
  'positions':[],
172
  "pbc":[ True, True, False] }
173
 
 
 
 
 
 
 
 
174
 
 
175
 
176
+ atoms = read(file)
177
+ lattice_vectors = atoms.cell
178
+ atom_symbols = atoms.get_chemical_symbols()
179
+ positions = atoms.get_positions()
180
 
181
+ structure["cell"] = np.array([[lattice_vectors[0][0], lattice_vectors[0][1], 0],
182
+ [lattice_vectors[1][0], lattice_vectors[1][1], 0],
183
  [0,0,1]])
184
+ structure['atoms'] = [get_atomic_number(element_symbol) for element_symbol in atom_symbols]
185
+ structure['positions'] = positions
186
+ print(structure)
 
 
 
 
 
 
 
 
 
187
 
188
  return structure
189