Skip to content

Commit 906cda4

Browse files
authored
Merge pull request #30 from rjkoch/fix_qbroad_bug
modified JeongPeakWidth to include new Q_broad term
2 parents 1ac3dcf + 7dee219 commit 906cda4

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,7 @@ after_success:
147147
- cd $TRAVIS_BUILD_DIR
148148
- pip install $MYPIPFLAGS codecov
149149
- codecov
150+
-
151+
deploy:
152+
- provider: releases
153+
- draft: true

src/diffpy/srreal/JeongPeakWidth.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ using namespace std;
3030
// Constructors --------------------------------------------------------------
3131

3232
JeongPeakWidth::JeongPeakWidth() :
33-
mdelta1(0.0), mdelta2(0.0), mqbroad(0.0)
33+
mdelta1(0.0), mdelta2(0.0), mqbroad(0.0), mqbroad_seperable(0.0)
3434
{
3535
this->registerDoubleAttribute("delta1",
3636
this, &JeongPeakWidth::getDelta1, &JeongPeakWidth::setDelta1);
3737
this->registerDoubleAttribute("delta2",
3838
this, &JeongPeakWidth::getDelta2, &JeongPeakWidth::setDelta2);
3939
this->registerDoubleAttribute("qbroad",
4040
this, &JeongPeakWidth::getQbroad, &JeongPeakWidth::setQbroad);
41+
this->registerDoubleAttribute("qbroad_seperable",
42+
this, &JeongPeakWidth::getQbroad_seperable, &JeongPeakWidth::setQbroad_seperable);
4143
}
4244

4345

@@ -69,7 +71,8 @@ double JeongPeakWidth::calculate(const BaseBondGenerator& bnds) const
6971
double corr = this->msdSharpeningRatio(r);
7072
// avoid calculating square root of negative value
7173
double fwhm = (corr <= 0) ? 0.0 :
72-
(sqrt(corr) * this->DebyeWallerPeakWidth::calculate(bnds));
74+
(sqrt(corr) * this->DebyeWallerPeakWidth::calculate(bnds) +
75+
pow(this->getQbroad_seperable()*r, 2));
7376
return fwhm;
7477
}
7578

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

@@ -118,6 +121,19 @@ const double& JeongPeakWidth::getQbroad() const
118121
}
119122

120123

124+
const double& JeongPeakWidth::getQbroad_seperable() const
125+
{
126+
return mqbroad_seperable;
127+
}
128+
129+
130+
void JeongPeakWidth::setQbroad_seperable(double qbroad_seperable)
131+
{
132+
if (mqbroad_seperable != qbroad_seperable) mticker.click();
133+
mqbroad_seperable = qbroad_seperable;
134+
}
135+
136+
121137
void JeongPeakWidth::setQbroad(double qbroad)
122138
{
123139
if (mqbroad != qbroad) mticker.click();

src/diffpy/srreal/JeongPeakWidth.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ class JeongPeakWidth : public DebyeWallerPeakWidth
4949
void setDelta2(double);
5050
const double& getQbroad() const;
5151
void setQbroad(double);
52+
const double& getQbroad_seperable() const;
53+
void setQbroad_seperable(double);
5254

5355
private:
5456

5557
// data
5658
double mdelta1;
5759
double mdelta2;
5860
double mqbroad;
61+
double mqbroad_seperable;
5962

6063
// methods
6164
double msdSharpeningRatio(const double& r) const;
@@ -71,6 +74,7 @@ class JeongPeakWidth : public DebyeWallerPeakWidth
7174
ar & mdelta1;
7275
ar & mdelta2;
7376
ar & mqbroad;
77+
ar & mqbroad_seperable;
7478
}
7579

7680
};

src/tests/TestPDFCalculator.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ class TestPDFCalculator : public CxxTest::TestSuite
5555
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("delta1"));
5656
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("delta2"));
5757
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("qbroad"));
58+
TS_ASSERT_EQUALS(0.0, jpw0->getDoubleAttr("qbroad_seperable"));
5859
JeongPeakWidth jpw;
5960
jpw.setDelta1(1.0);
6061
jpw.setDelta2(2.0);
6162
jpw.setQbroad(3.0);
63+
jpw.setQbroad_seperable(4.0);
6264
mpdfc->setPeakWidthModel(jpw.clone());
6365
const PeakWidthModelPtr& jpw1 = mpdfc->getPeakWidthModel();
6466
TS_ASSERT_EQUALS(1.0, jpw1->getDoubleAttr("delta1"));
6567
TS_ASSERT_EQUALS(2.0, jpw1->getDoubleAttr("delta2"));
6668
TS_ASSERT_EQUALS(3.0, jpw1->getDoubleAttr("qbroad"));
69+
TS_ASSERT_EQUALS(4.0, jpw1->getDoubleAttr("qbroad_seperable"));
6770
}
6871

6972

src/tests/TestPeakWidthModel.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ class TestPeakWidthModel : public CxxTest::TestSuite
8484
void test_attributes()
8585
{
8686
TS_ASSERT_EQUALS(0, mdwpw->namesOfDoubleAttributes().size());
87-
TS_ASSERT_EQUALS(3, mjepw->namesOfDoubleAttributes().size());
87+
TS_ASSERT_EQUALS(4, mjepw->namesOfDoubleAttributes().size());
8888
mcjepw->setDelta1(0.1);
8989
mcjepw->setDelta2(0.2);
9090
mcjepw->setQbroad(0.3);
91+
mcjepw->setQbroad_seperable(0.4);
9192
TS_ASSERT_EQUALS(0.1, mjepw->getDoubleAttr("delta1"));
9293
TS_ASSERT_EQUALS(0.2, mjepw->getDoubleAttr("delta2"));
9394
TS_ASSERT_EQUALS(0.3, mjepw->getDoubleAttr("qbroad"));
95+
TS_ASSERT_EQUALS(0.4, mjepw->getDoubleAttr("qbroad_seperable"));
9496
}
9597

9698

@@ -108,6 +110,7 @@ class TestPeakWidthModel : public CxxTest::TestSuite
108110
TS_ASSERT_DELTA(0.5 * w, mjepw->calculate(*bnds), meps);
109111
mcjepw->setDelta2(0);
110112
mcjepw->setQbroad(sqrt(3));
113+
mcjepw->setQbroad_seperable(0);
111114
TS_ASSERT_DELTA(2 * w, mjepw->calculate(*bnds), meps);
112115
}
113116

@@ -121,12 +124,14 @@ class TestPeakWidthModel : public CxxTest::TestSuite
121124
mcjepw->setDelta1(1.1);
122125
mcjepw->setDoubleAttr("delta2", 2.2);
123126
mcjepw->setDoubleAttr("qbroad", 0.03);
127+
mcjepw->setDoubleAttr("qbroad_seperable", 0.003);
124128
PeakWidthModelPtr pwm2 = dumpandload(mjepw);
125129
JeongPeakWidth* cpwm2 = dynamic_cast<JeongPeakWidth*>(pwm2.get());
126130
TS_ASSERT(cpwm2);
127131
TS_ASSERT_EQUALS(1.1, pwm2->getDoubleAttr("delta1"));
128132
TS_ASSERT_EQUALS(2.2, pwm2->getDoubleAttr("delta2"));
129133
TS_ASSERT_EQUALS(0.03, pwm2->getDoubleAttr("qbroad"));
134+
TS_ASSERT_EQUALS(0.003, pwm2->getDoubleAttr("qbroad_seperable"));
130135
}
131136

132137

0 commit comments

Comments
 (0)