Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI4dft v1.4 #36

Merged
merged 9 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.10.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -42,10 +42,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.10.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -61,10 +61,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.10.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -91,10 +91,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.10.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -110,10 +110,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
- name: Set up Python 3.10.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
GUI4dft (Graphical User Interface for support of Density Functional Theory calculations) - first free SIESTA oriented GUI. It is a cross-platform program.

## Install
GUI4DFT program is written in Python 3 (version >= 3.9). It has some dependences. To install the necessary modules, run in the terminal (in the <gui4dft path>):
GUI4DFT program is written in Python 3 (version 3.9 or 3.10). It has some dependences. To install the necessary modules, run in the terminal (in the <gui4dft path>):

pip3 install -r ./requirements.txt

Expand Down Expand Up @@ -34,7 +34,9 @@ v1.2 - Contains some additional features. For example, it allows visualizing the

v1.3 - This version uses pyqtgraph instead of matplotlib and pyside2 instead of PyQt5. The colors of the atoms and covalent radii are taken from the ASE module. The project is covered with tests.

v1.4 - This is the next release in 1.x branch. Pyside6. Added support for exporting structural data to input files VASP, CRYSTAL, QE.
v1.4 - Pyside6. Added support for exporting structural data to input files VASP, CRYSTAL, QE.

v1.5 - This is the next release in 1.x branch. Python 3.12.

The master branch contains more or less stable 1.x version functions.

Expand Down
1 change: 1 addition & 0 deletions src/core_atomistic/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, at_data):
self.xyz = np.array([at_data[0], at_data[1], at_data[2]])
self.let = at_data[3]
self.charge = int(at_data[4])
self.cluster: int = 0
self.is_visible: bool = True
self.selected: bool = False
self.active: bool = False
Expand Down
60 changes: 41 additions & 19 deletions src/core_atomistic/atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
def __getitem__(self, i):
return self.atoms[i]

def add_atom_with_data(self, xyz: np.ndarray, charge: int, tag: str = "") -> None:
def add_atom_with_data(self, xyz: np.ndarray, charge: int, let: str = "", tag: str = "") -> None:
"""
xyz: coords
charge: atomic number
tag: additional information
"""
let = self.mendeley.get_let(charge)
if let == "":
let = self.mendeley.get_let(charge)
atom = Atom([*xyz, let, charge])
atom.tag = tag
self.atoms.append(atom)
Expand Down Expand Up @@ -130,7 +131,7 @@
def twist_z(self, alpha):
cm = self.center_mass()
self.move(-cm)
z0 = self.minZ()
z0 = self.min_z()

Check warning on line 134 in src/core_atomistic/atomic_model.py

View check run for this annotation

Codecov / codecov/patch

src/core_atomistic/atomic_model.py#L134

Added line #L134 was not covered by tests
z1 = np.linalg.norm(self.lat_vector3)

for i in range(0, len(self.atoms)):
Expand Down Expand Up @@ -182,15 +183,17 @@
str2 = ani_file.readline()
else:
str2 = ani_file.readline()
atoms = []
new_model = AtomicModel()
mendeley = TPeriodTable()
reg = re.compile('[^a-zA-Z ]')
for i1 in range(0, number_of_atoms):
str1 = helpers.spacedel(str2)
s = str1.split(' ')
d1 = float(s[indexes[1]])
d2 = float(s[indexes[2]])
d3 = float(s[indexes[3]])
xyz = np.array([s[indexes[1]], s[indexes[2]], s[indexes[3]]], dtype=float)
if max(indexes) < len(s) - 1:
tag = s[max(indexes) + 1]
else:
tag = ""
c = s[indexes[0]]
if c.isnumeric():
charge = int(c)
Expand All @@ -199,10 +202,9 @@
c = reg.sub('', s[indexes[0]])
charge = mendeley.get_charge_by_letter(c)
if (charge > 0) or is_allow_charge_incorrect:
atoms.append([d1, d2, d3, c, charge])
new_model.add_atom_with_data(xyz, charge, let=c, tag=tag)
if i1 < number_of_atoms -1:
str2 = ani_file.readline()
new_model = AtomicModel(atoms)
new_model.set_lat_vectors_default()
return new_model

Expand Down Expand Up @@ -395,6 +397,12 @@
self.rotate_y(betta)
self.rotate_z(gamma)

def sub_model(self, inds):
new_model_atoms = []
for i in inds:
new_model_atoms.append(self.atoms[i])
return AtomicModel(new_model_atoms)

Check warning on line 404 in src/core_atomistic/atomic_model.py

View check run for this annotation

Codecov / codecov/patch

src/core_atomistic/atomic_model.py#L401-L404

Added lines #L401 - L404 were not covered by tests

def projection_to_cylinder(self, atomslist, radius):
"""This method returns projections on cylinder with radius for atom at."""
row = []
Expand Down Expand Up @@ -490,15 +498,15 @@
cif_text += "\n\n\n\n#End data_GUI4dft_Data\n\n\n"
return cif_text

def minX(self):
def min_x(self):
"""Minimum X-coordinate."""
minx = self.atoms[0].x
for atom in self.atoms:
if float(atom.x) < float(minx):
minx = atom.x
return float(minx)

def maxX(self):
def max_x(self):
"""Maximum X-coordinate."""
maxx = self.atoms[0].x
for atom in self.atoms:
Expand All @@ -508,9 +516,9 @@

def size_x(self):
"""The length of the molecule along the X axis."""
return self.maxX() - self.minX()
return self.max_x() - self.min_x()

def minY(self):
def min_y(self):
"""Minimum Y-coordinate."""
miny = self.atoms[0].y

Expand All @@ -519,7 +527,7 @@
miny = atom.y
return float(miny)

def maxY(self):
def max_y(self):
"""Maximum Y-coordinate."""
maxy = self.atoms[0].y

Expand All @@ -530,9 +538,9 @@

def size_y(self):
"""The length of the molecule along the Y axis."""
return self.maxY() - self.minY()
return self.max_y() - self.min_y()

def minZ(self):
def min_z(self):
"""Minimum Z-coordinate."""
minz = self.atoms[0].z

Expand All @@ -541,7 +549,7 @@
minz = atom.z
return float(minz)

def maxZ(self):
def max_z(self):
"""Maximum Z-coordinate."""
maxz = self.atoms[0].z

Expand All @@ -552,7 +560,11 @@

def size_z(self):
"""The length of the molecule along the Z axis."""
return self.maxZ() - self.minZ()
return self.max_z() - self.min_z()

def set_cluster(self, cluster, k):
for atom in cluster:
self.atoms[atom].cluster = k

Check warning on line 567 in src/core_atomistic/atomic_model.py

View check run for this annotation

Codecov / codecov/patch

src/core_atomistic/atomic_model.py#L566-L567

Added lines #L566 - L567 were not covered by tests

def sort_atoms_by_type(self):
for i in range(0, self.n_atoms()):
Expand Down Expand Up @@ -642,6 +654,16 @@
clusters.append(cluster)
return clusters

def find_clusters_by_tag(self):
clusters = []
tags = np.array(self.get_tags(), dtype=int)
size = max(tags)
for i in range(0, size):
clusters.append([])
for i in range(0, len(self.atoms)):
clusters[tags[i] - 1].append(i)
return clusters

Check warning on line 665 in src/core_atomistic/atomic_model.py

View check run for this annotation

Codecov / codecov/patch

src/core_atomistic/atomic_model.py#L658-L665

Added lines #L658 - L665 were not covered by tests

def find_bonds_exact(self):
"""The method returns list of bonds of the molecule."""
if self.bonds_per:
Expand Down Expand Up @@ -838,7 +860,7 @@
self.go_to_positive_array_translate(self.atoms)

def go_to_positive_coordinates(self):
d_vec = np.array([self.minX(), self.minY(), self.minZ()])
d_vec = np.array([self.min_x(), self.min_y(), self.min_z()])

Check warning on line 863 in src/core_atomistic/atomic_model.py

View check run for this annotation

Codecov / codecov/patch

src/core_atomistic/atomic_model.py#L863

Added line #L863 was not covered by tests
self.move_array(self.atoms, d_vec)
self.go_to_positive_array(self.atoms)

Expand Down
1 change: 0 additions & 1 deletion src/core_atomistic/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def list_of_values(filename, prop):
return list_of_val



def write_text_to_file(f_name, text): # pragma: no cover
if len(f_name) > 0:
with open(f_name, 'w') as f:
Expand Down
10 changes: 6 additions & 4 deletions src/core_atomistic_qt/opengl_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def __init__(self, parent=None):
self.main_model = None
self.perspective_angle: int = 35
self.background_color = np.array((1.0, 1.0, 1.0), dtype=float)
self.periodic_table = TPeriodTable()
self.color_of_atoms = self.periodic_table.get_all_colors()
self.color_of_bonds_by_atoms: bool = True
self.is_check_atom_selection: bool = False
self.quality: int = 1
# opengl lists
Expand Down Expand Up @@ -773,9 +776,9 @@ def auto_zoom(self):
if self.is_orthographic:
self.scale_factor = aspect * 6.0 / model_size
else:
x_max = self.main_model.maxX()
y_max = self.main_model.maxY()
z_max = self.main_model.maxZ()
x_max = self.main_model.max_x()
y_max = self.main_model.max_y()
z_max = self.main_model.max_z()
rad = self.main_model.get_covalent_radii().max()
h, w = self.height(), self.width()
size = x_max + rad if h > w else y_max + rad
Expand Down Expand Up @@ -864,7 +867,6 @@ def bond_len_correct(self, let1: str, let2: str, d: float):
ch2 = self.main_model.mendeley.get_charge_by_letter(let2)
self.main_model.mendeley.Bonds[ch1][ch2] = d
self.main_model.mendeley.Bonds[ch2][ch1] = d
#self.main_model.set_mendeley(self.periodic_table)
self.main_model.find_bonds_fast()
self.add_all_elements()
self.update()
8 changes: 4 additions & 4 deletions src/models/capedswcnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, n, m, leng, ncell, type, dist1, angle1, dist2, angle2):
for i in range(0, size1):
capatoms[i].z = -capatoms[i].z

minz = self.minZ()
maxz = capatoms.maxZ()
minz = self.min_z()
maxz = capatoms.max_z()

capatoms.move(np.array([0, 0, minz - maxz - zaz]))
capatoms.rotate_z(angle1)
Expand All @@ -52,8 +52,8 @@ def __init__(self, n, m, leng, ncell, type, dist1, angle1, dist2, angle2):
if not self.invert():
for i in range(0, size1):
capatoms[i].z = -capatoms[i].z
maxz = self.maxZ()
minz = capatoms.minZ()
maxz = self.max_z()
minz = capatoms.min_z()

zaz = dist2

Expand Down
Loading
Loading