Skip to content

Commit

Permalink
import from dgcode ncrystaldev git: candidate for version 3.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Aug 16, 2024
1 parent 8d05d93 commit 07a15fc
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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.
* Fix debug compilation of MMC messages.

v3.9.0 2024-08-12
* This release brings both general improvements and new features, as well
as a slew of maintenance updates and bug fixes. The first few items below
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.0 ${_project_metadata} )
project( NCrystal VERSION 3.9.1 ${_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.0'
__version__ = '3.9.1'
__status__ = "Production"
__author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
__copyright__ = "Copyright 2015-2024 %s"%__author__
Expand Down
135 changes: 135 additions & 0 deletions NCrystal/_hklobjects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
"""
Experimental feature for more object-oriented and less efficient access to hkl
lists.
See also https://github.com/mctools/ncrystal/issues/164.
"""

################################################################################
## ##
## This file is part of NCrystal (see https://mctools.github.io/ncrystal/) ##
## ##
## Copyright 2015-2024 NCrystal developers ##
## ##
## Licensed under the Apache License, Version 2.0 (the "License"); ##
## you may not use this file except in compliance with the License. ##
## You may obtain a copy of the License at ##
## ##
## http://www.apache.org/licenses/LICENSE-2.0 ##
## ##
## Unless required by applicable law or agreed to in writing, software ##
## distributed under the License is distributed on an "AS IS" BASIS, ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
## See the License for the specific language governing permissions and ##
## limitations under the License. ##
## ##
################################################################################

class HKLEntry:

"""A group or family of HKL planes, all sharing the same value of d-spacing
and structure factor (fsquared). If .is_symequiv evaluates to True, these
exactly represent a group of symmetry-equivalent planes.
"""
def __str__( self ):
hkl=self.hkl_label
return ( f'HKL( hkl_label=({hkl[0]},{hkl[1]},{hkl[2]}), '
f'd={self.d:g}Aa, F2={self.fsquared:g}barn, '
f'N={self.mult} )' )

def __init__(self,hh,kk,ll,mult,dsp,fsq,hklinfotype,issymeqv):
"""For internal usage only, do not create therse objects manually."""
self.__h = hh
self.__k = kk
self.__l = ll
self.__mult = mult
self.__dsp = dsp
self.__fsq = fsq
self.__hklinfotype = hklinfotype
self.__issymeqv = issymeqv

@property
def hkl_type( self ):
"""The type of HKL group represented by this entry. Returns
HKLInfoType.SymEqvGroup if this is a group of symmetry-equivalent
planes.
"""
return self.__hklinfotype

@property
def is_symequiv(self):
"""Returns True if .hkl_type equals HKLInfoType.SymEqvGroup."""
return self.__issymeqv

@property
def hkl_label( self ):
"""Returns a hkl label for the entry, i.e. one of the hkl points in the
group as a tuple of three integers: (h,k,l)."""
return (self.__h[0],self.__k[0],self.__l[0])

@property
def h( self ):
"""
An array of h values. Note that this has half the length of
.multiplicity, since we exclude entries that can be generated from each
other by a mere sign flip.
"""
return self.__h

@property
def k( self ):
"""
An array of k values. Note that this has half the length of
.multiplicity, since we exclude entries that can be generated from each
other by a mere sign flip.
"""
return self.__k

@property
def l( self ): # noqa E743
"""
An array of l values. Note that this has half the length of
.multiplicity, since we exclude entries that can be generated from each
other by a mere sign flip.
"""
return self.__l

@property
def dspacing( self ):
"""The d-spacing value in units of angstrom."""
return self.__dsp

@property
def d( self ):
"""The d-spacing value in units of angstrom."""
return self.__dsp

@property
def fsquared( self ):
"""The squared structure factor (F^2) in units of barn."""
return self.__fsq

@property
def f2( self ):
"""The squared structure factor (F^2) in units of barn."""
return self.__fsq

@property
def multiplicity( self ):
"""The number of hkl points in the group."""
return self.__mult

@property
def mult( self ):
"""The number of hkl points in the group."""
return self.__mult

def _iter_hklobjects( info ):
hklinfotype = info.hklInfoType()
issymeqv = info.hklIsSymEqvGroup()
for hh,kk,ll,mult,dsp,fsq in info.hklList(all_indices=True):
yield HKLEntry(hh,kk,ll,mult,dsp,fsq,
hklinfotype,issymeqv)

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.0
3.9.1
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 0
#define NCRYSTAL_VERSION 3009000 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.0"
#define NCRYSTAL_VERSION_PATCH 1
#define NCRYSTAL_VERSION 3009001 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.1"

#include "NCrystal/ncapi.h"
#include <stdexcept>
Expand Down
6 changes: 3 additions & 3 deletions ncrystal_core/include/NCrystal/internal/NCMMC_Defs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace NCRYSTAL_NAMESPACE {
#endif

#ifndef NDEBUG
# define NCRYSTAL_DEBUGMMCMSG(msg) { ::NCRYSTAL_NAMESPACE::Msg::detail:: \
outputMsgOSS( std::ostringstream() << "MMC: " << msg, \
::NCRYSTAL_NAMESPACE::MsgType::Info); }
#define NCRYSTAL_DEBUGMMCMSG(msg) ::NCRYSTAL_NAMESPACE::Msg::detail:: \
outputMsgMS( ::NCRYSTAL_NAMESPACE::Msg::detail::MsgStream() << "MMC:" << msg, \
::NCRYSTAL_NAMESPACE::MsgType::Warning );
#else
# define NCRYSTAL_DEBUGMMCMSG(msg) {}
#endif
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 0
#define NCRYSTAL_VERSION 3009000 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.0"
#define NCRYSTAL_VERSION_PATCH 1
#define NCRYSTAL_VERSION 3009001 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.1"
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 07a15fc

Please sign in to comment.