(git:b195825)
libcp2k.h File Reference
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  cp2k_transport_parameters
 Transport parameters read from a CP2K input file. This definition matches the respective type definition in the transport_env_types module. More...
 
struct  cp2k_csr_interop_type
 CP2K's C-interoperable CSR matrix This definition matches the respective type definition in the transport_env_types module. More...
 

Typedefs

typedef int force_env_t
 Definitions for the functions exported in libcp2k.F. More...
 
typedef void(* ext_method_callback_f_ptr) (cp2k_transport_parameters, cp2k_csr_interop_type, cp2k_csr_interop_type, cp2k_csr_interop_type *, cp2k_csr_interop_type *)
 Function pointer type for the externally evaluated density matrix Function pointer type pointing to a C routine that takes the S and H matrices as input and outputs a P matrix. More...
 

Functions

void cp2k_get_version (char *version_str, int str_length)
 Get the CP2K version string. More...
 
void cp2k_init ()
 Initialize CP2K and MPI. More...
 
void cp2k_init_without_mpi ()
 Initialize CP2K without initializing MPI. More...
 
void cp2k_finalize ()
 Finalize CP2K and MPI. More...
 
void cp2k_finalize_without_mpi ()
 Finalize CP2K and without finalizing MPI. More...
 
void cp2k_create_force_env (force_env_t *new_force_env, const char *input_file_path, const char *output_file_path)
 Create a new force environment. More...
 
void cp2k_create_force_env_comm (force_env_t *new_force_env, const char *input_file_path, const char *output_file_path, int mpi_comm)
 Create a new force environment (custom managed MPI) More...
 
void cp2k_destroy_force_env (force_env_t force_env)
 Destroy/cleanup a force environment. More...
 
void cp2k_set_positions (force_env_t force_env, const double *new_pos, int n_el)
 Set positions of the particles. More...
 
void cp2k_set_velocities (force_env_t force_env, const double *new_vel, int n_el)
 Set velocity of the particles. More...
 
void cp2k_set_cell (force_env_t force_env, const double *new_cell)
 Set the size of the cell. More...
 
void cp2k_get_result (force_env_t force_env, const char *description, double *result, int n_el)
 Get an arbitrary result as 1D array from CP2K. More...
 
void cp2k_get_natom (force_env_t force_env, int *natom)
 Get the number of atoms. More...
 
void cp2k_get_nparticle (force_env_t force_env, int *nparticle)
 Get the number of particles. More...
 
void cp2k_get_positions (force_env_t force_env, double *pos, int n_el)
 Get the positions of the particles. More...
 
void cp2k_get_forces (force_env_t force_env, double *force, int n_el)
 Get the forces for the particles. More...
 
void cp2k_get_potential_energy (force_env_t force_env, double *e_pot)
 Get the potential energy of the system. More...
 
void cp2k_get_cell (force_env_t force_env, const double *cell)
 Get the size of the cell. More...
 
void cp2k_get_qmmm_cell (force_env_t force_env, const double *cell)
 Get the size of the qmmm cell. More...
 
void cp2k_calc_energy_force (force_env_t force_env)
 Calculate energy and forces of the system. More...
 
void cp2k_calc_energy (force_env_t force_env)
 Calculate only the energy of the system. More...
 
void cp2k_run_input (const char *input_file_path, const char *output_file_path)
 Make a CP2K run with the given input file. More...
 
void cp2k_run_input_comm (const char *input_file_path, const char *output_file_path, int mpi_comm)
 Make a CP2K run with the given input file (custom managed MPI) More...
 
void cp2k_transport_set_callback (force_env_t force_env, ext_method_callback_f_ptr func)
 Set the function callback for the externally evaluated density matrix. More...
 
int cp2k_active_space_get_mo_count (force_env_t force_env)
 Get the number of molecular orbitals in the active space. More...
 
long int cp2k_active_space_get_fock_sub (force_env_t force_env, double *buf, long int buf_len)
 Get the Fock submatrix for the active space. More...
 
long int cp2k_active_space_get_eri_nze_count (force_env_t force_env)
 Get the number of non-zero elements in the ERI matrix. More...
 
int cp2k_active_space_get_eri (force_env_t force_env, int *buf_coords, long int buf_coords_len, double *buf_values, long int buf_values_len)
 Get the non-zero elements of the ERI matrix The buf_coords will contain the coordinates in the format [i1, j1, k1, l1, i2, j2, k2, l2, ... ]. More...
 

Typedef Documentation

◆ force_env_t

typedef int force_env_t

Definitions for the functions exported in libcp2k.F.

Author
Mohammad Hossein Bani-Hashemian

Definition at line 22 of file libcp2k.h.

◆ ext_method_callback_f_ptr

Function pointer type for the externally evaluated density matrix Function pointer type pointing to a C routine that takes the S and H matrices as input and outputs a P matrix.

Function definition example:

void c_scf_method(
cp2k_transport_parameters cp2k_transport_params,
);
CP2K's C-interoperable CSR matrix This definition matches the respective type definition in the trans...
Definition: libcp2k.h:268
Transport parameters read from a CP2K input file. This definition matches the respective type definit...
Definition: libcp2k.h:208
See also
cp2k_transport_parameters, cp2k_csr_interop_type

Definition at line 299 of file libcp2k.h.

Function Documentation

◆ cp2k_get_version()

void cp2k_get_version ( char *  version_str,
int  str_length 
)

Get the CP2K version string.

Parameters
version_strThe buffer to write the version string into
str_lengthThe size of the buffer (must be large enough)
Here is the caller graph for this function:

◆ cp2k_init()

void cp2k_init ( )

Initialize CP2K and MPI.

Warning
You are supposed to call cp2k_finalize() before exiting the program.
Here is the caller graph for this function:

◆ cp2k_init_without_mpi()

void cp2k_init_without_mpi ( )

Initialize CP2K without initializing MPI.

Warning
You are supposed to call cp2k_finalize() before exiting the program.

◆ cp2k_finalize()

void cp2k_finalize ( )

Finalize CP2K and MPI.

◆ cp2k_finalize_without_mpi()

void cp2k_finalize_without_mpi ( )

Finalize CP2K and without finalizing MPI.

◆ cp2k_create_force_env()

void cp2k_create_force_env ( force_env_t new_force_env,
const char *  input_file_path,
const char *  output_file_path 
)

Create a new force environment.

Parameters
new_force_envthe created force environment
input_file_pathPath to a CP2K input file
output_file_pathPath to a file where CP2K is going to append its output (created if non-existent)
Warning
You are supposed to call cp2k_destroy_force_env() to cleanup, before cp2k_finalize().
Here is the caller graph for this function:

◆ cp2k_create_force_env_comm()

void cp2k_create_force_env_comm ( force_env_t new_force_env,
const char *  input_file_path,
const char *  output_file_path,
int  mpi_comm 
)

Create a new force environment (custom managed MPI)

Parameters
new_force_envthe created force environment
input_file_pathPath to a CP2K input file
output_file_pathPath to a file where CP2K is will write its output. Will be created if not existent, otherwise appended.
mpi_commFortran MPI communicator if MPI is not managed by CP2K
Warning
You are supposed to call cp2k_destroy_force_env() to cleanup, before cp2k_finalize().

◆ cp2k_destroy_force_env()

void cp2k_destroy_force_env ( force_env_t  force_env)

Destroy/cleanup a force environment.

Parameters
force_envthe force environment

◆ cp2k_set_positions()

void cp2k_set_positions ( force_env_t  force_env,
const double *  new_pos,
int  n_el 
)

Set positions of the particles.

Parameters
force_envthe force environment
new_posArray containing the new positions of the particles
n_elSize of the new_pos array

◆ cp2k_set_velocities()

void cp2k_set_velocities ( force_env_t  force_env,
const double *  new_vel,
int  n_el 
)

Set velocity of the particles.

Parameters
force_envthe force environment
new_velArray containing the new velocities of the particles
n_elSize of the new_vel array

◆ cp2k_set_cell()

void cp2k_set_cell ( force_env_t  force_env,
const double *  new_cell 
)

Set the size of the cell.

Parameters
force_envthe force environment
new_cellArray containing the new cell

◆ cp2k_get_result()

void cp2k_get_result ( force_env_t  force_env,
const char *  description,
double *  result,
int  n_el 
)

Get an arbitrary result as 1D array from CP2K.

Parameters
force_envthe force environment
descriptionThe string tag of the result
resultsPre-allocated array
n_elsize of the results array

◆ cp2k_get_natom()

void cp2k_get_natom ( force_env_t  force_env,
int *  natom 
)

Get the number of atoms.

Parameters
force_envthe force environment
natomThe number of atoms

◆ cp2k_get_nparticle()

void cp2k_get_nparticle ( force_env_t  force_env,
int *  nparticle 
)

Get the number of particles.

Parameters
force_envthe force environment
nparticleThe number of particles

◆ cp2k_get_positions()

void cp2k_get_positions ( force_env_t  force_env,
double *  pos,
int  n_el 
)

Get the positions of the particles.

Parameters
force_envthe force environment
posPre-allocated array of at least 3*nparticle elements. Use cp2k_get_nparticle() to get the number of particles.
n_elSize of the force array

◆ cp2k_get_forces()

void cp2k_get_forces ( force_env_t  force_env,
double *  force,
int  n_el 
)

Get the forces for the particles.

Parameters
force_envthe force environment
forcePre-allocated array of at least 3*nparticle elements. Use cp2k_get_nparticle() to get the number of particles.
n_elSize of the force array

◆ cp2k_get_potential_energy()

void cp2k_get_potential_energy ( force_env_t  force_env,
double *  e_pot 
)

Get the potential energy of the system.

Parameters
force_envthe force environment
e_potThe potential energy
Here is the caller graph for this function:

◆ cp2k_get_cell()

void cp2k_get_cell ( force_env_t  force_env,
const double *  cell 
)

Get the size of the cell.

Parameters
force_envthe force environment
cellArray containing the cell

◆ cp2k_get_qmmm_cell()

void cp2k_get_qmmm_cell ( force_env_t  force_env,
const double *  cell 
)

Get the size of the qmmm cell.

Parameters
force_envthe force environment
cellArray containing the qmmm cell

◆ cp2k_calc_energy_force()

void cp2k_calc_energy_force ( force_env_t  force_env)

Calculate energy and forces of the system.

Parameters
force_envthe force environment
Here is the caller graph for this function:

◆ cp2k_calc_energy()

void cp2k_calc_energy ( force_env_t  force_env)

Calculate only the energy of the system.

Parameters
force_envthe force environment

◆ cp2k_run_input()

void cp2k_run_input ( const char *  input_file_path,
const char *  output_file_path 
)

Make a CP2K run with the given input file.

Parameters
input_file_pathPath to a CP2K input file
output_file_pathPath to a file where CP2K is going to append its output (created if non-existent)

◆ cp2k_run_input_comm()

void cp2k_run_input_comm ( const char *  input_file_path,
const char *  output_file_path,
int  mpi_comm 
)

Make a CP2K run with the given input file (custom managed MPI)

Parameters
input_file_pathPath to a CP2K input file
output_file_pathPath to a file where CP2K is going to append its output (created if non-existent)
mpi_commFortran MPI communicator if MPI is not managed by CP2K

◆ cp2k_transport_set_callback()

void cp2k_transport_set_callback ( force_env_t  force_env,
ext_method_callback_f_ptr  func 
)

Set the function callback for the externally evaluated density matrix.

◆ cp2k_active_space_get_mo_count()

int cp2k_active_space_get_mo_count ( force_env_t  force_env)

Get the number of molecular orbitals in the active space.

Parameters
force_envthe force environment
Returns
The number of elements or -1 if unavailable

◆ cp2k_active_space_get_fock_sub()

long int cp2k_active_space_get_fock_sub ( force_env_t  force_env,
double *  buf,
long int  buf_len 
)

Get the Fock submatrix for the active space.

Parameters
force_envthe force environment
bufPre-allocated array of at least mo_count^2 elements. Use cp2k_active_space_get_mo_count() to get the number of molecular orbitals.
buf_lenSize of the buf array
Returns
The number of elements written to buf or -1 if unavailable

◆ cp2k_active_space_get_eri_nze_count()

long int cp2k_active_space_get_eri_nze_count ( force_env_t  force_env)

Get the number of non-zero elements in the ERI matrix.

Parameters
force_envthe force environment
Returns
The number of elements or -1 if unavailable

◆ cp2k_active_space_get_eri()

int cp2k_active_space_get_eri ( force_env_t  force_env,
int *  buf_coords,
long int  buf_coords_len,
double *  buf_values,
long int  buf_values_len 
)

Get the non-zero elements of the ERI matrix The buf_coords will contain the coordinates in the format [i1, j1, k1, l1, i2, j2, k2, l2, ... ].

Parameters
force_envthe force environment
buf_coordsPre-allocated array of at least 4*nze_count elements. Use cp2k_active_space_get_eri_nze_count() to get the number of non-zero elements.
buf_coords_lenSize of the buf_coords array
buf_valuesPre-allocated array of at least nze_count elements. Use cp2k_active_space_get_eri_nze_count() to get the number of non-zero elements.
buf_values_lenSize of the buf_values array
Returns
The number of elements written to buf_values or -1 if unavailable