53#include "../../base/base_uses.f90"
60 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'mc_control'
80 INTEGER,
INTENT(IN) :: nnstep
82 INTEGER,
DIMENSION(:),
INTENT(IN) :: nchains
85 CHARACTER(len=*),
PARAMETER :: routinen =
'write_mc_restart'
87 CHARACTER(LEN=20) :: ensemble
88 CHARACTER(LEN=default_path_length) :: restart_file_name
89 CHARACTER(LEN=default_string_length) :: name
90 INTEGER :: handle, ichain, imol_type, iparticle, &
91 iunit, natom, nmol_types, nmolecule, &
93 REAL(kind=
dp) :: temperature
94 REAL(kind=
dp),
DIMENSION(1:3) :: abc
95 TYPE(
atom_type),
DIMENSION(:),
POINTER :: atom_list
102 CALL timeset(routinen, handle)
105 CALL get_mc_par(mc_par, restart_file_name=restart_file_name, temperature=temperature, &
109 CALL open_file(file_name=restart_file_name, unit_number=unit, &
110 file_action=
'WRITE', file_status=
'REPLACE')
116 molecule_kinds=molecule_kinds, &
119 nunits_tot =
SIZE(particles%els(:))
120 IF (sum(nchains(:)) == 0) nunits_tot = 0
121 WRITE (unit, *) nnstep
122 WRITE (unit, *) temperature, nunits_tot
123 WRITE (unit, *) ensemble
124 WRITE (unit, *) nchains(:)
125 WRITE (unit,
'(3(F10.6,3X))') abc(1:3)*
angstrom
130 IF (nunits_tot .GT. 0)
THEN
131 nmol_types =
SIZE(molecule_kinds%els(:))
133 DO imol_type = 1, nmol_types
134 molecule_kind => molecule_kinds%els(imol_type)
136 nmolecule=nmolecule, natom=natom)
138 DO ichain = 1, nmolecule
141 WRITE (unit,
'(1X,A,1X,3(F15.10,3X))') &
142 trim(adjustl(name)), &
143 particles%els(iparticle)%r(1:3)*
angstrom
144 iparticle = iparticle + 1
153 CALL timestop(handle)
173 INTEGER,
INTENT(IN) :: iw
174 INTEGER,
INTENT(INOUT) :: mc_nunits_tot
177 CHARACTER(len=*),
PARAMETER :: routinen =
'read_mc_restart'
179 CHARACTER(5),
ALLOCATABLE,
DIMENSION(:) :: atom_symbols
180 CHARACTER(default_string_length), &
181 DIMENSION(:, :),
POINTER :: atom_names
182 CHARACTER(LEN=20) :: ensemble, mc_ensemble
183 CHARACTER(LEN=default_path_length) :: dat_file, restart_file_name
184 INTEGER :: handle, i, ipart, iunit, nmol_types, &
185 nstart, nunits_tot, print_level, &
187 INTEGER,
DIMENSION(:),
POINTER :: nchains, nunits
189 REAL(kind=
dp) :: mc_temp, rand, temperature
190 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: r
191 REAL(kind=
dp),
DIMENSION(1:3) :: abc, box_length
199 CALL timeset(routinen, handle)
202 CALL get_mc_par(mc_par, restart_file_name=restart_file_name, temperature=mc_temp, &
203 ensemble=mc_ensemble, mc_molecule_info=mc_molecule_info, &
204 ionode=ionode, dat_file=dat_file, &
205 group=group, source=source, mc_input_file=mc_input_file)
207 nmol_types=nmol_types, atom_names=atom_names)
209 ALLOCATE (nchains(1:nmol_types))
216 CALL open_file(file_name=restart_file_name, unit_number=unit, &
217 file_action=
'READ', file_status=
'OLD')
219 READ (unit, *) nstart
220 READ (unit, *) temperature, nunits_tot
221 READ (unit, *) ensemble
222 READ (unit, *) nchains(1:nmol_types)
224 CALL group%bcast(nstart, source)
225 CALL group%bcast(temperature, source)
226 CALL group%bcast(nunits_tot, source)
227 CALL group%bcast(ensemble, source)
228 CALL group%bcast(nchains, source)
231 IF (abs(temperature - mc_temp) .GT. 0.01e0_dp)
THEN
233 WRITE (iw, *)
'The temperature in the restart file is ', &
234 'not the same as the input file.'
235 WRITE (iw, *)
'Input file temperature =', mc_temp
236 WRITE (iw, *)
'Restart file temperature =', temperature
238 cpabort(
"Temperature difference between restart and input")
240 IF (nunits_tot .NE. mc_nunits_tot)
THEN
242 WRITE (iw, *)
'The total number of units in the restart ', &
243 'file is not the same as the input file.'
244 WRITE (iw, *)
'Input file units =', mc_nunits_tot
245 WRITE (iw, *)
'Restart file units =', nunits_tot
247 mc_nunits_tot = nunits_tot
249 IF (ensemble .NE. mc_ensemble)
THEN
251 WRITE (iw, *)
'The ensemble in the restart file is ', &
252 'not the same as the input file.'
253 WRITE (iw, *)
'Input file ensemble =', mc_ensemble
254 WRITE (iw, *)
'Restart file ensemble =', ensemble
256 cpabort(
"Ensembles different between restart and input")
266 READ (unit, *) box_length(1:3)
268 box_length(1:3) = box_length(1:3)/
angstrom
270 CALL group%bcast(box_length, source)
271 IF (abs(box_length(1) - abc(1)) .GT. 0.0001e0_dp .OR. &
272 abs(box_length(2) - abc(2)) .GT. 0.0001e0_dp .OR. &
273 abs(box_length(3) - abc(3)) .GT. 0.0001e0_dp)
THEN
275 WRITE (iw, *)
'The cell length in the restart file is ', &
276 'not the same as the input file.'
277 WRITE (iw, *)
'Input file cell length =', abc(1:3)*
angstrom
278 WRITE (iw, *)
'Restart file cell length =', box_length(1:3)*
angstrom
284 IF (sum(nchains(:)) == 0)
THEN
285 ALLOCATE (r(3, nunits(1)))
286 ALLOCATE (atom_symbols(nunits(1)))
288 DO iunit = 1, nunits(1)
289 r(1:3, iunit) = (/real(iunit,
dp), real(iunit,
dp), real(iunit,
dp)/)
290 atom_symbols(iunit) = atom_names(iunit, 1)
295 box_length(:), dat_file, nchains(:), mc_input_file)
299 ALLOCATE (r(3, nunits_tot))
300 ALLOCATE (atom_symbols(nunits_tot))
303 DO ipart = 1, nunits_tot
304 READ (unit, *) atom_symbols(ipart), r(1:3, ipart)
305 r(1:3, ipart) = r(1:3, ipart)/
angstrom
311 box_length(:), dat_file, nchains(:), mc_input_file)
321 rand = rng_stream%next()
326 CALL timestop(handle)
331 DEALLOCATE (atom_symbols)
352 CHARACTER(LEN=*),
INTENT(IN) :: input_file_name
355 INTEGER :: f_env_id, ierr, output_unit
360 input_declaration=input_declaration, &
361 input_path=input_file_name, &
362 output_unit=output_unit, &
366 force_env => f_env%force_env
370 IF (ierr /= 0) cpabort(
"mc_create_force_env: destroy_force_env failed")
372 IF (
PRESENT(globenv_new)) &
394 para_env, box_length, nchains, input_declaration, mc_input_file, ionode)
397 REAL(
dp),
DIMENSION(:, :),
INTENT(INOUT) :: r
398 CHARACTER(default_string_length),
DIMENSION(:), &
399 INTENT(IN) :: atom_symbols
400 INTEGER,
INTENT(IN) :: nunits_tot
402 REAL(kind=
dp),
DIMENSION(1:3),
INTENT(IN) :: box_length
403 INTEGER,
DIMENSION(:),
POINTER :: nchains
406 LOGICAL,
INTENT(IN) :: ionode
410 box_length(:),
'bias_temp.dat', nchains(:), mc_input_file)
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Handles all functions related to the CELL.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
types that represent a subsys, i.e. a part of the system
subroutine, public cp_subsys_get(subsys, ref_count, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell)
returns information about various attributes of the given subsys
interface to use cp2k as library
recursive subroutine, public destroy_force_env(env_id, ierr, q_finalize)
deallocates the force_env with the given id
subroutine, public f_env_add_defaults(f_env_id, f_env, handle)
adds the default environments of the f_env to the stack of the defaults, and returns a new error and ...
subroutine, public get_cell(env_id, cell, per, ierr)
gets a cell
recursive subroutine, public create_force_env(new_env_id, input_declaration, input_path, output_path, mpi_comm, output_unit, owns_out_unit, input, ierr, work_dir, initial_variables)
creates a new force environment using the given input, and writing the output to the given output uni...
subroutine, public f_env_rm_defaults(f_env, ierr, handle)
removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly...
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
subroutine, public force_env_retain(force_env)
retains the given force env
Define type storing the global information of a run. Keep the amount of stored data small....
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
contains some general routines for dealing with the restart files and creating force_env for MC use
subroutine, public write_mc_restart(nnstep, mc_par, nchains, force_env)
writes the coordinates of the current step to a file that can be read in at the start of the next sim...
subroutine, public read_mc_restart(mc_par, force_env, iw, mc_nunits_tot, rng_stream)
reads the input coordinates of the simulation from a file written above
subroutine, public mc_create_force_env(force_env, input_declaration, para_env, input_file_name, globenv_new)
creates a force environment for any of the different kinds of MC simulations we can do (FIST,...
subroutine, public mc_create_bias_force_env(bias_env, r, atom_symbols, nunits_tot, para_env, box_length, nchains, input_declaration, mc_input_file, ionode)
essentially copies the cell size and coordinates of one force env to another that we will use to bias...
contains miscellaneous subroutines used in the Monte Carlo runs, mostly I/O stuff
subroutine, public mc_make_dat_file_new(coordinates, atom_names, nunits_tot, box_length, filename, nchains, mc_input_file)
writes a new input file that CP2K can read in for when we want to change a force env (change molecule...
holds all the structure types needed for Monte Carlo, except the mc_environment_type
subroutine, public get_mc_par(mc_par, nstep, nvirial, iuptrans, iupcltrans, iupvolume, nmoves, nswapmoves, rm, cl, diff, nstart, source, group, lbias, ionode, lrestart, lstop, rmvolume, rmcltrans, rmbond, rmangle, rmrot, rmtrans, temperature, pressure, rclus, beta, pmswap, pmvolume, pmtraion, pmtrans, pmcltrans, ensemble, program, restart_file_name, molecules_file, moves_file, coords_file, energy_file, displacement_file, cell_file, dat_file, data_file, box2_file, fft_lib, iprint, rcut, ldiscrete, discrete_step, pmavbmc, pbias, avbmc_atom, avbmc_rmin, avbmc_rmax, rmdihedral, input_file, mc_molecule_info, pmswap_mol, pmavbmc_mol, pmtrans_mol, pmrot_mol, pmtraion_mol, mc_input_file, mc_bias_file, pmvol_box, pmclus_box, virial_temps, exp_min_val, exp_max_val, min_val, max_val, eta, pmhmc, pmhmc_box, lhmc, rand2skip)
...
subroutine, public get_mc_molecule_info(mc_molecule_info, nmol_types, nchain_total, nboxes, names, conf_prob, nchains, nunits, mol_type, nunits_tot, in_box, atom_names, mass)
...
subroutine, public set_mc_par(mc_par, rm, cl, diff, nstart, rmvolume, rmcltrans, rmbond, rmangle, rmdihedral, rmrot, rmtrans, program, nmoves, nswapmoves, lstop, temperature, pressure, rclus, iuptrans, iupcltrans, iupvolume, pmswap, pmvolume, pmtraion, pmtrans, pmcltrans, beta, rcut, iprint, lbias, nstep, lrestart, ldiscrete, discrete_step, pmavbmc, mc_molecule_info, pmavbmc_mol, pmtrans_mol, pmrot_mol, pmtraion_mol, pmswap_mol, avbmc_rmin, avbmc_rmax, avbmc_atom, pbias, ensemble, pmvol_box, pmclus_box, eta, mc_input_file, mc_bias_file, exp_max_val, exp_min_val, min_val, max_val, pmhmc, pmhmc_box, lhmc, ionode, source, group, rand2skip)
changes the private elements of the mc_parameters_type
Interface to the message passing library MPI.
represent a simple array based list of the given type
Define the molecule kind structure types and the corresponding functionality.
subroutine, public get_molecule_kind(molecule_kind, atom_list, bond_list, bend_list, ub_list, impr_list, opbend_list, colv_list, fixd_list, g3x3_list, g4x6_list, vsite_list, torsion_list, shell_list, name, mass, charge, kind_number, natom, nbend, nbond, nub, nimpr, nopbend, nconstraint, nconstraint_fixd, nfixd, ncolv, ng3x3, ng4x6, nvsite, nfixd_restraint, ng3x3_restraint, ng4x6_restraint, nvsite_restraint, nrestraints, nmolecule, nsgf, nshell, ntorsion, molecule_list, nelectron, nelectron_alpha, nelectron_beta, bond_kind_set, bend_kind_set, ub_kind_set, impr_kind_set, opbend_kind_set, torsion_kind_set, molname_generated)
Get informations about a molecule kind.
Parallel (pseudo)random number generator (RNG) for multiple streams and substreams of random numbers.
represent a simple array based list of the given type
Definition of physical constants:
real(kind=dp), parameter, public angstrom
Type defining parameters related to the simulation cell.
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
contains the initially parsed file and the initial parallel environment
stores all the informations relevant to an mpi environment
represent a list of objects
represent a list of objects