Skip to content

Commit

Permalink
Do matrix qlab->qhkl by hand to avoid matrix cost. Refs #5397
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Aug 2, 2012
1 parent de8c2f3 commit 7f7bf85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ namespace Mantid
*/
double Strontium122::scatteringIntensity(const API::ExperimentInfo & exptSetup, const std::vector<double> & point) const
{
const double qx(point[0]), qy(point[1]), qz(point[2]), eps(point[3]);
const double qz(point[0]), qx(point[1]), qy(point[2]), eps(point[3]); // TobyFit has axis beam=x,up=z. Mantid has beam=z,up=y
const double qsqr = qx*qx + qy*qy + qz*qz;
const double epssqr = eps*eps;

const Kernel::V3D qLab(qy,qz,qx); // TobyFit has axis beam=x,up=z. Mantid has beam=z,up=y
const Geometry::OrientedLattice & latticeRot = exptSetup.sample().getOrientedLattice();
const double twoPi = 2.*M_PI;
static const double twoPi = 2.*M_PI;

const Kernel::DblMatrix & ub = latticeRot.getUB();
const double ub00(ub[0][0]), ub01(ub[0][1]), ub02(ub[0][2]),
ub10(ub[1][0]), ub11(ub[1][1]), ub12(ub[1][2]),
ub20(ub[2][0]), ub21(ub[2][1]), ub22(ub[2][2]);
const double twoPiDet= twoPi*(ub00*(ub11*ub22 - ub12*ub21) -
ub01*(ub10*ub22 - ub12*ub20) +
ub02*(ub10*ub21 - ub11*ub20));

const double qh = ((ub11*ub22 - ub12*ub21)*qx + (ub02*ub21 - ub01*ub22)*qy + (ub01*ub12 - ub02*ub11)*qz)/twoPiDet;
const double qk = ((ub12*ub20 - ub10*ub22)*qx + (ub00*ub22 - ub02*ub20)*qy + (ub02*ub10 - ub00*ub12)*qz)/twoPiDet;
const double ql = ((ub10*ub21 - ub11*ub20)*qx + (ub01*ub20 - ub00*ub21)*qy + (ub00*ub11 - ub01*ub10)*qz)/twoPiDet;

const Kernel::V3D qHKL = latticeRot.hklFromQ(qLab);
// Mantid definition doesn't contain 2*pi in definition of reciprocal lattice parameters
const double qh(qHKL[0]/twoPi), qk(qHKL[1]/twoPi), ql(qHKL[2]/twoPi);
const double astar = twoPi*latticeRot.b1(); //arlu(1)
const double bstar = twoPi*latticeRot.b2(); //arlu(2)
const double cstar = twoPi*latticeRot.b3(); //arlu(3)
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDAlgorithms/test/Strontium122Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Strontium122Test : public CxxTest::TestSuite
double weight(-1.0);
const ForegroundModel & sr122Function = sr122; // scatteringIntensity is private concrete model
TS_ASSERT_THROWS_NOTHING( weight = sr122Function.scatteringIntensity(experimentDescr, std::vector<double>(qOmega, qOmega + 4)) );
//TS_ASSERT_DELTA(0.24589087, weight, 1e-8);
TS_ASSERT_DELTA(0.24589087, weight, 1e-8);
}

};
Expand Down

0 comments on commit 7f7bf85

Please sign in to comment.