38 output.
section(
"CC2 Class has been initialized with the following parameters");
72 return value(
nemo->molecule().get_all_coords());
83 std::string
name()
const {
return "CC2";};
87 print(
"The CC2 code computes correlated ground and excited state energies:\n");
88 print(
" - MP2 ground state");
89 print(
" - CC2 ground and excited states");
90 print(
" - ADC(2) and CIS(D) excited states\n");
91 print(
"You need a SCF reference calculation from the nemo program. If there no such calculation can");
92 print(
"be found CC2 will perform its own. If excited states are requested also a CIS calculation is ");
93 print(
"necessary.\n");
94 print(
"Note that for correlated calculations the k parameter must be chosen small, typically k=5 or k=6 ");
95 print(
"because the curse of dimensions make higher k extremely expensive\n");
96 print(
"You can print all available calculation parameters by running\n");
97 print(
"cc2 --print_parameters\n");
98 print(
"You can perform a simple MP2 calculation by running\n");
99 print(
"cc2 --geometry=h2o.xyz\n");
100 print(
"provided you have an xyz file in your directory.\n");
106 print(
"\ndefault parameters for the cc2 program are\n");
107 param.print(
"cc2",
"end");
108 print(
"\n\nthe molecular geometry must be specified in a separate block:");
140 std::vector<CC_vecfunction>
146 return mp3_contribution;
161 const std::size_t excitation,
Info& info)
const;
220 bool converged =
true;
224 old_singles(tmp.first).function =
copy(tmp.second.function);
225 double old_omega=0.0;
230 solverT solver(allocT(
world, singles.
size()));
235 for (
size_t iter = 0; iter <
maxiter; iter++) {
248 output.
warning(
"iterate_singles: CC2 demanded but singles are not of type PARTICLE");
254 output.
warning(
"iterate_singles: CC2_response_ singles have wrong types");
258 output.
warning(
"iterate_singles: CCS_response_ singles have wrong types");
268 (
"Unknown calculation type in iterate singles: " +
assign_name(ctype)).c_str(), 1);
274 if (ctype ==
CT_CC2)
V = CCPotentials::get_CC2_singles_potential_gs(
world, singles, gs_doubles, info);
276 V = CCPotentials::get_CC2_singles_potential_ex(
world, singles2, gs_doubles, singles, ex_doubles, info);
277 else if (ctype ==
CT_LRCCS)
V = CCPotentials::get_CCS_potential_ex(
world,singles,
false, info);
289 omega = CCPotentials::compute_cis_expectation_value(
world, singles,
V,
true, info);
293 print(
"omega entering the update in the singles" ,
omega);
297 std::vector<std::shared_ptr<SeparatedConvolution<double, 3> > >
G(singles.
size());
298 for (
size_t i = 0; i <
G.size(); i++) {
300 G[i] = std::shared_ptr<SeparatedConvolution<double, 3> >(
317 output(
"Normalizing new singles");
320 }
else output(
"Singles not normalized");
330 const double R2vector_error = sqrt(R2rinnerr.
sum());
331 auto [rmsresidual, maxresidual]=CCPotentials::residual_stats(
residual);
334 if (
world.
rank() == 0) std::cout <<
"\n\n-----Results of current interation:-----\n";
336 std::cout <<
"\nName: ||" << singles.
name(0) <<
"||, ||GV" << singles.
name(0) <<
", ||residual||" <<
"\n";
339 << sqrt(R2xinnerx.
sum()) <<
", " << sqrt(R2GVinnerGV.
sum()) <<
", " << sqrt(R2rinnerr.
sum())
340 <<
"\n----------------------------------------\n";
341 for (
size_t i = 0; i < GV.size(); i++) {
345 << sqrt(R2xinnerx(i)) <<
", " << sqrt(R2GVinnerGV(i)) <<
", " << sqrt(R2rinnerr(i))
348 if (
world.
rank() == 0) std::cout <<
"\n----------------------------------------\n\n";
354 const double Rdelta = (0.5 * Rtmp / Rtmp2);
355 if (
world.
rank() == 0) std::cout <<
"omega, second-order update (FYI): " << std::fixed
367 for (
size_t i = 0; i < GV.size(); i++) {
375 if (
world.
rank()==0) CCPotentials::print_convergence(singles.
name(0),rmsresidual,
376 rmsresidual,
omega-old_omega,iter);
380 if (converged)
break;
387 bool no_change =
true;
389 std::cout <<
"Change in Singles functions after all the Microiterations" << std::endl;
391 const double change = (tmp.second.function - old_singles(tmp.first).function).
norm2();
392 tmp.second.current_error = change;
395 std::cout <<
"Change of " << tmp.second.name() <<
"=" << tmp.second.current_error << std::endl;
502 for (
auto& tmp_pair : vpairs) pairs.
insert(tmp_pair.i, tmp_pair.j, tmp_pair);
503 auto ccpair2function = [](
const CCPair&
a) {
return a.function();};
517 for (
int i=0; i<Fact.
dim(0); ++i) Fact(i,i)=0.0;
519 return fock_coupling;
Definition test_derivative.cc:24
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
CC_vecfunction initialize_singles(const FuncType type, const int ex=-1) const
read singles from file or initialize new ones
Definition CC2.cc:1053
double solve_cispd(Pairs< CCPair > &doubles, const Pairs< CCPair > &mp2_pairs, const CC_vecfunction &cis_singles)
Definition CC2.cc:621
CCMessenger & output
Formated Output (same as used in CC2Potentials structure)
Definition CC2.h:132
static bool iterate_singles(World &world, CC_vecfunction &singles, const CC_vecfunction singles2, Pairs< CCPair > &gs_doubles, Pairs< CCPair > &ex_doubles, const CalcType ctype, const std::size_t maxiter, Info &info)
Definition CC2.h:215
Tensor< double > enforce_core_valence_separation(const Tensor< double > &fmat)
Definition CC2.cc:347
bool iterate_ccs_singles(CC_vecfunction &x, Info &info) const
Definition CC2.h:198
void store_singles(const CC_vecfunction &singles, const int ex=-1) const
store singles to file
virtual bool selftest()
Definition CC2.h:112
double solve_mp2_coupled(Pairs< CCPair > &doubles, Info &info)
Definition CC2.cc:417
void output_calc_info_schema(const std::string model, const double &energy) const
Definition CC2.cc:327
World & world
The World.
Definition CC2.h:122
static void update_reg_residues_gs(World &world, const CC_vecfunction &singles, Pairs< CCPair > &doubles, const Info &info)
Definition CC2.cc:1132
static void help()
Definition CC2.h:85
CCParameters parameters
Structure holds all the parameters used in the CC2 calculation.
Definition CC2.h:124
double compute_mp3(const Pairs< CCPair > &mp2pairs) const
Definition CC2.h:143
void solve()
solve the CC2 ground state equations, returns the correlation energy
Definition CC2.cc:19
static void update_reg_residues_ex(World &world, const CC_vecfunction &singles, const CC_vecfunction &response, Pairs< CCPair > &doubles, const Info &info)
Definition CC2.cc:1150
static bool iterate_cc2_singles(World &world, CC_vecfunction &singles, Pairs< CCPair > &doubles, Info &info)
Definition CC2.h:169
std::tuple< Pairs< CCPair >, CC_vecfunction, double > solve_lrcc2(Pairs< CCPair > &gs_doubles, const CC_vecfunction &gs_singles, const CC_vecfunction &cis, const std::size_t excitation, Info &info) const
solve the excited state LR-CC2 equations for a given excitation
Definition CC2.cc:883
bool update_constant_part_adc2(const CC_vecfunction &ccs, CCPair &pair)
Definition CC2.h:465
bool update_constant_part_cispd(const CC_vecfunction &ccs, CCPair &pair)
Definition CC2.h:448
CC2(World &world_, const commandlineparser &parser, const std::shared_ptr< Nemo > nemo_)
Definition CC2.h:31
bool iterate_adc2_singles(Pairs< CCPair > &mp2, CC_vecfunction &singles, Pairs< CCPair > &x, Info &info)
Definition CC2.h:178
static void print_parameters()
Definition CC2.h:104
static Pairs< real_function_6d > compute_local_coupling(const std::vector< CCPair > &vpairs, const Info &info)
forward to the other function (converting CCPair to real_function)
Definition CC2.h:499
std::shared_ptr< Nemo > nemo
The SCF Calculation.
Definition CC2.h:126
double value()
Definition CC2.h:71
double solve_cc2(CC_vecfunction &tau, Pairs< CCPair > &u, Info &info) const
Definition CC2.cc:755
bool update_constant_part_cc2_gs(const CC_vecfunction &tau, CCPair &pair)
Definition CC2.h:434
std::vector< CC_vecfunction > solve_ccs() const
Definition CC2.cc:392
virtual ~CC2()
Definition CC2.h:68
PairVectorMap triangular_map
map Pair struct to vector
Definition CC2.h:134
static bool iterate_lrcc2_pairs(World &world, const CC_vecfunction &cc2_s, const CC_vecfunction lrcc2_s, Pairs< CCPair > &lrcc2_d, const Info &info)
Definition CC2.cc:676
static std::vector< real_function_3d > compute_local_coupling(const std::vector< real_function_3d > &singles, const Info &info)
compute the coupling of singles function if orbitals are localized
Definition CC2.h:510
CCPotentials CCOPS
The CC Operator Class.
Definition CC2.h:130
bool check_core_valence_separation(const Tensor< double > &fmat) const
Definition CC2.cc:339
static bool iterate_lrcc2_singles(World &world, const CC_vecfunction &cc2_s, Pairs< CCPair > &cc2_d, CC_vecfunction &lrcc2_s, Pairs< CCPair > lrcc2_d, Info &info)
Definition CC2.h:186
double value(const Tensor< double > &x)
Should return the value of the objective function.
Definition CC2.h:75
bool iterate_pair(CCPair &pair, const CC_vecfunction &singles=CC_vecfunction(UNDEFINED)) const
Iterates a pair of the CC2 doubles equations.
Definition CC2.cc:945
bool iterate_adc2_pairs(Pairs< CCPair > &cispd, const CC_vecfunction &ccs)
Definition CC2.cc:659
std::shared_ptr< TDHF > tdhf
The excited state cis calculation.
Definition CC2.h:128
std::string name() const
Definition CC2.h:83
bool update_constant_part_lrcc2(CCPair &pair, const CC_vecfunction &tau, const CC_vecfunction &x)
Definition CC2.h:482
void plot(const real_function_3d &f, const std::string &msg="unspecified function") const
Definition CC2.h:116
bool initialize_pairs(Pairs< CCPair > &pairs, const CCState ftype, const CalcType ctype, const CC_vecfunction &tau, const CC_vecfunction &x, const size_t extitation, const Info &info) const
read pairs from file or initialize new ones
Definition CC2.cc:1077
Definition CCStructures.h:956
std::string name() const
Definition CCStructures.h:1086
size_t i
Definition CCStructures.h:972
real_function_6d constant_part
the constant part
Definition CCStructures.h:1079
size_t j
Definition CCStructures.h:973
CCState type
Definition CCStructures.h:970
double bsh_eps
Definition CCStructures.h:1084
CalcType ctype
Definition CCStructures.h:971
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:204
static void set_truncate_mode(int value)
Sets the default truncation mode.
Definition funcdefaults.h:338
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:286
static void set_special_level(int value)
Existing functions are unaffected.
Definition funcdefaults.h:309
static void set_k(int value)
Sets the default wavelet order.
Definition funcdefaults.h:273
static void set_initial_level(int value)
Sets the default initial projection level.
Definition funcdefaults.h:303
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:147
double mp3_energy_contribution_macrotask_driver(const Pairs< CCPair > &mp2pairs) const
compute the MP3 energy contribution, macrotask version
Definition mp3.cc:928
static void print_parameters()
Definition molecule.cc:110
class implementing properties of QC models
Definition QCPropertyInterface.h:11
orthogonality projector
Definition projector.h:186
Convolutions in separated form (including Gaussian)
Definition operator.h:136
bool & modified()
Definition operator.h:176
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimension array.
Definition tensor.h:317
T sum() const
Returns the sum of all elements of the tensor.
Definition tensor.h:1662
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:161
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
WorldGopInterface & gop
Global operations.
Definition world.h:205
Generalized version of NonlinearSolver not limited to a single madness function.
Definition nonlinsol.h:202
double(* energy)()
Definition derivatives.cc:58
const int maxiter
Definition gygi_soltion.cc:68
static double u(double r, double c)
Definition he.cc:20
static double bsh_eps
Definition helium_exact.cc:62
Implements (2nd generation) static load/data balancing for functions.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
CalcType
Calculation Types used by CC2.
Definition CCStructures.h:27
@ CT_CC2
Definition CCStructures.h:28
@ CT_LRCC2
Definition CCStructures.h:28
@ CT_LRCCS
Definition CCStructures.h:28
@ CT_CISPD
Definition CCStructures.h:28
@ CT_TEST
Definition CCStructures.h:28
@ CT_MP2
Definition CCStructures.h:28
@ CT_ADC2
Definition CCStructures.h:28
void print_header2(const std::string &s)
medium section heading
Definition print.cc:54
response_space scale(response_space a, double b)
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:1971
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:30
CCState
Type of Pairs used by CC_Pair2 class.
Definition CCStructures.h:31
@ GROUND_STATE
Definition CCStructures.h:32
@ EXCITED_STATE
Definition CCStructures.h:32
FuncType
Definition ccpairfunction.h:26
@ RESPONSE
Definition ccpairfunction.h:26
@ UNDEFINED
Definition ccpairfunction.h:26
@ PARTICLE
Definition ccpairfunction.h:26
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
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:851
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:79
void plot_plane(World &world, const Function< double, NDIM > &function, const std::string name)
Definition funcplot.h:621
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
static SeparatedConvolution< double, 3 > * BSHOperatorPtr3D(World &world, double mu, double lo, double eps, const BoundaryConditions< 3 > &bc=FunctionDefaults< 3 >::get_bc(), int k=FunctionDefaults< 3 >::get_k())
Factory function generating separated kernel for convolution with exp(-mu*r)/(4*pi*r) in 3D.
Definition operator.h:2023
void print_size(World &world, const std::vector< Function< T, NDIM > > &v, const std::string &msg="vectorfunction")
Definition vmra.h:1679
NDIM & f
Definition mra.h:2416
double inner(response_space &a, response_space &b)
Definition response_functions.h:442
std::string type(const PairType &n)
Definition PNOParameters.h:18
std::string assign_name(const CCState &input)
Assigns strings to enums for formated output.
Definition CCStructures.cc:383
void save(const Function< T, NDIM > &f, const std::string name)
Definition mra.h:2745
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
static const double a
Definition nonlinschro.cc:118
Implementation of Krylov-subspace nonlinear equation solver.
Implements most functionality of separated operators.
double Q(double a)
Definition relops.cc:20
Definition CCStructures.h:77
void warning(const std::string &msg) const
Definition CCStructures.cc:45
void subsection(const std::string &msg) const
Definition CCStructures.cc:34
void section(const std::string &msg) const
Definition CCStructures.cc:23
Definition CCStructures.h:199
std::size_t iter_max_3D() const
Definition CCStructures.h:315
bool kain() const
Definition CCStructures.h:343
double thresh_bsh_3D() const
Definition CCStructures.h:295
double thresh_bsh_6D() const
Definition CCStructures.h:297
double thresh_3D() const
Definition CCStructures.h:287
double dconv_3D() const
Definition CCStructures.h:309
double lo() const
Definition CCStructures.h:283
long freeze() const
Definition CCStructures.h:355
double thresh_6D() const
Definition CCStructures.h:291
bool QtAnsatz() const
Definition CCStructures.h:349
double dmin() const
Definition CCStructures.h:285
std::size_t output_prec() const
Definition CCStructures.h:351
bool debug() const
Definition CCStructures.h:339
void information(World &world) const
print out the parameters
Definition CCStructures.cc:195
void sanity_check(World &world) const
check if parameters are set correct
Definition CCStructures.cc:206
Timer Structure.
Definition CCStructures.h:122
void info(const bool debug=true, const double norm=12345.6789)
print out information about the passed time since the CC_TIMER object was created
Definition CCStructures.cc:52
A helper structure which holds a map of functions.
Definition CCStructures.h:509
FuncType type
Definition CCStructures.h:645
size_t size() const
Get the size vector (number of functions in the map)
Definition CCStructures.h:702
double omega
Definition CCStructures.h:646
vector_real_function_3d get_vecfunction() const
Returns all the functions of the map as vector.
Definition CCStructures.h:695
CC_functionmap functions
Definition CCStructures.h:643
std::string name(const int ex) const
excitation irrep (direct product of x function and corresponding orbital)
Definition CCStructures.h:652
POD holding some basic functions and some intermediates for the CC2 calculation.
Definition CCStructures.h:1207
std::vector< Function< double, 3 > > mo_ket
Definition CCStructures.h:1208
Tensor< double > fock
Definition CCStructures.h:1213
CCIntermediatePotentials intermediate_potentials
Definition CCStructures.h:1214
std::vector< double > orbital_energies
Definition CCStructures.h:1212
std::vector< Function< double, 3 > > mo_bra
Definition CCStructures.h:1209
CCParameters parameters
Definition CCStructures.h:1211
Function< double, 3 > R_square
Definition CCStructures.h:1215
The interface to be provided by functions to be optimized.
Definition solvers.h:176
Definition CCStructures.h:381
Definition CCStructures.h:421
Pairs< R > convert(const Pairs< T > arg, const opT op) const
convert Pairs<T> to another type
Definition CCStructures.h:430
void insert(int i, int j, const T &pair)
Definition CCStructures.h:471
very simple command line parser
Definition commandlineparser.h:15
Definition nonlinsol.h:169
static double V(const coordT &r)
Definition tdse.cc:288
InputParameters param
Definition tdse.cc:203
static const double omega
Definition tdse_example.cc:51
double norm(const T i1)
Definition test_cloud.cc:72
F residual(const F &f)
Definition testcomplexfunctionsolver.cc:69
Defines operations on vectors of Functions.