Skip to content

Commit

Permalink
import from dgcode ncrystaldev git: candidate for version 3.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Aug 19, 2024
1 parent 07a15fc commit 6578af9
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 27 deletions.
33 changes: 22 additions & 11 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v3.9.2 2024-08-19
* Prevent rare error in the MiniMC framework, which happened when acos was
evaluated on a value which due to numerical instabilities was ever so
slightly larger than one.
* Minor tweaks to MMC parsing and plotting code.

v3.9.1 2024-08-16
* Add missing _hklobjects.py file which was left out by mistake. Thus
making the newly introduced info.hklObjects() function actually work.
Expand Down Expand Up @@ -64,11 +70,12 @@ v3.9.0 2024-08-12
show all output from NCrystal in some dedicated text box).
* NCrystal has been updated to work with latest versions of Numpy, Clang,
GCC, Python, Gemmi, and Spglib. Additionally work has started to support
Intel OneAPI compilers and Microsoft VSCode, although more work is needed
to finalise this. As part of these efforts, the ABI had to be broken in
some places, since for instance Microsoft VSCode did not support all the
data structures used previously (for instance, VSCode's `std::vector`
does not accept move-only objects like `std::unique_ptr`).
Intel OneAPI compilers and Microsoft VisualStudio, although more work is
needed to finalise this. As part of these efforts, the ABI had to be
broken in some places, since for instance Microsoft VisualStudio did not
support all the data structures used previously (for instance,
VisualStudio `std::vector` does not accept move-only objects like
`std::unique_ptr`).
* This concludes the highlights in this changelog entry - refer to the
following items for more detailed information about specific changes.
* Several speedups of the phonon convolution calculation code was
Expand All @@ -87,15 +94,16 @@ v3.9.0 2024-08-12
function, the NCrystal.enableFactoryThreads Python function, or the
ncrystal_enable_factory_threadpool C function.
* Build NCrystal library with -fno-math-errno (github issue #169).
* Several non-trivial fixes were implemented to prepare for MS VSCode and
Intel oneapi compilation support. This breaks ABI.
* Several non-trivial fixes were implemented to prepare for MS VisualStudio
and Intel oneapi compilation support. This breaks ABI.
* Apply -fp-model=precise for intel oneapi compiler.
* Change C++ DynamicInfoList type from
std::vector<std::unique_ptr<DynamicInfo>> to typedef
SmallVector<std::unique_ptr<DynamicInfo>,4>, since VSCode apparently does
not support std::vector's with move-only objects. This in principle
breaks the ABI and API, but is deemed necessary. A few other types in
internal non-API headers were changed as well for the same reason.
SmallVector<std::unique_ptr<DynamicInfo>,4>, since VisualStudio
apparently does not support std::vector's with move-only objects. This in
principle breaks the ABI and API, but is deemed necessary. A few other
types in internal non-API headers were changed as well for the same
reason.
* Fix build error due to ODR violation in the TopLvlVar type.
* Removed noexcept from C++ functions where it should not have been added
(e.g. those used for streaming to std::ostream).
Expand Down Expand Up @@ -134,6 +142,9 @@ v3.9.0 2024-08-12
feature is for now kept out of the documentation, but can be tested with:
"nctool --bench --help".
* Updated year in copyright notice in all files.
* Info objects gets a new .hklObjects() method which returns HKL list
information in a more object oriented and convenient format than the
existing .hklList(). See issue #164 for more details.

v3.8.2 2024-04-30
* Add importlib_metadata as python build dependency for Python < 3.8.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ endif()

cmake_policy( SET CMP0048 NEW )#Not sure if this is really needed

project( NCrystal VERSION 3.9.1 ${_project_metadata} )
project( NCrystal VERSION 3.9.2 ${_project_metadata} )

unset( _project_metadata )

Expand Down
2 changes: 1 addition & 1 deletion NCrystal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

#NB: Synchronize meta-data below with fields in setup.py+template_setup.py.in meta data:
__license__ = "Apache 2.0, http://www.apache.org/licenses/LICENSE-2.0"
__version__ = '3.9.1'
__version__ = '3.9.2'
__status__ = "Production"
__author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
__copyright__ = "Copyright 2015-2024 %s"%__author__
Expand Down
27 changes: 23 additions & 4 deletions NCrystal/_mmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,14 @@ def calcfrac(h):
if title:
plt.title(title)

plt.suptitle(self.cfgstr)
suptitle_fs = 'medium'
if len(self.cfgstr)>40:
suptitle_fs = 'small'
if len(self.cfgstr)>80:
suptitle_fs = 'x-small'
if len(self.cfgstr)>101:
suptitle_fs = 'xx-small'
plt.suptitle(self.cfgstr,fontsize=suptitle_fs)

absfracstr = 'unknown fraction'
if tot_integral_with_absorption and tot_integral:
Expand All @@ -448,6 +455,7 @@ def calcfrac(h):
plt.plot([], [], ' ', label="Absorbed %s"%absfracstr)

legargs = {}

_plt_final(do_grid = do_grid,
do_legend = do_legend,
do_show = do_show,
Expand Down Expand Up @@ -505,17 +513,26 @@ def _parse_unit(valstr,unitmap):

def _parse_energy( valstr ):
v,u,uv = _parse_unit( valstr, _energy_units )
if v is not None and u is None and uv is None:
from .exceptions import NCBadInput
raise NCBadInput('Invalid energy specification (missing unit'
f' like Aa or eV): "{valstr}"')
if v is None:
from .exceptions import NCBadInput
raise NCBadInput(f'Invalid energy specification: "{valstr}"')
if u.lower() in ('aa','angstrom'):
if u is not None and u.lower() in ('aa','angstrom'):
from .constants import wl2ekin
return wl2ekin(v)
v *= uv
return v

def _parse_length( valstr, mfp = None ):
v,u,uv = _parse_unit( valstr, _length_units )
if v is not None and u is None and uv is None:
from .exceptions import NCBadInput
_ex0="mfp" if mfp is not None else "mm"
raise NCBadInput('Invalid length specification (missing unit like '
f'{_ex0} or cm): "{valstr}"')
if v is None:
from .exceptions import NCBadInput
raise NCBadInput(f'Invalid length specification: "{valstr}"')
Expand Down Expand Up @@ -564,7 +581,8 @@ def _round2digits(x):
def quick_diffraction_pattern( cfgstr, *,
neutron_energy,
material_thickness,
nstat = 'auto' ):
nstat = 'auto',
nthreads = 'auto' ):

### TODO: change c-api and use:
### from .misc import MaterialSource
Expand Down Expand Up @@ -598,7 +616,8 @@ def simfct( n, cfgstr ):
geomcfg = f'sphere;r={r_meter}',
srccfg = (f'constant;ekin={neutron_energy_eV}'
f';n={n};z={-r_meter*(1-1e-13)}'),
tally_detail_lvl = 2
tally_detail_lvl = 2,
nthreads = nthreads
)
t1 = time.time()
return t1-t0, res
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.1
3.9.2
6 changes: 3 additions & 3 deletions ncrystal_core/include/NCrystal/NCVersion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

#define NCRYSTAL_VERSION_MAJOR 3
#define NCRYSTAL_VERSION_MINOR 9
#define NCRYSTAL_VERSION_PATCH 1
#define NCRYSTAL_VERSION 3009001 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.1"
#define NCRYSTAL_VERSION_PATCH 2
#define NCRYSTAL_VERSION 3009002 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.2"

#include "NCrystal/ncapi.h"
#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion ncrystal_core/include/NCrystal/internal/NCMMC_Defs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace NCRYSTAL_NAMESPACE {
#ifndef NDEBUG
#define NCRYSTAL_DEBUGMMCMSG(msg) ::NCRYSTAL_NAMESPACE::Msg::detail:: \
outputMsgMS( ::NCRYSTAL_NAMESPACE::Msg::detail::MsgStream() << "MMC:" << msg, \
::NCRYSTAL_NAMESPACE::MsgType::Warning );
::NCRYSTAL_NAMESPACE::MsgType::Info );
#else
# define NCRYSTAL_DEBUGMMCMSG(msg) {}
#endif
Expand Down
7 changes: 5 additions & 2 deletions ncrystal_core/include/NCrystal/internal/NCMMC_StdTallies.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ namespace NCRYSTAL_NAMESPACE {
const std::size_t n = b.size();
NCRYSTAL_DEBUGMMCMSG("Got result basket with size "<<n);
double exit_angle[basket_N];
for ( std::size_t i = 0; i < n; ++i )
exit_angle[i] = std::acos( b.neutrons.uz[i] );
for ( std::size_t i = 0; i < n; ++i ) {
nc_assert( b.neutrons.uz[i] > -(1.0+1e-14) );
nc_assert( b.neutrons.uz[i] < (1.0+1e-14) );
exit_angle[i] = std::acos( ncclamp(b.neutrons.uz[i],-1.0,1.0) );
}
for ( std::size_t i = 0; i < n; ++i )
exit_angle[i] *= kToDeg;
for ( std::size_t i = 0; i < n; ++i )
Expand Down
6 changes: 3 additions & 3 deletions ncrystal_core/include/NCrystal/ncrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1201,9 +1201,9 @@ extern "C" {
#endif
#define NCRYSTAL_VERSION_MAJOR 3
#define NCRYSTAL_VERSION_MINOR 9
#define NCRYSTAL_VERSION_PATCH 1
#define NCRYSTAL_VERSION 3009001 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.1"
#define NCRYSTAL_VERSION_PATCH 2
#define NCRYSTAL_VERSION 3009002 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.2"
NCRYSTAL_API int ncrystal_version(void); /* returns NCRYSTAL_VERSION */
NCRYSTAL_API const char * ncrystal_version_str(void); /* returns NCRYSTAL_VERSION_STR */

Expand Down

0 comments on commit 6578af9

Please sign in to comment.