Spaces:
Runtime error
Runtime error
Andrei tomut
commited on
Commit
•
a117bb5
1
Parent(s):
c592240
big grid
Browse files
backend/latmathcher/__init__.py
CHANGED
@@ -2,3 +2,4 @@
|
|
2 |
|
3 |
from .latmatcher import LatMatch
|
4 |
from .pipeline import PipelineLatMatch, atoms_to_greed
|
|
|
|
2 |
|
3 |
from .latmatcher import LatMatch
|
4 |
from .pipeline import PipelineLatMatch, atoms_to_greed
|
5 |
+
from .utils import generate_xyz_text
|
backend/latmathcher/__pycache__/latmatcher.cpython-310.pyc
DELETED
Binary file (5.42 kB)
|
|
backend/latmathcher/__pycache__/latmatcher.cpython-311.pyc
DELETED
Binary file (10.2 kB)
|
|
backend/latmathcher/latmatcher.py
CHANGED
@@ -53,6 +53,11 @@ class LatMatch:
|
|
53 |
|
54 |
n = int(np.ceil(eta))
|
55 |
for (nx, ny) in np.mgrid[-n:n, -n:n].T.reshape(n ** 2 * 4, 2):
|
|
|
|
|
|
|
|
|
|
|
56 |
d2 = (dx + nx) ** 2 + (dy + ny) ** 2
|
57 |
cost += np.mean(np.exp(- d2 / (2 * etac))) / n ** 2
|
58 |
return -cost
|
|
|
53 |
|
54 |
n = int(np.ceil(eta))
|
55 |
for (nx, ny) in np.mgrid[-n:n, -n:n].T.reshape(n ** 2 * 4, 2):
|
56 |
+
# print("nx:",nx)
|
57 |
+
# print("ny:", ny)
|
58 |
+
# print("dx:", dx)
|
59 |
+
# print("dy:", dy)
|
60 |
+
# print("etc:", etac)
|
61 |
d2 = (dx + nx) ** 2 + (dy + ny) ** 2
|
62 |
cost += np.mean(np.exp(- d2 / (2 * etac))) / n ** 2
|
63 |
return -cost
|
backend/latmathcher/utils.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
|
4 |
+
def generate_xyz_text(atoms):
|
5 |
+
"""
|
6 |
+
Generate the text content of an XYZ format from a list of atoms.
|
7 |
+
:param atoms: List of atoms with their symbols and coordinates
|
8 |
+
:return: XYZ format as a string
|
9 |
+
"""
|
10 |
+
xyz_content = f"{len(atoms)}\n"
|
11 |
+
xyz_content += "XYZ file content generated from atoms_to_greed function\n"
|
12 |
+
for atom in atoms:
|
13 |
+
symbol, coordinates = atom
|
14 |
+
xyz_content += f"{symbol} {coordinates[0]:.3f} {coordinates[1]:.3f} {coordinates[2]:.3f}\n"
|
15 |
+
return xyz_content
|
interface_connection/latmatcher_interface.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
|
3 |
from backend.latmathcher.plots import plot_atom_list
|
4 |
-
from backend.latmathcher import atoms_to_greed
|
5 |
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
|
@@ -100,9 +100,10 @@ def compute_supercell_a(file_material_a, file_material_b,inter_distance , max_an
|
|
100 |
|
101 |
|
102 |
# Write the content to a file
|
103 |
-
with open(file12, 'w') as file:
|
104 |
-
|
105 |
-
|
|
|
106 |
|
107 |
plot=plot_supercel(super_xyz, min_supercel)
|
108 |
return file12, str(rez[0]), str((rez[1], rez[2])),plot, xyz_content
|
@@ -134,8 +135,8 @@ def plot_supercel(super_xyz, min_supercel):
|
|
134 |
y = [0.0, min_supercel.sc_vec3[1][0], min_supercel.sc_vec3[1][0] + min_supercel.sc_vec3[1][1],
|
135 |
min_supercel.sc_vec3[1][1], 0.0]
|
136 |
plt.gca().add_patch(patches.Polygon(xy=list(zip(x, y)), fill=True, alpha=0.4, color="green"))
|
137 |
-
plt.ylim(-
|
138 |
-
plt.xlim(-10,
|
139 |
# super_a = [super_xyz[i] for i in range(len(new_structure["host_guest"])) if
|
140 |
# new_structure["host_guest"][i] == "host"]
|
141 |
# super_b = [super_xyz[i] for i in range(len(new_structure["host_guest"])) if
|
|
|
1 |
|
2 |
|
3 |
from backend.latmathcher.plots import plot_atom_list
|
4 |
+
from backend.latmathcher import atoms_to_greed, generate_xyz_text
|
5 |
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
|
|
|
100 |
|
101 |
|
102 |
# Write the content to a file
|
103 |
+
# with open(file12, 'w') as file:
|
104 |
+
# file.write(xyz_content)
|
105 |
+
atoms= atoms_to_greed(super_xyz, lat_v=min_supercel.sc_vec3, dim=(5,5,0))
|
106 |
+
xyz_content=generate_xyz_text(atoms)
|
107 |
|
108 |
plot=plot_supercel(super_xyz, min_supercel)
|
109 |
return file12, str(rez[0]), str((rez[1], rez[2])),plot, xyz_content
|
|
|
135 |
y = [0.0, min_supercel.sc_vec3[1][0], min_supercel.sc_vec3[1][0] + min_supercel.sc_vec3[1][1],
|
136 |
min_supercel.sc_vec3[1][1], 0.0]
|
137 |
plt.gca().add_patch(patches.Polygon(xy=list(zip(x, y)), fill=True, alpha=0.4, color="green"))
|
138 |
+
plt.ylim(min(y)-10, max(y)+10)
|
139 |
+
plt.xlim(min(x)-10, max(x)+10)
|
140 |
# super_a = [super_xyz[i] for i in range(len(new_structure["host_guest"])) if
|
141 |
# new_structure["host_guest"][i] == "host"]
|
142 |
# super_b = [super_xyz[i] for i in range(len(new_structure["host_guest"])) if
|