65#include "../base/base_uses.f90"
71 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'tmc_analysis'
89 CHARACTER(LEN=default_path_length) :: c_tmp
90 CHARACTER(LEN=default_string_length),
POINTER :: charge_atm(:)
91 INTEGER :: i_tmp, ntot
92 INTEGER,
DIMENSION(3) :: nr_bins
93 INTEGER,
DIMENSION(:),
POINTER :: i_arr_tmp
94 LOGICAL :: explicit, explicit_key, flag
95 REAL(kind=
dp),
POINTER :: charge(:)
98 NULLIFY (tmp_section, charge_atm, i_arr_tmp, charge)
100 cpassert(
ASSOCIATED(tmc_ana_section))
101 cpassert(.NOT.
ASSOCIATED(tmc_ana))
110 c_val=tmc_ana%out_file_prefix)
111 IF (tmc_ana%out_file_prefix /=
"")
THEN
112 tmc_ana%out_file_prefix = trim(tmc_ana%out_file_prefix)//
"_"
117 IF (explicit_key)
THEN
120 IF (
SIZE(i_arr_tmp(:)) == 3)
THEN
121 IF (any(i_arr_tmp(:) <= 0))
THEN
122 CALL cp_abort(__location__,
"The amount of intervals in each "// &
123 "direction has to be greater than 0.")
125 nr_bins(:) = i_arr_tmp(:)
126 ELSE IF (
SIZE(i_arr_tmp(:)) == 1)
THEN
127 IF (any(i_arr_tmp(:) <= 0))
THEN
128 cpabort(
"The amount of intervals has to be greater than 0.")
130 nr_bins(:) = i_arr_tmp(1)
131 ELSE IF (
SIZE(i_arr_tmp(:)) == 0)
THEN
134 cpabort(
"unknown amount of dimensions for the binning.")
141 IF (explicit_key)
THEN
149 IF (explicit_key)
THEN
155 ALLOCATE (charge_atm(i_tmp))
156 ALLOCATE (charge(i_tmp))
159 CALL cp_abort(__location__, &
160 "to calculate the classical cell dipole moment "// &
161 "the charges has to be specified")
165 tmc_ana%dim_per_elem)
167 IF (
ASSOCIATED(charge_atm))
DEALLOCATE (charge_atm)
168 IF (
ASSOCIATED(charge))
DEALLOCATE (charge)
173 IF (explicit_key)
THEN
176 SELECT CASE (trim(c_tmp))
184 cpwarn(
'unknown analysis type "'//trim(c_tmp)//
'" specified. Set to default.')
195 dim_per_elem=tmc_ana%dim_per_elem)
209 CHARACTER(LEN=default_path_length) :: tmp_cell_file, tmp_dip_file, tmp_pos_file
211 cpassert(
ASSOCIATED(ana_env))
214 ana_env%nr_dim = nr_dim
217 tmp_pos_file = ana_env%costum_pos_file_name
218 tmp_cell_file = ana_env%costum_cell_file_name
219 tmp_dip_file = ana_env%costum_dip_file_name
228 IF (
ASSOCIATED(ana_env%density_3d))
THEN
229 ana_env%costum_pos_file_name = tmp_pos_file
230 ana_env%costum_cell_file_name = tmp_cell_file
233 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
234 ana_env%costum_pos_file_name = tmp_pos_file
235 ana_env%costum_cell_file_name = tmp_cell_file
238 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
239 ana_env%costum_pos_file_name = tmp_pos_file
240 ana_env%costum_cell_file_name = tmp_cell_file
243 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
244 ana_env%costum_pos_file_name = tmp_pos_file
245 ana_env%costum_cell_file_name = tmp_cell_file
246 ana_env%costum_dip_file_name = tmp_dip_file
249 IF (
ASSOCIATED(ana_env%displace))
THEN
250 ana_env%costum_pos_file_name = tmp_pos_file
251 ana_env%costum_cell_file_name = tmp_cell_file
255 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
256 CALL ana_pair_correl_init(ana_pair_correl=ana_env%pair_correl, &
257 atoms=ana_env%atoms, cell=ana_env%cell)
260 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
261 CALL ana_dipole_moment_init(ana_dip_mom=ana_env%dip_mom, &
275 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp, &
280 cpassert(
ASSOCIATED(ana_env))
281 cpassert(
ASSOCIATED(ana_env%last_elem))
282 IF (.NOT. ana_env%restart)
RETURN
284 WRITE (file_name, fmt=
'(I9.9)') ana_env%last_elem%nr
286 trim(ana_env%out_file_prefix)// &
288 "ana"), ana_env%temperature))
291 CALL open_file(file_name=restart_file_name, file_status=
"REPLACE", &
292 file_action=
"WRITE", file_form=
"UNFORMATTED", &
293 unit_number=file_ptr)
294 WRITE (file_ptr) ana_env%temperature
299 l_tmp =
ASSOCIATED(ana_env%density_3d)
300 WRITE (file_ptr) l_tmp
302 WRITE (file_ptr) ana_env%density_3d%conf_counter, &
303 ana_env%density_3d%nr_bins, &
304 ana_env%density_3d%sum_vol, &
305 ana_env%density_3d%sum_vol2, &
306 ana_env%density_3d%sum_box_length, &
307 ana_env%density_3d%sum_box_length2, &
308 ana_env%density_3d%sum_density, &
309 ana_env%density_3d%sum_dens2
312 l_tmp =
ASSOCIATED(ana_env%pair_correl)
313 WRITE (file_ptr) l_tmp
315 WRITE (file_ptr) ana_env%pair_correl%conf_counter, &
316 ana_env%pair_correl%nr_bins, &
317 ana_env%pair_correl%step_length, &
318 ana_env%pair_correl%pairs, &
319 ana_env%pair_correl%g_r
322 l_tmp =
ASSOCIATED(ana_env%dip_mom)
323 WRITE (file_ptr) l_tmp
325 WRITE (file_ptr) ana_env%dip_mom%conf_counter, &
326 ana_env%dip_mom%charges, &
327 ana_env%dip_mom%last_dip_cl
330 l_tmp =
ASSOCIATED(ana_env%dip_ana)
331 WRITE (file_ptr) l_tmp
333 WRITE (file_ptr) ana_env%dip_ana%conf_counter, &
334 ana_env%dip_ana%ana_type, &
335 ana_env%dip_ana%mu2_pv_s, &
336 ana_env%dip_ana%mu_psv, &
337 ana_env%dip_ana%mu_pv, &
338 ana_env%dip_ana%mu2_pv_mat, &
339 ana_env%dip_ana%mu2_pv_mat
342 l_tmp =
ASSOCIATED(ana_env%displace)
343 WRITE (file_ptr) l_tmp
345 WRITE (file_ptr) ana_env%displace%conf_counter, &
346 ana_env%displace%disp
356 file_action=
"WRITE", file_status=
"REPLACE", &
357 unit_number=file_ptr)
358 WRITE (file_ptr, *) trim(restart_file_name)
373 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
376 REAL(kind=
dp) :: temp
378 cpassert(
ASSOCIATED(ana_env))
379 cpassert(
ASSOCIATED(elem))
380 IF (.NOT. ana_env%restart)
RETURN
386 INQUIRE (file=file_name, exist=l_tmp)
388 CALL open_file(file_name=file_name, file_status=
"OLD", &
389 file_action=
"READ", unit_number=file_ptr)
390 READ (file_ptr, *) file_name_tmp
393 CALL open_file(file_name=file_name_tmp, file_status=
"OLD", file_form=
"UNFORMATTED", &
394 file_action=
"READ", unit_number=file_ptr)
396 cpassert(ana_env%temperature == temp)
397 ana_env%last_elem => elem
402 READ (file_ptr) l_tmp
403 cpassert(
ASSOCIATED(ana_env%density_3d) .EQV. l_tmp)
405 READ (file_ptr) ana_env%density_3d%conf_counter, &
406 ana_env%density_3d%nr_bins, &
407 ana_env%density_3d%sum_vol, &
408 ana_env%density_3d%sum_vol2, &
409 ana_env%density_3d%sum_box_length, &
410 ana_env%density_3d%sum_box_length2, &
411 ana_env%density_3d%sum_density, &
412 ana_env%density_3d%sum_dens2
415 READ (file_ptr) l_tmp
416 cpassert(
ASSOCIATED(ana_env%pair_correl) .EQV. l_tmp)
418 READ (file_ptr) ana_env%pair_correl%conf_counter, &
419 ana_env%pair_correl%nr_bins, &
420 ana_env%pair_correl%step_length, &
421 ana_env%pair_correl%pairs, &
422 ana_env%pair_correl%g_r
425 READ (file_ptr) l_tmp
426 cpassert(
ASSOCIATED(ana_env%dip_mom) .EQV. l_tmp)
428 READ (file_ptr) ana_env%dip_mom%conf_counter, &
429 ana_env%dip_mom%charges, &
430 ana_env%dip_mom%last_dip_cl
433 READ (file_ptr) l_tmp
434 cpassert(
ASSOCIATED(ana_env%dip_ana) .EQV. l_tmp)
436 READ (file_ptr) ana_env%dip_ana%conf_counter, &
437 ana_env%dip_ana%ana_type, &
438 ana_env%dip_ana%mu2_pv_s, &
439 ana_env%dip_ana%mu_psv, &
440 ana_env%dip_ana%mu_pv, &
441 ana_env%dip_ana%mu2_pv_mat, &
442 ana_env%dip_ana%mu2_pv_mat
445 READ (file_ptr) l_tmp
446 cpassert(
ASSOCIATED(ana_env%displace) .EQV. l_tmp)
448 READ (file_ptr) ana_env%displace%conf_counter, &
449 ana_env%displace%disp
472 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_tmc_analysis'
474 INTEGER :: handle, weight_act
475 REAL(kind=
dp),
DIMENSION(3) :: dip_tmp
478 cpassert(
ASSOCIATED(elem))
479 cpassert(
ASSOCIATED(ana_env))
482 CALL timeset(routinen, handle)
485 IF (
ASSOCIATED(ana_env%last_elem))
THEN
486 weight_act = elem%nr - ana_env%last_elem%nr
489 IF (weight_act > 0)
THEN
491 IF (
ASSOCIATED(ana_env%density_3d))
THEN
492 CALL calc_density_3d(elem=ana_env%last_elem, &
493 weight=weight_act, atoms=ana_env%atoms, &
497 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
498 CALL calc_paircorrelation(elem=ana_env%last_elem, weight=weight_act, &
499 atoms=ana_env%atoms, ana_env=ana_env)
502 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
503 CALL calc_dipole_moment(elem=ana_env%last_elem, weight=weight_act, &
507 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
512 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
513 dip_tmp(:) = ana_env%last_elem%dipole(:)
514 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
515 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
517 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
520 ana_env%last_elem%dipole(:) = dip_tmp(:)
521 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
522 dip_tmp(:) = ana_env%last_elem%dipole(:)
523 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
524 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
526 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
529 ana_env%last_elem%dipole(:) = dip_tmp(:)
530 ana_env%last_elem%dipole(3) = -ana_env%last_elem%dipole(3)
531 dip_tmp(:) = ana_env%last_elem%dipole(:)
532 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
533 ana_env%dip_mom%last_dip_cl(3) = -ana_env%dip_mom%last_dip_cl(3)
535 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
538 ana_env%last_elem%dipole(:) = dip_tmp(:)
539 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
540 dip_tmp(:) = ana_env%last_elem%dipole(:)
541 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
542 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
544 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
547 ana_env%last_elem%dipole(:) = dip_tmp(:)
548 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
549 dip_tmp(:) = ana_env%last_elem%dipole(:)
550 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
551 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
553 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
556 ana_env%last_elem%dipole(:) = dip_tmp(:)
557 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
558 dip_tmp(:) = ana_env%last_elem%dipole(:)
559 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
560 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
562 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
565 ana_env%last_elem%dipole(:) = dip_tmp(:)
566 ana_env%last_elem%dipole(:) = -ana_env%last_elem%dipole(:)
567 dip_tmp(:) = ana_env%last_elem%dipole(:)
568 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
569 ana_env%dip_mom%last_dip_cl(:) = -ana_env%dip_mom%last_dip_cl(:)
571 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
574 ana_env%last_elem%dipole(:) = dip_tmp(:)
575 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
576 dip_tmp(:) = ana_env%last_elem%dipole(:)
577 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
578 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
581 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
583 CALL print_act_dipole_analysis(elem=ana_env%last_elem, &
588 IF (
ASSOCIATED(ana_env%displace))
THEN
589 CALL calc_displacement(elem=elem, ana_env=ana_env)
593 elem_tmp => ana_env%last_elem
594 ana_env%last_elem => elem
597 CALL timestop(handle)
609 CHARACTER(LEN=*),
PARAMETER :: routinen =
'finalize_tmc_analysis'
613 cpassert(
ASSOCIATED(ana_env))
616 CALL timeset(routinen, handle)
617 IF (
ASSOCIATED(ana_env%density_3d))
THEN
618 IF (ana_env%density_3d%conf_counter > 0)
THEN
619 CALL print_density_3d(ana_env=ana_env)
622 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
623 IF (ana_env%pair_correl%conf_counter > 0)
THEN
624 CALL print_paircorrelation(ana_env=ana_env)
627 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
628 IF (ana_env%dip_mom%conf_counter > 0)
THEN
629 CALL print_dipole_moment(ana_env)
632 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
633 IF (ana_env%dip_ana%conf_counter > 0)
THEN
634 CALL print_dipole_analysis(ana_env)
637 IF (
ASSOCIATED(ana_env%displace))
THEN
638 IF (ana_env%displace%conf_counter > 0)
THEN
639 CALL print_average_displacement(ana_env)
644 CALL timestop(handle)
658 INTEGER :: start_id, end_id
659 INTEGER,
OPTIONAL :: dir_ind
663 CHARACTER(LEN=*),
PARAMETER :: routinen =
'analyze_file_configurations'
665 INTEGER :: conf_nr, handle, nr_dim, stat
671 cpassert(
ASSOCIATED(ana_env))
672 cpassert(
ASSOCIATED(tmc_params))
675 CALL timeset(routinen, handle)
680 IF (ana_env%id_dip > 0)
THEN
681 tmc_params%print_dipole = .true.
683 tmc_params%print_dipole = .false.
688 nr_dim=ana_env%nr_dim)
690 IF (
ASSOCIATED(ana_env%last_elem)) conf_nr = ana_env%last_elem%nr
691 nr_dim =
SIZE(elem%pos)
702 IF (start_id < 0 .OR. conf_nr >= start_id)
THEN
703 IF (end_id < 0 .OR. conf_nr <= end_id)
THEN
710 IF (
ASSOCIATED(elem))
THEN
714 IF (.NOT.
ASSOCIATED(elem))
THEN
723 IF (
ASSOCIATED(elem))
THEN
728 CALL timestop(handle)
745 SUBROUTINE calc_density_3d(elem, weight, atoms, ana_env)
751 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_density_3d'
753 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
754 INTEGER ::
atom, bin_x, bin_y, bin_z, file_ptr, &
757 REAL(kind=
dp) :: mass_total, r_tmp, vol_cell, vol_sub_box
758 REAL(kind=
dp),
DIMENSION(3) :: atom_pos, cell_size, interval_size
759 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: mass_bin
763 cpassert(
ASSOCIATED(elem))
764 cpassert(
ASSOCIATED(elem%pos))
766 cpassert(
ASSOCIATED(atoms))
767 cpassert(
ASSOCIATED(ana_env))
768 cpassert(
ASSOCIATED(ana_env%cell))
769 cpassert(
ASSOCIATED(ana_env%density_3d))
770 cpassert(
ASSOCIATED(ana_env%density_3d%sum_density))
771 cpassert(
ASSOCIATED(ana_env%density_3d%sum_dens2))
774 CALL timeset(routinen, handle)
777 cell_size(:) = 0.0_dp
778 interval_size(:) = 0.0_dp
781 bin_x =
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
782 bin_y =
SIZE(ana_env%density_3d%sum_density(1, :, 1))
783 bin_z =
SIZE(ana_env%density_3d%sum_density(1, 1, :))
784 ALLOCATE (mass_bin(bin_x, bin_y, bin_z))
785 mass_bin(:, :, :) = 0.0_dp
791 abc=cell_size, vol=vol_cell)
793 ana_env%density_3d%sum_vol = ana_env%density_3d%sum_vol + &
794 vol_cell*(au2a)**3*weight
795 ana_env%density_3d%sum_vol2 = ana_env%density_3d%sum_vol2 + &
796 (vol_cell*(au2a)**3)**2*weight
798 ana_env%density_3d%sum_box_length(:) = ana_env%density_3d%sum_box_length(:) &
799 + cell_size(:)*(au2a)*weight
800 ana_env%density_3d%sum_box_length2(:) = ana_env%density_3d%sum_box_length2(:) &
801 + (cell_size(:)*(au2a))**2*weight
804 interval_size(1) = cell_size(1)/real(bin_x,
dp)
805 interval_size(2) = cell_size(2)/real(bin_y,
dp)
806 interval_size(3) = cell_size(3)/real(bin_z,
dp)
809 vol_cell = vol_cell*(au2a*1e-8)**3
810 vol_sub_box = interval_size(1)*interval_size(2)*interval_size(3)* &
814 DO atom = 1,
SIZE(elem%pos), ana_env%dim_per_elem
816 atom_pos(:) = elem%pos(
atom:
atom + 2)
821 atom_pos(:) = atom_pos(:) + 0.5_dp*cell_size(:)
823 bin_x = int(atom_pos(1)/interval_size(1)) + 1
824 bin_y = int(atom_pos(2)/interval_size(2)) + 1
825 bin_z = int(atom_pos(3)/interval_size(3)) + 1
826 cpassert(bin_x > 0 .AND. bin_y > 0 .AND. bin_z > 0)
827 cpassert(bin_x <=
SIZE(ana_env%density_3d%sum_density(:, 1, 1)))
828 cpassert(bin_y <=
SIZE(ana_env%density_3d%sum_density(1, :, 1)))
829 cpassert(bin_z <=
SIZE(ana_env%density_3d%sum_density(1, 1, :)))
832 mass_bin(bin_x, bin_y, bin_z) = mass_bin(bin_x, bin_y, bin_z) + &
834 mass_total = mass_total + &
844 r_tmp = mass_total/vol_cell - sum(mass_bin(:, :, :))/vol_sub_box/
SIZE(mass_bin(:, :, :))
845 cpassert(abs(r_tmp) < 1e-5)
848 ana_env%density_3d%sum_density(:, :, :) = ana_env%density_3d%sum_density(:, :, :) + &
849 weight*mass_bin(:, :, :)/vol_sub_box
852 ana_env%density_3d%sum_dens2(:, :, :) = ana_env%density_3d%sum_dens2(:, :, :) + &
853 weight*(mass_bin(:, :, :)/vol_sub_box)**2
855 ana_env%density_3d%conf_counter = ana_env%density_3d%conf_counter + weight
858 IF (ana_env%density_3d%print_dens)
THEN
864 INQUIRE (file=file_name, exist=flag)
865 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
866 file_action=
"WRITE", file_position=
"APPEND", &
867 unit_number=file_ptr)
869 WRITE (file_ptr, fmt=
'(A8,11A20)')
"# conf_nr",
"dens_act[g/cm^3]", &
870 "dens_average[g/cm^3]",
"density_variance", &
871 "averages:volume",
"box_lenth_x",
"box_lenth_y",
"box_lenth_z", &
872 "variances:volume",
"box_lenth_x",
"box_lenth_y",
"box_lenth_z"
874 WRITE (file_ptr, fmt=
"(I8,11F20.10)") ana_env%density_3d%conf_counter + 1 - weight, &
875 sum(mass_bin(:, :, :))/vol_sub_box/
SIZE(mass_bin(:, :, :)), &
876 sum(ana_env%density_3d%sum_density(:, :, :))/ &
877 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
878 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
879 sum(ana_env%density_3d%sum_dens2(:, :, :))/ &
880 SIZE(ana_env%density_3d%sum_dens2(:, :, :))/ &
881 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
882 (sum(ana_env%density_3d%sum_density(:, :, :))/ &
883 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
884 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2, &
885 ana_env%density_3d%sum_vol/ &
886 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
887 ana_env%density_3d%sum_box_length(:)/ &
888 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
889 ana_env%density_3d%sum_vol2/ &
890 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
891 (ana_env%density_3d%sum_vol/ &
892 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2, &
893 ana_env%density_3d%sum_box_length2(:)/ &
894 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
895 (ana_env%density_3d%sum_box_length(:)/ &
896 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2
900 DEALLOCATE (mass_bin)
902 CALL timestop(handle)
903 END SUBROUTINE calc_density_3d
912 SUBROUTINE print_density_3d(ana_env)
915 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA", &
916 routinen =
'print_density_3d'
918 CHARACTER(LEN=default_path_length) :: file_name, file_name_vari
919 INTEGER :: bin_x, bin_y, bin_z, file_ptr_dens, &
920 file_ptr_vari, handle, i, j, k
921 REAL(kind=
dp),
DIMENSION(3) :: cell_size, interval_size
923 cpassert(
ASSOCIATED(ana_env))
924 cpassert(
ASSOCIATED(ana_env%density_3d))
925 cpassert(
ASSOCIATED(ana_env%density_3d%sum_density))
926 cpassert(
ASSOCIATED(ana_env%density_3d%sum_dens2))
929 CALL timeset(routinen, handle)
934 bin_x =
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
935 bin_y =
SIZE(ana_env%density_3d%sum_density(1, :, 1))
936 bin_z =
SIZE(ana_env%density_3d%sum_density(1, 1, :))
937 CALL get_cell(cell=ana_env%cell, abc=cell_size)
938 interval_size(1) = cell_size(1)/real(bin_x, kind=
dp)*au2a
939 interval_size(2) = cell_size(2)/real(bin_y, kind=
dp)*au2a
940 interval_size(3) = cell_size(3)/real(bin_z, kind=
dp)*au2a
945 CALL open_file(file_name=file_name, file_status=
"REPLACE", &
946 file_action=
"WRITE", file_position=
"APPEND", &
947 unit_number=file_ptr_dens)
948 WRITE (file_ptr_dens, fmt=
'(A,1X,I0,1X,A,3(I0,1X),1X,A,1X,3F10.5)') &
949 "# configurations", ana_env%density_3d%conf_counter,
"bins", &
950 ana_env%density_3d%nr_bins,
"interval size", interval_size(:)
951 WRITE (file_ptr_dens, fmt=
'(A,3A10,A20)')
"#",
" x [A] ",
" y [A] ",
" z [A] ",
" density [g/cm^3] "
954 trim(ana_env%out_file_prefix)// &
957 CALL open_file(file_name=file_name_vari, file_status=
"REPLACE", &
958 file_action=
"WRITE", file_position=
"APPEND", &
959 unit_number=file_ptr_vari)
960 WRITE (file_ptr_vari, fmt=
'(A,1X,I0,1X,A,3(I0,1X),1X,A,1X,3F10.5)') &
961 "# configurations", ana_env%density_3d%conf_counter,
"bins", &
962 ana_env%density_3d%nr_bins,
"interval size", interval_size(:)
963 WRITE (file_ptr_vari, fmt=
'(A,3A10,A20)')
"#",
" x [A] ",
" y [A] ",
" z [A] ",
" variance"
965 DO i = 1,
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
966 DO j = 1,
SIZE(ana_env%density_3d%sum_density(1, :, 1))
967 DO k = 1,
SIZE(ana_env%density_3d%sum_density(1, 1, :))
968 WRITE (file_ptr_dens, fmt=
'(3F10.2,F20.10)') &
969 (i - 0.5_dp)*interval_size(1), (j - 0.5_dp)*interval_size(2), (k - 0.5_dp)*interval_size(3), &
970 ana_env%density_3d%sum_density(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp)
971 WRITE (file_ptr_vari, fmt=
'(3F10.2,F20.10)') &
972 (i - 0.5_dp)*interval_size(1), (j - 0.5_dp)*interval_size(2), (k - 0.5_dp)*interval_size(3), &
973 ana_env%density_3d%sum_dens2(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp) - &
974 (ana_env%density_3d%sum_density(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp))**2
981 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
982 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"density calculation",
"-"
983 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ",
cp_to_string(ana_env%temperature)
984 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations", &
986 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"average volume", &
988 REAL(ana_env%density_3d%conf_counter, kind=
dp))
989 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"average density in the cell: ", &
990 cp_to_string(sum(ana_env%density_3d%sum_density(:, :, :))/ &
991 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
992 REAL(ana_env%density_3d%conf_counter, kind=
dp))
993 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"density variance:", &
994 cp_to_string(sum(ana_env%density_3d%sum_dens2(:, :, :))/ &
995 SIZE(ana_env%density_3d%sum_dens2(:, :, :))/ &
996 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
997 (sum(ana_env%density_3d%sum_density(:, :, :))/ &
998 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
999 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2)
1000 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1001 IF (ana_env%print_test_output)
THEN
1002 WRITE (ana_env%io_unit, *)
"TMC|ANALYSIS_CELL_DENSITY_X= ", &
1003 sum(ana_env%density_3d%sum_density(:, :, :))/ &
1004 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
1005 REAL(ana_env%density_3d%conf_counter, kind=
dp)
1008 CALL timestop(handle)
1009 END SUBROUTINE print_density_3d
1023 SUBROUTINE ana_pair_correl_init(ana_pair_correl, atoms, cell)
1028 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ana_pair_correl_init'
1030 INTEGER :: counter, f_n, handle,
list, list_ind, s_n
1031 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1034 cpassert(
ASSOCIATED(ana_pair_correl))
1035 cpassert(.NOT.
ASSOCIATED(ana_pair_correl%g_r))
1036 cpassert(.NOT.
ASSOCIATED(ana_pair_correl%pairs))
1037 cpassert(
ASSOCIATED(atoms))
1038 cpassert(
SIZE(atoms) > 1)
1039 cpassert(
ASSOCIATED(cell))
1042 CALL timeset(routinen, handle)
1044 CALL get_cell(cell=cell, abc=cell_size)
1045 IF (ana_pair_correl%nr_bins <= 0)
THEN
1046 ana_pair_correl%nr_bins = ceiling(maxval(cell_size(:))/2.0_dp/(0.03/au2a))
1048 ana_pair_correl%step_length = maxval(cell_size(:))/2.0_dp/ &
1049 ana_pair_correl%nr_bins
1050 ana_pair_correl%conf_counter = 0
1054 ALLOCATE (pairs_tmp(
SIZE(atoms)))
1055 DO f_n = 1,
SIZE(atoms)
1056 DO s_n = f_n + 1,
SIZE(atoms)
1059 n2=atoms(s_n)%name, list_end=counter - 1)
1061 IF (list_ind < 0)
THEN
1062 pairs_tmp(counter)%f_n = atoms(f_n)%name
1063 pairs_tmp(counter)%s_n = atoms(s_n)%name
1064 pairs_tmp(counter)%pair_count = 1
1065 counter = counter + 1
1067 pairs_tmp(list_ind)%pair_count = pairs_tmp(list_ind)%pair_count + 1
1072 ALLOCATE (ana_pair_correl%pairs(counter - 1))
1073 DO list = 1, counter - 1
1074 ana_pair_correl%pairs(
list)%f_n = pairs_tmp(
list)%f_n
1075 ana_pair_correl%pairs(
list)%s_n = pairs_tmp(
list)%s_n
1076 ana_pair_correl%pairs(
list)%pair_count = pairs_tmp(
list)%pair_count
1078 DEALLOCATE (pairs_tmp)
1080 ALLOCATE (ana_pair_correl%g_r(
SIZE(ana_pair_correl%pairs(:)), ana_pair_correl%nr_bins))
1081 ana_pair_correl%g_r = 0.0_dp
1083 CALL timestop(handle)
1084 END SUBROUTINE ana_pair_correl_init
1095 SUBROUTINE calc_paircorrelation(elem, weight, atoms, ana_env)
1101 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_paircorrelation'
1103 INTEGER :: handle, i, ind, j, pair_ind
1104 REAL(kind=
dp) :: dist
1105 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1107 cpassert(
ASSOCIATED(elem))
1108 cpassert(
ASSOCIATED(elem%pos))
1109 cpassert(all(elem%box_scale(:) > 0.0_dp))
1110 cpassert(weight > 0)
1111 cpassert(
ASSOCIATED(atoms))
1112 cpassert(
ASSOCIATED(ana_env))
1113 cpassert(
ASSOCIATED(ana_env%cell))
1114 cpassert(
ASSOCIATED(ana_env%pair_correl))
1115 cpassert(
ASSOCIATED(ana_env%pair_correl%g_r))
1116 cpassert(
ASSOCIATED(ana_env%pair_correl%pairs))
1119 CALL timeset(routinen, handle)
1123 first_elem_loop:
DO i = 1,
SIZE(elem%pos), ana_env%dim_per_elem
1124 second_elem_loop:
DO j = i + 3,
SIZE(elem%pos), ana_env%dim_per_elem
1126 x2=elem%pos(j:j + ana_env%dim_per_elem - 1), &
1127 cell=ana_env%cell, box_scale=elem%box_scale)
1128 ind = ceiling(dist/ana_env%pair_correl%step_length)
1129 IF (ind <= ana_env%pair_correl%nr_bins)
THEN
1131 n1=atoms(int(i/real(ana_env%dim_per_elem, kind=
dp)) + 1)%name, &
1132 n2=atoms(int(j/real(ana_env%dim_per_elem, kind=
dp)) + 1)%name)
1133 cpassert(pair_ind > 0)
1134 ana_env%pair_correl%g_r(pair_ind, ind) = &
1135 ana_env%pair_correl%g_r(pair_ind, ind) + weight
1137 END DO second_elem_loop
1138 END DO first_elem_loop
1139 ana_env%pair_correl%conf_counter = ana_env%pair_correl%conf_counter + weight
1140 CALL get_cell(cell=ana_env%cell, abc=cell_size)
1141 ana_env%pair_correl%sum_box_scale = ana_env%pair_correl%sum_box_scale + &
1142 (elem%box_scale(:)*weight)
1144 CALL timestop(handle)
1145 END SUBROUTINE calc_paircorrelation
1153 SUBROUTINE print_paircorrelation(ana_env)
1156 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_paircorrelation'
1158 CHARACTER(LEN=default_path_length) :: file_name
1159 INTEGER :: bin, file_ptr, handle, pair
1160 REAL(kind=
dp) :: aver_box_scale(3), vol, voldr
1161 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1163 cpassert(
ASSOCIATED(ana_env))
1164 cpassert(
ASSOCIATED(ana_env%pair_correl))
1167 CALL timeset(routinen, handle)
1169 CALL get_cell(cell=ana_env%cell, abc=cell_size)
1170 aver_box_scale(:) = ana_env%pair_correl%sum_box_scale(:)/ana_env%pair_correl%conf_counter
1171 vol = (cell_size(1)*aver_box_scale(1))* &
1172 (cell_size(2)*aver_box_scale(2))* &
1173 (cell_size(3)*aver_box_scale(3))
1175 DO pair = 1,
SIZE(ana_env%pair_correl%pairs)
1178 ana_env%temperature)
1181 ana_env%pair_correl%pairs(pair)%f_n), &
1182 ana_env%pair_correl%pairs(pair)%s_n), &
1183 file_status=
"REPLACE", &
1184 file_action=
"WRITE", file_position=
"APPEND", &
1185 unit_number=file_ptr)
1186 WRITE (file_ptr, *)
"# radial distribution function of "// &
1187 trim(ana_env%pair_correl%pairs(pair)%f_n)//
" and "// &
1188 trim(ana_env%pair_correl%pairs(pair)%s_n)//
" of ", &
1189 ana_env%pair_correl%conf_counter,
" configurations"
1190 WRITE (file_ptr, *)
"# using a bin size of ", &
1191 ana_env%pair_correl%step_length*au2a, &
1192 "[A] (for Vol changes: referring to the reference cell)"
1193 DO bin = 1, ana_env%pair_correl%nr_bins
1194 voldr = 4.0/3.0*
pi*ana_env%pair_correl%step_length**3* &
1195 (real(bin, kind=
dp)**3 - real(bin - 1, kind=
dp)**3)
1196 WRITE (file_ptr, *) (bin - 0.5)*ana_env%pair_correl%step_length*au2a, &
1197 (ana_env%pair_correl%g_r(pair, bin)/ana_env%pair_correl%conf_counter)/ &
1198 (voldr*ana_env%pair_correl%pairs(pair)%pair_count/vol)
1202 IF (ana_env%print_test_output)
THEN
1203 WRITE (*, *)
"TMC|ANALYSIS_G_R_"// &
1204 trim(ana_env%pair_correl%pairs(pair)%f_n)//
"_"// &
1205 trim(ana_env%pair_correl%pairs(pair)%s_n)//
"_X= ", &
1206 sum(ana_env%pair_correl%g_r(pair, :)/ana_env%pair_correl%conf_counter/ &
1207 voldr*ana_env%pair_correl%pairs(pair)%pair_count/vol)
1212 CALL timestop(handle)
1213 END SUBROUTINE print_paircorrelation
1226 SUBROUTINE ana_dipole_moment_init(ana_dip_mom, atoms)
1230 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ana_dipole_moment_init'
1232 INTEGER ::
atom, charge, handle
1234 cpassert(
ASSOCIATED(ana_dip_mom))
1235 cpassert(
ASSOCIATED(ana_dip_mom%charges_inp))
1236 cpassert(
ASSOCIATED(atoms))
1239 CALL timeset(routinen, handle)
1241 ALLOCATE (ana_dip_mom%charges(
SIZE(atoms)))
1242 ana_dip_mom%charges = 0.0_dp
1244 DO atom = 1,
SIZE(atoms)
1245 charge_loop:
DO charge = 1,
SIZE(ana_dip_mom%charges_inp)
1246 IF (atoms(
atom)%name == ana_dip_mom%charges_inp(charge)%name)
THEN
1247 ana_dip_mom%charges(
atom) = ana_dip_mom%charges_inp(charge)%mass
1253 DEALLOCATE (ana_dip_mom%charges_inp)
1255 CALL timestop(handle)
1256 END SUBROUTINE ana_dipole_moment_init
1266 SUBROUTINE calc_dipole_moment(elem, weight, ana_env)
1271 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_dipole_moment'
1273 CHARACTER(LEN=default_path_length) :: file_name
1274 INTEGER :: handle, i
1275 REAL(kind=
dp),
DIMENSION(:),
POINTER :: dip_cl
1277 cpassert(
ASSOCIATED(elem))
1278 cpassert(
ASSOCIATED(elem%pos))
1279 cpassert(
ASSOCIATED(ana_env))
1280 cpassert(
ASSOCIATED(ana_env%dip_mom))
1281 cpassert(
ASSOCIATED(ana_env%dip_mom%charges))
1284 CALL timeset(routinen, handle)
1286 ALLOCATE (dip_cl(ana_env%dim_per_elem))
1289 DO i = 1,
SIZE(elem%pos, 1), ana_env%dim_per_elem
1290 dip_cl(:) = dip_cl(:) + elem%pos(i:i + ana_env%dim_per_elem - 1)* &
1291 ana_env%dip_mom%charges(int(i/real(ana_env%dim_per_elem, kind=
dp)) + 1)
1295 IF (.NOT.
ASSOCIATED(elem%dipole))
THEN
1296 ALLOCATE (elem%dipole(ana_env%dim_per_elem))
1297 elem%dipole(:) = dip_cl(:)
1300 IF (ana_env%dip_mom%print_cl_dip)
THEN
1302 ana_env%temperature)
1304 conf_nr=ana_env%dip_mom%conf_counter + 1, dip=dip_cl, &
1307 ana_env%dip_mom%conf_counter = ana_env%dip_mom%conf_counter + weight
1308 ana_env%dip_mom%last_dip_cl(:) = dip_cl
1313 CALL timestop(handle)
1314 END SUBROUTINE calc_dipole_moment
1322 SUBROUTINE print_dipole_moment(ana_env)
1325 IF (ana_env%print_test_output)
THEN
1326 WRITE (*, *)
"TMC|ANALYSIS_FINAL_CLASS_CELL_DIPOLE_MOMENT_X= ", &
1327 ana_env%dip_mom%last_dip_cl(:)
1329 END SUBROUTINE print_dipole_moment
1339 SUBROUTINE calc_dipole_analysis(elem, weight, ana_env)
1344 REAL(kind=
dp) :: vol, weight_act
1345 REAL(kind=
dp),
DIMENSION(3, 3) :: tmp_dip
1348 NULLIFY (scaled_cell)
1350 cpassert(
ASSOCIATED(elem))
1351 cpassert(
ASSOCIATED(elem%dipole))
1352 cpassert(
ASSOCIATED(ana_env))
1353 cpassert(
ASSOCIATED(ana_env%dip_ana))
1357 weight_act = weight_act/real(8.0, kind=
dp)
1361 ALLOCATE (scaled_cell)
1362 CALL get_scaled_cell(cell=ana_env%cell, box_scale=elem%box_scale, vol=vol, &
1363 scaled_cell=scaled_cell)
1366 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
1367 IF (all(ana_env%dip_mom%last_dip_cl /= elem%dipole))
THEN
1368 elem%dipole =
pbc(r=elem%dipole(:) - ana_env%dip_mom%last_dip_cl, &
1369 cell=scaled_cell) + ana_env%dip_mom%last_dip_cl
1373 ana_env%dip_ana%conf_counter = ana_env%dip_ana%conf_counter + weight_act
1376 ana_env%dip_ana%mu2_pv_s = ana_env%dip_ana%mu2_pv_s + &
1377 dot_product(elem%dipole(:), elem%dipole(:))/vol*weight_act
1379 tmp_dip(:, :) = 0.0_dp
1380 tmp_dip(:, 1) = elem%dipole(:)
1383 ana_env%dip_ana%mu_pv(:) = ana_env%dip_ana%mu_pv(:) + &
1384 tmp_dip(:, 1)/vol*weight_act
1387 ana_env%dip_ana%mu_psv(:) = ana_env%dip_ana%mu_psv(:) + &
1388 tmp_dip(:, 1)/sqrt(vol)*weight_act
1391 ana_env%dip_ana%mu2_pv(:) = ana_env%dip_ana%mu2_pv(:) + &
1392 tmp_dip(:, 1)**2/vol*weight_act
1395 tmp_dip(:, :) = matmul(tmp_dip(:, :), transpose(tmp_dip(:, :)))
1396 ana_env%dip_ana%mu2_pv_mat(:, :) = ana_env%dip_ana%mu2_pv_mat(:, :) + &
1397 tmp_dip(:, :)/vol*weight_act
1399 END SUBROUTINE calc_dipole_analysis
1408 SUBROUTINE print_act_dipole_analysis(elem, ana_env)
1412 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
1413 INTEGER :: counter_tmp, file_ptr
1415 REAL(kind=
dp) :: diel_const, diel_const_norm, &
1416 diel_const_sym, e0, kb
1417 REAL(kind=
dp),
DIMENSION(3, 3) :: tmp_dip
1420 counter_tmp = int(ana_env%dip_ana%conf_counter)
1423 e0 = 0.07957747154594767_dp
1424 diel_const_norm = 1/(3.0_dp*e0*kb*ana_env%temperature)
1428 ana_env%temperature)
1430 conf_nr=int(ana_env%dip_ana%conf_counter) + 1, dip=elem%dipole, &
1431 file_ext=
"dip_folded")
1436 ana_env%temperature)
1438 SELECT CASE (ana_env%dip_ana%ana_type)
1443 "diel_const_tensor"))
1448 "diel_const_tensor_sym"))
1450 cpwarn(
'unknown analysis type "'//
cp_to_string(ana_env%dip_ana%ana_type)//
'" used.')
1455 diel_const = 1.0_dp + (ana_env%dip_ana%mu2_pv_s/(ana_env%dip_ana%conf_counter) - &
1456 dot_product(ana_env%dip_ana%mu_psv(:)/(ana_env%dip_ana%conf_counter), &
1457 ana_env%dip_ana%mu_psv(:)/(ana_env%dip_ana%conf_counter)))* &
1461 diel_const_sym = 1.0_dp + ana_env%dip_ana%mu2_pv_s/(ana_env%dip_ana%conf_counter)* &
1465 INQUIRE (file=file_name, exist=flag)
1466 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
1467 file_action=
"WRITE", file_position=
"APPEND", &
1468 unit_number=file_ptr)
1469 IF (.NOT. flag)
THEN
1470 WRITE (file_ptr, fmt=
'(A8,5A20)')
"# conf",
"diel_const", &
1471 "diel_const_sym",
"diel_const_sym_x", &
1472 "diel_const_sym_y",
"diel_const_sym_z"
1474 WRITE (file_ptr, fmt=
"(I8,10F20.10)") counter_tmp, diel_const, &
1476 4.0_dp*
pi/(kb*ana_env%temperature)* &
1477 ana_env%dip_ana%mu2_pv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1481 INQUIRE (file=file_name_tmp, exist=flag)
1482 CALL open_file(file_name=file_name_tmp, file_status=
"UNKNOWN", &
1483 file_action=
"WRITE", file_position=
"APPEND", &
1484 unit_number=file_ptr)
1485 IF (.NOT. flag)
THEN
1486 WRITE (file_ptr, fmt=
'(A8,9A20)')
"# conf",
"xx",
"xy",
"xz", &
1490 tmp_dip(:, :) = 0.0_dp
1491 tmp_dip(:, 1) = ana_env%dip_ana%mu_psv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1493 WRITE (file_ptr, fmt=
"(I8,10F20.10)") counter_tmp, &
1494 4.0_dp*
pi/(kb*ana_env%temperature)* &
1495 (ana_env%dip_ana%mu2_pv_mat(:, :)/real(ana_env%dip_ana%conf_counter, kind=
dp) - &
1496 matmul(tmp_dip(:, :), transpose(tmp_dip(:, :))))
1498 END SUBROUTINE print_act_dipole_analysis
1506 SUBROUTINE print_dipole_analysis(ana_env)
1509 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA"
1512 REAL(kind=
dp) :: diel_const_scalar, kb
1513 REAL(kind=
dp),
DIMENSION(3) :: diel_const_sym, dielec_ev
1514 REAL(kind=
dp),
DIMENSION(3, 3) :: diel_const, tmp_dip, tmp_ev
1518 cpassert(
ASSOCIATED(ana_env))
1519 cpassert(
ASSOCIATED(ana_env%dip_ana))
1521 tmp_dip(:, :) = 0.0_dp
1522 diel_const(:, :) = 0.0_dp
1523 diel_const_scalar = 0.0_dp
1524 diel_const_sym = 0.0_dp
1527 tmp_dip(:, 1) = ana_env%dip_ana%mu_psv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1528 diel_const(:, :) = 4.0_dp*
pi/(kb*ana_env%temperature)* &
1529 (ana_env%dip_ana%mu2_pv_mat(:, :)/real(ana_env%dip_ana%conf_counter, kind=
dp) - &
1530 matmul(tmp_dip(:, :), transpose(tmp_dip(:, :))))
1533 diel_const_sym(:) = 4.0_dp*
pi/(kb*ana_env%temperature)* &
1534 ana_env%dip_ana%mu2_pv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1537 diel_const(i, i) = diel_const(i, i) + 1.0_dp
1538 diel_const_scalar = diel_const_scalar + diel_const(i, i)
1540 diel_const_scalar = diel_const_scalar/real(3, kind=
dp)
1542 tmp_dip(:, :) = diel_const
1543 CALL diag(3, tmp_dip, dielec_ev, tmp_ev)
1546 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1547 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"average dipoles",
"-"
1548 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ",
cp_to_string(ana_env%temperature)
1549 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations ", &
1552 WRITE (ana_env%io_unit, fmt=
'(T2,A,"| ",A)') plabel, &
1553 "ice analysis with directions of hexagonal structure"
1556 WRITE (ana_env%io_unit, fmt=
'(T2,A,"| ",A)') plabel, &
1557 "ice analysis with symmetrized dipoles in each direction."
1560 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"for product of 2 directions(per vol):"
1562 WRITE (ana_env%io_unit,
'(A,3F16.8,A)')
" |", ana_env%dip_ana%mu2_pv_mat(i, :)/ &
1563 REAL(ana_env%dip_ana%conf_counter, kind=
dp),
" |"
1566 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant tensor:"
1568 WRITE (ana_env%io_unit,
'(A,3F16.8,A)')
" |", diel_const(i, :),
" |"
1571 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric tensor eigenvalues", &
1575 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant symm ", &
1579 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant ", &
1581 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1583 END SUBROUTINE print_dipole_analysis
1596 SUBROUTINE calc_displacement(elem, ana_env)
1600 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_displacement'
1602 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
1603 INTEGER :: file_ptr, handle, ind
1605 REAL(kind=
dp) :: disp
1606 REAL(kind=
dp),
DIMENSION(3) :: atom_disp
1610 cpassert(
ASSOCIATED(elem))
1611 cpassert(
ASSOCIATED(elem%pos))
1612 cpassert(
ASSOCIATED(ana_env))
1613 cpassert(
ASSOCIATED(ana_env%displace))
1614 cpassert(
ASSOCIATED(ana_env%last_elem))
1617 CALL timeset(routinen, handle)
1619 DO ind = 1,
SIZE(elem%pos), ana_env%dim_per_elem
1621 atom_disp(:) = elem%pos(ind:ind + 2) - ana_env%last_elem%pos(ind:ind + 2)
1624 disp = disp + sum((atom_disp(:)*au2a)**2)
1626 ana_env%displace%disp = ana_env%displace%disp + disp
1627 ana_env%displace%conf_counter = ana_env%displace%conf_counter + 1
1629 IF (ana_env%displace%print_disp)
THEN
1632 ana_env%temperature)
1635 INQUIRE (file=file_name, exist=flag)
1636 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
1637 file_action=
"WRITE", file_position=
"APPEND", &
1638 unit_number=file_ptr)
1639 IF (.NOT. flag)
THEN
1640 WRITE (file_ptr, *)
"# conf squared deviation of the cell"
1642 WRITE (file_ptr, *) elem%nr, disp
1647 CALL timestop(handle)
1649 END SUBROUTINE calc_displacement
1657 SUBROUTINE print_average_displacement(ana_env)
1660 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA"
1662 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1663 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"average displacement",
"-"
1664 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ", &
1666 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations ", &
1668 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"cell root mean square deviation: ", &
1670 REAL(ana_env%displace%conf_counter, kind=
dp)))
1671 IF (ana_env%print_test_output)
THEN
1672 WRITE (*, *)
"TMC|ANALYSIS_AVERAGE_CELL_DISPLACEMENT_X= ", &
1673 sqrt(ana_env%displace%disp/ &
1674 REAL(ana_env%displace%conf_counter, kind=
dp))
1676 END SUBROUTINE print_average_displacement
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 ...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Collection of simple mathematical functions and subroutines.
subroutine, public diag(n, a, d, v)
Diagonalize matrix a. The eigenvalues are returned in vector d and the eigenvectors are returned in m...
Definition of physical constants:
real(kind=dp), parameter, public boltzmann
real(kind=dp), parameter, public a_mass
real(kind=dp), parameter, public joule
real(kind=dp), parameter, public angstrom
real(kind=dp), parameter, public massunit
module provides variables for the TMC analysis tool
integer function, public search_pair_in_list(pair_list, n1, n2, list_end)
search the pair of two atom types in list
subroutine, public tmc_ana_displacement_create(ana_disp, dim_per_elem)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_dipole_analysis_create(ana_dip_ana)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_dipole_moment_create(ana_dip_mom, charge_atm, charge, dim_per_elem)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_env_create(tmc_ana)
creates a new structure environment for TMC analysis
integer, parameter, public ana_type_default
integer, parameter, public ana_type_ice
character(len=default_path_length), parameter, public tmc_ana_pair_correl_file_name
character(len=default_path_length), parameter, public tmc_ana_density_file_name
integer, parameter, public ana_type_sym_xyz
subroutine, public tmc_ana_density_create(ana_dens, nr_bins)
creates a new structure environment for TMC analysis
subroutine, public tmc_ana_pair_correl_create(ana_pair_correl, nr_bins)
creates a new structure environment for TMC analysis
module analyses element of the TMC tree element structure e.g. density, radial distribution function,...
subroutine, public analysis_restart_read(ana_env, elem)
read analysis restart file
subroutine, public finalize_tmc_analysis(ana_env)
call all the necessarry analysis printing routines
subroutine, public tmc_read_ana_input(tmc_ana_section, tmc_ana)
creates a new para environment for tmc analysis
subroutine, public analyze_file_configurations(start_id, end_id, dir_ind, ana_env, tmc_params)
read the files and analyze the configurations
subroutine, public analysis_init(ana_env, nr_dim)
initialize all the necessarry analysis structures
subroutine, public do_tmc_analysis(elem, ana_env)
call all the necessarry analysis routines analysis the previous element with the weight of the differ...
subroutine, public analysis_restart_print(ana_env)
print analysis restart file
calculation section for TreeMonteCarlo
subroutine, public get_scaled_cell(cell, box_scale, scaled_hmat, scaled_cell, vol, abc, vec)
handles properties and calculations of a scaled cell
real(kind=dp) function, public nearest_distance(x1, x2, cell, box_scale)
neares distance of atoms within the periodic boundary condition
writing and printing the files, trajectory (pos, cell, dipoles) as well as restart files
subroutine, public analyse_files_close(tmc_ana)
close the files for reading configurations data to analyze
subroutine, public write_dipoles_in_file(file_name, conf_nr, dip, file_ext)
writes the cell dipoles in dipole trajectory file
subroutine, public read_element_from_file(elem, tmc_ana, conf_nr, stat)
read the trajectory element from a file from sub tree element
subroutine, public analyse_files_open(tmc_ana, stat, dir_ind)
opens the files for reading configurations data to analyze
character(len=default_path_length) function, public expand_file_name_char(file_name, extra)
placing a character string at the end of a file name (before the file extension)
character(len=default_path_length) function, public expand_file_name_temp(file_name, rvalue)
placing the temperature at the end of a file name (before the file extension)
tree nodes creation, searching, deallocation, references etc.
character(len= *), parameter, public tmc_default_trajectory_file_name
character(len= *), parameter, public tmc_default_unspecified_name
integer, parameter, public tmc_status_wait_for_new_task
character(len= *), parameter, public tmc_default_restart_in_file_name
character(len= *), parameter, public tmc_default_restart_out_file_name
integer, parameter, public tmc_status_ok
tree nodes creation, deallocation, references etc.
subroutine, public deallocate_sub_tree_node(tree_elem)
deallocates an elements of the subtree element structure
subroutine, public allocate_new_sub_tree_node(tmc_params, next_el, nr_dim)
allocates an elements of the subtree element structure
module handles definition of the tree nodes for the global and the subtrees binary tree parent elemen...
subroutine, public read_subtree_elem_unformated(elem, io_unit)
reads the TMC sub tree structure element unformated in file
subroutine, public write_subtree_elem_unformated(elem, io_unit)
prints out the TMC sub tree structure element unformated in file
module handles definition of the tree nodes for the global and the subtrees binary tree parent elemen...
Type defining parameters related to the simulation cell.