Skip to content

Commit

Permalink
import from dgcode git: version 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Apr 4, 2021
1 parent 2f01809 commit bd05cc8
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 18 deletions.
53 changes: 53 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
v2.6.0 2020-04-05
* Introduce NCMAT v4 which introduces a few new features, as described in
detail in the ncmat_doc.md file. The most important new feature relies
on the fact that it is possible to estimate atomic
mean-squared-displacements directly from a phonon density of state
distribution (VDOS), meaning that it is now allowed (and actually
recommended) to skip @DEBYETEMPERATURE's for crystalline materials where
atoms have VDOS curves available). This is not only useful, but improves
low-temperature reliability of the Debye-Waller factors used in the
elastic scattering components. This development was helped by Kemal
Ramic and Jose Ignacio Marquez Damian from the ESS Spallation Physics
group, and more details are available in the ncrystal GitHub issue
#58. The other new feature in NCMAT v4 is a new optional syntax for the
@CELL section, which allows more compact specification for certain
crystal systems (in particular cubic systems).
* The vast majority of crystalline materials in the NCrystal data library
were updated to take advantage of the new features, and in addition the
number of VDOS curves was increased dramatically, meaning that the
dynamics in almost all crystalline materials are now described using
actual VDOS curves rather than just Debye temperatures.
* Missing VDOS curves for all elements in beryllium-fluoride (BeF2),
aragonite (CaCO3), cuprite (Cu2O), periclase (MgO), and quartz (SiO2)
were provided by Kemal Ramic from the ESS Spallation Physics group,
based on modelling with Phonopy, VASP and OCLIMAX software.
* Missing VDOS curves for 14 mono-atomic materials were added (fixing
github issue #39): Au, Ba, Cr, Mg, Mo, Na, Nb, Pd, Pt, Rb, Sc, Sn, Y,
and Zn. Refer to comments in the individual NCMAT files for references
concerning the origin of these curves.
* Missing VDOS curves were added to uranium oxide (UO2), taken from
DOI:10.1103/PhysRevB.102.134312. Note that UO2 NCMAT files with VDOS
tuned for specific temperatures are available (refer to comments in the
UO2 NCMAT file for details).
* All existing files with VDOS have been update to NCMAT v4, and had
@DEBYETEMPERATURE sections removed in order to benefit from the better
performance of getting the atomic displacements from the VDOS.
* Added new material: gamma-Iron (Fe_sg225_Iron-gamma.ncmat) with VDOS
curve. At the same time, the not particularly useful beta-Iron file was
removed, so the NCrystal data library now contains both alpha- and
gamma-iron, both with VDOS curves.
* Expose debyeIsotropicMSD and debyeTempFromIsotropicMSD functions from
NCDebyeMSD.hh header to C and Python, allowing conversions between
atomic mean-squared-displacement and Debye temperature.
* Improve robustness of the function debyeTempFromIsotropicMSD. Previously
the internally deployed root-finding algorithm could fail under some
scenarios (e.g. non-ultra cold rubidium).
* Various improvements for ncrystal_vdos2ncmat.
* Compilation fix for pre-Catalina OSX where the aligned_alloc function is
apparently missing.
* Fix bug where early calls to removeAllDataSources could get reverted by
subsequent plugin loading.
* Before defining macros in public headers, check if present already and
if so undefine.

v2.5.81 2020-04-01
* RC2 for incoming release v2.6.0.

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(NOT DEFINED NCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE)
endif()

#Setup project:
project(NCrystal VERSION 2.5.81 LANGUAGES CXX C)
project(NCrystal VERSION 2.6.0 LANGUAGES CXX C)

if(NOT DEFINED NCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.81
2.6.0
1 change: 1 addition & 0 deletions data/UO2_sg225_Uraninite.ncmat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ NCMAT v4
# G. Noguere, J. P. Scotta, S. Xu, A. Filhol, J. Ollivier, E. Farhi,
# Y. Calzavarra, S. Rols, B. Fak, J.-M. Zanotti, and Q. Berrod
# Phys. Rev. B 102, 134312 - Published 30 October 2020
# https://doi.org/10.1103/PhysRevB.102.134312
#
# The paper above provided VDOS curves at 300K, 350K, 420K, 600K, 900K, 1200K,
# and 1675K. Most users will likely get decent performance for materials at most
Expand Down
8 changes: 4 additions & 4 deletions ncrystal_core/include/NCrystal/NCVersion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
#endif

#define NCRYSTAL_VERSION_MAJOR 2
#define NCRYSTAL_VERSION_MINOR 5
#define NCRYSTAL_VERSION_PATCH 81
#define NCRYSTAL_VERSION 2005081 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "2.5.81"
#define NCRYSTAL_VERSION_MINOR 6
#define NCRYSTAL_VERSION_PATCH 0
#define NCRYSTAL_VERSION 2006000 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "2.6.0"

#include "NCrystal/ncapi.h"
#include <stdexcept>
Expand Down
13 changes: 11 additions & 2 deletions ncrystal_core/include/NCrystal/internal/NCElIncScatter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ namespace NCrystal {
const char * name() const noexcept final { return "ElIncScatter"; }
virtual ~ElIncScatter();

//Construct from Info:
ElIncScatter( const Info& );
//Construct from Info. For special use-cases it is possible to apply an
//overall cross section scale-factor (>0.0), and to optionally use the total
//scattering cross section, rather than just sigma_incoherent:
//
//Two constructors based on Info objects are available, one taking the MSD
//information from AtomInfo, and getting them from integration of VDOS
//curves (.
struct msd_from_atominfo_t {};
struct msd_from_dyninfo_t {};
ElIncScatter( msd_from_atominfo_t, const Info&, double scale_factor = 1.0, bool use_total_xsect = false );
ElIncScatter( msd_from_dyninfo_t, const Info&, double scale_factor = 1.0, bool use_total_xsect = false );

//Constructor similar to the ElIncXS constructor:
ElIncScatter( const VectD& elements_meanSqDisp,
Expand Down
8 changes: 4 additions & 4 deletions ncrystal_core/include/NCrystal/ncrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ extern "C" {
# undef NCRYSTAL_VERSION_STR
#endif
#define NCRYSTAL_VERSION_MAJOR 2
#define NCRYSTAL_VERSION_MINOR 5
#define NCRYSTAL_VERSION_PATCH 81
#define NCRYSTAL_VERSION 2005081 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "2.5.81"
#define NCRYSTAL_VERSION_MINOR 6
#define NCRYSTAL_VERSION_PATCH 0
#define NCRYSTAL_VERSION 2006000 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "2.6.0"
NCRYSTAL_API int ncrystal_version(); /* returns NCRYSTAL_VERSION */
NCRYSTAL_API const char * ncrystal_version_str(); /* returns NCRYSTAL_VERSION_STR */

Expand Down
54 changes: 51 additions & 3 deletions ncrystal_core/src/NCElIncScatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@
////////////////////////////////////////////////////////////////////////////////

#include "NCrystal/internal/NCElIncScatter.hh"
#include "NCrystal/internal/NCVDOSEval.hh"
#include "NCrystal/NCInfo.hh"
#include "NCrystal/internal/NCElIncXS.hh"
#include "NCrystal/internal/NCRandUtils.hh"
#include "NCrystal/internal/NCDebyeMSD.hh"
#include "NCrystal/internal/NCSpan.hh"
#include "NCrystal/internal/NCDebyeMSD.hh"
#include <iostream>

namespace NC = NCrystal;

NC::ElIncScatter::~ElIncScatter() = default;

NC::ElIncScatter::ElIncScatter( const Info& ci )
NC::ElIncScatter::ElIncScatter( msd_from_atominfo_t, const Info& ci, double scale_factor, bool use_total_xsect )
{
nc_assert_always( !(scale_factor<=0.0) );

if ( !ci.hasAtomInfo() )
NCRYSTAL_THROW(MissingInfo,"Passed Info object lacks AtomInfo information"
" (elastic-incoherent model only works with crystalline materials).");
Expand All @@ -56,8 +62,11 @@ NC::ElIncScatter::ElIncScatter( const Info& ci )
ntot += ai.numberPerUnitCell();

for ( const auto& ai : atominfos ) {
scale.push_back(double(ai.numberPerUnitCell())/ntot);
bixs.push_back(ai.atomData().incoherentXS().get());
scale.push_back(double(ai.numberPerUnitCell())*scale_factor/ntot);
if (use_total_xsect)
bixs.push_back(ai.atomData().scatteringXS().get());
else
bixs.push_back(ai.atomData().incoherentXS().get());
if ( ai.msd().has_value() ) {
msd.push_back( ai.msd().value() );
} else {
Expand All @@ -76,6 +85,45 @@ NC::ElIncScatter::ElIncScatter( const Info& ci )
m_elincxs = std::make_unique<ElIncXS>( msd, bixs, scale );
}

NC::ElIncScatter::ElIncScatter( msd_from_dyninfo_t, const Info& info, double scale_factor, bool use_total_xsect )
{
VectD msd, bixs, scale;
msd.reserve(info.getDynamicInfoList().size());
bixs.reserve(info.getDynamicInfoList().size());
scale.reserve(info.getDynamicInfoList().size());

nc_assert_always( !(scale_factor<=0.0) );
unsigned nmissing = 0;
for ( auto& di : info.getDynamicInfoList() ) {
double msd_value(0.0);
if ( dynamic_cast<const DI_VDOS*>(di.get()) ) {
msd_value = VDOSEval( static_cast<const DI_VDOS*>(di.get())->vdosData() ).getMSD();
} else if ( dynamic_cast<const DI_VDOSDebye*>(di.get()) ) {
if ( !info.hasTemperature() )
NCRYSTAL_THROW(MissingInfo,"Requested to evaluate atomic mean-squared-displacements for a material without a temperature value.");
msd_value = debyeIsotropicMSD( static_cast<const DI_VDOSDebye*>(di.get())->debyeTemperature(),
info.getTemperature(),
di->atomData().averageMassAMU() );
} else {
++nmissing;
}
if ( msd_value ) {
msd.push_back( msd_value );
scale.push_back( di->fraction() * scale_factor );
if (use_total_xsect)
bixs.push_back(di->atomData().scatteringXS().get());
else
bixs.push_back(di->atomData().incoherentXS().get());
}
}

m_elincxs = std::make_unique<ElIncXS>( msd, bixs, scale );

if ( nmissing > 0 )
std::cout<<"NCrystal WARNING: Requested to create incoherent-elastic component from dynamic information in material where "<<nmissing
<<" atom"<<(nmissing==1?"":"s")<<" do not have the necessary information."<<std::endl;
}

NC::ElIncScatter::ElIncScatter( const VectD& elements_meanSqDisp,
const VectD& elements_boundincohxs,
const VectD& elements_scale )
Expand Down
56 changes: 55 additions & 1 deletion ncrystal_core/src/NCStdScatFact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "NCrystal/internal/NCElIncScatter.hh"
#include "NCrystal/internal/NCSABScatter.hh"
#include "NCrystal/internal/NCSABFactory.hh"
#include "NCrystal/internal/NCString.hh"//for safe_str2dbl

namespace NC = NCrystal;

Expand Down Expand Up @@ -116,9 +117,62 @@ namespace NCrystal {
if ( cfg.get_incoh_elas() && info.isCrystalline() ) {
const bool has_msd = info.hasAtomMSD() || ( info.hasTemperature() && info.hasDebyeTemperature() );
if ( has_msd )
components.push_back({1.0,makeSO<ElIncScatter>(info)});
components.push_back({1.0,makeSO<ElIncScatter>(ElIncScatter::msd_from_atominfo_t(),info)});
}

if ( info.countCustomSections( "SPECIALINCOHELAS" ) > 0 ) {
//Special "secret" test code for testing purposes (before we perhaps
//decide to make it an official feature). Add @CUSTOM_SPECIALINCOHELAS
//section to enable incoherent-elastic treatment in non-crystals.
if ( info.countCustomSections( "SPECIALINCOHELAS" ) != 1 )
NCRYSTAL_THROW(BadInput,"Only one CUSTOM_SPECIALINCOHELAS section is allowed in input.");
bool has_atominfo_msd = info.hasAtomMSD() || ( info.hasTemperature() && info.hasDebyeTemperature() );
bool has_dyninfovdos_msd = false;
if ( !has_atominfo_msd ) {
for ( auto& di : info.getDynamicInfoList() ) {
if ( dynamic_cast<const DI_VDOS*>(di.get()) ) {
//Allow if even a single VDOS is present (it might for instance be
//e.g. H-in-polyethylene where the almost irrelevant C atom is
//simply modelled as free gas).
has_dyninfovdos_msd = true;
break;
}
}
}
if (!has_atominfo_msd && !has_dyninfovdos_msd)
NCRYSTAL_THROW(BadInput,"Presence of CUSTOM_SPECIALINCOHELAS section requires ability to"
" determine atomic mean squared displacements for all atoms.");
if ( info.isCrystalline() )
NCRYSTAL_THROW(BadInput,"A @CUSTOM_SPECIALINCOHELAS section can currently only be used when there is otherwise no unit cell information in the input.");
if ( cfg.get_incoh_elas() ) {
//Decode:
//
//Syntax is single line with factor (>0.0,<=10.0), followed optionally by the keyword "include_sigma_coh"
const auto& cd = info.getCustomSection("SPECIALINCOHELAS");//vector<VectS>
if ( cd.size() != 1 )
NCRYSTAL_THROW(BadInput,"CUSTOM_SPECIALINCOHELAS section should only have 1 line.");
const auto& line = cd.at(0);
nc_assert_always(!line.empty());
if ( line.empty() || line.size() > 2 )
NCRYSTAL_THROW(BadInput,"Bad syntax in CUSTOM_SPECIALINCOHELAS section (too many entries).");
double scale_factor;
if (!safe_str2dbl( line.at(0), scale_factor ) || !(scale_factor>0.0) || !(scale_factor<=10.0) )
NCRYSTAL_THROW(BadInput,"Invalid scale factor in CUSTOM_SPECIALINCOHELAS section. Value should be in interval (0.0,10.0].");
bool include_sigma_coh(false);
if ( line.size()==2 ) {
if ( line.at(1)!="include_sigma_coh" )
NCRYSTAL_THROW2(BadInput,"Invalid keyword in CUSTOM_SPECIALINCOHELAS section. Syntax requires either"
" just the scale factor, or a scale factor followed by the keyword \"include_sigma_coh\".");
include_sigma_coh = true;
}
if (has_atominfo_msd)
components.push_back({1.0,makeSO<ElIncScatter>(ElIncScatter::msd_from_atominfo_t(),info,scale_factor, include_sigma_coh)});
else
components.push_back({1.0,makeSO<ElIncScatter>(ElIncScatter::msd_from_dyninfo_t(),info,scale_factor, include_sigma_coh)});
}
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
//Coherent-elastic (Bragg) component:
if ( cfg.get_coh_elas() && info.isCrystalline() && info.hasHKLInfo() ) {
Expand Down
2 changes: 1 addition & 1 deletion ncrystal_mcstas/NCrystal_sample.comp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* %I
*
* Written by: NCrystal developers
* Version: 2.5.81
* Version: 2.6.0
* Origin: NCrystal Developers (European Spallation Source ERIC and DTU Nutech)
*
* McStas sample component for the NCrystal scattering library. Find more
Expand Down
2 changes: 1 addition & 1 deletion ncrystal_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
################################################################################

__license__ = "Apache 2.0, http://www.apache.org/licenses/LICENSE-2.0"
__version__ = '2.5.81'
__version__ = '2.6.0'
__status__ = "Production"
__author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
__copyright__ = "Copyright 2015-2021 %s"%__author__
Expand Down

0 comments on commit bd05cc8

Please sign in to comment.