MPQC  3.0.0-alpha
psiexenv.h
1 //
2 // psiexenv.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_exenv_h
29 #define _chemistry_qc_psi_exenv_h
30 
31 #include <string>
32 #include <sstream>
33 #include <libpsio/psio.hpp>
34 #include <libchkpt/chkpt.hpp>
35 #include <chemistry/qc/psi/psiinput.h>
36 #include <chemistry/qc/psi/psifile11.h>
37 #include <chemistry/qc/wfn/spin.h>
38 
39 namespace sc {
40 
42 class PsiExEnv: public DescribedClass {
43 
45  PsiExEnv();
46 
47  static Ref<PsiExEnv> default_instance_;
48 
49  // Static Psi info
50  static std::string defaultinputname_;
51  static std::string defaultoutputname_;
52  static std::string file11name_;
53  static int ckptfile_;
54 
55  // Defaults
56  static std::string defaultpsiprefix_;
57  static std::string defaultcwd_;
58  static std::string defaultfileprefix_;
59  static std::string defaultstdout_;
60  static std::string defaultstderr_;
61 
62  // Calculation-specific info
63  std::string psiprefix_;
64  std::string cwd_; // working directory where all files will be placed
65  std::string inputname_;
66  std::string outputname_;
67  std::string fileprefix_;
68  std::string stdout_; // Standard output of psi modules
69  std::string stderr_; // Standard error of psi modules
70  int nscratch_;
71  std::vector<std::string> scratch_;
72  Ref<PsiInput> psiinput_;
73  Ref<PsiFile11> psifile11_;
74 
75  bool keep_output_;
76 
77  void config_psio();
78  psi::PSIO psio_;
79  psi::Chkpt* chkpt_;
80 
81  // Add the following to the PATH environmental variable
82  void add_to_path(const std::string &);
83 
84  // task id
85  int me_;
86 
87  public:
112  PsiExEnv(const Ref<KeyVal>&);
113  ~PsiExEnv();
114 
115  static const Ref<PsiExEnv>& get_default_instance();
116 
118  Ref<PsiInput> psi_input() const { return psiinput_; }
120  Ref<PsiFile11> psi_file11() const { return psifile11_; }
125 
129  void run_psi(bool skip_input = false);
131  void run_psi_module(const char * module, const std::vector<std::string>& args = std::vector<std::string>());
134  void run_psiclean(bool fullclean = true);
135 
137  const std::string& get_cwd() const { return cwd_;};
139  const std::string& get_fileprefix() const { return fileprefix_; };
141  int get_nscratch() const { return nscratch_; };
143  const std::string& get_scratch(int i) const { return scratch_[i]; };
144 
146  psi::PSIO& psio() { return psio_; }
148  psi::Chkpt& chkpt();
149 
150  void print(std::ostream&o=ExEnv::out0()) const;
151 
153  void keep_output();
154 };
155 
157 class PsiChkpt : public RefCount {
158  public:
160  PsiChkpt(const Ref<PsiExEnv>& exenv,
161  const Ref<Integral>& integral,
162  int debug);
163  ~PsiChkpt();
164 
165  int debug() const { return debug_; }
166 
167  const Ref<PsiExEnv>& exenv() const { return exenv_; }
168  const Ref<Integral>& integral() const { return integral_; }
169 
171  bool have_spin_unrestricted_mos() const;
173  RefDiagSCMatrix evals(SpinCase1 s,
174  bool spin_restricted = true) const;
176  RefSCMatrix coefs(SpinCase1 s,
177  bool spin_restricted = true) const;
179  std::vector< std::pair<unsigned int,unsigned int> > shell_map() const;
181  std::vector<unsigned int> ao_map() const;
182 
183  private:
184  Ref<PsiExEnv> exenv_;
185  Ref<Integral> integral_;
186  int debug_;
187 };
188 
189 }
190 
191 #endif
sc::PsiExEnv::get_psi_file11
Ref< PsiFile11 > get_psi_file11()
Creates the PsiFile11 object which PsiExEnv uses.
sc::PsiExEnv::get_scratch
const std::string & get_scratch(int i) const
Returns the ith scratch location.
Definition: psiexenv.h:143
sc::PsiChkpt::have_spin_unrestricted_mos
bool have_spin_unrestricted_mos() const
are there spin-specific orbitals?
sc::PsiExEnv::get_psi_input
Ref< PsiInput > get_psi_input()
Creates the PsiInput object which PsiExEnv uses.
sc::PsiExEnv::print
void print(std::ostream &o=ExEnv::out0()) const
Print the object.
sc::PsiExEnv::keep_output
void keep_output()
this will cause psi driver to keep the output next time it's run. Must be called every time to preven...
sc::RefSCMatrix
The RefSCMatrix class is a smart pointer to an SCMatrix specialization.
Definition: matrix.h:135
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::PsiChkpt::evals
RefDiagSCMatrix evals(SpinCase1 s, bool spin_restricted=true) const
read the orbital energies for spincase s and return as a diagonal matrix
sc::PsiChkpt
PsiChkpt know to read data from Psi checkpoint file and convert it to conform to the representations ...
Definition: psiexenv.h:157
sc::RefDiagSCMatrix
The RefDiagSCMatrix class is a smart pointer to an DiagSCMatrix specialization.
Definition: matrix.h:389
sc::PsiChkpt::shell_map
std::vector< std::pair< unsigned int, unsigned int > > shell_map() const
Returns a map from shells in Psi3 basis to std::pair<shell,contraction> in MPQC basis (note that Psi3...
sc::PsiExEnv::get_nscratch
int get_nscratch() const
Returns the number of scratch locations.
Definition: psiexenv.h:141
sc::PsiChkpt::ao_map
std::vector< unsigned int > ao_map() const
Returns a map from AO in Psi3 basis to AO in MPQC basis.
sc::PsiChkpt::PsiChkpt
PsiChkpt(const Ref< PsiExEnv > &exenv, const Ref< Integral > &integral, int debug)
Assume environment described by exenv; integrals specifies the basis set and the factory with convent...
sc::PsiExEnv::chkpt
psi::Chkpt & chkpt()
Returns an instance of psi::Chkpt.
sc::PsiExEnv::psi_input
Ref< PsiInput > psi_input() const
Returns the PsiInput object which PsiExEnv uses.
Definition: psiexenv.h:118
sc::PsiChkpt::coefs
RefSCMatrix coefs(SpinCase1 s, bool spin_restricted=true) const
read the orbital coefficients for spincase s
sc::PsiExEnv::run_psi_module
void run_psi_module(const char *module, const std::vector< std::string > &args=std::vector< std::string >())
Executes a Psi module using a system call. Throws if psi fails.
sc::DescribedClass
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
sc::PsiExEnv::get_cwd
const std::string & get_cwd() const
Returns current working directory.
Definition: psiexenv.h:137
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::PsiExEnv::psi_file11
Ref< PsiFile11 > psi_file11() const
Returns the PsiFile11 object which PsiExEnv uses.
Definition: psiexenv.h:120
sc::PsiExEnv::get_fileprefix
const std::string & get_fileprefix() const
Returns the Psi file prefix.
Definition: psiexenv.h:139
sc::PsiExEnv
PsiExEnv specifies a Psi execution environment.
Definition: psiexenv.h:42
sc::PsiExEnv::psio
psi::PSIO & psio()
Returns an instance of psi::PSIO.
Definition: psiexenv.h:146
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc::PsiExEnv::run_psi
void run_psi(bool skip_input=false)
Executes Psi input+driver.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::PsiExEnv::run_psiclean
void run_psiclean(bool fullclean=true)
cleans Psi scratch files using the same approach as psiclean.

Generated at Sun Jan 26 2020 23:23:59 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.