Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor #33

Merged
merged 7 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions include/damping/dftd_atm.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace dftd4 {
extern int get_atm_dispersion(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
const double s9,
const double a1,
const double a2,
const double alp,
double cutoff,
double s9,
double a1,
double a2,
double alp,
const TMatrix<double> &c6,
const TMatrix<double> &dc6dcn,
const TMatrix<double> &dc6dq,
Expand All @@ -48,23 +48,23 @@ extern int get_atm_dispersion(
extern int get_atm_dispersion_energy(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
const double s9,
const double a1,
const double a2,
const double alp,
double cutoff,
double s9,
double a1,
double a2,
double alp,
const TMatrix<double> &c6,
TVector<double> &energy
);

extern int get_atm_dispersion_derivs(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
const double s9,
const double a1,
const double a2,
const double alp,
double cutoff,
double s9,
double a1,
double a2,
double alp,
const TMatrix<double> &c6,
const TMatrix<double> &dc6dcn,
const TMatrix<double> &dc6dq,
Expand Down
12 changes: 6 additions & 6 deletions include/damping/dftd_rational.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

namespace dftd4 {

extern inline double fdmpr_bj(const int n, const double r, const double c);
extern inline double fdmprdr_bj(const int n, const double r, const double c);
extern inline double fdmpr_bj(int n, double r, double c);
extern inline double fdmprdr_bj(int n, double r, double c);

// Generic wrappers for two- and three-body dispersion

extern int get_dispersion2(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
const dparam &par,
const TMatrix<double> &c6,
const TMatrix<double> &dc6dcn,
Expand All @@ -47,7 +47,7 @@ extern int get_dispersion2(
extern int get_dispersion3(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
const dparam &par,
const TMatrix<double> &c6,
const TMatrix<double> &dc6dcn,
Expand All @@ -64,7 +64,7 @@ extern int get_dispersion3(
extern int get_dispersion2_energy(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
const dparam &par,
const TMatrix<double> &c6,
TVector<double> &energy
Expand All @@ -73,7 +73,7 @@ extern int get_dispersion2_energy(
extern int get_dispersion2_derivs(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
const dparam &par,
const TMatrix<double> &c6,
const TMatrix<double> &dc6dcn,
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_damping.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ namespace dftd4 {
* @returns Exit status.
*/
extern int
d4par(const std::string func, dftd4::dparam &par, const bool latm = true);
d4par(const std::string func, dftd4::dparam &par, bool latm = true);

} // namespace dftd4
4 changes: 2 additions & 2 deletions include/dftd_dispersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class dparam {
*/
extern int get_dispersion(
const TMolecule &mol,
const int charge,
int charge,
const TD4Model &d4,
const dparam &par,
const TCutoff cutoff,
TCutoff cutoff,
double &energy,
double *GRAD
);
Expand Down
4 changes: 2 additions & 2 deletions include/dftd_eeq.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace dftd4 {
extern int get_charges(
const TMolecule &mol,
const TMatrix<double> &dist,
const int charge,
const double cutoff,
int charge,
double cutoff,
TVector<double> &q,
TMatrix<double> &dqdr,
bool lgrad
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TMolecule {
at.New(NAtoms);
}

void FreeMemory(void) {
void FreeMemory() {
xyz.Delete();
at.Delete();
}
Expand Down
40 changes: 20 additions & 20 deletions include/dftd_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ template <class T> class TVector {

TVector() {
N = 0;
p = 0;
p = nullptr;
ElementSize = sizeof(T);
}
~TVector() {
if (p != 0) Delete();
if (p != nullptr) Delete();
}
void NewVector(int VectorLength) {
if (VectorLength < 0) { std::exit(EXIT_FAILURE); }
if (p != 0 && N == VectorLength) {
if (p != nullptr && N == VectorLength) {
Init();
} else {
Delete();
Expand All @@ -58,9 +58,9 @@ template <class T> class TVector {
void New(int VectorLength) { return NewVector(VectorLength); }
void NewVec(int VectorLength) { return NewVector(VectorLength); }

void Delete(void) {
if (p != 0 && N != 0) { delete[] p; }
p = 0;
void Delete() {
if (p != nullptr && N != 0) { delete[] p; }
p = nullptr;
N = 0;
}
void CopyVec(const TVector &v) {
Expand All @@ -73,8 +73,8 @@ template <class T> class TVector {
mem = (long int)N * ElementSize;
std::memcpy(p, v.p, mem);
}
void Init(void) {
if (p != 0) {
void Init() {
if (p != nullptr) {
long int mem = (long int)N * ElementSize;
std::memset(p, 0, mem);
}
Expand Down Expand Up @@ -104,20 +104,20 @@ template <class T> class TMatrix {
TMatrix() {
cols = 0;
rows = 0;
p = 0;
p = nullptr;
ElementSize = sizeof(T);
}
~TMatrix() {
if (p != 0) Delete();
if (p != nullptr) Delete();
}

void NewMatrix(int r, int c) {
if (r < 0 || c < 0) std::exit(EXIT_FAILURE);
if (p != 0 && r == rows && c == cols) {
if (p != nullptr && r == rows && c == cols) {
Init();
} else {
long int mem = (long int)r * (long int)c;
if (p != 0) Delete(); // Eventually delete old matrix
if (p != nullptr) Delete(); // Eventually delete old matrix

if (mem == 0) return; // don't touch pointer if no memory is allocated

Expand All @@ -136,26 +136,26 @@ template <class T> class TMatrix {
void New(int r, int c) { return NewMatrix(r, c); }
void NewMat(int r, int c) { return NewMatrix(r, c); }

void Delete(void) {
if (p != 0 && rows * cols != 0) { delete[] p; }
void Delete() {
if (p != nullptr && rows * cols != 0) { delete[] p; }
rows = 0;
cols = 0;
p = 0;
p = nullptr;
}

void Init(void) {
void Init() {
long int mem;
if (p != 0) {
if (p != nullptr) {
mem = (long int)cols * (long int)rows * ElementSize;
std::memset(p, 0, mem);
}
}

void Transpose(void) {
void Transpose() {
T x;
int i, j;

if (p != 0) {
if (p != nullptr) {
if (rows == cols) {
for (i = 0; i < rows; i++) {
for (j = 0; j < i; j++) {
Expand Down Expand Up @@ -191,7 +191,7 @@ template <class T> class TMatrix {
std::memcpy(p, m.p, mem);
}

void Print(char name[] = "unknown") {
void Print(const char name[] = "unknown") {
printf("Matrix printed: %s (%d, %d)\n", name, rows, cols);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
Expand Down
6 changes: 3 additions & 3 deletions include/dftd_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ class TD4Model {
extern inline double trapzd(const double a[23], const double b[23]);

extern inline double
weight_cn(const double wf, const double cn, const double cnref);
weight_cn(double wf, double cn, double cnref);

extern inline double
zeta(const double a, const double c, const double qref, const double qmod);
zeta(double a, double c, double qref, double qmod);
extern inline double
dzeta(const double a, const double c, const double qref, const double qmod);
dzeta(double a, double c, double qref, double qmod);

extern int get_max_ref(const TMolecule &mol, int &mref);

Expand Down
18 changes: 9 additions & 9 deletions include/dftd_ncoord.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern int calc_distances(const TMolecule &mol, TMatrix<double> &dist);
extern int get_ncoord_erf(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
Expand All @@ -69,7 +69,7 @@ extern int get_ncoord_erf(
extern int ncoord_erf(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn
);

Expand All @@ -87,7 +87,7 @@ extern int ncoord_erf(
extern int dncoord_erf(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr
);
Expand All @@ -104,7 +104,7 @@ extern int dncoord_erf(
extern int get_ncoord_d4(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad = false
Expand All @@ -122,7 +122,7 @@ extern int get_ncoord_d4(
extern int ncoord_d4(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn
);

Expand All @@ -140,7 +140,7 @@ extern int ncoord_d4(
extern int dncoord_d4(
const TMolecule &mol,
const TMatrix<double> &dist,
const double cutoff,
double cutoff,
TVector<double> &cn,
TMatrix<double> &dcndr
);
Expand Down Expand Up @@ -173,14 +173,14 @@ extern double derf_count(double k, double rr);
* @param lgrad Flag for gradient.
*/
extern int cut_coordination_number(
const double cn_max,
double cn_max,
TVector<double> &cn,
TMatrix<double> &dcndr,
bool lgrad
);

extern inline double log_cn_cut(const double cn_max, const double cn);
extern inline double log_cn_cut(double cn_max, double cn);

extern inline double dlog_cn_cut(const double cn_max, const double cn);
extern inline double dlog_cn_cut(double cn_max, double cn);

}; // namespace dftd4
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ project(
license: 'LGPL3-or-later',
meson_version: '>=0.51',
default_options: [
'cpp_std=c++11',
'default_library=both',
],
)
Expand Down
Loading
Loading