BraWl
Loading...
Searching...
No Matches
derived_types.f90
Go to the documentation of this file.
1
13
14 use kinds
15 use constants
16
17 implicit none
18
19 private
20
22
57
58 ! Paramater defining the mode of operation
59 integer :: mode
60 ! Number of unit cells in each direction and
61 ! number of atoms in the basis
62 integer :: n_1, n_2, n_3, n_basis
63 ! Number of chemical species
64 integer :: n_species
65 ! Number of atoms
66 integer :: n_atoms
67 ! Logical flag for fixed or time-based random seed
68 logical :: static_seed=.false.
69 ! Lattice type - name, e.g. fcc, bcc, hcp, ...
70 character(len=20) :: lattice
71 ! Lattice parameter (for writing xyz file)
72 real(real64) :: lattice_parameter
73 ! Lattice vectors (for writing xyz file)
74 real(real64), dimension(3,3) :: lattice_vectors
75 ! Vector to second basis atom (for writing xyz file)
76 real(real64), dimension(3) :: basis_vectors
77 ! Names of the chemical species
78 character(len=2), dimension(:), allocatable :: species_names
79 ! Concentrations of the chemical species
80 real(real64), dimension(:), allocatable :: species_concentrations
81 ! Number of atoms of each chemical species
82 integer(int64), dimension(:), allocatable :: species_numbers
83 ! Atom-atom interchange interaction file name
84 character(len=50) :: interaction_file
85 ! Interaction range (number of coordination shells)
86 integer :: interaction_range
87 ! Number of coordination shells for Warren-Cowley parameters
88 integer :: wc_range
89 ! Hamiltonian to use
90 procedure(hamiltonian), pointer, pass :: full_energy => null()
91 ! neighbour energy function to use
92 procedure(neighbour), pointer, pass :: nbr_energy => null()
93 ! Random site function to use
94 procedure(rand_site), pointer, pass :: rdm_site => null()
95 ! Random neighbour function to use
96 procedure(rand_neighbour), pointer, pass :: rdm_nbr => null()
97 ! Monte Carlo step to call. (Neighbour swap or whole lattice swap)
98 procedure(monte_carlo), pointer, pass :: mc_step => null()
99
100 end type run_params
101
142
143 ! Paramater defining the mode of Metropolis operation
144 ! Current options are:
145 ! - 'equilibrate'
146 ! - This option runs the Metropolis algorithm at a given
147 ! temperature and tracks the simulation energy and atomic
148 ! order parameters as a function of number of trial moves.
149 ! Optionally, you can dump a 'trajectory' showing how the
150 ! alloy configuration evolves.
151 ! - 'simulated_annealing'
152 ! - This option uses simulated annealing to examine atomic
153 ! short- and long-range order parameters, simulation energy,
154 ! and specific heat capacity as a function of temperature for a
155 ! given system. Optionally, you can dump the simulation
156 ! configuration at the end of each temperature.
157 ! - 'decorrelated_samples'
158 ! - This option draws grid configurations a set number of steps
159 ! apart (for producing indicative equilibrated atomic configs
160 ! at a given temperature.
161 character(len=30) :: mode
162 ! Number of monte carlo steps (at each temperature if annealing)
163 integer :: n_mc_steps
164 ! Burn in at FIRST temperature if doing simulated annealing?
165 logical :: burn_in_start
166 ! Burn in at ALL temperatures if doing simulated annealing?
167 logical :: burn_in
168 ! Number of burn-in steps (at each temperature if annealing)
169 integer :: n_burn_in_steps
170 ! Number of Monte Carlo trial moves between drawing samples
171 ! of ANY quantity
172 integer :: n_sample_steps
173 ! Do we want to total simulation energy and store it?
174 logical :: calculate_energies
175 ! Do we want to write the trajectory's energy to file
176 logical :: write_trajectory_energy
177 ! Do we want to calculate atomic short-range order parameters?
178 logical :: calculate_asro
179 ! Do we want to write the trajectory's energy to file
180 logical :: write_trajectory_asro
181 ! Number of monte carlo steps between drawing ASRO parameters
182 ! (MUST be an integer multiple of n_sample_steps)
183 integer :: n_sample_steps_asro
184 ! Do we want to store atomic long-range order parameters
185 logical :: calculate_alro
186 ! Number of monte carlo steps between drawing ALRO parameters
187 ! (MUST be an integer multiple of n_sample_steps)
188 integer :: n_sample_steps_alro
189 ! Do we want to write the trajectory as an xyz file
190 ! (for visualisation)
191 logical :: write_trajectory_xyz
192 ! Number of monte carlo steps between drawing ALRO parameters
193 ! (MUST be an integer multiple of n_sample_steps)
194 integer :: n_sample_steps_trajectory
195 ! Do we want to write the initial config (at each temp if annealing)
196 ! as an xyz file?
197 logical :: write_initial_config_xyz
198 ! Do we want to write the initial config (at each temp if annealing)
199 ! as a NetCDF file? (For restart later.)
200 logical :: write_initial_config_nc
201 ! Do we want to write the final config (at each temp if annealing)
202 ! as an xyz file?
203 logical :: write_final_config_xyz
204 ! Do we want to write the final config (at each temp if annealing)
205 ! as a NetCDF file? (For restart later.)
206 logical :: write_final_config_nc
207 ! Do we want to read a starting config from file?
208 ! (Useful if restarting an earlier run...)
209 logical :: read_start_config_nc
210 ! Name of file from which to read if so
211 character(len=144) :: start_config_file
212 ! Inverse temperature
213 real(real64) :: beta
214 ! Temperature of simulation (or start temperature if annealing)
215 ! Should come in units of Kelvin
216 real(real64) :: t
217 ! Number of temperature steps (if annealing)
218 integer :: t_steps
219 ! Temperature step size if annealing
220 real(real64) :: delta_t
221 ! Atom swap flag
222 ! If True then only swap neighbouring pairs of atoms
223 ! If False then permit swaps across the lattice
224 logical :: nbr_swap
225
226 end type metropolis_params
227
243
244 ! Number of nested sampling walkers
245 integer :: n_walkers
246 ! Number of steps required for walk generating a new configuration
247 integer :: n_steps
248 ! Number of NS iterations before sampling is finished
249 integer :: n_iter
250 ! Frequency of writing configuration (every traj_freq-th NS iteration)
251 integer :: traj_freq
252 ! Output filenames
253 character(len=100) :: outfile_ener, outfile_traj
254
255 end type ns_params
256
274
275 ! Number of sweeps (each sweep is n_atoms mc steps)
276 integer :: mc_sweeps
277 ! Number of bins across energy range
278 integer :: bins
279 ! Number of energy windows
280 integer :: num_windows
281 ! Number of bins in the overlap region
282 real :: bin_overlap
283 ! Number of bias weight updates
284 integer :: weight_update
285 ! Energy range minimum
286 real :: energy_min
287 ! Energy range maximum
288 real :: energy_max
289 ! Temperature of dynamics
290 real :: t
291
292 end type tmmc_params
293
323
324 ! Number of sweeps (each sweep is n_atoms mc steps)
325 integer :: mc_sweeps
326 ! Number of bins across energy range
327 integer :: bins
328 ! Number of energy windows
329 integer :: num_windows
330 ! Percentage overlap between windows
331 real :: bin_overlap
332 ! Tolerance for wang landau
333 real :: tolerance
334 ! Flatness for wang landau histogram
335 real :: flatness
336 ! Wang Landau density of states histogram tuning parameter
337 real :: wl_f
338 ! Energy range minimum
339 real :: energy_min
340 ! Energy range maximum
341 real :: energy_max
342 ! Radial density samples per bin
343 integer :: radial_samples
344 ! Performance analysis
345 integer :: performance
346 ! Dynamics type
347 logical :: nbr_swap
348 ! Monte Carlo step to call. (Neighbour swap or whole lattice swap)
349 procedure(), pointer, nopass :: mc_select => null()
350 end type wl_params
351
352 !--------------------------------------------------------------------!
353 ! Interfaces for various Hamiltonian and dynamics implementations !
354 ! chosen at runtime. !
355 ! !
356 ! C. D. Woodgate, Bristol 2025 !
357 !--------------------------------------------------------------------!
358 interface
359
373 function hamiltonian(setup, config)
374
375 use kinds, only : real64
376 use constants, only : array_int
377
378 import :: run_params
379
380 integer(array_int), dimension(:,:,:,:), intent(in) :: config
381 real(real64) :: hamiltonian
382 class(run_params), intent(in) :: setup
383
384 end function
385
401 function neighbour(setup, config, site_b, site_i, site_j, site_k)
402
403 use kinds, only : real64
404 use constants, only : array_int
405
406 import :: run_params
407
408 integer(array_int), dimension(:,:,:,:), intent(in) :: config
409 real(real64) :: neighbour
410 class(run_params), intent(in) :: setup
411 integer, intent(in) :: site_b, site_i, site_j, site_k
412
413 end function
414
424 function rand_site(setup)
425
426 use kinds, only : real64
427 use constants, only : array_int
428
429 import :: run_params
430
431 class(run_params), intent(in) :: setup
432 integer, dimension(4) :: rand_site
433
434 end function
435
447 function rand_neighbour(setup, site)
448
449 use kinds, only : real64
450 use constants, only : array_int
451
452 import :: run_params
453
454 class(run_params), intent(in) :: setup
455 integer, dimension(4), intent(in) :: site
456 integer, dimension(4) :: rand_neighbour
457
458 end function
459
474 function monte_carlo(setup, config, beta) result(accept)
475
476 use kinds, only : real64
477 use constants, only : array_int
478
479 import :: run_params
480
481 integer(array_int), dimension(:,:,:,:) :: config
482 class(run_params), intent(in) :: setup
483 integer :: accept
484 real(real64), intent(in) :: beta
485
486 end function monte_carlo
487
488 end interface
489
490end module derived_types
Function for evaluating the energy of the simulation.
Function performing a trial Monte Carlo move on a config.
Function for getting a random neighbour of a lattice site.
Function for getting a random neighbour of a lattice site.
Function for getting a random lattice site.
integer, parameter, public array_int
Definition constants.f90:28
integer, parameter real64
Longer "double" (64 bit, approx -1.8e308 to 1.8e308 and covering values down to about 2e-308 magnitud...
Definition kinds.f90:59
Derived type for parameters defining a Metropolis-Hastings run.
Derived type for nested sampling parameters.
Derived type for parameters specifying general simulation parameters which are common to all sampling...
Derived type for TMMC parameters.
Derived type for Wang-Landau sampling parameters.