8 #ifndef SRC_APPS_CHEM_ZNEMO_H_
9 #define SRC_APPS_CHEM_ZNEMO_H_
27 class Diamagnetic_potential_factor;
61 initialize<double>(
"physical_B",0.0);
62 initialize<double>(
"explicit_B",0.0);
63 initialize<std::vector<double> >(
"box",{1.0, 0.01, 0.0, 0.0, 0.0});
64 initialize<double>(
"shift",0.0);
65 initialize<int>(
"printlevel",2);
66 initialize<bool>(
"use_v_vector",
false);
67 initialize<double>(
"potential_radius",-1.0);
68 initialize<std::vector<std::string> >(
"guess",std::vector<std::string>(),
"list of l,m,exponent");
69 initialize<std::vector<std::string> >(
"guess_functions",std::vector<std::string>(),
"list function names");
80 double remaining_B=fabs(pb-eb);
83 double wave_function_radius=2.0*sqrt(-log(
thresh)/remaining_B);
85 double box_radius=wave_function_radius*1.33;
94 double shift()
const {
return get<double>(
"shift");}
95 double physical_B()
const {
return get<double>(
"physical_b");}
96 double explicit_B()
const {
return get<double>(
"explicit_b");}
97 std::vector<double>
box()
const {
return get<std::vector<double> >(
"box");}
100 std::vector<std::string>
guess()
const {
return get<std::vector<std::string>>(
"guess");}
101 std::vector<std::string>
guess_functions()
const {
return get<std::vector<std::string>>(
"guess_functions");}
113 lz_mo=zero_functions<double_complex,3>(
world,nmo);
114 J_mo=zero_functions<double_complex,3>(
world,nmo);
115 K_mo=zero_functions<double_complex,3>(
world,nmo);
135 std::vector<complex_function_3d>
lz_mo;
136 std::vector<complex_function_3d>
J_mo;
137 std::vector<complex_function_3d>
K_mo;
154 void tag(
const std::string msg) {
163 void end(
const std::string msg) {
183 std::string
name()
const override {
return "znemo";};
187 print(
"The znemo code computes Hartree-Fock energies and gradients in the presence of a strong");
188 print(
"magnetic field");
190 print(
"You can print all available calculation parameters by running\n");
191 print(
"znemo --print_parameters\n");
192 print(
"You can perform a simple calculation by running\n");
193 print(
"znemo --geometry=h2o.xyz\n");
194 print(
"provided you have an xyz file in your directory.");
201 print(
"default calculations parameters for the znemo program are the same as for the nemo program");
202 print(
"default parameters for the magnetic field of the znemo program are");
203 zparam.
print(
"complex",
"end");
204 print(
"\n\nthe molecular geometry must be specified in a separate block:");
249 std::vector<real_function_3d> r(3);
276 S*=-2.0/(
B*(
amo.size()+
bmo.size()));
282 const std::vector<complex_function_3d>& alpha_mo,
283 const std::vector<complex_function_3d>& beta_mo)
const;
288 std::vector<real_function_3d> r(3),
A(3);
293 A[0]=Bvec[1]*r[2]-Bvec[2]*r[1];
294 A[1]=Bvec[2]*r[0]-Bvec[0l]*r[2];
295 A[2]=Bvec[0l]*r[1]-Bvec[1]*r[0];
338 std::string
name=
"reference";
344 for (
auto&
a:
amo) ar &
a;
345 for (
auto&
a:
bmo) ar &
a;
356 std::vector<complex_function_3d>& mo_new)
const;
359 template<
typename solverT>
362 std::vector < std::vector<Function<double_complex, 3> > >&ulist = solver.get_ulist();
363 std::vector < std::vector<Function<double_complex, 3> > >&rlist = solver.get_rlist();
364 for (
unsigned int iter = 0; iter < ulist.size(); ++iter) {
365 std::vector<Function<double_complex, 3> >&
v = ulist[iter];
366 std::vector<Function<double_complex, 3> >& r = rlist[iter];
367 std::vector<Function<double_complex, 3> > vnew =
transform(
world,
v, U, trantol,
false);
368 std::vector<Function<double_complex, 3> > rnew =
transform(
world, r, U, trantol,
true);
371 for (
size_t i=0; i<
v.size(); i++) {
379 double compute_energy(
const std::vector<complex_function_3d>&
amo,
const potentials& apot,
380 const std::vector<complex_function_3d>&
bmo,
const potentials& bpot,
const bool do_print,
const bool no_confinement)
const;
385 const std::vector<complex_function_3d>& rhs)
const;
388 const std::vector<complex_function_3d>& mo,
389 const potentials& pot)
const;
392 const std::vector<complex_function_3d>& Vpsi,
393 const std::vector<complex_function_3d>&
psi,
395 const double levelshift=0.0)
const;
398 std::vector<complex_function_3d>& vnemo,
403 std::vector<complex_function_3d>
orthonormalize(
const std::vector<complex_function_3d>& mo)
const;
405 std::vector<complex_function_3d>
normalize(
const std::vector<complex_function_3d>& mo)
const;
409 const std::vector<complex_function_3d>&
bmo)
const {
418 const std::vector<complex_function_3d>&
bmo)
const {
428 const std::vector<complex_function_3d>&
bmo)
const;
432 const std::vector<complex_function_3d>&
bmo)
const;
434 std::vector<complex_function_3d>
make_bra(
const std::vector<complex_function_3d>& mo)
const;
447 std::shared_ptr<Diamagnetic_potential_factor>
diafac;
456 std::vector<complex_function_3d>
amo,
bmo;
465 std::vector<real_function_3d>
rvec;
467 std::shared_ptr<real_convolution_3d>
coulop;
481 double r=xyz.
normf();
500 double r=xyz.
normf();
503 double theta=acos(xyz[2]/r);
505 return r*exp(-
exponent*r)*cos(theta);
507 double theta=acos(xyz[2]/r);
508 double phi=atan2(xyz[1],xyz[0]);
536 double z_confinement=exp(-0.01*xyz[2]);
537 return std::pow(zbar/
l,
double(
m)) * exp(-0.25*zbar*z/(
l*
l)) * z_confinement;
double w(double t, double eps)
Definition: DKops.h:22
real_convolution_3d A(World &world)
Definition: DKops.h:230
Operators for the molecular HF and DFT code.
std::complex< double > double_complex
Definition: cfft.h:14
Definition: test_ar.cc:118
Definition: test_ar.cc:141
Contracted Gaussian basis.
Definition: madness/chem/molecularbasis.h:465
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:279
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:68
Function< T, NDIM > & scale(const Q q, bool fence=true)
Inplace, scale the function by a constant. No communication except for optional fence.
Definition: mra.h:953
Definition: MolecularOrbitals.h:24
static void save_restartaodata(World &world, const Molecule &molecule, const MolecularOrbitals< T, NDIM > &amo, const MolecularOrbitals< T, NDIM > &bmo, const AtomicBasisSet &aobasis)
save MOs in the AO projection for geometry restart
Definition: MolecularOrbitals.cc:83
MolecularOrbitals & update_mos_and_eps(const std::vector< Function< T, NDIM > > &mo_new, const Tensor< double > &eps_new)
updates will keep other member variables
Definition: MolecularOrbitals.h:109
Definition: molecule.h:124
madness::Tensor< double > get_all_coords() const
Definition: molecule.cc:397
static void print_parameters()
Definition: molecule.cc:110
World & world
Definition: nemo.h:310
Function< typename Tensor< T >::scalar_type, NDIM > compute_density(const std::vector< Function< T, NDIM > > nemo) const
Definition: nemo.h:139
Nemo_complex_Parameters()
ctor reading out the input file
Definition: znemo.h:60
int printlevel() const
Definition: znemo.h:93
double shift() const
Definition: znemo.h:94
Nemo_complex_Parameters(World &world, const commandlineparser &parser)
Definition: znemo.h:72
bool use_v_vector() const
Definition: znemo.h:99
std::vector< std::string > guess_functions() const
Definition: znemo.h:101
double physical_B() const
Definition: znemo.h:95
double explicit_B() const
Definition: znemo.h:96
double potential_radius() const
Definition: znemo.h:98
std::vector< double > box() const
Definition: znemo.h:97
void set_derived_values()
Definition: znemo.h:77
std::vector< std::string > guess() const
Definition: znemo.h:100
class for holding the parameters for calculation
Definition: QCCalculationParametersBase.h:290
virtual void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition: QCCalculationParametersBase.h:325
void print(const std::string header="", const std::string footer="") const
print all parameters
Definition: QCCalculationParametersBase.cc:22
void set_derived_value(const std::string &key, const T &value)
Definition: QCCalculationParametersBase.h:403
class implementing properties of QC models
Definition: QCPropertyInterface.h:11
virtual real_function_3d density() const
Definition: QCPropertyInterface.h:25
A tensor is a multidimension array.
Definition: tensor.h:317
T normf() const
Calculate the 2-norm of the vector elements.
Definition: vector.h:400
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:318
WorldGopInterface & gop
Global operations.
Definition: world.h:205
Generalized version of NonlinearSolver not limited to a single madness function.
Definition: nonlinsol.h:202
AtomicBasisSet aobasis
Definition: znemo.h:441
printleveler print_info
Definition: znemo.h:442
std::shared_ptr< Diamagnetic_potential_factor > diafac
Definition: znemo.h:447
Tensor< double > aeps
the orbital energies
Definition: znemo.h:459
Molecule & molecule() override
return the molecule of the target
Definition: znemo.h:228
std::vector< real_function_3d > rvec
the linear moments r={x,y,z}
Definition: znemo.h:465
void do_step_restriction(const std::vector< complex_function_3d > &mo, std::vector< complex_function_3d > &mo_new) const
Definition: madness/chem/znemo.cc:746
potentials compute_potentials(const std::vector< complex_function_3d > &mo, const real_function_3d &density, const std::vector< complex_function_3d > &rhs) const
compute the potential operators applied on the orbitals
Definition: madness/chem/znemo.cc:1063
void rotate_subspace(const Tensor< double_complex > &U, solverT &solver) const
rotate the KAIN subspace (cf. SCF.cc)
Definition: znemo.h:360
std::vector< complex_function_3d > compute_residuals(const std::vector< complex_function_3d > &Vpsi, const std::vector< complex_function_3d > &psi, Tensor< double > &eps, const double levelshift=0.0) const
Definition: madness/chem/znemo.cc:1124
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > read_real_guess() const
read the guess orbitals from a previous nemo or moldft calculation
Definition: madness/chem/znemo.cc:848
double compute_energy(const std::vector< complex_function_3d > &amo, const potentials &apot, const std::vector< complex_function_3d > &bmo, const potentials &bpot, const bool do_print, const bool no_confinement) const
Definition: madness/chem/znemo.cc:534
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > read_reference() const
read orbitals from a znemo calculation
Definition: madness/chem/znemo.cc:937
std::vector< complex_function_3d > amo
the molecular orbitals – alpha
Definition: znemo.h:456
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > read_restartaodata() const
read guess as projection of the orbitals onto an AO basis set (for geometry optimization)
Definition: madness/chem/znemo.cc:917
bool test_U_potentials() const
test the identity <F| f (T + Vdia ) f |F> = <F|f^2 (T + Udia) |F>
Definition: madness/chem/znemo.cc:114
Tensor< double > beps
Definition: znemo.h:459
Tensor< double > compute_linear_moment() const
compute the expectation value of the linear moment r
Definition: znemo.h:248
void test_landau_wave_function()
Definition: madness/chem/znemo.cc:718
bool need_recompute_factors_and_potentials(const double thresh) const override
Definition: madness/chem/znemo.cc:55
void output_calc_info_schema(const double &energy) const
Definition: madness/chem/znemo.cc:173
Tensor< double > compute_magnetic_potential_expectation(const std::vector< real_function_3d > &A) const
compute the expectation value of the magnetic vector potential A
Definition: znemo.h:261
std::string name() const override
Definition: znemo.h:183
static std::vector< real_function_3d > compute_magnetic_vector_potential(World &world, const coord_3d &Bvec)
compute the magnetic vector potential A
Definition: znemo.h:286
real_function_3d sbox
the spherical damping box
Definition: znemo.h:462
void iterate()
Definition: madness/chem/znemo.cc:205
std::vector< complex_function_3d > make_bra(const std::vector< complex_function_3d > &mo) const
Definition: madness/chem/znemo.cc:358
bool have_beta() const
are there explicit beta orbitals
Definition: znemo.h:301
std::vector< complex_function_3d > bmo
Definition: znemo.h:456
void test_compute_current_density() const
Definition: madness/chem/znemo.cc:700
coord_3d B
the magnetic field B=rot(A)
Definition: znemo.h:450
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > read_explicit_guess_functions() const
read a list of functions for the guess
Definition: madness/chem/znemo.cc:891
std::vector< complex_function_3d > orthonormalize(const std::vector< complex_function_3d > &mo) const
Definition: madness/chem/znemo.cc:335
double value()
compute the molecular energy
Definition: znemo.h:176
real_function_3d compute_density(const std::vector< complex_function_3d > &amo, const std::vector< complex_function_3d > &bmo) const
Definition: madness/chem/znemo.cc:348
void save_orbitals() const
Definition: znemo.h:337
Tensor< double > gradient()
Definition: znemo.h:221
std::shared_ptr< PotentialManager > potentialmanager
nuclear potential
Definition: znemo.h:453
Tensor< double > compute_kinetic_momentum() const
compute the expectation value of the kinetic momentum p
Definition: znemo.h:240
real_function_3d compute_nemo_spin_density(const std::vector< complex_function_3d > &amo, const std::vector< complex_function_3d > &bmo) const
Definition: znemo.h:417
void get_initial_orbitals()
get initial orbitals from guesses
Definition: madness/chem/znemo.cc:770
Tensor< double > compute_standard_gauge_shift(const Tensor< double > &p_exp) const
compute the shift of the molecule such that the kinetic momentum vanishes
Definition: znemo.h:269
void canonicalize(std::vector< complex_function_3d > &amo, std::vector< complex_function_3d > &vnemo, potentials &pot, XNonlinearSolver< std::vector< complex_function_3d >, double_complex, vector_function_allocator< double_complex, 3 > > &solver, Tensor< double_complex > fock, Tensor< double_complex > ovlp) const
Definition: madness/chem/znemo.cc:1171
real_function_3d compute_nemo_density(const std::vector< complex_function_3d > &amo, const std::vector< complex_function_3d > &bmo) const
Definition: znemo.h:408
std::shared_ptr< real_convolution_3d > coulop
Definition: znemo.h:467
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > read_complex_guess() const
read the guess orbitals from a previous nemo or moldft calculation
Definition: madness/chem/znemo.cc:883
void recompute_factors_and_potentials(const double thresh)
adapt the thresholds consistently to a common value
Definition: madness/chem/znemo.cc:69
Nemo::NemoCalculationParameters cparam
standard calculation parameters
Definition: znemo.h:445
real_function_3d compute_spin_density(const std::vector< complex_function_3d > &amo, const std::vector< complex_function_3d > &bmo) const
Definition: madness/chem/znemo.cc:353
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > custom_guess() const
Definition: madness/chem/znemo.cc:962
static void print_parameters()
Definition: znemo.h:198
const Molecule & molecule() const
Definition: znemo.h:229
Molecule mol
Definition: znemo.h:439
Tensor< double_complex > compute_vmat(const std::vector< complex_function_3d > &mo, const potentials &pot) const
Definition: madness/chem/znemo.cc:1104
void invalidate_factors_and_potentials() override
Definition: madness/chem/znemo.cc:63
const CalculationParameters & get_cparam() const
Definition: znemo.h:227
double analyze()
analyse the results only
Definition: madness/chem/znemo.cc:363
std::pair< MolecularOrbitals< double_complex, 3 >, MolecularOrbitals< double_complex, 3 > > hcore_guess() const
hcore guess including the magnetic field
Definition: madness/chem/znemo.cc:1001
Znemo(World &w, const commandlineparser &parser)
Definition: madness/chem/znemo.cc:19
bool selftest() override
Definition: znemo.h:208
static void help()
Definition: znemo.h:185
std::vector< complex_function_3d > normalize(const std::vector< complex_function_3d > &mo) const
Definition: madness/chem/znemo.cc:341
bool test() const
Definition: madness/chem/znemo.cc:101
Nemo_complex_Parameters param
Definition: znemo.h:440
std::vector< real_function_3d > compute_current_density(const std::vector< complex_function_3d > &alpha_mo, const std::vector< complex_function_3d > &beta_mo) const
compute the current density
Definition: madness/chem/znemo.cc:629
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition: parallel_archive.h:321
double(* energy)()
Definition: derivatives.cc:58
std::vector< Fcwf > transform(World &world, std::vector< Fcwf > &a, Tensor< std::complex< double >> U)
Definition: fcwf.cc:477
double psi(const Vector< double, 3 > &r)
Definition: hatom_energy.cc:78
static const double v
Definition: hatom_sf_dirac.cc:20
Defines functions that give information on this version of MADNESS.
double ss1
Definition: lapack.cc:62
double tt1
Definition: lapack.cc:62
static double pow(const double *a, const double *b)
Definition: lda.h:74
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
optimize the geometrical structure of a molecule
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
void print_header2(const std::string &s)
medium section heading
Definition: print.cc:54
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition: timers.h:127
FunctionFactory< double, 3 > real_factory_3d
Definition: functypedefs.h:93
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
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition: timers.cc:48
Function< double, 3 > real_function_3d
Definition: functypedefs.h:65
std::vector< Function< T, NDIM > > grad(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
shorthand gradient operator
Definition: vmra.h:1818
double inner(response_space &a, response_space &b)
Definition: response_functions.h:442
double imag(double x)
Definition: complexfun.h:56
double real(double x)
Definition: complexfun.h:52
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition: vmra.h:689
static const double a
Definition: nonlinschro.cc:118
Implementation of Krylov-subspace nonlinear equation solver.
Implements most functionality of separated operators.
static const double thresh
Definition: rk.cc:45
Definition: CalculationParameters.h:51
int nbeta() const
Definition: CalculationParameters.h:163
bool spin_restricted() const
Definition: CalculationParameters.h:174
class holding parameters for a nemo calculation beyond the standard dft parameters from moldft
Definition: nemo.h:333
following Doucot Pascier 2005
Definition: znemo.h:516
coord_3d origin
Definition: znemo.h:520
double l
radius Eq. (29)
Definition: znemo.h:519
double_complex operator()(const coord_3d &xyz1) const
following Eq. (43)
Definition: znemo.h:531
int m
Definition: znemo.h:518
landau_wave_function(const int m, const double B, const coord_3d &origin={0.0, 0.0, 0.0})
Definition: znemo.h:522
double exponent
Definition: znemo.h:490
p_orbital(const long &mm, const double &expo, const coord_3d &o)
Definition: znemo.h:492
long m
Definition: znemo.h:489
double_complex operator()(const coord_3d &xyz1) const
Definition: znemo.h:498
coord_3d origin
Definition: znemo.h:491
potentials(World &world, const std::size_t nmo)
Definition: znemo.h:110
std::vector< complex_function_3d > lz_mo
Definition: znemo.h:135
std::vector< complex_function_3d > diamagnetic_mo
Definition: znemo.h:134
std::vector< complex_function_3d > lz_commutator
Definition: znemo.h:139
void transform(const Tensor< double_complex > &U)
Definition: znemo.h:121
std::vector< complex_function_3d > zeeman_R_comm
Definition: znemo.h:140
std::vector< complex_function_3d > spin_zeeman_mo
Definition: znemo.h:138
std::vector< complex_function_3d > J_mo
Definition: znemo.h:136
std::vector< complex_function_3d > vnuc_mo
Definition: znemo.h:133
std::vector< complex_function_3d > K_mo
Definition: znemo.h:137
coord_3d origin
Definition: znemo.h:473
s_orbital(const double &expo, const coord_3d &o)
Definition: znemo.h:474
double exponent
Definition: znemo.h:472
double_complex operator()(const coord_3d &xyz1) const
Definition: znemo.h:479
void tag(const std::string msg)
Definition: znemo.h:154
bool do_print
Definition: znemo.h:146
void end(const std::string msg)
Definition: znemo.h:163
World & world
Definition: znemo.h:144
double sss
Definition: znemo.h:145
timer(World &world, bool do_print=true)
Definition: znemo.h:148
double ttt
Definition: znemo.h:145
very simple command line parser
Definition: commandlineparser.h:15
bool print_timings_
Definition: znemo.h:35
bool print_convergence_
Definition: znemo.h:36
bool print_setup() const
Definition: znemo.h:47
bool print_energies_
Definition: znemo.h:34
bool print_convergence() const
Definition: znemo.h:50
bool print_energies() const
Definition: znemo.h:48
bool print_debug() const
Definition: znemo.h:51
bool print_nothing_
Definition: znemo.h:32
printleveler(int printlevel)
Definition: znemo.h:39
bool print_debug_information_
Definition: znemo.h:37
bool print_timings() const
Definition: znemo.h:49
bool print_setup_
Definition: znemo.h:33
Definition: nonlinsol.h:169
Defines operations on vectors of Functions.