LCOV - code coverage report
Current view: top level - src/78_effpot - m_abstract_mover.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 8.6 % 35 3
Test Date: 2026-09-21 22:40:37 Functions: 12.5 % 8 1

            Line data    Source code
       1              : !!****m* ABINIT/m_abstract_mover
       2              : !! NAME
       3              : !! m_abstract_mover
       4              : !!
       5              : !! FUNCTION
       6              : !! This module contains the base type for all mover types.
       7              : !!
       8              : !!
       9              : !! Datatypes:
      10              : !!
      11              : !! * abstract_mover_t: defines the base api of movers.
      12              : !!
      13              : !! Subroutines:
      14              : !! TODO: add this when F2003 doc style is determined.
      15              : !!
      16              : !!
      17              : !! COPYRIGHT
      18              : !! Copyright (C) 2001-2026 ABINIT group (hexu)
      19              : !! This file is distributed under the terms of the
      20              : !! GNU General Public License, see ~abinit/COPYING
      21              : !! or http://www.gnu.org/copyleft/gpl.txt .
      22              : !! For the initials of contributors, see ~abinit/doc/developers/contributors.txt .
      23              : !!
      24              : !! SOURCE
      25              : 
      26              : 
      27              : #if defined HAVE_CONFIG_H
      28              : #include "config.h"
      29              : #endif
      30              : 
      31              : #include "abi_common.h"
      32              : 
      33              : module m_abstract_mover
      34              :   use defs_basis
      35              :   use m_abicore
      36              :   use m_errors
      37              : 
      38              :   use m_random_xoroshiro128plus, only: rng_t
      39              :   use m_multibinit_dataset, only: multibinit_dtset_type
      40              :   use m_abstract_potential, only: abstract_potential_t
      41              :   use m_multibinit_cell, only: mbcell_t, mbsupercell_t
      42              :   use m_hashtable_strval, only: hash_table_t
      43              :   implicit none
      44              : !!***
      45              : 
      46              :   private
      47              : 
      48              :   !-------------------------------------------------------------------!
      49              :   !>@brief Abstract_mover_t:
      50              :   !>  abstract mover. All the movers should be derived from this.
      51              :   !> A mover defines the evolution of a structure.
      52              :   !> it will call the potentials to calculate the energy derivative and E
      53              :   !> and use that to move the states.
      54              :   !
      55              :   !-------------------------------------------------------------------!
      56              :   type ,public :: abstract_mover_t
      57              :      ! This is the abstract class of mover
      58              :      ! It do the following things:
      59              :      ! calculate d(var)/dt and integrate new var.
      60              :      ! call functions to calculate observables.
      61              :      ! interact with hist file.
      62              : 
      63              :      ! a pointer to the supercell structure
      64              :      type(mbsupercell_t), pointer:: supercell=>null()
      65              :      type(hash_table_t), pointer :: etable=>null()
      66              :      ! a label for each mover. For printing out information
      67              :      character (len=200) :: label="Abstract Mover"
      68              :      ! time step.
      69              :      real(dp) :: dt= 0.0
      70              :      ! total time
      71              :      real(dp) :: total_time =0.0
      72              :      ! temperature (NOTE: It is not the real temperature of
      73              :      ! the structure, but a preset value, even when it is not
      74              :      ! a constant temperature mover!!!)
      75              :      real(dp) :: temperature =0.0
      76              :      ! time for themalization
      77              :      real(dp) :: thermal_time =0.0
      78              :      ! A pointer to the random number generator
      79              :      ! It is initialized outside the mover (by the manager).
      80              :      type(rng_t), pointer :: rng=>null()
      81              : 
      82              :    contains
      83              :      !procedure:: initialize       ! perhaps each effpot type should have own
      84              :      !procedure :: finalize
      85              :      procedure :: set_rng          ! set the pointer to an random number generator
      86              :      procedure :: set_params       ! set the parameters from input
      87              :      procedure :: set_initial_state ! initial state
      88              :      procedure:: run_one_step      ! defines how the system evolves.
      89              :      !procedure:: run_time
      90              :      !procedure:: run_temperature
      91              :      procedure :: reset            ! reset the mover
      92              :      procedure :: calc_observables ! call functions to calculate observables
      93              :      procedure :: write_hist       ! write hist file
      94              :   end type abstract_mover_t
      95              : 
      96              : contains
      97              : 
      98              :   !-------------------------------------------------------------------!
      99              :   ! set_rng:
     100              :   ! set the random number generator. The rng is already initialize
     101              :   ! outside.
     102              :   !-------------------------------------------------------------------!
     103            6 :   subroutine set_rng(self, rng)
     104              :     class(abstract_mover_t), intent(inout) :: self
     105              :     type(rng_t), target, intent(in) :: rng
     106            6 :     self%rng => rng
     107            6 :   end subroutine set_rng
     108              : 
     109              :   !-------------------------------------------------------------------!
     110              :   ! set_parms:
     111              :   !  set the variables using the input params
     112              :   !-------------------------------------------------------------------!
     113            0 :   subroutine set_params(self, params)
     114              :     ! set parameters from input file. (something else, like temperature for MvT calculation?)
     115              :     class(abstract_mover_t), intent(inout) :: self
     116              :     type(multibinit_dtset_type) :: params
     117            0 :     ABI_UNUSED_A(self)
     118            0 :     ABI_UNUSED_A(params)
     119            0 :     ABI_ERROR("set_params not implemented for this mover")
     120            0 :   end subroutine set_params
     121              : 
     122              :   !----------------------------------------------------------------------
     123              :   !> @brief set the pointer to supercell
     124              :   !> @param[in]  supercell
     125              :   !-------------------------------------------------------------------!
     126              :   subroutine set_supercell(self, supercell)
     127              :     class(abstract_mover_t), intent(inout) :: self
     128              :     type(mbsupercell_t), target :: supercell
     129              :     self%supercell=>supercell
     130              :   end subroutine set_supercell
     131              : 
     132              :   !----------------------------------------------------------------------
     133              :   !> @brief set initial state.
     134              :   !>
     135              :   !> @param[in]  mode: a integer to define the kind of initial state.
     136              :   !----------------------------------------------------------------------
     137            0 :   subroutine set_initial_state(self, mode)
     138              :     ! set initial positions, spin, etc
     139              :     class(abstract_mover_t), intent(inout) :: self
     140              :     integer, optional, intent(in) :: mode
     141              : 
     142            0 :     ABI_ERROR("set_initial_state not implemented for this mover")
     143            0 :     ABI_UNUSED_A(self)
     144              :     ABI_UNUSED(mode)
     145              : 
     146            0 :   end subroutine set_initial_state
     147              : 
     148              :   !-------------------------------------------------------------------!
     149              :   !> @brief: Run_one_step
     150              :   !>   effpot: the potential (which do the calculation of E and dE/dvar)
     151              :   !> param[in]: effpot
     152              :   !> param[in]: (optional) displacement
     153              :   !> param[in]: (optional) strain
     154              :   !> param[in]: (optional) spin
     155              :   !> param[in]: (optional) lwf
     156              :   ! NOTE: No need to pass the variable already saved in the mover.
     157              :   !     e.g. For spin mover, do NOT pass the spin to it.
     158              :   !    The other variables are only required if there is coupling with
     159              :   !    the mover variable.
     160              :   !-------------------------------------------------------------------!
     161            0 :   subroutine run_one_step(self, effpot, displacement, strain, spin, lwf, energy_table)
     162              :     ! run one step. (For MC also?)
     163              :     class(abstract_mover_t), intent(inout) :: self
     164              :     real(dp), optional, intent(inout) :: displacement(:,:), strain(:,:), spin(:,:), lwf(:)
     165              :     type(hash_table_t), optional, intent(inout) :: energy_table
     166              :     class(abstract_potential_t), intent(inout) :: effpot
     167            0 :     ABI_UNUSED_A(self)
     168            0 :     ABI_UNUSED_A(effpot)
     169            0 :     ABI_UNUSED_A(displacement)
     170            0 :     ABI_UNUSED_A(strain)
     171            0 :     ABI_UNUSED_A(spin)
     172            0 :     ABI_UNUSED_A(lwf)
     173            0 :     ABI_UNUSED_A(energy_table)
     174            0 :     ABI_ERROR("run_one_step not implemented for this mover")
     175            0 :   end subroutine run_one_step
     176              : 
     177              :   !-------------------------------------------------------------------!
     178              :   ! Reset:
     179              :   ! Reset the mover.
     180              :   ! It is used, when multiple sets of move are needed, e.g. for various
     181              :   ! temperature.
     182              :   !-------------------------------------------------------------------!
     183            0 :   subroutine reset(self)
     184              :     ! reset the state of mover (e.g. counter->0)
     185              :     ! so it can be reused.
     186              :     class(abstract_mover_t), intent(inout) :: self
     187            0 :     ABI_UNUSED_A(self)
     188            0 :     ABI_ERROR("reset not implemented for this mover")
     189            0 :   end subroutine reset
     190              : 
     191              :   !-------------------------------------------------------------------!
     192              :   !> @brief: calc_observables: calculate observables
     193              :   !-------------------------------------------------------------------!
     194            0 :   subroutine calc_observables(self)
     195              :     ! call functions to calculate observables.
     196              :     class(abstract_mover_t), intent(inout) :: self
     197            0 :     ABI_UNUSED_A(self)
     198            0 :     ABI_ERROR("calc_observables not implemented for this mover")
     199            0 :   end subroutine calc_observables
     200              : 
     201              :   !-------------------------------------------------------------------!
     202              :   !> @brief Write_hist:
     203              :   !   write to hist file.
     204              :   !-------------------------------------------------------------------!
     205            0 :   subroutine write_hist(self)
     206              :     ! write to hist file
     207              :     class(abstract_mover_t), intent(inout) :: self
     208            0 :     ABI_UNUSED_A(self)
     209            0 :     ABI_ERROR("write_hist not implemented for this mover")
     210            0 :   end subroutine write_hist
     211              : 
     212              :   !-------------------------------------------------------------------!
     213              :   !> @breif: Get_state: the current state
     214              :   !-------------------------------------------------------------------!
     215              :   subroutine get_state(self, displacement, strain, spin, lwf, ihist)
     216              :     ! get the state of the ihist(th) step. ihist can be 0 (current), -1 (last), ... -maxhist..
     217              :     !Note that the params are optional so it will be returned only if asked for.
     218              :     class(abstract_mover_t), intent(in):: self
     219              :     real(dp), optional, intent(inout) :: displacement, strain, spin, lwf
     220              :     integer, optional, intent(in):: ihist
     221              :     ABI_UNUSED_A(self)
     222              :     ABI_UNUSED_A(displacement)
     223              :     ABI_UNUSED_A(strain)
     224              :     ABI_UNUSED_A(spin)
     225              :     ABI_UNUSED_A(lwf)
     226              :     ABI_UNUSED_A(ihist)
     227              :     ABI_ERROR("get_state not implemented for this mover")
     228              :   end subroutine get_state
     229              : 
     230              : 
     231              : 
     232            0 : end module m_abstract_mover
        

Generated by: LCOV version 2.3-1