Skip to content

Commit

Permalink
Fix error in TobyFit B Matrix calculation of sample rotation.
Browse files Browse the repository at this point in the history
The sample-only contribition now looks much more like TobyFit.
Refs #7548
  • Loading branch information
martyngigg committed Oct 26, 2013
1 parent 586b248 commit 29132ac
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace Mantid
m_gonimeter->makeUniversalGoniometer();
m_gonimeter->setRotationAngle("phi", thetaInDegs);
m_gonimeter->setRotationAngle("chi", phiInDegs);
m_sampleToDetMatrix = m_gonimeter->getR()*m_exptInfo.sample().getOrientedLattice().getU();
m_sampleToDetMatrix = m_exptInfo.sample().getOrientedLattice().getU()*m_gonimeter->getR();

// EFixed
m_efixed = m_exptInfo.getEFixed(det);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ namespace Mantid
beamVec[TobyFitYVector::ApertureWidthCoord] = -cp_i * gg1;
beamVec[TobyFitYVector::ApertureHeightCoord] = 0.0;
beamVec[TobyFitYVector::ChopperTime] = -cp_i;
beamVec[TobyFitYVector::ScatterPointBeam] = cp_i * gg2 * sMat[1][0];
beamVec[TobyFitYVector::ScatterPointPerp] = cp_i * gg2 * sMat[1][1];
beamVec[TobyFitYVector::ScatterPointUp] = cp_i * gg2 * sMat[1][2];
beamVec[TobyFitYVector::ScatterPointBeam] = cp_i * gg2 * sMat[1][1];
beamVec[TobyFitYVector::ScatterPointPerp] = cp_i * gg2 * sMat[1][2];
beamVec[TobyFitYVector::ScatterPointUp] = cp_i * gg2 * sMat[1][0];
beamVec[TobyFitYVector::DetectorDepth] = 0.0;
beamVec[TobyFitYVector::DetectorWidthCoord] = 0.0;
beamVec[TobyFitYVector::DetectorHeightCoord] = 0.0;
Expand All @@ -101,9 +101,9 @@ namespace Mantid
perpVec[TobyFitYVector::ApertureWidthCoord] = -ct_i;
perpVec[TobyFitYVector::ApertureHeightCoord] = 0.0;
perpVec[TobyFitYVector::ChopperTime] = 0.0;
perpVec[TobyFitYVector::ScatterPointBeam] = ct_i * sMat[1][0];
perpVec[TobyFitYVector::ScatterPointPerp] = ct_i * sMat[1][1];
perpVec[TobyFitYVector::ScatterPointUp] = ct_i * sMat[1][2];
perpVec[TobyFitYVector::ScatterPointBeam] = ct_i * sMat[1][1];
perpVec[TobyFitYVector::ScatterPointPerp] = ct_i * sMat[1][2];
perpVec[TobyFitYVector::ScatterPointUp] = ct_i * sMat[1][0];
perpVec[TobyFitYVector::DetectorDepth] = 0.0;
perpVec[TobyFitYVector::DetectorWidthCoord] = 0.0;
perpVec[TobyFitYVector::DetectorHeightCoord] = 0.0;
Expand All @@ -113,9 +113,9 @@ namespace Mantid
upVec[TobyFitYVector::ApertureWidthCoord] = 0.0;
upVec[TobyFitYVector::ApertureHeightCoord] = -ct_i;
upVec[TobyFitYVector::ChopperTime] = 0.0;
upVec[TobyFitYVector::ScatterPointBeam] = ct_i * sMat[2][0];
upVec[TobyFitYVector::ScatterPointPerp] = ct_i * sMat[2][1];
upVec[TobyFitYVector::ScatterPointUp] = ct_i * sMat[2][2];
upVec[TobyFitYVector::ScatterPointBeam] = ct_i * sMat[1][0];
upVec[TobyFitYVector::ScatterPointPerp] = ct_i * sMat[1][2];
upVec[TobyFitYVector::ScatterPointUp] = -ct_i * sMat[1][1];
upVec[TobyFitYVector::DetectorDepth] = 0.0;
upVec[TobyFitYVector::DetectorWidthCoord] = 0.0;
upVec[TobyFitYVector::DetectorHeightCoord] = 0.0;
Expand All @@ -132,9 +132,9 @@ namespace Mantid
beamOutVec[TobyFitYVector::ApertureWidthCoord] = cp_f * ff1;
beamOutVec[TobyFitYVector::ApertureHeightCoord] = 0.0;
beamOutVec[TobyFitYVector::ChopperTime] = cp_f * (x0+x1)/x0;
beamOutVec[TobyFitYVector::ScatterPointBeam] = cp_f * ( sMat[0][0]/veli - (ds[0][0])/velf - ff2*sMat[1][0] );
beamOutVec[TobyFitYVector::ScatterPointPerp] = cp_f * ( sMat[0][1]/veli - (ds[0][1])/velf - ff2*sMat[1][1] );
beamOutVec[TobyFitYVector::ScatterPointUp] = cp_f * ( sMat[0][2]/veli - (ds[0][2])/velf - ff2*sMat[1][2] );
beamOutVec[TobyFitYVector::ScatterPointBeam] = cp_f * ( sMat[2][0]/veli - (ds[0][2])/velf - ff2*sMat[1][1] );
beamOutVec[TobyFitYVector::ScatterPointPerp] = cp_f * ( sMat[2][2]/veli - (ds[0][1])/velf - ff2*sMat[1][2] );
beamOutVec[TobyFitYVector::ScatterPointUp] = -cp_f * ( sMat[2][1]/veli - (ds[0][0])/velf - ff2*sMat[1][0] );
beamOutVec[TobyFitYVector::DetectorDepth] = cp_f/velf;
beamOutVec[TobyFitYVector::DetectorWidthCoord] = 0.0;
beamOutVec[TobyFitYVector::DetectorHeightCoord] = 0.0;
Expand All @@ -144,9 +144,9 @@ namespace Mantid
perpOutVec[TobyFitYVector::ApertureWidthCoord] = 0.0;
perpOutVec[TobyFitYVector::ApertureHeightCoord] = 0.0;
perpOutVec[TobyFitYVector::ChopperTime] = 0.0;
perpOutVec[TobyFitYVector::ScatterPointBeam] = -ct_f * ( ds[1][0] );
perpOutVec[TobyFitYVector::ScatterPointBeam] = -ct_f * ( ds[1][2] );
perpOutVec[TobyFitYVector::ScatterPointPerp] = -ct_f * ( ds[1][1] );
perpOutVec[TobyFitYVector::ScatterPointUp] = -ct_f * ( ds[1][2] );
perpOutVec[TobyFitYVector::ScatterPointUp] = -ct_f * ( -ds[1][0] );
perpOutVec[TobyFitYVector::DetectorDepth] = 0.0;
perpOutVec[TobyFitYVector::DetectorWidthCoord] = 0.0;
perpOutVec[TobyFitYVector::DetectorHeightCoord] = ct_f;
Expand All @@ -156,9 +156,9 @@ namespace Mantid
upOutVec[TobyFitYVector::ApertureWidthCoord] = 0.0;
upOutVec[TobyFitYVector::ApertureHeightCoord] = 0.0;
upOutVec[TobyFitYVector::ChopperTime] = 0.0;
upOutVec[TobyFitYVector::ScatterPointBeam] = -ct_f * ( ds[2][0] );
upOutVec[TobyFitYVector::ScatterPointPerp] = -ct_f * ( ds[2][1] );
upOutVec[TobyFitYVector::ScatterPointUp] = -ct_f * ( ds[2][2] );
upOutVec[TobyFitYVector::ScatterPointBeam] = -ct_f * ( ds[2][2] );
upOutVec[TobyFitYVector::ScatterPointPerp] = -ct_f * ( -ds[2][1] );
upOutVec[TobyFitYVector::ScatterPointUp] = -ct_f * ( -ds[2][0] );
upOutVec[TobyFitYVector::DetectorDepth]= 0.0;
upOutVec[TobyFitYVector::DetectorWidthCoord] = ct_f;
upOutVec[TobyFitYVector::DetectorHeightCoord] = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ namespace Mantid
L10(D02*D21 - D01*D22), L11(D00*D22 - D02*D20), L12(D20*D01 - D00*D21),
L20(D01*D12 - D02*D11), L21(D02*D10 - D00*D12), L22(D00*D11 - D01*D10);

const double dqlab0 = (L00*xVec3 + L01*xVec4 + L02*xVec5)/determinant;
const double dqlab1 = (L10*xVec3 + L11*xVec4 + L12*xVec5)/determinant;
const double dqlab2 = (L20*xVec3 + L21*xVec4 + L22*xVec5)/determinant;
const double dqlab0 = (L22*xVec3 + L02*xVec4 + L12*xVec5)/determinant;
const double dqlab1 = (L20*xVec3 + L00*xVec4 + L10*xVec5)/determinant;
const double dqlab2 = (L21*xVec3 + L01*xVec4 + L11*xVec5)/determinant;

std::vector<double> & deltaQE = m_deltaQE[PARALLEL_THREAD_NUMBER];
deltaQE[0] = (xVec0 - dqlab0);
Expand Down
34 changes: 17 additions & 17 deletions Code/Mantid/Framework/MDAlgorithms/test/TobyFitBMatrixTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ class TobyFitBMatrixTest : public CxxTest::TestSuite
TobyFitBMatrix bMatrix;
bMatrix.recalculate(*observation, qOmega);

// std::cerr << "\n\n";
// std::cerr << std::setiosflags(std::ios_base::fixed) << std::setprecision(8);
// for(unsigned int i = 0; i < bMatrix.numRows(); ++i)
// {
// for(unsigned int j = 0; j < bMatrix.numCols(); ++j)
// {
// std::cerr << bMatrix[i][j] << " ";
// }
// std::cerr << "\n";
// }
// std::cerr << "\n";
// std::cerr << "\n\n";
// std::cerr << std::setiosflags(std::ios_base::fixed) << std::setprecision(8);
// for(unsigned int i = 0; i < bMatrix.numRows(); ++i)
// {
// for(unsigned int j = 0; j < bMatrix.numCols(); ++j)
// {
// std::cerr << bMatrix[i][j] << " ";
// }
// std::cerr << "\n";
// }
// std::cerr << "\n";

double expected[NUM_ROWS][NUM_COLS] =
{
{13447.77443282, 0.73296352, 0.0, -13447.77443282, 0.0, 0.17571130, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0,-1.46727577, 0.0, 0.0, 0.0, 1.46727577, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, -1.46727577, 0.0, 0.0, 0.0, 1.46727577, 0.0, 0.0, 0.0, 0.0},
{-2387.21606587, 0.20616089, 0.0, 15077.15410023, 2.84517825, 0.54565504, 0.58043611, 1.82762473, 0.0, 0.0, -12689.93803436},
{0.0, 0.0, 0.0, 0.0, -0.84953829, 1.58316802, -0.33477735, 0.0, 0.0, 1.82762473, 0.0},
{0.0, 0.0, 0.0, 0.0, 0.67006116, 0.0, -1.70036178, 0.0, 1.82762473, 0.0, 0.0},
{13447.77443282, 0.73296352, 0.0, -13447.77443282, 0.17571130, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0,-1.46727577, 0.0, 0.0, 1.46727577, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, -1.46727577, 0.0, 0.0, 0.0, -1.46727577, 0.0, 0.0, 0.0, 0.0},
{-2387.21606587, 0.20616089, 0.0, 15077.15410023, 0.21296949, 2.28537259, -1.47292732, 1.82762473, 0.0, 0.0, -12689.93803436},
{0.0, 0.0, 0.0, 0.0, -0.33477735, 1.58316802, 0.84953829, 0.0, 0.0, 1.82762473, 0.0},
{0.0, 0.0, 0.0, 0.0, -1.70036178, 0.0, -0.67006116, 0.0, 1.82762473, 0.0, 0.0},
};

for(unsigned int i = 0; i < bMatrix.numRows(); ++i)
Expand Down

0 comments on commit 29132ac

Please sign in to comment.