Library to keep track of a sequential potential energy landscape.
Documentation: https://tdegeus.github.io/QPot
This library is free to use under the MIT license. Any additions are very much appreciated, in terms of suggested functionality, code, documentation, testimonials, word-of-mouth advertisement, etc. Bug reports or feature requests can be filed on GitHub. As always, the code comes with no guarantee. None of the developers can be held responsible for possible mistakes.
Download: .zip file | .tar.gz file.
(c - MIT) T.W.J. de Geus (Tom) | [email protected] | www.geus.me | github.com/tdegeus/QPot
- The documentation of the code.
- The code itself.
- The unit tests, under test.
- The examples, under examples.
The code is a C++ header-only library (see installation notes), but a Python module is also provided (see installation notes). The interfaces are identical except:
- All xtensor objects (
xt::xtensor<...>
) are NumPy arrays in Python. - All
::
in C++ are.
in Python.
Storage of a chunk of the series of yield positions, including support to move along the full series by providing sequential chunks upon request.
#include <QPot/Chunked.hpp>
int main()
{
xt::xtensor<double,1> y = xt::linspace<double>(-1, 10, 12);
QPot::Chunked yield(0.0, y);
std::cout << yield.i() << std::endl;
std::cout << yield.yleft() << std::endl;
std::cout << yield.yright() << std::endl;
yield.set_x(5.5);
return 0;
}
See QPot::Chunked for more information. Furthermore, please find this example.
Static list of yield points.
#include <QPot/Static.hpp>
int main()
{
xt::xtensor<double,1> y = xt::linspace<double>(-1, 10, 12);
QPot::Static yield(0.0, y);
std::cout << yield.currentIndex() << std::endl;
std::cout << yield.currentYieldLeft() << std::endl;
std::cout << yield.currentYieldRight() << std::endl;
yield.setPosition(5.5);
std::cout << yield.currentIndex() << std::endl;
std::cout << yield.currentYieldLeft() << std::endl;
std::cout << yield.currentYieldRight() << std::endl;
return 0;
}
See QPot::Static for more information.
Dynamically redraw yield points.
#include <QPot/Redraw.hpp>
int main()
{
auto uniform = [=](std::array<size_t, 2> shape) {
return xt::ones<double>(shape); };
size_t N = 10;
xt::xtensor<double,1> x = xt::zeros<double>({N});
QPot::RedrawList yield(x, uniform);
std::cout << yield.currentIndex() << std::endl;
std::cout << yield.currentYieldLeft() << std::endl;
std::cout << yield.currentYieldRight() << std::endl;
x.fill(5.5)
yield.setPosition(x);
std::cout << yield.currentIndex() << std::endl;
std::cout << yield.currentYieldLeft() << std::endl;
std::cout << yield.currentYieldRight() << std::endl;
return 0;
}
From Python one can use:
def uniform(shape): return np.ones(shape) x = np.random.rand([100]) y = QPot.RedrawList(x, uniform);
See QPot::RedrawList for more information.
conda install -c conda-forge qpot
# Download QPot
git checkout https://github.com/tdegeus/QPot.git
cd QPot
# Install headers, CMake and pkg-config support
cmake -Bbuild .
cd build
make install
conda install -c conda-forge python-qpot
Note that xsimd and hardware optimisation are not enabled. To enable them you have to compile on your system, as is discussed next.
You need xtensor, xtensor-python and optionally xsimd as prerequisites. In addition scikit-build is needed to control the build from Python. The easiest is to use conda to get the prerequisites:
conda install -c conda-forge xtensor-python conda install -c conda-forge xsimd conda install -c conda-forge scikit-buildIf you then compile and install with the same environment you should be good to go. Otherwise, a bit of manual labour might be needed to treat the dependencies.
# Download QPot
git checkout https://github.com/tdegeus/QPot.git
cd QPot
# Compile and install the Python module
# (-vv can be omitted as is controls just the verbosity)
python setup.py install --build-type Release -vv
# OR, Compile and install the Python module with hardware optimisation
# (with scikit-build CMake options can just be added as command-line arguments)
python setup.py install --build-type Release -DUSE_SIMDD=1 -vv
Using QPot your CMakeLists.txt
can be as follows
cmake_minimum_required(VERSION 3.1)
project(example)
find_package(QPot REQUIRED)
add_executable(example example.cpp)
target_link_libraries(example PRIVATE QPot)
The following targets are available:
-
QPot
Includes QPot and the xtensor dependency. -
QPot::assert
Enables assertions by definingQPOT_ENABLE_ASSERT
. -
QPot::debug
Enables all assertions by definingQPOT_ENABLE_ASSERT
andXTENSOR_ENABLE_ASSERT
. -
QPot::compiler_warings
Enables compiler warnings (generic).
It is advised to think about compiler optimisation and enabling xsimd.
Using CMake this can be done using the xtensor::optimize
and xtensor::use_xsimd
targets.
The above example then becomes:
cmake_minimum_required(VERSION 3.1)
project(example)
find_package(QPot REQUIRED)
find_package(xtensor REQUIRED)
find_package(xsimd REQUIRED)
add_executable(example example.cpp)
target_link_libraries(example PRIVATE
QPot
xtensor::optimize
xtensor::use_xsimd)
See the documentation of xtensor concerning optimisation.
Presuming that the compiler is c++
, compile using:
c++ -I/path/to/QPot/include ...
Note that you have to take care of the xtensor dependency, the C++ version, optimisation, enabling xsimd, ...
Presuming that the compiler is c++
, compile using:
c++ `pkg-config --cflags QPot` ...
Note that you have to take care of the xtensor dependency, the C++ version, optimization, enabling xsimd, ...
- Great simplification: only two free-functions are left (#43).
- [CMake] Minor style updates (#37)
- [Python] Build with scikit-build (#36)
- [docs] Minor readme updates
- [CMake] Minor style updates (#35)
- [CMake] Improving handling options
- [Python] Switching to xtensor-python : avoids copies (#33)
- [setup.py] Adding missing import
- [CI] Changing dummy version
- Adding global CMake options (+ updating CI)
- Adding missing include
- Avoiding setuptools_scm dependency if
SETUPTOOLS_SCM_PRETEND_VERSION
is defined - Building docs on release
- Minor bugfix bounds-check: including assertion of lock in criterion
- CMake updates.
- Adding convenience function
Chunked::size
.
- Adding convenience function
i_chunk
.
- Updating docs, readme, and example.
QPot::Chunked::redraw
: Allow trial.- Applying latest pcg32 features.
- Adding test for
Chunked::ymin_chunk
.
- Minor CMake updates.
- Integrating Python API in CMake.
- Marking
Chunked::i()
const (#24).
- Adding: Chunked storage (#23)
- Fixing version in doxygen docs
- [CI] Minor style update
- Updating doxygen-awesome
- Simplifying CMake
- Minor documentation updates
- API change: "yield()" -> "yieldPosition()" to avoid broken Python API
- Various documentation updates.
- Adding (optional) HDF5 test to test platform independence of sequence restore).
- Allowing restoring a sequence with less data.
- Allow prompt if a redraw was triggered on the last position update.
- Python API: relaxing dependencies.
- RedrawList: Adding extra assertion on position.
- Bugfix: making sure that "m_idx" is computed correctly after a redraw
- Adding QPot::random interface to simplify RedrawList and to make reconstruction in Python possible (see test).
- [docs] Dark background.
- Allow reconstruction of random RedrawList (see test-case).
- Adding documentation using doxygen.
- Switching to setuptools_scm for versioning.
- Minor style updates.
- Adding
nextYield
.
- Switching to GitHub CI.
- Adding
yield
to return the entire landscape or a cross-section. - Adding offset overloads to
currentYieldLeft
andcurrentYieldRight
. - Adding
currentYield
to get the landscape around the current position.
- Adding "checkYieldBoundLeft" and "checkYieldBoundRight" to "Static".
- Using Catch2 to test for floats.