26 #include "ObjCryst/ObjCryst/General.h"
27 #include "ObjCryst/ObjCryst/IO.h"
28 #include "ObjCryst/RefinableObj/IO.h"
29 #include "ObjCryst/RefinableObj/GlobalOptimObj.h"
31 #include "ObjCryst/ObjCryst/Scatterer.h"
32 #include "ObjCryst/ObjCryst/Crystal.h"
33 #include "ObjCryst/ObjCryst/ZScatterer.h"
35 #include "ObjCryst/ObjCryst/ScatteringPower.h"
36 #include "ObjCryst/ObjCryst/ScatteringPowerSphere.h"
37 #include "ObjCryst/ObjCryst/Atom.h"
38 #include "ObjCryst/ObjCryst/DiffractionDataSingleCrystal.h"
39 #include "ObjCryst/ObjCryst/PowderPattern.h"
40 #include "ObjCryst/Quirks/VFNStreamFormat.h"
41 #include "ObjCryst/ObjCryst/Molecule.h"
47 #include "boost/format.hpp"
63 ss.imbue(std::locale::classic());
72 while(0==isgraph(is.peek())) is.get();
75 while((endchar!=is.peek())&&(
' '!=is.peek()))
79 tmp<<(char)(tolower(c)) ;
81 if(tmp.str().find(
"nan")!=string::npos)
83 VFN_DEBUG_MESSAGE(
"InputFloat(..):"<<tmp.str()<<
" -> NAN ! -> 1",9);
86 if(tmp.str().find(
"inf")!=string::npos)
88 VFN_DEBUG_MESSAGE(
"InputFloat(..):"<<tmp.str()<<
" -> INF ! -> 1",9);
91 tmp.imbue(std::locale::classic());
93 VFN_DEBUG_MESSAGE(
"InputFloat(..):"<<f<<
","<<is.good(),3);
99 #if defined(_MSC_VER) || defined(__BORLANDC__)
100 return _isnan(r) || (!_finite(r));
102 return (isnan(r)!=0) || (isinf(r)!=0);
108 VFN_DEBUG_ENTRY(
"XMLCrystFileSaveGlobal(filename)",5)
110 ofstream out(filename.c_str());
114 VFN_DEBUG_EXIT(
"XMLCrystFileSaveGlobal(filename):End",5)
119 VFN_DEBUG_ENTRY(
"XMLCrystFileSaveGlobal(ostream)",5)
120 out.imbue(
std::locale::classic());
124 strftime(strDate,sizeof(strDate),"%Y-%m-%dT%H:%M:%S%Z",gmtime(&date));
125 tag.AddAttribute("Date",strDate);
126 tag.AddAttribute("Revision","1280");
135 for(
int i=0;i<gPowderPatternRegistry.GetNb();i++)
136 gPowderPatternRegistry.GetObj(i).XMLOutput(out,1);
141 tag.SetIsEndTag(true);
148 VFN_DEBUG_ENTRY(
"XMLCrystFileLoadObjectList(filename)",5)
150 ifstream is(filename.c_str());
152 is.imbue(std::locale::classic());
159 VFN_DEBUG_EXIT(
"XMLCrystFileLoadObjectList(filename):End",5)
160 for(
int i=0;i<reg.
GetNb();i++) reg.
GetObj(i).Print();
165 if((
"Crystal"==pTag->GetName()||
166 "DiffractionDataSingleCrystal"==pTag->GetName()||
167 "PowderPattern"==pTag->GetName()||
168 "GlobalOptimObj"==pTag->GetName())
169 && !(pTag->IsEndTag())) reg.
Register(*pTag);
176 const string &tagName,
177 const string &name, T*obj)
179 VFN_DEBUG_ENTRY(
"XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
181 ifstream is(filename.c_str());
183 is.imbue(std::locale::classic());
190 cout<<
"XMLCrystFileLoadObject(filename,IOCrystTag,T&):Not Found !"<<endl;
193 VFN_DEBUG_EXIT(
"XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
196 if(tagName!=tag.GetName())
continue;
197 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
198 if(
"Name"==tag.GetAttributeName(i))
199 if(name==tag.GetAttributeValue(i))
break;
201 VFN_DEBUG_MESSAGE(
"XMLCrystFileLoadObject(filename,IOCrystTag,T&):Found"<<tag,5)
203 obj->XMLInput(is,tag);
205 VFN_DEBUG_EXIT(
"XMLCrystFileLoadObject(filename,IOCrystTag,T&)",5)
213 DiffractionDataSingleCrystal*);
217 PowderPatternBackground*);
219 PowderPatternDiffraction*);
225 VFN_DEBUG_ENTRY(
"XMLCrystFileLoadAllObject(filename,)",5)
226 ifstream is(filename.c_str());
227 if(is.fail())
throw ObjCrystException(
"XMLCrystFileLoadAllObject() failed input");
229 (*fpObjCrystInformUser)(
"Finished loading XML file:"+filename);
230 VFN_DEBUG_EXIT(
"XMLCrystFileLoadAllObject(filename,)",5)
234 VFN_DEBUG_ENTRY(
"XMLCrystFileLoadAllObject(istream)",5)
235 is.imbue(
std::locale::classic());
237 do {is>>tag;}
while((
"ObjCryst"!=tag.GetName()) && (
false==is.eof()));
242 if(
true==is.eof())
break;
243 if(tag.GetName()==
"Crystal")
245 Crystal* obj =
new Crystal;
246 obj->XMLInput(is,tag);
248 if(tag.GetName()==
"PowderPattern")
250 PowderPattern* obj =
new PowderPattern;
251 obj->XMLInput(is,tag);
253 if(tag.GetName()==
"DiffractionDataSingleCrystal")
255 DiffractionDataSingleCrystal* obj =
new DiffractionDataSingleCrystal;
256 obj->XMLInput(is,tag);
258 if(tag.GetName()==
"GlobalOptimObj")
260 MonteCarloObj* obj =
new MonteCarloObj;
261 obj->XMLInput(is,tag);
264 (*fpObjCrystInformUser)(
"Finished loading XML");
265 VFN_DEBUG_EXIT(
"XMLCrystFileLoadAllObject(istream)",5)
274 VFN_DEBUG_ENTRY(
"ScatteringPowerAtom::XMLOutput():"<<this->
GetName(),5)
275 for(
int i=0;i<indent;i++) os <<
" " ;
277 tag.AddAttribute(
"Name",
mName);
278 tag.AddAttribute(
"Symbol",
mSymbol);
285 REAL* bdata = (REAL*)
mB.data();
309 for(
int i=0;i<=indent;i++) os <<
" " ;
315 tag2.SetIsEndTag(
true);
318 tag.SetIsEndTag(
true);
319 for(
int i=0;i<indent;i++) os <<
" " ;
321 VFN_DEBUG_EXIT(
"ScatteringPowerAtom::XMLOutput():"<<this->
GetName(),5)
326 VFN_DEBUG_ENTRY(
"ScatteringPowerAtom::XMLInput():"<<this->
GetName(),5)
327 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
329 if(
"Name"==tagg.GetAttributeName(i)) this->
SetName(tagg.GetAttributeValue(i));
330 if(
"Symbol"==tagg.GetAttributeName(i))
mSymbol=tagg.GetAttributeValue(i);
332 (*fpObjCrystInformUser)(
"Input ScatteringPowerAtom:"+
mName+
"("+
mSymbol+
")");
337 if((
"ScatteringPowerAtom"==tag.GetName())&&tag.IsEndTag())
339 VFN_DEBUG_EXIT(
"ScatteringPowerAtom::Exit():"<<this->
GetName(),5)
342 if(
"RGBColour"==tag.GetName())
349 if(
"Par"==tag.GetName())
351 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
353 if(
"Name"==tag.GetAttributeName(i))
355 if(
"Biso"==tag.GetAttributeValue(i))
361 if(
"B11"==tag.GetAttributeValue(i))
367 if(
"B22"==tag.GetAttributeValue(i))
373 if(
"B33"==tag.GetAttributeValue(i))
379 if(
"B12"==tag.GetAttributeValue(i))
385 if(
"B13"==tag.GetAttributeValue(i))
391 if(
"B23"==tag.GetAttributeValue(i))
397 if(
"ML Error"==tag.GetAttributeValue(i))
402 if(
"ML-NbGhost"==tag.GetAttributeValue(i))
407 if(
"Formal Charge"==tag.GetAttributeValue(i))
425 VFN_DEBUG_ENTRY(
"Atom::XMLOutput():"<<this->
GetName(),5)
426 for(
int i=0;i<indent;i++) os <<
" " ;
428 tag.AddAttribute(
"Name",
mName);
446 tag.SetIsEndTag(
true);
448 for(
int i=0;i<indent;i++) os <<
" " ;
451 VFN_DEBUG_EXIT(
"Atom::XMLOutput():"<<this->
GetName(),5)
456 VFN_DEBUG_ENTRY(
"Atom::XMLInput():"<<this->
GetName(),5)
458 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
460 if(
"Name"==tagg.GetAttributeName(i)) this->
SetName(tagg.GetAttributeValue(i));
461 if(
"ScattPow"==tagg.GetAttributeName(i)) scattPowName=tagg.GetAttributeValue(i);
463 (*fpObjCrystInformUser)(
"XML: Loading Atom:"+this->
GetName());
466 VFN_DEBUG_MESSAGE(
"Found Scattering Power:"<< scattPowName<<
" at "<<scattPow,4);
471 if((
"Atom"==tag.GetName())&&tag.IsEndTag())
473 VFN_DEBUG_EXIT(
"Atom::Exit():"<<this->
GetName(),5)
476 if(
"Par"==tag.GetName())
478 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
480 if(
"Name"==tag.GetAttributeName(i))
482 if(
"x"==tag.GetAttributeValue(i))
487 if(
"y"==tag.GetAttributeValue(i))
492 if(
"z"==tag.GetAttributeValue(i))
497 if(
"Occup"==tag.GetAttributeValue(i))
513 void ZAtom::XMLOutput(ostream &os,
int indent)
const
515 VFN_DEBUG_ENTRY(
"ZAtom::XMLOutput():"<<this->GetName(),5)
516 for(
int i=0;i<indent;i++) os << " " ;
518 tag.AddAttribute("Name",
mName);
541 this->
GetZScatterer().GetPar(&mAngle).XMLOutput(os,"Angle",indent);
544 this->
GetZScatterer().GetPar(&mDihed).XMLOutput(os,"DihedAng",indent);
547 this->
GetZScatterer().GetPar(&mOccupancy).XMLOutput(os,"Occup",indent);
551 tag.SetIsEndTag(true);
552 for(
int i=0;i<indent;i++) os << " " ;
554 VFN_DEBUG_EXIT("ZAtom::XMLOutput():"<<this->GetName(),5)
557 void ZAtom::XMLInput(istream &is,const
XMLCrystTag &tagg)
559 VFN_DEBUG_ENTRY(
"ZAtom::XMLInput():"<<this->GetName(),5)
560 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
562 if(
"Name"==tagg.GetAttributeName(i))
564 this->SetName(tagg.GetAttributeValue(i));
567 if(
"ScattPow"==tagg.GetAttributeName(i))
572 .GetObj(tagg.GetAttributeValue(i)));
576 if(
"BondAtom"==tagg.GetAttributeName(i))
581 if(
"AngleAtom"==tagg.GetAttributeName(i))
586 if(
"DihedAtom"==tagg.GetAttributeName(i))
595 if((
"ZAtom"==tag.GetName())&&tag.IsEndTag())
597 VFN_DEBUG_EXIT(
"ZAtom::Exit():"<<this->GetName(),5)
600 if("Par"==tag.GetName())
602 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
604 if(
"Name"==tag.GetAttributeName(i))
606 if(
"BondLength"==tag.GetAttributeValue(i))
611 if(
"Angle"==tag.GetAttributeValue(i))
616 if(
"DihedAng"==tag.GetAttributeValue(i))
621 if(
"Occup"==tag.GetAttributeValue(i))
640 VFN_DEBUG_ENTRY(
"ZScatterer::XMLOutput():"<<this->GetName(),5)
641 for(
int i=0;i<indent;i++) os <<
" " ;
643 tag.AddAttribute(
"Name",mName);
647 this->GetPar(mXYZ.data()+0).XMLOutput(os,
"x",indent);
650 this->GetPar(mXYZ.data()+1).XMLOutput(os,
"y",indent);
653 this->GetPar(mXYZ.data()+2).XMLOutput(os,
"z",indent);
656 this->GetPar(&mOccupancy).XMLOutput(os,
"Occup",indent);
659 this->GetPar(&mPhi).XMLOutput(os,
"Phi",indent);
662 this->GetPar(&mChi).XMLOutput(os,
"Chi",indent);
665 this->GetPar(&mPsi).XMLOutput(os,
"Psi",indent);
668 for(
int i=0;i<mZAtomRegistry.GetNb();i++) mZAtomRegistry.GetObj(i).XMLOutput(os,indent);
670 if(mZAtomRegistry.GetNb()>0)
672 for(
int i=0;i<=indent;i++) os <<
" " ;
674 tag2.AddAttribute(
"Name",this->GetZAtomRegistry().GetObj(mCenterAtomIndex).GetName());
679 tag.SetIsEndTag(
true);
680 for(
int i=0;i<indent;i++) os <<
" " ;
682 VFN_DEBUG_EXIT(
"ZScatterer::XMLOutput():"<<this->GetName(),5)
687 VFN_DEBUG_ENTRY(
"ZScatterer::XMLInput():"<<this->GetName(),5)
688 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
690 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
692 (*fpObjCrystInformUser)(
"XML: Loading ZScatterer:"+this->GetName());
696 if((
"ZScatterer"==tag.GetName())&&tag.IsEndTag())
698 VFN_DEBUG_EXIT(
"ZScatterer::Exit():"<<this->GetName(),5)
701 if(
"Par"==tag.GetName())
703 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
705 if(
"Name"==tag.GetAttributeName(i))
707 if(
"x"==tag.GetAttributeValue(i))
709 this->GetPar(mXYZ.data()+0).XMLInput(is,tag);
712 if(
"y"==tag.GetAttributeValue(i))
714 this->GetPar(mXYZ.data()+1).XMLInput(is,tag);
717 if(
"z"==tag.GetAttributeValue(i))
719 this->GetPar(mXYZ.data()+2).XMLInput(is,tag);
722 if(
"Occup"==tag.GetAttributeValue(i))
724 this->GetPar(&mOccupancy).XMLInput(is,tag);
727 if(
"Phi"==tag.GetAttributeValue(i))
729 this->GetPar(&mPhi).XMLInput(is,tag);
732 if(
"Chi"==tag.GetAttributeValue(i))
734 this->GetPar(&mChi).XMLInput(is,tag);
737 if(
"Psi"==tag.GetAttributeValue(i))
739 this->GetPar(&mPsi).XMLInput(is,tag);
746 if(
"ZAtom"==tag.GetName())
750 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
751 if(
"ScattPow"==tag.GetAttributeName(i))
752 scattPow=&(this->GetCrystal().GetScatteringPowerRegistry()
753 .GetObj(tag.GetAttributeValue(i)));
754 const long nb=mZAtomRegistry.GetNb();
755 this->AddAtom(
"",scattPow,0,0,0,0,0,1);
756 mZAtomRegistry.GetObj(nb).XMLInput(is,tag);
760 sprintf(buf,
"%d-%d",(
int)nb,(
int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()));
761 this->GetPar(&(mZAtomRegistry.GetObj(nb).mBondLength))
762 .SetName(
"Length"+(
string)buf);
764 sprintf(buf,
"%d-%d-%d",(
int)nb,(
int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()),
765 (
int)(mZAtomRegistry.GetObj(nb).GetZAngleAtom()));
766 this->GetPar(&(mZAtomRegistry.GetObj(nb).mAngle))
767 .SetName(
"Angle"+(
string)buf);
769 sprintf(buf,
"%d-%d-%d-%d",(
int)nb,(
int)(mZAtomRegistry.GetObj(nb).GetZBondAtom()),
770 (
int)(mZAtomRegistry.GetObj(nb).GetZAngleAtom()),
771 (
int)(mZAtomRegistry.GetObj(nb).GetZDihedralAngleAtom()));
772 this->GetPar(&(mZAtomRegistry.GetObj(nb).mDihed))
773 .SetName(
"Dihed"+(
string)buf);
776 if(
"PivotAtom"==tag.GetName())
778 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
779 if(
"Name"==tag.GetAttributeName(i))
781 mCenterAtomIndex=this->GetZAtomRegistry().Find(tag.GetAttributeValue(i));
793 VFN_DEBUG_ENTRY(
"Crystal::XMLOutput():"<<this->GetName(),5)
795 for(
int i=0;i<indent;i++) os <<
" " ;
797 tag.AddAttribute(
"Name",mName);
798 tag.AddAttribute(
"SpaceGroup",this->GetSpaceGroup().GetName());
803 this->GetPar(
"a").XMLOutput(os,
"a",indent);
806 this->GetPar(
"b").XMLOutput(os,
"b",indent);
809 this->GetPar(
"c").XMLOutput(os,
"c",indent);
812 this->GetPar(
"alpha").XMLOutput(os,
"alpha",indent);
815 this->GetPar(
"beta").XMLOutput(os,
"beta",indent);
818 this->GetPar(
"gamma").XMLOutput(os,
"gamma",indent);
821 for(
unsigned int i=0;i<this->GetNbOption();i++)
823 this->GetOption(i).XMLOutput(os,indent);
827 for(
int i=0;i<mScatteringPowerRegistry.GetNb();i++)
828 mScatteringPowerRegistry.GetObj(i).XMLOutput(os,indent);
830 for(
int i=0;i<mScattererRegistry.GetNb();i++)
831 mScattererRegistry.GetObj(i).XMLOutput(os,indent);
834 if(mvBumpMergePar.size()>0)
836 VBumpMergePar::const_iterator pos;
837 for(pos=mvBumpMergePar.begin();pos!=mvBumpMergePar.end();pos++)
839 for(
int k=0;k<=indent;k++) os <<
" " ;
841 tagBump.AddAttribute(
"ScattPow1",pos->first.first->GetName());
842 tagBump.AddAttribute(
"ScattPow2",pos->first.second->GetName());
845 ss << pos->second.mCanOverlap;
846 tagBump.AddAttribute(
"AllowMerge",ss.str());
849 tagBump.SetIsEndTag(
true);
850 os<<sqrt(pos->second.mDist2)<<tagBump<<endl;
852 for(
int k=0;k<=indent;k++) os <<
" " ;
854 os << tag2<< mBumpMergeScale;
855 tag2.SetIsEndTag(
true);
858 if(mvBondValenceRo.size()>0)
860 map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>::const_iterator pos;
861 for(pos=mvBondValenceRo.begin();pos!=mvBondValenceRo.end();pos++)
863 for(
int k=0;k<=indent;k++) os <<
" " ;
865 tagBVRo.AddAttribute(
"ScattPow1",pos->first.first->GetName());
866 tagBVRo.AddAttribute(
"ScattPow2",pos->first.second->GetName());
868 tagBVRo.SetIsEndTag(
true);
869 os<<pos->second<<tagBVRo<<endl;
871 for(
int k=0;k<=indent;k++) os <<
" " ;
873 os << tag2<< mBondValenceCostScale;
874 tag2.SetIsEndTag(
true);
879 tag.SetIsEndTag(
true);
880 for(
int i=0;i<indent;i++) os <<
" " ;
882 VFN_DEBUG_EXIT(
"Crystal::XMLOutput():"<<this->GetName(),5)
887 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():"<<this->GetName(),5)
888 (*fpObjCrystInformUser)(
"XML: Loading Crystal:");
890 for(
long i=0;i<mScatteringPowerRegistry.GetNb();i++)
892 this->RemoveSubRefObj(mScatteringPowerRegistry.GetObj(i));
893 mScatteringPowerRegistry.GetObj(i).DeRegisterClient(*
this);
895 mScatteringPowerRegistry.DeleteAll();
896 for(
long i=0;i<mScattererRegistry.GetNb();i++)
898 this->RemoveSubRefObj(mScattererRegistry.GetObj(i));
899 mScattererRegistry.GetObj(i).DeRegisterClient(*
this);
901 mScattererRegistry.DeleteAll();
903 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
905 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
906 if(
"SpaceGroup"==tagg.GetAttributeName(i))
907 this->Init(1,2,3,M_PI/2,M_PI/2,M_PI/2,tagg.GetAttributeValue(i),this->GetName());
909 (*fpObjCrystInformUser)(
"XML: Loading Crystal:"+this->GetName()+
"(spg:"+this->GetSpaceGroup().GetName()+
")");
913 if((
"Crystal"==tag.GetName())&&tag.IsEndTag())
915 this->UpdateDisplay();
916 VFN_DEBUG_EXIT(
"Crystal::Exit():"<<this->GetName(),5)
919 if(
"Par"==tag.GetName())
921 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
923 if(
"Name"==tag.GetAttributeName(i))
925 this->GetPar(tag.GetAttributeValue(i)).XMLInput(is,tag);
930 if(
"Option"==tag.GetName())
932 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
933 if(
"Name"==tag.GetAttributeName(i))
934 mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
935 this->InitRefParList();
938 if(
"AntiBumpDistance"==tag.GetName())
945 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
947 if(
"AllowMerge"==tag.GetAttributeName(i))
949 stringstream ss(tag.GetAttributeValue(i));
954 if(
"ScattPow1"==tag.GetAttributeName(i)) scattPow1=tag.GetAttributeValue(i);
955 if(
"ScattPow2"==tag.GetAttributeName(i)) scattPow2=tag.GetAttributeValue(i);
960 this->SetBumpMergeDistance(mScatteringPowerRegistry.GetObj(scattPow1),
961 mScatteringPowerRegistry.GetObj(scattPow2),
963 else this->SetBumpMergeDistance(mScatteringPowerRegistry.GetObj(scattPow1),
964 mScatteringPowerRegistry.GetObj(scattPow2),
968 if(
"BondValenceRo"==tag.GetName())
973 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
975 if(
"ScattPow1"==tag.GetAttributeName(i)) scattPow1=tag.GetAttributeValue(i);
976 if(
"ScattPow2"==tag.GetAttributeName(i)) scattPow2=tag.GetAttributeValue(i);
980 this->AddBondValenceRo(mScatteringPowerRegistry.GetObj(scattPow1),
981 mScatteringPowerRegistry.GetObj(scattPow2),ro);
984 if(
"AntiBumpScale"==tag.GetName())
989 if(
"BondValenceCostScale"==tag.GetName())
991 is>>mBondValenceCostScale;
994 if(
"Atom"==tag.GetName())
996 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():reading an Atom",5)
1000 this->AddScatterer(at);
1001 VFN_DEBUG_EXIT(
"Crystal::XMLInput():reading an Atom",5)
1004 if(
"ScatteringPowerAtom"==tag.GetName())
1006 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1007 VFN_DEBUG_MESSAGE(
"Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1010 this->AddScatteringPower(sc);
1011 VFN_DEBUG_EXIT(
"Crystal::XMLInput():reading a ScatteringPowerAtom",5)
1014 if(
"ScatteringPowerSphere"==tag.GetName())
1016 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1017 VFN_DEBUG_MESSAGE(
"Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1020 this->AddScatteringPower(sc);
1021 VFN_DEBUG_EXIT(
"Crystal::XMLInput():reading a ScatteringPowerSphere",5)
1024 if(
"ZScatterer"==tag.GetName())
1026 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():reading a ZScatterer",5)
1027 VFN_DEBUG_MESSAGE(
"Crystal::XMLInput():reading a ZScatterer",5)
1030 this->AddScatterer(z);
1031 VFN_DEBUG_EXIT(
"Crystal::XMLInput():reading a ZScatterer",5)
1034 if(
"Molecule"==tag.GetName())
1036 VFN_DEBUG_ENTRY(
"Crystal::XMLInput():reading a Molecule",5)
1037 VFN_DEBUG_MESSAGE(
"Crystal::XMLInput():reading a Molecule",5)
1040 this->AddScatterer(z);
1041 VFN_DEBUG_EXIT(
"Crystal::XMLInput():reading a Molecule",5)
1045 (*fpObjCrystInformUser)(
"XML: Finished loading Crystal:"+this->GetName());
1054 VFN_DEBUG_ENTRY(
"Radiation::XMLOutput():"<<this->GetName(),5)
1056 if(WAVELENGTH_ALPHA12==this->GetWavelengthType())
1057 tag.AddAttribute(
"XRayTube",mXRayTubeName);
1058 for(
int i=0;i<indent;i++) os <<
" " ;
1062 mRadiationType.XMLOutput(os,indent);
1065 mWavelengthType.XMLOutput(os,indent);
1068 for(
int i=0;i<indent;i++) os <<
" " ;
1071 os << tag2<< mLinearPolarRate;
1072 tag2.SetIsEndTag(
true);
1076 if(WAVELENGTH_ALPHA12==this->GetWavelengthType())
1078 for(
int i=0;i<indent;i++) os <<
" " ;
1081 os << tag2<< mXRayTubeDeltaLambda;
1082 tag2.SetIsEndTag(
true);
1085 for(
int i=0;i<indent;i++) os <<
" " ;
1088 os << tag2<< mXRayTubeAlpha2Alpha1Ratio;
1089 tag2.SetIsEndTag(
true);
1094 switch(this->GetWavelengthType())
1096 case WAVELENGTH_MONOCHROMATIC: this->GetPar(mWavelength.data()).XMLOutput(os,indent);
break;
1097 case WAVELENGTH_ALPHA12:
1099 this->GetPar(mWavelength.data()).XMLOutput(os,
"Wavelength",indent);
1102 case WAVELENGTH_TOF:
break;
1108 tag.SetIsEndTag(
true);
1109 for(
int i=0;i<indent;i++) os <<
" " ;
1112 VFN_DEBUG_EXIT(
"Radiation::XMLOutput():"<<this->GetName(),5)
1117 VFN_DEBUG_ENTRY(
"Radiation::XMLInput():"<<this->GetName(),5)
1118 string scattPowName;
1119 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
1121 if(
"XRayTube"==tagg.GetAttributeName(i))
1122 if(tagg.GetAttributeValue(i)!=
"")
1123 this->SetWavelength(tagg.GetAttributeValue(i));
1129 if((
"Radiation"==tag.GetName())&&tag.IsEndTag())
1131 VFN_DEBUG_EXIT(
"Radiation::Exit():"<<this->GetName(),5)
1134 if(
"Option"==tag.GetName())
1136 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1137 if(
"Name"==tag.GetAttributeName(i))
1139 if(
"Radiation"==tag.GetAttributeValue(i)) mRadiationType.XMLInput(is,tag);
1140 if(
"Spectrum"==tag.GetAttributeValue(i)) mWavelengthType.XMLInput(is,tag);
1143 if(
"LinearPolarRate"==tag.GetName())
1145 is>>mLinearPolarRate;
1148 if(
"XRayTubeDeltaLambda"==tag.GetName())
1150 is>>mXRayTubeDeltaLambda;
1153 if(
"XRayTubeAlpha2Alpha1Ratio"==tag.GetName())
1155 is>>mXRayTubeAlpha2Alpha1Ratio;
1158 if(
"Par"==tag.GetName())
1160 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1162 if(
"Name"==tag.GetAttributeName(i))
1164 if(
"Wavelength"==tag.GetAttributeValue(i))
1166 this->GetPar(mWavelength.data()).XMLInput(is,tag);
1182 VFN_DEBUG_ENTRY(
"DiffractionDataSingleCrystal::XMLOutput():"<<this->GetName(),5)
1183 for(
int i=0;i<indent;i++) os <<
" " ;
1185 tag.AddAttribute(
"Name",mName);
1186 tag.AddAttribute(
"Crystal",this->GetCrystal().GetName());
1190 this->GetPar(
"Scale factor").XMLOutput(os,
"Scale factor",indent);
1193 mRadiation.XMLOutput(os,indent);
1196 this->GetPar(&mGlobalBiso).XMLOutput(os,
"globalBiso",indent);
1199 mGroupOption.XMLOutput(os,indent);
1202 for(
int i=0;i<indent;i++) os <<
" " ;
1204 os << tag2<< mMaxSinThetaOvLambda;
1205 tag2.SetIsEndTag(
true);
1206 os << tag2<<endl<<endl;
1208 if(mGroupOption.GetChoice()!=2)
1211 for(
int i=0;i<indent;i++) os <<
" " ;
1214 for(
long j=0;j<this->GetNbRefl();j++)
1216 for(
int i=0;i<=indent;i++) os <<
" " ;
1217 os << mIntH(j) <<
" "
1220 << mObsIntensity(j) <<
" "
1221 << mObsSigma(j) <<
" "
1226 tag3.SetIsEndTag(
true);
1227 for(
int i=0;i<indent;i++) os <<
" " ;
1233 for(
int i=0;i<indent;i++) os <<
" " ;
1237 for(
long j=0;j<mNbGroup;j++)
1243 tag4.AddAttribute(
"Iobs",s.str());
1248 tag4.AddAttribute(
"IobsSigma",s.str());
1253 tag4.AddAttribute(
"Weight",s.str());
1255 for(
int i=0;i<=indent;i++) os <<
" " ;
1257 for(
long k=first;k<mGroupIndex(j);k++)
1259 for(
int i=0;i<=indent;i++) os <<
" " ;
1260 os << mIntH(k) <<
" "<< mIntK(k) <<
" "<< mIntL(k) <<
" "<<endl;
1262 for(
int i=0;i<=indent;i++) os <<
" " ;
1263 tag4.SetIsEndTag(
true);
1265 first=mGroupIndex(j);
1268 tag3.SetIsEndTag(
true);
1269 for(
int i=0;i<indent;i++) os <<
" " ;
1274 tag.SetIsEndTag(
true);
1275 for(
int i=0;i<indent;i++) os <<
" " ;
1277 VFN_DEBUG_EXIT(
"DiffractionDataSingleCrystal::XMLOutput():"<<this->GetName(),5)
1282 VFN_DEBUG_ENTRY(
"DiffractionDataSingleCrystal::XMLInput():"<<this->GetName(),5)
1283 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
1285 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1286 if(
"Crystal"==tagg.GetAttributeName(i))
1289 (*fpObjCrystInformUser)(
"XML: Loading Single Crystall data:"+this->GetName());
1293 if((
"DiffractionDataSingleCrystal"==tag.GetName())&&tag.IsEndTag())
1295 this->UpdateDisplay();
1296 VFN_DEBUG_EXIT(
"DiffractionDataSingleCrystal::XMLInput():"<<this->GetName(),5)
1299 if(
"Option"==tag.GetName())
1301 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1302 if(
"Name"==tag.GetAttributeName(i))
1304 string name=tag.GetAttributeValue(i);
1305 if(name==
"Twinning correction") name=
"Group Reflections";
1306 mOptionRegistry.GetObj(name).XMLInput(is,tag);
1310 if(
"Par"==tag.GetName())
1312 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1314 if(
"Name"==tag.GetAttributeName(i))
1316 if(
"Scale factor"==tag.GetAttributeValue(i))
1318 this->GetPar(&mScaleFactor).XMLInput(is,tag);
1324 if(
"Radiation"==tag.GetName()) mRadiation.XMLInput(is,tag);
1325 if(
"MaxSinThetaOvLambda"==tag.GetName())
1327 is>>mMaxSinThetaOvLambda;
1330 if(
"Par"==tag.GetName())
1332 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1334 if(
"Name"==tag.GetAttributeName(i))
1336 if(
"globalBiso"==tag.GetAttributeValue(i))
1338 this->GetPar(&mGlobalBiso).XMLInput(is,tag);
1344 if(
"HKLIobsSigmaWeightList"==tag.GetName())
1347 CrystVector_long h(100),k(100),l(100);
1348 CrystVector_REAL iobs(100),sigma(100),weight(100);
1351 is >>h(nbrefl)>>k(nbrefl)>>l(nbrefl);
1357 if(nbrefl==iobs.numElements())
1359 h.resizeAndPreserve(nbrefl+100);
1360 k.resizeAndPreserve(nbrefl+100);
1361 l.resizeAndPreserve(nbrefl+100);
1362 iobs.resizeAndPreserve(nbrefl+100);
1363 sigma.resizeAndPreserve(nbrefl+100);
1364 weight.resizeAndPreserve(nbrefl+100);
1366 while(0==isgraph(is.peek())) is.get();
1369 while(is.peek()!=
'<');
1372 h.resizeAndPreserve(nbrefl);
1373 k.resizeAndPreserve(nbrefl);
1374 l.resizeAndPreserve(nbrefl);
1375 iobs.resizeAndPreserve(nbrefl);
1376 sigma.resizeAndPreserve(nbrefl);
1377 weight.resizeAndPreserve(nbrefl);
1378 this->SetHklIobs(h,k,l,iobs,sigma);
1379 this->SetWeight(weight);
1380 this->SortReflectionBySinThetaOverLambda();
1382 this->FitScaleFactorForRw();
1384 if(
"HKLIobsSigmaWeightGROUPList"==tag.GetName())
1389 mGroupOption.SetChoice(2);
1391 mOptionRegistry.DeRegister(mGroupOption);
1392 mClockMaster.RemoveChild(mGroupOption.GetClock());
1396 mObsIntensity.resize(500);
1397 mObsSigma.resize(500);
1398 mGroupIndex.resize(500);
1399 mGroupIobs.resize(500);
1400 mGroupSigma.resize(500);
1401 mGroupWeight.resize(500);
1405 if(grouptag.GetName()==
"HKLIobsSigmaWeightGROUPList")
break;
1406 if(grouptag.GetName()==
"HKLGroup")
1408 for(
unsigned int i=0;i<grouptag.GetNbAttribute();++i)
1410 if(grouptag.GetAttributeName(i)==
"Iobs")
1413 sst<<grouptag.GetAttributeValue(i);
1414 sst>>mGroupIobs(mNbGroup);
1417 if(grouptag.GetAttributeName(i)==
"IobsSigma")
1420 sst<<grouptag.GetAttributeValue(i);
1421 sst>>mGroupSigma(mNbGroup);
1424 if(grouptag.GetAttributeName(i)==
"Weight")
1427 sst<<grouptag.GetAttributeValue(i);
1428 sst>>mGroupWeight(mNbGroup);
1432 VFN_DEBUG_MESSAGE(
"Group #"<<mNbGroup<<
" ,Iobs="<<mGroupIobs(mNbGroup)<<
" ,Sigma="<<mGroupSigma(mNbGroup)<<
" ,Weight="<<mGroupWeight(mNbGroup),2)
1435 is >>mH(mNbRefl)>>mK(mNbRefl)>>mL(mNbRefl);
1436 VFN_DEBUG_MESSAGE(
" "<<mH(mNbRefl)<<
" "<<mK(mNbRefl)<<
" "<<mL(mNbRefl),2)
1437 mGroupIndex(mNbRefl)=mNbGroup;
1439 if(mNbRefl==mH.numElements())
1441 mH.resizeAndPreserve(mNbRefl+500);
1442 mK.resizeAndPreserve(mNbRefl+500);
1443 mL.resizeAndPreserve(mNbRefl+500);
1444 mObsIntensity.resizeAndPreserve(mNbRefl+500);
1445 mObsSigma.resizeAndPreserve(mNbRefl+500);
1446 mGroupIndex.resizeAndPreserve(mNbRefl+500);
1448 while(0==isgraph(is.peek())) is.get();
1450 while(is.peek()!=
'<');
1452 if(++mNbGroup==mGroupIobs.numElements())
1454 mGroupIobs.resizeAndPreserve(mNbGroup+500);
1455 mGroupSigma.resizeAndPreserve(mNbGroup+500);
1456 mGroupWeight.resizeAndPreserve(mNbGroup+500);
1460 mH.resizeAndPreserve(mNbRefl);
1461 mK.resizeAndPreserve(mNbRefl);
1462 mL.resizeAndPreserve(mNbRefl);
1463 mObsIntensity.resizeAndPreserve(mNbRefl);
1464 mObsSigma.resizeAndPreserve(mNbRefl);
1465 mWeight.resizeAndPreserve(mNbRefl);
1466 mGroupIndex.resizeAndPreserve(mNbRefl);
1468 mGroupIobs.resizeAndPreserve(mNbGroup);
1469 mGroupWeight.resizeAndPreserve(mNbGroup);
1470 mGroupSigma.resizeAndPreserve(mNbGroup);
1472 mHasObservedData=
true;
1474 mMultiplicity.resize(mNbRefl);
1477 this->PrepareHKLarrays();
1478 this->SortReflectionBySinThetaOverLambda();
1481 (*fpObjCrystInformUser)(
"XML: Finished loading Single Crystal Data:"+this->GetName());
1490 VFN_DEBUG_ENTRY(
"PowderPatternBackground::XMLOutput():"<<this->GetName(),5)
1491 for(
int i=0;i<indent;i++) os <<
" " ;
1493 tag.AddAttribute(
"Name",this->GetName());
1497 mInterpolationModel.XMLOutput(os,indent);
1501 for(
int i=0;i<indent;i++) os <<
" " ;
1505 if(this->GetParentPowderPattern().GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1508 for(
long j=0;j<mBackgroundNbPoint;j++)
1511 for(
int i=0;i<=indent;i++) os <<
" " ;
1512 os << mBackgroundInterpPointX(j)*scale <<
" "
1513 << mBackgroundInterpPointIntensity(j) <<
" "
1514 << !this->GetPar(mBackgroundInterpPointIntensity.data()+j).IsFixed()<<
" "
1518 tag2.SetIsEndTag(
true);
1519 for(
int i=0;i<indent;i++) os <<
" " ;
1522 #ifdef USE_BACKGROUND_MAXLIKE_ERROR
1523 this->GetPar(
"ML Model Error").XMLOutput(os,
"ML Model Error",indent);
1528 tag.SetIsEndTag(
true);
1529 for(
int i=0;i<indent;i++) os <<
" " ;
1531 VFN_DEBUG_EXIT(
"PowderPatternBackground::XMLOutput():"<<this->GetName(),5)
1536 VFN_DEBUG_ENTRY(
"PowderPatternBackground::XMLInput():"<<this->GetName(),5)
1537 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
1539 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1540 if(
"Interpolation"==tagg.GetAttributeName(i))
1542 if(
"Linear"==tagg.GetAttributeValue(i)) mInterpolationModel.SetChoice(0);
1543 if(
"Spline"==tagg.GetAttributeValue(i)) mInterpolationModel.SetChoice(1);
1549 if((
"PowderPatternBackground"==tag.GetName())&&tag.IsEndTag())
1551 this->UpdateDisplay();
1552 VFN_DEBUG_EXIT(
"PowderPatternBackground::Exit():"<<this->GetName(),5)
1555 if((
"TThetaIntensityList"==tag.GetName())||(
"XIntensityList"==tag.GetName()))
1558 CrystVector_REAL bckgd2Theta(100);
1559 CrystVector_REAL bckgd(100);
1560 CrystVector_bool fix(100);
1563 VFN_DEBUG_MESSAGE(
"PowderPatternBackground::XMLInput():"<<mBackgroundNbPoint,1)
1564 is >>bckgd2Theta(nbPoint)
1568 if(nbPoint==bckgd2Theta.numElements())
1570 bckgd2Theta.resizeAndPreserve(nbPoint+100);
1571 bckgd.resizeAndPreserve(nbPoint+100);
1572 fix.resizeAndPreserve(nbPoint+100);
1574 while(0==isgraph(is.peek())) is.get();
1577 while(is.peek()!=
'<');
1578 bckgd2Theta.resizeAndPreserve(nbPoint);
1579 bckgd.resizeAndPreserve(nbPoint);
1580 if(this->GetParentPowderPattern().GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
1581 bckgd2Theta*= DEG2RAD;
1582 this->SetInterpPoints(bckgd2Theta,bckgd);
1583 this->InitRefParList();
1587 if(
"Par"==tag.GetName())
1589 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1591 if(
"Name"==tag.GetAttributeName(i))
1593 if(
"ML Model Error"==tag.GetAttributeValue(i))
1595 #ifdef USE_BACKGROUND_MAXLIKE_ERROR
1596 this->GetPar(
"ML Model Error").XMLInput(is,tag);
1603 if(
"Option"==tag.GetName())
1605 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1606 if(
"Name"==tag.GetAttributeName(i))
1607 mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
1619 VFN_DEBUG_ENTRY(
"PowderPatternDiffraction::XMLOutput():"<<this->GetName(),5)
1620 for(
int i=0;i<indent;i++) os <<
" " ;
1622 tag.AddAttribute(
"Name",this->GetName());
1623 tag.AddAttribute(
"Crystal",this->GetCrystal().GetName());
1626 ss<<this->IsIgnoringImagScattFact();
1627 tag.AddAttribute(
"IgnoreImagScattFact",ss.str());
1632 if(mFreezeLatticePar)
1635 t.AddAttribute(
"a", (boost::format(
"%f")%mFrozenLatticePar(0)).str() );
1636 t.AddAttribute(
"b", (boost::format(
"%f")%mFrozenLatticePar(1)).str() );
1637 t.AddAttribute(
"c", (boost::format(
"%f")%mFrozenLatticePar(2)).str() );
1638 t.AddAttribute(
"alpha", (boost::format(
"%f")%(mFrozenLatticePar(3)*180/M_PI)).str() );
1639 t.AddAttribute(
"beta" , (boost::format(
"%f")%(mFrozenLatticePar(4)*180/M_PI)).str() );
1640 t.AddAttribute(
"gamma", (boost::format(
"%f")%(mFrozenLatticePar(5)*180/M_PI)).str() );
1641 t.SetIsEmptyTag(
true);
1642 for(
int i=0;i<indent;i++) os <<
" " ;
1646 if(mpReflectionProfile!=0) mpReflectionProfile->XMLOutput(os,indent);
1648 this->GetPar(&mGlobalBiso).XMLOutput(os,
"globalBiso",indent);
1651 if(mCorrTextureMarchDollase.GetNbPhase()>0)
1653 mCorrTextureMarchDollase.XMLOutput(os,indent);
1656 mCorrTextureEllipsoid.XMLOutput(os,indent);
1659 if(mFhklObsSq.numElements()>0)
1662 for(
int i=0;i<indent;i++) os <<
" " ;
1665 for(
long j=0;j<this->GetNbRefl();j++)
1667 for(
int i=0;i<=indent;i++) os <<
" " ;
1668 os << mIntH(j) <<
" "
1671 << mFhklObsSq(j) <<endl;
1674 tag2.SetIsEndTag(
true);
1675 for(
int i=0;i<indent;i++) os <<
" " ;
1679 if(mpLeBailData!=0) mpLeBailData->XMLOutput(os,indent);
1683 tag.SetIsEndTag(
true);
1684 for(
int i=0;i<indent;i++) os <<
" " ;
1686 VFN_DEBUG_EXIT(
"PowderPatternDiffraction::XMLOutput():"<<this->GetName(),5)
1691 VFN_DEBUG_ENTRY(
"PowderPatternDiffraction::XMLInput():"<<this->GetName(),5)
1692 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
1694 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
1695 if(
"Crystal"==tagg.GetAttributeName(i))
1697 if(
"NeedLorentzCorr"==tagg.GetAttributeName(i))
1699 stringstream ss(tagg.GetAttributeValue(i));
1705 if(
"NeedPolarCorr"==tagg.GetAttributeName(i))
1707 stringstream ss(tagg.GetAttributeValue(i));
1713 if(
"Polar_AFactor"==tagg.GetAttributeName(i))
1715 stringstream ss(tagg.GetAttributeValue(i));
1721 if(
"NeedSlitApertureCorr"==tagg.GetAttributeName(i))
1723 stringstream ss(tagg.GetAttributeValue(i));
1729 if(
"IgnoreImagScattFact"==tagg.GetAttributeName(i))
1731 stringstream ss(tagg.GetAttributeValue(i));
1734 this->SetIsIgnoringImagScattFact(b);
1735 mClockLorentzPolarSlitCorrPar.Reset();
1741 if((
"PowderPatternCrystal"==tag.GetName())&&tag.IsEndTag())
1743 this->UpdateDisplay();
1744 VFN_DEBUG_EXIT(
"PowderPatternDiffraction::Exit():"<<this->GetName(),5)
1747 if(
"Par"==tag.GetName())
1749 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1751 if(
"Name"==tag.GetAttributeName(i))
1753 if(
"globalBiso"==tag.GetAttributeValue(i))
1755 this->GetPar(&mGlobalBiso).XMLInput(is,tag);
1758 if(
"U"==tag.GetAttributeValue(i))
1760 mpReflectionProfile->GetPar(
"U").XMLInput(is,tag);
1763 if(
"V"==tag.GetAttributeValue(i))
1765 mpReflectionProfile->GetPar(
"V").XMLInput(is,tag);
1768 if(
"W"==tag.GetAttributeValue(i))
1770 mpReflectionProfile->GetPar(
"W").XMLInput(is,tag);
1773 if(
"Eta0"==tag.GetAttributeValue(i))
1775 mpReflectionProfile->GetPar(
"Eta0").XMLInput(is,tag);
1778 if(
"Eta1"==tag.GetAttributeValue(i))
1780 mpReflectionProfile->GetPar(
"Eta1").XMLInput(is,tag);
1783 if(
"W0"==tag.GetAttributeValue(i))
1788 if(
"W1"==tag.GetAttributeValue(i))
1793 if(
"W2"==tag.GetAttributeValue(i))
1802 if(
"Option"==tag.GetName())
1804 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1806 if(
"Name"==tag.GetAttributeName(i))
1808 if(
"Profile Type"!=tag.GetAttributeValue(i))
1809 mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
1814 if(
"TextureMarchDollase"==tag.GetName())
1816 mCorrTextureMarchDollase.XMLInput(is,tag);
1819 if(
"TextureEllipsoid"==tag.GetName())
1821 mCorrTextureEllipsoid.XMLInput(is,tag);
1824 if(
"ReflectionProfilePseudoVoigt"==tag.GetName())
1826 if(mpReflectionProfile==0)
1831 if(mpReflectionProfile->GetClassName()!=
"ReflectionProfilePseudoVoigt")
1835 mpReflectionProfile->XMLInput(is,tag);
1838 if(
"ReflectionProfilePseudoVoigtAnisotropic"==tag.GetName())
1840 if(mpReflectionProfile==0)
1845 if(mpReflectionProfile->GetClassName()!=
"ReflectionProfilePseudoVoigtAnisotropic")
1849 mpReflectionProfile->XMLInput(is,tag);
1852 if(
"ReflectionProfileDoubleExponentialPseudoVoigt"==tag.GetName())
1854 if(mpReflectionProfile==0)
1860 if(mpReflectionProfile->GetClassName()!=
"ReflectionProfileDoubleExponentialPseudoVoigt")
1864 mpReflectionProfile->XMLInput(is,tag);
1867 if(
"FhklObsSq"==tag.GetName())
1870 CrystVector_REAL iobs(100),sigma;
1871 CrystVector_long h(100),k(100),l(100);
1872 mFhklObsSq.resize(100);
1875 is >>h(nbrefl)>>k(nbrefl)>>l(nbrefl)>>iobs(nbrefl);
1877 if(nbrefl==h.numElements())
1879 h.resizeAndPreserve(nbrefl+100);
1880 k.resizeAndPreserve(nbrefl+100);
1881 l.resizeAndPreserve(nbrefl+100);
1882 iobs.resizeAndPreserve(nbrefl+100);
1884 while(0==isgraph(is.peek())) is.get();
1886 while(is.peek()!=
'<');
1888 h.resizeAndPreserve(nbrefl);
1889 k.resizeAndPreserve(nbrefl);
1890 l.resizeAndPreserve(nbrefl);
1891 iobs.resizeAndPreserve(nbrefl);
1892 sigma.resizeAndPreserve(nbrefl);
1897 mpLeBailData->SetHklIobs(h,k,l,iobs,sigma);
1898 mpLeBailData->SetWavelength(this->GetRadiation().GetWavelength()(0));
1899 mpLeBailData->SetRadiationType(this->GetRadiation().GetRadiationType());
1902 const REAL min=iobs.max()*1e-6;
1903 unsigned long iresol=0;
1904 for(
long i=0;i<nbrefl;++i) if(iobs(i)>min) iresol=i;
1906 sprintf(buf,
"LeBail (d=%4.2fA?):",1/(2*abs(mpLeBailData->GetSinThetaOverLambda()(iresol))+1e-6));
1907 mpLeBailData->SetName(
string(buf)+this->GetCrystal().GetName());
1910 if(
"DiffractionDataSingleCrystal"==tag.GetName())
1913 mpLeBailData->XMLInput(is,tag);
1915 if(
"FrozenLatticePar"==tag.GetName())
1917 this->FreezeLatticePar(
true);
1918 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
1920 if(
"a"==tag.GetAttributeName(i))
1922 stringstream ss(tag.GetAttributeValue(i));
1926 this->SetFrozenLatticePar(0,v);
1928 if(
"b"==tag.GetAttributeName(i))
1930 stringstream ss(tag.GetAttributeValue(i));
1934 this->SetFrozenLatticePar(1,v);
1936 if(
"c"==tag.GetAttributeName(i))
1938 stringstream ss(tag.GetAttributeValue(i));
1942 this->SetFrozenLatticePar(2,v);
1944 if(
"alpha"==tag.GetAttributeName(i))
1946 stringstream ss(tag.GetAttributeValue(i));
1950 this->SetFrozenLatticePar(3,v*M_PI/180);
1952 if(
"beta"==tag.GetAttributeName(i))
1954 stringstream ss(tag.GetAttributeValue(i));
1958 this->SetFrozenLatticePar(4,v*M_PI/180);
1960 if(
"gamma"==tag.GetAttributeName(i))
1962 stringstream ss(tag.GetAttributeValue(i));
1966 this->SetFrozenLatticePar(5,v*M_PI/180);
1979 VFN_DEBUG_ENTRY(
"PowderPattern::XMLOutput():"<<this->GetName(),5)
1980 for(
int i=0;i<indent;i++) os <<
" " ;
1982 tag.AddAttribute(
"Name",mName);
1986 this->GetPar(&mXZero).XMLOutput(os,
"Zero",indent);
1988 if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
1990 this->GetPar(&mDIFC).XMLOutput(os,
"TOF-DIFC",indent);
1993 this->GetPar(&mDIFA).XMLOutput(os,
"TOF-DIFA",indent);
1998 this->GetPar(&m2ThetaDisplacement).XMLOutput(os,
"2ThetaDisplacement",indent);
2001 this->GetPar(&m2ThetaTransparency).XMLOutput(os,
"2ThetaTransparency",indent);
2005 for(
unsigned int i=0;i<this->GetNbOption();i++)
2007 this->GetOption(i).XMLOutput(os,indent);
2011 mRadiation.XMLOutput(os,indent);
2014 for(
int i=0;i<indent;i++) os <<
" " ;
2016 os << tag2<< mMaxSinThetaOvLambda;
2017 tag2.SetIsEndTag(
true);
2018 os << tag2<<endl<<endl;
2021 for(
int j=0;j<mPowderPatternComponentRegistry.GetNb();j++)
2023 mPowderPatternComponentRegistry.GetObj(j).XMLOutput(os,indent);
2024 XMLCrystTag tagg(
"PowderPatternComponent",
false,
true);
2027 ss<<mScaleFactor(j);
2028 tagg.AddAttribute(
"Scale",ss.str());
2030 tagg.AddAttribute(
"Name",mPowderPatternComponentRegistry.GetObj(j).GetName());
2032 for(
int i=0;i<indent;i++) os <<
" " ;
2033 os<<tagg<<endl<<endl;
2036 for(
int i=0;i<indent;i++) os <<
" " ;
2040 if(this->GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
2043 for(
unsigned long j=0;j<this->GetNbPoint();j++)
2045 for(
int i=0;i<=indent;i++) os <<
" " ;
2046 os << scale*mX(j) <<
" "
2047 << mPowderPatternObs(j) <<
" "
2048 << mPowderPatternObsSigma(j) <<
" "
2049 << mPowderPatternWeight(j) <<
" "
2052 tag2.SetIsEndTag(
true);
2053 for(
int i=0;i<indent;i++) os <<
" " ;
2056 for(
int j=0;j<mExcludedRegionMinX.numElements();j++)
2059 for(
int i=0;i<indent;i++) os <<
" " ;
2060 if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
2063 << mExcludedRegionMinX(j) <<
" "
2064 << mExcludedRegionMaxX(j) ;
2069 << mExcludedRegionMinX(j)*RAD2DEG <<
" "
2070 << mExcludedRegionMaxX(j)*RAD2DEG ;
2072 tag3.SetIsEndTag(
true);
2078 tag.SetIsEndTag(
true);
2079 for(
int i=0;i<indent;i++) os <<
" " ;
2081 VFN_DEBUG_EXIT(
"PowderPattern::XMLOutput():"<<this->GetName(),5)
2086 VFN_DEBUG_ENTRY(
"PowderPattern::XMLInput():"<<this->GetName(),5)
2087 for(
unsigned int i=0;i<tagg.GetNbAttribute();i++)
2089 if(
"Name"==tagg.GetAttributeName(i)) this->SetName(tagg.GetAttributeValue(i));
2091 (*fpObjCrystInformUser)(
"XML: Loading Powder Pattern:"+this->GetName());
2095 if((
"PowderPattern"==tag.GetName())&&tag.IsEndTag())
2097 this->UpdateDisplay();
2098 VFN_DEBUG_EXIT(
"PowderPattern::Exit():"<<this->GetName(),5)
2101 if(
"Radiation"==tag.GetName()) mRadiation.XMLInput(is,tag);
2102 if(
"MaxSinThetaOvLambda"==tag.GetName())
2104 is>>mMaxSinThetaOvLambda;
2107 if(
"Par"==tag.GetName())
2109 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
2111 if(
"Name"==tag.GetAttributeName(i))
2113 if((
"2ThetaZero"==tag.GetAttributeValue(i)) ||(
"Zero"==tag.GetAttributeValue(i)))
2115 this->GetPar(&mXZero).XMLInput(is,tag);
2118 if(
"2ThetaDisplacement"==tag.GetAttributeValue(i))
2120 this->GetPar(&m2ThetaDisplacement).XMLInput(is,tag);
2123 if(
"2ThetaTransparency"==tag.GetAttributeValue(i))
2125 this->GetPar(&m2ThetaTransparency).XMLInput(is,tag);
2128 if(
"TOF-DIFC"==tag.GetAttributeValue(i))
2130 this->GetPar(&mDIFC).XMLInput(is,tag);
2133 if(
"TOF-DIFA"==tag.GetAttributeValue(i))
2135 this->GetPar(&mDIFA).XMLInput(is,tag);
2142 if(
"Option"==tag.GetName())
2144 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
2145 if(
"Name"==tag.GetAttributeName(i))
2146 mOptionRegistry.GetObj(tag.GetAttributeValue(i)).XMLInput(is,tag);
2149 if(
"PowderPatternBackground"==tag.GetName())
2156 if(
"PowderPatternCrystal"==tag.GetName())
2163 if(
"PowderPatternComponent"==tag.GetName())
2167 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
2169 if(
"Scale"==tag.GetAttributeName(i))
2171 stringstream ss(tag.GetAttributeValue(i));
2175 if(
"Name"==tag.GetAttributeName(i)) name=tag.GetAttributeValue(i);
2178 mScaleFactor(mPowderPatternComponentRegistry.GetNb()-1)=scale;
2179 VFN_DEBUG_MESSAGE(
"->Adding Component :"<<name<<
"with scale="<<scale,8);
2182 if(
"ExcludeX"==tag.GetName())
2186 if(this->GetRadiation().GetWavelengthType()==WAVELENGTH_TOF)
2187 this->AddExcludedRegion(min,max);
2188 else this->AddExcludedRegion(min*DEG2RAD,max*DEG2RAD);
2192 if(
"IobsSigmaWeightList"==tag.GetName())
2195 VFN_DEBUG_ENTRY(
"Loading Iobs-Sigma-Weight List...",8);
2197 for(
unsigned int i=0;i<tag.GetNbAttribute();i++)
2199 if(
"TThetaMin"==tag.GetAttributeName(i))
2201 stringstream ss(tag.GetAttributeValue(i));
2203 VFN_DEBUG_MESSAGE(
"2Theta min="<<min,8);
2206 if(
"TThetaStep"==tag.GetAttributeName(i))
2208 stringstream ss(tag.GetAttributeValue(i));
2210 VFN_DEBUG_MESSAGE(
"2Theta step="<<step<<tag.GetAttributeValue(i),8);
2214 while(0==isgraph(is.peek())) is.get();
2217 cout <<
"PowderPattern::XMLInput(): no data point in the powder pattern !"<<endl;
2219 VFN_DEBUG_EXIT(
"Loading Iobs-Sigma-Weight List...",8);
2223 mPowderPatternObs.resize(500);
2224 mPowderPatternObsSigma.resize(500);
2225 mPowderPatternWeight.resize(500);
2228 is >>mPowderPatternObs(mNbPoint)
2229 >>mPowderPatternObsSigma(mNbPoint)
2230 >>mPowderPatternWeight(mNbPoint);
2232 VFN_DEBUG_MESSAGE(
"Point #"<<mNbPoint,5);
2233 if(mNbPoint==(
unsigned long)mPowderPatternObs.numElements())
2235 mPowderPatternObs.resizeAndPreserve(mNbPoint+500);
2236 mPowderPatternObsSigma.resizeAndPreserve(mNbPoint+500);
2237 mPowderPatternWeight.resizeAndPreserve(mNbPoint+500);
2239 while(0==isgraph(is.peek())) is.get();
2241 while(is.peek()!=
'<');
2242 this->SetPowderPatternPar(min,step,mNbPoint);
2243 mClockPowderPatternPar.Click();
2246 VFN_DEBUG_EXIT(
"Loading Iobs-Sigma-Weight List...",8);
2249 if(
"XIobsSigmaWeightList"==tag.GetName())
2251 VFN_DEBUG_ENTRY(
"Loading X-Iobs-Sigma-Weight List...",8);
2252 while(0==isgraph(is.peek())) is.get();
2255 cout <<
"PowderPattern::XMLInput(): no data point in the powder pattern !"<<endl;
2257 VFN_DEBUG_EXIT(
"Loading Iobs-Sigma-Weight List...",8);
2262 mPowderPatternObs.resize(500);
2263 mPowderPatternObsSigma.resize(500);
2264 mPowderPatternWeight.resize(500);
2268 >>mPowderPatternObs(mNbPoint)
2269 >>mPowderPatternObsSigma(mNbPoint)
2270 >>mPowderPatternWeight(mNbPoint);
2272 VFN_DEBUG_MESSAGE(
"Point #"<<mNbPoint,5);
2273 if(mNbPoint==(
unsigned long)mPowderPatternObs.numElements())
2275 mX.resizeAndPreserve(mNbPoint+500);
2276 mPowderPatternObs.resizeAndPreserve(mNbPoint+500);
2277 mPowderPatternObsSigma.resizeAndPreserve(mNbPoint+500);
2278 mPowderPatternWeight.resizeAndPreserve(mNbPoint+500);
2280 while(0==isgraph(is.peek())) is.get();
2282 while(is.peek()!=
'<');
2283 mX.resizeAndPreserve(mNbPoint);
2284 if(this->GetRadiation().GetWavelengthType()!=WAVELENGTH_TOF)
2286 this->SetPowderPatternX(mX);
2289 VFN_DEBUG_EXIT(
"Loading X-Iobs-Sigma-Weight List...",8);
T & GetObj(const unsigned int i)
Get object #i in the registry.
void Init(const REAL x, const REAL y, const REAL z, const string &name, const ScatteringPower *pow, const REAL popu=1)
initialize the atom (used for arrays of atoms).
void SetScatteringPower(const ScatteringPower *)
Set the ScatteringPower.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Pseudo-Voigt reflection profile, with 6-parameters anisotropic Lorentzian broadening and Toraya asymm...
void SetColour(const string &colorName)
Set the colour from the associated POV-Ray name.
Double-Exponential Pseudo-Voigt profile for TOF.
float string2floatC(const string &s)
Function to convert a substring to a floating point value, imposing a C locale (using '...
long GetNb() const
Get the index of an object in the registry, from its name Warning: it can change if an object is remo...
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
void Register(T &obj)
Register a new object. Already registered objects are skipped.
virtual void SetParentPowderPattern(PowderPattern &)
Set the PowderPattern object which uses this component.
CrystVector_REAL mXYZ
coordinates of the scatterer (or of its center..)
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
bool ISNAN_OR_INF(REAL r)
Test if the value is a NaN.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
ObjRegistry< OptimizationObj > gOptimizationObjRegistry("List of all Optimization objects")
Global Registry for all OptimizationObj.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Phase to compute a background contribution to a powder pattern using an interpolation.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
void XMLInput(istream &is, const XMLCrystTag &tag)
XMLInput From stream.
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
Class to compute the contribution to a powder pattern from a crystalline phase.
void XMLCrystFileLoadObject(const string &filename, const string &tagName, const string &name, T *obj)
Load an object from a file, identifying it from its tag.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
long GetZBondAtom() const
Index of the 1st atom used to define the atom in the Z-Matrix (the one from which the bondlength is c...
long GetZDihedralAngleAtom() const
Index of the 3rd atom used to define the atom in the Z-Matrix (the one from which the dihedral angle ...
bool mIsIsotropic
Is the scattering isotropic ?
virtual void SetParentPowderPattern(PowderPattern &)
Set the PowderPattern object which uses this component.
ObjRegistry< PowderPatternComponent > gPowderPatternComponentRegistry("List of all PowderPattern Components")
Global registry for all PowderPatternComponent objects.
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
REAL mBiso
Temperature isotropic B factor.
\ brief ScatteringPower for a spherical particule
ObjRegistry< DiffractionDataSingleCrystal > gDiffractionDataSingleCrystalRegistry("Global DiffractionDataSingleCrystal Registry")
Global registry for all PowderPattern objects.
float InputFloat(istream &is, const char endchar)
Safely read a floating-point value from a stream.
string mName
Name for this RefinableObject. Should be unique, at least in the same scope.+.
const ZScatterer & GetZScatterer() const
Get the ZScatterer associated to this ZAtom.
The basic atom scatterer, in a crystal.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
string mName
Name for this atom.
void XMLCrystFileSaveGlobal(const string &filename)
Save all Objcryst++ objects.
CrystVector_REAL mB
Anisotropic B(ij)
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
Class for individual atoms in a ZScatterer Object.
const ScatteringPower * mpScattPowAtom
The ScatteringPowerAtom associated to that atom.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
long mAtomBond
The index (in the ZScatterer) of the atoms which are used to define the position of this atom...
DiffractionData object for Single Crystal analysis.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
void XMLCrystFileLoadAllObject(const string &filename)
Load all 'top' objects from a file (Crystal, PowderPattern, DiffDataSingleCrystal and GlobalOptimObj ...
REAL mOccupancy
Occupancy : 0 <= occ <= 1 For a multi-atom scatterer (polyhedron,..), this is the overall occupancy o...
long GetZAngleAtom() const
Index of the 2nd atom used to define the atom in the Z-Matrix (the one from which the angle is calcul...
string mSymbol
Symbol of this atom.
void Init()
Initialization of the object, used by all constructors, and operator=.
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
ObjRegistry< XMLCrystTag > XMLCrystFileLoadObjectList(const string &filename)
Get the list (tags) of ObjCryst objects in a file.
float mColourRGB[3]
Colour for this ScatteringPower using RGB.
void SetCrystal(Crystal &)
Set the crystal in which is included this Scatterer.
ZScatterer: the basic type of complex scatterers, where atom positions are defined using a standard "...
const Crystal & GetCrystal() const
In which crystal is this Scatterer included ?
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Exception class for ObjCryst++ library.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
The Scattering Power for an Atom.
virtual const string & GetName() const
Name of the object.
REAL mBondLength
Bond length, angle and dihedral angle.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
Pseudo-Voigt reflection profile.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
class to input or output a well-formatted xml beginning or ending tag.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
const ObjRegistry< ZAtom > & GetZAtomRegistry() const
Access to the registry of ZAtoms.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
const ScatteringPower * GetScatteringPower() const
ScatteringPower for this atom.
virtual void SetName(const string &name)
Name of the object.
void XMLOutput(ostream &os, const string &name, int indent=0) const
XMLOutput to stream in well-formed XML.
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...