(git:97501a3)
Loading...
Searching...
No Matches
grid_basis_set.c
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2025 CP2K developers group <https://cp2k.org> */
4/* */
5/* SPDX-License-Identifier: BSD-3-Clause */
6/*----------------------------------------------------------------------------*/
7
8#include <assert.h>
9#include <stdlib.h>
10#include <string.h>
11
12#include "grid_basis_set.h"
13
14/*******************************************************************************
15 * \brief Allocates a basis set which can be passed to grid_create_task_list.
16 * See grid_task_list.h for details.
17 * \author Ole Schuett
18 ******************************************************************************/
19void grid_create_basis_set(const int nset, const int nsgf, const int maxco,
20 const int maxpgf, const int lmin[nset],
21 const int lmax[nset], const int npgf[nset],
22 const int nsgf_set[nset], const int first_sgf[nset],
23 const double sphi[nsgf][maxco],
24 const double zet[nset][maxpgf],
25 grid_basis_set **basis_set_out) {
26
27 grid_basis_set *basis_set = malloc(sizeof(grid_basis_set));
28 assert(basis_set != NULL);
29
30 basis_set->nset = nset;
31 basis_set->nsgf = nsgf;
32 basis_set->maxco = maxco;
33 basis_set->maxpgf = maxpgf;
34
35 size_t size = nset * sizeof(int);
36 basis_set->lmin = malloc(size);
37 assert(basis_set->lmin != NULL || size == 0);
38 basis_set->lmax = malloc(size);
39 assert(basis_set->lmax != NULL || size == 0);
40 basis_set->npgf = malloc(size);
41 assert(basis_set->npgf != NULL || size == 0);
42 basis_set->nsgf_set = malloc(size);
43 assert(basis_set->nsgf_set != NULL || size == 0);
44 basis_set->first_sgf = malloc(size);
45 assert(basis_set->first_sgf != NULL || size == 0);
46 if (size != 0) {
47 memcpy(basis_set->lmin, lmin, size);
48 memcpy(basis_set->lmax, lmax, size);
49 memcpy(basis_set->npgf, npgf, size);
50 memcpy(basis_set->nsgf_set, nsgf_set, size);
51 memcpy(basis_set->first_sgf, first_sgf, size);
52 }
53
54 size = nsgf * maxco * sizeof(double);
55 basis_set->sphi = malloc(size);
56 assert(basis_set->sphi != NULL || size == 0);
57 if (size != 0) {
58 memcpy(basis_set->sphi, sphi, size);
59 }
60
61 size = nset * maxpgf * sizeof(double);
62 basis_set->zet = malloc(size);
63 assert(basis_set->zet != NULL || size == 0);
64 if (size != 0) {
65 memcpy(basis_set->zet, zet, size);
66 }
67
68 *basis_set_out = basis_set;
69}
70
71/*******************************************************************************
72 * \brief Deallocates given basis set.
73 * \author Ole Schuett
74 ******************************************************************************/
76 free(basis_set->lmin);
77 free(basis_set->lmax);
78 free(basis_set->npgf);
79 free(basis_set->nsgf_set);
80 free(basis_set->first_sgf);
81 free(basis_set->sphi);
82 free(basis_set->zet);
83 free(basis_set);
84}
85
86// EOF
void grid_create_basis_set(const int nset, const int nsgf, const int maxco, const int maxpgf, const int lmin[nset], const int lmax[nset], const int npgf[nset], const int nsgf_set[nset], const int first_sgf[nset], const double sphi[nsgf][maxco], const double zet[nset][maxpgf], grid_basis_set **basis_set_out)
Allocates a basis set which can be passed to grid_create_task_list. See grid_task_list....
void grid_free_basis_set(grid_basis_set *basis_set)
Deallocates given basis set.
Internal representation of a basis set.