Skip to content

Commit

Permalink
added buckingham test and guassian first derivative
Browse files Browse the repository at this point in the history
  • Loading branch information
Danbr4d committed Apr 29, 2024
1 parent 7fed018 commit 167aa1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/math/function1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static std::map<Functions1D::Form, Function1DDefinition> functions1D_ = {
*/
{Functions1D::Form::GaussianC2,
{{"fwhm", "fwhm(x)"},
{FunctionProperties::FourierTransform},
{FunctionProperties::FirstDerivative, FunctionProperties::FourierTransform},
[](std::vector<double> params)
{
params.push_back(params[0] / (2.0 * sqrt(2.0 * log(2.0))));
Expand All @@ -201,8 +201,20 @@ static std::map<Functions1D::Form, Function1DDefinition> functions1D_ = {
*/
[](double x, double omega, const std::vector<double> &params)
{ return exp(-(x * x) / (2.0 * (params[2] + params[3] * omega) * (params[2] + params[3] * omega))); },
// First derivative (not defined)
{},
/*
*
* 1 ( x * x * (c1 + c2*omega)**2 )
* dy/dx = --------------------- * exp ( - -------------------------- )
* (c1 * c2 * omega)**2 ( 2 )
*
*/
[](double x, double omega, const std::vector<double> &params)
{
auto c1 = (params[2] * params[3] * omega);
auto c2 = 1 / pow(c1, 2);
return c2 * (exp(-(0.5 * x * x * (params[2] + params[3] * omega) * (params[2] + params[3] * omega))));
;
},
/*
* ( x * x * (c1 + c2*omega)**2 )
* FT(x) = exp ( - -------------------------- )
Expand All @@ -217,6 +229,7 @@ static std::map<Functions1D::Form, Function1DDefinition> functions1D_ = {
*/
[](double omega, const std::vector<double> &params)
{ return 1.0 / ((params[2] + params[3] * omega) * sqrt(2.0 * M_PI)); }}},

/*
* Lennard-Jones 12-6 Potential
*
Expand Down
6 changes: 6 additions & 0 deletions tests/pairPotentials/analytic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ TEST_F(PairPotentialsTest, LennardJonesForm)
testForce(Functions1D::Form::LennardJones126, "epsilon=0.35 sigma=2.166", testRDelta_ * 5);
}

TEST_F(PairPotentialsTest, Buckingham)
{
//Values put in for TeO2 from https://pubs.rsc.org/en/content/articlelanding/2014/cp/c4cp01273a
testEnergy(Functions1D::Form::Buckingham, "A=1595.266748 B=2.8912848 C=1", testRDelta_ * 5);
testForce(Functions1D::Form::Buckingham, "A=82970.688434 B=6.211565 C=31.361954", testRDelta_ * 5);
}
} // namespace UnitTest

0 comments on commit 167aa1b

Please sign in to comment.