mirror of https://github.com/QMCPACK/qmcpack.git
Merge branch 'develop' into remove-branch-clones
This commit is contained in:
commit
eb2086e2a6
|
@ -152,8 +152,8 @@ ENDFUNCTION()
|
|||
|
||||
FUNCTION(QMC_RUN_AND_CHECK BASE_NAME BASE_DIR PREFIX INPUT_FILE PROCS THREADS SHOULD_SUCCEED)
|
||||
# Map from name of check to appropriate flag for check_scalars.py
|
||||
LIST(APPEND SCALAR_CHECK_TYPE "kinetic" "totenergy" "variance" "eeenergy" "samples" "potential" "ionion" "localecp" "nonlocalecp" "flux" "kinetic_mixed" "kinetic_pure" "eeenergy_mixed" "eeenergy_pure" "potential_pure" "totenergy_A" "totenergy_B" "dtotenergy_AB" "ionion_A" "ionion_B" "dionion_AB" "eeenergy_A" "eeenergy_B" "deeenergy_AB" "Eloc" "ElocEstim")
|
||||
LIST(APPEND CHECK_SCALAR_FLAG "--ke" "--le" "--va" "--ee" "--ts" "--lp" "--ii" "--lpp" "--nlpp" "--fl" "--ke_m" "--ke_p" "--ee_m" "--ee_p" "--lp_p" "--le_A" "--le_B" "--dle_AB" "--ii_A" "--ii_B" "--dii_AB" "--ee_A" "--ee_B" "--dee_AB" "--eloc" "--elocest")
|
||||
LIST(APPEND SCALAR_CHECK_TYPE "kinetic" "totenergy" "variance" "eeenergy" "samples" "potential" "ionion" "localecp" "nonlocalecp" "flux" "kinetic_mixed" "kinetic_pure" "eeenergy_mixed" "eeenergy_pure" "potential_pure" "totenergy_A" "totenergy_B" "dtotenergy_AB" "ionion_A" "ionion_B" "dionion_AB" "eeenergy_A" "eeenergy_B" "deeenergy_AB" "Eloc" "ElocEstim" "latdev")
|
||||
LIST(APPEND CHECK_SCALAR_FLAG "--ke" "--le" "--va" "--ee" "--ts" "--lp" "--ii" "--lpp" "--nlpp" "--fl" "--ke_m" "--ke_p" "--ee_m" "--ee_p" "--lp_p" "--le_A" "--le_B" "--dle_AB" "--ii_A" "--ii_B" "--dii_AB" "--ee_A" "--ee_B" "--dee_AB" "--eloc" "--elocest" "--latdev")
|
||||
|
||||
|
||||
SET( TEST_ADDED FALSE )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
if [ $# -eq 1 ]; then
|
||||
QMCPACK_VER="$1"
|
||||
cp -p version.tex version.save.tex
|
||||
sed -i "s/development/$QMCPACK_VER/" version.tex
|
||||
sed -i "s/Development Version/$QMCPACK_VER/" version.tex
|
||||
fi
|
||||
|
||||
pdflatex qmcpack_manual.tex
|
||||
|
@ -14,5 +14,5 @@ pdflatex qmcpack_manual.tex
|
|||
|
||||
if [ ! -z "$QMCPACK_VER" ]; then
|
||||
mv version.save.tex version.tex
|
||||
echo added QMCPACK version $QMCPACK_VER
|
||||
echo Added QMCPACK version $QMCPACK_VER
|
||||
fi
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
\includegraphics[width=0.8\textwidth]{figures/QMCPACK_logo.png} \\
|
||||
{\huge User's Guide and Developer's Manual\\}
|
||||
{\huge Version~\QMCPACKver \\}
|
||||
{\huge \QMCPACKver \\}
|
||||
{\huge %v1.0\\
|
||||
\today}\\
|
||||
\vspace{2.5cm}
|
||||
|
|
|
@ -1 +1 @@
|
|||
\newcommand{\QMCPACKver}{development}
|
||||
\newcommand{\QMCPACKver}{Development Version}
|
||||
|
|
|
@ -327,10 +327,6 @@ ENDIF()
|
|||
SUBDIRS(QMCTools)
|
||||
#ENDIF(BUILD_QMCTOOLS)
|
||||
|
||||
IF(BUILD_SQD)
|
||||
SUBDIRS(SQD)
|
||||
ENDIF(BUILD_SQD)
|
||||
|
||||
if (BUILD_UNIT_TESTS) #{
|
||||
SET(HAS_TARGET_COMPILE_DEFINITIONS 1)
|
||||
IF (CMAKE_VERSION VERSION_LESS "2.8.11")
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
#// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
#// See LICENSE file in top directory for details.
|
||||
#//
|
||||
#// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
#//
|
||||
#// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
#//
|
||||
#// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/src/ohmms-config.h.cmake.in
|
||||
${qmcpack_BINARY_DIR}/src/ohmms-config.h)
|
||||
|
||||
SET(BASEDIR
|
||||
OhmmsApp/ProjectData.cpp
|
||||
Platforms/sysutil.cpp
|
||||
Message/Communicate.cpp
|
||||
)
|
||||
ADD_LIBRARY(qmcbase ${BASEDIR})
|
||||
|
||||
SET(HFSRCS
|
||||
Numerics/Clebsch_Gordan.cpp
|
||||
SQD/SphericalPotential/RadialPotential.cpp
|
||||
SQD/SphericalPotential/ZOverRPotential.cpp
|
||||
SQD/SphericalPotential/HarmonicPotential.cpp
|
||||
SQD/SphericalPotential/StepPotential.cpp
|
||||
SQD/SphericalPotential/SJPseudoPotential.cpp
|
||||
SQD/HartreeFock.cpp
|
||||
SQD/HartreeFock.IO.cpp
|
||||
SQD/SQDFrame.cpp
|
||||
SQD/HFApp.cpp
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(sqd ${HFSRCS})
|
||||
TARGET_LINK_LIBRARIES(sqd qmcbase)
|
|
@ -1,110 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include "Numerics/Clebsch_Gordan.h"
|
||||
|
||||
/**
|
||||
*@param lmax the maximum angular momentum
|
||||
*@brief Constructs all the Clebsch-Gordan coefficients
|
||||
for \f$ 0 \le l_1 \le l_{max}, 0 \le l_2 \le l_1 \f$.
|
||||
*
|
||||
This routine was adopted from a FORTRAN 77 algorithm taken
|
||||
from Rose's 'Elementary Theory of Angular Momentum', p. 39,
|
||||
Wigner's formula.
|
||||
Coeffienents known to be zero (because of either the
|
||||
L or M selection rules) are not computed, and these should not
|
||||
be sought.
|
||||
*@note The indexing of the vector is as follows:
|
||||
\f[ index = i + jI + kIJ + lIJK + mIJKL \f]
|
||||
where \f$ (I,J,K,L,M) \f$ are the maximum extent
|
||||
of the Clebsch-Gordon coefficients.
|
||||
*@note States with \f$ l > 6 \f$ are not allowed and will
|
||||
result in an error.
|
||||
*
|
||||
*/
|
||||
|
||||
Clebsch_Gordan::Clebsch_Gordan(const int lmax):
|
||||
Lmax(lmax), L1max(lmax+1), L2max(2*lmax+1)
|
||||
{
|
||||
CG_coeff.resize(L1max*L1max*L2max*L2max*L2max);
|
||||
for(int i=0; i<CG_coeff.size(); i++)
|
||||
CG_coeff[i] = 0.0;
|
||||
double si[33], fa[33], sum, prefactor;
|
||||
int lmin, i, l1, l2, l3, m1, m2, m3, nmin, nmax;
|
||||
si[0] = 1.0;
|
||||
fa[0] = 1.0;
|
||||
for(i=1; i<=32; i++)
|
||||
{
|
||||
si[i] = -si[i-1];
|
||||
fa[i] = static_cast<double>(i) * fa[i-1];
|
||||
}
|
||||
for(l1=0; l1<=Lmax; l1++)
|
||||
{
|
||||
for(l2=0; l2<=l1; l2++)
|
||||
{
|
||||
for(m1=-l1; m1<=l1; m1++)
|
||||
{
|
||||
for(m2=-l2; m2<=l2; m2++)
|
||||
{
|
||||
m3 = m1 + m2;
|
||||
lmin = std::abs(l1-l2);
|
||||
if(lmin < std::abs(m3))
|
||||
{
|
||||
lmin = std::abs(m3);
|
||||
}
|
||||
for(l3=lmin; l3<=l1+l2; l3++)
|
||||
{
|
||||
prefactor = 2.0*l3 + 1.0;
|
||||
prefactor *= fa[l3+l1-l2] / fa[l1+l2+l3+1];
|
||||
prefactor *= fa[l3-l1+l2] / fa[l1-m1];
|
||||
prefactor *= fa[l1+l2-l3] / fa[l1+m1];
|
||||
prefactor *= fa[l3+m3] / fa[l2-m2];
|
||||
prefactor *= fa[l3-m3] / fa[l2+m2];
|
||||
prefactor = sqrt(prefactor);
|
||||
nmax = l3 - l1 + l2;
|
||||
if(l3+m3 < nmax)
|
||||
{
|
||||
nmax = l3+m3;
|
||||
}
|
||||
nmin = 0;
|
||||
if(l1-l2-m3 < nmin)
|
||||
{
|
||||
nmin = -(l1-l2-m3);
|
||||
}
|
||||
sum = 0;
|
||||
for(i=nmin; i<=nmax; i++)
|
||||
{
|
||||
sum += (si[i+l2+m2]/fa[i]) * fa[l2+l3+m1-i] * fa[l1-m1+i]
|
||||
/ fa[l3-l1+l2-i] / fa[l3+m3-i] / fa[i+l1-l2-m3];
|
||||
}
|
||||
/* apply the relationship
|
||||
\langle l_1 m_1 l_2 m_2 | l_3 m_3 \rangle
|
||||
= (-1)^{l_1+l_2+l_3} \langle l_2 m_2 l_1 m_1 | l_3 m_3 */
|
||||
CG_coeff[index(l1,l2,l3,m1,m2)] = prefactor*sum;
|
||||
CG_coeff[index(l2,l1,l3,m2,m1)] = si[l1+l2+l3]*prefactor*sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \author Jordan Vincent
|
||||
* \author Curry Taylor
|
||||
* \note The original Prim was written in F90 by Tim Wilkens.
|
||||
*/
|
||||
#ifndef CLEBSCH_GORDAN_H
|
||||
#define CLEBSCH_GORDAN_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
/** Calculate and store the Clebsch-Gordan coefficients */
|
||||
class Clebsch_Gordan
|
||||
{
|
||||
public:
|
||||
|
||||
Clebsch_Gordan(const int lmax);
|
||||
///destructor
|
||||
~Clebsch_Gordan() { }
|
||||
|
||||
///vector to store the Clebsch-Gordan coefficients
|
||||
std::vector<double> CG_coeff;
|
||||
|
||||
/**
|
||||
*@brief return \f$ index = l_1 + l_2 L1max + l_3 L1max^2
|
||||
+ m_1 L1max^2 L2max + m_2 L1max^2 L2max^2 \f$
|
||||
*@note Lmax is internally added to m1 and m2 to offset the index
|
||||
*/
|
||||
inline int index(int l1, int l2, int l3, int m1, int m2) const
|
||||
{
|
||||
return l1+l2*L1max+l3*L1max*L1max
|
||||
+(m1+Lmax)*L1max*L1max*L2max+(m2+Lmax)*L1max*L1max*L2max*L2max;
|
||||
}
|
||||
|
||||
///return \f$ \langle l_1 m_1 l_2 m_2 | l_3 (m_1+m_2) \rangle \f$
|
||||
inline double cg(int l1, int l2, int l3, int m1, int m2) const
|
||||
{
|
||||
return CG_coeff[index(l1,l2,l3,m1,m2)];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
///maximum angular momentum
|
||||
int Lmax;
|
||||
//maximum for \f$ l_1 \f$ and \f$ l_2 \f$
|
||||
int L1max;
|
||||
//maximum for \f$ l_3, m_1 \f$ and \f$ m_2 \f$
|
||||
int L2max;
|
||||
/// default constructor not implemented
|
||||
Clebsch_Gordan() { }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_HDF_TRICUBICSPLINE_H
|
||||
#define OHMMS_HDF_TRICUBICSPLINE_H
|
||||
|
||||
#include "OhmmsData/HDFAttribIO.h"
|
||||
#include "Numerics/TriCubicSplineT.h"
|
||||
|
||||
/** Specialization for std::vector<double> */
|
||||
template<>
|
||||
struct HDFAttribIO<TriCubicSplineT<double> >: public HDFAttribIOBase
|
||||
{
|
||||
|
||||
typedef TriCubicSplineT<double> Data_t;
|
||||
Data_t& ref;
|
||||
|
||||
HDFAttribIO<Data_t>(Data_t& a):ref(a) { }
|
||||
|
||||
inline void write(hid_t grp, const char* name)
|
||||
{
|
||||
hsize_t dim[4];
|
||||
dim[0]=ref.nX;
|
||||
dim[1]=ref.nY;
|
||||
dim[2]=ref.nZ;
|
||||
dim[3]=8;
|
||||
hid_t dataspace = H5Screate_simple(4, dim, NULL);
|
||||
hid_t dataset =
|
||||
H5Dcreate(grp, name, H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
hid_t ret =
|
||||
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref.data());
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
}
|
||||
|
||||
inline void read(hid_t grp, const char* name)
|
||||
{
|
||||
hsize_t dim[4];
|
||||
dim[0]=ref.nX;
|
||||
dim[1]=ref.nY;
|
||||
dim[2]=ref.nZ;
|
||||
dim[3]=8;
|
||||
hid_t h1 = H5Dopen(grp, name);
|
||||
hid_t dataspace = H5Dget_space(h1);
|
||||
hid_t ret = H5Dread(h1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref.data());
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(h1);
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
|
@ -1,271 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef NUMEROVCLASS_H
|
||||
#define NUMEROVCLASS_H
|
||||
|
||||
/**@defgroup NumerovTransform Numerov Transformation
|
||||
*@brief Transform functors which provide interfaces to Numerov<ST,FT>.
|
||||
*
|
||||
*The prototype: "template<class SourceType> ATransformFunctor",
|
||||
*where SourceType encapsulates the form of an external potential.
|
||||
*
|
||||
*For examples, the RegularLinearTransform is implemented to solve
|
||||
*Radial Schrodinger equation
|
||||
*\f[ \frac{d^2R_{nl}}{dr^2}+k^2(r) R_{nl} = 0, \f] where
|
||||
*\f[k^2(r)=2[\varepsilon-\frac{L(L+1)}{2r^2}-V(r)], \f] and
|
||||
*\f$ V(r) \f$ is a radial potential on a linear grid.
|
||||
*
|
||||
*/
|
||||
/** Generic class to solve eigen problems using the Numerov
|
||||
*Integration Algorithm.
|
||||
*
|
||||
*Solve second order differential equations of the form
|
||||
\f[\frac{d^2y}{dx^2} + k^2(x)y = S(x)\f]
|
||||
using the Numerov algorithm
|
||||
\f[
|
||||
(1+\frac{h^2}{12}k^2_{n+2})y_{n+2} -
|
||||
2(1-\frac{5h^2}{12}k^2_{n+1})y_{n+1} + (1+\frac{h^2}{12}k^2_n)y_n =
|
||||
\frac{h^2}{12}(S_{n+2}+10S_{n+1}+S_n) + \mathcal{O}(h^6), \f] by
|
||||
solving for \f$y_{n+2}\f$ and recursively integrating forward in x.
|
||||
The boundary conditons being \f$y_0 = y(x_0)\f$ and \f$y_1 = y(x_1).\f$
|
||||
*
|
||||
* Two template parameters are required:
|
||||
- ST: source functor type, e.g., the transform functors in
|
||||
\ref NumerovTransform.
|
||||
- FT: grid functor type for the solution \f$y(x)\f$ and \f$V(x)\f$
|
||||
for \f$k^2(\epsilon,V(x))\f$.
|
||||
*
|
||||
*See \ref numerov_sec "Numerov algorihm".
|
||||
*
|
||||
*Specifically, the source functor should implement
|
||||
- value_type ST::setCusp(int i, value_type& z0, value_type& z1)
|
||||
- int ST::first() the first valid index for the grid
|
||||
- value_type ST::k2(i)
|
||||
- value_type ST::convert(value_type Z(x), x)
|
||||
*
|
||||
*/
|
||||
template<class ST, class FT>
|
||||
class Numerov
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum {lower_energy=-1, nothing, raise_energy};
|
||||
|
||||
typedef typename FT::value_type value_type;
|
||||
typedef typename FT::data_type data_type;
|
||||
|
||||
///constructor with source V(x) and target solution f(x) and TransForm y
|
||||
Numerov(ST& y, FT& f): Y(y), Target(f)
|
||||
{
|
||||
Z.resize(Target.size());
|
||||
//save the derivate of the first grid
|
||||
Y.setCusp(Y.first(), Target0, Target1);
|
||||
}
|
||||
|
||||
int evaluate(value_type e);
|
||||
|
||||
/**
|
||||
*\param lowerin lower bound for the eigen energy
|
||||
*\param upperin upper bound for the eigen energy
|
||||
*\param etol the energy tolerance
|
||||
*\return the eigen energy
|
||||
*\brief Solve for the eigen energy and eigen function self
|
||||
consistently.
|
||||
*/
|
||||
inline value_type solve(value_type lowerin, value_type upperin,
|
||||
value_type etol)
|
||||
{
|
||||
value_type lower = lowerin;
|
||||
value_type upper = upperin;
|
||||
value_type trialenergy=0.5*(lower+upper);
|
||||
value_type oldenergy = upper;
|
||||
int modifier = nothing;
|
||||
do
|
||||
{
|
||||
modifier = evaluate(trialenergy);
|
||||
if(modifier == raise_energy)
|
||||
lower = trialenergy;
|
||||
if(modifier == lower_energy)
|
||||
upper = trialenergy;
|
||||
oldenergy = trialenergy;
|
||||
trialenergy=0.5*(lower+upper);
|
||||
}
|
||||
while((std::abs(trialenergy-oldenergy))>etol);
|
||||
return trialenergy;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param e reference eigenvalue
|
||||
*\brief Reset the reference eigen energy for \f$k^2(\epsilon, V(x))\f$
|
||||
*and the classical TurningPoint \f$i\f$, where
|
||||
*\f$k^2(\epsilon,V(x_{i})) < 0\f$ and \f$k^2(\epsilon,V(x_{i-1})) > 0\f$
|
||||
*/
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
Target.m_Y = 0.0;
|
||||
TurningPoint = 0;
|
||||
Y.reset(e);
|
||||
int i=Target.size()-2;
|
||||
while(i > 1 && Y.k2(i)<0)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
TurningPoint = i;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
///engine that takes care of the transformation of variables
|
||||
ST& Y;
|
||||
|
||||
///real function that holds solution
|
||||
FT& Target;
|
||||
|
||||
///solution by Numerov Target <-> TransForm::convert(Z)
|
||||
data_type Z;
|
||||
|
||||
///cusp condition
|
||||
value_type Target0, Target1;
|
||||
|
||||
///the maximum size of physical data
|
||||
int TurningPoint;
|
||||
|
||||
///index reserved to truncate the data
|
||||
int Current;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*\param e reference eigen energy for \f$k^2(\epsilon, V(x))\f$
|
||||
*\return integer flag for the change of the reference eigen energy
|
||||
*/
|
||||
template<class TransForm, class FT>
|
||||
inline
|
||||
int Numerov<TransForm,FT>::evaluate(value_type e)
|
||||
{
|
||||
reset(e);
|
||||
const value_type MAX_VALUE = 1000;
|
||||
value_type dh2 = Target.dh()*Target.dh();
|
||||
value_type tentwelfth = 0.8333333333333333333333333333333333333333333333*dh2;
|
||||
value_type onetwelfth = 0.0833333333333333333333333333333333333333333333*dh2;
|
||||
//get the first index
|
||||
int first = Y.first();
|
||||
int second = first+1;
|
||||
Z[first] = Target0;
|
||||
Z[second] = Target1;
|
||||
value_type r0 = Target.r(first);
|
||||
value_type r1 = Target.r(second);
|
||||
value_type k2_m2 = Y.k2(first);
|
||||
value_type k2_m = Y.k2(second);
|
||||
value_type y_m2 = Z[first];
|
||||
value_type y_m = Z[second];
|
||||
//set the wave function
|
||||
Target(first) = Y.convert(y_m2,r0);
|
||||
Target(second) = Y.convert(y_m,r1);
|
||||
int num_nodes = 0;
|
||||
int nodes_to_find = Y.nodes();
|
||||
//not meaningful turning point, raise the energy
|
||||
if(TurningPoint == 1)
|
||||
return raise_energy;
|
||||
int e_mode =nothing;
|
||||
int i=first+2;
|
||||
while(i<=TurningPoint+2)
|
||||
{
|
||||
//get the radius of the current index
|
||||
r0 = Target.r(i);
|
||||
//get k^2
|
||||
value_type k2 = Y.k2(i);
|
||||
value_type y =
|
||||
((2.0-tentwelfth*k2_m)*y_m -
|
||||
(1.0+onetwelfth*k2_m2)*y_m2)/(1.0+onetwelfth*k2);
|
||||
Z[i] = y;
|
||||
//avoid exponential solution
|
||||
if(std::abs(y)>MAX_VALUE)
|
||||
{
|
||||
value_type yinv = 1.0/y;
|
||||
for(int j=0; j<=i; j++)
|
||||
Z[j]*=yinv;
|
||||
y_m2*=yinv;
|
||||
y_m*=yinv;
|
||||
y = 1.0;
|
||||
}
|
||||
//check the node
|
||||
if(y_m*y < 0.0)
|
||||
{
|
||||
num_nodes++;
|
||||
if( num_nodes > nodes_to_find)
|
||||
{
|
||||
return lower_energy;
|
||||
}
|
||||
}
|
||||
k2_m2 = k2_m;
|
||||
k2_m = k2;
|
||||
y_m2 = y_m;
|
||||
y_m = y;
|
||||
Target(i) = Y.convert(Z[i],r0);
|
||||
i++;
|
||||
}
|
||||
if(e_mode == nothing)
|
||||
{
|
||||
i = TurningPoint+3;
|
||||
while(i<=Target.size()-2)
|
||||
{
|
||||
r0 = Target.r(i);
|
||||
//get k^2
|
||||
value_type k2 = Y.k2(i);
|
||||
value_type y
|
||||
= ((2.0-tentwelfth*k2_m)*y_m - (1.0+onetwelfth*k2_m2)*y_m2)
|
||||
/(1.0+onetwelfth*k2);
|
||||
Z[i] = y;
|
||||
//growing beyond the turning point
|
||||
if(y/y_m > 1)
|
||||
{
|
||||
return raise_energy;
|
||||
}
|
||||
if(std::abs(y)>MAX_VALUE)
|
||||
{
|
||||
value_type yinv = 1.0/y;
|
||||
for(int j=0; j<=i; j++)
|
||||
Z[j]*=yinv;
|
||||
y_m2*=yinv;
|
||||
y_m*=yinv;
|
||||
y = 1.0;
|
||||
}
|
||||
if(y_m*y < 0.0)
|
||||
{
|
||||
num_nodes++;
|
||||
if(num_nodes > nodes_to_find)
|
||||
return lower_energy;
|
||||
}
|
||||
//assign numerov value to the real function
|
||||
k2_m2 = k2_m;
|
||||
k2_m = k2;
|
||||
y_m2 = y_m;
|
||||
y_m = y;
|
||||
Target(i) = Y.convert(Z[i],r0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if( num_nodes < nodes_to_find )
|
||||
return raise_energy;
|
||||
else
|
||||
return nothing;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,238 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** @file OneDimIntegration.h
|
||||
* @brief Inline functions to perform 1-D integration
|
||||
*/
|
||||
#ifndef QMCPLUSPLUS_ONEDIMINTEGRATION_H
|
||||
#define QMCPLUSPLUS_ONEDIMINTEGRATION_H
|
||||
|
||||
/**@file OneDimIntegration.h
|
||||
@brief Functions to perform integration in one-dimension
|
||||
@note The original Prim was written in F90 by Tim Wilkens.
|
||||
*/
|
||||
|
||||
/**
|
||||
*@param f the integrand
|
||||
*@param g the integral of f
|
||||
*@return the numerical integral of f
|
||||
*@brief Performs the second order Runge-Kutta
|
||||
algorithm to evaluate the integral of a radial
|
||||
grid function
|
||||
\f$ f(r) \f$: \f[ g(r) = \int_a^r dr' f(r') \f]
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline
|
||||
typename GF::value_type
|
||||
integrate_RK2(const GF& f, GF& g)
|
||||
{
|
||||
typedef typename GF::value_type value_type;
|
||||
//value_type ysum = 0.0;
|
||||
value_type yold=0.0;
|
||||
value_type ynew=0.0;
|
||||
g(0) = 0.0;
|
||||
for(int i=0; i < f.size()-1; i++)
|
||||
{
|
||||
//ysum += 0.5*f.dr(i)*(f(i)+f(i+1));
|
||||
ynew=yold+0.5*f.dr(i)*(f(i)+f(i+1));
|
||||
//g(i+1) = ysum;
|
||||
g(i+1) = ynew;
|
||||
yold = ynew;
|
||||
}
|
||||
//return ysum;
|
||||
return yold;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param f the integrand
|
||||
*@param g the integral of f
|
||||
*@return the numerical integral of f
|
||||
*@brief Performs the second order Runge-Kutta
|
||||
algorithm to evaluate the integral (in the
|
||||
forward direction) of a radial grid function
|
||||
\f$ f(r) \f$: \f[ g(r) = \int_a^r dr' f(r') \f]
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline
|
||||
typename GF::value_type
|
||||
integrate_RK2_forward(const GF& f, GF& g)
|
||||
{
|
||||
return integrate_RK2(f,g);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param f the integrand
|
||||
*@param g the integral of f
|
||||
*@return the numerical integral of f
|
||||
*@brief Performs the Runge-Kutta algorithm to
|
||||
evaluate the integral (in the backwards direction)
|
||||
of a radial grid function
|
||||
\f$ f(r) \f$: \f[ g(x) = \int_x^b dx' f(x'), \f]
|
||||
where \f$ b \f$ is the upper limit of \f$ x. \f$
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline
|
||||
typename GF::value_type
|
||||
integrate_RK2_backward(const GF& f, GF& g)
|
||||
{
|
||||
// typedef typename GF::value_type value_type;
|
||||
// int last = std::min(f.size(),g.size())-1;
|
||||
// value_type ysum=0.0;
|
||||
// g(last) = 0.0;
|
||||
// for(int i=last; i > 0; i--){
|
||||
// ysum += 0.5*f.dr(i)*(f(i)+f(i-1));
|
||||
// g(i)=ysum;
|
||||
// }
|
||||
// return ysum;
|
||||
typedef typename GF::value_type value_type;
|
||||
int last = std::min(f.size(),g.size())-1;
|
||||
value_type yold = 0.0;
|
||||
value_type ynew = 0.0;
|
||||
g(last) = 0.0;
|
||||
for(int i=last; i > 0; i--)
|
||||
{
|
||||
ynew = yold+0.5*f.dr(i-1)*(f(i)+f(i-1));
|
||||
g(i-1)=ynew;
|
||||
yold = ynew;
|
||||
}
|
||||
return yold;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param f the integrand
|
||||
*@return the numerical integral of f
|
||||
*@brief Performs the second order Runge-Kutta
|
||||
algorithm to evaluate the integral of a radial
|
||||
grid function
|
||||
\f$ f(r) \f$: \f[ y = \int_a^b dr' f(r'), \f]
|
||||
where \f$ (a,b) \f$ are the lower and upper
|
||||
limits of \f$ x.\f$
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline
|
||||
typename GF::value_type
|
||||
integrate_RK2(const GF& f)
|
||||
{
|
||||
typedef typename GF::value_type value_type;
|
||||
value_type sum = 0.0;
|
||||
for(int i=0; i < f.size()-1; i++)
|
||||
{
|
||||
sum += f.dr(i)*(f(i)+f(i+1));
|
||||
}
|
||||
return 0.5*sum;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param f the integrand
|
||||
*@brief Normalizes the function \f$ f(r) \f$:
|
||||
\f[ f(r) = \frac{1}{\sqrt{C}} f(r) \f] where
|
||||
\f[ C = \int_a^b dr f^2(r), \f]
|
||||
where \f$ (a,b) \f$ are the lower and upper
|
||||
limits of \f$ x.\f$
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline
|
||||
void normalize_RK2(GF& f)
|
||||
{
|
||||
typedef typename GF::value_type value_type;
|
||||
value_type sum = 0.0;
|
||||
for(int i=0; i < f.size()-1; i++)
|
||||
{
|
||||
sum += f.dr(i)*(pow(f(i),2)+pow(f(i+1),2));
|
||||
}
|
||||
value_type norm = 1.0/sqrt(0.5*sum);
|
||||
for(int i=0; i < f.size(); i++)
|
||||
f(i) *= norm;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param grid the radial grid
|
||||
*@param f the integrand
|
||||
*@return the numerical integral of f
|
||||
*@brief Performs the second order Runge-Kutta
|
||||
algorithm to evaluate the integral of a radial
|
||||
grid function
|
||||
\f$ f(r) \f$: \f[ y = \int_a^b dr' f(r'), \f]
|
||||
where \f$ (a,b) \f$ are the lower and upper
|
||||
limits of \f$ x.\f$
|
||||
*/
|
||||
|
||||
template<class GT, class Fn>
|
||||
inline
|
||||
typename Fn::value_type
|
||||
integrate_RK2(const GT& grid, const Fn& f)
|
||||
{
|
||||
typedef typename GT::value_type value_type;
|
||||
value_type sum = 0.0;
|
||||
for(int i=0; i < f.size()-1; i++)
|
||||
{
|
||||
sum += grid.dr(i)*(f(grid.r(i)) + f(grid.r(i+1)));
|
||||
}
|
||||
return 0.5*sum;
|
||||
}
|
||||
|
||||
template<class GF>
|
||||
typename GF::value_type
|
||||
integrate(const GF& f)
|
||||
{
|
||||
typedef typename GF::value_type value_type;
|
||||
const value_type one_third = 0.33333333333333333333333333333333;
|
||||
const value_type three_eighths = 0.375;
|
||||
const value_type BODES_FACTOR = 0.0444444444444444444444444444444;
|
||||
value_type sum = 0.0;
|
||||
int NumIntervals = f.size() - 1;
|
||||
int rem = NumIntervals % 4;
|
||||
//f.func(int i) return dr(i)*f(i)
|
||||
switch ( rem )
|
||||
{
|
||||
case 0:
|
||||
sum += 0.0;
|
||||
break;
|
||||
case 1:
|
||||
sum += 0.5 * (f.func(0)+ f.func(1));
|
||||
break;
|
||||
case 2:
|
||||
sum += one_third * (f.func(0)+ 4.0 * f.func(1) + f.func(2));
|
||||
break;
|
||||
case 3:
|
||||
sum += three_eighths * (f.func(0)+3.0*f.func(1)
|
||||
+ 3.0*f.func(2) + f.func(3));
|
||||
break;
|
||||
}
|
||||
for(int i = 0; i < f.size()-1; i+=4)
|
||||
{
|
||||
//std::cout << i << '\n';
|
||||
int pt0=(i+0);
|
||||
int pt1=(i+1);
|
||||
int pt2=(i+2);
|
||||
int pt3=(i+3);
|
||||
int pt4=(i+4);
|
||||
sum += 7.0 * f.func(pt0) +
|
||||
32.0 * f.func(pt1) +
|
||||
12.0 * f.func(pt2) +
|
||||
32.0 * f.func(pt3) +
|
||||
7.0 * f.func(pt4);
|
||||
}
|
||||
return BODES_FACTOR * sum;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,177 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_RADIALFUNCTIONUTILITY_H
|
||||
#define QMCPLUSPLUS_RADIALFUNCTIONUTILITY_H
|
||||
|
||||
#ifndef QMCPLUSPLUS_ONEDIMINTEGRATION_H
|
||||
#include "Numerics/OneDimIntegration.h"
|
||||
#endif
|
||||
/**@file RadialFunctorUtility.h
|
||||
@brief Utility functions for atomic Hartree-fock solutions
|
||||
@note The original Prim was written in F90 by Tim Wilkens.
|
||||
*/
|
||||
|
||||
/**
|
||||
*@param g \f$ Y_k(n_al_a;n_bl_b/r) \f$
|
||||
*@param a \f$ u_a(r) \f$
|
||||
*@param b \f$ u_b(r) \f$
|
||||
*@param prefactor scaling constant (simple multiplication factor)
|
||||
*@return \f$ prefactor R^k(ab,ab) or R^k(ab,ba) \f$
|
||||
*
|
||||
*@brief Calculates the function \f$ R_k(ij,rt) \f$
|
||||
On Page 311 of "Quantum Theory of Atomic Structure" Vol. 1 by J.C. Slater.
|
||||
*
|
||||
This function is used extensively to calculate the Coulomb and Exchange
|
||||
energies. The general equation is:
|
||||
\f[
|
||||
R^k(ab,xy) = \int_0^{\infty} dr u_{n_al_a}(r) u_{n_xl_x}(r)
|
||||
\frac{Y_k(n_bl_b,n_yl_y/r)}{r}
|
||||
\f]
|
||||
*
|
||||
*For the Hartree energy use \f$ R_k(ab,ab), \f$
|
||||
while for the Exchange energy \f$ R_k(ab,ba). \f$
|
||||
|
||||
*@note Here we use \f$ u(r) = rR(r). \f$
|
||||
|
||||
*/
|
||||
template<class T, class GF>
|
||||
inline T Phisq_x_Yk(const GF& g, const GF& a,
|
||||
const GF& b, T prefactor)
|
||||
{
|
||||
GF t;
|
||||
t.shallow_copy(g);
|
||||
for(int i=0; i < t.size(); i++)
|
||||
{
|
||||
t(i) = prefactor * g(i)*a(i)*b(i);
|
||||
}
|
||||
return integrate_RK2(t);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@param g return \f$ {\cal Y}_k(n_a l_a; n_b l_b/r) /r \f$
|
||||
*@param a \f$ u_a(r) \f$
|
||||
*@param b \f$ u_b(r) \f$
|
||||
*@param k integer parameter
|
||||
*
|
||||
*@brief Calculates the function:
|
||||
\f$ {\cal Y}_k(n_a l_a; n_b l_b/r) /r \f$
|
||||
On Page 17 of "Quantum Theory of Atomic Structure" Vol. 2 by J.C. Slater.
|
||||
*
|
||||
This function is used extensively to calculate the Coulomb and Exchange
|
||||
potentials. The actual equation is:
|
||||
\f[
|
||||
\frac{{\cal Y}_k(n_al_a;n_bl_b/r)}{r} =
|
||||
\frac{1}{r^{k+1}}
|
||||
\int_{0}^{r} dr' \: r'^k u_{n_a l_a}(r') u_{n_b l_b}(r')
|
||||
+ r^{k} \int_{r}^{\infty}dr' \:
|
||||
r'^{-k-1} u_{n_a l_a}(r') u_{n_b l_b}(r')
|
||||
\f]
|
||||
*@note Here we use \f$ u(r) = rR(r). \f$
|
||||
*/
|
||||
template<class GF>
|
||||
inline void
|
||||
Ykofr(GF& g, const GF& a, const GF& b, int k)
|
||||
{
|
||||
typedef typename GF::value_type value_type;
|
||||
int n = g.size();
|
||||
//The integrands of each of the two integrals
|
||||
GF first_integrand;
|
||||
GF second_integrand;
|
||||
first_integrand.shallow_copy(g);
|
||||
second_integrand.shallow_copy(g);
|
||||
std::vector<value_type> r_to_k(n);
|
||||
std::vector<value_type> r_to_minus_k_plus_one(n);
|
||||
//Store values for r_to_k and r_to_minus_kplus1
|
||||
for(int i=0; i < n; ++i)
|
||||
{
|
||||
value_type r0 = g.r(i)+1e-12;
|
||||
value_type t = std::pow(r0,k); // r0^k
|
||||
r_to_k[i] = t;
|
||||
r_to_minus_k_plus_one[i] = 1.0/(t*r0); // 1/r0^(k+1)
|
||||
value_type ab = a(i)*b(i);
|
||||
first_integrand(i) = r_to_k[i]*ab;
|
||||
second_integrand(i) = r_to_minus_k_plus_one[i]*ab;
|
||||
}
|
||||
//Allow r_1 to range over all the radial grid points.
|
||||
//Store the value of the integral at each grid point in
|
||||
//temporary grid objects A and B.
|
||||
GF A, B;
|
||||
A.shallow_copy(g);
|
||||
B.shallow_copy(g);
|
||||
integrate_RK2_forward(first_integrand,A);
|
||||
integrate_RK2_backward(second_integrand,B);
|
||||
//Too many for loops here *Yk_r = r_to_minus_k_plus_one * A + r_to_k * B;
|
||||
for(int i=0; i < n; ++i)
|
||||
{
|
||||
g(i) = r_to_minus_k_plus_one[i]*A(i)+r_to_k[i]*B(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param g the grid function to be returned
|
||||
*@param y the grid function to be transformed
|
||||
*@param a \f$ u_a(r) \f$
|
||||
*@param b \f$ u_b(r) \f$
|
||||
*@param coeff the coefficient
|
||||
*
|
||||
*@brief Makes \f$V_{Exchange}\f$ a local function.
|
||||
*
|
||||
\f$ V_{Exchange} \f$ is a non-local operator:
|
||||
\f[
|
||||
\hat{V}_{Exchange} \psi_a(r) = -\sum_b
|
||||
\delta_{\sigma_a,\sigma_b}\int dr'
|
||||
\frac{\psi_b^*(r')\psi_a(r')}{|r-r'|}\psi_b(r),
|
||||
\f]
|
||||
It is possible to transform this into a local operator by multiplying
|
||||
and dividing by \f$ \psi_a(r) \f$:
|
||||
\f[
|
||||
-\sum_b \delta_{\sigma_a,\sigma_b}\int dr'
|
||||
\frac{\psi_b^* (r')\psi_a(r')\psi_b(r')\psi_b(r)}{\psi_a(r)|r-r'|} \psi_a(r)
|
||||
\f]
|
||||
*/
|
||||
|
||||
template<class GF>
|
||||
inline void
|
||||
Make_Loc_Pot(GF& g, const GF& y, const GF& a, const GF& b,
|
||||
typename GF::value_type coeff)
|
||||
{
|
||||
int max_pt, pt=1;
|
||||
typename GF::value_type ratio;
|
||||
while(a(pt)/a(pt-1) >= 1.0 && pt<a.size()-1)
|
||||
{
|
||||
pt++;
|
||||
}
|
||||
max_pt = pt;
|
||||
const double tol = pow(10.0,-10.0);
|
||||
for(pt=0; pt < g.size(); pt++)
|
||||
{
|
||||
if(std::abs(a(pt)) > tol)
|
||||
{
|
||||
ratio = b(pt)/a(pt);
|
||||
if(pt >= max_pt && std::abs(ratio) > 1000)
|
||||
{
|
||||
ratio = 1000000.0 / ratio;
|
||||
}
|
||||
g(pt) -= coeff*ratio*y(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_TRICUBICSPLINETEMPLATE_H
|
||||
#define QMCPLUSPLUS_TRICUBICSPLINETEMPLATE_H
|
||||
#include "Numerics/XYZCubicGrid.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** Tri-cubic Splines with periodic boundary conditions and fixed first derivatives.
|
||||
*
|
||||
* Adapting TriCubicSpline implemented by K. Esler and D. Das.
|
||||
* Use stl containers
|
||||
*/
|
||||
template<class T, class Tg=T>
|
||||
class TriCubicSplineT
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef Tg point_type;
|
||||
typedef XYZCubicGrid<T,Tg> GridType;
|
||||
typedef TriCubicSplineT<T,Tg> ThisType;
|
||||
typedef typename GridType::KnotType KnotType;
|
||||
typedef typename GridType::Grid1DType Grid1DType;
|
||||
|
||||
//true, if this function evaluates grid-related properties
|
||||
bool GridManager;
|
||||
//Hide these later
|
||||
bool UpToDate;
|
||||
int nX, nY, nZ;
|
||||
int n001,n010,n011,n100,n101,n110,n111;
|
||||
GridType* m_grid;
|
||||
std::vector<KnotType> F;
|
||||
|
||||
/// constructor
|
||||
TriCubicSplineT(GridType* agrid):
|
||||
GridManager(true),UpToDate(false), nX(0), nY(0), nZ(0), m_grid(agrid)
|
||||
{
|
||||
if(m_grid)
|
||||
{
|
||||
nX = m_grid->nX;
|
||||
nY = m_grid->nY;
|
||||
nZ = m_grid->nZ;
|
||||
F.resize(nX*nY*nZ);
|
||||
n100=nY*nZ;
|
||||
n001=1;
|
||||
n010=nZ;
|
||||
n011=nZ+1;
|
||||
n101=n100+n001;
|
||||
n110=n100+n010;
|
||||
n111=n100+n011;
|
||||
}
|
||||
}
|
||||
|
||||
inline void setGridManager(bool willmanage)
|
||||
{
|
||||
GridManager=willmanage;
|
||||
}
|
||||
|
||||
inline void reset(bool periodic=true)
|
||||
{
|
||||
if(m_grid)
|
||||
{
|
||||
m_grid->setBC(periodic);
|
||||
if(!UpToDate)
|
||||
{
|
||||
UpdateX(0, 1, periodic); // Do dF/dx
|
||||
UpdateY(0, 2, periodic); // Do dF/dy
|
||||
UpdateZ(0, 3, periodic); // Do dF/dz
|
||||
UpdateY(1, 4, periodic); // Do d2F/dxdy
|
||||
UpdateZ(1, 5, periodic); // Do d2F/dxdz
|
||||
UpdateZ(2, 6, periodic); // Do d2F/dydz
|
||||
UpdateZ(4, 7, periodic); // Do d3F/dxdydz
|
||||
UpToDate=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline T* data()
|
||||
{
|
||||
return &(F[0][0]);
|
||||
}
|
||||
inline const T* data() const
|
||||
{
|
||||
return &(F[0][0]);
|
||||
}
|
||||
|
||||
inline T operator()(int n) const
|
||||
{
|
||||
return F[n][0];
|
||||
}
|
||||
|
||||
inline T& operator()(int n)
|
||||
{
|
||||
return F[n][0];
|
||||
}
|
||||
|
||||
inline T operator()(int i, int j, int k) const
|
||||
{
|
||||
return F[index(i,j,k)][0];
|
||||
}
|
||||
|
||||
inline T& operator()(int i, int j, int k)
|
||||
{
|
||||
return F[index(i,j,k)][0];
|
||||
}
|
||||
|
||||
inline int index(int i, int j, int k)
|
||||
{
|
||||
return k+nZ*(j+nY*i);
|
||||
}
|
||||
|
||||
template<class IT>
|
||||
inline void reset(IT first, IT last, bool periodic=true)
|
||||
{
|
||||
typename std::vector<KnotType>::iterator it(F.begin());
|
||||
while(first != last)
|
||||
{
|
||||
(*it)[0]=*first++;
|
||||
++it;
|
||||
}
|
||||
reset(periodic);
|
||||
}
|
||||
|
||||
//template<class PV>
|
||||
//inline void setgrid(const PV& r) {
|
||||
// m_grid->locate(r[0],r[1],r[2]);
|
||||
//}
|
||||
|
||||
inline T evaluate(const TinyVector<Tg,3>& r)
|
||||
{
|
||||
if(GridManager)
|
||||
{
|
||||
m_grid->locate(r[0],r[1],r[2],false);
|
||||
//m_grid->update(false);
|
||||
}
|
||||
if(m_grid->Loc<0)
|
||||
{
|
||||
return 1e-20;
|
||||
}
|
||||
//m_grid->update();
|
||||
int cur(m_grid->Loc);
|
||||
return
|
||||
m_grid->evaluate(F[cur] , F[cur+n001], F[cur+n010], F[cur+n011],
|
||||
F[cur+n100], F[cur+n101], F[cur+n110], F[cur+n111]);
|
||||
}
|
||||
|
||||
inline T evaluate(const TinyVector<Tg,3>& r, TinyVector<T,3>& gradf, T& lapf)
|
||||
{
|
||||
if(GridManager)
|
||||
{
|
||||
m_grid->locate(r[0],r[1],r[2],true);
|
||||
//m_grid->update(true);
|
||||
}
|
||||
if(m_grid->Loc<0)
|
||||
{
|
||||
gradf[0] = 1e-40;
|
||||
gradf[1] = 1e-40;
|
||||
gradf[2] = 1e-40;
|
||||
lapf = 1e-40;
|
||||
return 1e-20;
|
||||
}
|
||||
//m_grid->updateAll();
|
||||
int cur(m_grid->Loc);
|
||||
m_grid->evaluateAll(F[cur] , F[cur+n001], F[cur+n010], F[cur+n011],
|
||||
F[cur+n100], F[cur+n101], F[cur+n110], F[cur+n111]);
|
||||
gradf[0]=m_grid->gradfX;
|
||||
gradf[1]=m_grid->gradfY;
|
||||
gradf[2]=m_grid->gradfZ;
|
||||
lapf=m_grid->lapf;
|
||||
return m_grid->val;
|
||||
}
|
||||
|
||||
void resetParameters(VarRegistry<point_type>& vlist)
|
||||
{
|
||||
///DO NOTHING FOR NOW
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// dim: Dimension to calculate derivative w.r.t
|
||||
// source: Function to differentiate
|
||||
// dest: where to put result
|
||||
void UpdateX (int source, int target, bool periodic);
|
||||
void UpdateY (int source, int target, bool periodic);
|
||||
void UpdateZ (int source, int target, bool periodic);
|
||||
};
|
||||
|
||||
template<class T, class Tg>
|
||||
void TriCubicSplineT<T,Tg>::UpdateX(int source, int target, bool periodic)
|
||||
{
|
||||
OneDimGridFunctor<T,Tg>* temp=0;
|
||||
if(periodic)
|
||||
{
|
||||
temp = new OneDimCubicSplinePBC<T,Tg>(m_grid->gridX);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = new OneDimCubicSplineFirst<T,Tg>(m_grid->gridX);
|
||||
}
|
||||
int nyz=nY*nZ;
|
||||
// Loop over all y and z
|
||||
for(int iy = 0; iy < nY; iy++)
|
||||
{
|
||||
for(int iz = 0; iz < nZ; iz++)
|
||||
{
|
||||
int first(index(0,iy,iz));
|
||||
T* restrict s = temp->data();
|
||||
for(int ix=0,cur=first; ix< nX; ix++,cur+=nyz,s++)
|
||||
*s = F[cur][source];
|
||||
temp->spline();
|
||||
const T* restrict sfit = temp->data(1);
|
||||
for(int ix=0,cur=first; ix< nX; ix++,cur+=nyz)
|
||||
F[cur][target] = *sfit++;
|
||||
}
|
||||
}
|
||||
delete temp;
|
||||
}
|
||||
|
||||
template<class T, class Tg>
|
||||
void TriCubicSplineT<T,Tg>::UpdateY(int source, int target, bool periodic)
|
||||
{
|
||||
OneDimGridFunctor<T,Tg>* temp=0;
|
||||
if(periodic)
|
||||
{
|
||||
temp = new OneDimCubicSplinePBC<T,Tg>(m_grid->gridY);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = new OneDimCubicSplineFirst<T,Tg>(m_grid->gridY);
|
||||
}
|
||||
// Loop over all x and z
|
||||
for(int ix = 0; ix < nX; ix++)
|
||||
{
|
||||
for(int iz = 0; iz < nZ; iz++)
|
||||
{
|
||||
int first(index(ix,0,iz));
|
||||
T* restrict s = temp->data();
|
||||
for(int iy=0,cur=first; iy< nY; iy++,cur+=nZ,s++)
|
||||
*s = F[cur][source];
|
||||
temp->spline();
|
||||
const T* restrict sfit = temp->data(1);
|
||||
for(int iy=0,cur=first; iy< nY; iy++,cur+=nZ)
|
||||
F[cur][target] = *sfit++;
|
||||
}
|
||||
}
|
||||
delete temp;
|
||||
}
|
||||
|
||||
template<class T, class Tg>
|
||||
void TriCubicSplineT<T,Tg>::UpdateZ(int source, int target, bool periodic)
|
||||
{
|
||||
OneDimGridFunctor<T,Tg>* temp=0;
|
||||
if(periodic)
|
||||
{
|
||||
temp = new OneDimCubicSplinePBC<T,Tg>(m_grid->gridZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = new OneDimCubicSplineFirst<T,Tg>(m_grid->gridZ);
|
||||
}
|
||||
// Loop over all x and z
|
||||
for(int ix = 0; ix < nX; ix++)
|
||||
{
|
||||
for(int iy = 0; iy < nY; iy++)
|
||||
{
|
||||
int first(index(ix,iy,0));
|
||||
T* restrict s = temp->data();
|
||||
for(int iz=0,cur=first; iz< nZ; iz++,cur++,s++)
|
||||
*s = F[cur][source];
|
||||
temp->spline();
|
||||
const T* restrict sfit = temp->data(1);
|
||||
for(int iz=0,cur=first; iz< nZ; iz++,cur++)
|
||||
F[cur][target] = *sfit++;
|
||||
}
|
||||
}
|
||||
delete temp;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,565 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_XYZCUBICGRID_H
|
||||
#define QMCPLUSPLUS_XYZCUBICGRID_H
|
||||
#include <cmath>
|
||||
#include "OhmmsPETE/TinyVector.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** Tri-cubic Splines with periodic boundary conditions and fixed first derivatives.
|
||||
*
|
||||
* Adapting TriCubicSpline implemented by K. Esler and D. Das.
|
||||
* Use stl containers
|
||||
*/
|
||||
template<typename T, typename Tg>
|
||||
struct XYZCubicGrid
|
||||
{
|
||||
|
||||
typedef TinyVector<T,8> KnotType;
|
||||
typedef OneDimGridBase<Tg> Grid1DType;
|
||||
|
||||
/// functions which depend on the point where the interpolated value
|
||||
/// is required. t = (x - xi)/h
|
||||
inline Tg p1(Tg t)
|
||||
{
|
||||
return ((t-1.0)*(t-1.0)*(1.0+2.0*t));
|
||||
}
|
||||
inline Tg p2(Tg t)
|
||||
{
|
||||
return (t*t*(3.0-2.0*t));
|
||||
}
|
||||
inline Tg q1(Tg t)
|
||||
{
|
||||
return (t*(t-1.0)*(t-1.0));
|
||||
}
|
||||
inline Tg q2(Tg t)
|
||||
{
|
||||
return (t*t*(t-1.0));
|
||||
}
|
||||
inline Tg dp1(Tg t)
|
||||
{
|
||||
return (6.0*t*(t-1.0));
|
||||
}
|
||||
inline Tg dq1(Tg t)
|
||||
{
|
||||
return ((t-1.0)*(3.0*t-1.0));
|
||||
}
|
||||
inline Tg dp2(Tg t)
|
||||
{
|
||||
return (-dp1(t));
|
||||
}
|
||||
inline Tg dq2 (Tg t)
|
||||
{
|
||||
return ((3.0*t - 2.0)*t);
|
||||
}
|
||||
inline Tg d2p1(Tg t)
|
||||
{
|
||||
return (12.0*t-6.0);
|
||||
}
|
||||
inline Tg d2q1 (Tg t)
|
||||
{
|
||||
return (6.0*t - 4.0);
|
||||
}
|
||||
inline Tg d2p2 (Tg t)
|
||||
{
|
||||
return (-d2p1(t));
|
||||
}
|
||||
inline Tg d2q2 (Tg t)
|
||||
{
|
||||
return (6.0*t - 2.0);
|
||||
}
|
||||
|
||||
bool OwnGrid;
|
||||
bool Periodic;
|
||||
int Loc;
|
||||
int ix, iy, iz;
|
||||
int nX, nY, nZ;
|
||||
Tg x_min, x_max, LengthX, OneOverLx;
|
||||
Tg y_min, y_max, LengthY, OneOverLy;
|
||||
Tg z_min, z_max, LengthZ, OneOverLz;
|
||||
Tg h,k,l,hinv,kinv,linv;
|
||||
Tg u,v,w;
|
||||
Tg a0,a1,a2,a3,b0,b1,b2,b3,c0,c1,c2,c3;
|
||||
Tg da0,da1,da2,da3,db0,db1,db2,db3,dc0,dc1,dc2,dc3;
|
||||
Tg d2a0,d2a1,d2a2,d2a3,d2b0,d2b1,d2b2,d2b3,d2c0,d2c1,d2c2,d2c3;
|
||||
|
||||
T val, gradfX, gradfY, gradfZ, lapf;
|
||||
Grid1DType *gridX, *gridY, *gridZ;
|
||||
|
||||
XYZCubicGrid(): OwnGrid(false),Loc(-1),gridX(0),gridY(0),gridZ(0) {}
|
||||
XYZCubicGrid(Grid1DType *xgrid, Grid1DType *ygrid,
|
||||
Grid1DType *zgrid)
|
||||
{
|
||||
setGridXYZ(xgrid,ygrid,zgrid);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
setGridXYZ(Grid1DType *xgrid, Grid1DType *ygrid, Grid1DType *zgrid)
|
||||
{
|
||||
gridX=xgrid;
|
||||
gridY=ygrid;
|
||||
gridZ=zgrid;
|
||||
x_min=gridX->rmin();
|
||||
x_max=gridX->rmax();
|
||||
LengthX=x_max-x_min;
|
||||
OneOverLx=1.0/LengthX;
|
||||
y_min=gridY->rmin();
|
||||
y_max=gridY->rmax();
|
||||
LengthY=y_max-y_min;
|
||||
OneOverLy=1.0/LengthY;
|
||||
z_min=gridZ->rmin();
|
||||
z_max=gridZ->rmax();
|
||||
LengthZ=z_max-z_min;
|
||||
OneOverLz=1.0/LengthZ;
|
||||
nX = gridX->size();
|
||||
nY = gridY->size();
|
||||
nZ = gridZ->size();
|
||||
}
|
||||
|
||||
inline int size()
|
||||
{
|
||||
return nX*nY*nZ;
|
||||
}
|
||||
|
||||
/** process xmlnode to set the grids
|
||||
*/
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
std::vector<Tg> ri(3,-5.0);
|
||||
std::vector<Tg> rf(3,5.0);
|
||||
std::vector<int> npts(3,101);
|
||||
cur = cur->xmlChildrenNode;
|
||||
int idir(0);
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == "grid")
|
||||
{
|
||||
const xmlChar* a=xmlGetProp(cur,(const xmlChar*)"dir");
|
||||
if(a)
|
||||
{
|
||||
idir=atoi((const char*)a);
|
||||
}
|
||||
a=xmlGetProp(cur,(const xmlChar*)"ri");
|
||||
if(a)
|
||||
{
|
||||
ri[idir]=atof((const char*)a);
|
||||
}
|
||||
a=xmlGetProp(cur,(const xmlChar*)"rf");
|
||||
if(a)
|
||||
{
|
||||
rf[idir]=atof((const char*)a);
|
||||
}
|
||||
a=xmlGetProp(cur,(const xmlChar*)"npts");
|
||||
if(a)
|
||||
{
|
||||
npts[idir]=atoi((const char*)a);
|
||||
}
|
||||
}
|
||||
cur=cur->next;
|
||||
}
|
||||
if(gridX ==0)
|
||||
gridX=new LinearGrid<Tg>;
|
||||
if(gridY ==0)
|
||||
gridY=new LinearGrid<Tg>;
|
||||
if(gridZ ==0)
|
||||
gridZ=new LinearGrid<Tg>;
|
||||
gridX->set(ri[0],rf[0],npts[0]);
|
||||
gridY->set(ri[1],rf[1],npts[1]);
|
||||
gridZ->set(ri[2],rf[2],npts[2]);
|
||||
setGridXYZ(gridX,gridY,gridZ);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void setBC(bool pbc)
|
||||
{
|
||||
Periodic=pbc;
|
||||
}
|
||||
|
||||
inline int index(int i, int j, int k) const
|
||||
{
|
||||
return k+nZ*(j+nY*i);
|
||||
}
|
||||
|
||||
/** locate the grid point (x,y,z) and update the coefficients
|
||||
*/
|
||||
inline void locate(Tg x, Tg y, Tg z, bool updateall)
|
||||
{
|
||||
//grid(X,Y,Z)->locate(r) evaluates the factors used by interpolations
|
||||
Loc=-1;
|
||||
if(Periodic)
|
||||
{
|
||||
x-=LengthX*std::floor(x*OneOverLx);
|
||||
y-=LengthY*std::floor(y*OneOverLy);
|
||||
z-=LengthZ*std::floor(z*OneOverLz);
|
||||
//T x0=std::fmod(x-x_min,LengthX);
|
||||
//x=x0-LengthX*static_cast<int>(x0*TwoOverLx)+x_min;
|
||||
//T y0=std::fmod(y-y_min,LengthY);
|
||||
//y=y0-LengthY*static_cast<int>(y0*TwoOverLy)+y_min;
|
||||
//T z0=std::fmod(z-z_min,LengthZ);
|
||||
//z=z0-LengthZ*static_cast<int>(z0*TwoOverLz)+z_min;
|
||||
//if(x<x_min) x+=LengthX;
|
||||
//else if(x>=x_max) x-=LengthX;
|
||||
//if(y<y_min) y+=LengthY;
|
||||
//else if(y>=y_max) y-=LengthY;
|
||||
//if(z<z_min) z+=LengthZ;
|
||||
//else if(z>=z_max) z-=LengthZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(x<x_min || x > x_max)
|
||||
return;
|
||||
if(y<y_min || y > y_max)
|
||||
return;
|
||||
if(z<z_min || z > z_max)
|
||||
return;
|
||||
}
|
||||
ix=gridX->getIndex(x);
|
||||
iy=gridY->getIndex(y);
|
||||
iz=gridY->getIndex(z);
|
||||
h = gridX->dr(ix);
|
||||
hinv = 1.0/h;
|
||||
u = (x - gridX->r(ix))*hinv;
|
||||
k = gridY->dr(iy);
|
||||
kinv = 1.0/k;
|
||||
v = (y - gridY->r(iy))*kinv;
|
||||
l = gridZ->dr(iz);
|
||||
linv = 1.0/l;
|
||||
w = (z - gridZ->r(iz))*linv;
|
||||
Loc=index(ix,iy,iz);
|
||||
a0=p1(u);
|
||||
a1=p2(u);
|
||||
a2=h*q1(u);
|
||||
a3=h*q2(u);
|
||||
b0=p1(v);
|
||||
b1=p2(v);
|
||||
b2=k*q1(v);
|
||||
b3=k*q2(v);
|
||||
c0=p1(w);
|
||||
c1=p2(w);
|
||||
c2=l*q1(w);
|
||||
c3=l*q2(w);
|
||||
if(updateall)
|
||||
{
|
||||
da0=hinv*dp1(u);
|
||||
da1=hinv*dp2(u);
|
||||
da2=dq1(u);
|
||||
da3=dq2(u);
|
||||
db0=kinv*dp1(v);
|
||||
db1=kinv*dp2(v);
|
||||
db2=dq1(v);
|
||||
db3=dq2(v);
|
||||
dc0=linv*dp1(w);
|
||||
dc1=linv*dp2(w);
|
||||
dc2=dq1(w);
|
||||
dc3=dq2(w);
|
||||
d2a0=hinv*hinv*d2p1(u);
|
||||
d2a1=hinv*hinv*d2p2(u);
|
||||
d2a2=hinv*d2q1(u);
|
||||
d2a3=hinv*d2q2(u);
|
||||
d2b0=kinv*kinv*d2p1(v);
|
||||
d2b1=kinv*kinv*d2p2(v);
|
||||
d2b2=kinv*d2q1(v);
|
||||
d2b3=kinv*d2q2(v);
|
||||
d2c0=linv*linv*d2p1(w);
|
||||
d2c1=linv*linv*d2p2(w);
|
||||
d2c2=linv*d2q1(w);
|
||||
d2c3=linv*d2q2(w);
|
||||
}
|
||||
}
|
||||
|
||||
//inline int update() {
|
||||
// a0=p1(u); a1=p2(u); a2=h*q1(u); a3=h*q2(u);
|
||||
// b0=p1(v); b1=p2(v); b2=k*q1(v); b3=k*q2(v);
|
||||
// c0=p1(w); c1=p2(w); c2=l*q1(w); c3=l*q2(w);
|
||||
// return Loc;
|
||||
//}
|
||||
|
||||
inline void update(bool all)
|
||||
{
|
||||
if(Loc<0)
|
||||
return;
|
||||
a0=p1(u);
|
||||
a1=p2(u);
|
||||
a2=h*q1(u);
|
||||
a3=h*q2(u);
|
||||
b0=p1(v);
|
||||
b1=p2(v);
|
||||
b2=k*q1(v);
|
||||
b3=k*q2(v);
|
||||
c0=p1(w);
|
||||
c1=p2(w);
|
||||
c2=l*q1(w);
|
||||
c3=l*q2(w);
|
||||
if(all)
|
||||
{
|
||||
da0=hinv*dp1(u);
|
||||
da1=hinv*dp2(u);
|
||||
da2=dq1(u);
|
||||
da3=dq2(u);
|
||||
db0=kinv*dp1(v);
|
||||
db1=kinv*dp2(v);
|
||||
db2=dq1(v);
|
||||
db3=dq2(v);
|
||||
dc0=linv*dp1(w);
|
||||
dc1=linv*dp2(w);
|
||||
dc2=dq1(w);
|
||||
dc3=dq2(w);
|
||||
d2a0=hinv*hinv*d2p1(u);
|
||||
d2a1=hinv*hinv*d2p2(u);
|
||||
d2a2=hinv*d2q1(u);
|
||||
d2a3=hinv*d2q2(u);
|
||||
d2b0=kinv*kinv*d2p1(v);
|
||||
d2b1=kinv*kinv*d2p2(v);
|
||||
d2b2=kinv*d2q1(v);
|
||||
d2b3=kinv*d2q2(v);
|
||||
d2c0=linv*linv*d2p1(w);
|
||||
d2c1=linv*linv*d2p2(w);
|
||||
d2c2=linv*d2q1(w);
|
||||
d2c3=linv*d2q2(w);
|
||||
}
|
||||
}
|
||||
|
||||
inline T evaluate(const KnotType& f000, const KnotType& f001,
|
||||
const KnotType& f010, const KnotType& f011,
|
||||
const KnotType& f100, const KnotType& f101,
|
||||
const KnotType& f110, const KnotType& f111)
|
||||
{
|
||||
return
|
||||
a0*
|
||||
(b0*(f000[0]*c0+f001[0]*c1+f000[3]*c2+f001[3]*c3) +
|
||||
b1*(f010[0]*c0+f011[0]*c1+f010[3]*c2+f011[3]*c3) +
|
||||
b2*(f000[2]*c0+f001[2]*c1+f000[6]*c2+f001[6]*c3) +
|
||||
b3*(f010[2]*c0+f011[2]*c1+f010[6]*c2+f011[6]*c3))+
|
||||
a1 *
|
||||
(b0*(f100[0]*c0+f101[0]*c1+f100[3]*c2+f101[3]*c3) +
|
||||
b1*(f110[0]*c0+f111[0]*c1+f110[3]*c2+f111[3]*c3) +
|
||||
b2*(f100[2]*c0+f101[2]*c1+f100[6]*c2+f101[6]*c3) +
|
||||
b3*(f110[2]*c0+f111[2]*c1+f110[6]*c2+f111[6]*c3))+
|
||||
a2 *
|
||||
(b0*(f000[1]*c0+f001[1]*c1+f000[5]*c2+f001[5]*c3) +
|
||||
b1*(f010[1]*c0+f011[1]*c1+f010[5]*c2+f011[5]*c3) +
|
||||
b2*(f000[4]*c0+f001[4]*c1+f000[7]*c2+f001[7]*c3) +
|
||||
b3*(f010[4]*c0+f011[4]*c1+f010[7]*c2+f011[7]*c3))+
|
||||
a3 *
|
||||
(b0*(f100[1]*c0+f101[1]*c1+f100[5]*c2+f101[5]*c3) +
|
||||
b1*(f110[1]*c0+f111[1]*c1+f110[5]*c2+f111[5]*c3) +
|
||||
b2*(f100[4]*c0+f101[4]*c1+f100[7]*c2+f101[7]*c3) +
|
||||
b3*(f110[4]*c0+f111[4]*c1+f110[7]*c2+f111[7]*c3));
|
||||
}
|
||||
|
||||
inline void evaluateAll(const KnotType& f000, const KnotType& f001,
|
||||
const KnotType& f010, const KnotType& f011,
|
||||
const KnotType& f100, const KnotType& f101,
|
||||
const KnotType& f110, const KnotType& f111)
|
||||
{
|
||||
T Y000(f000[0]); // F
|
||||
T Y200(f000[1]); // dF/dx
|
||||
T Y020(f000[2]); // dF/dy
|
||||
T Y002(f000[3]); // dF/dz
|
||||
T Y220(f000[4]); // d2F/dxdy
|
||||
T Y202(f000[5]); // d2F/dxdz
|
||||
T Y022(f000[6]); // d2F/dydz
|
||||
T Y222(f000[7]); // d3F/dxdydz
|
||||
T Y001(f001[0]); // F
|
||||
T Y201(f001[1]); // dF/dx
|
||||
T Y021(f001[2]); // dF/dy
|
||||
T Y003(f001[3]); // dF/dz
|
||||
T Y221(f001[4]); // d2F/dxdy
|
||||
T Y203(f001[5]); // d2F/dxdz
|
||||
T Y023(f001[6]); // d2F/dydz
|
||||
T Y223(f001[7]); // d3F/dxdydz
|
||||
T Y010(f010[0]); // F
|
||||
T Y210(f010[1]); // dF/dx
|
||||
T Y030(f010[2]); // dF/dy
|
||||
T Y012(f010[3]); // dF/dz
|
||||
T Y230(f010[4]); // d2F/dxdy
|
||||
T Y212(f010[5]); // d2F/dxdz
|
||||
T Y032(f010[6]); // d2F/dydz
|
||||
T Y232(f010[7]); // d3F/dxdydz
|
||||
T Y011(f011[0]); // F
|
||||
T Y211(f011[1]); // dF/dx
|
||||
T Y031(f011[2]); // dF/dy
|
||||
T Y013(f011[3]); // dF/dz
|
||||
T Y231(f011[4]); // d2F/dxdy
|
||||
T Y213(f011[5]); // d2F/dxdz
|
||||
T Y033(f011[6]); // d2F/dydz
|
||||
T Y233(f011[7]); // d3F/dxdydz
|
||||
T Y100(f100[0]); // F
|
||||
T Y300(f100[1]); // dF/dx
|
||||
T Y120(f100[2]); // dF/dy
|
||||
T Y102(f100[3]); // dF/dz
|
||||
T Y320(f100[4]); // d2F/dxdy
|
||||
T Y302(f100[5]); // d2F/dxdz
|
||||
T Y122(f100[6]); // d2F/dydz
|
||||
T Y322(f100[7]); // d3F/dxdydz
|
||||
T Y101(f101[0]); // F
|
||||
T Y301(f101[1]); // dF/dx
|
||||
T Y121(f101[2]); // dF/dy
|
||||
T Y103(f101[3]); // dF/dz
|
||||
T Y321(f101[4]); // d2F/dxdy
|
||||
T Y303(f101[5]); // d2F/dxdz
|
||||
T Y123(f101[6]); // d2F/dydz
|
||||
T Y323(f101[7]); // d3F/dxdydz
|
||||
T Y110(f110[0]); // F
|
||||
T Y310(f110[1]); // dF/dx
|
||||
T Y130(f110[2]); // dF/dy
|
||||
T Y112(f110[3]); // dF/dz
|
||||
T Y330(f110[4]); // d2F/dxdy
|
||||
T Y312(f110[5]); // d2F/dxdz
|
||||
T Y132(f110[6]); // d2F/dydz
|
||||
T Y332(f110[7]); // d3F/dxdydz
|
||||
T Y111(f111[0]); // F
|
||||
T Y311(f111[1]); // dF/dx
|
||||
T Y131(f111[2]); // dF/dy
|
||||
T Y113(f111[3]); // dF/dz
|
||||
T Y331(f111[4]); // d2F/dxdy
|
||||
T Y313(f111[5]); // d2F/dxdz
|
||||
T Y133(f111[6]); // d2F/dydz
|
||||
T Y333(f111[7]); // d3F/dxdydz
|
||||
T term0 =
|
||||
b0*(Y000*c0+Y001*c1+Y002*c2+Y003*c3) +
|
||||
b1*(Y010*c0+Y011*c1+Y012*c2+Y013*c3) +
|
||||
b2*(Y020*c0+Y021*c1+Y022*c2+Y023*c3) +
|
||||
b3*(Y030*c0+Y031*c1+Y032*c2+Y033*c3);
|
||||
T term1 =
|
||||
b0*(Y100*c0+Y101*c1+Y102*c2+Y103*c3) +
|
||||
b1*(Y110*c0+Y111*c1+Y112*c2+Y113*c3) +
|
||||
b2*(Y120*c0+Y121*c1+Y122*c2+Y123*c3) +
|
||||
b3*(Y130*c0+Y131*c1+Y132*c2+Y133*c3);
|
||||
T term2 =
|
||||
b0*(Y200*c0+Y201*c1+Y202*c2+Y203*c3) +
|
||||
b1*(Y210*c0+Y211*c1+Y212*c2+Y213*c3) +
|
||||
b2*(Y220*c0+Y221*c1+Y222*c2+Y223*c3) +
|
||||
b3*(Y230*c0+Y231*c1+Y232*c2+Y233*c3);
|
||||
T term3 =
|
||||
b0*(Y300*c0+Y301*c1+Y302*c2+Y303*c3) +
|
||||
b1*(Y310*c0+Y311*c1+Y312*c2+Y313*c3) +
|
||||
b2*(Y320*c0+Y321*c1+Y322*c2+Y323*c3) +
|
||||
b3*(Y330*c0+Y331*c1+Y332*c2+Y333*c3);
|
||||
val = a0*term0 + a1*term1 + a2*term2 + a3*term3;
|
||||
gradfX = da0*term0 + da1*term1 + da2*term2 + da3*term3;
|
||||
gradfY =
|
||||
a0*
|
||||
(db0*(Y000*c0+Y001*c1+Y002*c2+Y003*c3) +
|
||||
db1*(Y010*c0+Y011*c1+Y012*c2+Y013*c3) +
|
||||
db2*(Y020*c0+Y021*c1+Y022*c2+Y023*c3) +
|
||||
db3*(Y030*c0+Y031*c1+Y032*c2+Y033*c3))+
|
||||
a1 *
|
||||
(db0*(Y100*c0+Y101*c1+Y102*c2+Y103*c3) +
|
||||
db1*(Y110*c0+Y111*c1+Y112*c2+Y113*c3) +
|
||||
db2*(Y120*c0+Y121*c1+Y122*c2+Y123*c3) +
|
||||
db3*(Y130*c0+Y131*c1+Y132*c2+Y133*c3))+
|
||||
a2 *
|
||||
(db0*(Y200*c0+Y201*c1+Y202*c2+Y203*c3) +
|
||||
db1*(Y210*c0+Y211*c1+Y212*c2+Y213*c3) +
|
||||
db2*(Y220*c0+Y221*c1+Y222*c2+Y223*c3) +
|
||||
db3*(Y230*c0+Y231*c1+Y232*c2+Y233*c3))+
|
||||
a3 *
|
||||
(db0*(Y300*c0+Y301*c1+Y302*c2+Y303*c3) +
|
||||
db1*(Y310*c0+Y311*c1+Y312*c2+Y313*c3) +
|
||||
db2*(Y320*c0+Y321*c1+Y322*c2+Y323*c3) +
|
||||
db3*(Y330*c0+Y331*c1+Y332*c2+Y333*c3));
|
||||
gradfZ =
|
||||
a0*
|
||||
(b0*(Y000*dc0+Y001*dc1+Y002*dc2+Y003*dc3) +
|
||||
b1*(Y010*dc0+Y011*dc1+Y012*dc2+Y013*dc3) +
|
||||
b2*(Y020*dc0+Y021*dc1+Y022*dc2+Y023*dc3) +
|
||||
b3*(Y030*dc0+Y031*dc1+Y032*dc2+Y033*dc3))+
|
||||
a1 *
|
||||
(b0*(Y100*dc0+Y101*dc1+Y102*dc2+Y103*dc3) +
|
||||
b1*(Y110*dc0+Y111*dc1+Y112*dc2+Y113*dc3) +
|
||||
b2*(Y120*dc0+Y121*dc1+Y122*dc2+Y123*dc3) +
|
||||
b3*(Y130*dc0+Y131*dc1+Y132*dc2+Y133*dc3))+
|
||||
a2 *
|
||||
(b0*(Y200*dc0+Y201*dc1+Y202*dc2+Y203*dc3) +
|
||||
b1*(Y210*dc0+Y211*dc1+Y212*dc2+Y213*dc3) +
|
||||
b2*(Y220*dc0+Y221*dc1+Y222*dc2+Y223*dc3) +
|
||||
b3*(Y230*dc0+Y231*dc1+Y232*dc2+Y233*dc3))+
|
||||
a3 *
|
||||
(b0*(Y300*dc0+Y301*dc1+Y302*dc2+Y303*dc3) +
|
||||
b1*(Y310*dc0+Y311*dc1+Y312*dc2+Y313*dc3) +
|
||||
b2*(Y320*dc0+Y321*dc1+Y322*dc2+Y323*dc3) +
|
||||
b3*(Y330*dc0+Y331*dc1+Y332*dc2+Y333*dc3));
|
||||
lapf =
|
||||
d2a0*
|
||||
(b0*(Y000*c0+Y001*c1+Y002*c2+Y003*c3) +
|
||||
b1*(Y010*c0+Y011*c1+Y012*c2+Y013*c3) +
|
||||
b2*(Y020*c0+Y021*c1+Y022*c2+Y023*c3) +
|
||||
b3*(Y030*c0+Y031*c1+Y032*c2+Y033*c3))+
|
||||
d2a1 *
|
||||
(b0*(Y100*c0+Y101*c1+Y102*c2+Y103*c3) +
|
||||
b1*(Y110*c0+Y111*c1+Y112*c2+Y113*c3) +
|
||||
b2*(Y120*c0+Y121*c1+Y122*c2+Y123*c3) +
|
||||
b3*(Y130*c0+Y131*c1+Y132*c2+Y133*c3))+
|
||||
d2a2 *
|
||||
(b0*(Y200*c0+Y201*c1+Y202*c2+Y203*c3) +
|
||||
b1*(Y210*c0+Y211*c1+Y212*c2+Y213*c3) +
|
||||
b2*(Y220*c0+Y221*c1+Y222*c2+Y223*c3) +
|
||||
b3*(Y230*c0+Y231*c1+Y232*c2+Y233*c3))+
|
||||
d2a3 *
|
||||
(b0*(Y300*c0+Y301*c1+Y302*c2+Y303*c3) +
|
||||
b1*(Y310*c0+Y311*c1+Y312*c2+Y313*c3) +
|
||||
b2*(Y320*c0+Y321*c1+Y322*c2+Y323*c3) +
|
||||
b3*(Y330*c0+Y331*c1+Y332*c2+Y333*c3))+
|
||||
a0*
|
||||
(d2b0*(Y000*c0+Y001*c1+Y002*c2+Y003*c3) +
|
||||
d2b1*(Y010*c0+Y011*c1+Y012*c2+Y013*c3) +
|
||||
d2b2*(Y020*c0+Y021*c1+Y022*c2+Y023*c3) +
|
||||
d2b3*(Y030*c0+Y031*c1+Y032*c2+Y033*c3))+
|
||||
a1 *
|
||||
(d2b0*(Y100*c0+Y101*c1+Y102*c2+Y103*c3) +
|
||||
d2b1*(Y110*c0+Y111*c1+Y112*c2+Y113*c3) +
|
||||
d2b2*(Y120*c0+Y121*c1+Y122*c2+Y123*c3) +
|
||||
d2b3*(Y130*c0+Y131*c1+Y132*c2+Y133*c3))+
|
||||
a2 *
|
||||
(d2b0*(Y200*c0+Y201*c1+Y202*c2+Y203*c3) +
|
||||
d2b1*(Y210*c0+Y211*c1+Y212*c2+Y213*c3) +
|
||||
d2b2*(Y220*c0+Y221*c1+Y222*c2+Y223*c3) +
|
||||
d2b3*(Y230*c0+Y231*c1+Y232*c2+Y233*c3))+
|
||||
a3 *
|
||||
(d2b0*(Y300*c0+Y301*c1+Y302*c2+Y303*c3) +
|
||||
d2b1*(Y310*c0+Y311*c1+Y312*c2+Y313*c3) +
|
||||
d2b2*(Y320*c0+Y321*c1+Y322*c2+Y323*c3) +
|
||||
d2b3*(Y330*c0+Y331*c1+Y332*c2+Y333*c3)) +
|
||||
a0*
|
||||
(b0*(Y000*d2c0+Y001*d2c1+Y002*d2c2+Y003*d2c3) +
|
||||
b1*(Y010*d2c0+Y011*d2c1+Y012*d2c2+Y013*d2c3) +
|
||||
b2*(Y020*d2c0+Y021*d2c1+Y022*d2c2+Y023*d2c3) +
|
||||
b3*(Y030*d2c0+Y031*d2c1+Y032*d2c2+Y033*d2c3))+
|
||||
a1 *
|
||||
(b0*(Y100*d2c0+Y101*d2c1+Y102*d2c2+Y103*d2c3) +
|
||||
b1*(Y110*d2c0+Y111*d2c1+Y112*d2c2+Y113*d2c3) +
|
||||
b2*(Y120*d2c0+Y121*d2c1+Y122*d2c2+Y123*d2c3) +
|
||||
b3*(Y130*d2c0+Y131*d2c1+Y132*d2c2+Y133*d2c3))+
|
||||
a2 *
|
||||
(b0*(Y200*d2c0+Y201*d2c1+Y202*d2c2+Y203*d2c3) +
|
||||
b1*(Y210*d2c0+Y211*d2c1+Y212*d2c2+Y213*d2c3) +
|
||||
b2*(Y220*d2c0+Y221*d2c1+Y222*d2c2+Y223*d2c3) +
|
||||
b3*(Y230*d2c0+Y231*d2c1+Y232*d2c2+Y233*d2c3))+
|
||||
a3 *
|
||||
(b0*(Y300*d2c0+Y301*d2c1+Y302*d2c2+Y303*d2c3) +
|
||||
b1*(Y310*d2c0+Y311*d2c1+Y312*d2c2+Y313*d2c3) +
|
||||
b2*(Y320*d2c0+Y321*d2c1+Y322*d2c2+Y323*d2c3) +
|
||||
b3*(Y330*d2c0+Y331*d2c1+Y332*d2c2+Y333*d2c3));
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -34,7 +34,7 @@ SET(HAMSRCS
|
|||
ForceBase.cpp
|
||||
HamiltonianFactory.cpp
|
||||
CoulombPotentialFactory.cpp
|
||||
model/HarmonicExternalPotential.cpp
|
||||
HarmonicExternalPotential.cpp
|
||||
StaticStructureFactor.cpp
|
||||
OrbitalImages.cpp
|
||||
SpinDensity.cpp
|
||||
|
@ -95,14 +95,6 @@ IF(OHMMS_DIM MATCHES 3)
|
|||
)
|
||||
ENDIF(QMC_CUDA)
|
||||
|
||||
# Add research-related sources here
|
||||
IF(QMC_BUILD_LEVEL GREATER 1)
|
||||
SET(HAMSRCS ${HAMSRCS}
|
||||
model/LennardJones_smoothed.cpp
|
||||
model/HFDHE2_Moroni1995.cpp
|
||||
model/HeSAPT_smoothed.cpp
|
||||
)
|
||||
ENDIF(QMC_BUILD_LEVEL GREATER 1)
|
||||
ENDIF(OHMMS_DIM MATCHES 3)
|
||||
|
||||
IF(QMC_CUDA)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "QMCHamiltonians/LocalMomentEstimator.h"
|
||||
#include "QMCHamiltonians/DensityEstimator.h"
|
||||
#include "QMCHamiltonians/SkEstimator.h"
|
||||
#include "QMCHamiltonians/model/HarmonicExternalPotential.h"
|
||||
#include "QMCHamiltonians/HarmonicExternalPotential.h"
|
||||
#include "QMCHamiltonians/StaticStructureFactor.h"
|
||||
#include "QMCHamiltonians/SpinDensity.h"
|
||||
#include "QMCHamiltonians/OrbitalImages.h"
|
||||
|
@ -50,21 +50,6 @@
|
|||
// #include "QMCHamiltonians/ZeroVarObs.h"
|
||||
#if !defined(QMC_CUDA) && QMC_BUILD_LEVEL>2
|
||||
#include "QMCHamiltonians/SkPot.h"
|
||||
#include "QMCHamiltonians/model/HardSphere.h"
|
||||
#include "QMCHamiltonians/model/GaussianPot.h"
|
||||
#include "QMCHamiltonians/model/HusePot.h"
|
||||
#include "QMCHamiltonians/model/OscillatoryPot.h"
|
||||
#include "QMCHamiltonians/model/ModPosTelPot.h"
|
||||
#include "QMCHamiltonians/model/HFDHE2Potential_tail.h"
|
||||
#include "QMCHamiltonians/model/HePressure.h"
|
||||
#include "QMCHamiltonians/model/JelliumPotential.h"
|
||||
#include "QMCHamiltonians/model/HFDHE2Potential.h"
|
||||
#include "QMCHamiltonians/model/HeEPotential.h"
|
||||
#include "QMCHamiltonians/model/HeEPotential_tail.h"
|
||||
#include "QMCHamiltonians/model/LennardJones_smoothed.h"
|
||||
#include "QMCHamiltonians/model/HFDHE2_Moroni1995.h"
|
||||
//#include "QMCHamiltonians/HFDBHE_smoothed.h"
|
||||
#include "QMCHamiltonians/model/HeSAPT_smoothed.h"
|
||||
#endif
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
#ifdef QMC_CUDA
|
||||
|
@ -171,36 +156,6 @@ bool HamiltonianFactory::build(xmlNodePtr cur, bool buildtree)
|
|||
addCoulombPotential(cur);
|
||||
}
|
||||
#if !defined(QMC_CUDA) && QMC_BUILD_LEVEL>2
|
||||
else if (potType == "hardsphere")
|
||||
{
|
||||
HardSphere* hs = new HardSphere(*targetPtcl);
|
||||
hs->put(cur);
|
||||
targetH->addOperator(hs,"HardSphere",true);
|
||||
}
|
||||
else if (potType == "gaussian")
|
||||
{
|
||||
GaussianPot* hs = new GaussianPot(*targetPtcl);
|
||||
hs->put(cur);
|
||||
targetH->addOperator(hs,"GaussianPot",true);
|
||||
}
|
||||
else if (potType == "huse")
|
||||
{
|
||||
HusePot* hs = new HusePot(*targetPtcl);
|
||||
hs->put(cur);
|
||||
targetH->addOperator(hs,"HusePot",true);
|
||||
}
|
||||
else if (potType == "modpostel")
|
||||
{
|
||||
ModPoschlTeller* hs = new ModPoschlTeller(*targetPtcl);
|
||||
hs->put(cur);
|
||||
targetH->addOperator(hs,"ModPoschlTeller",true);
|
||||
}
|
||||
else if (potType == "oscillatory")
|
||||
{
|
||||
OscillatoryPotential* hs = new OscillatoryPotential(*targetPtcl);
|
||||
hs->put(cur);
|
||||
targetH->addOperator(hs,"OscillatoryPotential",true);
|
||||
}
|
||||
else if (potType == "skpot")
|
||||
{
|
||||
SkPot* hs = new SkPot(*targetPtcl);
|
||||
|
@ -209,13 +164,6 @@ bool HamiltonianFactory::build(xmlNodePtr cur, bool buildtree)
|
|||
}
|
||||
#endif
|
||||
#if OHMMS_DIM==3
|
||||
/*
|
||||
else if (potType == "HFDBHE_smoothed") {
|
||||
HFDBHE_smoothed_phy* HFD = new HFDBHE_smoothed_phy(*targetPtcl);
|
||||
targetH->addOperator(HFD,"HFD-B(He)",true);
|
||||
HFD->addCorrection(*targetH);
|
||||
}
|
||||
*/
|
||||
else if (potType == "MPC" || potType == "mpc")
|
||||
addMPCPotential(cur);
|
||||
else if(potType == "pseudo")
|
||||
|
@ -225,64 +173,6 @@ bool HamiltonianFactory::build(xmlNodePtr cur, bool buildtree)
|
|||
{
|
||||
addCorePolPotential(cur);
|
||||
}
|
||||
else if (potType == "LJP_smoothed")
|
||||
{
|
||||
LennardJones_smoothed_phy* LJP = new LennardJones_smoothed_phy(*targetPtcl);
|
||||
targetH->addOperator(LJP,"LJP",true);
|
||||
LJP->addCorrection(*targetH);
|
||||
}
|
||||
else if (potType == "HeSAPT_smoothed")
|
||||
{
|
||||
HeSAPT_smoothed_phy* SAPT = new HeSAPT_smoothed_phy(*targetPtcl);
|
||||
targetH->addOperator(SAPT,"HeSAPT",true);
|
||||
SAPT->addCorrection(*targetH);
|
||||
}
|
||||
else if (potType == "HFDHE2_Moroni1995")
|
||||
{
|
||||
HFDHE2_Moroni1995_phy* HFD = new HFDHE2_Moroni1995_phy(*targetPtcl);
|
||||
targetH->addOperator(HFD,"HFD-HE2",true);
|
||||
HFD->addCorrection(*targetH);
|
||||
}
|
||||
else if(potType == "eHe")
|
||||
{
|
||||
std::string SourceName = "e";
|
||||
OhmmsAttributeSet hAttrib;
|
||||
hAttrib.add(SourceName, "source");
|
||||
hAttrib.put(cur);
|
||||
PtclPoolType::iterator pit(ptclPool.find(SourceName));
|
||||
if(pit == ptclPool.end())
|
||||
{
|
||||
APP_ABORT("Unknown source \"" + SourceName + "\" for e-He Potential.");
|
||||
}
|
||||
ParticleSet* source = (*pit).second;
|
||||
HeePotential* eHetype = new HeePotential(*targetPtcl, *source);
|
||||
targetH->addOperator(eHetype,potName,true);
|
||||
// targetH->addOperator(eHetype->makeDependants(*targetPtcl),potName,false);
|
||||
}
|
||||
else if(potType == "jellium")
|
||||
{
|
||||
std::string SourceName = "e";
|
||||
OhmmsAttributeSet hAttrib;
|
||||
hAttrib.add(SourceName, "source");
|
||||
hAttrib.put(cur);
|
||||
PtclPoolType::iterator pit(ptclPool.find(SourceName));
|
||||
if(pit == ptclPool.end())
|
||||
{
|
||||
APP_ABORT("Unknown source \"" + SourceName + "\" for e-He Potential.");
|
||||
}
|
||||
ParticleSet* source = (*pit).second;
|
||||
JelliumPotential* JP = new JelliumPotential(*source, *targetPtcl);
|
||||
targetH->addOperator(JP,potName,true);
|
||||
// targetH->addOperator(eHetype->makeDependants(*targetPtcl),potName,false);
|
||||
}
|
||||
else if(potType == "HFDHE2")
|
||||
{
|
||||
HFDHE2Potential* HFD = new HFDHE2Potential(*targetPtcl);
|
||||
targetH->addOperator(HFD,"HFDHE2",true);
|
||||
//HFD->addCorrection(*targetPtcl,*targetH);
|
||||
targetH->addOperator(HFD->makeDependants(*targetPtcl),HFD->depName,false);
|
||||
app_log() << " Adding HFDHE2Potential(Au) " << std::endl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -513,14 +403,6 @@ bool HamiltonianFactory::build(xmlNodePtr cur, bool buildtree)
|
|||
// DMCPressureCorr* DMCP = new DMCPressureCorr(*targetPtcl,nlen);
|
||||
// targetH->addOperator(DMCP,"PressureSum",false);
|
||||
}
|
||||
#if defined(QMC_BUILD_COMPLETE)
|
||||
else if (estType=="HFDHE2")
|
||||
{
|
||||
HePressure* BP = new HePressure(*targetPtcl);
|
||||
BP-> put(cur);
|
||||
targetH->addOperator(BP,"HePress",false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(potType=="momentum")
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
|
||||
#include <QMCHamiltonians/model/HarmonicExternalPotential.h>
|
||||
#include <QMCHamiltonians/HarmonicExternalPotential.h>
|
||||
#include <OhmmsData/AttributeSet.h>
|
||||
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_GAUSSIANPOT_H
|
||||
#define QMCPLUSPLUS_GAUSSIANPOT_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief GaussianPot for the indentical source and target particle sets.
|
||||
*
|
||||
*/
|
||||
struct GaussianPot: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
///number of particle
|
||||
int Centers;
|
||||
// core radius
|
||||
RealType d;
|
||||
// core strength
|
||||
RealType Q;
|
||||
|
||||
GaussianPot(ParticleSet& P)
|
||||
{
|
||||
Centers=P.getTotalNum();
|
||||
d = 1.0;
|
||||
Q=1.0;
|
||||
const DistanceTableData* d_table = DistanceTable::add(P,DT_AOS);
|
||||
}
|
||||
|
||||
~GaussianPot() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
//d_table = DistanceTable::add(P);
|
||||
//PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P)
|
||||
{
|
||||
const DistanceTableData* d_table=P.DistTables[0];
|
||||
Value = 0.0;
|
||||
for(int nn=0; nn<d_table->getTotNadj(); ++nn)
|
||||
{
|
||||
Value += std::exp(-1.0*(d_table->r(nn)*d)*(d_table->r(nn)*d));
|
||||
}
|
||||
return Value*=Q;
|
||||
//return C* std::accumulate(d_table->rinv.data(),
|
||||
// d_table->rinv.data()+d_table->getTotNadj(),
|
||||
// 0.0);
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
NewValue=Value;
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("GaussianPot::evaluatePbyP");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(P.DistTables[0]->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat) del+=(temp[iat].rinv1-temp[iat].rinv0);
|
||||
//return NewValue=Value+Q*del;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(d,"length");
|
||||
Tattrib.add(Q,"mag");
|
||||
Tattrib.put(cur);
|
||||
app_log()<<"GaussianPot parameters"<< std::endl;
|
||||
app_log()<<" length: "<<d<< std::endl;
|
||||
d=1.0/d;
|
||||
app_log()<<" mag: "<<Q<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
//os << "GaussianPot: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
GaussianPot* cl = new GaussianPot(qp);
|
||||
cl->d=d;
|
||||
cl->Q=Q;
|
||||
return cl;
|
||||
}
|
||||
|
||||
//#ifdef USE_FASTWALKER
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// std::vector<ValueType> e(W.walkers(),0.0);
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// e[iw] += d_table->rinv(iw,nn);
|
||||
// }
|
||||
// }
|
||||
// for(int iw=0; iw<W.walkers(); iw++) { LE[iw] += C*e[iw];}
|
||||
// }
|
||||
//#else
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// RealType e =0.0;
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++)
|
||||
// e += d_table->rinv(iw,nn);
|
||||
// LE[iw] += C*e;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HFDHE2POTENTIAL_H
|
||||
#define QMCPLUSPLUS_HFDHE2POTENTIAL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
#include "QMCHamiltonians/model/HFDHE2Potential_tail.h"
|
||||
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HFDHE2Potential for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HFDHE2Potential: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
Return_t tailcorr,TCValue,rc,A,alpha,c1,c2,c3,D;
|
||||
// remember that the default units are Hartree and Bohrs
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef;
|
||||
HFDHE2Potential_tail* TCorr;
|
||||
|
||||
// epsilon = 3.42016039e-5, rm = 5.607384357
|
||||
// C6 = 1.460008056, C8 = 14.22016431, C10 = 187.2033646;
|
||||
HFDHE2Potential(ParticleSet& P): PtclRef(&P)
|
||||
{
|
||||
Dependants=1;
|
||||
A = 18.63475757;
|
||||
alpha = -2.381392669;
|
||||
c1=1.460008056;
|
||||
c2=14.22016431;
|
||||
c3=187.2033646;
|
||||
D = 6.960524706;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
// Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
// Return_t N0 = P.G.size();
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
// tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
// std::cout <<" HFDHE2Potential tail correction is "<<tailcorr<< std::endl;
|
||||
depName = "HFDHE2tail";
|
||||
Return_t r2 = (rc*rc);
|
||||
Return_t rm2 = 1.0/r2;
|
||||
Return_t rm6 = std::pow(rm2,3);
|
||||
Return_t rm8 = rm6*rm2;
|
||||
Return_t rm10 = rm8*rm2;
|
||||
tailcorr = (A*std::exp(alpha*rc) - (c1*rm6+c2*rm8+c3*rm10)*dampF(rc));
|
||||
}
|
||||
|
||||
~HFDHE2Potential() { }
|
||||
|
||||
QMCHamiltonianBase* makeDependants(ParticleSet& qp )
|
||||
{
|
||||
TCorr = new HFDHE2Potential_tail(qp);
|
||||
return TCorr;
|
||||
}
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
PtclRef=&P;
|
||||
// Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
// Return_t N0 = P.G.size();
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
// tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = 0.0;
|
||||
TCValue = 0.0;
|
||||
for(int i=0; i<d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t r1 = d_table->r(i);
|
||||
if ( r1 < rc)
|
||||
{
|
||||
Return_t r2 = (r1*r1);
|
||||
Return_t rm2 = 1.0/r2;
|
||||
Return_t rm6 = std::pow(rm2,3);
|
||||
Return_t rm8 = rm6*rm2;
|
||||
Return_t rm10 = rm8*rm2;
|
||||
Value += (A*std::exp(alpha*r1) - (c1*rm6+c2*rm8+c3*rm10)*dampF(r1)) - tailcorr;
|
||||
TCValue +=tailcorr;
|
||||
}
|
||||
}
|
||||
TCorr->set_TC(TCValue);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t dampF(Return_t r)
|
||||
{
|
||||
if (r < D)
|
||||
{
|
||||
Return_t t1=(D/r - 1.0);
|
||||
return std::exp(-t1*t1);
|
||||
}
|
||||
else
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HFDHE2Potential (T/S): " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new HFDHE2Potential(qp);
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add("HFDHE2");
|
||||
// plist.add("HFDHE2tail");
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex]=Value;
|
||||
// plist[myIndex+1]=tailcorr;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,150 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HFDHE2POTENTIAL_TAIL_H
|
||||
#define QMCPLUSPLUS_HFDHE2POTENTIAL_TAIL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
///Using Kelvin and Angstrom
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HFDHE2Potential for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HFDHE2Potential_tail: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
Return_t tailcorr,rc,A,alpha,c1,c2,c3,D,KValue,Kpre;
|
||||
// remember that the default units are Hartree and Bohrs
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef;
|
||||
|
||||
// epsilon = 3.42016039e-5, rm = 5.607384357
|
||||
// C6 = 1.460008056, C8 = 14.22016431, C10 = 187.2033646;
|
||||
HFDHE2Potential_tail(ParticleSet& P): PtclRef(&P)
|
||||
{
|
||||
A = 18.63475757;
|
||||
alpha = -2.381392669;
|
||||
c1=1.460008056;
|
||||
c2=14.22016431;
|
||||
c3=187.2033646;
|
||||
D = 6.960524706;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
Return_t N0 = P.G.size();
|
||||
Kpre = 3.157733e+5/N0;
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
// tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
std::cout <<" HFDHE2Potential tail correction is "<<tailcorr<< std::endl;
|
||||
}
|
||||
|
||||
~HFDHE2Potential_tail() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
PtclRef=&P;
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
Return_t N0 = P.G.size();
|
||||
Kpre = 3.157733e+5/N0;
|
||||
Return_t rc = P.Lattice.WignerSeitzRadius;
|
||||
// tailcorr = 2*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
// std::cout <<" HFDHE2Potential tail correction is "<<tailcorr<< std::endl;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
// Value = 0.0;
|
||||
/*
|
||||
for(int i=0; i<d_table->getTotNadj(); i++) {
|
||||
Return_t r1 = d_table->r(i);
|
||||
if ( r1 < rc) {
|
||||
Return_t r2 = (r1*r1);
|
||||
Return_t rm2 = 1.0/r2;
|
||||
Return_t rm6 = std::pow(rm2,3);
|
||||
Return_t rm8 = rm6*rm2;
|
||||
Return_t rm10 = rm8*rm2;
|
||||
Value += (A*std::exp(alpha*r1) - (c1*rm6+c2*rm8+c3*rm10)*dampF(r1));
|
||||
}
|
||||
}*/
|
||||
Value += tailcorr;
|
||||
KValue = Value + P.PropertyList[LOCALENERGY];
|
||||
KValue *= Kpre;
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void set_TC(Return_t TCorr)
|
||||
{
|
||||
Value = TCorr;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
// inline Return_t dampF(Return_t r) {
|
||||
// if (r < D){
|
||||
// Return_t t1=(D/r - 1.0);
|
||||
// return std::exp(-t1*t1);
|
||||
// }
|
||||
// else
|
||||
// return 1.0;
|
||||
// }
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HFDHE2PotentialTailcorr: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
// return new HFDHE2Potential_tail(qp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add("HFDHE2tail");
|
||||
plist.add("KperP");
|
||||
// plist.add("HFDHE2tail");
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex]=Value;
|
||||
plist[myIndex+1]=KValue;
|
||||
// plist[myIndex+1]=tailcorr;
|
||||
}
|
||||
void setParticlePropertyList(PropertySetType& plist, int offset)
|
||||
{
|
||||
plist[myIndex+offset]=Value;
|
||||
plist[myIndex+1+offset]=KValue;
|
||||
// plist[myIndex+1]=tailcorr;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,113 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "QMCHamiltonians/model/HFDHE2_Moroni1995.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonian.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
HFDHE2_Moroni1995_phy::HFDHE2_Moroni1995_phy(ParticleSet& P): PtclRef(&P)
|
||||
{
|
||||
Dependants = 1;
|
||||
A = 18.63475757;
|
||||
alpha = -2.381392669;
|
||||
c1=1.460008056;
|
||||
c2=14.22016431;
|
||||
c3=187.2033646;
|
||||
D = 6.960524706;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume, N0 = P.G.size();
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
Return_t rcm2 = 1.0/(rc*rc), rcm6 = rcm2*rcm2*rcm2, rcm8 = rcm6*rcm2, rcm10 = rcm8*rcm2;
|
||||
mirrorshift = -2.0*(A*std::exp(alpha*rc) - (c1*rcm6+c2*rcm8+c3*rcm10)*dampF(rc));
|
||||
}
|
||||
|
||||
void HFDHE2_Moroni1995_phy::resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
PtclRef=&P;
|
||||
Return_t rc = P.Lattice.WignerSeitzRadius;
|
||||
Return_t rcm2 = 1.0/(rc*rc), rcm6 = rcm2*rcm2*rcm2, rcm8 = rcm6*rcm2, rcm10 = rcm8*rcm2;
|
||||
mirrorshift = -2.0*(A*std::exp(alpha*rc) - (c1*rcm6+c2*rcm8+c3*rcm10)*dampF(rc));
|
||||
}
|
||||
|
||||
HFDHE2_Moroni1995_phy::Return_t HFDHE2_Moroni1995_phy::evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = 0.0;
|
||||
smooth = 0.0;
|
||||
for(int i=0; i<d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t r1 = d_table->r(i);
|
||||
if (r1 < rc)
|
||||
{
|
||||
Return_t rm2 = 1.0/(r1*r1), rm6 = rm2*rm2*rm2, rm8 = rm6*rm2, rm10 = rm8*rm2;
|
||||
Return_t rd1 = 2.0*rc - r1, rdm2 = 1.0/(rd1*rd1), rdm6 = rdm2*rdm2*rdm2, rdm8 = rdm6*rdm2, rdm10 = rdm8*rdm2;
|
||||
Value += (A*std::exp(alpha*r1) - (c1*rm6+c2*rm8+c3*rm10)*dampF(r1));
|
||||
smooth += A*std::exp(alpha*rd1) - (c1*rdm6+c2*rdm8+c3*rdm10)*dampF(rd1) + mirrorshift;
|
||||
}
|
||||
}
|
||||
Value += smooth;
|
||||
// dep->setValue(-smooth);
|
||||
return Value;
|
||||
}
|
||||
|
||||
void HFDHE2_Moroni1995_phy::add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH)
|
||||
{
|
||||
HFDHE2_Moroni1995_phy* myclone=new HFDHE2_Moroni1995_phy(qp);
|
||||
targetH.addOperator(myclone,myName,true);
|
||||
myclone->addCorrection(targetH);
|
||||
}
|
||||
|
||||
void HFDHE2_Moroni1995_phy::addCorrection(QMCHamiltonian& targetH)
|
||||
{
|
||||
HFDHE2_Moroni1995_aux* auxterm = new HFDHE2_Moroni1995_aux(this);
|
||||
std::string auxname=myName+"_aux";
|
||||
targetH.addOperator(auxterm,auxname,false);
|
||||
}
|
||||
|
||||
/*
|
||||
void HFDHE2_Moroni1995_aux::registerObservables(std::vector<observable_helper*>& h5list, hid_t gid) const {
|
||||
int loc=h5list.size();
|
||||
std::vector<int> onedim(1,1);
|
||||
h5list.push_back(new observable_helper("HFDHE2_aux"));
|
||||
h5list[loc]->set_dimensions(onedim,myIndex);
|
||||
h5list[loc]->open(gid);
|
||||
|
||||
h5list.push_back(new observable_helper("KperP"));
|
||||
++loc;
|
||||
h5list[loc]->set_dimensions(onedim,myIndex);
|
||||
h5list[loc]->open(gid);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void HFDHE2_Moroni1995_aux::addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add("HFDHE2_aux");
|
||||
// plist.add("KperP");
|
||||
}
|
||||
|
||||
void HFDHE2_Moroni1995_aux::setObservables(PropertySetType& plist) {
|
||||
plist[myIndex]=Value;
|
||||
// plist[myIndex+1]=KValue;
|
||||
}
|
||||
|
||||
void HFDHE2_Moroni1995_aux::setParticlePropertyList(PropertySetType& plist, int offset)
|
||||
{
|
||||
plist[myIndex+offset]=Value;
|
||||
// plist[myIndex+1+offset]=KValue;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HFDHE2MORONI1995_H
|
||||
#define QMCPLUSPLUS_HFDHE2MORONI1995_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HFDHE2_Moroni1995_phy for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HFDHE2_Moroni1995_phy: public QMCHamiltonianBase
|
||||
{
|
||||
Return_t rc,A,alpha,c1,c2,c3,D,mirrorshift,smooth;
|
||||
// remember that the default units are Hartree and Bohrs
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef;
|
||||
// HFDHE2_Moroni1995_aux* dep;
|
||||
|
||||
// epsilon = 3.42016039e-5, rm = 5.607384357
|
||||
// C6 = 1.460008056, C8 = 14.22016431, C10 = 187.2033646;
|
||||
HFDHE2_Moroni1995_phy(ParticleSet& P);
|
||||
|
||||
~HFDHE2_Moroni1995_phy() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P);
|
||||
|
||||
Return_t evaluate(ParticleSet& P);
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t dampF(Return_t r)
|
||||
{
|
||||
if (r < D)
|
||||
{
|
||||
Return_t t1=(D/r - 1.0);
|
||||
return std::exp(-t1*t1);
|
||||
}
|
||||
else
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HFDHE2_Moroni1995_phy (T/S): " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
void add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH);
|
||||
|
||||
void addCorrection(QMCHamiltonian& targetH);
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new HFDHE2_Moroni1995_phy(qp);
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add(myName);
|
||||
/*
|
||||
for (int i=0; i<plist.Names.size(); i++)
|
||||
std::cout<<plist.Names[i];
|
||||
std::cout<< "!!!!!" << std::endl;
|
||||
*/
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex]=Value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct HFDHE2_Moroni1995_aux: public QMCHamiltonianBase
|
||||
{
|
||||
const HFDHE2_Moroni1995_phy* phyH;
|
||||
Return_t tailcorr;
|
||||
// Return_t KValue;
|
||||
|
||||
HFDHE2_Moroni1995_aux(const HFDHE2_Moroni1995_phy* orig): phyH(orig)
|
||||
{
|
||||
Return_t rho = phyH->PtclRef->G.size()/phyH->PtclRef->Lattice.Volume, N0 = phyH->PtclRef->G.size(), rc = phyH->PtclRef->Lattice.WignerSeitzRadius;
|
||||
tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
}
|
||||
|
||||
~HFDHE2_Moroni1995_aux() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet &P)
|
||||
{
|
||||
Return_t rho = phyH->PtclRef->G.size()/phyH->PtclRef->Lattice.Volume, N0 = phyH->PtclRef->G.size(), rc = phyH->PtclRef->Lattice.WignerSeitzRadius;
|
||||
tailcorr = 2.0*M_PI*rho*N0*(-26.7433377905*std::pow(rc,-7.0) - 2.8440930339*std::pow(rc,-5.0)-0.486669351961 *std::pow(rc,-3.0)+ std::exp(-2.381392669*rc)*(2.75969257875+6.571911675726*rc+7.82515114293*rc*rc) );
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet &P)
|
||||
{
|
||||
// Value += phyH->smooth;
|
||||
Value = -(phyH->smooth) + tailcorr;
|
||||
// atomic units vs. kelvins
|
||||
// KValue = 0.0;
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet &P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HFDHE2_Moroni1995_aux: " << phyH->PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
void addObservables(PropertySetType& plist);
|
||||
|
||||
void setObservables(PropertySetType& plist);
|
||||
|
||||
void setParticlePropertyList(PropertySetType& plist, int offset);
|
||||
*/
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,167 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HARDSPHERE_H
|
||||
#define QMCPLUSPLUS_HARDSPHERE_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HardSphere for the indentical source and target particle sets.
|
||||
*
|
||||
*/
|
||||
struct HardSphere: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
///number of particle
|
||||
int Centers;
|
||||
// hard core radius
|
||||
RealType d;
|
||||
// hard core strength
|
||||
RealType Q;
|
||||
|
||||
HardSphere(ParticleSet& P)
|
||||
{
|
||||
Centers=P.getTotalNum();
|
||||
d = 1.0;//cheating, need to fix this
|
||||
const DistanceTableData* d_table = DistanceTable::add(P,DT_AOS);
|
||||
}
|
||||
|
||||
~HardSphere() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
//d_table = DistanceTable::add(P);
|
||||
//PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P)
|
||||
{
|
||||
const DistanceTableData* d_table=P.DistTables[0];
|
||||
Value = 0.0;
|
||||
for(int nn=0; nn<d_table->getTotNadj(); ++nn)
|
||||
{
|
||||
if (d_table->r(nn)<=d)
|
||||
Value += 1;
|
||||
}
|
||||
return Value*=Q;
|
||||
//return C* std::accumulate(d_table->rinv.data(),
|
||||
// d_table->rinv.data()+d_table->getTotNadj(),
|
||||
// 0.0);
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
NewValue=Value;
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("HardSphere::evaluatePbyP");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(P.DistTables[0]->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat) del+=(temp[iat].rinv1-temp[iat].rinv0);
|
||||
//return NewValue=Value+Q*del;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(d,"length");
|
||||
Tattrib.add(Q,"mag");
|
||||
Tattrib.put(cur);
|
||||
app_log()<<"HardSphere parameters"<< std::endl;
|
||||
app_log()<<" length: "<<d<< std::endl;
|
||||
app_log()<<" mag: "<<Q<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
//os << "HardSphere: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
HardSphere* cl = new HardSphere(qp);
|
||||
cl->d=d;
|
||||
cl->Q=Q;
|
||||
return cl;
|
||||
}
|
||||
|
||||
//#ifdef USE_FASTWALKER
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// std::vector<ValueType> e(W.walkers(),0.0);
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// e[iw] += d_table->rinv(iw,nn);
|
||||
// }
|
||||
// }
|
||||
// for(int iw=0; iw<W.walkers(); iw++) { LE[iw] += C*e[iw];}
|
||||
// }
|
||||
//#else
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// RealType e =0.0;
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++)
|
||||
// e += d_table->rinv(iw,nn);
|
||||
// LE[iw] += C*e;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HEEPOTENTIAL_H
|
||||
#define QMCPLUSPLUS_HEEPOTENTIAL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
#include "QMCHamiltonians/model/HeEPotential_tail.h"
|
||||
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief He-e potential
|
||||
*/
|
||||
struct HeePotential: public QMCHamiltonianBase
|
||||
{
|
||||
RealType rc;
|
||||
RealType A,B,C,trunc,TCValue;
|
||||
// HeePotential_tail* TCorr;
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef, IRef;
|
||||
|
||||
HeePotential(ParticleSet& P, ParticleSet& I): PtclRef(&P), IRef(I)
|
||||
{
|
||||
// Dependants=1;
|
||||
// depName = "Heetail";
|
||||
A=0.655;
|
||||
B=89099;
|
||||
C=12608;
|
||||
d_table = DistanceTable::add(I,P,DT_AOS);
|
||||
// rc = P.Lattice.WignerSeitzRadius;
|
||||
// app_log()<<" RC is "<<rc<< std::endl;
|
||||
// if (rc>0) trunc= A*std::pow(rc,-4) * ( B/(C+std::pow(rc,6)) - 1 );
|
||||
// else trunc=0;
|
||||
// app_log()<<" trunc "<<trunc<< std::endl;
|
||||
}
|
||||
|
||||
~HeePotential() { }
|
||||
|
||||
// QMCHamiltonianBase* makeDependants(ParticleSet& qp )
|
||||
// {
|
||||
// // TCorr = new HeePotential_tail(qp);
|
||||
// return TCorr;
|
||||
// }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = 0.0;
|
||||
// TCValue=0.0;
|
||||
for(int i=0; i<d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t r1 = d_table->r(i);
|
||||
// if ( r1 < rc) {
|
||||
Value+=A*std::pow(r1,-4) * ( B/(C+std::pow(r1,6)) - 1 ) ;
|
||||
// TCValue+=trunc;
|
||||
// }
|
||||
}
|
||||
// TCorr->set_TC(TCValue);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
std::string tagName("HeePot");
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(tagName,"name");
|
||||
Tattrib.put(cur);
|
||||
if (tagName != "HeePot")
|
||||
myName=tagName;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HeePotential: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
HeePotential* HPclone = new HeePotential(qp,IRef);
|
||||
HPclone->myName = myName;
|
||||
return HPclone;
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add(myName);
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex]=Value;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HEEPOTENTIAL_TAIL_H
|
||||
#define QMCPLUSPLUS_HEEPOTENTIAL_TAIL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
// #include "Particle/WalkerSetRef.h"
|
||||
// #include "Particle/DistanceTableData.h"
|
||||
// #include "Particle/DistanceTable.h"
|
||||
// #include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
///Using Kelvin and Angstrom
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HFDHE2Potential for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HeePotential_tail: public QMCHamiltonianBase
|
||||
{
|
||||
ParticleSet* PtclRef;
|
||||
|
||||
HeePotential_tail(ParticleSet& P): PtclRef(&P)
|
||||
{
|
||||
}
|
||||
|
||||
~HeePotential_tail() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void set_TC(Return_t TCorr)
|
||||
{
|
||||
Value = TCorr;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HeePotentialTailcorr: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add("Heetail");
|
||||
}
|
||||
|
||||
// void setObservables(PropertySetType& plist)
|
||||
// {
|
||||
// plist[myIndex]=Value;
|
||||
// }
|
||||
// void setParticlePropertyList(PropertySetType& plist, int offset)
|
||||
// {
|
||||
// plist[myIndex+offset]=Value;
|
||||
// }
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,200 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HEPRESSURE_H
|
||||
#define QMCPLUSPLUS_HEPRESSURE_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "ParticleBase/ParticleAttribOps.h"
|
||||
#include "OhmmsData/ParameterSet.h"
|
||||
|
||||
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
@brief Evaluate the He Pressure.
|
||||
|
||||
where d is the dimension of space and /Omega is the volume.
|
||||
**/
|
||||
|
||||
struct HePressure: public QMCHamiltonianBase
|
||||
{
|
||||
double A,alpha,c0,c1,c2,c3,c1p,c2p,c3p,D,rdV,dV,dVnorm ;
|
||||
double pNorm,tailcorr,rcutoff,kNorm;
|
||||
bool ZV;
|
||||
bool ZB;
|
||||
|
||||
ParticleSet* sourcePtcl;
|
||||
DistanceTableData* d_table;
|
||||
|
||||
/** constructor
|
||||
*
|
||||
* HePressure operators need to be re-evaluated during optimization.
|
||||
*/
|
||||
HePressure(ParticleSet& P ): sourcePtcl(&P)
|
||||
{
|
||||
UpdateMode.set(OPTIMIZABLE,1);
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
Return_t N0 = P.G.size();
|
||||
rcutoff = P.Lattice.WignerSeitzRadius;
|
||||
Return_t rs = std::pow(3.0/(4.0*M_PI*rho),1.0/3.0);
|
||||
pNorm = -1.0/(3.0*P.Lattice.Volume);
|
||||
kNorm = 2.0/(3.0*P.Lattice.Volume);
|
||||
dVnorm = 2.0*pNorm*rs;
|
||||
A = 18.63475757;
|
||||
alpha = -2.381392669;
|
||||
c1=1.460008056;
|
||||
c2=14.22016431;
|
||||
c3=187.2033646;
|
||||
c0 = A*alpha;
|
||||
c1p = -6*c1;
|
||||
c2p = -8*c2;
|
||||
c3p = -10*c3;
|
||||
D = 6.960524706;
|
||||
Return_t r1 = rcutoff;
|
||||
Return_t r2 = (r1*r1);
|
||||
Return_t rm3 = 1.0/(r2*r1);
|
||||
Return_t rm5 = rm3/r2;
|
||||
Return_t rm7 = rm5/r2;
|
||||
tailcorr = (10*c3)/7*rm7 + (8*c2)/5*rm5 + (2*c1)*rm3 + ( A*std::exp(alpha*r1) * (6 - alpha*rcutoff*(6 - alpha*rcutoff* (3 - alpha* rcutoff))))/(alpha*alpha*alpha);
|
||||
tailcorr *= pNorm;
|
||||
tailcorr *= 2.0*M_PI*rho*N0;
|
||||
std::cout << std::setprecision(12) <<" HePressure:: Tail Correction for "<<sourcePtcl->getName()<<" is: "<<tailcorr<< std::endl;
|
||||
// std::cout <<" Cutoff is: "<<rcutoff<< std::endl;
|
||||
}
|
||||
///destructor
|
||||
~HePressure() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
sourcePtcl= &P;
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume;
|
||||
Return_t N0 = P.G.size();
|
||||
rcutoff = P.Lattice.WignerSeitzRadius;
|
||||
Return_t rs = std::pow(3.0/(4.0*M_PI*rho),1.0/3.0);
|
||||
pNorm = -1.0/(3.0*P.Lattice.Volume);
|
||||
kNorm = 2.0/(3.0*P.Lattice.Volume);
|
||||
dVnorm = 2.0*pNorm*rs;
|
||||
Return_t r1 = rcutoff;
|
||||
Return_t r2 = (r1*r1);
|
||||
Return_t rm3 = 1.0/(r2*r1);
|
||||
Return_t rm5 = rm3/r2;
|
||||
Return_t rm7 = rm5/r2;
|
||||
tailcorr = (10*c3)/7*rm7 + (8*c2)/5*rm5 + (2*c1)*rm3 + ( A*std::exp(alpha*r1) * (6 - alpha*rcutoff*(6 - alpha*rcutoff* (3 - alpha* rcutoff))))/(alpha*alpha*alpha);
|
||||
tailcorr *= pNorm;
|
||||
tailcorr *= 2.0*M_PI*rho*N0;
|
||||
// std::cout <<" Pressure Tail Correction for "<<sourcePtcl->getName()<<" is: "<<tailcorr<< std::endl;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = 0.0;
|
||||
// dV = 0.0;
|
||||
Return_t KE = P.PropertyList[LOCALENERGY]-P.PropertyList[LOCALPOTENTIAL];
|
||||
for(int i=0; i<d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t RR = d_table->r(i);
|
||||
if ( RR < rcutoff)
|
||||
{
|
||||
Return_t rm1 = 1.0/RR;
|
||||
Return_t rm2 = rm1*rm1;
|
||||
Return_t rm6 = std::pow(rm2,3);
|
||||
Return_t rm8 = rm6*rm2;
|
||||
Return_t rm10 = rm8*rm2;
|
||||
Return_t TMP1;
|
||||
if (RR < D)
|
||||
{
|
||||
Return_t t1=(D*rm1 - 1.0);
|
||||
Return_t dampF = std::exp(-t1*t1);
|
||||
TMP1 = c0*RR*std::exp(alpha*RR) - (c1p*rm6 + c2p*rm8 + c3p*rm10 + 2.0* (c1*rm6+c2*rm8+c3*rm10)*D*rm1*t1 )*dampF;
|
||||
}
|
||||
else
|
||||
TMP1 = c0*RR*std::exp(alpha*RR) - (c1p*rm6 + c2p*rm8 + c3p*rm10);
|
||||
Value += TMP1;
|
||||
dV += TMP1/RR;
|
||||
}
|
||||
}
|
||||
dV *= dVnorm;
|
||||
Value *= pNorm;
|
||||
rdV = Value + tailcorr;
|
||||
Value += kNorm*KE;
|
||||
Value += tailcorr;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// inline Return_t dampF(Return_t r) {
|
||||
// if (r < D){
|
||||
// Return_t t1=(D/r - 1.0);
|
||||
// return std::exp(-t1*t1);
|
||||
// }
|
||||
// else
|
||||
// return 1.0;
|
||||
// }
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
/** implements the virtual function.
|
||||
*
|
||||
* Nothing is done but should check the mass
|
||||
*/
|
||||
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HePressure: "<< sourcePtcl->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new HePressure(qp);
|
||||
}
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex=plist.add("HePress");
|
||||
plist.add("rijdrV");
|
||||
plist.add("drV");
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex]=Value;
|
||||
plist[myIndex+1]=rdV;
|
||||
plist[myIndex+2]=dV;
|
||||
}
|
||||
void setParticlePropertyList(PropertySetType& plist, int offset)
|
||||
{
|
||||
plist[myIndex+offset]=Value;
|
||||
plist[myIndex+1+offset]=rdV;
|
||||
plist[myIndex+2+offset]=dV;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "QMCHamiltonians/model/HeSAPT_smoothed.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonian.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
HeSAPT_smoothed_phy::HeSAPT_smoothed_phy(ParticleSet& P): PtclRef(&P)
|
||||
{
|
||||
Dependants = 1;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
Return_t rho = P.G.size()/P.Lattice.Volume, N0 = P.G.size();
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
mirrorshift = -2.0*((-4.27467067939-32.3451957988*rc-37.5775397337*rc*rc+4.0/rc)*std::exp(-5.72036885319*rc) + (18.2962387439-6.16632555293*rc+6.91482730781*rc*rc)*std::exp(-2.80857770752*rc) - damp(7,rc)*1.460977837725/std::pow(rc,6.) - damp(9,rc)*14.11785737/std::pow(rc,8.) - damp(11,rc)*183.691075/std::pow(rc,10.) + damp(12,rc)*76.70/std::pow(rc,11.) - damp(13,rc)*3372./std::pow(rc,12.) + damp(14,rc)*3806./std::pow(rc,13.) - damp(15,rc)*85340./std::pow(rc,14.) + damp(16,rc)*171000./std::pow(rc,15.) - damp(17,rc)*2860000./std::pow(rc,16.));
|
||||
}
|
||||
|
||||
void HeSAPT_smoothed_phy::resetTargetParticleSet (ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
PtclRef=&P;
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
mirrorshift = -2.0*((-4.27467067939-32.3451957988*rc-37.5775397337*rc*rc+4.0/rc)*std::exp(-5.72036885319*rc) + (18.2962387439-6.16632555293*rc+6.91482730781*rc*rc)*std::exp(-2.80857770752*rc) - damp(7,rc)*1.460977837725/std::pow(rc,6.) - damp(9,rc)*14.11785737/std::pow(rc,8.) - damp(11,rc)*183.691075/std::pow(rc,10.) + damp(12,rc)*76.70/std::pow(rc,11.) - damp(13,rc)*3372./std::pow(rc,12.) + damp(14,rc)*3806./std::pow(rc,13.) - damp(15,rc)*85340./std::pow(rc,14.) + damp(16,rc)*171000./std::pow(rc,15.) - damp(17,rc)*2860000./std::pow(rc,16.));
|
||||
}
|
||||
|
||||
HeSAPT_smoothed_phy::Return_t HeSAPT_smoothed_phy::evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = 0.0;
|
||||
smooth = 0.0;
|
||||
for(int i=0; i < d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t r1 = d_table->r(i);
|
||||
if (r1 < rc)
|
||||
{
|
||||
Return_t r1i = 1.0/r1, r2i = r1i*r1i, r6i = r2i*r2i*r2i, r8i = r6i*r2i, r10i = r8i*r2i, r11i = r10i*r1i, r12i = r10i*r2i, r13i = r11i*r2i, r14i = r12i*r2i, r15i = r13i*r2i, r16i = r14i*r2i;
|
||||
Return_t rd1 = 2.0*rc - r1, rd1i = 1.0/rd1, rd2i = rd1i*rd1i, rd6i = rd2i*rd2i*rd2i, rd8i = rd6i*rd2i, rd10i = rd8i*rd2i, rd11i = rd10i*rd1i, rd12i = rd10i*rd2i, rd13i = rd11i*rd2i, rd14i = rd12i*rd2i, rd15i = rd13i*rd2i, rd16i = rd14i*rd2i;
|
||||
Value += ((-4.27467067939-32.3451957988*r1-37.5775397337*r1*r1+4.0*r1i)*std::exp(-5.72036885319*r1) + (18.2962387439-6.16632555293*r1+6.91482730781*r1*r1)*std::exp(-2.80857770752*r1) - damp(7,r1)*1.460977837725*r6i - damp(9,r1)*14.11785737*r8i - damp(11,r1)*183.691075*r10i + damp(12,r1)*76.70*r11i - damp(13,r1)*3372.*r12i + damp(14,r1)*3806.*r13i - damp(15,r1)*85340.*r14i + damp(16,r1)*171000.*r15i - damp(17,r1)*2860000.*r16i);
|
||||
smooth += ((-4.27467067939-32.3451957988*rd1-37.5775397337*rd1*rd1+4.0*rd1i)*std::exp(-5.72036885319*rd1) + (18.2962387439-6.16632555293*rd1+6.91482730781*rd1*rd1)*std::exp(-2.80857770752*rd1) - damp(7,rd1)*1.460977837725*rd6i - damp(9,rd1)*14.11785737*rd8i - damp(11,rd1)*183.691075*rd10i + damp(12,rd1)*76.70*rd11i - damp(13,rd1)*3372.*rd12i + damp(14,rd1)*3806.*rd13i - damp(15,rd1)*85340.*rd14i + damp(16,rd1)*171000.*rd15i - damp(17,rd1)*2860000.*rd16i + mirrorshift);
|
||||
}
|
||||
}
|
||||
Value += smooth;
|
||||
// temporary tail corr. See Mathematica notebook.
|
||||
return Value;
|
||||
}
|
||||
|
||||
void HeSAPT_smoothed_phy::add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH)
|
||||
{
|
||||
HeSAPT_smoothed_phy* myClone = new HeSAPT_smoothed_phy(qp);
|
||||
targetH.addOperator(myClone, myName, true);
|
||||
myClone->addCorrection(targetH);
|
||||
}
|
||||
|
||||
void HeSAPT_smoothed_phy::addCorrection(QMCHamiltonian& targetH)
|
||||
{
|
||||
HeSAPT_smoothed_aux* auxTerm = new HeSAPT_smoothed_aux(this);
|
||||
std::string auxName = myName+"_aux";
|
||||
targetH.addOperator(auxTerm, auxName, false);
|
||||
}
|
||||
}
|
|
@ -1,421 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HESAPT_SMOOTHED_H
|
||||
#define QMCPLUSPLUS_HESAPT_SMOOTHED_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HeSAPT_smoothed_phy for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HeSAPT_smoothed_phy: public QMCHamiltonianBase
|
||||
{
|
||||
Return_t rc, mirrorshift, smooth;
|
||||
// remember that the default units are Hartrees and Bohrs
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef;
|
||||
|
||||
HeSAPT_smoothed_phy(ParticleSet& P);
|
||||
|
||||
~HeSAPT_smoothed_phy() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P);
|
||||
|
||||
Return_t evaluate(ParticleSet& P);
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t damp(int n, Return_t r)
|
||||
{
|
||||
Return_t wert, br, sum, term;
|
||||
int i;
|
||||
br = 2.41324077320*r;
|
||||
if (r >= 1.0)
|
||||
{
|
||||
sum = term = 1.0;
|
||||
for (i=1; i<=n; i++)
|
||||
{
|
||||
term *= (br/i);
|
||||
sum += term;
|
||||
}
|
||||
wert = 1.0 - std::exp(-br)*sum;
|
||||
}
|
||||
else
|
||||
{
|
||||
sum = 0.0;
|
||||
term = 1.0;
|
||||
for (i=1; i<=n; i++)
|
||||
term *= (br/i);
|
||||
for (i=n+1; i<=30; i++)
|
||||
{
|
||||
term *= (br/i);
|
||||
sum += term;
|
||||
}
|
||||
wert = std::exp(-br)*sum;
|
||||
}
|
||||
return wert;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HeSAPT_smoothed_phy: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
void add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH);
|
||||
|
||||
void addCorrection(QMCHamiltonian& targetH);
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new HeSAPT_smoothed_phy(qp);
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex = plist.add(myName);
|
||||
}
|
||||
|
||||
void setObservables(PropertySetType& plist)
|
||||
{
|
||||
plist[myIndex] = Value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HeSAPT_smoothed_aux for the indentical source and target particle sets.
|
||||
*/
|
||||
struct HeSAPT_smoothed_aux: public QMCHamiltonianBase
|
||||
{
|
||||
const HeSAPT_smoothed_phy* phyH;
|
||||
Return_t tailcorr;
|
||||
// remember that the default units are Hartrees and Bohrs
|
||||
|
||||
HeSAPT_smoothed_aux(const HeSAPT_smoothed_phy* orig): phyH(orig)
|
||||
{
|
||||
Return_t rho = phyH->PtclRef->G.size()/phyH->PtclRef->Lattice.Volume, N0 = phyH->PtclRef->G.size(), rc = phyH->PtclRef->Lattice.WignerSeitzRadius;
|
||||
std::string warningmsg = std::string(" Warning: Tail correction is set to ZERO because ...\n")
|
||||
+ " No pre-calculated tail correction value is found for the current\n"
|
||||
+ " system size and density. Please do a separate calculation\n"
|
||||
+ " of the tail correction and add it onto the LocalEnergy.\n"
|
||||
+ " And if necessary, edit QMCHamiltonians/HeSAPT_smoothed.h\n"
|
||||
+ " to add the new tailcorr value to the database.";
|
||||
if (N0 == 32)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002705961159; // RHO = 0.3648/sigma^3 : 01x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002178620081; // RHO = 0.3280/sigma^3 : 21x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002443783556; // RHO = 0.3470/sigma^3 : 31x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003280694504; // RHO = 0.4009/sigma^3 : 41x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003926875054; // RHO = 0.4378/sigma^3 : 51x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004941981444; // RHO = 0.4899/sigma^3 : 61x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 64)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002651066072; // RHO = 0.3648/sigma^3 : 02x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002137701388; // RHO = 0.3280/sigma^3 : 22x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002395972888; // RHO = 0.3470/sigma^3 : 32x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003209410359; // RHO = 0.4009/sigma^3 : 42x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003835898243; // RHO = 0.4378/sigma^3 : 52x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004817718362; // RHO = 0.4899/sigma^3 : 62x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 128)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002618281770; // RHO = 0.3648/sigma^3 : 03x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002113168481; // RHO = 0.3280/sigma^3 : 23x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002367366424; // RHO = 0.3470/sigma^3 : 33x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003166990570; // RHO = 0.4009/sigma^3 : 43x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003781940744; // RHO = 0.4378/sigma^3 : 53x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004744316477; // RHO = 0.4899/sigma^3 : 63x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 256)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002598285275; // RHO = 0.3648/sigma^3 : 04x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002098169307; // RHO = 0.3280/sigma^3 : 24x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002349898273; // RHO = 0.3470/sigma^3 : 34x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003141175814; // RHO = 0.4009/sigma^3 : 44x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003749179381; // RHO = 0.4378/sigma^3 : 54x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004699888991; // RHO = 0.4899/sigma^3 : 64x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
// tailcorr = -0.000274497151179; // N = 32, RHO = 0.022 /Angstrom^3 : 11x
|
||||
// N = 32, rho = 0.022 Angstroms^-3 = 0.003260063604 a0^-3
|
||||
// Will be different for other densities.
|
||||
// Generalize later.
|
||||
// tailcorr = -0.0002705961159; // N = 32, RHO = 0.3648 sigma^2 : 01x
|
||||
// tailcorr = -0.0002651066072; // N = 64, RHO = 0.3648 sigma^2 : 02x
|
||||
// tailcorr = -0.0002618281770; // N = 128, RHO = 0.3648 sigma^2 : 03x
|
||||
// tailcorr = -0.0002598285275; // N = 256, RHO = 0.3648 sigma^2 : 04x
|
||||
// tailcorr = -0.0002178620081; // N = 32, RHO = 0.3280 sigma^2 : 21x
|
||||
// tailcorr = -0.0002137701388; // N = 64, RHO = 0.3280 sigma^2 : 22x
|
||||
// tailcorr = -0.0002113168481; // N = 128, RHO = 0.3280 sigma^2 : 23x
|
||||
// tailcorr = -0.0002098169307; // N = 256, RHO = 0.3280 sigma^2 : 24x
|
||||
// tailcorr = -0.0002443783556; // N = 32, RHO = 0.3470 sigma^2 : 31x
|
||||
// tailcorr = -0.0002395972888; // N = 64, RHO = 0.3470 sigma^2 : 32x
|
||||
// tailcorr = -0.0002367366424; // N = 128, RHO = 0.3470 sigma^2 : 33x
|
||||
// tailcorr = -0.0002349898273; // N = 256, RHO = 0.3470 sigma^2 : 34x
|
||||
// tailcorr = -0.0003280694504; // N = 32, RHO = 0.4009 sigma^2 : 41x
|
||||
// tailcorr = -0.0003209410359; // N = 64, RHO = 0.4009 sigma^2 : 42x
|
||||
// tailcorr = -0.0003166990570; // N = 128, RHO = 0.4009 sigma^2 : 43x
|
||||
// tailcorr = -0.0003141175814; // N = 256, RHO = 0.4009 sigma^2 : 44x
|
||||
// tailcorr = -0.0003926875054; // N = 32, RHO = 0.4378 sigma^2 : 51x
|
||||
// tailcorr = -0.0003835898243; // N = 64, RHO = 0.4378 sigma^2 : 52x
|
||||
// tailcorr = -0.0003781940744; // N = 128, RHO = 0.4378 sigma^2 : 53x
|
||||
// tailcorr = -0.0003749179381; // N = 256, RHO = 0.4378 sigma^2 : 54x
|
||||
// tailcorr = -0.0004941981444; // N = 32, RHO = 0.4899 sigma^2 : 61x
|
||||
// tailcorr = -0.0004817718362; // N = 64, RHO = 0.4899 sigma^2 : 62x
|
||||
// tailcorr = -0.0004744316477; // N = 128, RHO = 0.4899 sigma^2 : 63x
|
||||
// tailcorr = -0.0004699888991; // N = 256, RHO = 0.4899 sigma^2 : 64x
|
||||
app_log() << " HeSAPT_smoothed_aux tail correction is " << tailcorr << std::endl;
|
||||
}
|
||||
|
||||
~HeSAPT_smoothed_aux() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
Return_t rho = phyH->PtclRef->G.size()/phyH->PtclRef->Lattice.Volume, N0 = phyH->PtclRef->G.size(), rc = phyH->PtclRef->Lattice.WignerSeitzRadius;
|
||||
std::string warningmsg = std::string(" Warning: Tail correction is set to ZERO because ...\n")
|
||||
+ " No pre-calculated tail correction value is found for the current\n"
|
||||
+ " system size and density. Please do a separate calculation\n"
|
||||
+ " of the tail correction and add it onto the LocalEnergy.\n"
|
||||
+ " And if necessary, edit QMCHamiltonians/HeSAPT_smoothed.h\n"
|
||||
+ " to add the new tailcorr value to the database.";
|
||||
if (N0 == 32)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002705961159; // RHO = 0.3648/sigma^3 : 01x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002178620081; // RHO = 0.3280/sigma^3 : 21x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002443783556; // RHO = 0.3470/sigma^3 : 31x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003280694504; // RHO = 0.4009/sigma^3 : 41x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003926875054; // RHO = 0.4378/sigma^3 : 51x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004941981444; // RHO = 0.4899/sigma^3 : 61x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 64)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002651066072; // RHO = 0.3648/sigma^3 : 02x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002137701388; // RHO = 0.3280/sigma^3 : 22x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002395972888; // RHO = 0.3470/sigma^3 : 32x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003209410359; // RHO = 0.4009/sigma^3 : 42x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003835898243; // RHO = 0.4378/sigma^3 : 52x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004817718362; // RHO = 0.4899/sigma^3 : 62x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 128)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002618281770; // RHO = 0.3648/sigma^3 : 03x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002113168481; // RHO = 0.3280/sigma^3 : 23x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002367366424; // RHO = 0.3470/sigma^3 : 33x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003166990570; // RHO = 0.4009/sigma^3 : 43x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003781940744; // RHO = 0.4378/sigma^3 : 53x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004744316477; // RHO = 0.4899/sigma^3 : 63x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (N0 == 256)
|
||||
{
|
||||
if (std::abs(rho - 3.237245782e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002598285275; // RHO = 0.3648/sigma^3 : 04x
|
||||
else
|
||||
if (std::abs(rho - 2.910681515e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002098169307; // RHO = 0.3280/sigma^3 : 24x
|
||||
else
|
||||
if (std::abs(rho - 3.079288066e-3) < 1.0e-7)
|
||||
tailcorr = -0.0002349898273; // RHO = 0.3470/sigma^3 : 34x
|
||||
else
|
||||
if (std::abs(rho - 3.557598229e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003141175814; // RHO = 0.4009/sigma^3 : 44x
|
||||
else
|
||||
if (std::abs(rho - 3.885049900e-3) < 1.0e-7)
|
||||
tailcorr = -0.0003749179381; // RHO = 0.4378/sigma^3 : 54x
|
||||
else
|
||||
if (std::abs(rho - 4.347386811e-3) < 1.0e-7)
|
||||
tailcorr = -0.0004699888991; // RHO = 0.4899/sigma^3 : 64x
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tailcorr = 0.0;
|
||||
app_log() << warningmsg << std::endl;
|
||||
}
|
||||
app_log() << " HeSAPT_smoothed_aux tail correction is " << tailcorr << std::endl;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = -(phyH->smooth) + tailcorr;
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "HeSAPT_smoothed_aux: " << phyH->PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,179 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_HUSEPOT_H
|
||||
#define QMCPLUSPLUS_HUSEPOT_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief HusePot for the indentical source and target particle sets.
|
||||
*
|
||||
*/
|
||||
struct HusePot: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
RealType m,V;
|
||||
RealType pf,K,L;
|
||||
RealType root3;
|
||||
|
||||
HusePot(ParticleSet& P):m(0),V(0),pf(0),K(0),L(0)
|
||||
{
|
||||
root3=std::sqrt(3);
|
||||
const DistanceTableData* d_table = DistanceTable::add(P,DT_AOS);
|
||||
}
|
||||
|
||||
~HusePot() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
//d_table = DistanceTable::add(P);
|
||||
//PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P)
|
||||
{
|
||||
const DistanceTableData* d_table=P.DistTables[0];
|
||||
Value = 0.0;
|
||||
for(int nn=0; nn<d_table->getTotNadj(); ++nn)
|
||||
{
|
||||
Value += f(d_table->r(nn));
|
||||
}
|
||||
return Value*=pf;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
NewValue=Value;
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("HusePot::evaluatePbyP");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(P.DistTables[0]->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat) del+=(temp[iat].rinv1-temp[iat].rinv0);
|
||||
//return NewValue=Value+Q*del;
|
||||
}
|
||||
|
||||
inline Return_t f(Return_t r)
|
||||
{
|
||||
Return_t x=r-root3;
|
||||
if (x>0)
|
||||
return 0;
|
||||
Return_t x3=x*x*x;
|
||||
Return_t x4=x3*x;
|
||||
Return_t x5=x4*x;
|
||||
return L*x5+K*x4-x3;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(m,"m");
|
||||
Tattrib.add(V,"V");
|
||||
Tattrib.put(cur);
|
||||
app_log()<<"HusePot parameters"<< std::endl;
|
||||
app_log()<<" m: "<<m<< std::endl;
|
||||
app_log()<<" V: "<<V<< std::endl;
|
||||
if(m > 0.1*std::pow(root3-1,3))
|
||||
APP_ABORT("m max is 0.1*std::pow(root3-1,3) ~ 0.0392304845 ");
|
||||
L=4*m*std::pow((root3-1),-5)-std::pow(root3-1,-2);
|
||||
K=5*m*std::pow((root3-1),-4)-2.0/(root3-1);
|
||||
Return_t rc= root3-0.6*(root3-1)/(1-m*4*std::pow(root3-1,-3));
|
||||
Return_t f_rc =1.0/f(rc);
|
||||
app_log()<<" Huse H: "<<f(1)*f_rc<< std::endl;
|
||||
pf=V*f_rc;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
//os << "HusePot: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
HusePot* cl = new HusePot(qp);
|
||||
cl->pf=pf;
|
||||
cl->L=L;
|
||||
cl->K=K;
|
||||
return cl;
|
||||
}
|
||||
|
||||
//#ifdef USE_FASTWALKER
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// std::vector<ValueType> e(W.walkers(),0.0);
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// e[iw] += d_table->rinv(iw,nn);
|
||||
// }
|
||||
// }
|
||||
// for(int iw=0; iw<W.walkers(); iw++) { LE[iw] += C*e[iw];}
|
||||
// }
|
||||
//#else
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// RealType e =0.0;
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++)
|
||||
// e += d_table->rinv(iw,nn);
|
||||
// LE[iw] += C*e;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_JELLIUMPOTENTIAL_H
|
||||
#define QMCPLUSPLUS_JELLIUMPOTENTIAL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include <numeric>
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief CoulombPotential for the different source and target particle sets.
|
||||
*
|
||||
* \f[ H = \sum_i \frac{Z(i)q}{r} \f]
|
||||
* where \f$ Z(i) \f$ is the effective charge of the Ith
|
||||
* ion and \f$ q \f$ is the charge of the set of quantum particles.
|
||||
* For instance, \f$ q = -1 \f$ for electrons and
|
||||
* \f$ q = 1 \f$ for positrons.
|
||||
*
|
||||
* @warning need to be generalized by checking visitor.Species.
|
||||
*/
|
||||
struct JelliumPotential: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
///number of ions
|
||||
int Centers;
|
||||
ParticleSet& sourcePtcl;
|
||||
DistanceTableData* d_table;
|
||||
///container for the ion charges
|
||||
std::vector<RealType> Z,RC,RS;
|
||||
|
||||
JelliumPotential(ParticleSet& ions, ParticleSet& els):
|
||||
sourcePtcl(ions), d_table(0)
|
||||
{
|
||||
d_table = DistanceTable::add(ions,els,DT_AOS);
|
||||
//index for attribute charge
|
||||
SpeciesSet& tspecies(ions.getSpeciesSet());
|
||||
int iz = tspecies.addAttribute("charge");
|
||||
int rs = tspecies.addAttribute("rs");
|
||||
Centers = ions.getTotalNum();
|
||||
RC.resize(Centers);
|
||||
RS.resize(Centers);
|
||||
Z.resize(Centers);
|
||||
RealType C = -1.0;
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
{
|
||||
Z[iat] = tspecies( iz ,ions.GroupID[iat])*C;
|
||||
RS[iat] = tspecies(rs,ions.GroupID[iat]);
|
||||
RC[iat] = std::pow(-Z[iat],1.0/3.0)*RS[iat];
|
||||
RS[iat] = 1.0/(RS[iat]*RS[iat]*RS[iat]);
|
||||
app_log()<<" rs is "<<rs<< std::endl;
|
||||
app_log()<<" iz is "<<iz<< std::endl;
|
||||
app_log()<<" RC is "<<RC[iat]<< std::endl;
|
||||
app_log()<<" RS^-3 is "<<RS[iat]<< std::endl;
|
||||
app_log()<<" Z is "<<Z[iat]<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
d_table = DistanceTable::add(sourcePtcl,P,DT_AOS);
|
||||
}
|
||||
|
||||
~JelliumPotential() { }
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value=0.0;
|
||||
for(int iat=0; iat<Centers; ++iat)
|
||||
{
|
||||
for(int nn=d_table->M[iat]; nn<d_table->M[iat+1]; ++nn)
|
||||
if (d_table->r(nn)<RC[iat])
|
||||
Value+= RS[iat]*std::pow(d_table->r(nn),2);
|
||||
else
|
||||
Value+= Z[iat]*d_table->rinv(nn);
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("JelliumPotential::evaluatePbyP should not be used");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(d_table->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat)
|
||||
//{
|
||||
// if (temp[iat].r1<RC[iat]) del+=RS[iat]*std::pow(temp[iat].r1,2);
|
||||
// else del +=Z[iat]*temp[iat].rinv1;
|
||||
// if (temp[iat].r0<RC[iat]) del-=RS[iat]*std::pow(temp[iat].r0,2);
|
||||
// else del -=Z[iat]*temp[iat].rinv0;
|
||||
//}
|
||||
//
|
||||
//return NewValue=Value+del;
|
||||
}
|
||||
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "JelliumPotential potential: " << sourcePtcl.getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new JelliumPotential(sourcePtcl, qp);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "QMCHamiltonians/model/LennardJones_smoothed.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonian.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
LennardJones_smoothed_phy::LennardJones_smoothed_phy(ParticleSet& P, RealType e /* =3.23648511e-5 */, RealType s /* =4.830139998 */): d_table(NULL), PtclRef(&P), epsilon(e), sigma(s)
|
||||
{
|
||||
Dependants = 1;
|
||||
s6 = sigma*sigma*sigma*sigma*sigma*sigma;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
RealType rc6i = std::pow(rc,-6.0);
|
||||
mirrorshift = -2.0*(s6*rc6i - 1.0)*rc6i;
|
||||
}
|
||||
|
||||
|
||||
void LennardJones_smoothed_phy::resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
PtclRef=&P;
|
||||
d_table = DistanceTable::add(P,DT_AOS);
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
RealType rc6i = std::pow(rc,-6.0);
|
||||
mirrorshift = -2.0*(s6*rc6i - 1.0)*rc6i;
|
||||
}
|
||||
|
||||
|
||||
LennardJones_smoothed_phy::Return_t LennardJones_smoothed_phy::evaluate(ParticleSet& P)
|
||||
{
|
||||
smooth = 0.0;
|
||||
Value = 0.0;
|
||||
for(int i=0; i<d_table->getTotNadj(); i++)
|
||||
{
|
||||
Return_t r1 = d_table->r(i);
|
||||
if (r1 < rc)
|
||||
{
|
||||
Return_t r6i = 1.0/(r1*r1*r1*r1*r1*r1),
|
||||
rd1 = 2.0*rc - r1, rd6i = 1.0/(rd1*rd1*rd1*rd1*rd1*rd1);
|
||||
Value += (s6*r6i - 1.0)*r6i;
|
||||
smooth += ((s6*rd6i - 1.0)*rd6i + mirrorshift);
|
||||
}
|
||||
}
|
||||
Value += smooth;
|
||||
Value *= 4.0*epsilon*s6;
|
||||
smooth *= 4.0*epsilon*s6;
|
||||
return Value;
|
||||
}
|
||||
|
||||
|
||||
void LennardJones_smoothed_phy::add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH)
|
||||
{
|
||||
LennardJones_smoothed_phy* myClone = new LennardJones_smoothed_phy(qp);
|
||||
targetH.addOperator(myClone, myName, true);
|
||||
myClone->addCorrection(targetH);
|
||||
}
|
||||
|
||||
|
||||
void LennardJones_smoothed_phy::addCorrection(QMCHamiltonian& targetH)
|
||||
{
|
||||
LennardJones_smoothed_aux* auxTerm = new LennardJones_smoothed_aux(this);
|
||||
std::string auxName = myName+"_aux";
|
||||
targetH.addOperator(auxTerm, auxName, false);
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: D.C. Yang, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_LENNARDJONES_SMOOTHED_H
|
||||
#define QMCPLUSPLUS_LENNARDJONES_SMOOTHED_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** @ingroup hamiltonian
|
||||
*@brief LennardJones_smoothed_phy for the indentical source and target particle sets.
|
||||
*/
|
||||
struct LennardJones_smoothed_phy: public QMCHamiltonianBase
|
||||
{
|
||||
RealType epsilon, sigma, s6, rc, mirrorshift, smooth;
|
||||
// remember that the default units are Kelvins and Bohrs
|
||||
DistanceTableData* d_table;
|
||||
ParticleSet* PtclRef;
|
||||
|
||||
LennardJones_smoothed_phy(ParticleSet& P, RealType e=3.23648511e-5, RealType s=4.830139998);
|
||||
|
||||
~LennardJones_smoothed_phy() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P);
|
||||
|
||||
Return_t evaluate(ParticleSet& P);
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "LennardJones_smoothed_phy: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
void add2Hamiltonian(ParticleSet& qp, TrialWaveFunction& psi, QMCHamiltonian& targetH);
|
||||
|
||||
void addCorrection(QMCHamiltonian& targetH);
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return new LennardJones_smoothed_phy(qp, epsilon, sigma);
|
||||
}
|
||||
|
||||
void addObservables(PropertySetType& plist)
|
||||
{
|
||||
myIndex = plist.add(myName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief LennardJones_smoothed_np for the indentical source and target particle sets.
|
||||
*/
|
||||
struct LennardJones_smoothed_aux: public QMCHamiltonianBase
|
||||
{
|
||||
const LennardJones_smoothed_phy* phyH;
|
||||
RealType epsilon, sigma, tailcorr, rc;
|
||||
|
||||
// epsilon = 10.22 K = 3.236485111e-5 Ha
|
||||
LennardJones_smoothed_aux(const LennardJones_smoothed_phy* orig, RealType e=3.23648511e-5, RealType s=4.830139998): phyH(orig), epsilon(e), sigma(s)
|
||||
{
|
||||
rc = phyH->PtclRef->Lattice.WignerSeitzRadius;
|
||||
tailcorr = 8.0*M_PI*epsilon*std::pow(sigma,6.0)*(std::pow(sigma,6.0)-3.0*std::pow(rc,6.0))*std::pow(phyH->PtclRef->getTotalNum(),2.0)/(9.0*std::pow(rc,9.0)*phyH->PtclRef->Lattice.Volume);
|
||||
// Note the 2 powers of N
|
||||
app_log() << " LennardJones_smoothed_aux tail correction is " << tailcorr << std::endl;
|
||||
}
|
||||
|
||||
~LennardJones_smoothed_aux() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
rc = P.Lattice.WignerSeitzRadius;
|
||||
tailcorr = 8.0*M_PI*epsilon*std::pow(sigma,6.0)*(std::pow(sigma,6.0)-3.0*std::pow(rc,6.0))*std::pow(P.getTotalNum(),2.0)/(9.0*std::pow(rc,9.0)*P.Lattice.Volume);
|
||||
app_log() << " LennardJones_smoothed_aux tail correction is " << tailcorr << std::endl;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P)
|
||||
{
|
||||
Value = -(phyH->smooth) + tailcorr;
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
os << "LennardJones_smoothed_aux (T/S): " << phyH->PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,164 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_MODPOSTEL_H
|
||||
#define QMCPLUSPLUS_MODPOSTEL_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief ModPoschlTeller for the indentical source and target particle sets.
|
||||
*
|
||||
*/
|
||||
struct ModPoschlTeller: public QMCHamiltonianBase
|
||||
{
|
||||
|
||||
///number of particle
|
||||
int Centers;
|
||||
// core radius
|
||||
RealType d;
|
||||
// core strength
|
||||
RealType Q;
|
||||
|
||||
ModPoschlTeller(ParticleSet& P)
|
||||
{
|
||||
Centers=P.getTotalNum();
|
||||
d = 1.0;
|
||||
Q=1.0;
|
||||
const DistanceTableData* d_table = DistanceTable::add(P,DT_AOS);
|
||||
}
|
||||
|
||||
~ModPoschlTeller() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
//d_table = DistanceTable::add(P);
|
||||
//PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P)
|
||||
{
|
||||
const DistanceTableData* d_table=P.DistTables[0];
|
||||
Value = 0.0;
|
||||
for(int nn=0; nn<d_table->getTotNadj(); ++nn)
|
||||
{
|
||||
Return_t x( 1.0/std::cosh(d*d_table->r(nn)) );
|
||||
Value += x*x;
|
||||
}
|
||||
return Value*= d*d*Q;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
NewValue=Value;
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("ModPoschlTeller::evaluatePbyP");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(P.DistTables[0]->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat) del+=(temp[iat].rinv1-temp[iat].rinv0);
|
||||
//return NewValue=Value+Q*del;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(Q,"v0");
|
||||
Tattrib.add(d,"r0");
|
||||
Tattrib.put(cur);
|
||||
app_log()<<"ModPoschlTeller parameters"<< std::endl;
|
||||
app_log()<<" range : "<<d<< std::endl;
|
||||
d=1.0/d;
|
||||
app_log()<<" mag : "<<Q<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
//os << "ModPoschlTeller: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
ModPoschlTeller* cl = new ModPoschlTeller(*this);
|
||||
return cl;
|
||||
}
|
||||
|
||||
//#ifdef USE_FASTWALKER
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// std::vector<ValueType> e(W.walkers(),0.0);
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// e[iw] += d_table->rinv(iw,nn);
|
||||
// }
|
||||
// }
|
||||
// for(int iw=0; iw<W.walkers(); iw++) { LE[iw] += C*e[iw];}
|
||||
// }
|
||||
//#else
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// RealType e =0.0;
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++)
|
||||
// e += d_table->rinv(iw,nn);
|
||||
// LE[iw] += C*e;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_OSCILLPOT_H
|
||||
#define QMCPLUSPLUS_OSCILLPOT_H
|
||||
#include "Particle/ParticleSet.h"
|
||||
#include "Particle/WalkerSetRef.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "QMCHamiltonians/QMCHamiltonianBase.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** @ingroup hamiltonian
|
||||
*@brief OscillatoryPotential for the indentical source and target particle sets.
|
||||
*
|
||||
*/
|
||||
struct OscillatoryPotential: public QMCHamiltonianBase
|
||||
{
|
||||
RealType v0, k0, r0, r1, rm0, rm1;
|
||||
|
||||
|
||||
OscillatoryPotential(ParticleSet& P)
|
||||
{
|
||||
v0=-1.0;
|
||||
k0=1.0;
|
||||
r0=1.0;
|
||||
r1=1.0;
|
||||
const DistanceTableData* d_table = DistanceTable::add(P,DT_AOS);
|
||||
}
|
||||
|
||||
~OscillatoryPotential() { }
|
||||
|
||||
void resetTargetParticleSet(ParticleSet& P)
|
||||
{
|
||||
//d_table = DistanceTable::add(P,DT_AOS);
|
||||
//PtclRef=&P;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluate(ParticleSet& P)
|
||||
{
|
||||
const DistanceTableData* d_table=P.DistTables[0];
|
||||
Value = 0.0;
|
||||
for(int nn=0; nn<d_table->getTotNadj(); ++nn)
|
||||
{
|
||||
Return_t x(d_table->r(nn));
|
||||
Return_t x2(x*x);
|
||||
Value += std::cos(k0*x)*std::exp(-x2*rm0)/std::sqrt(rm1*x2+1);
|
||||
}
|
||||
Value*=v0;
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t evaluate(ParticleSet& P, std::vector<NonLocalData>& Txy)
|
||||
{
|
||||
return evaluate(P);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
registerData(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.add(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
updateBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
NewValue=evaluate(P);
|
||||
buffer.put(Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
inline void copyFromBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.get(Value);
|
||||
NewValue=Value;
|
||||
}
|
||||
|
||||
inline void copyToBuffer(ParticleSet& P, BufferType& buffer)
|
||||
{
|
||||
buffer.put(Value);
|
||||
}
|
||||
|
||||
inline Return_t
|
||||
evaluatePbyP(ParticleSet& P, int active)
|
||||
{
|
||||
APP_ABORT("OscillatoryPotential::evaluatePbyP");
|
||||
return 0.0;
|
||||
//const std::vector<DistanceTableData::TempDistType> &temp(P.DistTables[0]->Temp);
|
||||
//Return_t del=0.0;
|
||||
//for(int iat=0; iat<Centers; ++iat) del+=(temp[iat].rinv1-temp[iat].rinv0);
|
||||
//return NewValue=Value+Q*del;
|
||||
}
|
||||
|
||||
/** Do nothing */
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
OhmmsAttributeSet Tattrib;
|
||||
Tattrib.add(v0,"v0");
|
||||
Tattrib.add(r0,"r0");
|
||||
Tattrib.add(r1,"r1");
|
||||
Tattrib.add(k0,"k0");
|
||||
Tattrib.put(cur);
|
||||
rm0=1.0/(r0*r0);
|
||||
rm1=1.0/(r1*r1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get(std::ostream& os) const
|
||||
{
|
||||
//os << "OscillatoryPotential: " << PtclRef->getName();
|
||||
return true;
|
||||
}
|
||||
|
||||
QMCHamiltonianBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi)
|
||||
{
|
||||
OscillatoryPotential* cl = new OscillatoryPotential(*this);
|
||||
return cl;
|
||||
}
|
||||
|
||||
//#ifdef USE_FASTWALKER
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// std::vector<ValueType> e(W.walkers(),0.0);
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// e[iw] += d_table->rinv(iw,nn);
|
||||
// }
|
||||
// }
|
||||
// for(int iw=0; iw<W.walkers(); iw++) { LE[iw] += C*e[iw];}
|
||||
// }
|
||||
//#else
|
||||
// inline void
|
||||
// evaluate(WalkerSetRef& W, ValueVectorType& LE) {
|
||||
// for(int iw=0; iw<W.walkers(); iw++) {
|
||||
// RealType e =0.0;
|
||||
// for(int nn = 0; nn< d_table->getTotNadj(); nn++)
|
||||
// e += d_table->rinv(iw,nn);
|
||||
// LE[iw] += C*e;
|
||||
// }
|
||||
// }
|
||||
//#endif
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_NONLINEAR_FITTING_H
|
||||
#define QMCPLUSPLUS_NONLINEAR_FITTING_H
|
||||
|
||||
#include "Numerics/SlaterTypeOrbital.h"
|
||||
#include "Numerics/OneDimIntegration.h"
|
||||
#include "Optimize/Minimize.h"
|
||||
|
||||
/** A class to optimize a radial function by a Slater-type orbital
|
||||
*
|
||||
* scalar is typedef (double) inherited from MinimizeFunction
|
||||
* Implements the virtual functions of MinizeFunction for optimization
|
||||
* - int NumParams() ; returns the number of parameters to be optimized
|
||||
* - scalar& Params(int i); assign the i-th value of the optimizable parameters
|
||||
* - scalar Params(int i); returns the i-th value of the optimizable parameters
|
||||
* - scalar Cost(); returns the cost function
|
||||
* - void WriteStuff
|
||||
*/
|
||||
class Any2Slater : public MinimizeFunction
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
///typedef of the source function
|
||||
typedef OneDimGridFunctor<scalar> SourceType;
|
||||
///typedef of the grid, using LogGrid
|
||||
typedef LogGrid<scalar> GridType;
|
||||
|
||||
Any2Slater(SourceType& in): Source(in),
|
||||
cg_tolerance(1e-6),cg_stepsize(0.001),cg_epsilon(1e-6)
|
||||
{
|
||||
OptParams.resize(1);
|
||||
psi_sq.resize(Source.size());
|
||||
scalar r2psi2=-10000.0;
|
||||
int igMax=-1;
|
||||
for(int ig=1; ig<Source.size(); ig++)
|
||||
{
|
||||
psi_sq[ig]=Source(ig)*Source(ig);
|
||||
scalar r=Source.r(ig);
|
||||
scalar t=r*r*psi_sq[ig];
|
||||
if(t>r2psi2)
|
||||
{
|
||||
r2psi2=t;
|
||||
igMax=ig;
|
||||
}
|
||||
}
|
||||
//integrate_RK2_forward(psi_sq,psi_norm);
|
||||
igMax+=2;
|
||||
Target.N=1;
|
||||
Target.Power=0;
|
||||
Target.Z=1/Source.r(igMax);
|
||||
Target.reset();
|
||||
Source.grid().locate(0.2*Source.r(igMax));
|
||||
minIndex=Source.grid().Loc;
|
||||
std::cout << "Initial exponent " << Target.Z << " at " << Source.r(igMax) << std::endl;
|
||||
std::cout << "The index of the cutoff " << minIndex << " at " << Source.r(minIndex) << std::endl;
|
||||
OptParams[0]=Target.Z;
|
||||
}
|
||||
|
||||
bool put(xmlNodePtr cur)
|
||||
{
|
||||
mPtr=cur;
|
||||
return true;
|
||||
}
|
||||
|
||||
///return the number of optimizable parameters
|
||||
int NumParams()
|
||||
{
|
||||
return OptParams.size();
|
||||
}
|
||||
|
||||
///assign optimization parameter i
|
||||
scalar& Params(int i)
|
||||
{
|
||||
return OptParams[i];
|
||||
}
|
||||
///return optimization parameter i
|
||||
scalar Params(int i) const
|
||||
{
|
||||
return OptParams[i];
|
||||
}
|
||||
|
||||
///use the OptParams modified the optimization library and evaluate the cost function
|
||||
scalar Cost()
|
||||
{
|
||||
Target.Z=OptParams[0];
|
||||
Target.reset();
|
||||
scalar del=0.0;
|
||||
for(int ig=minIndex; ig<Source.size(); ig++)
|
||||
{
|
||||
//scalar y= Target.f((*myGrid)(ig))-Source[ig];
|
||||
scalar r=Source.r(ig);
|
||||
scalar y= Target.f(r);
|
||||
scalar t=r*r*(y*y*-psi_sq[ig]);
|
||||
del += t*t;
|
||||
}
|
||||
return del;
|
||||
}
|
||||
|
||||
void WriteStuff()
|
||||
{
|
||||
std::cout << "Slater Z = " << Target.Z << " Norm = " << Target.Norm << std::endl;
|
||||
}
|
||||
|
||||
/** main optimization function using ConjugateGradient method
|
||||
*/
|
||||
bool optimize()
|
||||
{
|
||||
ConjugateGradient CG;
|
||||
CG.Tolerance = cg_tolerance;
|
||||
CG.StepSize = cg_stepsize;
|
||||
CG.epsilon = cg_epsilon;
|
||||
CG.Minimize(*this);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
SourceType& Source;
|
||||
scalar cg_tolerance;
|
||||
scalar cg_stepsize;
|
||||
scalar cg_epsilon;
|
||||
int minIndex;
|
||||
xmlNodePtr mPtr;
|
||||
GenericSTO<scalar> Target;
|
||||
std::vector<scalar> OptParams;
|
||||
Vector<scalar> psi_sq, psi_norm;
|
||||
};
|
||||
#endif
|
|
@ -1,275 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "ParticleBase/RandomSeqGenerator.h"
|
||||
#include "ParticleIO/XMLParticleIO.h"
|
||||
#include "Message/Communicate.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Particle/MCWalkerConfiguration.h"
|
||||
#include "Particle/HDFWalkerIO.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
#include "OhmmsPETE/OhmmsMatrix.h"
|
||||
#include "OhmmsApp/ProjectData.h"
|
||||
#include "OhmmsApp/RandomNumberControl.h"
|
||||
#include "QMC/QMCUtilities.h"
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
using namespace qmcplusplus;
|
||||
xmlDocPtr m_doc;
|
||||
xmlNodePtr m_root;
|
||||
xmlXPathContextPtr m_context;
|
||||
enum {SourceIndex = DistanceTableData::SourceIndex};
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
|
||||
///project description
|
||||
OHMMS::ProjectData myProject;
|
||||
///random number controller
|
||||
OHMMS::RandomNumberControl myRandomControl;
|
||||
if(argc>1)
|
||||
{
|
||||
// build an XML tree from a the file;
|
||||
LOGMSG("Opening file " << argv[1])
|
||||
m_doc = xmlParseFile(argv[1]);
|
||||
if (m_doc == NULL)
|
||||
{
|
||||
ERRORMSG("File " << argv[1] << " is invalid")
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
// Check the document is of the right kind
|
||||
m_root = xmlDocGetRootElement(m_doc);
|
||||
if (m_root == NULL)
|
||||
{
|
||||
ERRORMSG("Empty document");
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNMSG("No argument is given. Assume that does not need an input file")
|
||||
}
|
||||
m_context = xmlXPathNewContext(m_doc);
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//project",m_context);
|
||||
if(xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
WARNMSG("Project is not defined")
|
||||
myProject.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
myProject.put(result->nodesetval->nodeTab[0]);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
//initialize the random number generator
|
||||
xmlNodePtr rptr = myRandomControl.initialize(m_context);
|
||||
if(rptr)
|
||||
{
|
||||
xmlAddChild(m_root,rptr);
|
||||
}
|
||||
///the ions
|
||||
ParticleSet ion;
|
||||
MCWalkerConfiguration el;
|
||||
el.setName("e");
|
||||
int iu = el.Species.addSpecies("u");
|
||||
int id = el.Species.addSpecies("d");
|
||||
int icharge = el.Species.addAttribute("charge");
|
||||
el.Species(icharge,iu) = -1;
|
||||
el.Species(icharge,id) = -1;
|
||||
bool init_els = determineNumOfElectrons(el,m_context);
|
||||
result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//particleset",m_context);
|
||||
xmlNodePtr el_ptr=NULL, ion_ptr=NULL;
|
||||
for(int i=0; i<result->nodesetval->nodeNr; i++)
|
||||
{
|
||||
xmlNodePtr cur=result->nodesetval->nodeTab[i];
|
||||
xmlChar* aname= xmlGetProp(cur,(const xmlChar*)"name");
|
||||
if(aname)
|
||||
{
|
||||
char fc = aname[0];
|
||||
if(fc == 'e')
|
||||
{
|
||||
el_ptr=cur;
|
||||
}
|
||||
else
|
||||
if(fc == 'i')
|
||||
{
|
||||
ion_ptr=cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool donotresize = false;
|
||||
if(init_els)
|
||||
{
|
||||
el.setName("e");
|
||||
XMLReport("The configuration for electrons is already determined by the wave function")
|
||||
donotresize = true;
|
||||
}
|
||||
if(el_ptr)
|
||||
{
|
||||
XMLParticleParser pread(el,donotresize);
|
||||
pread.put(el_ptr);
|
||||
}
|
||||
if(ion_ptr)
|
||||
{
|
||||
XMLParticleParser pread(ion);
|
||||
pread.put(ion_ptr);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
if(!ion.getTotalNum())
|
||||
{
|
||||
ion.setName("i");
|
||||
ion.create(1);
|
||||
ion.R[0] = 0.0;
|
||||
}
|
||||
//The ion-ion distance-table
|
||||
DistanceTableData* d_ii = DistanceTable::getTable(DistanceTable::add(ion));
|
||||
d_ii->create(1);
|
||||
d_ii->evaluate(ion);
|
||||
std::vector<double> Cut, Core;
|
||||
int Centers = ion.getTotalNum();
|
||||
//attribute id for cut
|
||||
int icut = ion.Species.addAttribute("cut");
|
||||
//store the max distance from atom
|
||||
Cut.resize(Centers);
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
{
|
||||
int id = ion.GroupID[iat];
|
||||
Cut[iat] = ion.Species(icut,id);
|
||||
}
|
||||
int icore = ion.Species.addAttribute("core");
|
||||
//store the max distance from atom
|
||||
Core.resize(Centers);
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
{
|
||||
Core[iat]=ion.Species(icore,ion.GroupID[iat]);
|
||||
}
|
||||
//3N-dimensional Gaussian
|
||||
ParticleSet::ParticlePos_t chi(el.getTotalNum());
|
||||
makeGaussRandom(chi);
|
||||
//determine if odd or even number of particles
|
||||
int irem = el.getTotalNum()%2;
|
||||
int ihalf = el.getTotalNum()/2;
|
||||
//assign the core
|
||||
int ncore(0);
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
{
|
||||
double sep=0.8*Cut[iat];
|
||||
for(int iel=0; iel<Core[iat]/2; iel++,ncore++)
|
||||
{
|
||||
el.R[ncore]=ion.R[iat]+sep*chi[ncore];
|
||||
el.R[ncore+ihalf]=ion.R[iat]+sep*chi[ncore+ihalf];
|
||||
}
|
||||
}
|
||||
int ipart = ncore;
|
||||
int isave_iat=0;
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
{
|
||||
for(int nn=d_ii->M[iat]; nn<d_ii->M[iat+1]; nn++)
|
||||
{
|
||||
double bondlength = d_ii->r(nn);
|
||||
int jat = d_ii->J[nn];
|
||||
//only assign if the half bond-length < cutoff
|
||||
if(bondlength < Cut[iat]+Cut[jat])
|
||||
{
|
||||
if(ipart < ihalf)
|
||||
{
|
||||
XMLReport("Assigning particles = " << ipart << " and " << ipart+ihalf)
|
||||
/*place 2 electrons (an up and a down) at half
|
||||
the bond-length plus a random number multiplied
|
||||
by 10% of the bond-length*/
|
||||
el.R[ipart] = ion.R[iat]+0.5*d_ii->dr(nn)+0.1*bondlength*chi[ipart];
|
||||
el.R[ipart+ihalf] = ion.R[iat]+0.5*d_ii->dr(nn)+0.1*bondlength*chi[ipart+ihalf];
|
||||
ipart++;
|
||||
isave_iat = iat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//assign the last particle (if odd number of particles)
|
||||
int flag = 1;
|
||||
ipart = el.getTotalNum()-1;
|
||||
if(irem)
|
||||
{
|
||||
XMLReport("Assigning last particle.")
|
||||
for(int iat = isave_iat+1; iat<Centers; iat++)
|
||||
{
|
||||
for(int nn=d_ii->M[iat]; nn<d_ii->M[iat+1]; nn++)
|
||||
{
|
||||
double bondlength = d_ii->r(nn);
|
||||
if((0.5*bondlength < Cut[iat]) && flag)
|
||||
{
|
||||
XMLReport("Assigning particle = " << ipart)
|
||||
el.R[ipart] = ion.R[iat]+0.5*d_ii->dr(nn)+0.1*bondlength*chi[ipart];
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "Ionic configuration : " << ion.getName() << std::endl;
|
||||
ion.get(std::cout);
|
||||
std::cout << "Electronic configuration : " << el.getName() << std::endl;
|
||||
el.get(std::cout);
|
||||
std::string newxml(myProject.CurrentRoot());
|
||||
newxml.append(".ptcl.xml");
|
||||
std::ofstream ptcl_out(newxml.c_str());
|
||||
/*
|
||||
std::ofstream molmol("assign.xyz");
|
||||
|
||||
molmol << Centers+el.getTotalNum() << std::endl;
|
||||
molmol << std::endl;
|
||||
|
||||
for(int iat=0; iat<Centers; iat++)
|
||||
molmol << ion.Species.speciesName[ion.GroupID[iat]] << 0.5292*ion.R[iat] << std::endl;
|
||||
|
||||
for(int ipart=0; ipart<el.getTotalNum(); ipart++)
|
||||
molmol << "He" << 0.5292*el.R[ipart] << std::endl;
|
||||
|
||||
molmol.close();
|
||||
*/
|
||||
xmlXPathFreeContext(m_context);
|
||||
xmlFreeDoc(m_doc);
|
||||
int nup = el.last(0);
|
||||
int ndown = el.last(1)-el.last(0);
|
||||
ptcl_out << "<?xml version=\"1.0\"?>" << std::endl;
|
||||
ptcl_out << "<particleset name=\"e\">" << std::endl;
|
||||
ptcl_out << "<group name=\"u\" size=\"" << nup << "\">" << std::endl;
|
||||
ptcl_out << "<parameter name=\"charge\">-1</parameter>" << std::endl;
|
||||
ptcl_out << "<attrib name=\"position\" datatype=\"posArray\">" << std::endl;
|
||||
for (int ipart=0; ipart<nup; ++ipart)
|
||||
ptcl_out << el.R[ipart] << std::endl;
|
||||
ptcl_out << "</attrib>" << std::endl;
|
||||
ptcl_out << "</group>" << std::endl;
|
||||
ptcl_out << "<group name=\"d\" size=\"" << ndown << "\">" << std::endl;
|
||||
ptcl_out << "<parameter name=\"charge\">-1</parameter>" << std::endl;
|
||||
ptcl_out << "<attrib name=\"position\" datatype=\"posArray\">" << std::endl;
|
||||
for (int ipart=nup; ipart<el.getTotalNum(); ++ipart)
|
||||
ptcl_out << el.R[ipart] << std::endl;
|
||||
ptcl_out << "</attrib>" << std::endl;
|
||||
ptcl_out << "</group>" << std::endl;
|
||||
ptcl_out << "</particleset>" << std::endl;
|
||||
OHMMS::Controller->finalize();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ SET(MOSRCS
|
|||
# create libmocommon
|
||||
ADD_LIBRARY(mocommon ${MOSRCS})
|
||||
|
||||
set(QTOOLS convert4qmc MSDgenerator extract-eshdf-kvectors trace_density)
|
||||
set(QTOOLS convert4qmc MSDgenerator extract-eshdf-kvectors)
|
||||
ADD_EXECUTABLE(getSupercell getSupercell.cpp)
|
||||
|
||||
FOREACH(p ${QTOOLS})
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "Numerics/Transform2GridFunctor.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
#include "Numerics/GaussianBasisSet.h"
|
||||
#include "QMCTools/GridMolecularOrbitals.h"
|
||||
#include "QMCTools/GTO2GridBuilder.h"
|
||||
#include "QMCFactory/OneDimGridFactory.h"
|
||||
|
||||
|
|
|
@ -1,331 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
#include "QMCWaveFunctions/DetSetBuilderWithBasisSet.h"
|
||||
#include "QMCTools/GridMolecularOrbitals.h"
|
||||
#include "QMCTools/RGFBuilderBase.h"
|
||||
#include "QMCTools/STO2GridBuilder.h"
|
||||
#include "QMCTools/GTO2GridBuilder.h"
|
||||
#include "QMCTools/Any2GridBuilder.h"
|
||||
#include "QMCTools/NumericalRGFBuilder.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
GridMolecularOrbitals::GridMolecularOrbitals(ParticleSet& els, TrialWaveFunction& psi,
|
||||
ParticleSet& ions):
|
||||
OrbitalBuilderBase(els,psi), IonSys(ions), BasisSet(0), d_table(0), rbuilder(0)
|
||||
{
|
||||
//int d_ie = DistanceTable::add(ions,els);
|
||||
d_table = DistanceTable::add(ions,els);
|
||||
nlms_id["n"] = q_n;
|
||||
nlms_id["l"] = q_l;
|
||||
nlms_id["m"] = q_m;
|
||||
nlms_id["s"] = q_s;
|
||||
}
|
||||
|
||||
bool GridMolecularOrbitals::put(xmlNodePtr cur)
|
||||
{
|
||||
LOGMSG("GridMolecularOrbitals::put")
|
||||
DetSetBuilderWithBasisSet<GridMolecularOrbitals> spobuilder(targetPtcl,targetPsi,*this);
|
||||
if(spobuilder.put(cur))
|
||||
{
|
||||
BasisSet->resize(spobuilder.NumPtcl);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GridMolecularOrbitals::BasisSetType*
|
||||
GridMolecularOrbitals::addBasisSet(xmlNodePtr cur)
|
||||
{
|
||||
if(!BasisSet)
|
||||
BasisSet = new BasisSetType(IonSys.getSpeciesSet().getTotalNum());
|
||||
QuantumNumberType nlms;
|
||||
std::string rnl;
|
||||
//current number of centers
|
||||
int ncenters = CenterID.size();
|
||||
int activeCenter;
|
||||
int gridmode = -1;
|
||||
bool addsignforM = false;
|
||||
std::string sph("default"), Morder("gaussian");
|
||||
//go thru the tree
|
||||
cur = cur->xmlChildrenNode;
|
||||
std::map<std::string,RGFBuilderBase*> rbuilderlist;
|
||||
while(cur!=NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == basis_tag || cname == "atomicBasisSet")
|
||||
{
|
||||
int expandlm = GAUSSIAN_EXPAND;
|
||||
std::string abasis("invalid"), btype("Numerical");
|
||||
//Register valid attributes attributes
|
||||
OhmmsAttributeSet aAttrib;
|
||||
aAttrib.add(abasis,"elementType");
|
||||
aAttrib.add(abasis,"species");
|
||||
aAttrib.add(btype,"type");
|
||||
aAttrib.add(sph,"angular");
|
||||
aAttrib.add(addsignforM,"expM");
|
||||
aAttrib.add(Morder,"expandYlm");
|
||||
aAttrib.put(cur);
|
||||
if(abasis == "invalid")
|
||||
continue;
|
||||
if(sph == "spherical")
|
||||
addsignforM=1; //include (-1)^m
|
||||
if(Morder == "gaussian")
|
||||
{
|
||||
expandlm = GAUSSIAN_EXPAND;
|
||||
}
|
||||
else
|
||||
if(Morder == "natural")
|
||||
{
|
||||
expandlm = NATURAL_EXPAND;
|
||||
}
|
||||
else
|
||||
if(Morder == "no")
|
||||
{
|
||||
expandlm = DONOT_EXPAND;
|
||||
}
|
||||
if(addsignforM)
|
||||
LOGMSG("Spherical Harmonics contain (-1)^m factor")
|
||||
else
|
||||
LOGMSG("Spherical Harmonics DO NOT contain (-1)^m factor")
|
||||
//search the species name
|
||||
std::map<std::string,int>::iterator it = CenterID.find(abasis);
|
||||
if(it == CenterID.end())
|
||||
//add the name to the map CenterID
|
||||
{
|
||||
if(btype == "Numerical" || btype == "NG" || btype == "HFNG")
|
||||
{
|
||||
rbuilder = new NumericalRGFBuilder(cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
rbuilder = new Any2GridBuilder(cur);
|
||||
}
|
||||
//CenterID[abasis] = activeCenter = ncenters++;
|
||||
CenterID[abasis]=activeCenter=IonSys.getSpeciesSet().findSpecies(abasis);
|
||||
int Lmax(0); //maxmimum angular momentum of this center
|
||||
int num(0);//the number of localized basis functions of this center
|
||||
//process the basic property: maximun angular momentum, the number of basis functions to be added
|
||||
std::vector<xmlNodePtr> radGroup;
|
||||
xmlNodePtr cur1 = cur->xmlChildrenNode;
|
||||
xmlNodePtr gptr=0;
|
||||
while(cur1 != NULL)
|
||||
{
|
||||
std::string cname1((const char*)(cur1->name));
|
||||
if(cname1 == basisfunc_tag || cname1 == "basisGroup")
|
||||
{
|
||||
radGroup.push_back(cur1);
|
||||
int l=atoi((const char*)(xmlGetProp(cur1, (const xmlChar *)"l")));
|
||||
Lmax = std::max(Lmax,l);
|
||||
//expect that only Rnl is given
|
||||
if(expandlm)
|
||||
num += 2*l+1;
|
||||
else
|
||||
num++;
|
||||
}
|
||||
else
|
||||
if(cname1 == "grid")
|
||||
{
|
||||
gptr = cur1;
|
||||
}
|
||||
cur1 = cur1->next;
|
||||
}
|
||||
XMLReport("Adding a center " << abasis << " centerid "<< CenterID[abasis])
|
||||
XMLReport("Maximum angular momentum = " << Lmax)
|
||||
XMLReport("Number of centered orbitals = " << num)
|
||||
//create a new set of atomic orbitals sharing a center with (Lmax, num)
|
||||
//if(addsignforM) the basis function has (-1)^m sqrt(2)Re(Ylm)
|
||||
CenteredOrbitalType* aos = new CenteredOrbitalType(Lmax,addsignforM);
|
||||
aos->LM.resize(num);
|
||||
aos->NL.resize(num);
|
||||
//Now, add distinct Radial Orbitals and (l,m) channels
|
||||
num=0;
|
||||
rbuilder->setOrbitalSet(aos,abasis); //assign radial orbitals for the new center
|
||||
rbuilder->addGrid(gptr); //assign a radial grid for the new center
|
||||
std::vector<xmlNodePtr>::iterator it(radGroup.begin());
|
||||
std::vector<xmlNodePtr>::iterator it_end(radGroup.end());
|
||||
while(it != it_end)
|
||||
{
|
||||
cur1 = (*it);
|
||||
xmlAttrPtr att = cur1->properties;
|
||||
while(att != NULL)
|
||||
{
|
||||
std::string aname((const char*)(att->name));
|
||||
if(aname == "rid" || aname == "id")
|
||||
//accept id/rid
|
||||
{
|
||||
rnl = (const char*)(att->children->content);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<std::string,int>::iterator iit = nlms_id.find(aname);
|
||||
if(iit != nlms_id.end())
|
||||
//valid for n,l,m,s
|
||||
{
|
||||
nlms[(*iit).second] = atoi((const char*)(att->children->content));
|
||||
}
|
||||
}
|
||||
att = att->next;
|
||||
}
|
||||
XMLReport("\n(n,l,m,s) " << nlms[0] << " " << nlms[1] << " " << nlms[2] << " " << nlms[3])
|
||||
//add Ylm channels
|
||||
num = expandYlm(rnl,nlms,num,aos,cur1,expandlm);
|
||||
++it;
|
||||
}
|
||||
//add the new atomic basis to the basis set
|
||||
BasisSet->add(aos,activeCenter);
|
||||
#if !defined(HAVE_MPI)
|
||||
rbuilder->print(abasis,1);
|
||||
#endif
|
||||
if(rbuilder)
|
||||
{
|
||||
delete rbuilder;
|
||||
rbuilder=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNMSG("Species " << abasis << " is already initialized. Ignore the input.")
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
if(BasisSet)
|
||||
{
|
||||
BasisSet->setTable(d_table);
|
||||
LOGMSG("The total number of basis functions " << BasisSet->TotalBasis)
|
||||
return BasisSet;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRORMSG("BasisSet is not initialized.")
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
GridMolecularOrbitals::expandYlm(const std::string& rnl, const QuantumNumberType& nlms,
|
||||
int num, CenteredOrbitalType* aos, xmlNodePtr cur1,
|
||||
int expandlm)
|
||||
{
|
||||
if(expandlm == GAUSSIAN_EXPAND)
|
||||
{
|
||||
XMLReport("Expanding Ylm according to Gaussian98")
|
||||
std::map<std::string,int>::iterator rnl_it = RnlID.find(rnl);
|
||||
if(rnl_it == RnlID.end())
|
||||
{
|
||||
int nl = aos->Rnl.size();
|
||||
if(rbuilder->addRadialOrbital(cur1,nlms))
|
||||
{
|
||||
RnlID[rnl] = nl;
|
||||
int l = nlms[q_l];
|
||||
XMLReport("Adding " << 2*l+1 << " spherical orbitals for l= " << l)
|
||||
switch (l)
|
||||
{
|
||||
case(0):
|
||||
aos->LM[num] = aos->Ylm.index(0,0);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
break;
|
||||
case(1)://px(1),py(-1),pz(0)
|
||||
aos->LM[num] = aos->Ylm.index(1,1);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
aos->LM[num] = aos->Ylm.index(1,-1);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
aos->LM[num] = aos->Ylm.index(1,0);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
break;
|
||||
default://0,1,-1,2,-2,...,l,-l
|
||||
aos->LM[num] = aos->Ylm.index(l,0);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
for(int tm=1; tm<=l; tm++)
|
||||
{
|
||||
aos->LM[num] = aos->Ylm.index(l,tm);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
aos->LM[num] = aos->Ylm.index(l,-tm);
|
||||
aos->NL[num] = nl;
|
||||
num++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if(expandlm == NATURAL_EXPAND)
|
||||
{
|
||||
XMLReport("Expanding Ylm as -l,-l+1,...,l-1,l")
|
||||
std::map<std::string,int>::iterator rnl_it = RnlID.find(rnl);
|
||||
if(rnl_it == RnlID.end())
|
||||
{
|
||||
int nl = aos->Rnl.size();
|
||||
if(rbuilder->addRadialOrbital(cur1,nlms))
|
||||
{
|
||||
RnlID[rnl] = nl;
|
||||
int l = nlms[q_l];
|
||||
XMLReport("Adding " << 2*l+1 << " spherical orbitals")
|
||||
for(int tm=-l; tm<=l; tm++,num++)
|
||||
{
|
||||
aos->LM[num] = aos->Ylm.index(l,tm);
|
||||
aos->NL[num] = nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLReport("Ylm is NOT expanded.")
|
||||
//assign the index for real Spherical Harmonic with (l,m)
|
||||
aos->LM[num] = aos->Ylm.index(nlms[q_l],nlms[q_m]);
|
||||
//radial orbitals: add only distinct orbitals
|
||||
std::map<std::string,int>::iterator rnl_it = RnlID.find(rnl);
|
||||
if(rnl_it == RnlID.end())
|
||||
{
|
||||
int nl = aos->Rnl.size();
|
||||
if(rbuilder->addRadialOrbital(cur1,nlms))
|
||||
//assign the index for radial orbital with (n,l)
|
||||
{
|
||||
aos->NL[num] = nl;
|
||||
RnlID[rnl] = nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//assign the index for radial orbital with (n,l) if repeated
|
||||
XMLReport("Already added radial function for id: " << rnl)
|
||||
aos->NL[num] = (*rnl_it).second;
|
||||
}
|
||||
//increment number of basis functions
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_CONVERT2_RADIALGRID_H
|
||||
#define QMCPLUSPLUS_CONVERT2_RADIALGRID_H
|
||||
|
||||
#include "QMCWaveFunctions/OrbitalBuilderBase.h"
|
||||
#include "QMCTools/MolecularOrbitalBasis.h"
|
||||
#include "QMCTools/RGFBuilderBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** derived class from OrbitalBuilderBase
|
||||
*
|
||||
* Create a basis set of molecular orbital types as defined in MolecularOrbitalBasis
|
||||
* with radial wave functions on the radial grids.
|
||||
*/
|
||||
class GridMolecularOrbitals: public OrbitalBuilderBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//@typedef radial grid type
|
||||
typedef OneDimGridBase<RealType> GridType;
|
||||
//@typedef \f$R_{nl}\f$ radial functor type defined on a grid
|
||||
typedef OneDimGridFunctor<RealType> RadialOrbitalType;
|
||||
//@typedef centered orbital type which represents a set of \f$R_{nl}Y_{lm}\f$ for a center
|
||||
typedef SphericalBasisSet<RadialOrbitalType,GridType> CenteredOrbitalType;
|
||||
//@typedef molecuar orbital basis composed of multiple CenteredOrbitalType s
|
||||
typedef MolecularOrbitalBasis<CenteredOrbitalType> BasisSetType;
|
||||
|
||||
/** constructor
|
||||
* \param els reference to the electrons
|
||||
* \param psi reference to the wavefunction
|
||||
* \param ions reference to the ions
|
||||
*/
|
||||
GridMolecularOrbitals(ParticleSet& els, TrialWaveFunction& psi, ParticleSet& ions);
|
||||
|
||||
/** initialize the Antisymmetric wave function for electrons
|
||||
*@param cur the current xml node
|
||||
*
|
||||
*/
|
||||
bool put(xmlNodePtr cur);
|
||||
|
||||
/** process basis element to build the basis set
|
||||
*@param cur the current xml node
|
||||
*@return a pointer to the BasisSet
|
||||
*
|
||||
*This member function is necessary in order to use SDSetBuilderWithBasisSet
|
||||
*to initialize fermion wavefunctions with slater determinants.
|
||||
*/
|
||||
BasisSetType* addBasisSet(xmlNodePtr cur);
|
||||
|
||||
private:
|
||||
|
||||
enum {DONOT_EXPAND=0, GAUSSIAN_EXPAND=1, NATURAL_EXPAND};
|
||||
|
||||
///reference to the ionic system with which the basis set are associated
|
||||
ParticleSet& IonSys;
|
||||
|
||||
///pointer to the BasisSet built by GridMolecularOrbitals
|
||||
BasisSetType* BasisSet;
|
||||
|
||||
///distance table pointer
|
||||
DistanceTableData* d_table;
|
||||
|
||||
///Current RadiaaGridFunctorBuilder
|
||||
RGFBuilderBase* rbuilder;
|
||||
///map for the radial orbitals
|
||||
std::map<std::string,int> RnlID;
|
||||
///map for the centers
|
||||
std::map<std::string,int> CenterID;
|
||||
|
||||
///map for (n,l,m,s) to its quantum number index
|
||||
std::map<std::string,int> nlms_id;
|
||||
|
||||
///append Ylm channels
|
||||
int expandYlm(const std::string& rnl, const QuantumNumberType& nlms, int num,
|
||||
CenteredOrbitalType* aos, xmlNodePtr cur1,
|
||||
int expandlm=DONOT_EXPAND);
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,208 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "QMCTools/HDFWalkerMerger.h"
|
||||
#include "Utilities/RandomGeneratorIO.h"
|
||||
using namespace qmcplusplus;
|
||||
|
||||
|
||||
HDFWalkerMerger::HDFWalkerMerger(const std::string& aroot, int ncopy)
|
||||
: NumCopy(ncopy), FileRoot(aroot)
|
||||
{
|
||||
}
|
||||
|
||||
HDFWalkerMerger::~HDFWalkerMerger() { }
|
||||
|
||||
void HDFWalkerMerger::init()
|
||||
{
|
||||
char fname[128];
|
||||
char GrpName[128];
|
||||
hsize_t dimin[3], summary_size=3;
|
||||
std::vector<double> summaryIn;
|
||||
//determine the minimum configuration and walkers for each config
|
||||
int min_config=10000;
|
||||
MaxNumWalkers=0;
|
||||
for(int ip=0; ip<NumCopy; ip++)
|
||||
{
|
||||
int nconf=1;
|
||||
numWalkersIn.push_back(new std::vector<hsize_t>);
|
||||
sprintf(fname,"%s.p%03d.config.h5",FileRoot.c_str(),ip);
|
||||
hid_t hfile = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
hid_t h_config = H5Gopen(hfile,"config_collection");
|
||||
hid_t h1=H5Dopen(h_config,"NumOfConfigurations");
|
||||
if(h1>-1)
|
||||
{
|
||||
H5Dread(h1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&(nconf));
|
||||
H5Dclose(h1);
|
||||
}
|
||||
for(int iconf=0; iconf<nconf; iconf++)
|
||||
{
|
||||
sprintf(GrpName,"config%04d/coord",iconf);
|
||||
h1 = H5Dopen(h_config,GrpName);
|
||||
hid_t dataspace = H5Dget_space(h1);
|
||||
int rank = H5Sget_simple_extent_ndims(dataspace);
|
||||
int status_n = H5Sget_simple_extent_dims(dataspace, dimin, NULL);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(h1);
|
||||
numWalkersIn[ip]->push_back(dimin[0]);
|
||||
MaxNumWalkers = std::max(MaxNumWalkers,dimin[0]);
|
||||
}
|
||||
h1 = H5Dopen(h_config,"Summary");
|
||||
hid_t summary_space = H5Dget_space(h1);
|
||||
H5Sget_simple_extent_ndims(summary_space);
|
||||
H5Sget_simple_extent_dims(summary_space,&summary_size, NULL);
|
||||
if(Summary.size() != summary_size)
|
||||
{
|
||||
Summary.resize(summary_size,0.0);
|
||||
summaryIn.resize(summary_size,0.0);
|
||||
}
|
||||
H5Dread(h1, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &summaryIn[0]);
|
||||
for(hsize_t k=0; k<summary_size; k++)
|
||||
{
|
||||
Summary[k] += summaryIn[k];
|
||||
}
|
||||
H5Sclose(summary_space);
|
||||
H5Dclose(h1);
|
||||
H5Fclose(hfile);
|
||||
min_config = std::min(min_config,nconf);
|
||||
}
|
||||
NumPtcl = dimin[1];
|
||||
Dimension = dimin[2];
|
||||
NumConfig = min_config;
|
||||
OffSet.resize(NumCopy+1,NumConfig);
|
||||
OffSet=0;
|
||||
for(int ip=0; ip<NumCopy; ip++)
|
||||
{
|
||||
for(int iconf=0; iconf<NumConfig; iconf++)
|
||||
{
|
||||
OffSet(ip+1,iconf) = OffSet(ip,iconf)+(*numWalkersIn[ip])[iconf];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HDFWalkerMerger::writeHeader(hid_t gid)
|
||||
{
|
||||
int cur_version=1;
|
||||
hsize_t dim=1;
|
||||
hid_t header_space= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t header_set= H5Dcreate(gid, "version", H5T_NATIVE_INT, header_space, H5P_DEFAULT);
|
||||
H5Dwrite(header_set, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&cur_version);
|
||||
H5Dclose(header_set);
|
||||
header_set= H5Dcreate(gid, "ncontexts", H5T_NATIVE_INT, header_space, H5P_DEFAULT);
|
||||
H5Dwrite(header_set, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&NumCopy);
|
||||
H5Dclose(header_set);
|
||||
H5Sclose(header_space);
|
||||
}
|
||||
|
||||
void HDFWalkerMerger::merge()
|
||||
{
|
||||
init();
|
||||
char fname[128];
|
||||
char GrpName[128];
|
||||
char ConfName[128];
|
||||
#if H5_VERS_RELEASE < 4
|
||||
hssize_t offset[]= {0,0,0};
|
||||
#else
|
||||
hsize_t offset[]= {0,0,0};
|
||||
#endif
|
||||
typedef std::vector<OHMMS_PRECISION> Container_t;
|
||||
Container_t vecIn(MaxNumWalkers*NumPtcl*Dimension);
|
||||
sprintf(fname,"%s.config.h5",FileRoot.c_str());
|
||||
hid_t masterfile= H5Fcreate(fname,H5F_ACC_TRUNC, H5P_DEFAULT,H5P_DEFAULT);
|
||||
writeHeader(masterfile);
|
||||
hid_t mastercf = H5Gcreate(masterfile,"config_collection",0);
|
||||
hsize_t onedim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &onedim, NULL);
|
||||
hid_t dataset= H5Dcreate(mastercf, "NumOfConfigurations", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&NumConfig);
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(dataspace);
|
||||
hsize_t dimout[3], dimin[3];
|
||||
dimin[1]=NumPtcl;
|
||||
dimin[2]=Dimension;
|
||||
dimout[1]=NumPtcl;
|
||||
dimout[2]=Dimension;
|
||||
//create new dataspace for each config
|
||||
for(int iconf=0; iconf<NumConfig; iconf++)
|
||||
{
|
||||
dimout[0]=OffSet(NumCopy,iconf);
|
||||
sprintf(ConfName,"config%04d",iconf);
|
||||
hid_t cf_id = H5Gcreate(mastercf,ConfName,0);
|
||||
dataspace = H5Screate_simple(3,dimout,NULL);
|
||||
dataset = H5Dcreate(cf_id,"coord",H5T_NATIVE_DOUBLE, dataspace,H5P_DEFAULT);
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(dataspace);
|
||||
H5Gclose(cf_id);
|
||||
}
|
||||
//use random_states opposed to random_states
|
||||
for(int ip=0; ip<NumCopy; ip++)
|
||||
{
|
||||
sprintf(fname,"%s.p%03d.config.h5",FileRoot.c_str(),ip);
|
||||
hid_t h0 = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
hid_t cfcollect = H5Gopen(h0,"config_collection");
|
||||
const std::vector<hsize_t>& nw(*(numWalkersIn[ip]));
|
||||
for(int iconf=0; iconf<NumConfig; iconf++)
|
||||
{
|
||||
//get the number of walkers for (ip,iconf)
|
||||
dimin[0] = nw[iconf];
|
||||
sprintf(ConfName,"config%04d",iconf);
|
||||
hid_t cf_id = H5Gopen(cfcollect,ConfName);
|
||||
HDFAttribIO<Container_t> in(vecIn, 3, dimin);
|
||||
in.read(cf_id,"coord");
|
||||
H5Gclose(cf_id);
|
||||
//change the offset
|
||||
offset[0]=OffSet(ip,iconf);
|
||||
//create simple data to write
|
||||
hid_t memspace = H5Screate_simple(3, dimin, NULL);
|
||||
cf_id = H5Gopen(mastercf,ConfName);
|
||||
hid_t dataset = H5Dopen(cf_id,"coord");
|
||||
hid_t filespace = H5Dget_space(dataset);
|
||||
herr_t status = H5Sselect_hyperslab(filespace,H5S_SELECT_SET, offset,NULL,dimin,NULL);
|
||||
status = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, memspace, filespace, H5P_DEFAULT, &vecIn[0]);
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(filespace);
|
||||
H5Sclose(memspace);
|
||||
H5Gclose(cf_id);
|
||||
}
|
||||
H5Gclose(cfcollect);
|
||||
sprintf(GrpName,"context%04d",ip);
|
||||
hid_t mycontext = H5Gcreate(masterfile,GrpName,0);
|
||||
hid_t ranIn = H5Gopen(h0,"random_state");
|
||||
HDFAttribIO<RandomGenerator_t> r(Random);
|
||||
r.read(ranIn,"dummy");
|
||||
H5Gclose(ranIn);
|
||||
hid_t ranOut=H5Gcreate(mycontext, "random_state",0);
|
||||
r.write(ranOut,"dummy");
|
||||
H5Gclose(ranOut);
|
||||
H5Gclose(mycontext);
|
||||
H5Fclose(h0);
|
||||
}
|
||||
//write the summaryset
|
||||
double d=1.0/static_cast<double>(NumCopy);
|
||||
for(int k=0; k<Summary.size(); k++)
|
||||
Summary[k]*=d;
|
||||
hsize_t dim=Summary.size();
|
||||
hid_t summary_space = H5Screate_simple(1, &dim, NULL);
|
||||
hid_t summary_set = H5Dcreate(mastercf, "Summary", H5T_NATIVE_DOUBLE, summary_space, H5P_DEFAULT);
|
||||
ret = H5Dwrite(summary_set, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,&Summary[0]);
|
||||
H5Dclose(summary_set);
|
||||
H5Sclose(summary_space);
|
||||
H5Gclose(mastercf);
|
||||
H5Fclose(masterfile);
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_WALKER_MERGE_IO_H
|
||||
#define QMCPLUSPLUS_WALKER_MERGE_IO_H
|
||||
|
||||
#include <string>
|
||||
#include "OhmmsPETE/OhmmsMatrix.h"
|
||||
#include "Numerics/HDFSTLAttrib.h"
|
||||
|
||||
class Communicate;
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/** Writes a set of walker configurations to an HDF5 file. */
|
||||
|
||||
class HDFWalkerMerger
|
||||
{
|
||||
|
||||
///the physical dimension
|
||||
int Dimension;
|
||||
///the number of separate files
|
||||
int NumCopy;
|
||||
///the number of configuration
|
||||
int NumConfig;
|
||||
///the number of particles
|
||||
int NumPtcl;
|
||||
///communicator
|
||||
Communicate* myComm;
|
||||
|
||||
///maxmimum number of walkers for any config
|
||||
hsize_t MaxNumWalkers;
|
||||
///file root
|
||||
std::string FileRoot;
|
||||
|
||||
///numWalkerIn[node]->operator[](iconfig) returns the number of walkers
|
||||
std::vector<std::vector<hsize_t>*> numWalkersIn;
|
||||
/** offset of the walkers
|
||||
*
|
||||
* OffSet(NumCopy,*) is the total number of walkers for the merged
|
||||
* configuration.
|
||||
*/
|
||||
Matrix<hsize_t> OffSet;
|
||||
|
||||
/** summary is accumulated */
|
||||
std::vector<double> Summary;
|
||||
|
||||
/** write header information */
|
||||
void writeHeader(hid_t git);
|
||||
|
||||
/** initialize sizes */
|
||||
void init();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
HDFWalkerMerger(const std::string& froot, int ncopy);
|
||||
~HDFWalkerMerger();
|
||||
|
||||
/** set communicator */
|
||||
void setCommunicator(Communicate* c);
|
||||
|
||||
void merge();
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,273 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "ParticleBase/RandomSeqGenerator.h"
|
||||
#include "ParticleIO/XMLParticleIO.h"
|
||||
#include "Message/Communicate.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Particle/MCWalkerConfiguration.h"
|
||||
#include "Particle/HDFWalkerIO.h"
|
||||
#include "Particle/DistanceTable.h"
|
||||
#include "Particle/DistanceTableData.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
#include "OhmmsPETE/OhmmsMatrix.h"
|
||||
#include "OhmmsApp/ProjectData.h"
|
||||
#include "OhmmsApp/RandomNumberControl.h"
|
||||
#include "QMC/QMCUtilities.h"
|
||||
#include "OhmmsData/ParameterSet.h"
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
using namespace qmcplusplus;
|
||||
xmlDocPtr m_doc;
|
||||
xmlNodePtr m_root;
|
||||
xmlXPathContextPtr m_context;
|
||||
enum {SourceIndex = DistanceTableData::SourceIndex};
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
|
||||
///project description
|
||||
OHMMS::ProjectData myProject;
|
||||
///random number controller
|
||||
OHMMS::RandomNumberControl myRandomControl;
|
||||
if(argc>1)
|
||||
{
|
||||
// build an XML tree from a the file;
|
||||
LOGMSG("Opening file " << argv[1])
|
||||
m_doc = xmlParseFile(argv[1]);
|
||||
if (m_doc == NULL)
|
||||
{
|
||||
ERRORMSG("File " << argv[1] << " is invalid")
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
// Check the document is of the right kind
|
||||
m_root = xmlDocGetRootElement(m_doc);
|
||||
if (m_root == NULL)
|
||||
{
|
||||
ERRORMSG("Empty document");
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNMSG("No argument is given. Assume that does not need an input file")
|
||||
}
|
||||
m_context = xmlXPathNewContext(m_doc);
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//project",m_context);
|
||||
if(xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
WARNMSG("Project is not defined")
|
||||
myProject.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
myProject.put(result->nodesetval->nodeTab[0]);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
//initialize the random number generator
|
||||
xmlNodePtr rptr = myRandomControl.initialize(m_context);
|
||||
if(rptr)
|
||||
{
|
||||
xmlAddChild(m_root,rptr);
|
||||
}
|
||||
///the ions
|
||||
ParticleSet ion;
|
||||
MCWalkerConfiguration el;
|
||||
el.setName("e");
|
||||
int iu = el.Species.addSpecies("u");
|
||||
int id = el.Species.addSpecies("d");
|
||||
int icharge = el.Species.addAttribute("charge");
|
||||
el.Species(icharge,iu) = -1;
|
||||
el.Species(icharge,id) = -1;
|
||||
bool init_els = determineNumOfElectrons(el,m_context);
|
||||
result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//particleset",m_context);
|
||||
xmlNodePtr el_ptr=NULL, ion_ptr=NULL;
|
||||
for(int i=0; i<result->nodesetval->nodeNr; i++)
|
||||
{
|
||||
xmlNodePtr cur=result->nodesetval->nodeTab[i];
|
||||
xmlChar* aname= xmlGetProp(cur,(const xmlChar*)"name");
|
||||
if(aname)
|
||||
{
|
||||
char fc = aname[0];
|
||||
if(fc == 'e')
|
||||
{
|
||||
el_ptr=cur;
|
||||
}
|
||||
else
|
||||
if(fc == 'i')
|
||||
{
|
||||
ion_ptr=cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool donotresize = false;
|
||||
if(init_els)
|
||||
{
|
||||
el.setName("e");
|
||||
XMLReport("The configuration for electrons is already determined by the wave function")
|
||||
donotresize = true;
|
||||
}
|
||||
if(el_ptr)
|
||||
{
|
||||
XMLParticleParser pread(el,donotresize);
|
||||
pread.put(el_ptr);
|
||||
}
|
||||
if(ion_ptr)
|
||||
{
|
||||
XMLParticleParser pread(ion);
|
||||
pread.put(ion_ptr);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
if(!ion.getTotalNum())
|
||||
{
|
||||
ion.setName("i");
|
||||
ion.create(1);
|
||||
ion.R[0] = 0.0;
|
||||
}
|
||||
double ri = 0.0;
|
||||
double rf = 20.0;
|
||||
int npts = 100;
|
||||
ParameterSet m_param;
|
||||
m_param.add(ri,"ri","AU");
|
||||
m_param.add(rf,"rf","AU");
|
||||
m_param.add(npts,"npts","int");
|
||||
std::string type = "elel";
|
||||
result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//paircorrelation",m_context);
|
||||
xmlNodePtr cur=result->nodesetval->nodeTab[0];
|
||||
type = ((const char*)xmlGetProp(cur,(const xmlChar*)"type"));
|
||||
XMLReport("Type = " << type)
|
||||
xmlNodePtr tcur = cur->children;
|
||||
m_param.put(cur);
|
||||
std::vector<xmlNodePtr> wset;
|
||||
int pid=OHMMS::Controller->mycontext();
|
||||
while(tcur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(tcur->name));
|
||||
if(cname == "mcwalkerset")
|
||||
{
|
||||
int pid_target=pid;
|
||||
xmlChar* anode=xmlGetProp(tcur,(const xmlChar*)"node");
|
||||
if(anode)
|
||||
{
|
||||
pid_target = atoi((const char*)anode);
|
||||
}
|
||||
if(pid_target == pid)
|
||||
wset.push_back(tcur);
|
||||
}
|
||||
tcur=tcur->next;
|
||||
}
|
||||
std::vector<std::string> ConfigFile;
|
||||
if(wset.size())
|
||||
{
|
||||
for(int i=0; i<wset.size(); i++)
|
||||
{
|
||||
xmlChar* att= xmlGetProp(wset[i],(const xmlChar*)"file");
|
||||
if(att)
|
||||
ConfigFile.push_back((const char*)att);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
int nup = el.last(0);
|
||||
int ndown = el.last(1)-el.last(0);
|
||||
int factor = 1;
|
||||
if(nup)
|
||||
factor*=nup;
|
||||
if(ndown)
|
||||
factor*=ndown;
|
||||
DistanceTableData* d_table;
|
||||
//create a grid
|
||||
LinearGrid<double> grid;
|
||||
grid.set(ri,rf,npts);
|
||||
double rcut = grid.rmax();
|
||||
XMLReport("Grid Values: ri = " << ri << " rf = " << rf << " npts = " << npts)
|
||||
int nsp = el.groups();
|
||||
int ng = nsp*nsp;
|
||||
Matrix<int> histogram;
|
||||
histogram.resize(grid.size(),ng);
|
||||
d_table = DistanceTable::getTable(DistanceTable::add(el));
|
||||
d_table->create(1);
|
||||
int count = 0;
|
||||
XMLReport("List of the configuration files:")
|
||||
for(int i=0; i<ConfigFile.size(); i++)
|
||||
XMLReport(ConfigFile[i]);
|
||||
for(int i=0; i<ConfigFile.size(); i++)
|
||||
{
|
||||
HDFWalkerInput wReader(ConfigFile[i]);
|
||||
while(wReader.put(el))
|
||||
{
|
||||
for(MCWalkerConfiguration::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
el.R = (*it)->R;
|
||||
DistanceTable::update(el);
|
||||
for(int i=0; i<d_table->size(SourceIndex); i++)
|
||||
{
|
||||
for(int nn=d_table->M[i]; nn<d_table->M[i+1]; nn++)
|
||||
{
|
||||
double r = d_table->r(nn);
|
||||
if(r < rcut)
|
||||
{
|
||||
count++;
|
||||
int index = grid.index(r);
|
||||
int id = d_table->PairID[nn];
|
||||
histogram(index,id)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string froot(myProject.CurrentRoot());
|
||||
froot.append(".pc");
|
||||
std::ofstream pc_out(froot.c_str());
|
||||
double vol = 4.0*4.0*atan(1.0)/3.0*pow(rcut,3);
|
||||
double norm = static_cast<double>(count*factor)/(vol);
|
||||
for(int ng=0; ng<histogram.rows()-1; ng++)
|
||||
{
|
||||
double r1 = grid[ng];
|
||||
//double r2 = (i<(grid.size()-1)) ? grid[i+1]:(2.0*grid[i]-grid[i-1]);
|
||||
double r2 = grid[ng+1];
|
||||
// double r = 0.5*(r1+r2);
|
||||
double r = 0.75*(pow(r2,4)-pow(r1,4))/(pow(r2,3)-pow(r1,3));
|
||||
pc_out << std::setw(20) << r;
|
||||
for(int j=0; j<histogram.cols(); j++)
|
||||
{
|
||||
//volume element dr = 4/3\pi[(r+dr)^3-r^3]
|
||||
//double binVol = 4.0*4.0*atan(1.0)/3.0*(pow(r2,3)-pow(r1,3));
|
||||
double binVol = 1.0;
|
||||
pc_out << std::setw(20) << static_cast<double>(histogram(ng,j))/(binVol*norm);
|
||||
}
|
||||
pc_out << std::endl;
|
||||
}
|
||||
std::cout << "Ionic configuration : " << ion.getName() << std::endl;
|
||||
ion.get(std::cout);
|
||||
std::cout << "Electronic configuration : " << el.getName() << std::endl;
|
||||
el.get(std::cout);
|
||||
xmlXPathFreeContext(m_context);
|
||||
xmlFreeDoc(m_doc);
|
||||
OHMMS::Controller->finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "QMCTools/HDFWalkerMerger.h"
|
||||
#include "Utilities/RandomGeneratorIO.h"
|
||||
#include "Utilities/UtilityFunctions.h"
|
||||
#include "Message/Communicate.h"
|
||||
#include "Message/CommOperators.h"
|
||||
|
||||
using namespace qmcplusplus;
|
||||
|
||||
|
||||
HDFWalkerMerger::HDFWalkerMerger(const std::string& aroot, int ncopy)
|
||||
: NumCopy(ncopy), FileRoot(aroot)
|
||||
{
|
||||
}
|
||||
|
||||
HDFWalkerMerger::~HDFWalkerMerger() { }
|
||||
|
||||
void HDFWalkerMerger::setCommunicator(Communicate* c)
|
||||
{
|
||||
myComm=c;
|
||||
}
|
||||
|
||||
void HDFWalkerMerger::init()
|
||||
{
|
||||
char fname[128];
|
||||
char GrpName[128];
|
||||
int nprocs=myComm->ncontexts();
|
||||
int mynode=myComm->mycontext();
|
||||
hsize_t dimin[3], summary_size=3;
|
||||
std::vector<int> nw_pernode(nprocs,0);
|
||||
std::vector<int> nc_offset(nprocs+1,0);
|
||||
FairDivideLow(NumCopy,nprocs,nc_offset);
|
||||
std::cout << "Number of copies " << NumCopy << std::endl;
|
||||
std::cout << "Number of proces " << nprocs << std::endl;
|
||||
for(int i=0; i<=nprocs; i++)
|
||||
std::cout << nc_offset[i] << std::endl;
|
||||
numWalkersIn.push_back(new std::vector<hsize_t>);
|
||||
//determine the minimum configuration and walkers for each config
|
||||
int min_config=1;
|
||||
for(int ip=nc_offset[mynode]; ip<nc_offset[mynode+1]; ip++)
|
||||
{
|
||||
int nconf=1;
|
||||
sprintf(fname,"%s.p%03d.config.h5",FileRoot.c_str(),ip);
|
||||
hid_t hfile = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
hid_t h_config = H5Gopen(hfile,"config_collection");
|
||||
hid_t h1=H5Dopen(h_config,"NumOfConfigurations");
|
||||
if(h1>-1)
|
||||
{
|
||||
H5Dread(h1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&(nconf));
|
||||
H5Dclose(h1);
|
||||
}
|
||||
//iconf is the last one
|
||||
int iconf=nconf-1;
|
||||
sprintf(GrpName,"config%04d/coord",iconf);
|
||||
h1 = H5Dopen(h_config,GrpName);
|
||||
hid_t dataspace = H5Dget_space(h1);
|
||||
int rank = H5Sget_simple_extent_ndims(dataspace);
|
||||
int status_n = H5Sget_simple_extent_dims(dataspace, dimin, NULL);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(h1);
|
||||
nw_pernode[mynode]+=dimin[0];
|
||||
numWalkersIn[0]->push_back(dimin[0]);
|
||||
H5Fclose(hfile);
|
||||
}
|
||||
myComm->allreduce(nw_pernode);
|
||||
NumPtcl = dimin[1];
|
||||
Dimension = dimin[2];
|
||||
OffSet.resize(2,nprocs+1);
|
||||
OffSet=0;
|
||||
int ip_in=0;
|
||||
for(int ip=0; ip<nprocs; ip++)
|
||||
{
|
||||
OffSet(0,ip+1)=OffSet(0,ip)+nw_pernode[ip];
|
||||
if(mynode ==0)
|
||||
{
|
||||
std::cout << ip << " has " << nw_pernode[ip] << std::endl;
|
||||
}
|
||||
}
|
||||
for(int ip=0; ip<=nprocs; ip++)
|
||||
OffSet(1,ip)=nc_offset[ip];
|
||||
OffSet(nprocs,1)=nc_offset[nprocs];
|
||||
MaxNumWalkers=nw_pernode[mynode];
|
||||
NumConfig=1;
|
||||
}
|
||||
|
||||
void HDFWalkerMerger::writeHeader(hid_t gid)
|
||||
{
|
||||
int cur_version=1;
|
||||
hsize_t dim=1;
|
||||
hid_t header_space= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t header_set= H5Dcreate(gid, "version", H5T_NATIVE_INT, header_space, H5P_DEFAULT);
|
||||
H5Dwrite(header_set, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&cur_version);
|
||||
H5Dclose(header_set);
|
||||
header_set= H5Dcreate(gid, "ncontexts", H5T_NATIVE_INT, header_space, H5P_DEFAULT);
|
||||
H5Dwrite(header_set, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&NumCopy);
|
||||
H5Dclose(header_set);
|
||||
H5Sclose(header_space);
|
||||
}
|
||||
|
||||
void HDFWalkerMerger::merge()
|
||||
{
|
||||
init();
|
||||
char fname[128];
|
||||
char GrpName[128];
|
||||
char ConfName[128];
|
||||
#if H5_VERS_RELEASE < 4
|
||||
hssize_t offset[]= {0,0,0};
|
||||
#else
|
||||
hsize_t offset[]= {0,0,0};
|
||||
#endif
|
||||
typedef std::vector<OHMMS_PRECISION> Container_t;
|
||||
Container_t vecLoc(MaxNumWalkers*NumPtcl*Dimension);
|
||||
hsize_t dimout[3], dimin[3];
|
||||
dimin[1]=NumPtcl;
|
||||
dimin[2]=Dimension;
|
||||
dimout[1]=NumPtcl;
|
||||
dimout[2]=Dimension;
|
||||
////create new dataspace for each config
|
||||
//for(int iconf=0; iconf<NumConfig; iconf++) {
|
||||
// dimout[0]=OffSet(NumCopy,iconf);
|
||||
// sprintf(ConfName,"config%04d",iconf);
|
||||
// hid_t cf_id = H5Gcreate(mastercf,ConfName,0);
|
||||
// dataspace = H5Screate_simple(3,dimout,NULL);
|
||||
// dataset = H5Dcreate(cf_id,"coord",H5T_NATIVE_DOUBLE, dataspace,H5P_DEFAULT);
|
||||
// H5Dclose(dataset);
|
||||
// H5Sclose(dataspace);
|
||||
// H5Gclose(cf_id);
|
||||
//}
|
||||
int nprocs=myComm->ncontexts();
|
||||
int mynode=myComm->mycontext();
|
||||
int ndacc=0; //local data count
|
||||
for(int ip=OffSet(1,mynode),ipL=0; ip<OffSet(1,mynode+1); ip++,ipL++)
|
||||
{
|
||||
sprintf(fname,"%s.p%03d.config.h5",FileRoot.c_str(),ip);
|
||||
hid_t h0 = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
hid_t cfcollect = H5Gopen(h0,"config_collection");
|
||||
//get the number of walkers for (ip,iconf)
|
||||
dimin[0] = (*numWalkersIn[0])[ipL];
|
||||
sprintf(ConfName,"config%04d",0);
|
||||
std::cout << "Node " << mynode << " reads " << dimin[0] << " walkers from " << fname << std::endl;
|
||||
int nd=dimin[0]*NumPtcl*Dimension;
|
||||
hid_t cf_id = H5Gopen(cfcollect,ConfName);
|
||||
Container_t vecIn(nd);
|
||||
HDFAttribIO<Container_t> in(vecIn, 3, dimin);
|
||||
in.read(cf_id,"coord");
|
||||
H5Gclose(cf_id);
|
||||
copy(vecIn.begin(),vecIn.begin()+nd,vecLoc.begin()+ndacc);
|
||||
ndacc+=nd;
|
||||
H5Fclose(h0);
|
||||
}
|
||||
MPI_Info info=MPI_INFO_NULL;
|
||||
hid_t acc_tpl1=H5Pcreate(H5P_FILE_ACCESS);
|
||||
herr_t ret=H5Pset_fapl_mpio(acc_tpl1,myComm->getMPI(),info);
|
||||
sprintf(fname,"%s.config.h5",FileRoot.c_str());
|
||||
hid_t masterfile= H5Fcreate(fname,H5F_ACC_TRUNC, H5P_DEFAULT,acc_tpl1);
|
||||
ret=H5Pclose(acc_tpl1);
|
||||
dimout[0]=OffSet(0,nprocs);
|
||||
hid_t mastercf = H5Gcreate(masterfile,"config_collection",0);
|
||||
hid_t c1 = H5Gcreate(mastercf,"config0000",0);
|
||||
//create global dimensionality
|
||||
hid_t sid1=H5Screate_simple(3,dimout,NULL);
|
||||
//create dataset collectively
|
||||
hid_t dataset1=H5Dcreate(c1,"coord",H5T_NATIVE_DOUBLE,sid1,H5P_DEFAULT);
|
||||
hsize_t start[3],count[3],stride[3]= {1,1,1};
|
||||
start[0]=OffSet(0,mynode);
|
||||
start[1]=0;
|
||||
start[2]=0;
|
||||
count[0]=OffSet(0,mynode+1)-OffSet(0,mynode);
|
||||
count[1]=NumPtcl;
|
||||
count[2]=Dimension;
|
||||
//get the database
|
||||
hid_t file_dataspace=H5Dget_space(dataset1);
|
||||
ret=H5Sselect_hyperslab(file_dataspace,H5S_SELECT_SET,start,stride,count,NULL);
|
||||
//create data independently
|
||||
hid_t mem_dataspace=H5Screate_simple(3,count,NULL);
|
||||
ret=H5Dwrite(dataset1,H5T_NATIVE_DOUBLE,mem_dataspace,file_dataspace,H5P_DEFAULT, &vecLoc[0]);
|
||||
H5Sclose(file_dataspace);
|
||||
ret = H5Dclose(dataset1);
|
||||
H5Sclose(sid1);
|
||||
H5Gclose(c1);
|
||||
H5Gclose(mastercf);
|
||||
H5Fclose(masterfile);
|
||||
////write the summaryset
|
||||
//double d=1.0/static_cast<double>(NumCopy);
|
||||
//for(int k=0; k<Summary.size(); k++) Summary[k]*=d;
|
||||
//hsize_t dim=Summary.size();
|
||||
//hid_t summary_space = H5Screate_simple(1, &dim, NULL);
|
||||
//hid_t summary_set = H5Dcreate(mastercf, "Summary", H5T_NATIVE_DOUBLE, summary_space, H5P_DEFAULT);
|
||||
//ret = H5Dwrite(summary_set, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,&Summary[0]);
|
||||
//H5Dclose(summary_set);
|
||||
//H5Sclose(summary_space);
|
||||
//// H5Gclose(mastercf);
|
||||
//H5Fclose(masterfile);
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_SIMPLE_UTILITIES_H
|
||||
#define QMCPLUSPLUS_SIMPLE_UTILITIES_H
|
||||
|
||||
#include "QMCWaveFunctions/OrbitalBuilderBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
/** A convenient function to evaluate the electron configuration
|
||||
*@param el the electron configuration
|
||||
*@param acontext xpath context
|
||||
*/
|
||||
inline
|
||||
bool
|
||||
determineNumOfElectrons(ParticleSet& el, xmlXPathContextPtr acontext)
|
||||
{
|
||||
//initialize el with the wave function information
|
||||
//This is to determine the number of up and down electrons
|
||||
std::vector<int> N;
|
||||
std::string sdname("//");
|
||||
sdname.append(OrbitalBuilderBase::sd_tag);
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)(sdname.c_str()),acontext);
|
||||
bool found_el=false;
|
||||
int nsd= result->nodesetval->nodeNr;
|
||||
XMLReport("Found " << nsd << " SlaterDeterminant.")
|
||||
if(nsd)
|
||||
{
|
||||
std::vector<xmlNodePtr> dset;
|
||||
xmlNodePtr cur=result->nodesetval->nodeTab[0]->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == OrbitalBuilderBase::det_tag)
|
||||
dset.push_back(cur);
|
||||
cur=cur->next;
|
||||
}
|
||||
if(dset.size())
|
||||
{
|
||||
XMLReport("Found " << dset.size() << OrbitalBuilderBase::det_tag)
|
||||
for(int i=0; i<dset.size(); i++)
|
||||
{
|
||||
int norb = 0;
|
||||
xmlChar* orb=xmlGetProp(dset[i],(const xmlChar*)"orbitals");
|
||||
if(orb)
|
||||
{
|
||||
norb = atoi((const char*)orb);
|
||||
XMLReport("Using attribute orbitals " << norb)
|
||||
}
|
||||
else
|
||||
{
|
||||
cur = dset[i]->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == OrbitalBuilderBase::spo_tag)
|
||||
norb++;
|
||||
cur=cur->next;
|
||||
}
|
||||
XMLReport("Counting the number or ortbials " << norb)
|
||||
}
|
||||
N.push_back(norb);
|
||||
}
|
||||
el.create(N);
|
||||
found_el=true;
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
if(N.empty())
|
||||
{
|
||||
result = xmlXPathEvalExpression((const xmlChar*)"//particleset",acontext);
|
||||
int n= result->nodesetval->nodeNr;
|
||||
int pset=0;
|
||||
while(!found_el && pset<n)
|
||||
{
|
||||
xmlChar* s= xmlGetProp(result->nodesetval->nodeTab[pset],(const xmlChar*)"name");
|
||||
if(s)
|
||||
{
|
||||
if(s[0] == 'e')
|
||||
{
|
||||
xmlNodePtr cur = result->nodesetval->nodeTab[pset]->children;
|
||||
found_el=true;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == "group")
|
||||
{
|
||||
xmlChar* g= xmlGetProp(cur,(const xmlChar*)"size");
|
||||
if(s)
|
||||
{
|
||||
N.push_back(atoi((const char*)g));
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
pset++;
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
}
|
||||
if(N.empty())
|
||||
{
|
||||
ERRORMSG("Could not determine the number of electrons. Assuming He(1,1)")
|
||||
N.resize(2);
|
||||
N[0]=1;
|
||||
N[1]=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLReport("The electron configured by //slaterdeterminant or //particle/group/@name=\'e\'")
|
||||
}
|
||||
el.create(N);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
#if defined(HAVE_LIBHDF5)
|
||||
#include "Numerics/HDFNumericAttrib.h"
|
||||
#endif
|
||||
#include "QMCTools/GridMolecularOrbitals.h"
|
||||
#include "QMCTools/RGFBuilderBase.h"
|
||||
#include "QMCFactory/OneDimGridFactory.h"
|
||||
namespace qmcplusplus
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Numerics/LibxmlNumericIO.h"
|
||||
#include "Numerics/SlaterTypeOrbital.h"
|
||||
#include "Numerics/Transform2GridFunctor.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
#include "QMCWaveFunctions/MolecularOrbitals/GridMolecularOrbitals.h"
|
||||
#include "QMCWaveFunctions/MolecularOrbitals/STO2GridBuilder.h"
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
bool
|
||||
STO2GridBuilder::putCommon(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Add a new Slater Type Orbital with quantum numbers \f$(n,l,m,s)\f$
|
||||
* \param cur the current xmlNode to be processed
|
||||
* \param nlms a vector containing the quantum numbers \f$(n,l,m,s)\f$
|
||||
* \return true is succeeds
|
||||
*
|
||||
This function puts the STO on a logarithmic grid and calculates the boundary
|
||||
conditions for the 1D Cubic Spline. The derivates at the endpoint
|
||||
are assumed to be all zero. Note: for the radial orbital we use
|
||||
\f[ f(r) = \frac{R(r)}{r^l}, \f] where \f$ R(r) \f$ is the usual
|
||||
radial orbital and \f$ l \f$ is the angular momentum.
|
||||
*/
|
||||
bool
|
||||
STO2GridBuilder::addRadialOrbital(xmlNodePtr cur,
|
||||
const QuantumNumberType& nlms)
|
||||
{
|
||||
if(!m_orbitals)
|
||||
{
|
||||
ERRORMSG("m_orbitals, SphericalOrbitals<ROT,GT>*, is not initialized")
|
||||
return false;
|
||||
}
|
||||
RadialOrbitalType *radorb = NULL;
|
||||
int n=nlms[0];
|
||||
int l=nlms[1];
|
||||
RealType zeta = 1.0;
|
||||
xmlNodePtr s = cur->xmlChildrenNode;
|
||||
while(s != NULL)
|
||||
{
|
||||
std::string cname((const char*)(s->name));
|
||||
if(cname == "parameter" || cname =="Var")
|
||||
{
|
||||
putContent(zeta,s);
|
||||
}
|
||||
s=s->next;
|
||||
}
|
||||
XMLReport("Zeta = " << zeta)
|
||||
STONorm<RealType> anorm(n);
|
||||
GenericSTO<RealType> sto(n-l-1,zeta,anorm(n-1,zeta));
|
||||
XMLReport("Calculating 1D-Cubic spline.")
|
||||
//pointer to the grid
|
||||
GridType* agrid = m_orbitals->Grids[0];
|
||||
radorb = new OneDimCubicSpline<RealType>(agrid);
|
||||
//spline the slater type orbital
|
||||
Transform2GridFunctor<GenericSTO<RealType>,RadialOrbitalType> transform(sto, *radorb);
|
||||
transform.generate(agrid->rmin(), agrid->rmax(),agrid->size());
|
||||
//add the radial orbital to the list
|
||||
m_orbitals->Rnl.push_back(radorb);
|
||||
m_orbitals->RnlID.push_back(nlms);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QMCPLUSPLUS_STO2RADIALGRIDFUNCTOR_H
|
||||
#define QMCPLUSPLUS_STO2RADIALGRIDFUNCTOR_H
|
||||
|
||||
#include "QMCWaveFunctions/MolecularOrbitals/RGFBuilderBase.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
||||
/**Class to convert SlaterTypeOrbital to a radial orbital on a log grid.
|
||||
*
|
||||
* For a center,
|
||||
* - only one grid is used
|
||||
* - any number of radial orbitals
|
||||
*/
|
||||
struct STO2GridBuilder: public RGFBuilderBase
|
||||
{
|
||||
|
||||
///constructor
|
||||
STO2GridBuilder() {}
|
||||
bool addRadialOrbital(xmlNodePtr cur, const QuantumNumberType& nlms);
|
||||
bool putCommon(xmlNodePtr cur);
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,179 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include "OhmmsData/OhmmsElementBase.h"
|
||||
#include "OhmmsData/HDFAttribIO.h"
|
||||
#include "OhmmsPETE/TinyVector.h"
|
||||
#include "OhmmsPETE/OhmmsMatrix.h"
|
||||
using namespace qmcplusplus;
|
||||
|
||||
int print_help()
|
||||
{
|
||||
std::cout << "Usage: density [--fileroot std::string | --diff root1 root2 ] --np int " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct DensityObserver
|
||||
{
|
||||
typedef TinyVector<double,3> PosType;
|
||||
int npts;
|
||||
int nsamples;
|
||||
double rmin;
|
||||
double rmax;
|
||||
double delta;
|
||||
double deltainv;
|
||||
Matrix<double> value;
|
||||
DensityObserver():rmin(-7.92),rmax(7.92),delta(0.16),nsamples(0)
|
||||
{
|
||||
deltainv=1.0/delta;
|
||||
npts=static_cast<int>((rmax-rmin)/delta)+1;
|
||||
value.resize(npts,npts);
|
||||
value=0.0;
|
||||
std::cout << " Density grid " << npts << std::endl;
|
||||
}
|
||||
|
||||
inline void accumulate(const std::vector<PosType>& pos, int nat)
|
||||
{
|
||||
nsamples+=pos.size();
|
||||
for(int i=0; i<nat; i++)
|
||||
{
|
||||
double x=pos[i][0];
|
||||
double y=pos[i][1];
|
||||
if(x>rmin && x<rmax && y >rmin && y<rmax)
|
||||
{
|
||||
value(static_cast<int>((x-rmin)*deltainv),static_cast<int>((y-rmin)*deltainv))+=1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getData(const char* fname, int nproc);
|
||||
|
||||
void print(const char* fname)
|
||||
{
|
||||
std::ofstream fout(fname);
|
||||
fout.setf(std::ios::scientific, std::ios::floatfield);
|
||||
fout.setf(std::ios::left,std::ios::adjustfield);
|
||||
fout.precision(6);
|
||||
double norm=1.0/static_cast<double>(nsamples);
|
||||
double x=rmin;
|
||||
for(int ix=0; ix<npts; ix++,x+=delta)
|
||||
{
|
||||
double y=rmin;
|
||||
for(int jx=0; jx<npts; jx++,y+=delta)
|
||||
fout << std::setw(20) << y << std::setw(20) << x << std::setw(20) << norm*value(ix,jx) << std::endl;
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc<2)
|
||||
return print_help();
|
||||
int iargc=0;
|
||||
int nproc=1;
|
||||
std::vector<std::string> fnamein(2);
|
||||
std::string h5fileroot("0");
|
||||
bool getdiff=false;
|
||||
while(iargc<argc)
|
||||
{
|
||||
std::string c(argv[iargc]);
|
||||
if(c == "--fileroot")
|
||||
{
|
||||
h5fileroot=argv[++iargc];
|
||||
}
|
||||
else
|
||||
if(c == "--diff")
|
||||
{
|
||||
fnamein[0]=argv[++iargc];
|
||||
fnamein[1]=argv[++iargc];
|
||||
getdiff=true;
|
||||
}
|
||||
else
|
||||
if(c == "--np")
|
||||
{
|
||||
nproc=atoi(argv[++iargc]);
|
||||
}
|
||||
else
|
||||
if(c == "--help" || c == "-h")
|
||||
{
|
||||
return print_help();
|
||||
}
|
||||
++iargc;
|
||||
}
|
||||
if(getdiff)
|
||||
{
|
||||
std::cout << "Going to compare two density " << fnamein[0] << " " << fnamein[1] << std::endl;
|
||||
DensityObserver recorder1;
|
||||
recorder1.getData(fnamein[0].c_str(),nproc);
|
||||
DensityObserver recorder2;
|
||||
recorder2.getData(fnamein[1].c_str(),nproc);
|
||||
recorder1.value -= recorder2.value;
|
||||
recorder1.print("rho_diff.dat");
|
||||
}
|
||||
else
|
||||
{
|
||||
DensityObserver recorder;
|
||||
recorder.getData(h5fileroot.c_str(),nproc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DensityObserver::getData(const char* froot, int nproc)
|
||||
{
|
||||
typedef TinyVector<double,3> PosType;
|
||||
hsize_t dimIn[3],dimTot[3];
|
||||
char fname[256],coordname[128];
|
||||
for(int ip=0; ip<nproc; ip++)
|
||||
{
|
||||
if(nproc>1)
|
||||
sprintf(fname,"%s.p%03d.config.h5",froot,ip);
|
||||
else
|
||||
sprintf(fname,"%s.config.h5",froot);
|
||||
hid_t fileID = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
int nconf=1;
|
||||
hid_t mastercf = H5Gopen(fileID,"config_collection");
|
||||
hid_t h1=H5Dopen(mastercf,"NumOfConfigurations");
|
||||
H5Dread(h1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&(nconf));
|
||||
H5Dclose(h1);
|
||||
std::cout << "Adding data in " << fname << " number of configurations = " << nconf << std::endl;
|
||||
for(int iconf=0; iconf<nconf; iconf++)
|
||||
{
|
||||
sprintf(coordname,"config%04d/coord",iconf);
|
||||
hid_t dataset = H5Dopen(mastercf,coordname);
|
||||
hid_t dataspace = H5Dget_space(dataset);
|
||||
int rank = H5Sget_simple_extent_ndims(dataspace);
|
||||
int status_n = H5Sget_simple_extent_dims(dataspace, dimTot, NULL);
|
||||
std::vector<PosType> pos(dimTot[0]*dimTot[1]);
|
||||
hid_t ret = H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(pos[0][0]));
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(dataspace);
|
||||
std::accumulate(pos,dimTot[0]*dimTot[1]);
|
||||
}
|
||||
}
|
||||
std::string outfname(froot);
|
||||
outfname.append(".den.dat");
|
||||
print(outfname.c_str());
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <fstream>
|
||||
#include "Message/Communicate.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Numerics/GaussianTimesRN.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
#include "QMCFactory/OneDimGridFactory.h"
|
||||
|
||||
using namespace qmcplusplus;
|
||||
|
||||
struct ECPTest
|
||||
{
|
||||
|
||||
typedef OneDimGridFactory::RealType RealType;
|
||||
typedef OneDimGridFactory::GridType GridType;
|
||||
typedef GaussianTimesRN<RealType> InFuncType;
|
||||
typedef OneDimCubicSpline<RealType> OutFuncType;
|
||||
|
||||
std::string Name;
|
||||
RealType Zeff;
|
||||
|
||||
ECPTest(const std::string& fname);
|
||||
void buildSemiLocal(xmlNodePtr cur);
|
||||
void buildLocal(xmlNodePtr cur);
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
|
||||
int iargc=0;
|
||||
ECPTest ecp(argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ECPTest::ECPTest(const std::string& fname)
|
||||
{
|
||||
// build an XML tree from a the file;
|
||||
xmlDocPtr m_doc = xmlParseFile(fname.c_str());
|
||||
if (m_doc == NULL)
|
||||
{
|
||||
ERRORMSG("File " << fname << " is invalid")
|
||||
xmlFreeDoc(m_doc);
|
||||
}
|
||||
// Check the document is of the right kind
|
||||
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
ERRORMSG("Empty document");
|
||||
xmlFreeDoc(m_doc);
|
||||
}
|
||||
cur=cur->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)cur->name);
|
||||
if(cname == "header")
|
||||
{
|
||||
Zeff = atoi((const char*)xmlGetProp(cur,(const xmlChar*)"zval"));
|
||||
Name = (const char*)xmlGetProp(cur,(const xmlChar*)"symbol");
|
||||
}
|
||||
else
|
||||
if(cname == "semilocal")
|
||||
{
|
||||
buildSemiLocal(cur);
|
||||
}
|
||||
else
|
||||
if(cname == "local")
|
||||
{
|
||||
buildLocal(cur);
|
||||
}
|
||||
cur=cur->next;
|
||||
}
|
||||
xmlFreeDoc(m_doc);
|
||||
}
|
||||
|
||||
void ECPTest::buildSemiLocal(xmlNodePtr cur)
|
||||
{
|
||||
GridType* grid_semilocal=0;
|
||||
std::vector<InFuncType*> semilocal;
|
||||
cur=cur->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)cur->name);
|
||||
if(cname == "grid")
|
||||
{
|
||||
grid_semilocal=OneDimGridFactory::createGrid(cur);
|
||||
}
|
||||
else
|
||||
if(cname == "vps")
|
||||
{
|
||||
xmlNodePtr cur1=cur->children;
|
||||
while(cur1 != NULL)
|
||||
{
|
||||
if(xmlStrEqual(cur1->name,(const xmlChar*)"basisGroup"))
|
||||
{
|
||||
InFuncType* a=new InFuncType;
|
||||
a->putBasisGroup(cur1);
|
||||
semilocal.push_back(a);
|
||||
}
|
||||
cur1=cur1->next;
|
||||
}
|
||||
}
|
||||
cur=cur->next;
|
||||
}
|
||||
std::string fname(Name);
|
||||
fname.append(".semilocal.dat");
|
||||
std::ofstream fout(fname.c_str());
|
||||
fout.setf(std::ios::scientific, std::ios::floatfield);
|
||||
fout.precision(12);
|
||||
int ig=0;
|
||||
while(ig<grid_semilocal->size())
|
||||
{
|
||||
double r=(*grid_semilocal)[ig++];
|
||||
fout << std::setw(20) << setprecision(12) << r;
|
||||
for(int i=0; i<semilocal.size(); i++)
|
||||
{
|
||||
fout << std::setw(20) << semilocal[i]->f(r);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void ECPTest::buildLocal(xmlNodePtr cur)
|
||||
{
|
||||
GridType* grid_semilocal=0;
|
||||
InFuncType* localpp;
|
||||
cur=cur->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)cur->name);
|
||||
if(cname == "grid")
|
||||
{
|
||||
grid_semilocal=OneDimGridFactory::createGrid(cur);
|
||||
}
|
||||
else
|
||||
if(cname == "basisGroup")
|
||||
{
|
||||
localpp=new InFuncType;
|
||||
localpp->putBasisGroup(cur);
|
||||
}
|
||||
cur=cur->next;
|
||||
}
|
||||
std::cout << " Effective Z = " << Zeff << std::endl;
|
||||
std::string fname(Name);
|
||||
fname.append(".local.dat");
|
||||
std::ofstream fout(fname.c_str());
|
||||
fout.setf(std::ios::scientific, std::ios::floatfield);
|
||||
fout.precision(12);
|
||||
int ig=0;
|
||||
while(ig<grid_semilocal->size())
|
||||
{
|
||||
double r=(*grid_semilocal)[ig++];
|
||||
fout << std::setw(20) << setprecision(12) << r << std::setw(20) << localpp->f(r)-Zeff/r<< std::endl;
|
||||
}
|
||||
delete localpp;
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "Numerics/MatrixOperators.h"
|
||||
#include "Utilities/RandomGenerator.h"
|
||||
#include "Utilities/Timer.h"
|
||||
using namespace qmcplusplus;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Random.init(0,1,-1);
|
||||
typedef double scalar_t;
|
||||
int N=100;
|
||||
int M=2000;
|
||||
int L=5;
|
||||
Matrix<scalar_t> A(N,M), B(M,L), C(N,L);
|
||||
Vector<scalar_t> y(M),z(N);
|
||||
double gemm_t=0.0;
|
||||
double gemv_t=0.0;
|
||||
Timer myTimer;
|
||||
int niter=100;
|
||||
for(int iter=0; iter<niter; iter++)
|
||||
{
|
||||
for(int i=0; i<N; i++)
|
||||
for(int j=0; j<M; j++)
|
||||
A(i,j)=Random();
|
||||
//A(i,j)=scalar_t(Random(),Random());
|
||||
for(int i=0; i<M; i++)
|
||||
for(int j=0; j<L; j++)
|
||||
B(i,j)=Random();
|
||||
//B(i,j)=scalar_t(Random(),Random());
|
||||
for(int i=0; i<M; i++)
|
||||
y(i)=Random();
|
||||
//y(i)=scalar_t(Random(),Random());
|
||||
myTimer.restart();
|
||||
MatrixOperators::product(A,B,C);
|
||||
gemm_t+=myTimer.elapsed();
|
||||
myTimer.restart();
|
||||
MatrixOperators::product(A,y,z.data());
|
||||
gemv_t+=myTimer.elapsed();
|
||||
// std::cout << "<<<<<< GEMM TEST " << std::endl;
|
||||
// for(int i=0; i<N; i++) {
|
||||
// for(int j=0; j<L; j++) {
|
||||
// scalar_t v=0.0;
|
||||
// for(int k=0; k<M; k++) v+=A(i,k)*B(k,j);
|
||||
// std::cout << i << "," << j << " " << v-C(i,j) << " " << v << std::endl;
|
||||
// }
|
||||
// }
|
||||
// std::cout << "<<<<<< GEMV TEST " << std::endl;
|
||||
// for(int i=0; i<N; i++) {
|
||||
// scalar_t v=0.0;
|
||||
// for(int j=0; j<M; j++) v+=A(i,j)*y(j);
|
||||
// std::cout << i << " " << v-z[i] << " " << v << std::endl;
|
||||
// }
|
||||
}
|
||||
std::cout << "|"<<N << "|"<<M << "|" << L << "|" << gemm_t/niter << "|" << gemv_t/niter<< "|" << std::endl;
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include "Configuration.h"
|
||||
#include "Numerics/HDFNumericAttrib.h"
|
||||
#include "Utilities/IteratorUtility.h"
|
||||
using namespace qmcplusplus;
|
||||
|
||||
int print_help()
|
||||
{
|
||||
std::cout << "Usage: gofr --fileroot std::string --np int " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct GofRObserver
|
||||
{
|
||||
int NumSamples;
|
||||
int NumNodes;
|
||||
std::string DataSetName;
|
||||
Vector<double> gofr;
|
||||
Vector<double> gofr2;
|
||||
Matrix<double> gofr_dat;
|
||||
|
||||
GofRObserver(const std::string& aname):DataSetName(aname),NumSamples(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline void accumulate(int count)
|
||||
{
|
||||
int nbin=gofr_dat.cols();
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
double* restrict dptr=gofr_dat[i];
|
||||
for(int k=0; k<nbin; k++,dptr++)
|
||||
{
|
||||
gofr[k] += *dptr;
|
||||
gofr2[k] += (*dptr)*(*dptr);
|
||||
}
|
||||
}
|
||||
NumSamples = count;
|
||||
}
|
||||
|
||||
inline void resize(int ns, int nbin)
|
||||
{
|
||||
NumSamples=ns;
|
||||
gofr_dat.resize(ns,nbin);
|
||||
gofr_dat=0.0;
|
||||
gofr.resize(nbin);
|
||||
gofr2.resize(nbin);
|
||||
gofr=0.0;
|
||||
gofr2=0.0;
|
||||
}
|
||||
|
||||
void getData(const char* fname, int nproc);
|
||||
|
||||
void print(const char* fname)
|
||||
{
|
||||
std::ofstream fout(fname);
|
||||
fout.setf(std::ios::scientific, std::ios::floatfield);
|
||||
fout.setf(std::ios::left,std::ios::adjustfield);
|
||||
fout.precision(6);
|
||||
//double norm=static_cast<double>(NumNodes)/static_cast<double>(NumSamples);
|
||||
double norm=1.0/static_cast<double>(NumSamples);
|
||||
double sqrtnorm=sqrt(norm);
|
||||
for(int i=0; i<gofr.size(); i++)
|
||||
{
|
||||
double avg=gofr[i]*norm;
|
||||
double var= sqrt(gofr2[i]*norm-avg*avg);
|
||||
fout << std::setw(3) << i << std::setw(20) << avg << std::setw(20) << var*sqrtnorm << std::setw(20) << var << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc<2)
|
||||
return print_help();
|
||||
int iargc=0;
|
||||
int nproc=1;
|
||||
std::vector<std::string> gofr_name;
|
||||
std::string h5fileroot("0");
|
||||
while(iargc<argc)
|
||||
{
|
||||
std::string c(argv[iargc]);
|
||||
if(c == "--fileroot")
|
||||
{
|
||||
h5fileroot=argv[++iargc];
|
||||
}
|
||||
else
|
||||
if(c == "--np" || c == "-np")
|
||||
{
|
||||
nproc=atoi(argv[++iargc]);
|
||||
}
|
||||
else
|
||||
if(c == "--help" || c == "-h")
|
||||
{
|
||||
return print_help();
|
||||
}
|
||||
else
|
||||
if(c == "--dataset" || c == "-d")
|
||||
{
|
||||
gofr_name.push_back(argv[++iargc]);
|
||||
}
|
||||
++iargc;
|
||||
}
|
||||
for(int i=0; i<gofr_name.size(); i++)
|
||||
{
|
||||
GofRObserver recorder(gofr_name[i]);
|
||||
recorder.getData(h5fileroot.c_str(),nproc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GofRObserver::getData(const char* froot, int nproc)
|
||||
{
|
||||
NumNodes=nproc;
|
||||
char fname[128];
|
||||
int count_max=1000000;
|
||||
for(int ip=0; ip<nproc; ip++)
|
||||
{
|
||||
if(nproc>1)
|
||||
sprintf(fname,"%s.p%03d.config.h5",froot,ip);
|
||||
else
|
||||
sprintf(fname,"%s.config.h5",froot);
|
||||
std::cout << "Getting data from " << fname << std::endl;
|
||||
hid_t fileid = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
hid_t obsid = H5Gopen(fileid,"observables");
|
||||
int count=0;
|
||||
HDFAttribIO<int> i(count);
|
||||
i.read(obsid,"count");
|
||||
count_max = std::min(count_max,count);
|
||||
std::string gname(DataSetName);
|
||||
gname.append("/value");
|
||||
//check dimension
|
||||
hid_t h1 = H5Dopen(obsid, gname.c_str());
|
||||
hid_t dataspace = H5Dget_space(h1);
|
||||
hsize_t dims_out[2];
|
||||
int rank = H5Sget_simple_extent_ndims(dataspace);
|
||||
int status_n = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);
|
||||
H5Dclose(h1);
|
||||
if(gofr_dat.size() ==0)
|
||||
{
|
||||
resize(dims_out[0],dims_out[1]);
|
||||
}
|
||||
Matrix<double> tmp(dims_out[0],dims_out[1]);
|
||||
HDFAttribIO<Matrix<double> > o(tmp);
|
||||
o.read(obsid,gname.c_str());
|
||||
gofr_dat += tmp;
|
||||
H5Gclose(obsid);
|
||||
H5Fclose(fileid);
|
||||
}
|
||||
std::cout << "Number of blocks " << count_max << std::endl;
|
||||
std::accumulate(count_max);
|
||||
std::string outfname(froot);
|
||||
outfname += "."+ DataSetName+".dat";
|
||||
print(outfname.c_str());
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Message/Communicate.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "QMCWaveFunctions/MolecularOrbitals/GTO2GridBuilder.h"
|
||||
using namespace qmcplusplus;
|
||||
|
||||
void buildBasisSet(xmlNodePtr cur);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
|
||||
// build an XML tree from a the file;
|
||||
xmlDocPtr m_doc = xmlParseFile(argv[1]);
|
||||
if (m_doc == NULL)
|
||||
{
|
||||
ERRORMSG("File " << argv[1] << " is invalid")
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
// Check the document is of the right kind
|
||||
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
ERRORMSG("Empty document");
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc);
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//atomicBasisSet",m_context);
|
||||
if(!xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
for(int ic=0; ic<result->nodesetval->nodeNr; ic++)
|
||||
{
|
||||
buildBasisSet(result->nodesetval->nodeTab[ic]);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void buildBasisSet(xmlNodePtr cur)
|
||||
{
|
||||
xmlNodePtr anchor = cur;
|
||||
xmlNodePtr grid_ptr = 0;
|
||||
std::vector<xmlNodePtr> phi_ptr;
|
||||
std::vector<QuantumNumberType> nlms;
|
||||
int Lmax = 0;
|
||||
int current = 0;
|
||||
std::string acenter("none");
|
||||
const xmlChar* aptr = xmlGetProp(cur,(const xmlChar*)"species");
|
||||
if(aptr)
|
||||
acenter = (const char*)aptr;
|
||||
std::cout << "Building basis set for " << acenter << std::endl;
|
||||
cur = anchor->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == "grid")
|
||||
grid_ptr = cur;
|
||||
else
|
||||
if(cname == "basisSet")
|
||||
{
|
||||
phi_ptr.push_back(cur);
|
||||
nlms.push_back(QuantumNumberType());
|
||||
int n=1,l=0,m=0;
|
||||
const xmlChar* lptr = xmlGetProp(cur,(const xmlChar*)"l");
|
||||
if(lptr)
|
||||
l = atoi((const char*)lptr);
|
||||
const xmlChar* nptr = xmlGetProp(cur,(const xmlChar*)"n");
|
||||
if(nptr)
|
||||
n = atoi((const char*)nptr);
|
||||
const xmlChar* mptr = xmlGetProp(cur,(const xmlChar*)"m");
|
||||
if(mptr)
|
||||
m = atoi((const char*)mptr);
|
||||
Lmax = std::max(l,Lmax);
|
||||
nlms[current][0]=n;
|
||||
nlms[current][1]=l;
|
||||
nlms[current][2]=m;
|
||||
current++;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
RGFBuilderBase::CenteredOrbitalType aos(Lmax);
|
||||
RGFBuilderBase* rbuilder = new GTO2GridBuilder;
|
||||
rbuilder->setOrbitalSet(&aos,acenter);
|
||||
rbuilder->addGrid(grid_ptr);
|
||||
for(int i=0; i<nlms.size(); i++)
|
||||
{
|
||||
rbuilder->addRadialOrbital(phi_ptr[i],nlms[i]);
|
||||
}
|
||||
rbuilder->print(acenter,1);
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Message/Communicate.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
#include "Numerics/Transform2GridFunctor.h"
|
||||
#include "Numerics/GaussianBasisSet.h"
|
||||
#include "QMCTools/Any2Slater.h"
|
||||
|
||||
struct GTO2Slater
|
||||
{
|
||||
|
||||
typedef GaussianCombo<double> GTOType;
|
||||
typedef LogGrid<double> GridType;
|
||||
|
||||
bool Normalized;
|
||||
GridType myGrid;
|
||||
xmlNodePtr gridPtr;
|
||||
std::map<std::string,xmlNodePtr> sPtr;
|
||||
|
||||
GTO2Slater():Normalized(false),gridPtr(0) {}
|
||||
int parse(const char* fname);
|
||||
bool put(xmlNodePtr);
|
||||
void optimize();
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());
|
||||
GTO2Slater transformer;
|
||||
transformer.parse(argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GTO2Slater::parse(const char* fname)
|
||||
{
|
||||
// build an XML tree from a the file;
|
||||
xmlDocPtr m_doc = xmlParseFile(fname);
|
||||
if (m_doc == NULL)
|
||||
{
|
||||
ERRORMSG("File " << fname << " is invalid")
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
// Check the document is of the right kind
|
||||
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
ERRORMSG("Empty document");
|
||||
xmlFreeDoc(m_doc);
|
||||
return 1;
|
||||
}
|
||||
xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc);
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//atomicBasisSet",m_context);
|
||||
if(!xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
for(int ic=0; ic<result->nodesetval->nodeNr; ic++)
|
||||
{
|
||||
std::cout << "Going to optimize" << std::endl;
|
||||
if(put(result->nodesetval->nodeTab[ic]))
|
||||
{
|
||||
optimize();
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool GTO2Slater::put(xmlNodePtr cur)
|
||||
{
|
||||
cur = cur->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == "grid")
|
||||
gridPtr = cur;
|
||||
else
|
||||
if(cname == "basisGroup")
|
||||
{
|
||||
std::string rid("invalid");
|
||||
std::string rtype("Gaussian");
|
||||
std::string norm("no");
|
||||
int l=0;
|
||||
OhmmsAttributeSet inAttrib;
|
||||
inAttrib.add(rid,"rid");
|
||||
inAttrib.add(l,"l");
|
||||
inAttrib.add(rtype,"type");
|
||||
inAttrib.add(norm,"normalized");
|
||||
inAttrib.put(cur);
|
||||
if(rtype == "Gaussian" && l == 0)
|
||||
//pick only S
|
||||
{
|
||||
//if Ngto==1, don't do it
|
||||
if(norm == "yes")
|
||||
Normalized=true;
|
||||
else
|
||||
Normalized=false;
|
||||
std::map<std::string,xmlNodePtr>::iterator it(sPtr.find(rid));
|
||||
if(it == sPtr.end())
|
||||
{
|
||||
sPtr[rid]=cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
cur=cur->next;
|
||||
}
|
||||
if(sPtr.empty())
|
||||
return false;
|
||||
return
|
||||
true;
|
||||
}
|
||||
|
||||
/** main functio to optimize multiple contracted S orbitals
|
||||
*/
|
||||
void GTO2Slater::optimize()
|
||||
{
|
||||
//construct one-dim grid
|
||||
double ri = 1e-5;
|
||||
double rf = 10.0;
|
||||
int npts = 101;
|
||||
std::string gridType("log");
|
||||
if(gridPtr)
|
||||
{
|
||||
OhmmsAttributeSet radAttrib;
|
||||
radAttrib.add(gridType,"type");
|
||||
radAttrib.add(npts,"npts");
|
||||
radAttrib.add(ri,"ri");
|
||||
radAttrib.add(rf,"rf");
|
||||
radAttrib.put(gridPtr);
|
||||
}
|
||||
myGrid.set(ri,rf,npts);
|
||||
//create a numerical grid funtor
|
||||
typedef OneDimCubicSpline<double> RadialOrbitalType;
|
||||
RadialOrbitalType radorb(&myGrid);
|
||||
int L= 0;
|
||||
//Loop over all the constracted S orbitals
|
||||
std::map<std::string,xmlNodePtr>::iterator it(sPtr.begin()),it_end(sPtr.end());
|
||||
while(it != it_end)
|
||||
{
|
||||
//create contracted gaussian
|
||||
GTOType gset(L,Normalized);
|
||||
//read the radfunc's of basisGroup
|
||||
gset.putBasisGroup((*it).second);
|
||||
//convert to a radial functor
|
||||
Transform2GridFunctor<GTOType,RadialOrbitalType> transform(gset, radorb);
|
||||
transform.generate(myGrid.rmin(),myGrid.rmax(),myGrid.size());
|
||||
//optimize it with the radial functor
|
||||
Any2Slater gto2slater(radorb);
|
||||
gto2slater.optimize();
|
||||
++it;
|
||||
}
|
||||
sPtr.clear();
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "Utilities/RandomGenerator.h"
|
||||
#include <vector>
|
||||
#include "QMCTools/HDFWalkerMerger.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OHMMS::Controller->initialize(argc,argv);
|
||||
OhmmsInfo welcome(argc,argv,OHMMS::Controller->rank());
|
||||
qmcplusplus::Random.init(0,1,-1);
|
||||
if(argc<2)
|
||||
{
|
||||
std::cerr << " Usage: h5merge <rootname> -n <number-of-processor> -o[utfile] <outfile> " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
int ic=0;
|
||||
int np=1;
|
||||
std::string ofile(argv[1]);
|
||||
while(ic<argc)
|
||||
{
|
||||
std::string w(argv[ic]);
|
||||
if(w.find("-n")<w.size())
|
||||
{
|
||||
np=atoi(argv[++ic]);
|
||||
}
|
||||
else
|
||||
if(w.find("-o")<w.size())
|
||||
{
|
||||
ofile=argv[++ic];
|
||||
}
|
||||
++ic;
|
||||
}
|
||||
std::cout << "Number of processors = " << np << std::endl;
|
||||
//qmcplusplus::HDFWalkerMerger merger(argv[1],atoi(argv[2]));
|
||||
//qmcplusplus::HDFWalkerMerger merger(argv[1],np);
|
||||
//merger.merge();
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,61 +0,0 @@
|
|||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
#// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
#// See LICENSE file in top directory for details.
|
||||
#//
|
||||
#// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
#//
|
||||
#// File developed by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
|
||||
#// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
#//
|
||||
#//
|
||||
#// File created by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
|
||||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#! /usr/bin/perl
|
||||
# only works for csf's right now
|
||||
|
||||
if($#ARGV != 1)
|
||||
{
|
||||
print "Usage: script filename cutoff \n";
|
||||
exit(1)
|
||||
}
|
||||
|
||||
$filename = $ARGV[0];
|
||||
$dbl1 = $ARGV[1];
|
||||
# check file exists
|
||||
open(INN,"< $filename");
|
||||
@alldata = <INN>;
|
||||
close(INN);
|
||||
|
||||
$dcnt = 0;
|
||||
$int1 = 0;
|
||||
$ndet = 0;
|
||||
|
||||
while($dcnt < $#alldata+1)
|
||||
{
|
||||
if($alldata[$dcnt] =~ /<csf/)
|
||||
{
|
||||
$alldata[$dcnt] =~ /qchem_coeff.\"(\S*)\"/;
|
||||
$somevar = $1;
|
||||
#print "my num $somevar\n";
|
||||
if(abs($somevar) > abs($dbl1))
|
||||
{
|
||||
$ndet++;
|
||||
$alldata[$dcnt] =~ /occ.\"(.*)[12](0*)"/;
|
||||
$mylength = length($1)+1;
|
||||
#print "dol1 $1 dol2 $2 \n";
|
||||
#print "my length is $mylength\n";
|
||||
if($mylength > $int1)
|
||||
{
|
||||
$int1 = $mylength;
|
||||
}
|
||||
}
|
||||
}
|
||||
$dcnt++;
|
||||
}
|
||||
|
||||
# must add number of core orbitals to this
|
||||
print "Number of determinants: $ndet \n";
|
||||
print "Required number of orbitals: $int1 \n";
|
|
@ -1,164 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <OhmmsData/OhmmsElementBase.h>
|
||||
#include <Numerics/HDFSTLAttrib.h>
|
||||
using namespace qmcplusplus;
|
||||
|
||||
int print_help()
|
||||
{
|
||||
std::cerr << "Usage: observable [--fileroot std::string ] list-of-obervables " << std::endl;
|
||||
std::cerr << " Example: observable --fileroot myhdf --first 10 density " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct ObservableFile
|
||||
{
|
||||
int first_block;
|
||||
std::string h5name;
|
||||
std::vector<std::string> olist;
|
||||
ObservableFile(int argc, char** argv);
|
||||
int dump_averages();
|
||||
|
||||
template<typename IT>
|
||||
inline void accumulate_n(IT first, IT last, IT result)
|
||||
{
|
||||
for(; first<last;)
|
||||
*result++ += *first++;
|
||||
}
|
||||
|
||||
template<typename IT, typename T>
|
||||
inline void scale_n(IT first, IT last, T fac)
|
||||
{
|
||||
for(; first<last;)
|
||||
*first++ *=fac;
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc<2)
|
||||
return print_help();
|
||||
ObservableFile in(argc,argv);
|
||||
return in.dump_averages();
|
||||
}
|
||||
|
||||
ObservableFile::ObservableFile(int argc, char** argv)
|
||||
:first_block(0)
|
||||
{
|
||||
int iargc=1;
|
||||
while(iargc<argc)
|
||||
{
|
||||
std::string c(argv[iargc]);
|
||||
if(c.find("fileroot")<c.size())
|
||||
{
|
||||
h5name=argv[++iargc];
|
||||
}
|
||||
else
|
||||
if(c.find("first")<c.size())
|
||||
{
|
||||
first_block=atoi(argv[++iargc]);
|
||||
}
|
||||
else
|
||||
if(c.find("help")<c.size())
|
||||
{
|
||||
print_help();
|
||||
}
|
||||
else
|
||||
{
|
||||
olist.push_back(argv[iargc]);
|
||||
}
|
||||
++iargc;
|
||||
}
|
||||
}
|
||||
|
||||
int ObservableFile::dump_averages()
|
||||
{
|
||||
if(h5name.empty())
|
||||
{
|
||||
std::cerr << " Invalid file. Provide --fileroot root-of-h5-file " << std::endl;
|
||||
return 1;
|
||||
}
|
||||
herr_t status = H5Eset_auto(NULL, NULL);
|
||||
char fname[256];
|
||||
if(h5name.find("h5")<h5name.size())
|
||||
sprintf(fname,"%s",h5name.c_str());
|
||||
else
|
||||
sprintf(fname,"%s.h5",h5name.c_str());
|
||||
hid_t fileID = H5Fopen(fname,H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
if(fileID<0)
|
||||
{
|
||||
std::cerr << " Cannot find " << fname << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(olist.empty())
|
||||
{
|
||||
std::cerr << "No observables given." << std::endl;
|
||||
print_help();
|
||||
return 1;
|
||||
}
|
||||
for(int i=0; i<olist.size(); ++i)
|
||||
{
|
||||
hid_t gid=H5Gopen(fileID,olist[i].c_str());
|
||||
if(gid<0)
|
||||
{
|
||||
std::cerr << "Cannot find " << olist[i] << " group. Abort" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
hid_t dataset = H5Dopen(gid,"value");
|
||||
hid_t dataspace = H5Dget_space(dataset);
|
||||
//check the dimension of the active observable
|
||||
int rank = H5Sget_simple_extent_ndims(dataspace);
|
||||
std::vector<hsize_t> in_dims(rank);
|
||||
int status_n = H5Sget_simple_extent_dims(dataspace, &in_dims[0], NULL);
|
||||
std::vector<int> dims(rank-1);
|
||||
int num_blocks=static_cast<int>(in_dims[0]);
|
||||
int nb=num_blocks-first_block;
|
||||
//skip it
|
||||
if(nb<0)
|
||||
continue;
|
||||
std::cout << "<<<< Input dimension " << num_blocks;
|
||||
int tot_size=1;
|
||||
for(int dim=0; dim<rank-1; ++dim)
|
||||
{
|
||||
tot_size *= dims[dim]=static_cast<int>(in_dims[dim+1]);
|
||||
std::cout << " "<< dims[dim] ;
|
||||
}
|
||||
std::cout << "\n Total size = " << tot_size << std::endl;
|
||||
std::vector<double> odata_in;
|
||||
odata_in.resize(tot_size*num_blocks);
|
||||
hid_t ret = H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(odata_in[0]));
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(dataspace);
|
||||
std::vector<double> odata_tot(tot_size,0.0), odata2_tot(tot_size,0.0);
|
||||
std::vector<double>::iterator first=odata_in.begin()+first_block*tot_size;
|
||||
for(int b=first_block; b<num_blocks; ++b,first+=tot_size)
|
||||
accumulate_n(first,first+tot_size,odata_tot.begin());
|
||||
double fac=1.0/static_cast<double>(nb);
|
||||
scale_n(odata_tot.begin(),odata_tot.end(),fac);
|
||||
HDFAttribIO<std::vector<double> > dummy(odata_tot,dims);
|
||||
dummy.write(gid,"average");
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,593 +0,0 @@
|
|||
!//////////////////////////////////////////////////////////////////////////////////////
|
||||
!// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
!// See LICENSE file in top directory for details.
|
||||
!//
|
||||
!// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
!//
|
||||
!// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!//
|
||||
!// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
!
|
||||
! Copyright (C) 2004 PWSCF group
|
||||
! This file is distributed under the terms of the
|
||||
! GNU General Public License. See the file `License'
|
||||
! in the root directory of the present distribution,
|
||||
! or http://www.gnu.org/copyleft/gpl.txt .
|
||||
!
|
||||
!-----------------------------------------------------------------------
|
||||
PROGRAM pw2qmcpack
|
||||
!-----------------------------------------------------------------------
|
||||
|
||||
! This subroutine writes the file "prefix".pwscf.xml and "prefix".pwscf.h5
|
||||
! containing the plane wave coefficients and other stuff needed by the
|
||||
! QMC code QMCPACK.
|
||||
|
||||
#include "f_defs.h"
|
||||
|
||||
USE io_files, ONLY : nd_nmbr, prefix, outdir, tmp_dir, trimcheck
|
||||
USE io_global, ONLY : ionode, ionode_id
|
||||
USE mp, ONLY : mp_bcast
|
||||
!
|
||||
IMPLICIT NONE
|
||||
INTEGER :: ios
|
||||
|
||||
NAMELIST / inputpp / prefix, outdir
|
||||
|
||||
CALL start_postproc(nd_nmbr)
|
||||
!
|
||||
! set default values for variables in namelist
|
||||
!
|
||||
prefix = 'pwscf'
|
||||
CALL get_env( 'ESPRESSO_TMPDIR', outdir )
|
||||
IF ( TRIM( outdir ) == ' ' ) outdir = './'
|
||||
|
||||
IF ( ionode ) THEN
|
||||
!
|
||||
READ (5, inputpp, err=200, iostat=ios)
|
||||
200 CALL errore('pw2qmcpack', 'reading inputpp namelist', ABS(ios))
|
||||
tmp_dir = trimcheck (outdir)
|
||||
!
|
||||
END IF
|
||||
!
|
||||
! ... Broadcast variables
|
||||
!
|
||||
CALL mp_bcast( prefix, ionode_id )
|
||||
CALL mp_bcast(tmp_dir, ionode_id )
|
||||
!
|
||||
CALL read_file
|
||||
CALL openfil_pp
|
||||
!
|
||||
CALL compute_qmcpack
|
||||
!
|
||||
CALL stop_pp
|
||||
STOP
|
||||
|
||||
END PROGRAM pw2qmcpack
|
||||
|
||||
|
||||
SUBROUTINE compute_qmcpack
|
||||
|
||||
USE kinds, ONLY: DP
|
||||
USE ions_base, ONLY : nat, ntyp => nsp, ityp, tau, zv, atm
|
||||
USE cell_base, ONLY: omega, alat, tpiba2, at, bg
|
||||
USE char, ONLY: title
|
||||
USE constants, ONLY: tpi
|
||||
USE ener, ONLY: ewld, ehart, etxc, vtxc, etot, etxcc
|
||||
USE gvect, ONLY: ngm, gstart, nr1, nr2, nr3, nrx1, nrx2, nrx3, &
|
||||
nrxx, g, gg, ecutwfc, gcutm, nl, igtongl
|
||||
USE klist , ONLY: nks, nelec, nelup, neldw, xk
|
||||
USE lsda_mod, ONLY: lsda, nspin
|
||||
USE scf, ONLY: rho, rho_core, rhog, rhog_core
|
||||
USE vlocal, ONLY: vloc, vnew, strf
|
||||
USE wvfct, ONLY: npw, npwx, nbnd, gamma_only, igk, g2kin, wg, et
|
||||
USE uspp, ONLY: nkb, vkb, dvan
|
||||
USE uspp_param, ONLY: nh
|
||||
USE becmod, ONLY: becp
|
||||
USE io_global, ONLY: stdout
|
||||
USE io_files, ONLY: nd_nmbr, nwordwfc, iunwfc, iun => iunsat, tmp_dir, prefix
|
||||
USE wavefunctions_module, ONLY : evc, psic
|
||||
use gsmooth, only: nls, nrxxs, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s
|
||||
use iotk_module
|
||||
use iotk_xtox_interf
|
||||
IMPLICIT NONE
|
||||
INTEGER :: ig, ibnd, ik, io, na, j, ispin, nbndup, nbnddown, &
|
||||
nk, ngtot, ig7, ikk, nt, ijkb0, ikb, ih, jh, jkb, at_num, &
|
||||
nelec_tot, nelec_up, nelec_down, ii, igx, igy, igz
|
||||
INTEGER, ALLOCATABLE :: INDEX(:), igtog(:)
|
||||
LOGICAL :: exst, found
|
||||
REAL(DP) :: ek, eloc, enl, charge, etotefield
|
||||
REAL(DP) :: bg_qmc(3,3), tau_r(3), g_red(3)
|
||||
COMPLEX(DP), ALLOCATABLE :: phase(:),aux(:), hpsi(:,:), eigpacked(:)
|
||||
COMPLEX(DP), ALLOCATABLE :: psitr(:)
|
||||
REAL(DP), ALLOCATABLE :: g_cart(:,:),psireal(:)
|
||||
INTEGER :: ios, ierr, h5len,ig_c,save_complex, nup,ndown
|
||||
INTEGER, EXTERNAL :: atomic_number, is_complex
|
||||
INTEGER, ALLOCATABLE:: g_qmc(:,:)
|
||||
REAL (DP), EXTERNAL :: ewald
|
||||
|
||||
CHARACTER(256) :: tmp,h5name,eigname
|
||||
CHARACTER(iotk_attlenx) :: attr
|
||||
|
||||
CALL init_us_1
|
||||
CALL newd
|
||||
!####io = 77
|
||||
|
||||
!####WRITE (6,'(/,5x,''Writing file pwfn.data for program CASINO'')')
|
||||
|
||||
!####CALL seqopn( 77, 'pwfn.data', 'formatted',exst)
|
||||
|
||||
!ALLOCATE (hpsi(npwx, nbnd))
|
||||
ALLOCATE (aux(nrxx))
|
||||
ALLOCATE (becp (nkb,nbnd))
|
||||
! four times npwx should be enough
|
||||
ALLOCATE (INDEX (4*npwx) )
|
||||
ALLOCATE (igtog (4*npwx) )
|
||||
|
||||
|
||||
!hpsi (:,:) = (0.d0, 0.d0)
|
||||
INDEX(:) = 0
|
||||
igtog(:) = 0
|
||||
|
||||
IF( lsda ) THEN
|
||||
nbndup = nbnd
|
||||
nbnddown = nbnd
|
||||
nk = nks/2
|
||||
! nspin = 2
|
||||
ELSE
|
||||
nbndup = nbnd
|
||||
nbnddown = 0
|
||||
nk = nks
|
||||
! nspin = 1
|
||||
ENDIF
|
||||
|
||||
! if(nks > 1) rewind(iunigk)
|
||||
! do ik=1,nks
|
||||
! if(nks > 1) read(iunigk) npw, igk
|
||||
!
|
||||
! if(nks > 1) rewind(iunigk)
|
||||
ek = 0.d0
|
||||
eloc= 0.d0
|
||||
enl = 0.d0
|
||||
!
|
||||
DO ispin = 1, nspin
|
||||
!
|
||||
! calculate the local contribution to the total energy
|
||||
!
|
||||
! bring rho to G-space
|
||||
!
|
||||
aux(:) = CMPLX ( rho(:,ispin), 0.d0)
|
||||
CALL cft3(aux,nr1,nr2,nr3,nrx1,nrx2,nrx3,-1)
|
||||
!
|
||||
DO nt=1,ntyp
|
||||
DO ig = 1, ngm
|
||||
eloc = eloc + vloc(igtongl(ig),nt) * strf(ig,nt) &
|
||||
* CONJG(aux(nl(ig)))
|
||||
ENDDO
|
||||
ENDDO
|
||||
|
||||
DO ik = 1, nk
|
||||
ikk = ik + nk*(ispin-1)
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio (evc, nwordwfc, iunwfc, ikk, - 1)
|
||||
CALL init_us_2 (npw, igk, xk (1, ikk), vkb)
|
||||
CALL ccalbec (nkb, npwx, npw, nbnd, becp, vkb, evc)
|
||||
|
||||
DO ig =1, npw
|
||||
IF( igk(ig) > 4*npwx ) &
|
||||
CALL errore ('pw2qmcpack','increase allocation of index', ig)
|
||||
INDEX( igk(ig) ) = 1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
|
||||
#ifdef __PARA
|
||||
CALL reduce(1,eloc)
|
||||
CALL reduce(1,ek)
|
||||
CALL poolreduce(1,ek)
|
||||
CALL poolreduce(1,enl)
|
||||
#endif
|
||||
eloc = eloc * omega
|
||||
ek = ek * tpiba2
|
||||
|
||||
ngtot = 0
|
||||
DO ig = 1, 4*npwx
|
||||
IF( INDEX(ig) == 1 ) THEN
|
||||
ngtot = ngtot + 1
|
||||
igtog(ngtot) = ig
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
ALLOCATE (g_qmc(3,ngtot))
|
||||
ALLOCATE (g_cart(3,ngtot))
|
||||
|
||||
! get the number of electrons
|
||||
nelec_tot= NINT(nelec)
|
||||
nup=NINT(nelup)
|
||||
ndown=NINT(neldw)
|
||||
|
||||
if(nup .eq. 0) then
|
||||
ndown=nelec_tot/2
|
||||
nup=nelec_tot-ndown
|
||||
endif
|
||||
|
||||
h5name = TRIM( prefix ) // '.pwscf.h5'
|
||||
eigname = "eigenstates_"//trim(iotk_itoa(nr1s))//'_'//trim(iotk_itoa(nr2s))//'_'//trim(iotk_itoa(nr3s))
|
||||
|
||||
bg_qmc(:,:)=bg(:,:)/alat
|
||||
|
||||
!! create a file for particle set
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix )// '.ptcl.xml'
|
||||
CALL iotk_open_write(iun, FILE=TRIM(tmp), ROOT="qmcsystem", IERR=ierr )
|
||||
|
||||
CALL iotk_write_attr (attr,"name","global",first=.true.)
|
||||
CALL iotk_write_begin(iun, "simulationcell",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","lattice",first=.true.)
|
||||
CALL iotk_write_attr (attr,"units","bohr")
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,100) alat*at(1,1), alat*at(2,1), alat*at(3,1)
|
||||
WRITE(iun,100) alat*at(1,2), alat*at(2,2), alat*at(3,2)
|
||||
WRITE(iun,100) alat*at(1,3), alat*at(2,3), alat*at(3,3)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_attr (attr,"name","reciprocal",first=.true.)
|
||||
CALL iotk_write_attr (attr,"units","2pi/bohr")
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,100) bg_qmc(1,1), bg_qmc(2,1), bg_qmc(3,1)
|
||||
WRITE(iun,100) bg_qmc(1,2), bg_qmc(2,2), bg_qmc(3,2)
|
||||
WRITE(iun,100) bg_qmc(1,3), bg_qmc(2,3), bg_qmc(3,3)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","bconds",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,'(a)') 'p p p'
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","LR_dim_cutoff",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,'(a)') '10'
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "simulationcell")
|
||||
|
||||
! <particleset name="ions">
|
||||
CALL iotk_write_attr (attr,"name","ion0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nat)
|
||||
CALL iotk_write_begin(iun, "particleset",ATTR=attr)
|
||||
|
||||
! ionic species --> group
|
||||
DO na=1,ntyp
|
||||
CALL iotk_write_attr (attr,"name",TRIM(atm(na)),first=.true.)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) zv(na)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_end(iun, "group")
|
||||
ENDDO
|
||||
|
||||
! <attrib name="ionid"/>
|
||||
CALL iotk_write_attr (attr,"name","ionid",first=.true.)
|
||||
CALL iotk_write_attr (attr,"datatype","stringArray")
|
||||
CALL iotk_write_begin(iun, "attrib",ATTR=attr)
|
||||
write(iun,'(a)') (TRIM(atm(ityp(na))),na=1,nat)
|
||||
CALL iotk_write_end(iun, "attrib")
|
||||
|
||||
! <attrib name="position"/>
|
||||
CALL iotk_write_attr (attr,"name","position",first=.true.)
|
||||
CALL iotk_write_attr (attr,"datatype","posArray")
|
||||
CALL iotk_write_attr (attr,"condition","0")
|
||||
CALL iotk_write_begin(iun, "attrib",ATTR=attr)
|
||||
! write in cartesian coordinates in bohr
|
||||
! problem with xyz ordering inrelation to real-space grid
|
||||
DO na = 1, nat
|
||||
!tau_r(1)=alat*(tau(1,na)*bg_qmc(1,1)+tau(2,na)*bg_qmc(1,2)+tau(3,na)*bg_qmc(1,3))
|
||||
!tau_r(2)=alat*(tau(1,na)*bg_qmc(2,1)+tau(2,na)*bg_qmc(2,2)+tau(3,na)*bg_qmc(2,3))
|
||||
!tau_r(3)=alat*(tau(1,na)*bg_qmc(3,1)+tau(2,na)*bg_qmc(3,2)+tau(3,na)*bg_qmc(3,3))
|
||||
tau_r(1)=alat*tau(1,na)
|
||||
tau_r(2)=alat*tau(2,na)
|
||||
tau_r(3)=alat*tau(3,na)
|
||||
WRITE(iun,100) (tau_r(j),j=1,3)
|
||||
ENDDO
|
||||
!write(iun,100) tau
|
||||
CALL iotk_write_end(iun, "attrib")
|
||||
CALL iotk_write_end(iun, "particleset")
|
||||
! </particleset>
|
||||
|
||||
! <particleset name="e">
|
||||
CALL iotk_write_attr (attr,"name","e",first=.true.)
|
||||
CALL iotk_write_attr (attr,"random","yes")
|
||||
CALL iotk_write_begin(iun, "particleset",ATTR=attr)
|
||||
|
||||
! <group name="u" size="" >
|
||||
CALL iotk_write_attr (attr,"name","u",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nup)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) -1
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "group")
|
||||
|
||||
! <group name="d" size="" >
|
||||
CALL iotk_write_attr (attr,"name","d",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",ndown)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) -1
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "group")
|
||||
CALL iotk_write_end(iun, "particleset")
|
||||
CALL iotk_close_write(iun)
|
||||
|
||||
!! close the file
|
||||
DO ik = 0, nk-1
|
||||
! create a xml input file for each k-point
|
||||
IF(nk .gt. 1) THEN
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix ) //TRIM(iotk_index(ik))// '.wfs.xml'
|
||||
ELSE
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix )// '.wfs.xml'
|
||||
ENDIF
|
||||
CALL iotk_open_write(iun, FILE=TRIM(tmp), ROOT="qmcsystem", IERR=ierr )
|
||||
! <wavefunction name="psi0">
|
||||
CALL iotk_write_attr (attr,"name","psi0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"target","e")
|
||||
CALL iotk_write_begin(iun, "wavefunction",ATTR=attr)
|
||||
write(iun,'(a)') '<!-- Uncomment this out to use plane-wave basis functions'
|
||||
CALL iotk_write_attr (attr,"type","PW",first=.true.)
|
||||
CALL iotk_write_attr (attr,"href",TRIM(h5name))
|
||||
CALL iotk_write_attr (attr,"version","1.10")
|
||||
CALL iotk_write_begin(iun, "determinantset",ATTR=attr)
|
||||
write(iun,'(a)') '--> '
|
||||
CALL iotk_write_attr (attr,"type","bspline",first=.true.)
|
||||
CALL iotk_write_attr (attr,"href",TRIM(h5name))
|
||||
CALL iotk_write_attr (attr,"version","0.10")
|
||||
CALL iotk_write_begin(iun, "determinantset",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"ecut",ecutwfc/2,first=.true.)
|
||||
! basisset to overwrite cutoff to a smaller value
|
||||
CALL iotk_write_begin(iun, "basisset",ATTR=attr)
|
||||
! add grid to use spline on FFT grid
|
||||
CALL iotk_write_attr (attr,"dir","0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr1s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"dir","1",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr2s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"dir","2",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr3s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "basisset")
|
||||
|
||||
!CALL iotk_write_attr (attr,"href",TRIM(h5name),first=.true.)
|
||||
!CALL iotk_write_empty(iun, "coefficients",ATTR=attr)
|
||||
|
||||
! write the index of the twist angle
|
||||
CALL iotk_write_attr (attr,"name","twistIndex",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
write(iun,*) ik
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","twistAngle",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
g_red(1)=at(1,1)*xk(1,ik+1)+at(2,1)*xk(2,ik+1)+at(3,1)*xk(3,ik+1)
|
||||
g_red(2)=at(1,2)*xk(1,ik+1)+at(2,2)*xk(2,ik+1)+at(3,2)*xk(3,ik+1)
|
||||
g_red(3)=at(1,3)*xk(1,ik+1)+at(2,3)*xk(2,ik+1)+at(3,3)*xk(3,ik+1)
|
||||
!write(iun,100) xk(1,ik+1),xk(2,ik+1),xk(3,ik+1)
|
||||
write(iun,100) g_red(1),g_red(2),g_red(3)
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
!write(iun,'(a)') '<!-- Uncomment this out for bspline wavefunctions '
|
||||
CALL iotk_write_attr (attr,"name","eigenstates",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
write(iun,'(a)') TRIM(eigname)
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
!write(iun,'(a)') '--> '
|
||||
|
||||
|
||||
CALL iotk_write_begin(iun, "slaterdeterminant")
|
||||
! build determinant for up electrons
|
||||
CALL iotk_write_attr (attr,"id","updet",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nup)
|
||||
CALL iotk_write_begin(iun, "determinant",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"mode","ground",first=.true.)
|
||||
CALL iotk_write_attr (attr,"spindataset",0)
|
||||
CALL iotk_write_begin(iun, "occupation",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "occupation")
|
||||
CALL iotk_write_end(iun, "determinant")
|
||||
|
||||
! build determinant for down electrons
|
||||
CALL iotk_write_attr (attr,"id","downdet",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",ndown)
|
||||
IF( lsda ) CALL iotk_write_attr (attr,"ref","updet")
|
||||
CALL iotk_write_begin(iun, "determinant",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"mode","ground",first=.true.)
|
||||
IF( lsda ) THEN
|
||||
CALL iotk_write_attr (attr,"spindataset",1)
|
||||
ELSE
|
||||
CALL iotk_write_attr (attr,"spindataset",0)
|
||||
ENDIF
|
||||
CALL iotk_write_begin(iun, "occupation",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "occupation")
|
||||
CALL iotk_write_end(iun, "determinant")
|
||||
CALL iotk_write_end(iun, "slaterdeterminant")
|
||||
|
||||
CALL iotk_write_end(iun, "determinantset")
|
||||
CALL iotk_write_end(iun, "wavefunction")
|
||||
|
||||
CALL iotk_close_write(iun)
|
||||
ENDDO
|
||||
|
||||
tmp = TRIM( tmp_dir )//TRIM( prefix ) //'.pwscf.h5'
|
||||
h5len = LEN_TRIM(tmp)
|
||||
|
||||
DO ig=1, ngtot
|
||||
ig_c =igtog(ig)
|
||||
g_cart(1,ig)=tpi/alat*g(1,ig_c)
|
||||
g_cart(2,ig)=tpi/alat*g(2,ig_c)
|
||||
g_cart(3,ig)=tpi/alat*g(3,ig_c)
|
||||
g_qmc(1,ig)=at(1,1)*g(1,ig_c)+at(2,1)*g(2,ig_c)+at(3,1)*g(3,ig_c)
|
||||
g_qmc(2,ig)=at(1,2)*g(1,ig_c)+at(2,2)*g(2,ig_c)+at(3,2)*g(3,ig_c)
|
||||
g_qmc(3,ig)=at(1,3)*g(1,ig_c)+at(2,3)*g(2,ig_c)+at(3,3)*g(3,ig_c)
|
||||
ENDDO
|
||||
|
||||
|
||||
! generate hdf5 file containing all the parameters
|
||||
! print out 2*occupied bands
|
||||
CALL pwhdf_open_file(tmp,h5len)
|
||||
!CALL pwhdf_write_basis(g,igtog,ngtot)
|
||||
CALL pwhdf_write_basis(g_qmc,g_cart,ngtot)
|
||||
CALL pwhdf_write_parameters(nelec_tot,nspin,nbnd,nk,ecutwfc/2,alat,at)
|
||||
!
|
||||
100 FORMAT (3(1x,f20.15))
|
||||
|
||||
ALLOCATE (eigpacked(ngtot))
|
||||
|
||||
! start a main section to save eigen values and vector
|
||||
CALL pwhdf_open_eigg
|
||||
DO ik = 1, nk
|
||||
g_red(1)=at(1,1)*xk(1,ik)+at(2,1)*xk(2,ik)+at(3,1)*xk(3,ik)
|
||||
g_red(2)=at(1,2)*xk(1,ik)+at(2,2)*xk(2,ik)+at(3,2)*xk(3,ik)
|
||||
g_red(3)=at(1,3)*xk(1,ik)+at(2,3)*xk(2,ik)+at(3,3)*xk(3,ik)
|
||||
CALL pwhdf_open_twist(ik,g_red(1),nbnd,nspin)
|
||||
!CALL pwhdf_open_twist(ik,xk(1,ik),2*nbnd,nspin)
|
||||
DO ispin = 1, nspin
|
||||
ikk = ik + nk*(ispin-1)
|
||||
IF( nks > 1 ) THEN
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio(evc,nwordwfc,iunwfc,ikk,-1)
|
||||
ENDIF
|
||||
DO ibnd = 1, nbnd
|
||||
DO ig=1, ngtot
|
||||
! now for all G vectors find the PW coefficient for this k-point
|
||||
found = .FALSE.
|
||||
DO ig7 = 1, npw
|
||||
IF( igk(ig7) == igtog(ig) )THEN
|
||||
eigpacked(ig)=evc(ig7,ibnd)
|
||||
found = .TRUE.
|
||||
GOTO 17
|
||||
ENDIF
|
||||
ENDDO
|
||||
! if can't find the coefficient this is zero
|
||||
17 IF( .NOT. found ) eigpacked(ig)=(0.d0,0.d0)
|
||||
ENDDO
|
||||
CALL pwhdf_write_band(ibnd,ispin,et(ibnd,ikk)/2,eigpacked,ngtot)
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_close_twist
|
||||
ENDDO
|
||||
CALL pwhdf_close_eigg
|
||||
|
||||
!ALLOCATE (phase(nrxxs))
|
||||
|
||||
ALLOCATE(psireal(nrx1s*nrx2s*nrx3s))
|
||||
ALLOCATE(psitr(nrx1s*nrx2s*nrx3s))
|
||||
|
||||
! open real-space wavefunction on FFT grid
|
||||
CALL pwhdf_open_eigr(nr1s,nr2s,nr3s)
|
||||
DO ik = 1, nk
|
||||
!! evaluate the phase
|
||||
!phase(:) = (0.d0,0.d0)
|
||||
!if ( ig_(ik,ib)>0) phase( nls(ig_(ik,ib)) ) = (1.d0,0.d0)
|
||||
!call cft3s (phase, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, +2)
|
||||
g_red(1)=at(1,1)*xk(1,ik)+at(2,1)*xk(2,ik)+at(3,1)*xk(3,ik)
|
||||
g_red(2)=at(1,2)*xk(1,ik)+at(2,2)*xk(2,ik)+at(3,2)*xk(3,ik)
|
||||
g_red(3)=at(1,3)*xk(1,ik)+at(2,3)*xk(2,ik)+at(3,3)*xk(3,ik)
|
||||
|
||||
IF(g_red(1)*g_red(1)+g_red(2)*g_red(2)+g_red(3)*g_red(3)<1e-12) THEN
|
||||
save_complex=0
|
||||
ELSE
|
||||
save_complex=1
|
||||
ENDIF
|
||||
|
||||
! open a twsit
|
||||
CALL pwhdf_open_twist(ik,g_red(1),nbnd,nspin)
|
||||
DO ispin = 1, nspin
|
||||
ikk = ik + nk*(ispin-1)
|
||||
IF( nks > 1 ) THEN
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio(evc,nwordwfc,iunwfc,ikk,-1)
|
||||
ENDIF
|
||||
DO ibnd = 1, nbnd !!transform G to R
|
||||
psic(:)=(0.d0,0.d0)
|
||||
psic(nls(igk(1:npw)))=evc(1:npw,ibnd)
|
||||
call cft3s (psic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2)
|
||||
|
||||
!! THIS IS ORIGINAL: changes are made to convert real and reorder for C arrays
|
||||
!!CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psic,1)
|
||||
IF(save_complex .eq. 1) THEN
|
||||
!psic(:)=psic(:)/omega
|
||||
!CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psic,save_complex)
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
psitr(ii)=psic(igx+nr1s*(igy+igz*nr2s))/omega
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psitr,save_complex)
|
||||
ELSE
|
||||
!DO ig=1,nr1s*nr2s*nr3s
|
||||
! psireal(ig)=real(psic(ig))
|
||||
!ENDDO
|
||||
!psireal(1:nr1s*nr2s*nr3s)=real(psic(1:nr1s*nr2s*nr3s))/omega
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
psireal(ii)=real(psic(igx+nr1s*(igy+igz*nr2s)))/omega
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psireal,save_complex)
|
||||
ENDIF
|
||||
!! conversion and output complete for each band
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_close_twist
|
||||
ENDDO
|
||||
CALL pwhdf_close_eigr
|
||||
|
||||
! write charge density
|
||||
! ignore spin for the time being
|
||||
!CALL pwhdf_write_rho(rho,rhog(1,1),ngm)
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
psireal(ii)=rho(igx+nr1s*(igy+igz*nr2s),1)
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_write_rho(psireal,rhog(1,1),ngm)
|
||||
|
||||
! close the file
|
||||
CALL pwhdf_close_file
|
||||
|
||||
DEALLOCATE (igtog)
|
||||
DEALLOCATE (index)
|
||||
DEALLOCATE (becp)
|
||||
DEALLOCATE (aux)
|
||||
!DEALLOCATE (hpsi)
|
||||
DEALLOCATE (eigpacked)
|
||||
DEALLOCATE (g_qmc)
|
||||
DEALLOCATE (g_cart)
|
||||
DEALLOCATE (psireal)
|
||||
DEALLOCATE (psitr)
|
||||
!DEALLOCATE (phase)
|
||||
|
||||
END SUBROUTINE compute_qmcpack
|
||||
|
||||
|
|
@ -1,614 +0,0 @@
|
|||
!//////////////////////////////////////////////////////////////////////////////////////
|
||||
!// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
!// See LICENSE file in top directory for details.
|
||||
!//
|
||||
!// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
!//
|
||||
!// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!//
|
||||
!// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
!//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
!
|
||||
! Copyright (C) 2004 PWSCF group
|
||||
! This file is distributed under the terms of the
|
||||
! GNU General Public License. See the file `License'
|
||||
! in the root directory of the present distribution,
|
||||
! or http://www.gnu.org/copyleft/gpl.txt .
|
||||
!
|
||||
!-----------------------------------------------------------------------
|
||||
PROGRAM pw2qmcpack
|
||||
!-----------------------------------------------------------------------
|
||||
|
||||
! This subroutine writes the file "prefix".pwscf.xml and "prefix".pwscf.h5
|
||||
! containing the plane wave coefficients and other stuff needed by QMCPACK.
|
||||
|
||||
#include "f_defs.h"
|
||||
|
||||
USE io_files, ONLY : nd_nmbr, prefix, outdir, tmp_dir, trimcheck
|
||||
USE io_global, ONLY : ionode, ionode_id
|
||||
USE mp, ONLY : mp_bcast
|
||||
!
|
||||
IMPLICIT NONE
|
||||
INTEGER :: ios
|
||||
|
||||
NAMELIST / inputpp / prefix, outdir
|
||||
|
||||
CALL start_postproc(nd_nmbr)
|
||||
!
|
||||
! set default values for variables in namelist
|
||||
!
|
||||
prefix = 'pwscf'
|
||||
CALL get_env( 'ESPRESSO_TMPDIR', outdir )
|
||||
IF ( TRIM( outdir ) == ' ' ) outdir = './'
|
||||
ios = 0
|
||||
IF ( ionode ) THEN
|
||||
!
|
||||
!READ (5, inputpp, err=200, iostat=ios)
|
||||
READ (5, inputpp, iostat=ios)
|
||||
tmp_dir = trimcheck (outdir)
|
||||
!
|
||||
END IF
|
||||
CALL mp_bcast( ios, ionode_id )
|
||||
IF ( ios/=0 ) CALL errore('pw2qmcpack', 'reading inputpp namelist', ABS(ios))
|
||||
!
|
||||
! ... Broadcast variables
|
||||
!
|
||||
CALL mp_bcast( prefix, ionode_id )
|
||||
CALL mp_bcast(tmp_dir, ionode_id )
|
||||
!
|
||||
CALL read_file
|
||||
CALL openfil_pp
|
||||
!
|
||||
CALL compute_qmcpack
|
||||
!
|
||||
CALL stop_pp
|
||||
STOP
|
||||
|
||||
END PROGRAM pw2qmcpack
|
||||
|
||||
|
||||
SUBROUTINE compute_qmcpack
|
||||
|
||||
USE kinds, ONLY: DP
|
||||
USE ions_base, ONLY : nat, ntyp => nsp, ityp, tau, zv, atm
|
||||
USE cell_base, ONLY: omega, alat, tpiba2, at, bg
|
||||
USE char, ONLY: title
|
||||
USE constants, ONLY: tpi
|
||||
USE ener, ONLY: ewld, ehart, etxc, vtxc, etot, etxcc
|
||||
USE gvect, ONLY: ngm, gstart, nr1, nr2, nr3, nrx1, nrx2, nrx3, &
|
||||
nrxx, g, gg, ecutwfc, gcutm, nl, igtongl
|
||||
USE klist , ONLY: nks, nelec, nelup, neldw, xk
|
||||
USE lsda_mod, ONLY: lsda, nspin
|
||||
!!V3.0
|
||||
!!USE scf, ONLY: rho, rho_core, rhog, rhog_core
|
||||
!!USE vlocal, ONLY: vloc, vnew, strf
|
||||
!!USE wvfct, ONLY: npw, npwx, nbnd, gamma_only, igk, g2kin, wg, et
|
||||
USE scf, ONLY: rho, rho_core, rhog_core, vnew
|
||||
USE vlocal, ONLY: vloc, strf
|
||||
USE wvfct, ONLY: npw, npwx, nbnd, igk, g2kin, wg, et
|
||||
USE control_flags, ONLY: gamma_only
|
||||
USE uspp, ONLY: nkb, vkb, dvan
|
||||
USE uspp_param, ONLY: nh
|
||||
USE becmod, ONLY: becp, calbec
|
||||
USE io_global, ONLY: stdout
|
||||
USE io_files, ONLY: nd_nmbr, nwordwfc, iunwfc, iun => iunsat, tmp_dir, prefix
|
||||
USE wavefunctions_module, ONLY : evc, psic
|
||||
use gsmooth, only: nls, nrxxs, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s
|
||||
use iotk_module
|
||||
use iotk_xtox_interf
|
||||
USE mp_global, ONLY: inter_pool_comm, intra_pool_comm
|
||||
USE mp, ONLY: mp_sum
|
||||
|
||||
IMPLICIT NONE
|
||||
INTEGER :: ig, ibnd, ik, io, na, j, ispin, nbndup, nbnddown, &
|
||||
nk, ngtot, ig7, ikk, nt, ijkb0, ikb, ih, jh, jkb, at_num, &
|
||||
nelec_tot, nelec_up, nelec_down, ii, igx, igy, igz
|
||||
INTEGER, ALLOCATABLE :: INDEX(:), igtog(:)
|
||||
LOGICAL :: exst, found
|
||||
REAL(DP) :: ek, eloc, enl, charge, etotefield
|
||||
REAL(DP) :: bg_qmc(3,3), tau_r(3), g_red(3)
|
||||
COMPLEX(DP), ALLOCATABLE :: phase(:),aux(:), hpsi(:,:), eigpacked(:)
|
||||
COMPLEX(DP), ALLOCATABLE :: psitr(:)
|
||||
REAL(DP), ALLOCATABLE :: g_cart(:,:),psireal(:)
|
||||
INTEGER :: ios, ierr, h5len,ig_c,save_complex, nup,ndown
|
||||
INTEGER, EXTERNAL :: atomic_number, is_complex
|
||||
INTEGER, ALLOCATABLE:: g_qmc(:,:)
|
||||
REAL (DP), EXTERNAL :: ewald
|
||||
|
||||
CHARACTER(256) :: tmp,h5name,eigname
|
||||
CHARACTER(iotk_attlenx) :: attr
|
||||
|
||||
CALL init_us_1
|
||||
CALL newd
|
||||
!####io = 77
|
||||
|
||||
!####WRITE (6,'(/,5x,''Writing file pwfn.data for program CASINO'')')
|
||||
|
||||
!####CALL seqopn( 77, 'pwfn.data', 'formatted',exst)
|
||||
|
||||
!ALLOCATE (hpsi(npwx, nbnd))
|
||||
ALLOCATE (aux(nrxx))
|
||||
ALLOCATE (becp (nkb,nbnd))
|
||||
! four times npwx should be enough
|
||||
ALLOCATE (INDEX (4*npwx) )
|
||||
ALLOCATE (igtog (4*npwx) )
|
||||
|
||||
|
||||
!hpsi (:,:) = (0.d0, 0.d0)
|
||||
INDEX(:) = 0
|
||||
igtog(:) = 0
|
||||
|
||||
IF( lsda ) THEN
|
||||
nbndup = nbnd
|
||||
nbnddown = nbnd
|
||||
nk = nks/2
|
||||
! nspin = 2
|
||||
ELSE
|
||||
nbndup = nbnd
|
||||
nbnddown = 0
|
||||
nk = nks
|
||||
! nspin = 1
|
||||
ENDIF
|
||||
|
||||
! if(nks > 1) rewind(iunigk)
|
||||
! do ik=1,nks
|
||||
! if(nks > 1) read(iunigk) npw, igk
|
||||
!
|
||||
! if(nks > 1) rewind(iunigk)
|
||||
ek = 0.d0
|
||||
eloc= 0.d0
|
||||
enl = 0.d0
|
||||
!
|
||||
DO ispin = 1, nspin
|
||||
!
|
||||
! calculate the local contribution to the total energy
|
||||
!
|
||||
! bring rho to G-space
|
||||
!
|
||||
!aux(:) = CMPLX ( rho(:,ispin), 0.d0)
|
||||
aux(:) = CMPLX ( rho%of_r(:,ispin), 0.d0)
|
||||
CALL cft3(aux,nr1,nr2,nr3,nrx1,nrx2,nrx3,-1)
|
||||
!
|
||||
DO nt=1,ntyp
|
||||
DO ig = 1, ngm
|
||||
eloc = eloc + vloc(igtongl(ig),nt) * strf(ig,nt) &
|
||||
* CONJG(aux(nl(ig)))
|
||||
ENDDO
|
||||
ENDDO
|
||||
|
||||
DO ik = 1, nk
|
||||
ikk = ik + nk*(ispin-1)
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio (evc, nwordwfc, iunwfc, ikk, - 1)
|
||||
CALL init_us_2 (npw, igk, xk (1, ikk), vkb)
|
||||
!CALL ccalbec (nkb, npwx, npw, nbnd, becp, vkb, evc)
|
||||
CALL calbec ( npw, vkb, evc, becp )
|
||||
|
||||
DO ig =1, npw
|
||||
IF( igk(ig) > 4*npwx ) &
|
||||
CALL errore ('pw2qmcpack','increase allocation of index', ig)
|
||||
INDEX( igk(ig) ) = 1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
|
||||
!#ifdef __PARA
|
||||
! CALL reduce(1,eloc)
|
||||
! CALL reduce(1,ek)
|
||||
! CALL poolreduce(1,ek)
|
||||
! CALL poolreduce(1,enl)
|
||||
!#endif
|
||||
#ifdef __PARA
|
||||
call mp_sum( eloc, intra_pool_comm )
|
||||
call mp_sum( ek, intra_pool_comm )
|
||||
call mp_sum( ek, inter_pool_comm )
|
||||
call mp_sum( enl, inter_pool_comm )
|
||||
!call mp_sum( demet, inter_pool_comm )
|
||||
#endif
|
||||
|
||||
eloc = eloc * omega
|
||||
ek = ek * tpiba2
|
||||
|
||||
ngtot = 0
|
||||
DO ig = 1, 4*npwx
|
||||
IF( INDEX(ig) == 1 ) THEN
|
||||
ngtot = ngtot + 1
|
||||
igtog(ngtot) = ig
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
ALLOCATE (g_qmc(3,ngtot))
|
||||
ALLOCATE (g_cart(3,ngtot))
|
||||
|
||||
! get the number of electrons
|
||||
nelec_tot= NINT(nelec)
|
||||
nup=NINT(nelup)
|
||||
ndown=NINT(neldw)
|
||||
|
||||
if(nup .eq. 0) then
|
||||
ndown=nelec_tot/2
|
||||
nup=nelec_tot-ndown
|
||||
endif
|
||||
|
||||
h5name = TRIM( prefix ) // '.pwscf.h5'
|
||||
eigname = "eigenstates_"//trim(iotk_itoa(nr1s))//'_'//trim(iotk_itoa(nr2s))//'_'//trim(iotk_itoa(nr3s))
|
||||
|
||||
bg_qmc(:,:)=bg(:,:)/alat
|
||||
|
||||
!! create a file for particle set
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix )// '.ptcl.xml'
|
||||
CALL iotk_open_write(iun, FILE=TRIM(tmp), ROOT="qmcsystem", IERR=ierr )
|
||||
|
||||
CALL iotk_write_attr (attr,"name","global",first=.true.)
|
||||
CALL iotk_write_begin(iun, "simulationcell",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","lattice",first=.true.)
|
||||
CALL iotk_write_attr (attr,"units","bohr")
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,100) alat*at(1,1), alat*at(2,1), alat*at(3,1)
|
||||
WRITE(iun,100) alat*at(1,2), alat*at(2,2), alat*at(3,2)
|
||||
WRITE(iun,100) alat*at(1,3), alat*at(2,3), alat*at(3,3)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_attr (attr,"name","reciprocal",first=.true.)
|
||||
CALL iotk_write_attr (attr,"units","2pi/bohr")
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,100) bg_qmc(1,1), bg_qmc(2,1), bg_qmc(3,1)
|
||||
WRITE(iun,100) bg_qmc(1,2), bg_qmc(2,2), bg_qmc(3,2)
|
||||
WRITE(iun,100) bg_qmc(1,3), bg_qmc(2,3), bg_qmc(3,3)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","bconds",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,'(a)') 'p p p'
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","LR_dim_cutoff",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
WRITE(iun,'(a)') '10'
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "simulationcell")
|
||||
|
||||
! <particleset name="ions">
|
||||
CALL iotk_write_attr (attr,"name","ion0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nat)
|
||||
CALL iotk_write_begin(iun, "particleset",ATTR=attr)
|
||||
|
||||
! ionic species --> group
|
||||
DO na=1,ntyp
|
||||
CALL iotk_write_attr (attr,"name",TRIM(atm(na)),first=.true.)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) zv(na)
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
|
||||
CALL iotk_write_end(iun, "group")
|
||||
ENDDO
|
||||
|
||||
! <attrib name="ionid"/>
|
||||
CALL iotk_write_attr (attr,"name","ionid",first=.true.)
|
||||
CALL iotk_write_attr (attr,"datatype","stringArray")
|
||||
CALL iotk_write_begin(iun, "attrib",ATTR=attr)
|
||||
write(iun,'(a)') (TRIM(atm(ityp(na))),na=1,nat)
|
||||
CALL iotk_write_end(iun, "attrib")
|
||||
|
||||
! <attrib name="position"/>
|
||||
CALL iotk_write_attr (attr,"name","position",first=.true.)
|
||||
CALL iotk_write_attr (attr,"datatype","posArray")
|
||||
CALL iotk_write_attr (attr,"condition","0")
|
||||
CALL iotk_write_begin(iun, "attrib",ATTR=attr)
|
||||
! write in cartesian coordinates in bohr
|
||||
! problem with xyz ordering inrelation to real-space grid
|
||||
DO na = 1, nat
|
||||
!tau_r(1)=alat*(tau(1,na)*bg_qmc(1,1)+tau(2,na)*bg_qmc(1,2)+tau(3,na)*bg_qmc(1,3))
|
||||
!tau_r(2)=alat*(tau(1,na)*bg_qmc(2,1)+tau(2,na)*bg_qmc(2,2)+tau(3,na)*bg_qmc(2,3))
|
||||
!tau_r(3)=alat*(tau(1,na)*bg_qmc(3,1)+tau(2,na)*bg_qmc(3,2)+tau(3,na)*bg_qmc(3,3))
|
||||
tau_r(1)=alat*tau(1,na)
|
||||
tau_r(2)=alat*tau(2,na)
|
||||
tau_r(3)=alat*tau(3,na)
|
||||
WRITE(iun,100) (tau_r(j),j=1,3)
|
||||
ENDDO
|
||||
!write(iun,100) tau
|
||||
CALL iotk_write_end(iun, "attrib")
|
||||
CALL iotk_write_end(iun, "particleset")
|
||||
! </particleset>
|
||||
|
||||
! <particleset name="e">
|
||||
CALL iotk_write_attr (attr,"name","e",first=.true.)
|
||||
CALL iotk_write_attr (attr,"random","yes")
|
||||
CALL iotk_write_begin(iun, "particleset",ATTR=attr)
|
||||
|
||||
! <group name="u" size="" >
|
||||
CALL iotk_write_attr (attr,"name","u",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nup)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) -1
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "group")
|
||||
|
||||
! <group name="d" size="" >
|
||||
CALL iotk_write_attr (attr,"name","d",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",ndown)
|
||||
CALL iotk_write_begin(iun, "group",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"name","charge",first=.true.)
|
||||
CALL iotk_write_begin(iun, "parameter",ATTR=attr)
|
||||
write(iun,*) -1
|
||||
CALL iotk_write_end(iun, "parameter")
|
||||
CALL iotk_write_end(iun, "group")
|
||||
CALL iotk_write_end(iun, "particleset")
|
||||
CALL iotk_close_write(iun)
|
||||
|
||||
!! close the file
|
||||
DO ik = 0, nk-1
|
||||
! create a xml input file for each k-point
|
||||
IF(nk .gt. 1) THEN
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix ) //TRIM(iotk_index(ik))// '.wfs.xml'
|
||||
ELSE
|
||||
tmp = TRIM( tmp_dir ) // TRIM( prefix )// '.wfs.xml'
|
||||
ENDIF
|
||||
CALL iotk_open_write(iun, FILE=TRIM(tmp), ROOT="qmcsystem", IERR=ierr )
|
||||
! <wavefunction name="psi0">
|
||||
CALL iotk_write_attr (attr,"name","psi0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"target","e")
|
||||
CALL iotk_write_begin(iun, "wavefunction",ATTR=attr)
|
||||
write(iun,'(a)') '<!-- Uncomment this out to use plane-wave basis functions'
|
||||
CALL iotk_write_attr (attr,"type","PW",first=.true.)
|
||||
CALL iotk_write_attr (attr,"href",TRIM(h5name))
|
||||
CALL iotk_write_attr (attr,"version","1.10")
|
||||
CALL iotk_write_begin(iun, "determinantset",ATTR=attr)
|
||||
write(iun,'(a)') '--> '
|
||||
CALL iotk_write_attr (attr,"type","bspline",first=.true.)
|
||||
CALL iotk_write_attr (attr,"href",TRIM(h5name))
|
||||
CALL iotk_write_attr (attr,"version","0.10")
|
||||
CALL iotk_write_begin(iun, "determinantset",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"ecut",ecutwfc/2,first=.true.)
|
||||
! basisset to overwrite cutoff to a smaller value
|
||||
CALL iotk_write_begin(iun, "basisset",ATTR=attr)
|
||||
! add grid to use spline on FFT grid
|
||||
CALL iotk_write_attr (attr,"dir","0",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr1s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"dir","1",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr2s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"dir","2",first=.true.)
|
||||
CALL iotk_write_attr (attr,"npts",nr3s)
|
||||
CALL iotk_write_attr (attr,"closed","no")
|
||||
CALL iotk_write_empty(iun, "grid",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "basisset")
|
||||
|
||||
!CALL iotk_write_attr (attr,"href",TRIM(h5name),first=.true.)
|
||||
!CALL iotk_write_empty(iun, "coefficients",ATTR=attr)
|
||||
|
||||
! write the index of the twist angle
|
||||
CALL iotk_write_attr (attr,"name","twistIndex",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
write(iun,*) ik
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
|
||||
CALL iotk_write_attr (attr,"name","twistAngle",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
g_red(1)=at(1,1)*xk(1,ik+1)+at(2,1)*xk(2,ik+1)+at(3,1)*xk(3,ik+1)
|
||||
g_red(2)=at(1,2)*xk(1,ik+1)+at(2,2)*xk(2,ik+1)+at(3,2)*xk(3,ik+1)
|
||||
g_red(3)=at(1,3)*xk(1,ik+1)+at(2,3)*xk(2,ik+1)+at(3,3)*xk(3,ik+1)
|
||||
!write(iun,100) xk(1,ik+1),xk(2,ik+1),xk(3,ik+1)
|
||||
write(iun,100) g_red(1),g_red(2),g_red(3)
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
!write(iun,'(a)') '<!-- Uncomment this out for bspline wavefunctions '
|
||||
CALL iotk_write_attr (attr,"name","eigenstates",first=.true.)
|
||||
CALL iotk_write_begin(iun, "h5tag",ATTR=attr)
|
||||
write(iun,'(a)') TRIM(eigname)
|
||||
CALL iotk_write_end(iun, "h5tag")
|
||||
!write(iun,'(a)') '--> '
|
||||
|
||||
|
||||
CALL iotk_write_begin(iun, "slaterdeterminant")
|
||||
! build determinant for up electrons
|
||||
CALL iotk_write_attr (attr,"id","updet",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",nup)
|
||||
CALL iotk_write_begin(iun, "determinant",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"mode","ground",first=.true.)
|
||||
CALL iotk_write_attr (attr,"spindataset",0)
|
||||
CALL iotk_write_begin(iun, "occupation",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "occupation")
|
||||
CALL iotk_write_end(iun, "determinant")
|
||||
|
||||
! build determinant for down electrons
|
||||
CALL iotk_write_attr (attr,"id","downdet",first=.true.)
|
||||
CALL iotk_write_attr (attr,"size",ndown)
|
||||
IF( lsda ) CALL iotk_write_attr (attr,"ref","updet")
|
||||
CALL iotk_write_begin(iun, "determinant",ATTR=attr)
|
||||
CALL iotk_write_attr (attr,"mode","ground",first=.true.)
|
||||
IF( lsda ) THEN
|
||||
CALL iotk_write_attr (attr,"spindataset",1)
|
||||
ELSE
|
||||
CALL iotk_write_attr (attr,"spindataset",0)
|
||||
ENDIF
|
||||
CALL iotk_write_begin(iun, "occupation",ATTR=attr)
|
||||
CALL iotk_write_end(iun, "occupation")
|
||||
CALL iotk_write_end(iun, "determinant")
|
||||
CALL iotk_write_end(iun, "slaterdeterminant")
|
||||
|
||||
CALL iotk_write_end(iun, "determinantset")
|
||||
CALL iotk_write_end(iun, "wavefunction")
|
||||
|
||||
CALL iotk_close_write(iun)
|
||||
ENDDO
|
||||
|
||||
tmp = TRIM( tmp_dir )//TRIM( prefix ) //'.pwscf.h5'
|
||||
h5len = LEN_TRIM(tmp)
|
||||
|
||||
DO ig=1, ngtot
|
||||
ig_c =igtog(ig)
|
||||
g_cart(1,ig)=tpi/alat*g(1,ig_c)
|
||||
g_cart(2,ig)=tpi/alat*g(2,ig_c)
|
||||
g_cart(3,ig)=tpi/alat*g(3,ig_c)
|
||||
g_qmc(1,ig)=at(1,1)*g(1,ig_c)+at(2,1)*g(2,ig_c)+at(3,1)*g(3,ig_c)
|
||||
g_qmc(2,ig)=at(1,2)*g(1,ig_c)+at(2,2)*g(2,ig_c)+at(3,2)*g(3,ig_c)
|
||||
g_qmc(3,ig)=at(1,3)*g(1,ig_c)+at(2,3)*g(2,ig_c)+at(3,3)*g(3,ig_c)
|
||||
ENDDO
|
||||
|
||||
|
||||
! generate hdf5 file containing all the parameters
|
||||
! print out 2*occupied bands
|
||||
CALL pwhdf_open_file(tmp,h5len)
|
||||
!CALL pwhdf_write_basis(g,igtog,ngtot)
|
||||
CALL pwhdf_write_basis(g_qmc,g_cart,ngtot)
|
||||
CALL pwhdf_write_parameters(nelec_tot,nspin,nbnd,nk,ecutwfc/2,alat,at)
|
||||
!
|
||||
100 FORMAT (3(1x,f20.15))
|
||||
|
||||
ALLOCATE (eigpacked(ngtot))
|
||||
|
||||
! start a main section to save eigen values and vector
|
||||
CALL pwhdf_open_eigg
|
||||
DO ik = 1, nk
|
||||
g_red(1)=at(1,1)*xk(1,ik)+at(2,1)*xk(2,ik)+at(3,1)*xk(3,ik)
|
||||
g_red(2)=at(1,2)*xk(1,ik)+at(2,2)*xk(2,ik)+at(3,2)*xk(3,ik)
|
||||
g_red(3)=at(1,3)*xk(1,ik)+at(2,3)*xk(2,ik)+at(3,3)*xk(3,ik)
|
||||
CALL pwhdf_open_twist(ik,g_red(1),nbnd,nspin)
|
||||
!CALL pwhdf_open_twist(ik,xk(1,ik),2*nbnd,nspin)
|
||||
DO ispin = 1, nspin
|
||||
ikk = ik + nk*(ispin-1)
|
||||
IF( nks > 1 ) THEN
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio(evc,nwordwfc,iunwfc,ikk,-1)
|
||||
ENDIF
|
||||
DO ibnd = 1, nbnd
|
||||
DO ig=1, ngtot
|
||||
! now for all G vectors find the PW coefficient for this k-point
|
||||
found = .FALSE.
|
||||
DO ig7 = 1, npw
|
||||
IF( igk(ig7) == igtog(ig) )THEN
|
||||
eigpacked(ig)=evc(ig7,ibnd)
|
||||
found = .TRUE.
|
||||
GOTO 17
|
||||
ENDIF
|
||||
ENDDO
|
||||
! if can't find the coefficient this is zero
|
||||
17 IF( .NOT. found ) eigpacked(ig)=(0.d0,0.d0)
|
||||
ENDDO
|
||||
CALL pwhdf_write_band(ibnd,ispin,et(ibnd,ikk)/2,eigpacked,ngtot)
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_close_twist
|
||||
ENDDO
|
||||
CALL pwhdf_close_eigg
|
||||
|
||||
!ALLOCATE (phase(nrxxs))
|
||||
|
||||
ALLOCATE(psireal(nrx1s*nrx2s*nrx3s))
|
||||
ALLOCATE(psitr(nrx1s*nrx2s*nrx3s))
|
||||
|
||||
! open real-space wavefunction on FFT grid
|
||||
CALL pwhdf_open_eigr(nr1s,nr2s,nr3s)
|
||||
DO ik = 1, nk
|
||||
!! evaluate the phase
|
||||
!phase(:) = (0.d0,0.d0)
|
||||
!if ( ig_(ik,ib)>0) phase( nls(ig_(ik,ib)) ) = (1.d0,0.d0)
|
||||
!call cft3s (phase, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, +2)
|
||||
g_red(1)=at(1,1)*xk(1,ik)+at(2,1)*xk(2,ik)+at(3,1)*xk(3,ik)
|
||||
g_red(2)=at(1,2)*xk(1,ik)+at(2,2)*xk(2,ik)+at(3,2)*xk(3,ik)
|
||||
g_red(3)=at(1,3)*xk(1,ik)+at(2,3)*xk(2,ik)+at(3,3)*xk(3,ik)
|
||||
|
||||
IF(g_red(1)*g_red(1)+g_red(2)*g_red(2)+g_red(3)*g_red(3)<1e-12) THEN
|
||||
save_complex=0
|
||||
ELSE
|
||||
save_complex=1
|
||||
ENDIF
|
||||
|
||||
! open a twsit
|
||||
CALL pwhdf_open_twist(ik,g_red(1),nbnd,nspin)
|
||||
DO ispin = 1, nspin
|
||||
ikk = ik + nk*(ispin-1)
|
||||
IF( nks > 1 ) THEN
|
||||
CALL gk_sort (xk (1, ikk), ngm, g, ecutwfc / tpiba2, npw, igk, g2kin)
|
||||
CALL davcio(evc,nwordwfc,iunwfc,ikk,-1)
|
||||
ENDIF
|
||||
DO ibnd = 1, nbnd !!transform G to R
|
||||
psic(:)=(0.d0,0.d0)
|
||||
psic(nls(igk(1:npw)))=evc(1:npw,ibnd)
|
||||
call cft3s (psic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2)
|
||||
|
||||
!! THIS IS ORIGINAL: changes are made to convert real and reorder for C arrays
|
||||
!!CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psic,1)
|
||||
IF(save_complex .eq. 1) THEN
|
||||
!psic(:)=psic(:)/omega
|
||||
!CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psic,save_complex)
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
psitr(ii)=psic(igx+nr1s*(igy+igz*nr2s))/omega
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psitr,save_complex)
|
||||
ELSE
|
||||
!DO ig=1,nr1s*nr2s*nr3s
|
||||
! psireal(ig)=real(psic(ig))
|
||||
!ENDDO
|
||||
!psireal(1:nr1s*nr2s*nr3s)=real(psic(1:nr1s*nr2s*nr3s))/omega
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
psireal(ii)=real(psic(igx+nr1s*(igy+igz*nr2s)))/omega
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_write_wfr(ibnd,ispin,et(ibnd,ikk)/2,psireal,save_complex)
|
||||
ENDIF
|
||||
!! conversion and output complete for each band
|
||||
ENDDO
|
||||
ENDDO
|
||||
CALL pwhdf_close_twist
|
||||
ENDDO
|
||||
CALL pwhdf_close_eigr
|
||||
|
||||
! write charge density
|
||||
! ignore spin for the time being
|
||||
!CALL pwhdf_write_rho(rho,rhog(1,1),ngm)
|
||||
ii=1
|
||||
DO igx=1,nr1s
|
||||
DO igy=0,nr2s-1
|
||||
DO igz=0,nr3s-1
|
||||
!psireal(ii)=rho(igx+nr1s*(igy+igz*nr2s),1)
|
||||
psireal(ii)=rho%of_r(igx+nr1s*(igy+igz*nr2s),1)
|
||||
ii=ii+1
|
||||
ENDDO
|
||||
ENDDO
|
||||
ENDDO
|
||||
!CALL pwhdf_write_rho(psireal,rhog(1,1),ngm)
|
||||
CALL pwhdf_write_rho(psireal,rho%of_g(1,1),ngm)
|
||||
|
||||
! close the file
|
||||
CALL pwhdf_close_file
|
||||
|
||||
DEALLOCATE (igtog)
|
||||
DEALLOCATE (index)
|
||||
DEALLOCATE (becp)
|
||||
DEALLOCATE (aux)
|
||||
!DEALLOCATE (hpsi)
|
||||
DEALLOCATE (eigpacked)
|
||||
DEALLOCATE (g_qmc)
|
||||
DEALLOCATE (g_cart)
|
||||
DEALLOCATE (psireal)
|
||||
DEALLOCATE (psitr)
|
||||
!DEALLOCATE (phase)
|
||||
|
||||
END SUBROUTINE compute_qmcpack
|
||||
|
||||
|
|
@ -1,394 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (C) 2004 PWSCF group
|
||||
* Copyright (C) 2007 QMCPACK developers
|
||||
*
|
||||
* @author Jeongnim Kim http://www.mcc.uiuc.edu/qmcpack/
|
||||
* @brief Implements generic hdf5 interfaces for plane wave codes and qmcpack
|
||||
*
|
||||
* - pwhdf_open_file: open hdf5 file
|
||||
* - pwhdf_close_file : close hdf5 file
|
||||
* - pwhdf_open_eigg : open eigenstates
|
||||
* - pwhdf_close_eigg : close eigenstates
|
||||
* - pwhdf_open_eigr : open eigenstates_nx_ny_nz
|
||||
* - pwhdf_close_eigr : close eigenstates_nx_ny_nz
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "c_defs.h"
|
||||
#include "hdf5.h"
|
||||
|
||||
/* file handler */
|
||||
static hid_t h_file=-1;
|
||||
/* main handler */
|
||||
static hid_t h_main=-1;
|
||||
/* twist angle handler */
|
||||
static hid_t h_twist=-1;
|
||||
/* number of fft grid */
|
||||
static int h_ngrid[3];
|
||||
/* number of real-space grids */
|
||||
static int h_ngridtot=0;
|
||||
/* check for gamma */
|
||||
static int is_gamma=0;
|
||||
void F77_FUNC_(pwhdf_open_file,PWHDF_OPEN_FILE)(const char* fname, const int* length)
|
||||
{
|
||||
char * hfname = ( char * ) malloc( (*length) + 1 ) ;
|
||||
memcpy( hfname , fname , *length ) ;
|
||||
hfname[*length] = '\0' ;
|
||||
|
||||
if(h_file>=0) H5Fclose(h_file);
|
||||
|
||||
h_file = H5Fcreate(hfname,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
|
||||
|
||||
/* impelements version 1.00 hdf5 format */
|
||||
int version[]={1,10};
|
||||
hsize_t dim=2;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_file, "version", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,version);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
free(hfname);
|
||||
}
|
||||
void F77_FUNC_(pwhdf_close_file,PWHDF_CLOSE_FILE)()
|
||||
{
|
||||
if(h_file>=0) H5Fclose(h_file);
|
||||
h_file=-1;
|
||||
}
|
||||
|
||||
/** write basisset: number of plane waves, plane wave coefficients
|
||||
*/
|
||||
void F77_FUNC_(pwhdf_write_basis,PWHDF_WRITE_BASIS)(const int* ig,
|
||||
const double* gcart, const int* ngtot)
|
||||
{
|
||||
int ng=*ngtot;
|
||||
|
||||
hid_t h_basis = H5Gcreate(h_file,"basis",0);
|
||||
hsize_t dim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_basis, "num_planewaves", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,ngtot);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
hsize_t dims[2];
|
||||
dims[0] = ng;
|
||||
dims[1] = 3;
|
||||
dataspace = H5Screate_simple(2, dims, NULL);
|
||||
|
||||
dataset = H5Dcreate(h_basis, "multipliers", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,ig);
|
||||
H5Dclose(dataset);
|
||||
H5Sclose(dataspace);
|
||||
|
||||
dataspace = H5Screate_simple(2, dims, NULL);
|
||||
dataset = H5Dcreate(h_basis, "planewaves", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,gcart);
|
||||
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
H5Gclose(h_basis);
|
||||
}
|
||||
|
||||
|
||||
/** write basisset: number of plane waves, plane wave coefficients
|
||||
void F77_FUNC_(pwhdf_write_basis,PWHDF_WRITE_BASIS)(const double* g, const int* igtog, const int* ngtot)
|
||||
{
|
||||
int ng=*ngtot;
|
||||
int *ig=(int*)malloc(3*ng*sizeof(int));
|
||||
for(int i=0,i3=0; i<ng; i++)
|
||||
{
|
||||
int cur=3*(igtog[i]-1);
|
||||
ig[i3++]=(int)g[cur++];
|
||||
ig[i3++]=(int)g[cur++];
|
||||
ig[i3++]=(int)g[cur++];
|
||||
}
|
||||
|
||||
hid_t h_basis = H5Gcreate(h_file,"basis",0);
|
||||
hsize_t dim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_basis, "num_planewaves", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,ngtot);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
hsize_t dims[2];
|
||||
dims[0] = ng;
|
||||
dims[1] = 3;
|
||||
dataspace = H5Screate_simple(2, dims, NULL);
|
||||
dataset = H5Dcreate(h_basis, "planewaves", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,ig);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
H5Gclose(h_basis);
|
||||
|
||||
free(ig);
|
||||
}
|
||||
*/
|
||||
void F77_FUNC_(pwhdf_write_parameters,PWHDF_WRITE_PARAMETERS)(
|
||||
const int* nelec, const int* nspin, const int* nband, const int* nk,
|
||||
const double* ecut, const double* alat, const double* at)
|
||||
{
|
||||
|
||||
hid_t h_param = H5Gcreate(h_file,"parameters",0);
|
||||
hsize_t dim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_param, "num_spins", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,nspin);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
dataset= H5Dcreate(h_param, "num_electrons", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,nelec);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
dataset= H5Dcreate(h_param, "num_bands", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,nband);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
dataset= H5Dcreate(h_param, "num_twists", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,nk);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
int iscomplex=1;
|
||||
dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
dataset= H5Dcreate(h_param, "complex_coefficients", H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,&iscomplex);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
dataset= H5Dcreate(h_param, "maximum_ecut", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,ecut);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
double lattice[9];
|
||||
for(int i=0; i<9; i++) lattice[i]=(*alat)*at[i];
|
||||
hsize_t dims[]={3,3};
|
||||
dataspace = H5Screate_simple(2, dims, NULL);
|
||||
dataset = H5Dcreate(h_param, "lattice", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,lattice);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
H5Gclose(h_param);
|
||||
}
|
||||
|
||||
/* open mainbody:eigenstates */
|
||||
void F77_FUNC_(pwhdf_open_eigg,PWHDF_OPEN_EIGG)()
|
||||
{
|
||||
if(h_main>=0) H5Gclose(h_main);
|
||||
h_main = H5Gcreate(h_file,"eigenstates",0);
|
||||
}
|
||||
|
||||
/* close eigenstates */
|
||||
void F77_FUNC_(pwhdf_close_eigg,PWHDF_CLOSE_EIGG)()
|
||||
{
|
||||
if(h_main>=0) H5Gclose(h_main);
|
||||
h_main=-1;
|
||||
}
|
||||
|
||||
/* open twist# */
|
||||
void F77_FUNC_(pwhdf_open_twist,PWHDF_OPEN_TWIST)(const int* ik, const double *xk,
|
||||
const int* nband, const int* nspin)
|
||||
{
|
||||
char twistname[16];
|
||||
sprintf(twistname,"twist%i",(*ik)-1);
|
||||
if(h_twist>=0) H5Gclose(h_twist);
|
||||
h_twist = H5Gcreate(h_main,twistname,0);
|
||||
|
||||
/* write twist_angle */
|
||||
hsize_t dim=3;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_twist, "twist_angle", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,xk);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
if((xk[0]*xk[0]+xk[1]*xk[1]+xk[2]*xk[2]) < 1e-12)
|
||||
is_gamma=1;
|
||||
else
|
||||
is_gamma=0;
|
||||
|
||||
/* create band#/spin# groups so that H5Gopen can be used */
|
||||
for(int ib=0; ib<*nband; ib++)
|
||||
{
|
||||
char bandname[16];
|
||||
sprintf(bandname,"band%i",ib);
|
||||
hid_t h_band = H5Gcreate(h_twist,bandname,0);
|
||||
for(int ispin=0; ispin<*nspin; ispin++)
|
||||
{
|
||||
char spinname[16];
|
||||
sprintf(spinname,"spin%i",ispin);
|
||||
hid_t h_spin = H5Gcreate(h_band,spinname,0);
|
||||
H5Gclose(h_spin);
|
||||
}
|
||||
H5Gclose(h_band);
|
||||
}
|
||||
}
|
||||
/* close twist# */
|
||||
void F77_FUNC_(pwhdf_close_twist,PWHDF_CLOSE_TWIST)()
|
||||
{
|
||||
if(h_twist>=0) H5Gclose(h_twist);
|
||||
h_twist=-1;
|
||||
}
|
||||
|
||||
/* write eigen value and eigen vector for (ibnd, ispin) */
|
||||
void F77_FUNC_(pwhdf_write_band,PWHDF_WRITE_BAND)(const int* ibnd,
|
||||
const int* ispin, const double* e,
|
||||
const double* eigv, const int* ngtot)
|
||||
{
|
||||
char spinname[16];
|
||||
sprintf(spinname,"band%i/spin%i",(*ibnd)-1,(*ispin)-1);
|
||||
hid_t h_spin = H5Gopen(h_twist,spinname);
|
||||
hsize_t dim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_spin, "eigenvalue", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,e);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
hsize_t dims[2];
|
||||
dims[0] = *ngtot;
|
||||
dims[1] = 2;
|
||||
dataspace = H5Screate_simple(2, dims, NULL);
|
||||
dataset = H5Dcreate(h_spin, "eigenvector", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,eigv);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
H5Gclose(h_spin);
|
||||
}
|
||||
|
||||
/* open mainbody:eigenstates */
|
||||
void F77_FUNC_(pwhdf_open_eigr,PWHDF_OPEN_EIGR)(const int* nr1, const int* nr2, const int*nr3)
|
||||
{
|
||||
/* swap the order : CHECK THIS! */
|
||||
h_ngrid[0]=*nr1;
|
||||
h_ngrid[1]=*nr2;
|
||||
h_ngrid[2]=*nr3;
|
||||
h_ngridtot=(*nr1)*(*nr2)*(*nr3);
|
||||
char wfrname[16];
|
||||
sprintf(wfrname,"eigenstates_%i_%i_%i",h_ngrid[0],h_ngrid[1],h_ngrid[2]);
|
||||
if(h_main>=0) H5Gclose(h_main);
|
||||
h_main = H5Gcreate(h_file,wfrname,0);
|
||||
}
|
||||
|
||||
/* close twist# */
|
||||
void F77_FUNC_(pwhdf_close_eigr,PWHDF_CLOSE_EIGR)()
|
||||
{
|
||||
if(h_main>=0) H5Gclose(h_main);
|
||||
h_main=-1;
|
||||
}
|
||||
/* write eigen value and eigen vector for (ibnd, ispin) */
|
||||
void F77_FUNC_(pwhdf_write_wfr,PWHDF_WRITE_WFR)(const int* ibnd,
|
||||
const int* ispin, const double* e,
|
||||
const double* eigr, const int* use_complex)
|
||||
{
|
||||
char spinname[16];
|
||||
sprintf(spinname,"band%i/spin%i",(*ibnd)-1,(*ispin)-1);
|
||||
/*sprintf(spinname,"band_%i",(*ibnd)-1);*/
|
||||
hid_t h_spin = H5Gopen(h_twist,spinname);
|
||||
|
||||
/* write eigenvalue */
|
||||
hsize_t dim=1;
|
||||
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
|
||||
hid_t dataset= H5Dcreate(h_spin, "eigenvalue", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,e);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
hsize_t dims_out=(*use_complex)?4:3;
|
||||
hsize_t dims[4];
|
||||
dims[0] = h_ngrid[0];
|
||||
dims[1] = h_ngrid[1];
|
||||
dims[2] = h_ngrid[2];
|
||||
dims[3] = 2;
|
||||
dataspace = H5Screate_simple(dims_out, dims, NULL);
|
||||
dataset = H5Dcreate(h_spin, "eigenvector", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,eigr);
|
||||
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
H5Gclose(h_spin);
|
||||
}
|
||||
|
||||
/* write eigen value and eigen vector for (ibnd, ispin) */
|
||||
void F77_FUNC_(pwhdf_write_rho,PWHDF_WRITE_RHO)(const double* rho, const double* rhog, int ngm)
|
||||
{
|
||||
/* write eigenvector */
|
||||
hsize_t dims[3];
|
||||
dims[0] = h_ngrid[0];
|
||||
dims[1] = h_ngrid[1];
|
||||
dims[2] = h_ngrid[2];
|
||||
hid_t dataspace = H5Screate_simple(3, dims, NULL);
|
||||
hid_t dataset = H5Dcreate(h_file, "chargedensity_r", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,rho);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
|
||||
/*
|
||||
hsize_t gdims[2];
|
||||
gdims[0]=ngm;
|
||||
gdims[1]=2;
|
||||
dataspace = H5Screate_simple(2, gdims, NULL);
|
||||
dataset = H5Dcreate(h_file, "chargedensity_g", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
|
||||
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,rhog);
|
||||
H5Sclose(dataspace);
|
||||
H5Dclose(dataset);
|
||||
*/
|
||||
|
||||
/* testing with paraview/vtk
|
||||
if(is_gamma)
|
||||
{
|
||||
char vtkname[32];
|
||||
sprintf(vtkname,"band%i.vtk",(*ibnd)-1);
|
||||
FILE *vtk=fopen(vtkname,"w");
|
||||
|
||||
fprintf(vtk,"# vtk DataFile Version 3.0\n");
|
||||
fprintf(vtk,"vtk output\n");
|
||||
fprintf(vtk,"ASCII\n");
|
||||
fprintf(vtk,"DATASET STRUCTURED_POINTS\n");
|
||||
fprintf(vtk,"DIMENSIONS %i %i %i\n",h_ngrid[0],h_ngrid[1],h_ngrid[2]);
|
||||
fprintf(vtk,"ORIGIN 0 0 0\n");
|
||||
fprintf(vtk,"SPACING 1 1 1\n");
|
||||
fprintf(vtk,"\nPOINT_DATA %i\n",h_ngridtot);
|
||||
fprintf(vtk,"SCALARS scalars float\n");
|
||||
fprintf(vtk,"LOOKUP_TABLE default\n");
|
||||
|
||||
for(int i=0,i2=0; i<h_ngridtot;i+=10)
|
||||
{
|
||||
for(int j=0; j<10; j++,i2+=2) fprintf(vtk,"%12.6e ",eigr[i2]*eigr[i2]);
|
||||
fprintf(vtk,"\n");
|
||||
}
|
||||
fprintf(vtk,"\n");
|
||||
fclose(vtk);
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include "OhmmsPETE/OhmmsVector.h"
|
||||
#include "Numerics/OneDimGridBase.h"
|
||||
#include "Numerics/OneDimCubicSpline.h"
|
||||
|
||||
#define FUNCTION(r) cos(r)
|
||||
#define DFUNCTION(r) sin(r)
|
||||
//#define USE_PBC
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double ri = 0.0;
|
||||
double rf = 1.0;
|
||||
int npts = 101;
|
||||
const double nk=2;
|
||||
const double twopi = 8.0*atan(1.0)*nk;
|
||||
LinearGrid<double> agrid;
|
||||
agrid.set(ri,rf,npts);
|
||||
#if defined(USE_PBC)
|
||||
typedef OneDimCubicSplinePBC<double> OrbitalType;
|
||||
#else
|
||||
typedef OneDimCubicSplineFirst<double> OrbitalType;
|
||||
#endif
|
||||
OrbitalType aorb(&agrid);
|
||||
aorb.resize(agrid.size());
|
||||
for(int i=0; i<agrid.size(); i++)
|
||||
{
|
||||
aorb(i)=FUNCTION(twopi*agrid(i));
|
||||
}
|
||||
aorb.spline(0,twopi*DFUNCTION(twopi*agrid.rmin()),agrid.size()-1, twopi*DFUNCTION(twopi*agrid.rmax()));
|
||||
std::string fname("testpbc.dat");
|
||||
std::ofstream dfile(fname.c_str());
|
||||
dfile.setf(std::ios::scientific, std::ios::floatfield);
|
||||
dfile.setf(std::ios::left,std::ios::adjustfield);
|
||||
dfile.precision(15);
|
||||
const double c1=1.0/twopi;
|
||||
const double c2=c1*c1;
|
||||
double du,d2u,_r,_rinv,y;
|
||||
#if defined(USE_PBC)
|
||||
for(int ig=agrid.size()/2; ig<agrid.size() ; ig++)
|
||||
{
|
||||
_r = agrid(ig)+0.5*agrid.dr(ig)-agrid.rmax();
|
||||
_rinv = 1.0/_r;
|
||||
//aorb.setgrid(_r);
|
||||
y=aorb.evaluate(_r,_rinv,du,d2u);
|
||||
dfile << std::setw(30) << _r << std::setw(30) << FUNCTION(twopi*_r) << std::setw(30) << y << std::setw(30) << du*c1 << std::setw(3) << d2u*c2 << std::endl;
|
||||
}
|
||||
#endif
|
||||
for(int ig=0; ig<agrid.size()-1; ig++)
|
||||
{
|
||||
_r = agrid(ig)+0.5*agrid.dr(ig);
|
||||
_rinv = 1.0/_r;
|
||||
//aorb.setgrid(_r);
|
||||
y=aorb.evaluate(_r,_rinv,du,d2u);
|
||||
dfile << std::setw(30) << _r << std::setw(30) << FUNCTION(twopi*_r) << std::setw(30) << y
|
||||
<< std::setw(30) << du*c1 << std::setw(3) << d2u*c2 << std::endl;
|
||||
}
|
||||
#if defined(USE_PBC)
|
||||
for(int ig=0; ig<agrid.size()/2; ig++)
|
||||
{
|
||||
_r = agrid(ig)+0.5*agrid.dr(ig)+agrid.rmax();
|
||||
_rinv = 1.0/_r;
|
||||
//aorb.setgrid(_r);
|
||||
y=aorb.evaluate(_r,_rinv,du,d2u);
|
||||
dfile << std::setw(30) << _r << std::setw(30) << FUNCTION(twopi*_r) << std::setw(30) << y << std::setw(30) << du*c1 << std::setw(3) << d2u*c2 << std::endl;
|
||||
}
|
||||
#endif
|
||||
dfile << std::endl;
|
||||
return 0;
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include "OhmmsData/OhmmsElementBase.h"
|
||||
#include "Numerics/HDFSTLAttrib.h"
|
||||
#include "Numerics/TriCubicSplineT.h"
|
||||
#include "Numerics/HDFTriCubicSpline.h"
|
||||
#include "Utilities/Clock.h"
|
||||
|
||||
struct TestFunc
|
||||
{
|
||||
|
||||
double k0,k1,k2;
|
||||
double d2factor;
|
||||
|
||||
TestFunc(int nk0=1, int nk1=1, int nk2=1)
|
||||
{
|
||||
const double twopi = 8.0*atan(1.0);
|
||||
k0=twopi*static_cast<double>(nk0);
|
||||
k1=twopi*static_cast<double>(nk1);
|
||||
k2=twopi*static_cast<double>(nk2);
|
||||
d2factor = -(k0*k0+k1*k1+k2*k2);
|
||||
}
|
||||
|
||||
//inline double operator()(const TinyVector<double,3>& pos) {
|
||||
// return sin(k0*pos[0])*sin(k1*pos[1])*sin(k2*pos[2]);
|
||||
//}
|
||||
//inline double operator()(double x, double y, double z) {
|
||||
// return sin(k0*x)*sin(k1*y)*sin(k2*z);
|
||||
//}
|
||||
//
|
||||
inline double f(const TinyVector<double,3>& pos)
|
||||
{
|
||||
return sin(k0*pos[0])*sin(k1*pos[1])*sin(k2*pos[2]);
|
||||
}
|
||||
|
||||
inline double f(double x, double y, double z)
|
||||
{
|
||||
return sin(k0*x)*sin(k1*y)*sin(k2*z);
|
||||
}
|
||||
|
||||
inline double d2f(const TinyVector<double,3>& pos)
|
||||
{
|
||||
return d2factor*f(pos);
|
||||
}
|
||||
|
||||
inline double d2f(double x, double y, double z)
|
||||
{
|
||||
return d2factor*f(x,y,z);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct ComboFunc
|
||||
{
|
||||
|
||||
std::vector<double> C;
|
||||
std::vector<TestFunc*> F;
|
||||
|
||||
ComboFunc() {}
|
||||
void push_back(double c, TestFunc* fn)
|
||||
{
|
||||
C.push_back(c);
|
||||
F.push_back(fn);
|
||||
}
|
||||
|
||||
|
||||
inline double f(double x, double y, double z)
|
||||
{
|
||||
double res=0;
|
||||
for(int i=0; i<C.size(); i++)
|
||||
res += C[i]*F[i]->f(x,y,z);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline double d2f(double x, double y, double z)
|
||||
{
|
||||
double res=0;
|
||||
for(int i=0; i<C.size(); i++)
|
||||
res += C[i]*F[i]->d2f(x,y,z);
|
||||
return res;
|
||||
}
|
||||
|
||||
inline double f(const TinyVector<double,3>& pos)
|
||||
{
|
||||
return f(pos[0],pos[1],pos[2]);
|
||||
}
|
||||
|
||||
inline double d2f(const TinyVector<double,3>& pos)
|
||||
{
|
||||
return d2f(pos[0],pos[1],pos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double ri = 0.0;
|
||||
double rf = 1.0;
|
||||
std::vector<int> npts(3);
|
||||
npts[0]=51;
|
||||
npts[1]=51;
|
||||
npts[2]=51;
|
||||
double xcut=0.23;
|
||||
double ycut=0.67;
|
||||
const int nk0=1;
|
||||
const int nk1=1;
|
||||
const int nk2=1;
|
||||
//Create one-dimensional grids for three orthogonal directions
|
||||
typedef LinearGrid<double> GridType;
|
||||
GridType gridX, gridY, gridZ;
|
||||
gridX.set(ri,rf,npts[0]);
|
||||
gridY.set(ri,rf,npts[1]);
|
||||
gridZ.set(ri,rf,npts[2]);
|
||||
//Create an analytic function for assignment
|
||||
ComboFunc infunc;
|
||||
infunc.push_back(0.5,new TestFunc(1,1,1));
|
||||
//infunc.push_back(0.3,new TestFunc(1,1,2));
|
||||
//infunc.push_back(0.1,new TestFunc(1,2,1));
|
||||
//infunc.push_back(0.01,new TestFunc(2,1,1));
|
||||
//infunc.push_back(0.01,new TestFunc(2,2,1));
|
||||
//infunc.push_back(0.001,new TestFunc(2,1,2));
|
||||
//infunc.push_back(0.001,new TestFunc(2,2,2));
|
||||
//infunc.push_back(0.001,new TestFunc(5,5,5));
|
||||
//infunc.push_back(-0.3,new TestFunc(7,2,3));
|
||||
//infunc.push_back(0.01,new TestFunc(7,7,7));
|
||||
//infunc.push_back(0.001,new TestFunc(5,5,5));
|
||||
//Write to an array
|
||||
std::vector<double> inData(npts[0]*npts[1]*npts[2]);
|
||||
std::vector<double>::iterator it(inData.begin());
|
||||
Pooma::Clock timer;
|
||||
timer.start();
|
||||
//Assign the values
|
||||
for(int ix=0; ix<npts[0]; ix++)
|
||||
{
|
||||
double x(gridX(ix));
|
||||
for(int iy=0; iy<npts[1]; iy++)
|
||||
{
|
||||
double y(gridY(iy));
|
||||
for(int iz=0; iz<npts[2]; iz++)
|
||||
{
|
||||
(*it)=infunc.f(x,y,gridZ(iz));
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
timer.stop();
|
||||
std::cout << "Time to evaluate " << timer.cpu_time() << std::endl;
|
||||
//Test TriCubicSplineT function
|
||||
//Create XYZCubicGrid
|
||||
XYZCubicGrid<double> grid3(&gridX,&gridY,&gridZ);
|
||||
//Create a TriCubicSpline with PBC: have to think more about fixed-boundary conditions
|
||||
TriCubicSplineT<double> aorb(&grid3);
|
||||
//Reset the coefficients
|
||||
aorb.reset(inData.begin(), inData.end());
|
||||
double lap,val;
|
||||
TinyVector<double,3> grad;
|
||||
//aorb.reset();
|
||||
//Write for vtk ImageData
|
||||
std::string fname("spline3d.vti");
|
||||
std::ofstream dfile(fname.c_str());
|
||||
dfile.setf(std::ios::scientific, std::ios::floatfield);
|
||||
dfile.setf(std::ios::left,std::ios::adjustfield);
|
||||
dfile.precision(10);
|
||||
dfile << "<?xml version=\"1.0\"?>" << std::endl;
|
||||
dfile << "<VTKFile type=\"ImageData\" version=\"0.1\">" << std::endl;
|
||||
dfile << " <ImageData WholeExtent=\"0 " << npts[0]-2 << " 0 " << npts[1]-2 << " 0 " << npts[2]-2
|
||||
<< "\" Origin=\"0 0 0\" Spacing=\"1 1 1\">"<< std::endl;
|
||||
dfile << " <Piece Extent=\"0 " << npts[0]-2 << " 0 " << npts[1]-2 << " 0 " << npts[2]-2 << "\">" << std::endl;
|
||||
dfile << " <PointData Scalars=\"wfs\">" << std::endl;
|
||||
dfile << " <DataArray type=\"Float32\" Name=\"wfs\">" << std::endl;
|
||||
timer.start();
|
||||
int ng=0;
|
||||
for(int ix=0; ix<npts[0]-1; ix++)
|
||||
{
|
||||
double x(gridX(ix));
|
||||
for(int iy=0; iy<npts[1]-1; iy++)
|
||||
{
|
||||
double y(gridY(iy));
|
||||
for(int iz=0; iz<npts[2]-1; iz++, ng++)
|
||||
{
|
||||
TinyVector<double,3> p(x,y,gridZ(iz));
|
||||
//aorb.setgrid(p);
|
||||
//Timing with the std::ofstream is not correct.
|
||||
//Uncomment the line below and comment out the next two line.
|
||||
//double t=aorb.evaluate(p,grad,lap);
|
||||
dfile << std::setw(20) << aorb.evaluate(p,grad,lap);
|
||||
if(ng%5 == 4)
|
||||
dfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
timer.stop();
|
||||
std::cout << "Time to evaluate with spline " << timer.cpu_time() << std::endl;
|
||||
dfile << " </DataArray>" << std::endl;
|
||||
dfile << " </PointData>" << std::endl;
|
||||
dfile << " </Piece>" << std::endl;
|
||||
dfile << " </ImageData>" << std::endl;
|
||||
dfile << "</VTKFile>" << std::endl;
|
||||
hid_t h_file = H5Fcreate("spline3d.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
|
||||
HDFAttribIO<std::vector<double> > dump(inData,npts);
|
||||
dump.write(h_file,"orb0000");
|
||||
HDFAttribIO<TriCubicSplineT<double> > dump1(aorb);
|
||||
dump1.write(h_file,"spline0000");
|
||||
H5Fclose(h_file);
|
||||
//double lap;
|
||||
//TinyVector<double,3> grad;
|
||||
//for(int k=0; k<nptY-1; k++) {
|
||||
// //TinyVector<double,3> p(xcut,ycut,gridZ(k)+0.11*gridZ.dr(k));
|
||||
// TinyVector<double,3> p(xcut,gridY(k)+0.11*gridY.dr(k),ycut);
|
||||
// aorb.setgrid(p);
|
||||
// double y=aorb.evaluate(p,grad,lap);
|
||||
// dfile << std::setw(30) << p[1] << std::setw(30) << infunc.f(p) << std::setw(30) << y << std::setw(30) << infunc.d2f(p) << std::setw(30) << lap << std::endl;
|
||||
//}
|
||||
return 0;
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include "OhmmsData/OhmmsElementBase.h"
|
||||
#include "Numerics/HDFSTLAttrib.h"
|
||||
#include "Numerics/TriCubicSplineT.h"
|
||||
#include "Numerics/HDFTriCubicSpline.h"
|
||||
#include "Utilities/Clock.h"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Pooma::Clock timer;
|
||||
double ri = 0.0;
|
||||
double rf = 1.0;
|
||||
std::vector<int> npts(3);
|
||||
npts[0]=51;
|
||||
npts[1]=51;
|
||||
npts[2]=51;
|
||||
double xcut=0.23;
|
||||
double ycut=0.67;
|
||||
const int nk0=1;
|
||||
const int nk1=1;
|
||||
const int nk2=1;
|
||||
//Create one-dimensional grids for three orthogonal directions
|
||||
typedef LinearGrid<double> GridType;
|
||||
GridType gridX, gridY, gridZ;
|
||||
gridX.set(ri,rf,npts[0]);
|
||||
gridY.set(ri,rf,npts[1]);
|
||||
gridZ.set(ri,rf,npts[2]);
|
||||
//Write to an array
|
||||
std::vector<double> inData(npts[0]*npts[1]*npts[2]);
|
||||
timer.start();
|
||||
hid_t h_file = H5Fopen("spline3d.h5",H5F_ACC_RDWR,H5P_DEFAULT);
|
||||
HDFAttribIO<std::vector<double> > dummy(inData,npts);
|
||||
dummy.read(h_file,"orb0000");
|
||||
H5Fclose(h_file);
|
||||
timer.stop();
|
||||
std::cout << "Time to read image data " << timer.cpu_time() << std::endl;
|
||||
//Create XYZCubicGrid
|
||||
XYZCubicGrid<double> grid3(&gridX,&gridY,&gridZ);
|
||||
//Create a TriCubicSpline with PBC: have to think more about fixed-boundary conditions
|
||||
TriCubicSplineT<double> aorb(&grid3);
|
||||
//Reset the coefficients
|
||||
timer.start();
|
||||
aorb.reset(inData.begin(), inData.end());
|
||||
timer.stop();
|
||||
std::cout << "Time to set up spline coefficients " << timer.cpu_time() << std::endl;
|
||||
double lap,val;
|
||||
TinyVector<double,3> grad;
|
||||
//vector<double>::iterator it(inData.begin());
|
||||
timer.start();
|
||||
for(int ix=0; ix<npts[0]-1; ix++)
|
||||
{
|
||||
double x(gridX(ix));
|
||||
for(int iy=0; iy<npts[1]-1; iy++)
|
||||
{
|
||||
double y(gridY(iy));
|
||||
int ng = npts[2]*(iy+ix*npts[1]);
|
||||
for(int iz=0; iz<npts[2]-1; iz++)
|
||||
{
|
||||
TinyVector<double,3> p(x,y,gridZ(iz));
|
||||
//aorb.setgrid(p);
|
||||
inData[ng++]=aorb.evaluate(p,grad,lap);
|
||||
//(*it) = aorb.evaluate(p,grad,lap); ++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
timer.stop();
|
||||
std::cout << "Time to evaluate the values " << timer.cpu_time() << std::endl;
|
||||
timer.start();
|
||||
h_file = H5Fcreate("spline3d_writeback.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
|
||||
HDFAttribIO<std::vector<double> > dump(inData,npts);
|
||||
dump.write(h_file,"orb0000");
|
||||
HDFAttribIO<TriCubicSplineT<double> > dump1(aorb);
|
||||
dump1.write(h_file,"spline0000");
|
||||
H5Fclose(h_file);
|
||||
timer.stop();
|
||||
std::cout << "Time to write to hdf5 " << timer.cpu_time() << std::endl;
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,60 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "OhmmsPETE/TinyVector.h"
|
||||
#include "Numerics/SphericalTensor.h"
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int l=5;
|
||||
TinyVector<double,3> pos(0.1,0.3,-0.45), deltax(0.0001,0.0,0.0), deltay(0.0,0.0001,0.0), deltaz(0.0,0.0,0.0001), tpos, g;
|
||||
if(argc>1)
|
||||
l = atoi(argv[1]);
|
||||
if(argc>4)
|
||||
{
|
||||
pos[0] = atof(argv[2]);
|
||||
pos[1] = atof(argv[3]);
|
||||
pos[2] = atof(argv[4]);
|
||||
}
|
||||
SphericalTensor<double,TinyVector<double,3> > Y1(l,true), Y2(l,true), Yp(l,true), Ym(l,true);
|
||||
Y1.evaluate(pos);
|
||||
std::cout.setf(std::ios::scientific, std::ios::floatfield);
|
||||
for(int lm=0; lm<Y1.size(); lm++)
|
||||
{
|
||||
std::cout << lm << std::endl;
|
||||
std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm]
|
||||
<< std::setprecision(12) << Y1.gradYlm[lm] << std::endl;
|
||||
//std::cout << std::setw(20) << std::setprecision(12) << Y2.Ylm[lm]
|
||||
// << std::setprecision(12) << Y2.gradYlm[lm] << std::endl;
|
||||
}
|
||||
// for(int lm=0; lm<Y1.size(); lm++) {
|
||||
// tpos = pos+deltax; Yp.evaluate(tpos);
|
||||
// tpos = pos-deltax; Ym.evaluate(tpos);
|
||||
// g[0] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
|
||||
// tpos = pos+deltay; Yp.evaluate(tpos);
|
||||
// tpos = pos-deltay; Ym.evaluate(tpos);
|
||||
// g[1] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
|
||||
// tpos = pos+deltaz; Yp.evaluate(tpos);
|
||||
// tpos = pos-deltaz; Ym.evaluate(tpos);
|
||||
// g[2] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002;
|
||||
// std::cout << lm << std::endl;
|
||||
// std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm]
|
||||
// << std::setprecision(12) << Y1.gradYlm[lm] - g << std::endl;
|
||||
// }
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
#// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
#// See LICENSE file in top directory for details.
|
||||
#//
|
||||
#// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
#//
|
||||
#// File developed by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp.
|
||||
#// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
#//
|
||||
#// File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp.
|
||||
#//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
PROJECT(sqd)
|
||||
|
||||
#CONFIGURE_FILE(${hf_SOURCE_DIR}/../Configuration.h.in
|
||||
# ${hf_SOURCE_DIR}/../Configuration.h)
|
||||
|
||||
#INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
|
||||
#INCLUDE(${CMAKE_ROOT}/Modules/FindQt.cmake)
|
||||
#INCLUDE(${PROJECT_CMAKE}/FindQwt.cmake)
|
||||
|
||||
SET(QT_FOUND 0)
|
||||
|
||||
IF(QT_FOUND)
|
||||
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${QT_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_PREFIX_INSTALL}/include)
|
||||
INCLUDE_DIRECTORIES(${QWT_INCLUDE_DIR})
|
||||
|
||||
ADD_DEFINITIONS(-DHAVE_QT)
|
||||
LINK_LIBRARIES(${QWT_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||
ENDIF(QT_FOUND)
|
||||
|
||||
SET(HFSRCS
|
||||
../Numerics/Clebsch_Gordan.cpp
|
||||
SphericalPotential/RadialPotential.cpp
|
||||
SphericalPotential/ZOverRPotential.cpp
|
||||
SphericalPotential/HarmonicPotential.cpp
|
||||
SphericalPotential/StepPotential.cpp
|
||||
SphericalPotential/SJPseudoPotential.cpp
|
||||
SphericalPotential/SHEGPotential.cpp
|
||||
HartreeFock.cpp
|
||||
HartreeFock.IO.cpp
|
||||
HFApp.cpp
|
||||
)
|
||||
|
||||
IF(QT_FOUND)
|
||||
SET(qwtheaders
|
||||
NxyCurvePlot.h
|
||||
XmlTreeBuilder.h
|
||||
SQDFrame.h
|
||||
)
|
||||
|
||||
SET(qwtsources
|
||||
NxyCurvePlot.cpp
|
||||
XmlTreeBuilder.cpp
|
||||
SQDFrame.cpp
|
||||
)
|
||||
|
||||
QT_WRAP_CPP(sqd_MOC_SRCS qwtsources qwtheaders)
|
||||
|
||||
LINK_LIBRARIES(${FORTRAN_LIBS})
|
||||
ADD_EXECUTABLE(sqd ${HFSRCS} ${qwtsources})
|
||||
TARGET_LINK_LIBRARIES(sqd qmcbase qmcutil)
|
||||
ELSE(QT_FOUND)
|
||||
SET(HFSRCS ${HFSRCS} SQDFrame.cpp)
|
||||
ADD_EXECUTABLE(sqd ${HFSRCS})
|
||||
TARGET_LINK_LIBRARIES(sqd qmcbase qmcutil)
|
||||
FOREACH(l ${QMC_UTIL_LIBS})
|
||||
TARGET_LINK_LIBRARIES(sqd ${l})
|
||||
ENDFOREACH(l ${QMC_UTIL_LIBS})
|
||||
TARGET_LINK_LIBRARIES(sqd ${MPI_LIBRARY})
|
||||
ENDIF(QT_FOUND)
|
|
@ -1,126 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "SQD/SQDFrame.h"
|
||||
#include "OhmmsApp/ProjectData.h"
|
||||
|
||||
#ifdef HAVE_QT
|
||||
#include <qapplication.h>
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
OhmmsInfo Welcome("sqd");
|
||||
QApplication a( argc, argv );
|
||||
if(argc<2)
|
||||
{
|
||||
std::cerr << "Usage: sqd file-name [-nox]" << std::endl;
|
||||
std::cerr << "Use -nox if you like to skip plotting the results." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool showplot = true;
|
||||
int i=1;
|
||||
while(i<argc)
|
||||
{
|
||||
std::string arg(argv[i]);
|
||||
if(arg == "-nox")
|
||||
{
|
||||
showplot = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
SQDFrame *w = new SQDFrame;
|
||||
a.setMainWidget( w );
|
||||
if(w->solve(argv[1]))
|
||||
{
|
||||
w->show();
|
||||
return a.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
OhmmsInfo Welcome("sqd");
|
||||
if(argc<2)
|
||||
{
|
||||
std::cerr << "Usage: sqd file-name [-nox]" << std::endl;
|
||||
std::cerr << "Use -nox if you like to skip plotting the results." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
SQDFrame sqd;
|
||||
if(sqd.solve(argv[1]))
|
||||
{
|
||||
sqd.show();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
SQDFrame::solve(const char* fname)
|
||||
{
|
||||
xmlNsPtr ns=NULL;
|
||||
// build an XML tree from a the file;
|
||||
m_doc = xmlParseFile(fname);
|
||||
if (m_doc == NULL)
|
||||
return false;
|
||||
//using XPath instead of recursive search
|
||||
xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc);
|
||||
// Check the document is of the right kind
|
||||
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
fprintf(stderr,"empty document\n");
|
||||
xmlFreeDoc(m_doc);
|
||||
return false;
|
||||
}
|
||||
if (xmlStrcmp(cur->name, (const xmlChar *) "simulation"))
|
||||
{
|
||||
fprintf(stderr,"document of the wrong type, root node != simulation\n");
|
||||
xmlFreeDoc(m_doc);
|
||||
return false;
|
||||
}
|
||||
//project description, assign id and series
|
||||
qmcplusplus::ProjectData myProject;
|
||||
xmlXPathObjectPtr result
|
||||
= xmlXPathEvalExpression((const xmlChar*)"//project",m_context);
|
||||
if(xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
WARNMSG("Project is not defined")
|
||||
myProject.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
myProject.put(result->nodesetval->nodeTab[0]);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
using namespace ohmmshf;
|
||||
HFSolver = new HartreeFock(Pot,Psi);
|
||||
bool success = HFSolver->put(cur);
|
||||
if(!success)
|
||||
{
|
||||
ERRORMSG("The input file does not conform. Exit")
|
||||
return false;
|
||||
}
|
||||
HFSolver->setRoot(myProject.CurrentRoot());
|
||||
success = HFSolver->solve();
|
||||
xmlFreeDoc(m_doc);
|
||||
xmlCleanupParser();
|
||||
return success;
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "SQD/SQDFrame.h"
|
||||
#include <qapplication.h>
|
||||
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
QApplication a( argc, argv );
|
||||
if(argc<2)
|
||||
{
|
||||
std::cerr << "Usage: sqd file-name [-nox]" << std::endl;
|
||||
std::cerr << "Use -nox if you like to skip plotting the results." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
bool showplot = true;
|
||||
int i=1;
|
||||
while(i<argc)
|
||||
{
|
||||
std::string arg(argv[i]);
|
||||
if(arg == "-nox")
|
||||
{
|
||||
showplot = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
SQDFrame *w = new SQDFrame;
|
||||
a.setMainWidget( w );
|
||||
w->solve(argv[1]);
|
||||
w->show();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
void
|
||||
SQDFrame::solve(const char* fname)
|
||||
{
|
||||
using namespace ohmmshf;
|
||||
using namespace xmlpp;
|
||||
myParser.parse_file(fname);
|
||||
docRoot = myParser.get_document()->get_root_node(); //deleted by DomParser.
|
||||
parseXMLFile(Pot,Psi,elementType,potType,gridType,docRoot);
|
||||
HFSolver = new HartreeFock(Pot,Psi,docRoot);
|
||||
HFSolver->setRoot(fname);
|
||||
HFSolver->solve(potType,gridType,Psi.size());
|
||||
std::ofstream fout("test.dat");
|
||||
for(int ig; ig<Psi.m_grid->size(); ig++)
|
||||
{
|
||||
for(int orb=0; orb<Psi.NumUniqueOrb; orb++)
|
||||
{
|
||||
fout << std::setw(15) << Psi(orb,ig);
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
Psi.print(elementType);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_MAIN_HFCONFIGURATION_H
|
||||
#define OHMMS_MAIN_HFCONFIGURATION_H
|
||||
/*!\mainpage AtomicHF
|
||||
*\author Jeongnim Kim
|
||||
*\author Jordan Vincent
|
||||
*
|
||||
*\section intro_sec Introduction
|
||||
*
|
||||
*Package to solve the Hartree-Fock equations for a centered (atomic-like)
|
||||
*spherically symmetric potential using the Numerov algorithm.
|
||||
*
|
||||
*\section main_sec Schrodinger Equation
|
||||
*
|
||||
*The single-particle Schrodinger Equation involving the mass
|
||||
\f$m\f$ and an external potential \f$V(\bf r)\f$,
|
||||
\f[
|
||||
\left[-\frac{1}{2m}\nabla^2 + V(\bf r)\right]\Psi(\bf r) = E \Psi(\bf r),
|
||||
\f]
|
||||
*is reduced to a Radial Schrodinger Equation
|
||||
\f[
|
||||
\left\{
|
||||
\frac{1}{2m}\frac{d^{2}}{dr^{2}}
|
||||
+\left[
|
||||
E-V(r)-\frac{l(l+1)}{2mr^{2}}
|
||||
\right]
|
||||
\right\} u_{l}(r)=0,
|
||||
\f]
|
||||
*for a spherically symmetric potentials \f$V(r)\f$ and the wave functions are
|
||||
\f[
|
||||
\Psi({\bf r}) = \sum_{l=0}^{\infty}\sum_{m=-l}^{l} A_{lm}
|
||||
\frac{u_{l}(r)}{r}Y_{l}^{m}(\theta,\phi).
|
||||
\f]
|
||||
*AtomicHF uses the Numerov algorithm to solve the Radial Schrodinger Equation.
|
||||
*Several external radial potentials are implemented which are defined
|
||||
*in \ref RadialPotential.
|
||||
*
|
||||
*Within Hartree-Fock approximation, the Schrodinger Equation is generalized
|
||||
*to include electron-electron Coulomb and exchange interactions (Hartree
|
||||
*and exchange terms). Hartree and Exchange terms are implemented in
|
||||
*HartreePotential and ExchangePotential, while the external potential and
|
||||
*kinetic energy terms are handled by ZOverRPotential,
|
||||
*HarmonicPotential, SJPseudopotential specific for the physical model.
|
||||
*
|
||||
*\section numerov_sec Numemov algorithm
|
||||
*
|
||||
*Numerov algorithm (B. Numerov, Publ. de l'observ. astrophsique
|
||||
*central de Russie, vol. 2, p 188, 1933.) is based on a two-step, fifth order
|
||||
*predictor-corrector method for a second-order ordinary differential equation
|
||||
*of type \f[\frac{d^2y}{dx^2} + k^2(x)y = S(x).\f]
|
||||
*Utilizing Taylor expansions for \f$x\f$, the solution is obtained by
|
||||
*recursively integrating forward in x as
|
||||
\f[
|
||||
(1+\frac{h^2}{12}k^2_{n+2})y_{n+2} -
|
||||
2(1-\frac{5h^2}{12}k^2_{n+1})y_{n+1} + (1+\frac{h^2}{12}k^2_n)y_n =
|
||||
\frac{h^2}{12}(S_{n+2}+10S_{n+1}+S_n) + \mathcal{O}(h^6).
|
||||
\f]
|
||||
*Numerov algorithm uses a uniform linear grid.
|
||||
Therefore, a transformation function is used to handle
|
||||
- transformations of variables between the physical grid to Numerov grid
|
||||
- cusp conditions or boundary conditions
|
||||
- range of the eigen values
|
||||
*
|
||||
*Any grid type can be used as far as the source functor can transform
|
||||
*the original grid variable to a uniform grid on \f$x\f$.
|
||||
*
|
||||
*\section hf_sec Hartree-Fock method
|
||||
*
|
||||
*Short description of HF method here.
|
||||
*
|
||||
*\section app_sec How to run AtomicHF code
|
||||
*
|
||||
*/
|
||||
#include "Configuration.h"
|
||||
#include "SQD/YlmRnlSet.h"
|
||||
/**@namespace ohmmshf
|
||||
*@brief Define basic data types for the applications.
|
||||
*
|
||||
* In order to reduce complier-time complexity and to enable switching
|
||||
* between CPLUSPLUS libraries for array and expression template,
|
||||
* basic data types are defined.
|
||||
*/
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**Trait class for spherical orbitals
|
||||
*
|
||||
*This class defines the data types to represent the spherical potential and wave functions.
|
||||
*/
|
||||
struct SphericalOrbitalTraits
|
||||
{
|
||||
|
||||
///@typedef the basis set type
|
||||
typedef YlmRnlSet<double> BasisSetType;
|
||||
|
||||
///@typedef the type of value: double
|
||||
typedef BasisSetType::value_type value_type;
|
||||
|
||||
///@typedef the type of radial grids
|
||||
typedef BasisSetType::RadialGrid_t RadialGrid_t;
|
||||
|
||||
///@typedef the type of radial orbitals
|
||||
typedef BasisSetType::RadialOrbital_t RadialOrbital_t;
|
||||
|
||||
///@typedef the type of radial orbital set
|
||||
typedef BasisSetType::RadialOrbitalSet_t RadialOrbitalSet_t;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,439 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include "SQD/HFConfiguration.h"
|
||||
#include "Numerics/Clebsch_Gordan.h"
|
||||
#include "SQD/fillshells.h"
|
||||
#include "SQD/SphericalPotential/ZOverRPotential.h"
|
||||
#include "SQD/SphericalPotential/HarmonicPotential.h"
|
||||
#include "SQD/SphericalPotential/StepPotential.h"
|
||||
#include "SQD/SphericalPotential/SJPseudoPotential.h"
|
||||
#include "SQD/SphericalPotential/SHEGPotential.h"
|
||||
#include "SQD/HartreeFock.h"
|
||||
#include "OhmmsData/ParameterSet.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
#include "Utilities/OhmmsInfo.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/** The contructor.
|
||||
*@param pot the potential
|
||||
* @param psi the wavefunction
|
||||
*/
|
||||
HartreeFock::HartreeFock(RadialPotentialSet& pot,
|
||||
SphericalOrbitalTraits::BasisSetType& psi):
|
||||
Pot(pot), Psi(psi),
|
||||
num_closed_shells(0),
|
||||
maxiter(1000), eig_tol(1e-12),
|
||||
scf_tol(1e-8), ratio(0.35),
|
||||
GridType("none"),
|
||||
grid_ptr(NULL), orb_ptr(NULL),
|
||||
pot_ptr(NULL), myGrid(0) { }
|
||||
|
||||
/** Sets the root for all output files.
|
||||
*@param aroot the root for all output files
|
||||
*/
|
||||
|
||||
void HartreeFock::setRoot(const std::string& aroot)
|
||||
{
|
||||
RootFileName = aroot;
|
||||
LogFileName = RootFileName + ".log";
|
||||
}
|
||||
|
||||
/** Set the parameters for the eigen solver
|
||||
*@param q the current xml node which contains the parameter definitions for the eigen solver
|
||||
*@return true if successful
|
||||
*
|
||||
*Available parameters
|
||||
<ul>
|
||||
<li> max_iter, the maximum self-consistent iterations, default=1000
|
||||
<li> eig_tol, the eigen-value tolerance, default = \f$1 e^{-12}\f$
|
||||
<li> en_tol, the tolerance of the self-consistent loops,
|
||||
default = \f$1 e^{-8}\f$
|
||||
<li> mix_ratio, the mixing ratio of the charge density, default = 0.35
|
||||
</ul>
|
||||
*/
|
||||
bool HartreeFock::put(xmlNodePtr d_root)
|
||||
{
|
||||
xmlNodePtr cur = NULL;
|
||||
//using XPath instead of recursive search
|
||||
xmlXPathContextPtr m_context = xmlXPathNewContext(d_root->doc);
|
||||
xmlXPathObjectPtr result = xmlXPathEvalExpression((const xmlChar*)"//atom",m_context);
|
||||
if(xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
ERRORMSG("Missing Atom information. Exit")
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur = result->nodesetval->nodeTab[0];
|
||||
xmlAttrPtr att = cur->properties;
|
||||
while(att != NULL)
|
||||
{
|
||||
std::string aname((const char*)(att->name));
|
||||
const char *avalue = (const char*)(att->children->content);
|
||||
if(aname == "name")
|
||||
{
|
||||
AtomName = avalue;
|
||||
}
|
||||
else if (aname == "num_closed_shells")
|
||||
{
|
||||
num_closed_shells = atoi(avalue);
|
||||
}
|
||||
att = att->next;
|
||||
}
|
||||
XMLReport("Atom name = " << AtomName);
|
||||
XMLReport("Number of closed shells = " << num_closed_shells);
|
||||
//initialize xmlNode pointers for the grid, wavefunction and potential
|
||||
xmlNodePtr cur1 = cur->xmlChildrenNode;
|
||||
while(cur1 != NULL)
|
||||
{
|
||||
std::string cname1((const char*)(cur1->name));
|
||||
if(cname1 == "grid")
|
||||
{
|
||||
grid_ptr = cur1;
|
||||
}
|
||||
else if(cname1 == "orbitalset")
|
||||
{
|
||||
orb_ptr = cur1;
|
||||
}
|
||||
else if(cname1 == "hamiltonian")
|
||||
{
|
||||
pot_ptr = cur1;
|
||||
OhmmsAttributeSet aAttrib;
|
||||
aAttrib.add(PotType,"type");
|
||||
aAttrib.put(cur1);
|
||||
}
|
||||
cur1 = cur1->next;
|
||||
}
|
||||
}
|
||||
if(orb_ptr == NULL || pot_ptr == NULL || grid_ptr == NULL)
|
||||
{
|
||||
ERRORMSG("Missing one of nodes: <grid/>, <orbitalset/> or <hamiltonian/>. Exit");
|
||||
return false;
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
//initialize the grid
|
||||
bool success = initGrid();
|
||||
if(!success)
|
||||
{
|
||||
ERRORMSG("Failed to create a grid");
|
||||
return false;
|
||||
}
|
||||
Psi.m_grid = myGrid;
|
||||
//initialize the wavefunction
|
||||
success = initOrbitalSet();
|
||||
if(!success)
|
||||
{
|
||||
ERRORMSG("Failed to create/initialiaze orbitals");
|
||||
return false;
|
||||
}
|
||||
//initialize the internal storage for a potential
|
||||
Pot.initialize(Psi);
|
||||
//initialize the Hamiltonian
|
||||
success = initHamiltonian();
|
||||
if(!success)
|
||||
{
|
||||
ERRORMSG("Failed to create/initialiaze hamiltonian");
|
||||
return false;
|
||||
}
|
||||
//initialize the eigen solver
|
||||
result = xmlXPathEvalExpression((const xmlChar*)"//eigensolve",m_context);
|
||||
if(xmlXPathNodeSetIsEmpty(result->nodesetval))
|
||||
{
|
||||
WARNMSG("Using default values for eigen solver");
|
||||
}
|
||||
else
|
||||
{
|
||||
ParameterSet params;
|
||||
params.add(maxiter,"max_iter","int");
|
||||
params.add(eig_tol,"eig_tol","double");
|
||||
params.add(scf_tol,"etot_tol","double");
|
||||
params.add(ratio,"mix_ratio","double");
|
||||
params.put(result->nodesetval->nodeTab[0]);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
XMLReport("maximum iterations = " << maxiter);
|
||||
XMLReport("eigentolerance = " << eig_tol);
|
||||
XMLReport("scftolerance = " << scf_tol);
|
||||
XMLReport("ratio = " << ratio);
|
||||
xmlXPathFreeContext(m_context);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Initialize the radial grid.
|
||||
*
|
||||
*Available parameters
|
||||
<ul>
|
||||
<li> type: the grid type (log or linear)
|
||||
<li> scale: the scaling factor, default 1.0
|
||||
<li> min: the minimum value of the grid, default 0.001
|
||||
<li> max: the maximum value of the grid, default 1000.0
|
||||
<li> npts: the number of grid points, default 2001
|
||||
</ul>
|
||||
*/
|
||||
|
||||
bool HartreeFock::initGrid()
|
||||
{
|
||||
xmlNodePtr cur = grid_ptr;
|
||||
double scale = 1.0;
|
||||
double rmin = 0.001;
|
||||
double rmax = 1000.0;
|
||||
int npts = 2001;
|
||||
//use common method
|
||||
OhmmsAttributeSet aAttrib;
|
||||
aAttrib.add(scale,"scale");
|
||||
aAttrib.add(GridType,"type");
|
||||
aAttrib.add(rmin,"ri");
|
||||
aAttrib.add(rmax,"rf");
|
||||
aAttrib.add(npts,"npts");
|
||||
aAttrib.put(cur);
|
||||
//use old method via <parameter/>
|
||||
XMLReport("Grid type = " << GridType);
|
||||
ParameterSet params;
|
||||
params.add(rmin,"min","double");
|
||||
params.add(rmax,"max","double");
|
||||
params.add(npts,"npts","int");
|
||||
params.put(cur->xmlChildrenNode);
|
||||
if(GridType == "log")
|
||||
{
|
||||
myGrid = new LogGrid<double>;
|
||||
rmin/=scale;
|
||||
rmax/=sqrt(scale);
|
||||
myGrid->set(rmin,rmax,npts);
|
||||
}
|
||||
else if(GridType == "linear")
|
||||
{
|
||||
myGrid = new LinearGrid<double>;
|
||||
rmin/=scale;
|
||||
rmax/=sqrt(scale);
|
||||
myGrid->set(rmin,rmax,npts);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRORMSG("Grid Type Options: Log or Linear.");
|
||||
return false;
|
||||
}
|
||||
XMLReport("Radial Grid: type " << GridType << " rmin = "
|
||||
<< rmin << ", rmax = " << rmax << ", npts = " << npts);
|
||||
// << ", dh = " << myGrid->dh() << ", npts = " << npts)
|
||||
return myGrid != 0;
|
||||
}
|
||||
|
||||
/** Initialize the wavefunction.
|
||||
*
|
||||
*Available parameters
|
||||
<ul>
|
||||
<li> rest_type: the restriction type (spin, spin_space, none)
|
||||
</ul>
|
||||
*/
|
||||
|
||||
bool HartreeFock::initOrbitalSet()
|
||||
{
|
||||
//find the restriction type
|
||||
xmlNodePtr cur = orb_ptr;
|
||||
if(xmlHasProp(cur,(const xmlChar*)"condition"))
|
||||
{
|
||||
Psi.Restriction = (const char*)(xmlGetProp(cur, (const xmlChar *) "condition"));
|
||||
XMLReport("Orbital restriction type = " << Psi.Restriction);
|
||||
}
|
||||
//fill the closed shells (shell filling depends of potential)
|
||||
if(num_closed_shells)
|
||||
{
|
||||
if(PotType.find("nuclear")<PotType.size())
|
||||
{
|
||||
FillShellsNucPot(Psi,num_closed_shells);
|
||||
}
|
||||
if(PotType == "harmonic" || PotType == "step" || PotType == "heg")
|
||||
{
|
||||
FillShellsHarmPot(Psi,num_closed_shells);
|
||||
}
|
||||
//if(PotType == "heg") {
|
||||
// FillShellsHarmPot(Psi,num_closed_shells,1);
|
||||
//}
|
||||
}
|
||||
//pass the xmlNode to Psi
|
||||
Psi.put(cur);
|
||||
app_log() << "Total number of orbitals = " << Psi.size() << std::endl;
|
||||
app_log() << "Total number of unique radial orbitals = " << Psi.NumUniqueOrb << std::endl;
|
||||
app_log() << "(Orbital index, Number of Orbitals, n,l,m,s)"<< std::endl;;
|
||||
for(int j=0; j < Psi.size(); j++)
|
||||
{
|
||||
int id = Psi.ID[j];
|
||||
app_log()<< "(" << id << ", " << Psi.IDcount[id]
|
||||
<< ", " << Psi.N[j]
|
||||
<< ", " << Psi.L[j]
|
||||
<< ", " << Psi.M[j]
|
||||
<< ", " << Psi.S[j]
|
||||
<< ")" << std::endl;
|
||||
}
|
||||
//return false if there is no wave functions
|
||||
return Psi.size() != 0;
|
||||
}
|
||||
|
||||
/** Initialize the Hamiltonian.
|
||||
*
|
||||
*Available Hamiltonians
|
||||
<ul>
|
||||
<li> Nuclear
|
||||
<li> Harmonic
|
||||
<li> Step
|
||||
<li> Pseudo
|
||||
<li> Nuclear Scalar Relativistic
|
||||
</ul>
|
||||
*/
|
||||
bool HartreeFock::initHamiltonian()
|
||||
{
|
||||
//set charge to zero
|
||||
Psi.Charge=0;
|
||||
|
||||
if(PotType.find("nuclear")<PotType.size())
|
||||
{
|
||||
XMLReport("Creating a Nuclear Potential.");
|
||||
double Z = Psi.size();
|
||||
ParameterSet params;
|
||||
params.add(Z,"z","double");
|
||||
params.put(pot_ptr);
|
||||
XMLReport("Potential Paramter: Z = " << Z);
|
||||
Pot.add(new ZOverRPotential(Z), true);
|
||||
Psi.CuspParam = Z;
|
||||
Psi.Charge=Z;
|
||||
} // Z/r potential
|
||||
else if(PotType=="heg")
|
||||
{
|
||||
XMLReport("Creating a Spherical Jellium potential.");
|
||||
SHEGPotential* ap=new SHEGPotential(Psi.size());
|
||||
ap->put(pot_ptr);
|
||||
Pot.add(ap);
|
||||
Psi.CuspParam = 0.0;//set cusp to zero
|
||||
}//spherical Jellium
|
||||
else if(PotType == "harmonic")
|
||||
{
|
||||
XMLReport("Creating a Harmonic Potential.");
|
||||
double Omega=0.5;
|
||||
ParameterSet params;
|
||||
params.add(Omega,"z","double");
|
||||
params.add(Omega,"omega","double");
|
||||
params.put(pot_ptr);
|
||||
XMLReport("Potential Parameter: Omega = " << Omega);
|
||||
Pot.add(new HarmonicPotential(Omega),true);
|
||||
Psi.CuspParam = 0.0;
|
||||
} //Harmonic
|
||||
else if(PotType == "step")
|
||||
{
|
||||
XMLReport("Creating a Step-Function Potential.");
|
||||
StepPotential* apot = new StepPotential;
|
||||
apot->put(pot_ptr);
|
||||
Pot.add(apot,true);
|
||||
Psi.CuspParam = 0.0;
|
||||
} //step potential
|
||||
else if(PotType == "pseudo")
|
||||
{
|
||||
XMLReport("Creating a Starkloff-Joannopoulos Pseudo-Potential.");
|
||||
double rc, lambda, Zeff;
|
||||
ParameterSet params;
|
||||
params.add(rc,"rc","double");
|
||||
params.add(lambda,"lambda","double");
|
||||
params.add(Zeff,"zeff","double");
|
||||
params.put(pot_ptr);
|
||||
XMLReport("Potential Parameter: Effective Charge = " << Zeff);
|
||||
XMLReport("Potential Parameter: Core Radius = " << rc);
|
||||
XMLReport("Potential Parameter: Lambda = " << lambda);
|
||||
Pot.add(new SJPseudoPotential(Zeff,rc,lambda));
|
||||
Psi.CuspParam = 0.0;
|
||||
Psi.Charge=Zeff;
|
||||
} // if Pseudo
|
||||
else
|
||||
{
|
||||
ERRORMSG("Unknown potential type" << PotType);
|
||||
return false;
|
||||
}
|
||||
//determine maximum angular momentum
|
||||
int lmax = 0;
|
||||
int norb = Psi.size();
|
||||
for(int i=0; i<norb; i++)
|
||||
if(Psi.L[i] > lmax)
|
||||
lmax = Psi.L[i];
|
||||
XMLReport("Maximum Angular Momentum = " << lmax);
|
||||
//add Hartree and Exchange common to all
|
||||
Clebsch_Gordan* CG_coeff = new Clebsch_Gordan(lmax);
|
||||
Pot.add(new HartreePotential(CG_coeff,norb));
|
||||
Pot.add(new ExchangePotential(CG_coeff,norb));
|
||||
double m=1.0;
|
||||
ParameterSet params1;
|
||||
params1.add(m,"mass","double");
|
||||
params1.put(pot_ptr);
|
||||
Pot.setMass(m);
|
||||
XMLReport("Effective mass = " << Pot.getMass());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Print the orbitals and their corresponding eigenvalues to a file "AtomName.orb.dat".
|
||||
*@return the maximum radius of the orbital set
|
||||
*
|
||||
*The orbitals can easily be plotted by using gnuplot or xmgrace.
|
||||
*/
|
||||
int HartreeFock::report()
|
||||
{
|
||||
std::string fileforplot(RootFileName);
|
||||
fileforplot.append(".orb.dat");
|
||||
std::ofstream fout(fileforplot.c_str());
|
||||
fout << "#Results for " << AtomName << " with " << PotType
|
||||
<< " potential on " << GridType << " grid." << std::endl;
|
||||
fout << "#Eigen values " << std::endl;
|
||||
fout.precision(10);
|
||||
fout.setf(std::ios::scientific,std::ios::floatfield);
|
||||
for(int orb=0; orb<eigVal.size(); orb++)
|
||||
{
|
||||
fout << "# n=" << Psi.N[orb] << " " << " l=" << Psi.L[orb]
|
||||
<< std::setw(25) << eigVal[orb] << " " << std::endl;
|
||||
}
|
||||
fout << "#The number of unique radial orbitals " << Psi.NumUniqueOrb << std::endl;
|
||||
//find the maximum radius for the orbital set
|
||||
int max_rad_all = 0;
|
||||
int orbindex = 0;
|
||||
for(int orb=0; orb<Psi.NumUniqueOrb; orb++)
|
||||
{
|
||||
int max_rad = myGrid->size()-1;
|
||||
while(std::abs(Psi(orbindex,max_rad)) < 1e-12)
|
||||
max_rad--;
|
||||
max_rad += 2;
|
||||
max_rad_all = std::max(max_rad_all,max_rad);
|
||||
orbindex += Psi.IDcount[orb];
|
||||
}
|
||||
fout.precision(12);
|
||||
for(int ig=0; ig<max_rad_all; ig++)
|
||||
{
|
||||
fout << std::setw(22) << myGrid->r(ig);
|
||||
orbindex=0;
|
||||
for(int orb=0; orb<Psi.NumUniqueOrb; orb++)
|
||||
{
|
||||
fout << std::setw(22) << Psi(orbindex,ig);
|
||||
orbindex += Psi.IDcount[orb];
|
||||
}
|
||||
fout << std::endl;
|
||||
}
|
||||
Psi.print_HDF5(RootFileName,GridType,eigVal);
|
||||
Psi.print_basis(AtomName,RootFileName,GridType);
|
||||
Pot.getStorage(Psi,RootFileName);
|
||||
return max_rad_all;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include "SQD/HFConfiguration.h"
|
||||
#include "SQD/SphericalPotential/ZOverRPotential.h"
|
||||
#include "SQD/SphericalPotential/HarmonicPotential.h"
|
||||
#include "SQD/SphericalPotential/StepPotential.h"
|
||||
#include "SQD/SphericalPotential/RegularLinearTransform.h"
|
||||
#include "SQD/SphericalPotential/RegularLogTransform.h"
|
||||
#include "SQD/SphericalPotential/NuclearLinearTransform.h"
|
||||
#include "SQD/SphericalPotential/NuclearLogTransform.h"
|
||||
#include "SQD/SphericalPotential/NuclearRelLogTransform.h"
|
||||
#include "Numerics/Numerov.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
#include "SQD/HartreeFock.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/** Solve a HF eigen problem for a spherically-symmetric external potential.
|
||||
* @param norb the number of eigen vectors to be obtained
|
||||
*/
|
||||
template<typename Transform_t>
|
||||
inline void
|
||||
HartreeFock::run(int norb)
|
||||
{
|
||||
typedef Numerov<Transform_t, RadialOrbital_t> Numerov_t;
|
||||
value_type Vtotal,KEnew, KEold,E;
|
||||
value_type lowerbound, upperbound;
|
||||
std::vector<value_type> energy(Pot.size());
|
||||
eigVal.resize(norb);
|
||||
int iter = 0;
|
||||
Vtotal = Pot.evaluate(Psi,energy,norb);
|
||||
Pot.mix(0.0);
|
||||
KEnew = Pot.calcKE(Psi,0,norb);
|
||||
std::string label("spdf");
|
||||
std::ofstream log_stream(LogFileName.c_str());
|
||||
log_stream.precision(8);
|
||||
do
|
||||
{
|
||||
KEold = KEnew;
|
||||
value_type eigsum = 0.0;
|
||||
//loop over the orbitals
|
||||
for(int ob=0; ob < norb; ob++)
|
||||
{
|
||||
//set the number of nodes of the eigen vector
|
||||
Pot.V[ob].setNumOfNodes(Pot.getNumOfNodes(Psi.N[ob],Psi.L[ob]));
|
||||
//calculate the lower and upper bounds for the eigenvalue
|
||||
Pot.EnergyBound(lowerbound,upperbound);
|
||||
//set up the transformer
|
||||
Transform_t es(Pot.V[ob], Psi.N[ob], Psi.L[ob],Psi.CuspParam,
|
||||
Pot.getMass());
|
||||
//initialize the numerov solver
|
||||
Numerov_t numerov(es,Psi(ob));
|
||||
//calculate the eigenvalue and the corresponding orbital
|
||||
eigsum += (eigVal[ob] =
|
||||
numerov.solve(lowerbound, upperbound, eig_tol));
|
||||
log_stream << Psi.N[ob]<< label[Psi.L[ob]] << '\t'
|
||||
<< eigVal[ob] << std::endl;
|
||||
}
|
||||
log_stream << std::endl;
|
||||
//normalize the orbitals
|
||||
Psi.normalize(norb);
|
||||
//restrict the orbitals
|
||||
Psi.applyRestriction(norb);
|
||||
//calculate the new kinetic energy
|
||||
KEnew = Pot.calcKE(Psi,eigsum,norb);
|
||||
//the total energy
|
||||
// E = KEnew + Vtotal;
|
||||
//for the new orbitals Psi, calculate the new SCF potentials
|
||||
Vtotal = Pot.evaluate(Psi,energy,norb);
|
||||
//calculate the total energy
|
||||
E = KEnew + Vtotal;
|
||||
//restrict the potential
|
||||
Pot.applyRestriction(Psi);
|
||||
//mix the new SCF potential with the old
|
||||
Pot.mix(ratio);
|
||||
log_stream.precision(10);
|
||||
log_stream << "Iteration #" << iter+1 << std::endl;
|
||||
log_stream << "KE = " << std::setw(15) << KEnew
|
||||
<< " PE = " << std::setw(15) << Vtotal << std::endl;
|
||||
log_stream << "PE/KE = " << std::setw(15) << Vtotal/KEnew
|
||||
<< " Energy = " << std::setw(15) << E << std::endl;
|
||||
log_stream << std::endl;
|
||||
iter++;
|
||||
//continue the loop until the kinetic energy converges
|
||||
}
|
||||
while(std::abs(KEnew-KEold)>scf_tol && iter<maxiter);
|
||||
log_stream << "V_External = " << energy[0] << std::endl;
|
||||
log_stream << "V_Hartree = " << energy[1] << std::endl;
|
||||
log_stream << "V_Exchange = " << energy[2] << std::endl;
|
||||
log_stream << "E_tot = " << E << std::endl;
|
||||
}
|
||||
|
||||
/** Instantiate a Transformation function based on the potential and grid type and call run.
|
||||
*/
|
||||
bool HartreeFock::solve()
|
||||
{
|
||||
int norb = Psi.size();
|
||||
if(PotType == "nuclear")
|
||||
{
|
||||
if(GridType == "linear")
|
||||
{
|
||||
run<NuclearLinearTransform<RadialOrbital_t> >(norb);
|
||||
}
|
||||
else if(GridType == "log")
|
||||
{
|
||||
run<NuclearLogTransform<RadialOrbital_t> >(norb);
|
||||
}
|
||||
}
|
||||
else if(PotType == "nuclear_scalar_rel")
|
||||
{
|
||||
if(GridType == "log")
|
||||
{
|
||||
run<NuclearRelLogTransform<RadialOrbital_t> >(norb);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GridType == "linear")
|
||||
{
|
||||
run<RegularLinearTransform<RadialOrbital_t> >(norb);
|
||||
}
|
||||
else if(GridType == "log")
|
||||
{
|
||||
run<RegularLogTransform<RadialOrbital_t> >(norb);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_ATOMICHF_HARTREEFOCK_H
|
||||
#define OHMMS_ATOMICHF_HARTREEFOCK_H
|
||||
#include "SQD/HFConfiguration.h"
|
||||
#include "SQD/RadialPotentialSet.h"
|
||||
#include "OhmmsData/libxmldefs.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**Hartree-Fock solver
|
||||
*/
|
||||
class HartreeFock
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef SphericalOrbitalTraits::BasisSetType BasisSetType;
|
||||
typedef SphericalOrbitalTraits::value_type value_type;
|
||||
typedef SphericalOrbitalTraits::RadialOrbital_t RadialOrbital_t;
|
||||
|
||||
HartreeFock(RadialPotentialSet& pot, BasisSetType& psi);
|
||||
|
||||
bool put(xmlNodePtr cur);
|
||||
void setRoot(const std::string& aroot);
|
||||
bool solve();
|
||||
int report();
|
||||
inline value_type getE(int i) const
|
||||
{
|
||||
return eigVal[i];
|
||||
}
|
||||
|
||||
private:
|
||||
///maximum number of scf iterations
|
||||
int maxiter;
|
||||
///number of closed shells
|
||||
int num_closed_shells;
|
||||
///tolerance for the eigen solver
|
||||
value_type eig_tol;
|
||||
///tolerance for the self-consistent field solver
|
||||
value_type scf_tol;
|
||||
///mixing ratio of self-consistent field
|
||||
value_type ratio;
|
||||
///root of all the output files
|
||||
std::string RootFileName;
|
||||
///name of the log file
|
||||
std::string LogFileName;
|
||||
std::string AtomName, PotType, GridType;
|
||||
|
||||
|
||||
xmlNodePtr grid_ptr;
|
||||
xmlNodePtr pot_ptr;
|
||||
xmlNodePtr orb_ptr;
|
||||
///pointer to the radial grid
|
||||
SphericalOrbitalTraits::RadialGrid_t* myGrid;
|
||||
///container for the eigenvalues
|
||||
std::vector<value_type> eigVal;
|
||||
///the radial potential
|
||||
RadialPotentialSet& Pot;
|
||||
///the radial orbitals
|
||||
BasisSetType& Psi;
|
||||
|
||||
bool initGrid();
|
||||
bool initHamiltonian();
|
||||
bool initOrbitalSet();
|
||||
|
||||
/** exceute HF-SCF calculations
|
||||
* @param norb number of orbitals
|
||||
*
|
||||
* Transform_t handles boundary (cusp) conditions
|
||||
*/
|
||||
template<typename Transform_t> void run(int norb);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <qfile.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qvaluevector.h>
|
||||
#include <qptrvector.h>
|
||||
#include <qwt_legend.h>
|
||||
#include <qwt_plot_canvas.h>
|
||||
#include "SQD/NxyCurvePlot.h"
|
||||
|
||||
std::map<long,QColor> NxyCurvePlot::ColorList;
|
||||
|
||||
NxyCurvePlot::NxyCurvePlot(QWidget *parent, const char* aname):
|
||||
QwtPlot(parent,aname)
|
||||
{
|
||||
ColorList[0] = black;
|
||||
ColorList[1] = black;
|
||||
ColorList[2] = red;
|
||||
ColorList[3] = green;
|
||||
ColorList[4] = blue;
|
||||
ColorList[5] = cyan;
|
||||
ColorList[6] = magenta;
|
||||
setFrameStyle(QFrame::Box);
|
||||
setLineWidth(0);
|
||||
setCanvasLineWidth(2);
|
||||
setCanvasBackground(white);
|
||||
enableGridX(TRUE);
|
||||
enableGridY(TRUE);
|
||||
setGridMajPen(QPen(gray, 0, DotLine));
|
||||
//setAutoLegend(TRUE);
|
||||
//setLegendPos(Qwt::Right);
|
||||
initCurve();
|
||||
connect(this, SIGNAL(plotMousePressed(const QMouseEvent&)),
|
||||
this, SLOT(modifyCurves(const QMouseEvent&)));
|
||||
}
|
||||
|
||||
QSize NxyCurvePlot::sizeHint() const
|
||||
{
|
||||
return QSize(540,270);
|
||||
}
|
||||
|
||||
void NxyCurvePlot::initCurve()
|
||||
{
|
||||
removeCurves();
|
||||
}
|
||||
|
||||
void NxyCurvePlot::clear()
|
||||
{
|
||||
initCurve();
|
||||
replot();
|
||||
}
|
||||
|
||||
/*!
|
||||
*\brief append a dataset to a QwtplotCurve curveId
|
||||
*/
|
||||
void NxyCurvePlot::appendCurveData(long curveId,
|
||||
double *x,
|
||||
double *y,
|
||||
int size)
|
||||
{
|
||||
QwtPlotCurve *curve = NxyCurvePlot::curve(curveId);
|
||||
//curve->setPen(darkRed);
|
||||
curve->setPen(QPen(ColorList[curveId],2));
|
||||
curve->setStyle(QwtCurve::Spline);
|
||||
///attach a curve to the specifies arrays without copyings
|
||||
//curve->setRawData(x,y,size);
|
||||
setCurveData(curveId,x,y,size);
|
||||
//d_legend->setPen(curveId,ColorList[curveId]);
|
||||
}
|
||||
|
||||
void NxyCurvePlot::modifyCurves(const QMouseEvent &e)
|
||||
{
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_SQD_NXYCURVEPLOT_H_
|
||||
#define OHMMS_SQD_NXYCURVEPLOT_H_
|
||||
|
||||
#include <qwt_plot.h>
|
||||
#include <map>
|
||||
|
||||
class QwtLegend;
|
||||
|
||||
/**class to plot multiple 2D plots sharing a common x axis
|
||||
*@brief provide functionality of xmgrace -nxy
|
||||
*/
|
||||
class NxyCurvePlot: public QwtPlot
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
NxyCurvePlot(QWidget *parent, const char* aname=NULL);
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
virtual void appendCurveData(long curveId,
|
||||
double *x,
|
||||
double *y,
|
||||
int size);
|
||||
|
||||
public slots:
|
||||
|
||||
void clear();
|
||||
|
||||
void modifyCurves(const QMouseEvent& e);
|
||||
|
||||
private:
|
||||
|
||||
void initCurve();
|
||||
QwtLegend *d_legend_in;
|
||||
static std::map<long,QColor> ColorList;
|
||||
};
|
||||
|
||||
#endif /*_RANDOMPLOT_H_*/
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_SIMPLETREEBUILDER_H
|
||||
#define OHMMS_SIMPLETREEBUILDER_H
|
||||
|
||||
// template<class NP>
|
||||
// void
|
||||
// SimpleTreeBuilder(QListViewItem *parentItem, NP parentNode){}
|
||||
void SimpleTreeBuilder(QListViewItem *parentItem, xmlNodePtr parentNode)
|
||||
{
|
||||
QListViewItem *thisItem = 0;
|
||||
xmlNodePtr cur=parentNode->children;
|
||||
while(cur != NULL)
|
||||
{
|
||||
QString cname((const char*)(cur->name));
|
||||
if(cname != "comment")
|
||||
{
|
||||
if(parentItem != 0)
|
||||
{
|
||||
if(cname == "text")
|
||||
{
|
||||
parentItem->setText(1,(const char*)(cur->content));
|
||||
}
|
||||
else
|
||||
if(cname == "PARAMETER")
|
||||
{
|
||||
thisItem = new QListViewItem(parentItem,thisItem);
|
||||
///process attributes: type or format
|
||||
xmlAttrPtr att = cur->properties;
|
||||
while(att != NULL)
|
||||
{
|
||||
QString aname((const char*)(att->name));
|
||||
if(aname == "name")
|
||||
{
|
||||
thisItem->setText(0,(const char*)(att->children->content));
|
||||
}
|
||||
else
|
||||
if(aname == "InUnit")
|
||||
{
|
||||
thisItem->setText(2,(const char*)(att->children->content));
|
||||
}
|
||||
att = att->next;
|
||||
}
|
||||
thisItem->setText(1,(const char*)(cur->children->content));
|
||||
}
|
||||
else
|
||||
{
|
||||
thisItem = new QListViewItem(parentItem,thisItem);
|
||||
thisItem->setText(0,cname);
|
||||
SimpleTreeBuilder(thisItem,cur);
|
||||
///process attributes: type or format
|
||||
xmlAttrPtr att = cur->properties;
|
||||
while(att != NULL)
|
||||
{
|
||||
QString aname((const char*)(att->name));
|
||||
if(aname == "name")
|
||||
{
|
||||
thisItem->setText(1,(const char*)(att->children->content));
|
||||
}
|
||||
else
|
||||
{
|
||||
new QListViewItem(thisItem,aname,(const char*)(att->children->content));
|
||||
}
|
||||
att = att->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
/*
|
||||
void SimpleTreeBuilder(QListViewItem *parentItem, const QDomElement& parentNode) {
|
||||
|
||||
QListViewItem *thisItem = 0;
|
||||
QDomNode node = parentNode.firstChild();
|
||||
while ( !node.isNull() ) {
|
||||
if(node.isElement() && node.nodeName() != "comment") {
|
||||
if(parentItem != 0) {
|
||||
if(node.isText()) {
|
||||
parentItem->setText(1,node.nodeValue());
|
||||
} else {
|
||||
if(node.nodeName() == "PARAMETER"){
|
||||
thisItem = new QListViewItem(parentItem,thisItem);
|
||||
QDomNamedNodeMap att_map=node.attributes();
|
||||
for(int i=0; i<att_map.count(); i++) {
|
||||
QDomNode att=att_map.item(i);
|
||||
if(att.nodeName() == "name")
|
||||
thisItem->setText(0,att.nodeValue());
|
||||
else if(att.nodeName() == "Unit")
|
||||
thisItem->setText(2,att.nodeValue());
|
||||
}
|
||||
if(!node.firstChild().isNull())
|
||||
thisItem->setText(1,node.firstChild().nodeValue());
|
||||
} else {
|
||||
thisItem = new QListViewItem(parentItem,thisItem);
|
||||
thisItem->setText(0,node.nodeName());
|
||||
SimpleTreeBuilder(thisItem,node.toElement());
|
||||
QDomNamedNodeMap att_map=node.attributes();
|
||||
for(int i=0; i<att_map.count(); i++) {
|
||||
QDomAttr att=att_map.item(i).toAttr(); //QDomNode att=att_map.item(i);
|
||||
thisItem->setText(1,att.nodeValue());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node.nextSibling();
|
||||
}
|
||||
if(thisItem) thisItem->setOpen(true);
|
||||
}
|
||||
*/
|
||||
#endif
|
|
@ -1,314 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_RADIALPOTENTIALSET_H
|
||||
#define OHMMS_RADIALPOTENTIALSET_H
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
#include "Numerics/OneDimIntegration.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class RadialPotentialSet
|
||||
@brief A composite class of RadialPotentialBase's
|
||||
*
|
||||
*RadialPotentialSet contains a set of RadialPotentialBase's
|
||||
*constituting a total Hamiltonian
|
||||
*and provides interfaces to perform Hartree-Fock calculations
|
||||
*of atoms, spherical quantum dots and equivalents.
|
||||
*/
|
||||
struct RadialPotentialSet
|
||||
{
|
||||
|
||||
typedef RadialPotentialBase::BasisSetType BasisSetType;
|
||||
typedef RadialPotentialBase::value_type value_type;
|
||||
typedef RadialPotentialBase::RadialOrbital_t RadialOrbital_t;
|
||||
typedef RadialPotentialBase::RadialGrid_t RadialGrid_t;
|
||||
|
||||
///the grid potentials for each orbital
|
||||
RadialPotentialBase::RadialOrbitalSet_t V;
|
||||
|
||||
///the grid potentials for each orbital for self-consistent calculations
|
||||
RadialPotentialBase::RadialOrbitalSet_t Vsave;
|
||||
|
||||
///Effective-mass of the quantum particle
|
||||
value_type EffectiveMass;
|
||||
|
||||
///the Self Consistent Fields
|
||||
std::vector<RadialPotentialBase*> SCF;
|
||||
|
||||
/**an external potential
|
||||
*
|
||||
*@note HartreePotential or ExchangePotential cannot become the
|
||||
*external potential
|
||||
*/
|
||||
RadialPotentialBase* Vext;
|
||||
|
||||
///constructor
|
||||
RadialPotentialSet(): EffectiveMass(1.0), Vext(NULL) { }
|
||||
|
||||
///destructor
|
||||
~RadialPotentialSet()
|
||||
{
|
||||
for(int i=0; i<SCF.size(); i++)
|
||||
delete SCF[i];
|
||||
}
|
||||
|
||||
/**
|
||||
*@param a RadialPotentialBase
|
||||
*@param vect if tree, set a to Vext
|
||||
*@brief add a new Self Consistent Field to the list
|
||||
*/
|
||||
void add(RadialPotentialBase* a, bool vext=false)
|
||||
{
|
||||
SCF.push_back(a);
|
||||
if(vext)
|
||||
Vext = a;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param n the principal quantum number
|
||||
*@param l the angular quantum number
|
||||
*@return the number of radial nodes
|
||||
*@brief The external potential evalue the properties of a radial orbital.
|
||||
*
|
||||
*Vext is also responsible to calculate the lower and upper bounds
|
||||
*for eigen values.
|
||||
*/
|
||||
inline int getNumOfNodes(int n, int l)
|
||||
{
|
||||
if(!Vext)
|
||||
Vext = SCF[0];
|
||||
return Vext->getNumOfNodes(n,l);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param lower the lower bound of the eigen values
|
||||
*@param upper the upper bound of the eigen values
|
||||
*/
|
||||
inline
|
||||
void EnergyBound(value_type& lower, value_type& upper) const
|
||||
{
|
||||
lower = Vext->MinEigenValue;
|
||||
upper = Vext->MaxEigenValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param m the mass of the quantum particle in AU
|
||||
*@brief Set the effective mass
|
||||
*/
|
||||
inline void setMass(value_type m)
|
||||
{
|
||||
EffectiveMass = m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@return the effective mass of the quantum particle
|
||||
*/
|
||||
inline value_type getMass() const
|
||||
{
|
||||
return EffectiveMass;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param ig the grid index
|
||||
*@return the value of the external potential
|
||||
*/
|
||||
inline
|
||||
value_type getV(int ig) const
|
||||
{
|
||||
return Vext->getV(ig);
|
||||
}
|
||||
|
||||
///return the number of Self Consistent Fields
|
||||
inline int size() const
|
||||
{
|
||||
return SCF.size();
|
||||
}
|
||||
|
||||
///create a grid potential for each orbital in the wavefunction
|
||||
void initialize(BasisSetType& psi)
|
||||
{
|
||||
for(int i=0; i < psi.size(); i++)
|
||||
V.push_back(RadialOrbital_t(psi.m_grid));
|
||||
for(int i=0; i<psi.size(); i++)
|
||||
Vsave.push_back(RadialOrbital_t(psi.m_grid));
|
||||
}
|
||||
|
||||
///reset the grid potentials to zero
|
||||
void reset()
|
||||
{
|
||||
for(int i=0; i<V.size(); i++)
|
||||
{
|
||||
V[i].m_Y = 0.0;
|
||||
Vsave[i].m_Y = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param Energy vector to store the sum of each SCF of
|
||||
the SCF matrix elements
|
||||
*@param norb number of orbitals
|
||||
*@brief Loop over all the SCFs to generate a new potential
|
||||
*for each orbital.
|
||||
*/
|
||||
inline value_type evaluate(BasisSetType& psi,
|
||||
std::vector<value_type>& Energy,
|
||||
int norb)
|
||||
{
|
||||
value_type sum = 0.0;
|
||||
for(int i=0; i < V.size(); i++)
|
||||
V[i].m_Y = 0.0;
|
||||
for(int ip=0; ip<SCF.size(); ip++)
|
||||
{
|
||||
sum += (Energy[ip] = SCF[ip]->evaluate(psi,V,norb));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param x the mixing ratio
|
||||
*@brief Mix the old potential with the new potential.
|
||||
*
|
||||
\f[ V_{New}(r) = (1-x)V_{New}(r) +
|
||||
x V_{Old}(r). \f] This is for convergence purposes, so
|
||||
that the convergence is "smoother" and decreases the
|
||||
possibility of having dramatic changes in the potential.
|
||||
*/
|
||||
inline void mix(value_type x)
|
||||
{
|
||||
value_type y = 1-x;
|
||||
for(int ob=0; ob < V.size(); ob++)
|
||||
{
|
||||
V[ob].m_Y = y*V[ob].m_Y + x*Vsave[ob].m_Y;
|
||||
Vsave[ob].m_Y = V[ob].m_Y;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param eigsum the sum of the eigenvalues
|
||||
*@param norb the number of orbitals
|
||||
*@return the total kinetic energy
|
||||
*@brief Calculates the total kinetic energy.
|
||||
*
|
||||
\f[ KE = \sum_i^{Norb} \left\{ \epsilon_i - \int_0^{\infty}
|
||||
dr \psi_i V(r) \psi_i \right\}. \f] This is true because
|
||||
\f[
|
||||
\langle \psi_i | -\frac{1}{2} \nabla^2 | \psi_i \rangle
|
||||
= -\frac{1}{2r^2}\frac{d}{dr}\left(r^2 \frac{d}{dr} -
|
||||
\frac{l(l+1)}{2r^2}\right) = (\epsilon - V(r))
|
||||
\f]
|
||||
*/
|
||||
inline value_type calcKE(BasisSetType& psi,
|
||||
value_type eigsum,
|
||||
int norb)
|
||||
{
|
||||
value_type sum=0.0;
|
||||
RadialOrbital_t integrand(psi(0));
|
||||
for(int ob=0; ob < norb; ob++)
|
||||
{
|
||||
for(int i=0; i < integrand.size(); i++)
|
||||
{
|
||||
integrand(i) = V[ob](i)*psi(ob,i)*psi(ob,i);
|
||||
}
|
||||
sum+=integrate_RK2(integrand);
|
||||
}
|
||||
return eigsum-sum;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@brief Restrict the potential.
|
||||
*
|
||||
Normally each orbital \f$ \psi_i \f$ of the wavefunction
|
||||
has its own unique potential, but we want to restrict
|
||||
the potential to be the same for orbitals with the same
|
||||
quantum numbers, such as \f$ (n,l) \f$. What this function
|
||||
does is assign the average potential to all the orbitals that
|
||||
are restricted to be the same.
|
||||
*/
|
||||
|
||||
void applyRestriction(BasisSetType& psi)
|
||||
{
|
||||
static std::vector<value_type> sum;
|
||||
if(sum.empty())
|
||||
{
|
||||
sum.resize(psi.m_grid->size());
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
sum[ig] = 0.0;
|
||||
}
|
||||
//index of starting orbital index
|
||||
int o_start = 0;
|
||||
//index of ending orbital index
|
||||
int o_end = 0;
|
||||
//orbital index
|
||||
int orb = 0;
|
||||
while (orb < psi.size())
|
||||
{
|
||||
//loop over unique orbitals
|
||||
for(int uorb=0; uorb < psi.NumUniqueOrb; uorb++)
|
||||
{
|
||||
//for each unique orbital, loop over all
|
||||
//identical orbitals
|
||||
for(int i=0; i < psi.IDcount[uorb]; i++)
|
||||
{
|
||||
//add all the orbitals together for averaging
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
sum[ig] += V[orb](ig);
|
||||
}
|
||||
//increment the orbital index
|
||||
orb++;
|
||||
}
|
||||
int o_end = o_start+psi.IDcount[uorb];
|
||||
//assign the average back to the orbitals
|
||||
for(int o = o_start; o < o_end; o++)
|
||||
{
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
V[o](ig) = sum[ig]/psi.IDcount[uorb];
|
||||
}
|
||||
}
|
||||
o_start = o_end;
|
||||
//reset the sum for the next average
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
sum[ig] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param RootFileName the name of file root
|
||||
*@brief Loop over all the SCFs to output the internal
|
||||
*storage.
|
||||
*@note Only applies for the Hartree and Exchange potentials.
|
||||
*/
|
||||
void getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName)
|
||||
{
|
||||
for(int ip=0; ip<SCF.size(); ip++)
|
||||
SCF[ip]->getStorage(psi,RootFileName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,42 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Form implementation generated from reading ui file 'sqd.ui'
|
||||
**
|
||||
** Created: Mon May 31 19:07:56 2004
|
||||
** by: The User Interface Compiler ($Id$)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
****************************************************************************/
|
||||
|
||||
#include <set>
|
||||
#include "SQD/SQDFrame.h"
|
||||
|
||||
SQDFrame::SQDFrame()
|
||||
: HFSolver(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
SQDFrame::~SQDFrame()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
if(HFSolver)
|
||||
delete HFSolver;
|
||||
}
|
||||
|
|
@ -1,233 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Form implementation generated from reading ui file 'sqd.ui'
|
||||
**
|
||||
** Created: Mon May 31 19:07:56 2004
|
||||
** by: The User Interface Compiler ($Id$)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
****************************************************************************/
|
||||
|
||||
#include "SQD/SQDFrame.h"
|
||||
|
||||
#ifdef HAVE_QT
|
||||
#include <set>
|
||||
#include <qvariant.h>
|
||||
#include <qlabel.h>
|
||||
#include <qframe.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtooltip.h>
|
||||
#include <qwhatsthis.h>
|
||||
#include <qapplication.h>
|
||||
#include <qsplitter.h>
|
||||
#include <qvbox.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qfile.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qlayout.h>
|
||||
#include <qwt_plot_canvas.h>
|
||||
#include "SQD/NxyCurvePlot.h"
|
||||
|
||||
/*
|
||||
* Constructs a SQDFrame as a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'.
|
||||
*/
|
||||
SQDFrame::SQDFrame( QWidget* parent, const char* name, WFlags fl )
|
||||
: QWidget( parent, name, fl ), HFSolver(NULL)
|
||||
{
|
||||
if ( !name )
|
||||
setName( "SQDFrame" );
|
||||
potLabel = new QLabel( this, "poteLabel" );
|
||||
potLabel->setGeometry( QRect( 240, 20, 260, 24 ) );
|
||||
potFrame = new NxyCurvePlot(this,"potPlot");
|
||||
potFrame->setGeometry( QRect( 20, 60, 540, 200 ) );
|
||||
potFrame->setFrameShape( QFrame::StyledPanel );
|
||||
potFrame->setFrameShadow( QFrame::Raised );
|
||||
wfsLabel = new QLabel( this, "wfsLabel" );
|
||||
wfsLabel->setGeometry( QRect( 160, 280, 400, 24 ) );
|
||||
wfsFrame = new NxyCurvePlot(this,"wfsPlot");
|
||||
wfsFrame->setGeometry( QRect( 20, 320, 540, 270 ) );
|
||||
d_log = new QTextEdit(this);
|
||||
d_log->setGeometry( QRect( 40, 600, 510, 200 ));
|
||||
d_log->setTextFormat(Qt::LogText);
|
||||
QFrame *hb = new QFrame(this,"buttonbox");
|
||||
hb->setGeometry(QRect(40,805,540,60));
|
||||
QHBoxLayout *layout = new QHBoxLayout(hb);
|
||||
quitButton = new QPushButton(hb, "quitButton" );
|
||||
layout->addItem(new QSpacerItem( 50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ));
|
||||
layout->addWidget(quitButton);
|
||||
layout->addItem(new QSpacerItem( 50, 20, QSizePolicy::Fixed, QSizePolicy::Minimum ));
|
||||
saveButton = new QPushButton( hb, "saveButton" );
|
||||
layout->addWidget(saveButton);
|
||||
layout->addItem(new QSpacerItem( 50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ));
|
||||
connect( quitButton, SIGNAL(clicked()), qApp, SLOT(quit()) );
|
||||
connect( saveButton, SIGNAL(clicked()), this, SLOT(slotSave()) );
|
||||
resize( QSize(600, 860).expandedTo(minimumSizeHint()) );
|
||||
languageChange();
|
||||
clearWState( WState_Polished );
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
SQDFrame::~SQDFrame()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
if(HFSolver)
|
||||
delete HFSolver;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the strings of the subwidgets using the current
|
||||
* language.
|
||||
*/
|
||||
void SQDFrame::languageChange()
|
||||
{
|
||||
setCaption( tr( "Effective-mass simulation of a spherical quantum dot" ) );
|
||||
setIconText( tr( "sqd" ) );
|
||||
potLabel->setText( tr( "<font size=\"+1\">Radial potential</font>" ) );
|
||||
wfsLabel->setText( tr( "<font size=\"+1\">Solutions of a radial Schrodinger Eq. <fon size=\"+2\"><i>u<sub>l</sub></i></font></font>" ) );
|
||||
quitButton->setText( tr( "Quit" ) );
|
||||
saveButton->setText( tr( "Save" ) );
|
||||
QToolTip::add(quitButton, "Leave the application");
|
||||
QToolTip::add(saveButton, "Save the results of the application");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@overload void SQDFrame::showEvent(QShowEvent *event)
|
||||
@brief Fill the frame with the results from Hartree-Fock calculations
|
||||
*
|
||||
*The summary is given in the log frame and potential and the solution of the orbitals
|
||||
\f$u_{nl} = r R_{nl}\f$ are plotted with respect to the radius.
|
||||
*/
|
||||
void SQDFrame::showEvent( QShowEvent *event)
|
||||
{
|
||||
int max_rad_all = HFSolver->report();
|
||||
QString msg
|
||||
= QString("Potential type: %1\nGrid type: %2\nEffective mass: %3").arg(potType).arg(gridType).arg(Pot.getMass());
|
||||
d_log->append(msg);
|
||||
d_log->append("Eigen energies of a spherical quantum dot");
|
||||
for(int i=0; i<Psi.size(); i++)
|
||||
{
|
||||
msg
|
||||
= QString("\tOrbital n=%1.l=%2.m=%3.s=%4 %5").arg(Psi.N[i]).arg(Psi.L[i]).arg(Psi.M[i]).arg(Psi.S[i]).arg(HFSolver->getE(i));
|
||||
d_log->append(msg);
|
||||
}
|
||||
long y1 = potFrame->insertCurve("Potential Energy");
|
||||
potFrame->appendCurveData(y1,
|
||||
Psi.m_grid->data(),
|
||||
Pot.Vext->data(),
|
||||
max_rad_all);
|
||||
potFrame->replot();
|
||||
int orbindex = 0;
|
||||
wfsFrame->setAxisTitle(QwtPlot::xBottom, "Radius in AU");
|
||||
for(int orb=0; orb<Psi.NumUniqueOrb; orb++)
|
||||
{
|
||||
int n = Psi.N[orbindex];
|
||||
int l = Psi.L[orbindex];
|
||||
QString cname= QString("n=%1.l=%2").arg(n,l);
|
||||
y1 = wfsFrame->insertCurve(cname);
|
||||
wfsFrame->appendCurveData(y1,Psi.m_grid->data(),Psi(orbindex).data(),max_rad_all);
|
||||
orbindex += Psi.IDcount[orb];
|
||||
}
|
||||
wfsFrame->replot();
|
||||
// double e = HFSolver->getE(0);
|
||||
// int orb = 0;
|
||||
// int ng = Psi.m_grid->size();
|
||||
// int n = Psi.N[orb];
|
||||
// int l = Psi.L[orb];
|
||||
// QString cname= QString("n=%1.l=%2").arg(n,l);
|
||||
// y1 = wfsFrame->insertCurve(cname);
|
||||
// wfsFrame->appendCurveData(y1,Psi.m_grid->data()+1,Psi(orb).data()+1,ng-1);
|
||||
// for(orb=1; orb<Psi.NumUniqueOrb; orb++){
|
||||
// int n_cur = Psi.N[orb];
|
||||
// int l_cur = Psi.L[orb];
|
||||
// //if(std::abs(e-HFSolver->getE(orb))>1e-6 || n_cur != n || l_cur != l ) {
|
||||
// if(n_cur != n || l_cur != l) {
|
||||
// n=n_cur; l=l_cur;
|
||||
// cname= QString("n=%1.l=%2").arg(n,l);
|
||||
// y1 = wfsFrame->insertCurve(cname);
|
||||
// wfsFrame->appendCurveData(y1,Psi.m_grid->data()+1,Psi(orb).data()+1,ng-1);
|
||||
// e = HFSolver->getE(orb);
|
||||
// }
|
||||
// }
|
||||
// wfsFrame->replot();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief save results
|
||||
*/
|
||||
void SQDFrame::slotSave()
|
||||
{
|
||||
QString fname = QFileDialog::getSaveFileName(".",QString::null,this);
|
||||
bool save2file=false;
|
||||
if(!fname.isEmpty())
|
||||
{
|
||||
QFileInfo fi(fname);
|
||||
if(fi.exists())
|
||||
{
|
||||
QMessageBox mb("Save as",
|
||||
"File exists. Do you really want to overwrite the file?",
|
||||
QMessageBox::Information,
|
||||
QMessageBox::Yes | QMessageBox::Default,
|
||||
QMessageBox::No,
|
||||
QMessageBox::Cancel | QMessageBox::Escape);
|
||||
mb.setButtonText(QMessageBox::Yes,"Save");
|
||||
mb.setButtonText(QMessageBox::No,"Don't Save");
|
||||
save2file = (mb.exec() == QMessageBox::Yes);
|
||||
}
|
||||
else
|
||||
{
|
||||
save2file = true;
|
||||
}
|
||||
}
|
||||
if(save2file)
|
||||
{
|
||||
QFile file(fname); // Write the text to a file
|
||||
if ( file.open( IO_WriteOnly ) )
|
||||
{
|
||||
QTextStream stream( &file );
|
||||
stream << d_log->text();
|
||||
d_log->setModified( FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
SQDFrame::SQDFrame() : HFSolver(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
SQDFrame::~SQDFrame()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
if(HFSolver)
|
||||
delete HFSolver;
|
||||
}
|
||||
|
||||
|
||||
void SQDFrame::show()
|
||||
{
|
||||
HFSolver->report();
|
||||
}
|
||||
#endif
|
|
@ -1,125 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** Form interface generated from reading ui file 'sqd.ui'
|
||||
**
|
||||
** Created: Mon May 31 19:07:43 2004
|
||||
** by: The User Interface Compiler ($Id$)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SQDFRAME_H
|
||||
#define SQDFRAME_H
|
||||
|
||||
#include "SQD/HartreeFock.h"
|
||||
#ifdef HAVE_QT
|
||||
#include <qvariant.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class QGridLayout;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class NxyCurvePlot;
|
||||
class QTextEdit;
|
||||
|
||||
/** A main application to solve Hartree-Fock equation in a spherical potential.
|
||||
*/
|
||||
class SQDFrame : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SQDFrame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~SQDFrame();
|
||||
|
||||
/**
|
||||
@param fname the name of an input file
|
||||
@brief solve Hartree-Fock eqution with an input xml file fname
|
||||
*/
|
||||
bool solve(const char* fname);
|
||||
|
||||
public slots:
|
||||
|
||||
void slotSave();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@brief Show the potential and wave functions
|
||||
*/
|
||||
void showEvent ( QShowEvent * );
|
||||
|
||||
protected slots:
|
||||
|
||||
virtual void languageChange();
|
||||
|
||||
private:
|
||||
QLabel* potLabel;
|
||||
QLabel* wfsLabel;
|
||||
NxyCurvePlot* potFrame;
|
||||
NxyCurvePlot* wfsFrame;
|
||||
QPushButton* saveButton;
|
||||
QPushButton* quitButton;
|
||||
QTextEdit *d_log;
|
||||
|
||||
std::string elementType;
|
||||
std::string potType;
|
||||
std::string gridType;
|
||||
|
||||
ohmmshf::RadialPotentialSet Pot;
|
||||
ohmmshf::SphericalOrbitalTraits::BasisSetType Psi;
|
||||
ohmmshf::HartreeFock *HFSolver;
|
||||
|
||||
xmlDocPtr m_doc;
|
||||
|
||||
//xmlpp::DomParser myParser;
|
||||
//xmlpp::Node *docRoot;
|
||||
|
||||
};
|
||||
#else
|
||||
|
||||
/** A main application to solve Hartree-Fock equation in a spherical
|
||||
potential.
|
||||
*/
|
||||
class SQDFrame
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
SQDFrame();
|
||||
~SQDFrame();
|
||||
|
||||
/**
|
||||
@param fname the name of an input file
|
||||
@brief solve Hartree-Fock eqution with an input xml file fname
|
||||
*/
|
||||
bool solve(const char* fname);
|
||||
|
||||
void show();
|
||||
|
||||
ohmmshf::RadialPotentialSet Pot;
|
||||
ohmmshf::SphericalOrbitalTraits::BasisSetType Psi;
|
||||
ohmmshf::HartreeFock *HFSolver;
|
||||
|
||||
xmlDocPtr m_doc;
|
||||
};
|
||||
#endif
|
||||
#endif // SQDFRAME_H
|
|
@ -1,63 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include "SQD/SphericalPotential/HarmonicPotential.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
/*!
|
||||
* \param omega The force constant of a harmonic oscillator.
|
||||
*/
|
||||
HarmonicPotential::HarmonicPotential(value_type omega): Omega(omega)
|
||||
{
|
||||
MinEigenValue = 0.0;
|
||||
}
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
HarmonicPotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V,
|
||||
int norb)
|
||||
{
|
||||
if(!Vext)
|
||||
{
|
||||
Vext = new RadialOrbital_t(psi(0));
|
||||
integrand=new RadialOrbital_t(psi(0));
|
||||
value_type omega2=Omega*Omega*0.5;
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
(*Vext)(ig)= omega2*psi.m_grid->r(ig)*psi.m_grid->r(ig);
|
||||
}
|
||||
}
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
value_type sum = 0.0;
|
||||
value_type v = (*Vext)(ig);
|
||||
for(int o=0; o < norb; o++)
|
||||
{
|
||||
V[o](ig) += v;
|
||||
sum += std::pow(psi(o,ig),2);
|
||||
}
|
||||
(*integrand)(ig) = v*sum;
|
||||
}
|
||||
return integrate_RK2(*integrand);
|
||||
}
|
||||
|
||||
int HarmonicPotential::getNumOfNodes(int n, int l)
|
||||
{
|
||||
MaxEigenValue = (2.0*static_cast<value_type>(2*n+l)+3.0)*Omega;
|
||||
return n;
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_HARMONICPOTENTIAL_H
|
||||
#define OHMMSHF_HARMONICPOTENTIAL_H
|
||||
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class HarmonicPotential
|
||||
@brief implements the Harmonic potential of
|
||||
\f[
|
||||
V_{Harmonic}(r) = \frac{1}{2}\omega^2 r^2
|
||||
\f]
|
||||
*/
|
||||
struct HarmonicPotential: public RadialPotentialBase
|
||||
{
|
||||
value_type Omega;
|
||||
HarmonicPotential(value_type omega);
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
///return \f$ n \f$
|
||||
int getNumOfNodes(int n, int l);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,156 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_NUCLEAR_LINEAR_TRANSFORMFUNCTION_H
|
||||
#define OHMMS_NUCLEAR_LINEAR_TRANSFORMFUNCTION_H
|
||||
|
||||
#include <numeric>
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
|
||||
/**@ingroup NumerovTransform
|
||||
*\brief Transform function for the radial Schroedinger equation on a
|
||||
*linear grid with a Nuclear potential \f$V(r) = -\frac{Z}{r}.\f$
|
||||
*
|
||||
*Implements a transformation for the Numerov algorithm:
|
||||
\f[
|
||||
\frac{d^2u_{nl}}{dr^2}+k^2(r) u_{nl} = 0,
|
||||
\f]
|
||||
*where
|
||||
\f[
|
||||
k^2(r)=2[\varepsilon-\frac{L(L+1)}{2r^2}-V(r)].
|
||||
\f]
|
||||
*/
|
||||
template<class SourceType>
|
||||
struct NuclearLinearTransform
|
||||
{
|
||||
|
||||
typedef SourceType Source_t;
|
||||
typedef typename SourceType::value_type value_type;
|
||||
|
||||
///source function on a linear grid
|
||||
Source_t& V;
|
||||
|
||||
///number of nodes for given quantum numbers
|
||||
int NumNodes;
|
||||
|
||||
///reference energy \f$\varepsilon\f$
|
||||
value_type E;
|
||||
|
||||
///Nuclear charge
|
||||
value_type Z;
|
||||
|
||||
///parameter to determine the cusp condition
|
||||
value_type CuspParam;
|
||||
|
||||
///principal quantum number
|
||||
value_type N;
|
||||
|
||||
///angular momentum quantum number
|
||||
value_type L;
|
||||
|
||||
///LL \f$=l(l+1)/(2m_{eff})\f$
|
||||
value_type LL;
|
||||
|
||||
/** Constructor for \f$u_{nl}\f$
|
||||
* \param v the source function on a grid
|
||||
* \param n the principal quantum number
|
||||
* \param l the anuglar quantum number
|
||||
* \param z the charge
|
||||
* \param meff the effective mass
|
||||
* \note For the Nuclear potential the number of nodes for
|
||||
the radial function with quantum numbers
|
||||
\f$n\f$ and \f$l\f$ is \f$n-l-1\f$.
|
||||
*/
|
||||
NuclearLinearTransform(Source_t& v, int n, int l, value_type z,
|
||||
value_type meff=1.0):
|
||||
V(v), E(0.0), N(n), CuspParam(z), Z(z)
|
||||
{
|
||||
NumNodes = v.getNumOfNodes();
|
||||
L = static_cast<value_type>(l);
|
||||
LL = 0.5*L*(L+1)/meff;
|
||||
}
|
||||
|
||||
///returns the starting valid index
|
||||
inline int first() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param i index of the first value of the linear grid
|
||||
*\param z0 \f$u_{nl}(r_0)\f$
|
||||
*\param z1 \f$u_{nl}(r_0 + dr)\f$
|
||||
*\return the derivate of the target function before transformation
|
||||
*\brief Assign the first and second values using the cusp condition.
|
||||
*
|
||||
For \f$l=0\f$ in the limit \f$r\rightarrow 0\f$
|
||||
\f[
|
||||
u(r) \approx r(1-Zr),
|
||||
\f]
|
||||
while for positive l the condition is
|
||||
\f[
|
||||
u(r) \approx r^{l+1}.
|
||||
\f]
|
||||
*/
|
||||
value_type setCusp(int i, value_type& z0, value_type& z1)
|
||||
{
|
||||
value_type r0 = V.r(i);
|
||||
value_type dr = V.dr(i);
|
||||
value_type deriv;
|
||||
if(L<std::numeric_limits<value_type>::epsilon())
|
||||
{
|
||||
z0 = std::pow(r0,L+1);
|
||||
deriv = static_cast<value_type>(L+1)*std::pow(r0,L);
|
||||
}
|
||||
else
|
||||
{
|
||||
z0 = r0*(1-Z*r0);
|
||||
deriv = 1.0-2*Z*r0;
|
||||
}
|
||||
z1 = z0 + deriv*dr;
|
||||
return deriv;
|
||||
}
|
||||
|
||||
///returns the number of nodes
|
||||
inline int nodes() const
|
||||
{
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
///return \f$k^2(r_i)=2[\varepsilon-L(L+1)/2r_i^2-V(r_i)]\f$
|
||||
inline value_type k2(int i)
|
||||
{
|
||||
value_type rinv = 1.0/V.r(i);
|
||||
return 2.0*(E-LL*rinv*rinv-V(i));
|
||||
}
|
||||
|
||||
/*!\fn value_type convert(value_type y, value_type r)
|
||||
*\param y the value of \f$u_{nl}(r)\f$
|
||||
*\param r the grid value
|
||||
*\return The same value: no transformation is needed.
|
||||
*/
|
||||
inline value_type convert(value_type y, value_type r)
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
///reset the reference energy and turning point
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
E = e;
|
||||
}
|
||||
};
|
||||
#endif
|
|
@ -1,164 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_NUCLEAR_LOG_TRANSFORMFUNCTION_H
|
||||
#define OHMMS_NUCLEAR_LOG_TRANSFORMFUNCTION_H
|
||||
|
||||
#include <numeric>
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
/**@ingroup NumerovTransform
|
||||
*\brief Transform function for the radial Schroedinger equation on a
|
||||
*log grid with a Nuclear potential \f$V(r) = -\frac{Z}{r}\f$.
|
||||
*
|
||||
*The Numerov algorithm can only be integrated on a uniform grid. To
|
||||
solve the equation on the log grid it is necessary to make the
|
||||
following change of variables
|
||||
\f[ Z_{nl}(r) = \frac{u_{nl}(r)}{\sqrt{r}}
|
||||
\mbox{ and } y = \log(r).
|
||||
\f]
|
||||
*The Transform function for the Numerov algorithm becomes:
|
||||
\f[
|
||||
\frac{d^2Z_{nl}(y)}{dy^2} + k'^2(r)Z_{nl}(y) = 0,
|
||||
\f] where
|
||||
\f[
|
||||
k'^2(r) = 2r^2[\varepsilon -\frac{(L+\frac{1}{2})^2}{2r^2}-V(r)]
|
||||
\f]
|
||||
*/
|
||||
template<class SourceType>
|
||||
struct NuclearLogTransform
|
||||
{
|
||||
|
||||
typedef SourceType Source_t;
|
||||
typedef typename SourceType::value_type value_type;
|
||||
|
||||
Source_t& V;
|
||||
|
||||
///number of nodes for given quantum numbers
|
||||
int NumNodes;
|
||||
|
||||
///reference energy \f$\varepsilon\f$
|
||||
value_type E;
|
||||
|
||||
///Nuclear charge
|
||||
value_type Z;
|
||||
|
||||
///parameter to determine the cusp condition
|
||||
value_type CuspParam;
|
||||
|
||||
///principal quantum number
|
||||
value_type N;
|
||||
|
||||
///angular momentum quantum number
|
||||
value_type L;
|
||||
|
||||
///\f[LL=(l+\frac{1}{2})^2/(2m_{eff})\f]
|
||||
value_type LL;
|
||||
|
||||
/** Constructor for \f$Z_{nl}\f$
|
||||
* \param v the source function on a grid
|
||||
* \param n the principal quantum number
|
||||
* \param l the anuglar momentum quantum number
|
||||
* \param z the charge
|
||||
* \param meff the effective mass
|
||||
* \note For the Nuclear potential \f$V(r) = -Z/r\f$ the
|
||||
number of nodes for the radial function with quantum numbers
|
||||
\f$n\f$ and \f$l\f$ is \f$n-l-1\f$.
|
||||
*/
|
||||
NuclearLogTransform(Source_t& v, int n, int l, value_type z,
|
||||
value_type meff=1.0):
|
||||
V(v), E(0.0), N(n), CuspParam(z)
|
||||
{
|
||||
NumNodes = v.getNumOfNodes();
|
||||
L = static_cast<value_type>(l);
|
||||
LL = 0.5*(L+0.5)*(L+0.5)/meff;
|
||||
}
|
||||
|
||||
///returns the starting valid index
|
||||
inline int first() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param i index of the first value of the log grid
|
||||
*\param z0 \f$Z_{nl}(r_0)\f$
|
||||
*\param z1 \f$Z_{nl}(r_0 + dr)\f$
|
||||
*\return the derivate of the target function before transformation
|
||||
*\brief Assign the first and second values using the cusp condition.
|
||||
*
|
||||
For \f$l=0\f$ in the limit \f$r\rightarrow 0\f$
|
||||
\f[
|
||||
Z(r) \approx \sqrt{r}(1-Zr),
|
||||
\f]
|
||||
while for positive l the condition is
|
||||
\f[
|
||||
Z(r)\approx r^{l+\frac{1}{2}}.
|
||||
\f]
|
||||
*/
|
||||
value_type setCusp(int i, value_type& z0, value_type& z1)
|
||||
{
|
||||
value_type r0 = V.r(i);
|
||||
value_type dr = V.dr(i);
|
||||
value_type deriv;
|
||||
if(L)
|
||||
{
|
||||
z0 = std::pow(r0,L+0.5);
|
||||
deriv = (L+0.5)*std::pow(r0,L-0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type r0h = sqrt(r0);
|
||||
z0 = r0h*(1-CuspParam*r0);
|
||||
deriv = 0.5*(1/r0h - 3.0*CuspParam*r0h);
|
||||
}
|
||||
z1 = z0 + deriv*dr;
|
||||
return deriv;
|
||||
}
|
||||
|
||||
///returns the number of nodes
|
||||
inline int nodes() const
|
||||
{
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
/*return \f$ k'^2(r_i) = 2r_i^2[\varepsilon
|
||||
-(L+\frac{1}{2})^2/2r_i^2-V(r_i)] \f$
|
||||
*/
|
||||
inline value_type k2(int i)
|
||||
{
|
||||
value_type rsq = std::pow(V.r(i),2.0);
|
||||
return 2.0*(rsq*(E-V(i))-LL); //2.0*rsq*(E-LL/rsq-V(i));
|
||||
}
|
||||
|
||||
/*!\fn value_type convert(value_type y, value_type r)
|
||||
*\param y the value \f$Z_{nl}(r)\f$
|
||||
*\param r the grid value
|
||||
*\return \f$u_{nl}(r) = \sqrt{r}Z_{nl}(r)\f$
|
||||
*/
|
||||
inline value_type convert(value_type y, value_type r)
|
||||
{
|
||||
return y*sqrt(r);
|
||||
}
|
||||
|
||||
///reset the reference energy and turning point
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
E = e;
|
||||
}
|
||||
};
|
||||
/**@}*/
|
||||
|
||||
#endif
|
|
@ -1,260 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_NUCLEAR_RELATIVISTIC_LOG_TRANSFORMFUNCTION_H
|
||||
#define OHMMS_NUCLEAR_RELATIVISTIC_LOG_TRANSFORMFUNCTION_H
|
||||
|
||||
#include <numeric>
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
|
||||
//#define PRINT_DEBUG
|
||||
/**@ingroup NumerovTransform
|
||||
*\brief Transform function for the radial Schroedinger equation on a
|
||||
*log grid with the scalar Nuclear relativistic potential.
|
||||
*
|
||||
*The Nuclear scalar relativistic radial equation with
|
||||
*\f$V(r) = -Z/r\f$
|
||||
\f[
|
||||
-\frac{1}{2M}\frac{d^2u_{nl}}{dr^2}
|
||||
+\left[ V+\frac{l(l+1)}{2Mr^2}
|
||||
+\frac{\alpha^2}{4M^2r}\frac{dV}{dr}\right] u_{nl}
|
||||
-\frac{\alpha^2}{4M^2}\frac{dV}{dr}\frac{du_{nl}}{dr}
|
||||
= \varepsilon' u_{nl},
|
||||
\f]
|
||||
where
|
||||
\f[
|
||||
\varepsilon'=\varepsilon-\frac{m}{\alpha^2}
|
||||
\f]
|
||||
and
|
||||
\f[
|
||||
M(r)=m+\frac{\alpha^2}{2}\left(\varepsilon'-V(r)\right).
|
||||
\f]
|
||||
*
|
||||
To convert this equation to a form that is compatable with the Numerov
|
||||
algoritm the following change of variables is necessary:
|
||||
\f[ Z_{nl}(r)=u_{nl}(r)/\sqrt{M}, \f] this leads to
|
||||
\f[
|
||||
\frac{d^2Z_{nl}}{dr^2}=\left[ \frac{l(l+1)}{r^2}
|
||||
+ 2M(V-\varepsilon')+\frac{\alpha^2}{2Mr}\frac{dV}{dr}
|
||||
+\frac{3\alpha^4}{16M^2} \left( \frac{dV}{dr} \right)^2
|
||||
+ \frac{\alpha^2}{4M}\frac{d^2V}{dr^2}\right]Z_{nl}.
|
||||
\f]
|
||||
The Numerov algorithm can only be integrated on a uniform grid. To
|
||||
solve the equation on the logarithmic grid it is necessary to make
|
||||
another change of variables
|
||||
\f[ \Psi_{nl}(r) = \frac{Z_{nl}(r)}{\sqrt{r}} \mbox{ and } y = \log(r) \f]
|
||||
with the final result
|
||||
\f[
|
||||
\frac{d^2\Psi_{nl}}{dy^2} = \left[ \frac{(l+\frac{1}{2})^2}{r^2}
|
||||
+ 2M(V-\varepsilon')+\frac{\alpha^2}{2Mr}\frac{dV}{dr}
|
||||
+ \frac{3\alpha^4}{16M^2} \left( \frac{dV}{dr} \right)^2
|
||||
+ \frac{\alpha^2}{4M}\frac{d^2V}{dr^2}\right]r^2 \Psi_{nl}.
|
||||
\f]
|
||||
*The Transform function for the Numerov algorithm becomes:
|
||||
\f[
|
||||
\frac{d^2\Psi_{nl}(y)}{dy^2} + k'^2(r)\Psi_{nl}(y) = 0,
|
||||
\f] where
|
||||
\f[
|
||||
k'^2(r) = r^2 \left[ 2M(V-\varepsilon')
|
||||
+ \frac{(l+\frac{1}{2})^2}{r^2} + \frac{\alpha^2}{2Mr}\frac{dV}{dr}
|
||||
+ \frac{3\alpha^4}{16M^2} \left( \frac{dV}{dr} \right)^2
|
||||
+ \frac{\alpha^2}{4M}\frac{d^2V}{dr^2} \right]
|
||||
\f]
|
||||
*
|
||||
See Koelling, D.D. and Harmon, B.N. J. Phys. C: Solid State Phys.,
|
||||
\textbf{10}, 3107, (1977).
|
||||
*/
|
||||
template<class SourceType>
|
||||
struct NuclearRelLogTransform
|
||||
{
|
||||
|
||||
typedef SourceType Source_t;
|
||||
typedef typename SourceType::value_type value_type;
|
||||
|
||||
Source_t& V;
|
||||
|
||||
///number of nodes for given quantum numbers
|
||||
int NumNodes;
|
||||
|
||||
///reference energy \f$\varepsilon\f$
|
||||
value_type E;
|
||||
|
||||
///parameter to determine the cusp condition
|
||||
value_type CuspParam;
|
||||
|
||||
///principal quantum number
|
||||
value_type N;
|
||||
|
||||
///angular momentum quantum number
|
||||
value_type L;
|
||||
|
||||
///\f[LL=(l+\frac{1}{2})^2/(2m_{eff})\f]
|
||||
value_type LL;
|
||||
|
||||
/**
|
||||
*Fine-Structure constant \f$\alpha = 7.297352568e-3 \approx 1/137\f$
|
||||
*For reference see http://physics.nist.gov/cgi-bin/cuu/Value?alph
|
||||
*/
|
||||
value_type alpha;
|
||||
|
||||
///\f$\alpha^2\f$
|
||||
value_type alpha2;
|
||||
|
||||
/**
|
||||
* \param v the source function on a grid
|
||||
* \param n the principal quantum number
|
||||
* \param l the anuglar momentum quantum number
|
||||
* \param z the charge
|
||||
* \param meff the effective mass
|
||||
* \note For the Nuclear Scalar Relativistic potential the
|
||||
number of nodes for the radial function with quantum numbers
|
||||
\f$n\f$ and \f$l\f$ is \f$n-l-1\f$, the same as in the
|
||||
nonrelativistic case.
|
||||
* \brief Constructor for \f$\Psi_{nl}\f$
|
||||
*
|
||||
Calculate the boundary conditions for the One-Dimensional Cubic
|
||||
*Spline for the Nuclear Potential \f$V(r) = -Z/r.\f$
|
||||
*/
|
||||
NuclearRelLogTransform(Source_t& v, int n, int l, value_type z,
|
||||
value_type meff=1.0):
|
||||
V(v), E(0.0), N(n), CuspParam(z), alpha(7.297352568e-3)
|
||||
{
|
||||
NumNodes = v.getNumOfNodes();
|
||||
L = static_cast<value_type>(l);
|
||||
LL = 0.5*(L+0.5)*(L+0.5)/meff;
|
||||
alpha2 = alpha*alpha;
|
||||
int imin = 0;
|
||||
int imax = V.size()-1;
|
||||
//calculate first derivative at the boundaries
|
||||
value_type yp1 = CuspParam/(V.r(imin)*V.r(imin));
|
||||
value_type ypn = CuspParam/(V.r(imax)*V.r(imax));
|
||||
V.spline(imin,yp1,imax,ypn);
|
||||
//cubic-spline test
|
||||
#ifdef PRINT_DEBUG
|
||||
std::string fname("check_spline");
|
||||
fname.append(".dat");
|
||||
std::ofstream dfile(fname.c_str());
|
||||
for(int ig=imin+1; ig<V.size(); ig++)
|
||||
{
|
||||
value_type _r = V.r(ig),y,dy,d2y;
|
||||
// V.setgrid(_r);
|
||||
y = V.evaluate(_r,1.0/_r,dy,d2y);
|
||||
dfile << std::setw(15) << setprecision(12) << _r << std::setw(20) << V(ig)
|
||||
<< std::setw(20) << dV[ig] << std::setw(20) << dy << std::setw(20) << d2V[ig]
|
||||
<< std::setw(20) << d2y << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
///returns the starting valid index
|
||||
inline int first() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param i index of the first value of the log grid
|
||||
*\param z0 \f$\Psi_{nl}(r_0)\f$
|
||||
*\param z1 \f$\Psi_{nl}(r_0 + dr)\f$
|
||||
*\return the derivate of the target function before transformation
|
||||
*\brief Assign the first and second values using the cusp condition.
|
||||
*
|
||||
For \f$l=0\f$ in the limit \f$r\rightarrow 0\f$
|
||||
\f[
|
||||
\Psi(r) \approx \sqrt{r}(1-Zr),
|
||||
\f]
|
||||
while for positive \f$l\f$ the condition is
|
||||
\f[
|
||||
\Psi(r) \approx r^{l+\frac{1}{2}}.
|
||||
\f]
|
||||
*/
|
||||
value_type setCusp(int i, value_type& z0, value_type& z1)
|
||||
{
|
||||
value_type r0 = V.r(i);
|
||||
value_type dr = V.dr(i);
|
||||
value_type deriv;
|
||||
if(L)
|
||||
{
|
||||
z0 = std::pow(r0,L+0.5);
|
||||
deriv = (L+0.5)*std::pow(r0,L-0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type r0h = sqrt(r0);
|
||||
z0 = r0h*(1-CuspParam*r0);
|
||||
deriv = 0.5*(1/r0h - 3.0*CuspParam*r0h);
|
||||
}
|
||||
z1 = z0 + deriv*dr;
|
||||
return deriv;
|
||||
}
|
||||
|
||||
///returns the number of nodes
|
||||
inline int nodes() const
|
||||
{
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*@brief return \f$ k'^2(r_i) \f$
|
||||
*
|
||||
\f[ = r_i^2 \left[ 2M(r_i)(V-\varepsilon')
|
||||
+ \frac{(l+\frac{1}{2})^2}{r_i^2}
|
||||
+ \left. \frac{\alpha^2}{2M(r_i)r_i}\frac{dV}{dr} \right|_{r=r_i}
|
||||
+ \frac{3\alpha^4}{16M(r_i)^2}
|
||||
\left. \left( \frac{dV}{dr} \right)^2 \right|_{r=r_i}
|
||||
+ \frac{\alpha^2}{4M(r_i)}\left. \frac{d^2V}{dr^2} \right|_{r=r_i}
|
||||
\right] \f]
|
||||
*/
|
||||
inline value_type k2(int i)
|
||||
{
|
||||
value_type r0 = V.r(i);
|
||||
value_type rinv = 1.0/r0;
|
||||
value_type rsq = std::pow(r0,2.0);
|
||||
// V.setgrid(r0);
|
||||
V.evaluate(r0,rinv);
|
||||
value_type M = 1.0 + 0.5*alpha2*(E-V.Y);
|
||||
value_type Minv = 1.0/M;
|
||||
return 2.0*(rsq*(M*(E-V.Y) - 0.5*Minv*alpha2*
|
||||
(0.5*rinv*V.dY + 0.1875*alpha2*Minv*V.dY*V.dY
|
||||
+ 0.25*V.d2Y)) - LL);
|
||||
//return 2.0*(rsq*(E-V.Y)-LL);
|
||||
}
|
||||
|
||||
|
||||
/*!\fn value_type convert(value_type y, value_type r)
|
||||
*\param y the value \f$\Psi_{nl}(r)\f$
|
||||
*\param r the grid value
|
||||
*\return \f$u_{nl}(r) = \sqrt{rM}\Psi_{nl}\f$
|
||||
*/
|
||||
inline value_type convert(value_type y, value_type r)
|
||||
{
|
||||
// int i = V.setgrid(r);
|
||||
value_type rinv = 1.0/r;
|
||||
V.evaluate(r,rinv);
|
||||
return y*sqrt(r)*sqrt(1.0 + 0.5*alpha2*(E-V.Y));
|
||||
}
|
||||
|
||||
///reset the reference energy and turning point
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
E = e;
|
||||
}
|
||||
};
|
||||
/**@}*/
|
||||
|
||||
#endif
|
|
@ -1,384 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
#include "Numerics/Clebsch_Gordan.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
RadialPotentialBase::~RadialPotentialBase()
|
||||
{
|
||||
if(Vext)
|
||||
delete Vext;
|
||||
if(integrand)
|
||||
delete integrand;
|
||||
}
|
||||
|
||||
void RadialPotentialBase::getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName)
|
||||
{
|
||||
std::string fname = RootFileName + ".Vext.xml";
|
||||
xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0");
|
||||
xmlNodePtr p0 = xmlNewNode(NULL, BAD_CAST "pseudo");
|
||||
{
|
||||
xmlNodePtr p1 = xmlNewNode(NULL,(const xmlChar*)"header");
|
||||
xmlNewProp(p1,(const xmlChar*)"symbol",(const xmlChar*)"H");
|
||||
xmlNewProp(p1,(const xmlChar*)"atomic-number",(const xmlChar*)"1");
|
||||
std::ostringstream s;
|
||||
s << Qinfty;
|
||||
xmlNewProp(p1,(const xmlChar*)"zval",(const xmlChar*)s.str().c_str());//this is important
|
||||
xmlNewProp(p1,(const xmlChar*)"creator",(const xmlChar*)"atomichf");
|
||||
xmlNewProp(p1,(const xmlChar*)"flavor",(const xmlChar*)"HF");
|
||||
xmlNewProp(p1,(const xmlChar*)"relativistic",(const xmlChar*)"no");
|
||||
xmlNewProp(p1,(const xmlChar*)"polarized",(const xmlChar*)"no");
|
||||
xmlNewProp(p1,(const xmlChar*)"core-correction",(const xmlChar*)"no");
|
||||
xmlNewProp(p1,(const xmlChar*)"xc-functional-type",(const xmlChar*)"HF");
|
||||
xmlNewProp(p1,(const xmlChar*)"xc-functional-parameterizaton",(const xmlChar*)"NA");
|
||||
xmlAddChild(p0,p1);
|
||||
}
|
||||
{
|
||||
xmlNodePtr p1 = xmlNewNode(NULL,(const xmlChar*)"grid");
|
||||
xmlNewProp(p1,(const xmlChar*)"grid_id",(const xmlChar*)"global");
|
||||
xmlNewProp(p1,(const xmlChar*)"type",(const xmlChar*)"numerical");
|
||||
xmlNewProp(p1,(const xmlChar*)"units",(const xmlChar*)"bohr");
|
||||
std::ostringstream s;
|
||||
s << psi.m_grid->size();
|
||||
xmlNewProp(p1,(const xmlChar*)"npts",(const xmlChar*)s.str().c_str());
|
||||
std::ostringstream gr;
|
||||
gr.setf(std::ios_base::scientific);
|
||||
gr.precision(15);
|
||||
gr <<"\n";
|
||||
for(int ig=0; ig<psi.m_grid->size(); ++ig)
|
||||
gr<<(*psi.m_grid)[ig]<< std::endl;
|
||||
xmlNodePtr posPtr=xmlNewTextChild(p1,NULL,
|
||||
(const xmlChar*)"data", (const xmlChar*)gr.str().c_str());
|
||||
xmlAddChild(p0,p1);
|
||||
}
|
||||
{
|
||||
xmlNodePtr p1 = xmlNewNode(NULL,(const xmlChar*)"semilocal");
|
||||
xmlNewProp(p1,(const xmlChar*)"units",(const xmlChar*)"hartree");
|
||||
xmlNewProp(p1,(const xmlChar*)"format",(const xmlChar*)"r*V");
|
||||
xmlNewProp(p1,(const xmlChar*)"npots-down",(const xmlChar*)"1");
|
||||
xmlNewProp(p1,(const xmlChar*)"npots-up",(const xmlChar*)"0");
|
||||
xmlNodePtr p2 = xmlNewNode(NULL,(const xmlChar*)"vps");
|
||||
xmlNewProp(p2,(const xmlChar*)"principal-n",(const xmlChar*)"100");
|
||||
xmlNewProp(p2,(const xmlChar*)"l",(const xmlChar*)"s");
|
||||
std::ostringstream s;
|
||||
s << Rcut;
|
||||
xmlNewProp(p2,(const xmlChar*)"cutoff",(const xmlChar*)s.str().c_str());
|
||||
xmlNewProp(p2,(const xmlChar*)"occupation",(const xmlChar*)"1");
|
||||
xmlNewProp(p2,(const xmlChar*)"spin",(const xmlChar*)"-1");
|
||||
xmlNodePtr p3 = xmlNewNode(NULL,(const xmlChar*)"radfunc");
|
||||
xmlNewProp(p3,(const xmlChar*)"grid_def",(const xmlChar*)"global");
|
||||
std::ostringstream gr;
|
||||
gr.setf(std::ios_base::scientific);
|
||||
gr.precision(15);
|
||||
gr <<"\n";
|
||||
for(int ig=0; ig<psi.m_grid->size(); ++ig)
|
||||
gr<<((*Vext)(ig))*((*psi.m_grid)[ig])<< std::endl;
|
||||
xmlNodePtr posPtr=xmlNewTextChild(p3,NULL,
|
||||
(const xmlChar*)"data", (const xmlChar*)gr.str().c_str());
|
||||
xmlAddChild(p2,p3);
|
||||
xmlAddChild(p1,p2);
|
||||
xmlAddChild(p0,p1);
|
||||
}
|
||||
xmlDocSetRootElement(doc, p0);
|
||||
xmlSaveFormatFile(fname.c_str(),doc,1);
|
||||
xmlFreeDoc(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
*@param cg The Clebsch-Gordan matrix elements
|
||||
*@param norb the number of orbitals
|
||||
*@brief The Constructor for the HartreePotential
|
||||
*/
|
||||
HartreePotential::HartreePotential(Clebsch_Gordan* cg, int norb)
|
||||
: CG_coeff(cg), Ykii_r(0), Ykjj_r(0)
|
||||
{
|
||||
storage.resize(norb*(norb+1)/2);
|
||||
for(int nn=0; nn<storage.size(); nn++)
|
||||
storage[nn] = 0.0;
|
||||
}
|
||||
HartreePotential::~HartreePotential()
|
||||
{
|
||||
if(Ykii_r)
|
||||
{
|
||||
delete Ykii_r;
|
||||
delete Ykjj_r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param V increment the potential
|
||||
*@parma norb the number of orbitals
|
||||
*@return The Hartree energy
|
||||
\f[
|
||||
E_{Hartree} =
|
||||
\frac{1}{2} \sum_{ij} \sum_{k=0}^{\min(2l_i,2l_j)} (-1)^{-m_i-m_j}
|
||||
\frac{(2l_j+1)(2l_i+1)}{(2k+1)^2} \\
|
||||
\langle l_j m_j l_j (-m_j)| k 0 \rangle \langle l_j 0 l_j 0| k 0 \rangle
|
||||
\langle l_i m_i l_i (-m_i)| k 0 \rangle \langle l_i 0 l_i 0| k 0 \rangle
|
||||
{\cal R}^k(ij;ij)
|
||||
\f]
|
||||
*
|
||||
*@brief Calculates the Hartree potential for each orbital and the
|
||||
*Hartree energy.
|
||||
*
|
||||
The Hartree potential for the \textit{ith} orbital
|
||||
\f[
|
||||
\hat{V}_{H} u_{n_i l_i}(r) =
|
||||
\sum_j \sum_{k=0}^{\min(2l_i,2l_j)} (-1)^{-m_i-m_j}
|
||||
\frac{(2l_j+1)(2l_i+1)}{(2k+1)^2} \langle l_j m_j l_j (-m_j)| k 0 \rangle
|
||||
\langle l_j 0 l_j 0| k 0 \rangle
|
||||
\langle l_i m_i l_i (-m_i)| k 0 \rangle \langle l_i 0 l_i 0| k 0 \rangle
|
||||
\frac{{\cal Y}_k(n_jl_j;n_jl_j/r)}{r} u_{n_i l_i}(r)
|
||||
\f]
|
||||
*
|
||||
see RadialFunctorUtility.h for the implementation of
|
||||
\f$ {\cal Y}_k(n_jl_j;n_jl_j/r) /r \f$ and
|
||||
\f$ {\cal R}^k(ij;ij). \f$
|
||||
*
|
||||
*@note The sumnation over the orbitals {ij} includes \f$ i=j. \f$
|
||||
*/
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
HartreePotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb)
|
||||
{
|
||||
int kmax, k;
|
||||
int pt;
|
||||
value_type coeff, ith_orb_coeff, jth_orb_coeff, energy_coeff = 0;
|
||||
value_type Ehartree=0;
|
||||
if(Ykii_r==0)
|
||||
{
|
||||
Ykii_r=new RadialOrbital_t(psi(0));
|
||||
Ykjj_r=new RadialOrbital_t(psi(0));
|
||||
}
|
||||
RadialOrbital_t& ykii_ref(*Ykii_r);
|
||||
RadialOrbital_t& ykjj_ref(*Ykjj_r);
|
||||
//RadialOrbital_t Ykii_r(psi(0));
|
||||
//RadialOrbital_t Ykjj_r(psi(0));
|
||||
//RadialOrbital_t Psisq_x_Yk(psi(0));
|
||||
int npts = psi.m_grid->size();
|
||||
int nn=0;
|
||||
for(int i=0; i < norb; i++)
|
||||
{
|
||||
int mi = psi.M[i];
|
||||
int li = psi.L[i];
|
||||
int two_li_plus_one = 2*li + 1;
|
||||
for(int j=i; j < norb; j++, nn++)
|
||||
{
|
||||
int mj = psi.M[j];
|
||||
int lj = psi.L[j];
|
||||
int two_lj_plus_one = 2*lj + 1;
|
||||
int kmax = (li > lj) ? 2*lj : 2*li;
|
||||
for(int k=kmax; k >= 0; k -= 2)
|
||||
{
|
||||
int two_k_plus_one = 2*k+1;
|
||||
coeff = static_cast<value_type>(two_li_plus_one*two_lj_plus_one)/
|
||||
static_cast<value_type>(two_k_plus_one)/static_cast<value_type>(two_k_plus_one)
|
||||
* CG_coeff->cg(li,li,k,0,0) * CG_coeff->cg(lj,lj,k,0,0)
|
||||
* CG_coeff->cg(li,li,k,mi,-mi) * CG_coeff->cg(lj,lj,k,mj,-mj)
|
||||
* std::pow(-1.0, mi+mj);
|
||||
if(i == j)
|
||||
coeff /= 2.0; //double counting
|
||||
ith_orb_coeff = psi.Occ[i] * coeff;
|
||||
jth_orb_coeff = psi.Occ[j] * coeff;
|
||||
energy_coeff = psi.Occ[j] * psi.Occ[i] * coeff;
|
||||
Ykofr(*Ykii_r, psi(i), psi(i), k);
|
||||
Ykofr(*Ykjj_r, psi(j), psi(j), k);
|
||||
for(int gp=0; gp<npts; gp++)
|
||||
{
|
||||
V[i](gp) += jth_orb_coeff*ykjj_ref(gp);
|
||||
V[j](gp) += ith_orb_coeff*ykii_ref(gp);
|
||||
}
|
||||
storage[nn] = 0.0;
|
||||
storage[nn] += Phisq_x_Yk(ykjj_ref, psi(i), psi(i), 0.5*energy_coeff);
|
||||
storage[nn] += Phisq_x_Yk(ykii_ref, psi(j), psi(j), 0.5*energy_coeff);
|
||||
Ehartree += storage[nn];
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ehartree;
|
||||
}
|
||||
|
||||
void HartreePotential::getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName)
|
||||
{
|
||||
std::string fileforoutput = RootFileName + ".hartree";
|
||||
std::ofstream fout(fileforoutput.c_str());
|
||||
std::string llabel("spdf");
|
||||
std::string slabel("d0u");
|
||||
int norb = psi.size();
|
||||
int nn=0;
|
||||
value_type temp;
|
||||
fout << "orb#1" << '\t' << "orb#2" << '\t' << "Hartree" << std::endl;
|
||||
fout.precision(12);
|
||||
fout.setf(std::ios::scientific,std::ios::floatfield);
|
||||
for(int i=0; i<norb; i++)
|
||||
{
|
||||
for(int j=i; j<norb; j++, nn++)
|
||||
{
|
||||
temp = storage[nn];
|
||||
if(std::abs(temp) < 1e-12)
|
||||
temp = 0.0;
|
||||
fout << psi.N[i] << llabel[psi.L[i]] << slabel[psi.S[i]+1]
|
||||
<< '\t' << psi.N[j] << llabel[psi.L[j]] << slabel[psi.S[j]+1]
|
||||
<< '\t' << temp << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*@param cg The Clebsch-Gordan matrix elements
|
||||
*@param norb the number of orbitals
|
||||
*@brief The Constructor for the ExchangePotential
|
||||
*/
|
||||
|
||||
ExchangePotential::ExchangePotential(Clebsch_Gordan* cg, int norb)
|
||||
: CG_coeff(cg) , Ykij_r(0)
|
||||
{
|
||||
storage.resize(norb*(norb+1)/2);
|
||||
for(int nn=0; nn<storage.size(); nn++)
|
||||
storage[nn] = 0.0;
|
||||
}
|
||||
|
||||
ExchangePotential::~ExchangePotential()
|
||||
{
|
||||
if(Ykij_r)
|
||||
delete Ykij_r;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param V increment the potential
|
||||
*@parma norb the number of orbitals
|
||||
*@return The Exchange energy
|
||||
\f[
|
||||
E_{Exchange} =
|
||||
-\sum_j \delta_{\sigma_i,\sigma_j} \sum_{k=|l_j-l_i|}^{l_i+l_j}
|
||||
\frac{(2l_i+1)(2l_j+1)}{(2k+1)^2}
|
||||
\langle l_i (-m_i) l_j m_j| k (m_i-m_j) \rangle^2
|
||||
\langle l_i 0 l_j 0| k 0 \rangle^2 {\cal R}^k(ij;ji)
|
||||
\f]
|
||||
*
|
||||
*@brief Calculates and the Exchange potential for each orbital and
|
||||
the Exchange energy.
|
||||
*
|
||||
The Exchange potential for the \textit{ith} orbital
|
||||
\f[
|
||||
\hat{V}_{E} u_{n_j l_j}(r) =
|
||||
-\sum_j \delta_{\sigma_i,\sigma_j} \sum_{k=|l_j-l_i|}^{l_i+l_j}
|
||||
\frac{(2l_i+1)(2l_j+1)}{(2k+1)^2}
|
||||
\langle l_i (-m_i) l_j m_j| k (m_i-m_j) \rangle^2
|
||||
\langle l_i 0 l_j 0| k 0 \rangle^2
|
||||
\frac{{\cal Y}_k(n_jl_j;n_il_i/r)}{r} u_{n_j l_j}(r)
|
||||
\f]
|
||||
*
|
||||
see RadialFunctorUtility.h for the implementation of
|
||||
\f$ {\cal Y}_k(n_jl_j;n_il_i/r) /r \f$ and
|
||||
\f$ {\cal R}^k(ij;ji). \f$ Also includes a function to
|
||||
make the exchange a local potential.
|
||||
*
|
||||
*@note The sumnation over the orbitals {ij} includes \f$ i=j. \f$
|
||||
*/
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
ExchangePotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb)
|
||||
{
|
||||
value_type ith_orb_coeff, jth_orb_coeff, coeff;
|
||||
value_type energy_coeff=0;
|
||||
value_type Eexchange=0;
|
||||
//zero_all_orbitals(); V is reset before entering
|
||||
if(Ykij_r==0)
|
||||
{
|
||||
Ykij_r = new RadialOrbital_t(psi(0));
|
||||
}
|
||||
int nn=0;
|
||||
//Loop over all pairs of electrons once
|
||||
for(int i=0; i < norb; i++)
|
||||
{
|
||||
int si = psi.S[i];
|
||||
int mi = psi.M[i];
|
||||
int li = psi.L[i];
|
||||
int two_li_plus_one = 2*li + 1;
|
||||
for(int j=i; j < norb; j++, nn++)
|
||||
{
|
||||
int sj = psi.S[j];
|
||||
int mj = psi.M[j];
|
||||
int lj = psi.L[j];
|
||||
int two_lj_plus_one = 2*lj + 1;
|
||||
int kmax = li + lj;
|
||||
int kmin = std::abs(li - lj);
|
||||
if( si == sj )
|
||||
{
|
||||
for(int k=kmax; k >= kmin; k-=2)
|
||||
{
|
||||
int two_k_plus_one = 2*k + 1;
|
||||
coeff = static_cast<value_type>(two_li_plus_one * two_lj_plus_one) /
|
||||
static_cast<value_type>(two_k_plus_one*two_k_plus_one)
|
||||
* CG_coeff->cg(li,lj,k,0,0) * CG_coeff->cg(li,lj,k,-mi,mj)
|
||||
* CG_coeff->cg(li,lj,k,0,0) * CG_coeff->cg(li,lj,k,-mi,mj);
|
||||
if(i == j)
|
||||
coeff /= 2.0; //double counting
|
||||
ith_orb_coeff = psi.Occ[i] * coeff;
|
||||
jth_orb_coeff = psi.Occ[j] * coeff;
|
||||
energy_coeff = psi.Occ[j] * psi.Occ[i] * coeff;
|
||||
Ykofr(*Ykij_r, psi(i), psi(j), k); // Ykofr_phi1_phi2
|
||||
Make_Loc_Pot(V[i], *Ykij_r, psi(i), psi(j),jth_orb_coeff);
|
||||
Make_Loc_Pot(V[j], *Ykij_r, psi(j), psi(i),ith_orb_coeff);
|
||||
storage[nn] = -1.0*Phisq_x_Yk(*Ykij_r, psi(i), psi(j), energy_coeff);
|
||||
Eexchange += storage[nn];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Eexchange;
|
||||
}
|
||||
|
||||
void ExchangePotential::getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName)
|
||||
{
|
||||
std::string fileforoutput = RootFileName + ".exchange";
|
||||
std::ofstream fout(fileforoutput.c_str());
|
||||
std::string llabel("spdf");
|
||||
std::string slabel("d0u");
|
||||
int norb = psi.size();
|
||||
int nn=0;
|
||||
value_type temp;
|
||||
fout << "orb#1" << '\t' << "orb#2" << '\t' << "Exchange" << std::endl;
|
||||
fout.precision(12);
|
||||
fout.setf(std::ios::scientific,std::ios::floatfield);
|
||||
for(int i=0; i<norb; i++)
|
||||
{
|
||||
for(int j=i; j<norb; j++, nn++)
|
||||
{
|
||||
temp = storage[nn];
|
||||
if(std::abs(temp) < 1e-12)
|
||||
temp = 0.0;
|
||||
fout << psi.N[i] << llabel[psi.L[i]] << slabel[psi.S[i]+1]
|
||||
<< '\t' << psi.N[j] << llabel[psi.L[j]] << slabel[psi.S[j]+1]
|
||||
<< '\t' << temp << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,195 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_RADIALPOTENTIALBASE_H
|
||||
#define OHMMSHF_RADIALPOTENTIALBASE_H
|
||||
|
||||
#include "SQD/HFConfiguration.h"
|
||||
#include "OhmmsData/libxmldefs.h"
|
||||
|
||||
class Clebsch_Gordan;
|
||||
/**
|
||||
*@defgroup RadialPotential
|
||||
*@brief Classes to define potentials on a radial grid.
|
||||
*
|
||||
*A radial potential is defined on a radial grid,
|
||||
*OneDimGridBase<T> and RadialPotentialSet are used to represent
|
||||
*the LHS of Radial Schrodinger Equation.
|
||||
*/
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
*@ingroup RadialPotential
|
||||
*@class RadialPotentialBase
|
||||
*@brief An abstract base class for a Radial Potential.
|
||||
*
|
||||
*Inherited classes implement the member function evaluate
|
||||
*to calculate matrix elements for a Hamiltonian term.
|
||||
*/
|
||||
struct RadialPotentialBase
|
||||
{
|
||||
|
||||
typedef SphericalOrbitalTraits::BasisSetType BasisSetType;
|
||||
typedef SphericalOrbitalTraits::value_type value_type;
|
||||
typedef SphericalOrbitalTraits::RadialGrid_t RadialGrid_t;
|
||||
typedef SphericalOrbitalTraits::RadialOrbital_t RadialOrbital_t;
|
||||
typedef SphericalOrbitalTraits::RadialOrbitalSet_t RadialOrbitalSet_t;
|
||||
|
||||
///lower-bound for eigenvalues
|
||||
value_type MinEigenValue;
|
||||
|
||||
///upper-bound for eigenvalues
|
||||
value_type MaxEigenValue;
|
||||
|
||||
///the core charge at infinity
|
||||
value_type Qinfty;
|
||||
///the cutoff radius
|
||||
value_type Rcut;
|
||||
|
||||
///storage for an external potential
|
||||
RadialOrbital_t* Vext;
|
||||
///storage for a temporary integrand
|
||||
RadialOrbital_t* integrand;
|
||||
|
||||
///constructor
|
||||
RadialPotentialBase()
|
||||
: MinEigenValue(0.0), MaxEigenValue(0.0), Qinfty(0.0), Rcut(1.0)
|
||||
, Vext(0), integrand(0)
|
||||
{}
|
||||
|
||||
///destructor
|
||||
virtual ~RadialPotentialBase();
|
||||
|
||||
/**
|
||||
*@param psi the wavefunction
|
||||
*@param V the potential
|
||||
*@param norb the number of orbitals
|
||||
*@return The sum of the matrix elements of a Radial Potential \f$V(r)\f$
|
||||
*@brief Calculates and assigns the values of a Randial Potential for
|
||||
*each orbital.
|
||||
*
|
||||
\f[
|
||||
\sum_{k=0}^{N_{orb}} \langle k|V(r)|k \rangle = \sum_{k=0}^{N_{orb}}
|
||||
\int_0^{\infty} dr \: \psi_k^*(r)V(r)\psi_k(r)
|
||||
\f]
|
||||
*/
|
||||
virtual
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V,
|
||||
int norb) = 0;
|
||||
|
||||
/**
|
||||
*@param n the principal quantum number
|
||||
*@param l the angular quantum number
|
||||
*@return the number of radial nodes
|
||||
*/
|
||||
virtual int getNumOfNodes(int n, int l)=0;
|
||||
|
||||
/**
|
||||
*@param RootFileName the name of file root
|
||||
*@brief Output the internal storage of the potential.
|
||||
*@note Only applies for the Hartree and Exchange potentials.
|
||||
*/
|
||||
virtual void getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName);
|
||||
|
||||
/**
|
||||
*@param ig the grid index
|
||||
*@return the value of the external potential
|
||||
*/
|
||||
inline
|
||||
value_type getV(int ig) const
|
||||
{
|
||||
return (*Vext)(ig);
|
||||
}
|
||||
|
||||
|
||||
/**@return the pointer of the data **/
|
||||
inline value_type* data() const
|
||||
{
|
||||
if(Vext)
|
||||
return Vext->data();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
*@param cur the current xml node to process
|
||||
*@return true if the input is valid
|
||||
*/
|
||||
virtual bool put(xmlNodePtr cur)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*@ingroup RadialPotential
|
||||
*@class HartreePotential
|
||||
*@brief Implements the Hartree potential.
|
||||
*/
|
||||
struct HartreePotential: public RadialPotentialBase
|
||||
{
|
||||
///the Clebsch Gordan coefficient matrix
|
||||
Clebsch_Gordan *CG_coeff;
|
||||
///aux functors
|
||||
RadialOrbital_t *Ykii_r;
|
||||
RadialOrbital_t *Ykjj_r;
|
||||
|
||||
/**store the matrix elements
|
||||
\f$\langle \psi_i \psi_j |V| \psi_i \psi_j \rangle \f$ */
|
||||
Vector<value_type> storage;
|
||||
HartreePotential(Clebsch_Gordan* cg, int norb);
|
||||
~HartreePotential();
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
void getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName);
|
||||
int getNumOfNodes(int n, int l)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*@ingroup RadialPotential
|
||||
*@class ExchangePotential
|
||||
*@brief Implements the exchange potential
|
||||
*/
|
||||
struct ExchangePotential: public RadialPotentialBase
|
||||
{
|
||||
///the Clebsch Gordan coefficient matrix
|
||||
Clebsch_Gordan *CG_coeff;
|
||||
RadialOrbital_t *Ykij_r;
|
||||
/**store the matrix elements
|
||||
\f$\langle \psi_i \psi_j |V| \psi_j \psi_i \rangle \f$ */
|
||||
Vector<value_type> storage;
|
||||
ExchangePotential(Clebsch_Gordan* cg, int norb);
|
||||
~ExchangePotential();
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
void getStorage(const BasisSetType& psi,
|
||||
const std::string& RootFileName);
|
||||
int getNumOfNodes(int n, int l)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jordan E. Vincent, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_REGULAR_LINEAR_TRANSFORMFUNCTION_H
|
||||
#define OHMMS_REGULAR_LINEAR_TRANSFORMFUNCTION_H
|
||||
|
||||
#include <numeric>
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
|
||||
/**@ingroup NumerovTransform
|
||||
*\brief Transform function for the radial Schroedinger equation on a
|
||||
*linear grid with a regular potential.
|
||||
*
|
||||
*For regular potentials, the asymptotic approximation for \f$u_{l}\f$
|
||||
*near the origin follows\f[\lim_{r\rightarrow 0} u(r) \approx r^{(l+1)}. \f]
|
||||
*An example for Regular potentials is a Harmonic potential,
|
||||
\f[
|
||||
V(r) = \frac{1}{2}\omega^2r^2.
|
||||
\f]
|
||||
*
|
||||
*Implements a transformation for the Numerov algorithm:
|
||||
\f[
|
||||
\frac{d^2u_{nl}}{dr^2}+k^2(r) u_{nl} = 0,
|
||||
\f]
|
||||
*where
|
||||
\f[
|
||||
k^2(r)=2[\varepsilon-\frac{L(L+1)}{2r^2}-V(r)].
|
||||
\f]
|
||||
*
|
||||
*/
|
||||
template<class SourceType>
|
||||
struct RegularLinearTransform
|
||||
{
|
||||
|
||||
typedef SourceType Source_t;
|
||||
typedef typename SourceType::value_type value_type;
|
||||
|
||||
///source function on a linear grid
|
||||
Source_t& V;
|
||||
|
||||
///number of nodes for given quantum numbers
|
||||
int NumNodes;
|
||||
|
||||
///reference energy \f$\varepsilon\f$
|
||||
value_type E;
|
||||
|
||||
///parameter to determine the cusp condition
|
||||
value_type CuspParam;
|
||||
|
||||
///principal quantum number
|
||||
value_type N;
|
||||
|
||||
///angular momentum quantum number
|
||||
value_type L;
|
||||
|
||||
///LL \f$=l(l+1)/(2m_{eff})\f$
|
||||
value_type LL;
|
||||
|
||||
/** Constructor for \f$u_{nl}\f$
|
||||
* \param v the source function on a grid
|
||||
* \param n the principal quantum number
|
||||
* \param cusparam parameter used to calculate cusp conditions
|
||||
* \param meff the effective mass
|
||||
* \note For the Harmonic potential \f$V(r) = \frac{1}{2}\omega^2r^2\f$
|
||||
* the number of nodes for the radial function with quantum numbers
|
||||
* \f$n\f$ and \f$l\f$ is \f$n\f$.
|
||||
*\todo The argument cuspparam should be removed and the source
|
||||
* object should encapsulate the cusp conditions.
|
||||
*/
|
||||
RegularLinearTransform(Source_t& v,
|
||||
int n,
|
||||
int l,
|
||||
value_type cuspparam,
|
||||
value_type meff=1.0):
|
||||
V(v), E(0.0), N(n), CuspParam(cuspparam)
|
||||
{
|
||||
NumNodes = v.getNumOfNodes();
|
||||
L = static_cast<value_type>(l);
|
||||
LL = 0.5*L*(L+1)/meff;
|
||||
}
|
||||
|
||||
///returns the starting valid index
|
||||
inline int first() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param i index of the first value of the linear grid
|
||||
*\param z0 \f$u_{nl}(r_0)\f$
|
||||
*\param z1 \f$u_{nl}(r_0 + dr)\f$
|
||||
*\return the derivate of the target function before transformation
|
||||
*\brief Assign the first and second values using the cusp condition.
|
||||
*
|
||||
In the limit \f$r\rightarrow 0 \f$ \f[u(r) \approx r^{(l+1)}.\f]
|
||||
*/
|
||||
value_type setCusp(int i, value_type& z0, value_type& z1)
|
||||
{
|
||||
value_type deriv;
|
||||
value_type r0 = V.r(i);
|
||||
value_type dr = V.dr(i);
|
||||
z0 = std::pow(r0,L+1);
|
||||
if(L)
|
||||
deriv = static_cast<value_type>(L+1)*std::pow(r0,L);
|
||||
else
|
||||
deriv = 1.0;
|
||||
z1 = z0 + deriv*dr;
|
||||
return deriv;
|
||||
}
|
||||
|
||||
///returns the number of nodes
|
||||
inline int nodes() const
|
||||
{
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
///return \f$k^2(r_i)=2[\varepsilon-L(L+1)/2r_i^2-V(r_i)]\f$
|
||||
inline value_type k2(int i)
|
||||
{
|
||||
value_type rinv = 1.0/V.r(i);
|
||||
return 2.0*(E-LL*rinv*rinv-V(i));
|
||||
}
|
||||
|
||||
/*!\fn value_type convert(value_type y, value_type r)
|
||||
*\param y the value of \f$u_{nl}(r)\f$
|
||||
*\param r the grid value
|
||||
*\return the same value: no transformation is needed.
|
||||
*/
|
||||
inline value_type convert(value_type y, value_type r)
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
///reset the reference energy and turning point
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
E = e;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,150 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_REGULAR_LOG_TRANSFORMFUNCTION_H
|
||||
#define OHMMS_REGULAR_LOG_TRANSFORMFUNCTION_H
|
||||
|
||||
#include "Numerics/OneDimGridFunctor.h"
|
||||
|
||||
/**@ingroup NumerovTransform
|
||||
*\brief Transform function for the radial Schroedinger equation on a log grid
|
||||
*with a regular potential.
|
||||
*
|
||||
*For regular potentials, the asymptotic approximation for \f$u_{l}\f$
|
||||
*near the origin follows\f[\lim_{r\rightarrow 0} u(r) \approx r^{(l+1)}.\f]
|
||||
*An example for Regular potentials is a Harmonic potential,
|
||||
\f[
|
||||
V(r) = \frac{1}{2}\omega^2r^2.
|
||||
\f]
|
||||
*
|
||||
*Since the Numerov algorithm can only be integrated on a uniform grid,
|
||||
*it is necessary to make the following change of variables
|
||||
*\f[
|
||||
Z_{nl}(r) = \frac{u_{nl}(r)}{\sqrt{r}} \mbox{ and } y = log(r).
|
||||
\f]
|
||||
*The Transform function for the Numerov algorithm becomes
|
||||
\f[
|
||||
\frac{d^2Z_{nl}(y)}{dy^2} + k'^2(r)Z_{nl}(y) = 0,
|
||||
\f]
|
||||
where
|
||||
\f[
|
||||
k'^2(r) = 2r^2[\varepsilon -\frac{(L+\frac{1}{2})^2}{2r^2}-V(r)]
|
||||
\f]
|
||||
*/
|
||||
template<class SourceType>
|
||||
struct RegularLogTransform
|
||||
{
|
||||
|
||||
typedef SourceType Source_t;
|
||||
typedef typename SourceType::value_type value_type;
|
||||
|
||||
Source_t& V;
|
||||
|
||||
///number of nodes for given quantum numbers
|
||||
int NumNodes;
|
||||
|
||||
///reference energy \f$\varepsilon\f$
|
||||
value_type E;
|
||||
|
||||
///parameter to determine the cusp condition
|
||||
value_type CuspParam;
|
||||
|
||||
///principal quantum number
|
||||
value_type N;
|
||||
|
||||
///angular momentum quantum number
|
||||
value_type L;
|
||||
|
||||
///\f[LL=(l+\frac{1}{2})^2/(2m_{eff})\f]
|
||||
value_type LL;
|
||||
|
||||
/** Constructor for \f$Z_{nl}\f$
|
||||
* \param v the source function on a grid
|
||||
* \param n the principal quantum number
|
||||
* \param l the anuglar quantum number
|
||||
* \param z the charge
|
||||
* \param meff the effective mass
|
||||
* \note For the Harmonic potential \f$V(r) = \frac{1}{2}\omega^2r^2\f$
|
||||
* the number of nodes for the radial function with quantum numbers
|
||||
* \f$n\f$ and \f$l\f$ is \f$n\f$.
|
||||
*/
|
||||
RegularLogTransform(Source_t& v, int n, int l,
|
||||
value_type cuspparam,
|
||||
value_type meff=1.0):
|
||||
V(v), E(0.0), N(n), CuspParam(cuspparam)
|
||||
{
|
||||
NumNodes = v.getNumOfNodes();
|
||||
L = static_cast<value_type>(l);
|
||||
LL = 0.5*(L+0.5)*(L+0.5)/meff;
|
||||
}
|
||||
|
||||
///returns the starting valid index
|
||||
inline int first() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*\param i index of the first value of the log grid
|
||||
*\param z0 \f$Z_{nl}(r_0)\f$
|
||||
*\param z1 \f$Z_{nl}(r_0 + dr)\f$
|
||||
*\return the derivate of the target function before transformation
|
||||
*\brief Assign the first and second values using the cusp condition.
|
||||
*
|
||||
In the limit \f$r\rightarrow 0 \f$ \f[ Z_{nl}(r)
|
||||
\approx r^{(l+\frac{1}{2})}. \f]
|
||||
*/
|
||||
value_type setCusp(int i, value_type& z0, value_type& z1)
|
||||
{
|
||||
value_type r0 = V.r(i);
|
||||
value_type dr = V.dr(i);
|
||||
z0 = std::pow(r0,L+0.5);
|
||||
z1 = z0 + (L+0.5)*std::pow(r0,L-0.5)*dr;
|
||||
return static_cast<value_type>(L+1)*std::pow(r0,L);
|
||||
}
|
||||
|
||||
///returns the number of nodes
|
||||
inline int nodes() const
|
||||
{
|
||||
return NumNodes;
|
||||
}
|
||||
|
||||
/*return \f$ k'^2(r_i) = 2r_i^2[\varepsilon
|
||||
-(L+\frac{1}{2})^2/2r_i^2-V(r_i)] \f$
|
||||
*/
|
||||
inline value_type k2(int i)
|
||||
{
|
||||
value_type rsq = std::pow(V.r(i),2.0);
|
||||
return 2.0*(rsq*(E-V(i))-LL); //2.0*rsq*(E-LL/rsq-V(i));
|
||||
}
|
||||
|
||||
/*!\fn value_type convert(value_type y, value_type r)
|
||||
*\param y the value \f$Z_{nl}(r)\f$
|
||||
*\param r the grid value
|
||||
*\return \f$u_{nl}(r) = \sqrt{r}Z_{nl}(r)\f$
|
||||
*/
|
||||
inline value_type convert(value_type y, value_type r)
|
||||
{
|
||||
return y*sqrt(r);
|
||||
}
|
||||
|
||||
///reset the reference energy and turning point
|
||||
inline void reset(value_type e)
|
||||
{
|
||||
E = e;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,103 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include "SQD/SphericalPotential/SHEGPotential.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
#include "OhmmsData/ParameterSet.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
SHEGPotential::SHEGPotential(int nel, value_type rs):
|
||||
Ntot(nel), Zext(nel), Rs(rs), Zgauss(0.0), Sgauss(1.0)
|
||||
{
|
||||
MaxEigenValue=0.0;
|
||||
}
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
SHEGPotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V,
|
||||
int norb)
|
||||
{
|
||||
//intialize the external potential
|
||||
if(!Vext)
|
||||
{
|
||||
integrand=new RadialOrbital_t(psi(0));
|
||||
//evaluate Rmax from the density
|
||||
Rmax=Rs*std::pow(Ntot,1.0/3.0);
|
||||
Qinfty=Zext;//assign Zext to Qinfty
|
||||
Rcut=Rmax;//assign Rmax to Rcut
|
||||
value_type normin=-Zext/2.0/Rmax;
|
||||
value_type r2=1.0/Rmax/Rmax;
|
||||
XMLReport(" Total charge = " << Ntot);
|
||||
XMLReport(" Total background charge = " << Zext);
|
||||
XMLReport(" Rs (density) = " << Rs);
|
||||
XMLReport(" Rmax (background) = " << Rmax);
|
||||
XMLReport(" Zgauss (gaussian depth) = " << Zgauss);
|
||||
XMLReport(" Sgauss (gaussian width) = " << Sgauss);
|
||||
Vext = new RadialOrbital_t(psi(0));
|
||||
for(int ig=0; ig < psi.m_grid->size(); ++ig)
|
||||
{
|
||||
value_type r=(*psi.m_grid)(ig);
|
||||
if(r<=Rmax)
|
||||
(*Vext)(ig)=normin*(3.0-(r*r)*r2)-Zgauss * exp(-r*r/Sgauss/Sgauss);
|
||||
else
|
||||
(*Vext)(ig)=-Zext/r-Zgauss * exp(-r*r/Sgauss/Sgauss) ;
|
||||
// std::cout << r << " " << (*Vext)(ig) << std::endl;
|
||||
}
|
||||
}
|
||||
for(int ig=0; ig < psi.m_grid->size(); ++ig)
|
||||
{
|
||||
value_type t = (*Vext)(ig);
|
||||
value_type sum = 0.0;
|
||||
for(int o=0; o < norb; o++)
|
||||
{
|
||||
V[o](ig) += t;
|
||||
sum += psi(o,ig)*psi(o,ig);
|
||||
//sum += std::pow(psi(o,ig),2);
|
||||
}
|
||||
(*integrand)(ig) = t*sum;
|
||||
}
|
||||
return integrate_RK2(*integrand);
|
||||
}
|
||||
|
||||
/** return the number of nodes for n and l
|
||||
* @param n principal quantum number
|
||||
* @param l angular number
|
||||
* @return number of nodes
|
||||
*/
|
||||
int SHEGPotential::getNumOfNodes(int n, int l)
|
||||
{
|
||||
MinEigenValue=-Ntot*3./2./Rmax - Zgauss;
|
||||
//double check this
|
||||
return n;
|
||||
}
|
||||
|
||||
bool SHEGPotential::put(xmlNodePtr cur)
|
||||
{
|
||||
ParameterSet params;
|
||||
params.add(Rs,"rs","double");
|
||||
params.add(Zext,"Z","double");
|
||||
params.add(Zgauss,"Zgauss","double");
|
||||
params.add(Sgauss,"Sgauss","double");
|
||||
params.put(cur);
|
||||
if(Zext<Ntot)
|
||||
{
|
||||
XMLReport("Invalid background charge Z=" << Zext << " Overwriting by " << Ntot);
|
||||
Zext=Ntot;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_SPHERICAL_HEG_POTENTIAL_H
|
||||
#define OHMMSHF_SPHERICAL_HEG_POTENTIAL_H
|
||||
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class SHEGPotential
|
||||
@brief implements spherical jellium
|
||||
*/
|
||||
struct SHEGPotential: public RadialPotentialBase
|
||||
{
|
||||
///number of particles
|
||||
value_type Ntot;
|
||||
///external background charge
|
||||
value_type Zext;
|
||||
value_type Zgauss;
|
||||
value_type Sgauss;
|
||||
///density
|
||||
value_type Rs;
|
||||
///maximum radius of the background charge
|
||||
value_type Rmax;
|
||||
|
||||
SHEGPotential(int nel, value_type rs=1);
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
///return \f$ n \f$
|
||||
int getNumOfNodes(int n, int l);
|
||||
|
||||
bool put(xmlNodePtr cur);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,86 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include "SQD/SphericalPotential/SJPseudoPotential.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
* \param vreg a registry for the optimizable variables \f$r_c\f$
|
||||
* and \f$\lambda\f$
|
||||
* \param zeff \f$Z_{Eff}\f$ the effective charge of the core
|
||||
* \param r_c \f$r_{c}\f$ the core-radius
|
||||
* \param lambda \f$\lambda\f$ the decay parameter
|
||||
* \brief The Constructor for the Starkloff-Joannopoulos
|
||||
* pseudopotential
|
||||
*
|
||||
*/
|
||||
|
||||
SJPseudoPotential::SJPseudoPotential(VarRegistry<value_type>& vreg,
|
||||
value_type zeff, value_type r_c,
|
||||
value_type lambda):
|
||||
Zeff(zeff), rc(r_c), SJ_lambda(lambda)
|
||||
{
|
||||
vreg["SJ_lambda"]=SJ_lambda;
|
||||
vreg["r_core"]=rc;
|
||||
//vreg.add("SJ_lambda",&SJ_lambda);
|
||||
//vreg.add("r_core",&rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* \param zeff \f$Z_{Eff}\f$ the effective charge of the core
|
||||
* \param r_c \f$r_{c}\f$ the core-radius
|
||||
* \param lambda \f$\lambda\f$ the decay parameter
|
||||
* \brief The Constructor for the Starkloff-Joannopoulos
|
||||
pseudopotential
|
||||
*
|
||||
*/
|
||||
|
||||
SJPseudoPotential::SJPseudoPotential(value_type zeff, value_type r_c,
|
||||
value_type lambda):
|
||||
Zeff(zeff), rc(r_c), SJ_lambda(lambda) { }
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
SJPseudoPotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb)
|
||||
{
|
||||
RadialOrbital_t integrand(psi(0));
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
value_type r = psi.m_grid->r(ig);
|
||||
value_type SJ_num = 1.0-exp(-SJ_lambda*r);
|
||||
value_type SJ_den = 1.0+exp(-SJ_lambda*(r-rc));
|
||||
value_type v = -Zeff/r*SJ_num/SJ_den;
|
||||
value_type sum = 0.0;
|
||||
for(int o=0; o < norb; o++)
|
||||
{
|
||||
V[o](ig) += v;
|
||||
sum += std::pow(psi(o,ig),2);
|
||||
}
|
||||
integrand(ig) = v*sum;
|
||||
}
|
||||
return integrate_RK2(integrand);
|
||||
}
|
||||
|
||||
int SJPseudoPotential::getNumOfNodes(int n, int l)
|
||||
{
|
||||
//warning, the number of nodes should always be 1
|
||||
MinEigenValue = -(2.0*Zeff)/rc;
|
||||
return n-l-1;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_SJPSEUDOPOTENTIAL_H
|
||||
#define OHMMSHF_SJPSEUDOPOTENTIAL_H
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
#include "Optimize/VarList.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class SJPseudoPotential
|
||||
@brief implements the Starkloff-Joannopoulos pseudopotential
|
||||
*
|
||||
\f[
|
||||
V_{SJ}(r) = -\frac{Z_{Eff}}{r}\frac{1-e^{-\lambda r}}
|
||||
{1+e^{-\lambda (r-r_c)}}
|
||||
\f]
|
||||
*
|
||||
See Th. Starkloff and J.D. Joannopoulos, Phys. Rev. B, \textbf{16},
|
||||
5212, (1977).
|
||||
*/
|
||||
struct SJPseudoPotential: public RadialPotentialBase
|
||||
{
|
||||
value_type Zeff, SJ_lambda, rc;
|
||||
SJPseudoPotential(VarRegistry<value_type>&,value_type,
|
||||
value_type,value_type);
|
||||
SJPseudoPotential(value_type,value_type,value_type);
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t&V, int norb);
|
||||
///must always return 1
|
||||
inline int getNumOfNodes(int n, int l);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,126 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include "SQD/SphericalPotential/StepPotential.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
/*!
|
||||
*Add a step function.
|
||||
*/
|
||||
StepPotential::StepPotential()
|
||||
{
|
||||
Rseg.resize(2);
|
||||
Vseg.resize(2);
|
||||
Vseg[0] = -10;
|
||||
Vseg[1] = 0;
|
||||
Rseg[0] = 4.0;
|
||||
Rseg[1] = 10;
|
||||
MinEigenValue = -10.0;
|
||||
MaxEigenValue = 0.0;
|
||||
}
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
StepPotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V,
|
||||
int norb)
|
||||
{
|
||||
if(!Vext)
|
||||
{
|
||||
integrand=new RadialOrbital_t(psi(0));
|
||||
Vext = new RadialOrbital_t(psi(0));
|
||||
int ilow=0, ihi=1;
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
(*Vext)(ig) = Vseg[ilow];
|
||||
if(psi.m_grid->r(ig)> Rseg[ilow])
|
||||
{
|
||||
ilow++;
|
||||
ihi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
value_type v = (*Vext)(ig);
|
||||
value_type sum = 0.0;
|
||||
for(int o=0; o < norb; o++)
|
||||
{
|
||||
V[o](ig) += v;
|
||||
sum += std::pow(psi(o,ig),2);
|
||||
}
|
||||
(*integrand)(ig) = v*sum;
|
||||
}
|
||||
return integrate_RK2(*integrand);
|
||||
}
|
||||
|
||||
int StepPotential::getNumOfNodes(int n, int l)
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
bool StepPotential::put(xmlNodePtr cur)
|
||||
{
|
||||
cur = cur->xmlChildrenNode;
|
||||
std::vector<double> r0, v0;
|
||||
double vmin=1000;
|
||||
double vmax=-1000;
|
||||
while(cur!= NULL)
|
||||
{
|
||||
std::string cname((const char*)(cur->name));
|
||||
if(cname == "Region")
|
||||
{
|
||||
xmlAttrPtr att = cur->properties;
|
||||
double rmin, rmax, v;
|
||||
while(att != NULL)
|
||||
{
|
||||
std::string aname((const char*)(att->name));
|
||||
const char* vname= (const char*)(att->children->content);
|
||||
if(aname == "rmin")
|
||||
{
|
||||
rmin = atof(vname);
|
||||
}
|
||||
else
|
||||
if(aname == "rmax")
|
||||
{
|
||||
rmax = atof(vname);
|
||||
}
|
||||
else
|
||||
if(aname == "value")
|
||||
{
|
||||
v = atof(vname);
|
||||
vmin = std::min(v,vmin);
|
||||
vmax = std::min(v,vmax);
|
||||
}
|
||||
att = att->next;
|
||||
}
|
||||
r0.push_back(rmax);
|
||||
v0.push_back(v);
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
if(r0.size())
|
||||
{
|
||||
MinEigenValue = vmin;
|
||||
//This needs to be reconsidered
|
||||
//MaxEigenValue = vmax;
|
||||
Vseg=v0;
|
||||
Rseg=r0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_STEPPOTENTIAL_H
|
||||
#define OHMMSHF_STEPPOTENTIAL_H
|
||||
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class StepPotential
|
||||
@brief implements the multiple step potential profile.
|
||||
*
|
||||
*\image html steppot.png
|
||||
*/
|
||||
struct StepPotential: public RadialPotentialBase
|
||||
{
|
||||
std::vector<value_type> Rseg;
|
||||
std::vector<value_type> Vseg;
|
||||
StepPotential();
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
///return \f$ n \f$
|
||||
int getNumOfNodes(int n, int l);
|
||||
|
||||
bool put(xmlNodePtr cur);
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -1,63 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include "SQD/SphericalPotential/ZOverRPotential.h"
|
||||
#include "Numerics/RadialFunctorUtility.h"
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/** constructor for the Nuclear Potential \f$V(r)=frac{Z}{r}\f$
|
||||
*
|
||||
* \param z the charge of the Nuclear Potential
|
||||
*/
|
||||
ZOverRPotential::ZOverRPotential(value_type z): Z(z)
|
||||
{
|
||||
Qinfty=Z;
|
||||
}
|
||||
|
||||
RadialPotentialBase::value_type
|
||||
ZOverRPotential::evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb)
|
||||
{
|
||||
if(!Vext)
|
||||
{
|
||||
Vext = new RadialOrbital_t(psi(0));
|
||||
integrand=new RadialOrbital_t(psi(0));
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
(*Vext)(ig) = -Z/psi.m_grid->r(ig);
|
||||
}
|
||||
}
|
||||
for(int ig=0; ig < psi.m_grid->size(); ig++)
|
||||
{
|
||||
value_type t = (*Vext)(ig);
|
||||
value_type sum = 0.0;
|
||||
for(int o=0; o < norb; o++)
|
||||
{
|
||||
V[o](ig) += t;
|
||||
sum += std::pow(psi(o,ig),2);
|
||||
}
|
||||
(*integrand)(ig) = t*sum;
|
||||
}
|
||||
return integrate_RK2(*integrand);
|
||||
}
|
||||
|
||||
int ZOverRPotential::getNumOfNodes(int n, int l)
|
||||
{
|
||||
MinEigenValue = -2.0*Z*Z/static_cast<value_type>(n*n);
|
||||
return n-l-1;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMSHF_ZOVERRFUNCTOR_H
|
||||
#define OHMMSHF_ZOVERRFUNCTOR_H
|
||||
|
||||
#include "SQD/SphericalPotential/RadialPotential.h"
|
||||
|
||||
namespace ohmmshf
|
||||
{
|
||||
|
||||
/**
|
||||
@ingroup RadialPotential
|
||||
@class ZOverRPotential
|
||||
@brief implements the Nuclear potential of
|
||||
\f[
|
||||
V_{Nuclear}(r) = -\frac{Z}{r}
|
||||
\f]
|
||||
*/
|
||||
struct ZOverRPotential: public RadialPotentialBase
|
||||
{
|
||||
value_type Z;
|
||||
ZOverRPotential(value_type z);
|
||||
value_type evaluate(const BasisSetType& psi,
|
||||
RadialOrbitalSet_t& V, int norb);
|
||||
///return \f$ n-l-1 \f$
|
||||
int getNumOfNodes(int n, int l);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "ohmms-config.h"
|
||||
#endif
|
||||
#include "SQD/XmlTreeBuilder.h"
|
||||
#include <qimage.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qpopupmenu.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qfile.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qprinter.h>
|
||||
#include <qapplication.h>
|
||||
#include <qaccel.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpaintdevicemetrics.h>
|
||||
#include <qwhatsthis.h>
|
||||
#include <qsimplerichtext.h>
|
||||
#include <qsplitter.h>
|
||||
#include <qlistview.h>
|
||||
#include <qlabel.h>
|
||||
#include <qvbox.h>
|
||||
#include "SQD/filesave.xpm"
|
||||
#include "SQD/fileopen.xpm"
|
||||
#include "SQD/fileprint.xpm"
|
||||
#include "SQD/QtUtility.h"
|
||||
#include "OhmmsData/libxmldefs.h"
|
||||
/*! \brief Constructor
|
||||
* Register OhmmsElementBase objects corresponding to the major tags of input xml files.
|
||||
* OhmmsElementSet contains default objects \ref ohmmsdefaults and the constructor
|
||||
* adds OhmmsElementBase subclasses that depend on the default objects.
|
||||
*
|
||||
*/
|
||||
XmlTreeBuilder::XmlTreeBuilder()
|
||||
: QMainWindow( 0, "ohmms application main window", WDestructiveClose | WGroupLeader ),
|
||||
m_doc(NULL), m_context(NULL)
|
||||
{
|
||||
QPixmap openIcon, saveIcon, printIcon;
|
||||
QToolBar * fileTools = new QToolBar( this, "file operations" );
|
||||
fileTools->setLabel( "File Operations" );
|
||||
openIcon = QPixmap( fileopen_xpm );
|
||||
QToolButton * fileOpen
|
||||
= new QToolButton( openIcon, "Open File", QString::null,
|
||||
this, SLOT(choose()), fileTools, "open file" );
|
||||
saveIcon = QPixmap( filesave );
|
||||
QToolButton * fileSave
|
||||
= new QToolButton( saveIcon, "Save File", QString::null,
|
||||
this, SLOT(save()), fileTools, "save file" );
|
||||
(void)QWhatsThis::whatsThisButton( fileTools );
|
||||
const char * fileOpenText = "<p><img source=\"fileopen\"> "
|
||||
"Click this button to open a <em>new file</em>.<br>"
|
||||
"You can also select the <b>Open</b> command "
|
||||
"from the <b>File</b> menu.</p>";
|
||||
QWhatsThis::add( fileOpen, fileOpenText );
|
||||
QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", openIcon );
|
||||
const char * fileSaveText = "<p>Click this button to save the file you "
|
||||
"are editing. You will be prompted for a file name.\n"
|
||||
"You can also select the <b>Save</b> command "
|
||||
"from the <b>File</b> menu.</p>";
|
||||
QWhatsThis::add( fileSave, fileSaveText );
|
||||
const char * filePrintText = "Click this button to print the file you "
|
||||
"are editing.\n"
|
||||
"You can also select the Print command "
|
||||
"from the File menu.";
|
||||
QPopupMenu * file = new QPopupMenu( this );
|
||||
menuBar()->insertItem( "&File", file );
|
||||
int id;
|
||||
id = file->insertItem( openIcon, "&Open...",
|
||||
this, SLOT(choose()), CTRL+Key_O );
|
||||
file->setWhatsThis( id, fileOpenText );
|
||||
id = file->insertItem( saveIcon, "&Save",
|
||||
this, SLOT(save()), CTRL+Key_S );
|
||||
file->setWhatsThis( id, fileSaveText );
|
||||
id = file->insertItem( "Save &As...", this, SLOT(saveAs()) );
|
||||
file->setWhatsThis( id, fileSaveText );
|
||||
file->insertSeparator();
|
||||
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_W );
|
||||
file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
|
||||
menuBar()->insertSeparator();
|
||||
QPopupMenu * help = new QPopupMenu( this );
|
||||
menuBar()->insertItem( "&Help", help );
|
||||
help->insertItem( "&About", this, SLOT(about()), Key_F1 );
|
||||
help->insertSeparator();
|
||||
help->insertItem( "What's &This", this, SLOT(whatsThis()), SHIFT+Key_F1 );
|
||||
//d_view = new QSplitter( Qt::Vertical, this);
|
||||
//d_view = new QScrollView(this);
|
||||
d_view = new QVBox(this);
|
||||
setCentralWidget(d_view);
|
||||
nodeView = new QListView(d_view,"whatever");
|
||||
nodeView->addColumn("Node Name");
|
||||
nodeView->addColumn("Value");
|
||||
nodeView->addColumn("Unit");
|
||||
nodeView->setSorting(-1);
|
||||
nodeView->setRootIsDecorated(TRUE);
|
||||
resize( 450, 600 );
|
||||
}
|
||||
|
||||
XmlTreeBuilder::~XmlTreeBuilder()
|
||||
{
|
||||
if(m_doc)
|
||||
xmlFreeDoc(m_doc);
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::closeEvent( QCloseEvent* ce )
|
||||
{
|
||||
switch( QMessageBox::information( this, "Ohmms Session",
|
||||
"Do you want to save the changes"
|
||||
" to the document?",
|
||||
"Yes", "No", "Cancel",
|
||||
0, 1 ) )
|
||||
{
|
||||
case 0:
|
||||
save();
|
||||
ce->accept();
|
||||
break;
|
||||
case 1:
|
||||
ce->accept();
|
||||
break;
|
||||
case 2:
|
||||
default: // just for sanity
|
||||
ce->ignore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
d_view->resize(e->size());
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::choose()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName( QString::null, QString::null,
|
||||
this);
|
||||
if ( !fn.isEmpty() )
|
||||
load( fn );
|
||||
else
|
||||
statusBar()->message( "Loading aborted", 2000 );
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::load( const QString &fileName )
|
||||
{
|
||||
parse(fileName.ascii());
|
||||
setCaption( fileName );
|
||||
statusBar()->message( "Loaded document " + fileName, 2000 );
|
||||
}
|
||||
|
||||
|
||||
void XmlTreeBuilder::save()
|
||||
{
|
||||
if(m_doc)
|
||||
xmlSaveFormatFile(d_filename.ascii(),m_doc,1);
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::saveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName( QString::null, QString::null,
|
||||
this );
|
||||
if ( !fn.isEmpty() )
|
||||
{
|
||||
d_filename = fn;
|
||||
save();
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBar()->message( "Saving aborted", 2000 );
|
||||
}
|
||||
}
|
||||
|
||||
void XmlTreeBuilder::about()
|
||||
{
|
||||
QMessageBox::about( this, "Ohmms Session",
|
||||
"This example demonstrates simple use of "
|
||||
"QMainWindow,\nQMenuBar and QToolBar.");
|
||||
}
|
||||
|
||||
/*!\fn bool XmlTreeBuilder::parse(const char* fname) {
|
||||
*\param fname an input xml file to be parsed.
|
||||
*\return true if successful.
|
||||
*/
|
||||
bool XmlTreeBuilder::parse(const char* fname)
|
||||
{
|
||||
d_filename = fname; //QString("%1.%2").arg(fname).arg(1);
|
||||
QFileInfo fi(fname);
|
||||
//free an existing document
|
||||
if(m_doc)
|
||||
xmlFreeDoc(m_doc);
|
||||
// build an XML tree from a the file;
|
||||
m_doc = xmlParseFile(fname);
|
||||
if (m_doc == NULL)
|
||||
return false;
|
||||
// Check the document is of the right kind
|
||||
xmlNodePtr cur = xmlDocGetRootElement(m_doc);
|
||||
if (cur == NULL)
|
||||
{
|
||||
fprintf(stderr,"empty document\n");
|
||||
xmlFreeDoc(m_doc);
|
||||
m_doc = NULL;
|
||||
return false;
|
||||
}
|
||||
QListViewItem *a=new QListViewItem(nodeView,fi.fileName());
|
||||
SimpleTreeBuilder(a,cur);
|
||||
nodeView->setOpen(a,true);
|
||||
nodeView->show();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is distributed under the University of Illinois/NCSA Open Source License.
|
||||
// See LICENSE file in top directory for details.
|
||||
//
|
||||
// Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
|
||||
//
|
||||
// File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef OHMMS_XMLTREEBUILDER_H
|
||||
#define OHMMS_XMLTREEBUILDER_H
|
||||
|
||||
/*!\class OhmmsQt
|
||||
* \brief A generic application.
|
||||
*/
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <qmainwindow.h>
|
||||
#include "OhmmsData/libxmldefs.h"
|
||||
|
||||
class QTextEdit;
|
||||
class QListView;
|
||||
class QScrollView;
|
||||
|
||||
|
||||
class XmlTreeBuilder: public QMainWindow
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
///constructor
|
||||
XmlTreeBuilder();
|
||||
|
||||
///destructor
|
||||
~XmlTreeBuilder();
|
||||
|
||||
///parse a file
|
||||
bool parse(const char* fname);
|
||||
|
||||
protected:
|
||||
|
||||
void closeEvent( QCloseEvent* );
|
||||
|
||||
protected slots:
|
||||
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
|
||||
void load( const QString &fileName );
|
||||
void save();
|
||||
void choose();
|
||||
void saveAs();
|
||||
void about();
|
||||
|
||||
private:
|
||||
|
||||
xmlDocPtr m_doc;
|
||||
xmlXPathContextPtr m_context;
|
||||
|
||||
QTextEdit *e;
|
||||
QString d_filename;
|
||||
QListView* nodeView;
|
||||
QWidget* d_view;
|
||||
};
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue