Skip to content

Commit 7997744

Browse files
committed
Merge branch 'master' of github.com:vincefn/objcryst into upstream-objcryst
* 'master' of github.com:vincefn/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() Correct march/SSE flags for rules-gnu.mak Enable building against unbundled cctbx library
2 parents ae19d03 + c1fb1d6 commit 7997744

File tree

8 files changed

+59
-33
lines changed

8 files changed

+59
-33
lines changed

Fox/gnu.mak

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ shared-wxgtk=1
88
shared-fftw=1
99
shared-glut=1
1010
shared-mysql=1
11+
shared-cctbx=1
1112
endif
1213

1314
all: Fox
1415

1516
default: all
1617

1718
Fox:
18-
$(MAKE) -f gnu.mak wxcryst=1 opengl=1 fftw=1 debug=$(debug) unicode=$(unicode) cod=$(cod) shared=$(shared) shared-wxgtk=$(shared-wxgtk) shared-glut=$(shared-glut) shared-newmat=$(shared-newmat) shared-fftw=$(shared-fftw) shared-mysql=$(shared-mysql) -C src Fox
19+
$(MAKE) -f gnu.mak wxcryst=1 opengl=1 fftw=1 debug=$(debug) unicode=$(unicode) cod=$(cod) shared=$(shared) shared-wxgtk=$(shared-wxgtk) shared-glut=$(shared-glut) shared-newmat=$(shared-newmat) shared-fftw=$(shared-fftw) shared-mysql=$(shared-mysql) shared-cctbx=$(shared-cctbx) -C src Fox
1920

2021
Fox-nogui:
2122
$(MAKE) -f gnu.mak wxcryst=0 opengl=0 fftw=0 cod=0 debug=$(debug) -C src Fox-nogui

Fox/src/gnu.mak

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else
1515
endif
1616

1717
ifeq ($(profile),2)
18-
%.o : %.cpp $(libwx) $(libnewmat) libcctbx
18+
%.o : %.cpp $(libwx) $(libnewmat) $(libcctbx)
1919
@rm -f $(*F).gcda $(*F).gcno
2020
@$(MAKEDEPEND)
2121
${CXX} ${CPPFLAGS} ${CXXFLAGS} -c $< -o $@
@@ -33,11 +33,11 @@ endif
3333
libFox: $(OBJ)
3434

3535
#Main Application
36-
Fox: $(libwx) $(libnewmat) $(libfftw) $(COD_LIB) libCrystVector libQuirks libRefinableObj libcctbx libCryst libwxCryst
36+
Fox: $(libwx) $(libnewmat) $(libfftw) $(COD_LIB) libCrystVector libQuirks libRefinableObj $(libcctbx) libCryst libwxCryst
3737
$(MAKE) -f gnu.mak libFox
3838
${LINKER} ${CRYST_LDFLAGS} -o $@ ${filter-out %.h %.a %.so lib%, $^} $(OBJ) ${LOADLIBES}
3939

40-
Fox-nogui: $(libnewmat) libcctbx libCrystVector libQuirks libRefinableObj libCryst Fox.o
40+
Fox-nogui: $(libnewmat) $(libcctbx) libCrystVector libQuirks libRefinableObj libCryst Fox.o
4141
${LINKER} ${CRYST_LDFLAGS} -o $@ ${filter-out %.h %.a %.so lib%, $^} ${LOADLIBES}
4242

4343
fox: Fox

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

+17-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

@@ -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)

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/rules-gnu.mak

+10-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ shared-newmat=1
2424
shared-wxgtk=1
2525
shared-fftw=1
2626
shared-glut=1
27+
shared-cctbx=1
2728
endif
2829
### Rules for Linux & GCC
2930
# C compiler
@@ -122,7 +123,7 @@ UNAME_S := $(shell uname -m)
122123
SSE_FLAGS =
123124
ifneq ($(sse),0)
124125
ifneq ($(UNAME_S),arm64)
125-
SSE_FLAGS = -DHAVE_SSE_MATHFUN -DUSE_SSE2 -march=native $(UNAME_S)
126+
SSE_FLAGS = -DHAVE_SSE_MATHFUN -DUSE_SSE2 -march=native
126127
endif
127128
endif
128129

@@ -237,7 +238,11 @@ $(DIR_STATIC_LIBS)/lib/libcctbx.a: $(BUILD_DIR)/cctbx.tar.bz2
237238
#ln -sf $(BUILD_DIR)/boost $(DIR_STATIC_LIBS)/include/
238239
#rm -Rf $(BUILD_DIR)/cctbx
239240

240-
libcctbx: $(DIR_STATIC_LIBS)/lib/libcctbx.a
241+
ifneq ($(shared-cctbx),1)
242+
libcctbx= $(DIR_STATIC_LIBS)/lib/libcctbx.a
243+
else
244+
libcctbx=
245+
endif
241246

242247
$(BUILD_DIR)/fftw-3.3.10.tar.gz:
243248
cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) http://fftw.org/fftw-3.3.10.tar.gz
@@ -268,13 +273,13 @@ libboost:$(BUILD_DIR)/boost_1_68_0.tar.bz2
268273
rm -Rf $(BUILD_DIR)/boost_1_68_0
269274

270275
#ObjCryst++
271-
libCryst: $(libwx) libcctbx
276+
libCryst: $(libwx) $(libcctbx)
272277
$(MAKE) -f gnu.mak -C ${DIR_LIBCRYST} lib
273278

274279
libcryst: libCryst
275280

276281
#wxCryst++
277-
libwxCryst: $(libwx) $(libfreeglut) $(libfftw) libcctbx
282+
libwxCryst: $(libwx) $(libfreeglut) $(libfftw) $(libcctbx)
278283
$(MAKE) -f gnu.mak -C ${DIR_WXWCRYST} lib
279284

280285
#Vector computation library
@@ -286,5 +291,5 @@ libQuirks: $(libwx)
286291
$(MAKE) -f gnu.mak -C ${DIR_VFNQUIRKS} lib
287292

288293
#Library to take care of refinable parameters, plus Global optimization and Least Squares refinements
289-
libRefinableObj:$(libnewmat) $(libwx) libcctbx
294+
libRefinableObj:$(libnewmat) $(libwx) $(libcctbx)
290295
$(MAKE) -f gnu.mak -C ${DIR_REFOBJ}/ lib

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)