LCOV - code coverage report
Current view: top level - src/grpp - grpp.c (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:b4bd748) Lines: 0 45 0.0 %
Date: 2025-03-09 07:56:22 Functions: 0 6 0.0 %

          Line data    Source code
       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 <stdlib.h>
      18             : 
      19             : #define LIBGRPP_MAX_NUMBER_POTENTIALS 100
      20             : 
      21           0 : libgrpp_grpp_t *libgrpp_new_grpp() {
      22           0 :   return (libgrpp_grpp_t *)calloc(1, sizeof(libgrpp_grpp_t));
      23             : }
      24             : 
      25           0 : void libgrpp_grpp_set_local_potential(libgrpp_grpp_t *grpp,
      26             :                                       libgrpp_potential_t *pot) {
      27           0 :   if (grpp->U_L != NULL) {
      28           0 :     libgrpp_delete_potential(grpp->U_L);
      29             :   }
      30             : 
      31           0 :   grpp->U_L = pot;
      32           0 : }
      33             : 
      34           0 : void libgrpp_grpp_add_averaged_potential(libgrpp_grpp_t *grpp,
      35             :                                          libgrpp_potential_t *pot) {
      36           0 :   if (grpp->n_arep == 0) {
      37           0 :     grpp->U_arep = (libgrpp_potential_t **)calloc(
      38             :         LIBGRPP_MAX_NUMBER_POTENTIALS, sizeof(libgrpp_potential_t *));
      39             :   }
      40             : 
      41           0 :   grpp->U_arep[grpp->n_arep++] = pot;
      42           0 : }
      43             : 
      44           0 : void libgrpp_grpp_add_spin_orbit_potential(libgrpp_grpp_t *grpp,
      45             :                                            libgrpp_potential_t *pot) {
      46           0 :   if (grpp->n_esop == 0) {
      47           0 :     grpp->U_esop = (libgrpp_potential_t **)calloc(
      48             :         LIBGRPP_MAX_NUMBER_POTENTIALS, sizeof(libgrpp_potential_t *));
      49             :   }
      50             : 
      51           0 :   grpp->U_esop[grpp->n_esop++] = pot;
      52           0 : }
      53             : 
      54           0 : void libgrpp_grpp_add_outercore_potential(libgrpp_grpp_t *grpp,
      55             :                                           libgrpp_potential_t *pot,
      56             :                                           libgrpp_shell_t *oc_shell) {
      57           0 :   if (grpp->n_oc_shells == 0) {
      58           0 :     grpp->U_oc = (libgrpp_potential_t **)calloc(LIBGRPP_MAX_NUMBER_POTENTIALS,
      59             :                                                 sizeof(libgrpp_potential_t *));
      60           0 :     grpp->oc_shells = (libgrpp_shell_t **)calloc(LIBGRPP_MAX_NUMBER_POTENTIALS,
      61             :                                                  sizeof(libgrpp_shell_t *));
      62             :   }
      63             : 
      64           0 :   grpp->U_oc[grpp->n_oc_shells] = pot;
      65           0 :   grpp->oc_shells[grpp->n_oc_shells] = oc_shell;
      66           0 :   grpp->n_oc_shells++;
      67           0 : }
      68             : 
      69           0 : void libgrpp_delete_grpp(libgrpp_grpp_t *grpp) {
      70           0 :   if (grpp == NULL) {
      71             :     return;
      72             :   }
      73             : 
      74             :   /*
      75             :    * scalar-relativistic part
      76             :    */
      77           0 :   if (grpp->U_L != NULL) {
      78           0 :     libgrpp_delete_potential(grpp->U_L);
      79             :   }
      80             : 
      81           0 :   for (int i = 0; i < grpp->n_arep; i++) {
      82           0 :     if (grpp->U_arep[i] != NULL) {
      83           0 :       libgrpp_delete_potential(grpp->U_arep[i]);
      84             :     }
      85             :   }
      86           0 :   free(grpp->U_arep);
      87             : 
      88             :   /*
      89             :    * effective spin-orbit operator
      90             :    */
      91           0 :   for (int i = 0; i < grpp->n_esop; i++) {
      92           0 :     if (grpp->U_esop[i] != NULL) {
      93           0 :       libgrpp_delete_potential(grpp->U_esop[i]);
      94             :     }
      95             :   }
      96           0 :   free(grpp->U_esop);
      97             : 
      98             :   /*
      99             :    * outercore shells and potentials
     100             :    */
     101           0 :   for (int i = 0; i < grpp->n_oc_shells; i++) {
     102           0 :     if (grpp->U_oc[i] != NULL) {
     103           0 :       libgrpp_delete_potential(grpp->U_oc[i]);
     104             :     }
     105           0 :     if (grpp->oc_shells[i] != NULL) {
     106           0 :       libgrpp_delete_shell(grpp->oc_shells[i]);
     107             :     }
     108             :   }
     109           0 :   free(grpp->U_oc);
     110           0 :   free(grpp->oc_shells);
     111             : 
     112           0 :   free(grpp);
     113             : }

Generated by: LCOV version 1.15