Skip to content

Commit c1fb1d6

Browse files
committed
Add UnitCell::ChangeSpaceGroup(), which updates lattice parameter symmetry constraints.
Take into accound spacegroup clock in UnitCell::GetLatticePar and InitMatrices
1 parent 80fe8fa commit c1fb1d6

File tree

5 files changed

+41
-24
lines changed

5 files changed

+41
-24
lines changed

ObjCryst/ObjCryst/CIF.cpp

+2-2
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);

ObjCryst/ObjCryst/PowderPattern.cpp

+1-1
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
{

ObjCryst/ObjCryst/UnitCell.cpp

+14-3
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

@@ -393,7 +403,8 @@ void UnitCell::InitMatrices() const
393403
{
394404
//:NOTE: The Matrices must remain upper triangular, since this is assumed for
395405
//optimization purposes in some procedures.
396-
if(mClockMetricMatrix>mClockLatticePar) return;//no need to update
406+
if( (mClockMetricMatrix>mClockLatticePar)
407+
&&(mClockMetricMatrix>mSpaceGroup.GetClockSpaceGroup())) return;//no need to update
397408
//this->UpdateLatticePar(); we should be able to do this...
398409

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

ObjCryst/ObjCryst/UnitCell.h

+6
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;

ObjCryst/wxCryst/wxPowderPattern.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -2635,51 +2635,51 @@ void WXCellExplorer::OnSelectCell(wxCommandEvent &event)
26352635
{
26362636
switch(pos->first.mlattice)
26372637
{
2638-
case TRICLINIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("P-1");break;
2639-
case MONOCLINIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("P2/m");break;
2640-
case ORTHOROMBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Pmmm");break;
2641-
case HEXAGONAL:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("P6/mmm");break;
2642-
case RHOMBOEDRAL:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("R-3m");break;
2643-
case TETRAGONAL:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("P4/mmm");break;
2644-
case CUBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Pm-3m");break;
2638+
case TRICLINIC:mpCrystal->ChangeSpaceGroup("P-1");break;
2639+
case MONOCLINIC:mpCrystal->ChangeSpaceGroup("P2/m");break;
2640+
case ORTHOROMBIC:mpCrystal->ChangeSpaceGroup("Pmmm");break;
2641+
case HEXAGONAL:mpCrystal->ChangeSpaceGroup("P6/mmm");break;
2642+
case RHOMBOEDRAL:mpCrystal->ChangeSpaceGroup("R-3m");break;
2643+
case TETRAGONAL:mpCrystal->ChangeSpaceGroup("P4/mmm");break;
2644+
case CUBIC:mpCrystal->ChangeSpaceGroup("Pm-3m");break;
26452645
}
26462646
break;
26472647
}
26482648
case LATTICE_I:
26492649
{
26502650
switch(pos->first.mlattice)
26512651
{
2652-
case MONOCLINIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("I2/m");break;
2653-
case ORTHOROMBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("I222");break;
2654-
case TETRAGONAL:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("I4/mmm");break;
2655-
case CUBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Im-3m");break;
2652+
case MONOCLINIC:mpCrystal->ChangeSpaceGroup("I2/m");break;
2653+
case ORTHOROMBIC:mpCrystal->ChangeSpaceGroup("I222");break;
2654+
case TETRAGONAL:mpCrystal->ChangeSpaceGroup("I4/mmm");break;
2655+
case CUBIC:mpCrystal->ChangeSpaceGroup("Im-3m");break;
26562656
}
26572657
break;
26582658
}
26592659
case LATTICE_A:
26602660
{
26612661
switch(pos->first.mlattice)
26622662
{
2663-
case MONOCLINIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("A2/m");break;
2664-
case ORTHOROMBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Amm2");break;
2663+
case MONOCLINIC:mpCrystal->ChangeSpaceGroup("A2/m");break;
2664+
case ORTHOROMBIC:mpCrystal->ChangeSpaceGroup("Amm2");break;
26652665
}
26662666
break;
26672667
}
26682668
case LATTICE_C:
26692669
{
26702670
switch(pos->first.mlattice)
26712671
{
2672-
case MONOCLINIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("C2/m");break;
2673-
case ORTHOROMBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Cmmm");break;
2672+
case MONOCLINIC:mpCrystal->ChangeSpaceGroup("C2/m");break;
2673+
case ORTHOROMBIC:mpCrystal->ChangeSpaceGroup("Cmmm");break;
26742674
}
26752675
break;
26762676
}
26772677
case LATTICE_F://,LATTICE_A,LATTICE_B,LATTICE_C};
26782678
{
26792679
switch(pos->first.mlattice)
26802680
{
2681-
case ORTHOROMBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Fmmm");break;
2682-
case CUBIC:mpCrystal->GetSpaceGroup().ChangeSpaceGroup("Fm-3m");break;
2681+
case ORTHOROMBIC:mpCrystal->ChangeSpaceGroup("Fmmm");break;
2682+
case CUBIC:mpCrystal->ChangeSpaceGroup("Fm-3m");break;
26832683
}
26842684
break;
26852685
}
@@ -4968,7 +4968,7 @@ void WXProfileFitting::OnExploreSpacegroups(wxCommandEvent &event)
49684968
mpLog->AppendText(wxString::Format(_T("\n\nYou can copy the chosen spacegroup symbol in the Crystal window\n")));
49694969
mpLog->AppendText(wxString::Format(_T("\n\nThe spacegroup with the best nGoF has been applied\n")));
49704970
// Set best solution
4971-
pCrystal->GetSpaceGroup().ChangeSpaceGroup(vSPG.front().hm);
4971+
pCrystal->ChangeSpaceGroup(vSPG.front().hm);
49724972
pDiff->GetParentPowderPattern().UpdateDisplay();
49734973
pDiff->SetExtractionMode(true,true);
49744974
pDiff->ExtractLeBail(5);

0 commit comments

Comments
 (0)