vesin_c Module

This is a Fortran interface to the C-API of vesin, from the header vesin.h.



Enumerations

enum, bind(c)

Enumerators

enumerator:: VesinUnknownDevice = 0

Unknown device, used for default initialization and to indicate no allocated data.

enumerator:: VesinCPU = 1

CPU device

enumerator:: VesinCUDA = 2

CPU device

Description

Device type on which the data can be

enum, bind(c)

Enumerators

enumerator:: VesinAutoAlgorithm = 0

Automatically select algorithm based on system size

enumerator:: VesinBruteForce = 1

Brute-force O(n^2) algorithm with minimum image convention

enumerator:: VesinCellList = 2

Cell list algorithm with O(n) scaling

Description

Algorithm to use for neighbor list construction


Interfaces

interface

Compute a neighbor list.

The data is returned in a VesinNeighborList. For an initial call, the VesinNeighborList should be default-initalized. The VesinNeighborList can be re-used across calls to this functions to re-use memory allocations, and once it is no longer needed, users should call vesin_free to release the corresponding memory.

  • public function vesin_neighbors(points, n_points, box, periodic, device, options, neighbors, error_message) result(status) bind(c, name="vesin_neighbors")

    Arguments

    Type IntentOptional Attributes Name
    real(kind=c_double), intent(in) :: points(3,n_points)

    Positions of all points in the system;

    integer(kind=c_size_t), value :: n_points

    Number of elements in the points array

    real(kind=c_double), intent(in) :: box(3,3)

    Bounding box for the system. If the system is non-periodic, this is ignored. This should contain the three vectors of the bounding box, one vector per column of the matrix.

    logical(kind=c_bool) :: periodic(3)

    Is the system using periodic boundary conditions? This should be an array of three booleans, one for each dimension.

    type(VesinDevice), value :: device

    Device where the points and box data is allocated.

    type(VesinOptions), value :: options

    Options for the calculation

    type(VesinNeighborList) :: neighbors

    A type(VesinNeighborList) instance, that will be used to store the computed list of neighbors.

    type(c_ptr), intent(in) :: error_message

    A type(c_ptr) to a null-terminated char* containing the error message of this function if any.

    Return Value integer(kind=c_int)

    Non-zero integer upon error; zero otherwise.

interface

Free all allocated memory inside a VesinNeighborList, according to it's device.

  • public subroutine vesin_free(neighbors) bind(C, name="vesin_free")

    Arguments

    Type IntentOptional Attributes Name
    type(VesinNeighborList) :: neighbors

Derived Types

type, public, bind(c) ::  VesinDevice

Device on which data can be allocated

Components

Type Visibility Attributes Name Initial
integer(kind=c_int), public :: type = VesinUnknownDevice

Device type (VesinUnknownDevice, VesinCPU, etc.)

integer(kind=c_int), public :: device_id = 0

Device index (0 for CPU, GPU index for CUDA)

type, public, bind(c) ::  VesinOptions

Used for storing Vesin options.

Components

Type Visibility Attributes Name Initial
real(kind=c_double), public :: cutoff = 0.0_c_double

Spherical cutoff, only pairs below this cutoff will be included

logical(kind=c_bool), public :: full

Should the returned neighbor list be a full list (include both i -> j and j -> i pairs) or a half list (include only i -> j)?

logical(kind=c_bool), public :: sorted = .false.

Should the neighbor list be sorted? If .true., the returned pairs will be sorted by the first point index (i). The order of the second point index (j) and shifts in the list of pairs is unspecified.

integer(kind=c_int), public :: algorithm = VesinAutoAlgorithm

Which algorithm to use for the calculation

logical(kind=c_bool), public :: return_shifts = .false.

Should the returned VesinNeighborList contain shifts?

logical(kind=c_bool), public :: return_distances = .false.

Should the returned VesinNeighborList contain distances?

logical(kind=c_bool), public :: return_vectors = .false.

Should the returned VesinNeighborList contain vector?

real(kind=c_double), public :: skin = 0.0_c_double

Skin size for Verlet caching.

type, public, bind(c) ::  VesinNeighborList

Used as return type from vesin_neighbors().

Read more…

Components

Type Visibility Attributes Name Initial
integer(kind=c_size_t), public :: length = 0_c_size_t

Number of pairs in this neighbor list

type(VesinDevice), public :: device

Device used for the data allocations

type(c_ptr), public :: pairs = c_null_ptr

Array of pairs (storing the indices of the first and second point in the pair), containing length elements.

type(c_ptr), public :: shifts = c_null_ptr

Array of box shifts, one for each pair. This is only set if options.return_pairs was true during the calculation.

type(c_ptr), public :: distances = c_null_ptr

Array of pair distance (i.e. distance between the two points), one for each pair. This is only set if options.return_distances was true during the calculation.

type(c_ptr), public :: vectors = c_null_ptr

Array of pair vector (i.e. vector between the two points), one for each pair. This is only set if options.return_vector was true during the calculation.

type(c_ptr), public :: opaque = c_null_ptr

Private pointer used to hold additional internal data