Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
17ad738
Improve commenting and formatting
nedtaylor Oct 23, 2024
902afc8
Add walk step size variables
nedtaylor Oct 23, 2024
5634a9f
Remove unused checks
nedtaylor Oct 23, 2024
362f66c
Add comments
nedtaylor Oct 23, 2024
190af4f
Remove unused pi
nedtaylor Oct 23, 2024
64c8a1b
Add 2body procedure
nedtaylor Oct 23, 2024
6992f41
Move host element map to call to generator
nedtaylor Oct 23, 2024
984e6da
Fix error handling
nedtaylor Oct 23, 2024
19081c9
Add missing initialisation
nedtaylor Oct 23, 2024
7816d7f
Fix missing variable
nedtaylor Oct 23, 2024
614fab2
Split evolver into three separate module files
nedtaylor Oct 23, 2024
dd772b4
Add raffle__ prefix to module names
nedtaylor Oct 23, 2024
71971ec
Fix set host
nedtaylor Oct 23, 2024
ab8b148
Fix comments
nedtaylor Oct 23, 2024
ae97ba2
Change real12 to real32
nedtaylor Oct 23, 2024
67f240c
Split edit_geom into two modules
nedtaylor Oct 23, 2024
d5c7af0
Rename raffle__rw_geom to raffle__geom_rw
nedtaylor Oct 23, 2024
ed4aa6a
Rename elements to raffle__element_utils
nedtaylor Oct 23, 2024
9f769ff
Add comments
nedtaylor Oct 23, 2024
159811f
Add walk step size parameters
nedtaylor Oct 23, 2024
b405367
Split add_atom into two modules
nedtaylor Oct 23, 2024
1bd0193
Fix geom_rw rename
nedtaylor Oct 23, 2024
caab918
Remove unused module imports
nedtaylor Oct 23, 2024
e4bc1b4
Rename total to gdf in distribs_container_type
nedtaylor Oct 23, 2024
1413186
Rename extended_geom to raffle__geom_extd
nedtaylor Oct 23, 2024
b2e7c37
Fix element_utils reference
nedtaylor Oct 23, 2024
d1bb589
Replace rw_geom with geom_rw
nedtaylor Oct 23, 2024
d759d8f
Fix missing line continuation symbols
nedtaylor Oct 23, 2024
7a04c03
Standardise module names
nedtaylor Oct 23, 2024
bc6c33a
Update ignore list
nedtaylor Oct 23, 2024
570f64a
Remove file
nedtaylor Oct 23, 2024
a206431
Add centralised version number handling
nedtaylor Oct 23, 2024
86fb0d7
Remove redundancies
nedtaylor Oct 23, 2024
ac88388
Improve comments and formatting
nedtaylor Oct 23, 2024
9ceee54
Fix bond_info pair index reference
nedtaylor Oct 23, 2024
031d8a4
Fix missing distributions reference
nedtaylor Oct 23, 2024
9c8dc79
Remove unused procedures
nedtaylor Oct 23, 2024
8f76ccb
Add comments
nedtaylor Oct 23, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ fort.*
*.log
*.agr
*.pdf
*.eps
*.eps
*.pyc
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ set(FORTRAN_SRC_DIR ${SRC_DIR}/fortran)
set(LIB_DIR ${FORTRAN_SRC_DIR}/lib)

set(LIB_FILES
mod_error_handling.f90
mod_io_utils.F90
mod_constants.f90
mod_misc.f90
mod_misc_maths.f90
mod_misc_linalg.f90
mod_edit_geom.f90
mod_extended_geom.f90
mod_elements.f90
mod_dist_calcs.f90
mod_geom_utils.f90
mod_geom_extd.f90
mod_element_utils.f90
mod_evaluator.f90
mod_atom_adder.f90
mod_place_methods.f90
mod_viability.f90
mod_distribs.f90
mod_distribs_host.f90
)

set(SPECIAL_LIB_FILES
mod_rw_geom.f90
mod_evolver.f90
mod_geom_rw.f90
mod_distribs_container.f90
mod_generator.f90
# mod_generator_sub.f90
)
Expand Down
67 changes: 37 additions & 30 deletions app/inputs.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module inputs
!! Module for reading input files and setting global variables.
use misc_raffle, only: file_check,flagmaker, icount, to_lower
use generator, only: stoichiometry_type
use constants, only: real12, verbose, pi
use raffle__misc, only: file_check,flagmaker, icount, to_lower
use raffle__generator, only: stoichiometry_type
use raffle__constants, only: real32, pi
use raffle__io_utils
implicit none


Expand All @@ -21,29 +22,31 @@ module inputs
public :: bond_pairs, pair_radii

public :: set_global_vars
public :: verbose


logical :: lseed

integer :: verbose
integer :: seed !random seed
integer :: num_structures ! number of structures to generate
integer :: task ! task setting (defines the RAFFLE task)
type(stoichiometry_type), dimension(:), allocatable :: stoich ! stoichiometry of species to add

integer :: vdW, volvar

real(real12), dimension(3) :: cutoff_min_list, cutoff_max_list
real(real12), dimension(3) :: width_list, sigma_list
real(real32), dimension(3) :: cutoff_min_list, cutoff_max_list
real(real32), dimension(3) :: width_list, sigma_list

real(real12), dimension(:), allocatable :: element_energies
real(real12), dimension(:), allocatable :: pair_radii
real(real32), dimension(:), allocatable :: element_energies
real(real32), dimension(:), allocatable :: pair_radii
character(3), dimension(:), allocatable :: element_symbols
character(3), dimension(:,:), allocatable :: bond_pairs

integer, dimension(3) :: grid = [0, 0, 0]
real(real12) :: grid_spacing = 0._real12
real(real12), dimension(5) :: method_probab = &
[1._real12, 0.1_real12, 0.5_real12, 0.5_real12, 1._real12]
real(real32) :: grid_spacing = 0._real32
real(real32), dimension(5) :: method_probab = &
[1._real32, 0.1_real32, 0.5_real32, 0.5_real32, 1._real32]

character(1024), dimension(:), allocatable :: database_list ! list of directories containing input database
character(1024) :: database_format !format of input file (POSCAR, XYZ, etc.
Expand Down Expand Up @@ -81,7 +84,7 @@ subroutine set_global_vars()
!---------------------------------------------------------------------------
! Reads flags and assigns to variables
!---------------------------------------------------------------------------
flagloop: do i=0,command_argument_count()-1
flagloop: do i=0,command_argument_count()
empty=.false.
if (skip) then
skip=.false.
Expand Down Expand Up @@ -119,6 +122,10 @@ subroutine set_global_vars()
!------------------------------------------------------------------------
elseif(index(buffer,'-v').eq.1)then
flag="-v"
call print_build_info()
stop 0
elseif(index(buffer,'--verbose').eq.1)then
flag="--verbose"
call flagmaker(buffer,flag,i,skip,empty)
if(.not.empty) read(buffer,*) verbose
elseif(index(buffer,'-h').eq.1)then
Expand Down Expand Up @@ -182,9 +189,9 @@ subroutine read_input_file(file_name)
character(1024) :: stoichiometry, database, buffer, energies, &
bond_radii
!! Strings buffers to hold input values (usually derived types).
real(real12), dimension(3) :: width, sigma
real(real32), dimension(3) :: width, sigma
!! Width and sigma values for distribution functions.
real(real12) :: void, rand, walk, grow, min
real(real32) :: void, rand, walk, grow, min
!! Placement method probabilities.
character(50), dimension(3) :: cutoff_min, cutoff_max
!! Cutoff values for distribution functions.
Expand Down Expand Up @@ -213,12 +220,12 @@ subroutine read_input_file(file_name)
output_dir = "iteration1"
cutoff_min = "-1.0"
cutoff_max = "-1.0"
width = -1._real12
sigma = -1._real12
width = -1._real32
sigma = -1._real32
database_format = "vasprun.xml"
void = 0._real12; rand = 0._real12
walk = 0._real12; grow = 0._real12
min = 0._real12
void = 0._real32; rand = 0._real32
walk = 0._real32; grow = 0._real32
min = 0._real32
!---------------------------------------------------------------------------
! read namelists from input file
!---------------------------------------------------------------------------
Expand Down Expand Up @@ -263,7 +270,7 @@ subroutine read_input_file(file_name)
method_probab = [void, rand, walk, grow, min]
if(all(abs(method_probab).lt.1.E-6))then
method_probab = &
[1._real12, 0.1_real12, 0.5_real12, 0.5_real12, 1._real12]
[1._real32, 0.1_real32, 0.5_real32, 0.5_real32, 1._real32]
end if

if(trim(stoichiometry).ne."")then
Expand Down Expand Up @@ -349,23 +356,23 @@ function read_value_from_string(string) result(output)
! Arguments
character(*), intent(in) :: string
!! Input string.
real(real12) :: output
real(real32) :: output
!! Output value.

! Local variables
integer :: k, pos
!! Loop index, position.
real(real12) :: variable, power
real(real32) :: variable, power
!! Variable and power values.
character(:), allocatable :: string_
!! Copy of input string.
character(12) :: numeric_set = "0123456789.-"
!! Numeric set.

pos = 1
output = 1._real12
variable = 0._real12
power = 1._real12
output = 1._real32
variable = 0._real32
power = 1._real32
string_ = trim(to_lower(string))
loop: do
!! read until first non-numeric character
Expand All @@ -382,20 +389,20 @@ function read_value_from_string(string) result(output)

pos = pos + k - 1
!! identify what the next character is (*, /, pi)
!! if *, then change power factor to 1._real12
!! if /, then change power factor to -1._real12
!! if pi, then change power factor to 1._real12 and variable = pi
!! if *, then change power factor to 1._real32
!! if /, then change power factor to -1._real32
!! if pi, then change power factor to 1._real32 and variable = pi
!! if blank space, move pos to next non-space character and cycle
!! if end of string, exit loop

if (string_(pos:pos).eq."*")then
power = 1._real12
power = 1._real32
pos = pos + 1
elseif(string_(pos:pos).eq."/")then
power = -1._real12
power = -1._real32
pos = pos + 1
elseif(string_(pos:pos+1).eq."pi")then
power = 1._real12
power = 1._real32
output = output * pi ** power
pos = pos + 2
end if
Expand Down
14 changes: 7 additions & 7 deletions app/main.f90
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
program raffle_program
!! Main program for the interface-based random structure search
use constants, only: real12
use error_handling, only: stop_program
use misc_raffle, only: touch
use raffle__constants, only: real32
use raffle__io_utils, only: stop_program
use raffle__misc, only: touch
use inputs
use read_structures, only: get_evolved_gvectors_from_data
use raffle, only: raffle_generator_type, gvector_container_type
use rw_geom, only: geom_read, geom_write
use raffle, only: raffle_generator_type, distribs_container_type
use raffle__geom_rw, only: geom_read, geom_write
implicit none

! Local variables
Expand All @@ -17,7 +17,7 @@ program raffle_program
character(:), allocatable :: next_dir
!! Next directory name

real(real12), dimension(:), allocatable :: tmp_energies
real(real32), dimension(:), allocatable :: tmp_energies
!! Temporary array for element energies
character(len=3), dimension(:), allocatable :: tmp_symbols
!! Temporary array for element symbols
Expand Down Expand Up @@ -78,7 +78,7 @@ program raffle_program
generator%distributions = get_evolved_gvectors_from_data( &
input_dir = database_list, &
file_format = database_format, &
gvector_container_template = gvector_container_type(&
distribs_container_template = distribs_container_type(&
width = width_list, &
sigma = sigma_list, &
cutoff_min = cutoff_min_list, &
Expand Down
46 changes: 23 additions & 23 deletions app/mod_read_structures.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module read_structures
!! This module takes a list of directories and reads in the structures from
!! the contained files. The structures are then converted to a set of
!! generalised vectors (gvectors, aka distribution functions).
use constants, only: real12
use misc_raffle, only: grep
use misc_linalg, only: modu
use rw_geom, only: basis_type, geom_read, geom_write, igeom_input
use raffle__constants, only: real32
use raffle__misc, only: grep
use raffle__misc_linalg, only: modu
use raffle__geom_rw, only: basis_type, geom_read, geom_write, igeom_input
use rw_vasprun, only: get_energy_from_vasprun, get_structure_from_vasprun
use evolver, only: gvector_container_type
use raffle__distribs_container, only: distribs_container_type
#ifdef ENABLE_ATHENA
use machine_learning, only: network_setup, &
network_train, network_train_graph, &
Expand All @@ -28,19 +28,19 @@ module read_structures

!###############################################################################
function get_evolved_gvectors_from_data(input_dir, &
file_format, gvector_container_template) &
result(gvector_container)
file_format, distribs_container_template) &
result(distribs_container)
!! Read structures from the input directories and evolve them to gvectors.
implicit none

! Arguments
character(*), dimension(..), intent(in) :: input_dir
!! List of directories containing the structures to be read.
type(gvector_container_type), intent(in), optional :: &
gvector_container_template
!! Optional. A template gvector_container to be used.
type(gvector_container_type), allocatable :: gvector_container
!! The gvector_container containing the evolved gvectors.
type(distribs_container_type), intent(in), optional :: &
distribs_container_template
!! Optional. A template distribs_container to be used.
type(distribs_container_type), allocatable :: distribs_container
!! The distribs_container containing the evolved gvectors.
character(*), intent(in), optional :: file_format
!! Optional. The format of the input files. Default is vasprun.xml.

Expand All @@ -51,7 +51,7 @@ function get_evolved_gvectors_from_data(input_dir, &
!! The format of the input files.
integer :: num_structures
!! The number of structures read.
real(real12) :: energy
real(real32) :: energy
!! The energy of the structure.
character(50) :: buffer
!! A buffer for reading strings.
Expand All @@ -71,19 +71,19 @@ function get_evolved_gvectors_from_data(input_dir, &
#ifdef ENABLE_ATHENA
type(graph_type), dimension(:), allocatable :: graphs
!! Graph representations of the structures.
real(real12), dimension(:), allocatable :: &
real(real32), dimension(:), allocatable :: &
labels, labels_train, labels_validate
!! The labels for the structures.
real(real12), dimension(:,:), allocatable :: &
real(real32), dimension(:,:), allocatable :: &
dataset, data_train, data_validate
!! The dataset for the structures.
#endif


if(present(gvector_container_template)) then
gvector_container = gvector_container_template
if(present(distribs_container_template)) then
distribs_container = distribs_container_template
else
gvector_container = gvector_container_type()
distribs_container = distribs_container_type()
end if

if(present(file_format)) then
Expand All @@ -104,9 +104,9 @@ function get_evolved_gvectors_from_data(input_dir, &
ifile_format = 0
end if

! inquire(file='gvector_container.dat', exist=success)
! inquire(file='distribs_container.dat', exist=success)
! if(success) then
! call gvector_container%read('gvector_container.dat')
! call distribs_container%read('distribs_container.dat')
! goto 100
! end if
! ! For each new run of the code, it should populate a new directory and ...
Expand Down Expand Up @@ -179,15 +179,15 @@ function get_evolved_gvectors_from_data(input_dir, &
basis%energy, &
( trim(basis%spec(j)%name), basis%spec(j)%num, &
j=1, basis%nspec )
call gvector_container%add(basis)
call distribs_container%add(basis)
end do
cycle
end select

write(*,*) &
"Found structure: ", trim(adjustl(structure_list(i))), &
" with energy: ", basis%energy
call gvector_container%add(basis)
call distribs_container%add(basis)
num_structures = num_structures + 1

! ! STORE THE ENERGY IN AN ARRAY
Expand All @@ -198,7 +198,7 @@ function get_evolved_gvectors_from_data(input_dir, &



100 call gvector_container%evolve()
100 call distribs_container%evolve()


#ifdef ENABLE_ATHENA
Expand Down
Loading