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();
194 Radiation::~Radiation()
199 const static string className=
"Radiation";
203 void Radiation::operator=(
const Radiation &old)
211 mClockWavelength.
Click();
240 mClockWavelength.
Click();
243 const REAL alpha2Alpha2ratio)
245 VFN_DEBUG_MESSAGE(
"Radiation::SetWavelength(tubeName,ratio):",5)
251 if(XRayTubeElementName.length() >=3)
254 if(XRayTubeElementName==
"CoA1")
265 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
266 <<
" not modifying wavelength !"<<endl;
273 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
274 <<
" not modifying wavelength !"<<endl;
282 REAL lambda1 = 0, lambda2 = 0;
283 if(XRayTubeElementName==
"Co")
292 cctbx::eltbx::wavelengths::characteristic ch(
mXRayTubeName+
"A1");
295 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
296 <<
" not modifying wavelength !"<<endl;
299 lambda1=ch.as_angstrom();
300 cctbx::eltbx::wavelengths::characteristic ch2(
mXRayTubeName+
"A2");
303 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
304 <<
" not modifying wavelength !"<<endl;
307 lambda2=ch2.as_angstrom();
311 cout <<
"WARNING: could not interpret X-Ray tube name:"<<XRayTubeElementName<<endl
312 <<
" not modifying wavelength !"<<endl;
319 mClockWavelength.
Click();
332 VFN_DEBUG_MESSAGE(
"Radiation::Print():"<<this->
GetName(),5)
333 cout <<
"Radiation:" <<
" " ;
337 case RAD_NEUTRON: cout<<
"Neutron,";
break;
338 case RAD_XRAY: cout<<
"X-Ray,";
break;
339 case RAD_ELECTRON: cout<<
"Electron,";
break;
342 cout <<
"Wavelength=" <<
" ";
345 case WAVELENGTH_MONOCHROMATIC: cout<<
"monochromatic:"<<
" "<<
mWavelength(0) <<endl;
break;
346 case WAVELENGTH_ALPHA12: cout <<
"tube:"<<
" "<<
mXRayTubeName<<
", Alpha1/Alpha2= "
348 case WAVELENGTH_MAD: cout<<
"mad"<<
" "<<endl;
break;
349 case WAVELENGTH_DAFS: cout<<
"dafs"<<
" "<<endl;
break;
350 case WAVELENGTH_LAUE: cout<<
"laue"<<
" "<<endl;
break;
351 case WAVELENGTH_TOF: cout<<
"Time Of Flight"<<
" "<<endl;
break;
359 void Radiation::InitOptions()
361 static string RadiationTypeName;
362 static string RadiationTypeChoices[3];
363 static string WavelengthTypeName;
364 static string WavelengthTypeChoices[3];
366 static bool needInitNames=
true;
367 if(
true==needInitNames)
369 RadiationTypeName=
"Radiation";
370 RadiationTypeChoices[0]=
"Neutron";
371 RadiationTypeChoices[1]=
"X-Ray";
372 RadiationTypeChoices[2]=
"Electron";
374 WavelengthTypeName=
"Spectrum";
375 WavelengthTypeChoices[0]=
"Monochromatic";
376 WavelengthTypeChoices[1]=
"X-Ray Tube";
377 WavelengthTypeChoices[2]=
"Time Of Flight";
390 RefinablePar tmp(
"Wavelength",
mWavelength.data(),0.05,20.,
391 gpRefParTypeRadiationWavelength,REFPAR_DERIV_STEP_ABSOLUTE,
392 true,
true,
true,
false,1.0);
393 tmp.SetDerivStep(1e-4);
394 tmp.AssignClock(mClockWavelength);
400 WXCrystObjBasic* Radiation::WXCreate(wxWindow* parent)
403 mpWXCrystObj=
new WXRadiation(parent,
this);
414 ScatteringData::ScatteringData():
416 mpCrystal(0),mGlobalBiso(0),mUseFastLessPreciseFunc(false),
417 mIgnoreImagScattFact(false),mMaxSinThetaOvLambda(10)
419 VFN_DEBUG_MESSAGE(
"ScatteringData::ScatteringData()",10)
421 RefinablePar tmp(
"Global Biso",&mGlobalBiso,-1.,1.,
422 gpRefParTypeScattPowTemperatureIso,REFPAR_DERIV_STEP_ABSOLUTE,
423 true,
true,
true,
false,1.0);
424 tmp.SetDerivStep(1e-4);
425 tmp.AssignClock(mClockGlobalBiso);
434 ScatteringData::ScatteringData(
const ScatteringData &old):
435 mNbRefl(old.mNbRefl),
436 mpCrystal(old.mpCrystal),mUseFastLessPreciseFunc(old.mUseFastLessPreciseFunc),
438 mClockHKL(old.mClockHKL),
439 mIgnoreImagScattFact(old.mIgnoreImagScattFact),
440 mMaxSinThetaOvLambda(old.mMaxSinThetaOvLambda)
442 VFN_DEBUG_MESSAGE(
"ScatteringData::ScatteringData(&old)",10)
443 mClockStructFactor.Reset();
445 mClockScattFactor.Reset();
446 mClockScattFactorResonant.Reset();
447 mClockThermicFact.Reset();
448 this->SetHKL(old.GetH(),old.GetK(),old.GetL());
449 VFN_DEBUG_MESSAGE("ScatteringData::ScatteringData(&old):End",5)
451 RefinablePar tmp(
"Global Biso",&mGlobalBiso,-1.,1.,
452 gpRefParTypeScattPowTemperatureIso,REFPAR_DERIV_STEP_ABSOLUTE,
453 true,
true,
true,
false,1.0);
454 tmp.SetDerivStep(1e-4);
455 tmp.AssignClock(mClockGlobalBiso);
464 ScatteringData::~ScatteringData()
466 VFN_DEBUG_MESSAGE(
"ScatteringData::~ScatteringData()",10)
470 const CrystVector_REAL &k,
471 const CrystVector_REAL &l)
473 VFN_DEBUG_ENTRY(
"ScatteringData::SetHKL(h,k,l)",5)
480 VFN_DEBUG_EXIT(
"ScatteringData::SetHKL(h,k,l):End",5)
486 VFN_DEBUG_ENTRY(
"ScatteringData::GenHKLFullSpace2()",5)
487 TAU_PROFILE(
"ScatteringData::GenHKLFullSpace2()",
"void (REAL,bool)",TAU_DEFAULT);
491 no crystal assigned yet to this ScatteringData object.");
499 cctbx::miller::index_generator igen(uc,
500 this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg().type(),
514 H.resizeAndPreserve(
mNbRefl+100);
515 K.resizeAndPreserve(
mNbRefl+100);
516 L.resizeAndPreserve(
mNbRefl+100);
519 cctbx::miller::index<> h = igen.next();
520 if (h.is_zero())
break;
524 cctbx::miller::sym_equiv_indices sei(this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg(),h);
544 cctbx::miller::index<> h = igen.next();
545 if (h.is_zero())
break;
546 cctbx::miller::sym_equiv_indices sei(this->
GetCrystal().GetSpaceGroup().GetCCTbxSpg(),h);
547 for(
int i=0;i<sei.multiplicity(
true);i++)
549 cctbx::miller::index<> k = sei(i).h();
552 H.resizeAndPreserve(
mNbRefl+100);
553 K.resizeAndPreserve(
mNbRefl+100);
554 L.resizeAndPreserve(
mNbRefl+100);
576 VFN_DEBUG_EXIT(
"ScatteringData::GenHKLFullSpace2():End",5)
581 VFN_DEBUG_ENTRY(
"ScatteringData::GenHKLFullSpace()",5)
585 no wavelength assigned yet to this ScatteringData object.");;
588 VFN_DEBUG_EXIT(
"ScatteringData::GenHKLFullSpace()",5)
595 VFN_DEBUG_MESSAGE(
"ScatteringData::SetCrystal()",5)
622 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflX()",1)
624 VFN_DEBUG_EXIT(
"ScatteringData::GetReflX()",1)
629 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflY()",1)
631 VFN_DEBUG_EXIT(
"ScatteringData::GetReflY()",1)
636 VFN_DEBUG_ENTRY(
"ScatteringData::GetReflZ()",1)
638 VFN_DEBUG_EXIT(
"ScatteringData::GetReflZ()",1)
644 VFN_DEBUG_ENTRY(
"ScatteringData::GetSinThetaOverLambda()",1)
646 VFN_DEBUG_EXIT(
"ScatteringData::GetSinThetaOverLambda()",1)
652 VFN_DEBUG_ENTRY(
"ScatteringData::GetTheta()",1)
654 VFN_DEBUG_EXIT(
"ScatteringData::GetTheta()",1)
665 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcSq()",2)
668 #ifdef __LIBCRYST_VECTOR_USE_BLITZ__
674 pi=mFhklCalcImag.data();
678 *p++ = *pr * *pr + *pi * *pi;
682 for(
long i=mNbReflUsed;i<
mNbRefl;i++) *p++ = 0;
685 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcSq()",2)
689 std::map<RefinablePar*, CrystVector_REAL>& ScatteringData::GetFhklCalcSq_FullDeriv(std::set<RefinablePar *> &vPar)
691 TAU_PROFILE(
"ScatteringData::GetFhklCalcSq_FullDeriv()",
"void ()",TAU_DEFAULT);
692 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcSq()",2)
693 this->CalcStructFactor_FullDeriv(vPar);
695 mFhklCalcSq_FullDeriv.clear();
696 const REAL *pr,*pi,*prd,*pid;
698 for(
std::set<
RefinablePar *>::iterator par=vPar.begin();par!=vPar.end();par++)
700 if((*par)==0)
continue;
701 if(mFhklCalcReal_FullDeriv[*par].size()==0)
703 mFhklCalcSq_FullDeriv[*par].resize(0);
706 mFhklCalcSq_FullDeriv[*par].resize(
mNbRefl);
708 pi=mFhklCalcImag.data();
709 prd=mFhklCalcReal_FullDeriv[*par].data();
710 pid=mFhklCalcImag_FullDeriv[*par].data();
711 p=mFhklCalcSq_FullDeriv[*par].data();
713 *p++ = 2*(*pr++ * *prd++ + *pi++ * *pid++);
714 for(
long i=mNbReflUsed;i<
mNbRefl;i++) *p++ = 0;
716 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcSq()",2)
717 return mFhklCalcSq_FullDeriv;
722 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcReal()",2)
724 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcReal()",2)
730 VFN_DEBUG_ENTRY(
"ScatteringData::GetFhklCalcImag()",2)
732 VFN_DEBUG_EXIT(
"ScatteringData::GetFhklCalcImag()",2)
733 return mFhklCalcImag;
749 void ScatteringData::SetUseFastLessPreciseFunc(
const bool useItOrNot)
758 VFN_DEBUG_MESSAGE(
"ScatteringData::SetIsIgnoringImagScattFact():"<<b,10)
767 VFN_DEBUG_ENTRY(
"ScatteringData::PrintFhklCalc()",5)
769 CrystVector_REAL theta;
772 os <<
" Number of reflections:"<<
mNbRefl<<endl;
773 os <<
" H K L F(hkl)^2 Re(F) Im(F)";
774 os <<
" Theta 1/2d"<<endl;
775 os << FormatVertVectorHKLFloats<REAL>
776 (
mH,mK,mL,
mFhklCalcSq,
mFhklCalcReal,mFhklCalcImag,theta,
mSinThetaLambda,12,4,
mNbReflUsed);
777 VFN_DEBUG_EXIT(
"ScatteringData::PrintFhklCalc()",5)
782 VFN_DEBUG_ENTRY(
"ScatteringData::PrintFhklCalcDetail()",5)
784 CrystVector_REAL theta;
787 vector<const CrystVector_REAL *> v;
795 v.push_back(&mFhklCalcImag);
796 os <<
" Number of reflections:"<<
mNbRefl<<endl;
797 os <<
" H K L 1/2d Theta F(hkl)^2";
798 os <<
" Re(F) Im(F) ";
799 vector<CrystVector_REAL> sf;
802 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
807 cout<<pos->first->GetName()<<
":"<<pos->first->GetForwardScatteringFactor(RAD_XRAY)<<endl;
811 sf[2*i+1] = mvImagGeomSF[pos->first];
814 v.push_back(&(sf[2*i]));
815 v.push_back(&(sf[2*i+1]));
822 os << FormatVertVectorHKLFloats<REAL>(v,12,4,
mNbReflUsed);
823 VFN_DEBUG_EXIT(
"ScatteringData::PrintFhklCalcDetail()",5)
827 const bool enableRestraints)
867 VFN_DEBUG_ENTRY(
"ScatteringData::PrepareHKLarrays()"<<
mNbRefl<<
" reflections",5)
889 bool noSpgChange=
false;
915 VFN_DEBUG_EXIT(
"ScatteringData::PrepareHKLarrays()"<<mNbRefl<<
" reflections",5)
923 VFN_DEBUG_MESSAGE(
"ScatteringData::GetNbReflBelowMaxSinThetaOvLambda()",4)
925 if((mNbReflUsed>0)&&(mNbReflUsed<
mNbRefl))
940 <<
" nb refl="<<mNbReflUsed,4)
949 TAU_PROFILE(
"ScatteringData::SortReflectionBySinThetaOverLambda()",
"void ()",TAU_DEFAULT);
950 VFN_DEBUG_ENTRY(
"ScatteringData::SortReflectionBySinThetaOverLambda()",5)
952 CrystVector_long sortedSubs;
954 CrystVector_long oldH,oldK,oldL,oldMult;
963 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 1",2)
973 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 2",2)
976 subs=sortedSubs(i+shift);
983 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 3",2)
987 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 4",2)
990 VFN_DEBUG_MESSAGE(
"ScatteringData::SortReflectionBySinThetaOverLambda() 5"<<maxSTOL,2)
992 VFN_DEBUG_MESSAGE(
" "<<
mIntH(maxSubs)<<
" "<< mIntK(maxSubs)<<
" "<< mIntL(maxSubs)<<
" "<<
mSinThetaLambda(maxSubs),1)
995 VFN_DEBUG_MESSAGE(
" "<<
mIntH(maxSubs)<<
" "<< mIntK(maxSubs)<<
" "<< mIntL(maxSubs)<<
" "<<
mSinThetaLambda(maxSubs),1)
996 if(maxSubs==(mNbRefl-1))
1002 if(maxSubs==mNbRefl)
1004 VFN_DEBUG_EXIT(
"ScatteringData::SortReflectionBySinThetaOverLambda():"<<mNbRefl<<
" reflections",5)
1008 mH.resizeAndPreserve(mNbRefl);
1009 mK.resizeAndPreserve(mNbRefl);
1010 mL.resizeAndPreserve(mNbRefl);
1012 sortedSubs.resizeAndPreserve(mNbRefl);
1016 VFN_DEBUG_EXIT(
"ScatteringData::SortReflectionBySinThetaOverLambda():"<<mNbRefl<<
" reflections",5)
1022 TAU_PROFILE(
"ScatteringData::EliminateExtinctReflections()",
"void ()",TAU_DEFAULT);
1023 VFN_DEBUG_ENTRY(
"ScatteringData::EliminateExtinctReflections()",7)
1026 CrystVector_long subscriptKeptRefl(
mNbRefl);
1027 subscriptKeptRefl=0;
1030 if( this->
GetCrystal().GetSpaceGroup().IsReflSystematicAbsent(
mH(j),mK(j),mL(j))==
false )
1031 subscriptKeptRefl(nbKeptRefl++)=j;
1033 VFN_DEBUG_MESSAGE(
"ScatteringData::EliminateExtinctReflections():4",5)
1037 CrystVector_long oldH,oldK,oldL;
1038 CrystVector_int oldMulti;
1052 subs=subscriptKeptRefl(i);
1060 VFN_DEBUG_EXIT(
"ScatteringData::EliminateExtinctReflections():End",7)
1061 return subscriptKeptRefl;
1068 Cannot compute sin(theta)/lambda : there is no crystal affected to this \
1069 ScatteringData object yet.");
1072 Cannot compute sin(theta)/lambda : there are no reflections !");
1079 VFN_DEBUG_ENTRY(
"ScatteringData::CalcSinThetaLambda()",3)
1080 TAU_PROFILE(
"ScatteringData::CalcSinThetaLambda()",
"void (bool)",TAU_DEFAULT);
1083 const CrystMatrix_REAL bMatrix= this->
GetBMatrix();
1089 mX(i)=bMatrix(0,0)*
mH(i)+bMatrix(0,1)*mK(i)+bMatrix(0,2)*mL(i);
1090 mY(i)=bMatrix(1,0)*
mH(i)+bMatrix(1,1)*mK(i)+bMatrix(1,2)*mL(i);
1091 mZ(i)=bMatrix(2,0)*
mH(i)+bMatrix(2,1)*mK(i)+bMatrix(2,2)*mL(i);
1110 const REAL h=
mH(i),k=mK(i),l=mL(i);
1111 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));
1116 if(this->
GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1148 cout <<
"Wavelength not given in ScatteringData::CalcSinThetaLambda() !" <<endl;
1155 VFN_DEBUG_EXIT(
"ScatteringData::CalcSinThetaLambda()",3)
1160 const CrystMatrix_REAL bMatrix= this->
GetBMatrix();
1161 const REAL x=bMatrix(0,0)*h+bMatrix(0,1)*k+bMatrix(0,2)*l;
1162 const REAL y=bMatrix(1,0)*h+bMatrix(1,1)*k+bMatrix(1,2)*l;
1163 const REAL z=bMatrix(2,0)*h+bMatrix(2,1)*k+bMatrix(2,2)*l;
1164 return sqrt(x*x+y*y+z*z)/2;
1180 TAU_PROFILE(
"ScatteringData::CalcScattFactor()",
"void (bool)",TAU_DEFAULT);
1181 VFN_DEBUG_ENTRY(
"ScatteringData::CalcScattFactor()",4)
1190 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) f0+f'"
1195 VFN_DEBUG_EXIT(
"ScatteringData::CalcScattFactor()",4)
1206 TAU_PROFILE(
"ScatteringData::CalcTemperatureFactor()",
"void (bool)",TAU_DEFAULT);
1207 VFN_DEBUG_ENTRY(
"ScatteringData::CalcTemperatureFactor()",4)
1213 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) DebyeWaller"<<endl
1218 VFN_DEBUG_EXIT(
"ScatteringData::CalcTemperatureFactor()",4)
1225 VFN_DEBUG_ENTRY(
"ScatteringData::CalcResonantScattFactor()",4)
1226 TAU_PROFILE(
"ScatteringData::CalcResonantScattFactor()",
"void (bool)",TAU_DEFAULT);
1232 VFN_DEBUG_EXIT(
"ScatteringData::CalcResonantScattFactor()->Lambda=0. fprime=fsecond=0",4)
1245 VFN_DEBUG_EXIT(
"ScatteringData::CalcResonantScattFactor()",4)
1256 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcGlobalTemperatureFactor()",2)
1257 TAU_PROFILE(
"ScatteringData::CalcGlobalTemperatureFactor()",
"void ()",TAU_DEFAULT);
1301 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcStructFactor():Fhkl Recalc ?"<<endl
1306 <<
"mClockStructFactor<mClockLuzzatiFactor" <<(
bool)(
mClockStructFactor<mClockLuzzatiFactor)<<endl
1314 VFN_DEBUG_ENTRY(
"ScatteringData::CalcStructFactor()",3)
1315 TAU_PROFILE(
"ScatteringData::CalcStructFactor()",
"void ()",TAU_DEFAULT);
1319 mFhklCalcImag.resize(nbRefl);
1323 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();
1327 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcStructFactor():Fhkl Recalc, "<<pScattPow->
GetName(),2)
1328 const REAL * RESTRICT pGeomR=
mvRealGeomSF[pScattPow].data();
1329 const REAL * RESTRICT pGeomI=mvImagGeomSF[pScattPow].data();
1334 REAL * RESTRICT pImag=mFhklCalcImag.data();
1336 VFN_DEBUG_MESSAGE(
"->mvRealGeomSF[i] "
1338 VFN_DEBUG_MESSAGE(
"->mvImagGeomSF[i] "
1339 <<mvImagGeomSF[pScattPow].numElements()<<
"elements",2)
1340 VFN_DEBUG_MESSAGE(
"->mvScatteringFactor[i]"
1342 VFN_DEBUG_MESSAGE(
"->mvTemperatureFactor[i]"
1344 VFN_DEBUG_MESSAGE(
"->mFhklCalcReal "<<
mFhklCalcReal.numElements()<<
"elements",2)
1345 VFN_DEBUG_MESSAGE(
"->mFhklCalcImag "<<mFhklCalcImag.numElements()<<
"elements",2)
1346 VFN_DEBUG_MESSAGE(
"-> H K L sin(t/l) Re(F) Im(F) scatt Temp->"<<pScattPow->
GetName(),1)
1350 mvImagGeomSF[pScattPow],
1359 const REAL fsecond=mvFsecond[pScattPow];
1360 VFN_DEBUG_MESSAGE(
"->fsecond= "<<fsecond,10)
1361 for(
long j=mNbReflUsed;j>0;j--)
1363 VFN_DEBUG_MESSAGE(
"-->"<<j<<
" "<<*pReal<<
" "<<*pImag<<
" "<<*pGeomR<<
" "<<*pGeomI<<
" "<<*pScatt<<
" "<<*pTemp,1)
1364 *pReal++ += (*pGeomR * *pScatt - *pGeomI * fsecond)* *pTemp * *pLuzzati;
1365 *pImag++ += (*pGeomI++ * *pScatt++ + *pGeomR++ * fsecond)* *pTemp++ * *pLuzzati++;
1370 for(
long j=mNbReflUsed;j>0;j--)
1372 *pReal++ += *pGeomR++ * *pTemp * *pScatt * *pLuzzati;
1373 *pImag++ += *pGeomI++ * *pTemp++ * *pScatt++ * *pLuzzati++;
1377 <<
",f\"="<<mvFsecond[pScattPow]<<endl<<
1380 mvImagGeomSF[pScattPow],
1385 mFhklCalcImag,10,4,mNbReflUsed
1392 const REAL fsecond=mvFsecond[pScattPow];
1393 VFN_DEBUG_MESSAGE(
"->fsecond= "<<fsecond,2)
1394 for(
long j=mNbReflUsed;j>0;j--)
1396 *pReal += (*pGeomR * *pScatt - *pGeomI * fsecond)* *pTemp;
1397 *pImag += (*pGeomI * *pScatt + *pGeomR * fsecond)* *pTemp;
1398 VFN_DEBUG_MESSAGE(
"-->"<<j<<
" "<<*pReal<<
" "<<*pImag<<
" "<<*pGeomR<<
" "<<*pGeomI<<
" "<<*pScatt<<
" "<<*pTemp,1)
1399 pGeomR++;pGeomI++;pTemp++;pScatt++;pReal++;pImag++;
1404 for(
long j=mNbReflUsed;j>0;j--)
1406 *pReal++ += *pGeomR++ * *pTemp * *pScatt;
1407 *pImag++ += *pGeomI++ * *pTemp++ * *pScatt++;
1412 mvImagGeomSF[pScattPow],
1416 mFhklCalcImag,10,4,mNbReflUsed
1426 REAL *pImag=mFhklCalcImag.data();
1431 *pImag++ *= *pTemp++;
1437 VFN_DEBUG_EXIT(
"ScatteringData::CalcStructFactor()",3)
1440 void ScatteringData::CalcStructFactor_FullDeriv(std::set<RefinablePar *> &vPar)
1442 TAU_PROFILE(
"ScatteringData::CalcStructFactor_FullDeriv()",
"void ()",TAU_DEFAULT);
1445 this->CalcGeomStructFactor_FullDeriv(vPar);
1448 mFhklCalcReal_FullDeriv.clear();
1449 mFhklCalcImag_FullDeriv.clear();
1451 mFhklCalcImag_FullDeriv[0]=mFhklCalcImag;
1452 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
1454 if(*par==0)
continue;
1455 if((*par)->GetType()->IsDescendantFromOrSameAs(gpRefParTypeScatt)==
false)
1458 mFhklCalcReal_FullDeriv[*par].resize(0);
1459 mFhklCalcImag_FullDeriv[*par].resize(0);
1462 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();
1465 const ScatteringPower* pScattPow=pos->first;
1466 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
1470 if(mFhklCalcReal_FullDeriv[*par].size()==0)
1472 mFhklCalcReal_FullDeriv[*par].resize(
mNbRefl);
1473 mFhklCalcImag_FullDeriv[*par].resize(
mNbRefl);
1474 mFhklCalcReal_FullDeriv[*par]=0;
1475 mFhklCalcImag_FullDeriv[*par]=0;
1477 const REAL * RESTRICT pGeomRd=mvRealGeomSF_FullDeriv[*par][pScattPow].data();
1478 const REAL * RESTRICT pGeomId=mvImagGeomSF_FullDeriv[*par][pScattPow].data();
1482 REAL * RESTRICT pReal=mFhklCalcReal_FullDeriv[*par].data();
1483 REAL * RESTRICT pImag=mFhklCalcImag_FullDeriv[*par].data();
1489 const REAL fsecond=mvFsecond[pScattPow];
1490 for(
long j=mNbReflUsed;j>0;j--)
1492 *pReal++ += (*pGeomRd * *pScatt - *pGeomId * fsecond)* *pTemp * *pLuzzati;
1493 *pImag++ += (*pGeomId++ * *pScatt++ + *pGeomRd++ * fsecond)* *pTemp++ * *pLuzzati++;
1498 for(
long j=mNbReflUsed;j>0;j--)
1500 *pReal++ += *pGeomRd++ * *pTemp * *pScatt * *pLuzzati;
1501 *pImag++ += *pGeomId++ * *pTemp++ * *pScatt++ * *pLuzzati++;
1509 const REAL fsecond=mvFsecond[pScattPow];
1510 for(
long j=mNbReflUsed;j>0;j--)
1512 *pReal += (*pGeomRd * *pScatt - *pGeomId * fsecond)* *pTemp;
1513 *pImag += (*pGeomId * *pScatt + *pGeomRd * fsecond)* *pTemp;
1514 pGeomRd++;pGeomId++;pTemp++;pScatt++;pReal++;pImag++;
1519 for(
long j=mNbReflUsed;j>0;j--)
1521 *pReal++ += *pGeomRd++ * *pTemp * *pScatt;
1522 *pImag++ += *pGeomId++ * *pTemp++ * *pScatt++;
1531 &&(mFhklCalcReal_FullDeriv[*par].size()>0)
1532 &&(mFhklCalcImag_FullDeriv[*par].size()>0))
1534 REAL * RESTRICT pReal=mFhklCalcReal_FullDeriv[*par].data();
1535 REAL * RESTRICT pImag=mFhklCalcImag_FullDeriv[*par].data();
1540 *pImag++ *= *pTemp++;
1546 std::vector<const CrystVector_REAL*> v;
1550 std::map<RefinablePar*, CrystVector_REAL> oldDerivR,oldDerivI;
1551 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
1553 const REAL step=(*par)->GetDerivStep();
1554 (*par)->Mutate(step);
1557 oldDerivI[*par]=mFhklCalcImag;
1558 (*par)->Mutate(-2*step);
1561 oldDerivR[*par]/=2*step;
1562 oldDerivI[*par]-=mFhklCalcImag;
1563 oldDerivI[*par]/=2*step;
1564 (*par)->Mutate(step);
1566 v.push_back(&(mFhklCalcReal_FullDeriv[*par]));
1567 v.push_back(&(oldDerivR[*par]));
1568 v.push_back(&(mFhklCalcImag_FullDeriv[*par]));
1569 v.push_back(&(oldDerivI[*par]));
1570 if(v.size()>14)
break;
1572 cout<<
"############################ Fhkl Deriv Real, Imag ##############################"
1573 <<endl<<FormatVertVectorHKLFloats<REAL>(v,14,4,20)
1574 <<
"############################ END Fhkl Deriv Real, Imag ##############################"<<endl;
1588 TAU_PROFILE(
"ScatteringData::GeomStructFactor()",
"void (Vx,Vy,Vz,data,M,M,bool)",TAU_DEFAULT);
1589 VFN_DEBUG_ENTRY(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz,...)",3)
1591 VFN_DEBUG_MESSAGE(
"-->Number of translation vectors:"
1592 <<this->
GetCrystal().GetSpaceGroup().GetNbTranslationVectors()-1,2)
1593 VFN_DEBUG_MESSAGE(
"-->Has an inversion Center:"
1594 <<this->
GetCrystal().GetSpaceGroup().HasInversionCenter(),2)
1595 VFN_DEBUG_MESSAGE(
"-->Number of symetry operations (w/o transl&inv cent.):"\
1596 <<this->
GetCrystal().GetSpaceGroup().GetNbSymmetrics(
true,
true),2)
1597 VFN_DEBUG_MESSAGE(
"-->Number of Scattering Components :"
1598 <<this->
GetCrystal().GetScatteringComponentList().GetNbComponent(),2)
1599 VFN_DEBUG_MESSAGE(
"-->Number of reflections:"
1600 <<this->
GetNbRefl()<<
" (actually used:"<<mNbReflUsed<<
")",2)
1602 static long counter=0;
1603 VFN_DEBUG_MESSAGE(
"-->Number of GeomStructFactor calculations so far:"<<counter++,3)
1626 CrystMatrix_REAL allCoords(nbSymmetrics,3);
1627 CrystVector_REAL tmpVect(mNbReflUsed);
1628 #ifndef HAVE_SSE_MATHFUN
1630 CrystVector_long intVect(nbRefl);
1633 map<const ScatteringPower*,bool> vUsed;
1635 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator pos=
mvRealGeomSF.begin();pos!=
mvRealGeomSF.end();++pos)
1636 vUsed[pos->first]=
false;
1642 else vUsed[pow]=
false;
1644 for(
long i=0;i<nbComp;i++)
1645 vUsed[(*pScattCompList)(i).mpScattPow]=
true;
1647 for(map<const ScatteringPower*,bool>::const_iterator pos=vUsed.begin();pos!=vUsed.end();++pos)
1652 mvImagGeomSF[pos->first].resize(mNbReflUsed);
1654 mvImagGeomSF[pos->first]=0;
1659 map<const ScatteringPower*,CrystVector_REAL>::iterator
1662 poubelle=mvImagGeomSF.find(pos->first);
1663 if(poubelle!=mvImagGeomSF.end()) mvImagGeomSF.erase(poubelle);
1669 for(
long i=0;i<nbComp;i++)
1671 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(),comp"<<i,3)
1672 const REAL x=(*pScattCompList)(i).
mX;
1673 const REAL y=(*pScattCompList)(i).mY;
1674 const REAL z=(*pScattCompList)(i).mZ;
1676 const REAL popu= (*pScattCompList)(i).mOccupancy
1677 *(*pScattCompList)(i).mDynPopCorr
1683 const REAL STBF=2.*pSpg->
GetCCTbxSpg().inv_t().den();
1684 for(
int j=0;j<nbSymmetrics;j++)
1688 allCoords(j,0) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[0])/STBF;
1689 allCoords(j,1) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[1])/STBF;
1690 allCoords(j,2) -= ((REAL)pSpg->
GetCCTbxSpg().inv_t()[2])/STBF;
1693 for(
int j=0;j<nbSymmetrics;j++)
1695 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(),comp #"<<i<<
", sym #"<<j,3)
1697 #ifndef HAVE_SSE_MATHFUN
1701 REAL * RESTRICT iisf=mvImagGeomSF[pScattPow].data();
1703 const long intX=(long)(allCoords(j,0)*sLibCrystNbTabulSine);
1704 const long intY=(long)(allCoords(j,1)*sLibCrystNbTabulSine);
1705 const long intZ=(long)(allCoords(j,2)*sLibCrystNbTabulSine);
1707 const long * RESTRICT intH=
mIntH.data();
1708 const long * RESTRICT intK=mIntK.data();
1709 const long * RESTRICT intL=mIntL.data();
1711 register long * RESTRICT tmpInt=intVect.data();
1718 for(
int jj=mNbReflUsed;jj>0;jj--)
1719 *tmpInt++ = (*intH++ * intX + *intK++ * intY + *intL++ *intZ)
1720 &sLibCrystNbTabulSineMASK;
1724 tmpInt=intVect.data();
1725 for(
int jj=mNbReflUsed;jj>0;jj--)
1727 const REAL *pTmp=&spLibCrystTabulCosineSine[*tmpInt++ <<1];
1728 *rrsf++ += popu * *pTmp++;
1729 *iisf++ += popu * *pTmp;
1735 tmpInt=intVect.data();
1736 for(
int jj=mNbReflUsed;jj>0;jj--)
1737 *rrsf++ += popu * spLibCrystTabulCosine[*tmpInt++];
1743 const REAL x=allCoords(j,0);
1744 const REAL y=allCoords(j,1);
1745 const REAL z=allCoords(j,2);
1746 const register REAL *hh=
mH2Pi.data();
1747 const register REAL *kk=mK2Pi.data();
1748 const register REAL *ll=mL2Pi.data();
1750 #ifdef HAVE_SSE_MATHFUN
1756 static const float twopi=6.283185307179586f;
1757 sincos_ps(_mm_mul_ps(_mm_load1_ps(&twopi),_mm_set_ps(x,y,z,0)),cnxyz0,snxyz0);
1759 for(
long k=1;k<mMaxHKL;k++)
1761 cnxyz0[k]=_mm_sub_ps(_mm_mul_ps(cnxyz0[k-1],cnxyz0[0]),_mm_mul_ps(snxyz0[k-1],snxyz0[0]));
1762 snxyz0[k]=_mm_add_ps(_mm_mul_ps(snxyz0[k-1],cnxyz0[0]),_mm_mul_ps(cnxyz0[k-1],snxyz0[0]));
1765 for(
long k=0;k<4;++k){*(pcnxyz0+k)=1.0f;*(psnxyz0+k)=0.0f;}
1766 for(
long k=1;k<mMaxHKL;k++)
1768 _mm_store_ps(pcnxyz0+4*k,cnxyz0[k-1]);
1769 _mm_store_ps(psnxyz0+4*k,snxyz0[k-1]);
1775 REAL *isf=mvImagGeomSF[pScattPow].data();
1776 const long *h=
mIntH.data();
1777 const long *k=mIntK.data();
1778 const long *l=mIntL.data();
1780 const v4sf v4popu=_mm_set1_ps(popu);
1781 for(jj=mNbReflUsed;jj>3;jj-=4)
1784 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]);
1785 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]);
1786 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]);
1787 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]);
1788 #define CH _mm_set_ps(pcnxyz0[*(h)*4],pcnxyz0[*(h+1)*4],pcnxyz0[*(h+2)*4],pcnxyz0[*(h+3)*4])
1789 #define SH _mm_set_ps(psnxyz0[*(h)*4],psnxyz0[*(h+1)*4],psnxyz0[*(h+2)*4],psnxyz0[*(h+3)*4])
1791 _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))))));
1793 _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))))));
1794 rsf+=4;isf+=4;h+=4;k+=4,l+=4;
1798 const float ch=pcnxyz0[*h *4];
1799 const float sh=psnxyz0[*h++ *4];
1800 const float ck=pcnxyz0[*k *4+1];
1801 const float sk=psnxyz0[*k++ *4+1];
1802 const float cl=pcnxyz0[*l *4+2];
1803 const float sl=psnxyz0[*l++ *4+2];
1804 *rsf++ += popu*(ch*(ck*cl-sk*sl)-sh*(sk*cl+ck*sl));
1805 *isf++ += popu*(sh*(ck*cl-sk*sl)+ch*(sk*cl+ck*sl));
1811 const long *h=
mIntH.data();
1812 const long *k=mIntK.data();
1813 const long *l=mIntL.data();
1815 const v4sf v4popu=_mm_set1_ps(popu);
1816 for(jj=mNbReflUsed;jj>3;jj-=4)
1819 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]);
1820 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]);
1821 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]);
1822 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]);
1823 #define CH _mm_set_ps(pcnxyz0[*(h)*4],pcnxyz0[*(h+1)*4],pcnxyz0[*(h+2)*4],pcnxyz0[*(h+3)*4])
1824 #define SH _mm_set_ps(psnxyz0[*(h)*4],psnxyz0[*(h+1)*4],psnxyz0[*(h+2)*4],psnxyz0[*(h+3)*4])
1826 _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))))));
1827 rsf+=4;h+=4;k+=4,l+=4;
1831 const float ch=pcnxyz0[*h *4];
1832 const float sh=psnxyz0[*h++ *4];
1833 const float ck=pcnxyz0[*k *4+1];
1834 const float sk=psnxyz0[*k++ *4+1];
1835 const float cl=pcnxyz0[*l *4+2];
1836 const float sl=psnxyz0[*l++ *4+2];
1837 *rsf++ += popu*(ch*(ck*cl-sk*sl)-sh*(sk*cl+ck*sl));
1843 const v4sf v4x=_mm_load1_ps(&x);
1844 const v4sf v4y=_mm_load1_ps(&y);
1845 const v4sf v4z=_mm_load1_ps(&z);
1846 const v4sf v4popu=_mm_load1_ps(&popu);
1850 REAL *isf=mvImagGeomSF[pScattPow].data();
1859 sincos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_loadu_ps(hh),v4x),
1860 _mm_mul_ps(_mm_loadu_ps(kk),v4y)
1862 _mm_mul_ps(_mm_loadu_ps(ll),v4z)
1864 _mm_storeu_ps(rsf,_mm_add_ps(_mm_mul_ps(v4cos,v4popu),_mm_loadu_ps(rsf)));
1865 _mm_storeu_ps(isf,_mm_add_ps(_mm_mul_ps(v4sin,v4popu),_mm_loadu_ps(isf)));
1867 hh+=4;kk+=4;ll+=4;rsf+=4;isf+=4;
1871 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
1872 *rsf++ += popu * cos(tmp);
1873 *isf++ += popu * sin(tmp);
1886 const v4sf v4cos=cos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_loadu_ps(hh),v4x),
1887 _mm_mul_ps(_mm_loadu_ps(kk),v4y)
1889 _mm_mul_ps(_mm_loadu_ps(ll),v4z)));
1890 _mm_storeu_ps(rsf,_mm_add_ps(_mm_loadu_ps(rsf),_mm_mul_ps(v4cos,v4popu)));
1891 hh+=4;kk+=4;ll+=4;rsf+=4;
1895 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
1896 *rsf++ += popu * cos(tmp);
1901 register REAL *tmp=tmpVect.data();
1902 for(
int jj=0;jj<
mNbReflUsed;jj++) *tmp++ = *hh++ * x + *kk++ * y + *ll++ *z;
1907 for(
int jj=0;jj<
mNbReflUsed;jj++) *sf++ += popu * cos(*tmp++);
1911 sf=mvImagGeomSF[pScattPow].data();
1913 for(
int jj=0;jj<
mNbReflUsed;jj++) *sf++ += popu * sin(*tmp++);
1919 if(nbTranslationVectors > 1)
1924 REAL * RESTRICT p1=tmpVect.data();
1925 const register REAL * RESTRICT hh=
mH2Pi.data();
1926 const register REAL * RESTRICT kk=mK2Pi.data();
1927 const register REAL * RESTRICT ll=mL2Pi.data();
1928 for(
long j=mNbReflUsed;j>0;j--) *p1++ += 2*cos((*hh++ - *kk++ - *ll++)/3.);
1932 for(
int j=1;j<nbTranslationVectors;j++)
1934 const REAL x=(*pTransVect)[j].tr[0];
1935 const REAL y=(*pTransVect)[j].tr[1];
1936 const REAL z=(*pTransVect)[j].tr[2];
1937 REAL *p1=tmpVect.data();
1938 const register REAL *hh=
mH2Pi.data();
1939 const register REAL *kk=mK2Pi.data();
1940 const register REAL *ll=mL2Pi.data();
1941 for(
long j=mNbReflUsed;j>0;j--) *p1++ += cos(*hh++ *x + *kk++ *y + *ll++ *z );
1944 for(map<const ScatteringPower*,CrystVector_REAL>::iterator
1946 pos->second *= tmpVect;
1949 for(map<const ScatteringPower*,CrystVector_REAL>::iterator
1950 pos=mvImagGeomSF.begin();pos!=mvImagGeomSF.end();++pos)
1951 pos->second *= tmpVect;
1958 VFN_DEBUG_MESSAGE(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz):\
1959 Inversion Center not at the origin...",2)
1965 const REAL STBF=2*pSpg->
GetCCTbxSpg().inv_t().den();
1967 const REAL xc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[0])/STBF;
1968 const REAL yc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[1])/STBF;
1969 const REAL zc=((REAL)pSpg->
GetCCTbxSpg().inv_t()[2])/STBF;
1970 #ifdef __LIBCRYST_VECTOR_USE_BLITZ__
1971 tmpVect =
mH2Pi() * xc + mK2PI() * yc + mL2PI() * zc;
1974 const REAL * RESTRICT hh=
mH2Pi.data();
1975 const REAL * RESTRICT kk=mK2Pi.data();
1976 const REAL * RESTRICT ll=mL2Pi.data();
1977 REAL * RESTRICT ttmpVect=tmpVect.data();
1978 for(
long ii=mNbReflUsed;ii>0;ii--)
1979 *ttmpVect++ = *hh++ * xc + *kk++ * yc + *ll++ * zc;
1983 CrystVector_REAL cosTmpVect;
1984 CrystVector_REAL sinTmpVect;
1985 cosTmpVect=cos(tmpVect);
1986 sinTmpVect=sin(tmpVect);
1988 map<const ScatteringPower*,CrystVector_REAL>::iterator posi=mvImagGeomSF.begin();
1989 map<const ScatteringPower*,CrystVector_REAL>::iterator posr=
mvRealGeomSF.begin();
1990 for(;posi!=mvImagGeomSF.end();)
1992 posi->second = posr->second;
1993 posi->second *= sinTmpVect;
1994 posr->second *= cosTmpVect;
2002 VFN_DEBUG_EXIT(
"ScatteringData::GeomStructFactor(Vx,Vy,Vz,...)",3)
2004 void ScatteringData::CalcGeomStructFactor_FullDeriv(std::set<RefinablePar*> &vPar)
2006 TAU_PROFILE(
"ScatteringData::CalcGeomStructFactor_FullDeriv()",
"void (..)",TAU_DEFAULT);
2007 TAU_PROFILE_TIMER(timer1,
"ScatteringData::CalcGeomStructFactor_FullDeriv:1-ScattCompList deriv",
"", TAU_FIELD);
2008 TAU_PROFILE_TIMER(timer2,
"ScatteringData::CalcGeomStructFactor_FullDeriv:2-Geom SF",
"", TAU_FIELD);
2020 CrystMatrix_REAL allCoords(nbSymmetrics,3);
2024 TAU_PROFILE_START(timer1);
2026 std::map<RefinablePar*,CrystVector_REAL> vdx,vdy,vdz,vdocc;
2027 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2029 if(*par==0)
continue;
2030 CrystVector_REAL *pdx =&(vdx[*par]);
2031 CrystVector_REAL *pdy =&(vdy[*par]);
2032 CrystVector_REAL *pdz =&(vdz[*par]);
2033 CrystVector_REAL *pdocc=&(vdocc[*par]);
2034 pdx->resize(nbComp);
2035 pdy->resize(nbComp);
2036 pdz->resize(nbComp);
2037 pdocc->resize(nbComp);
2039 const REAL p0=(*par)->GetValue();
2040 const REAL step=(*par)->GetDerivStep();
2041 (*par)->Mutate(step);
2043 REAL *ppdx =pdx->data();
2044 REAL *ppdy =pdy->data();
2045 REAL *ppdz =pdz->data();
2046 REAL *ppdocc=pdocc->data();
2047 for(
unsigned long i=0;i<nbComp;++i)
2049 *ppdx++ =(*pScattCompList)(i).
mX;
2050 *ppdy++ =(*pScattCompList)(i).mY;
2051 *ppdz++ =(*pScattCompList)(i).mZ;
2052 *ppdocc++=(*pScattCompList)(i).mOccupancy*(*pScattCompList)(i).mDynPopCorr;
2054 (*par)->Mutate(-2*step);
2059 ppdocc=pdocc->data();
2060 for(
unsigned long i=0;i<nbComp;++i)
2062 *ppdx -=(*pScattCompList)(i).
mX;
2064 *ppdy -=(*pScattCompList)(i).mY;
2066 *ppdz -=(*pScattCompList)(i).mZ;
2068 *ppdocc-=(*pScattCompList)(i).mOccupancy*(*pScattCompList)(i).mDynPopCorr;
2071 (*par)->SetValue(p0);
2072 if( (MaxAbs(vdx[*par])==0)&&(MaxAbs(vdy[*par])==0)&&(MaxAbs(vdz[*par])==0)&&(MaxAbs(vdocc[*par])==0))
2080 TAU_PROFILE_STOP(timer1);
2081 TAU_PROFILE_START(timer2);
2082 CrystVector_REAL transMult(mNbReflUsed);
2083 if(!hasinv) transMult=1;
2085 if(nbTranslationVectors > 1)
2089 REAL * RESTRICT p1=transMult.data();
2090 const register REAL * RESTRICT hh=
mH2Pi.data();
2091 const register REAL * RESTRICT kk=mK2Pi.data();
2092 const register REAL * RESTRICT ll=mL2Pi.data();
2093 for(
long j=mNbReflUsed;j>0;j--) *p1++ += 2*cos((*hh++ - *kk++ - *ll++)/3.);
2097 for(
int j=1;j<nbTranslationVectors;j++)
2099 const REAL x=(*pTransVect)[j].tr[0];
2100 const REAL y=(*pTransVect)[j].tr[1];
2101 const REAL z=(*pTransVect)[j].tr[2];
2102 REAL *p1=transMult.data();
2103 const register REAL * RESTRICT hh=
mH2Pi.data();
2104 const register REAL * RESTRICT kk=mK2Pi.data();
2105 const register REAL * RESTRICT ll=mL2Pi.data();
2106 for(
long j=mNbReflUsed;j>0;j--) *p1++ += cos(*hh++ *x + *kk++ *y + *ll++ *z );
2113 mvRealGeomSF_FullDeriv.clear();
2114 mvImagGeomSF_FullDeriv.clear();
2115 CrystVector_REAL c(mNbReflUsed),s(mNbReflUsed);
2116 CrystMatrix_REAL allCoordsDeriv(nbSymmetrics,3);
2117 for(
unsigned long i=0;i<nbComp;i++)
2119 const REAL x0=(*pScattCompList)(i).
mX;
2120 const REAL y0=(*pScattCompList)(i).mY;
2121 const REAL z0=(*pScattCompList)(i).mZ;
2122 const ScatteringPower *pScattPow=(*pScattCompList)(i).mpScattPow;
2123 const REAL popu= (*pScattCompList)(i).mOccupancy
2124 *(*pScattCompList)(i).mDynPopCorr;
2126 for(
int j=0;j<nbSymmetrics;j++)
2128 const REAL x=allCoords(j,0);
2129 const REAL y=allCoords(j,1);
2130 const REAL z=allCoords(j,2);
2134 const register REAL *hh=
mH2Pi.data();
2135 const register REAL *kk=mK2Pi.data();
2136 const register REAL *ll=mL2Pi.data();
2137 #ifdef HAVE_SSE_MATHFUN
2138 const v4sf v4x=_mm_load1_ps(&x);
2139 const v4sf v4y=_mm_load1_ps(&y);
2140 const v4sf v4z=_mm_load1_ps(&z);
2142 const v4sf v4popu=_mm_load1_ps(&popu); POSSIBLY_UNUSED(v4popu)
2151 sincos_ps(_mm_add_ps(_mm_add_ps(_mm_mul_ps(_mm_load_ps(hh),v4x),
2152 _mm_mul_ps(_mm_load_ps(kk),v4y)
2154 _mm_mul_ps(_mm_load_ps(ll),v4z)
2156 _mm_store_ps(pc,v4cos);
2157 _mm_store_ps(ps,v4sin);
2159 hh+=4;kk+=4;ll+=4;pc+=4;ps+=4;
2163 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
2170 const REAL tmp = *hh++ * x + *kk++ * y + *ll++ *z;
2176 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2178 if((*par)==0)
continue;
2179 if(vdx[*par].size()==0)
continue;
2180 REAL dx =vdx[*par](i);
2181 REAL dy =vdy[*par](i);
2182 REAL dz =vdz[*par](i);
2183 const REAL dpopu=vdocc[*par](i);
2185 if((abs(dx)+abs(dy)+abs(dz)+abs(dpopu))==0)
continue;
2186 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
2188 mvRealGeomSF_FullDeriv[*par][pScattPow].resize(
mNbRefl);
2189 mvRealGeomSF_FullDeriv[*par][pScattPow]=0;
2191 if(mvImagGeomSF_FullDeriv[*par][pScattPow].size()==0)
2193 mvImagGeomSF_FullDeriv[*par][pScattPow].resize(
mNbRefl);
2194 mvImagGeomSF_FullDeriv[*par][pScattPow]=0;
2197 const register REAL *hh=
mH2Pi.data();
2198 const register REAL *kk=mK2Pi.data();
2199 const register REAL *ll=mL2Pi.data();
2200 const register REAL *pmult=transMult.data();
2201 register REAL *rsf=mvRealGeomSF_FullDeriv[*par][pScattPow].data();
2202 register REAL *isf=mvImagGeomSF_FullDeriv[*par][pScattPow].data();
2203 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcGeomStructFactor_FullDeriv()comp="<<i<<
", par="<<(*par)->GetName()<<
", rs="<<mvRealGeomSF_FullDeriv[*par][pScattPow].size(),1)
2204 const REAL *pc=c.data();
2205 const REAL *ps=s.data();
2212 *rsf += (dpopu * *pc - popu* *ps * (*hh * dx + *kk * dy + *ll * dz))* *pmult;
2213 if(!hasinv) *isf += (dpopu * *ps + popu* *pc * (*hh * dx + *kk * dy + *ll * dz))* *pmult;
2217 ps++;pc++;hh++;kk++;ll++;pmult++;rsf++;isf++;
2230 TAU_PROFILE_STOP(timer2);
2232 std::vector<const CrystVector_REAL*> v;
2236 std::map< std::pair<const ScatteringPower *,RefinablePar*>,CrystVector_REAL> mr,mi;
2239 for(std::set<RefinablePar*>::iterator par=vPar.begin();par!=vPar.end();++par)
2241 for(std::map<const ScatteringPower*,CrystVector_REAL>::iterator pos=
mvRealGeomSF.begin();pos!=
mvRealGeomSF.end();++pos)
2243 const ScatteringPower *pScattPow=pos->first;
2244 cout<<(*par)->GetName()<<
","<<pScattPow->GetName();
2245 if(mvRealGeomSF_FullDeriv[*par][pScattPow].size()==0)
2247 cout<<
" => skipped (deriv==0)"<<endl;
2251 const REAL step=(*par)->GetDerivStep();
2252 (*par)->Mutate(step);
2255 mi[make_pair(pScattPow,*par)]=mvImagGeomSF[pScattPow];
2256 (*par)->Mutate(-2*step);
2258 mr[make_pair(pScattPow,*par)]-=
mvRealGeomSF[pScattPow];
2259 mr[make_pair(pScattPow,*par)]/=step*2;
2260 mi[make_pair(pScattPow,*par)]-=mvImagGeomSF[pScattPow];
2261 mi[make_pair(pScattPow,*par)]/=step*2;
2262 (*par)->Mutate(step);
2264 v.push_back(&(mvRealGeomSF_FullDeriv[*par][pScattPow]));
2265 v.push_back(&(mr[make_pair(pScattPow,*par)]));
2268 v.push_back(&(mvImagGeomSF_FullDeriv[*par][pScattPow]));
2269 v.push_back(&(mi[make_pair(pScattPow,*par)]));
2271 if(v.size()>20)
break;
2273 if(v.size()>20)
break;
2275 cout<<
"############################ Geom Fhkl Deriv Real, Imag ##############################"
2276 <<endl<<FormatVertVectorHKLFloats<REAL>(v,11,4,20)
2277 <<
"############################ END GeomF hkl Deriv Real, Imag ##############################"<<endl;
2278 cout<<
"############################ X Y Z Occ ##############################"
2279 <<endl<<FormatVertVector<REAL>(vdx[*(vPar.begin())],vdy[*(vPar.begin())],vdz[*(vPar.begin())],vdocc[*(vPar.begin())],8,4,20)<<endl
2280 <<
"############################ END X Y Z Occ ##############################"<<endl;
2292 VFN_DEBUG_ENTRY(
"ScatteringData::CalcLuzzatiFactor",3)
2293 bool useLuzzati=
false;
2294 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
2297 if(pos->first->GetMaximumLikelihoodPositionError()!=0)
2306 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): not needed, no positionnal errors",3)
2324 .GetMaximumLikelihoodParClock()>mClockLuzzatiFactor)
2334 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): no recalc needed",3)
2337 TAU_PROFILE(
"ScatteringData::CalcLuzzatiFactor()",
"void ()",TAU_DEFAULT);
2353 for(
long j=0;j<
mNbReflUsed;j++) {*fact++ = exp(b * *stol * *stol);stol++;}
2354 VFN_DEBUG_MESSAGE(
"ScatteringData::CalcLuzzatiFactor():"<<pScattPow->
GetName()<<endl<<
2361 mClockLuzzatiFactor.
Click();
2362 VFN_DEBUG_EXIT(
"ScatteringData::CalcLuzzatiFactor(): no recalc needed",3)
2374 if( (mClockFhklCalcVariance>mClockLuzzatiFactor)
2378 bool hasGhostAtoms=
false;
2379 for(map<const ScatteringPower*,CrystVector_REAL>::const_iterator
2382 if(pos->first->GetMaximumLikelihoodNbGhostAtom()!=0)
2394 VFN_DEBUG_ENTRY(
"ScatteringData::CalcStructFactVariance()",3)
2395 TAU_PROFILE(
"ScatteringData::CalcStructFactVariance()",
"void ()",TAU_DEFAULT);
2398 map<const ScatteringPower*,REAL> vComp;
2403 for(
long i=0;i<nbComp;i++)
2405 pComp=&((*pList)(i));
2408 for(
long i=0;i<nbComp;i++)
2410 pComp=&((*pList)(i));
2413 for(map<const ScatteringPower*,REAL>::iterator
2414 pos=vComp.begin();pos!=vComp.end();++pos)
2415 pos->second *= this->GetCrystal().GetSpaceGroup().GetNbSymmetrics();
2418 map<const ScatteringPower*,REAL> vGhost;
2422 for(
int i=0;i<nbScattPow;i++)
2426 vGhost[pow]=nb*mult;
2440 &&(vGhost[pScattPow]==0))
continue;
2454 const REAL nbghost=vGhost[pScattPow];
2457 *pVar++ += *pExp++ * *pScatt * *pScatt * nbghost;
2464 const REAL occ=vComp[pScattPow];
2465 const REAL nbghost=vGhost[pScattPow];
2468 *pVar++ += *pExp++ * *pScatt * *pScatt * ( occ*(1 - *pLuz * *pLuz) + nbghost);
2475 mClockFhklCalcVariance.
Click();
2476 VFN_DEBUG_EXIT(
"ScatteringData::CalcStructFactVariance()",3)
CrystVector_REAL GetLatticePar() const
Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians...
const RefinableObjClock & GetClockNbReflBelowMaxSinThetaOvLambda() const
Clock the last time the number of reflections used was changed.
const CrystVector_REAL & GetH() const
Return the 1D array of H coordinates for all reflections.
void Print() const
Print to screen/console the charcteristics of the radiation.
const RefinableObjClock & GetMasterClockScatteringPower() const
Get the clock which reports all changes in ScatteringPowers.
const CrystVector_REAL & GetFhklCalcImag() const
Access to imaginary part of F(hkl)calc.
map< const ScatteringPower *, CrystVector_REAL > mvRealGeomSF
Geometrical Structure factor for each ScatteringPower, as vectors with NbRefl elements.
REAL GetMaximumLikelihoodNbGhostAtom() const
Maximum Likelihood: get the number of ghost elements per asymmetric unit.
virtual long GetNbReflBelowMaxSinThetaOvLambda() const
Recalc, and get the number of reflections which should be actually used, due to the maximuml sin(thet...
RefinableObjClock mClockGeomStructFact
Clock the last time the geometrical structure factors were computed.
map< const ScatteringPower *, REAL > mvFprime
Anomalous X-Ray scattering term f' and f" are stored here for each ScatteringPower We store here only...
bool mIgnoreImagScattFact
Ignore imaginary part of scattering factor.
REAL mXRayTubeDeltaLambda
Absolute difference between alpha1 and alpha2, in angstroems.
RefinableObjClock mClockHKL
Clock for the list of hkl.
void AddSubRefObj(RefinableObj &)
void AddPar(const RefinablePar &newRefPar)
Add a refinable parameter.
RadiationType GetRadiationType() const
Neutron or x-ray experiment ? Wavelength ?
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...
const CrystMatrix_REAL & GetBMatrix() const
Get the 'B' matrix (UnitCell::mBMatrix)for the UnitCell (orthogonalization matrix for the given latti...
const CrystVector_REAL & GetSinThetaOverLambda() const
Return an array with for all reflections.
RefObjOpt mWavelengthType
monochromatic ? Alpha1 & Alpha2 ? Multi-Wavelength ?
const RefinableObjClock & GetClockLatticePar() const
last time the Lattice parameters were changed
void CalcGlobalTemperatureFactor() const
Compute the overall temperature factor affecting all reflections.
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components.
const RefParType * gpRefParTypeScattDataCorrInt
Generic type for correction to calculated intensities.
const cctbx::sgtbx::space_group & GetCCTbxSpg() const
Get the underlying cctbx Spacegroup object.
RefinableObjClock mClockNbReflUsed
Clock recording the last time the number of reflections used has increased.
const CrystVector_REAL & GetTheta() const
Return an array with theta values for all reflections.
virtual CrystMatrix_REAL GetResonantScattFactReal(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the real part of the resonant scattering factor.
virtual void PrepareHKLarrays()
const RefParType * gpRefParTypeScattDataCorrPos
Parameter type for correction to peak positions.
const RefinableObjClock & GetClockSpaceGroup() const
Get the SpaceGroup Clock (corresponding to the time of the initialization of the SpaceGroup) ...
Output vectors as column arrays, with the first 3 columns printed as integers.
RefinableObjClock mClockScattFactor
Clock the last time scattering factors were computed.
CrystVector_REAL mGlobalTemperatureFactor
Global Biso factor.
A scattering position in a crystal, associated with the corresponding occupancy and a pointer to the ...
REAL mMaxSinThetaOvLambda
Maximum sin(theta)/lambda for all calculations (10 by default).
long GetNbComponent() const
Number of components.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
bool IsBeingRefined() const
Is the object being refined ? (Can be refined by one algorithm at a time only.)
virtual void CalcSinThetaLambda() const
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.
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_REAL GetWavelength() const
wavelength of the experiment (in Angstroems)
REAL mLinearPolarRate
Linear Polarization Rate (default:0, X-Ray tube unmonochromatized)
REAL GetMaxSinThetaOvLambda() const
Get the maximum value for sin(theta)/lambda.
CrystVector_REAL mFhklCalcVariance
The variance on all calculated structure factors, taking into account the positionnal errors and the ...
virtual void CalcResonantScattFactor() const
bool HasCrystal() const
Has a Crystal structure associated yet ?
REAL mXRayTubeAlpha2Alpha1Ratio
Ratio alpha2/alpha1 (should be 0.5)
REAL GetMaximumLikelihoodPositionError() const
Maximum Likelihood: get the estimated error (sigma) on the positions for this kind of element...
const RefinableObjClock & GetClockRadiation() const
Last time the nature (X-Rays/Neutron, number of wavelengths)radiation has been changed.
void Click()
Record an event for this clock (generally, the 'time' an object has been modified, or some computation has been made)
bool HasInversionCenter() const
Is centrosymmetric ?
void AddChild(const RefinableObjClock &)
Add a 'child' clock.
RefinableObjClock mClockStructFactor
Clock for the structure factor.
const RefParType * gpRefParTypeScattDataCorrInt_Ellipsoid
Parameter type for the ellipsoid coefficient.
string mXRayTubeName
Name of the X-Ray tube used, if relevant.
long mNbRefl
Number of H,K,L 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 ...
virtual void SetCrystal(Crystal &crystal)
Set the crystal for this experiment.
CrystVector_REAL mWavelength
Wavelength of the Experiment, in Angstroems.
const RefParType * gpRefParTypeScattDataProfile
Type for reflection profile.
map< const ScatteringPower *, CrystVector_REAL > mvTemperatureFactor
Thermic factors for each ScatteringPower, as vectors with NbRefl elements.
const RefParType * gpRefParTypeScattDataProfileAsym
Type for reflection profile asymmetry.
RadiationType GetRadiationType() const
Get the radiation type (X-Rays, Neutron)
virtual void RegisterClient(RefinableObj &) const
Register a new object using this object.
CrystVector_REAL mH2Pi
H,K,L coordinates, multiplied by 2PI.
Class to compute structure factors for a set of reflections and a Crystal.
RefinableObjClock mClockMaster
Master clock, which is changed whenever the object has been altered.
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.
virtual const Radiation & GetRadiation() const =0
Get the radiation object for this data.
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
const RefinableObjClock & GetClockWavelength() const
Last time the wavelength has been changed.
Radiation()
Default constructor.
const CrystVector_REAL & GetL() const
Return the 1D array of L coordinates for all reflections.
REAL mDynPopCorr
Dynamical Population Correction.
const RefParType * gpRefParTypeScattDataScale
Type for scattering data scale factors.
CrystVector_int mMultiplicity
Multiplicity for each reflections (mostly for powder diffraction)
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 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...
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
RefinableObjClock mClockTheta
Clock the last time theta was computed.
void CalcGeomStructFactor() const
Compute the 'Geometrical Structure Factor' for each ScatteringPower of the Crystal.
map< const ScatteringPower *, CrystVector_REAL > mvLuzzatiFactor
The Luzzati 'D' factor for each scattering power and each reflection.
const CrystVector_REAL & GetReflZ() const
Return the 1D array of orthonormal z coordinates for all reflections (recipr. space) ...
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...
virtual CrystVector_long SortReflectionBySinThetaOverLambda(const REAL maxSTOL=-1.)
const RefParType * gpRefParTypeScattDataBackground
Parameter type for background intensity.
REAL GetXRayTubeDeltaLambda() const
Get the wavelength difference for Alpha1 and Alpha2.
int GetNbTranslationVectors() const
Number of translation vectors (1 for 'P' cells, 2 for 'I', 4 for 'F',etc..)
CrystVector_REAL mTheta
theta for the crystal and the HKL in ReciprSpace (in radians)
const RefParType * gpRefParTypeScattDataCorrIntPO_Amplitude
Parameter type for the amplitude of preferred orientation.
RefinableObjClock mClockThermicFact
Clock the last time temperature factors were computed.
The crystallographic space group, and the cell choice.
const ScatteringPower * mpScattPow
The ScatteringPower associated with this position.
void CalcStructFactor() const
Compute the overall structure factor (real and imaginary part).
CrystVector_REAL mH
H,K,L coordinates.
virtual const CrystMatrix_REAL & GetBMatrix() const
Get access to the B matrix used to compute reflection positions.
const map< const ScatteringPower *, CrystVector_REAL > & GetScatteringFactor() const
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
void CalcLuzzatiFactor() const
Calculate the Luzzati factor associated to each ScatteringPower and each reflection, for maximum likelihood optimization.
const RefinableObjClock & GetClockScattCompList() const
Get the list of all scattering components.
WavelengthType GetWavelengthType() const
Get the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
CrystVector_long mIntH
H,K,L integer coordinates.
CrystVector_REAL mSinThetaLambda
for the crystal and the reflections in ReciprSpace
virtual CrystMatrix_REAL GetResonantScattFactImag(const ScatteringData &data, const int spgSymPosIndex=-1) const =0
Get the imaginary part of the resonant scattering factor.
const CrystVector_REAL & GetK2Pi() const
Return the 1D array of K coordinates for all reflections, multiplied by 2*pi.
void SetIsIgnoringImagScattFact(const bool b)
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
void SetWavelength(const REAL)
Set the (monochromatic) wavelength of the beam.
const CrystVector_REAL & GetReflY() const
Return the 1D array of orthonormal y coordinates for all reflections (recipr. space) ...
const CrystVector_REAL & GetFhklCalcSq() const
Returns the Array of calculated |F(hkl)|^2 for all reflections.
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.
const CrystVector_REAL & GetReflX() const
Return the 1D array of orthonormal x coordinates for all reflections (recipr. space) ...
virtual void SetMaxSinThetaOvLambda(const REAL max)
Set the maximum value for sin(theta)/lambda.
void CalcScattFactor() const
WavelengthType
Incident beam characteristics : monochromatic, X-Ray tube with Alpha1 and alpha2, MAD (a few waveleng...
const CrystVector_REAL & GetFhklObsSq() const
Returns the Array of observed |F(hkl)|^2 for all reflections.
RefinableObjClock mClockScattFactorResonant
Clock the last time resonant scattering factors were computed.
RefObjOpt mRadiationType
Neutron ? X-Ray ? (Electron: unimplemented)
const RefParType * gpRefParTypeScattDataProfileWidth
Type for reflection profile width.
REAL mGlobalBiso
Global Biso, affecting the overall structure factor for all reflections (but not the structure factor...
const RefParType * gpRefParTypeScattDataCorrIntAbsorp
Parameter type for absorption correction.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
void SetRadiationType(const RadiationType)
Set the radiation type (X-Rays, Neutron)
CrystVector_REAL mFhklObsSq
Observed squared structure factors (zero-sized if none)
const CrystVector_REAL & GetWavelength() const
Get the wavelength(s) in Angstroems.
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
const Crystal & GetCrystal() const
Const access to the data's crystal.
output a string with a fixed length (adding necessary space or removing excess characters) : ...
const RefParType * gpRefParTypeScattDataProfileType
Type for reflection profiles type (e.g. gaussian/lorentzian mix)
const CrystVector_REAL & GetFhklCalcReal() const
Access to real part of F(hkl)calc.
CrystVector_REAL mFhklCalcSq
F(HKL)^2 calc for each reflection.
const RefParType * gpRefParTypeScattDataCorrIntPolar
Parameter type for polarization correction.
long mNbReflUsed
Number of reflections which are below the max.
bool IsInversionCenterAtOrigin() const
Is the center of symmetry at the origin ?
CrystVector_long EliminateExtinctReflections()
const CrystVector_REAL & GetL2Pi() const
Return the 1D array of L coordinates for all reflections, multiplied by 2*pi.
unsigned int GetExpectedIntensityFactor(const REAL h, const REAL k, const REAL l) const
Get the "expected intensity factor" for a given reflection.
map< const ScatteringPower *, CrystVector_REAL > mvScatteringFactor
Scattering factors for each ScatteringPower, as vectors with NbRefl elements.
Crystal * mpCrystal
Pointer to the crystal corresponding to this experiment.
const RefParType * gpRefParTypeScattDataCorr
Generic type for scattering data correction parameter.
void Reset()
Reset a Clock to 0, to force an update.
CrystVector_int mExpectedIntensityFactor
Expected intensity factor for all reflections.
void CalcTemperatureFactor() const
Exception class for ObjCryst++ library.
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
long GetNbRefl() const
Return the number of reflections in this experiment.
const RefinableObjClock & GetClockTheta() const
Clock the last time the sin(theta)/lambda and theta arrays were re-computed.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
REAL GetXRayTubeAlpha2Alpha1Ratio() const
Get the Kalpha2/Kalpha1 ratio.
Generic class for parameters of refinable objects.
const RefParType * gpRefParTypeScattDataCorrIntPO_Direction
Parameter type for preferred orientation direction.
RefinableObjClock mClockStructFactorSq
Clock for the square modulus of the structure factor.
RefinableObjClock mClockFhklObsSq
Last time observed squared structure factors were altered.
RefinableObjClock mClockGlobalBiso
last time the global Biso factor was modified
virtual const string & GetName() const
Name of the object.
virtual void PrintFhklCalc(ostream &os=cout) const
Print H, K, L F^2 Re(F) Im(F) theta sin(theta)/lambda for all reflections.
bool mUseFastLessPreciseFunc
Use faster, but less precise, approximations for functions? (integer approximations to compute sin an...
int GetSpaceGroupNumber() const
Id number of the spacegroup.
RefinableObjClock mClockGlobalTemperatureFact
last time the global temperature factor was computed
virtual void SetApproximationFlag(const bool allow)
Enable or disable numerical approximations.
virtual void SetHKL(const CrystVector_REAL &h, const CrystVector_REAL &k, const CrystVector_REAL &l)
input H,K,L
const RefParType * gpRefParTypeScattDataCorrIntExtinc
Parameter type for extinction correction.
RadiationType
Type of radiation used.
virtual void EndOptimization()
This should be called by any optimization class at the end of an optimization.
const RefParType * gpRefParTypeScattDataCorrIntPO_Fraction
Parameter type for fraction of preferred orientation.
Crystal class: Unit cell, spacegroup, scatterers.
void SetWavelengthType(const WavelengthType &type)
Set the Wavelength type (monochromatic, Alpha1+Alpha2, Time Of Flight...)
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.
class of refinable parameter types.
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
void CalcStructFactVariance() const
Calculate the variance associated to the calculated structure factor.
const CrystVector_REAL & GetK() const
Return the 1D array of K coordinates for all reflections.
virtual void DeRegisterClient(RefinableObj &) const
Deregister an object (which not any more) using this object.
const RefParType * gpRefParTypeScattData
Generic type for scattering data.
CrystVector_REAL mFhklCalcReal
real &imaginary parts of F(HKL)calc
Class to define the radiation (type, monochromaticity, wavelength(s)) of an experiment.
const CrystVector_REAL & GetH2Pi() const
Return the 1D array of H coordinates for all reflections, multiplied by 2*pi.
int mOptimizationDepth
Is the object being refined or optimized ? if mOptimizationDepth=0, no optimization is taking place...
void AddOption(RefObjOpt *opt)
bool IsIgnoringImagScattFact() const
If true, then the imaginary part of the scattering factor is ignored during Structure factor computat...
CrystVector_REAL mX
reflection coordinates in an orthonormal base
const std::vector< SpaceGroup::TRx > & GetTranslationVectors() const
Return all Translation Vectors, as a 3 columns-array.
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...