75 typedef std::vector<Function<double,3> >
vecfuncT;
93 double r2=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];
95 return prefactor*
exp(-r2/(2.0*sigma*sigma));
109 x=size*(random.
get()-random.
get());
110 y=size*(random.
get()-random.
get());
111 z=size*(random.
get()-random.
get());
112 prefactor= x*y*z/(
fabs(x*y*z));
126 double r2 = (r[0]-x)*(r[0]-x)+(r[1]-y)*(r[1]-y)+(r[2]-z)*(r[2]-z);
127 return prefactor*
exp(-r2/(2.0*sigma*sigma));
135 root(
World& world) : world(world), omega(0.0),expv(0.0),converged(false),err(10.0),
delta(10.0),iter(0) {}
136 root(
World& world,
vecfuncT& x,
double omega) :world(world), x(x), omega(omega),converged(false),err(10.0),
delta(10.0),iter(0) {}
138 root(
const root& other) : world(other.world), x(other.x),
139 omega(other.omega),expv(other.expv), converged(other.converged),
140 err(other.err),
delta(other.
delta),iter(other.iter),number(other.number){}
143 root(
World &world,
double omega,
double expv,
double delta,
double error,
bool converged,
int iter,
int number) : world(world),
144 omega(omega),expv(expv),converged(converged),err(error),delta(delta),iter(iter),number(number) {}
175 return root(world,
sub(world,x,b.
x));
189 return (this->omega<other.
omega);
192 return (this->omega>other.
omega);
213 static double rfunction(
const coord_3d& r) {
214 return sqrt(r[0]*r[0] + r[1]*r[1] + r[2]*r[2]);
217 static double rfunction2(
const coord_3d& r) {
218 return sqrt(r[0]*r[0] + r[1]*r[1] + r[2]*r[2])+1.0;
222 static double monopole(
const coord_3d &r){
223 return r[0]*r[0] + r[1]*r[1] + r[2]*r[2];
226 static double x(
const coord_3d &r){
return r[0];}
227 static double x2(
const coord_3d &r){
return r[0]-0.7;}
228 static double x3(
const coord_3d &r){
return r[0]+0.7;}
229 static double y(
const coord_3d &r){
return r[1];}
230 static double z(
const coord_3d &r){
return r[2];}
233 static double b1u(
const coord_3d &r){
return r[0]*(r[0]*r[0]-3*r[1]*r[1]);}
234 static double b2u(
const coord_3d &r){
return r[1]*(3*r[0]*r[0]-r[1]*r[1]);}
235 static double e1g1(
const coord_3d &r){
return r[0]*r[2];}
236 static double e1g2(
const coord_3d &r){
return r[1]*r[2];}
237 static double a2u(
const coord_3d &r){
return r[2];}
238 static double e2u1(
const coord_3d &r){
return r[2]*(r[0]*r[0]-r[1]*r[1]);}
239 static double e2u2(
const coord_3d &r){
return r[0]*r[1]*r[2];}
242 static double random_number(
const coord_3d &r){
250 static bool compare_roots(
const root &
a,
const root &
b){
253 static bool compare_roots_error(
const root &
a,
const root &
b){
271 econv_(calc.
param.econv),
272 dconv_(calc.
param.econv),
273 guess_thresh_(1.e-4),
279 guess_mode_(
"all_orbitals"),
280 thresh_(dconv_*0.01),
292 guess_damp_fock_(true),
295 noise_box_(
get_calc().molecule.bounding_cube()),
298 noise_gaussnumber_(25),
301 read_and_save_koala_(false),
303 guess_exf_(
"dipole"){
307 omega_=std::vector<double>(9,100.0);
308 active_mo_ = nmo-nfreeze_;
310 std::ifstream
f(input.c_str());
313 while (std::getline(
f,s)) {
314 std::istringstream ss(s);
316 if (tag ==
"end")
break;
317 else if (tag ==
"guess") ss >> guess_;
318 else if (tag ==
"guess_preopt") ss >> preopt_;
319 else if (tag ==
"nroot") ss >> nroot_;
321 else if (tag ==
"guess_thresh") ss >> guess_thresh_;
322 else if (tag ==
"guess_econv") ss >> guess_econv_;
323 else if (tag ==
"guess_dconv") ss >> guess_dconv_;
324 else if (tag ==
"guess_iter") ss >> guess_iter_;
325 else if (tag ==
"guess_iter_fock") ss >> guess_iter_fock_;
326 else if (tag ==
"guess_roots") ss >> guess_roots_;
327 else if (tag ==
"guess_omega") ss >> guess_omega_;
328 else if (tag ==
"guess_mode") ss >> guess_mode_;
329 else if (tag ==
"thresh") ss >> thresh_;
330 else if (tag ==
"bsh_eps") ss >> bsh_eps_;
331 else if (tag ==
"iter_max") ss >> iter_max_;
332 else if (tag ==
"freeze") ss >> nfreeze_;
333 else if (tag ==
"econv") ss >> econv_;
334 else if (tag ==
"dconv") ss >> dconv_;
335 else if (tag ==
"fixed_point") fixed_point_=
true;
336 else if (tag ==
"print_grid") print_grid_=
true;
337 else if (tag ==
"plot") plot_=
true;
338 else if (tag ==
"guess_save") guess_save_=
true;
339 else if (tag ==
"guess_damp") guess_damp_=
true;
340 else if (tag ==
"guess_pull") guess_pull_=
true;
341 else if (tag ==
"guess_damp_iter") ss >> guess_damp_iter_;
342 else if (tag ==
"guess_damp_fock") guess_damp_fock_ =
true;
343 else if (tag ==
"noise") noise_=
true;
344 else if (tag ==
"noise_box") ss >> noise_box_;
345 else if (tag ==
"noise_comp") ss >> noise_comp_;
346 else if (tag ==
"noise_width") ss >> noise_width_;
347 else if (tag ==
"noise_gaussnumber") ss >> noise_gaussnumber_;
348 else if (tag ==
"hf") hf_=
true;
349 else if (tag ==
"triplet") triplet_=
true;
350 else if (tag ==
"koala_read_and_save") read_and_save_koala_=
true;
351 else if (tag ==
"guess_exf") ss >> guess_exf_;
352 else if (tag ==
"omega0") ss >> omega_[0];
353 else if (tag ==
"omega1") ss >> omega_[1];
354 else if (tag ==
"omega2") ss >> omega_[2];
355 else if (tag ==
"omega3") ss >> omega_[3];
356 else if (tag ==
"omega4") ss >> omega_[4];
357 else if (tag ==
"omega5") ss >> omega_[5];
358 else if (tag ==
"omega6") ss >> omega_[6];
359 else if (tag ==
"omega7") ss >> omega_[7];
360 else if (tag ==
"omega8") ss >> omega_[8];
361 else if (tag ==
"active_mo") ss >> active_mo_;
362 else if (tag ==
"active_mo") guess_mode_=
"active_space";
363 else if (tag ==
"analyze") analyze_=
true;
372 if (world.
rank() == 0) {
375 if (nfreeze_>0)
madness::print(
" # frozen orbitals ",0,
" to ",nfreeze_-1);
412 std::vector<root>&
roots();
426 std::vector<root> roots_;
435 std::vector<vecfuncT> exchange_intermediate_;
460 Tensor<double> guess_phases_;
463 double guess_thresh_;
472 int guess_iter_fock_;
493 std::vector<double> omega_;
517 int guess_damp_iter_;
518 bool guess_damp_fock_;
527 double noise_gaussnumber_;
537 bool read_and_save_koala_;
552 void initialize_roots(
World &world,std::vector<root> &
roots);
555 void guess_MO(
World &world,std::vector<root> &
roots);
557 void guess_read(
World &world,std::vector<root> &
roots);
563 void guess_koala(
World &world,std::vector<root> &
roots);
565 void guess_physical(
World &world,std::vector<root> &
roots);
568 void guess_noise(
World &world,std::vector<root> &
roots);
570 void guess_aspace(
World &world,std::vector<root> &
roots);
572 void guess_forced(
World &world,std::vector<root> &
roots);
574 void guess_benzene_custom(
World &world,std::vector<root> &
roots);
577 void add_noise(
World & world,std::vector<root> &
roots)
const;
579 std::vector<root> guess();
582 std::vector<root> guess_big(
const std::string exf);
585 std::vector<real_function_3d> excitation_functions(
const std::string exf)
const;
588 bool orthogonalize_fock(
World& world,std::vector<root> &
roots)
const;
589 bool orthogonalize_fock(
World& world,std::vector<root> &
roots,
int iter)
const;
599 template<
typename solverT>
600 bool iterate_all_CIS_roots(
World& world, std::vector<solverT>& solver,
603 bool check_convergence(std::vector<root> &
roots)
const;
619 template<
typename solverT>
622 template<
typename solverT>
655 std::vector<vecfuncT> make_exchange_intermediate(
const vecfuncT& active_mo,
659 double expectation_value(
World &world,
const root &thisroot,
const vecfuncT &Vx)
const;
674 Tensor<double> make_perturbed_fock_matrix(
const std::vector<root>&
roots,
const std::vector<vecfuncT> &
V)
const;
695 void save_root(
World& world,
const int i,
const root&
root)
const;
704 void normalize(
World& world,
root& x)
const;
707 void orthonormalize_fock(
World &world,std::vector<root> &
roots)
const;
710 void orthonormalize_fock(
World &world,std::vector<root> &
roots,
const std::vector<vecfuncT> &Vphi)
const;
713 void orthonormalize(
World& world, std::vector<root>&
roots)
const;
716 Tensor<double> overlap(
const std::vector<root>& r1,
717 const std::vector<root>& r2)
const;
728 double oscillator_strength_length(
const root&
root)
const;
738 double oscillator_strength_velocity(
const root&
root)
const;
741 void analyze(
const std::vector<root>&
roots)
const;
double operator()(const coord_3d &r) const
Definition: tdhf_CIS.h:125
void error(const char *msg)
Definition: world.cc:128
The CIS class holds all machinery to compute excited state properties.
Definition: tdhf_CIS.h:203
Definition: shared_ptr_bits.h:38
const mpreal exp(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2234
const double pi
Mathematical constant pi.
Definition: constants.h:44
int iter
Definition: tdhf_CIS.h:153
Main include file for MADNESS and defines Function interface.
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:175
root operator+=(const root &b)
Definition: tdhf_CIS.h:178
Try to create noise using random gauss functions.
Definition: tdhf_CIS.h:101
root(World &world, const vecfuncT &x1)
Definition: tdhf_CIS.h:137
root & operator=(const root &other)
Definition: tdhf_CIS.h:159
std::istream & position_stream(std::istream &f, const std::string &tag)
Definition: position_stream.cc:37
bool solve_internal_par(const std::string mode, std::vector< root > &roots, const int iter_max)
Definition: tdhf_CIS.cc:205
void solve()
solve the CIS equations for n roots
Definition: tdhf_CIS.cc:161
const double sigma
Definition: dielectric.cc:187
tensorT aeps
orbital energies for alpha and beta orbitals
Definition: chem/SCF.h:745
::std::string string
Definition: gtest-port.h:872
root(World &world, vecfuncT &x, double omega)
Definition: tdhf_CIS.h:136
Definition: chem/SCF.h:712
root operator*(double a)
Definition: tdhf_CIS.h:183
std::shared_ptr< FunctionFunctorInterface< double, 3 > > functorT
Definition: tdhf_CIS.h:103
double V(const Vector< double, 3 > &r)
Definition: apps/ii/hatom_energy.cc:46
NDIM & f
Definition: mra.h:2179
bool converged
Definition: tdhf_CIS.h:150
POD holding excitation energy and response vector for a single excitation.
Definition: tdhf_CIS.h:134
Function< TENSOR_RESULT_TYPE(L, R), NDIM > add(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator+ but with optional fence and no automatic compression.
Definition: mra.h:1734
vecfuncT x
Definition: tdhf_CIS.h:147
void print_root(const root &root) const
Definition: tdhf_CIS.cc:112
std::vector< double > amplitudes_
Definition: tdhf_CIS.h:156
root(const root &other)
Definition: tdhf_CIS.h:138
gauss_function(double molecule_box)
Definition: tdhf_CIS.h:84
vecfuncT amo
alpha and beta molecular orbitals
Definition: chem/SCF.h:729
double err
Definition: tdhf_CIS.h:151
int number
Definition: tdhf_CIS.h:154
bool print_grid() const
are we supposed to print the grid for an external guess
Definition: tdhf_CIS.cc:248
std::vector< root > & roots()
return the roots of the response equation
Definition: tdhf_CIS.cc:245
Implements most functionality of separated operators.
noise(double size, double width)
Definition: tdhf_CIS.h:107
double delta
Definition: tdhf_CIS.h:152
Defines operations on vectors of FunctionsThis file defines a number of operations on vectors of func...
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values.
Definition: vmra.h:290
CalculationParameters param
Definition: chem/SCF.h:717
root(World &world)
Definition: tdhf_CIS.h:135
World & world
Definition: tdhf_CIS.h:146
Generalized version of NonlinearSolver not limited to a single madness function.
Definition: nonlinsol.h:174
Example implementation of Krylov-subspace nonlinear equation solver.
Gauss_function structure is needed to mimic noise.
Definition: tdhf_CIS.h:79
double lo
Smallest length scale we need to resolve.
Definition: chem/SCF.h:305
Function< TENSOR_RESULT_TYPE(L, R), NDIM > sub(const Function< L, NDIM > &left, const Function< R, NDIM > &right, bool fence=true)
Same as operator- but with optional fence and no automatic compression.
Definition: mra.h:1778
double operator()(const coord_3d &r) const
Definition: tdhf_CIS.h:92
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
noise(double size)
Definition: tdhf_CIS.h:106
void Analyze()
Read and analyze roots.
Definition: tdhf_CIS.cc:131
vector< functionT > vecfuncT
Definition: chem/corepotential.cc:61
root(World &world, double omega, double expv, double delta, double error, bool converged, int iter, int number)
Definition: tdhf_CIS.h:143
double expv
Definition: tdhf_CIS.h:149
std::shared_ptr< FunctionFunctorInterface< double, 3 > > functorT
Definition: tdhf_CIS.h:81
tensorT sqrt(const tensorT &s, double tol=1e-8)
Computes matrix square root (not used any more?)
Definition: DFcode/moldft.cc:446
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
void print_roots(const std::vector< root > &roots) const
Definition: tdhf_CIS.cc:97
const SCF & get_calc() const
return the HF reference
Definition: tdhf_CIS.h:392
double omega
Definition: tdhf_CIS.h:148
bool operator>(const root &other) const
Definition: tdhf_CIS.h:191
void sort_roots(std::vector< root > &roots, std::string criterium) const
If roots[j] < roots[i] and i
Definition: tdhf_CIS.cc:122
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:58
ProcessID rank() const
Returns the process rank in this world (same as MPI_Comm_rank()))
Definition: worldfwd.h:526
const double delta
Definition: dielectric_external_field.cc:120
Implements (2nd generation) static load/data balancing for functions.
void print(const A &a)
Print a single item to std::cout terminating with new line.
Definition: print.h:122
CIS(World &world, const SCF &calc, const std::string input)
ctor
Definition: tdhf_CIS.h:265
bool operator<(const root &other) const
Definition: tdhf_CIS.h:188
const mpreal fabs(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2187
A random number generator (portable, vectorized, and thread-safe)
Definition: ran.h:72
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
FLOAT b(int j, FLOAT z)
Definition: y1.cc:79
double wall_time()
Returns the wall time in seconds relative to arbitrary origin.
Definition: world.cc:248
const mpreal root(const mpreal &v, unsigned long int k, mp_rnd_t rnd_mode)
Definition: mpreal.h:2180
root operator-(const root &b) const
Definition: tdhf_CIS.h:174
double get()
Definition: ran.h:90