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 .NE.
"")
THEN
112 tmc_ana%out_file_prefix = trim(tmc_ana%out_file_prefix)//
"_"
117 IF (explicit_key)
THEN
120 IF (
SIZE(i_arr_tmp(:)) .EQ. 3)
THEN
121 IF (any(i_arr_tmp(:) .LE. 0)) &
122 CALL cp_abort(__location__,
"The amount of intervals in each "// &
123 "direction has to be greater than 0.")
124 nr_bins(:) = i_arr_tmp(:)
125 ELSE IF (
SIZE(i_arr_tmp(:)) .EQ. 1)
THEN
126 IF (any(i_arr_tmp(:) .LE. 0)) &
127 cpabort(
"The amount of intervals has to be greater than 0.")
128 nr_bins(:) = i_arr_tmp(1)
129 ELSE IF (
SIZE(i_arr_tmp(:)) .EQ. 0)
THEN
132 cpabort(
"unknown amount of dimensions for the binning.")
139 IF (explicit_key)
THEN
147 IF (explicit_key)
THEN
153 ALLOCATE (charge_atm(i_tmp))
154 ALLOCATE (charge(i_tmp))
157 CALL cp_abort(__location__, &
158 "to calculate the classical cell dipole moment "// &
159 "the charges has to be specified")
163 tmc_ana%dim_per_elem)
165 IF (
ASSOCIATED(charge_atm))
DEALLOCATE (charge_atm)
166 IF (
ASSOCIATED(charge))
DEALLOCATE (charge)
171 IF (explicit_key)
THEN
174 SELECT CASE (trim(c_tmp))
182 cpwarn(
'unknown analysis type "'//trim(c_tmp)//
'" specified. Set to default.')
193 dim_per_elem=tmc_ana%dim_per_elem)
207 CHARACTER(LEN=default_path_length) :: tmp_cell_file, tmp_dip_file, tmp_pos_file
209 cpassert(
ASSOCIATED(ana_env))
212 ana_env%nr_dim = nr_dim
215 tmp_pos_file = ana_env%costum_pos_file_name
216 tmp_cell_file = ana_env%costum_cell_file_name
217 tmp_dip_file = ana_env%costum_dip_file_name
226 IF (
ASSOCIATED(ana_env%density_3d))
THEN
227 ana_env%costum_pos_file_name = tmp_pos_file
228 ana_env%costum_cell_file_name = tmp_cell_file
231 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
232 ana_env%costum_pos_file_name = tmp_pos_file
233 ana_env%costum_cell_file_name = tmp_cell_file
236 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
237 ana_env%costum_pos_file_name = tmp_pos_file
238 ana_env%costum_cell_file_name = tmp_cell_file
241 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
242 ana_env%costum_pos_file_name = tmp_pos_file
243 ana_env%costum_cell_file_name = tmp_cell_file
244 ana_env%costum_dip_file_name = tmp_dip_file
247 IF (
ASSOCIATED(ana_env%displace))
THEN
248 ana_env%costum_pos_file_name = tmp_pos_file
249 ana_env%costum_cell_file_name = tmp_cell_file
253 IF (
ASSOCIATED(ana_env%pair_correl)) &
254 CALL ana_pair_correl_init(ana_pair_correl=ana_env%pair_correl, &
255 atoms=ana_env%atoms, cell=ana_env%cell)
257 IF (
ASSOCIATED(ana_env%dip_mom)) &
258 CALL ana_dipole_moment_init(ana_dip_mom=ana_env%dip_mom, &
271 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp, &
276 cpassert(
ASSOCIATED(ana_env))
277 cpassert(
ASSOCIATED(ana_env%last_elem))
278 IF (.NOT. ana_env%restart)
RETURN
280 WRITE (file_name, fmt=
'(I9.9)') ana_env%last_elem%nr
282 trim(ana_env%out_file_prefix)// &
284 "ana"), ana_env%temperature))
287 CALL open_file(file_name=restart_file_name, file_status=
"REPLACE", &
288 file_action=
"WRITE", file_form=
"UNFORMATTED", &
289 unit_number=file_ptr)
290 WRITE (file_ptr) ana_env%temperature
295 l_tmp =
ASSOCIATED(ana_env%density_3d)
296 WRITE (file_ptr) l_tmp
298 WRITE (file_ptr) ana_env%density_3d%conf_counter, &
299 ana_env%density_3d%nr_bins, &
300 ana_env%density_3d%sum_vol, &
301 ana_env%density_3d%sum_vol2, &
302 ana_env%density_3d%sum_box_length, &
303 ana_env%density_3d%sum_box_length2, &
304 ana_env%density_3d%sum_density, &
305 ana_env%density_3d%sum_dens2
308 l_tmp =
ASSOCIATED(ana_env%pair_correl)
309 WRITE (file_ptr) l_tmp
311 WRITE (file_ptr) ana_env%pair_correl%conf_counter, &
312 ana_env%pair_correl%nr_bins, &
313 ana_env%pair_correl%step_length, &
314 ana_env%pair_correl%pairs, &
315 ana_env%pair_correl%g_r
318 l_tmp =
ASSOCIATED(ana_env%dip_mom)
319 WRITE (file_ptr) l_tmp
321 WRITE (file_ptr) ana_env%dip_mom%conf_counter, &
322 ana_env%dip_mom%charges, &
323 ana_env%dip_mom%last_dip_cl
326 l_tmp =
ASSOCIATED(ana_env%dip_ana)
327 WRITE (file_ptr) l_tmp
329 WRITE (file_ptr) ana_env%dip_ana%conf_counter, &
330 ana_env%dip_ana%ana_type, &
331 ana_env%dip_ana%mu2_pv_s, &
332 ana_env%dip_ana%mu_psv, &
333 ana_env%dip_ana%mu_pv, &
334 ana_env%dip_ana%mu2_pv_mat, &
335 ana_env%dip_ana%mu2_pv_mat
338 l_tmp =
ASSOCIATED(ana_env%displace)
339 WRITE (file_ptr) l_tmp
341 WRITE (file_ptr) ana_env%displace%conf_counter, &
342 ana_env%displace%disp
352 file_action=
"WRITE", file_status=
"REPLACE", &
353 unit_number=file_ptr)
354 WRITE (file_ptr, *) trim(restart_file_name)
369 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
372 REAL(kind=
dp) :: temp
374 cpassert(
ASSOCIATED(ana_env))
375 cpassert(
ASSOCIATED(elem))
376 IF (.NOT. ana_env%restart)
RETURN
382 INQUIRE (file=file_name, exist=l_tmp)
384 CALL open_file(file_name=file_name, file_status=
"OLD", &
385 file_action=
"READ", unit_number=file_ptr)
386 READ (file_ptr, *) file_name_tmp
389 CALL open_file(file_name=file_name_tmp, file_status=
"OLD", file_form=
"UNFORMATTED", &
390 file_action=
"READ", unit_number=file_ptr)
392 cpassert(ana_env%temperature .EQ. temp)
393 ana_env%last_elem => elem
398 READ (file_ptr) l_tmp
399 cpassert(
ASSOCIATED(ana_env%density_3d) .EQV. l_tmp)
401 READ (file_ptr) ana_env%density_3d%conf_counter, &
402 ana_env%density_3d%nr_bins, &
403 ana_env%density_3d%sum_vol, &
404 ana_env%density_3d%sum_vol2, &
405 ana_env%density_3d%sum_box_length, &
406 ana_env%density_3d%sum_box_length2, &
407 ana_env%density_3d%sum_density, &
408 ana_env%density_3d%sum_dens2
411 READ (file_ptr) l_tmp
412 cpassert(
ASSOCIATED(ana_env%pair_correl) .EQV. l_tmp)
414 READ (file_ptr) ana_env%pair_correl%conf_counter, &
415 ana_env%pair_correl%nr_bins, &
416 ana_env%pair_correl%step_length, &
417 ana_env%pair_correl%pairs, &
418 ana_env%pair_correl%g_r
421 READ (file_ptr) l_tmp
422 cpassert(
ASSOCIATED(ana_env%dip_mom) .EQV. l_tmp)
424 READ (file_ptr) ana_env%dip_mom%conf_counter, &
425 ana_env%dip_mom%charges, &
426 ana_env%dip_mom%last_dip_cl
429 READ (file_ptr) l_tmp
430 cpassert(
ASSOCIATED(ana_env%dip_ana) .EQV. l_tmp)
432 READ (file_ptr) ana_env%dip_ana%conf_counter, &
433 ana_env%dip_ana%ana_type, &
434 ana_env%dip_ana%mu2_pv_s, &
435 ana_env%dip_ana%mu_psv, &
436 ana_env%dip_ana%mu_pv, &
437 ana_env%dip_ana%mu2_pv_mat, &
438 ana_env%dip_ana%mu2_pv_mat
441 READ (file_ptr) l_tmp
442 cpassert(
ASSOCIATED(ana_env%displace) .EQV. l_tmp)
444 READ (file_ptr) ana_env%displace%conf_counter, &
445 ana_env%displace%disp
468 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_tmc_analysis'
470 INTEGER :: handle, weight_act
471 REAL(kind=
dp),
DIMENSION(3) :: dip_tmp
474 cpassert(
ASSOCIATED(elem))
475 cpassert(
ASSOCIATED(ana_env))
478 CALL timeset(routinen, handle)
481 IF (
ASSOCIATED(ana_env%last_elem))
THEN
482 weight_act = elem%nr - ana_env%last_elem%nr
485 IF (weight_act .GT. 0)
THEN
487 IF (
ASSOCIATED(ana_env%density_3d)) &
488 CALL calc_density_3d(elem=ana_env%last_elem, &
489 weight=weight_act, atoms=ana_env%atoms, &
492 IF (
ASSOCIATED(ana_env%pair_correl)) &
493 CALL calc_paircorrelation(elem=ana_env%last_elem, weight=weight_act, &
494 atoms=ana_env%atoms, ana_env=ana_env)
496 IF (
ASSOCIATED(ana_env%dip_mom)) &
497 CALL calc_dipole_moment(elem=ana_env%last_elem, weight=weight_act, &
500 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
505 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
506 dip_tmp(:) = ana_env%last_elem%dipole(:)
507 IF (
ASSOCIATED(ana_env%dip_mom)) &
508 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
509 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
512 ana_env%last_elem%dipole(:) = dip_tmp(:)
513 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
514 dip_tmp(:) = ana_env%last_elem%dipole(:)
515 IF (
ASSOCIATED(ana_env%dip_mom)) &
516 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
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(3) = -ana_env%last_elem%dipole(3)
522 dip_tmp(:) = ana_env%last_elem%dipole(:)
523 IF (
ASSOCIATED(ana_env%dip_mom)) &
524 ana_env%dip_mom%last_dip_cl(3) = -ana_env%dip_mom%last_dip_cl(3)
525 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
528 ana_env%last_elem%dipole(:) = dip_tmp(:)
529 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
530 dip_tmp(:) = ana_env%last_elem%dipole(:)
531 IF (
ASSOCIATED(ana_env%dip_mom)) &
532 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
533 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
536 ana_env%last_elem%dipole(:) = dip_tmp(:)
537 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
538 dip_tmp(:) = ana_env%last_elem%dipole(:)
539 IF (
ASSOCIATED(ana_env%dip_mom)) &
540 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
541 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
544 ana_env%last_elem%dipole(:) = dip_tmp(:)
545 ana_env%last_elem%dipole(1) = -ana_env%last_elem%dipole(1)
546 dip_tmp(:) = ana_env%last_elem%dipole(:)
547 IF (
ASSOCIATED(ana_env%dip_mom)) &
548 ana_env%dip_mom%last_dip_cl(1) = -ana_env%dip_mom%last_dip_cl(1)
549 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
552 ana_env%last_elem%dipole(:) = dip_tmp(:)
553 ana_env%last_elem%dipole(:) = -ana_env%last_elem%dipole(:)
554 dip_tmp(:) = ana_env%last_elem%dipole(:)
555 IF (
ASSOCIATED(ana_env%dip_mom)) &
556 ana_env%dip_mom%last_dip_cl(:) = -ana_env%dip_mom%last_dip_cl(:)
557 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
560 ana_env%last_elem%dipole(:) = dip_tmp(:)
561 ana_env%last_elem%dipole(2) = -ana_env%last_elem%dipole(2)
562 dip_tmp(:) = ana_env%last_elem%dipole(:)
563 IF (
ASSOCIATED(ana_env%dip_mom)) &
564 ana_env%dip_mom%last_dip_cl(2) = -ana_env%dip_mom%last_dip_cl(2)
566 CALL calc_dipole_analysis(elem=ana_env%last_elem, weight=weight_act, &
568 CALL print_act_dipole_analysis(elem=ana_env%last_elem, &
573 IF (
ASSOCIATED(ana_env%displace))
THEN
574 CALL calc_displacement(elem=elem, ana_env=ana_env)
578 elem_tmp => ana_env%last_elem
579 ana_env%last_elem => elem
582 CALL timestop(handle)
594 CHARACTER(LEN=*),
PARAMETER :: routinen =
'finalize_tmc_analysis'
598 cpassert(
ASSOCIATED(ana_env))
601 CALL timeset(routinen, handle)
602 IF (
ASSOCIATED(ana_env%density_3d))
THEN
603 IF (ana_env%density_3d%conf_counter .GT. 0) &
604 CALL print_density_3d(ana_env=ana_env)
606 IF (
ASSOCIATED(ana_env%pair_correl))
THEN
607 IF (ana_env%pair_correl%conf_counter .GT. 0) &
608 CALL print_paircorrelation(ana_env=ana_env)
610 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
611 IF (ana_env%dip_mom%conf_counter .GT. 0) &
612 CALL print_dipole_moment(ana_env)
614 IF (
ASSOCIATED(ana_env%dip_ana))
THEN
615 IF (ana_env%dip_ana%conf_counter .GT. 0) &
616 CALL print_dipole_analysis(ana_env)
618 IF (
ASSOCIATED(ana_env%displace))
THEN
619 IF (ana_env%displace%conf_counter .GT. 0) &
620 CALL print_average_displacement(ana_env)
624 CALL timestop(handle)
638 INTEGER :: start_id, end_id
639 INTEGER,
OPTIONAL :: dir_ind
643 CHARACTER(LEN=*),
PARAMETER :: routinen =
'analyze_file_configurations'
645 INTEGER :: conf_nr, handle, nr_dim, stat
651 cpassert(
ASSOCIATED(ana_env))
652 cpassert(
ASSOCIATED(tmc_params))
655 CALL timeset(routinen, handle)
660 IF (ana_env%id_dip .GT. 0)
THEN
661 tmc_params%print_dipole = .true.
663 tmc_params%print_dipole = .false.
668 nr_dim=ana_env%nr_dim)
670 IF (
ASSOCIATED(ana_env%last_elem)) conf_nr = ana_env%last_elem%nr
671 nr_dim =
SIZE(elem%pos)
682 IF (start_id .LT. 0 .OR. conf_nr .GE. start_id)
THEN
683 IF (end_id .LT. 0 .OR. conf_nr .LE. end_id)
THEN
690 IF (
ASSOCIATED(elem))
THEN
694 IF (.NOT.
ASSOCIATED(elem)) &
702 IF (
ASSOCIATED(elem)) &
706 CALL timestop(handle)
723 SUBROUTINE calc_density_3d(elem, weight, atoms, ana_env)
729 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_density_3d'
731 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
732 INTEGER ::
atom, bin_x, bin_y, bin_z, file_ptr, &
735 REAL(kind=
dp) :: mass_total, r_tmp, vol_cell, vol_sub_box
736 REAL(kind=
dp),
DIMENSION(3) :: atom_pos, cell_size, interval_size
737 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: mass_bin
741 cpassert(
ASSOCIATED(elem))
742 cpassert(
ASSOCIATED(elem%pos))
743 cpassert(weight .GT. 0)
744 cpassert(
ASSOCIATED(atoms))
745 cpassert(
ASSOCIATED(ana_env))
746 cpassert(
ASSOCIATED(ana_env%cell))
747 cpassert(
ASSOCIATED(ana_env%density_3d))
748 cpassert(
ASSOCIATED(ana_env%density_3d%sum_density))
749 cpassert(
ASSOCIATED(ana_env%density_3d%sum_dens2))
752 CALL timeset(routinen, handle)
755 cell_size(:) = 0.0_dp
756 interval_size(:) = 0.0_dp
759 bin_x =
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
760 bin_y =
SIZE(ana_env%density_3d%sum_density(1, :, 1))
761 bin_z =
SIZE(ana_env%density_3d%sum_density(1, 1, :))
762 ALLOCATE (mass_bin(bin_x, bin_y, bin_z))
763 mass_bin(:, :, :) = 0.0_dp
769 abc=cell_size, vol=vol_cell)
771 ana_env%density_3d%sum_vol = ana_env%density_3d%sum_vol + &
772 vol_cell*(au2a)**3*weight
773 ana_env%density_3d%sum_vol2 = ana_env%density_3d%sum_vol2 + &
774 (vol_cell*(au2a)**3)**2*weight
776 ana_env%density_3d%sum_box_length(:) = ana_env%density_3d%sum_box_length(:) &
777 + cell_size(:)*(au2a)*weight
778 ana_env%density_3d%sum_box_length2(:) = ana_env%density_3d%sum_box_length2(:) &
779 + (cell_size(:)*(au2a))**2*weight
782 interval_size(1) = cell_size(1)/real(bin_x,
dp)
783 interval_size(2) = cell_size(2)/real(bin_y,
dp)
784 interval_size(3) = cell_size(3)/real(bin_z,
dp)
787 vol_cell = vol_cell*(au2a*1e-8)**3
788 vol_sub_box = interval_size(1)*interval_size(2)*interval_size(3)* &
792 DO atom = 1,
SIZE(elem%pos), ana_env%dim_per_elem
794 atom_pos(:) = elem%pos(
atom:
atom + 2)
799 atom_pos(:) = atom_pos(:) + 0.5_dp*cell_size(:)
801 bin_x = int(atom_pos(1)/interval_size(1)) + 1
802 bin_y = int(atom_pos(2)/interval_size(2)) + 1
803 bin_z = int(atom_pos(3)/interval_size(3)) + 1
804 cpassert(bin_x .GT. 0 .AND. bin_y .GT. 0 .AND. bin_z .GT. 0)
805 cpassert(bin_x .LE.
SIZE(ana_env%density_3d%sum_density(:, 1, 1)))
806 cpassert(bin_y .LE.
SIZE(ana_env%density_3d%sum_density(1, :, 1)))
807 cpassert(bin_z .LE.
SIZE(ana_env%density_3d%sum_density(1, 1, :)))
810 mass_bin(bin_x, bin_y, bin_z) = mass_bin(bin_x, bin_y, bin_z) + &
812 mass_total = mass_total + &
822 r_tmp = mass_total/vol_cell - sum(mass_bin(:, :, :))/vol_sub_box/
SIZE(mass_bin(:, :, :))
823 cpassert(abs(r_tmp) .LT. 1e-5)
826 ana_env%density_3d%sum_density(:, :, :) = ana_env%density_3d%sum_density(:, :, :) + &
827 weight*mass_bin(:, :, :)/vol_sub_box
830 ana_env%density_3d%sum_dens2(:, :, :) = ana_env%density_3d%sum_dens2(:, :, :) + &
831 weight*(mass_bin(:, :, :)/vol_sub_box)**2
833 ana_env%density_3d%conf_counter = ana_env%density_3d%conf_counter + weight
836 IF (ana_env%density_3d%print_dens)
THEN
842 INQUIRE (file=file_name, exist=flag)
843 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
844 file_action=
"WRITE", file_position=
"APPEND", &
845 unit_number=file_ptr)
847 WRITE (file_ptr, fmt=
'(A8,11A20)')
"# conf_nr",
"dens_act[g/cm^3]", &
848 "dens_average[g/cm^3]",
"density_variance", &
849 "averages:volume",
"box_lenth_x",
"box_lenth_y",
"box_lenth_z", &
850 "variances:volume",
"box_lenth_x",
"box_lenth_y",
"box_lenth_z"
851 WRITE (file_ptr, fmt=
"(I8,11F20.10)") ana_env%density_3d%conf_counter + 1 - weight, &
852 sum(mass_bin(:, :, :))/vol_sub_box/
SIZE(mass_bin(:, :, :)), &
853 sum(ana_env%density_3d%sum_density(:, :, :))/ &
854 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
855 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
856 sum(ana_env%density_3d%sum_dens2(:, :, :))/ &
857 SIZE(ana_env%density_3d%sum_dens2(:, :, :))/ &
858 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
859 (sum(ana_env%density_3d%sum_density(:, :, :))/ &
860 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
861 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2, &
862 ana_env%density_3d%sum_vol/ &
863 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
864 ana_env%density_3d%sum_box_length(:)/ &
865 REAL(ana_env%density_3d%conf_counter, kind=
dp), &
866 ana_env%density_3d%sum_vol2/ &
867 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
868 (ana_env%density_3d%sum_vol/ &
869 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2, &
870 ana_env%density_3d%sum_box_length2(:)/ &
871 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
872 (ana_env%density_3d%sum_box_length(:)/ &
873 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2
877 DEALLOCATE (mass_bin)
879 CALL timestop(handle)
880 END SUBROUTINE calc_density_3d
889 SUBROUTINE print_density_3d(ana_env)
892 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA", &
893 routinen =
'print_density_3d'
895 CHARACTER(LEN=default_path_length) :: file_name, file_name_vari
896 INTEGER :: bin_x, bin_y, bin_z, file_ptr_dens, &
897 file_ptr_vari, handle, i, j, k
898 REAL(kind=
dp),
DIMENSION(3) :: cell_size, interval_size
900 cpassert(
ASSOCIATED(ana_env))
901 cpassert(
ASSOCIATED(ana_env%density_3d))
902 cpassert(
ASSOCIATED(ana_env%density_3d%sum_density))
903 cpassert(
ASSOCIATED(ana_env%density_3d%sum_dens2))
906 CALL timeset(routinen, handle)
911 bin_x =
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
912 bin_y =
SIZE(ana_env%density_3d%sum_density(1, :, 1))
913 bin_z =
SIZE(ana_env%density_3d%sum_density(1, 1, :))
914 CALL get_cell(cell=ana_env%cell, abc=cell_size)
915 interval_size(1) = cell_size(1)/real(bin_x, kind=
dp)*au2a
916 interval_size(2) = cell_size(2)/real(bin_y, kind=
dp)*au2a
917 interval_size(3) = cell_size(3)/real(bin_z, kind=
dp)*au2a
922 CALL open_file(file_name=file_name, file_status=
"REPLACE", &
923 file_action=
"WRITE", file_position=
"APPEND", &
924 unit_number=file_ptr_dens)
925 WRITE (file_ptr_dens, fmt=
'(A,1X,I0,1X,A,3(I0,1X),1X,A,1X,3F10.5)') &
926 "# configurations", ana_env%density_3d%conf_counter,
"bins", &
927 ana_env%density_3d%nr_bins,
"interval size", interval_size(:)
928 WRITE (file_ptr_dens, fmt=
'(A,3A10,A20)')
"#",
" x [A] ",
" y [A] ",
" z [A] ",
" density [g/cm^3] "
931 trim(ana_env%out_file_prefix)// &
934 CALL open_file(file_name=file_name_vari, file_status=
"REPLACE", &
935 file_action=
"WRITE", file_position=
"APPEND", &
936 unit_number=file_ptr_vari)
937 WRITE (file_ptr_vari, fmt=
'(A,1X,I0,1X,A,3(I0,1X),1X,A,1X,3F10.5)') &
938 "# configurations", ana_env%density_3d%conf_counter,
"bins", &
939 ana_env%density_3d%nr_bins,
"interval size", interval_size(:)
940 WRITE (file_ptr_vari, fmt=
'(A,3A10,A20)')
"#",
" x [A] ",
" y [A] ",
" z [A] ",
" variance"
942 DO i = 1,
SIZE(ana_env%density_3d%sum_density(:, 1, 1))
943 DO j = 1,
SIZE(ana_env%density_3d%sum_density(1, :, 1))
944 DO k = 1,
SIZE(ana_env%density_3d%sum_density(1, 1, :))
945 WRITE (file_ptr_dens, fmt=
'(3F10.2,F20.10)') &
946 (i - 0.5_dp)*interval_size(1), (j - 0.5_dp)*interval_size(2), (k - 0.5_dp)*interval_size(3), &
947 ana_env%density_3d%sum_density(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp)
948 WRITE (file_ptr_vari, fmt=
'(3F10.2,F20.10)') &
949 (i - 0.5_dp)*interval_size(1), (j - 0.5_dp)*interval_size(2), (k - 0.5_dp)*interval_size(3), &
950 ana_env%density_3d%sum_dens2(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp) - &
951 (ana_env%density_3d%sum_density(i, j, k)/real(ana_env%density_3d%conf_counter, kind=
dp))**2
958 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
959 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"density calculation",
"-"
960 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ",
cp_to_string(ana_env%temperature)
961 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations", &
963 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"average volume", &
965 REAL(ana_env%density_3d%conf_counter, kind=
dp))
966 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"average density in the cell: ", &
967 cp_to_string(sum(ana_env%density_3d%sum_density(:, :, :))/ &
968 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
969 REAL(ana_env%density_3d%conf_counter, kind=
dp))
970 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"density variance:", &
971 cp_to_string(sum(ana_env%density_3d%sum_dens2(:, :, :))/ &
972 SIZE(ana_env%density_3d%sum_dens2(:, :, :))/ &
973 REAL(ana_env%density_3d%conf_counter, kind=
dp) - &
974 (sum(ana_env%density_3d%sum_density(:, :, :))/ &
975 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
976 REAL(ana_env%density_3d%conf_counter, kind=
dp))**2)
977 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
978 IF (ana_env%print_test_output) &
979 WRITE (ana_env%io_unit, *)
"TMC|ANALYSIS_CELL_DENSITY_X= ", &
980 sum(ana_env%density_3d%sum_density(:, :, :))/ &
981 SIZE(ana_env%density_3d%sum_density(:, :, :))/ &
982 REAL(ana_env%density_3d%conf_counter, kind=
dp)
984 CALL timestop(handle)
985 END SUBROUTINE print_density_3d
999 SUBROUTINE ana_pair_correl_init(ana_pair_correl, atoms, cell)
1004 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ana_pair_correl_init'
1006 INTEGER :: counter, f_n, handle,
list, list_ind, s_n
1007 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1010 cpassert(
ASSOCIATED(ana_pair_correl))
1011 cpassert(.NOT.
ASSOCIATED(ana_pair_correl%g_r))
1012 cpassert(.NOT.
ASSOCIATED(ana_pair_correl%pairs))
1013 cpassert(
ASSOCIATED(atoms))
1014 cpassert(
SIZE(atoms) .GT. 1)
1015 cpassert(
ASSOCIATED(cell))
1018 CALL timeset(routinen, handle)
1020 CALL get_cell(cell=cell, abc=cell_size)
1021 IF (ana_pair_correl%nr_bins .LE. 0)
THEN
1022 ana_pair_correl%nr_bins = ceiling(maxval(cell_size(:))/2.0_dp/(0.03/au2a))
1024 ana_pair_correl%step_length = maxval(cell_size(:))/2.0_dp/ &
1025 ana_pair_correl%nr_bins
1026 ana_pair_correl%conf_counter = 0
1030 ALLOCATE (pairs_tmp(
SIZE(atoms)))
1031 DO f_n = 1,
SIZE(atoms)
1032 DO s_n = f_n + 1,
SIZE(atoms)
1035 n2=atoms(s_n)%name, list_end=counter - 1)
1037 IF (list_ind .LT. 0)
THEN
1038 pairs_tmp(counter)%f_n = atoms(f_n)%name
1039 pairs_tmp(counter)%s_n = atoms(s_n)%name
1040 pairs_tmp(counter)%pair_count = 1
1041 counter = counter + 1
1043 pairs_tmp(list_ind)%pair_count = pairs_tmp(list_ind)%pair_count + 1
1048 ALLOCATE (ana_pair_correl%pairs(counter - 1))
1049 DO list = 1, counter - 1
1050 ana_pair_correl%pairs(
list)%f_n = pairs_tmp(
list)%f_n
1051 ana_pair_correl%pairs(
list)%s_n = pairs_tmp(
list)%s_n
1052 ana_pair_correl%pairs(
list)%pair_count = pairs_tmp(
list)%pair_count
1054 DEALLOCATE (pairs_tmp)
1056 ALLOCATE (ana_pair_correl%g_r(
SIZE(ana_pair_correl%pairs(:)), ana_pair_correl%nr_bins))
1057 ana_pair_correl%g_r = 0.0_dp
1059 CALL timestop(handle)
1060 END SUBROUTINE ana_pair_correl_init
1071 SUBROUTINE calc_paircorrelation(elem, weight, atoms, ana_env)
1077 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_paircorrelation'
1079 INTEGER :: handle, i, ind, j, pair_ind
1080 REAL(kind=
dp) :: dist
1081 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1083 cpassert(
ASSOCIATED(elem))
1084 cpassert(
ASSOCIATED(elem%pos))
1085 cpassert(all(elem%box_scale(:) .GT. 0.0_dp))
1086 cpassert(weight .GT. 0)
1087 cpassert(
ASSOCIATED(atoms))
1088 cpassert(
ASSOCIATED(ana_env))
1089 cpassert(
ASSOCIATED(ana_env%cell))
1090 cpassert(
ASSOCIATED(ana_env%pair_correl))
1091 cpassert(
ASSOCIATED(ana_env%pair_correl%g_r))
1092 cpassert(
ASSOCIATED(ana_env%pair_correl%pairs))
1095 CALL timeset(routinen, handle)
1099 first_elem_loop:
DO i = 1,
SIZE(elem%pos), ana_env%dim_per_elem
1100 second_elem_loop:
DO j = i + 3,
SIZE(elem%pos), ana_env%dim_per_elem
1102 x2=elem%pos(j:j + ana_env%dim_per_elem - 1), &
1103 cell=ana_env%cell, box_scale=elem%box_scale)
1104 ind = ceiling(dist/ana_env%pair_correl%step_length)
1105 IF (ind .LE. ana_env%pair_correl%nr_bins)
THEN
1107 n1=atoms(int(i/real(ana_env%dim_per_elem, kind=
dp)) + 1)%name, &
1108 n2=atoms(int(j/real(ana_env%dim_per_elem, kind=
dp)) + 1)%name)
1109 cpassert(pair_ind .GT. 0)
1110 ana_env%pair_correl%g_r(pair_ind, ind) = &
1111 ana_env%pair_correl%g_r(pair_ind, ind) + weight
1113 END DO second_elem_loop
1114 END DO first_elem_loop
1115 ana_env%pair_correl%conf_counter = ana_env%pair_correl%conf_counter + weight
1116 CALL get_cell(cell=ana_env%cell, abc=cell_size)
1117 ana_env%pair_correl%sum_box_scale = ana_env%pair_correl%sum_box_scale + &
1118 (elem%box_scale(:)*weight)
1120 CALL timestop(handle)
1121 END SUBROUTINE calc_paircorrelation
1129 SUBROUTINE print_paircorrelation(ana_env)
1132 CHARACTER(LEN=*),
PARAMETER :: routinen =
'print_paircorrelation'
1134 CHARACTER(LEN=default_path_length) :: file_name
1135 INTEGER :: bin, file_ptr, handle, pair
1136 REAL(kind=
dp) :: aver_box_scale(3), vol, voldr
1137 REAL(kind=
dp),
DIMENSION(3) :: cell_size
1139 cpassert(
ASSOCIATED(ana_env))
1140 cpassert(
ASSOCIATED(ana_env%pair_correl))
1143 CALL timeset(routinen, handle)
1145 CALL get_cell(cell=ana_env%cell, abc=cell_size)
1146 aver_box_scale(:) = ana_env%pair_correl%sum_box_scale(:)/ana_env%pair_correl%conf_counter
1147 vol = (cell_size(1)*aver_box_scale(1))* &
1148 (cell_size(2)*aver_box_scale(2))* &
1149 (cell_size(3)*aver_box_scale(3))
1151 DO pair = 1,
SIZE(ana_env%pair_correl%pairs)
1154 ana_env%temperature)
1157 ana_env%pair_correl%pairs(pair)%f_n), &
1158 ana_env%pair_correl%pairs(pair)%s_n), &
1159 file_status=
"REPLACE", &
1160 file_action=
"WRITE", file_position=
"APPEND", &
1161 unit_number=file_ptr)
1162 WRITE (file_ptr, *)
"# radial distribution function of "// &
1163 trim(ana_env%pair_correl%pairs(pair)%f_n)//
" and "// &
1164 trim(ana_env%pair_correl%pairs(pair)%s_n)//
" of ", &
1165 ana_env%pair_correl%conf_counter,
" configurations"
1166 WRITE (file_ptr, *)
"# using a bin size of ", &
1167 ana_env%pair_correl%step_length*au2a, &
1168 "[A] (for Vol changes: referring to the reference cell)"
1169 DO bin = 1, ana_env%pair_correl%nr_bins
1170 voldr = 4.0/3.0*
pi*ana_env%pair_correl%step_length**3* &
1171 (real(bin, kind=
dp)**3 - real(bin - 1, kind=
dp)**3)
1172 WRITE (file_ptr, *) (bin - 0.5)*ana_env%pair_correl%step_length*au2a, &
1173 (ana_env%pair_correl%g_r(pair, bin)/ana_env%pair_correl%conf_counter)/ &
1174 (voldr*ana_env%pair_correl%pairs(pair)%pair_count/vol)
1178 IF (ana_env%print_test_output) &
1179 WRITE (*, *)
"TMC|ANALYSIS_G_R_"// &
1180 trim(ana_env%pair_correl%pairs(pair)%f_n)//
"_"// &
1181 trim(ana_env%pair_correl%pairs(pair)%s_n)//
"_X= ", &
1182 sum(ana_env%pair_correl%g_r(pair, :)/ana_env%pair_correl%conf_counter/ &
1183 voldr*ana_env%pair_correl%pairs(pair)%pair_count/vol)
1187 CALL timestop(handle)
1188 END SUBROUTINE print_paircorrelation
1201 SUBROUTINE ana_dipole_moment_init(ana_dip_mom, atoms)
1205 CHARACTER(LEN=*),
PARAMETER :: routinen =
'ana_dipole_moment_init'
1207 INTEGER ::
atom, charge, handle
1209 cpassert(
ASSOCIATED(ana_dip_mom))
1210 cpassert(
ASSOCIATED(ana_dip_mom%charges_inp))
1211 cpassert(
ASSOCIATED(atoms))
1214 CALL timeset(routinen, handle)
1216 ALLOCATE (ana_dip_mom%charges(
SIZE(atoms)))
1217 ana_dip_mom%charges = 0.0_dp
1219 DO atom = 1,
SIZE(atoms)
1220 charge_loop:
DO charge = 1,
SIZE(ana_dip_mom%charges_inp)
1221 IF (atoms(
atom)%name .EQ. ana_dip_mom%charges_inp(charge)%name)
THEN
1222 ana_dip_mom%charges(
atom) = ana_dip_mom%charges_inp(charge)%mass
1228 DEALLOCATE (ana_dip_mom%charges_inp)
1230 CALL timestop(handle)
1231 END SUBROUTINE ana_dipole_moment_init
1241 SUBROUTINE calc_dipole_moment(elem, weight, ana_env)
1246 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_dipole_moment'
1248 CHARACTER(LEN=default_path_length) :: file_name
1249 INTEGER :: handle, i
1250 REAL(kind=
dp),
DIMENSION(:),
POINTER :: dip_cl
1252 cpassert(
ASSOCIATED(elem))
1253 cpassert(
ASSOCIATED(elem%pos))
1254 cpassert(
ASSOCIATED(ana_env))
1255 cpassert(
ASSOCIATED(ana_env%dip_mom))
1256 cpassert(
ASSOCIATED(ana_env%dip_mom%charges))
1259 CALL timeset(routinen, handle)
1261 ALLOCATE (dip_cl(ana_env%dim_per_elem))
1264 DO i = 1,
SIZE(elem%pos, 1), ana_env%dim_per_elem
1265 dip_cl(:) = dip_cl(:) + elem%pos(i:i + ana_env%dim_per_elem - 1)* &
1266 ana_env%dip_mom%charges(int(i/real(ana_env%dim_per_elem, kind=
dp)) + 1)
1270 IF (.NOT.
ASSOCIATED(elem%dipole))
THEN
1271 ALLOCATE (elem%dipole(ana_env%dim_per_elem))
1272 elem%dipole(:) = dip_cl(:)
1275 IF (ana_env%dip_mom%print_cl_dip)
THEN
1277 ana_env%temperature)
1279 conf_nr=ana_env%dip_mom%conf_counter + 1, dip=dip_cl, &
1282 ana_env%dip_mom%conf_counter = ana_env%dip_mom%conf_counter + weight
1283 ana_env%dip_mom%last_dip_cl(:) = dip_cl
1288 CALL timestop(handle)
1289 END SUBROUTINE calc_dipole_moment
1297 SUBROUTINE print_dipole_moment(ana_env)
1300 IF (ana_env%print_test_output) &
1301 WRITE (*, *)
"TMC|ANALYSIS_FINAL_CLASS_CELL_DIPOLE_MOMENT_X= ", &
1302 ana_env%dip_mom%last_dip_cl(:)
1303 END SUBROUTINE print_dipole_moment
1313 SUBROUTINE calc_dipole_analysis(elem, weight, ana_env)
1318 REAL(kind=
dp) :: vol, weight_act
1319 REAL(kind=
dp),
DIMENSION(3, 3) :: tmp_dip
1322 NULLIFY (scaled_cell)
1324 cpassert(
ASSOCIATED(elem))
1325 cpassert(
ASSOCIATED(elem%dipole))
1326 cpassert(
ASSOCIATED(ana_env))
1327 cpassert(
ASSOCIATED(ana_env%dip_ana))
1331 weight_act = weight_act/real(8.0, kind=
dp)
1334 ALLOCATE (scaled_cell)
1335 CALL get_scaled_cell(cell=ana_env%cell, box_scale=elem%box_scale, vol=vol, &
1336 scaled_cell=scaled_cell)
1339 IF (
ASSOCIATED(ana_env%dip_mom))
THEN
1340 IF (all(ana_env%dip_mom%last_dip_cl .NE. elem%dipole))
THEN
1341 elem%dipole =
pbc(r=elem%dipole(:) - ana_env%dip_mom%last_dip_cl, &
1342 cell=scaled_cell) + ana_env%dip_mom%last_dip_cl
1346 ana_env%dip_ana%conf_counter = ana_env%dip_ana%conf_counter + weight_act
1349 ana_env%dip_ana%mu2_pv_s = ana_env%dip_ana%mu2_pv_s + &
1350 dot_product(elem%dipole(:), elem%dipole(:))/vol*weight_act
1352 tmp_dip(:, :) = 0.0_dp
1353 tmp_dip(:, 1) = elem%dipole(:)
1356 ana_env%dip_ana%mu_pv(:) = ana_env%dip_ana%mu_pv(:) + &
1357 tmp_dip(:, 1)/vol*weight_act
1360 ana_env%dip_ana%mu_psv(:) = ana_env%dip_ana%mu_psv(:) + &
1361 tmp_dip(:, 1)/sqrt(vol)*weight_act
1364 ana_env%dip_ana%mu2_pv(:) = ana_env%dip_ana%mu2_pv(:) + &
1365 tmp_dip(:, 1)**2/vol*weight_act
1368 tmp_dip(:, :) = matmul(tmp_dip(:, :), transpose(tmp_dip(:, :)))
1369 ana_env%dip_ana%mu2_pv_mat(:, :) = ana_env%dip_ana%mu2_pv_mat(:, :) + &
1370 tmp_dip(:, :)/vol*weight_act
1372 END SUBROUTINE calc_dipole_analysis
1381 SUBROUTINE print_act_dipole_analysis(elem, ana_env)
1385 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
1386 INTEGER :: counter_tmp, file_ptr
1388 REAL(kind=
dp) :: diel_const, diel_const_norm, &
1389 diel_const_sym, e0, kb
1390 REAL(kind=
dp),
DIMENSION(3, 3) :: tmp_dip
1393 counter_tmp = int(ana_env%dip_ana%conf_counter)
1396 e0 = 0.07957747154594767_dp
1397 diel_const_norm = 1/(3.0_dp*e0*kb*ana_env%temperature)
1401 ana_env%temperature)
1403 conf_nr=int(ana_env%dip_ana%conf_counter) + 1, dip=elem%dipole, &
1404 file_ext=
"dip_folded")
1409 ana_env%temperature)
1411 SELECT CASE (ana_env%dip_ana%ana_type)
1416 "diel_const_tensor"))
1421 "diel_const_tensor_sym"))
1423 cpwarn(
'unknown analysis type "'//
cp_to_string(ana_env%dip_ana%ana_type)//
'" used.')
1428 diel_const = 1.0_dp + (ana_env%dip_ana%mu2_pv_s/(ana_env%dip_ana%conf_counter) - &
1429 dot_product(ana_env%dip_ana%mu_psv(:)/(ana_env%dip_ana%conf_counter), &
1430 ana_env%dip_ana%mu_psv(:)/(ana_env%dip_ana%conf_counter)))* &
1434 diel_const_sym = 1.0_dp + ana_env%dip_ana%mu2_pv_s/(ana_env%dip_ana%conf_counter)* &
1438 INQUIRE (file=file_name, exist=flag)
1439 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
1440 file_action=
"WRITE", file_position=
"APPEND", &
1441 unit_number=file_ptr)
1442 IF (.NOT. flag)
THEN
1443 WRITE (file_ptr, fmt=
'(A8,5A20)')
"# conf",
"diel_const", &
1444 "diel_const_sym",
"diel_const_sym_x", &
1445 "diel_const_sym_y",
"diel_const_sym_z"
1447 WRITE (file_ptr, fmt=
"(I8,10F20.10)") counter_tmp, diel_const, &
1449 4.0_dp*
pi/(kb*ana_env%temperature)* &
1450 ana_env%dip_ana%mu2_pv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1454 INQUIRE (file=file_name_tmp, exist=flag)
1455 CALL open_file(file_name=file_name_tmp, file_status=
"UNKNOWN", &
1456 file_action=
"WRITE", file_position=
"APPEND", &
1457 unit_number=file_ptr)
1458 IF (.NOT. flag)
THEN
1459 WRITE (file_ptr, fmt=
'(A8,9A20)')
"# conf",
"xx",
"xy",
"xz", &
1463 tmp_dip(:, :) = 0.0_dp
1464 tmp_dip(:, 1) = ana_env%dip_ana%mu_psv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1466 WRITE (file_ptr, fmt=
"(I8,10F20.10)") counter_tmp, &
1467 4.0_dp*
pi/(kb*ana_env%temperature)* &
1468 (ana_env%dip_ana%mu2_pv_mat(:, :)/real(ana_env%dip_ana%conf_counter, kind=
dp) - &
1469 matmul(tmp_dip(:, :), transpose(tmp_dip(:, :))))
1471 END SUBROUTINE print_act_dipole_analysis
1479 SUBROUTINE print_dipole_analysis(ana_env)
1482 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA"
1485 REAL(kind=
dp) :: diel_const_scalar, kb
1486 REAL(kind=
dp),
DIMENSION(3) :: diel_const_sym, dielec_ev
1487 REAL(kind=
dp),
DIMENSION(3, 3) :: diel_const, tmp_dip, tmp_ev
1491 cpassert(
ASSOCIATED(ana_env))
1492 cpassert(
ASSOCIATED(ana_env%dip_ana))
1494 tmp_dip(:, :) = 0.0_dp
1495 diel_const(:, :) = 0.0_dp
1496 diel_const_scalar = 0.0_dp
1497 diel_const_sym = 0.0_dp
1500 tmp_dip(:, 1) = ana_env%dip_ana%mu_psv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1501 diel_const(:, :) = 4.0_dp*
pi/(kb*ana_env%temperature)* &
1502 (ana_env%dip_ana%mu2_pv_mat(:, :)/real(ana_env%dip_ana%conf_counter, kind=
dp) - &
1503 matmul(tmp_dip(:, :), transpose(tmp_dip(:, :))))
1506 diel_const_sym(:) = 4.0_dp*
pi/(kb*ana_env%temperature)* &
1507 ana_env%dip_ana%mu2_pv(:)/real(ana_env%dip_ana%conf_counter, kind=
dp)
1510 diel_const(i, i) = diel_const(i, i) + 1.0_dp
1511 diel_const_scalar = diel_const_scalar + diel_const(i, i)
1513 diel_const_scalar = diel_const_scalar/real(3, kind=
dp)
1515 tmp_dip(:, :) = diel_const
1516 CALL diag(3, tmp_dip, dielec_ev, tmp_ev)
1519 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1520 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"average dipoles",
"-"
1521 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ",
cp_to_string(ana_env%temperature)
1522 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations ", &
1525 WRITE (ana_env%io_unit, fmt=
'(T2,A,"| ",A)') plabel, &
1526 "ice analysis with directions of hexagonal structure"
1528 WRITE (ana_env%io_unit, fmt=
'(T2,A,"| ",A)') plabel, &
1529 "ice analysis with symmetrized dipoles in each direction."
1531 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"for product of 2 directions(per vol):"
1533 WRITE (ana_env%io_unit,
'(A,3F16.8,A)')
" |", ana_env%dip_ana%mu2_pv_mat(i, :)/ &
1534 REAL(ana_env%dip_ana%conf_counter, kind=
dp),
" |"
1537 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant tensor:"
1539 WRITE (ana_env%io_unit,
'(A,3F16.8,A)')
" |", diel_const(i, :),
" |"
1542 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric tensor eigenvalues", &
1546 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant symm ", &
1550 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"dielectric constant ", &
1552 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1554 END SUBROUTINE print_dipole_analysis
1567 SUBROUTINE calc_displacement(elem, ana_env)
1571 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calc_displacement'
1573 CHARACTER(LEN=default_path_length) :: file_name, file_name_tmp
1574 INTEGER :: file_ptr, handle, ind
1576 REAL(kind=
dp) :: disp
1577 REAL(kind=
dp),
DIMENSION(3) :: atom_disp
1581 cpassert(
ASSOCIATED(elem))
1582 cpassert(
ASSOCIATED(elem%pos))
1583 cpassert(
ASSOCIATED(ana_env))
1584 cpassert(
ASSOCIATED(ana_env%displace))
1585 cpassert(
ASSOCIATED(ana_env%last_elem))
1588 CALL timeset(routinen, handle)
1590 DO ind = 1,
SIZE(elem%pos), ana_env%dim_per_elem
1592 atom_disp(:) = elem%pos(ind:ind + 2) - ana_env%last_elem%pos(ind:ind + 2)
1595 disp = disp + sum((atom_disp(:)*au2a)**2)
1597 ana_env%displace%disp = ana_env%displace%disp + disp
1598 ana_env%displace%conf_counter = ana_env%displace%conf_counter + 1
1600 IF (ana_env%displace%print_disp)
THEN
1603 ana_env%temperature)
1606 INQUIRE (file=file_name, exist=flag)
1607 CALL open_file(file_name=file_name, file_status=
"UNKNOWN", &
1608 file_action=
"WRITE", file_position=
"APPEND", &
1609 unit_number=file_ptr)
1611 WRITE (file_ptr, *)
"# conf squared deviation of the cell"
1612 WRITE (file_ptr, *) elem%nr, disp
1617 CALL timestop(handle)
1619 END SUBROUTINE calc_displacement
1627 SUBROUTINE print_average_displacement(ana_env)
1630 CHARACTER(LEN=*),
PARAMETER :: fmt_my =
'(T2,A,"| ",A,T41,A40)', plabel =
"TMC_ANA"
1632 WRITE (ana_env%io_unit, fmt=
"(/,T2,A)") repeat(
"-", 79)
1633 WRITE (ana_env%io_unit, fmt=
"(T2,A,T35,A,T80,A)")
"-",
"average displacement",
"-"
1634 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"temperature ", &
1636 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"used configurations ", &
1638 WRITE (ana_env%io_unit, fmt=fmt_my) plabel,
"cell root mean square deviation: ", &
1640 REAL(ana_env%displace%conf_counter, kind=
dp)))
1641 IF (ana_env%print_test_output) &
1642 WRITE (*, *)
"TMC|ANALYSIS_AVERAGE_CELL_DISPLACEMENT_X= ", &
1643 sqrt(ana_env%displace%disp/ &
1644 REAL(ana_env%displace%conf_counter, kind=
dp))
1645 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.