Permalink
Browse files

Wavefunction constructor from reference (#1277)

* Add Wavefunction CTOR from ref wfn

This handles the shallow_copy and set_reference_wavefunction which are
otherwise copy-pasted in each derived class

* Use delegating constructor for CIWavefunction
  • Loading branch information...
robertodr authored and andysim committed Oct 26, 2018
1 parent da8c3de commit 4e9d75ae0de47c85cb9eb7172f235fcbda37c712
@@ -51,19 +51,13 @@ PRAGMA_WARNING_POP
namespace psi {
namespace detci {
CIWavefunction::CIWavefunction(std::shared_ptr<Wavefunction> ref_wfn) : Wavefunction(Process::environment.options) {
// Copy the wavefuntion then update
shallow_copy(ref_wfn);
set_reference_wavefunction(ref_wfn);
CIWavefunction::CIWavefunction(std::shared_ptr<Wavefunction> ref_wfn, Options& options)
: Wavefunction{ref_wfn, options} {
common_init();
}
CIWavefunction::CIWavefunction(std::shared_ptr<Wavefunction> ref_wfn, Options& options) : Wavefunction(options) {
// Copy the wavefuntion then update
shallow_copy(ref_wfn);
set_reference_wavefunction(ref_wfn);
common_init();
}
CIWavefunction::CIWavefunction(std::shared_ptr<Wavefunction> ref_wfn)
: CIWavefunction{ref_wfn, Process::environment.options} {}
CIWavefunction::~CIWavefunction() {
cleanup_ci();
@@ -72,8 +72,8 @@ namespace detci {
class CIWavefunction : public Wavefunction {
public:
CIWavefunction(std::shared_ptr<Wavefunction> reference_wavefunction);
CIWavefunction(std::shared_ptr<Wavefunction> reference_wavefunction, Options &options);
explicit CIWavefunction(std::shared_ptr<Wavefunction> reference_wavefunction);
virtual ~CIWavefunction();
double compute_energy();
@@ -85,6 +85,13 @@ Wavefunction::Wavefunction(std::shared_ptr<Molecule> molecule, std::shared_ptr<B
common_init();
}
Wavefunction::Wavefunction(SharedWavefunction reference_wavefunction, Options &options)
: options_(options), dipole_field_strength_{{0.0, 0.0, 0.0}}, PCM_enabled_(false) {
// Copy the wavefuntion then update
shallow_copy(reference_wavefunction);
set_reference_wavefunction(reference_wavefunction);
}
Wavefunction::Wavefunction(Options &options)
: options_(options), dipole_field_strength_{{0.0, 0.0, 0.0}}, PCM_enabled_(false) {}
@@ -255,6 +255,9 @@ class PSI_API Wavefunction : public std::enable_shared_from_this<Wavefunction> {
/// Constructor for an entirely new wavefunction with an existing basis and global options
Wavefunction(std::shared_ptr<Molecule> molecule, std::shared_ptr<BasisSet> basis);
/// Blank constructor for derived classes
Wavefunction(SharedWavefunction reference_wavefunction, Options& options);
/// Blank constructor for derived classes
Wavefunction(Options& options);

0 comments on commit 4e9d75a

Please sign in to comment.