24                      final_evaluation, para_env)
 
   80#include "../base/base_uses.f90" 
   83   REAL(KIND=
dp), 
DIMENSION(:), 
POINTER     :: x
 
   84   REAL(KIND=
dp), 
INTENT(OUT), 
OPTIONAL     :: f
 
   85   REAL(KIND=
dp), 
DIMENSION(:), 
OPTIONAL, &
 
   87   INTEGER, 
INTENT(IN)                      :: master
 
   88   LOGICAL, 
INTENT(IN), 
OPTIONAL            :: final_evaluation
 
   91   CHARACTER(len=*), 
PARAMETER :: routineN = 
'cp_eval_at' 
   93   INTEGER                                  :: ensemble, handle, idg, idir, ip, &
 
   94                                               nparticle, nsize, shell_index
 
   95   LOGICAL                                  :: explicit, my_final_evaluation
 
   96   REAL(KIND=
dp)                            :: f_ts, potential_energy
 
   97   REAL(KIND=
dp), 
DIMENSION(3, 3)           :: av_ptens
 
   98   REAL(KIND=
dp), 
DIMENSION(:), 
POINTER     :: cell_gradient, gradient_ts
 
  105   CHARACTER(LEN=default_string_length)     :: project_name
 
  112   NULLIFY (core_particles)
 
  113   NULLIFY (gradient_ts)
 
  115   NULLIFY (shell_particles)
 
  121   CALL timeset(routinen, handle)
 
  123   CALL force_env_get(gopt_env%force_env, subsys=subsys, cell=cell)
 
  125                      core_particles=core_particles, &
 
  126                      particles=particles, &
 
  127                      shell_particles=shell_particles, &
 
  130   spgr => gopt_env%spgr
 
  132   my_final_evaluation = .false.
 
  133   IF (
PRESENT(final_evaluation)) my_final_evaluation = final_evaluation
 
  135   SELECT CASE (gopt_env%type_id)
 
  139      SELECT CASE (gopt_env%type_id)
 
  143                                          calc_force=
PRESENT(gradient), &
 
  144                                          require_consistent_energy_force=gopt_env%require_consistent_energy_force)
 
  150         IF (
PRESENT(gradient)) 
THEN 
  151            IF (master == para_env%mepos) 
THEN  
  153               IF (spgr%keep_space_group) 
THEN 
  161         ALLOCATE (gradient_ts(particles%n_els*3))
 
  165         CALL cp_eval_at_ts(gopt_env, x, f_ts, gradient_ts, calc_force=.true.)
 
  168         IF (
PRESENT(f)) f = f_ts
 
  170         IF (
PRESENT(gradient)) 
THEN 
  171            IF (master == para_env%mepos) 
THEN  
  172               cpassert(
ASSOCIATED(gradient))
 
  173               gradient = gradient_ts
 
  176         DEALLOCATE (gradient_ts)
 
  183      IF (.NOT. virial%pv_availability) &
 
  184         CALL cp_abort(__location__, &
 
  185                       "Cell optimization requested but FORCE_EVAL%STRESS_TENSOR was not defined! "// &
 
  186                       "Activate the evaluation of the stress tensor for cell optimization!")
 
  187      SELECT CASE (gopt_env%cell_method_id)
 
  196                                             calc_force=
PRESENT(gradient), &
 
  197                                             require_consistent_energy_force=gopt_env%require_consistent_energy_force)
 
  199            CALL force_env_get(gopt_env%force_env, potential_energy=potential_energy)
 
  206            IF (
PRESENT(gradient)) 
THEN 
  207               cpassert(any(virial_avg%pv_total /= 0))
 
  209               av_ptens(:, :) = virial_avg%pv_total(:, :)/cell%deth
 
  210               IF (master == para_env%mepos) 
THEN  
  211                  cpassert(
ASSOCIATED(gradient))
 
  214                  cpassert((
SIZE(gradient) == nsize + 6))
 
  217                  IF (spgr%keep_space_group) 
THEN 
  222                  cell_gradient => gradient(nsize + 1:nsize + 6)
 
  223                  cell_gradient = 0.0_dp
 
  224                  CALL get_dg_dh(cell_gradient, av_ptens, gopt_env%cell_env%pres_ext, cell, gopt_env%cell_env%mtrx, &
 
  225                                 keep_angles=gopt_env%cell_env%keep_angles, &
 
  226                                 keep_symmetry=gopt_env%cell_env%keep_symmetry, &
 
  227                                 pres_int=gopt_env%cell_env%pres_int, &
 
  228                                 pres_constr=gopt_env%cell_env%pres_constr, &
 
  229                                 constraint_id=gopt_env%cell_env%constraint_id)
 
  233               CALL para_env%bcast(gopt_env%cell_env%pres_int, 0)
 
  234               IF (gopt_env%cell_env%constraint_id /= 
fix_none) &
 
  235                  CALL para_env%bcast(gopt_env%cell_env%pres_constr, 0)
 
  238      CASE (default_cell_geo_opt_id, default_cell_md_id)
 
  239         CALL apply_cell_change(gopt_env, cell, x, update_forces=.false.)
 
  241         CALL write_cell(cell, gopt_env%geo_section)
 
  244            TYPE(virial_type) :: virial_avg
 
  245            IF (my_final_evaluation) 
THEN 
  246               CALL force_env_calc_energy_force(gopt_env%force_env, &
 
  247                                                calc_force=
PRESENT(gradient), &
 
  248                                                require_consistent_energy_force=gopt_env%require_consistent_energy_force)
 
  250                  CALL force_env_get(gopt_env%force_env, potential_energy=f)
 
  253               SELECT CASE (gopt_env%cell_method_id)
 
  254               CASE (default_cell_geo_opt_id)
 
  255                  work => section_vals_get_subs_vals(gopt_env%motion_section, 
"GEO_OPT")
 
  256                  CALL section_vals_get(work, explicit=explicit)
 
  257                  IF (.NOT. explicit) &
 
  258                     CALL cp_abort(__location__, &
 
  259                                   "Cell optimization at 0K was requested. GEO_OPT section MUST be provided in the input file!")
 
  261                  CALL gopt_new_logger_create(new_logger, gopt_env%force_env%root_section, para_env, &
 
  262                                              project_name, id_run=geo_opt_run)
 
  263                  CALL cp_add_default_logger(new_logger)
 
  264                  CALL cp_geo_opt(gopt_env%force_env, gopt_env%globenv, eval_opt_geo=.false.)
 
  265                  CALL force_env_get(gopt_env%force_env, potential_energy=potential_energy)
 
  267               CASE (default_cell_md_id)
 
  268                  work => section_vals_get_subs_vals(gopt_env%motion_section, 
"MD")
 
  269                  avgs_section => section_vals_get_subs_vals(work, 
"AVERAGES")
 
  270                  CALL section_vals_get(work, explicit=explicit)
 
  271                  IF (.NOT. explicit) &
 
  274                     "Cell optimization at finite temperature was requested. MD section MUST be provided in the input file!")
 
  276                  CALL section_vals_val_get(gopt_env%motion_section, 
"MD%ENSEMBLE", i_val=ensemble)
 
  277                  IF (ensemble /= nvt_ensemble) &
 
  278                     CALL cp_abort(__location__, &
 
  279                                   "Cell optimization at finite temperature requires the NVT MD ensemble!")
 
  281                  CALL gopt_new_logger_create(new_logger, gopt_env%force_env%root_section, para_env, &
 
  282                                              project_name, id_run=mol_dyn_run)
 
  283                  CALL cp_add_default_logger(new_logger)
 
  284                  CALL create_averages(averages, avgs_section, virial_avg=.true., force_env=gopt_env%force_env)
 
  285                  CALL qs_mol_dyn(gopt_env%force_env, gopt_env%globenv, averages, rm_restart_info=.false.)
 
  287                  potential_energy = averages%avepot
 
  288                  virial_avg = averages%virial
 
  289                  CALL release_averages(averages)
 
  293               CALL cp_rm_default_logger()
 
  294               CALL gopt_new_logger_release(new_logger, gopt_env%force_env%root_section, para_env, project_name, &
 
  297               CALL virial_update(virial_avg, subsys, para_env)
 
  304            IF (
PRESENT(gradient)) 
THEN 
  305               cpassert(any(virial_avg%pv_total /= 0))
 
  307               av_ptens(:, :) = virial_avg%pv_total(:, :)/cell%deth
 
  308               IF (master == para_env%mepos) 
THEN  
  309                  cpassert(
ASSOCIATED(gradient))
 
  310                  IF (spgr%keep_space_group) 
THEN 
  311                     CALL spgr_apply_rotations_stress(spgr, cell, av_ptens)
 
  312                     CALL spgr_write_stress_tensor(av_ptens, spgr)
 
  315                  CALL get_dg_dh(gradient, av_ptens, gopt_env%cell_env%pres_ext, cell, gopt_env%cell_env%mtrx, &
 
  316                                 keep_angles=gopt_env%cell_env%keep_angles, &
 
  317                                 keep_symmetry=gopt_env%cell_env%keep_symmetry, &
 
  318                                 pres_int=gopt_env%cell_env%pres_int, &
 
  319                                 pres_constr=gopt_env%cell_env%pres_constr, &
 
  320                                 constraint_id=gopt_env%cell_env%constraint_id)
 
  324               CALL para_env%bcast(gopt_env%cell_env%pres_int, 0)
 
  325               IF (gopt_env%cell_env%constraint_id /= fix_none) &
 
  326                  CALL para_env%bcast(gopt_env%cell_env%pres_constr, 0)
 
  332   CASE (default_shellcore_method_id)
 
  334      DO ip = 1, particles%n_els
 
  335         shell_index = particles%els(ip)%shell_index
 
  336         IF (shell_index /= 0) 
THEN 
  338               idg = 3*(shell_index - 1) + idir
 
  339               shell_particles%els(shell_index)%r(idir) = core_particles%els(ip)%r(idir) - x(idg)
 
  343      CALL write_structure_data(particles%els, cell, gopt_env%motion_section)
 
  346      CALL force_env_calc_energy_force(gopt_env%force_env, &
 
  347                                       calc_force=
PRESENT(gradient), &
 
  348                                       require_consistent_energy_force=gopt_env%require_consistent_energy_force)
 
  352         CALL force_env_get(gopt_env%force_env, potential_energy=f)
 
  356      IF (
PRESENT(gradient)) 
THEN 
  357         IF (master == para_env%mepos) 
THEN  
  358            cpassert(
ASSOCIATED(gradient))
 
  360            DO ip = 1, shell_particles%n_els
 
  363                  gradient(idg) = -(core_particles%els(ip)%f(idir) - shell_particles%els(ip)%f(idir))
 
  372   CALL timestop(handle)
 
 
subroutine cp_eval_at(gopt_env, x, f, gradient, master, final_evaluation, para_env)
evaluete the potential energy and its gradients using an array with same dimension as the particle_se...
 
Handles the type to compute averages during an MD.
 
subroutine, public create_averages(averages, averages_section, virial_avg, force_env)
Creates averages environment.
 
subroutine, public release_averages(averages)
releases the given averages env
 
collects all references to literature in CP2K as new algorithms / method are included from literature...
 
integer, save, public henkelman1999
 
Handles all functions related to the CELL.
 
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
 
contains a functional that calculates the energy and its derivatives for the geometry optimizer
 
subroutine, public get_dg_dh(gradient, av_ptens, pres_ext, cell, mtrx, keep_angles, keep_symmetry, pres_int, pres_constr, constraint_id)
Computes the derivatives for the cell.
 
subroutine, public gopt_new_logger_release(new_logger, root_section, para_env, project_name, id_run)
releases a new logger used for cell optimization algorithm
 
subroutine, public gopt_new_logger_create(new_logger, root_section, para_env, project_name, id_run)
creates a new logger used for cell optimization algorithm
 
Handles all functions related to the CELL.
 
various routines to log and control the output. The idea is that decisions about where to log should ...
 
subroutine, public cp_rm_default_logger()
the cousin of cp_add_default_logger, decrements the stack, so that the default logger is what it has ...
 
subroutine, public cp_add_default_logger(logger)
adds a default logger. MUST be called before logging occours
 
types that represent a subsys, i.e. a part of the system
 
subroutine, public unpack_subsys_particles(subsys, f, r, s, v, fscale, cell)
Unpack components of a subsystem particle sets into a single vector.
 
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
 
subroutine, public pack_subsys_particles(subsys, f, r, s, v, fscale, cell)
Pack components of a subsystem particle sets into a single vector.
 
Contains types used for a Dimer Method calculations.
 
recursive subroutine, public cp_eval_at_ts(gopt_env, x, f, gradient, calc_force)
Computes the dimer energy/gradients (including the rotation of the dimer)
 
Interface for the force calculations.
 
recursive subroutine, public force_env_calc_energy_force(force_env, calc_force, consistent_energies, skip_external_control, eval_energy_forces, require_consistent_energy_force, linres, calc_stress_tensor)
Interface routine for force and energy calculations.
 
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
 
integer function, public force_env_get_nparticle(force_env)
returns the number of particles in a force environment
 
performs geometry optimization
 
subroutine, public cp_geo_opt(force_env, globenv, eval_opt_geo, rm_restart_info)
Main driver to perform geometry optimization.
 
contains a functional that calculates the energy and its derivatives for the geometry optimizer
 
subroutine, public apply_cell_change(gopt_env, cell, x, update_forces)
Apply coordinate transformations after cell (shape) change.
 
contains a functional that calculates the energy and its derivatives for the geometry optimizer
 
Defines the basic variable types.
 
integer, parameter, public dp
 
integer, parameter, public default_string_length
 
Perform a molecular dynamics (MD) run using QUICKSTEP.
 
subroutine, public qs_mol_dyn(force_env, globenv, averages, rm_restart_info, hmc_e_initial, hmc_e_final, mdctrl)
Main driver module for Molecular Dynamics.
 
Interface to the message passing library MPI.
 
represent a simple array based list of the given type
 
Define methods related to particle_type.
 
subroutine, public write_structure_data(particle_set, cell, input_section)
Write structure data requested by a separate structure data input section to the output unit....
 
Space Group Symmetry Type Module (version 1.0, Ferbruary 12, 2021)
 
Space Group Symmetry Module (version 1.0, January 16, 2020)
 
subroutine, public spgr_apply_rotations_stress(spgr, cell, stress)
routine applies the rotation matrices to the stress tensor.
 
subroutine, public spgr_apply_rotations_coord(spgr, coord)
routine applies the rotation matrices to the coordinates.
 
subroutine, public spgr_apply_rotations_force(spgr, force)
routine applies the rotation matrices to the forces.
 
subroutine, public spgr_write_stress_tensor(stress, spgr)
Variable precision output of the symmetrized stress tensor.
 
subroutine, public virial_update(virial, subsys, para_env)
Updates the virial given the virial and subsys.
 
Type defining parameters related to the simulation cell.
 
type of a logger, at the moment it contains just a print level starting at which level it should be l...
 
represents a system: atoms, molecules, their pos,vel,...
 
calculates the potential energy of a system, and its derivatives
 
stores all the informations relevant to an mpi environment
 
represent a list of objects