Skip to content

Commit

Permalink
Merge pull request #34 from sozykinsa/version1_4_beta
Browse files Browse the repository at this point in the history
Version1 4 beta
  • Loading branch information
sozykinsa authored Feb 4, 2024
2 parents 0753699 + c81246d commit c574403
Show file tree
Hide file tree
Showing 105 changed files with 589 additions and 392 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Lint with flake8
Expand All @@ -37,6 +36,25 @@ jobs:
# exit-zero treats all errors as warnings. black defaults to 88 characters
flake8 . --exclude src/ui/*, --count --exit-zero --max-complexity=18 --max-line-length=120 --statistics
test-core:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Test with pytest
run: |
python -m pytest tests_core_atomistic --cov=src/core_atomistic --cov-report=xml --cov-report=term-missing
test-linux:

runs-on: ubuntu-latest
Expand All @@ -50,12 +68,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-qt
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Test with pytest
run: |
python -m pytest tests --cov=src/core_gui_atomistic --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl --ignore=tests/core_gui_atomistic_qt
python -m pytest tests --cov=src --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -81,12 +98,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-qt pytest-xvfb
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Test with pytest
run: |
python -m pytest tests --color=yes --cov=src/core_gui_atomistic --cov=src/src_gui4dft --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl
python -m pytest tests --color=yes --cov=src/core_atomistic --cov=src/src_gui4dft --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl
test-mac:

Expand All @@ -105,4 +121,4 @@ jobs:
pip install -r requirements-dev.txt
- name: Test with pytest
run: |
python -m pytest tests --color=yes --cov=src/core_gui_atomistic --cov=src/src_gui4dft --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl
python -m pytest tests --color=yes --cov=src/core_atomistic --cov=src/src_gui4dft --cov-report=xml --cov-report=term-missing --ignore=tests/gui4dft_opengl
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ executable/build/
executable/gui4dft.spec
tests/.coverage
.coverage
coverage.xml
coverage.xml
/tests_core_atomistic/.pytest_cache
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
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.8). It has some dependences. To install the necessary modules, run in the terminal (command line):
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>):

pip3 install -r ./requirements.txt

To run the program, type
To run the program, type (in the <gui4dft path>/src)

python3 gui4dft.py

## Problems with Install?

You have to set the variable QT_API:

export QT_API=pyside2 (in linux, or https://www.architectryan.com/2018/08/31/how-to-change-environment-variables-on-windows-10/ in Windows)
export QT_API=pyside6 (in linux, or https://www.architectryan.com/2018/08/31/how-to-change-environment-variables-on-windows-10/ in Windows)

Some operating systems may require additional packages to be installed:

Xubuntu: sudo apt-get install qtbase5-dev
Ubuntu 22.04: sudo apt-get install -y libxcb-cursor-dev
Xubuntu: ? sudo apt-get install qtbase5-dev

## Explanations for the versions of the program

Expand All @@ -33,7 +34,7 @@ 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. Added support for exporting structural data to input files VASP, CRYSTAL, QE.
v1.4 - This is the next release in 1.x branch. Pyside6. Added support for exporting structural data to input files VASP, CRYSTAL, QE.

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

Expand Down
2 changes: 2 additions & 0 deletions requirements-dev-qt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest-qt
pytest-xvfb
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pytest
pytest-cov
pytest-qt
pytest-xvfb
black
flake8
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyopengl
pyside2
pyside6
qtpy
ase
numpy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from core_gui_atomistic import helpers
from core_atomistic import helpers
import numpy as np


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from numpy.linalg import inv
from numpy.linalg import norm

from core_gui_atomistic import helpers
from core_gui_atomistic.periodic_table import TPeriodTable
from core_gui_atomistic.atom import Atom
from core_atomistic import helpers
from core_atomistic.periodic_table import TPeriodTable
from core_atomistic.atom import Atom
from scipy.spatial.distance import cdist
from scipy.optimize import fmin
import scipy
Expand Down Expand Up @@ -783,6 +783,16 @@ def types_of_atoms(self):
types.append([i, elements[i]])
return types

def get_charge_to_type_array(self):
per_tab = self.mendeley
text = ""
types = self.types_of_atoms()
charge_to_type = np.zeros(200, dtype=int)
for i in range(0, len(types)):
text += ' ' + str(per_tab.get_let(int(types[i][0])))
charge_to_type[int(types[i][0])] = i + 1
return charge_to_type, text

def formula(self):
text = ""
charges = self.types_of_atoms()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# -*- coding: utf-8 -*-

import numpy as np
from ase.data import covalent_radii
from ase.data import covalent_radii, atomic_masses_common
from ase.data.colors import cpk_colors, jmol_colors


class TPeriodTableAtom:
"""Replace color by 'user_color', 'ase_color', 'xxx_color'"""
def __init__(self, charge, radius, let, color, mass=1):
def __init__(self, charge, radius, let, color, mass=0):
self.charge = charge
self.radius = radius
self.let = let
# self.color = color
self.mass = mass
if (mass == 0) and (charge < 119):
self.mass = atomic_masses_common[charge]
else:
self.mass = mass


default_color = [0.6, 0.6, 1.0, 1.0]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import numpy as np
from core_gui_atomistic.atomic_model import AtomicModel
from core_atomistic.atomic_model import AtomicModel


class GUI4dftProjectFile(object):
class ProjectFile(object):

@staticmethod
def project_file_writer(model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import OpenGL.GL as gl
import OpenGL.GLU as glu
from qtpy.QtWidgets import QOpenGLWidget
from PySide2.QtCore import QEvent
from PySide2.QtCore import Qt
from PySide2.QtGui import QColor, QPainter, QFont
from qtpy.QtCore import QEvent
from qtpy.QtCore import Qt
from qtpy.QtGui import QColor, QPainter, QFont
from copy import deepcopy
from core_gui_atomistic.periodic_table import TPeriodTable
from core_gui_atomistic.atom import Atom
from core_atomistic.periodic_table import TPeriodTable
from core_atomistic.atom import Atom
import math
import numpy as np

Expand Down Expand Up @@ -619,9 +619,6 @@ def light_prepare(self) -> None:
gl.glEnable(gl.GL_LIGHT0)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glEnable(gl.GL_COLOR_MATERIAL)
# gl.glDisable(gl.GL_COLOR_MATERIAL)

# Determine the current lighting model
gl.glLightModelf(gl.GL_LIGHT_MODEL_TWO_SIDE, gl.GL_TRUE) # two-side lighting calculation

gl.glEnable(gl.GL_LIGHT0)
Expand Down Expand Up @@ -680,7 +677,7 @@ def render_text(self, text_to_render, font=QFont()):
fl = False
if fl:
used_space.append([pos_x, pos_y])
painter.drawText(pos_x - self.property_x_shift, pos_y - self.property_y_shift, st)
painter.drawText(int(pos_x - self.property_x_shift), int(pos_y - self.property_y_shift), st)
painter.end()

@staticmethod
Expand Down Expand Up @@ -861,3 +858,13 @@ def set_atomic_structure(self, structure):
self.main_model.find_bonds_fast()
self.add_all_elements()
self.update()

def bond_len_correct(self, let1: str, let2: str, d: float):
ch1 = self.main_model.mendeley.get_charge_by_letter(let1)
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()
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# ------------------------------------------------------
# https://www.pythonguis.com/tutorials/pyside-plotting-pyqtgraph/

from PySide2.QtWidgets import QWidget, QVBoxLayout
from PySide2.QtGui import QFont
from PySide2.QtCore import Qt
from qtpy.QtWidgets import QWidget, QVBoxLayout
from qtpy.QtGui import QFont
from qtpy.QtCore import Qt
import pyqtgraph as pg # pip install pyqtgraph
import numpy as np
from typing import List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------------------------
# https://www.pythonguis.com/tutorials/pyside-plotting-pyqtgraph/

from PySide2.QtWidgets import QWidget, QVBoxLayout
from qtpy.QtWidgets import QWidget, QVBoxLayout
import pyqtgraph as pg # pip install pyqtgraph


Expand Down
8 changes: 4 additions & 4 deletions src/gui4dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import sys
from pathlib import Path

from PySide2.QtCore import QCoreApplication, Qt
from PySide2.QtGui import QIcon
from PySide2.QtWidgets import QApplication
from qtpy.QtCore import QCoreApplication, Qt
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import QApplication

from src_gui4dft.qtbased.mainform import MainForm
from qtbased.gui4dftform import MainForm

sys.path.append('.')

Expand Down
4 changes: 2 additions & 2 deletions src/src_gui4dft/models/bint.py → src/models/bint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import math

from core_gui_atomistic.atom import Atom
from core_gui_atomistic.atomic_model import AtomicModel as TAtomicModel
from core_atomistic.atom import Atom
from core_atomistic.atomic_model import AtomicModel as TAtomicModel


class BiNT(TAtomicModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from src_gui4dft.models.hexagonal_plane import HexagonalPlane
from models.hexagonal_plane import HexagonalPlane


class BNplane(HexagonalPlane):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
from pathlib import Path

from core_gui_atomistic.atom import Atom
from core_gui_atomistic.atomic_model import AtomicModel as TAtomicModel
from src_gui4dft.models.swnt import SWNT
from core_atomistic.atom import Atom
from core_atomistic.atomic_model import AtomicModel as TAtomicModel
from models.swnt import SWNT


class CapedSWNT(TAtomicModel):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
69 changes: 69 additions & 0 deletions src/models/cells/hgy.fdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
NumberOfAtoms 24
NumberOfSpecies 1
WriteCoorStep True
%block ChemicalSpeciesLabel
1 6 C
%endblock ChemicalSpeciesLabel
LatticeConstant 1.0 Ang
%block LatticeParameters
10.918132 10.928019191942518 30.0 90.0 90.0 120.00000
%endblock LatticeParameters
AtomicCoordinatesFormat Ang
%block AtomicCoordinatesAndAtomicSpecies
7.73771075 3.91646015 0.00321888 1
5.83793527 5.69686868 0.00319663 1
7.00307550 2.64489670 0.00307992 1
5.58637353 2.79043812 0.00286192 1
6.90851533 5.07320737 0.00327538 1
4.51568352 3.41388222 0.00280007 1
2.27998040 4.56839740 0.00299596 1
3.68665538 4.57067093 0.00292072 1
1.45070689 3.41175512 0.00293376 1
0.12813302 5.69609889 0.00325181 1
1.54433620 5.83873967 0.00311587 1
2.24726774 7.05705163 0.00304912 1
3.71590058 7.05956093 0.00303845 1
4.42123046 5.84219660 0.00303219 1
1.66047367 8.35368040 0.00310463 1
4.29878106 8.35798568 0.00318221 1
9.14444238 3.91853989 0.00325878 1
9.88011355 2.64811366 0.00317446 1
7.70830376 1.42741070 0.00313964 1
9.17704378 1.42984463 0.00319481 1
7.12538799 0.12889487 0.00300610 1
9.76369877 0.13318502 0.00312341 1
9.97401099 5.07495527 0.00337039 1
11.29642180 2.79082798 0.00306982 1
%endblock AtomicCoordinatesAndAtomicSpecies
SystemName tpdhg
SystemLabel C224
WriteMullikenPop 1
PAO.BasisSize DZP
MeshCutoff 350.0 Ry
SpinPolarized True
MaxSCFIterations 150
SolutionMethod diagon
NetCharge 0.00
DM.NumberPulay 4
DM.MixingWeight 0.3
DM.UseSaveDM .true.
NeglNonOverlapInt False
XC.functional=GGA
XC.authors=PBE
WriteCoorXmol True
WriteForces .true.
WriteMullikenPop 1
MD.TypeOfRun cg # Type of dynamics: Conjugate gradients
MD.NumCGsteps 320 # number of CG steps
MD.MaxCGDispl 0.10 Ang
MD.MaxForceTol 0.04 eV/Ang
MD.UseSaveXV yes
MD.VariableCell .false.
%block kgrid_Monkhorst_Pack
3 0 0 0.0
0 3 0 0.0
0 0 1 0.0
%endblock kgrid_Monkhorst_Pack
%block ProjectedDensityOfStates
-24.00 15.00 0.100 1000 eV
%endblock ProjectedDensityOfStates
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c574403

Please sign in to comment.