(git:ed6f26b)
Loading...
Searching...
No Matches
grpp_shell.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: MIT */
6/*----------------------------------------------------------------------------*/
7
8/*
9 * libgrpp - a library for the evaluation of integrals over
10 * generalized relativistic pseudopotentials.
11 *
12 * Copyright (C) 2021-2023 Alexander Oleynichenko
13 */
14
15/*
16 * representation of atom-centered shell of contracted Gaussian functions
17 */
18#include <math.h>
19#include <stdlib.h>
20
21#ifndef M_PI
22#define M_PI 3.1415926535897932384626433
23#endif
24
25#include "libgrpp.h"
26
27#include "grpp_norm_gaussian.h"
28
29/**
30 * constructs new object representing a shell; returns pointer to it.
31 */
32libgrpp_shell_t *libgrpp_new_shell(double *origin, int L, int num_primitives,
33 double *coeffs, double *alpha) {
34 libgrpp_shell_t *shell = (libgrpp_shell_t *)malloc(sizeof(libgrpp_shell_t));
35
36 shell->L = L;
37 shell->origin[0] = origin[0];
38 shell->origin[1] = origin[1];
39 shell->origin[2] = origin[2];
40 shell->cart_size = (L + 1) * (L + 2) / 2;
42
43 shell->num_primitives = num_primitives;
44 shell->coeffs = (double *)calloc(num_primitives, sizeof(double));
45 shell->alpha = (double *)calloc(num_primitives, sizeof(double));
46 for (int i = 0; i < num_primitives; i++) {
47 shell->coeffs[i] = coeffs[i];
48 shell->alpha[i] = alpha[i];
49 }
50
51 return shell;
52}
53
54/**
55 * creates deep copy of the 'libgrpp_shell_t' object
56 */
59 src_shell->origin, src_shell->L, src_shell->num_primitives,
60 src_shell->coeffs, src_shell->alpha);
61
62 return new_shell;
63}
64
65/**
66 * removes primitive gaussians (from the contracted function)
67 * with zero coefficients
68 */
70 int nprim = 0;
71
72 for (int i = 0; i < shell->num_primitives; i++) {
73 if (fabs(shell->coeffs[i]) > LIBGRPP_ZERO_THRESH) {
74 shell->coeffs[nprim] = shell->coeffs[i];
75 shell->alpha[nprim] = shell->alpha[i];
76 nprim++;
77 }
78 }
79
80 shell->num_primitives = nprim;
81}
82
83/**
84 * multiplies coefficients of the primitive gaussians by their normalization
85 * factors
86 */
88 for (int i = 0; i < shell->num_primitives; i++) {
89 double norm_factor =
90 libgrpp_gaussian_norm_factor(shell->L, 0, 0, shell->alpha[i]);
91 shell->coeffs[i] *= norm_factor;
92 }
93}
94
95/**
96 * returns number of Cartesian primitives encapsulated inside the shell
97 */
98int libgrpp_get_shell_size(libgrpp_shell_t *shell) { return shell->cart_size; }
99
100/**
101 * destructor for the shell object
102 */
104 free(shell->cart_list);
105 free(shell->coeffs);
106 free(shell->alpha);
107 free(shell);
108}
109
111 int ncart = (L + 1) * (L + 2) / 2;
112
113 int *cart_list = (int *)calloc(3 * ncart, sizeof(int));
115
116 return cart_list;
117}
static void const int const int i
static double norm_factor(double alpha, int L)
double libgrpp_gaussian_norm_factor(int n, int l, int m, double alpha)
libgrpp_parameters_t libgrpp_params
int libgrpp_get_shell_size(libgrpp_shell_t *shell)
Definition grpp_shell.c:98
libgrpp_shell_t * libgrpp_new_shell(double *origin, int L, int num_primitives, double *coeffs, double *alpha)
Definition grpp_shell.c:32
void libgrpp_delete_shell(libgrpp_shell_t *shell)
Definition grpp_shell.c:103
void libgrpp_shell_mult_normcoef(libgrpp_shell_t *shell)
Definition grpp_shell.c:87
libgrpp_shell_t * libgrpp_shell_deep_copy(libgrpp_shell_t *src_shell)
Definition grpp_shell.c:57
int * libgrpp_generate_shell_cartesians(int L)
Definition grpp_shell.c:110
void libgrpp_shell_shrink(libgrpp_shell_t *shell)
Definition grpp_shell.c:69
#define LIBGRPP_ZERO_THRESH
int(* cartesian_generator)(int L, int *cart_list)