CP2K 2.4 (Revision 12889)
Functions | Variables

pw_grids Namespace Reference

This module defines the grid data type and some basic operations on it. More...

Functions

subroutine, public pw_grid_create (pw_grid, pe_group, local, error)
 Initialize a PW grid with all defaults.
LOGICAL, public pw_grid_compare (grida, gridb)
 Check if two pw_grids are equal.
subroutine, public get_pw_grid_info (pw_grid, id_nr, mode, vol, dvol, npts, ngpts, ngpts_cut, dr, cutoff, orthorhombic, gvectors, gsquare, error)
 Access to information stored in the pw_grid_type.
subroutine, public set_pw_grid_info (pw_grid, grid_span, npts, bounds, cutoff, spherical, error)
 Set some information stored in the pw_grid_type.
subroutine, public pw_grid_setup (cell, pw_grid, grid_span, cutoff, bounds, npts, spherical, odd, fft_usage, ncommensurate, icommensurate, blocked, ref_grid, rs_dims, iounit, error)
 sets up a pw_grid
subroutine pw_grid_setup_internal (cell, pw_grid, blocked, ref_grid, rs_dims, iounit, error)
 sets up a pw_grid, needs valid bounds as input, it is up to you to make sure of it using pw_grid_bounds_from_n
subroutine, public create_gvectors (pw_grid, cell, ecut, blocked, ref_grid, error)
subroutine pw_grid_print (pw_grid, info, error)
 Output of information on pw_grid.
subroutine pw_grid_distribute (pw_grid, yz_mask, ref_grid, blocked, rs_dims, error)
 Distribute grids in real and Fourier Space to the processors in group.
subroutine pre_tag (pw_grid, yz_mask, ref_grid)
subroutine order_mask (yz_mask, yz_index, error)
subroutine pw_grid_count (h_inv, pw_grid, cutoff, yz_mask)
 Count total number of g vectors.
subroutine pw_grid_assign (h_inv, pw_grid, cutoff, error)
 Setup maps from 1d to 3d space.
subroutine pw_grid_set_maps (grid_span, g_hat, mapl, mapm, mapn, npts)
 Setup maps from 1d to 3d space.
subroutine pw_grid_allocate (pw_grid, ng, bounds, error)
 Allocate all (Pointer) Arrays in pw_grid.
subroutine pw_grid_sort (pw_grid, ref_grid, error)
 Sort g-vectors according to length.
subroutine sort_shells (gsq, g_hat, idx, error)
subroutine redist (g_hat, idx, s1, s2, error)
subroutine pw_grid_remap (pw_grid, yz, error)
 Reorder yzq and yzp arrays for parallel FFT according to FFT mapping.
subroutine, public pw_grid_change (cell, pw_grid)
 Recalculate the g-vectors after a change of the box.
subroutine, public pw_grid_retain (pw_grid, error)
 retains the given pw grid
subroutine, public pw_grid_release (pw_grid, error)
 releases the given pw grid

Variables

INTEGER grid_tag = 0
CHARACTER(len=*), parameter,
private 
moduleN = 'pw_grids'

Detailed Description

This module defines the grid data type and some basic operations on it.

Note:
pw_grid_create : set the defaults pw_grid_release : release all memory connected to type pw_grid_setup : main routine to set up a grid input: cell (the box for the grid) pw_grid (the grid; pw_gridgrid_span has to be set) cutoff (optional, if not given pw_gridbounds has to be set) pe_group (optional, if not given we have a local grid)

if no cutoff or a negative cutoff is given, all g-vectors in the box are included (no spherical cutoff)

for a distributed setup the array in para rs_dims has to be initialized output: pw_grid

pw_grid_change : updates g-vectors after a change of the box

History
JGH (20-12-2000) : Adapted for parallel use JGH (07-02-2001) : Added constructor and destructor routines JGH (21-02-2003) : Generalized reference grid concept JGH (19-11-2007) : Refactoring and modularization JGH (21-12-2007) : pw_grid_setup refactoring
Author:
apsi CJM

Function Documentation

subroutine,public pw_grids::create_gvectors ( TYPE(pw_grid_type),pointer  pw_grid,
TYPE(cell_type),intent(in)  cell,
REAL(KIND=dp)  ecut,
INTEGER,optional  blocked,
TYPE(pw_grid_type),intent(in),optional  ref_grid,
TYPE(cp_error_type),intent(inout)  error 
)

Definition at line 513 of file pw_grids.f90.

References pw_grid_allocate(), pw_grid_assign(), pw_grid_count(), pw_grid_distribute(), pw_grid_remap(), and pw_grid_sort().

Here is the call graph for this function:

subroutine,public pw_grids::get_pw_grid_info ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(out),optional  id_nr,
INTEGER,intent(out),optional  mode,
REAL(dp),intent(out),optional  vol,
REAL(dp),intent(out),optional  dvol,
INTEGER,dimension(3),intent(out),optional  npts,
INTEGER(int_8),intent(out),optional  ngpts,
INTEGER(int_8),intent(out),optional  ngpts_cut,
REAL(dp),dimension(3),intent(out),optional  dr,
REAL(dp),intent(out),optional  cutoff,
LOGICAL,intent(out),optional  orthorhombic,
REAL(dp),dimension(:, :),optional,pointer  gvectors,
REAL(dp),dimension(:),optional,pointer  gsquare,
TYPE(cp_error_type),intent(inout)  error 
)

Access to information stored in the pw_grid_type.

History
none
Author:
JGH (17-Nov-2007)

Definition at line 173 of file pw_grids.f90.

References error.

Referenced by xray_diffraction::calculate_rhotot_elec_gspace(), qs_dftb_coulomb::dftb_spme_evaluate(), spme::spme_evaluate(), qs_scf_post_gpw::write_mo_free_results(), and xray_diffraction::xray_diffraction_spectrum().

Here is the caller graph for this function:

subroutine pw_grids::order_mask ( INTEGER,dimension(:, :),intent(in)  yz_mask,
INTEGER,dimension(:, :),intent(out)  yz_index,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Definition at line 1102 of file pw_grids.f90.

Referenced by pw_grid_distribute().

Here is the caller graph for this function:

subroutine pw_grids::pre_tag ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,dimension(:, :),intent(inout)  yz_mask,
TYPE(pw_grid_type),intent(in)  ref_grid 
) [private]

Definition at line 1037 of file pw_grids.f90.

References pw_grid_types::HALFSPACE.

Referenced by pw_grid_distribute().

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_allocate ( TYPE(pw_grid_type),intent(inout)  pw_grid,
INTEGER,intent(in)  ng,
INTEGER,dimension(:, :),intent(in)  bounds,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Allocate all (Pointer) Arrays in pw_grid.

History
JGH (20-12-2000) : Added status variable Bounds of arrays now from calling routine, this makes it independent from parallel setup
Author:
apsi Christopher Mundy

Definition at line 1609 of file pw_grids.f90.

References pw_grid_types::PW_MODE_DISTRIBUTED, and timings::timeset().

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_assign ( REAL(KIND=dp),dimension(3, 3)  h_inv,
TYPE(pw_grid_type),pointer  pw_grid,
REAL(KIND=dp),intent(in)  cutoff,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Setup maps from 1d to 3d space.

History
JGH (29-12-2000) : Adapted for parallel use
Author:
apsi Christopher Mundy

Definition at line 1330 of file pw_grids.f90.

References pw_grid_types::FULLSPACE, pw_grid_types::HALFSPACE, pw_grid_set_maps(), pw_grid_types::PW_MODE_DISTRIBUTED, pw_grid_types::PW_MODE_LOCAL, termination::stop_program(), timings::timeset(), and mathconstants::twopi.

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public pw_grids::pw_grid_change ( TYPE(cell_type),pointer  cell,
TYPE(pw_grid_type),pointer  pw_grid 
)

Recalculate the g-vectors after a change of the box.

History
JGH (20-12-2000) : get local grid size from definition of g. Assume that gsq is allocated. Local routine, no information on distribution of PW required. JGH (8-Mar-2001) : also update information on volume and grid spaceing
Author:
apsi Christopher Mundy

Definition at line 2047 of file pw_grids.f90.

References kinds::dp, REAL(), and mathconstants::twopi.

Referenced by dgs::dg_grid_change(), ewald_pw_methods::ewald_pw_grid_change(), and pw_env_methods::pw_env_rebuild().

Here is the call graph for this function:

Here is the caller graph for this function:

LOGICAL,public pw_grids::pw_grid_compare ( TYPE(pw_grid_type),intent(in)  grida,
TYPE(pw_grid_type),intent(in)  gridb 
)

Check if two pw_grids are equal.

History
none
Author:
JGH (14-Feb-2001)

Definition at line 150 of file pw_grids.f90.

Referenced by pw_poisson_methods::pw_poisson_solve(), pw_pool_types::pw_pool_give_back_pw(), and qs_vxc::qs_vxc_create().

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_count ( REAL(KIND=dp),dimension(3, 3)  h_inv,
TYPE(pw_grid_type),pointer  pw_grid,
REAL(KIND=dp),intent(in)  cutoff,
INTEGER,dimension(:, :),intent(out)  yz_mask 
) [private]

Count total number of g vectors.

History
JGH (22-12-2000) : Adapted for parallel use
Author:
apsi Christopher Mundy

Definition at line 1238 of file pw_grids.f90.

References pw_grid_types::FULLSPACE, util::get_limit(), pw_grid_types::HALFSPACE, pw_grid_types::PW_MODE_DISTRIBUTED, pw_grid_types::PW_MODE_LOCAL, termination::stop_program(), and mathconstants::twopi.

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public pw_grids::pw_grid_create ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(in)  pe_group,
LOGICAL,intent(in),optional  local,
TYPE(cp_error_type),intent(inout)  error 
)

Initialize a PW grid with all defaults.

History
JGH (21-Feb-2003) : initialize pw_gridreference
Author:
JGH (7-Feb-2001) & fawzi

Definition at line 77 of file pw_grids.f90.

References CPPostcondition, pw_grid_types::FULLSPACE, grid_tag, message_passing::mp_comm_dup(), pw_grid_types::PW_MODE_DISTRIBUTED, and pw_grid_types::PW_MODE_LOCAL.

Referenced by ewald_pw_types::ewald_pw_init(), library_tests::pw_fft_test(), qmmm_pw_grid::pw_grid_create_copy_no_pbc(), library_tests::rs_pw_transfer_test(), ewald_spline_util::Setup_Ewald_Spline(), and xc_derivative_set_types::xc_dset_create().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_distribute ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,dimension(:, :),intent(inout)  yz_mask,
TYPE(pw_grid_type),intent(in),optional  ref_grid,
INTEGER,intent(in),optional  blocked,
INTEGER,dimension(2),intent(in),optional  rs_dims,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Distribute grids in real and Fourier Space to the processors in group.

History
JGH (01-Mar-2001) optional reference grid JGH (22-May-2002) bug fix for pre_tag and HALFSPACE grids JGH (09-Sep-2003) reduce scaling for distribution
Author:
JGH (22-12-2000)

Definition at line 681 of file pw_grids.f90.

References util::get_limit(), pw_grid_types::HALFSPACE, message_passing::mp_cart_coords(), message_passing::mp_cart_create(), message_passing::mp_cart_rank(), message_passing::mp_dims_create(), message_passing::MPI_COMM_SELF, order_mask(), pre_tag(), pw_grid_types::PW_MODE_DISTRIBUTED, pw_grid_types::PW_MODE_LOCAL, and timings::timeset().

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_print ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(in)  info,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Output of information on pw_grid.

Author:
JGH[18-05-2007] from earlier versions

Definition at line 565 of file pw_grids.f90.

References pw_grid_types::HALFSPACE, pw_grid_types::PW_MODE_LOCAL, and REAL().

Referenced by pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public pw_grids::pw_grid_release ( TYPE(pw_grid_type),pointer  pw_grid,
TYPE(cp_error_type),intent(inout)  error 
)

releases the given pw grid

Parameters:
pw_gridthe pw grid to release
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
see doc/ReferenceCounting.html
History
04.2003 created [fawzi]
Author:
fawzi

Definition at line 2133 of file pw_grids.f90.

References CPPostconditionNoFail, CPPreconditionNoFail, message_passing::mp_comm_free(), and pw_grid_types::PW_MODE_DISTRIBUTED.

Referenced by cp_ddapc_types::cp_ddapc_ewald_release(), pw_poisson_types::pw_poisson_release(), qmmm_types::qmmm_per_pot_type_dealloc(), and realspace_grid_types::rs_grid_release_descriptor().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_remap ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,dimension(:, :),intent(out)  yz,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Reorder yzq and yzp arrays for parallel FFT according to FFT mapping.

History
none
Author:
JGH (17-Jan-2001)

Definition at line 1970 of file pw_grids.f90.

References pw_grid_types::HALFSPACE, pw_grid_types::PW_MODE_LOCAL, and timings::timeset().

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine,public pw_grids::pw_grid_retain ( TYPE(pw_grid_type),pointer  pw_grid,
TYPE(cp_error_type),intent(inout)  error 
)

retains the given pw grid

Parameters:
pw_gridthe pw grid to retain
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
see doc/ReferenceCounting.html
History
04.2003 created [fawzi]
Author:
fawzi

Definition at line 2104 of file pw_grids.f90.

References CPPreconditionNoFail.

subroutine pw_grids::pw_grid_set_maps ( INTEGER,intent(in)  grid_span,
INTEGER,dimension(:, :),intent(in)  g_hat,
TYPE(map_pn),intent(inout)  mapl,
TYPE(map_pn),intent(inout)  mapm,
TYPE(map_pn),intent(inout)  mapn,
INTEGER,dimension(:),intent(in)  npts 
) [private]

Setup maps from 1d to 3d space.

Note:
Maps are to full 3D space (not distributed)
History
JGH (21-12-2000) : Size of g_hat locally determined
Author:
apsi Christopher Mundy

Definition at line 1543 of file pw_grids.f90.

References pw_grid_types::HALFSPACE.

Referenced by pw_grid_assign().

Here is the caller graph for this function:

subroutine,public pw_grids::pw_grid_setup ( TYPE(cell_type),intent(in)  cell,
TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(in),optional  grid_span,
REAL(KIND=dp),intent(in),optional  cutoff,
INTEGER,dimension(2, 3),intent(in),optional  bounds,
INTEGER,dimension(3),intent(in),optional  npts,
LOGICAL,intent(in),optional  spherical,
LOGICAL,intent(in),optional  odd,
LOGICAL,intent(in),optional  fft_usage,
INTEGER,intent(in),optional  ncommensurate,
INTEGER,intent(in),optional  icommensurate,
INTEGER,intent(in),optional  blocked,
TYPE(pw_grid_type),intent(in),optional  ref_grid,
INTEGER,dimension(2),intent(in),optional  rs_dims,
INTEGER,intent(in),optional  iounit,
TYPE(cp_error_type),intent(inout)  error 
)

sets up a pw_grid

Parameters:
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
this is the function that should be used in the future
Author:
JGH (21-Dec-2007)

Definition at line 279 of file pw_grids.f90.

References error, pw_grid_info::pw_find_cutoff(), pw_grid_setup_internal(), set_pw_grid_info(), termination::stop_program(), and timings::timeset().

Here is the call graph for this function:

subroutine pw_grids::pw_grid_setup_internal ( TYPE(cell_type),intent(in)  cell,
TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(in),optional  blocked,
TYPE(pw_grid_type),intent(in),optional  ref_grid,
INTEGER,dimension(2),intent(in),optional  rs_dims,
INTEGER,intent(in),optional  iounit,
TYPE(cp_error_type),intent(inout)  error 
) [private]

sets up a pw_grid, needs valid bounds as input, it is up to you to make sure of it using pw_grid_bounds_from_n

Parameters:
errorvariable to control error logging, stopping,... see module cp_error_handling
Note:
this is the function that should be used in the future
History
JGH (20-Dec-2000) : Adapted for parallel use JGH (28-Feb-2001) : New optional argument fft_usage JGH (21-Mar-2001) : Reference grid code JGH (21-Mar-2001) : New optional argument symm_usage JGH (22-Mar-2001) : Simplify group assignment (mp_comm_dup) JGH (21-May-2002) : Remove orthorhombic keyword (code is fast enough) JGH (19-Feb-2003) : Negative cutoff can be used for non-spheric grids Joost VandeVondele (Feb-2004) : optionally generate pw grids that are commensurate in rs JGH (18-Dec-2007) : Refactoring
Author:
fawzi

Definition at line 409 of file pw_grids.f90.

References kinds::dp, message_passing::mp_comm_compare(), pw_grid_allocate(), pw_grid_assign(), pw_grid_count(), pw_grid_distribute(), pw_grid_print(), pw_grid_remap(), pw_grid_sort(), pw_grid_types::PW_MODE_DISTRIBUTED, and REAL().

Referenced by pw_grid_setup().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::pw_grid_sort ( TYPE(pw_grid_type),intent(inout)  pw_grid,
TYPE(pw_grid_type),intent(in),optional  ref_grid,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Sort g-vectors according to length.

History
JGH (20-12-2000) : allocate idx, ng = SIZE ( pw_grid % gsq ) the sorting is local and independent from parallelisation WARNING: Global ordering depends now on the number of cpus. JGH (28-02-2001) : check for ordering against reference grid JGH (01-05-2001) : sort spherical cutoff grids also within shells reference grids for non-spherical cutoffs JGH (20-06-2001) : do not sort non-spherical grids JGH (19-02-2003) : Order all grids, this makes subgrids also for non-spherical cutoffs possible JGH (21-02-2003) : Introduce gather array for general reference grids
Author:
apsi Christopher Mundy

Definition at line 1683 of file pw_grids.f90.

References sort_shells(), termination::stop_program(), and timings::timeset().

Referenced by create_gvectors(), and pw_grid_setup_internal().

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine pw_grids::redist ( INTEGER,dimension(:, :),intent(in)  g_hat,
INTEGER,dimension(:),intent(inout)  idx,
INTEGER,intent(in)  s1,
INTEGER,intent(in)  s2,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Definition at line 1917 of file pw_grids.f90.

Referenced by sort_shells().

Here is the caller graph for this function:

subroutine,public pw_grids::set_pw_grid_info ( TYPE(pw_grid_type),pointer  pw_grid,
INTEGER,intent(in),optional  grid_span,
INTEGER,dimension(3),intent(in),optional  npts,
INTEGER,dimension(2, 3),intent(in),optional  bounds,
REAL(KIND=dp),intent(in),optional  cutoff,
LOGICAL,intent(in),optional  spherical,
TYPE(cp_error_type),intent(inout)  error 
)

Set some information stored in the pw_grid_type.

History
none
Author:
JGH (19-Nov-2007)

Definition at line 223 of file pw_grids.f90.

References CPPostcondition, and error.

Referenced by pw_grid_setup().

Here is the caller graph for this function:

subroutine pw_grids::sort_shells ( REAL(KIND=dp),dimension(:),intent(in)  gsq,
INTEGER,dimension(:, :),intent(in)  g_hat,
INTEGER,dimension(:),intent(inout)  idx,
TYPE(cp_error_type),intent(inout)  error 
) [private]

Definition at line 1872 of file pw_grids.f90.

References redist(), and timings::timeset().

Referenced by pw_grid_sort().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 66 of file pw_grids.f90.

Referenced by pw_grid_create().

CHARACTER(len=*),parameter,private pw_grids::moduleN = 'pw_grids'

Definition at line 67 of file pw_grids.f90.