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=20) :: 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
314
315 ! Number of sweeps (each sweep is n_atoms mc steps)
316 integer :: mc_sweeps
317 ! Number of bins across energy range
318 integer :: bins
319 ! Number of energy windows
320 integer :: num_windows
321 ! Number of bins in the overlap region
322 integer :: bin_overlap
323 ! Tolerance for wang landau
324 real :: tolerance
325 ! Flatness for wang landau histogram
326 real :: flatness
327 ! Wang Landau density of states histogram tuning parameter
328 real :: wl_f
329 ! Energy range minimum
330 real :: energy_min
331 ! Energy range maximum
332 real :: energy_max
333 ! Radial density samples per bin
334 integer :: radial_samples
335
336 end type wl_params
337
338 !--------------------------------------------------------------------!
339 ! Interfaces for various Hamiltonian and dynamics implementations !
340 ! chosen at runtime. !
341 ! !
342 ! C. D. Woodgate, Bristol 2025 !
343 !--------------------------------------------------------------------!
344 interface
345
359 function hamiltonian(setup, config)
360
361 use kinds, only : real64
362 use constants, only : array_int
363
364 import :: run_params
365
366 integer(array_int), dimension(:,:,:,:), intent(in) :: config
367 real(real64) :: hamiltonian
368 class(run_params), intent(in) :: setup
369
370 end function
371
387 function neighbour(setup, config, site_b, site_i, site_j, site_k)
388
389 use kinds, only : real64
390 use constants, only : array_int
391
392 import :: run_params
393
394 integer(array_int), dimension(:,:,:,:), intent(in) :: config
395 real(real64) :: neighbour
396 class(run_params), intent(in) :: setup
397 integer, intent(in) :: site_b, site_i, site_j, site_k
398
399 end function
400
410 function rand_site(setup)
411
412 use kinds, only : real64
413 use constants, only : array_int
414
415 import :: run_params
416
417 class(run_params), intent(in) :: setup
418 integer, dimension(4) :: rand_site
419
420 end function
421
433 function rand_neighbour(setup, site)
434
435 use kinds, only : real64
436 use constants, only : array_int
437
438 import :: run_params
439
440 class(run_params), intent(in) :: setup
441 integer, dimension(4), intent(in) :: site
442 integer, dimension(4) :: rand_neighbour
443
444 end function
445
460 function monte_carlo(setup, config, beta) result(accept)
461
462 use kinds, only : real64
463 use constants, only : array_int
464
465 import :: run_params
466
467 integer(array_int), dimension(:,:,:,:) :: config
468 class(run_params), intent(in) :: setup
469 integer :: accept
470 real(real64), intent(in) :: beta
471
472 end function monte_carlo
473
474 end interface
475
476end 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.