58#include "./base/base_uses.f90"
64 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cell_methods'
94 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
96 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
97 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: tag
99 cpassert(.NOT.
ASSOCIATED(cell))
102 IF (
PRESENT(periodic))
THEN
107 cell%orthorhombic = .false.
108 cell%input_cell_canonicalized = .false.
109 cell%input_hmat(:, :) = 0.0_dp
110 cell%input_to_canonical(:, :) = 0.0_dp
111 cell%input_recip_to_canonical(:, :) = 0.0_dp
113 IF (
PRESENT(hmat))
CALL init_cell(cell, hmat)
114 IF (
PRESENT(tag)) cell%tag = tag
127 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: hmat_input, hmat_canonical
129 REAL(kind=
dp),
PARAMETER :: eps_hmat = 1.0e-12_dp
131 REAL(kind=
dp),
DIMENSION(3, 3) :: tmat
133 cpassert(
ASSOCIATED(cell))
135 IF (maxval(abs(hmat_canonical - hmat_input)) <= eps_hmat)
THEN
136 cell%input_cell_canonicalized = .false.
137 cell%input_hmat(:, :) = 0.0_dp
138 cell%input_to_canonical(:, :) = 0.0_dp
139 cell%input_recip_to_canonical(:, :) = 0.0_dp
141 tmat = matmul(hmat_canonical,
inv_3x3(hmat_input))
142 cell%input_cell_canonicalized = .true.
143 cell%input_hmat(:, :) = hmat_input(:, :)
144 cell%input_to_canonical(:, :) = tmat(:, :)
145 cell%input_recip_to_canonical(:, :) = transpose(
inv_3x3(tmat))
154 SUBROUTINE canonicalize_cell_matrix(cell)
158 REAL(kind=
dp),
DIMENSION(3) :: abc, cell_angle
160 cpassert(
ASSOCIATED(cell))
163 cell_angle(1) =
angle(cell%hmat(:, 2), cell%hmat(:, 3))
164 cell_angle(2) =
angle(cell%hmat(:, 1), cell%hmat(:, 3))
165 cell_angle(3) =
angle(cell%hmat(:, 1), cell%hmat(:, 2))
167 CALL set_cell_param(cell, cell_length=abc, cell_angle=cell_angle, &
168 periodic=cell%perd, do_init_cell=.true.)
170 END SUBROUTINE canonicalize_cell_matrix
184 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
186 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
188 REAL(kind=
dp),
PARAMETER :: eps_hmat = 1.0e-14_dp
191 REAL(kind=
dp) :: a, acosa, acosah, acosg, alpha, asina, &
192 asinah, asing, beta,
gamma, norm, &
194 REAL(kind=
dp),
DIMENSION(3) :: abc
196 cpassert(
ASSOCIATED(cell))
198 IF (
PRESENT(hmat)) cell%hmat(:, :) = hmat(:, :)
199 IF (
PRESENT(periodic)) cell%perd(:) = periodic(:)
201 cell%deth = abs(
det_3x3(cell%hmat))
203 IF (cell%deth < 1.0e-10_dp)
THEN
205 CALL cp_abort(__location__, &
206 "An invalid set of cell vectors was specified. "// &
207 "The cell volume is too small")
210 SELECT CASE (cell%symmetry_id)
219 SELECT CASE (cell%symmetry_id)
221 abc(1:3) = sum(abc(1:3))/3.0_dp
225 SELECT CASE (cell%symmetry_id)
227 a = 0.5_dp*(abc(1) + abc(2))
231 a = 0.5_dp*(abc(1) + abc(3))
235 a = 0.5_dp*(abc(2) + abc(3))
240 cell%hmat(1, 1) = abc(1); cell%hmat(1, 2) = 0.0_dp; cell%hmat(1, 3) = 0.0_dp
241 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = abc(2); cell%hmat(2, 3) = 0.0_dp
242 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
245 a = 0.5_dp*(abc(1) + abc(2))
249 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosg; cell%hmat(1, 3) = 0.0_dp
250 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asing; cell%hmat(2, 3) = 0.0_dp
251 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
254 a = sum(abc(1:3))/3.0_dp
255 alpha = (
angle(cell%hmat(:, 3), cell%hmat(:, 2)) + &
256 angle(cell%hmat(:, 1), cell%hmat(:, 3)) + &
257 angle(cell%hmat(:, 1), cell%hmat(:, 2)))/3.0_dp
260 acosah = a*cos(0.5_dp*alpha)
261 asinah = a*sin(0.5_dp*alpha)
263 norm_c = sqrt(1.0_dp - norm*norm)
264 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosa; cell%hmat(1, 3) = acosah*norm
265 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asina; cell%hmat(2, 3) = asinah*norm
266 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = a*norm_c
269 beta =
angle(cell%hmat(:, 1), cell%hmat(:, 3))
270 cell%hmat(1, 1) = abc(1); cell%hmat(1, 2) = 0.0_dp; cell%hmat(1, 3) = abc(3)*cos(beta)
271 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = abc(2); cell%hmat(2, 3) = 0.0_dp
272 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)*sin(beta)
276 a = 0.5_dp*(abc(1) + abc(2))
277 gamma =
angle(cell%hmat(:, 1), cell%hmat(:, 2))
280 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosg; cell%hmat(1, 3) = 0.0_dp
281 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asing; cell%hmat(2, 3) = 0.0_dp
282 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
288 IF ((abs(cell%hmat(1, 2)) < eps_hmat) .AND. (abs(cell%hmat(1, 3)) < eps_hmat) .AND. &
289 (abs(cell%hmat(2, 1)) < eps_hmat) .AND. (abs(cell%hmat(2, 3)) < eps_hmat) .AND. &
290 (abs(cell%hmat(3, 1)) < eps_hmat) .AND. (abs(cell%hmat(3, 2)) < eps_hmat))
THEN
291 cell%orthorhombic = .true.
293 cell%orthorhombic = .false.
298 IF (cell%orthorhombic)
THEN
299 cell%hmat(1, 2) = 0.0_dp
300 cell%hmat(1, 3) = 0.0_dp
301 cell%hmat(2, 1) = 0.0_dp
302 cell%hmat(2, 3) = 0.0_dp
303 cell%hmat(3, 1) = 0.0_dp
304 cell%hmat(3, 2) = 0.0_dp
307 dim = count(cell%perd == 1)
308 IF ((dim == 1) .AND. (.NOT. cell%orthorhombic))
THEN
309 cpabort(
"Non-orthorhombic and not periodic")
313 cell%deth = abs(
det_3x3(cell%hmat))
314 IF (cell%deth < 1.0e-10_dp)
THEN
315 CALL cp_abort(__location__, &
316 "An invalid set of cell vectors was obtained after applying "// &
317 "the requested cell symmetry. The cell volume is too small")
319 cell%h_inv =
inv_3x3(cell%hmat)
337 RECURSIVE SUBROUTINE read_cell(cell, cell_ref, use_ref_cell, cell_section, &
338 topology_section, check_for_ref, para_env)
340 TYPE(
cell_type),
POINTER :: cell, cell_ref
341 LOGICAL,
INTENT(INOUT),
OPTIONAL :: use_ref_cell
343 LOGICAL,
INTENT(IN),
OPTIONAL :: check_for_ref
346 REAL(kind=
dp),
PARAMETER :: eps = 1.0e-14_dp
348 CHARACTER(LEN=default_path_length) :: cell_file_name, coord_file_name, &
350 INTEGER :: canonicalize_mode, cell_file_format, &
351 coord_file_format, my_per
352 INTEGER,
DIMENSION(:),
POINTER :: multiple_unit_cell
353 LOGICAL :: canonicalize_cell, cell_read_a, cell_read_abc, cell_read_alpha_beta_gamma, &
354 cell_read_b, cell_read_c, cell_read_file, my_check_ref, tmp_comb_abc, tmp_comb_cell, &
355 tmp_comb_top, topo_read_coord
356 REAL(kind=
dp),
DIMENSION(3) :: read_ang, read_len
357 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat_input, read_mat
358 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cell_par
362 my_check_ref = .true.
363 NULLIFY (cell_ref_section, cell_par, cell_tmp, multiple_unit_cell)
371 IF (.NOT.
ASSOCIATED(cell))
CALL cell_create(cell, tag=
"CELL")
372 IF (.NOT.
ASSOCIATED(cell_ref))
CALL cell_create(cell_ref, tag=
"CELL_REF")
373 IF (
PRESENT(check_for_ref)) my_check_ref = check_for_ref
376 cell%orthorhombic = .false.
379 cell%hmat(:, :) = 0.0_dp
380 cell%h_inv(:, :) = 0.0_dp
381 cell%input_cell_canonicalized = .false.
382 cell%input_hmat(:, :) = 0.0_dp
383 cell%input_to_canonical(:, :) = 0.0_dp
384 cell%input_recip_to_canonical(:, :) = 0.0_dp
385 cell_read_file = .false.
386 cell_read_a = .false.
387 cell_read_b = .false.
388 cell_read_c = .false.
389 cell_read_abc = .false.
390 cell_read_alpha_beta_gamma = .false.
391 hmat_input(:, :) = 0.0_dp
392 read_mat(:, :) = 0.0_dp
409 CALL section_vals_val_get(cell_section,
"ALPHA_BETA_GAMMA", explicit=cell_read_alpha_beta_gamma)
415 tmp_comb_top = (.NOT. (cell_read_file .OR. cell_read_abc))
416 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_a))
417 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_b))
418 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_c))
419 IF (tmp_comb_top)
THEN
420 CALL cp_warn(__location__, &
421 "None of the keywords CELL_FILE_NAME, ABC, or A, B, C "// &
422 "are specified in CELL section. CP2K will now attempt to read "// &
423 "TOPOLOGY/COORD_FILE_NAME if its format can be parsed for "// &
425 IF (
ASSOCIATED(topology_section))
THEN
427 IF (topo_read_coord)
THEN
430 SELECT CASE (coord_file_format)
444 CALL cp_abort(__location__, &
445 "COORD_FILE_FORMAT is not set to one of the implemented "// &
446 "CELL_FILE_FORMAT options and cannot be parsed for cell information!")
449 CALL cp_abort(__location__, &
450 "COORD_FILE_NAME is not set, so no cell information is available!")
453 CALL cp_warn(__location__, &
454 "TOPOLOGY section is not available, so COORD_FILE_NAME cannot "// &
455 "be parsed for cell information in lieu of missing CELL settings.")
460 IF (cell_read_file)
THEN
461 tmp_comb_cell = (cell_read_abc .OR. (cell_read_a .OR. (cell_read_b .OR. cell_read_c)))
463 CALL cp_warn(__location__, &
464 "Cell Information provided through A, B, C, or ABC in conjunction "// &
465 "with CELL_FILE_NAME. The definition in external file will override "// &
469 SELECT CASE (cell_file_format)
481 CALL cp_abort(__location__, &
482 "CELL_FILE_FORMAT is not set to one of the implemented "// &
483 "options and cannot be parsed for cell information!")
485 read_mat = cell_tmp%hmat
487 IF (cell_read_abc)
THEN
492 IF (cell_read_a .OR. cell_read_b .OR. cell_read_c) &
493 CALL cp_warn(__location__, &
494 "Cell information provided through vectors A, B or C in conjunction with ABC. "// &
495 "The definition of the ABC keyword will override the one provided by A, B and C.")
497 tmp_comb_abc = ((cell_read_a .EQV. cell_read_b) .AND. (cell_read_b .EQV. cell_read_c))
498 IF (tmp_comb_abc)
THEN
500 read_mat(:, 1) = cell_par(:)
502 read_mat(:, 2) = cell_par(:)
504 read_mat(:, 3) = cell_par(:)
505 IF (cell_read_alpha_beta_gamma) &
506 CALL cp_warn(__location__, &
507 "The keyword ALPHA_BETA_GAMMA is ignored because it was used without the "// &
510 CALL cp_abort(__location__, &
511 "Neither of the keywords CELL_FILE_NAME or ABC are specified, "// &
512 "and cell vector settings in A, B, C are incomplete!")
518 IF (any(read_mat(:, :) > eps))
THEN
521 IF (.NOT. canonicalize_cell .AND. &
522 ((abs(read_mat(2, 1)) > eps) .OR. &
523 (abs(read_mat(3, 1)) > eps) .OR. &
524 (abs(read_mat(3, 2)) > eps)))
THEN
526 CALL cp_warn(__location__, &
527 "CELL%CANONICALIZE AUTO keeps the general input cell orientation. "// &
528 "The cell matrix is not a lower triangle and does not conform to the "// &
529 "program convention that A lies along the X-axis and B is in the XY plane. "// &
530 "Set CELL%CANONICALIZE TRUE to explicitly transform the cell and supported "// &
531 "cell-dependent input to the canonical internal frame.")
533 CALL cp_warn(__location__, &
534 "Cell vectors are read but cell matrix is not "// &
535 "a lower triangle, not conforming to the program "// &
536 "convention that A lies along the X-axis and "// &
537 "B is in the XY plane.")
542 IF (any(read_ang(:) > eps) .AND. any(read_len(:) > eps))
THEN
543 CALL set_cell_param(cell, cell_length=read_len, cell_angle=read_ang, &
544 do_init_cell=.false.)
546 CALL cp_abort(__location__, &
547 "No meaningful cell information is read from parser!")
551 CALL reset_cell_section_by_cell_mat(cell, cell_section)
555 IF (any(multiple_unit_cell /= 1))
CALL set_multiple_unit_cell(cell, multiple_unit_cell)
560 cell%perd = [1, 0, 0]
562 cell%perd = [0, 1, 0]
564 cell%perd = [0, 0, 1]
566 cell%perd = [1, 1, 0]
568 cell%perd = [1, 0, 1]
570 cell%perd = [0, 1, 1]
572 cell%perd = [1, 1, 1]
574 cell%perd = [0, 0, 0]
576 cpabort(
"Invalid or not yet implemented cell periodicity")
583 hmat_input(:, :) = cell%hmat(:, :)
586 IF (.NOT. canonicalize_cell .AND. any(abs(cell_tmp%hmat - cell%hmat) > eps))
THEN
587 WRITE (unit=error_msg, fmt=
"(A)") &
588 "When initializing cell vectors with requested symmetry, one "// &
589 "or more elements of the cell matrix has varied significantly. "// &
590 "The input parameters are either deviating from the symmetry, "// &
591 "or not conforming to the program convention that cell matrix "// &
592 "is a lower triangle. The symmetrized cell vectors will be used "// &
593 "anyway with the input atomic coordinates."
594 CALL cp_warn(__location__, error_msg)
596 IF (canonicalize_cell)
THEN
597 CALL canonicalize_cell_matrix(cell_tmp)
602 CALL reset_cell_section_by_cell_mat(cell, cell_section)
604 IF (my_check_ref)
THEN
607 IF (parsed_cp2k_input(cell_ref_section, check_this_section=.true.))
THEN
608 IF (
PRESENT(use_ref_cell)) use_ref_cell = .true.
609 CALL read_cell(cell_ref, cell_ref, use_ref_cell=use_ref_cell, &
610 cell_section=cell_ref_section, check_for_ref=.false., &
613 CALL cell_clone(cell, cell_ref, tag=
"CELL_REF")
614 IF (
PRESENT(use_ref_cell)) use_ref_cell = .false.
628 FUNCTION parsed_cp2k_input(input_file, check_this_section)
RESULT(res)
631 LOGICAL,
INTENT(IN),
OPTIONAL :: check_this_section
638 IF (
PRESENT(check_this_section)) my_check = check_this_section
639 res =
ASSOCIATED(input_file)
641 cpassert(input_file%ref_count > 0)
642 IF (.NOT. my_check)
THEN
650 END FUNCTION parsed_cp2k_input
668 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: cell_length, cell_angle
669 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
670 LOGICAL,
INTENT(IN) :: do_init_cell
672 REAL(kind=
dp),
PARAMETER :: eps = epsilon(0.0_dp)
674 REAL(kind=
dp) :: cos_alpha, cos_beta, cos_gamma, sin_gamma
676 cpassert(
ASSOCIATED(cell))
677 cpassert(all(cell_angle /= 0.0_dp))
679 cos_gamma = cos(cell_angle(3));
IF (abs(cos_gamma) < eps) cos_gamma = 0.0_dp
680 IF (abs(abs(cos_gamma) - 1.0_dp) < eps) cos_gamma = sign(1.0_dp, cos_gamma)
681 sin_gamma = sin(cell_angle(3));
IF (abs(sin_gamma) < eps) sin_gamma = 0.0_dp
682 IF (abs(abs(sin_gamma) - 1.0_dp) < eps) sin_gamma = sign(1.0_dp, sin_gamma)
683 cos_beta = cos(cell_angle(2));
IF (abs(cos_beta) < eps) cos_beta = 0.0_dp
684 IF (abs(abs(cos_beta) - 1.0_dp) < eps) cos_beta = sign(1.0_dp, cos_beta)
685 cos_alpha = cos(cell_angle(1));
IF (abs(cos_alpha) < eps) cos_alpha = 0.0_dp
686 IF (abs(abs(cos_alpha) - 1.0_dp) < eps) cos_alpha = sign(1.0_dp, cos_alpha)
688 cell%hmat(:, 1) = [1.0_dp, 0.0_dp, 0.0_dp]
689 cell%hmat(:, 2) = [cos_gamma, sin_gamma, 0.0_dp]
690 cell%hmat(:, 3) = [cos_beta, (cos_alpha - cos_gamma*cos_beta)/sin_gamma, 0.0_dp]
691 cell%hmat(3, 3) = sqrt(1.0_dp - cell%hmat(1, 3)**2 - cell%hmat(2, 3)**2)
693 cell%hmat(:, 1) = cell%hmat(:, 1)*cell_length(1)
694 cell%hmat(:, 2) = cell%hmat(:, 2)*cell_length(2)
695 cell%hmat(:, 3) = cell%hmat(:, 3)*cell_length(3)
697 IF (do_init_cell)
THEN
698 IF (
PRESENT(periodic))
THEN
699 CALL init_cell(cell=cell, periodic=periodic)
715 SUBROUTINE set_multiple_unit_cell(cell, multiple_unit_cell)
718 INTEGER,
DIMENSION(:),
POINTER :: multiple_unit_cell
720 cpassert(
ASSOCIATED(cell))
723 IF (any(multiple_unit_cell <= 0)) &
724 CALL cp_abort(__location__, &
725 "CELL%MULTIPLE_UNIT_CELL accepts only integer values larger than 0! "// &
726 "A value of 0 or negative is meaningless!")
729 cell%hmat(:, 1) = cell%hmat(:, 1)*multiple_unit_cell(1)
730 cell%hmat(:, 2) = cell%hmat(:, 2)*multiple_unit_cell(2)
731 cell%hmat(:, 3) = cell%hmat(:, 3)*multiple_unit_cell(3)
733 END SUBROUTINE set_multiple_unit_cell
754 CHARACTER(len=*) :: cif_file_name
758 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_cif'
761 INTEGER,
DIMENSION(3) :: periodic
763 REAL(kind=
dp),
DIMENSION(3) :: cell_angles, cell_lengths
766 CALL timeset(routinen, handle)
769 para_env=para_env, apply_preprocessing=.false.)
775 begin_line=.false., search_from_begin_of_file=.true.)
776 IF (.NOT. found)
THEN
778 begin_line=.false., search_from_begin_of_file=.true.)
780 cpabort(
"The field _cell_length_a or _cell.length_a was not found in CIF file! ")
782 CALL cif_get_real(parser, cell_lengths(1))
787 begin_line=.false., search_from_begin_of_file=.true.)
788 IF (.NOT. found)
THEN
790 begin_line=.false., search_from_begin_of_file=.true.)
792 cpabort(
"The field _cell_length_b or _cell.length_b was not found in CIF file! ")
794 CALL cif_get_real(parser, cell_lengths(2))
799 begin_line=.false., search_from_begin_of_file=.true.)
800 IF (.NOT. found)
THEN
802 begin_line=.false., search_from_begin_of_file=.true.)
804 cpabort(
"The field _cell_length_c or _cell.length_c was not found in CIF file! ")
806 CALL cif_get_real(parser, cell_lengths(3))
811 begin_line=.false., search_from_begin_of_file=.true.)
812 IF (.NOT. found)
THEN
814 begin_line=.false., search_from_begin_of_file=.true.)
816 cpabort(
"The field _cell_angle_alpha or _cell.angle_alpha was not found in CIF file! ")
818 CALL cif_get_real(parser, cell_angles(1))
823 begin_line=.false., search_from_begin_of_file=.true.)
824 IF (.NOT. found)
THEN
826 begin_line=.false., search_from_begin_of_file=.true.)
828 cpabort(
"The field _cell_angle_beta or _cell.angle_beta was not found in CIF file! ")
830 CALL cif_get_real(parser, cell_angles(2))
835 begin_line=.false., search_from_begin_of_file=.true.)
836 IF (.NOT. found)
THEN
838 begin_line=.false., search_from_begin_of_file=.true.)
840 cpabort(
"The field _cell_angle_gamma or _cell.angle_gamma was not found in CIF file! ")
842 CALL cif_get_real(parser, cell_angles(3))
846 CALL set_cell_param(cell, cell_lengths, cell_angles, periodic=periodic, &
851 CALL timestop(handle)
863 SUBROUTINE cif_get_real(parser, r)
866 REAL(kind=
dp),
INTENT(OUT) :: r
868 CHARACTER(LEN=default_string_length) :: s_tag
872 iln = len_trim(s_tag)
873 IF (index(s_tag,
"(") /= 0) iln = index(s_tag,
"(") - 1
874 READ (s_tag(1:iln), *) r
876 END SUBROUTINE cif_get_real
892 CHARACTER(len=*) :: extxyz_file_name
896 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_extxyz'
898 CHARACTER(len=default_path_length) :: raw_cell_str
899 INTEGER :: handle, i, id1, id2, ios, j
900 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
903 CALL timeset(routinen, handle)
906 para_env=para_env, apply_preprocessing=.false.)
909 id1 = index(parser%input_line,
"LATTICE=")
911 id2 = index(parser%input_line(id1 + 9:),
'"')
912 READ (parser%input_line(id1 + 9:id1 + id2 + 7),
'(A)') raw_cell_str
913 READ (raw_cell_str, *, iostat=ios) hmat(:, 1), hmat(:, 2), hmat(:, 3)
915 CALL cp_abort(__location__,
"Error while parsing extended XYZ file "// &
916 "<"//trim(extxyz_file_name)//
"> for cell vectors: "// &
917 "found <lattice=> field as <"//trim(raw_cell_str)//
">")
926 CALL cp_abort(__location__, &
927 "The field <lattice=> was not found on comment line "// &
928 "of XYZ file, so cell information cannot be set via "// &
929 "extended XYZ specification! ")
934 CALL timestop(handle)
958 CHARACTER(len=*) :: pdb_file_name
962 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_pdb'
964 CHARACTER(LEN=default_string_length) :: cryst
965 INTEGER :: handle, i, ios
966 INTEGER,
DIMENSION(3) :: periodic
968 REAL(kind=
dp),
DIMENSION(3) :: cell_angles, cell_lengths
971 CALL timeset(routinen, handle)
974 para_env=para_env, apply_preprocessing=.false.)
977 begin_line=.true., search_from_begin_of_file=.true.)
979 cpabort(
"The line <CRYST1> was not found in PDB file! ")
982 READ (parser%input_line, *, iostat=ios) cryst, cell_lengths(:), cell_angles(:)
984 CALL cp_abort(__location__,
"Error while parsing PDB file "// &
985 "<"//trim(pdb_file_name)//
"> for cell lengths and angles: "// &
986 "found CRYST1 line as <"//trim(parser%input_line)//
">")
992 CALL set_cell_param(cell, cell_lengths, cell_angles, periodic=periodic, &
997 CALL timestop(handle)
1011 CHARACTER(len=*) :: cp2k_file_name
1015 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_cp2k'
1017 INTEGER :: handle, i, idum, j
1019 REAL(kind=
dp) :: xdum
1020 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1023 CALL timeset(routinen, handle)
1026 para_env=para_env, apply_preprocessing=.false.)
1030 DO WHILE (.NOT. my_end)
1031 READ (parser%input_line, *) idum, xdum, hmat(:, 1), hmat(:, 2), hmat(:, 3)
1042 CALL timestop(handle)
1056 CHARACTER(len=*) :: xsc_file_name
1060 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_xsc'
1062 INTEGER :: handle, i, idum, j
1063 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1066 CALL timeset(routinen, handle)
1069 para_env=para_env, apply_preprocessing=.false.)
1072 READ (parser%input_line, *) idum, hmat(:, 1), hmat(:, 2), hmat(:, 3)
1081 CALL timestop(handle)
1093 SUBROUTINE reset_cell_section_by_cell_mat(cell, cell_section)
1098 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cell_par
1107 ALLOCATE (cell_par(3))
1108 cell_par = cell%hmat(:, 1)
1110 ALLOCATE (cell_par(3))
1111 cell_par = cell%hmat(:, 2)
1113 ALLOCATE (cell_par(3))
1114 cell_par = cell%hmat(:, 3)
1117 END SUBROUTINE reset_cell_section_by_cell_mat
1134 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: tag
1136 CHARACTER(LEN=default_string_length) :: label, unit_str
1137 INTEGER :: output_unit
1142 IF (
PRESENT(tag))
THEN
1143 label = trim(tag)//
"|"
1145 label = trim(cell%tag)//
"|"
1169 CHARACTER(LEN=*),
INTENT(IN) :: unit_str
1170 INTEGER,
INTENT(IN) :: output_unit
1171 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: label
1173 CHARACTER(LEN=12) :: tag
1174 CHARACTER(LEN=3) :: string
1175 CHARACTER(LEN=default_string_length) :: my_label
1176 REAL(kind=
dp) :: alpha, beta,
gamma, val
1177 REAL(kind=
dp),
DIMENSION(3) :: abc
1186 IF (output_unit > 0)
THEN
1188 IF (
PRESENT(label))
THEN
1191 my_label = trim(tag)//
"|"
1194 WRITE (unit=output_unit, fmt=
"(/,T2,A,T61,F20.6)") &
1195 trim(my_label)//
" Volume ["//trim(unit_str)//
"^3]:", val
1197 WRITE (unit=output_unit, fmt=
"(T2,A,T30,3F10.3,3X,A6,F12.6)") &
1198 trim(my_label)//
" Vector a ["//trim(unit_str)//
"]:", cell%hmat(:, 1)*val, &
1199 "|a| = ", abc(1)*val, &
1200 trim(my_label)//
" Vector b ["//trim(unit_str)//
"]:", cell%hmat(:, 2)*val, &
1201 "|b| = ", abc(2)*val, &
1202 trim(my_label)//
" Vector c ["//trim(unit_str)//
"]:", cell%hmat(:, 3)*val, &
1203 "|c| = ", abc(3)*val
1204 WRITE (unit=output_unit, fmt=
"(T2,A,T69,F12.6)") &
1205 trim(my_label)//
" Angle (b,c), alpha [degree]: ", alpha, &
1206 trim(my_label)//
" Angle (a,c), beta [degree]: ", beta, &
1207 trim(my_label)//
" Angle (a,b), gamma [degree]: ",
gamma
1212 WRITE (unit=output_unit, fmt=
"(T2,A,T61,A20)") &
1213 trim(my_label)//
" Requested initial symmetry: ", &
1214 adjustr(trim(
enum_i2c(enum, cell%symmetry_id)))
1217 IF (cell%orthorhombic)
THEN
1218 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1219 trim(my_label)//
" Numerically orthorhombic: ",
"YES"
1221 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1222 trim(my_label)//
" Numerically orthorhombic: ",
" NO"
1224 IF (sum(cell%perd(1:3)) == 0)
THEN
1225 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
1226 trim(my_label)//
" Periodicity",
"NONE"
1229 IF (cell%perd(1) == 1) string = trim(string)//
"X"
1230 IF (cell%perd(2) == 1) string = trim(string)//
"Y"
1231 IF (cell%perd(3) == 1) string = trim(string)//
"Z"
1232 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1233 trim(my_label)//
" Periodicity", adjustr(string)
Handles all functions related to the CELL.
subroutine, public write_cell_low(cell, unit_str, output_unit, label)
Write the cell parameters to the output unit.
subroutine, public write_cell(cell, subsys_section, tag)
Write the cell parameters to the output unit.
subroutine, public read_cell_cp2k(cp2k_file_name, cell, para_env)
Reads cell information from cp2k file.
subroutine, public read_cell_cif(cif_file_name, cell, para_env)
Reads cell information from CIF file.
subroutine, public set_cell_param(cell, cell_length, cell_angle, periodic, do_init_cell)
Sets the cell using the internal parameters (a,b,c) (alpha,beta,gamma) using the convention: a parall...
subroutine, public read_cell_pdb(pdb_file_name, cell, para_env)
Reads cell information from CRYST1 record of PDB file.
subroutine, public cell_finalize_canonical_input(cell, hmat_input, hmat_canonical)
Store the transform between the user input cell and the canonical cell.
subroutine, public read_cell_extxyz(extxyz_file_name, cell, para_env)
Reads cell information from comment line of extended xyz file.
recursive subroutine, public read_cell(cell, cell_ref, use_ref_cell, cell_section, topology_section, check_for_ref, para_env)
...
subroutine, public read_cell_xsc(xsc_file_name, cell, para_env)
Reads cell information from xsc file.
subroutine, public init_cell(cell, hmat, periodic)
Initialise/readjust a simulation cell after hmat has been changed.
subroutine, public cell_create(cell, hmat, periodic, tag)
allocates and initializes a cell
Handles all functions related to the CELL.
integer, parameter, public use_perd_xyz
integer, parameter, public cell_sym_monoclinic
integer, parameter, public use_perd_y
integer, parameter, public cell_sym_triclinic
integer, parameter, public cell_sym_tetragonal_ab
integer, parameter, public use_perd_xz
integer, parameter, public cell_sym_rhombohedral
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
integer, parameter, public use_perd_x
subroutine, public cell_clone(cell_in, cell_out, tag)
Clone cell variable.
integer, parameter, public cell_sym_tetragonal_ac
integer, parameter, public use_perd_z
integer, parameter, public use_perd_yz
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
integer, parameter, public use_perd_none
integer, parameter, public cell_sym_hexagonal_gamma_60
integer, parameter, public cell_sym_orthorhombic
integer, parameter, public cell_sym_none
integer, parameter, public cell_sym_hexagonal_gamma_120
integer, parameter, public cell_sym_monoclinic_gamma_ab
integer, parameter, public cell_sym_cubic
integer, parameter, public use_perd_xy
integer, parameter, public cell_sym_tetragonal_bc
real(kind=dp) function, public plane_distance(h, k, l, cell)
Calculate the distance between two lattice planes as defined by a triple of Miller indices (hkl).
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,...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_get_next_line(parser, nline, at_end)
Read the next input line and broadcast the input information. Skip (nline-1) lines and skip also all ...
subroutine, public parser_search_string(parser, string, ignore_case, found, line, begin_line, search_from_begin_of_file)
Search a string pattern in a file defined by its logical unit number "unit". A case sensitive search ...
Utility routines to read data from files. Kept as close as possible to the old parser because.
subroutine, public parser_release(parser)
releases the parser
subroutine, public parser_create(parser, file_name, unit_nr, para_env, end_section_label, separator_chars, comment_char, continuation_char, quote_char, section_char, parse_white_lines, initial_variables, apply_preprocessing)
Start a parser run. Initial variables allow to @SET stuff before opening the file.
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
real(kind=dp) function, public cp_unit_to_cp2k(value, unit_str, defaults, power)
converts to the internal cp2k units to the given unit
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Machine interface based on Fortran 2003 and POSIX.
integer, parameter, public default_output_unit
Definition of mathematical constants and functions.
real(kind=dp), parameter, public degree
real(kind=dp), parameter, public sqrt3
Collection of simple mathematical functions and subroutines.
pure real(kind=dp) function, public angle(a, b)
Calculation of the angle between the vectors a and b. The angle is returned in radians.
pure real(kind=dp) function, dimension(3, 3), public inv_3x3(a)
Returns the inverse of the 3 x 3 matrix a.
Interface to the message passing library MPI.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
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...
stores all the informations relevant to an mpi environment