29 #include <gsl/gsl_sf_result.h>
31 #include <gsl/gsl_sf_legendre.h>
32 #include <gsl/gsl_errno.h>
40 QPMS_EWALD_LONG_RANGE = 1,
41 QPMS_EWALD_SHORT_RANGE = 2,
43 QPMS_EWALD_FULL = QPMS_EWALD_LONG_RANGE | QPMS_EWALD_SHORT_RANGE | QPMS_EWALD_0TERM,
124 double *legendre_plus1;
125 double *legendre_minus1;
126 gsl_sf_legendre_t legendre_normconv;
127 int legendre_csphase;
148 static inline complex
double lilgamma(
double t) {
151 return sqrt(t*t - 1);
153 return -I * sqrt(1 - t*t);
157 static inline complex
double clilgamma(complex
double z) {
158 complex
double a1 = z - 1, a2 = z + 1;
160 if (creal(a2) < 0 && cimag(a2) <= 0)
165 if (creal(a1) < 0 && cimag(a1) >= 0)
234 gsl_sf_result *result);
238 int ewald32_sr_integral(
double r,
double k,
double n,
double eta,
double *result,
double *err, gsl_integration_workspace *workspace);
249 int xbranch, complex
double z);
256 int xbranch, complex
double z, _Bool bigimz);
267 int xbranch, complex
double z);
276 complex
double wavenumber
281 complex
double *target_sigmasr_y,
282 double *target_sigmasr_y_err,
285 complex
double wavenumber,
288 LatticeDimensionality latdim,
304 bool pgen_generates_shifted_points,
313 complex
double *target_sigmalr_y,
314 double *target_sigmalr_y_err,
317 complex
double wavenumber,
318 double unitcell_volume,
320 LatticeDimensionality latdim,
335 bool pgen_generates_shifted_points,
qpms_ewald3_constants_t * qpms_ewald3_constants_init(qpms_l_t lMax, int csphase)
Constructor for qpms_ewald3_constants_t.
Definition: ewald.c:104
struct qpms_ewald3_constants_t qpms_ewald3_constants_t
Object holding the Ewald sum constant factors.
int ewald3_sigma_long(complex double *target_sigmalr_y, double *target_sigmalr_y_err, const qpms_ewald3_constants_t *c, double eta, complex double wavenumber, double unitcell_volume, LatticeDimensionality latdim, PGen *pgen_K, bool pgen_generates_shifted_points, cart3_t k, cart3_t particle_shift)
Long-range part of outgoing scalar spherical wavefunctions' lattice sum .
Definition: ewald.c:645
void ewald3_2_sigma_long_Delta_series(complex double *target, double *target_err, int maxn, complex double x, int xbranch, complex double z)
The Delta_n factor from [Kambe II], Appendix 3, used in 2D-in-3D long range sum.
Definition: ewaldsf.c:382
int cx_gamma_inc_series_e(double a, complex double z, qpms_csf_result *result)
Incomplete Gamma function as a series.
Definition: ewaldsf.c:50
int hyperg_2F2_series(double a, double b, double c, double d, double x, gsl_sf_result *result)
Hypergeometric 2F2, used to calculate some errors.
Definition: ewaldsf.c:233
int complex_gamma_inc_e(double a, complex double x, int m, qpms_csf_result *result)
Incomplete gamma for complex second argument.
Definition: ewaldsf.c:174
void qpms_ewald3_constants_free(qpms_ewald3_constants_t *)
Destructor for qpms_ewald3_constants_t.
Definition: ewald.c:245
struct qpms_csf_result qpms_csf_result
Structure for holding complex-valued result of computation and an error estimate.
int complex_expint_n_e(int n, complex double x, qpms_csf_result *result)
Exponential integral for complex second argument.
Definition: ewaldsf.c:214
void ewald3_2_sigma_long_Delta(complex double *target, double *target_err, int maxn, complex double x, int xbranch, complex double z)
The Delta_n factor from [Kambe II], Appendix 3, used in 2D-in-3D long range sum.
Definition: ewaldsf.c:442
void ewald3_2_sigma_long_Delta_recurrent(complex double *target, double *target_err, int maxn, complex double x, int xbranch, complex double z, _Bool bigimz)
The Delta_n factor from [Kambe II], Appendix 3, used in 2D-in-3D long range sum.
int ewald3_sigma0(complex double *result, double *err, const qpms_ewald3_constants_t *c, double eta, complex double wavenumber)
The Ewald sum "self-interaction" term that appears in the lattice sums with zero (direct-space) Brava...
Definition: ewald.c:260
gsl_error_handler_t IgnoreUnderflowsGSLErrorHandler
Use this handler to ignore underflows of incomplete gamma.
Definition: ewald.h:48
int ewald3_sigma_short(complex double *target_sigmasr_y, double *target_sigmasr_y_err, const qpms_ewald3_constants_t *c, double eta, complex double wavenumber, LatticeDimensionality latdim, PGen *pgen_R, bool pgen_generates_shifted_points, cart3_t k, cart3_t particle_shift)
Short-range part of outgoing scalar spherical wavefunctions' lattice sum .
Definition: ewald.c:764
int cx_gamma_inc_CF_e(double a, complex double z, qpms_csf_result *result)
Incomplete Gamma function as continued fractions.
Definition: ewaldsf.c:154
Lattice point generators and lattice vector analysis / transformation.
size_t qpms_y_t
Type for the (l, m) multiindex of transversal (M or N -type) VSWFs.
Definition: qpms_types.h:44
int qpms_l_t
Type for spherical harmonic degree l.
Definition: qpms_types.h:27
Generic lattice point generator type.
Definition: lattices.h:120
3D cartesian coordinates. See also vectors.h.
Definition: qpms_types.h:186
Structure for holding complex-valued result of computation and an error estimate.
Definition: ewald.h:141
double err
Error estimate.
Definition: ewald.h:143
complex double val
Calculation result.
Definition: ewald.h:142
Object holding the Ewald sum constant factors.
Definition: ewald.h:56
complex double ** S1_constfacs
The constant factors for the long range part of a 1D Ewald sum along the z axis.
Definition: ewald.h:89
complex double * s1_constfacs_1Dz_base
Internal pointer holding memory for the 1D Ewald sum constant factors.
Definition: ewald.h:119
qpms_l_t * s1_jMaxes
The values of maximum j's in the long-range part summation, [(l-|m|/2)].
Definition: ewald.h:60
complex double * S1_constfacs_base
Definition: ewald.h:103
complex double ** s1_constfacs
The constant factors for the long range part of a 2D Ewald sum.
Definition: ewald.h:62
complex double ** s1_constfacs_1Dz
The constant factors for the long range part of a 1D Ewald sum along the z axis.
Definition: ewald.h:111
complex double * s1_constfacs_base
Internal pointer holding memory for the 2D Ewald sum constant factors.
Definition: ewald.h:76