Skip to content
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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ after_success:
- cd $TRAVIS_BUILD_DIR
- pip install $MYPIPFLAGS codecov
- codecov
-
deploy:
- provider: releases
- draft: true
22 changes: 19 additions & 3 deletions src/diffpy/srreal/JeongPeakWidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ using namespace std;
// Constructors --------------------------------------------------------------

JeongPeakWidth::JeongPeakWidth() :
mdelta1(0.0), mdelta2(0.0), mqbroad(0.0)
mdelta1(0.0), mdelta2(0.0), mqbroad(0.0), mqbroad_seperable(0.0)
{
this->registerDoubleAttribute("delta1",
this, &JeongPeakWidth::getDelta1, &JeongPeakWidth::setDelta1);
this->registerDoubleAttribute("delta2",
this, &JeongPeakWidth::getDelta2, &JeongPeakWidth::setDelta2);
this->registerDoubleAttribute("qbroad",
this, &JeongPeakWidth::getQbroad, &JeongPeakWidth::setQbroad);
this->registerDoubleAttribute("qbroad_seperable",
this, &JeongPeakWidth::getQbroad_seperable, &JeongPeakWidth::setQbroad_seperable);
}


Expand Down Expand Up @@ -69,7 +71,8 @@ double JeongPeakWidth::calculate(const BaseBondGenerator& bnds) const
double corr = this->msdSharpeningRatio(r);
// avoid calculating square root of negative value
double fwhm = (corr <= 0) ? 0.0 :
(sqrt(corr) * this->DebyeWallerPeakWidth::calculate(bnds));
(sqrt(corr) * this->DebyeWallerPeakWidth::calculate(bnds) +
pow(this->getQbroad_seperable()*r, 2));
return fwhm;
}

Expand All @@ -82,7 +85,7 @@ double JeongPeakWidth::maxWidth(StructureAdapterPtr stru,
this->msdSharpeningRatio(rmin),
this->msdSharpeningRatio(rmax));
// if the sharpening factor is larger than 1 adjust the maximum width
double rv = maxwidth0 * sqrt(max(1.0, maxmsdsharp));
double rv = maxwidth0 * sqrt(max(1.0, maxmsdsharp))+ pow(this->getQbroad_seperable()*rmax, 2);
return rv;
}

Expand Down Expand Up @@ -118,6 +121,19 @@ const double& JeongPeakWidth::getQbroad() const
}


const double& JeongPeakWidth::getQbroad_seperable() const
{
return mqbroad_seperable;
}


void JeongPeakWidth::setQbroad_seperable(double qbroad_seperable)
{
if (mqbroad_seperable != qbroad_seperable) mticker.click();
mqbroad_seperable = qbroad_seperable;
}


void JeongPeakWidth::setQbroad(double qbroad)
{
if (mqbroad != qbroad) mticker.click();
Expand Down
4 changes: 4 additions & 0 deletions src/diffpy/srreal/JeongPeakWidth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ class JeongPeakWidth : public DebyeWallerPeakWidth
void setDelta2(double);
const double& getQbroad() const;
void setQbroad(double);
const double& getQbroad_seperable() const;
void setQbroad_seperable(double);

private:

// data
double mdelta1;
double mdelta2;
double mqbroad;
double mqbroad_seperable;

// methods
double msdSharpeningRatio(const double& r) const;
Expand All @@ -71,6 +74,7 @@ class JeongPeakWidth : public DebyeWallerPeakWidth
ar & mdelta1;
ar & mdelta2;
ar & mqbroad;
ar & mqbroad_seperable;
}

};
Expand Down
3 changes: 3 additions & 0 deletions src/tests/TestPDFCalculator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ class TestPDFCalculator : public CxxTest::TestSuite
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("delta1"));
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("delta2"));
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("qbroad"));
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("qbroad_seperable"));
JeongPeakWidth jpw;
jpw.setDelta1(1.0);
jpw.setDelta2(2.0);
jpw.setQbroad(3.0);
jpw.setQbroad_seperable(4.0);
mpdfc->setPeakWidthModel(jpw.clone());
const PeakWidthModelPtr& jpw1 = mpdfc->getPeakWidthModel();
TS_ASSERT_EQUALS(1.0, jpw1->getDoubleAttr("delta1"));
TS_ASSERT_EQUALS(2.0, jpw1->getDoubleAttr("delta2"));
TS_ASSERT_EQUALS(3.0, jpw1->getDoubleAttr("qbroad"));
TS_ASSERT_EQUALS(4.0, jpw1->getDoubleAttr("qbroad_seperable"));
}


Expand Down
7 changes: 6 additions & 1 deletion src/tests/TestPeakWidthModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ class TestPeakWidthModel : public CxxTest::TestSuite
void test_attributes()
{
TS_ASSERT_EQUALS(0, mdwpw->namesOfDoubleAttributes().size());
TS_ASSERT_EQUALS(3, mjepw->namesOfDoubleAttributes().size());
TS_ASSERT_EQUALS(4, mjepw->namesOfDoubleAttributes().size());
mcjepw->setDelta1(0.1);
mcjepw->setDelta2(0.2);
mcjepw->setQbroad(0.3);
mcjepw->setQbroad_seperable(0.4);
TS_ASSERT_EQUALS(0.1, mjepw->getDoubleAttr("delta1"));
TS_ASSERT_EQUALS(0.2, mjepw->getDoubleAttr("delta2"));
TS_ASSERT_EQUALS(0.3, mjepw->getDoubleAttr("qbroad"));
TS_ASSERT_EQUALS(0.4, mjepw->getDoubleAttr("qbroad_seperable"));
}


Expand All @@ -108,6 +110,7 @@ class TestPeakWidthModel : public CxxTest::TestSuite
TS_ASSERT_DELTA(0.5 * w, mjepw->calculate(*bnds), meps);
mcjepw->setDelta2(0);
mcjepw->setQbroad(sqrt(3));
mcjepw->setQbroad_seperable(0);
TS_ASSERT_DELTA(2 * w, mjepw->calculate(*bnds), meps);
}

Expand All @@ -121,12 +124,14 @@ class TestPeakWidthModel : public CxxTest::TestSuite
mcjepw->setDelta1(1.1);
mcjepw->setDoubleAttr("delta2", 2.2);
mcjepw->setDoubleAttr("qbroad", 0.03);
mcjepw->setDoubleAttr("qbroad_seperable", 0.003);
PeakWidthModelPtr pwm2 = dumpandload(mjepw);
JeongPeakWidth* cpwm2 = dynamic_cast<JeongPeakWidth*>(pwm2.get());
TS_ASSERT(cpwm2);
TS_ASSERT_EQUALS(1.1, pwm2->getDoubleAttr("delta1"));
TS_ASSERT_EQUALS(2.2, pwm2->getDoubleAttr("delta2"));
TS_ASSERT_EQUALS(0.03, pwm2->getDoubleAttr("qbroad"));
TS_ASSERT_EQUALS(0.003, pwm2->getDoubleAttr("qbroad_seperable"));
}


Expand Down