MADNESS 0.10.1
ground_parameters.h
Go to the documentation of this file.
1
2/// \file GroundStateCalculation
3/// \brief Input parameters for a response calculation, read from a specified
4/// archive.
5
6#ifndef MADNESS_APPS_GROUNDPARAMS_H_INCLUDED
7#define MADNESS_APPS_GROUNDPARAMS_H_INCLUDED
8
9#include <utility>
10
11#include "../chem/molecule.h"
12#include "Plot_VTK.h"
13#include "basic_operators.h"
14#include "madness/chem/NWChem.h" // For nwchem interface
18#include "madness/chem/projector.h" // For easy calculation of (1 - \hat{\rho}^0)
22
23using namespace madness;
24
26 // Ground state parameters that are read in from archive
27 std::string inFile{"../moldft.restartdata"};///< Name of input archive to read in ground state
28 bool spinrestricted{true};///< Indicates if ground state calc. was open or closed shell
29 unsigned int num_orbitals{};///< Number of orbitals in ground state
30 Tensor<double> energies{}; ///< Energy of ground state orbitals
31 Tensor<double> occ{}; ///< Occupancy of ground state orbitals
32 double L{}; ///< Box size of ground state - response calcluation is in same box
33 int k{}; ///< Order of polynomial used in ground state
34 Molecule molecule_in{}; ///< The molecule used in ground state calculation
35 std::vector<real_function_3d> g_orbitals{};///< The ground state orbitals
36 std::string xc{}; ///< Name of xc functional used in ground state
37 std::string localize_method{}; ///< Name of localization method used in ground state
38 double converged_for_thresh{}; ///< Convergence threshold used in ground state calculation
39
40 // Default constructor
41 public:
42 explicit GroundStateCalculation(World& world) { read(world); }
43
44 explicit GroundStateCalculation(World& world, std::string input_file)
45 : inFile{std::move(input_file)} {
46 read(world);
47 }
48
50
51 bool is_spinrestricted() const { return spinrestricted; }
52
53 unsigned int n_orbitals() const { return num_orbitals; }
54
56
57 Tensor<double> get_occ() const { return occ; }
58
59 Molecule molecule() const { return molecule_in; }
60
61 double get_L() const { return L; }
62
63 int get_k() const { return k; }
64
66
67 std::string get_xc() const { return xc; }
68 std::string get_localize_method() const { return localize_method; }
69
70 std::string get_archive() const { return xc; }
71
72 // Initializes ResponseParameters using the contents of file \c filename
73 void read(World& world) {
74 // Save the filename
75
76 unsigned int dummyversion;
77 double dummy1;
78 std::vector<int> dummy2;
79 archive::ParallelInputArchive input(world, inFile.c_str());
80 input & dummyversion;
81 input & dummy1; // double
82 input & spinrestricted; // bool
83 input & L; // double box size
84 input & k; // int wavelet order
85 input & molecule_in; // Molecule
86 input & xc; // std:string xc functional
87 input & localize_method; // std:string localize method
88 if (dummyversion > 3) {
90 }
91 input & num_orbitals; // int
92 input & energies; // Tensor<double> orbital energies
93 input & occ; // Tensor<double> orbital occupations
94 input & dummy2; // std::vector<int> sets of orbitals(?)
95
96 // Check that order is positive and less than 30
97 if (k < 1 or k > 30) {
98 if (world.rank() == 0)
99 print(
100 "\n ***PLEASE NOTE***\n Invalid wavelet order read from "
101 "archive, setting to 8.\n This seems to happen when the default "
102 "wavelet order is used in moldft.");
103 k = 8;
104 }
105 // Set this so we can read in whats
106 // written in the archive
108 // Possible to call this function multiple times now
109 // Do this to ensure everything works.
110 world.gop.fence();
111 g_orbitals.clear();
112 world.gop.fence();
113 // Read in ground state orbitals
114 for (unsigned int i = 0; i < num_orbitals; i++) {
115 real_function_3d reader;
116 input & reader;
117 g_orbitals.push_back(reader);
118 }
119 world.gop.fence();
120 //projector_irrep c2v("c2v");
121 //g_orbitals = c2v(g_orbitals);
122 // Clean up
123 truncate(world, g_orbitals);
124 }
125
126 // Prints all information
127 void print_params() const {
128 madness::print("\n Ground State Parameters");
129 madness::print(" -----------------------");
130 madness::print(" Ground State Archive:", inFile);
131 madness::print(" Ground State Functional:", xc);
132 madness::print(" Localize Method Functional:", localize_method);
133 madness::print(" Spin Restricted:", spinrestricted);
134 madness::print(" Number of orbitals:", num_orbitals);
135 madness::print(" L:", L);
136 madness::print(" Wavelet Order:", k);
137 madness::print(" Orbital Energies:", energies);
138 }
139};
140
141#endif
Operators for the molecular HF and DFT code.
Definition ground_parameters.h:25
std::string inFile
Name of input archive to read in ground state.
Definition ground_parameters.h:27
bool spinrestricted
Indicates if ground state calc. was open or closed shell.
Definition ground_parameters.h:28
std::string xc
Name of xc functional used in ground state.
Definition ground_parameters.h:36
std::string get_localize_method() const
Definition ground_parameters.h:68
GroundStateCalculation(World &world)
Definition ground_parameters.h:42
double L
Box size of ground state - response calcluation is in same box.
Definition ground_parameters.h:32
double get_L() const
Definition ground_parameters.h:61
std::vector< real_function_3d > g_orbitals
The ground state orbitals.
Definition ground_parameters.h:35
std::string get_xc() const
Definition ground_parameters.h:67
vector_real_function_3d & orbitals()
Definition ground_parameters.h:65
std::string localize_method
Name of localization method used in ground state.
Definition ground_parameters.h:37
Molecule molecule_in
The molecule used in ground state calculation.
Definition ground_parameters.h:34
Tensor< double > occ
Occupancy of ground state orbitals.
Definition ground_parameters.h:31
unsigned int n_orbitals() const
Definition ground_parameters.h:53
void print_params() const
Definition ground_parameters.h:127
GroundStateCalculation(World &world, std::string input_file)
Definition ground_parameters.h:44
double converged_for_thresh
Convergence threshold used in ground state calculation.
Definition ground_parameters.h:38
int k
Order of polynomial used in ground state.
Definition ground_parameters.h:33
bool is_spinrestricted() const
Definition ground_parameters.h:51
int get_k() const
Definition ground_parameters.h:63
Tensor< double > get_energies() const
Definition ground_parameters.h:55
void read(World &world)
Definition ground_parameters.h:73
unsigned int num_orbitals
Number of orbitals in ground state.
Definition ground_parameters.h:29
Molecule molecule() const
Definition ground_parameters.h:59
Tensor< double > get_occ() const
Definition ground_parameters.h:57
Tensor< double > energies
Energy of ground state orbitals.
Definition ground_parameters.h:30
GroundStateCalculation(const GroundStateCalculation &other)=default
std::string get_archive() const
Definition ground_parameters.h:70
static void set_k(int value)
Sets the default wavelet order.
Definition funcdefaults.h:170
Definition molecule.h:129
A tensor is a multidimensional array.
Definition tensor.h:317
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:320
WorldGopInterface & gop
Global operations.
Definition world.h:207
An archive for storing local or parallel data, wrapping a BinaryFstreamInputArchive.
Definition parallel_archive.h:366
Provides FunctionDefaults and utilities for coordinate transformation.
Provides typedefs to hide use of templates and to increase interoperability.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void truncate(World &world, response_space &v, double tol, bool fence)
Definition basic_operators.cc:31
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:94
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
Definition mraimpl.h:50
Declaration of molecule-related classes and functions.
Defines and implements most of Tensor.