MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
psiwfn.h
1//
2// psiwfn.h
3//
4// Copyright (C) 2002 Edward Valeev
5//
6// Author: Edward Valeev <evaleev@vt.edu>
7// Maintainer: EV
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _chemistry_qc_psi_psiwfn_h
29#define _chemistry_qc_psi_psiwfn_h
30
31#include <chemistry/qc/wfn/wfn.h>
32#include <chemistry/qc/wfn/obwfn.h>
33#include <chemistry/qc/psi/psiexenv.h>
34#include <chemistry/qc/wfn/spin.h>
35#include <chemistry/qc/wfn/orbitalspace.h>
36#include <chemistry/qc/mbptr12/mbptr12.h>
37
38namespace sc {
39
41
47
48 Ref<PsiExEnv> exenv_;
50 int value_implemented() const {
51 return 1;
52 }
53
54 protected:
55 Ref<PsiWavefunction> prerequisite_;
56 int nirrep_;
57 size_t memory_;
58 char *memory_str_;
59 bool compute_1rdm_;
60 char *dertype_;
62 virtual void write_input(int conv) =0;
63
64 std::vector<unsigned int> read_occ(const Ref<KeyVal> &keyval, const char *name,
65 size_t nirrep);
66
68 int debug() const;
69
70 public:
94
96
99
102 virtual void write_basic_input(int conv);
103 void compute();
104 void print(std::ostream&o=ExEnv::out0()) const;
105 int nirrep() const { return nirrep_; }
106
109 virtual RefSymmSCMatrix mo_density(SpinCase1 spin = AnySpinCase1) =0;
110
113 return exenv_;
114 }
115
118 return exenv_->get_psi_input();
119 }
120
121#if 0
123 std::vector< std::pair<unsigned int,unsigned int> > shell_map();
125 std::vector<unsigned int> ao_map();
126#endif
127
130
131 void obsolete();
133 };
134
135 class PsiSCF;
136
139
141 protected:
142 Ref<PsiSCF> reference_;
143 unsigned int nfzc_;
144 unsigned int nfzv_;
145 mutable std::vector<unsigned int> frozen_docc_;
146 mutable std::vector<unsigned int> frozen_uocc_;
147 RefSymmSCMatrix mo_density_[NSpinCases1];
148
149 void write_input(int conv);
150 // set fz2restr to use RESTRICTED instead of FROZEN keywords
151 void write_input_frozen2restricted(int conv, bool fz2restr);
152
153 double valacc_to_refacc() const { return 100.0; }
154
160 virtual std::vector<unsigned int> map_density_to_sb();
161
162 public:
197
198 void print(std::ostream& os) const;
199 double magnetic_moment() const;
202
203 void compute(); // compute is overloaded because reference object needs to be marked computed
204 void obsolete();
208
209 const Ref<PsiSCF>& reference() const;
212
213#if 0 // these should be implemented in PsiCC classes
215 const Ref<OrbitalSpace>& occ_act_sb(SpinCase1);
217 const Ref<OrbitalSpace>& vir_act_sb(SpinCase1);
218#endif
220 unsigned int nfzc() const;
222 unsigned int nfzv() const;
226 virtual const Ref<OrbitalSpace>& orbs_sb(SpinCase1 spin);
227
229 const std::vector<unsigned int>& frozen_docc() const;
231 const std::vector<unsigned int>& frozen_uocc() const;
233 const std::vector<unsigned int> docc_act();
234 const std::vector<unsigned int> socc();
235 const std::vector<unsigned int> uocc_act();
236 const std::vector<unsigned int> docc();
237 const std::vector<unsigned int> uocc();
238
240 virtual double reference_energy();
241
244#if 0
246 RefSymmSCMatrix onepdm(const SpinCase1 &spin);
247 RefSymmSCMatrix onepdm();
250 RefSymmSCMatrix twopdm();
253 RefSymmSCMatrix twopdm_dirac_from_components();
254#endif
256 RefSymmSCMatrix twopdm_dirac(const SpinCase2 &pairspin);
259 void print_onepdm_vec(FILE *output,const RefSCVector &opdm,double TOL);
260 void print_onepdm_mat(FILE *output,const RefSymmSCMatrix &opdm,double TOL);
261 void print_twopdm_mat(FILE *output,const RefSymmSCMatrix &tpdm, double TOL);
262 void print_twopdm_arr(FILE *output,double *tpdm,double TOL);
263 };
264
265
268
269 class PsiSCF : public PsiWavefunction {
270 Ref<OrbitalSpace> orbs_sb_[NSpinCases1];
271 RefDiagSCMatrix evals_[NSpinCases1];
272 RefSCMatrix coefs_[NSpinCases1];
273 RefSymmSCMatrix mo_density_[NSpinCases1];
274 std::vector<unsigned int> occpi_[NSpinCases1];
275 std::vector<unsigned int> uoccpi_[NSpinCases1];
276 std::vector<unsigned int> mopi_;
277 std::vector<double> occupation_[NSpinCases1];
278 void compute_occupations(SpinCase1 spin);
279
280 // PsiCorrWavefunction needs to be able to set value of PsiSCF
281 friend void PsiCorrWavefunction::compute();
282 protected:
283 std::vector<unsigned int> docc_;
284 std::vector<unsigned int> socc_;
285 int multp_;
286 int charge_;
287 int maxiter_;
288 double diisdamp_;
289 double levelshift_;
290 bool diis_;
291 static const int default_maxiter = 200;
293 static double guess_acc_ratio() { return 1e4; }
294
297
298 public:
314 PsiSCF(StateIn&);
315 ~PsiSCF();
317
318 double magnetic_moment() const;
319
323 enum RefType {rhf, hsoshf, uhf};
325 virtual PsiSCF::RefType reftype() const =0;
327 virtual const RefDiagSCMatrix& evals(SpinCase1 spin = AnySpinCase1);
329 virtual const RefSCMatrix& coefs(SpinCase1 spin = AnySpinCase1);
331 const std::vector<unsigned int>& occpi(SpinCase1 S);
333 const std::vector<unsigned int>& uoccpi(SpinCase1 S);
335 const std::vector<unsigned int>& mopi();
337 const Ref<OrbitalSpace>& orbs_sb(SpinCase1 spin);
341 double occupation(int mo);
343 double alpha_occupation(int mo);
345 double beta_occupation(int mo);
346
352
357 RefSymmSCMatrix mo_density(SpinCase1 spin = AnySpinCase1);
358
360 unsigned int nmo();
362 unsigned int nocc(SpinCase1 spin);
364 unsigned int multiplicity() const { return multp_; }
365
366 void obsolete();
368 };
369
372
373 class PsiCLHF : public PsiSCF {
374 protected:
375 void write_input(int conv);
376 public:
377 PsiCLHF(const Ref<KeyVal>&);
379 ~PsiCLHF();
380 void print(std::ostream& os = ExEnv::out0()) const;
381
382 void write_basic_input(int conv);
384 return true;
385 }
386 PsiSCF::RefType reftype() const {
387 return rhf;
388 }
389 };
390
393
394 class PsiHSOSHF : public PsiSCF {
395 protected:
396 void write_input(int conv);
397 public:
398 PsiHSOSHF(const Ref<KeyVal>&);
400 ~PsiHSOSHF();
401 void print(std::ostream& os = ExEnv::out0()) const;
402
403 void write_basic_input(int conv);
405 return true;
406 }
407 PsiSCF::RefType reftype() const {
408 return hsoshf;
409 }
410
412 const RefSCMatrix& coefs_semicanonical(SpinCase1 s);
415
416 private:
417 RefSCMatrix coefs_sc_[NSpinCases1];
418 RefDiagSCMatrix evals_sc_[NSpinCases1];
419
421 void semicanonical();
422
423 void obsolete();
424 };
425
428
429 class PsiUHF : public PsiSCF {
430 protected:
431 void write_input(int conv);
432 public:
433 PsiUHF(const Ref<KeyVal>&);
434 PsiUHF(StateIn&);
435 ~PsiUHF();
436 void print(std::ostream& os = ExEnv::out0()) const;
437
438 void write_basic_input(int conv);
440 return true;
441 }
442 PsiSCF::RefType reftype() const {
443 return uhf;
444 }
445 };
446
447 namespace detail {
456 RefSymmSCMatrix rdopdm(SpinCase1 spin,
457 const std::vector<unsigned int>& mopi,
458 const std::vector<unsigned int>& dmap,
459 Ref<SCMatrixKit> kit = 0);
464 RefSymmSCMatrix rdtpdm(SpinCase2 pairspin,
465 const std::vector<unsigned int>& dmap,
466 bool spinfree = false,
467 Ref<SCMatrixKit> kit = 0);
468 }
469}
470#endif
static std::ostream & out0()
Return an ostream that writes from node 0.
CartesianOrdering
Describes the ordering of the cartesian functions in a shell.
Definition integral.h:175
PsiCLHF is a concrete implementation of Psi RHF wave function.
Definition psiwfn.h:373
PsiSCF::RefType reftype() const
Returns the PsiSCF::RefType of this particular Psi SCF wave function.
Definition psiwfn.h:386
bool analytic_gradient_implemented() const
must overload this in a derived class if analytic gradient can be computed
Definition psiwfn.h:383
void write_basic_input(int conv)
Writes out Psi input file entries specific to this PsiWavefunction.
void print(std::ostream &os=ExEnv::out0()) const
Print information about the object.
void write_input(int conv)
Prepares a complete Psi input file. The input file is assumed to have been opened.
PsiCorrWavefunction is a Psi correlated wave function.
Definition psiwfn.h:140
int nelectron()
Number of electrons.
RefSymmSCMatrix twopdm_dirac()
produces spin-free 2-RDM
void set_desired_value_accuracy(double acc)
sets the desired value accuracy
PsiCorrWavefunction(const Ref< KeyVal > &)
A KeyVal constructor is used to generate a PsiCorrWavefunction object from the input.
void write_input(int conv)
Prepares a complete Psi input file. The input file is assumed to have been opened.
RefSymmSCMatrix density()
reimplementation of PsiWavefunction::density()
RefSymmSCMatrix mo_density(SpinCase1 spin)
return one-particel density matrix in symmetry-blocked orbitals
unsigned int nfzv() const
total # of frozen unoccupied orbitals
virtual const Ref< OrbitalSpace > & orbs_sb(SpinCase1 spin)
symmetry-blocked space of MO's from Psi3 the default implementation returns the orbitals from referen...
const std::vector< unsigned int > & frozen_uocc() const
virtual std::vector< unsigned int > map_density_to_sb()
returns the index map that transforms indices in which densities are reported in Psi to the symmetry-...
virtual double reference_energy()
reference energy
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void obsolete()
Marks all results as being out of date.
const std::vector< unsigned int > & frozen_docc() const
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
void compute()
Recompute at least the results that have compute true and are not already computed.
double magnetic_moment() const
Computes the S (or J) magnetic moment of the target state(s), in units of .
void print(std::ostream &os) const
Print information about the object.
unsigned int nfzc() const
total # of frozen doubly-occupied orbitals
RefSymmSCMatrix twopdm_dirac(const SpinCase2 &pairspin)
produces 2-RDM for spin case pairspin
const std::vector< unsigned int > docc_act()
PsiHSOSHF is a concrete implementation of Psi ROHF wave function.
Definition psiwfn.h:394
const RefDiagSCMatrix & evals_semicanonical(SpinCase1 s)
returns the eigenvalues of semicanonical MOs in AO basis
void write_input(int conv)
Prepares a complete Psi input file. The input file is assumed to have been opened.
bool analytic_gradient_implemented() const
must overload this in a derived class if analytic gradient can be computed
Definition psiwfn.h:404
PsiSCF::RefType reftype() const
Returns the PsiSCF::RefType of this particular Psi SCF wave function.
Definition psiwfn.h:407
void write_basic_input(int conv)
Writes out Psi input file entries specific to this PsiWavefunction.
void print(std::ostream &os=ExEnv::out0()) const
Print information about the object.
const RefSCMatrix & coefs_semicanonical(SpinCase1 s)
returns the semicanonical MO coefficients in AO basis
PsiSCF is an abstract base for all Psi SCF wave functions.
Definition psiwfn.h:269
unsigned int nocc(SpinCase1 spin)
number of occupied MOs of spin
RefSymmSCMatrix density()
Returns the SO density.
static double guess_acc_ratio()
how much lower is the desired accuracy of the guess?
Definition psiwfn.h:293
void import_occupations(const Ref< OneBodyWavefunction > &obwfn)
imports occupations from obwfn.
const Ref< OrbitalSpace > & orbs_sb(SpinCase1 spin)
symmetry-blocked space
const std::vector< unsigned int > & uoccpi(SpinCase1 S)
Number of unoccupied orbitals of spin S per irrep.
double beta_occupation(int mo)
Returns the occupation for beta orbitals.
unsigned int multiplicity() const
spin multiplicity
Definition psiwfn.h:364
const std::vector< unsigned int > & mopi()
Number of orbitals per irrep.
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
unsigned int nmo()
number of MOs
RefSymmSCMatrix ao_density(SpinCase1)
AO-basis densities.
RefSymmSCMatrix alpha_density()
Return alpha electron densities in the SO basis.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
virtual PsiSCF::RefType reftype() const =0
Returns the PsiSCF::RefType of this particular Psi SCF wave function.
void obsolete()
Marks all results as being out of date.
double alpha_occupation(int mo)
Returns the occupation for alpha orbitals.
RefSymmSCMatrix beta_density()
Return beta electron densities in the SO basis.
virtual const RefSCMatrix & coefs(SpinCase1 spin=AnySpinCase1)
Returns the coefficient matrix in AO basis.
PsiSCF(const Ref< KeyVal > &)
The KeyVal constructor uses all keywords of PsiWavefunction class and the following additional keywor...
Ref< OneBodyWavefunction > guess_wfn_
guess wave function is only used to get the occupations
Definition psiwfn.h:296
virtual const RefDiagSCMatrix & evals(SpinCase1 spin=AnySpinCase1)
Returns the eigenvalues matrix.
double magnetic_moment() const
Computes the S (or J) magnetic moment of the target state(s), in units of .
RefSymmSCMatrix ao_density()
Returns the AO density.
const std::vector< unsigned int > & occpi(SpinCase1 S)
Number of occupied orbitals of spin S per irrep.
int nelectron()
Number of electrons.
double occupation(int mo)
Returns the total occupation for orbital mo.
RefSymmSCMatrix mo_density(SpinCase1 spin=AnySpinCase1)
MO-basis density.
PsiUHF is a concrete implementation of Psi UHF wave function.
Definition psiwfn.h:429
PsiSCF::RefType reftype() const
Returns the PsiSCF::RefType of this particular Psi SCF wave function.
Definition psiwfn.h:442
void write_input(int conv)
Prepares a complete Psi input file. The input file is assumed to have been opened.
void write_basic_input(int conv)
Writes out Psi input file entries specific to this PsiWavefunction.
bool analytic_gradient_implemented() const
must overload this in a derived class if analytic gradient can be computed
Definition psiwfn.h:439
void print(std::ostream &os=ExEnv::out0()) const
Print information about the object.
PsiWavefunction is an abstract base for all Psi wave functions.
Definition psiwfn.h:46
virtual void write_basic_input(int conv)
Writes out Psi input file entries specific to this PsiWavefunction.
double nuclear_repulsion_energy()
return Psi3 nuclear repulsion energy
void symmetry_changed()
Call this if you have changed the molecular symmetry of the molecule contained by this MolecularEnerg...
void compute()
Recompute at least the results that have compute true and are not already computed.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void print(std::ostream &o=ExEnv::out0()) const
Print information about the object.
PsiWavefunction(const Ref< KeyVal > &)
The KeyVal constructor.
Ref< PsiInput > get_psi_input() const
Return an associated PsiInput object.
Definition psiwfn.h:117
virtual void write_input(int conv)=0
Prepares a complete Psi input file. The input file is assumed to have been opened.
static Integral::CartesianOrdering cartesian_ordering()
returns the Psi3 convention for the ordering of the cartesian functions
void obsolete()
Marks all results as being out of date.
virtual RefSymmSCMatrix mo_density(SpinCase1 spin=AnySpinCase1)=0
Returns the MO basis density (blocked by symmetry)
int debug() const
return the debug level
Ref< PsiExEnv > exenv() const
Return an associated PsiExEnv object.
Definition psiwfn.h:112
virtual RefSymmSCMatrix density()
Returns the SO density.
refcount_t reference()
Increment the reference count and return the new count.
Definition ref.h:271
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition matrix.h:389
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition matrix.h:135
The RefSCVector class is a smart pointer to an SCVector specialization.
Definition matrix.h:55
The RefSymmSCMatrix class is a smart pointer to an SCSymmSCMatrix specialization.
Definition matrix.h:265
A template class that maintains references counts.
Definition ref.h:361
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
A Wavefunction is a MolecularEnergy that utilizies a GaussianBasisSet.
Definition wfn.h:52
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.