-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit in new repository after project reorganisation
- Loading branch information
0 parents
commit 838b631
Showing
112 changed files
with
7,289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Sources | ||
*.h text | ||
*.c text | ||
*.hpp text | ||
*.cpp text | ||
*.py text | ||
*.cmake text | ||
|
||
# Documents | ||
*.md text | ||
*.txt text | ||
|
||
# Visual Studio | ||
*.sln text eol=crlf merge=union | ||
*.vcxproj text eol=crlf merge=union | ||
*.vcxproj.filters text eol=crlf merge=union |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Byte-compiled / optimized / binary extensions | ||
__pycache__/ | ||
*.py[cod] | ||
*.so | ||
|
||
# Distribution / packaging | ||
dependencies/ | ||
build/ | ||
dist/ | ||
sdist/ | ||
eggs/ | ||
develop-eggs/ | ||
*.egg-info/ | ||
*.egg | ||
.installed.cfg | ||
MANIFEST | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
project(pybinding) | ||
add_definitions("-std=c++11") | ||
|
||
# Python 3.x is required, 3.4 recommended | ||
set(PYTHON_VERSION 3) | ||
add_subdirectory(dependencies/boost_python) | ||
|
||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
find_package(NumPy REQUIRED) | ||
find_package(Eigen3orDownload 3.2.4 REQUIRED) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE) | ||
endif() | ||
|
||
include_directories( | ||
include | ||
${EIGEN3_INCLUDE_DIR} | ||
${PYTHON_INCLUDE_DIR} | ||
${NUMPY_INCLUDE_DIRS} | ||
) | ||
|
||
file(GLOB_RECURSE srcs FOLLOW_SYMLINKS include/* src/*) | ||
|
||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}) | ||
boost_python_add_module(_pybinding ${srcs}) | ||
|
||
# compiler specific config | ||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) | ||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) | ||
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Intel) | ||
add_definitions("-xHost") | ||
find_package(MKL REQUIRED) | ||
if(MKL_INCLUDE_DIR) | ||
add_definitions(-mkl=parallel -DTBM_USE_MKL) | ||
set(CMAKE_MODULE_LINKER_FLAGS "-mkl=parallel") | ||
endif() | ||
# disable a warning generated by the Eigen3 library | ||
add_definitions(-diag-disable 1478) | ||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include CMakeLists.txt license.md | ||
recursive-include cmake *.cmake | ||
recursive-include include *.hpp | ||
recursive-include src *.cpp *.hpp | ||
recursive-include docs *.py | ||
recursive-include dependencies/boost_python CMakeLists.txt *.cmake | ||
recursive-include dependencies/boost_python/include *.hpp | ||
recursive-include dependencies/boost_python/src *.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# - Try to find Eigen3 lib | ||
# | ||
# This module supports requiring a minimum version, e.g. you can do | ||
# find_package(Eigen3 3.1.2) | ||
# to require version 3.1.2 or newer of Eigen3. | ||
# | ||
# Once done this will define | ||
# | ||
# EIGEN3_FOUND - system has eigen lib with correct version | ||
# EIGEN3_INCLUDE_DIR - the eigen include directory | ||
# EIGEN3_VERSION - eigen version | ||
|
||
# Copyright (c) 2006, 2007 Montel Laurent, <[email protected]> | ||
# Copyright (c) 2008, 2009 Gael Guennebaud, <[email protected]> | ||
# Copyright (c) 2009 Benoit Jacob <[email protected]> | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
if(NOT Eigen3_FIND_VERSION) | ||
if(NOT Eigen3_FIND_VERSION_MAJOR) | ||
set(Eigen3_FIND_VERSION_MAJOR 2) | ||
endif(NOT Eigen3_FIND_VERSION_MAJOR) | ||
if(NOT Eigen3_FIND_VERSION_MINOR) | ||
set(Eigen3_FIND_VERSION_MINOR 91) | ||
endif(NOT Eigen3_FIND_VERSION_MINOR) | ||
if(NOT Eigen3_FIND_VERSION_PATCH) | ||
set(Eigen3_FIND_VERSION_PATCH 0) | ||
endif(NOT Eigen3_FIND_VERSION_PATCH) | ||
|
||
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") | ||
endif(NOT Eigen3_FIND_VERSION) | ||
|
||
macro(_eigen3_check_version) | ||
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) | ||
|
||
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") | ||
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") | ||
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") | ||
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") | ||
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") | ||
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") | ||
|
||
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) | ||
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) | ||
set(EIGEN3_VERSION_OK FALSE) | ||
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) | ||
set(EIGEN3_VERSION_OK TRUE) | ||
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) | ||
|
||
if(NOT EIGEN3_VERSION_OK) | ||
message(STATUS "Found Eigen3 ${EIGEN3_VERSION} in ${EIGEN3_INCLUDE_DIR}, " | ||
"but at least version ${Eigen3_FIND_VERSION} is required") | ||
endif(NOT EIGEN3_VERSION_OK) | ||
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) | ||
endmacro(_eigen3_check_version) | ||
|
||
if (EIGEN3_INCLUDE_DIR) | ||
|
||
# in cache already | ||
_eigen3_check_version() | ||
|
||
else (EIGEN3_INCLUDE_DIR) | ||
|
||
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library | ||
PATHS | ||
${CMAKE_INSTALL_PREFIX}/include | ||
${KDE4_INCLUDE_DIR} | ||
PATH_SUFFIXES eigen3 eigen | ||
) | ||
|
||
if(EIGEN3_INCLUDE_DIR) | ||
_eigen3_check_version() | ||
if(EIGEN3_VERSION_OK) | ||
message(STATUS "Found Eigen3: ${EIGEN3_VERSION} ${EIGEN3_INCLUDE_DIR}" "") | ||
endif() | ||
mark_as_advanced(EIGEN3_INCLUDE_DIR) | ||
endif(EIGEN3_INCLUDE_DIR) | ||
|
||
endif(EIGEN3_INCLUDE_DIR) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# - Try to find Eigen3 or download it | ||
# An exact version must be specified. | ||
# The output variables are: | ||
# | ||
# EIGEN3_INCLUDE_DIR - the eigen include directory | ||
# EIGEN3_VERSION - eigen version | ||
# | ||
|
||
if(Eigen3orDownload_FIND_VERSION) | ||
# try to find local copy first | ||
find_package(Eigen3 ${Eigen3orDownload_FIND_VERSION}) | ||
else() | ||
message(FATAL_ERROR "A version must be specified") | ||
endif() | ||
|
||
if (NOT EIGEN3_FOUND) | ||
# try to download it, if it isn't already | ||
set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/dependencies") | ||
set(EIGEN3_INCLUDE_DIR ${dependencies_dir}/eigen3) | ||
|
||
if(NOT EXISTS ${EIGEN3_INCLUDE_DIR}) | ||
message(STATUS "Downloading Eigen3...") | ||
set(tmp_dir "${dependencies_dir}/tmp") | ||
set(tar_file "${tmp_dir}/eigen.tar.gz") | ||
file(DOWNLOAD "https://bitbucket.org/eigen/eigen/get/${Eigen3orDownload_FIND_VERSION}.tar.gz" | ||
${tar_file}) | ||
|
||
# extract downloaded tar file | ||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${tar_file} | ||
WORKING_DIRECTORY ${tmp_dir}) | ||
file(REMOVE ${tar_file}) | ||
file(GLOB ex_dir ${tmp_dir}/eigen-*) | ||
|
||
if(NOT EXISTS ${ex_dir}) | ||
set(EIGEN3_INCLUDE_DIR "EIGEN3_INCLUDE_DIR-NOTFOUND") | ||
if(Eigen3orDownload_FIND_REQUIRED) | ||
message(FATAL_ERROR "Could not find or download Eigen3 ${Eigen3orDownload_FIND_VERSION}") | ||
endif() | ||
else() | ||
set(EIGEN3_VERSION ${Eigen3orDownload_FIND_VERSION}) | ||
|
||
# rename to a nicer dir | ||
file(RENAME ${ex_dir} ${EIGEN3_INCLUDE_DIR}) | ||
# delete everything except the headers and signature file | ||
file(GLOB to_delete ${EIGEN3_INCLUDE_DIR}/*) | ||
list(REMOVE_ITEM to_delete ${EIGEN3_INCLUDE_DIR}/Eigen) | ||
list(REMOVE_ITEM to_delete ${EIGEN3_INCLUDE_DIR}/unsupported) | ||
list(REMOVE_ITEM to_delete ${EIGEN3_INCLUDE_DIR}/signature_of_eigen3_matrix_library) | ||
file(REMOVE_RECURSE ${to_delete}) | ||
file(REMOVE_RECURSE ${tmp_dir}) | ||
|
||
message(STATUS "Downloaded Eigen3: ${EIGEN3_VERSION} ${EIGEN3_INCLUDE_DIR}") | ||
mark_as_advanced(EIGEN3_INCLUDE_DIR) | ||
endif() | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(MKLROOT_PATH $ENV{MKLROOT}) | ||
if(NOT MKLROOT_PATH) | ||
set(MKLROOT_PATH "/opt/intel/mkl") | ||
endif() | ||
|
||
find_path(MKL_INCLUDE_DIR mkl.h | ||
PATHS ${MKLROOT_PATH}/include ${MKLROOT_PATH}/mkl/include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# - Find the NumPy libraries | ||
# This module finds if NumPy is installed, and sets the following variables | ||
# indicating where it is. | ||
# | ||
# NUMPY_FOUND - was NumPy found | ||
# NUMPY_VERSION - the version of NumPy found as a string | ||
# NUMPY_VERSION_MAJOR - the major version number of NumPy | ||
# NUMPY_VERSION_MINOR - the minor version number of NumPy | ||
# NUMPY_VERSION_PATCH - the patch version number of NumPy | ||
# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 | ||
# NUMPY_INCLUDE_DIRS - path to the NumPy include files | ||
|
||
#============================================================================ | ||
# Copyright 2012 Continuum Analytics, Inc. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files | ||
# (the "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to permit | ||
# persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
# OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
#============================================================================ | ||
|
||
# Finding NumPy involves calling the Python interpreter | ||
if(NumPy_FIND_REQUIRED) | ||
find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) | ||
else() | ||
find_package(PythonInterp ${PYTHON_VERSION}) | ||
endif() | ||
|
||
if(NOT PYTHONINTERP_FOUND) | ||
set(NUMPY_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" | ||
"import numpy as n; print(n.__version__); print(n.get_include());" | ||
RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS | ||
OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT | ||
ERROR_VARIABLE _NUMPY_ERROR_VALUE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) | ||
if(NumPy_FIND_REQUIRED) | ||
message(FATAL_ERROR | ||
"NumPy import failure:\n${_NUMPY_ERROR_VALUE}") | ||
endif() | ||
set(NUMPY_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
# Convert the process output into a list | ||
string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES_OUTPUT}) | ||
string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) | ||
# Just in case there is unexpected output from the Python command. | ||
list(GET _NUMPY_VALUES -2 NUMPY_VERSION) | ||
list(GET _NUMPY_VALUES -1 NUMPY_INCLUDE_DIRS) | ||
|
||
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _VER_CHECK "${NUMPY_VERSION}") | ||
if("${_VER_CHECK}" STREQUAL "") | ||
# The output from Python was unexpected. Raise an error always | ||
# here, because we found NumPy, but it appears to be corrupted somehow. | ||
message(FATAL_ERROR | ||
"Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n") | ||
return() | ||
endif() | ||
|
||
# Make sure all directory separators are '/' | ||
string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) | ||
|
||
# Get the major and minor version numbers | ||
string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) | ||
list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) | ||
list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) | ||
list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) | ||
string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) | ||
math(EXPR NUMPY_VERSION_DECIMAL | ||
"(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") | ||
|
||
find_package_message(NUMPY | ||
"Found NumPy: ${NUMPY_VERSION} ${NUMPY_INCLUDE_DIRS}" | ||
"${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") | ||
|
||
set(NUMPY_FOUND TRUE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pybinding as pb | ||
from pybinding.repository import graphene | ||
|
||
# create a new model | ||
model = pb.Model( | ||
graphene.lattice.monolayer(), | ||
pb.shape.rectangle(x=50, y=50), # [nm] | ||
pb.magnetic.constant(60), # [T] | ||
pb.electric.constant(0.1), # [eV] | ||
pb.greens.KPM() | ||
) | ||
|
||
result = pb.result.ldos_point( | ||
model, | ||
energy=np.linspace(-0.5, 0.5, 1000), # [eV] | ||
broadening=0.03, # [eV] | ||
position=(0, 0) # (x, y) [nm] | ||
) | ||
|
||
result.plot() | ||
plt.show() |
Oops, something went wrong.