Menu

Tree [19cbb7] ticket_158 /
 History

HTTPS access


File Date Author Commit
 Demos 2022-10-03 Ulf Lorenz Ulf Lorenz [ee5135] Harmonized copyright headers
 build 2022-10-02 Ulf Lorenz Ulf Lorenz [b20300] Ticket #187 : added a test for the Python inter...
 cmake 2022-10-02 Ulf Lorenz Ulf Lorenz [1075a8] Replaced tabs by spaces
 doc 2022-10-03 Ulf Lorenz Ulf Lorenz [ee5135] Harmonized copyright headers
 include 2022-11-15 Ulf Lorenz Ulf Lorenz [2b47b2] Ticket #158 : added tests for non-zero temperature
 licenses 2022-01-02 Ulf Lorenz Ulf Lorenz [ce3206] Ticket #210 : started to outsource settings int...
 python 2022-11-12 Ulf Lorenz Ulf Lorenz [b98d96] Ticket #158 : added new code to Python interface
 scripts 2022-10-02 Ulf Lorenz Ulf Lorenz [1075a8] Replaced tabs by spaces
 src 2022-11-15 Ulf Lorenz Ulf Lorenz [19cbb7] Ticket_158: got acceptance test almost to work
 test 2022-11-15 Ulf Lorenz Ulf Lorenz [19cbb7] Ticket_158: got acceptance test almost to work
 tools 2022-01-07 Ulf Lorenz Ulf Lorenz [cc2760] Updated cppcheck configuration and suppressions
 AUTHORS 2019-12-29 Ulf Lorenz Ulf Lorenz [4315c8] Fixed a pretty severe memory leak
 CMakeLists.txt 2022-10-02 Ulf Lorenz Ulf Lorenz [1075a8] Replaced tabs by spaces
 CONTRIBUTING 2022-01-06 Ulf Lorenz Ulf Lorenz [38d26b] Ticket #159 : added documentation on how to set...
 LICENSE 2017-08-27 Ulf Lorenz Ulf Lorenz [3bb05e] Ticket 94: put all documentation files under CC...
 NEWS 2022-10-02 Ulf Lorenz Ulf Lorenz [6bd680] Ticket #187: updated NEWS
 README 2022-01-06 Ulf Lorenz Ulf Lorenz [09442d] Minor improvements to README
 README_VirtualMachine 2022-01-07 Ulf Lorenz Ulf Lorenz [59b100] Fixed an incorrect URL
 Vagrantfile 2022-01-06 Ulf Lorenz Ulf Lorenz [38d26b] Ticket #159 : added documentation on how to set...

Read Me

Description
===========

Wavepacket C++ is a C++ library to numerically solve the Schroedinger equation
for distinguishable particles.

A Python interface / Python module is also available, see the end of this
readme for installation instructions.

The code is under the (very permissive) ISC license. See the file LICENSE for
further details.

The current detailed status of what is implemented can be found in the wiki
https://sourceforge.net/p/wavepacket/cpp/wiki/Features/

If you lack a feature that you would like to have, drop a mail to ulf@wavepacket.org.
Depending on the complexity of the feature, this will lead to an immediate,
rapid, or priorized implementation.


System requirements (C++ library)
=================================

Note that the package provides a mostly automatized installation in a virtual machine.
See README_VirtualMachine for the details.

To be able to compile the code, you need the following:

* A Unix system.
  I only test the build under Linux, but if you get the other requirements, any
  other Unix should be fine as well. Building on Windows is principally possible,
  but rather complicated, see the wiki.
* CMake >= 3.16
    - you can download it from https://cmake.org
* a compiler that implements the C++-14 standard.
  Any modern g++ (version 5 or later) or CLang++ (version 3.4 or later) should be fine.
* the tensor library that we use
    - clone it via git
      git clone https://github.com/juanjosegarciaripoll/tensor.git
    - the current CMake branch or (when released) version 1.0 may be the most convenient to build.
      - note that you will need to enable FFTW support, which also requires the fftw libraries
        (run the configure script with "--with-fftw" or CMake with "-D TENSOR_FFTW=ON")
      - you do _not_ need Arpack, which only adds more dependency management.
        Disable with --without-arpack or the CMake variant "-D TENSOR_ARPACK=OFF".
* the boost libraries from http://www.boost.org
    - You need at least boost version 1.56; most distributions should come with this version
      nowadays
* doxygen if you want to build the documentation
* gnuplot, ffmpeg, possibly ImageMagick for the processing of the plotting output


Compilation and getting started (C++)
=====================================

Simple Installation
-------------------

WavePacket uses CMake for the setup of the build process.  Assuming you have
all requirements installed in standard locations, you can compile and install
the library with the following steps. They assume the wavepacket directory (where
this Readme resides) to be ${WP_SRCDIR}.

1. Create a new build directory where the binary files will be placed
   (we do a so-called out-of-source build)
2. In the build directory, run "cmake -S ${WP_SRCDIR}". If this does not work, see the
   notes in the next section.
3. In the build directory, run "make -j 4" (or however many cores you have).
4. Optionally, check that everything went ok by running "ctest -j 4" (or however many cores you have)
   and getting a cup of coffee.
   If some test fails, drop me a mail (ulf@wavepacket.org). I usually run these tests
   only on my private machine, so spurious numerical noise may occur and lead to test
   errors. I would be glad to know that to fix the tests.
5. Install everything by running "make install", usually with admin privileges
   afterwards you can remove the build directory


Configuring the build
---------------------

You can change various settings of the build process by defining variables to
your preferences. There are three ways to do so:

1. When you originally run cmake, add flags "-D<var>=<value>", for example
   cmake -DCMAKE_BUILD_TYPE=Debug -S ${WP_SRCDIR}
2. After running cmake once, run
   ccmake ${WP_SRCDIR}
   This fires up a textmode program where you can edit the variables and
   reconfigure/regenerate the build system by hitting "c", then "g".
   Some variables are marked as advanced, hit "t" to be able to edit them.
3. Alternatively, you can run "cmake-gui" for a graphical interface for
   the editing of the variables. Select the build directory and you get a
   list of all settings.

The most important variables that you may wish to change:

* CMAKE_INSTALL_PREFIX
    defines the root path where all the libraries and such will be installed.
    Default is "/usr/local"
* CMAKE_CXX_COMPILER
    the full path to the C++ compiler to use
* WP_BUILD_DEMOS, WP_BUILD_DOCUMENTATION, WP_BUILD_PYTHON
    Set to "ON" or "OFF" to enable / disable these features
* WP_TENSOR_CPPFLAGS, WP_TENSOR_LDFLAGS
    The automatic detection of the tensor library is relatively complex. You
    can override it by supplying the compilation and linking flags explicitly
    in these two variables.



First Steps
-----------

The installation also installs a build script to simplify the compilation of your
own programs. The syntax is

wp-build.sh  <executable_name> <source_file>

The script is documented and can be found under scripts/ for additional
details. The building is also documented in the package documentation (the
"Hello, world" tutorial). Check also the "Demos" subdirectory where you
can find some demo source code to try this out.

The package documentation is available online: 
http://wavepacket.sourceforge.net/cpp-doc/current/index.xhtml
and also optionally compiled when building the library.
It contains a small tutorial that should cover the basic concepts of the library.
Also, some special use-cases/demos are discussed in depth. Several solutions to
common problems can be found under the demos (everything below directory
Demos/), and in the acceptance tests under test/acceptance/.


The Python interface
====================

The Python bindings allows access to the WavePacket classes via Python.
This can be useful because debugging and experimenting is simpler
and faster in Python as compared to C++.

For more details on how to use the Python bindings and the limitations, see
the tutorial "Using the Python interface"
http://wavepacket.sourceforge.net/cpp-doc/current/sec_python.xhtml

Note that this module is not a Python package with a "Python look&feel", but a
binding to a C++ library. It may feel awkward at times as a result. For
example, you need to wrap all CTensors in numpy.arrays for proper manipulation.


Installation requirements
-------------------------

If you have installed the Python package manager "pip", you can install any
missing dependency with "${PYTHON} -m pip install <package>". Required packages are

* Python3
* numpy
* unittest
* pybind11 >= 2.6.0

The Python interface also offers some Python-only extensions for plotting.
This requires additional packages

* matplotlib
* FFMpeg (for writing video files, get from https://ffmpeg.org)


Building with the Python interface
----------------------------------

The build with the Python interface is completely analogous to the C++ version (see above).
All you need to do is to set the WP_BUILD_PYTHON option, that is, run

    cmake -D WP_BUILD_PYTHON=ON -S ${WP_SRCDIR}

To make sure that everything works, I would recommend to run the tests (run
"ctest" in the binary directory), because they will fail on binding errors.

The build uses CMake's facilities to try to locate a Python3 installation,
which should just work for most users. In obscure cases (e.g., multiple Python
installations), you may want to provide a hint with the variable
"Python3_ROOT_DIR", e.g. adding the flag
"-DPython3_ROOT_DIR=/home/me/special_python3_installation".


Using the Python interface
--------------------------

Starting with version 0.3.2, Wavepacket no longer installs the Python bindings
as a Python package, but puts it in the installation directory. As a
consequence, you need to tell Python where to find the Wavepacket bindings. By
default, they are installed under ${INSTALL_DIR}/lib/wavepacket_python. By
default, the ${INSTALL_DIR} is /usr/local.

* You can set the PYTHONPATH variable. It is a colon-separated list of directories,
  so something like "export PYTHONPATH=/usr/local/lib/wavepacket_python" should do the trick.
* Or you can set the path variable directly in Python with

  import sys
  sys.path.append('/usr/local/lib/wavepacket_python')

Afterwards, you can just "import wavepacket" and use all classes from this namespace, e.g.,
"wavepacket.PlaneWaveDof(...)". See the tutorial and the demos for more information.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.