Skip to content

Commit 5431c27

Browse files
committed
Merge branch 'upstream-objcryst':
Add UnitCell::ChangeSpaceGroup(), which updates lattice parameter symmetry constraints. Take into accound spacegroup clock in UnitCell::GetLatticePar and InitMatrices Throw an exception if alpha, beta or gamma are not within ]0;pi[ in UnitCell::Init()
2 parents 322a22e + 7997744 commit 5431c27

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/ObjCryst/ObjCryst/CIF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
11331133
// The origin extension may not make sense, so we need to watch for exception
11341134
try
11351135
{
1136-
pCryst->GetSpaceGroup().ChangeSpaceGroup(hmorig+*posOrig);
1136+
pCryst->ChangeSpaceGroup(hmorig+*posOrig);
11371137
}
11381138
catch(invalid_argument)
11391139
{
@@ -1179,7 +1179,7 @@ Crystal* CreateCrystalFromCIF(CIF &cif,const bool verbose,const bool checkSymAsX
11791179
}
11801180
}
11811181
if(verbose) cout<<endl<<"Finally using spacegroup name:"<<bestsymbol<<endl;
1182-
pCryst->GetSpaceGroup().ChangeSpaceGroup(bestsymbol);
1182+
pCryst->ChangeSpaceGroup(bestsymbol);
11831183
}
11841184
// Try to set name from CIF. If that fails, the computed formula will be used at the end
11851185
if(pos->second.mName!="") pCryst->SetName(pos->second.mName);

src/ObjCryst/ObjCryst/PowderPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7100,7 +7100,7 @@ void SpaceGroupExplorer::RunAll(const bool fitprofile_all, const bool verbose, c
71007100
if(keep_best)
71017101
{
71027102
if(verbose) cout<<"Restoring best spacegroup: "<<mvSPG.front().hm<<endl;
7103-
pCrystal->GetSpaceGroup().ChangeSpaceGroup(mvSPG.front().hm);
7103+
pCrystal->ChangeSpaceGroup(mvSPG.front().hm);
71047104
}
71057105
else
71067106
{

src/ObjCryst/ObjCryst/UnitCell.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ CrystVector_REAL UnitCell::GetLatticePar() const
9393
{
9494
VFN_DEBUG_MESSAGE("UnitCell::GetLatticePar()",0)
9595

96-
if(mClockLatticeParUpdate>mClockLatticePar) return mCellDim;
96+
if( (mClockLatticeParUpdate>mClockLatticePar)
97+
&&(mClockLatticeParUpdate>mSpaceGroup.GetClockSpaceGroup())) return mCellDim;
9798
else
9899
{
99100
//:NOTE: cannot use this->UpdateLatticePar() because it is not a const member function
@@ -164,7 +165,8 @@ REAL UnitCell::GetLatticePar(int whichPar)const
164165
if( (whichPar<0) || (whichPar>5))
165166
throw ObjCrystException("UnitCell::LatticePar(int) :trying to access parameter>5!");
166167

167-
if(mClockLatticeParUpdate>mClockLatticePar) return mCellDim(whichPar);
168+
if( (mClockLatticeParUpdate>mClockLatticePar)
169+
&&(mClockLatticeParUpdate>mSpaceGroup.GetClockSpaceGroup())) return mCellDim(whichPar);
168170
else
169171
{
170172
const int num = mSpaceGroup.GetSpaceGroupNumber();
@@ -320,6 +322,14 @@ void UnitCell::Print(ostream &os)const
320322
const SpaceGroup & UnitCell::GetSpaceGroup() const {return mSpaceGroup;}
321323
SpaceGroup & UnitCell::GetSpaceGroup() {return mSpaceGroup;}
322324

325+
void UnitCell::ChangeSpaceGroup(const string &spgId)
326+
{
327+
this->GetSpaceGroup().ChangeSpaceGroup(spgId);
328+
this->InitRefParList();
329+
this->UpdateLatticePar();
330+
}
331+
332+
323333
const RefinableObjClock& UnitCell::GetClockLatticePar()const {return mClockLatticePar;}
324334
const RefinableObjClock& UnitCell::GetClockMetricMatrix()const {return mClockMetricMatrix;}
325335

@@ -344,6 +354,9 @@ void UnitCell::Init(const REAL a, const REAL b, const REAL c, const REAL alpha,
344354
//mSpaceGroup.Print();
345355
mSpaceGroup.ChangeSpaceGroup(SpaceGroupId);
346356
//mSpaceGroup.Print();
357+
if((alpha<=0)||(alpha>=M_PI)) throw ObjCrystException("alpha must be within ]0;pi[");
358+
if((beta<=0) ||(beta>=M_PI)) throw ObjCrystException("beta must be within ]0;pi[");
359+
if((gamma<=0)||(gamma>=M_PI)) throw ObjCrystException("gamma must be within ]0;pi[");
347360
mCellDim(0)=a;
348361
mCellDim(1)=b;
349362
mCellDim(2)=c;
@@ -390,7 +403,8 @@ void UnitCell::InitMatrices() const
390403
{
391404
//:NOTE: The Matrices must remain upper triangular, since this is assumed for
392405
//optimization purposes in some procedures.
393-
if(mClockMetricMatrix>mClockLatticePar) return;//no need to update
406+
if( (mClockMetricMatrix>mClockLatticePar)
407+
&&(mClockMetricMatrix>mSpaceGroup.GetClockSpaceGroup())) return;//no need to update
394408
//this->UpdateLatticePar(); we should be able to do this...
395409

396410
VFN_DEBUG_MESSAGE("UnitCell::InitMatrices() for crystal : "+this->GetName(),5)

src/ObjCryst/ObjCryst/UnitCell.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ class UnitCell:public RefinableObj
161161
const SpaceGroup & GetSpaceGroup()const;
162162
/// Access to the SpaceGroup object.
163163
SpaceGroup & GetSpaceGroup();
164+
/** Change the spacegroup. This function should be called
165+
* rather than using GetSpaceGroup().ChangeSpaceGroup(),
166+
* as the latter does not allow to update the refinable
167+
* parameters constraints of the lattive parameters.
168+
*/
169+
void ChangeSpaceGroup(const string &spgId);
164170

165171
// :TODO: ?
166172
//virtual void XMLOutput(ostream &os,int indent=0)const;

0 commit comments

Comments
 (0)