Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/glwhart/enumlib
Browse files Browse the repository at this point in the history
  • Loading branch information
Gus Hart committed Sep 10, 2019
2 parents a3ae7bd + e2ad79a commit 1bf9f02
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 58 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Revision History for `enumlib`

## 2.0.2 (JJ)
- Fixed functions in `enumlib/wrap` to reflect changes to `get_dvector_permutations`.

## 2.0.1 (GLWH)
- Removed a bunch of print statements related to debugging of Rev. 2.0.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ be found in the ('enumlib/support/input') directory.
Detailed directions on how to run the code for several of the example
input files can be found in the `enumlib/support/EXAMPLES` file.

There are also helper programs in the aux_src directory for making VASP POSCARs, pictures of
2-D enumerations, etc.
There are also helper programs in the `aux_src` directory for making VASP POSCARs, pictures of
2D enumerations, etc.

`makeStr.py` <-- Makes POSCARS for the desired enumerated structures.
(`makeStr.x` from the fortran code has been superceded by this python script.)
Expand Down
50 changes: 34 additions & 16 deletions aux_src/HNF_profiler.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Module HNF_profiler
use derivative_structure_generator, only: get_all_HNFs, remove_duplicate_lattices, &
& get_dvector_permutations
use vector_matrix_utilities, only: minkowski_reduce_basis, norm, matrix_inverse, determinant
use symmetry, only: make_primitive, get_lattice_pointGroup
use symmetry, only: make_primitive, get_lattice_pointGroup, get_spaceGroup
use enumeration_types
implicit none
public get_HNFs
Expand All @@ -15,7 +15,7 @@ Module HNF_profiler
!!system.</parameter>
!!<parameter name="atom_pos" regular="true">The atomic basis in
!!cartesian coordinates.</parameter>
!!<parameter name="atom_types" regular="true">The atomic occupansies
!!<parameter name="atom_types" regular="true">The atomic occupancies
!!for each atom in the cell (atom A = 0, B = 1 ....).</parameter>
!!<parameter name="n_" regular="true">The determinant of the desired
!!HNF.</parameter>
Expand All @@ -32,8 +32,9 @@ Module HNF_profiler
!!<parameter name="pgs" regular="true">The size of the
!!point-group for the superlattice.</parameter>
subroutine get_HNFs(A, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_, eps_)
real(dp), intent(in) :: A(3,3), atom_pos(:,:)
integer, intent(in) :: atom_types(:)
real(dp), intent(in) :: A(3,3)
real(dp), allocatable :: atom_pos(:,:)
integer, intent(inout) :: atom_types(:)
integer, intent(out) :: hnfs(100,3,3)
real(dp), intent(out) :: r_mins(100), r_maxs(100)
integer, intent(out) :: pgs(100), dets(100)
Expand All @@ -46,13 +47,19 @@ subroutine get_HNFs(A, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_
type(RotPermList), pointer :: RPlist(:)
integer, pointer :: all_hnfs(:,:,:), unq_hnfs(:,:,:), degeneracy_list(:)
type(opList), pointer :: fixop(:)
real(dp), pointer :: latts(:,:,:), d(:,:), pg_Ops(:,:,:), atomPos(:,:)
real(dp), allocatable :: atomPos(:,:), d(:,:)
real(dp), pointer :: latts(:,:,:), pg_Ops(:,:,:)
real(dp) :: reduced_latt(3,3), norms(3), inv_lat(3,3), prim_lat(3,3)
integer :: temp_hnfs(100,3,3), det_fix, js(100), HNF(3,3),temp_mat(3,3)
integer, pointer :: atomTypes(:)
real(dp), allocatable, target :: temp_pos(:,:)
integer, allocatable, target :: temp_types(:)

real(dp), allocatable :: sg_op(:,:,:)
real(dp), allocatable :: sg_fract(:,:)
logical :: lattcoords
integer :: nD

! It only makes sense to use this code for bulk crystals and not
! surfaces so we hardcode the LatDim to be 3.
LatDim = 3
Expand Down Expand Up @@ -88,25 +95,36 @@ subroutine get_HNFs(A, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_
! Here we allocate temp variables for the atom types and positions
! and then associate them with pointers that will be passed into
! make_primitive. This is necessary because F90wrap cannot have
! pointers declared in the subroutine call derictley and so we
! pointers declared in the subroutine called directly and so we
! have to define the pointers internally. The pointers also can't
! be set equal to the input variables becaus it causes segfaults
! be set equal to the input variables because it causes segfaults
! when the code is run, hence the temporary variables.
allocate(temp_pos(size(atom_pos,1),size(atom_pos,2)),temp_types(size(atom_types,1)))
temp_pos = atom_pos
temp_types = atom_types
atomPos => temp_pos
temp_types = atom_types
atomPos = temp_pos
atomTypes => temp_types
call make_primitive(prim_lat, atomTypes, atomPos, .False., eps_=eps)

call get_dvector_permutations(prim_lat, d, dRPList, LatDim, eps)
! Get the space group of the parent lattice.
lattcoords = .false.
call get_spaceGroup(prim_lat, atom_types, atom_pos, sg_op, sg_fract, &
& lattcoords, eps)

! The number of active sites is the same as the number of atoms.
nD = size(atom_pos,2)

call get_dvector_permutations(prim_lat, d, nD, sg_op, sg_fract, dRPList, &
LatDim, eps)
call matrix_inverse(prim_lat, inv_lat)

do i=n_min,n_max
! Find all the HFNs then remove those that are equivalent.
! Find all the HNFs then remove those that are equivalent.
call get_all_HNFs(i, all_hnfs)
call remove_duplicate_lattices(all_hnfs, LatDim, prim_lat, d, dRPList, unq_hnfs, &
fixop, RPList, latts, degeneracy_list,eps)

call remove_duplicate_lattices(all_hnfs, LatDim, prim_lat, sg_op, &
sg_fract, d, dRPList, unq_hnfs, fixop, RPList, latts, &
degeneracy_list,eps)
count_i = 0
max_rmin = 0
temp_hnfs = 0
Expand Down Expand Up @@ -136,7 +154,7 @@ subroutine get_HNFs(A, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_
js(count_i) = j
end if
end do

do j=1,count_i
! We repeat the minkowski reduction here to get the rmax
! value and retrieve the point group for the lattice. Later
Expand All @@ -154,11 +172,11 @@ subroutine get_HNFs(A, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_
r_maxs(n_hnfs) = this_rmax
dets(n_hnfs) = i
pgs(n_hnfs) = size(pg_Ops,3)
if (n_hnfs==100) exit
if (n_hnfs==100) exit
end do
deallocate(latts, unq_hnfs, RPList, fixOp)
js = 0
if (n_hnfs==100) exit
if (n_hnfs==100) exit
end do
end subroutine get_HNFs

Expand Down
33 changes: 17 additions & 16 deletions aux_src/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
##BRIEF DESCRIPTION
### BRIEF DESCRIPTION

## Description of aux_src files

These files contain program's that can be useful for some users and need should be maintained but are not necessary for the main code, enum.x, to run. A description of what each file does follows:
These files contain programs that can be useful for some users and need should be maintained but are not necessary for the main code, `enum.x`, to run. A description of what each file does follows:

#makestr.f90:
makestr.f90 is used for making POSCARs, it is accessed and used in the src directory by typing
# makestr.f90:
`makestr.f90` is used for making `POSCAR`s. It is accessed and used in the src directory by typing
`make makestr.x`

#make2Dplot.f90: This program is used to make a 2D plot of the
# make2Dplot.f90:
This program is used to make a 2D plot of the
enumeration results. It can also be compiled in the src directory by
typing `make 2Dplot.x`. This program relies on splot.f which won't
typing `make 2Dplot.x`. This program relies on `splot.f` which won't
compile with gfortran. To use this program compile with ifort.

#convert_structure_to_enumformat.f90:
# convert_structure_to_enumformat.f90:
This program is designed to convert a structures.in file to structure.enum.out file. It can be compiled in the src directory using `make convert_structures_to_enumformat.x`

#HNF_counter.f90:
# HNF_counter.f90:

#compare_two_enum_files.f90:
# compare_two_enum_files.f90:
It can be compiled from the src directory using `make compare_enum_files.x`

#cwrapper.f90:
# cwrapper.f90:
This prgram provides an interface for C++.

#find_structure_in_list.f90:
# find_structure_in_list.f90:
It can be compiled from the src directory using `make find_structure_in_list.x`
ih
#makePerovStr.f90:

# makePerovStr.f90:
This program reads in a file in struct_enum.out format and writes out a VASP-like structue file. It can be compiled from the src directory using `make makeperovstr.x`

#makeStr2D.f90:
# makeStr2D.f90:
This program reads in a file in struct_enum.out format and writes out a VASP-like structue file for a surface calculation. It can be compiled in the src directory using `make makestr.2d`

#random_lattice_driver.f90:
# random_lattice_driver.f90:

If you have questions, email or call: gus.hart@gmail.com, 801-422-7444

For in-depth examples, please see the `EXAMPLES` file in the `support` directory.
For in-depth examples, please see the `EXAMPLES` file in the `support` directory.
4 changes: 2 additions & 2 deletions src/derivative_structure_generator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ MODULE derivative_structure_generator
private
public get_all_HNFs, remove_duplicate_lattices, get_SNF, get_all_2D_HNFs,&
& gen_multilattice_derivatives, find_permutation_of_group,&
get_dvector_permutations, get_rotation_perms_lists, do_rotperms_form_groups,&
& mixed_radix_counter
& get_dvector_permutations, get_rotation_perms_lists,&
& do_rotperms_form_groups, mixed_radix_counter

CONTAINS

Expand Down
5 changes: 0 additions & 5 deletions src/fixed_cells.in

This file was deleted.

7 changes: 3 additions & 4 deletions wrap/f90wrap_HNF_profiler.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ subroutine f90wrap_get_hnfs(a, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs,
dets, n0, n1, n2, n_, eps_)
use hnf_profiler, only: get_hnfs
implicit none

real(8), intent(in), dimension(3,3) :: a
real(8), intent(in), dimension(n0,n1) :: atom_pos
integer, intent(in), dimension(n2) :: atom_types
real(8), intent(in), dimension(n0,n1), allocatable :: atom_pos(:,:)
integer, intent(inout), dimension(n2) :: atom_types
integer, dimension(100,3,3), intent(inout) :: hnfs
real(8), dimension(100), intent(inout) :: r_mins
real(8), dimension(100), intent(inout) :: r_maxs
Expand All @@ -26,4 +26,3 @@ subroutine f90wrap_get_hnfs(a, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs,
end subroutine f90wrap_get_hnfs

! End of module hnf_profiler defined in file ../aux_src/HNF_profiler.f90

26 changes: 13 additions & 13 deletions wrap/supercell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def get_supers(atoms,n_=None,eps_=None):
n_ (default 100) multiples of the parent cell.
Args:
atoms (quipy.atoms.Atoms): an atoms object that the supercell
atoms (quipy.atoms.Atoms): an atoms object that the supercell
matrices will be found for.
n_ (int): optional maximum number of multiples to find.
eps_ (float): optional floating point tolerance.
Returns:
(hnfs,rmin) the integer matrices that create unique supercells of the parent,
and the rmin_values that match.
Expand All @@ -30,8 +30,8 @@ def get_supers(atoms,n_=None,eps_=None):
u_atoms = np.unique(atoms_nums)
atom_types = []
for i in atoms_nums:
atom_types.append(np.where(u_atoms==i)[0][0])
atom_types.append(np.where(u_atoms==i)[0][0])

Hnf_Profiler.get_hnfs(np.transpose(atoms.cell), np.transpose(atoms.positions),
atom_types, hnfs, rmin, rmax, pgs, dets, n_=n_, eps_=eps_)
# We have more entries than needed. We only want to keep the non-zero ones.
Expand All @@ -43,20 +43,20 @@ def get_supers(atoms,n_=None,eps_=None):
class Hnf_Profiler(f90wrap.runtime.FortranModule):
"""
Module hnf_profiler
Defined at ../aux_src/HNF_profiler.f90 lines 1-141
"""
@staticmethod
def get_hnfs(a, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_=None, \
eps_=None):
"""
get_hnfs(a, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets[, n_, eps_])
Defined at ../aux_src/HNF_profiler.f90 lines 34-141
Parameters
----------
a : float array
Expand All @@ -69,13 +69,13 @@ def get_hnfs(a, atom_pos, atom_types, hnfs, r_mins, r_maxs, pgs, dets, n_=None,
dets : int array
n_ : int
eps_ : float
"""
_supercell.f90wrap_get_hnfs(a=a, atom_pos=atom_pos, atom_types=atom_types, \
hnfs=hnfs, r_mins=r_mins, r_maxs=r_maxs, pgs=pgs, dets=dets, n_=n_, \
eps_=eps_)

_dt_array_initialisers = []


hnf_profiler = Hnf_Profiler()

0 comments on commit 1bf9f02

Please sign in to comment.