Compare commits

...

10 Commits

Author SHA1 Message Date
Sylvain Tricot c9aa391634 Merge branch 'hotfix/1.7.post13' 2023-03-29 11:45:01 +02:00
Sylvain Tricot cf74431c31 Fix new dtype values for Numpy.
Numpy does not allow anylonger types np.int or np.float.
These are replaced simply by int and float python native types.
2023-03-29 11:41:52 +02:00
Sylvain Tricot 0699f193b3 Merge branch 'hotfix/1.7.post12' 2022-10-06 18:24:31 +02:00
Sylvain Tricot 2bdc9943b9 Fix numpy bug with alen()
* The numpy.alen() function is deprecated. We use len() instead
* The use of pkg_resources is discouraged. We use importlib.metadata
  instead. I also removed setuptools_scm get_version. I switch to
  a simple call to "git describe", easier now that we use git flow
* The build fails with python3.10 if compiling wx from sources.
  A fix in the Makefile will be proposed in a future commit.
2022-10-06 18:19:16 +02:00
Sylvain Tricot b6f2531999 Merge branch 'hotfix/1.7.post11' 2022-10-05 13:44:04 +02:00
Sylvain Tricot a4351f5606 Add a "light" installation of msspec
This is similar to a "devel" installation, but only the
virtualenv is created and the msspec package is installed
inside (not in edit mode). Bindings to the Fortran code
are not built.

It is intended to use msspec functions to create clusters but
without having to install wx.
2022-10-05 13:40:22 +02:00
Sylvain Tricot 74ca8f467f Removed malloc NPH_M parameter.
epsi-builds/msspec_python3/pipeline/head There was a failure building this commit Details
In get_theta_phi_scan, the malloc keyword was given
with NPH_M=8000. It was enough for most of calculations
but it was also impossible to change in cases where more
memory was needed. The keyword is now removed so that
it can be direclty specified by the user if needed.
The default value was increased to 8000 instead of 2000.
2021-12-13 18:51:12 +01:00
Sylvain Tricot 38023dcd52 Bug in matplotlib 3.5.0
epsi-builds/msspec_python3/pipeline/head This commit looks good Details
There is presumably a bug when using pcolormesh
with msspec in matplotlib 3.5.0. The stereo projection
does not work properly and the CPU is rising at 100% as
well as the memory usage. Meanwhile, the event loop of Wx
is affected freezing the GUI. Reverting to last stable 3.4.3
version fixes the problem for now. A true fix should be found
asap.
2021-12-02 12:20:40 +01:00
Sylvain Tricot 75c599de95 Added 'other_parameters' keyword in _get_scan.
epsi-builds/msspec_python3/pipeline/head This commit looks good Details
This allows to set or modify any option right before runing
Phagen and Spec. Mostly for debug purposes.
2021-11-30 17:53:47 +01:00
Sylvain Tricot e36373a576 Fixed bug in 'mean_free_path' option.
It was impossible to enter a numerical value.
The 'allowed_values' keyword was set in the definition
of the 'mean_free_path' parameter, I commented it to
allow any value for this option.
2021-11-30 16:56:20 +01:00
9 changed files with 63 additions and 44 deletions

View File

@ -32,10 +32,17 @@ devel: venv pybinding wx
@$(INSIDE_VENV) pip install -e src/
light: VENV_PATH = ./_venv
light: venv
@$(INSIDE_VENV) pip install src/
_build_wx/wxPython.target:
@$(INSIDE_VENV) echo "Building wxPython for your `python --version 2>&1` under Linux $(DISTRO_RELEASE)..."
# Create a folder to build wx into
@mkdir -p _build_wx
@$(INSIDE_VENV) pip install attrdict sip
# TODO: attrdict is no longer compatible with collections package. The build will fail
# download the wheel or the source if it cannot find a wheel
@$(INSIDE_VENV) cd _build_wx && pip download -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/$(DISTRO_RELEASE) wxPython
# Build the source if a tar.gz was downloaded

View File

@ -727,15 +727,15 @@ class SpecIO(object):
content += line
nat = p.extra_nat
nra_arr = np.ones((nat), dtype=np.int)
nra_arr = np.ones((nat), dtype=int)
thfwd_arr = np.ones((nat))
path_filtering = p.extra_parameters['calculation'].get_parameter(
'path_filtering').value
if (path_filtering is not None and
'backward_scattering' in path_filtering):
ibwd_arr = np.ones((nat), dtype=np.int)
ibwd_arr = np.ones((nat), dtype=int)
else:
ibwd_arr = np.zeros((nat), dtype=np.int)
ibwd_arr = np.zeros((nat), dtype=int)
thbwd_arr = np.ones((nat))
for at in p.extra_atoms:
i = at.get('proto_index') - 1

View File

@ -301,7 +301,7 @@ class _MSCALCULATOR(Calculator):
wf = 4.5
source_energy = self.source_parameters.get_parameter('energy').value
ke = source_energy - binding_energy - wf
#return np.array(ke, dtype=np.float).flatten()
#return np.array(ke, dtype=float).flatten()
return ke
@ -383,7 +383,7 @@ class _MSCALCULATOR(Calculator):
'NODES_EX_M' : 3,
'NSPIN_M' : 1, # to change for spin dependent
'NTH_M' : 2000,
'NPH_M' : 2000,
'NPH_M' : 8000,
'NDIM_M' : 100000,
'N_TILT_M' : 11, # to change see extdir.f
'N_ORD_M' : 250,
@ -615,7 +615,7 @@ class _PED(_MSCALCULATOR):
def _get_scan(self, scan_type='theta', phi=0,
theta=np.linspace(-70, 70, 141), level=None,
kinetic_energy=None, data=None,
malloc={}):
malloc={}, other_parameters={}):
LOGGER.info("Computting the %s scan...", scan_type)
if data:
self.iodata = data
@ -650,6 +650,13 @@ class _PED(_MSCALCULATOR):
self.spectroscopy_parameters.set_parameter('level', level)
# It is still possible to modify any option right before runing phagen
# and spec
for k, v in other_parameters.items():
grp_str, param_str = k.split('.')
grp = getattr(self, grp_str)
grp.set_parameter(param_str, v, force=True)
self.get_tmatrix()
self.run_spec(malloc)
@ -851,7 +858,7 @@ class _PED(_MSCALCULATOR):
return self.iodata
def get_scattering_factors(self, level='1s', kinetic_energy=None,
data=None):
data=None, **kwargs):
"""Computes the scattering factors of all prototypical atoms in the
cluster.
@ -870,11 +877,11 @@ class _PED(_MSCALCULATOR):
"""
data = self._get_scan(scan_type='scatf', level=level, data=data,
kinetic_energy=kinetic_energy)
kinetic_energy=kinetic_energy, **kwargs)
return data
def get_theta_scan(self, phi=0, theta=np.linspace(-70, 70, 141),
level=None, kinetic_energy=None, data=None):
level=None, kinetic_energy=None, data=None, **kwargs):
"""Computes a polar scan of the emitted photoelectrons.
:param phi: The azimuthal angle in degrees. See
@ -891,11 +898,12 @@ class _PED(_MSCALCULATOR):
"""
data = self._get_scan(scan_type='theta', level=level, theta=theta,
phi=phi, kinetic_energy=kinetic_energy, data=data)
phi=phi, kinetic_energy=kinetic_energy,
data=data, **kwargs)
return data
def get_phi_scan(self, phi=np.linspace(0, 359, 359), theta=0,
level=None, kinetic_energy=None, data=None):
level=None, kinetic_energy=None, data=None, **kwargs):
"""Computes an azimuthal scan of the emitted photoelectrons.
:param phi: All the values of the azimuthal angle to be computed. See
@ -912,12 +920,13 @@ class _PED(_MSCALCULATOR):
"""
data = self._get_scan(scan_type='phi', level=level, theta=theta,
phi=phi, kinetic_energy=kinetic_energy, data=data)
phi=phi, kinetic_energy=kinetic_energy,
data=data, **kwargs)
return data
def get_theta_phi_scan(self, phi=np.linspace(0, 360),
theta=np.linspace(0, 90, 45), level=None,
kinetic_energy=None, data=None):
kinetic_energy=None, data=None, **kwargs):
"""Computes a stereographic scan of the emitted photoelectrons.
The azimuth ranges from 0 to 360° and the polar angle ranges from 0 to
@ -934,11 +943,11 @@ class _PED(_MSCALCULATOR):
"""
data = self._get_scan(scan_type='theta_phi', level=level, theta=theta,
phi=phi, kinetic_energy=kinetic_energy, data=data,
malloc={'NPH_M': 8000})
**kwargs)
return data
def get_energy_scan(self, phi=0, theta=0,
level=None, kinetic_energy=None, data=None):
level=None, kinetic_energy=None, data=None, **kwargs):
"""Computes an energy scan of the emitted photoelectrons.
:param phi: All the values of the azimuthal angle to be computed. See
@ -955,7 +964,8 @@ class _PED(_MSCALCULATOR):
"""
data = self._get_scan(scan_type='energy', level=level, theta=theta,
phi=phi, kinetic_energy=kinetic_energy, data=data)
phi=phi, kinetic_energy=kinetic_energy,
data=data, **kwargs)
return data

View File

@ -1310,8 +1310,8 @@ class ScanParameters(BaseParameters):
# LOGGER.error('Incompatible options!')
# raise ValueError(msg)
# p._value = np.array(p.value, dtype=np.float).flatten()
arr = np.array(p.value, dtype=np.float).flatten()
# p._value = np.array(p.value, dtype=float).flatten()
arr = np.array(p.value, dtype=float).flatten()
theta0 = arr[0]
theta1 = arr[-1]
@ -1345,7 +1345,7 @@ class ScanParameters(BaseParameters):
# LOGGER.error('Incompatible options')
# raise ValueError(msg)
arr = np.array(p.value, dtype=np.float).flatten()
arr = np.array(p.value, dtype=float).flatten()
phi0 = arr[0]
phi1 = arr[-1]
@ -1539,7 +1539,7 @@ class CalculationParameters(BaseParameters):
Parameter('cutoff_factor', types=(int, float),
limits=(1e-4, 999.9999), default=0.01, private=False),
Parameter('mean_free_path', types=(int, float, str),
default='SeahDench', allowed_values=('mono', 'SeahDench'),
default='SeahDench', #allowed_values=('mono', 'SeahDench'),
doc="""
The electron mean free path value. You can either:
- Enter a value (in Angströms), in this case any value <=0 will disable the damping

View File

@ -18,8 +18,8 @@
# along with this msspec. If not, see <http://www.gnu.org/licenses/>.
#
# Source file : src/msspec/utils.py
# Last modified: ven. 10 avril 2020 15:49:35
# Committed by : "Sylvain Tricot <sylvain.tricot@univ-rennes1.fr>"
# Last modified: Thu, 06 Oct 2022 18:19:16 +0200
# Committed by : Sylvain Tricot <sylvain.tricot@univ-rennes1.fr> 1665073156 +0200
"""
@ -38,7 +38,11 @@ import ase.atom
from ase import Atom
from ase import Atoms
from msspec.iodata import Data
try:
from msspec.iodata import Data
except ImportError as err:
print(err)
from msspec.misc import LOGGER
@ -476,7 +480,7 @@ def hemispherical_cluster(cluster, emitter_tag=0, emitter_plane=0, diameter=0,
a = cell[:, 0].max() # a lattice parameter
# the number of planes in the cluster
p = np.alen(np.unique(np.round(cluster.get_positions()[:, 2], 4)))
p = len(np.unique(np.round(cluster.get_positions()[:, 2], 4)))
# the symbol of your emitter
symbol = cluster[np.where(cluster.get_tags() == emitter_tag)[0][0]].symbol
@ -581,7 +585,7 @@ def hemispherical_cluster(cluster, emitter_tag=0, emitter_plane=0, diameter=0,
# an array of all unique remaining z
all_z = np.sort(np.unique(np.round(cluster.get_positions()[:, 2], 4)))
assert emitter_plane < np.alen(all_z), ("There are not enough existing "
assert emitter_plane < len(all_z), ("There are not enough existing "
"plans.")
ze = all_z[- emitter_plane - 1] # the z-coordinate of the emitter
Atoms.translate(cluster, [0, 0, -ze]) # put the emitter in (0,0,0)

View File

@ -16,39 +16,38 @@
# along with this msspec. If not, see <http://www.gnu.org/licenses/>.
#
# Source file : src/msspec/version.py
# Last modified: ven. 10 avril 2020 17:34:38
# Committed by : "Sylvain Tricot <sylvain.tricot@univ-rennes1.fr>"
# Last modified: Thu, 06 Oct 2022 18:19:16 +0200
# Committed by : Sylvain Tricot <sylvain.tricot@univ-rennes1.fr> 1665073156 +0200
import os
from pkg_resources import DistributionNotFound
from pkg_resources import get_distribution
from pkg_resources import parse_version
from importlib.metadata import version
import subprocess
# find the version number
# 1- Try to read it from the git info
# 2- If it fails, try to read it from the distribution file
# 1- If it fails, try to read it from the distribution file
# 2- Try to read it from the git info
# 3- If it fails, try to read it from the VERSION file
PKGNAME = 'msspec'
try:
from setuptools_scm import get_version
v = get_version(root='../../', relative_to=__file__, version_scheme="post-release")
v = parse_version(v)
if v._version.post[-1] == 0:
__version__ = v.base_version
else:
__version__ = v.public
__version__ = version(PKGNAME)
except Exception as err:
try:
__version__ = get_distribution(__name__.strip('.version')).version
p = subprocess.run(["git", "describe"], capture_output=True, text=True)
if p.stdout not in ("", None):
__version__ = p.stdout.strip()
else:
raise NameError("git describe failed!")
except Exception as err:
try:
thisfile_path = os.path.abspath(__file__)
thisfile_dir = os.path.dirname(thisfile_path)
versionfile = os.path.join(thisfile_dir, "../VERSION")
with open(versionfile, "r") as fd:
__version__ = fd.readline()
__version__ = fd.readline().strip()
except Exception as err:
print("Unable to get the version number!")
__version__ = "9.9.9"

View File

@ -41,8 +41,7 @@ F2PYFLAGS_DBG = --debug-capi --debug
# /!\ DO NOT EDIT BELOW THAT LINE (unlesss you know what you're doing...) #
# CORE CONFIGURATION #
################################################################################
#VERSION:=$(shell python -c "import msspec; print(msspec.__version__)")
VERSION:=$(shell git describe|sed 's/-\([[:digit:]]\+\)-.*/\.post\1/')
VERSION:=$(shell git describe)
VENV_PATH := $(INSTALL_PREFIX)/src/msspec_venv_$(VERSION)

View File

@ -2,7 +2,7 @@ ase
h5py
ipython
lxml
matplotlib
matplotlib==3.4.3
numpy
Pint
pandas

0
utils/dockerized/linux/msspec Normal file → Executable file
View File