MADNESS  0.10.1
DF.h
Go to the documentation of this file.
1 #ifndef MADNESS_APPS_DF_H_INCLUDED
2 #define MADNESS_APPS_DF_H_INCLUDED
3 
4 #include <madness/mra/mra.h>
5 #include <madness/mra/operator.h>
6 #include <madness/constants.h>
7 #include <madness/mra/nonlinsol.h> // The kain solver
8 #include <vector>
9 #include <math.h>
10 #include <stdio.h>
11 #include <iomanip>
12 #include <complex>
13 #include <cmath>
14 #include <string>
15 #include <algorithm>
16 #include <madness/chem/molecule.h>
17 #include "DFParameters.h"
18 #include "InitParameters.h"
19 
20 
21 using namespace madness;
22 
23 
24 /// Given a molecule and nonrelativistic ground state orbitals, solve the Dirac-Hartree-Fock equations
25 class DF {
26  private:
27  // Member variables
28 
29  // DFParameter object to hold all user input variables
31 
32  // InitParametesr object to hold all variables needed from
33  // nonrelativistic ground state calculation. Read from an archive
35 
36  // Timer variables
37  std::vector<double> sss, ttt;
38 
39  // Tensor for holding energies
41 
42  //Vector of DF Fcwf occupied orbitals
43  std::vector<Fcwf> occupieds;
44 
45  //Total energy of the system
46  double total_energy;
47 
48  //Whether or not the calculation to be done is closed shell
50 
51  public:
52 
53  // Start a timer
54  void start_timer(World & world);
55 
56  // Needed to do timers correctly
57  double pop(std::vector<double> & v);
58 
59  // Stop a timer
61 
62  //Find current time (relative to job start)
63  Tensor<double> get_times(World& world);
64 
65  // Collective constructor uses contents of file \c filename and broadcasts to all nodes
66  DF(World & world, // MADNESS world object
67  const char* input_file); // Input file
68 
69  // Collective constructor uses contents of stream \c input and broadcasts to all nodes
70  DF(World & world, // MADNESS world object
71  std::shared_ptr<std::istream> input); // Pointer to input stream
72 
73  static void help() {
74  print_header2("help page for DIRAC ");
75  print("The DIRAC code computes Dirac-Fock energies");
76  }
77 
78  static void print_parameters() {
79  print("no parameter help is available for the dirac code");
80  print("\nYou need a dft-block and a DiracFock-block in an input file named 'input'");
81  }
82 
83 
84 
85  //Calculates the kinetic+rest energy expectation value of psi
86  double rele(World& world, Fcwf& psi);
87 
88  //Applies the exchange operator to all of occupieds
89  void exchange(World& world, real_convolution_3d& op, std::vector<Fcwf>& Kpsis);
90 
91  //diagonalizes occupieds in the Fock space. Transforms occupieds and Kpsis.
92  void diagonalize(World& world, real_function_3d& myV,real_convolution_3d& op, std::vector<Fcwf>& Kpsis);
93 
94  // Small function to print geometry of a molecule nicely
95  // Straight up stolen from Bryan
96  void print_molecule(World &world);
97 
98  //Saves the state of a DF job so that it can be restarted
99  void saveDF(World& world);
100 
101  //Creates the gaussian nuclear potential from the molecule object
102  void make_gaussian_potential(World& world, real_function_3d& potential);
103 
104  //Creates the gaussian nuclear potential from the molecule object. Also calculates the nuclear repulsion energy
105  void make_gaussian_potential(World& world, real_function_3d& potential, double& nuclear_repulsion_energy);
106 
107  //Creates the fermi nuclear potential from the molecule object
109 
110  //Creates the fermi nuclear potential from the molecule object. Also calculates the nuclear repulsion energy
111  void make_fermi_potential(World& world, real_convolution_3d& op, real_function_3d& potential, double& nuclear_repulsion_energy);
112 
113  //Load balancing function
114  void DF_load_balance(World& world, real_function_3d& Vnuc);
115 
116  //Does one full SCF iteration
117  bool iterate(World& world, real_function_3d& V, real_convolution_3d& op, real_function_3d& JandV, std::vector<Fcwf>& Kpsis, XNonlinearSolver<std::vector<Fcwf>, std::complex<double>, Fcwf_vector_allocator>& kainsolver, double& tolerance, int& iteration_number, double& nuclear_repulsion_energy);
118 
119 
120  //Runs the job specified in the input parameters
121  void solve(World& world);
122 
123  //solves the Dirac Fock equation for the occupied orbitals
124  void solve_occupied(World & world);
125 
126  //Lineplot the densities. Currently only along x axis from 0 to L
127  void make_density_lineplots(World& world, const char* filename, int npt, double endpnt);
128 
129  //Lineplot the densities of the large and small component separately. only along x axis from 0 to L
130  void make_component_lineplots(World& world, const char* filename1, const char* filename2, int npt, double endpnt);
131 
132  //orthogonormalize occupieds, overwriting the ones in memory
133  void orthogonalize_inplace(World& world);
134 
135  //Lineplot the densities of the large and small component separately. only along x axis on log scale from 10^-startpnt to 10^endpnt with pts evenly spaced in log space
136  void make_component_logplots(World& world, const char* filename1, const char* filename2, int npt, int startpnt, int endpnt);
137 
138  //print the number of coefficients used to represent all occupied orbitals. primarily used when debugging.
139  void print_sizes(World& world, bool individual);
140 
141 };
142 
143 
144 #endif
145 
146 //kthxbye
147 
double potential(const coord_3d &r)
Definition: 3dharmonic.cc:132
Given a molecule and nonrelativistic ground state orbitals, solve the Dirac-Hartree-Fock equations.
Definition: DF.h:25
Tensor< double > energies
Definition: DF.h:40
DFParameters DFparams
Definition: DF.h:30
void make_fermi_potential(World &world, real_convolution_3d &op, real_function_3d &potential)
bool closed_shell
Definition: DF.h:49
static void print_parameters()
Definition: DF.h:78
std::vector< double > sss
Definition: DF.h:37
std::vector< Fcwf > occupieds
Definition: DF.h:43
InitParameters Init_params
Definition: DF.h:34
static void help()
Definition: DF.h:73
double total_energy
Definition: DF.h:46
Definition: fcwf.h:112
Definition: fcwf.h:12
A parallel world class.
Definition: world.h:132
Generalized version of NonlinearSolver not limited to a single madness function.
Definition: nonlinsol.h:202
Defines common mathematical and physical constants.
void print_molecule(World &world, const GroundStateCalculation &g_params)
double psi(const Vector< double, 3 > &r)
Definition: hatom_energy.cc:78
static const double v
Definition: hatom_sf_dirac.cc:20
void solve(World &world, real_function_6d &pair, double &energy, long maxiter, double dcut)
Definition: helium_mp2.cc:663
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Main include file for MADNESS and defines Function interface.
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static const char * filename
Definition: legendre.cc:96
void print_header2(const std::string &s)
medium section heading
Definition: print.cc:54
static double pop(std::vector< double > &v)
Definition: SCF.cc:113
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
static std::vector< double > ttt
Definition: SCF.cc:105
void start_timer(madness::World &world)
Definition: timer.cc:17
void end_timer(madness::World &world, const char *msg)
Definition: timer.cc:23
Implementation of Krylov-subspace nonlinear equation solver.
Implements most functionality of separated operators.
real_function_3d iterate(World &world, const real_function_3d &V, const real_function_3d &psi, double &eps)
Definition: rk.cc:392
Definition: DFParameters.h:12
Definition: InitParameters.h:19
static double V(const coordT &r)
Definition: tdse.cc:288