42#include "../base/base_uses.f90"
47 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cell_opt_types'
64 LOGICAL :: keep_angles = .false., &
65 keep_symmetry = .false., &
67 REAL(kind=
dp) :: pres_ext = 0.0_dp, pres_int = 0.0_dp, pres_tol = 0.0_dp, pres_constr = 0.0_dp
68 REAL(kind=
dp),
DIMENSION(3, 3) :: mtrx = 0.0_dp
71 REAL(kind=
dp),
DIMENSION(3, 3) :: input_to_opt = 0.0_dp, &
92 CHARACTER(LEN=default_string_length) :: constraint_string, label
93 INTEGER :: output_unit
94 LOGICAL :: constraint_explicit
98 NULLIFY (cell_env%opt_cell, cell)
101 CALL cell_clone(cell, cell_env%opt_cell, tag=
"CELL_OPT_CANONICAL")
105 cell_env%input_to_opt = matmul(cell_env%opt_cell%hmat, cell%h_inv)
106 cell_env%opt_to_input = matmul(cell%hmat, cell_env%opt_cell%h_inv)
112 c_val=constraint_string, explicit=constraint_explicit)
114 cell_env%constraint_id)
119 IF (constraint_explicit)
THEN
121 c_val=trim(adjustl( &
125 CALL cell_opt_validate_constraint(cell_env)
134 cell_env%opt_cell%orthorhombic, &
135 cell_env%keep_angles))
THEN
136 IF (iand(cell_env%constraint_id,
mask_shear) /= 0)
THEN
137 CALL cp_warn(__location__, &
138 "CELL_OPT: CONSTRAINT ("// &
140 ") pins a shear component of a non-orthorhombic cell. "// &
141 "The masked pressure criterion is met at the constrained minimum "// &
142 "only if the stresses conjugate to the pinned components vanish "// &
143 "there, for example when the pinned values are the stress-free "// &
144 "ones; otherwise it can stay off the external pressure. Check "// &
145 "the per-step ""Pressure is converged"" line: with L-BFGS the "// &
146 """run CONVERGED"" banner can appear while it is NO. The "// &
147 "projected-stress criterion planned in #6031 removes this limitation.")
149 CALL cp_warn(__location__, &
150 "CELL_OPT: CONSTRAINT ("// &
152 ") fixes a diagonal component while KEEP_ANGLES pins the "// &
153 "angles of a non-orthorhombic cell. The masked pressure criterion "// &
154 "is met at the constrained minimum only if the stresses conjugate "// &
155 "to the pinned components vanish there, for example when the "// &
156 "pinned values are the stress-free ones; otherwise it can stay "// &
157 "off the external pressure. Check the per-step ""Pressure is "// &
158 "converged"" line: with L-BFGS the ""run CONVERGED"" banner can "// &
159 "appear while it is NO. The projected-stress criterion planned "// &
160 "in #6031 removes this limitation.")
166 cell_env%mtrx, cell_env%input_to_opt)
172 IF (output_unit > 0)
THEN
173 WRITE (unit=output_unit, fmt=
"(/,T2,A,T61,F20.1)") &
174 "CELL_OPT| Pressure tolerance [bar]: ",
cp_unit_from_cp2k(cell_env%pres_tol,
"bar")
175 IF (cell_env%keep_volume)
THEN
176 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
177 "CELL_OPT| Keep volume of cell: ",
"YES"
179 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
180 "CELL_OPT| Keep volume of cell: ",
" NO"
182 IF (cell_env%keep_angles)
THEN
183 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
184 "CELL_OPT| Keep angles between the cell vectors: ",
"YES"
186 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
187 "CELL_OPT| Keep angles between the cell vectors: ",
" NO"
189 IF (cell_env%keep_symmetry)
THEN
190 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
191 "CELL_OPT| Keep cell symmetry: ",
"YES"
193 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
194 "CELL_OPT| Keep cell symmetry: ",
" NO"
197 IF (count(cell%perd /= 0) == 2 .AND. .NOT. constraint_explicit)
THEN
198 label = trim(label)//
" (auto)"
200 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A)") &
201 "CELL_OPT| Constraint: ", trim(label)
211 SUBROUTINE cell_opt_validate_constraint(cell_env)
214 LOGICAL :: bad_constraint
228 IF (cell_env%keep_angles)
THEN
232 cell_env%opt_cell%orthorhombic))
THEN
233 CALL cp_abort(__location__, &
234 "CELL_OPT: CONSTRAINT ("// &
236 ") fixes only part of the b or c cell vector and would "// &
237 "destroy the KEEP_ANGLES projection.")
241 IF (cell_env%keep_symmetry .AND. cell_env%constraint_id /=
fix_none)
THEN
245 cell_env%opt_cell%symmetry_id)
246 IF (bad_constraint)
THEN
247 CALL cp_abort(__location__, &
248 "CELL_OPT: CONSTRAINT ("// &
250 ") fixes only part of the components coupled by "// &
251 "KEEP_SYMMETRY ("// &
254 ") and would break the cell symmetry.")
258 END SUBROUTINE cell_opt_validate_constraint
Handles all functions related to the CELL.
subroutine, public canonicalize_cell_matrix(cell)
Canonicalize a general cell matrix without changing lengths and angles.
subroutine, public cell_create(cell, hmat, periodic, tag)
allocates and initializes a cell
Contains type used for a Simulation Cell Optimization.
subroutine, public cell_opt_env_release(cell_env)
...
subroutine, public cell_opt_env_create(cell_env, force_env, geo_section)
...
contains a functional that calculates the energy and its derivatives for the geometry optimizer
pure logical function, public keep_symmetry_conflict(mask, symmetry_id)
Whether a CONSTRAINT mask conflicts with the KEEP_SYMMETRY projection.
pure integer function, public keep_symmetry_coupled_set(symmetry_id)
The set of cell components coupled by a crystal system (for diagnostics).
subroutine, public read_external_press_tensor(geo_section, cell, pres_ext, mtrx, input_to_opt)
Reads the external pressure tensor.
pure logical function, public pres_crit_shear_pinned(mask, orthorhombic, keep_angles)
Whether the masked pressure criterion is structurally off target.
integer, parameter, public mask_shear
pure logical function, public keep_angles_conflict(mask, orthorhombic)
Whether a CONSTRAINT mask conflicts with the KEEP_ANGLES projection.
subroutine, public parse_cell_constraint(constraint_string, cell, explicit, mask)
Parses the tokens of the CONSTRAINT keyword into a cell component mask.
pure character(len=default_string_length) function, public cell_opt_constraint_label(mask)
Returns the label of the consolidated cell constraint mask.
Handles all functions related to the CELL.
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
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
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Type containing all informations abour the simulation cell optimization.
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...
wrapper to abstract the force evaluation of the various methods