Skip to content

Commit

Permalink
Testsuite (#7)
Browse files Browse the repository at this point in the history
- add simple testsuite for CN and full dispersion energy
- refactoring (fully separate out gradient calculation, mark constant arguments passed by reference)
- update license/copyright header
  • Loading branch information
marvinfriede authored Dec 11, 2022
1 parent 0921efe commit 9331390
Show file tree
Hide file tree
Showing 27 changed files with 938 additions and 246 deletions.
2 changes: 1 addition & 1 deletion include/dftd_cblas.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_damping.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
50 changes: 31 additions & 19 deletions include/dftd_dispersion.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -37,28 +37,40 @@ class dparam {
int alp;
};

extern int d4dim(TMolecule& mol);
extern
int d4dim(const TMolecule& mol);

extern int d4(TMolecule& mol, int ndim, double wf, double g_a, double g_c,
TVector<double>& cn, TVector<double>& gw, TMatrix<double>& c6ref);
extern
int d4(const TMolecule& mol, int ndim, double wf, double g_a, double g_c,
const TVector<double>& cn, TVector<double>& gw, TMatrix<double>& c6ref);

extern int edisp(TMolecule& mol, TMatrix<double>& dist, int ndim,
TVector<double>& q, dparam& par, double g_a, double g_c,
TVector<double>& gw, TMatrix<double>& c6ref, bool lmbd,
double& energy);
extern
int edisp(const TMolecule& mol, const TMatrix<double>& dist, const dparam& par,
int ndim, TVector<double>& q,double g_a, double g_c,
TVector<double>& gw, TMatrix<double>& c6ref, bool lmbd,
double& energy);

extern int dispgrad(TMolecule& mol, TMatrix<double>& dist, int ndim,
TVector<double>& q, TMatrix<double>& dqdr,
TVector<double>& cn, TMatrix<double>& dcndr, dparam& par,
double wf, double g_a, double g_c, TMatrix<double>& c6ref,
bool lmbd, double& energy, TMatrix<double>& gradient);
extern
int dispgrad(const TMolecule& mol, const TMatrix<double>& dist,
const dparam& par, int ndim, const TVector<double>& q,
TMatrix<double>& dqdr, TVector<double>& cn,
TMatrix<double>& dcndr, double wf, double g_a, double g_c,
TMatrix<double>& c6ref, bool lmbd, double& energy,
TMatrix<double>& gradient);

extern int apprabc(TMolecule& mol, TMatrix<double>& dist, int ndim,
dparam& par, TVector<double>& c6ab, double& energy);
extern
int apprabc(const TMolecule& mol, const TMatrix<double>& dist,
const dparam& par, int ndim, TVector<double>& c6ab,
double& energy);

extern int dabcappr(TMolecule& mol, TMatrix<double>& dist, int ndim,
dparam& par, TVector<double>& gw, TVector<double>& dgw,
TMatrix<double>& c6ref, TVector<double>& dc6dr,
TVector<double>& dc6dcn, double& energy);
extern
int dabcappr(const TMolecule& mol, const TMatrix<double>& dist,
const dparam& par, int ndim, TVector<double>& gw,
TVector<double>& dgw, TMatrix<double>& c6ref,
TVector<double>& dc6dr, TVector<double>& dc6dcn, double& energy);

extern
int DFTVDW_D4(const TMolecule &mol, const dparam &par, const int &charge,
double &energy, double *GRAD);

} // namespace dftd
2 changes: 1 addition & 1 deletion include/dftd_econv.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
14 changes: 8 additions & 6 deletions include/dftd_eeq.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand All @@ -27,10 +27,12 @@

namespace dftd {

extern int eeq_chrgeq(TMolecule& mol, int& charge, TMatrix<double>& dist,
TVector<double>& cn, TMatrix<double>& dcndr,
TVector<double>& q, TMatrix<double>& dqdr, double& energy,
TMatrix<double>& gradient, bool lverbose = false,
bool lgrad = false, bool lcpq = false);
extern
int eeq_chrgeq(const TMolecule& mol, const TMatrix<double>& dist,
const int& charge, const TVector<double>& cn,
TVector<double>& q, double& energy,
TMatrix<double>& dcndr, TMatrix<double>& dqdr,
TMatrix<double>& gradient, bool lgrad = false,
bool lverbose = false, bool lcpq = false);

}
2 changes: 1 addition & 1 deletion include/dftd_geometry.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_matrix.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
85 changes: 71 additions & 14 deletions include/dftd_ncoord.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -35,31 +35,44 @@ namespace dftd {
* @param dist Distance matrix (inout).
* @return Exit status.
*/
extern int calc_distances(TMolecule& mol, TMatrix<double>& dist);
extern int calc_distances(const TMolecule& mol, TMatrix<double>& dist);

/**
* Calculate error function coordination number.
* Wrapper for error function coordination number.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param dcndr Derivative of coordination number.
* @param lgrad Flag for gradient computation.
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int ncoord_erf(TMolecule& mol, TMatrix<double>& dist,
TVector<double>& cn, double thr = 1600.0);
extern int get_ncoord_erf(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
TMatrix<double>& dcndr,
bool lgrad = false,
double thr = 1600.0
);

/**
* Calculate covalent coordination number for DFT-D4.
* Calculate error function coordination number.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param dcndr Derivative of coordination number.
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int ncoord_d4(TMolecule& mol, TMatrix<double>& dist,
TVector<double>& cn, double thr = 1600.0);
extern int ncoord_erf(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
double thr = 1600.0
);

/**
* Calculate error function coordination number and derivative
Expand All @@ -72,9 +85,49 @@ extern int ncoord_d4(TMolecule& mol, TMatrix<double>& dist,
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int dncoord_erf(TMolecule& mol, TMatrix<double>& dist,
TVector<double>& cn, TMatrix<double>& dcndr,
double thr = 1600.0);
extern int dncoord_erf(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
TMatrix<double>& dcndr,
double thr = 1600.0
);


/**
* Wrapper for error function coordination number for DFT-D4.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int get_ncoord_d4(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
TMatrix<double>& dcndr,
bool lgrad = false,
double thr = 1600.0
);

/**
* Calculate covalent coordination number for DFT-D4.
*
* @param mol Molecule object.
* @param dist Distance matrix.
* @param cn Vector of coordination numbers.
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int ncoord_d4(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
double thr = 1600.0
);


/**
* Calculate covalent coordination number and derivative
Expand All @@ -87,9 +140,13 @@ extern int dncoord_erf(TMolecule& mol, TMatrix<double>& dist,
* @param thr Real-space cutoff (default: 1600.0).
* @return Exit status.
*/
extern int dncoord_d4(TMolecule& mol, TMatrix<double>& dist,
TVector<double>& cn, TMatrix<double>& dcndr,
double thr = 1600.0);
extern int dncoord_d4(
const TMolecule& mol,
const TMatrix<double>& dist,
TVector<double>& cn,
TMatrix<double>& dcndr,
double thr = 1600.0
);

/**
* Error function counting function for coordination number contributions.
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_parameters.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion include/dftd_readxyz.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
4 changes: 3 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of cpp-d4.
#
# Copyright (C) 2019-2021 Sebastian Ehlert
# Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
#
# cpp-d4 is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -77,3 +77,5 @@ executable(
dependencies: cpp_d4_dep,
install: true,
)

subdir('test')
2 changes: 1 addition & 1 deletion src/dftd_damping.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* This file is part of cpp-d4.
*
* Copyright (C) 2019-2021 Sebastian Ehlert
* Copyright (C) 2019 Sebastian Ehlert, Marvin Friede
*
* cpp-d4 is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
Expand Down
Loading

0 comments on commit 9331390

Please sign in to comment.