28 #include "cctbx/sgtbx/space_group.h"
29 #include "cctbx/miller/index_generator.h"
30 #include "cctbx/miller/sym_equiv.h"
31 #include "cctbx/eltbx/wavelengths.h"
33 #include "ObjCryst/ObjCryst/ScatteringData.h"
34 #include "ObjCryst/Quirks/VFNDebug.h"
35 #include "ObjCryst/Quirks/VFNStreamFormat.h"
36 #include "ObjCryst/Quirks/Chronometer.h"
39 #include "ObjCryst/wxCryst/wxPowderPattern.h"
40 #include "ObjCryst/wxCryst/wxRadiation.h"
47 #ifdef HAVE_SSE_MATHFUN
48 #include "ObjCryst/Quirks/sse_mathfun.h"
51 #define POSSIBLY_UNUSED(expr) (void)(expr)
74 const RefParType *gpRefParTypeRadiationWavelength=0;
76 long NiftyStaticGlobalObjectsInitializer_ScatteringData::mCount=0;
78 #ifndef HAVE_SSE_MATHFUN
88 static REAL sLibCrystTabulCosineRatio;
92 #define sLibCrystNbTabulSine 8192
93 #define sLibCrystNbTabulSineMASK 8191
95 static REAL *spLibCrystTabulCosine;
96 static REAL *spLibCrystTabulCosineSine;
98 void InitLibCrystTabulCosine()
100 VFN_DEBUG_MESSAGE(
"InitLibCrystTabulCosine()",10)
101 spLibCrystTabulCosine=
new REAL[sLibCrystNbTabulSine];
102 spLibCrystTabulCosineSine=
new REAL[sLibCrystNbTabulSine*2];
103 REAL *tmp=spLibCrystTabulCosine;
104 sLibCrystTabulCosineRatio=sLibCrystNbTabulSine/2./M_PI;
105 for(REAL i=0;i<sLibCrystNbTabulSine;i++) *tmp++ = cos(i/sLibCrystTabulCosineRatio);
106 tmp=spLibCrystTabulCosineSine;
107 for(REAL i=0;i<sLibCrystNbTabulSine;i++)
109 *tmp++ = cos(i/sLibCrystTabulCosineRatio);
110 *tmp++ = sin(i/sLibCrystTabulCosineRatio);
114 void DeleteLibCrystTabulCosine()
116 delete[] spLibCrystTabulCosine;
117 delete[] spLibCrystTabulCosineSine;
121 static bool sLibCrystTabulExpIsInit=
false;
122 static const long sLibCrystNbTabulExp=10000;
123 static const REAL sLibCrystMinTabulExp=-5.;
124 static const REAL sLibCrystMaxTabulExp=10.;
125 static REAL *spLibCrystTabulExp;
126 void InitLibCrystTabulExp()
128 VFN_DEBUG_MESSAGE(
"InitLibCrystTabulExp()",10)
129 spLibCrystTabulExp=new REAL[sLibCrystNbTabulExp];
130 REAL *tmp=spLibCrystTabulExp;
131 for(REAL i=0;i<sLibCrystNbTabulExp;i++)
132 *tmp++ = exp(sLibCrystMinTabulExp+i*(sLibCrystMaxTabulExp-sLibCrystMinTabulExp)/sLibCrystNbTabulExp);
133 sLibCrystTabulExpIsInit=true;
136 void DeleteLibCrystTabulExp() {
delete[] spLibCrystTabulExp;}
147 mWavelength(1),mXRayTubeName(
""),mXRayTubeDeltaLambda(0.),
148 mXRayTubeAlpha2Alpha1Ratio(0.5),mLinearPolarRate(0)
181 mRadiationType(old.mRadiationType),
182 mWavelengthType(old.mWavelengthType),
183 mWavelength(old.mWavelength),
184 mXRayTubeName(old.mXRayTubeName),
185 mXRayTubeDeltaLambda(old.mXRayTubeDeltaLambda),
186 mXRayTubeAlpha2Alpha1Ratio(old.mXRayTubeAlpha2Alpha1Ratio),
187 mLinearPolarRate(old.mLinearPolarRate)
189 mClockWavelength.
Click();
195 Radiation::~Radiation()
200 const static string className=
"Radiation";
204 void Radiation::operator=(
const Radiation &old)
211 mClockWavelength.
Click();
223 if(rad == RAD_ELECTRON)
234 if(type==WAVELENGTH_TOF)
240 if(type==WAVELENGTH_ALPHA12)
246 if(type==WAVELENGTH_MONOCHROMATIC)
262 mClockWavelength.
Click();
267 const REAL alpha2Alpha2ratio)
269 VFN_DEBUG_MESSAGE(
"Radiation::SetWavelength(tubeName,ratio):",5)
275 if(XRayTubeElementName.length() >=3)
277 if(XRayTubeElementName==
"CoA1")
289 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
290 <<
" not modifying wavelength !"<<endl;
298 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
299 <<
" not modifying wavelength !"<<endl;
307 REAL lambda1 = 0, lambda2 = 0;
308 if(XRayTubeElementName==
"Co")
317 cctbx::eltbx::wavelengths::characteristic ch(
mXRayTubeName+
"A1");
320 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
321 <<
" not modifying wavelength !"<<endl;
324 lambda1=ch.as_angstrom();
325 cctbx::eltbx::wavelengths::characteristic ch2(
mXRayTubeName+
"A2");
328 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
329 <<
" not modifying wavelength !"<<endl;
332 lambda2=ch2.as_angstrom();
336 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
337 <<
" not modifying wavelength !"<<endl;
344 VFN_DEBUG_MESSAGE(
"Radiation::SetWavelength("<<XRayTubeElementName<<
","<<alpha2Alpha2ratio<<
"):", 10)
347 mClockWavelength.
Click();
360 VFN_DEBUG_MESSAGE(
"Radiation::Print():"<<this->
GetName(),5)
361 cout <<
"Radiation:" <<
" " ;
365 case RAD_NEUTRON: cout<<
"Neutron,";
break;
366 case RAD_XRAY: cout<<
"X-Ray,";
break;
367 case RAD_ELECTRON: cout<<
"Electron,";
break;
370 cout <<
"Wavelength=" <<
" ";
373 case WAVELENGTH_MONOCHROMATIC: cout<<
"monochromatic:"<<
" "<<
mWavelength(0) <<endl;
break;
374 case WAVELENGTH_ALPHA12: cout <<
"tube:"<<
" "<<
mXRayTubeName<<
", Alpha1/Alpha2= "
376 case WAVELENGTH_MAD: cout<<
"mad"<<
" "<<endl;
break;
377 case WAVELENGTH_DAFS: cout<<
"dafs"<<
" "<<endl;
break;
378 case WAVELENGTH_LAUE: cout<<
"laue"<<
" "<<endl;
break;
379 case WAVELENGTH_TOF: cout<<
"Time Of Flight"<<
" "<<endl;
break;
387 void Radiation::InitOptions()
389 static string RadiationTypeName;
390 static string RadiationTypeChoices[3];
391 static string WavelengthTypeName;
392 static string WavelengthTypeChoices[3];
394 static bool needInitNames=
true;
395 if(
true==needInitNames)
397 RadiationTypeName=
"Radiation";
398 RadiationTypeChoices[0]=
"Neutron";
399 RadiationTypeChoices[1]=
"X-Ray";
400 RadiationTypeChoices[2]=
"Electron";
402 WavelengthTypeName=
"Spectrum";
403 WavelengthTypeChoices[0]=
"Monochromatic";
404 WavelengthTypeChoices[1]=
"X-Ray Tube";
405 WavelengthTypeChoices[2]=
"Time Of Flight";
418 RefinablePar tmp(
"Wavelength",
mWavelength.data(),0.05,20.,
419 gpRefParTypeRadiationWavelength,REFPAR_DERIV_STEP_ABSOLUTE,
420 true,
true,
true,
false,1.0);
421 tmp.SetDerivStep(1e-4);
422 tmp.AssignClock(mClockWavelength);
427 gpRefParTypeRadiationWavelength,REFPAR_DERIV_STEP_ABSOLUTE,
428 true,
true,
true,
false,1.0);
429 tmp.SetDerivStep(1e-4);
430 tmp.AssignClock(mClockWavelength);
435 gpRefParTypeRadiationWavelength,REFPAR_DERIV_STEP_ABSOLUTE,
436 true,
true,
true,
false,1.0);
437 tmp.SetDerivStep(1e-4);
438 tmp.AssignClock(mClockWavelength);
444 WXCrystObjBasic* Radiation::WXCreate(wxWindow* parent)
447 mpWXCrystObj=
new WXRadiation(parent,
this);
458 ScatteringData::ScatteringData():
460 mpCrystal(0),mGlobalBiso(0),mUseFastLessPreciseFunc(false),
461 mIgnoreImagScattFact(false),mMaxSinThetaOvLambda(10)
463 VFN_DEBUG_MESSAGE(
"ScatteringData::ScatteringData()",10)
465 RefinablePar tmp(
"Global Biso",&mGlobalBiso,-1.,1.,
466 gpRefParTypeScattPowTemperatureIso,REFPAR_DERIV_STEP_ABSOLUTE,
467 true,
true,
true,
false,1.0);
468 tmp.SetDerivStep(1e-4);
469 tmp.AssignClock(mClockGlobalBiso);
478 ScatteringData::ScatteringData(
const ScatteringData &old):
479 mNbRefl(old.mNbRefl),
480 mpCrystal(old.mpCrystal),mUseFastLessPreciseFunc(old.mUseFastLessPreciseFunc),
482 mClockHKL(old.mClockHKL),
483 mIgnoreImagScattFact(old.mIgnoreImagScattFact),
484 mMaxSinThetaOvLambda(old.mMaxSinThetaOvLambda)
486 VFN_DEBUG_MESSAGE(
"ScatteringData::ScatteringData(&old)",10)
487 mClockStructFactor.Reset();
489 mClockScattFactor.Reset();
490 mClockScattFactorResonant.Reset();
491 mClockThermicFact.Reset();
492 this->SetHKL(old.GetH(),old.GetK(),old.GetL());
493 VFN_DEBUG_MESSAGE("ScatteringData::ScatteringData(&old):End",5)
495 RefinablePar tmp(
"Global Biso",&mGlobalBiso,-1.,1.,
496 gpRefParTypeScattPowTemperatureIso,REFPAR_DERIV_STEP_ABSOLUTE,
497 true,
true,
true,
false,1.0);
498 tmp.SetDerivStep(1e-4);
499 tmp.AssignClock(mClockGlobalBiso);
508 ScatteringData::~ScatteringData()
510 VFN_DEBUG_MESSAGE(
"ScatteringData::~ScatteringData()",10)
514 const CrystVector_REAL &k,
515 const CrystVector_REAL &l)
521 const CrystVector_REAL &k,
522 const CrystVector_REAL &l)
const
524 VFN_DEBUG_ENTRY(
"ScatteringData::SetHKL(h,k,l)",5)
531 VFN_DEBUG_EXIT(
"ScatteringData::SetHKL(h,k,l):End",5)
542 VFN_DEBUG_ENTRY(
"ScatteringData::GenHKLFullSpace2()",5)
543 TAU_PROFILE(
"ScatteringData::GenHKLFullSpace2()",
"void (REAL,bool)",TAU_DEFAULT);
547 no crystal assigned yet to this ScatteringData object.");
555 cctbx::miller::index_generator igen(uc,
556 this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg().type(),
570 H.resizeAndPreserve(
mNbRefl+100);
571 K.resizeAndPreserve(
mNbRefl+100);
572 L.resizeAndPreserve(
mNbRefl+100);
575 cctbx::miller::index<> h = igen.next();
576 if (h.is_zero())
break;
580 cctbx::miller::sym_equiv_indices sei(this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg(),h);
600 cctbx::miller::index<> h = igen.next();
601 if (h.is_zero())
break;
602 cctbx::miller::sym_equiv_indices sei(this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg(),h);
603 for(
int i=0;i<sei.multiplicity(
true);i++)
605 cctbx::miller::index<> k = sei(i).h();
608 H.resizeAndPreserve(
mNbRefl+100);
609 K.resizeAndPreserve(
mNbRefl+100);
610 L.resizeAndPreserve(
mNbRefl+100);
632 VFN_DEBUG_EXIT(
"ScatteringData::GenHKLFullSpace2():End",5)
642 VFN_DEBUG_ENTRY(
"ScatteringData::GenHKLFullSpace()",5)
646 no wavelength assigned yet to this ScatteringData object.");;
649 VFN_DEBUG_EXIT(
"ScatteringData::GenHKLFullSpace()",5)
656 VFN_DEBUG_MESSAGE(
"ScatteringData::SetCrystal()",5)
685 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflX()",1)
687 VFN_DEBUG_EXIT(
"ScatteringData::GetReflX()",1)
692 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflY()",1)
694 VFN_DEBUG_EXIT(
"ScatteringData::GetReflY()",1)
699 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflZ()",1)
701 VFN_DEBUG_EXIT(
"ScatteringData::GetReflZ()",1)
707 VFN_DEBUG_ENTRY(
"ScatteringData::GetSinThetaOverLambda()",1)
709 VFN_DEBUG_EXIT(
"ScatteringData::GetSinThetaOverLambda()",1)
715 VFN_DEBUG_ENTRY(
"ScatteringData::GetTheta()",1)
717 VFN_DEBUG_EXIT(
"ScatteringData::GetTheta()",1)
728 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcSq()",2)
731 #ifdef __LIBCRYST_VECTOR_USE_BLITZ__
737 pi=mFhklCalcImag.data();
741 *p++ = *pr * *pr + *pi * *pi;
748 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcSq()",2)
752 std::map<RefinablePar*, CrystVector_REAL>& ScatteringData::GetFhklCalcSq_FullDeriv(std::set<RefinablePar *> &vPar)
754 TAU_PROFILE(
"ScatteringData::GetFhklCalcSq_FullDeriv()",
"void ()",TAU_DEFAULT);
755 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcSq()",2)
756 this->CalcStructFactor_FullDeriv(vPar);
758 mFhklCalcSq_FullDeriv.clear();
759 const REAL *pr,*pi,*prd,*pid;
761 for(std::set<
RefinablePar *>::iterator par=vPar.begin();par!=vPar.end();par++)
763 if((*par)==0)
continue;
764 if(mFhklCalcReal_FullDeriv[*par].size()==0)
766 mFhklCalcSq_FullDeriv[*par].resize(0);
769 mFhklCalcSq_FullDeriv[*par].resize(
mNbRefl);
771 pi=mFhklCalcImag.data();
772 prd=mFhklCalcReal_FullDeriv[*par].data();
773 pid=mFhklCalcImag_FullDeriv[*par].data();
774 p=mFhklCalcSq_FullDeriv[*par].data();
776 *p++ = 2*(*pr++ * *prd++ + *pi++ * *pid++);
779 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcSq()",2)
780 return mFhklCalcSq_FullDeriv;
785 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcReal()",2)
787 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcReal()",2)
793 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcImag()",2)
795 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcImag()",2)
796 return mFhklCalcImag;
806 if(obs.numElements() !=
mNbRefl)
807 throw ObjCrystException(
"ScatteringData::SetFhklObsSq(): incorrect number of reflections !");
820 void ScatteringData::SetUseFastLessPreciseFunc(
const bool useItOrNot)
829 VFN_DEBUG_MESSAGE(
"ScatteringData::SetIsIgnoringImagScattFact():"<<b,10)
838 VFN_DEBUG_ENTRY(
"ScatteringData::PrintFhklCalc()",5)
840 CrystVector_REAL theta;
843 os <<
" Number of reflections:"<<
mNbRefl<<endl;
844 os <<
" H K L F(hkl)^2 Re(F) Im(F)";
845 os <<
" Theta 1/2d"<<endl;
846 os << FormatVertVectorHKLFloats<REAL>
847 (
mH,mK,mL,
mFhklCalcSq,
mFhklCalcReal,mFhklCalcImag,theta,
mSinThetaLambda,12,4,
mNbReflUsed);
848 VFN_DEBUG_EXIT(
"ScatteringData::PrintFhklCalc()",5)
853 VFN_DEBUG_ENTRY(
"ScatteringData::PrintFhklCalcDetail()",5)
855 CrystVector_REAL theta;
858 vector<const CrystVector_REAL *> v;
866 v.push_back(&mFhklCalcImag);
867 os <<
" Number of reflections:"<<
mNbRefl<<endl;
868 os <<
" H K L 1/2d Theta F(hkl)^2";
869 os <<
" Re(F) Im(F) ";
870 vector<CrystVector_REAL> sf;
873 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
878 cout<<pos->first->GetName()<<
":"<<pos->first->GetForwardScatteringFactor(RAD_XRAY)<<endl;
882 sf[2*i+1] = mvImagGeomSF[pos->first];
885 v.push_back(&(sf[2*i]));
886 v.push_back(&(sf[2*i+1]));
893 os << FormatVertVectorHKLFloats<REAL>(v,12,4,
mNbReflUsed);
894 VFN_DEBUG_EXIT(
"ScatteringData::PrintFhklCalcDetail()",5)
898 const bool enableRestraints)
938 VFN_DEBUG_ENTRY(
"ScatteringData::PrepareHKLarrays()"<<
mNbRefl<<
" reflections",5)
960 bool noSpgChange=
false;
986 VFN_DEBUG_EXIT(
"ScatteringData::PrepareHKLarrays()"<<
mNbRefl<<
" reflections",5)
994 VFN_DEBUG_MESSAGE(
"ScatteringData::GetNbReflBelowMaxSinThetaOvLambda()",4)
1020 TAU_PROFILE(
"ScatteringData::SortReflectionBySinThetaOverLambda()",
"void ()",TAU_DEFAULT);
1021 VFN_DEBUG_ENTRY(
"ScatteringData::SortReflectionBySinThetaOverLambda()",5)
1023 CrystVector_long sortedSubs;
1025 CrystVector_long oldH,oldK,oldL,oldMult;
1034 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 1",2)
1044 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 2",2)
1047 subs=sortedSubs(i+shift);
1054 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 3",2)
1058 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 4",2)
1061 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 5"<<maxSTOL,2)
1063 VFN_DEBUG_MESSAGE(
" "<<
mIntH(maxSubs)<<
" "<< mIntK(maxSubs)<<
" "<< mIntL(maxSubs)<<
" "<<
mSinThetaLambda(maxSubs),1)
1066 VFN_DEBUG_MESSAGE(
" "<<
mIntH(maxSubs)<<
" "<< mIntK(maxSubs)<<
" "<< mIntL(maxSubs)<<
" "<<
mSinThetaLambda(maxSubs),1)
1075 VFN_DEBUG_EXIT(
"ScatteringData::SortReflectionBySinThetaOverLambda():"<<
mNbRefl<<
" reflections",5)
1080 mK.resizeAndPreserve(
mNbRefl);
1081 mL.resizeAndPreserve(
mNbRefl);
1083 sortedSubs.resizeAndPreserve(
mNbRefl);
1087 VFN_DEBUG_EXIT(
"ScatteringData::SortReflectionBySinThetaOverLambda():"<<
mNbRefl<<
" reflections",5)
1093 TAU_PROFILE(
"ScatteringData::EliminateExtinctReflections()",
"void ()",TAU_DEFAULT);
1094 VFN_DEBUG_ENTRY(
"ScatteringData::EliminateExtinctReflections()",7)
1097 CrystVector_long subscriptKeptRefl(
mNbRefl);
1098 subscriptKeptRefl=0;
1101 if( this->
GetCrystal().GetSpaceGroup().IsReflSystematicAbsent(
mH(j),mK(j),mL(j))==
false )
1102 subscriptKeptRefl(nbKeptRefl++)=j;
1104 VFN_DEBUG_MESSAGE(
"ScatteringData::EliminateExtinctReflections():4",5)
1108 CrystVector_long oldH,oldK,oldL;
1109 CrystVector_int oldMulti;
1123 subs=subscriptKeptRefl(i);
1131 VFN_DEBUG_EXIT(
"ScatteringData::EliminateExtinctReflections():End",7)
1132 return subscriptKeptRefl;
1139 Cannot compute sin(theta)/lambda : there is no crystal affected to this \
1140 ScatteringData object yet.");
1143 Cannot compute sin(theta)/lambda : there are no reflections !");
1150 VFN_DEBUG_ENTRY(
"ScatteringData::CalcSinThetaLambda()",3)
1151 TAU_PROFILE(
"ScatteringData::CalcSinThetaLambda()",
"void (bool)",TAU_DEFAULT);
1154 const CrystMatrix_REAL bMatrix= this->
GetBMatrix();
1160 mX(i)=bMatrix(0,0)*
mH(i)+bMatrix(0,1)*mK(i)+bMatrix(0,2)*mL(i);
1161 mY(i)=bMatrix(1,0)*
mH(i)+bMatrix(1,1)*mK(i)+bMatrix(1,2)*mL(i);
1162 mZ(i)=bMatrix(2,0)*
mH(i)+bMatrix(2,1)*mK(i)+bMatrix(2,2)*mL(i);
1181 const REAL h=
mH(i),k=mK(i),l=mL(i);
1182 mSinThetaLambda(i)=0.5*sqrt((h*h/(a*a)*sa*sa+k*k/(b*b)*sb*sb+l*l/(c*c)*sg*sg+2*k*l/(b*c)*(cb*cg-ca)+2*l*h/(c*a)*(cg*ca-cb)+2*h*k/(a*b)*(ca*cb-cg))/(1-ca*ca-cb*cb-cg*cg+2*ca*cb*cg));
1187 if(this->
GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1219 cout <<
"Wavelength not given in ScatteringData::CalcSinThetaLambda() !" <<endl;
1226 VFN_DEBUG_EXIT(
"ScatteringData::CalcSinThetaLambda()",3)
1231 const CrystMatrix_REAL bMatrix= this->
GetBMatrix();
1232 const REAL x=bMatrix(0,0)*h+bMatrix(0,1)*k+bMatrix(0,2)*l;
1233 const REAL y=bMatrix(1,0)*h+bMatrix(1,1)*k+bMatrix(1,2)*l;
1234 const REAL z=bMatrix(2,0)*h+bMatrix(2,1)*k+bMatrix(2,2)*l;
1235 return sqrt(x*x+y*y+z*z)/2;
1251 TAU_PROFILE(
"ScatteringData::CalcScattFactor()",
"void (bool)",TAU_DEFAULT);
1252 VFN_DEBUG_ENTRY(
"ScatteringData::CalcScattFactor()",4)
1261 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) f0+f'"
1266 VFN_DEBUG_EXIT(
"ScatteringData::CalcScattFactor()",4)
1277 TAU_PROFILE(
"ScatteringData::CalcTemperatureFactor()",
"void (bool)",TAU_DEFAULT);
1278 VFN_DEBUG_ENTRY(
"ScatteringData::CalcTemperatureFactor()",4)
1284 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) DebyeWaller"<<endl
1289 VFN_DEBUG_EXIT(
"ScatteringData::CalcTemperatureFactor()",4)
1296 VFN_DEBUG_ENTRY(
"ScatteringData::CalcResonantScattFactor()",4)
1297 TAU_PROFILE(
"ScatteringData::CalcResonantScattFactor()",
"void (bool)",TAU_DEFAULT);
1303 VFN_DEBUG_EXIT(
"ScatteringData::CalcResonantScattFactor()->Lambda=0. fprime=fsecond=0",4)
1316 VFN_DEBUG_EXIT(
"ScatteringData::CalcResonantScattFactor()",4)
1327 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcGlobalTemperatureFactor()",2)
1328 TAU_PROFILE(
"ScatteringData::CalcGlobalTemperatureFactor()",
"void ()",TAU_DEFAULT);
1372 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcStructFactor():Fhkl Recalc ?"<<endl
1377 <<
"mClockStructFactor<mClockLuzzatiFactor" <<(
bool)(
mClockStructFactor<mClockLuzzatiFactor)<<endl
1385 VFN_DEBUG_ENTRY(
"ScatteringData::CalcStructFactor()",3)
1386 TAU_PROFILE(
"ScatteringData::CalcStructFactor()",
"void ()",TAU_DEFAULT);
1390 mFhklCalcImag.resize(nbRefl);
1394 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();
1398 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcStructFactor():Fhkl Recalc, "<<pScattPow->
GetName(),2)
1399 const REAL * RESTRICT pGeomR=
mvRealGeomSF[pScattPow].data();
1400 const REAL * RESTRICT pGeomI=mvImagGeomSF[pScattPow].data();
1405 REAL * RESTRICT pImag=mFhklCalcImag.data();
1407 VFN_DEBUG_MESSAGE(
"->mvRealGeomSF[i] "
1409 VFN_DEBUG_MESSAGE(
"->mvImagGeomSF[i] "
1410 <<mvImagGeomSF[pScattPow].numElements()<<
"elements",2)
1411 VFN_DEBUG_MESSAGE(
"->mvScatteringFactor[i]"
1413 VFN_DEBUG_MESSAGE(
"->mvTemperatureFactor[i]"
1415 VFN_DEBUG_MESSAGE(
"->mFhklCalcReal "<<
mFhklCalcReal.numElements()<<
"elements",2)
1416 VFN_DEBUG_MESSAGE(
"->mFhklCalcImag "<<mFhklCalcImag.numElements()<<
"elements",2)
1417 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) Re(F) Im(F) scatt Temp->"<<pScattPow->
GetName(),1)
1421 mvImagGeomSF[pScattPow],
1430 const REAL fsecond=mvFsecond[pScattPow];
1431 VFN_DEBUG_MESSAGE(
"->fsecond= "<<fsecond,10)
1434 VFN_DEBUG_MESSAGE(
"-->"<<j<<
" "<<*pReal<<
" "<<*pImag<<
" "<<*pGeomR<<
" "<<*pGeomI<<
" "<<*pScatt<<
" "<<*pTemp,1)
1435 *pReal++ += (*pGeomR * *pScatt - *pGeomI * fsecond)* *pTemp * *pLuzzati;
1436 *pImag++ += (*pGeomI++ * *pScatt++ + *pGeomR++ * fsecond)* *pTemp++ * *pLuzzati++;
1443 *pReal++ += *pGeomR++ * *pTemp * *pScatt * *pLuzzati;
1444 *pImag++ += *pGeomI++ * *pTemp++ * *pScatt++ * *pLuzzati++;
1448 <<
",f\"="<<mvFsecond[pScattPow]<<endl<<
1451 mvImagGeomSF[pScattPow],
1463 const REAL fsecond=mvFsecond[pScattPow];
1464 VFN_DEBUG_MESSAGE(
"->fsecond= "<<fsecond,2)
1467 *pReal += (*pGeomR * *pScatt - *pGeomI * fsecond)* *pTemp;
1468 *pImag += (*pGeomI * *pScatt + *pGeomR * fsecond)* *pTemp;
1469 VFN_DEBUG_MESSAGE(
"-->"<<j<<
" "<<*pReal<<
" "<<*pImag<<
" "<<*pGeomR<<
" "<<*pGeomI<<
" "<<*pScatt<<
" "<<*pTemp,1)
1470 pGeomR++;pGeomI++;pTemp++;pScatt++;pReal++;pImag++;
1477 *pReal++ += *pGeomR++ * *pTemp * *pScatt;
1478 *pImag++ += *pGeomI++ * *pTemp++ * *pScatt++;
1483 mvImagGeomSF[pScattPow],
1497 REAL *pImag=mFhklCalcImag.data();
1502 *pImag++ *= *pTemp++;
1508 VFN_DEBUG_EXIT(
"ScatteringData::CalcStructFactor()",3)
1511 void ScatteringData::CalcStructFactor_FullDeriv(std::set<RefinablePar *> &vPar)
1513 TAU_PROFILE(
"ScatteringData::CalcStructFactor_FullDeriv()",
"void ()",TAU_DEFAULT);
1516 this->CalcGeomStructFactor_FullDeriv(vPar);
1519 mFhklCalcReal_FullDeriv.clear();
1520 mFhklCalcImag_FullDeriv.clear();
1522 mFhklCalcImag_FullDeriv[0]=mFhklCalcImag;
1523 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
1525 if(*par==0)
continue;
1526 if((*par)->GetType()->IsDescendantFromOrSameAs(gpRefParTypeScatt)==
false)
1529 mFhklCalcReal_FullDeriv[*par].resize(0);
1530 mFhklCalcImag_FullDeriv[*par].resize(0);
1533 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();
1536 const ScatteringPower* pScattPow=pos->first;
1537 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
1541 if(mFhklCalcReal_FullDeriv[*par].size()==0)
1543 mFhklCalcReal_FullDeriv[*par].resize(
mNbRefl);
1544 mFhklCalcImag_FullDeriv[*par].resize(
mNbRefl);
1545 mFhklCalcReal_FullDeriv[*par]=0;
1546 mFhklCalcImag_FullDeriv[*par]=0;
1548 const REAL * RESTRICT pGeomRd=mvRealGeomSF_FullDeriv[*par][pScattPow].data();
1549 const REAL * RESTRICT pGeomId=mvImagGeomSF_FullDeriv[*par][pScattPow].data();
1553 REAL * RESTRICT pReal=mFhklCalcReal_FullDeriv[*par].data();
1554 REAL * RESTRICT pImag=mFhklCalcImag_FullDeriv[*par].data();
1560 const REAL fsecond=mvFsecond[pScattPow];
1563 *pReal++ += (*pGeomRd * *pScatt - *pGeomId * fsecond)* *pTemp * *pLuzzati;
1564 *pImag++ += (*pGeomId++ * *pScatt++ + *pGeomRd++ * fsecond)* *pTemp++ * *pLuzzati++;
1571 *pReal++ += *pGeomRd++ * *pTemp * *pScatt * *pLuzzati;
1572 *pImag++ += *pGeomId++ * *pTemp++ * *pScatt++ * *pLuzzati++;
1580 const REAL fsecond=mvFsecond[pScattPow];
1583 *pReal += (*pGeomRd * *pScatt - *pGeomId * fsecond)* *pTemp;
1584 *pImag += (*pGeomId * *pScatt + *pGeomRd * fsecond)* *pTemp;
1585 pGeomRd++;pGeomId++;pTemp++;pScatt++;pReal++;pImag++;
1592 *pReal++ += *pGeomRd++ * *pTemp * *pScatt;
1593 *pImag++ += *pGeomId++ * *pTemp++ * *pScatt++;
1602 &&(mFhklCalcReal_FullDeriv[*par].size()>0)
1603 &&(mFhklCalcImag_FullDeriv[*par].size()>0))
1605 REAL * RESTRICT pReal=mFhklCalcReal_FullDeriv[*par].data();
1606 REAL * RESTRICT pImag=mFhklCalcImag_FullDeriv[*par].data();
1611 *pImag++ *= *pTemp++;
1617 std::vector<const CrystVector_REAL*> v;
1621 std::map<RefinablePar*, CrystVector_REAL> oldDerivR,oldDerivI;
1622 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
1624 const REAL step=(*par)->GetDerivStep();
1625 (*par)->Mutate(step);
1628 oldDerivI[*par]=mFhklCalcImag;
1629 (*par)->Mutate(-2*step);
1632 oldDerivR[*par]/=2*step;
1633 oldDerivI[*par]-=mFhklCalcImag;
1634 oldDerivI[*par]/=2*step;
1635 (*par)->Mutate(step);
1637 v.push_back(&(mFhklCalcReal_FullDeriv[*par]));
1638 v.push_back(&(oldDerivR[*par]));
1639 v.push_back(&(mFhklCalcImag_FullDeriv[*par]));
1640 v.push_back(&(oldDerivI[*par]));
1641 if(v.size()>14)
break;
1643 cout<<
"############################ Fhkl Deriv Real, Imag ##############################"
1644 <<endl<<FormatVertVectorHKLFloats<REAL>(v,14,4,20)
1645 <<
"############################ END Fhkl Deriv Real, Imag ##############################"<<endl;
1660 TAU_PROFILE(
"ScatteringData::GeomStructFactor()",
"void (Vx,Vy,Vz,data,M,M,bool)",TAU_DEFAULT);
1661 VFN_DEBUG_ENTRY(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz,...)",3)
1663 VFN_DEBUG_MESSAGE(
"-->Number of translation vectors:"
1664 <<this->
GetCrystal().GetSpaceGroup().GetNbTranslationVectors()-1,2)
1665 VFN_DEBUG_MESSAGE(
"-->Has an inversion Center:"
1666 <<this->
GetCrystal().GetSpaceGroup().HasInversionCenter(),2)
1667 VFN_DEBUG_MESSAGE(
"-->Number of symetry operations (w/o transl&inv cent.):"\
1668 <<this->
GetCrystal().GetSpaceGroup().GetNbSymmetrics(
true,
true),2)
1669 VFN_DEBUG_MESSAGE(
"-->Number of Scattering Components :"
1670 <<this->
GetCrystal().GetScatteringComponentList().GetNbComponent(),2)
1671 VFN_DEBUG_MESSAGE(
"-->Number of reflections:"
1672 <<this->
GetNbRefl()<<
" (actually used:"<<mNbReflUsed<<
")",2)
1674 static long counter=0;
1675 VFN_DEBUG_MESSAGE(
"-->Number of GeomStructFactor calculations so far:"<<counter++,3)
1698 CrystMatrix_REAL allCoords(nbSymmetrics,3);
1700 #ifndef HAVE_SSE_MATHFUN
1702 CrystVector_long intVect(nbRefl);
1705 map<const ScatteringPower*,bool> vUsed;
1707 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();pos!=
mvRealGeomSF.end();++pos)
1708 vUsed[pos->first]=
false;
1714 else vUsed[pow]=
false;
1716 for(
long i=0;i<nbComp;i++)
1717 vUsed[(*pScattCompList)(i).mpScattPow]=
true;
1719 for(map<const ScatteringPower*,bool>::const_iterator pos=vUsed.begin();pos!=vUsed.end();++pos)
1726 mvImagGeomSF[pos->first]=0;
1731 map<const ScatteringPower*,CrystVector_REAL>::iterator
1734 poubelle=mvImagGeomSF.find(pos->first);
1735 if(poubelle!=mvImagGeomSF.end()) mvImagGeomSF.erase(poubelle);
1741 for(
long i=0;i<nbComp;i++)
1743 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(),comp"<<i,3)
1744 const REAL x=(*pScattCompList)(i).
mX;
1745 const REAL y=(*pScattCompList)(i).mY;
1746 const REAL z=(*pScattCompList)(i).mZ;
1748 const REAL popu= (*pScattCompList)(i).mOccupancy
1749 *(*pScattCompList)(i).mDynPopCorr
1755 const REAL STBF=2.*pSpg->
GetCCTbxSpg().inv_t().den();
1756 for(
int j=0;j<nbSymmetrics;j++)
1760 allCoords(j,0) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[0])/STBF;
1761 allCoords(j,1) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[1])/STBF;
1762 allCoords(j,2) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[2])/STBF;
1765 for(
int j=0;j<nbSymmetrics;j++)
1767 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(),comp #"<<i<<
", sym #"<<j,3)
1769 #ifndef HAVE_SSE_MATHFUN
1773 REAL * RESTRICT iisf=mvImagGeomSF[pScattPow].data();
1775 const long intX=(long)(allCoords(j,0)*sLibCrystNbTabulSine);
1776 const long intY=(long)(allCoords(j,1)*sLibCrystNbTabulSine);
1777 const long intZ=(long)(allCoords(j,2)*sLibCrystNbTabulSine);
1779 const long * RESTRICT intH=
mIntH.data();
1780 const long * RESTRICT intK=mIntK.data();
1781 const long * RESTRICT intL=mIntL.data();
1783 long * RESTRICT tmpInt=intVect.data();
1791 *tmpInt++ = (*intH++ * intX + *intK++ * intY + *intL++ *intZ)
1792 &sLibCrystNbTabulSineMASK;
1796 tmpInt=intVect.data();
1799 const REAL *pTmp=&spLibCrystTabulCosineSine[*tmpInt++ <<1];
1800 *rrsf++ += popu * *pTmp++;
1801 *iisf++ += popu * *pTmp;
1807 tmpInt=intVect.data();
1809 *rrsf++ += popu * spLibCrystTabulCosine[*tmpInt++];
1815 const REAL x=allCoords(j,0);
1816 const REAL y=allCoords(j,1);
1817 const REAL z=allCoords(j,2);
1818 const REAL *hh=
mH2Pi.data();
1819 const REAL *kk=mK2Pi.data();
1820 const REAL *ll=mL2Pi.data();
1822 #ifdef HAVE_SSE_MATHFUN
1828 static const float twopi=6.283185307179586f;
1829 sincos_ps(_mm_mul_ps(_mm_load1_ps(&twopi),_mm_set_ps(x,y,z,0)),cnxyz0,snxyz0);
1831 for(
long k=1;k<mMaxHKL;k++)
1833 cnxyz0[k]=_mm_sub_ps(_mm_mul_ps(cnxyz0[k-1],cnxyz0[0]),_mm_mul_ps(snxyz0[k-1],snxyz0[0]));
1834 snxyz0[k]=_mm_add_ps(_mm_mul_ps(snxyz0[k-1],cnxyz0[0]),_mm_mul_ps(cnxyz0[k-1],snxyz0[0]));
1837 for(
long k=0;k<4;++k){*(pcnxyz0+k)=1.0f;*(psnxyz0+k)=0.0f;}
1838 for(
long k=1;k<mMaxHKL;k++)
1840 _mm_store_ps(pcnxyz0+4*k,cnxyz0[k-1]);
1841 _mm_store_ps(psnxyz0+4*k,snxyz0[k-1]);
1847 REAL *isf=mvImagGeomSF[pScattPow].data();
1848 const long *h=
mIntH.data();
1849 const long *k=mIntK.data();
1850 const long *l=mIntL.data();
1852 const v4sf v4popu=_mm_set1_ps(popu);
1856 const v4sf ck=_mm_set_ps(pcnxyz0[(*(k))*4+1],pcnxyz0[(*(k+1))*4+1],pcnxyz0[(*(k+2))*4+1],pcnxyz0[(*(k+3))*4+1]);
1857 const v4sf cl=_mm_set_ps(pcnxyz0[(*(l))*4+1],pcnxyz0[(*(l+1))*4+1],pcnxyz0[(*(l+2))*4+1],pcnxyz0[(*(l+3))*4+1]);
1858 const v4sf sk=_mm_set_ps(psnxyz0[(*(k))*4+1],psnxyz0[(*(k+1))*4+1],psnxyz0[(*(k+2))*4+1],psnxyz0[(*(k+3))*4+1]);
1859 const v4sf sl=_mm_set_ps(psnxyz0[(*(l))*4+1],psnxyz0[(*(l+1))*4+1],psnxyz0[(*(l+2))*4+1],psnxyz0[(*(l+3))*4+1]);
1860 #define CH _mm_set_ps(pcnxyz0[*(h)*4],pcnxyz0[*(h+1)*4],pcnxyz0[*(h+2)*4],pcnxyz0[*(h+3)*4])
1861 #define SH _mm_set_ps(psnxyz0[*(h)*4],psnxyz0[*(h+1)*4],psnxyz0[*(h+2)*4],psnxyz0[*(h+3)*4])
1863 _mm_store_ps(rsf,_mm_mul_ps(v4popu,_mm_sub_ps(_mm_mul_ps(CH,_mm_sub_ps(_mm_mul_ps(ck,cl),_mm_mul_ps(sk,sl))),_mm_mul_ps(SH,_mm_add_ps(_mm_mul_ps(ck,sl),_mm_mul_ps(sk,cl))))));
1865 _mm_store_ps(isf,_mm_mul_ps(v4popu,_mm_add_ps(_mm_mul_ps(SH,_mm_sub_ps(_mm_mul_ps(ck,cl),_mm_mul_ps(sk,sl))),_mm_mul_ps(CH,_mm_add_ps(_mm_mul_ps(ck,sl),_mm_mul_ps(sk,cl))))));
1866 rsf+=4;isf+=4;h+=4;k+=4,l+=4;
1870 const float ch=pcnxyz0[*h *4];
1871 const float sh=psnxyz0[*h++ *4];
1872 const float ck=pcnxyz0[*k *4+1];
1873 const float sk=psnxyz0[*k++ *4+1];
1874 const float cl=pcnxyz0[*l *4+2];
1875 const float sl=psnxyz0[*l++ *4+2];
1876 *rsf++ += popu*(ch*(ck*cl-sk*sl)-sh*(sk*cl+ck*sl));
1877 *isf++ += popu*(sh*(ck*cl-sk*sl)+ch*(sk*cl+ck*sl));
1883 const long *h=
mIntH.data();
1884 const long *k=mIntK.data();
1885 const long *l=mIntL.data();
1887 const v4sf v4popu=_mm_set1_ps(popu);
1891 const v4sf ck=_mm_set_ps(pcnxyz0[(*(k))*4+1],pcnxyz0[(*(k+1))*4+1],pcnxyz0[(*(k+2))*4+1],pcnxyz0[(*(k+3))*4+1]);
1892 const v4sf cl=_mm_set_ps(pcnxyz0[(*(l))*4+1],pcnxyz0[(*(l+1))*4+1],pcnxyz0[(*(l+2))*4+1],pcnxyz0[(*(l+3))*4+1]);
1893 const v4sf sk=_mm_set_ps(psnxyz0[(*(k))*4+1],psnxyz0[(*(k+1))*4+1],psnxyz0[(*(k+2))*4+1],psnxyz0[(*(k+3))*4+1]);
1894 const v4sf sl=_mm_set_ps(psnxyz0[(*(l))*4+1],psnxyz0[(*(l+1))*4+1],psnxyz0[(*(l+2))*4+1],psnxyz0[(*(l+3))*4+1]);
1895 #define CH _mm_set_ps(pcnxyz0[*(h)*4],pcnxyz0[*(h+1)*4],pcnxyz0[*(h+2)*4],pcnxyz0[*(h+3)*4])
1896 #define SH _mm_set_ps(psnxyz0[*(h)*4],psnxyz0[*(h+1)*4],psnxyz0[*(h+2)*4],psnxyz0[*(h+3)*4])
1898 _mm_store_ps(rsf,_mm_mul_ps(v4popu,_mm_sub_ps(_mm_mul_ps(CH,_mm_sub_ps(_mm_mul_ps(ck,cl),_mm_mul_ps(sk,sl))),_mm_mul_ps(SH,_mm_add_ps(_mm_mul_ps(ck,sl),_mm_mul_ps(sk,cl))))));
1899 rsf+=4;h+=4;k+=4,l+=4;
1903 const float ch=pcnxyz0[*h *4];
1904 const float sh=psnxyz0[*h++ *4];
1905 const float ck=pcnxyz0[*k *4+1];
1906 const float sk=psnxyz0[*k++ *4+1];
1907 const float cl=pcnxyz0[*l *4+2];
1908 const float sl=psnxyz0[*l++ *4+2];
1909 *rsf++ += popu*(ch*(ck*cl-sk*sl)-sh*(sk*cl+ck*sl));
1915 const v4sf v4x=_mm_load1_ps(&x);
1916 const v4sf v4y=_mm_load1_ps(&y);
1917 const v4sf v4z=_mm_load1_ps(&z);
1918 const v4sf v4popu=_mm_load1_ps(&popu);
1922 REAL *isf=mvImagGeomSF[pScattPow].data();
1931 sincos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_loadu_ps(hh),v4x),
1932 _mm_mul_ps(_mm_loadu_ps(kk),v4y)
1934 _mm_mul_ps(_mm_loadu_ps(ll),v4z)
1936 _mm_storeu_ps(rsf,_mm_add_ps(_mm_mul_ps(v4cos,v4popu),_mm_loadu_ps(rsf)));
1937 _mm_storeu_ps(isf,_mm_add_ps(_mm_mul_ps(v4sin,v4popu),_mm_loadu_ps(isf)));
1939 hh+=4;kk+=4;ll+=4;rsf+=4;isf+=4;
1943 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
1944 *rsf++ += popu * cos(tmp);
1945 *isf++ += popu * sin(tmp);
1958 const v4sf v4cos=cos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_loadu_ps(hh),v4x),
1959 _mm_mul_ps(_mm_loadu_ps(kk),v4y)
1961 _mm_mul_ps(_mm_loadu_ps(ll),v4z)));
1962 _mm_storeu_ps(rsf,_mm_add_ps(_mm_loadu_ps(rsf),_mm_mul_ps(v4cos,v4popu)));
1963 hh+=4;kk+=4;ll+=4;rsf+=4;
1967 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
1968 *rsf++ += popu * cos(tmp);
1973 REAL *tmp=tmpVect.data();
1974 for(
int jj=0;jj<
mNbReflUsed;jj++) *tmp++ = *hh++ * x + *kk++ * y + *ll++ *z;
1979 for(
int jj=0;jj<
mNbReflUsed;jj++) *sf++ += popu * cos(*tmp++);
1983 sf=mvImagGeomSF[pScattPow].data();
1985 for(
int jj=0;jj<
mNbReflUsed;jj++) *sf++ += popu * sin(*tmp++);
1991 if(nbTranslationVectors > 1)
1996 REAL * RESTRICT p1=tmpVect.data();
1997 const REAL * RESTRICT hh=
mH2Pi.data();
1998 const REAL * RESTRICT kk=mK2Pi.data();
1999 const REAL * RESTRICT ll=mL2Pi.data();
2000 for(
long j=
mNbReflUsed;j>0;j--) *p1++ += 2*cos((*hh++ - *kk++ - *ll++)/3.);
2004 for(
int j=1;j<nbTranslationVectors;j++)
2006 const REAL x=(*pTransVect)[j].tr[0];
2007 const REAL y=(*pTransVect)[j].tr[1];
2008 const REAL z=(*pTransVect)[j].tr[2];
2009 REAL *p1=tmpVect.data();
2010 const REAL *hh=
mH2Pi.data();
2011 const REAL *kk=mK2Pi.data();
2012 const REAL *ll=mL2Pi.data();
2013 for(
long j=
mNbReflUsed;j>0;j--) *p1++ += cos(*hh++ *x + *kk++ *y + *ll++ *z );
2016 for(map<const ScatteringPower*,CrystVector_REAL>::iterator
2018 pos->second *= tmpVect;
2021 for(map<const ScatteringPower*,CrystVector_REAL>::iterator
2022 pos=mvImagGeomSF.begin();pos!=mvImagGeomSF.end();++pos)
2023 pos->second *= tmpVect;
2030 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz):\
2031 Inversion Center not at the origin...",2)
2037 const REAL STBF=2*pSpg->
GetCCTbxSpg().inv_t().den();
2039 const REAL xc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[0])/STBF;
2040 const REAL yc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[1])/STBF;
2041 const REAL zc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[2])/STBF;
2042 #ifdef __LIBCRYST_VECTOR_USE_BLITZ__
2043 tmpVect =
mH2Pi() * xc + mK2PI() * yc + mL2PI() * zc;
2046 const REAL * RESTRICT hh=
mH2Pi.data();
2047 const REAL * RESTRICT kk=mK2Pi.data();
2048 const REAL * RESTRICT ll=mL2Pi.data();
2049 REAL * RESTRICT ttmpVect=tmpVect.data();
2051 *ttmpVect++ = *hh++ * xc + *kk++ * yc + *ll++ * zc;
2055 CrystVector_REAL cosTmpVect;
2056 CrystVector_REAL sinTmpVect;
2057 cosTmpVect=cos(tmpVect);
2058 sinTmpVect=sin(tmpVect);
2060 map<const ScatteringPower*,CrystVector_REAL>::iterator posi=mvImagGeomSF.begin();
2061 map<const ScatteringPower*,CrystVector_REAL>::iterator posr=
mvRealGeomSF.begin();
2062 for(;posi!=mvImagGeomSF.end();)
2064 posi->second = posr->second;
2065 posi->second *= sinTmpVect;
2066 posr->second *= cosTmpVect;
2074 VFN_DEBUG_EXIT(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz,...)",3)
2076 void ScatteringData::CalcGeomStructFactor_FullDeriv(std::set<RefinablePar*> &vPar)
2078 TAU_PROFILE(
"ScatteringData::CalcGeomStructFactor_FullDeriv()",
"void (..)",TAU_DEFAULT);
2079 TAU_PROFILE_TIMER(timer1,
"ScatteringData::CalcGeomStructFactor_FullDeriv:1-ScattCompList deriv",
"", TAU_FIELD);
2080 TAU_PROFILE_TIMER(timer2,
"ScatteringData::CalcGeomStructFactor_FullDeriv:2-Geom SF",
"", TAU_FIELD);
2092 CrystMatrix_REAL allCoords(nbSymmetrics,3);
2096 TAU_PROFILE_START(timer1);
2098 std::map<RefinablePar*,CrystVector_REAL> vdx,vdy,vdz,vdocc;
2099 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2101 if(*par==0)
continue;
2102 CrystVector_REAL *pdx =&(vdx[*par]);
2103 CrystVector_REAL *pdy =&(vdy[*par]);
2104 CrystVector_REAL *pdz =&(vdz[*par]);
2105 CrystVector_REAL *pdocc=&(vdocc[*par]);
2106 pdx->resize(nbComp);
2107 pdy->resize(nbComp);
2108 pdz->resize(nbComp);
2109 pdocc->resize(nbComp);
2111 const REAL p0=(*par)->GetValue();
2112 const REAL step=(*par)->GetDerivStep();
2113 (*par)->Mutate(step);
2115 REAL *ppdx =pdx->data();
2116 REAL *ppdy =pdy->data();
2117 REAL *ppdz =pdz->data();
2118 REAL *ppdocc=pdocc->data();
2119 for(
unsigned long i=0;i<nbComp;++i)
2121 *ppdx++ =(*pScattCompList)(i).
mX;
2122 *ppdy++ =(*pScattCompList)(i).mY;
2123 *ppdz++ =(*pScattCompList)(i).mZ;
2124 *ppdocc++=(*pScattCompList)(i).mOccupancy*(*pScattCompList)(i).mDynPopCorr;
2126 (*par)->Mutate(-2*step);
2131 ppdocc=pdocc->data();
2132 for(
unsigned long i=0;i<nbComp;++i)
2134 *ppdx -=(*pScattCompList)(i).
mX;
2136 *ppdy -=(*pScattCompList)(i).mY;
2138 *ppdz -=(*pScattCompList)(i).mZ;
2140 *ppdocc-=(*pScattCompList)(i).mOccupancy*(*pScattCompList)(i).mDynPopCorr;
2143 (*par)->SetValue(p0);
2144 if( (MaxAbs(vdx[*par])==0)&&(MaxAbs(vdy[*par])==0)&&(MaxAbs(vdz[*par])==0)&&(MaxAbs(vdocc[*par])==0))
2152 TAU_PROFILE_STOP(timer1);
2153 TAU_PROFILE_START(timer2);
2155 if(!hasinv) transMult=1;
2157 if(nbTranslationVectors > 1)
2161 REAL * RESTRICT p1=transMult.data();
2162 const REAL * RESTRICT hh=
mH2Pi.data();
2163 const REAL * RESTRICT kk=mK2Pi.data();
2164 const REAL * RESTRICT ll=mL2Pi.data();
2165 for(
long j=
mNbReflUsed;j>0;j--) *p1++ += 2*cos((*hh++ - *kk++ - *ll++)/3.);
2169 for(
int j=1;j<nbTranslationVectors;j++)
2171 const REAL x=(*pTransVect)[j].tr[0];
2172 const REAL y=(*pTransVect)[j].tr[1];
2173 const REAL z=(*pTransVect)[j].tr[2];
2174 REAL *p1=transMult.data();
2175 const REAL * RESTRICT hh=
mH2Pi.data();
2176 const REAL * RESTRICT kk=mK2Pi.data();
2177 const REAL * RESTRICT ll=mL2Pi.data();
2178 for(
long j=
mNbReflUsed;j>0;j--) *p1++ += cos(*hh++ *x + *kk++ *y + *ll++ *z );
2185 mvRealGeomSF_FullDeriv.clear();
2186 mvImagGeomSF_FullDeriv.clear();
2188 CrystMatrix_REAL allCoordsDeriv(nbSymmetrics,3);
2189 for(
unsigned long i=0;i<nbComp;i++)
2191 const REAL x0=(*pScattCompList)(i).
mX;
2192 const REAL y0=(*pScattCompList)(i).mY;
2193 const REAL z0=(*pScattCompList)(i).mZ;
2194 const ScatteringPower *pScattPow=(*pScattCompList)(i).mpScattPow;
2195 const REAL popu= (*pScattCompList)(i).mOccupancy
2196 *(*pScattCompList)(i).mDynPopCorr;
2198 for(
int j=0;j<nbSymmetrics;j++)
2200 const REAL x=allCoords(j,0);
2201 const REAL y=allCoords(j,1);
2202 const REAL z=allCoords(j,2);
2206 const REAL *hh=
mH2Pi.data();
2207 const REAL *kk=mK2Pi.data();
2208 const REAL *ll=mL2Pi.data();
2209 #ifdef HAVE_SSE_MATHFUN
2210 const v4sf v4x=_mm_load1_ps(&x);
2211 const v4sf v4y=_mm_load1_ps(&y);
2212 const v4sf v4z=_mm_load1_ps(&z);
2214 const v4sf v4popu=_mm_load1_ps(&popu); POSSIBLY_UNUSED(v4popu);
2223 sincos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_load_ps(hh),v4x),
2224 _mm_mul_ps(_mm_load_ps(kk),v4y)
2226 _mm_mul_ps(_mm_load_ps(ll),v4z)
2228 _mm_store_ps(pc,v4cos);
2229 _mm_store_ps(ps,v4sin);
2231 hh+=4;kk+=4;ll+=4;pc+=4;ps+=4;
2235 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
2242 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
2248 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2250 if((*par)==0)
continue;
2251 if(vdx[*par].size()==0)
continue;
2252 REAL dx =vdx[*par](i);
2253 REAL dy =vdy[*par](i);
2254 REAL dz =vdz[*par](i);
2255 const REAL dpopu=vdocc[*par](i);
2257 if((abs(dx)+abs(dy)+abs(dz)+abs(dpopu))==0)
continue;
2258 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
2260 mvRealGeomSF_FullDeriv[*par][pScattPow].resize(
mNbRefl);
2261 mvRealGeomSF_FullDeriv[*par][pScattPow]=0;
2263 if(mvImagGeomSF_FullDeriv[*par][pScattPow].size()==0)
2265 mvImagGeomSF_FullDeriv[*par][pScattPow].resize(
mNbRefl);
2266 mvImagGeomSF_FullDeriv[*par][pScattPow]=0;
2269 const REAL *hh=
mH2Pi.data();
2270 const REAL *kk=mK2Pi.data();
2271 const REAL *ll=mL2Pi.data();
2272 const REAL *pmult=transMult.data();
2273 REAL *rsf=mvRealGeomSF_FullDeriv[*par][pScattPow].data();
2274 REAL *isf=mvImagGeomSF_FullDeriv[*par][pScattPow].data();
2275 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcGeomStructFactor_FullDeriv()comp="<<i<<
", par="<<(*par)->GetName()<<
", rs="<<mvRealGeomSF_FullDeriv[*par][pScattPow].size(),1)
2276 const REAL *pc=c.data();
2277 const REAL *ps=s.data();
2284 *rsf += (dpopu * *pc - popu* *ps * (*hh * dx + *kk * dy + *ll * dz))* *pmult;
2285 if(!hasinv) *isf += (dpopu * *ps + popu* *pc * (*hh * dx + *kk * dy + *ll * dz))* *pmult;
2289 ps++;pc++;hh++;kk++;ll++;pmult++;rsf++;isf++;
2302 TAU_PROFILE_STOP(timer2);
2304 std::vector<const CrystVector_REAL*> v;
2308 std::map< std::pair<const ScatteringPower *,RefinablePar*>,CrystVector_REAL> mr,mi;
2311 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2313 for(std::map<const ScatteringPower*,CrystVector_REAL>::iterator pos=
mvRealGeomSF.begin();pos!=
mvRealGeomSF.end();++pos)
2315 const ScatteringPower *pScattPow=pos->first;
2316 cout<<(*par)->GetName()<<
","<<pScattPow->GetName();
2317 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
2319 cout<<
" => skipped (deriv==0)"<<endl;
2323 const REAL step=(*par)->GetDerivStep();
2324 (*par)->Mutate(step);
2327 mi[make_pair(pScattPow,*par)]=mvImagGeomSF[pScattPow];
2328 (*par)->Mutate(-2*step);
2330 mr[make_pair(pScattPow,*par)]-=
mvRealGeomSF[pScattPow];
2331 mr[make_pair(pScattPow,*par)]/=step*2;
2332 mi[make_pair(pScattPow,*par)]-=mvImagGeomSF[pScattPow];
2333 mi[make_pair(pScattPow,*par)]/=step*2;
2334 (*par)->Mutate(step);
2336 v.push_back(&(mvRealGeomSF_FullDeriv[*par][pScattPow]));
2337 v.push_back(&(mr[make_pair(pScattPow,*par)]));
2340 v.push_back(&(mvImagGeomSF_FullDeriv[*par][pScattPow]));
2341 v.push_back(&(mi[make_pair(pScattPow,*par)]));
2343 if(v.size()>20)
break;
2345 if(v.size()>20)
break;
2347 cout<<
"############################ Geom Fhkl Deriv Real, Imag ##############################"
2348 <<endl<<FormatVertVectorHKLFloats<REAL>(v,11,4,20)
2349 <<
"############################ END GeomF hkl Deriv Real, Imag ##############################"<<endl;
2350 cout<<
"############################ X Y Z Occ ##############################"
2351 <<endl<<FormatVertVector<REAL>(vdx[*(vPar.begin())],vdy[*(vPar.begin())],vdz[*(vPar.begin())],vdocc[*(vPar.begin())],8,4,20)<<endl
2352 <<
"############################ END X Y Z Occ ##############################"<<endl;
2364 VFN_DEBUG_ENTRY(
"ScatteringData::CalcLuzzatiFactor",3)
2365 bool useLuzzati=
false;
2366 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
2369 if(pos->first->GetMaximumLikelihoodPositionError()!=0)
2378 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): not needed, no positionnal errors",3)
2396 .GetMaximumLikelihoodParClock()>mClockLuzzatiFactor)
2406 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): no recalc needed",3)
2409 TAU_PROFILE(
"ScatteringData::CalcLuzzatiFactor()",
"void ()",TAU_DEFAULT);
2425 for(
long j=0;j<
mNbReflUsed;j++) {*fact++ = exp(b * *stol * *stol);stol++;}
2426 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcLuzzatiFactor():"<<pScattPow->
GetName()<<endl<<
2433 mClockLuzzatiFactor.
Click();
2434 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): no recalc needed",3)
2446 if( (mClockFhklCalcVariance>mClockLuzzatiFactor)
2450 bool hasGhostAtoms=
false;
2451 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
2454 if(pos->first->GetMaximumLikelihoodNbGhostAtom()!=0)
2466 VFN_DEBUG_ENTRY(
"ScatteringData::CalcStructFactVariance()",3)
2467 TAU_PROFILE(
"ScatteringData::CalcStructFactVariance()",
"void ()",TAU_DEFAULT);
2470 map<const ScatteringPower*,REAL> vComp;
2475 for(
long i=0;i<nbComp;i++)
2477 pComp=&((*pList)(i));
2480 for(
long i=0;i<nbComp;i++)
2482 pComp=&((*pList)(i));
2485 for(map<const ScatteringPower*,REAL>::iterator
2486 pos=vComp.begin();pos!=vComp.end();++pos)
2487 pos->second *= this->GetCrystal().GetSpaceGroup().GetNbSymmetrics();
2490 map<const ScatteringPower*,REAL> vGhost;
2494 for(
int i=0;i<nbScattPow;i++)
2498 vGhost[pow]=nb*mult;
2512 &&(vGhost[pScattPow]==0))
continue;
2526 const REAL nbghost=vGhost[pScattPow];
2529 *pVar++ += *pExp++ * *pScatt * *pScatt * nbghost;
2536 const REAL occ=vComp[pScattPow];
2537 const REAL nbghost=vGhost[pScattPow];
2540 *pVar++ += *pExp++ * *pScatt * *pScatt * ( occ*(1 - *pLuz * *pLuz) + nbghost);
2547 mClockFhklCalcVariance.
Click();
2548 VFN_DEBUG_EXIT(
"ScatteringData::CalcStructFactVariance()",3)
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
const RefParType * gpRefParTypeScattDataCorrIntPO_Direction
Parameter type for preferred orientation direction.
const RefParType * gpRefParTypeScattDataScale
Type for scattering data scale factors.
const RefParType * gpRefParTypeScattDataProfileWidth
Type for reflection profile width.
RadiationType
Type of radiation used.
const RefParType * gpRefParTypeScattDataCorrIntAbsorp
Parameter type for absorption correction.
WavelengthType
Incident beam characteristics : monochromatic, X-Ray tube with Alpha1 and alpha2, MAD (a few waveleng...
const RefParType * gpRefParTypeScattDataCorrPos
Parameter type for correction to peak positions.
const RefParType * gpRefParTypeScattDataProfile
Type for reflection profile.
const RefParType * gpRefParTypeScattDataCorrIntPO_Fraction
Parameter type for fraction of preferred orientation.
const RefParType * gpRefParTypeScattDataBackground
Parameter type for background intensity.
const RefParType * gpRefParTypeScattDataCorr
Generic type for scattering data correction parameter.
const RefParType * gpRefParTypeScattDataProfileType
Type for reflection profiles type (e.g. gaussian/lorentzian mix)
const RefParType * gpRefParTypeScattDataCorrInt_Ellipsoid
Parameter type for the ellipsoid coefficient.
const RefParType * gpRefParTypeScattDataCorrIntPO_Amplitude
Parameter type for the amplitude of preferred orientation.
const RefParType * gpRefParTypeScattDataCorrInt
Generic type for correction to calculated intensities.
const RefParType * gpRefParTypeScattDataProfileAsym
Type for reflection profile asymmetry.
const RefParType * gpRefParTypeScattData
Generic type for scattering data.
const RefParType * gpRefParTypeScattDataCorrIntPolar
Parameter type for polarization correction.
const RefParType * gpRefParTypeScattDataCorrIntExtinc
Parameter type for extinction correction.
Crystal class: Unit cell, spacegroup, scatterers.
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components.
const RefinableObjClock & GetClockScattererList() const
When was the list of scatterers last changed ?
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
const RefinableObjClock & GetClockScattCompList() const
Get the list of all scattering components.
const RefinableObjClock & GetMasterClockScatteringPower() const
Get the clock which reports all changes in ScatteringPowers.
Exception class for ObjCryst++ library.
Class to define the radiation (type, monochromaticity, wavelength(s)) of an experiment.
REAL mLinearPolarRate
Linear Polarization Rate (default:0, X-Ray tube unmonochromatized)
void Print() const
Print to screen/console the charcteristics of the radiation.
CrystVector_REAL mWavelength
Wavelength of the Experiment, in Angstroems.
string mXRayTubeName
Name of the X-Ray tube used, if relevant.
RefObjOpt mRadiationType
Neutron ? X-Ray ? (Electron: unimplemented)
REAL GetXRayTubeAlpha2Alpha1Ratio() const
Get the Kalpha2/Kalpha1 ratio.
WavelengthType GetWavelengthType() const
Get the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
REAL mXRayTubeDeltaLambda
Absolute difference between alpha1 and alpha2, in angstroems.
const CrystVector_REAL & GetWavelength() const
Get the wavelength(s) in Angstroems.
REAL mXRayTubeAlpha2Alpha1Ratio
Ratio alpha2/alpha1 (should be 0.5)
REAL GetXRayTubeDeltaLambda() const
Get the wavelength difference for Alpha1 and Alpha2.
const RefinableObjClock & GetClockWavelength() const
Last time the wavelength has been changed.
void SetRadiationType(const RadiationType)
Set the radiation type (X-Rays, Neutron)
RefObjOpt mWavelengthType
monochromatic ? Alpha1 & Alpha2 ? Multi-Wavelength ?
const RefinableObjClock & GetClockRadiation() const
Last time the nature (X-Rays/Neutron, number of wavelengths)radiation has been changed.
Radiation()
Default constructor.
void SetWavelength(const REAL)
Set the (monochromatic) wavelength of the beam.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
void SetWavelengthType(const WavelengthType &type)
Set the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
RadiationType GetRadiationType() const
Get the radiation type (X-Rays, Neutron)
Class to compute structure factors for a set of reflections and a Crystal.
long mNbReflUsed
Number of reflections which are below the max.
RefinableObjClock mClockNbReflUsed
Clock recording the last time the number of reflections used has increased.
virtual void SetHKL(const CrystVector_REAL &h, const CrystVector_REAL &k, const CrystVector_REAL &l)
input H,K,L
CrystVector_REAL mSinThetaLambda
for the crystal and the reflections in ReciprSpace
const RefinableObjClock & GetClockNbReflBelowMaxSinThetaOvLambda() const
Clock the last time the number of reflections used was changed.
map< const ScatteringPower *, CrystVector_REAL > mvScatteringFactor
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
map< const ScatteringPower *, REAL > mvFprime
Anomalous X-Ray scattering term f' and f" are stored here for each ScatteringPower We store here only...
virtual const Radiation & GetRadiation() const =0
Get the radiation object for this data.
const map< const ScatteringPower *, CrystVector_REAL > & GetScatteringFactor() const
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
REAL mGlobalBiso
Global Biso, affecting the overall structure factor for all reflections (but not the structure factor...
RefinableObjClock mClockStructFactor
Clock for the structure factor.
virtual void PrintFhklCalc(ostream &os=cout) const
Print H, K, L F^2 Re(F) Im(F) theta sin(theta)/lambda for all reflections.
void CalcGeomStructFactor() const
Compute the 'Geometrical Structure Factor' for each ScatteringPower of the Crystal.
RefinableObjClock mClockFhklObsSq
Last time observed squared structure factors were altered.
RefinableObjClock mClockGlobalTemperatureFact
last time the global temperature factor was computed
const CrystVector_REAL & GetH2Pi() const
Return the 1D array of H coordinates for all reflections, multiplied by 2*pi.
RefinableObjClock mClockTheta
Clock the last time theta was computed.
const CrystVector_REAL & GetSinThetaOverLambda() const
Return an array with for all reflections.
const CrystVector_REAL & GetK() const
Return the 1D array of K coordinates for all reflections.
void CalcScattFactor() const
REAL GetMaxSinThetaOvLambda() const
Get the maximum value for sin(theta)/lambda.
bool mIgnoreImagScattFact
Ignore imaginary part of scattering factor.
virtual void GenHKLFullSpace(const REAL maxTheta, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value.
CrystVector_REAL GetWavelength() const
wavelength of the experiment (in Angstroems)
void CalcLuzzatiFactor() const
Calculate the Luzzati factor associated to each ScatteringPower and each reflection,...
RefinableObjClock mClockThermicFact
Clock the last time temperature factors were computed.
bool IsIgnoringImagScattFact() const
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
virtual void PrepareHKLarrays() const
const CrystVector_REAL & GetL2Pi() const
Return the 1D array of L coordinates for all reflections, multiplied by 2*pi.
const CrystVector_REAL & GetTheta() const
Return an array with theta values for all reflections.
const CrystVector_REAL & GetReflZ() const
Return the 1D array of orthonormal z coordinates for all reflections (recipr. space)
virtual void SetMaxSinThetaOvLambda(const REAL max)
Set the maximum value for sin(theta)/lambda.
virtual void SetCrystal(Crystal &crystal)
Set the crystal for this experiment.
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
CrystVector_REAL mFhklCalcSq
F(HKL)^2 calc for each reflection.
void CalcStructFactVariance() const
Calculate the variance associated to the calculated structure factor.
const CrystVector_REAL & GetReflX() const
Return the 1D array of orthonormal x coordinates for all reflections (recipr. space)
virtual void GenHKLFullSpace2(const REAL maxsithsl, const bool unique=false)
Generate a list of h,k,l to describe a full reciprocal space, up to a given maximum theta value.
RefinableObjClock mClockStructFactorSq
Clock for the square modulus of the structure factor.
map< const ScatteringPower *, CrystVector_REAL > mvTemperatureFactor
Thermic factors for each ScatteringPower, as vectors with NbRefl elements.
const CrystVector_REAL & GetH() const
Return the 1D array of H coordinates for all reflections.
CrystVector_REAL mFhklObsSq
Observed squared structure factors (zero-sized if none)
const CrystVector_REAL & GetFhklCalcSq() const
Returns the Array of calculated |F(hkl)|^2 for all reflections.
void CalcGlobalTemperatureFactor() const
Compute the overall temperature factor affecting all reflections.
const CrystVector_REAL & GetFhklObsSq() const
Returns the vector of observed |F(hkl)|^2 for all reflections.
RadiationType GetRadiationType() const
Neutron or x-ray experiment ? Wavelength ?
bool mUseFastLessPreciseFunc
Use faster, but less precise, approximations for functions? (integer approximations to compute sin an...
virtual CrystVector_long SortReflectionBySinThetaOverLambda(const REAL maxSTOL=-1.) const
const RefinableObjClock & GetClockTheta() const
Clock the last time the sin(theta)/lambda and theta arrays were re-computed.
bool HasCrystal() const
Has a Crystal structure associated yet ?
CrystVector_int mExpectedIntensityFactor
Expected intensity factor for all reflections.
CrystVector_REAL mFhklCalcReal
real &imaginary parts of F(HKL)calc
CrystVector_REAL mFhklCalcVariance
The variance on all calculated structure factors, taking into account the positionnal errors and the ...
map< const ScatteringPower *, CrystVector_REAL > mvLuzzatiFactor
The Luzzati 'D' factor for each scattering power and each reflection.
Crystal * mpCrystal
Pointer to the crystal corresponding to this experiment.
RefinableObjClock mClockScattFactor
Clock the last time scattering factors were computed.
virtual void CalcResonantScattFactor() const
CrystVector_REAL mX
reflection coordinates in an orthonormal base
map< const ScatteringPower *, CrystVector_REAL > mvRealGeomSF
Geometrical Structure factor for each ScatteringPower, as vectors with NbRefl elements.
virtual void CalcSinThetaLambda() const
const CrystVector_REAL & GetL() const
Return the 1D array of L coordinates for all reflections.
RefinableObjClock mClockGlobalBiso
last time the global Biso factor was modified
void CalcStructFactor() const
Compute the overall structure factor (real and imaginary part).
long mNbRefl
Number of H,K,L reflections.
const CrystVector_REAL & GetFhklCalcImag() const
Access to imaginary part of F(hkl)calc.
virtual const CrystMatrix_REAL & GetBMatrix() const
Get access to the B matrix used to compute reflection positions.
CrystVector_REAL mH
H,K,L coordinates.
CrystVector_long mIntH
H,K,L integer coordinates.
CrystVector_long EliminateExtinctReflections()
REAL mMaxSinThetaOvLambda
Maximum sin(theta)/lambda for all calculations (10 by default).
void SetFhklObsSq(const CrystVector_REAL &obs)
Set the vector of observed |F(hkl)|^2 for all reflections.
virtual void PrintFhklCalcDetail(ostream &os=cout) const
Print H, K, L sin(theta)/lambda theta F^2 Re(F) Im(F) [Re(F) Im(F)]_i, where [Re(F) Im(F)]_i are the ...
RefinableObjClock mClockGeomStructFact
Clock the last time the geometrical structure factors were computed.
void SetIsIgnoringImagScattFact(const bool b)
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
const CrystVector_REAL & GetReflY() const
Return the 1D array of orthonormal y coordinates for all reflections (recipr. space)
CrystVector_REAL mTheta
theta for the crystal and the HKL in ReciprSpace (in radians)
long GetNbRefl() const
Return the number of reflections in this experiment.
virtual long GetNbReflBelowMaxSinThetaOvLambda() const
Recalc, and get the number of reflections which should be actually used, due to the maximuml sin(thet...
CrystVector_REAL mGlobalTemperatureFactor
Global Biso factor.
void CalcTemperatureFactor() const
const Crystal & GetCrystal() const
Const access to the data's crystal.
RefinableObjClock mClockScattFactorResonant
Clock the last time resonant scattering factors were computed.
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
const CrystVector_REAL & GetFhklCalcReal() const
Access to real part of F(hkl)calc.
CrystVector_REAL mH2Pi
H,K,L coordinates, multiplied by 2PI.
const CrystVector_REAL & GetK2Pi() const
Return the 1D array of K coordinates for all reflections, multiplied by 2*pi.
RefinableObjClock mClockHKL
Clock for the list of hkl.
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
CrystVector_int mMultiplicity
Multiplicity for each reflections (mostly for powder diffraction)
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal.
virtual CrystVector_REAL GetTemperatureFactor(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the temperature factor for all reflections of a given ScatteringData object.
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the real part of the resonant scattering factor.
REAL GetMaximumLikelihoodNbGhostAtom() const
Maximum Likelihood: get the number of ghost elements per asymmetric unit.
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the imaginary part of the resonant scattering factor.
REAL GetMaximumLikelihoodPositionError() const
Maximum Likelihood: get the estimated error (sigma) on the positions for this kind of element.
virtual CrystVector_REAL GetScatteringFactor(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the Scattering factor for all reflections of a given ScatteringData object.
A scattering position in a crystal, associated with the corresponding occupancy and a pointer to the ...
const ScatteringPower * mpScattPow
The ScatteringPower associated with this position.
REAL mDynPopCorr
Dynamical Population Correction.
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
long GetNbComponent() const
Number of components.
The crystallographic space group, and the cell choice.
int GetNbSymmetrics(const bool noCenter=false, const bool noTransl=false) const
Return the number of equivalent positions in the spacegroup, ie the multilicity of the general positi...
bool IsInversionCenterAtOrigin() const
Is the center of symmetry at the origin ?
unsigned int GetExpectedIntensityFactor(const REAL h, const REAL k, const REAL l) const
Get the "expected intensity factor" for a given reflection.
int GetSpaceGroupNumber() const
Id number of the spacegroup.
int GetNbTranslationVectors() const
Number of translation vectors (1 for 'P' cells, 2 for 'I', 4 for 'F',etc..)
bool HasInversionCenter() const
Is centrosymmetric ?
CrystMatrix_REAL GetAllSymmetrics(const REAL x, const REAL y, const REAL z, const bool noCenter=false, const bool noTransl=false, const bool noIdentical=false) const
Get all equivalent positions of a (xyz) position.
void GetSymmetric(unsigned int i, REAL &x, REAL &y, REAL &z, const bool noCenter=false, const bool noTransl=false, const bool derivative=false) const
Get all equivalent positions of a (xyz) position.
const RefinableObjClock & GetClockSpaceGroup() const
Get the SpaceGroup Clock (corresponding to the time of the initialization of the SpaceGroup)
const std::vector< SpaceGroup::TRx > & GetTranslationVectors() const
Return all Translation Vectors, as a 3 columns-array.
const cctbx::sgtbx::space_group & GetCCTbxSpg() const
Get the underlying cctbx Spacegroup object.
CrystVector_REAL GetLatticePar() const
Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians.
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
const CrystMatrix_REAL & GetBMatrix() const
Get the 'B' matrix (UnitCell::mBMatrix)for the UnitCell (orthogonalization matrix for the given latti...
const RefinableObjClock & GetClockLatticePar() const
last time the Lattice parameters were changed
class of refinable parameter types.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
void Reset()
Reset a Clock to 0, to force an update.
void AddChild(const RefinableObjClock &)
Add a 'child' clock.
void Click()
Record an event for this clock (generally, the 'time' an object has been modified,...
Generic class for parameters of refinable objects.
void SetIsUsed(const bool)
Is the parameter used (if not, it is simply irrelevant in the model) ?
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
void AddPar(const RefinablePar &newRefPar)
Add a refinable parameter.
bool IsBeingRefined() const
Is the object being refined ? (Can be refined by one algorithm at a time only.)
virtual void RegisterClient(RefinableObj &) const
Register a new object using this object.
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
virtual const string & GetName() const
Name of the object.
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
void AddOption(RefObjOpt *opt)
int mOptimizationDepth
Is the object being refined or optimized ? if mOptimizationDepth=0, no optimization is taking place.
virtual void DeRegisterClient(RefinableObj &) const
Deregister an object (which not any more) using this object.
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new,...
RefinableObjClock mClockMaster
Master clock, which is changed whenever the object has been altered.
void AddSubRefObj(RefinableObj &)
output a string with a fixed length (adding necessary space or removing excess characters) :
Output vectors as column arrays, with the first 3 columns printed as integers.