(git:ed6f26b)
Loading...
Searching...
No Matches
grpp_full_grpp_integrals.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#include "libgrpp.h"
16
17#include <assert.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include "grpp_utils.h"
23
24/**
25 * Evaluates integrals over the full GRPP operator consisting of three parts:
26 * - scalar relativistic (local)
27 * - scalar relativistic (semi-local)
28 * - effective spin-orbit (semi-local)
29 * - outercore potentials (non-local)
30 *
31 * See libgrpp.h for the definition of the libgrpp_grpp_t structure.
32 */
34 libgrpp_shell_t *shell_B,
35 libgrpp_grpp_t *grpp_operator,
36 double *grpp_origin, double *arep_matrix,
37 double *so_x_matrix, double *so_y_matrix,
38 double *so_z_matrix) {
39 assert(libgrpp_is_initialized());
40
41 size_t size = shell_A->cart_size * shell_B->cart_size;
42 double *buf_arep = (double *)calloc(size, sizeof(double));
43 double *buf_so_x = (double *)calloc(size, sizeof(double));
44 double *buf_so_y = (double *)calloc(size, sizeof(double));
45 double *buf_so_z = (double *)calloc(size, sizeof(double));
46
47 memset(arep_matrix, 0, sizeof(double) * size);
48 memset(so_x_matrix, 0, sizeof(double) * size);
49 memset(so_y_matrix, 0, sizeof(double) * size);
50 memset(so_z_matrix, 0, sizeof(double) * size);
51
52 /*
53 * radially-local ("type-1") integrals
54 */
55 libgrpp_type1_integrals(shell_A, shell_B, grpp_origin, grpp_operator->U_L,
56 buf_arep);
57 libgrpp_daxpy(size, 1.0, buf_arep, arep_matrix);
58
59 /*
60 * semilocal AREP ("type-2") integrals
61 */
62 for (int L = 0; L < grpp_operator->n_arep; L++) {
63 libgrpp_type2_integrals(shell_A, shell_B, grpp_origin,
64 grpp_operator->U_arep[L], buf_arep);
65 libgrpp_daxpy(size, 1.0, buf_arep, arep_matrix);
66 }
67
68 /*
69 * semilocal SO ("type-3") integrals
70 */
71 for (int i_so = 0; i_so < grpp_operator->n_esop; i_so++) {
72 libgrpp_potential_t *so_potential = grpp_operator->U_esop[i_so];
73 libgrpp_spin_orbit_integrals(shell_A, shell_B, grpp_origin, so_potential,
74 buf_so_x, buf_so_y, buf_so_z);
75
76 int L = so_potential->L;
77 libgrpp_daxpy(size, 2.0 / (2 * L + 1), buf_so_x, so_x_matrix);
78 libgrpp_daxpy(size, 2.0 / (2 * L + 1), buf_so_y, so_y_matrix);
79 libgrpp_daxpy(size, 2.0 / (2 * L + 1), buf_so_z, so_z_matrix);
80 }
81
82 /*
83 * integrals over outercore non-local potentials,
84 * the part specific for GRPP.
85 *
86 * note that proper pre-factors for the SO part are calculated inside
87 * the libgrpp_outercore_potential_integrals() procedure.
88 */
90 shell_A, shell_B, grpp_origin, grpp_operator->n_oc_shells,
91 grpp_operator->U_oc, grpp_operator->oc_shells, buf_arep, buf_so_x,
92 buf_so_y, buf_so_z);
93
94 libgrpp_daxpy(size, 1.0, buf_arep, arep_matrix);
95 libgrpp_daxpy(size, 1.0, buf_so_x, so_x_matrix);
96 libgrpp_daxpy(size, 1.0, buf_so_y, so_y_matrix);
97 libgrpp_daxpy(size, 1.0, buf_so_z, so_z_matrix);
98
99 /*
100 * cleanup
101 */
102 free(buf_arep);
103 free(buf_so_x);
104 free(buf_so_y);
105 free(buf_so_z);
106}
void libgrpp_full_grpp_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, libgrpp_grpp_t *grpp_operator, double *grpp_origin, double *arep_matrix, double *so_x_matrix, double *so_y_matrix, double *so_z_matrix)
int libgrpp_is_initialized()
void libgrpp_outercore_potential_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *rpp_origin, int num_oc_shells, libgrpp_potential_t **oc_potentials, libgrpp_shell_t **oc_shells, double *arep, double *esop_x, double *esop_y, double *esop_z)
void libgrpp_spin_orbit_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *rpp_origin, libgrpp_potential_t *potential, double *so_x_matrix, double *so_y_matrix, double *so_z_matrix)
void libgrpp_type1_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *rpp_origin, libgrpp_potential_t *potential, double *matrix)
void libgrpp_type2_integrals(libgrpp_shell_t *shell_A, libgrpp_shell_t *shell_B, double *rpp_origin, libgrpp_potential_t *potential, double *matrix)
void libgrpp_daxpy(int n, double a, double *x, double *y)
Definition grpp_utils.c:46
libgrpp_potential_t ** U_esop
libgrpp_potential_t ** U_oc
libgrpp_shell_t ** oc_shells
libgrpp_potential_t * U_L
libgrpp_potential_t ** U_arep