whitespace cleanup: replace tabs and remove trailing whitespace
This commit is contained in:
@ -26,7 +26,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
// Put together by John Smith john at arrows dot demon dot co dot uk,
|
||||
// Put together by John Smith john at arrows dot demon dot co dot uk,
|
||||
// using ideas by others.
|
||||
//
|
||||
// Calculate erf(z) for complex z.
|
||||
@ -34,7 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
// The code includes some hard coded constants that are intended to
|
||||
// give about 14 decimal places of accuracy. This is appropriate for
|
||||
// 64-bit floating point numbers.
|
||||
// 64-bit floating point numbers.
|
||||
//
|
||||
// Oct 1999: Fixed a typo that in
|
||||
// const Complex cerf_continued_fraction( const Complex z )
|
||||
@ -46,14 +46,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// Abramowitz and Stegun: (eqn: 7.1.14) gives this continued
|
||||
// fraction for erfc(z)
|
||||
//
|
||||
// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2
|
||||
// erfc(z) = sqrt(pi).exp(-z^2). 1 1/2 1 3/2 2 5/2
|
||||
// --- --- --- --- --- --- ...
|
||||
// z + z + z + z + z + z +
|
||||
//
|
||||
// This is evaluated using Lentz's method, as described in the narative
|
||||
// of Numerical Recipes in C.
|
||||
//
|
||||
// The continued fraction is true providing real(z)>0. In practice we
|
||||
// The continued fraction is true providing real(z)>0. In practice we
|
||||
// like real(z) to be significantly greater than 0, say greater than 0.5.
|
||||
//
|
||||
template< class Complex>
|
||||
@ -63,9 +63,9 @@ const Complex cerfc_continued_fraction( const Complex z )
|
||||
double eps = 1e-15 ; // large enough so that 1.0+eps > 1.0, when using
|
||||
// the floating point arithmetic
|
||||
//
|
||||
// first calculate z+ 1/2 1
|
||||
// first calculate z+ 1/2 1
|
||||
// --- --- ...
|
||||
// z + z +
|
||||
// z + z +
|
||||
Complex f(z) ;
|
||||
Complex C(f) ;
|
||||
Complex D(0.0) ;
|
||||
@ -80,7 +80,7 @@ const Complex cerfc_continued_fraction( const Complex z )
|
||||
C = z + a/C ;
|
||||
|
||||
if (D.real() == 0.0 && D.imag() == 0.0)
|
||||
D = tiny ;
|
||||
D = tiny ;
|
||||
|
||||
D = 1.0 / D ;
|
||||
|
||||
@ -134,9 +134,9 @@ const Complex cerf_series( const Complex z )
|
||||
|
||||
return sum * 2.0 / sqrt(M_PI) ;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Numerical Recipes quotes a formula due to Rybicki for evaluating
|
||||
// Numerical Recipes quotes a formula due to Rybicki for evaluating
|
||||
// Dawson's Integral:
|
||||
//
|
||||
// exp(-x^2) integral exp(t^2).dt = 1/sqrt(pi) lim sum exp(-(z-n.h)^2) / n
|
||||
@ -151,9 +151,9 @@ const Complex cerf_rybicki( const Complex z )
|
||||
double h = 0.2 ; // numerical experiment suggests this is small enough
|
||||
|
||||
//
|
||||
// choose an even n0, and then shift z->z-n0.h and n->n-h.
|
||||
// n0 is chosen so that real((z-n0.h)^2) is as small as possible.
|
||||
//
|
||||
// choose an even n0, and then shift z->z-n0.h and n->n-h.
|
||||
// n0 is chosen so that real((z-n0.h)^2) is as small as possible.
|
||||
//
|
||||
int n0 = 2*(int) (floor( z.imag()/(2*h) + 0.5 )) ;
|
||||
|
||||
Complex z0( 0.0, n0*h ) ;
|
||||
@ -161,14 +161,14 @@ const Complex cerf_rybicki( const Complex z )
|
||||
Complex sum(0.0,0.0) ;
|
||||
//
|
||||
// limits of sum chosen so that the end sums of the sum are
|
||||
// fairly small. In this case exp(-(35.h)^2)=5e-22
|
||||
// fairly small. In this case exp(-(35.h)^2)=5e-22
|
||||
//
|
||||
//
|
||||
for (int np=-35; np<=35; np+=2)
|
||||
{
|
||||
Complex t( zp.real(), zp.imag()-np*h) ;
|
||||
Complex b( exp(t*t) / (np+n0) ) ;
|
||||
sum += b ;
|
||||
sum += b ;
|
||||
}
|
||||
|
||||
sum = sum * 2 * exp(-z*z) / M_PI ;
|
||||
@ -180,7 +180,7 @@ template< class Complex>
|
||||
const Complex cerf( const Complex z )
|
||||
{
|
||||
//
|
||||
// Use the method appropriate to size of z -
|
||||
// Use the method appropriate to size of z -
|
||||
// there probably ought to be an extra option for NaN z, or infinite z
|
||||
//
|
||||
//
|
||||
@ -194,20 +194,20 @@ const Complex cerf( const Complex z )
|
||||
|
||||
//
|
||||
// Footnote:
|
||||
//
|
||||
//
|
||||
// Using the definitions from Abramowitz and Stegun (7.3.1, 7.3.2)
|
||||
// The fresnel intgerals defined as:
|
||||
//
|
||||
// / t=x
|
||||
// C(x) = | cos(pi/2 t^2) dt
|
||||
// /
|
||||
// t=0
|
||||
// t=0
|
||||
//
|
||||
// and
|
||||
// / t=x
|
||||
// S(x) = | sin(pi/2 t^2) dt
|
||||
// /
|
||||
// t=0
|
||||
// t=0
|
||||
//
|
||||
// These can be derived from erf(x) using 7.3.22
|
||||
//
|
||||
@ -216,8 +216,8 @@ const Complex cerf( const Complex z )
|
||||
// 2
|
||||
//
|
||||
// --------------------------------------------------------------------------
|
||||
// Some test examples -
|
||||
// comparative data taken from Abramowitz and Stegun table 7.9.
|
||||
// Some test examples -
|
||||
// comparative data taken from Abramowitz and Stegun table 7.9.
|
||||
// Table 7.9 tabulates w(z), where w(z) = exp(-z*z) erfc(iz)
|
||||
// I have copied twelve values of w(z) from the table, and separately
|
||||
// calculated them using this code. The results are identical.
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
*
|
||||
* Copyright (c), Ilya Valuev 2006 All Rights Reserved.
|
||||
*
|
||||
* Author : Ilya Valuev, MIPT, Moscow, Russia
|
||||
* Author : Ilya Valuev, MIPT, Moscow, Russia
|
||||
*
|
||||
* Project : ivutils
|
||||
* Project : ivutils
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*s****************************************************************************
|
||||
@ -250,7 +250,7 @@ public:
|
||||
if(man){
|
||||
iterator it=base_t::begin();
|
||||
for(;it!=base_t::end();++it)
|
||||
if(*it)
|
||||
if(*it)
|
||||
delete (*it);
|
||||
}
|
||||
base_t::clear();
|
||||
@ -427,7 +427,7 @@ class RefObject{
|
||||
void *ref_data;
|
||||
int ref_count;
|
||||
public:
|
||||
|
||||
|
||||
protected:
|
||||
virtual void delete_data(void *data);
|
||||
virtual void *new_data();
|
||||
@ -437,7 +437,7 @@ protected:
|
||||
|
||||
|
||||
class RefA: public RefObject{
|
||||
|
||||
|
||||
public:
|
||||
refA(){
|
||||
ref_data = new A;
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
*
|
||||
* Copyright (c), Ilya Valuev 2005 All Rights Reserved.
|
||||
*
|
||||
* Author : Ilya Valuev, MIPT, Moscow, Russia
|
||||
* Author : Ilya Valuev, MIPT, Moscow, Russia
|
||||
*
|
||||
* Project : GridMD, ivutils
|
||||
* Project : GridMD, ivutils
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/*s****************************************************************************
|
||||
* $Log: wpmd.h,v $
|
||||
* Revision 1.4 2011/06/11 16:53:55 valuev
|
||||
@ -134,8 +134,8 @@
|
||||
*******************************************************************************/
|
||||
# ifndef WPMD_H
|
||||
# define WPMD_H
|
||||
|
||||
/** @file wpmd.h
|
||||
|
||||
/** @file wpmd.h
|
||||
@brief Classes for Wave Packet Molecular Dynamics of two component plasma. */
|
||||
|
||||
# ifndef _USE_MATH_DEFINES
|
||||
@ -143,7 +143,7 @@
|
||||
# endif
|
||||
# include <complex>
|
||||
# include <vector>
|
||||
# include <cmath>
|
||||
# include <cmath>
|
||||
# include "logexc.h"
|
||||
# include "cvector_3.h"
|
||||
# include "pairhash.h"
|
||||
@ -168,7 +168,7 @@ const double h_plank2 = h_plank * 2.;
|
||||
inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){
|
||||
if((fabs(real(z))+fabs(imag(z)))<1e-8)
|
||||
return c*two_over_sqr_pi;
|
||||
else
|
||||
else
|
||||
return cerf(z*c)/z;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ inline cdouble cerf_div(const cdouble &z, const cdouble &c=i_unit){
|
||||
inline double erf_div(const double &z, double c=1){
|
||||
if(fabs(z)<1e-8)
|
||||
return c*two_over_sqr_pi;
|
||||
else
|
||||
else
|
||||
return erf(z*c)/z;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ public:
|
||||
|
||||
|
||||
OverlapDeriv():I0(0),I1(0),IDD(10){}
|
||||
|
||||
|
||||
void set1(const WavePacket& w1_) {
|
||||
w1=w1_;
|
||||
d1.set(w1);
|
||||
@ -330,7 +330,7 @@ public:
|
||||
|
||||
enum {NORM_UNDEFINED, NORM_CALCULATED, NORM_FACTORIZED, NORM_INVERTED};
|
||||
int norm_matrix_state[2];
|
||||
|
||||
|
||||
// Arrays for temporal data
|
||||
chmatrix IDD; // Second derivatives of the overlap integral (used in Norm matrix)
|
||||
vector<cdouble> ID, IDYs; // First derivatives of the overlap integral (used in Norm matrix)
|
||||
@ -346,7 +346,7 @@ public:
|
||||
/// HARTREE Hartree product (no antisymmetrization) \n
|
||||
/// DPRODUCT product of det0*det1 of antisymmetrized functions for spins 0, 1 \n
|
||||
/// UHF unrestricted Hartree-Fock
|
||||
enum APPROX {HARTREE, DPRODUCT, UHF } approx;
|
||||
enum APPROX {HARTREE, DPRODUCT, UHF } approx;
|
||||
///\em Sets overlap matrix element to zero if the overlap norm is less than this value
|
||||
double ovl_tolerance;
|
||||
|
||||
@ -375,14 +375,14 @@ public:
|
||||
|
||||
///\en 0 -- indicates that the inter-partition force should be full, and energy half,\n
|
||||
/// 1 -- inter-partition force and energy counts one half (LAMMPS compatibility)
|
||||
int newton_pair;
|
||||
int newton_pair;
|
||||
|
||||
//int myid; ///<\en id for partitions
|
||||
|
||||
|
||||
///\en Partition arrays storing the tags of particles. The initial tags should be >0.
|
||||
/// If the tag stored is <0, then the particle is ghost with -tag.
|
||||
/// partition1[2] is for ions, 0, 1 for each electron spin
|
||||
vector<int> partition1[3];
|
||||
vector<int> partition1[3];
|
||||
//vector<int> partition2[3]; ///<\en 2 for ions
|
||||
|
||||
|
||||
@ -391,7 +391,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term
|
||||
///\en 1 -- all my, -1 all other, 2 -- my mixed term, -2 -- other mixed term
|
||||
int check_ee(int s1,int icj1,int ick2){
|
||||
//printf(" (%d %d) ",partition1[s1][icj1],partition1[s1][ick2]);
|
||||
int c1=(int)(partition1[s1][icj1]>0);
|
||||
@ -402,8 +402,8 @@ public:
|
||||
int tag2=abs(partition1[s1][ick2]);
|
||||
int num=tag_index(tag1-1,tag2-1);
|
||||
if(num<0){ // compare wave packets
|
||||
int cmp= s1<2 ?
|
||||
wp[s1][icj1].compare(wp[s1][ick2],1e-15) :
|
||||
int cmp= s1<2 ?
|
||||
wp[s1][icj1].compare(wp[s1][ick2],1e-15) :
|
||||
compare_vec(xi[icj1],xi[ick2],1e-15);
|
||||
if((cmp>0 && c1) || (cmp<0 && c2))
|
||||
res= 2; // my mixed term
|
||||
@ -421,12 +421,12 @@ public:
|
||||
}
|
||||
|
||||
///\en Returns electron-electron inter-partition multipliers for energy (first) and force (second)
|
||||
/// for a 4- and 2- electron additive terms (all inter-partition interactions are
|
||||
/// for a 4- and 2- electron additive terms (all inter-partition interactions are
|
||||
/// calculated only once based on particle tags)
|
||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||
/// NOW ASSIGNS BASED ON THE FIRST PAIR ONLY
|
||||
pair<double, double> check_part1(int s1,int icj1,int ick2){
|
||||
int res=check_ee(s1,icj1,ick2);
|
||||
int res=check_ee(s1,icj1,ick2);
|
||||
if(res==1){ // my term
|
||||
//printf(" *\n");
|
||||
return make_pair(1.,1.); // all at my partition
|
||||
@ -439,7 +439,7 @@ public:
|
||||
//printf(" *\n");
|
||||
return make_pair(1.,1.); // my inter-partition
|
||||
}
|
||||
else if(res==-2){
|
||||
else if(res==-2){
|
||||
//printf(" \n");
|
||||
return make_pair(0., newton_pair ? 0.0 : 1. ); // other inter-partition: must add force if newton comm is off
|
||||
}
|
||||
@ -447,18 +447,18 @@ public:
|
||||
}
|
||||
|
||||
///\en Returns elctron-ion inter-partition multipliers for energy (first) and force (second)
|
||||
/// for ion-electron additive terms (all inter-partition interactions are
|
||||
/// for ion-electron additive terms (all inter-partition interactions are
|
||||
/// calculated only once based on particle tags)
|
||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||
/// BASED ON ION ATTACHMENT
|
||||
pair<double,double> check_part1ei(int s1,int icj1,int ick2, int ion){
|
||||
//printf("%d ",partition1[2][ion]);
|
||||
int ci=(int)(partition1[2][ion]>0);
|
||||
|
||||
|
||||
if(!newton_pair){ // care about mixed terms
|
||||
int cee=check_ee(s1,icj1,ick2);
|
||||
if((cee==2 || cee==-2) || (ci && cee==-1) || (!ci && cee==1)) // all mixed variants
|
||||
make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off
|
||||
make_pair(0., 1. ); // other inter-partition: must add force if newton comm is off
|
||||
}
|
||||
if(ci){
|
||||
//printf(" *\n");
|
||||
@ -471,7 +471,7 @@ public:
|
||||
}
|
||||
|
||||
///\en Returns ion-ion inter-partition multipliers for energy (first) and force (second)
|
||||
/// for ion-electron additive terms (all inter-partition interactions are
|
||||
/// for ion-electron additive terms (all inter-partition interactions are
|
||||
/// calculated only once based on particle tags)
|
||||
/// If force multiplier is zero, then the term may be omitted (energy will also be zero).
|
||||
pair<double,double> check_part1ii(int ion1, int ion2){
|
||||
@ -485,7 +485,7 @@ public:
|
||||
norm_matrix_state[0] = norm_matrix_state[1] = NORM_UNDEFINED;
|
||||
ovl_tolerance=0.;
|
||||
approx = DPRODUCT;
|
||||
|
||||
|
||||
me=m_electron;
|
||||
one_h=1./h_plank;
|
||||
h2_me=h_sq/me;
|
||||
@ -530,11 +530,11 @@ protected:
|
||||
///\en resizes all internal arrays according to new electrons added
|
||||
virtual void resize(int flag);
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///\en Prepares to setup a new system of particles using \ref add_ion() and add_electron().
|
||||
/// There is no need to call this function when using
|
||||
/// There is no need to call this function when using
|
||||
/// \ref set_electrons() and \ref set_ions() to setup particles.
|
||||
virtual void reset(){
|
||||
for(int s=0;s<2;s++){
|
||||
@ -556,10 +556,10 @@ public:
|
||||
//e 0x4 -- PBC along Z
|
||||
//e cell specifies the lengths of the simulation box in all directions
|
||||
//e if PBCs are used, the corresponding coordinates of electrons and ions
|
||||
//e in periodic directions must be within the range [0, cell[per_dir])
|
||||
//e in periodic directions must be within the range [0, cell[per_dir])
|
||||
//e @returns 1 if OK
|
||||
int set_pbc(const Vector_3P pcell=NULL, int pbc_=0x7);
|
||||
|
||||
|
||||
///\en Setup electrons: forms internal wave packet representations.
|
||||
/// If PBCs are used the coords must be within a range [0, cell).
|
||||
/// Default electron mass is AWPMD::me.
|
||||
@ -572,9 +572,9 @@ public:
|
||||
|
||||
///\en Adds an ion with charge q and position x,
|
||||
/// \return id of the ion starting from 0
|
||||
/// The tags must be nonzero, >0 for the local particle, <0 for ghost particle.
|
||||
/// The tags must be nonzero, >0 for the local particle, <0 for ghost particle.
|
||||
/// Unique particle id is abs(tag).
|
||||
/// Default tag (0) means inserting the current particle id as local particle.
|
||||
/// Default tag (0) means inserting the current particle id as local particle.
|
||||
int add_ion(double q, const Vector_3 &x, int tag=0){
|
||||
qi.push_back(q);
|
||||
xi.push_back(x);
|
||||
@ -586,24 +586,24 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//e calculates interaction in the system of ni ions + electrons
|
||||
//e calculates interaction in the system of ni ions + electrons
|
||||
//e the electonic subsystem must be previously setup by set_electrons, ionic by set_ions
|
||||
//e the iterators are describing ionic system only
|
||||
// 0x1 -- give back ion forces
|
||||
// 0x2 -- add ion forces to the existing set
|
||||
// 0x4 -- calculate derivatives for electronic time step (NOT IMPLEMENTED)
|
||||
//e if PBCs are used the coords must be within a range [0, cell)
|
||||
virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||
virtual int interaction(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
||||
|
||||
//e same as interaction, but using Hartee factorization (no antisymmetrization)
|
||||
virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||
virtual int interaction_hartree(int flag=0, Vector_3P fi=NULL, Vector_3P fe_x=NULL,
|
||||
Vector_3P fe_p=NULL, double *fe_w=NULL, double *fe_pw=NULL, Vector_2P fe_c=NULL);
|
||||
|
||||
///\en Calculates ion-ion interactions and updates Eii and ion forces if requested. This function
|
||||
/// is called form intaraction() and interaction_hartree if calc_ii is set.
|
||||
virtual int interaction_ii(int flag,Vector_3P fi=NULL);
|
||||
|
||||
|
||||
//e Calculates Norm matrix
|
||||
//e The result is saved in AWPMD::Norm[s]
|
||||
void norm_matrix(int s);
|
||||
@ -642,7 +642,7 @@ public:
|
||||
}
|
||||
|
||||
///\en Prepares force arrays according to \a flag setting for interaction()
|
||||
virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x,
|
||||
virtual void clear_forces(int flagi,Vector_3P fi, Vector_3P fe_x,
|
||||
Vector_3P fe_p, double *fe_w, double *fe_pw, Vector_2P fe_c=NULL);
|
||||
|
||||
|
||||
@ -651,7 +651,7 @@ public:
|
||||
/// Default mass (-1) is the electron mass AWPMD::me.
|
||||
WavePacket create_wp(Vector_3 &x, Vector_3 &v, double &w, double &pw, double mass=-1);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user