29 #include "cctbx/sgtbx/space_group.h"
31 #include "ObjCryst/ObjCryst/Crystal.h"
32 #include "ObjCryst/ObjCryst/Molecule.h"
33 #include "ObjCryst/ObjCryst/Atom.h"
35 #include "ObjCryst/Quirks/VFNStreamFormat.h"
36 #include "ObjCryst/Quirks/VFNDebug.h"
39 #include "ObjCryst/wxCryst/wxCrystal.h"
47 const RefParType *gpRefParTypeCrystal=0;
48 long NiftyStaticGlobalObjectsInitializer_Crystal::mCount=0;
57 mScattererRegistry(
"List of Crystal Scatterers"),
58 mBumpMergeCost(0.0),mBumpMergeScale(1.0),
59 mDistTableMaxDistance(1.0),
60 mScatteringPowerRegistry(
"List of Crystal ScatteringPowers"),
61 mBondValenceCost(0.0),mBondValenceCostScale(1.0),mDeleteSubObjInDestructor(1)
63 VFN_DEBUG_MESSAGE(
"Crystal::Crystal()",10)
65 this->
Init(10,11,12,M_PI/2+.1,M_PI/2+.2,M_PI/2+.3,
"P1",
"");
73 Crystal::Crystal(
const REAL a,
const REAL b,
const REAL c,
const string &SpaceGroupId):
74 mScattererRegistry(
"List of Crystal Scatterers"),
75 mBumpMergeCost(0.0),mBumpMergeScale(1.0),
76 mDistTableMaxDistance(1.0),
77 mScatteringPowerRegistry(
"List of Crystal ScatteringPowers"),
78 mBondValenceCost(0.0),mBondValenceCostScale(1.0),mDeleteSubObjInDestructor(1)
80 VFN_DEBUG_MESSAGE(
"Crystal::Crystal(a,b,c,Sg)",10)
81 this->
Init(a,b,c,M_PI/2,M_PI/2,M_PI/2,SpaceGroupId,
"");
91 const REAL beta,
const REAL gamma,
const string &SpaceGroupId):
92 mScattererRegistry(
"List of Crystal Scatterers"),
93 mBumpMergeCost(0.0),mBumpMergeScale(1.0),
94 mDistTableMaxDistance(1.0),
95 mScatteringPowerRegistry(
"List of Crystal ScatteringPowers"),
96 mBondValenceCost(0.0),mBondValenceCostScale(1.0),mDeleteSubObjInDestructor(1)
98 VFN_DEBUG_MESSAGE(
"Crystal::Crystal(a,b,c,alpha,beta,gamma,Sg)",10)
99 this->
Init(a,b,c,alpha,beta,gamma,SpaceGroupId,
"");
109 mScattererRegistry(
"List of Crystal Scatterers"),
110 mBumpMergeCost(0.0),mBumpMergeScale(1.0),
111 mDistTableMaxDistance(1.0),
112 mScatteringPowerRegistry(
"List of Crystal ScatteringPowers"),
113 mBondValenceCost(0.0),mBondValenceCostScale(1.0),mDeleteSubObjInDestructor(1)
115 VFN_DEBUG_MESSAGE(
"Crystal::Crystal()",10)
118 this->
Init(10,11,12,M_PI/2+.1,M_PI/2+.2,M_PI/2+.3,
"P1",
"");
133 VFN_DEBUG_ENTRY(
"Crystal::~Crystal()",5)
136 VFN_DEBUG_MESSAGE(
"Crystal::~Crystal(&scatt):1:"<<i,5)
140 if( mDeleteSubObjInDestructor )
150 VFN_DEBUG_MESSAGE(
"Crystal::~Crystal(&scatt):2:"<<i,5)
155 if( mDeleteSubObjInDestructor )
165 VFN_DEBUG_EXIT(
"Crystal::~Crystal()",5)
170 const static string className=
"Crystal";
176 VFN_DEBUG_ENTRY(
"Crystal::AddScatterer(&scatt)",5)
182 VFN_DEBUG_EXIT(
"Crystal::AddScatterer(&scatt):Finished",5)
187 VFN_DEBUG_MESSAGE(
"Crystal::RemoveScatterer(&scatt)",5)
191 if(del)
delete scatt;
193 VFN_DEBUG_MESSAGE(
"Crystal::RemoveScatterer(&scatt):Finished",5)
239 VFN_DEBUG_ENTRY(
"Crystal::RemoveScatteringPower()",2)
245 if(del)
delete scattPow;
249 if((pos->first.first==scattPow)||(pos->first.second==scattPow))
257 for(map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>::iterator
260 if((pos->first.first==scattPow)||(pos->first.second==scattPow))
267 VFN_DEBUG_EXIT(
"Crystal::RemoveScatteringPower()",2)
297 VFN_DEBUG_MESSAGE(
"Crystal::GetScatteringComponentList()",2)
298 TAU_PROFILE(
"Crystal::GetScatteringComponentList()",
"ScattCompList& ()",TAU_DEFAULT);
311 VFN_DEBUG_MESSAGE(
"Crystal::GetScatteringComponentList():End",2)
324 void Crystal::Print(ostream &os)
const
326 VFN_DEBUG_MESSAGE(
"Crystal::Print()",5)
327 this->UnitCell::Print(os);
335 std::map<long, REAL>::const_iterator posBV;
346 <<
", Occup=" <<
FormatFloat(list(j).mOccupancy,6,4)
349 if( NULL != list(j).mpScattPow )
351 os <<
", ScattPow:" <<
FormatString(list(j).mpScattPow->GetName(),16)
352 <<
", Biso=" << FormatFloat(list(j).mpScattPow->GetBiso());
356 os <<
", ScattPow: dummy";
363 os <<
": Valence="<<posBV->second<<
" (expected="
364 <<this->mScattCompList(k).mpScattPow->GetFormalCharge()<<
")";
371 <<
"Occupancy = occ * dyn, where:"<<endl
372 <<
" - occ is the 'real' occupancy"<< endl
373 <<
" - dyn is the dynamical occupancy correction, indicating either"<< endl
374 <<
" an atom on a special position, or several identical atoms "<< endl
375 <<
" overlapping (dyn=0.5 -> atom on a symetry plane / 2fold axis.."<< endl
376 <<
" -> OR 2 atoms strictly overlapping)"<< endl
382 os <<
" Total number of components (atoms) in one unit cell : " << nbAtoms<<endl<<endl;
384 VFN_DEBUG_MESSAGE(
"Crystal::Print():End",5)
389 VFN_DEBUG_MESSAGE(
"Crystal::MinDistanceTable()",5)
393 CrystMatrix_REAL minDistTable(nbComponent,nbComponent);
396 REAL min=minDistance*minDistance;
397 if(minDistance<0) min = -1.;
399 for(
int i=0;i<nbComponent;i++)
402 std::vector<Crystal::Neighbour>::const_iterator pos;
407 dist=minDistTable(i,pos->mNeighbourIndex);
409 && ((tmp>min) || ( (
mvDistTableSq[i].mIndex !=pos->mNeighbourIndex)
411 !=pos->mNeighbourSymmetryIndex))))
412 minDistTable(i,pos->mNeighbourIndex)=tmp;
415 for(
int i=0;i<nbComponent;i++)
417 for(
int j=0;j<=i;j++)
419 if(9999.>minDistTable(i,j)) minDistTable(i,j)=sqrt(minDistTable(i,j));
420 else minDistTable(i,j)=-1;
421 minDistTable(j,i)=minDistTable(i,j);
424 VFN_DEBUG_MESSAGE(
"Crystal::MinDistanceTable():End",3)
430 VFN_DEBUG_MESSAGE(
"Crystal::PrintMinDistanceTable()",5)
431 CrystMatrix_REAL minDistTable;
433 VFN_DEBUG_MESSAGE(
"Crystal::PrintMinDistanceTable():0",5)
434 os <<
"Table of minimal distances between all components (atoms)"<<endl;
438 VFN_DEBUG_MESSAGE(
"Crystal::PrintMinDistanceTable()1:Scatt:"<<i,3)
448 VFN_DEBUG_MESSAGE(
"Crystal::PrintMinDistanceTable()2:Scatt,comp:"<<i<<
","<<j,3)
450 for(
long k=0;k<nbComponent;k++)
452 if(minDistTable(l,k)>0) os <<
FormatFloat(minDistTable(l,k),6,3) ;
458 VFN_DEBUG_MESSAGE(
"Crystal::PrintMinDistanceTable():End",3)
463 VFN_DEBUG_MESSAGE(
"Crystal::POVRayDescription(os,bool)",5)
464 os <<
"/////////////////////// MACROS////////////////////"<<endl;
466 os <<
"#macro ObjCrystAtom(atomx,atomy,atomz,atomr,atomc,occ,atten)"
468 <<
" { <atomx,atomy,atomz>,atomr"<<endl
469 <<
" finish {ambient 0.5*occ*atten diffuse 0.4*occ*atten phong occ*atten specular 0.2*occ*atten "
470 <<
"roughness 0.02 metallic reflection 0.0}"<<endl
471 <<
" pigment { colour atomc transmit (1-occ*atten)}"<<endl
472 <<
" no_shadow"<<endl
474 <<
"#end"<<endl<<endl;
476 os <<
"#macro ObjCrystBond(x1,y1,z1,x2,y2,z2,bondradius,bondColour,occ,atten)"<<endl
478 <<
" { <x1,y1,z1>,"<<endl
479 <<
" <x2,y2,z2>,"<<endl
480 <<
" bondradius"<<endl
481 <<
" finish {ambient 0.5*occ*atten diffuse 0.4*occ*atten phong occ*atten specular 0.2*occ*atten "
482 <<
"roughness 0.02 metallic reflection 0.0}"<<endl
483 <<
" pigment { colour bondColour transmit (1-occ*atten)}"<<endl
484 <<
" no_shadow"<<endl
486 <<
"#end"<<endl<<endl;
488 os <<
"//////////// Crystal Unit Cell /////////////////" <<endl;
491 os <<
" //box{ <0,0,0>, <"<< x <<
"," << y <<
"," << z <<
">" <<endl;
492 os <<
" // pigment {colour rgbf<1,1,1,0.9>}" << endl;
493 os <<
" // hollow" << endl;
494 os <<
" //}" <<endl<<endl;
496 #define UNITCELL_EDGE(X0,Y0,Z0,X1,Y1,Z1)\
498 REAL x0=X0,y0=Y0,z0=Z0,x1=X1,y1=Y1,z1=Z1;\
499 this->FractionalToOrthonormalCoords(x0,y0,z0);\
500 this->FractionalToOrthonormalCoords(x1,y1,z1);\
501 os << " ObjCrystBond("\
502 <<x0<<","<<y0<<","<<z0<< ","\
503 <<x1<<","<<y1<<","<<z1<< ","\
504 << "0.02,rgb<1.0,1.0,1.0>,1.0,1.0)"<<endl;\
507 UNITCELL_EDGE(0,0,0,1,0,0)
508 UNITCELL_EDGE(0,0,0,0,1,0)
509 UNITCELL_EDGE(0,0,0,0,0,1)
511 UNITCELL_EDGE(1,1,1,0,1,1)
512 UNITCELL_EDGE(1,1,1,1,0,1)
513 UNITCELL_EDGE(1,1,1,1,1,0)
515 UNITCELL_EDGE(1,0,0,1,1,0)
516 UNITCELL_EDGE(1,0,0,1,0,1)
518 UNITCELL_EDGE(0,1,0,1,1,0)
519 UNITCELL_EDGE(0,1,0,0,1,1)
521 UNITCELL_EDGE(0,0,1,1,0,1)
522 UNITCELL_EDGE(0,0,1,0,1,1)
524 os <<endl<<
"/////////////// GLOBAL DECLARATIONS FOR ATOMS & BONDS ///////"<<endl;
525 os <<
"// Atom colours"<<endl;
532 <<
"= rgb <"<< r<<
","<<g<<
","<<b<<
">;"<< endl;
534 os <<
"// Bond colours"<<endl
535 <<
" #declare colour_freebond = rgb <0.7,0.7,0.7>;"<< endl
536 <<
" #declare colour_nonfreebond= rgb <0.3,0.3,0.3>;"<< endl;
539 os <<
"/////////////// SCATTERERS ///////"<<endl;
546 const REAL xMin,
const REAL xMax,
547 const REAL yMin,
const REAL yMax,
548 const REAL zMin,
const REAL zMax,
549 const bool displayNames,
550 const bool hideHydrogens)
const
552 VFN_DEBUG_ENTRY(
"Crystal::GLInitDisplayList()",5)
558 REAL xc=(xMin+xMax)/2.;
559 REAL yc=(yMin+yMax)/2.;
560 REAL zc=(zMin+zMax)/2.;
561 if(
false==displayNames)
603 const GLfloat colour0 [] = {0.00, 0.00, 0.00, 0.00};
604 const GLfloat colour1 [] = {0.50, 0.50, 0.50, 1.00};
605 const GLfloat colour2 [] = {1.00, 1.00, 1.00, 1.00};
606 glMaterialfv(GL_FRONT, GL_AMBIENT, colour2);
607 glMaterialfv(GL_FRONT, GL_DIFFUSE, colour0);
608 glMaterialfv(GL_FRONT, GL_SPECULAR, colour0);
609 glMaterialfv(GL_FRONT, GL_EMISSION, colour2);
610 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
612 x=1.2-xc;y=-yc;z=-zc;
614 glRasterPos3f(en*x,y,z);
617 x=-xc;y=1.2-yc;z=-zc;
619 glRasterPos3f(en*x,y,z);
622 x=-xc;y=-yc;z=1.2-zc;
624 glRasterPos3f(en*x,y,z);
627 glMaterialfv(GL_FRONT, GL_AMBIENT, colour1);
628 glMaterialfv(GL_FRONT, GL_DIFFUSE, colour2);
629 glMaterialfv(GL_FRONT, GL_SPECULAR, colour2);
630 glMaterialfv(GL_FRONT, GL_EMISSION, colour0);
631 glMaterialfv(GL_FRONT, GL_SHININESS, colour0);
633 glTranslatef(-xc*en, -yc, -zc);
636 glNormal3f((x110+x010-xM)*en,y110+y010-yM,z110+z010-zM);
637 glVertex3f( x110*en, y110, z110);
638 glVertex3f( x010*en, y010, z010);
640 glNormal3f((x011+x010-xM)*en,y011+y010-yM,z011+z010-zM);
641 glVertex3f( x010*en, y010, z010);
642 glVertex3f( x011*en, y011, z011);
644 glNormal3f((x011+x111-xM)*en,y011+y111-yM,z011+z111-zM);
645 glVertex3f( x011*en, y011, z011);
646 glVertex3f( x111*en, y111, z111);
648 glNormal3f((x110+x111-xM)*en,y110+y111-yM,z110+z111-zM);
649 glVertex3f( x111*en, y111, z111);
650 glVertex3f( x110*en, y110, z110);
652 glNormal3f((x101+x001-xM)*en,y101+y001-yM,z101+z001-zM);
653 glVertex3f( x101*en, y101, z101);
654 glVertex3f( x001*en, y001, z001);
656 glNormal3f((x000+x001-xM)*en,y000+y001-yM,z000+z001-zM);
657 glVertex3f( x001*en, y001, z001);
658 glVertex3f( x000*en, y000, z000);
660 glNormal3f((x000+x100-xM)*en,y000+y100-yM,z000+z100-zM);
661 glVertex3f( x000*en, y000, z000);
662 glVertex3f( x100*en, y100, z100);
664 glNormal3f((x101+x100-xM)*en,y101+y100-yM,z101+z100-zM);
665 glVertex3f( x100*en, y100, z100);
666 glVertex3f( x101*en, y101, z101);
668 glNormal3f((x101+x111-xM)*en,y101+y111-yM,z101+z111-zM);
669 glVertex3f( x101*en, y101, z101);
670 glVertex3f( x111*en, y111, z111);
672 glNormal3f((x001+x011-xM)*en,y001+y011-yM,z001+z011-zM);
673 glVertex3f( x001*en, y001, z001);
674 glVertex3f( x011*en, y011, z011);
676 glNormal3f((x000+x010-xM)*en,y000+y010-yM,z000+z010-zM);
677 glVertex3f( x000*en, y000, z000);
678 glVertex3f( x010*en, y010, z010);
680 glNormal3f((x100+x110-xM)*en,y100+y110-yM,z100+z110-zM);
681 glVertex3f( x100*en, y100, z100);
682 glVertex3f( x110*en, y110, z110);
688 VFN_DEBUG_MESSAGE(
"Crystal::GLView(bool):Scatterers...",5)
691 glTranslatef(-xc*en, -yc, -zc);
692 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
694 bool displayEnantiomer=
false;
698 xMin,xMax,yMin,yMax,zMin,zMax,
699 displayEnantiomer,displayNames,hideHydrogens);
703 cout <<
"Crystal::GLView(): Compiled without OpenGL support !" <<endl;
705 VFN_DEBUG_EXIT(
"Crystal::GLInitDisplayList(bool)",5)
710 VFN_DEBUG_ENTRY(
"Crystal::CalcDynPopCorr(REAL)",4)
711 TAU_PROFILE(
"Crystal::CalcDynPopCorr()",
"void (REAL)",TAU_DEFAULT);
718 CrystVector_REAL neighborsDist(nbComponent*nbSymmetrics);
723 const REAL overlapDistSq=overlapDist*overlapDist;
725 for(
long i=0;i<nbComponent;i++)
727 VFN_DEBUG_MESSAGE(
"Crystal::CalcDynPopCorr(): Component:"<<i,0)
735 std::vector<Crystal::Neighbour>::const_iterator pos;
739 VFN_DEBUG_MESSAGE(
"Crystal::CalcDynPopCorr(): Component:"<<i<<
"Neighbour:"<<pos->mNeighbourIndex,0)
741 if(atomicNumber==
mScattCompList(pos->mNeighbourIndex).mpScattPow->GetDynPopCorrIndex())
743 if(overlapDistSq > pos->mDist2)
747 if(nbNeighbors==neighborsDist.numElements()) neighborsDist.resizeAndPreserve(nbNeighbors+20);
748 neighborsDist(nbNeighbors++)=sqrt(pos->mDist2);
753 for(
long j=0;j<nbNeighbors;j++)
755 dist=neighborsDist(j)-mergeDist;
757 corr += fabs((overlapDist-dist-mergeDist)/(overlapDist-mergeDist));
762 VFN_DEBUG_EXIT(
"Crystal::CalcDynPopCorr(REAL):End.",4)
787 throw ObjCrystException(
"Crystal::GetDynPopCorr(): did not find this scatterer !");
793 VFN_DEBUG_MESSAGE(
"Crystal::SetUseDynPopCorr()",1)
805 VFN_DEBUG_MESSAGE(
"Crystal::FindScatterer(name)",0)
811 Cannot find this scatterer:"+scattName);
814 Crystal::BumpMergePar::BumpMergePar():
815 mDist2(1.),mCanOverlap(false){}
817 Crystal::BumpMergePar::BumpMergePar(
const REAL dist,
const bool canOverlap):
818 mDist2(dist*dist),mCanOverlap(canOverlap){}
825 VFN_DEBUG_ENTRY(
"Crystal::GetBumpMergeCost()",4)
828 TAU_PROFILE(
"Crystal::GetBumpMergeCost()",
"REAL (REAL)",TAU_DEFAULT);
832 std::vector<NeighbourHood>::const_iterator pos;
833 std::vector<Crystal::Neighbour>::const_iterator neigh;
836 VBumpMergePar::const_iterator par;
840 for(neigh=pos->mvNeighbour.begin();neigh<pos->mvNeighbour.end();neigh++)
846 if(neigh->mDist2 > par->second.mDist2)
continue;
847 if(
true==par->second.mCanOverlap)
848 tmp = 0.5*sin(M_PI*(1.-sqrt(neigh->mDist2/par->second.mDist2)))/0.1;
850 tmp = tan(M_PI*0.49999*(1.-sqrt(neigh->mDist2/par->second.mDist2)))/0.1;
863 VFN_DEBUG_MESSAGE(
"Crystal::SetBumpMergeDistance()",5)
870 const bool allowMerge)
872 VFN_DEBUG_MESSAGE(
"Crystal::SetBumpMergeDistance("<<scatt1.
GetName()<<
","<<scatt2.
GetName()<<
")="<<dist<<
","<<allowMerge,3)
873 if(&scatt1 < &scatt2)
882 Crystal::VBumpMergePar::iterator pos;
883 if(&scatt1 < &scatt2) pos=
mvBumpMergePar.find(make_pair(&scatt1 , &scatt2));
898 VFN_DEBUG_ENTRY(
"Crystal::GlobalOptRandomMove()",2)
901 if( ((rand()/(REAL)RAND_MAX)<.02) && (nb>1))
905 const unsigned long n1=rand()%nb;
906 const unsigned long n2=( (rand()%(nb-1)) +n1+1) %nb;
922 VFN_DEBUG_EXIT(
"Crystal::GlobalOptRandomMove()",2)
932 VFN_DEBUG_ENTRY(
"Crystal::OutputCIF()",5)
935 string tempname =
mName;
937 size = tempname.size();
940 tempname = tempname.substr(0,32);
941 size = tempname.size();
948 where = tempname.find(
" ",0);
949 while (where != (
int)string::npos)
951 tempname.replace(where,1,
"_");
952 where = tempname.find(
" ",0);
955 os <<
"data_" << tempname <<endl<<endl;
958 os <<
"_computing_structure_solution 'FOX http://objcryst.sourceforge.net'"<<endl<<endl;
976 os <<
"_symmetry_space_group_name_H-M '"
978 os <<
"_symmetry_space_group_name_Hall '"
1000 os <<
"loop_" << endl
1001 <<
" _atom_site_label" <<endl
1002 <<
" _atom_site_type_symbol" <<endl
1003 <<
" _atom_site_fract_x"<<endl
1004 <<
" _atom_site_fract_y" <<endl
1005 <<
" _atom_site_fract_z" <<endl
1006 <<
" _atom_site_U_iso_or_equiv" <<endl
1007 <<
" _atom_site_occupancy" <<endl
1008 <<
" _atom_site_adp_type" <<endl;
1010 const double BtoU = 1.0 / (8 * M_PI * M_PI);
1011 std::vector<const ScatteringPower*> anisovec;
1012 std::vector<std::string> namevec;
1013 CrystMatrix_REAL minDistTable;
1022 if(0==list(j).mpScattPow)
continue;
1023 bool redundant=
false;
1024 for(
unsigned long l=0;l<k;++l)
if(abs(minDistTable(l,k))<mindist) redundant=
true;
1029 size_t posc=s.find(
' ');
1030 while(posc!=string::npos){s[posc]=
'~';posc=s.find(
' ');}
1032 bool isiso = list(j).mpScattPow->IsIsotropic();
1035 anisovec.push_back(list(j).mpScattPow);
1036 namevec.push_back(s);
1041 <<
FormatString(list(j).mpScattPow->GetSymbol(),8) <<
" "
1042 << FormatFloat(list(j).mX,9,6) <<
" "
1043 << FormatFloat(list(j).mY,9,6) <<
" "
1044 << FormatFloat(list(j).mZ,9,6) <<
" "
1045 << FormatFloat(list(j).mpScattPow->GetBiso()*BtoU,9,6) <<
" "
1046 << FormatFloat(list(j).mOccupancy,6,4)
1047 << (isiso ?
" Uiso" :
" Uani")
1056 if( anisovec.size() > 0 )
1061 <<
" _atom_site_aniso_label" << endl
1062 <<
" _atom_site_aniso_U_11" << endl
1063 <<
" _atom_site_aniso_U_22" << endl
1064 <<
" _atom_site_aniso_U_33" << endl
1065 <<
" _atom_site_aniso_U_12" << endl
1066 <<
" _atom_site_aniso_U_13" << endl
1067 <<
" _atom_site_aniso_U_23" << endl;
1070 for(
size_t i = 0; i < anisovec.size(); ++i)
1073 for(
int j=0; j<6; ++j)
1074 os << FormatFloat(anisovec[i]->GetBij(j)*BtoU,9,6) <<
" ";
1087 if(0==list(j).mpScattPow)
continue;
1088 bool redundant=
false;
1089 for(
unsigned long l=0;l<k;++l)
if(abs(minDistTable(l,k))<mindist) redundant=
true;
1096 <<
"# The following atoms have been excluded by Fox because they are"<<endl
1097 <<
"# almost fully overlapping with another atom (d<" << mindist <<
"A)"<< endl;
1100 <<
FormatString(list(j).mpScattPow->GetName(),8) <<
" "
1102 << FormatFloat(list(j).mX,9,6) <<
" "
1103 << FormatFloat(list(j).mY,9,6) <<
" "
1104 << FormatFloat(list(j).mZ,9,6) <<
" "
1105 << FormatFloat(list(j).mpScattPow->GetBiso()*BtoU,9,6) <<
" "
1106 << FormatFloat(list(j).mOccupancy,6,4)
1118 os <<
"# Dynamical occupancy corrections found by ObjCryst++:"<<endl
1119 <<
"# values below 1. (100%) indicate a correction,"<<endl
1120 <<
"# which means either that the atom is on a special position,"<<endl
1121 <<
"# or that it is overlapping with another identical atom."<<endl;
1138 VFN_DEBUG_EXIT(
"Crystal::OutputCIF()",5)
1142 CrystVector_uint & groupIndex,
1143 unsigned int &first)
const
1146 unsigned int latticeIndex=0;
1147 VFN_DEBUG_MESSAGE(
"Crystal::GetGeneGroup()",4)
1149 for(
long j=0;j<this->
GetNbPar();j++)
1154 if(latticeIndex==0) latticeIndex=first++;
1155 groupIndex(i)=latticeIndex;
1196 void Crystal::RemoveBondValenceRo(
const ScatteringPower &pow1,
const ScatteringPower &pow2)
1198 map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>::iterator pos;
1207 VFN_DEBUG_MESSAGE(
"Crystal::GetBondValenceCost()?",4)
1217 VFN_DEBUG_MESSAGE(
"Crystal::GetBondValenceCost():"<<
mvBondValenceCalc.size()<<
" valences",4)
1218 TAU_PROFILE(
"Crystal::GetBondValenceCost()",
"REAL ()",TAU_DEFAULT);
1220 std::map<long, REAL>::const_iterator pos;
1223 const REAL a=pos->second-
mScattCompList(pos->first).mpScattPow->GetFormalCharge();
1225 VFN_DEBUG_MESSAGE(
"Crystal::GetBondValenceCost():"
1227 <<
"="<<pos->second,4)
1233 std::map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>& Crystal::GetBondValenceRoList()
1236 const std::map<pair<const ScatteringPower*,const ScatteringPower*>, REAL>& Crystal::GetBondValenceRoList()
const
1243 VFN_DEBUG_MESSAGE(
"Crystal::CalcBondValenceSum()?",4)
1246 VFN_DEBUG_MESSAGE(
"Crystal::CalcBondValenceSum()",4)
1247 TAU_PROFILE(
"Crystal::CalcBondValenceSum()",
"void ()",TAU_DEFAULT);
1254 std::vector<Crystal::Neighbour>::const_iterator pos;
1258 const REAL dist=sqrt(pos->mDist2);
1259 const REAL occup=
mScattCompList(pos->mNeighbourIndex).mOccupancy
1262 map<pair<const ScatteringPower*,const ScatteringPower*>,REAL>::const_iterator pos;
1267 const REAL v=exp((pos->second-dist)/0.37);
1278 const REAL beta,
const REAL gamma,
const string &SpaceGroupId,
1281 VFN_DEBUG_MESSAGE(
"Crystal::Init(a,b,c,alpha,beta,gamma,Sg,name)",10)
1287 VFN_DEBUG_MESSAGE(
"Crystal::Init(a,b,c,alpha,beta,gamma,Sg,name):End",10)
1292 return b1->GetLength()<b2->GetLength();
1297 VFN_DEBUG_ENTRY(
"Crystal::ConnectAtoms(...)",10)
1303 if(warnuser_fail) (*fpObjCrystInformUser)(
"Crystal::ConnectAtoms(): cannot connect atoms unless there are only Atoms in a Crystal");
1313 std::set<int> vAssignedAtoms;
1314 std::set<int> vTriedAtom0;
1315 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...)",10)
1318 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): new Molecule ?",7)
1321 int maxAtomicNumber = 0;
1324 if((vAssignedAtoms.count(i)>0) || (vTriedAtom0.find(i)!=vTriedAtom0.end()) )
continue;
1325 if(
mScattCompList(i).mpScattPow->GetClassName()==
"ScatteringPowerAtom")
1333 else if((p->
GetAtomicNumber()>maxAtomicNumber) && (maxAtomicNumber!=6))
1342 (*fpObjCrystInformUser)(
"Crystal::ConnectAtoms(): cannot connect atoms unless there are only Atoms in a Crystal");
1343 VFN_DEBUG_EXIT(
"Crystal::ConnectAtoms(...):cannot connect atoms unless there are only Atoms in th structure:"<<i<<
":"<<
mScattCompList(i).mpScattPow->GetClassName(),10)
1349 if((pmol==NULL) && warnuser_fail)
1351 (*fpObjCrystInformUser)(
"Crystal::ConnectAtoms(): cannot connect atoms unless there is at least one carbon atom");
1352 VFN_DEBUG_EXIT(
"Crystal::ConnectAtoms(...):cannot connect atoms unless there is at least one carbon atom",10)
1357 vTriedAtom0.insert(atom0);
1360 std::map<int,int>newAtoms;
1362 std::map<MolAtom*,int> molAtoms;
1368 vAssignedAtoms.insert(atom0);
1377 pmol->GetAtomList().back()->SetOccupancy(occ);
1379 molAtoms[pmol->GetAtomList().back()]=atom0;
1381 vector<unsigned int> vElementCount(140);
1382 for(vector<unsigned int>::iterator pos=vElementCount.begin();pos!=vElementCount.end();++pos) *pos=0;
1384 while(newAtoms.size()>0)
1386 atom0=newAtoms.begin()->first;
1388 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...):atom0="<<atom0<<
","<<newAtoms.size()<<
" new atoms",7)
1390 for(std::vector<Crystal::Neighbour>::const_iterator pos=
mvDistTableSq[atom0].mvNeighbour.begin();
1395 if( (vAssignedAtoms.count(pos->mNeighbourIndex)!=0) || (p1->
GetMaxCovBonds()==0))
1397 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...):atom0="<<p0->
GetName()<<
"-"<<p1->
GetName()<<
"("<<p1->
GetMaxCovBonds()<<
"):dcov="<<dcov<<
",d="<<sqrt(pos->mDist2),7)
1398 if( ((min_relat_dist*dcov)<sqrt(pos->mDist2))
1399 &&((max_relat_dist*dcov)>sqrt(pos->mDist2)))
1401 vAssignedAtoms.insert(pos->mNeighbourIndex);
1408 pmol->GetAtomList().back()->SetOccupancy(occ);
1410 molAtoms[pmol->GetAtomList().back()]=pos->mNeighbourIndex;
1414 newAtoms.erase(atom0);
1418 if((vElementCount[6]>0) && (pmol->
GetNbComponent()>=3)) keep=
true;
1422 std::vector<unsigned int> vnb;
1424 cout<<
" Crystal::ConnectAtoms(..): Molecule ?";
1426 for(
unsigned int i=0;i<vElementCount.size();++i)
1427 if(vElementCount[i]!=0)
1429 vnb.push_back(vElementCount[i]);
1431 cout<<
"Z="<<i<<
"("<< vElementCount[i]<<
") ";
1440 if((vElementCount[8]==1) && (vElementCount[1]==2)) keep=
true;
1441 if((vElementCount[8]==1) && (vElementCount[1]==3)) keep=
true;
1442 if((vElementCount[7]==1) && (vElementCount[1]==3)) keep=
true;
1443 if((vElementCount[7]==1) && (vElementCount[1]==4)) keep=
true;
1444 if((vElementCount[7]==1) && (vElementCount[8]==2)) keep=
true;
1445 if((vElementCount[7]==1) && (vElementCount[8]==3)) keep=
true;
1446 if((vElementCount[5]==1) && (vElementCount[1]==3)) keep=
true;
1447 if((vElementCount[5]==1) && (vElementCount[1]==4)) keep=
true;
1448 if((vElementCount[14]==1) && (vElementCount[8]==4)) keep=
true;
1449 if((vElementCount[15]==1) && (vElementCount[8]==4)) keep=
true;
1452 if( ((vnb[0]==1)||(vnb[1]==1)) &&((vnb[0]+vnb[1])>2)) keep=
true;
1459 for(std::map<MolAtom*,int>::const_iterator pos=molAtoms.begin();pos!=molAtoms.end();++pos) vAssignedAtoms.erase(pos->second);
1464 for(
unsigned int i=0;i<pmol->GetAtomList().size();i++)
1466 for(
unsigned int j=i+1;j<pmol->GetAtomList().size();j++)
1468 const REAL d=
GetBondLength(pmol->GetAtom(i), pmol->GetAtom(j));
1471 if( ((min_relat_dist*dcov)<d) && ((max_relat_dist*dcov)>d))
1473 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...):Add bond="<<pmol->GetAtom(i).GetName()<<
"-"<<pmol->GetAtom(j).GetName()<<
", d="<<d<<
"(dcov="<<dcov<<
")",6)
1474 pmol->
AddBond(pmol->GetAtom(i),pmol->GetAtom(j),d,.01,.02,
false);
1479 for(vector<MolAtom*>::iterator pos=pmol->GetAtomList().begin();pos!=pmol->GetAtomList().end();)
1483 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...):max bonds for:"<<(*pos)->GetName()<<
"?",10)
1486 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...):no bond remaining for:"<<(*pos)->GetName()<<
"! Removing atom from Molecule",10)
1488 vAssignedAtoms.erase(molAtoms[*pos]);
1489 molAtoms.erase(*pos);
1494 int extra=p->second.size()-maxbonds;
1498 std::vector<MolBond*> vbonds;
1500 for(std::set<MolAtom*>::iterator p1=p->second.begin();p1!=p->second.end();++p1)
1502 vbonds.push_back(*(pmol->
FindBond(**pos,**p1)));
1503 nbbond+=(*p1)->GetOccupancy();
1505 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): too many bonds for"<<(*pos)->GetName()<<
" ?(allowed="<<maxbonds<<
",nb="<<p->second.size()<<
",nb_occ="<<nbbond<<
")", 10)
1506 if((nbbond-maxbonds)>0.2)
1508 std::sort(vbonds.begin(), vbonds.end(),CompareBondDist);
1509 std::vector<MolBond*>::reverse_iterator p=vbonds.rbegin();
1510 for(
int j=0;j<extra;j++)
1512 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): Remove bond="<<(*p)->GetAtom1().GetName()<<
"-"<<(*p)->GetAtom2().GetName()<<
", d="<<(*p)->GetLength(),10)
1514 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): Next bond ="<<(*p)->GetAtom1().GetName()<<
"-"<<(*p)->GetAtom2().GetName()<<
", d="<<(*p)->GetLength(),10)
1526 for(set<MolAtom*>::const_iterator pos1=pos->second.begin();
1527 pos1!=pos->second.end();++pos1)
1529 for(set<MolAtom*>::const_iterator pos2=pos1;
1530 pos2!=pos->second.end();++pos2)
1532 if(pos2==pos1)
continue;
1533 if(pmol->
FindBondAngle(**pos1,*(pos->first),**pos2)== pmol->GetBondAngleList().end())
1535 GetBondAngle(**pos1,*(pos->first),**pos2),0.01,0.02,
false);
1540 REAL xc=0,yc=0,zc=0;
1541 for(std::map<MolAtom*,int>::const_iterator pos=molAtoms.begin();pos!=molAtoms.end();++pos)
1555 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): center?"<<pmol->
GetNbComponent()<<
","<<molAtoms.size()<<
":"<<xc<<
","<<yc<<
","<<zc,10)
1561 std::set<Scatterer*> vpAtom;
1562 for(std::set<int>::const_iterator pos=vAssignedAtoms.begin();pos!=vAssignedAtoms.end();++pos)
1567 while(vpAtom.size()>0)
1569 VFN_DEBUG_MESSAGE(
"Crystal::ConnectAtoms(...): remove atom:"<<(*vpAtom.begin())->
GetName()<<
","<<vpAtom.size()<<
" remaining...",6)
1571 vpAtom.erase(vpAtom.begin());
1573 VFN_DEBUG_EXIT(
"Crystal::ConnectAtoms(...)",10)
1578 VFN_DEBUG_ENTRY(
"Crystal::InitOptions",10)
1579 static string UseDynPopCorrname;
1580 static string UseDynPopCorrchoices[2];
1582 static string DisplayEnantiomername;
1583 static string DisplayEnantiomerchoices[2];
1585 static bool needInitNames=
true;
1586 if(
true==needInitNames)
1588 UseDynPopCorrname=
"Use Dynamical Occupancy Correction";
1589 UseDynPopCorrchoices[0]=
"No";
1590 UseDynPopCorrchoices[1]=
"Yes";
1592 DisplayEnantiomername=
"Display Enantiomer";
1593 DisplayEnantiomerchoices[0]=
"No";
1594 DisplayEnantiomerchoices[1]=
"Yes";
1596 needInitNames=
false;
1598 VFN_DEBUG_MESSAGE(
"Crystal::Init(a,b,c,alpha,beta,gamma,Sg,name):Init options",5)
1606 VFN_DEBUG_EXIT(
"Crystal::InitOptions",10)
1609 Crystal::Neighbour::Neighbour(
const unsigned long neighbourIndex,
const int sym,
1611 mNeighbourIndex(neighbourIndex),mNeighbourSymmetryIndex(sym),mDist2(dist2)
1614 struct DistTableInternalPosition
1616 DistTableInternalPosition(
const long atomIndex,
const int sym,
1617 const REAL x,
const REAL y,
const REAL z):
1618 mAtomIndex(atomIndex),mSymmetryIndex(sym),mX(x),mY(y),mZ(z)
1645 std::vector<NeighbourHood>::iterator pos;
1647 pos->mvNeighbour.clear();
1649 VFN_DEBUG_MESSAGE(
"Crystal::CalcDistTable():1",3)
1660 const REAL halfasuxrange=(asux1-asux0)*0.5+1e-5;
1661 const REAL halfasuyrange=(asuy1-asuy0)*0.5+1e-5;
1662 const REAL halfasuzrange=(asuz1-asuz0)*0.5+1e-5;
1664 const REAL asuxc=0.5*(asux0+asux1);
1665 const REAL asuyc=0.5*(asuy0+asuy1);
1666 const REAL asuzc=0.5*(asuz0+asuz1);
1673 std::vector<DistTableInternalPosition> vPos;
1675 std::vector<unsigned long> vUniqueIndex(nbComponent);
1681 VFN_DEBUG_MESSAGE(
"Crystal::CalcDistTable(fast):2",3)
1682 TAU_PROFILE(
"Crystal::CalcDistTable(fast=true)",
"Matrix (string&)",TAU_DEFAULT);
1683 TAU_PROFILE_TIMER(timer1,
"DiffractionData::CalcDistTable1",
"", TAU_FIELD);
1684 TAU_PROFILE_TIMER(timer2,
"DiffractionData::CalcDistTable2",
"", TAU_FIELD);
1686 TAU_PROFILE_START(timer1);
1689 bool loopOnLattice=
true;
1692 &&((this->
GetLatticePar(2)*.5)>mDistTableMaxDistance)) loopOnLattice=
false;
1694 CrystMatrix_REAL symmetricsCoords;
1699 for(
long i=0;i<nbComponent;i++)
1701 VFN_DEBUG_MESSAGE(
"Crystal::CalcDistTable(fast):3:component "<<i,0)
1708 bool hasUnique=
false;
1709 for(
int j=0;j<nbSymmetrics;j++)
1712 REAL x=fmod(symmetricsCoords(j,0)-asuxc,(REAL)1.0);
if(x<-.5)x+=1;
else if(x>.5)x-=1;
1713 REAL y=fmod(symmetricsCoords(j,1)-asuyc,(REAL)1.0);
if(y<-.5)y+=1;
else if(y>.5)y-=1;
1714 REAL z=fmod(symmetricsCoords(j,2)-asuzc,(REAL)1.0);
if(z<-.5)z+=1;
else if(z>.5)z-=1;
1717 if( (abs(x)<maxdx) && (abs(y)<maxdy) && (abs(z)<maxdz) )
1718 vPos.push_back(DistTableInternalPosition(i, j, x+asuxc, y+asuyc, z+asuzc));
1721 if( (abs(x)<halfasuxrange) && (abs(y)<halfasuyrange) && (abs(z)<halfasuzrange) )
1724 vUniqueIndex[i]=vPos.size()-1;
1733 TAU_PROFILE_STOP(timer1);
1734 TAU_PROFILE_START(timer2);
1738 const CrystMatrix_REAL* pOrthMatrix=&(this->
GetOrthMatrix());
1740 const REAL m00=(*pOrthMatrix)(0,0);
1741 const REAL m01=(*pOrthMatrix)(0,1);
1742 const REAL m02=(*pOrthMatrix)(0,2);
1743 const REAL m11=(*pOrthMatrix)(1,1);
1744 const REAL m12=(*pOrthMatrix)(1,2);
1745 const REAL m22=(*pOrthMatrix)(2,2);
1747 for(
long i=0;i<nbComponent;i++)
1749 VFN_DEBUG_MESSAGE(
"Crystal::CalcDistTable(fast):4:component "<<i,0)
1751 if(!this->
IsBeingRefined()) cout<<endl<<
"Unique pos:"<<vUniqueIndex[i]<<
":"
1752 <<vPos[vUniqueIndex[i]].mAtomIndex<<
":"
1753 <<
mScattCompList(vPos[vUniqueIndex[i]].mAtomIndex).mpScattPow->GetName()<<
":"
1754 <<vPos[vUniqueIndex[i]].mSymmetryIndex<<
":"
1757 <<
FormatFloat(vPos[vUniqueIndex[i]].mZ,8,5)<<endl;
1759 std::vector<Crystal::Neighbour> *
const vnb=&(
mvDistTableSq[i].mvNeighbour);
1760 const REAL x0i=vPos[vUniqueIndex[i] ].mX;
1761 const REAL y0i=vPos[vUniqueIndex[i] ].mY;
1762 const REAL z0i=vPos[vUniqueIndex[i] ].mZ;
1763 for(
unsigned long j=0;j<vPos.size();j++)
1765 if((vUniqueIndex[i]==j) && (!loopOnLattice))
continue;
1767 REAL x=fmod(vPos[j].mX - x0i,(REAL)1.0);
if(x<-.5)x+=1;
if(x>.5)x-=1;
1768 REAL y=fmod(vPos[j].mY - y0i,(REAL)1.0);
if(y<-.5)y+=1;
if(y>.5)y-=1;
1769 REAL z=fmod(vPos[j].mZ - z0i,(REAL)1.0);
if(z<-.5)z+=1;
if(z>.5)z-=1;
1771 const REAL x0=m00 * x + m01 * y + m02 * z;
1772 const REAL y0= m11 * y + m12 * z;
1773 const REAL z0= m22 * z;
1777 for(
int sz=-1;sz<=1;sz+=2)
1779 for(
int nz=(sz+1)/2;;++nz)
1781 const REAL z=z0+sz*nz*m22;
1782 if(abs(z)>mDistTableMaxDistance)
break;
1783 for(
int sy=-1;sy<=1;sy+=2)
1785 for(
int ny=(sy+1)/2;;++ny)
1787 const REAL y=y0 + sy*ny*m11 + sz*nz*m12;
1788 if(abs(y)>mDistTableMaxDistance)
break;
1789 for(
int sx=-1;sx<=1;sx+=2)
1791 for(
int nx=(sx+1)/2;;++nx)
1793 if((vUniqueIndex[i]==j) && (nx==0) && (ny==0) && (nz==0))
continue;
1794 const REAL x=x0 + sx*nx*m00 + sy*ny*m01 + sz*nz*m02;
1795 if(abs(x)>mDistTableMaxDistance)
break;
1796 const REAL d2=x*x+y*y+z*z;
1797 if(d2<=asymUnitMargin2)
1799 Neighbour neigh(vPos[j].mAtomIndex,vPos[j].mSymmetryIndex,d2);
1800 vnb->push_back(neigh);
1804 <<vPos[j].mSymmetryIndex<<
":"
1811 <<
"("<<sx*nx<<
","<<sy*ny<<
","<<sz*nz<<
")"<<endl;
1823 const REAL d2=x0*x0+y0*y0+z0*z0;
1824 if(d2<=asymUnitMargin2)
1826 Neighbour neigh(vPos[j].mAtomIndex,vPos[j].mSymmetryIndex,d2);
1827 vnb->push_back(neigh);
1831 <<vPos[j].mSymmetryIndex<<
":"
1834 <<vPos[j].mZ<<
" vector="
1835 <<x0<<
","<<y0<<
","<<z0<<
":"<<sqrt(d2)<<
","<<asymUnitMargin2<<endl;
1842 TAU_PROFILE_STOP(timer2);
1845 VFN_DEBUG_EXIT(
"Crystal::CalcDistTable()",4)
1849 mDeleteSubObjInDestructor=b;
1852 #ifdef __WX__CRYST__
1855 VFN_DEBUG_ENTRY(
"Crystal::WXCreate(wxWindow*)",6)
1857 mpWXCrystObj=new
WXCrystal(parent,this);
1858 VFN_DEBUG_EXIT("
Crystal::WXCreate(wxWindow*)",6)
1859 return mpWXCrystObj;
RefinableObjClock mBondValenceCalcClock
Last time Bond Valences were calculated.
CrystVector_REAL GetLatticePar() const
Lattice parameters (a,b,c,alpha,beta,gamma) as a 6-element vector in Angstroems and radians...
const RefinableObjClock & GetMasterClockScatteringPower() const
Get the clock which reports all changes in ScatteringPowers.
void RemoveBumpMergeDistance(const ScatteringPower &scatt1, const ScatteringPower &scatt2)
Remove an Anti-bumping distance between two scattering types.
void RemoveScatterer(Scatterer *scatt, const bool del=true)
Remove a Scatterer. This also deletes the scatterer unless del=false.
RefinableObjClock mClockScattCompList
void CalcBondValenceSum() const
Calculate all Bond Valences.
void AddSubRefObj(RefinableObj &)
Crystal()
Default Constructor.
void PrintMinDistanceTable(const REAL minDistance=0.1, ostream &os=cout) const
Print the minimum distance table between all scattering centers (atoms) in the crystal.
virtual void Init(const REAL a, const REAL b, const REAL c, const REAL alpha, const REAL beta, const REAL gamma, const string &SpaceGroupId, const string &name)
Init all UnitCell parameters.
virtual void UpdateDisplay() const
If there is an interface, this should be automatically be called each time there is a 'new...
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...
virtual ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const =0
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
const RefinableObjClock & GetClockLatticePar() const
last time the Lattice parameters were changed
~Crystal()
Crystal destructor.
virtual const ScatteringComponentList & GetScatteringComponentList() const
Get the list of all scattering components.
const cctbx::sgtbx::space_group & GetCCTbxSpg() const
Get the underlying cctbx Spacegroup object.
const RefinableObjClock & GetMaximumLikelihoodParClock() const
Get the clock value for the last change on the maximum likelihood parameters (positionnal error...
const RefinableObjClock & GetClockScatterer() const
Last time anything in the scatterer was changed (atoms, positions, scattering power) ...
REAL mBondValenceCostScale
Bond Valence cost scale factor.
REAL GetBondLength(const MolAtom &at1, const MolAtom &at2)
Get The Bond Length between two atoms.
void OrthonormalToFractionalCoords(REAL &x, REAL &y, REAL &z) const
Get fractional cartesian coordinates for a set of (x,y,z) orthonormal coordinates.
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...
void SetUseDynPopCorr(const int use)
Set the use of dynamical population correction (Crystal::mUseDynPopCorr).
bool IsBeingRefined() const
Is the object being refined ? (Can be refined by one algorithm at a time only.)
virtual void GlobalOptRandomMove(const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
Make a random move of the current configuration.
void FractionalToOrthonormalCoords(REAL &x, REAL &y, REAL &z) const
Get orthonormal cartesian coordinates for a set of (x,y,z) fractional coordinates.
RefinableObjClock mLatticeClock
Clock for lattice paramaters.
vector< MolBond * >::const_iterator FindBond(const MolAtom &, const MolAtom &) const
Searches whether a bond between two atoms already exists.
int FindScatterer(const string &scattName) const
Find a scatterer (its index # in mpScatterrer[]) with a given name.
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.
Interatomic distance for a given neighbour.
RefinableObjClock mBondValenceCostClock
Last time the Bond Valence cost was calculated.
ObjRegistry< ScatteringPower > mScatteringPowerRegistry
The registry of ScatteringPower for this Crystal.
ObjRegistry< Scatterer > mScattererRegistry
The registry of scatterers for this UnitCell.
int GetUseDynPopCorr() const
Get dynamical population correction setting.
REAL GetBumpMergeCost() const
Get the Anti-bumping/pro-Merging cost function.
void AddBondAngle(MolAtom &atom1, MolAtom &atom2, MolAtom &atom3, const REAL angle, const REAL sigma, const REAL delta, const bool updateDisplay=true)
Add a bond angle restraint.
void Click()
Record an event for this clock (generally, the 'time' an object has been modified, or some computation has been made)
void RemoveSubRefObj(RefinableObj &)
long GetNbPar() const
Total number of refinable parameter in the object.
virtual REAL GetLogLikelihood() const
Get -log(likelihood) of the current configuration for the object.
void AddChild(const RefinableObjClock &)
Add a 'child' clock.
unsigned int GetMaxCovBonds() const
Maximum number of covalent bonds (from openbabel element.txt)
void SetBumpMergeDistance(const ScatteringPower &scatt1, const ScatteringPower &scatt2, const REAL dist=1.5)
Set the Anti-bumping distance between two scattering types.
RefinableObjClock mClockDynPopCorr
RefinablePar & GetPar(const long i)
Access all parameters in the order they were inputted.
const RefinableObjClock & GetClockScattererList() const
When was the list of scatterers last changed ?
void Print() const
Print the list of Scattering components. For debugging.
Bond between two atoms, also a restraint on the associated bond length.
RefinableObjClock mClockScattererList
Last time the list of Scatterers was changed.
virtual int GetNbComponent() const =0
Number of components in the scatterer (eg number of point scatterers)
void CalcDynPopCorr(const REAL overlapDist=1., const REAL mergeDist=.0) const
Compute the 'Dynamical population correction for all atoms. Atoms which are considered "equivalent" (...
virtual void RegisterClient(RefinableObj &) const
Register a new object using this object.
REAL mBumpMergeScale
Bump-merge scale factor.
virtual int GetNbComponent() const
Number of components in the scatterer (eg number of point scatterers)
RefinableObjClock mMasterClockScatteringPower
master clock recording every change in Scattering Powers
ObjRegistry< RefinableObj > gTopRefinableObjRegistry("Global Top RefinableObj registry")
This is a special registry for 'top' object for an optimization.
RefinableObjClock mClockMaster
Master clock, which is changed whenever the object has been altered.
void AddAtom(const REAL x, const REAL y, const REAL z, const ScatteringPower *pPow, const string &name, const bool updateDisplay=true)
Add an atom.
Generic Refinable Object.
const SpaceGroup & GetSpaceGroup() const
Access to the SpaceGroup object.
void AddScatterer(Scatterer *scatt)
Add a scatterer to the crystal.
void Reset()
Reset the list.
RefinableObjClock mBondValenceParClock
Last Time Bond Valence parameters were changed.
REAL GetZ() const
Z coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
const RefinableObjClock & GetClockMaster() const
This clocks records any change in the object. See refinableObj::mClockMaster.
ScatteringComponentList mScattCompList
The list of all scattering components in the crystal.
void ResetDynPopCorr() const
Reset Dynamical Population Correction factors (ie set it to 1)
RefinableObjClock mBumpMergeParClock
Last Time Anti-bump parameters were changed.
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
Abstract base class for all objects in wxCryst.
const RefinableObjClock & GetClockMetricMatrix() const
last time the metric matrices were changed
void SetDeleteSubObjInDestructor(const bool b)
Set whether to delete the Scatterers and ScatteringPowers in the destructor.
string mName
Name for this RefinableObject. Should be unique, at least in the same scope.+.
REAL mBondValenceCost
Current Bond Valence cost.
REAL GetBondValenceCost() const
Get the Bond-Valence cost function, which compares the expected valence to the one computed from Bond...
void RemoveScatteringPower(ScatteringPower *scattPow, const bool del=true)
Remove a ScatteringPower for this Crystal.
const AsymmetricUnit & GetAsymUnit() const
Get the AsymmetricUnit for this spacegroup.
std::vector< NeighbourHood > mvDistTableSq
Interatomic distance table for all unique atoms.
void ConnectAtoms(const REAL min_relat_dist=0.4, const REAL max_relat_dist=1.3, const bool warnuser_fail=false)
Convert as much as possible the crystal's atoms to molecule(s).
REAL GetBondAngle(const MolAtom &at1, const MolAtom &at2, const MolAtom &at3)
Get The Bond Angle of 3 atoms.
Molecule : class for complex scatterer descriptions using cartesian coordinates with bond length/angl...
Class to store POV-Ray output options.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual void SetY(const REAL y)
Y coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
const RefinableObjClock & GetClockScattCompList() const
Get the list of all scattering components.
REAL mBumpMergeCost
Current bump-merge cost.
REAL GetVolume() const
Volume of Unit Cell (in Angstroems)
RefObjOpt mUseDynPopCorr
Use Dynamical population correction (ScatteringComponent::mDynPopCorr) during Structure factor calcul...
virtual void GLInitDisplayList(const bool noSymmetrics=false, const REAL xMin=-.1, const REAL xMax=1.1, const REAL yMin=-.1, const REAL yMax=1.1, const REAL zMin=-.1, const REAL zMax=1.1, const bool displayEnantiomer=false, const bool displayNames=false, const bool hideHydrogens=false) const =0
wxCryst class for Crystals
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
void RemoveChild(const RefinableObjClock &)
remove a child clock. This also tells the child clock to remove the parent.
REAL GetX() const
X coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
ostream & POVRayDescription(ostream &os, const CrystalPOVRayOptions &options) const
XMLOutput POV-Ray Description for this Crystal.
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.
Scatterer & GetScatt(const string &scattName)
Provides an access to the scatterers.
virtual void GetGeneGroup(const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
Get the gene group assigned to each parameter.
output a number as a formatted float:
REAL GetDynPopCorr(const Scatterer *pscatt, unsigned int component) const
Access the Dynamical Occupancy Correction for a given component (atom) in a given Scatterer...
MolAtom : atom inside a Molecule.
ObjRegistry< Scatterer > & GetScattererRegistry()
Get the registry of scatterers.
const map< MolAtom *, set< MolAtom * > > & GetConnectivityTable()
Get the connectivity table.
vector< MolAtom * >::iterator RemoveAtom(MolAtom &, const bool del=true)
Remove an atom.
CrystMatrix_REAL GetMinDistanceTable(const REAL minDistance=0.1) const
Minimum interatomic distance between all scattering components (atoms) in the crystal.
ObjRegistry< ScatteringPower > & GetScatteringPowerRegistry()
Get the registry of ScatteringPower included in this Crystal.
VBumpMergePar mvBumpMergePar
Anti-bump parameters map.
output a string with a fixed length (adding necessary space or removing excess characters) : ...
virtual void SetX(const REAL x)
X coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
void CalcDistTable(const bool fast) const
Compute the distance Table (mDistTable) for all scattering components.
RefObjOpt mDisplayEnantiomer
Display the enantiomeric (mirror along x) structure in 3D? This can be helpful for non-centrosymmetri...
virtual void BeginOptimization(const bool allowApproximations=false, const bool enableRestraints=false)
This should be called by any optimization class at the begining of an optimization.
void SetCrystal(Crystal &)
Set the crystal in which is included this Scatterer.
virtual string GetComponentName(const int i) const =0
Name for the i-th component of this scatterer.
virtual void CIFOutput(ostream &os, double mindist=0.5) const
output Crystal structure as a cif file (EXPERIMENTAL !)
void Reset()
Reset a Clock to 0, to force an update.
int GetAtomicNumber() const
Atomic number for this atom.
Exception class for ObjCryst++ library.
vector< MolBondAngle * >::const_iterator FindBondAngle(const MolAtom &at1, const MolAtom &at0, const MolAtom &at2) const
Searches whether a bond between three atoms already exists, searching for either (at1,at2,at3) and (at3,at2,at1), as these are equivalent.
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
The Scattering Power for an Atom.
virtual void GLInitDisplayList(const bool onlyIndependentAtoms=false, const REAL xMin=-.1, const REAL xMax=1.1, const REAL yMin=-.1, const REAL yMax=1.1, const REAL zMin=-.1, const REAL zMax=1.1, const bool displayNames=false, const bool hideHydrogens=false) const
Create an OpenGL DisplayList of the crystal.
void BuildConnectivityTable() const
Build the Connectivity table.
const CrystMatrix_REAL & GetOrthMatrix() const
Get the orthogonalization matrix (UnitCell::mOrthMatrix)for the UnitCell in real space.
map< pair< const ScatteringPower *, const ScatteringPower * >, REAL > mvBondValenceRo
Map of Bond Valence "Ro" parameters for each couple of ScatteringPower.
virtual const string & GetName() const
Name of the object.
void Init(const REAL a, const REAL b, const REAL c, const REAL alpha, const REAL beta, const REAL gamma, const string &SpaceGroupId, const string &name)
Init all Crystal parameters.
RefinableObjClock mClockNeighborTable
virtual const ScatteringComponentList & GetScatteringComponentList() const =0
Get the list of all scattering components for this scatterer.
std::map< long, REAL > mvBondValenceCalc
List of calculated bond valences, as a map, the key being the index of the atom in Crystal::mScattCom...
Crystal class: Unit cell, spacegroup, scatterers.
vector< MolBond * >::iterator RemoveBond(const MolBond &, const bool del=true)
Remove a bond.
void SetGlobalOptimStep(const RefParType *type, const REAL step)
Change the maximum step to use during Global Optimization algorithms.
REAL GetY() const
Y coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
Storage for anti-bump/merge parameters.
class to input or output a well-formatted xml beginning or ending tag.
RefinableObjClock mDistTableClock
The time when the distance table was last calculated.
long GetNbScatterer() const
Number of scatterers in the crystal.
ScatteringPower & GetScatteringPower(const string &name)
Find a ScatteringPower from its name. Names must be unique in a given Crystal.
class of refinable parameter types.
list of scattering positions in a crystal, associated with the corresponding occupancy and a pointer ...
virtual void DeRegisterClient(RefinableObj &) const
Deregister an object (which not any more) using this object.
Generic type of scatterer: can be an atom, or a more complex assembly of atoms.
void AddScatteringPower(ScatteringPower *scattPow)
Add a ScatteringPower for this Crystal.
char GetExtension() const
Extension to space group symbol ('1','2':origin choice ; 'R','H'=rhomboedral/hexagonal) ...
RefinableObjClock mBumpMergeCostClock
Last Time Anti-bump parameters were changed.
void AddOption(RefObjOpt *opt)
REAL mDistTableMaxDistance
The distance up to which the distance table & neighbours needs to be calculated.
REAL GetCovalentRadius() const
Covalent Radius for this atom, in Angstroems (from cctbx)
void InitOptions()
Init options.
void AddBond(MolAtom &atom1, MolAtom &atom2, const REAL length, const REAL sigma, const REAL delta, const REAL bondOrder=1., const bool updateDisplay=true)
Add a bond.
std::map< pair< const ScatteringPower *, const ScatteringPower * >, Crystal::BumpMergePar > VBumpMergePar
Anti-bump parameters.
virtual void SetZ(const REAL z)
Z coordinate (fractionnal) of the scatterer (for complex scatterers, this corresponds to the position...
Abstract Base Class to describe the scattering power of any Scatterer component in a crystal...