Generated from get_ke.c with ROBODoc v3.2.2 on Fri Sep 14 14:23:16 2001

TABLE OF CONTENTS

  1. QMD-MGDFT/get_ke.c

QMD-MGDFT/get_ke.c

NAME
   Ab initio real space code with multigrid acceleration
   Quantum molecular dynamics package.
   Version: 2.1.5
COPYRIGHT
   Copyright (C) 1995  Emil Briggs
   Copyright (C) 1998  Emil Briggs, Charles Brabec, Mark Wensell, 
                       Dan Sullivan, Chris Rapcewicz, Jerzy Bernholc
   Copyright (C) 2001  Emil Briggs, Wenchang Lu,
                       Marco Buongiorno Nardelli,Charles Brabec, 
                       Mark Wensell,Dan Sullivan, Chris Rapcewicz,
                       Jerzy Bernholc
FUNCTION
   REAL get_ke(STATE *sp, int tid)
   Computes the kinetic energy of a given orbital. 
INPUTS
   sp: points to orbital structure (see md.h)
   tid: thread ID
OUTPUT
   kinetic energy is returned
PARENTS
   quench.c
CHILDREN
   gather_psi.c pack_ptos.c app6_del2.c
SOURCE
    #include <float.h>
    #include <math.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include "md.h"
    
    
    
    #if GAMMA_PT
    REAL get_ke(STATE *sp, int tid)
    
    {
    
        int pbasis, sbasis;
        REAL *work1, *work2;
        REAL *tmp_psi, *sg_psi, KE;
        int dimx, dimy, dimz;
    
    #if 1
        REAL time1, time2;
        time1 = my_crtc();
    #endif
    
    
        dimx = sp->dimx;
        dimy = sp->dimy;
        dimz = sp->dimz;
        pbasis = sp->pbasis;
        sbasis = sp->sbasis;
    
    
        /* Grab some memory */
        sg_psi = (REAL *)get_mem(4 * (sbasis));
        tmp_psi = sg_psi + sbasis;
        work2 = tmp_psi + sbasis;
    
        gather_psi(tmp_psi, NULL, sp, tid);
    
        /* Pack psi into smoothing array */
        pack_ptos(sg_psi, tmp_psi, dimx, dimy, dimz);
    
        app6_del2((S0_GRID *)sg_psi, (P0_GRID *)work2);
    
        KE = -0.5 * ct.vel * QMD_sdot(pbasis, tmp_psi, 1, work2, 1);
        KE = real_sum_all(KE);
    
        /* Release our memory */
        release_mem(sg_psi);
    
    #if 1
        time2 = my_crtc();
        md_timings(MG_EIGTIME, (time2 - time1), tid);
    #endif
    
        return KE;
    
    } /* end get_ke */
    
    #else
    
    
    /* Complex version */
    REAL get_ke(STATE *sp, int tid)
    
    {
    
        int pbasis, sbasis;
        REAL *work1, *work2;
        REAL *tmp_psiR, *tmp_psiI, *sg_psiR, *sg_psiI, KE;
        int dimx, dimy, dimz;
    
    #if 1
        REAL time1, time2;
        time1 = my_crtc();
    #endif
    
    
        dimx = sp->dimx;
        dimy = sp->dimy;
        dimz = sp->dimz;
        pbasis = sp->pbasis;
        sbasis = sp->sbasis;
    
    
        /* Grab some memory */
        sg_psiR = (REAL *)get_mem(4 * (sbasis));
        tmp_psiR = sg_psiR + sbasis;
        work1 = tmp_psiR + sbasis;
    
        sg_psiI = (REAL *)get_mem(4 * (sbasis));
        tmp_psiI = sg_psiI + sbasis;
        work2 = tmp_psiI + sbasis;
    
    
        gather_psi(tmp_psiR, tmp_psiI, sp, tid);
    
        /* Pack psi into smoothing array */
        pack_ptos(sg_psiR, tmp_psiR, dimx, dimy, dimz);
    
        pack_ptos(sg_psiI, tmp_psiI, dimx, dimy, dimz);
      
        app6_del2((S0_GRID *)sg_psiR, (P0_GRID *)work1);
        app6_del2((S0_GRID *)sg_psiI, (P0_GRID *)work2);
    
        KE  = -0.5 * ct.vel * QMD_sdot(pbasis, tmp_psiR, 1, work1, 1);
        KE += -0.5 * ct.vel * QMD_sdot(pbasis, tmp_psiI, 1, work2, 1);
        KE = real_sum_all(KE);
    
        /* Release our memory */
        release_mem(sg_psiR);
        release_mem(sg_psiI);
    
    #if 1
        time2 = my_crtc();
        md_timings(MG_EIGTIME, (time2 - time1), tid);
    #endif
    
        return KE;
    
    
    } /* end get_ke */
    
    
    #endif