Skip to content

Commit

Permalink
Revert "Refs #10199 use same cost function as ISAW"
Browse files Browse the repository at this point in the history
This reverts commit 0cd3ae9.
  • Loading branch information
VickieLynch committed Nov 11, 2014
1 parent 2671ccb commit 22c434b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 746 deletions.
12 changes: 0 additions & 12 deletions Code/Mantid/Framework/Crystal/src/OptimizeCrystalPlacement.cpp
Expand Up @@ -355,10 +355,6 @@ namespace Mantid

fit_alg->setProperty( "MaxIterations" , 60 );

fit_alg->setProperty( "Minimizer" , "Simplex" );

fit_alg->setProperty( "CostFunction" , "Simplex" );

fit_alg->setProperty( "Constraints" , Constr );

fit_alg->setProperty( "InputWorkspace" , mwkspc );
Expand All @@ -384,14 +380,6 @@ namespace Mantid
Ties +="GonRotx=0.0,GonRoty=0.0,GonRotz=0.0";

}
else
{
if( !Ties.empty())
Ties +=",";

Ties +="GonRotx=0.0,GonRotz=0.0";

}

if( !Ties.empty())
fit_alg->setProperty("Ties",Ties);
Expand Down
47 changes: 20 additions & 27 deletions Code/Mantid/Framework/Crystal/src/PeakHKLErrors.cpp
Expand Up @@ -21,14 +21,12 @@
#include "MantidKernel/Matrix.h"
#include "MantidKernel/Quat.h"
#include "MantidKernel/V3D.h"
#include "MantidGeometry/Crystal/IndexingUtils.h"
#include <cctype>
#include <string>

using namespace Mantid::DataObjects;
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::Geometry;
using Mantid::Geometry::CompAssembly;
using Mantid::Geometry::IObjComponent_const_sptr;
using Mantid::Geometry::IComponent_const_sptr;
Expand Down Expand Up @@ -366,7 +364,11 @@ namespace Mantid

std::map<int, Mantid::Kernel::Matrix<double> > RunNum2GonMatrixMap;
getRun2MatMap( Peaks, OptRuns, RunNum2GonMatrixMap);
DblMatrix UB = Peaks->sample().getOrientedLattice().getUB();
const DblMatrix & UBx = Peaks->sample().getOrientedLattice().getUB();

DblMatrix UBinv( UBx );
UBinv.Invert();
UBinv /= ( 2 * M_PI );

double GonRotx =getParameter("GonRotx");
double GonRoty =getParameter("GonRoty");
Expand All @@ -377,7 +379,6 @@ namespace Mantid


double ChiSqTot = 0.0;
std::vector<V3D> q_vectors;
for( size_t i = 0; i< nData; i+= 3 )
{
int peakNum = (int)( .5 + xValues[i] );
Expand All @@ -399,35 +400,27 @@ namespace Mantid
peak.setGoniometerMatrix( GonRot*peak.getGoniometerMatrix());
}

q_vectors.push_back( peak.getQSampleFrame());
V3D hkl = UBinv * peak.getQSampleFrame();



for( int k = 0; k<3; k++ )
{
double d1 = hkl[k] - floor( hkl[k] );
if( d1>.5 ) d1 = d1 - 1;
if( d1 < -.5 ) d1 = d1 + 1;

out[i+k] = d1;
ChiSqTot += d1*d1;
}


}
std::vector<double> sigabc(1);// only need chisq
std::vector<V3D> miller_ind;
std::vector<V3D> indexed_qs;
double fit_error;
miller_ind.reserve( q_vectors.size() );
indexed_qs.reserve( q_vectors.size() );
double tolerance = 0.12;
IndexingUtils::GetIndexedPeaks( UB, q_vectors, tolerance,
miller_ind, indexed_qs, fit_error );
ChiSqTot = IndexingUtils::Optimize_UB(UB, miller_ind,indexed_qs,out);

int num_indexed = IndexingUtils::NumberIndexed(UB, q_vectors, tolerance);
/*for( size_t p = 0 ; p < nData; p++ )
{
out[p] *= 0.1*static_cast<double>(num_indexed)*static_cast<double>(nData);
out[p] -= static_cast<double>(num_indexed)/static_cast<double>(nData);
}*/
g_log.notice() << "New UB will index " << num_indexed << " Peaks out of " << nData
<< " with tolerance of " << std::setprecision(3) << std::setw(5) << tolerance
<< "\n";

g_log.debug() << "------------------------Function-----------------------------------------------"<<std::endl;
for( size_t p = 0 ; p < nParams() ; p++ )
{
g_log.debug() << parameterName(p)<<"("<<getParameter(p
)<<"),";
g_log.debug() << parameterName(p)<<"("<<getParameter(p)<<"),";
if ((p + 1) % 6 ==0 )
g_log.debug() << std::endl;
}
Expand Down
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/CurveFitting/CMakeLists.txt
Expand Up @@ -22,7 +22,6 @@ set ( SRC_FILES
src/CostFuncFitting.cpp
src/CostFuncLeastSquares.cpp
src/CostFuncRwp.cpp
src/CostFuncSimplex.cpp
src/CubicSpline.cpp
src/DampingMinimizer.cpp
src/DeltaFunction.cpp
Expand Down Expand Up @@ -128,7 +127,6 @@ set ( INC_FILES
inc/MantidCurveFitting/CostFuncFitting.h
inc/MantidCurveFitting/CostFuncLeastSquares.h
inc/MantidCurveFitting/CostFuncRwp.h
inc/MantidCurveFitting/CostFuncSimplex.h
inc/MantidCurveFitting/CubicSpline.h
inc/MantidCurveFitting/DampingMinimizer.h
inc/MantidCurveFitting/DeltaFunction.h
Expand Down

This file was deleted.

Expand Up @@ -10,7 +10,6 @@
#include "MantidAPI/IDomainCreator.h"
#include "MantidCurveFitting/CostFuncLeastSquares.h"
#include "MantidCurveFitting/CostFuncRwp.h"
#include "MantidCurveFitting/CostFuncSimplex.h"

#include <stdexcept>
#include <vector>
Expand Down Expand Up @@ -66,8 +65,6 @@ class MANTID_CURVEFITTING_DLL SeqDomain: public API::FunctionDomain
void rwpVal(const CostFuncRwp& rwp);
/// Calculate the value, first and second derivatives of a RWP cost function
void rwpValDerivHessian(const CostFuncRwp& rwp, bool evalFunction, bool evalDeriv, bool evalHessian);
virtual void simplexVal(const CostFuncSimplex& simplex);
virtual void simplexValDerivHessian(const CostFuncSimplex& leastSquares, bool evalFunction, bool evalDeriv, bool evalHessian);

/// Create an instance of SeqDomain in one of two forms: either SeqDomain for sequential domain creation
/// or ParDomain for parallel calculations
Expand Down

0 comments on commit 22c434b

Please sign in to comment.