59#include "./base/base_uses.f90"
65 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cell_methods'
97 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
99 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
100 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: tag
102 cpassert(.NOT.
ASSOCIATED(cell))
105 IF (
PRESENT(periodic))
THEN
110 cell%orthorhombic = .false.
111 cell%input_cell_canonicalized = .false.
112 cell%input_hmat(:, :) = 0.0_dp
113 cell%input_to_canonical(:, :) = 0.0_dp
114 cell%input_recip_to_canonical(:, :) = 0.0_dp
116 IF (
PRESENT(hmat))
CALL init_cell(cell, hmat)
117 IF (
PRESENT(tag)) cell%tag = tag
130 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: hmat_input, hmat_canonical
132 REAL(kind=
dp),
PARAMETER :: eps_hmat = 1.0e-12_dp
134 REAL(kind=
dp),
DIMENSION(3, 3) :: tmat
136 cpassert(
ASSOCIATED(cell))
138 IF (maxval(abs(hmat_canonical - hmat_input)) <= eps_hmat)
THEN
139 cell%input_cell_canonicalized = .false.
140 cell%input_hmat(:, :) = 0.0_dp
141 cell%input_to_canonical(:, :) = 0.0_dp
142 cell%input_recip_to_canonical(:, :) = 0.0_dp
144 tmat = matmul(hmat_canonical,
inv_3x3(hmat_input))
145 cell%input_cell_canonicalized = .true.
146 cell%input_hmat(:, :) = hmat_input(:, :)
147 cell%input_to_canonical(:, :) = tmat(:, :)
148 cell%input_recip_to_canonical(:, :) = transpose(
inv_3x3(tmat))
161 REAL(kind=
dp),
DIMENSION(3) :: abc, cell_angle
163 cpassert(
ASSOCIATED(cell))
166 cell_angle(1) =
angle(cell%hmat(:, 2), cell%hmat(:, 3))
167 cell_angle(2) =
angle(cell%hmat(:, 1), cell%hmat(:, 3))
168 cell_angle(3) =
angle(cell%hmat(:, 1), cell%hmat(:, 2))
170 CALL set_cell_param(cell, cell_length=abc, cell_angle=cell_angle, &
171 periodic=cell%perd, do_init_cell=.true.)
187 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
189 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
191 REAL(kind=
dp),
PARAMETER :: eps_hmat = 1.0e-14_dp
194 REAL(kind=
dp) :: a, acosa, acosah, acosg, alpha, asina, &
195 asinah, asing, beta,
gamma, norm, &
197 REAL(kind=
dp),
DIMENSION(3) :: abc
199 cpassert(
ASSOCIATED(cell))
201 IF (
PRESENT(hmat)) cell%hmat(:, :) = hmat(:, :)
202 IF (
PRESENT(periodic)) cell%perd(:) = periodic(:)
204 cell%deth = abs(
det_3x3(cell%hmat))
206 IF (cell%deth < 1.0e-10_dp)
THEN
208 CALL cp_abort(__location__, &
209 "An invalid set of cell vectors was specified. "// &
210 "The cell volume is too small")
213 SELECT CASE (cell%symmetry_id)
222 SELECT CASE (cell%symmetry_id)
224 abc(1:3) = sum(abc(1:3))/3.0_dp
228 SELECT CASE (cell%symmetry_id)
230 a = 0.5_dp*(abc(1) + abc(2))
234 a = 0.5_dp*(abc(1) + abc(3))
238 a = 0.5_dp*(abc(2) + abc(3))
243 cell%hmat(1, 1) = abc(1); cell%hmat(1, 2) = 0.0_dp; cell%hmat(1, 3) = 0.0_dp
244 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = abc(2); cell%hmat(2, 3) = 0.0_dp
245 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
248 a = 0.5_dp*(abc(1) + abc(2))
252 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosg; cell%hmat(1, 3) = 0.0_dp
253 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asing; cell%hmat(2, 3) = 0.0_dp
254 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
257 a = sum(abc(1:3))/3.0_dp
258 alpha = (
angle(cell%hmat(:, 3), cell%hmat(:, 2)) + &
259 angle(cell%hmat(:, 1), cell%hmat(:, 3)) + &
260 angle(cell%hmat(:, 1), cell%hmat(:, 2)))/3.0_dp
263 acosah = a*cos(0.5_dp*alpha)
264 asinah = a*sin(0.5_dp*alpha)
266 norm_c = sqrt(1.0_dp - norm*norm)
267 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosa; cell%hmat(1, 3) = acosah*norm
268 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asina; cell%hmat(2, 3) = asinah*norm
269 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = a*norm_c
272 beta =
angle(cell%hmat(:, 1), cell%hmat(:, 3))
273 cell%hmat(1, 1) = abc(1); cell%hmat(1, 2) = 0.0_dp; cell%hmat(1, 3) = abc(3)*cos(beta)
274 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = abc(2); cell%hmat(2, 3) = 0.0_dp
275 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)*sin(beta)
279 a = 0.5_dp*(abc(1) + abc(2))
280 gamma =
angle(cell%hmat(:, 1), cell%hmat(:, 2))
283 cell%hmat(1, 1) = a; cell%hmat(1, 2) = acosg; cell%hmat(1, 3) = 0.0_dp
284 cell%hmat(2, 1) = 0.0_dp; cell%hmat(2, 2) = asing; cell%hmat(2, 3) = 0.0_dp
285 cell%hmat(3, 1) = 0.0_dp; cell%hmat(3, 2) = 0.0_dp; cell%hmat(3, 3) = abc(3)
291 IF ((abs(cell%hmat(1, 2)) < eps_hmat) .AND. (abs(cell%hmat(1, 3)) < eps_hmat) .AND. &
292 (abs(cell%hmat(2, 1)) < eps_hmat) .AND. (abs(cell%hmat(2, 3)) < eps_hmat) .AND. &
293 (abs(cell%hmat(3, 1)) < eps_hmat) .AND. (abs(cell%hmat(3, 2)) < eps_hmat))
THEN
294 cell%orthorhombic = .true.
296 cell%orthorhombic = .false.
301 IF (cell%orthorhombic)
THEN
302 cell%hmat(1, 2) = 0.0_dp
303 cell%hmat(1, 3) = 0.0_dp
304 cell%hmat(2, 1) = 0.0_dp
305 cell%hmat(2, 3) = 0.0_dp
306 cell%hmat(3, 1) = 0.0_dp
307 cell%hmat(3, 2) = 0.0_dp
310 dim = count(cell%perd == 1)
311 IF ((dim == 1) .AND. (.NOT. cell%orthorhombic))
THEN
312 cpabort(
"Non-orthorhombic and not periodic")
316 cell%deth = abs(
det_3x3(cell%hmat))
317 IF (cell%deth < 1.0e-10_dp)
THEN
318 CALL cp_abort(__location__, &
319 "An invalid set of cell vectors was obtained after applying "// &
320 "the requested cell symmetry. The cell volume is too small")
322 cell%h_inv =
inv_3x3(cell%hmat)
340 RECURSIVE SUBROUTINE read_cell(cell, cell_ref, use_ref_cell, cell_section, &
341 topology_section, check_for_ref, para_env)
343 TYPE(
cell_type),
POINTER :: cell, cell_ref
344 LOGICAL,
INTENT(INOUT),
OPTIONAL :: use_ref_cell
346 LOGICAL,
INTENT(IN),
OPTIONAL :: check_for_ref
349 REAL(kind=
dp),
PARAMETER :: eps = 1.0e-14_dp
351 CHARACTER(LEN=default_path_length) :: cell_file_name, coord_file_name, &
353 INTEGER :: canonicalize_mode, cell_file_format, &
354 coord_file_format, my_per
355 INTEGER,
DIMENSION(:),
POINTER :: multiple_unit_cell
356 LOGICAL :: canonicalize_cell, cell_read_a, cell_read_abc, cell_read_alpha_beta_gamma, &
357 cell_read_b, cell_read_c, cell_read_file, my_check_ref, tmp_comb_abc, tmp_comb_cell, &
358 tmp_comb_top, topo_read_coord
359 REAL(kind=
dp),
DIMENSION(3) :: read_ang, read_len
360 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat_input, read_mat
361 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cell_par
365 my_check_ref = .true.
366 NULLIFY (cell_ref_section, cell_par, cell_tmp, multiple_unit_cell)
374 IF (.NOT.
ASSOCIATED(cell))
CALL cell_create(cell, tag=
"CELL")
375 IF (.NOT.
ASSOCIATED(cell_ref))
CALL cell_create(cell_ref, tag=
"CELL_REF")
376 IF (
PRESENT(check_for_ref)) my_check_ref = check_for_ref
379 cell%orthorhombic = .false.
382 cell%hmat(:, :) = 0.0_dp
383 cell%h_inv(:, :) = 0.0_dp
384 cell%input_cell_canonicalized = .false.
385 cell%input_hmat(:, :) = 0.0_dp
386 cell%input_to_canonical(:, :) = 0.0_dp
387 cell%input_recip_to_canonical(:, :) = 0.0_dp
388 cell_read_file = .false.
389 cell_read_a = .false.
390 cell_read_b = .false.
391 cell_read_c = .false.
392 cell_read_abc = .false.
393 cell_read_alpha_beta_gamma = .false.
394 hmat_input(:, :) = 0.0_dp
395 read_mat(:, :) = 0.0_dp
412 CALL section_vals_val_get(cell_section,
"ALPHA_BETA_GAMMA", explicit=cell_read_alpha_beta_gamma)
418 tmp_comb_top = (.NOT. (cell_read_file .OR. cell_read_abc))
419 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_a))
420 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_b))
421 tmp_comb_top = (tmp_comb_top .AND. (.NOT. cell_read_c))
422 IF (tmp_comb_top)
THEN
423 CALL cp_warn(__location__, &
424 "None of the keywords CELL_FILE_NAME, ABC, or A, B, C "// &
425 "are specified in CELL section. CP2K will now attempt to read "// &
426 "TOPOLOGY/COORD_FILE_NAME if its format can be parsed for "// &
428 IF (
ASSOCIATED(topology_section))
THEN
430 IF (topo_read_coord)
THEN
433 SELECT CASE (coord_file_format)
447 CALL cp_abort(__location__, &
448 "COORD_FILE_FORMAT is not set to one of the implemented "// &
449 "CELL_FILE_FORMAT options and cannot be parsed for cell information!")
452 CALL cp_abort(__location__, &
453 "COORD_FILE_NAME is not set, so no cell information is available!")
456 CALL cp_warn(__location__, &
457 "TOPOLOGY section is not available, so COORD_FILE_NAME cannot "// &
458 "be parsed for cell information in lieu of missing CELL settings.")
463 IF (cell_read_file)
THEN
464 tmp_comb_cell = (cell_read_abc .OR. (cell_read_a .OR. (cell_read_b .OR. cell_read_c)))
465 IF (tmp_comb_cell)
THEN
466 CALL cp_warn(__location__, &
467 "Cell Information provided through A, B, C, or ABC in conjunction "// &
468 "with CELL_FILE_NAME. The definition in external file will override "// &
473 SELECT CASE (cell_file_format)
485 CALL cp_abort(__location__, &
486 "CELL_FILE_FORMAT is not set to one of the implemented "// &
487 "options and cannot be parsed for cell information!")
489 read_mat = cell_tmp%hmat
491 IF (cell_read_abc)
THEN
496 IF (cell_read_a .OR. cell_read_b .OR. cell_read_c)
THEN
497 CALL cp_warn(__location__, &
498 "Cell information provided through vectors A, B or C in conjunction with ABC. "// &
499 "The definition of the ABC keyword will override the one provided by A, B and C.")
502 tmp_comb_abc = ((cell_read_a .EQV. cell_read_b) .AND. (cell_read_b .EQV. cell_read_c))
503 IF (tmp_comb_abc)
THEN
505 read_mat(:, 1) = cell_par(:)
507 read_mat(:, 2) = cell_par(:)
509 read_mat(:, 3) = cell_par(:)
510 IF (cell_read_alpha_beta_gamma)
THEN
511 CALL cp_warn(__location__, &
512 "The keyword ALPHA_BETA_GAMMA is ignored because it was used without the "// &
516 CALL cp_abort(__location__, &
517 "Neither of the keywords CELL_FILE_NAME or ABC are specified, "// &
518 "and cell vector settings in A, B, C are incomplete!")
524 IF (any(read_mat(:, :) > eps))
THEN
527 IF (.NOT. canonicalize_cell .AND. &
528 ((abs(read_mat(2, 1)) > eps) .OR. &
529 (abs(read_mat(3, 1)) > eps) .OR. &
530 (abs(read_mat(3, 2)) > eps)))
THEN
532 CALL cp_warn(__location__, &
533 "CELL%CANONICALIZE AUTO keeps the general input cell orientation. "// &
534 "The cell matrix is not a lower triangle and does not conform to the "// &
535 "program convention that A lies along the X-axis and B is in the XY plane. "// &
536 "Set CELL%CANONICALIZE TRUE to explicitly transform the cell and supported "// &
537 "cell-dependent input to the canonical internal frame.")
539 CALL cp_warn(__location__, &
540 "Cell vectors are read but cell matrix is not "// &
541 "a lower triangle, not conforming to the program "// &
542 "convention that A lies along the X-axis and "// &
543 "B is in the XY plane.")
548 IF (any(read_ang(:) > eps) .AND. any(read_len(:) > eps))
THEN
549 CALL set_cell_param(cell, cell_length=read_len, cell_angle=read_ang, &
550 do_init_cell=.false.)
552 CALL cp_abort(__location__, &
553 "No meaningful cell information is read from parser!")
557 CALL reset_cell_section_by_cell_mat(cell, cell_section)
561 IF (any(multiple_unit_cell /= 1))
CALL set_multiple_unit_cell(cell, multiple_unit_cell)
566 cell%perd = [1, 0, 0]
568 cell%perd = [0, 1, 0]
570 cell%perd = [0, 0, 1]
572 cell%perd = [1, 1, 0]
574 cell%perd = [1, 0, 1]
576 cell%perd = [0, 1, 1]
578 cell%perd = [1, 1, 1]
580 cell%perd = [0, 0, 0]
582 cpabort(
"Invalid or not yet implemented cell periodicity")
589 hmat_input(:, :) = cell%hmat(:, :)
592 IF (.NOT. canonicalize_cell .AND. any(abs(cell_tmp%hmat - cell%hmat) > eps))
THEN
593 WRITE (unit=error_msg, fmt=
"(A)") &
594 "When initializing cell vectors with requested symmetry, one "// &
595 "or more elements of the cell matrix has varied significantly. "// &
596 "The input parameters are either deviating from the symmetry, "// &
597 "or not conforming to the program convention that cell matrix "// &
598 "is a lower triangle. The symmetrized cell vectors will be used "// &
599 "anyway with the input atomic coordinates."
600 CALL cp_warn(__location__, error_msg)
602 IF (canonicalize_cell)
THEN
608 CALL reset_cell_section_by_cell_mat(cell, cell_section)
610 IF (my_check_ref)
THEN
613 IF (parsed_cp2k_input(cell_ref_section, check_this_section=.true.))
THEN
614 IF (
PRESENT(use_ref_cell)) use_ref_cell = .true.
615 CALL read_cell(cell_ref, cell_ref, use_ref_cell=use_ref_cell, &
616 cell_section=cell_ref_section, check_for_ref=.false., &
619 CALL cell_clone(cell, cell_ref, tag=
"CELL_REF")
620 IF (
PRESENT(use_ref_cell)) use_ref_cell = .false.
634 FUNCTION parsed_cp2k_input(input_file, check_this_section)
RESULT(res)
637 LOGICAL,
INTENT(IN),
OPTIONAL :: check_this_section
644 IF (
PRESENT(check_this_section)) my_check = check_this_section
645 res =
ASSOCIATED(input_file)
647 cpassert(input_file%ref_count > 0)
648 IF (.NOT. my_check)
THEN
656 END FUNCTION parsed_cp2k_input
674 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: cell_length, cell_angle
675 INTEGER,
DIMENSION(3),
INTENT(IN),
OPTIONAL :: periodic
676 LOGICAL,
INTENT(IN) :: do_init_cell
678 REAL(kind=
dp),
PARAMETER :: eps = epsilon(0.0_dp)
680 REAL(kind=
dp) :: cos_alpha, cos_beta, cos_gamma, sin_gamma
682 cpassert(
ASSOCIATED(cell))
683 cpassert(all(cell_angle /= 0.0_dp))
685 cos_gamma = cos(cell_angle(3));
IF (abs(cos_gamma) < eps) cos_gamma = 0.0_dp
686 IF (abs(abs(cos_gamma) - 1.0_dp) < eps) cos_gamma = sign(1.0_dp, cos_gamma)
687 sin_gamma = sin(cell_angle(3));
IF (abs(sin_gamma) < eps) sin_gamma = 0.0_dp
688 IF (abs(abs(sin_gamma) - 1.0_dp) < eps) sin_gamma = sign(1.0_dp, sin_gamma)
689 cos_beta = cos(cell_angle(2));
IF (abs(cos_beta) < eps) cos_beta = 0.0_dp
690 IF (abs(abs(cos_beta) - 1.0_dp) < eps) cos_beta = sign(1.0_dp, cos_beta)
691 cos_alpha = cos(cell_angle(1));
IF (abs(cos_alpha) < eps) cos_alpha = 0.0_dp
692 IF (abs(abs(cos_alpha) - 1.0_dp) < eps) cos_alpha = sign(1.0_dp, cos_alpha)
694 cell%hmat(:, 1) = [1.0_dp, 0.0_dp, 0.0_dp]
695 cell%hmat(:, 2) = [cos_gamma, sin_gamma, 0.0_dp]
696 cell%hmat(:, 3) = [cos_beta, (cos_alpha - cos_gamma*cos_beta)/sin_gamma, 0.0_dp]
697 cell%hmat(3, 3) = sqrt(1.0_dp - cell%hmat(1, 3)**2 - cell%hmat(2, 3)**2)
699 cell%hmat(:, 1) = cell%hmat(:, 1)*cell_length(1)
700 cell%hmat(:, 2) = cell%hmat(:, 2)*cell_length(2)
701 cell%hmat(:, 3) = cell%hmat(:, 3)*cell_length(3)
703 IF (do_init_cell)
THEN
704 IF (
PRESENT(periodic))
THEN
705 CALL init_cell(cell=cell, periodic=periodic)
721 SUBROUTINE set_multiple_unit_cell(cell, multiple_unit_cell)
724 INTEGER,
DIMENSION(:),
POINTER :: multiple_unit_cell
726 cpassert(
ASSOCIATED(cell))
729 IF (any(multiple_unit_cell <= 0))
THEN
730 CALL cp_abort(__location__, &
731 "CELL%MULTIPLE_UNIT_CELL accepts only integer values larger than 0! "// &
732 "A value of 0 or negative is meaningless!")
736 cell%hmat(:, 1) = cell%hmat(:, 1)*multiple_unit_cell(1)
737 cell%hmat(:, 2) = cell%hmat(:, 2)*multiple_unit_cell(2)
738 cell%hmat(:, 3) = cell%hmat(:, 3)*multiple_unit_cell(3)
740 END SUBROUTINE set_multiple_unit_cell
761 CHARACTER(len=*) :: cif_file_name
765 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_cif'
768 INTEGER,
DIMENSION(3) :: periodic
770 REAL(kind=
dp),
DIMENSION(3) :: cell_angles, cell_lengths
773 CALL timeset(routinen, handle)
776 para_env=para_env, apply_preprocessing=.false.)
782 begin_line=.false., search_from_begin_of_file=.true.)
783 IF (.NOT. found)
THEN
785 begin_line=.false., search_from_begin_of_file=.true.)
786 IF (.NOT. found)
THEN
787 cpabort(
"The field _cell_length_a or _cell.length_a was not found in CIF file! ")
790 CALL cif_get_real(parser, cell_lengths(1))
795 begin_line=.false., search_from_begin_of_file=.true.)
796 IF (.NOT. found)
THEN
798 begin_line=.false., search_from_begin_of_file=.true.)
799 IF (.NOT. found)
THEN
800 cpabort(
"The field _cell_length_b or _cell.length_b was not found in CIF file! ")
803 CALL cif_get_real(parser, cell_lengths(2))
808 begin_line=.false., search_from_begin_of_file=.true.)
809 IF (.NOT. found)
THEN
811 begin_line=.false., search_from_begin_of_file=.true.)
812 IF (.NOT. found)
THEN
813 cpabort(
"The field _cell_length_c or _cell.length_c was not found in CIF file! ")
816 CALL cif_get_real(parser, cell_lengths(3))
821 begin_line=.false., search_from_begin_of_file=.true.)
822 IF (.NOT. found)
THEN
824 begin_line=.false., search_from_begin_of_file=.true.)
825 IF (.NOT. found)
THEN
826 cpabort(
"The field _cell_angle_alpha or _cell.angle_alpha was not found in CIF file! ")
829 CALL cif_get_real(parser, cell_angles(1))
834 begin_line=.false., search_from_begin_of_file=.true.)
835 IF (.NOT. found)
THEN
837 begin_line=.false., search_from_begin_of_file=.true.)
838 IF (.NOT. found)
THEN
839 cpabort(
"The field _cell_angle_beta or _cell.angle_beta was not found in CIF file! ")
842 CALL cif_get_real(parser, cell_angles(2))
847 begin_line=.false., search_from_begin_of_file=.true.)
848 IF (.NOT. found)
THEN
850 begin_line=.false., search_from_begin_of_file=.true.)
851 IF (.NOT. found)
THEN
852 cpabort(
"The field _cell_angle_gamma or _cell.angle_gamma was not found in CIF file! ")
855 CALL cif_get_real(parser, cell_angles(3))
859 CALL set_cell_param(cell, cell_lengths, cell_angles, periodic=periodic, &
864 CALL timestop(handle)
876 SUBROUTINE cif_get_real(parser, r)
879 REAL(kind=
dp),
INTENT(OUT) :: r
881 CHARACTER(LEN=default_string_length) :: s_tag
885 iln = len_trim(s_tag)
886 IF (index(s_tag,
"(") /= 0) iln = index(s_tag,
"(") - 1
887 READ (s_tag(1:iln), *) r
889 END SUBROUTINE cif_get_real
903 CHARACTER(len=*) :: xyz_file_name
907 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_xyz'
913 CALL timeset(routinen, handle)
916 para_env=para_env, apply_preprocessing=.false.)
919 IF (.NOT. has_cell)
THEN
920 CALL cp_abort(__location__, &
921 "The keyword CELL_FILE_FORMAT requested cell information "// &
922 "from XYZ file, but it is not available from the file <"// &
923 trim(adjustl(xyz_file_name))//
"> as CELL_FILE_NAME specified!")
926 CALL timestop(handle)
978 CHARACTER(LEN=*),
INTENT(IN) :: line
979 TYPE(
cell_type),
INTENT(INOUT),
POINTER :: cell
980 LOGICAL,
INTENT(OUT) :: has_cell
981 INTEGER,
INTENT(OUT),
OPTIONAL :: step
982 REAL(kind=
dp),
INTENT(OUT),
OPTIONAL :: time, ener
984 CHARACTER(LEN=3) :: abc
985 CHARACTER(LEN=max_line_length) :: my_line, raw_str
986 INTEGER :: i, id1, id2, ios, j, my_step
987 REAL(kind=
dp) :: my_ener, my_time
988 REAL(kind=
dp),
DIMENSION(3) :: my_abc, my_albega
989 REAL(kind=
dp),
DIMENSION(3, 3) :: my_hmat
993 my_time = huge(0.0_dp)
994 my_ener = huge(0.0_dp)
1001 id1 = index(my_line,
"LATTICE=")
1003 id2 = index(my_line(id1 + 9:),
'"')
1004 READ (my_line(id1 + 9:id1 + id2 + 7),
'(A)') raw_str
1005 READ (raw_str, *, iostat=ios) my_hmat(:, 1), my_hmat(:, 2), my_hmat(:, 3)
1007 CALL cp_abort(__location__,
"Error while parsing input line for cell vectors as "// &
1008 "extended XYZ format: expected 9 real values in the <lattice=> "// &
1009 "quoted field, found <"//trim(raw_str)//
"> which is invalid!")
1018 IF (
PRESENT(step))
THEN
1019 id1 = index(my_line,
"STEP=")
1021 READ (my_line(id1 + 5:),
'(A)') raw_str
1022 READ (raw_str, *, iostat=ios) my_step
1024 CALL cp_abort(__location__, &
1025 "Error while parsing input line for step as extended "// &
1026 "XYZ format: expected 1 integer value in the <step=> "// &
1027 "field, found <"//trim(raw_str)//
"> which is invalid!")
1032 IF (
PRESENT(time))
THEN
1033 id1 = index(my_line,
"TIME=")
1035 READ (my_line(id1 + 5:),
'(A)') raw_str
1036 READ (raw_str, *, iostat=ios) my_time
1038 CALL cp_abort(__location__, &
1039 "Error while parsing input line for time as extended "// &
1040 "XYZ format: expected 1 real value in the <time=> "// &
1041 "field, found <"//trim(raw_str)//
"> which is invalid!")
1046 IF (
PRESENT(ener))
THEN
1047 id1 = index(my_line,
"ENERGY=")
1049 READ (my_line(id1 + 7:),
'(A)') raw_str
1050 READ (raw_str, *, iostat=ios) my_ener
1052 CALL cp_abort(__location__, &
1053 "Error while parsing input line for energy as extended "// &
1054 "XYZ format: expected 1 real value in the <energy=> "// &
1055 "field, found <"//trim(raw_str)//
"> which is invalid!")
1063 id1 = index(my_line,
" "//abc(i:i)//
" = ")
1065 READ (my_line(id1 + 5:),
'(A)') raw_str
1066 READ (raw_str, *, iostat=ios) my_abc(i)
1068 CALL cp_abort(__location__, &
1069 "Error while parsing input line for cell vector as dumpdcd "// &
1070 "XYZ format: expected 1 real value in the <"//abc(i:i)//
" = > "// &
1071 "field, found <"//trim(raw_str)//
"> which is invalid!")
1077 id1 = index(my_line,
" ALPHA = ")
1079 READ (my_line(id1 + 9:),
'(A)') raw_str
1080 READ (raw_str, *, iostat=ios) my_albega(1)
1082 CALL cp_abort(__location__, &
1083 "Error while parsing input line for cell angle alpha as dumpdcd "// &
1084 "XYZ format: expected 1 real value in the <alpha = > "// &
1085 "field, found <"//trim(raw_str)//
"> which is invalid!")
1090 id1 = index(my_line,
" BETA = ")
1092 READ (my_line(id1 + 8:),
'(A)') raw_str
1093 READ (raw_str, *, iostat=ios) my_albega(2)
1095 CALL cp_abort(__location__, &
1096 "Error while parsing input line for cell angle beta as dumpdcd "// &
1097 "XYZ format: expected 1 real value in the <beta = > "// &
1098 "field, found <"//trim(raw_str)//
"> which is invalid!")
1103 id1 = index(my_line,
" GAMMA = ")
1105 READ (my_line(id1 + 9:),
'(A)') raw_str
1106 READ (raw_str, *, iostat=ios) my_albega(3)
1108 CALL cp_abort(__location__, &
1109 "Error while parsing input line for cell angle gamma as dumpdcd "// &
1110 "XYZ format: expected 1 real value in the <gamma = > "// &
1111 "field, found <"//trim(raw_str)//
"> which is invalid!")
1116 IF (all(my_abc(1:3) > 0.0_dp) .AND. all(my_albega(1:3) > 0.0_dp))
THEN
1118 CALL set_cell_param(cell, my_abc, my_albega, do_init_cell=.false.)
1120 IF (
PRESENT(step))
THEN
1121 id1 = index(my_line,
" I = ")
1123 READ (my_line(id1 + 5:),
'(A)') raw_str
1124 READ (raw_str, *, iostat=ios) my_step
1126 CALL cp_abort(__location__, &
1127 "Error while parsing input line for step as dumpdcd "// &
1128 "XYZ format: expected 1 integer value in the <i = > "// &
1129 "field, found <"//trim(raw_str)//
"> which is invalid!")
1134 IF (
PRESENT(time))
THEN
1135 id1 = index(my_line,
" TIME = ")
1137 READ (my_line(id1 + 8:),
'(A)') raw_str
1138 READ (raw_str, *, iostat=ios) my_time
1140 CALL cp_abort(__location__, &
1141 "Error while parsing input line for time as dumpdcd "// &
1142 "XYZ format: expected 1 real value in the <time = > "// &
1143 "field, found <"//trim(raw_str)//
"> which is invalid!")
1148 IF (
PRESENT(ener))
THEN
1149 id1 = index(my_line,
" E = ")
1151 READ (my_line(id1 + 5:),
'(A)') raw_str
1152 READ (raw_str, *, iostat=ios) my_ener
1154 CALL cp_abort(__location__, &
1155 "Error while parsing input line for energy as dumpdcd "// &
1156 "XYZ format: expected 1 real value in the <E = > "// &
1157 "field, found <"//trim(raw_str)//
"> which is invalid!")
1186 CHARACTER(len=*) :: pdb_file_name
1190 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_pdb'
1192 CHARACTER(LEN=default_string_length) :: cryst
1193 INTEGER :: handle, i, ios
1194 INTEGER,
DIMENSION(3) :: periodic
1196 REAL(kind=
dp),
DIMENSION(3) :: cell_angles, cell_lengths
1199 CALL timeset(routinen, handle)
1202 para_env=para_env, apply_preprocessing=.false.)
1205 begin_line=.true., search_from_begin_of_file=.true.)
1206 IF (.NOT. found)
THEN
1207 cpabort(
"The line <CRYST1> was not found in PDB file! ")
1211 READ (parser%input_line, *, iostat=ios) cryst, cell_lengths(:), cell_angles(:)
1213 CALL cp_abort(__location__,
"Error while parsing PDB file "// &
1214 "<"//trim(pdb_file_name)//
"> for cell lengths and angles: "// &
1215 "found CRYST1 line as <"//trim(parser%input_line)//
">")
1221 CALL set_cell_param(cell, cell_lengths, cell_angles, periodic=periodic, &
1222 do_init_cell=.true.)
1226 CALL timestop(handle)
1240 CHARACTER(len=*) :: cp2k_file_name
1244 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_cp2k'
1246 INTEGER :: handle, i, idum, j
1248 REAL(kind=
dp) :: xdum
1249 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1252 CALL timeset(routinen, handle)
1255 para_env=para_env, apply_preprocessing=.false.)
1259 DO WHILE (.NOT. my_end)
1260 READ (parser%input_line, *) idum, xdum, hmat(:, 1), hmat(:, 2), hmat(:, 3)
1271 CALL timestop(handle)
1285 CHARACTER(len=*) :: xsc_file_name
1289 CHARACTER(len=*),
PARAMETER :: routinen =
'read_cell_xsc'
1291 INTEGER :: handle, i, idum, j
1292 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
1295 CALL timeset(routinen, handle)
1298 para_env=para_env, apply_preprocessing=.false.)
1301 READ (parser%input_line, *) idum, hmat(:, 1), hmat(:, 2), hmat(:, 3)
1310 CALL timestop(handle)
1322 SUBROUTINE reset_cell_section_by_cell_mat(cell, cell_section)
1327 REAL(kind=
dp),
DIMENSION(:),
POINTER :: cell_par
1336 ALLOCATE (cell_par(3))
1337 cell_par = cell%hmat(:, 1)
1339 ALLOCATE (cell_par(3))
1340 cell_par = cell%hmat(:, 2)
1342 ALLOCATE (cell_par(3))
1343 cell_par = cell%hmat(:, 3)
1346 END SUBROUTINE reset_cell_section_by_cell_mat
1363 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: tag
1365 CHARACTER(LEN=default_string_length) :: label, unit_str
1366 INTEGER :: output_unit
1371 IF (
PRESENT(tag))
THEN
1372 label = trim(tag)//
"|"
1374 label = trim(cell%tag)//
"|"
1398 CHARACTER(LEN=*),
INTENT(IN) :: unit_str
1399 INTEGER,
INTENT(IN) :: output_unit
1400 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: label
1402 CHARACTER(LEN=12) :: tag
1403 CHARACTER(LEN=3) :: string
1404 CHARACTER(LEN=default_string_length) :: my_label
1405 REAL(kind=
dp) :: alpha, beta,
gamma, val
1406 REAL(kind=
dp),
DIMENSION(3) :: abc
1415 IF (output_unit > 0)
THEN
1417 IF (
PRESENT(label))
THEN
1420 my_label = trim(tag)//
"|"
1423 WRITE (unit=output_unit, fmt=
"(/,T2,A,T61,F20.6)") &
1424 trim(my_label)//
" Volume ["//trim(unit_str)//
"^3]:", val
1426 WRITE (unit=output_unit, fmt=
"(T2,A,T30,3F10.3,3X,A6,F12.6)") &
1427 trim(my_label)//
" Vector a ["//trim(unit_str)//
"]:", cell%hmat(:, 1)*val, &
1428 "|a| = ", abc(1)*val, &
1429 trim(my_label)//
" Vector b ["//trim(unit_str)//
"]:", cell%hmat(:, 2)*val, &
1430 "|b| = ", abc(2)*val, &
1431 trim(my_label)//
" Vector c ["//trim(unit_str)//
"]:", cell%hmat(:, 3)*val, &
1432 "|c| = ", abc(3)*val
1433 WRITE (unit=output_unit, fmt=
"(T2,A,T69,F12.6)") &
1434 trim(my_label)//
" Angle (b,c), alpha [degree]: ", alpha, &
1435 trim(my_label)//
" Angle (a,c), beta [degree]: ", beta, &
1436 trim(my_label)//
" Angle (a,b), gamma [degree]: ",
gamma
1441 WRITE (unit=output_unit, fmt=
"(T2,A,T61,A20)") &
1442 trim(my_label)//
" Requested initial symmetry: ", &
1443 adjustr(trim(
enum_i2c(enum, cell%symmetry_id)))
1446 IF (cell%orthorhombic)
THEN
1447 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1448 trim(my_label)//
" Numerically orthorhombic: ",
"YES"
1450 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1451 trim(my_label)//
" Numerically orthorhombic: ",
" NO"
1453 IF (sum(cell%perd(1:3)) == 0)
THEN
1454 WRITE (unit=output_unit, fmt=
"(T2,A,T77,A4)") &
1455 trim(my_label)//
" Periodicity",
"NONE"
1458 IF (cell%perd(1) == 1) string = trim(string)//
"X"
1459 IF (cell%perd(2) == 1) string = trim(string)//
"Y"
1460 IF (cell%perd(3) == 1) string = trim(string)//
"Z"
1461 WRITE (unit=output_unit, fmt=
"(T2,A,T78,A3)") &
1462 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_xyz_comment(line, cell, has_cell, step, time, ener)
Reads comment line of XYZ files to get cell, step, time and energy info.
subroutine, public read_cell_xyz(xyz_file_name, cell, para_env)
Reads xyz file and pass comments on the second line to get cell information.
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.
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 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
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 max_line_length
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