Code Monkey home page Code Monkey logo

nusquids's People

Contributors

arguelles avatar atrettin avatar cnweaver avatar connorsponsler avatar fkallen avatar jcarpiod avatar jsalvado avatar jvansanten avatar kotoyo avatar mmkekic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nusquids's Issues

Install should include data

Currently, at configure time we fix the paths in global.h to point to the source directory, and do not change them when we install this header. As a result, a user can build and install the library, but then have it break down if the source directory (with the only copy of the default data tables) is subsequently deleted. We should probably:

  1. Copy the data files to a suitable place like ${prefix}/share/nusquids
  2. Update the paths in global.h when installing it to point to the installed data

configure does not identify Ubuntu if run in WSL2.

Configure was giving me some trouble with finding the python libraries, turns out that uname -a will not give you an "ubuntu" if you're running Ubuntu with WSL2 (or WSL1 probably). My quick fix was to add another if to check for WSL in the output of uname. Maybe there's a better way to check the distro?

if uname -a | grep -i 'ubuntu' > /dev/null; then

found architecture 'x86_64', required architecture 'arm64'

I was trying to install nuSQuIDS on a Mac with the Apple M2 Max chip.

./configure --prefix="../nusquids" --with-gsl-incdir="../gsl/include" --with-gsl-libdir="../gsl/lib" --with-squids-incdir="../include" --with-squids-libdir="../squids/lib"

Checking manually specified GSL...
Looking for hdf5...
 Found hdf5 version 1.10.4 via executables in $PATH
Checking manually specified SQUIDS...
Generating config file...
Generating version header...
Generating data path header...
Generating makefile...
./configure: line 868: pkg-config: command not found
Done.

To build the library, run the following: make
After, to build examples: make examples

The doing

make

produced the following error:

Compiling src/body.cpp to build/body.o
Compiling src/nuSQuIDS.cpp to build/nuSQuIDS.o
Compiling src/resources.cpp to build/resources.o
Compiling src/taudecay.cpp to build/taudecay.o
Compiling src/tools.cpp to build/tools.o
Compiling src/xsections.cpp to build/xsections.o
Linking lib/libnuSQuIDS.a
Linking lib/libnuSQuIDS.dylib
ld: warning: -pie being ignored. It is only used when linking a main executable
ld: warning: ignoring duplicate libraries: '-lm', '-lpthread'
ld: warning: ignoring file '/opt/anaconda3/lib/libhdf5_hl.100.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/anaconda3/lib/libhdf5.103.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/anaconda3/lib/libz.1.2.11.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: warning: ignoring file '/opt/anaconda3/lib/libc++.1.0.dylib': found architecture 'x86_64', required architecture 'arm64'
ld: Undefined symbols:
  _H5Aclose, referenced from:
........
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libnuSQuIDS.dylib] Error 1

I have no root access.

Distutils removed in Python3.12

distutils was deprecated and then removed with the release of Python 3.12.

And since homebrew now also distributes that newer version of Python with boost-python - the current build system doesn't quite work in newer versions of MacOS because of the distutils dependency in the configure script here.

I found that using sysconfig and site can workaround the way it's used. Something like this works on my end - but this needs more testing against other Python versions. The lines highlighted in the link above could be replaced with

    PYTHON_INCDIR=`${PYTHON_EXE} -c 'import sysconfig; print(sysconfig.get_config_vars("INCLUDEDIR")[0])'`
    if [ -d "$PYTHON_INCDIR" ]; then
        echo " Found python include dir $PYTHON_INCDIR"
    else
        echo " Unable to locate the python include dir"
        return
    fi

    # This is the directory to which libraries should be installed for python to find them
    PYTHON_MODULEDIR=`${PYTHON_EXE} -c 'import site; print(site.USER_SITE)'`
    if [ "$PYTHON_MODULEDIR" ]; then
        echo " Python module install dir is $PYTHON_MODULEDIR"
    else
        echo " Unable to locate the python module dir"
        return
    fi

    # This is the directory that python claims contains its standard library,
    # which may or may not include the actual libpython
    PYTHON_STDLIBDIR=`${PYTHON_EXE} -c 'import sysconfig; print(sysconfig.get_config_vars("LIBDIR")[0])'`
    # This may contain a suffix which appears after the version like in 'libpython3.6m'
    # See https://www.python.org/dev/peps/pep-3149/#proposal
    PYTHONLIBSUFFIX=`${PYTHON_EXE} -c 'import sysconfig; print(sysconfig.get_config_vars("PY_BUILTIN_MODULE_CFLAGS")' 2>/dev/null`

Installation bug

Greetings,

I'm trying to install nuSQuIDS and am receiving the following compiler error:

$ ./configure --with-hdf5=/usr/local/hdf5 --with-squids=/usr/local
Looking for pkg-config...
Looking for gsl...
Found gsl version 1.16
Checking manually specified HDF5...
Looking for hdf5...
Checking manually specified SQUIDS...
Generating config file...
Generating version header...
Generating makefile...
Done.
To build library, run the following: make
After, to build examples: make examples
$ make
Compiling src/nuSQuIDS.cpp to build/nuSQuIDS.o
src/nuSQuIDS.cpp:625:38: error: invalid argument; expected 'enable' or 'disable'
#pragma clang loop vectorize(assume_safety)
^
1 error generated.
make: *** [build/nuSQuIDS.o] Error 1

Segmentation fault while importing nuSQuIDS in python

Hi! I have correctly installed all of the prerequisites for nuSQuIDS. However, when I try to use python bindings by importing nuSQuIDS, I get a segmentation fault.

 % python                 
Python 3.11.0 | packaged by conda-forge | (main, Jan 15 2023, 05:44:48) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nuSQuIDS
zsh: segmentation fault  python

No output or logs are generated.

All of the 18 tests in nuSQuIDS pass when I run make test. The following are the versions of the packages I am using:

python - 3.11.0
boost - 1.80.0
hdf5 - 1.12.2_2
squids - 1.3.0

I'd be happy to provide any more information that you might need.

The instructions to build the python bindings are outdated

With the latest update, the python bindings are no longer built with
cd resources/python/src/ make

Instead, one has to run
make python
and, optionally,
make python-install

The configure file correctly states the commands, that's how I found out.

Readable example notebook?

Hi there,

The python example notebook (resources/python/example/nuSQUIDS-DEMO.ipynb) has a glitch, that's why we can't read it. Is it possible to fix that?

It is a minor issue, however, it will be convenient to see the code and the results in notebook format.

Regards,
Samiur

Binder notebook does not work

Hello,

first of all, very cool project :) I tried to run the Binder notebook but I got this error, which happens after the test stage:

Installing headers in /home/jovyan/software/include/nuSQuIDS
Installing libraries in /home/jovyan/software/lib
Installing config information in /home/jovyan/software/lib/pkgconfig
g++ -O3 -fPIC -std=c++11 -I/srv/conda/envs/notebook/include/python3.9 -fpermissive -I/home/jovyan/software/include -Wno-abi -I/srv/conda/envs/notebook/include -I/srv/conda/envs/notebook/include -I../include/ -I/srv/conda/envs/notebook//include -I/srv/conda/envs/notebook/lib/python3.9/site-packages/numpy/core/include -I/home/jovyan/resources/python/src/../../..//include -I/home/jovyan/resources/python/src/..//inc -c nuSQUIDSpy.cpp -o nuSQUIDSpy.o
In file included from /srv/conda/envs/notebook/include/boost/python/detail/is_xxx.hpp:8:0,
                 from /srv/conda/envs/notebook/include/boost/python/detail/is_auto_ptr.hpp:9,
                 from /srv/conda/envs/notebook/include/boost/python/detail/copy_ctor_mutates_rhs.hpp:8,
                 from /srv/conda/envs/notebook/include/boost/python/detail/value_arg.hpp:7,
                 from /srv/conda/envs/notebook/include/boost/python/object/forward.hpp:10,
                 from /srv/conda/envs/notebook/include/boost/python/object/pointer_holder.hpp:16,
                 from /srv/conda/envs/notebook/include/boost/python/to_python_indirect.hpp:10,
                 from /srv/conda/envs/notebook/include/boost/python/converter/arg_to_python.hpp:10,
                 from /srv/conda/envs/notebook/include/boost/python/call.hpp:15,
                 from /srv/conda/envs/notebook/include/boost/python/object_core.hpp:14,
                 from /srv/conda/envs/notebook/include/boost/python/args.hpp:22,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:11,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/srv/conda/envs/notebook/include/boost/python/detail/is_auto_ptr.hpp:17:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 BOOST_PYTHON_IS_XXX_DEF(auto_ptr, std::auto_ptr, 1)
                                        ^
/srv/conda/envs/notebook/include/boost/detail/is_xxx.hpp:20:4: note: in definition of macro ‘BOOST_DETAIL_IS_XXX_DEF’
    qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) >        \
    ^~~~~~~~~~~~~~
/srv/conda/envs/notebook/include/boost/python/detail/is_auto_ptr.hpp:17:1: note: in expansion of macro ‘BOOST_PYTHON_IS_XXX_DEF’
 BOOST_PYTHON_IS_XXX_DEF(auto_ptr, std::auto_ptr, 1)
 ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from /srv/conda/envs/notebook/include/boost/function/function_base.hpp:16,
                 from /srv/conda/envs/notebook/include/boost/function/detail/prologue.hpp:17,
                 from /srv/conda/envs/notebook/include/boost/function/function_template.hpp:13,
                 from /srv/conda/envs/notebook/include/boost/function/detail/maybe_include.hpp:15,
                 from /srv/conda/envs/notebook/include/boost/function/function0.hpp:11,
                 from /srv/conda/envs/notebook/include/boost/python/errors.hpp:13,
                 from /srv/conda/envs/notebook/include/boost/python/handle.hpp:11,
                 from /srv/conda/envs/notebook/include/boost/python/args_fwd.hpp:10,
                 from /srv/conda/envs/notebook/include/boost/python/args.hpp:10,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:11,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /srv/conda/envs/notebook/include/boost/python/wrapper.hpp:8:0,
                 from /srv/conda/envs/notebook/include/boost/python/object/value_holder.hpp:15,
                 from /srv/conda/envs/notebook/include/boost/python/object/class_metadata.hpp:14,
                 from /srv/conda/envs/notebook/include/boost/python/class.hpp:23,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:18,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/srv/conda/envs/notebook/include/boost/python/override.hpp: In member function ‘boost::python::detail::method_result boost::python::override::operator()() const’:
/srv/conda/envs/notebook/include/boost/python/override.hpp:103:13: warning: ‘PyObject* PyEval_CallFunction(PyObject*, const char*,...)’ is deprecated [-Wdeprecated-declarations]
             ));
             ^
In file included from /srv/conda/envs/notebook/include/python3.9/Python.h:145:0,
                 from /srv/conda/envs/notebook/include/boost/python/detail/wrap_python.hpp:178,
                 from /srv/conda/envs/notebook/include/boost/python/detail/prefix.hpp:13,
                 from /srv/conda/envs/notebook/include/boost/python/args.hpp:8,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:11,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/srv/conda/envs/notebook/include/python3.9/ceval.h:26:43: note: declared here
 Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
                                           ^~~~~~~~~~~~~~~~~~~
In file included from /srv/conda/envs/notebook/include/boost/python/exception_translator.hpp:10:0,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:28,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/srv/conda/envs/notebook/include/boost/bind.hpp: At global scope:
/srv/conda/envs/notebook/include/boost/bind.hpp:41:1: note: #pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.
 )
 ^
In file included from /srv/conda/envs/notebook/include/boost/python/object/iterator.hpp:28:0,
                 from /srv/conda/envs/notebook/include/boost/python/iterator.hpp:12,
                 from /srv/conda/envs/notebook/include/boost/python.hpp:37,
                 from nuSQUIDSpy.h:36,
                 from nuSQUIDSpy.cpp:24:
/srv/conda/envs/notebook/include/boost/detail/iterator.hpp:13:37: note: #pragma message: This header is deprecated. Use <iterator>instead.
 BOOST_HEADER_DEPRECATED("<iterator>")
                                     ^
Linking /home/jovyan/resources/python/src/..//bindings/nuSQUIDSpy.a
Linking /home/jovyan/resources/python/src/..//bindings/nuSQUIDSpy.so
g++: error: libpython3.9.a: No such file or directory
g++: error: libpython3.9.a: No such file or directory
Makefile:56: recipe for target '/home/jovyan/resources/python/src/..//bindings/nuSQUIDSpy.so' failed
make: *** [/home/jovyan/resources/python/src/..//bindings/nuSQUIDSpy.so] Error 1
Removing intermediate container ce95417b036c
The command '/bin/sh -c ./binder/postBuild' returned a non-zero code: 2

Kind regards,
Roberto

nuSQUIDS constructor in python binding example

Hi,

In the python binding example, the cell

interactions = False
logscale = False
E_min = 1.0*units.GeV
E_max = 10.0*units.GeV
E_nodes = 101
neutrino_flavors = 3

nsq.nuSQUIDS(E_min, E_max, E_nodes, neutrino_flavors,nsq.NeutrinoType.neutrino,logscale,interactions)

results in a function signature mismatch error

ArgumentError: Python argument types in
    nuSQUIDS.__init__(nuSQUIDS, float, float, int, int, NeutrinoType, bool, bool)
did not match C++ signature:
    __init__(_object*, unsigned int numneu, nusquids::NeutrinoType NT)
    __init__(_object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > filename)
    __init__(_object*, nusquids::marray<double, 1u, std::allocator<double> > E_vector, unsigned int numneu, nusquids::NeutrinoType NT, bool iinteraction, std::shared_ptr<nusquids::NeutrinoCrossSections> ncs)
    __init__(_object*, nusquids::marray<double, 1u, std::allocator<double> > E_vector, unsigned int numneu, nusquids::NeutrinoType NT, bool iinteraction)
    __init__(_object*, nusquids::marray<double, 1u, std::allocator<double> > E_vector, unsigned int numneu, nusquids::NeutrinoType NT)
    __init__(_object*, nusquids::marray<double, 1u, std::allocator<double> > E_vector, unsigned int numneu)

I also tried to pass a numpy array by:

E_vector = np.array(E_min, E_max, E_nodes)
nsq.nuSQUIDS(E_vector, neutrino_flavors,nsq.NeutrinoType.neutrino,logscale,interactions)

But the signture still does not match.

I looked into resources/python/src/nuSQUIDSpy.cpp, and there is a struct of marray_from_python, but I haven't figured out how to use it yet.

Any hints for initialing nuSQUIDS in the multiple energy mode? Or is it possible to construct an nusquids::marray<double, 1u, std::allocator<double> > object from numpy array?

Boost-python can't be found on ARM64 Ubuntu

On ARM64 Ubuntu the configure file can't find boost/boost-python

#25 19.86 Looking for pkg-config...
#25 19.92  Found /usr/bin/pkg-config
#25 19.92 Looking for gsl...
#25 20.11  Found gsl version 2.7.1
#25 20.45 Looking for hdf5...
#25 20.80  Found hdf5 version 1.10.7 via executables in $PATH
#25 22.34 Checking manually specified SQUIDS...
#25 22.46 Looking for python
#25 22.57  Using python executable /usr/bin/python
#25 24.25 <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
#25 24.27 <string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
#25 24.31  Found python include dir /usr/include/python3.10
#25 24.89 <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
#25 24.91 <string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
#25 24.95  Python module install dir is /usr/lib/python3/dist-packages
#25 25.53 <string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
#25 25.55 <string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
#25 26.35  Found python library /usr/lib/aarch64-linux-gnu/libpython3.10.a
#25 27.59 Looking for boost built for python 310 in ...
#25 27.60  Unable to locate the boost_python library in /usr
#25 27.60  Found boost in /usr
#25 27.60  Boost include directory is /usr/include
#25 27.60  Boost library directory is /usr/lib/x86_64-linux-gnu
#25 27.66 *** Failed to find boost python; python bindings will not be built ***
#25 27.66 Looking for numpy...
#25 29.72  Found numpy
#25 29.72  Numpy include directory is /usr/lib/python3/dist-packages/numpy/core/include
#25 29.99 Generating config file...
#25 30.00 Generating version header...
#25 30.06 Generating data path header...
#25 30.06 Generating makefile...
#25 30.18 Done.

The culprit is here:

https://github.com/arguelles/nuSQuIDS/blob/master/configure#L264C98-L264C98

One needs to add

${GUESS_DIR}/lib/aarch64-linux-gnu

as an additional search hint.

nuSQUIDSpy CrossSectionLibrary not found

nuSQUIDSpy CrossSectionLibrary is not found and ModuleError is thrown, handling it falls to search for the file /xsec/nusigma_ which is not present in the specified directory, the files present are nusigma_proton.h5 and nusigma_neutron.h5. This requires the CrossSectionLibrary and the addTarget feature to work. The boost python bindings in nuSQUIDSpy.cpp shows a suspicious TODO comment saying "Map constructor?". Please help on this.
image
image
image
image

Detector depth

It would be good to have an option to modify the detector depth for underground detectors such as IceCube, DUNE, etc.

Best fit params

Minor issue in nuSQuIDS.cpp

The value of dm^2_31 for normal ordering is 2.57e-3 in the code, while in the original paper (arxiv:1409.5439) the best fit value is 2.457e-3

Docstrings for the python bindings

At the moment, the existing python interface is usable, but doesn't have great documentation. I often use jupyter's Shift+Tab keybindings to bring up docstrings for unfamiliar functions in order to better understand the purpose of each method. For NuSQuIDS, this currently brings up the default description showing the C++ signature, but not much less. For example, this, when trying to understand the Earth class:

> import nuSQuIDS as nsq
> nsq.Earth?

Docstring:      <no docstring>
Init docstring:
__init__( (object)arg1) -> None :

    C++ signature :
        void __init__(_object*)

__init__( (object)arg1, (str)arg2) -> None :

    C++ signature :
        void __init__(_object*,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
File:           /opt/conda/lib/python3.8/site-packages/nuSQuIDS.so
Type:           class
Subclasses:     

Adding python docstrings would help new users to understand the interface better and increase usability.

Two-neutrino mode fails

While running nuSQUIDS nus(numneu,neutrino) with numneu=2, the file executes and crashes with segmentation fault during EvolveState( ). This error comes from the attempt to evaluate HI, which always constructs the potential assuming three neutrino flavours. This is done even when propagating through the vacuum. This problem was easily fixed with an if statement.

The second problem is an error in MatrixExp.h (constant density mode), where one_normest_core
assigns a parameter 't' the default value t=2. An error is raised because of the statement
if (t >= A->size1)
throw std::runtime_error("t should be smaller than the order of the matrix.");
where A is an nxn matrix. For n = 2 this will give an error. This was fixed by changing the default value of 't' to 1, although I don't know if this will cause any trouble when doing the exponentials.

Problems while compiling

I get the following error which comes from the following line:

include "nuSQuIDS/nuSQuIDS.h"

which gives the following error:
/home/jose/Programs/SQuIDS/InstallDir/include/SQuIDS/detail/ProxyFwd.h: In member function ‘void squids::detail::AssignWrapper::apply4(squids::detail::double_vector4)’:
/home/jose/Programs/SQuIDS/InstallDir/include/SQuIDS/detail/ProxyFwd.h:94:10: note: The ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
void apply4(double_vector4 rhs){
^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.