Generated from norm_psi.c with ROBODoc v3.2.2 on Fri Sep 14 14:23:21 2001
TABLE OF CONTENTS
- QMD-MGDFT/norm_psi.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
void norm_psi(STATE *sp, REAL bv)
This function normalizes an orbital to a specific value.
(psi, psi) = bv
INPUTS
sp: point to orbital structure, only use wave function here
bv: normalize to it
OUTPUT
wave function are updated to be normalized
PARENTS
init_wf.c init_wflcao.c sundiag_mpi.c subdiag_smp.c
CHILDREN
real_sum_all.c gather_psi.c scatter_psi.c
SOURCE
#include "md.h"
#include <float.h>
#include <math.h>
#include <stdlib.h>
/* This function is used to normalize the wavefunctions */
void norm_psi(STATE *sp, REAL bv)
{
int idx, incx=1, size;
REAL sum, sum1;
REAL *tmp_psiR, *tmp_psiI;
tmp_psiR = get_mem(2*sp->pbasis);
tmp_psiI = tmp_psiR + sp->pbasis;
#if GAMMA_PT
tmp_psiI = NULL;
#endif
gather_psi(tmp_psiR, tmp_psiI, sp, 0);
size = sp->pbasis;
#if GAMMA_PT
sum1 = snrm2(&size, tmp_psiR, &incx);
sum1 = sum1 * sum1 * sp->vel;
#else
sum1 = 0.0;
for(idx = 0;idx < size;idx++) {
sum1 += tmp_psiR[idx]*tmp_psiR[idx] + tmp_psiI[idx]*tmp_psiI[idx];
} /* end for */
sum1 = sum1 * sp->vel;
#endif
/*Now compute the sum over all processors */
sum1 = real_sum_all(sum1);
/* Normalize correctly */
sum = sqrt(bv / sum1);
QMD_sscal(size, sum, tmp_psiR, incx);
#if !GAMMA_PT
QMD_sscal(size, sum, tmp_psiI, incx);
#endif
scatter_psi(tmp_psiR, tmp_psiI, sp, 0);
release_mem(tmp_psiR);
my_barrier();
} /* end norm_psi */