Skip to content

Commit e240e39

Browse files
committed
Merge branch 'master' of github.com:vincefn/objcryst into upstream-objcryst
* 'master' of github.com:vincefn/objcryst: Add access to the weight (g/mol) for ScatteringPowerAtom and Crystal
2 parents ac1875a + 9c4b05b commit e240e39

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

ObjCryst/ObjCryst/Crystal.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ void Crystal::Print(ostream &os)const
381381
for(int i=0;i<mScattCompList.GetNbComponent();i++)
382382
nbAtoms += genMult * mScattCompList(i).mOccupancy * mScattCompList(i).mDynPopCorr;
383383
os << " Total number of components (atoms) in one unit cell : " << nbAtoms<<endl
384-
<< " Chemical formula: "<< this->GetFormula() <<endl;
384+
<< " Chemical formula: "<< this->GetFormula() << endl
385+
<< " Weight: "<< this->GetWeight()<< " g/mol" << endl;
385386

386387
VFN_DEBUG_MESSAGE("Crystal::Print():End",5)
387388
}
@@ -415,6 +416,23 @@ std::string Crystal::GetFormula() const
415416
}
416417

417418

419+
REAL Crystal::GetWeight() const
420+
{
421+
this->GetScatteringComponentList();
422+
if(mScattCompList.GetNbComponent() == 0) return 0;
423+
REAL w;
424+
for(unsigned int i=0; i<mScattCompList.GetNbComponent(); ++i)
425+
{
426+
const ScatteringComponent* psi = &mScattCompList(i);
427+
if(psi->mpScattPow == 0) continue;
428+
if(psi->mpScattPow->GetClassName().compare("ScatteringPowerAtom")!=0) continue;
429+
const ScatteringPowerAtom *pat=dynamic_cast<const ScatteringPowerAtom*>(psi->mpScattPow);
430+
w += pat->GetAtomicWeight() * psi->mOccupancy * psi->mDynPopCorr ;
431+
}
432+
return w;
433+
}
434+
435+
418436
CrystMatrix_REAL Crystal::GetMinDistanceTable(const REAL minDistance) const
419437
{
420438
VFN_DEBUG_MESSAGE("Crystal::MinDistanceTable()",5)

ObjCryst/ObjCryst/Crystal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ class Crystal:public UnitCell
192192

193193
/// Formula with atoms in alphabetic order
194194
std::string GetFormula() const;
195+
/// Weight for the crystal formula, in atomic units (g/mol). This should be
196+
/// multiplied by the spacegroup multiplity to get the unit cell weight.
197+
REAL GetWeight() const;
195198

196199
/** \brief Minimum interatomic distance between all scattering components (atoms) in
197200
* the crystal.

ObjCryst/ObjCryst/ScatteringPower.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ void ScatteringPowerAtom::Init(const string &name,const string &symbol,const REA
366366

367367
cctbx::eltbx::tiny_pse::table tpse(mSymbol);
368368
mAtomicNumber=tpse.atomic_number();
369+
mAtomicWeight=tpse.weight();
369370

370371
cctbx::eltbx::icsd_radii::table ticsd(mSymbol);
371372
mRadius= ticsd.radius();
@@ -781,6 +782,7 @@ string ScatteringPowerAtom::GetElementName() const
781782
}
782783

783784
int ScatteringPowerAtom::GetAtomicNumber() const {return mAtomicNumber;}
785+
REAL ScatteringPowerAtom::GetAtomicWeight() const {return mAtomicWeight;}
784786
REAL ScatteringPowerAtom::GetRadius() const {return mRadius;}
785787
REAL ScatteringPowerAtom::GetCovalentRadius() const {return mCovalentRadius;}
786788
unsigned int ScatteringPowerAtom::GetMaxCovBonds()const{ return mMaxCovBonds;}

ObjCryst/ObjCryst/ScatteringPower.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ class ScatteringPowerAtom:virtual public ScatteringPower
381381
*which uses data from the CRC Handbook of Chemistry & Physics, 63rd & 70th editions
382382
*/
383383
string GetElementName() const;
384-
///Atomic number for this atom
384+
/// Atomic number for this atom
385385
int GetAtomicNumber() const;
386+
/// Atomic weight (g/mol) for this atom
387+
REAL GetAtomicWeight() const;
386388
/// Atomic radius for this atom or ion, in Angstroems (ICSD table from cctbx)
387389
REAL GetRadius() const;
388390
/// Covalent Radius for this atom, in Angstroems (from cctbx)
@@ -412,6 +414,8 @@ class ScatteringPowerAtom:virtual public ScatteringPower
412414
string mSymbol;
413415
/// atomic number (Z) for the atom
414416
int mAtomicNumber;
417+
/// atomic weight (g/mol) for the atom
418+
REAL mAtomicWeight;
415419

416420
/** Pointer to cctbx's gaussian describing the thomson x-ray
417421
* scattering factor.

0 commit comments

Comments
 (0)