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