MADNESS  0.10.1
apps/molresponse/testing/write_test_input.h
Go to the documentation of this file.
1 //
2 // Created by Florian Bischoff on 5/27/21.
3 // Modified by Adrian Hurtado on 2/01/22
4 //
5 
6 #ifndef MADNESS_WRITE_RESPONSE_INPUT_H
7 #define MADNESS_WRITE_RESPONSE_INPUT_H
8 
10 
11 #include "response_parameters.h"
12 
13 namespace molresponse {
14 
15  /// will write a test input and remove it from disk upon destruction
17 
18  double eprec = 1.e-4;// was 1e-4 ... trying to make test faster
19 
20  std::string filename_;
21  std::string molecule_path;
22  bool keepfile = true;
23 
24  write_test_input() : filename_("moldft.in") {}
25 
26  explicit write_test_input(const CalculationParameters& param, const std::string& filename,
27  std::string mol_path)
28  : filename_(filename),molecule_path(mol_path) {
29  std::ofstream of(filename_);
30  write_to_test_input("dft", &param, of);
32  of.close();
33  }
34 
36  if (not keepfile) std::remove(filename_.c_str());
37  }
38 
39  std::string filename() const { return filename_; }
40 
41  static std::ostream& write_to_test_input(const std::string& groupname,
43  std::ostream& of) {
44  of << groupname << endl;
45  of << param->print_to_string(true);
46  of << "end\n";
47  return of;
48  }
49 
50  static std::ostream& write_molecule_to_test_input(std::string mol_path, std::ostream& of) {
51 
52 
53  std::cout<<mol_path<<"\n";
54  std::ifstream mol_file(mol_path);
55  std::string line;
56  while(getline(mol_file,line)){
57  std::cout<<line<<"\n";
58  of<<line<<"\n";
59  }
60  return of;
61 
62  }
63  };
64  /// will write a test input and remove it from disk upon destruction
66 
67  double eprec = 1.e-4;// was 1e-4 ... trying to make test faster
68 
69  std::string filename_;
70  bool keepfile = true;
71 
72  write_response_input() : filename_("response_test") {}
73 
74  explicit write_response_input(const ResponseParameters& param, const std::string& filename)
75  : filename_(filename) {
76  std::ofstream of(filename_);
77  write_to_test_input("response", &param, of);
78  of.close();
79  }
80 
82  if (not keepfile) std::remove(filename_.c_str());
83  }
84 
85  std::string filename() const { return filename_; }
86 
87  static std::ostream& write_to_test_input(const std::string& groupname,
89  std::ostream& of) {
90  of << groupname << endl;
91  of << param->print_to_string(true);
92  of << "end\n";
93  return of;
94  }
95  };
96 
97 
98 }// namespace madness
99 
100 
101 #endif//MADNESS_WRITE_RESPONSE_INPUT_H
class for holding the parameters for calculation
Definition: QCCalculationParametersBase.h:290
Definition: apps/molresponse/testing/write_test_input.h:13
Definition: CalculationParameters.h:51
Definition: response_parameters.h:24
will write a test input and remove it from disk upon destruction
Definition: apps/molresponse/testing/write_test_input.h:65
std::string filename() const
Definition: apps/molresponse/testing/write_test_input.h:85
write_response_input()
Definition: apps/molresponse/testing/write_test_input.h:72
bool keepfile
Definition: apps/molresponse/testing/write_test_input.h:70
~write_response_input()
Definition: apps/molresponse/testing/write_test_input.h:81
std::string filename_
Definition: apps/molresponse/testing/write_test_input.h:69
static std::ostream & write_to_test_input(const std::string &groupname, const ResponseParameters *param, std::ostream &of)
Definition: apps/molresponse/testing/write_test_input.h:87
double eprec
Definition: apps/molresponse/testing/write_test_input.h:67
write_response_input(const ResponseParameters &param, const std::string &filename)
Definition: apps/molresponse/testing/write_test_input.h:74
will write a test input and remove it from disk upon destruction
Definition: apps/molresponse/testing/write_test_input.h:16
static std::ostream & write_molecule_to_test_input(std::string mol_path, std::ostream &of)
Definition: apps/molresponse/testing/write_test_input.h:50
double eprec
Definition: apps/molresponse/testing/write_test_input.h:18
std::string filename_
Definition: apps/molresponse/testing/write_test_input.h:20
bool keepfile
Definition: apps/molresponse/testing/write_test_input.h:22
write_test_input(const CalculationParameters &param, const std::string &filename, std::string mol_path)
Definition: apps/molresponse/testing/write_test_input.h:26
~write_test_input()
Definition: apps/molresponse/testing/write_test_input.h:35
write_test_input()
Definition: apps/molresponse/testing/write_test_input.h:24
std::string molecule_path
Definition: apps/molresponse/testing/write_test_input.h:21
std::string filename() const
Definition: apps/molresponse/testing/write_test_input.h:39
static std::ostream & write_to_test_input(const std::string &groupname, const QCCalculationParametersBase *param, std::ostream &of)
Definition: apps/molresponse/testing/write_test_input.h:41
InputParameters param
Definition: tdse.cc:203