mmpol_prepare Subroutine

public subroutine mmpol_prepare(sys_obj)

Uses

  • proc~~mmpol_prepare~~UsesGraph proc~mmpol_prepare mmpol_prepare module~mod_electrostatics mod_electrostatics proc~mmpol_prepare->module~mod_electrostatics module~mod_profiling mod_profiling proc~mmpol_prepare->module~mod_profiling module~mod_constants mod_constants proc~mmpol_prepare->module~mod_constants module~mod_io mod_io proc~mmpol_prepare->module~mod_io module~mod_adjacency_mat mod_adjacency_mat proc~mmpol_prepare->module~mod_adjacency_mat module~mod_electrostatics->module~mod_profiling module~mod_electrostatics->module~mod_constants module~mod_electrostatics->module~mod_io module~mod_electrostatics->module~mod_adjacency_mat module~mod_memory mod_memory module~mod_electrostatics->module~mod_memory module~mod_topology mod_topology module~mod_electrostatics->module~mod_topology module~mod_profiling->module~mod_constants module~mod_profiling->module~mod_io module~mod_profiling->module~mod_memory iso_c_binding iso_c_binding module~mod_constants->iso_c_binding module~mod_io->module~mod_constants module~mod_adjacency_mat->module~mod_memory module~mod_memory->module~mod_constants module~mod_memory->module~mod_io module~mod_memory->iso_c_binding module~mod_topology->module~mod_adjacency_mat module~mod_topology->module~mod_memory

Compute some derived quantities from the input that are used during the calculation. The upstream code have to provide cmm, q, pol, adjacency matrix and in the case of AMOEBA also multipoles rotation information, and polarization group information.
This routine
* compute connectivity lists from connected atoms
* invert polar_mm list creating mm_polar
* populate cpol list of coordinates
* compute factors for thole damping
* scales by 1/3 AMOEBA quadrupoles (?)
* Build list for polarization groups, compute groups connectivity
* performs multipoles rotation

Arguments

Type IntentOptional Attributes Name
type(ommp_system), intent(inout) :: sys_obj

The system object to bi initialized


Calls

proc~~mmpol_prepare~~CallsGraph proc~mmpol_prepare mmpol_prepare proc~time_push time_push proc~mmpol_prepare->proc~time_push proc~build_conn_upto_n build_conn_upto_n proc~mmpol_prepare->proc~build_conn_upto_n proc~matcpy matcpy proc~mmpol_prepare->proc~matcpy proc~remove_null_pol remove_null_pol proc~mmpol_prepare->proc~remove_null_pol proc~ommp_message ommp_message proc~mmpol_prepare->proc~ommp_message proc~thole_init thole_init proc~mmpol_prepare->proc~thole_init proc~reverse_grp_tab reverse_grp_tab proc~mmpol_prepare->proc~reverse_grp_tab proc~build_pg_adjacency_matrix build_pg_adjacency_matrix proc~mmpol_prepare->proc~build_pg_adjacency_matrix proc~rotate_multipoles rotate_multipoles proc~mmpol_prepare->proc~rotate_multipoles proc~make_screening_lists make_screening_lists proc~mmpol_prepare->proc~make_screening_lists proc~time_pull time_pull proc~mmpol_prepare->proc~time_pull proc~mem_stat mem_stat proc~time_push->proc~mem_stat proc~fatal_error fatal_error proc~time_push->proc~fatal_error proc~build_conn_upto_n->proc~matcpy proc~mat_mult mat_mult proc~build_conn_upto_n->proc~mat_mult proc~matfree matfree proc~build_conn_upto_n->proc~matfree proc~sparse_identity sparse_identity proc~build_conn_upto_n->proc~sparse_identity proc~mat_andnot mat_andnot proc~build_conn_upto_n->proc~mat_andnot proc~remove_null_pol->proc~ommp_message interface~mallocate mallocate proc~remove_null_pol->interface~mallocate interface~mfree mfree proc~remove_null_pol->interface~mfree proc~thole_init->proc~ommp_message proc~thole_init->proc~fatal_error proc~reverse_grp_tab->interface~mallocate proc~reverse_grp_tab->interface~mfree proc~compress_list compress_list proc~reverse_grp_tab->proc~compress_list proc~reallocate_mat reallocate_mat proc~build_pg_adjacency_matrix->proc~reallocate_mat proc~rotation_matrix rotation_matrix proc~rotate_multipoles->proc~rotation_matrix proc~screening_rules screening_rules proc~make_screening_lists->proc~screening_rules proc~compress_data compress_data proc~make_screening_lists->proc~compress_data proc~make_screening_lists->interface~mallocate proc~make_screening_lists->interface~mfree proc~make_screening_lists->proc~compress_list proc~time_pull->proc~ommp_message proc~time_pull->proc~mem_stat proc~time_pull->proc~fatal_error proc~screening_rules->proc~fatal_error proc~compress_data->interface~mallocate proc~memory_init memory_init proc~mem_stat->proc~memory_init proc~mat_mult->proc~reallocate_mat proc~fatal_error->proc~ommp_message proc~close_output close_output proc~fatal_error->proc~close_output proc~mat_andnot->proc~reallocate_mat proc~r_alloc1 r_alloc1 interface~mallocate->proc~r_alloc1 proc~i_alloc1 i_alloc1 interface~mallocate->proc~i_alloc1 proc~i_alloc2 i_alloc2 interface~mallocate->proc~i_alloc2 proc~r_alloc3 r_alloc3 interface~mallocate->proc~r_alloc3 proc~r_alloc2 r_alloc2 interface~mallocate->proc~r_alloc2 proc~i_alloc3 i_alloc3 interface~mallocate->proc~i_alloc3 proc~l_alloc1 l_alloc1 interface~mallocate->proc~l_alloc1 proc~l_alloc2 l_alloc2 interface~mallocate->proc~l_alloc2 proc~r_free1 r_free1 interface~mfree->proc~r_free1 proc~i_free3 i_free3 interface~mfree->proc~i_free3 proc~l_free2 l_free2 interface~mfree->proc~l_free2 proc~l_free1 l_free1 interface~mfree->proc~l_free1 proc~i_free1 i_free1 interface~mfree->proc~i_free1 proc~i_free2 i_free2 interface~mfree->proc~i_free2 proc~r_free3 r_free3 interface~mfree->proc~r_free3 proc~r_free2 r_free2 interface~mfree->proc~r_free2 proc~compress_list->interface~mallocate proc~compress_list->interface~mfree proc~rotation_matrix->proc~fatal_error proc~chk_free chk_free proc~r_free1->proc~chk_free proc~i_free3->proc~chk_free proc~l_free2->proc~chk_free proc~l_free1->proc~chk_free proc~r_alloc1->proc~memory_init proc~chk_alloc chk_alloc proc~r_alloc1->proc~chk_alloc proc~close_output->proc~ommp_message proc~i_alloc1->proc~memory_init proc~i_alloc1->proc~chk_alloc proc~i_alloc2->proc~memory_init proc~i_alloc2->proc~chk_alloc proc~r_alloc3->proc~memory_init proc~r_alloc3->proc~chk_alloc proc~r_alloc2->proc~memory_init proc~r_alloc2->proc~chk_alloc proc~i_alloc3->proc~memory_init proc~i_alloc3->proc~chk_alloc proc~l_alloc1->proc~memory_init proc~l_alloc1->proc~chk_alloc proc~l_alloc2->proc~memory_init proc~l_alloc2->proc~chk_alloc proc~i_free1->proc~chk_free proc~i_free2->proc~chk_free proc~r_free3->proc~chk_free proc~r_free2->proc~chk_free proc~chk_free->proc~fatal_error proc~chk_alloc->proc~fatal_error

Called by

proc~~mmpol_prepare~~CalledByGraph proc~mmpol_prepare mmpol_prepare proc~mmpol_init_from_mmp mmpol_init_from_mmp proc~mmpol_init_from_mmp->proc~mmpol_prepare proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~mmpol_init_from_xyz->proc~mmpol_prepare proc~ommp_system_from_qm_helper ommp_system_from_qm_helper proc~ommp_system_from_qm_helper->proc~mmpol_prepare proc~ommp_init_mmp ommp_init_mmp proc~ommp_init_mmp->proc~mmpol_init_from_mmp program~test_si_geomgrad_num test_SI_geomgrad_num program~test_si_geomgrad_num->proc~ommp_system_from_qm_helper program~test_si_geomgrad test_SI_geomgrad program~test_si_geomgrad->proc~ommp_system_from_qm_helper proc~ommp_init_xyz ommp_init_xyz proc~ommp_init_xyz->proc~mmpol_init_from_xyz proc~c_ommp_system_from_qm_helper C_ommp_system_from_qm_helper proc~c_ommp_system_from_qm_helper->proc~ommp_system_from_qm_helper proc~c_ommp_init_mmp C_ommp_init_mmp proc~c_ommp_init_mmp->proc~ommp_init_mmp proc~c_ommp_init_xyz C_ommp_init_xyz proc~c_ommp_init_xyz->proc~ommp_init_xyz

Contents

Source Code


Source Code

    subroutine mmpol_prepare(sys_obj)
        !! Compute some derived quantities from the input that 
        !! are used during the calculation. The upstream code have
        !! to provide cmm, q, pol, adjacency matrix and in
        !! the case of AMOEBA also multipoles rotation information, and 
        !! polarization group information.   
        !! This routine    
        !!   * compute connectivity lists from connected atoms    
        !!   * invert polar_mm list creating mm_polar   
        !!   * populate cpol list of coordinates   
        !!   * compute factors for thole damping    
        !!   * scales by 1/3 AMOEBA quadrupoles (?)    
        !!   * Build list for polarization groups, compute groups connectivity   
        !!   * performs multipoles rotation   

        use mod_adjacency_mat, only: build_conn_upto_n, matcpy, reverse_grp_tab
        use mod_io, only: ommp_message
        use mod_profiling, only: time_push, time_pull
        use mod_constants, only: OMMP_VERBOSE_DEBUG
        use mod_electrostatics, only: thole_init, remove_null_pol, &
                                      make_screening_lists

        implicit none
        
        type(ommp_system), intent(inout) :: sys_obj
        !! The system object to bi initialized

        integer(ip) :: i
        
        type(yale_sparse) :: adj, pg_adj

        call time_push()
        call ommp_message("Building connectivity lists", OMMP_VERBOSE_DEBUG)
        
        ! compute connectivity lists from connected atoms
        if(size(sys_obj%top%conn) < 4) then
            call matcpy(sys_obj%top%conn(1), adj)
            deallocate(sys_obj%top%conn)
            call build_conn_upto_n(adj, 4, sys_obj%top%conn, .false.)
        end if

        call remove_null_pol(sys_obj%eel)
       
        ! invert mm_polar list creating mm_polar
        sys_obj%eel%mm_polar(:) = 0
        if(sys_obj%eel%pol_atoms > 0) then
            call ommp_message("Creating MM->polar and polar->MM lists", &
                              OMMP_VERBOSE_DEBUG)
            !$omp parallel do default(shared) private(i)
            do i = 1, sys_obj%eel%pol_atoms
                sys_obj%eel%mm_polar(sys_obj%eel%polar_mm(i)) = i
            end do

            call ommp_message("Populating coordinates of polarizable atoms", &
                              OMMP_VERBOSE_DEBUG)
            ! populate cpol list of coordinates
            !$omp parallel do default(shared) private(i)
            do i = 1, sys_obj%eel%pol_atoms
                sys_obj%eel%cpol(:,i) = sys_obj%top%cmm(:, sys_obj%eel%polar_mm(i))
            end do

            call ommp_message("Setting Thole factors", OMMP_VERBOSE_DEBUG)
            ! compute factors for thole damping
            call thole_init(sys_obj%eel)
        else
            sys_obj%eel%thole = 0.0
        end if

        if(sys_obj%amoeba) then
            ! Copy multipoles from q to q0
            sys_obj%eel%q0 = sys_obj%eel%q

            ! scales by 1/3 AMOEBA quadrupoles (?)
            ! Mysterious division of multipoles by three
            ! FL told me that it was done like that in
            ! Tinker
            sys_obj%eel%q0(5:10,:) = sys_obj%eel%q0(5:10,:) / 3.0_rp

            ! polarization groups connectivity list
            call reverse_grp_tab(sys_obj%eel%mmat_polgrp, &
                                 sys_obj%eel%polgrp_mmat)
            call build_pg_adjacency_matrix(sys_obj%eel, pg_adj)
            call build_conn_upto_n(pg_adj, 3, sys_obj%eel%pg_conn, .true.)

            ! performs multipoles rotation
            call rotate_multipoles(sys_obj%eel)
        end if

        call ommp_message("Building screening lists", OMMP_VERBOSE_DEBUG)
        call time_push()
        call make_screening_lists(sys_obj%eel)
        call time_pull("Preparing screening lists")
        call ommp_message("MMPol initialization (mmpol_prepare) completed.", OMMP_VERBOSE_DEBUG)
        call time_pull('MMPol object initialization (mmpol_prepare)')
    end subroutine mmpol_prepare