ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
sccs_sa.h
Go to the documentation of this file.
1#ifndef SCCS_SA_H
2#define SCCS_SA_H
3
5
6#include <vector>
7
8namespace ModuleBase
9{
10class Matrix3;
11}
12namespace ModulePW
13{
14class PW_Basis;
15}
16
17namespace ModuleSccs
18{
20
21// Probe erfc((|r| - R)/radial_spread), R = solvent_radius * radial_scale, cut
22// at R + 5 radial_spread, unit grid integral, on the local G vectors (Environ
23// solvent_probe, but summing all periodic images within the cutoff, so narrow
24// cells are not truncated). lattice in lattice_scale Bohr; collective.
25std::vector<double> sa_probe_kernel(
26 const ModulePW::PW_Basis &basis,
27 const ModuleBase::Matrix3 &lattice,
28 double lattice_scale,
29 const SolventAwareParameters &parameters);
30
31// Periodic convolution with the probe.
32std::vector<double> convolve_probe(
33 const std::vector<double> &kernel, const ModulePW::PW_Basis &basis, const std::vector<double> &values);
34
35// Component-wise convolution; of grad s it is grad c = p * grad s.
36std::vector<ModuleBase::Vector3<double>> convolve_grad(
37 const std::vector<double> &kernel, const ModulePW::PW_Basis &basis,
38 const std::vector<ModuleBase::Vector3<double>> &gradient);
39
40// Filled boundary s_sa = s + (1 - s) f(c) of the probe solute fraction c = p * s,
41// f(c) = 1 - erfc((c - filling_thr)/filling_spread)/2, with f' and f''
42// (Environ solvent_aware_boundary).
44{
45 std::vector<double> fraction;
46 std::vector<double> filling;
47 std::vector<double> dfilling;
48 std::vector<double> d2filling;
49 std::vector<double> boundary;
50};
51
53 const std::vector<double> &local,
54 const std::vector<double> &kernel,
55 const SolventAwareParameters &parameters,
56 const ModulePW::PW_Basis &basis);
57
58// Solvent-aware state of an SCCS cavity, empty without the filling: the
59// local boundary s, its filling, the filled volume int(s_sa - s) in Bohr^3
60// and the chain data of the filled surface, s'' = d2s/dn2, grad n and the
61// gradient of the probe solute fraction, grad c = p * (s' grad n).
62// filling.boundary is empty: s_sa itself is SccsResponse::solute.
63// active is set on every pool rank; the grid arrays are empty on a rank
64// without real-space grid points.
66{
67 bool enabled() const { return active; }
68
69 bool active = false;
70 std::vector<double> local;
72 double volume = 0.0;
73 std::vector<double> d2solute_drho2;
74 std::vector<ModuleBase::Vector3<double>> density_gradient;
75 std::vector<ModuleBase::Vector3<double>> fraction_gradient;
76};
77
78// Environ solvent_aware_boundary, deriv_method 'chain': turn grad s and
79// lapl s of the local boundary into those of s_sa, given the derivatives of
80// the probe solute fraction, fraction_gradient = grad c = p * grad s and
81// fraction_laplacian = lapl c = p * lapl s.
83 const std::vector<double> &local,
84 const SolventAwareBoundary &filled,
85 const std::vector<ModuleBase::Vector3<double>> &fraction_gradient,
86 const std::vector<double> &fraction_laplacian,
87 std::vector<ModuleBase::Vector3<double>> &gradient,
88 std::vector<double> &laplacian);
89
90// Filled surface and volume, a = s' grad n, b = p * a, g = (1 - f) a + (1 - s) f' b:
91// S = sum_i (|g_i|_r - r), |g|_r = sqrt(|g|^2 + r^2); V = sum_i s_sa,i.
92// With u = g/|g|_r, A = (1 - f) u + p * ((1 - s) f' u), alpha = -f' u.a +
93// (1 - s) f'' u.b and beta = -f' u.b, the exact derivatives are
94// dS/dn = s' (beta + p * alpha) + s'' A.grad n - div(s' A),
95// dV/dn = s' ((1 - f) + p * ((1 - s) f')),
96// bounded where g vanishes (|u| <= 1), unlike Environ's continuum curvature.
97// density_potential = surface_tension dS/dn + pressure dV/dn; collective.
99{
100 std::vector<ModuleBase::Vector3<double>> gradient;
101 std::vector<double> density_potential;
102};
103
105 const FilledCavity &cavity,
106 const std::vector<double> &dsolute_drho,
107 const std::vector<double> &kernel,
108 const ModulePW::PW_Basis &basis,
109 double tpiba,
110 double regularization,
111 double surface_tension,
112 double pressure);
113
114// Environ calc_solvent_aware_de_dboundary, from dE/ds_sa to dE/ds:
115// (1 - f) dE/ds_sa + p * ((1 - s) f' dE/ds_sa). The probe is even, so the
116// convolution is its own transpose and this is the exact adjoint.
117std::vector<double> sa_adjoint(
118 const FilledCavity &cavity,
119 const std::vector<double> &kernel,
120 const ModulePW::PW_Basis &basis,
121 const std::vector<double> &boundary_potential);
122} // namespace ModuleSccs
123
124#endif
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
3 elements vector
Definition vector3.h:21
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Definition clebsch_gordan_coeff.cpp:8
Definition pw_op.cpp:3
Definition sccs_fixed_src.h:11
void sa_chain_derivs(const std::vector< double > &local, const SolventAwareBoundary &filled, const std::vector< ModuleBase::Vector3< double > > &fraction_gradient, const std::vector< double > &fraction_laplacian, std::vector< ModuleBase::Vector3< double > > &gradient, std::vector< double > &laplacian)
Definition sccs_sa.cpp:208
SolventAwareBoundary sa_boundary(const std::vector< double > &local, const std::vector< double > &kernel, const SolventAwareParameters &parameters, const ModulePW::PW_Basis &basis)
Definition sccs_sa.cpp:172
std::vector< double > sa_probe_kernel(const ModulePW::PW_Basis &basis, const ModuleBase::Matrix3 &lattice, double lattice_scale, const SolventAwareParameters &parameters)
Definition sccs_sa.cpp:46
std::vector< double > convolve_probe(const std::vector< double > &kernel, const ModulePW::PW_Basis &basis, const std::vector< double > &values)
Definition sccs_sa.cpp:127
SolventAwareNonelectrostatic sa_nonelec(const FilledCavity &cavity, const std::vector< double > &dsolute_drho, const std::vector< double > &kernel, const ModulePW::PW_Basis &basis, double tpiba, double regularization, double surface_tension, double pressure)
Definition sccs_sa.cpp:231
std::vector< ModuleBase::Vector3< double > > convolve_grad(const std::vector< double > &kernel, const ModulePW::PW_Basis &basis, const std::vector< ModuleBase::Vector3< double > > &gradient)
Definition sccs_sa.cpp:144
std::vector< double > sa_adjoint(const FilledCavity &cavity, const std::vector< double > &kernel, const ModulePW::PW_Basis &basis, const std::vector< double > &boundary_potential)
Definition sccs_sa.cpp:329
Definition sccs_sa.h:66
std::vector< double > local
Definition sccs_sa.h:70
double volume
Definition sccs_sa.h:72
bool active
Definition sccs_sa.h:69
bool enabled() const
Definition sccs_sa.h:67
std::vector< double > d2solute_drho2
Definition sccs_sa.h:73
SolventAwareBoundary filling
Definition sccs_sa.h:71
std::vector< ModuleBase::Vector3< double > > density_gradient
Definition sccs_sa.h:74
std::vector< ModuleBase::Vector3< double > > fraction_gradient
Definition sccs_sa.h:75
Definition sccs_sa.h:44
std::vector< double > d2filling
Definition sccs_sa.h:48
std::vector< double > filling
Definition sccs_sa.h:46
std::vector< double > fraction
Definition sccs_sa.h:45
std::vector< double > boundary
Definition sccs_sa.h:49
std::vector< double > dfilling
Definition sccs_sa.h:47
std::vector< ModuleBase::Vector3< double > > gradient
Definition sccs_sa.h:100
std::vector< double > density_potential
Definition sccs_sa.h:101
Definition sccs_cavity.h:10