Skip to content

Commit 136a9d1

Browse files
authored
Merge branch 'master' into qchem
2 parents 2e5fc33 + 79d6cd8 commit 136a9d1

13 files changed

Lines changed: 68234 additions & 43704 deletions

File tree

EFP2.C

Lines changed: 2320 additions & 0 deletions
Large diffs are not rendered by default.

EFP2.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#ifndef EFP2_H_INCLUDED
2+
#define EFP2_H_INCLUDED
3+
4+
#include <vector>
5+
6+
class EFP2_impl;
7+
class InputSection;
8+
9+
class EFP2 {
10+
public:
11+
/* Initialize EFP2 instance using user's input. */
12+
void init(InputSection &);
13+
14+
/* Returns true if the current EFP2 instance was initialized. */
15+
bool initialized();
16+
17+
/* Returns if_multipole_field value. */
18+
bool get_if_multipole_field();
19+
20+
/* Returns updated if_multipole_field value. */
21+
void update_multipole_field();
22+
23+
/* Returns if_pol_field value. */
24+
bool get_if_pol_field();
25+
26+
/* Returns updated if_pol_field value. */
27+
void update_pol_field();
28+
29+
/* Reorient EFP fragments according to Q-Chem's orientation of
30+
* ab initio subsystem. */
31+
void reorient_geometry();
32+
33+
/* Print geometry of EFP subsystem. */
34+
void print_geometry();
35+
36+
/* Setup all necessary stuff for AI/EFP dispersion computation
37+
* if enabled */
38+
void setup_aiefp_dispersion();
39+
40+
/* Compute all EFP and the rest of QM/EFP interactions after
41+
* the QM SCF has converged.
42+
* \p do_grad - specifies whether to compute the gradient.
43+
* If \p do_grad is not zero than the gradient will also be
44+
* computed. */
45+
void compute(int do_grad);
46+
47+
/* Update quantum mechanical Hamiltonian with the contributions
48+
* from EFP multipoles and atoms using AOints.
49+
* \p h - a Hamiltonian matrix.
50+
* \p code - Q-Chem's ShlPrs code. */
51+
void update_mult_ints(double *h, INTEGER code);
52+
53+
/* Update quantum mechanical Hamiltonian with the contributions
54+
* from EFP induced diples using AOints.
55+
* \p h - a Hamiltonian matrix.
56+
* \p code - Q-Chem's ShlPrs code. */
57+
void update_pol_ints(double *h, INTEGER code);
58+
59+
/* Update quantum mechanical Hamiltonian with the contributions
60+
* from EFPs using AOints.
61+
* \p h - a Hamiltonian matrix.
62+
* \p code - Q-Chem's ShlPrs code. */
63+
// void update_wf(double *h, INTEGER code);
64+
65+
/* Update quantum mechanical Hamiltonian with the contributions
66+
* from EFPs using libqints.
67+
* \p h - a Hamiltonian matrix.
68+
* \p code - Q-Chem's ShlPrs code. */
69+
void update_wf_qints(double *h, INTEGER code);
70+
71+
/* Update the positions of quantum nuclei for libefp. */
72+
void update_qm_atoms();
73+
74+
/* Returns the wavefunction dependent energy.
75+
* \p w - is a density matrix.
76+
* \p n - is a total number of elements in array \p w. */
77+
double get_wf_dependent_energy(double *w, double n);
78+
79+
/* Returns the total EFP energy. */
80+
double get_total_energy();
81+
82+
/* Returns EFP correction to the energy of the excited state.
83+
* \p w - is the density matrix of the excited state WF.
84+
* \p n - is the total number of elements in array \p w.
85+
* \p Ecis - excitation energy */
86+
double get_excited_state_energy_correction(double *w, size_t n, double Ecis);
87+
88+
/* Returns gradient on quantum nuclei from EFP electrostatics.
89+
* Upon return the \p a vector will contain 3*N elements of
90+
* gradient, where N is the number of QM atoms. */
91+
void get_qm_gradient(std::vector<double> &a);
92+
93+
/* Returns current EFP gradient.
94+
* The vector \p a will contain 6*N gradient values for
95+
* fragment translation and rotation. N is the total number of
96+
* EFP fragments. */
97+
void get_gradient(std::vector<double> &a);
98+
99+
/* computes pairwise energies between QM region and EFP fragments.
100+
* \p Escf - reference AI energy (HF or excitation energy)
101+
* \p if_excited = 1/0 a switch to distinguish between the ground state (0) or excited state (1). */
102+
void get_pairwise_energy(double Estate, int if_excited);
103+
104+
/* Print EFP energy terms to stdout. */
105+
void print_energy();
106+
107+
/* Print pairwise energy decomposition to stdout.
108+
* \p if_excited = 1/0 a switch to distinguish between the ground state (0) or excited state (1). */
109+
void print_pairwise_energy(int if_excited);
110+
111+
/* Returns a EFP2 singleton instance. */
112+
static EFP2& instance() {
113+
static EFP2 instance;
114+
return instance;
115+
}
116+
117+
private:
118+
EFP2();
119+
EFP2(const EFP2 &);
120+
~EFP2();
121+
122+
EFP2_impl *impl_;
123+
};
124+
125+
#endif /* EFP2_H_INCLUDED */

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ molecular systems by replacing chemically inert part of a system by a set of
77
Effective Fragments while performing regular _ab initio_ calculation on the
88
chemically active part [1-8]. The LIBEFP library is a full implementation of
99
the EFP method. It allows users to easily incorporate EFP support into their
10-
favourite quantum chemistry package. LIBEFP is used by many major quantum
11-
chemistry packages, such as [Q-Chem](http://www.q-chem.com),
12-
[PSI4](http://www.psicode.org), [NWChem](http://www.nwchem-sw.org),
13-
[GAMESS](http://www.msg.ameslab.gov/GAMESS),
14-
[Molcas](https://gitlab.com/Molcas), and others.
10+
favourite quantum chemistry package.
11+
LIBEFP is interfaced to [Q-Chem](http://www.q-chem.com) and
12+
[PSI4](http://www.psicode.org) for QM/EFP calculations.
1513

1614
Detailed description of methods and algorithms can be found in two LIBEFP
1715
papers:
@@ -69,7 +67,7 @@ For CMake instructions, see [README-cmake.md](README-cmake.md).
6967
## Documentation
7068

7169
The description of public LIBEFP API is available
72-
[here](https://ilyak.github.io/libefp/doxygen_html/efp_8h.html).
70+
[here](https://libefp2.github.io/doxygen_html/index.html).
7371
Also see [this](interface/readme.txt) file for step-by-step instructions.
7472
Fortran bindings to LIBEFP are available in
7573
[interface/efp.f90](interface/efp.f90).

fraglib/h2o_reduced.efp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
RUNTYP=MAKEFP EFFECTIVE FRAGMENT POTENTIAL DATA FOLLOWS...
2+
FRAGNAMEEFP GENERATED AT Tue Mar 27 16:14:27 2012
3+
$H2O_REDUCED_L
4+
EFP DATA FOR FRAGNAME SCFTYP=RHF ... GENERATED WITH BASIS SET=6-311++G(3df,2p)
5+
COORDINATES (BOHR)
6+
A01O1 0.0000000000 0.1191094785 0.0000000000 15.9949100 8.0
7+
A02H2 -1.4223059670 -0.9451766865 0.0000000000 1.0078250 1.0
8+
A03H3 1.4223059670 -0.9451766865 0.0000000000 1.0078250 1.0
9+
BO21 -0.7111529835 -0.4130336040 0.0000000000 0.0000000 0.0
10+
BO31 0.7111529835 -0.4130336040 0.0000000000 0.0000000 0.0
11+
STOP
12+
MONOPOLES
13+
A01O1 -8.4173680991 8.00000
14+
A02H2 -0.3512187169 1.00000
15+
A03H3 -0.3512187169 1.00000
16+
BO21 -0.4400972335 0.00000
17+
BO31 -0.4400972335 0.00000
18+
STOP
19+
DIPOLES
20+
A01O1 0.0000000000 -0.4127062480 0.0000000000
21+
A02H2 -0.0027268078 -0.0014022974 0.0000000000
22+
A03H3 0.0027268078 -0.0014022974 0.0000000000
23+
BO21 0.2657818726 0.2358863756 0.0000000000
24+
BO31 -0.2657818726 0.2358863756 0.0000000000
25+
STOP
26+
POLARIZABLE POINTS
27+
CT1 -0.7491370634 -0.4890369778 0.0000000020
28+
2.6629294234 1.7670590537 0.7812922107 1.2832534969 >
29+
-0.0000000037 -0.0000000033 1.1482095947 -0.0000000144 >
30+
-0.0000000132
31+
CT2 0.7491370628 -0.4890369781 0.0000000040
32+
2.6629294254 1.7670590567 0.7812922113 -1.2832535009 >
33+
0.0000000076 -0.0000000067 -1.1482095971 0.0000000195 >
34+
-0.0000000177
35+
CT3 0.0000000011 0.3892153728 -0.4957986131
36+
1.4502428775 1.8574126776 2.7113709049 0.0000000046 >
37+
-0.0000000029 -0.9972382204 0.0000000048 -0.0000000034 >
38+
-1.0913249895
39+
CT4 -0.0000000005 0.3892153799 0.4957986071
40+
1.4502428978 1.8574127185 2.7113708742 -0.0000000023 >
41+
-0.0000000009 0.9972382303 -0.0000000024 -0.0000000017 >
42+
1.0913250020
43+
STOP
44+
$END

src/efp.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,36 @@ efp_get_frag_multipole_count(struct efp *efp, size_t frag_idx, size_t *n_mult)
14151415
return EFP_RESULT_SUCCESS;
14161416
}
14171417

1418+
/*
1419+
EFP_EXPORT enum efp_result
1420+
efp_get_frag_rank(struct efp *efp, size_t frag_idx, size_t *rank)
1421+
{
1422+
assert(efp);
1423+
assert(rank);
1424+
assert(frag_idx < efp->n_frag);
1425+
1426+
struct frag *frag = efp->frags + frag_idx;
1427+
1428+
*rank = 0;
1429+
for (size_t i=0; i<frag->n_multipole_pts; i++) {
1430+
struct multipole_pt *pt = frag->multipole_pts + i;
1431+
size_t rank_tmp = 0;
1432+
if (pt->if_dip)
1433+
rank_tmp = 1;
1434+
if (pt->if_quad)
1435+
rank_tmp = 2;
1436+
if (pt->if_oct)
1437+
rank_tmp = 3;
1438+
if (rank_tmp > *rank)
1439+
*rank = rank_tmp;
1440+
if (*rank == 3)
1441+
break;
1442+
}
1443+
1444+
return EFP_RESULT_SUCCESS;
1445+
}
1446+
*/
1447+
14181448
EFP_EXPORT enum efp_result
14191449
efp_get_frag_rank(struct efp *efp, size_t frag_idx, size_t *rank)
14201450
{
@@ -1634,7 +1664,6 @@ efp_get_induced_dipole_conj_values(struct efp *efp, double *dip)
16341664

16351665
for (size_t i = 0; i < efp->n_frag; i++) {
16361666
struct frag *frag = efp->frags + i;
1637-
16381667
for (size_t j = 0; j < frag->n_polarizable_pts; j++) {
16391668
struct polarizable_pt *pt = frag->polarizable_pts + j;
16401669

@@ -2465,7 +2494,6 @@ print_frag_info(struct efp *efp, size_t frag_index) {
24652494
}
24662495

24672496
print_ligand(efp, frag_index);
2468-
24692497
printf("\n");
24702498
}
24712499

src/efp.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,16 @@ enum efp_result efp_get_frag_multipole_count(struct efp *efp, size_t frag_idx,
840840
enum efp_result efp_get_frag_multipole_coord(struct efp *efp, size_t frag_idx,
841841
size_t *n_mult);
842842

843+
/**
844+
* Computes multipole rank of a fragment
845+
* @param efp
846+
* @param[in] frag_idx fragment index
847+
* @param[out] rank Highest rank of multipoles in the fragment
848+
* (0 - charge, 1 - dipole, 2 - quad, 3 - oct)
849+
* @return ::EFP_RESULT_SUCCESS on success or error code otherwise.
850+
*/
851+
// enum efp_result efp_get_frag_mult_rank(struct efp *efp, size_t frag_idx, size_t mult_idx, size_t *rank);
852+
843853
/**
844854
* Computes multipole rank of a fragment
845855
* @param efp
@@ -1481,7 +1491,6 @@ void print_ene(struct efp_energy *energy);
14811491
*/
14821492
void print_energies(struct efp *efp);
14831493

1484-
14851494
#ifdef __cplusplus
14861495
} /* extern "C" */
14871496
#endif

0 commit comments

Comments
 (0)