8 #ifndef SRC_APPS_CHEM_BSHAPPLY_H_
9 #define SRC_APPS_CHEM_BSHAPPLY_H_
23 template<
typename T, std::
size_t NDIM>
56 std::vector<Function<T,NDIM> > Vpsi=
copy(
world,Vpsi1);
64 std::vector < std::shared_ptr<SeparatedConvolution<double,NDIM> > > ops(
psi.size());
65 for (
int i=0; i<eps.
dim(0); ++i) {
66 T e_i= (eps.
ndim()==2) ? eps(i,i) : eps(i);
67 if (
printme)
print(
"orbital energy for the BSH operator",e_i);
68 ops[i]=std::shared_ptr<SeparatedConvolution<double,NDIM> >(
70 ops[i]->destructive()=
true;
73 const std::vector<Function<T,NDIM> > tmp =
apply(
world,ops,-2.0*Vpsi);
75 const std::vector<Function<T,NDIM> > bra_res=
make_bra(res);
80 for (
int i=0; i<norms.
size(); ++i) {
81 norms(i)=sqrt(norms(i));
82 rnorms(i)=sqrt(rnorms(i));
85 print(
"norm2(tmp)",norms);
86 print(
"norm2(res)",rnorms);
91 for (
size_t i=0; i<
psi.size(); ++i) delta_eps(i)=
std::real(in(i))/(norms[i]*norms[i]);
95 if (
printme) printf(
"time in BSHApply() %8.4fs\n",cpu1-cpu0);
112 std::tuple<std::vector<Function<T,NDIM>,
Tensor<T> > > result;
134 bool consistent=(
psi.size()==size_t(fock1.
dim(0)));
135 if ((fock1.
ndim()==2) and not (
psi.size()==
size_t(fock1.
dim(1)))) consistent=
false;
137 if (not consistent) {
138 print(
"Fock matrix dimensions",fock1.
ndim(), fock1.
dim(0), fock1.
dim(1));
139 print(
"number of orbitals",
psi.size());
143 bool do_coupling=(fock1.
ndim()==2);
151 for (
int i=0; i<fock.
dim(0); ++i) {
155 print(
"coupling fock matrix");
161 std::vector<T> eps(
psi.size());
163 for (
int i=0; i<fock1.
dim(0); ++i) eps[i]=fock1(i)-
eps_in_green(fock1(i));
165 for (
int i=0; i<fock1.
dim(0); ++i) eps[i]=fock1(i,i)-
eps_in_green(fock1(i,i));
This header should include pretty much everything needed for the parallel runtime.
apply the BSH operator on a vector of functions with corresponding potentials
Definition: BSHApply.h:24
std::vector< Function< T, NDIM > > make_bra(const std::vector< Function< T, NDIM > > &rhs) const
Definition: BSHApply.h:117
double bshtol
Definition: BSHApply.h:31
bool destroy_Vpsi
Definition: BSHApply.h:33
std::vector< Function< T, NDIM > > add_coupling_and_levelshift(const std::vector< Function< T, NDIM > > psi, const Tensor< T > fock1) const
Definition: BSHApply.h:130
double levelshift
Definition: BSHApply.h:29
MolecularOrbitals< T, NDIM > operator()(const MolecularOrbitals< T, NDIM > &arg, const std::vector< Function< T, NDIM > > &Vpsi) const
apply the BSH operator on the vector of functions and respective potentials
Definition: BSHApply.h:110
Function< double, NDIM > metric
Definition: BSHApply.h:34
return_value ret_value
Definition: BSHApply.h:35
double eps_in_green(const T eps) const
limit the orbital energy (diagonal fock matrix element) entering the Green's function parameter mu
Definition: BSHApply.h:123
double lo
Definition: BSHApply.h:30
bool printme
Definition: BSHApply.h:32
World & world
Definition: BSHApply.h:28
BSHApply(World &world)
Definition: BSHApply.h:38
return_value
Definition: BSHApply.h:27
@ residual
Definition: BSHApply.h:27
@ update
Definition: BSHApply.h:27
std::tuple< std::vector< Function< T, NDIM > >, Tensor< double > > operator()(const std::vector< Function< T, NDIM > > psi, const Tensor< T > eps, const std::vector< Function< T, NDIM > > &Vpsi1) const
apply the BSH operator on the vector of functions and respective potentials
Definition: BSHApply.h:50
long dim(int i) const
Returns the size of dimension i.
Definition: basetensor.h:147
long ndim() const
Returns the number of dimensions in the tensor.
Definition: basetensor.h:144
long size() const
Returns the number of elements in the tensor.
Definition: basetensor.h:138
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:204
bool is_initialized() const
Returns true if the function is initialized.
Definition: mra.h:147
Definition: MolecularOrbitals.h:24
std::vector< Function< T, NDIM > > get_mos() const
Definition: MolecularOrbitals.h:64
A parallel world class.
Definition: world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only)
Definition: tensor.h:2502
double psi(const Vector< double, 3 > &r)
Definition: hatom_energy.cc:78
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition: timers.h:127
response_space scale(response_space a, double b)
response_space apply(World &world, std::vector< std::vector< std::shared_ptr< real_convolution_3d >>> &op, response_space &f)
Definition: basic_operators.cc:39
void truncate(World &world, response_space &v, double tol, bool fence)
Definition: basic_operators.cc:30
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition: mra.h:2002
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition: print.h:225
double inner(response_space &a, response_space &b)
Definition: response_functions.h:442
double imag(double x)
Definition: complexfun.h:56
double real(double x)
Definition: complexfun.h:52
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition: vmra.h:689