ttadano / alamode

Ab initio simulator for thermal transport and lattice anharmonicity
http://sourceforge.net/projects/alamode
MIT License
132 stars 53 forks source link

SPGLIB Root Question #130

Closed ejmeitz closed 1 year ago

ejmeitz commented 1 year ago

In the CMAKE file for alm CMAKE looks for the spglib library with:

if (SPGLIB_ROOT)
    include_directories("${SPGLIB_ROOT}/include")
    set(spglib "-L${SPGLIB_ROOT}/lib -L${SPGLIB_ROOT}/lib64 -lsymspg")
else()
    message("SPGLIB_ROOT is not given by -DSPGLIB_ROOT option. Just add -lsymspg.")
    set(spglib "-lsymspg")
endif()

I am interpreting SPGLIB_ROOT to be the folder you can clone from github. This has no include folder. All of the header files are just inside src with the .cpp files. From what I understand ALAMODE just needs the spglib.h file and does not need to link against spglib. However, there is no include folder so this first if will never work and if I try to build with that flag the resulting executable will not work.

I understand this flag is not mandatory to compile, but when I try the other method (no SPGLIB_ROOT flag) ALAMODE is unable to find libsymspg.so.2 file when I try to run it even though it is in my /usr/local/lib folder. I'm pretty sure I'm doing something wrong but I also think the CMAKE file is incorrect. Please let me know how I can fix this.

Thanks!

ttadano commented 1 year ago

SPGLIB_ROOT is the directory where the spglib's lib and include subdirectories exist, which is specified by the -DCMAKE_INSTALL_PREFIX option (https://spglib.github.io/spglib/install.html). You may need to run all commands up to cmake --install . to generate the lib and include directories.

The second option (empty SPGLIB_ROOT) is supposed to work only when the spglib header file and library file are placed in the system directories included, respectively, in ${INCLUDE_DIR} and ${LD_LIBRARY_PATH} environment variables.

If the build was successful, but a runtime error occurred, please add

export SPGLIB_ROOT=/path/to/spglib/installdir
export LD_LIBRARY_PATH=$SPGLIB_ROOT/lib:$LD_LIBRARY_PATH

to your .bashrc (or .zshrc if you use zsh).

ejmeitz commented 1 year ago

Perfect, adding the paths directly to my bashrc fixed it. Not really sure why it could not find the libraries in /usr/local though as that is the default.

By the way the tests in the test folder do not pass if you have numpy above 1.22.0. I pasted the error below. Downgrading numpy fixed this.

test_si.py:139: UserWarning: Input line 42 contained no data and will not be counted towards `max_rows=64`.  This differs from the behaviour in NumPy <=1.22 which counted lines rather than rows.  If desired, the previous behaviour can be achieved by using `itertools.islice`.
Please see the 1.23 release notes for an example on how to do this.  If you wish to ignore this warning, use `warnings.filterwarnings`.  This warning is expected to be removed in the future and is given only once per `loadtxt` call.
  data_ref = np.loadtxt(fname_ref,
ValueError: could not convert string to float: 'FCs'
ttadano commented 1 year ago

Thank you for letting me know about the issue in the test_si.py script. I've fixed it.