mirror of
https://github.com/triqs/dft_tools
synced 2024-10-14 20:11:48 +02:00
Merge tag '1.5'
Release 1.5
This commit is contained in:
commit
1bab92c721
45
.clang-format
Normal file
45
.clang-format
Normal file
@ -0,0 +1,45 @@
|
||||
BasedOnStyle: LLVM
|
||||
|
||||
AccessModifierOffset: 0
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 150
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 3
|
||||
ContinuationIndentWidth: 3
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerBinding : false
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 2
|
||||
Language: Cpp
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation : All
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
SpaceAfterControlStatementKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInParentheses: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 2
|
||||
UseTab: Never
|
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
.git
|
||||
Dockerfile
|
||||
Jenkinsfile
|
48
.travis.yml
Normal file
48
.travis.yml
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
language: cpp
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
# - clang
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main' -y
|
||||
- wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
|
||||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y --allow-unauthenticated g++-7 clang-5.0
|
||||
- export LIBRARY_PATH=/usr/lib/llvm-5.0/lib:$LIBRARY_PATH
|
||||
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
|
||||
- sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-5.0 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-5.0
|
||||
- sudo apt-get install -y --allow-unauthenticated libboost-all-dev cmake git libgfortran3 gfortran openmpi-bin openmpi-common openmpi-doc libopenmpi-dev libblas-dev liblapack-dev libfftw3-dev libgmp-dev hdf5-tools libhdf5-serial-dev python-h5py python-dev python-numpy python-scipy python-jinja2 python-virtualenv python-matplotlib python-tornado python-zmq python-mpi4py python-mako clang-format-5.0 libclang-5.0-dev python-clang-5.0 python-sphinx libjs-mathjax valgrind libnfft3-dev
|
||||
|
||||
install: true
|
||||
|
||||
script:
|
||||
# ===== Set up Cpp2Py
|
||||
- git clone https://github.com/triqs/cpp2py
|
||||
- mkdir cpp2py/build && cd cpp2py/build
|
||||
- git checkout master
|
||||
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DPYTHON_INTERPRETER=/usr/bin/python -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/root_install
|
||||
- make -j8 install
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- source root_install/share/cpp2pyvars.sh
|
||||
# ===== Set up TRIQS
|
||||
- git clone https://github.com/TRIQS/triqs --branch unstable
|
||||
- mkdir triqs/build && cd triqs/build
|
||||
- git checkout unstable
|
||||
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/root_install -DCMAKE_BUILD_TYPE=Debug
|
||||
- make -j8 install
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
- source root_install/share/triqsvars.sh
|
||||
# ===== Set up dft_tools and Test using fsanitize=address
|
||||
- mkdir build && cd build
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DCMAKE_CXX_FLAGS='-fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold'
|
||||
- make -j8
|
||||
- export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer
|
||||
- export ASAN_OPTIONS=symbolize=1:detect_leaks=0
|
||||
- export CTEST_OUTPUT_ON_FAILURE=1
|
||||
- if [ "$CXX" = g++ ]; then export LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so; elif [ "$CXX" = clang++ ]; then export LD_PRELOAD=/usr/lib/llvm-5.0/lib/clang/5.0.1/lib/linux/libclang_rt.asan-x86_64.so; fi
|
||||
- cd test && ctest
|
@ -1,50 +1,83 @@
|
||||
# Version number of the application
|
||||
set (DFT_TOOLS_VERSION "1.4")
|
||||
set (DFT_TOOLS_RELEASE "1.4.0")
|
||||
set (DFT_TOOLS_VERSION "1.5")
|
||||
set (DFT_TOOLS_RELEASE "1.5.0")
|
||||
|
||||
# Append triqs installed files to the cmake load path
|
||||
list(APPEND CMAKE_MODULE_PATH ${TRIQS_PATH}/share/triqs/cmake)
|
||||
|
||||
# start configuration
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(dft_tools CXX Fortran)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
enable_testing()
|
||||
|
||||
# Load TRIQS, including all predefined variables from TRIQS installation
|
||||
find_package(TRIQS REQUIRED)
|
||||
|
||||
# Check that versions are compatible
|
||||
if(NOT DFT_TOOLS_VERSION EQUAL TRIQS_VERSION)
|
||||
message(FATAL_ERROR "The application version is not compatible with the TRIQS library (TRIQS library version: ${TRIQS_VERSION} while this application version: ${DFT_TOOLS_VERSION})")
|
||||
# Default to Release build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE)
|
||||
endif()
|
||||
message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} -------------")
|
||||
|
||||
# start configuration
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(dft_tools C CXX Fortran)
|
||||
|
||||
# Use shared libraries
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
|
||||
# Load TRIQS and Cpp2Py
|
||||
find_package(TRIQS 1.5 EXACT REQUIRED)
|
||||
find_package(Cpp2Py REQUIRED)
|
||||
|
||||
if (NOT ${TRIQS_WITH_PYTHON_SUPPORT})
|
||||
MESSAGE(FATAL_ERROR "dft_tools require Python support in TRIQS")
|
||||
endif()
|
||||
|
||||
# Get hash
|
||||
triqs_get_git_hash(${CMAKE_SOURCE_DIR} "DFT_TOOLS")
|
||||
if(${GIT_RESULT} EQUAL 0)
|
||||
message(STATUS "Hash: ${DFT_TOOLS_GIT_HASH}")
|
||||
endif(${GIT_RESULT} EQUAL 0)
|
||||
# Default Install directory to TRIQS_ROOT if not given. Checks an absolute name is given.
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
|
||||
message(STATUS " No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
|
||||
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
||||
endif()
|
||||
message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} -------------")
|
||||
|
||||
# We want to be installed in the TRIQS tree
|
||||
set(CMAKE_INSTALL_PREFIX ${TRIQS_PATH})
|
||||
# Macro defined in TRIQS which picks the hash of repo.
|
||||
triqs_get_git_hash_of_source_dir(DFT_TOOLS_GIT_HASH)
|
||||
message(STATUS "Git hash: ${DFT_TOOLS_GIT_HASH}")
|
||||
|
||||
add_subdirectory(fortran/dmftproj)
|
||||
|
||||
# Add the compiling options (-D... ) for C++
|
||||
message(STATUS "TRIQS : Adding compilation flags detected by the library (C++11/14, libc++, etc...) ")
|
||||
add_definitions(${TRIQS_CXX_DEFINITIONS})
|
||||
|
||||
add_subdirectory(c++)
|
||||
add_subdirectory(python)
|
||||
add_subdirectory(shells)
|
||||
add_subdirectory(test)
|
||||
option(BUILD_DOC "Build documentation" OFF)
|
||||
if(${BUILD_DOC})
|
||||
if(NOT TRIQS_WITH_DOCUMENTATION)
|
||||
|
||||
#------------------------
|
||||
# tests
|
||||
#------------------------
|
||||
|
||||
enable_testing()
|
||||
|
||||
option(Build_Tests "Build the tests of the library " ON)
|
||||
if (Build_Tests)
|
||||
message(STATUS "-------- Preparing tests -------------")
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
#------------------------
|
||||
# Documentation
|
||||
#------------------------
|
||||
option(Build_Documentation "Build documentation" OFF)
|
||||
if(${Build_Documentation})
|
||||
if(NOT ${TRIQS_WITH_DOCUMENTATION})
|
||||
message("Error: TRIQS library has not been compiled with its documentation")
|
||||
endif()
|
||||
add_subdirectory(doc)
|
||||
endif(${BUILD_DOC})
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Packaging
|
||||
#--------------------------------------------------------
|
||||
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
|
||||
if(BUILD_DEBIAN_PACKAGE)
|
||||
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
||||
message(FATAL_ERROR "CMAKE_INSTALL_PREFIX must be /usr for packaging")
|
||||
endif()
|
||||
SET(CPACK_GENERATOR "DEB")
|
||||
SET(CPACK_PACKAGE_VERSION ${DFT_TOOLS_VERSION})
|
||||
SET(CPACK_PACKAGE_CONTACT "https://github.com/TRIQS/dft_tools")
|
||||
EXECUTE_PROCESS(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CMAKE_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.23), libgcc1 (>= 1:6), libstdc++6, python, libpython2.7, libopenmpi1.10, libhdf5-10, libgmp10, libfftw3-double3, libibverbs1, libgfortran3, zlib1g, libsz2, libhwloc5, libquadmath0, libaec0, libnuma1, libltdl7, libblas3, liblapack3, python-numpy, python-h5py, python-jinja2, python-mako, python-mpi4py, python-matplotlib, python-scipy, cpp2py (= ${DFT_TOOLS_VERSION}), triqs (= ${DFT_TOOLS_VERSION})")
|
||||
INCLUDE(CPack)
|
||||
endif()
|
||||
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
# See ../triqs/packaging for other options
|
||||
FROM flatironinstitute/triqs:master-ubuntu-clang
|
||||
|
||||
ARG APPNAME=dft_tools
|
||||
COPY . $SRC/$APPNAME
|
||||
WORKDIR $BUILD/$APPNAME
|
||||
RUN chown build .
|
||||
USER build
|
||||
ARG BUILD_DOC=0
|
||||
RUN cmake $SRC/$APPNAME -DTRIQS_ROOT=${INSTALL} -DBuild_Documentation=${BUILD_DOC} && make -j2 && make test
|
||||
USER root
|
||||
RUN make install
|
140
Jenkinsfile
vendored
Normal file
140
Jenkinsfile
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
def projectName = "dft_tools"
|
||||
def documentationPlatform = "ubuntu-clang"
|
||||
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
|
||||
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
|
||||
def publish = !env.BRANCH_NAME.startsWith("PR-")
|
||||
|
||||
properties([
|
||||
disableConcurrentBuilds(),
|
||||
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
|
||||
pipelineTriggers([
|
||||
upstream(
|
||||
threshold: 'SUCCESS',
|
||||
upstreamProjects: triqsProject
|
||||
)
|
||||
])
|
||||
])
|
||||
|
||||
/* map of all builds to run, populated below */
|
||||
def platforms = [:]
|
||||
|
||||
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
|
||||
/* .each is currently broken in jenkins */
|
||||
for (int i = 0; i < dockerPlatforms.size(); i++) {
|
||||
def platform = dockerPlatforms[i]
|
||||
platforms[platform] = { -> node('docker') {
|
||||
stage(platform) { timeout(time: 1, unit: 'HOURS') {
|
||||
checkout scm
|
||||
/* construct a Dockerfile for this base */
|
||||
sh """
|
||||
( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins
|
||||
mv -f Dockerfile.jenkins Dockerfile
|
||||
"""
|
||||
/* build and tag */
|
||||
def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg BUILD_DOC=${platform==documentationPlatform} .")
|
||||
if (!publish || platform != documentationPlatform) {
|
||||
/* but we don't need the tag so clean it up (except for documentation) */
|
||||
sh "docker rmi --no-prune ${img.imageName()}"
|
||||
}
|
||||
} }
|
||||
} }
|
||||
}
|
||||
|
||||
def osxPlatforms = [
|
||||
["gcc", ['CC=gcc-7', 'CXX=g++-7']],
|
||||
["clang", ['CC=/usr/local/opt/llvm/bin/clang', 'CXX=/usr/local/opt/llvm/bin/clang++', 'CXXFLAGS=-I/usr/local/opt/llvm/include', 'LDFLAGS=-L/usr/local/opt/llvm/lib']]
|
||||
]
|
||||
for (int i = 0; i < osxPlatforms.size(); i++) {
|
||||
def platformEnv = osxPlatforms[i]
|
||||
def platform = platformEnv[0]
|
||||
platforms["osx-$platform"] = { -> node('osx && triqs') {
|
||||
stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') {
|
||||
def srcDir = pwd()
|
||||
def tmpDir = pwd(tmp:true)
|
||||
def buildDir = "$tmpDir/build"
|
||||
def installDir = "$tmpDir/install"
|
||||
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
|
||||
dir(installDir) {
|
||||
deleteDir()
|
||||
}
|
||||
|
||||
checkout scm
|
||||
dir(buildDir) { withEnv(platformEnv[1]+[
|
||||
"PATH=$triqsDir/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin",
|
||||
"CPATH=$triqsDir/include",
|
||||
"LIBRARY_PATH=$triqsDir/lib",
|
||||
"CMAKE_PREFIX_PATH=$triqsDir/share/cmake"]) {
|
||||
deleteDir()
|
||||
sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir"
|
||||
sh "make -j3"
|
||||
try {
|
||||
sh "make test"
|
||||
} catch (exc) {
|
||||
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
|
||||
throw exc
|
||||
}
|
||||
sh "make install"
|
||||
} }
|
||||
} }
|
||||
} }
|
||||
}
|
||||
|
||||
try {
|
||||
parallel platforms
|
||||
if (publish) { node("docker") {
|
||||
stage("publish") { timeout(time: 1, unit: 'HOURS') {
|
||||
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
||||
def workDir = pwd()
|
||||
dir("$workDir/gh-pages") {
|
||||
def subdir = env.BRANCH_NAME
|
||||
git(url: "ssh://git@github.com/TRIQS/${projectName}.git", branch: "gh-pages", credentialsId: "ssh", changelog: false)
|
||||
sh "rm -rf ${subdir}"
|
||||
docker.image("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() {
|
||||
sh "cp -rp \$INSTALL/share/doc/${projectName} ${subdir}"
|
||||
}
|
||||
sh "git add -A ${subdir}"
|
||||
sh """
|
||||
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Generated documentation for ${env.BRANCH_NAME}' -m '${env.BUILD_TAG} ${commit}'
|
||||
"""
|
||||
// note: credentials used above don't work (need JENKINS-28335)
|
||||
sh "git push origin gh-pages"
|
||||
}
|
||||
dir("$workDir/docker") { try {
|
||||
git(url: "ssh://git@github.com/TRIQS/docker.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false)
|
||||
sh "echo '160000 commit ${commit}\t${projectName}' | git update-index --index-info"
|
||||
sh """
|
||||
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
|
||||
"""
|
||||
// note: credentials used above don't work (need JENKINS-28335)
|
||||
sh "git push origin ${env.BRANCH_NAME}"
|
||||
} catch (err) {
|
||||
echo "Failed to update docker repo"
|
||||
} }
|
||||
} }
|
||||
} }
|
||||
} catch (err) {
|
||||
if (env.BRANCH_NAME != "jenkins") emailext(
|
||||
subject: "\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED",
|
||||
body: """\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED
|
||||
|
||||
$err
|
||||
|
||||
Check console output at \$BUILD_URL to view full results.
|
||||
|
||||
Building \$BRANCH_NAME for \$CAUSE
|
||||
\$JOB_DESCRIPTION
|
||||
|
||||
Chages:
|
||||
\$CHANGES
|
||||
|
||||
End of build log:
|
||||
\${BUILD_LOG,maxLines=60}
|
||||
""",
|
||||
to: 'mzingl@flatironinstitute.org, hstrand@flatironinstitute.org, nils.wentzell@gmail.com, dsimon@flatironinstitute.org',
|
||||
recipientProviders: [
|
||||
[$class: 'DevelopersRecipientProvider'],
|
||||
],
|
||||
replyTo: '$DEFAULT_REPLYTO'
|
||||
)
|
||||
throw err
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
# Linking and include info
|
||||
add_library(atm_c dos_tetra3d.hpp dos_tetra3d.cpp argsort.hpp argsort.cpp)
|
||||
set_target_properties(atm_c PROPERTIES LINKER_LANGUAGE CXX)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/c++/plovasp/atm ${TRIQS_INCLUDE_ALL})
|
||||
target_link_libraries(atm_c triqs)
|
||||
target_compile_options(atm_c PRIVATE -std=c++17)
|
||||
|
||||
install(TARGETS atm_c DESTINATION lib)
|
||||
|
||||
|
@ -1,24 +1,13 @@
|
||||
find_package(TriqsTest)
|
||||
enable_testing()
|
||||
|
||||
# Linking and include info
|
||||
#add_library(atm_c dos_tetra3d.hpp dos_tetra3d.cpp argsort.h argsort.c)
|
||||
#set_target_properties(atm_c PROPERTIES LINKER_LANGUAGE CXX)
|
||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/c++/plovasp/atm ${TRIQS_INCLUDE_ALL})
|
||||
|
||||
FILE(GLOB TestList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
FOREACH( TestName1 ${TestList} )
|
||||
STRING(REPLACE ".cpp" "" TestName ${TestName1})
|
||||
add_executable( ${TestName} ${CMAKE_CURRENT_SOURCE_DIR}/${TestName}.cpp )
|
||||
target_link_libraries( ${TestName} atm_c ${TRIQS_LIBRARY_ALL} )
|
||||
add_executable( ${TestName} ${TestName}.cpp )
|
||||
target_link_libraries( ${TestName} atm_c triqs)
|
||||
triqs_set_rpath_for_target( ${TestName} )
|
||||
triqs_add_cpp_test( ${TestName} )
|
||||
if (TESTS_C_WITH_VALGRIND)
|
||||
add_test ( ${TestName}_valgrind valgrind --error-exitcode=1 ${CMAKE_CURRENT_BINARY_DIR}/${TestName})
|
||||
endif()
|
||||
add_test(NAME ${TestName} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${t})
|
||||
ENDFOREACH( TestName1 ${TestList} )
|
||||
|
||||
#add_executable(test_atm test2py.cpp)
|
||||
#target_link_libraries(test_atm atm_c)
|
||||
|
||||
#add_subdirectory(test)
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import pytriqs.utility.mpi as mpi
|
||||
from pytriqs.operators.util import *
|
||||
from pytriqs.archive import HDFArchive
|
||||
from pytriqs.applications.impurity_solvers.cthyb import *
|
||||
from pytriqs.gf.local import *
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from triqs_cthyb import *
|
||||
from pytriqs.gf import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
|
||||
dft_filename='Gd_fcc'
|
||||
U = 9.6
|
||||
@ -52,7 +52,7 @@ spin_names = ["up","down"]
|
||||
orb_names = [i for i in range(n_orb)]
|
||||
|
||||
# Use GF structure determined by DFT blocks
|
||||
gf_struct = SK.gf_struct_solver[0]
|
||||
gf_struct = [(block, indices) for block, indices in SK.gf_struct_solver[0].iteritems()]
|
||||
# Construct U matrix for density-density calculations
|
||||
Umat, Upmat = U_matrix_kanamori(n_orb=n_orb, U_int=U, J_hund=J)
|
||||
# Construct Hamiltonian and solver
|
||||
|
@ -1,29 +1,23 @@
|
||||
# generate the conf.py
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
|
||||
|
||||
# all rst files of the documentation
|
||||
file(GLOB_RECURSE doc_sources *.rst)
|
||||
# ---------------------------------
|
||||
# Top Sphinx target
|
||||
# ---------------------------------
|
||||
# Sources
|
||||
file(GLOB_RECURSE sources *.rst)
|
||||
|
||||
# create documentation target
|
||||
set(sphinx_top ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
|
||||
add_custom_command(OUTPUT ${sphinx_top} DEPENDS ${doc_sources} py_copy
|
||||
COMMAND ${CMAKE_BINARY_DIR}/build_pytriqs ${TRIQS_SPHINXBUILD_EXECUTABLE} -c . -b html ${CMAKE_CURRENT_SOURCE_DIR} html)
|
||||
add_custom_target(doc_sphinx ALL DEPENDS ${sphinx_top})
|
||||
add_custom_command(OUTPUT ${sphinx_top} DEPENDS ${sources}
|
||||
COMMAND ${TRIQS_SPHINXBUILD_EXECUTABLE} -c . -j8 -b html ${CMAKE_CURRENT_SOURCE_DIR} html)
|
||||
add_custom_target(doc_sphinx ALL DEPENDS ${sphinx_top} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# install
|
||||
# ---------------------------------
|
||||
# Install
|
||||
# ---------------------------------
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DESTINATION share/doc/dft_tools
|
||||
FILES_MATCHING
|
||||
PATTERN "*.html"
|
||||
PATTERN "*.png"
|
||||
PATTERN "*.js"
|
||||
FILES_MATCHING
|
||||
REGEX "\\.(html|pdf|png|gif|jpg|js|xsl|css|py|txt|inv|bib)$"
|
||||
PATTERN "_*"
|
||||
PATTERN "*.jpg"
|
||||
PATTERN "*.gif"
|
||||
PATTERN "*.xsl"
|
||||
PATTERN "*.css"
|
||||
PATTERN "*.pdf"
|
||||
PATTERN "*.py"
|
||||
PATTERN "*.txt"
|
||||
PATTERN "*.inv"
|
||||
PATTERN "*.bib"
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
.. module:: pytriqs.applications.dft
|
||||
.. module:: triqs_dft_tools
|
||||
|
||||
.. _documentation:
|
||||
|
||||
|
@ -23,11 +23,11 @@ Loading modules
|
||||
|
||||
First, we load the necessary modules::
|
||||
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from pytriqs.gf.local import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
from pytriqs.gf import *
|
||||
from pytriqs.archive import HDFArchive
|
||||
from pytriqs.operators.util import *
|
||||
from pytriqs.applications.impurity_solvers.cthyb import *
|
||||
from triqs_cthyb import *
|
||||
|
||||
The last two lines load the modules for the construction of the
|
||||
:ref:`CTHYB solver <triqscthyb:welcome>`.
|
||||
@ -56,7 +56,7 @@ Initializing the solver
|
||||
-----------------------
|
||||
|
||||
We also have to specify the :ref:`CTHYB solver <triqscthyb:welcome>` related settings.
|
||||
We assume that the DMFT script for SrVO3 is executed on 16 cores. A sufficient set
|
||||
We assume that the DMFT script for SrVO3 is executed on 16 cores. A sufficient set
|
||||
of parameters for a first guess is::
|
||||
|
||||
p = {}
|
||||
@ -80,7 +80,7 @@ each material individually. A guide on how to set the tail fit parameters is giv
|
||||
|
||||
|
||||
The next step is to initialize the
|
||||
:class:`solver class <pytriqs.applications.impurity_solvers.cthyb.Solver>`.
|
||||
:class:`solver class <triqs_cthyb.Solver>`.
|
||||
It consist of two parts:
|
||||
|
||||
#. Calculating the multi-band interaction matrix, and constructing the
|
||||
@ -94,7 +94,7 @@ The first step is done using methods of the :ref:`TRIQS <triqslibs:welcome>` lib
|
||||
spin_names = ["up","down"]
|
||||
orb_names = [i for i in range(n_orb)]
|
||||
# Use GF structure determined by DFT blocks:
|
||||
gf_struct = SK.gf_struct_solver[0]
|
||||
gf_struct = [(block, indices) for block, indices in SK.gf_struct_solver[0].iteritems()]
|
||||
# Construct U matrix for density-density calculations:
|
||||
Umat, Upmat = U_matrix_kanamori(n_orb=n_orb, U_int=U, J_hund=J)
|
||||
|
||||
@ -102,7 +102,7 @@ We assumed here that we want to use an interaction matrix with
|
||||
Kanamori definitions of :math:`U` and :math:`J`.
|
||||
|
||||
Next, we construct the Hamiltonian and the solver::
|
||||
|
||||
|
||||
h_int = h_int_density(spin_names, orb_names, map_operator_structure=SK.sumk_to_solver[0], U=Umat, Uprime=Upmat)
|
||||
S = Solver(beta=beta, gf_struct=gf_struct)
|
||||
|
||||
@ -125,7 +125,7 @@ some additional refinements::
|
||||
|
||||
for iteration_number in range(1,loops+1):
|
||||
if mpi.is_master_node(): print "Iteration = ", iteration_number
|
||||
|
||||
|
||||
SK.symm_deg_gf(S.Sigma_iw,orb=0) # symmetrizing Sigma
|
||||
SK.set_Sigma([ S.Sigma_iw ]) # put Sigma into the SumK class
|
||||
chemical_potential = SK.calc_mu( precision = prec_mu ) # find the chemical potential for given density
|
||||
@ -137,17 +137,17 @@ some additional refinements::
|
||||
dm = S.G_iw.density()
|
||||
SK.calc_dc(dm, U_interact = U, J_hund = J, orb = 0, use_dc_formula = dc_type)
|
||||
S.Sigma_iw << SK.dc_imp[0]['up'][0,0]
|
||||
|
||||
|
||||
# Calculate new G0_iw to input into the solver:
|
||||
S.G0_iw << S.Sigma_iw + inverse(S.G_iw)
|
||||
S.G0_iw << inverse(S.G0_iw)
|
||||
|
||||
# Solve the impurity problem:
|
||||
S.solve(h_int=h_int, **p)
|
||||
|
||||
|
||||
# Solved. Now do post-solution stuff:
|
||||
mpi.report("Total charge of impurity problem : %.6f"%S.G_iw.total_density())
|
||||
|
||||
|
||||
# Now mix Sigma and G with factor mix, if wanted:
|
||||
if (iteration_number>1 or previous_present):
|
||||
if mpi.is_master_node():
|
||||
@ -158,7 +158,7 @@ some additional refinements::
|
||||
del ar
|
||||
S.G_iw << mpi.bcast(S.G_iw)
|
||||
S.Sigma_iw << mpi.bcast(S.Sigma_iw)
|
||||
|
||||
|
||||
# Write the final Sigma and G to the hdf5 archive:
|
||||
if mpi.is_master_node():
|
||||
ar = HDFArchive(dft_filename+'.h5','a')
|
||||
@ -188,8 +188,8 @@ to start with a lower statistics (less measurements), but then increase it at a
|
||||
point close to converged results (e.g. after a few initial iterations). This helps
|
||||
to keep computational costs low during the first iterations.
|
||||
|
||||
Using the Kanamori Hamiltonian and the parameters above (but on 16 cores),
|
||||
your self energy after the **first iteration** should look like the
|
||||
Using the Kanamori Hamiltonian and the parameters above (but on 16 cores),
|
||||
your self energy after the **first iteration** should look like the
|
||||
self energy shown below.
|
||||
|
||||
.. image:: images_scripts/SrVO3_Sigma_iw_it1.png
|
||||
@ -208,12 +208,12 @@ Therefore disabled the tail fitting first::
|
||||
p["perform_tail_fit"] = False
|
||||
|
||||
and perform only one DMFT iteration. The resulting self energy can be tail fitted by hand::
|
||||
|
||||
|
||||
Sigma_iw_fit = S.Sigma_iw.copy()
|
||||
Sigma_iw_fit << tail_fit(S.Sigma_iw, fit_max_moment = 4, fit_min_n = 40, fit_max_n = 160)[0]
|
||||
|
||||
Plot the self energy and adjust the tail fit parameters such that you obtain a
|
||||
proper fit. The :meth:`tail_fit function <pytriqs.gf.local.tools.tail_fit>` is part
|
||||
proper fit. The :meth:`fit_tail function <pytriqs.gf.tools.tail_fit>` is part
|
||||
of the :ref:`TRIQS <triqslibs:welcome>` library.
|
||||
|
||||
For a self energy which is going to zero for :math:`i\omega \rightarrow 0` our suggestion is
|
||||
|
@ -27,7 +27,7 @@ Initialisation
|
||||
All tools described below are collected in an extension of the :class:`SumkDFT <dft.sumk_dft.SumkDFT>` class and are
|
||||
loaded by importing the module :class:`SumkDFTTools <dft.sumk_dft_tools.SumkDFTTools>`::
|
||||
|
||||
from pytriqs.applications.dft.sumk_dft_tools import *
|
||||
from triqs_dft_tools.sumk_dft_tools import *
|
||||
|
||||
The initialisation of the class is equivalent to that of the :class:`SumkDFT <dft.sumk_dft.SumkDFT>`
|
||||
class::
|
||||
@ -37,7 +37,7 @@ class::
|
||||
Note that all routines available in :class:`SumkDFT <dft.sumk_dft.SumkDFT>` are also available here.
|
||||
|
||||
If required, we have to load and initialise the real frequency self energy. Most conveniently,
|
||||
you have your self energy already stored as a real frequency :class:`BlockGf <pytriqs.gf.local.BlockGf>` object
|
||||
you have your self energy already stored as a real frequency :class:`BlockGf <pytriqs.gf.BlockGf>` object
|
||||
in a hdf5 file::
|
||||
|
||||
ar = HDFArchive('case.h5', 'a')
|
||||
@ -45,10 +45,10 @@ in a hdf5 file::
|
||||
|
||||
You may also have your self energy stored in text files. For this case the :ref:`TRIQS <triqslibs:welcome>` library offers
|
||||
the function :meth:`read_gf_from_txt`, which is able to load the data from text files of one Greens function block
|
||||
into a real frequency :class:`ReFreqGf <pytriqs.gf.local.ReFreqGf>` object. Loading each block separately and
|
||||
building up a :class:´BlockGf <pytriqs.gf.local.BlockGf>´ is done with::
|
||||
into a real frequency :class:`ReFreqGf <pytriqs.gf.ReFreqGf>` object. Loading each block separately and
|
||||
building up a :class:´BlockGf <pytriqs.gf.BlockGf>´ is done with::
|
||||
|
||||
from pytriqs.gf.local.tools import *
|
||||
from pytriqs.gf.tools import *
|
||||
# get block names
|
||||
n_list = [n for n,nl in SK.gf_struct_solver[0].iteritems()]
|
||||
# load sigma for each block - in this example sigma is composed of 1x1 blocks
|
||||
|
@ -107,7 +107,7 @@ Now we convert these files into an hdf5 file that can be used for the
|
||||
DMFT calculations. For this purpose we
|
||||
use the python module :class:`Wien2kConverter <dft.converters.wien2k_converter.Wien2kConverter>`. It is initialized as::
|
||||
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
Converter = Wien2kConverter(filename = case)
|
||||
|
||||
The only necessary parameter to this construction is the parameter `filename`.
|
||||
@ -338,7 +338,7 @@ matrix of the imaginary part, and then move on to the next :math:`\mathbf{k}`-po
|
||||
|
||||
The converter itself is used as::
|
||||
|
||||
from pytriqs.applications.dft.converters.hk_converter import *
|
||||
from triqs_dft_tools.converters.hk_converter import *
|
||||
Converter = HkConverter(filename = hkinputfile)
|
||||
Converter.convert_dft_input()
|
||||
|
||||
@ -372,7 +372,7 @@ as a placeholder for the actual prefix chosen by the user when creating the
|
||||
input for :program:`wannier90`.
|
||||
Once these two files are available, one can use the converter as follows::
|
||||
|
||||
from pytriqs.applications.dft.converters import Wannier90Converter
|
||||
from triqs_dft_tools.converters import Wannier90Converter
|
||||
Converter = Wannier90Converter(seedname='seedname')
|
||||
Converter.convert_dft_input()
|
||||
|
||||
|
@ -22,7 +22,7 @@ The first thing is the :class:`SumkDFT <dft.sumk_dft.SumkDFT>` class.
|
||||
It contains all basic routines that are necessary to perform a summation in k-space
|
||||
to get the local quantities used in DMFT. It is initialized by::
|
||||
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
SK = SumkDFT(hdf_file = filename + '.h5')
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
from pytriqs.applications.impurity_solvers.hubbard_I.hubbard_solver import Solver
|
||||
|
||||
import os
|
||||
|
@ -1,5 +1,5 @@
|
||||
from pytriqs.applications.dft.sumk_dft_tools import *
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from triqs_dft_tools.sumk_dft_tools import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
from pytriqs.applications.impurity_solvers.hubbard_I.hubbard_solver import Solver
|
||||
|
||||
# Creates the data directory, cd into it:
|
||||
|
@ -1,9 +1,9 @@
|
||||
import pytriqs.utility.mpi as mpi
|
||||
from pytriqs.operators.util import *
|
||||
from pytriqs.archive import HDFArchive
|
||||
from pytriqs.applications.impurity_solvers.cthyb import *
|
||||
from pytriqs.gf.local import *
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from triqs_cthyb import *
|
||||
from pytriqs.gf import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
|
||||
dft_filename='SrVO3'
|
||||
U = 4.0
|
||||
@ -30,7 +30,7 @@ p["fit_min_n"] = 30
|
||||
p["fit_max_n"] = 60
|
||||
|
||||
# If conversion step was not done, we could do it here. Uncomment the lines it you want to do this.
|
||||
#from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
#from triqs_dft_tools.converters.wien2k_converter import *
|
||||
#Converter = Wien2kConverter(filename=dft_filename, repacking=True)
|
||||
#Converter.convert_dft_input()
|
||||
#mpi.barrier()
|
||||
@ -58,7 +58,7 @@ spin_names = ["up","down"]
|
||||
orb_names = [i for i in range(n_orb)]
|
||||
|
||||
# Use GF structure determined by DFT blocks
|
||||
gf_struct = SK.gf_struct_solver[0]
|
||||
gf_struct = [(block, indices) for block, indices in SK.gf_struct_solver[0].iteritems()]
|
||||
|
||||
# Construct U matrix for density-density calculations
|
||||
Umat, Upmat = U_matrix_kanamori(n_orb=n_orb, U_int=U, J_hund=J)
|
||||
|
@ -1,10 +1,10 @@
|
||||
import pytriqs.utility.mpi as mpi
|
||||
from pytriqs.operators.util import *
|
||||
from pytriqs.archive import HDFArchive
|
||||
from pytriqs.applications.impurity_solvers.cthyb import *
|
||||
from pytriqs.gf.local import *
|
||||
from pytriqs.applications.dft.sumk_dft import *
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from triqs_cthyb import *
|
||||
from pytriqs.gf import *
|
||||
from triqs_dft_tools.sumk_dft import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
|
||||
dft_filename='SrVO3'
|
||||
U = 9.6
|
||||
@ -31,7 +31,7 @@ p["fit_min_n"] = 30
|
||||
p["fit_max_n"] = 60
|
||||
|
||||
# If conversion step was not done, we could do it here. Uncomment the lines it you want to do this.
|
||||
#from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
#from triqs_dft_tools.converters.wien2k_converter import *
|
||||
#Converter = Wien2kConverter(filename=dft_filename, repacking=True)
|
||||
#Converter.convert_dft_input()
|
||||
#mpi.barrier()
|
||||
@ -59,7 +59,7 @@ spin_names = ["up","down"]
|
||||
orb_names = [i for i in range(n_orb)]
|
||||
|
||||
# Use GF structure determined by DFT blocks
|
||||
gf_struct = SK.gf_struct_solver[0]
|
||||
gf_struct = [(block, indices) for block, indices in SK.gf_struct_solver[0].iteritems()]
|
||||
|
||||
# Construct Slater U matrix
|
||||
Umat = U_matrix(n_orb=n_orb, U_int=U, J_hund=J, basis='cubic',)
|
||||
|
@ -84,8 +84,8 @@ Using the transport code
|
||||
|
||||
First we have to read the Wien2k files and store the relevant information in the hdf5 archive::
|
||||
|
||||
from pytriqs.applications.dft.converters.wien2k_converter import *
|
||||
from pytriqs.applications.dft.sumk_dft_tools import *
|
||||
from triqs_dft_tools.converters.wien2k_converter import *
|
||||
from triqs_dft_tools.sumk_dft_tools import *
|
||||
|
||||
Converter = Wien2kConverter(filename='case', repacking=True)
|
||||
Converter.convert_transport_input()
|
||||
|
@ -1,6 +1,6 @@
|
||||
.. index:: DFTTools
|
||||
|
||||
.. module:: pytriqs.applications.dft
|
||||
.. module:: triqs_dft_tools
|
||||
|
||||
.. _dft:
|
||||
|
||||
|
@ -83,7 +83,7 @@ Finally, you will have to change the calls to :program:`python_with_DMFT` to
|
||||
|
||||
|
||||
Version compatibility
|
||||
---------------------
|
||||
---------------------
|
||||
|
||||
Be careful that the version of the TRIQS library and of the dft tools must be
|
||||
compatible (more information on the :ref:`TRIQS website <triqslibs:welcome>`.
|
||||
@ -97,3 +97,18 @@ Checkout the version of the code that you want, for instance::
|
||||
$ git co 1.2
|
||||
|
||||
Then follow the steps 2 to 5 described above to compile the code.
|
||||
|
||||
Custom CMake options
|
||||
--------------------
|
||||
|
||||
Functionality of ``dft_tools`` can be tweaked using extra compile-time options passed to CMake::
|
||||
|
||||
cmake -DOPTION1=value1 -DOPTION2=value2 ... ../cthyb.src
|
||||
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
| Options | Syntax |
|
||||
+===============================================================+===============================================+
|
||||
| Disable testing (not recommended) | -DBuild_Tests=OFF |
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
| Build the documentation locally | -DBuild_Documentation=ON |
|
||||
+---------------------------------------------------------------+-----------------------------------------------+
|
||||
|
@ -6,7 +6,8 @@ set(SOURCES modules.f dmftproj.f readcomline.f set_ang_trans.f setsym.f
|
||||
|
||||
# The main target and what to link with...
|
||||
add_executable(dmftproj ${SOURCES})
|
||||
target_link_libraries(dmftproj ${TRIQS_LIBRARY_LAPACK})
|
||||
find_package(LAPACK)
|
||||
target_link_libraries(dmftproj ${LAPACK_LIBRARIES})
|
||||
|
||||
# where to install
|
||||
install (TARGETS dmftproj DESTINATION bin)
|
||||
|
@ -1,16 +1,19 @@
|
||||
# where will the python end up in triqs?
|
||||
set(python_destination pytriqs/applications/dft)
|
||||
set(PYTHON_LIB_DEST ${CPP2PY_PYTHON_LIB_DEST_ROOT}/triqs_dft_tools)
|
||||
|
||||
# site_customize for build
|
||||
set(package_name "pytriqs.applications")
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/sitecustomize.py ${CMAKE_CURRENT_BINARY_DIR}/sitecustomize.py @ONLY)
|
||||
set(package_name "triqs_dft_tools")
|
||||
|
||||
# make a local pytriqs copy
|
||||
triqs_prepare_local_pytriqs(${python_destination})
|
||||
|
||||
# VASP converter
|
||||
add_subdirectory(converters/plovasp)
|
||||
# Create a temporary copy of the python modules so that we can run before installation with the test
|
||||
FILE(GLOB PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py )
|
||||
foreach(f ${PYTHON_SOURCES})
|
||||
configure_file(${f} ${f} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
# add version file
|
||||
configure_file(version.py.in version.py)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${python_destination})
|
||||
configure_file(version.py.in version.py @ONLY)
|
||||
|
||||
# install files
|
||||
install(FILES ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${PYTHON_LIB_DEST})
|
||||
|
||||
add_subdirectory(converters)
|
||||
|
@ -1,13 +1,14 @@
|
||||
import copy
|
||||
import numpy as np
|
||||
from pytriqs.gf.local import GfImFreq, BlockGf
|
||||
from pytriqs.gf import GfImFreq, BlockGf
|
||||
from ast import literal_eval
|
||||
import pytriqs.utility.mpi as mpi
|
||||
from warnings import warn
|
||||
|
||||
class BlockStructure(object):
|
||||
""" Contains information about the Green function structure.
|
||||
|
||||
This class contains information about the structure of the solver
|
||||
This class contains information about the structure of the solver
|
||||
and sumk Green functions and the mapping between them.
|
||||
|
||||
Parameters
|
||||
@ -33,19 +34,21 @@ class BlockStructure(object):
|
||||
solver_to_sumk_block : list of dict
|
||||
solver_to_sumk_block[ish][from_block] = to_block
|
||||
|
||||
maps from the solver block to the sumk block
|
||||
maps from the solver block to the sumk block
|
||||
for *inequivalent* correlated shell ish
|
||||
"""
|
||||
def __init__(self,gf_struct_sumk=None,
|
||||
gf_struct_solver=None,
|
||||
solver_to_sumk=None,
|
||||
sumk_to_solver=None,
|
||||
solver_to_sumk_block=None):
|
||||
solver_to_sumk_block=None,
|
||||
deg_shells=None):
|
||||
self.gf_struct_sumk = gf_struct_sumk
|
||||
self.gf_struct_solver = gf_struct_solver
|
||||
self.solver_to_sumk = solver_to_sumk
|
||||
self.sumk_to_solver = sumk_to_solver
|
||||
self.solver_to_sumk_block = solver_to_sumk_block
|
||||
self.deg_shells = deg_shells
|
||||
|
||||
@classmethod
|
||||
def full_structure(cls,gf_struct,corr_to_inequiv):
|
||||
@ -99,20 +102,21 @@ class BlockStructure(object):
|
||||
gf_struct_sumk = gs_sumk_all,
|
||||
solver_to_sumk = copy.deepcopy(solver_to_sumk),
|
||||
sumk_to_solver = solver_to_sumk,
|
||||
solver_to_sumk_block = s2sblock)
|
||||
solver_to_sumk_block = s2sblock,
|
||||
deg_shells = [[] for ish in range(len(gf_struct))])
|
||||
|
||||
def pick_gf_struct_solver(self,new_gf_struct):
|
||||
""" Pick selected orbitals within blocks.
|
||||
""" Pick selected orbitals within blocks.
|
||||
|
||||
This throws away parts of the Green's function that (for some
|
||||
reason - be sure that you know what you're doing) shouldn't be
|
||||
reason - be sure that you know what you're doing) shouldn't be
|
||||
included in the calculation.
|
||||
|
||||
To drop an entire block, just don't include it.
|
||||
To drop a certain index within a block, just don't include it.
|
||||
|
||||
If it was before:
|
||||
|
||||
If it was before:
|
||||
|
||||
[{'up':[0,1],'down':[0,1],'left':[0,1]}]
|
||||
|
||||
to choose the 0th index of the up block and the 1st index of
|
||||
@ -130,11 +134,11 @@ class BlockStructure(object):
|
||||
Parameters
|
||||
----------
|
||||
new_gf_struct : list of dict
|
||||
formatted the same as gf_struct_solver:
|
||||
formatted the same as gf_struct_solver:
|
||||
|
||||
new_gf_struct[ish][block]=list of indices in that block.
|
||||
"""
|
||||
|
||||
|
||||
for ish in range(len(self.gf_struct_solver)):
|
||||
gf_struct = new_gf_struct[ish]
|
||||
|
||||
@ -154,24 +158,24 @@ class BlockStructure(object):
|
||||
new_ind = gf_struct[blk].index(ind)
|
||||
self.sumk_to_solver[ish][k]=(blk,new_ind)
|
||||
else:
|
||||
self.sumk_to_solver[ish][k]=(None,None)
|
||||
self.sumk_to_solver[ish][k]=(None,None)
|
||||
# reindexing gf_struct so that it starts with 0
|
||||
for k in gf_struct:
|
||||
gf_struct[k]=range(len(gf_struct[k]))
|
||||
self.gf_struct_solver[ish]=gf_struct
|
||||
|
||||
def pick_gf_struct_sumk(self,new_gf_struct):
|
||||
""" Pick selected orbitals within blocks.
|
||||
""" Pick selected orbitals within blocks.
|
||||
|
||||
This throws away parts of the Green's function that (for some
|
||||
reason - be sure that you know what you're doing) shouldn't be
|
||||
reason - be sure that you know what you're doing) shouldn't be
|
||||
included in the calculation.
|
||||
|
||||
To drop an entire block, just don't include it.
|
||||
To drop a certain index within a block, just don't include it.
|
||||
|
||||
If it was before:
|
||||
|
||||
If it was before:
|
||||
|
||||
[{'up':[0,1],'down':[0,1],'left':[0,1]}]
|
||||
|
||||
to choose the 0th index of the up block and the 1st index of
|
||||
@ -188,11 +192,11 @@ class BlockStructure(object):
|
||||
Parameters
|
||||
----------
|
||||
new_gf_struct : list of dict
|
||||
formatted the same as gf_struct_solver:
|
||||
formatted the same as gf_struct_solver:
|
||||
|
||||
new_gf_struct[ish][block]=list of indices in that block.
|
||||
|
||||
However, the indices are not according to the solver Gf
|
||||
However, the indices are not according to the solver Gf
|
||||
but the sumk Gf.
|
||||
"""
|
||||
|
||||
@ -218,7 +222,7 @@ class BlockStructure(object):
|
||||
Parameters
|
||||
----------
|
||||
mapping : list of dict
|
||||
the dict consists of elements
|
||||
the dict consists of elements
|
||||
(from_block,from_index) : (to_block,to_index)
|
||||
that maps from one structure to the other
|
||||
"""
|
||||
@ -254,7 +258,7 @@ class BlockStructure(object):
|
||||
def create_gf(self,ish=0,gf_function=GfImFreq,**kwargs):
|
||||
""" Create a zero BlockGf having the gf_struct_solver structure.
|
||||
|
||||
When using GfImFreq as gf_function, typically you have to
|
||||
When using GfImFreq as gf_function, typically you have to
|
||||
supply beta as keyword argument.
|
||||
|
||||
Parameters
|
||||
@ -284,7 +288,7 @@ class BlockStructure(object):
|
||||
.. warning::
|
||||
|
||||
Elements that are zero in the new structure due to
|
||||
the new block structure will be just ignored, thus
|
||||
the new block structure will be just ignored, thus
|
||||
approximated to zero.
|
||||
|
||||
Parameters
|
||||
@ -292,15 +296,24 @@ class BlockStructure(object):
|
||||
G : BlockGf
|
||||
the Gf that should be converted
|
||||
G_struct : GfStructure
|
||||
the structure ofthat G
|
||||
the structure of that G
|
||||
ish : int
|
||||
shell index
|
||||
show_warnings : bool
|
||||
whether to show warnings when elements of the Green's
|
||||
show_warnings : bool or float
|
||||
whether to show warnings when elements of the Green's
|
||||
function get thrown away
|
||||
if float, set the threshold for the magnitude of an element
|
||||
about to be thrown away to trigger a warning
|
||||
(default: 1.e-10)
|
||||
**kwargs :
|
||||
options passed to the constructor for the new Gf
|
||||
"""
|
||||
|
||||
warning_threshold = 1.e-10
|
||||
if isinstance(show_warnings, float):
|
||||
warning_threshold = show_warnings
|
||||
show_warnings = True
|
||||
|
||||
G_new = self.create_gf(ish=ish,**kwargs)
|
||||
for block in G_struct.gf_struct_solver[ish].keys():
|
||||
for i1 in G_struct.gf_struct_solver[ish][block]:
|
||||
@ -311,22 +324,24 @@ class BlockStructure(object):
|
||||
i2_sol = self.sumk_to_solver[ish][i2_sumk]
|
||||
if i1_sol[0] is None or i2_sol[0] is None:
|
||||
if show_warnings:
|
||||
warn(('Element {},{} of block {} of G is not present '+
|
||||
'in the new structure').format(i1,i2,block))
|
||||
if mpi.is_master_node():
|
||||
warn(('Element {},{} of block {} of G is not present '+
|
||||
'in the new structure').format(i1,i2,block))
|
||||
continue
|
||||
if i1_sol[0]!=i2_sol[0]:
|
||||
if show_warnings:
|
||||
warn(('Element {},{} of block {} of G is approximated '+
|
||||
'to zero to match the new structure.').format(
|
||||
i1,i2,block))
|
||||
if show_warnings and np.max(np.abs(G[block][i1,i2].data)) > warning_threshold:
|
||||
if mpi.is_master_node():
|
||||
warn(('Element {},{} of block {} of G is approximated '+
|
||||
'to zero to match the new structure. Max abs value: {}').format(
|
||||
i1,i2,block,np.max(np.abs(G[block][i1,i2].data))))
|
||||
continue
|
||||
G_new[i1_sol[0]][i1_sol[1],i2_sol[1]] = \
|
||||
G[block][i1,i2]
|
||||
return G_new
|
||||
|
||||
def approximate_as_diagonal(self):
|
||||
""" Create a structure for a GF with zero off-diagonal elements.
|
||||
|
||||
""" Create a structure for a GF with zero off-diagonal elements.
|
||||
|
||||
.. warning::
|
||||
|
||||
In general, this will throw away non-zero elements of the
|
||||
@ -351,7 +366,8 @@ class BlockStructure(object):
|
||||
def __eq__(self,other):
|
||||
def compare(one,two):
|
||||
if type(one)!=type(two):
|
||||
return False
|
||||
if not (isinstance(one, (bool, np.bool_)) and isinstance(two, (bool, np.bool_))):
|
||||
return False
|
||||
if one is None and two is None:
|
||||
return True
|
||||
if isinstance(one,list) or isinstance(one,tuple):
|
||||
@ -361,10 +377,10 @@ class BlockStructure(object):
|
||||
if not compare(x,y):
|
||||
return False
|
||||
return True
|
||||
elif isinstance(one,int):
|
||||
return one==two
|
||||
elif isinstance(one,str):
|
||||
elif isinstance(one,(int,bool, str, np.bool_)):
|
||||
return one==two
|
||||
elif isinstance(one,np.ndarray):
|
||||
return np.all(one==two)
|
||||
elif isinstance(one,dict):
|
||||
if set(one.keys()) != set(two.keys()):
|
||||
return False
|
||||
@ -375,8 +391,9 @@ class BlockStructure(object):
|
||||
warn('Cannot compare {}'.format(type(one)))
|
||||
return False
|
||||
|
||||
for prop in [ "gf_struct_sumk", "gf_struct_solver",
|
||||
"solver_to_sumk", "sumk_to_solver", "solver_to_sumk_block"]:
|
||||
for prop in [ "gf_struct_sumk", "gf_struct_solver",
|
||||
"solver_to_sumk", "sumk_to_solver", "solver_to_sumk_block",
|
||||
"deg_shells"]:
|
||||
if not compare(getattr(self,prop),getattr(other,prop)):
|
||||
return False
|
||||
return True
|
||||
@ -388,8 +405,8 @@ class BlockStructure(object):
|
||||
""" Reduce to dict for HDF5 export."""
|
||||
|
||||
ret = {}
|
||||
for element in [ "gf_struct_sumk", "gf_struct_solver",
|
||||
"solver_to_sumk_block"]:
|
||||
for element in [ "gf_struct_sumk", "gf_struct_solver",
|
||||
"solver_to_sumk_block","deg_shells"]:
|
||||
ret[element] = getattr(self,element)
|
||||
|
||||
def construct_mapping(mapping):
|
||||
@ -436,6 +453,18 @@ class BlockStructure(object):
|
||||
keys = sorted(element[ish].keys(),key=keyfun)
|
||||
for k in keys:
|
||||
s+=' '+str(k)+str(element[ish][k])+'\n'
|
||||
s += "deg_shells\n"
|
||||
for ish in range(len(self.deg_shells)):
|
||||
s+=' shell '+str(ish)+'\n'
|
||||
for l in range(len(self.deg_shells[ish])):
|
||||
s+=' equivalent group '+str(l)+'\n'
|
||||
if isinstance(self.deg_shells[ish][l],dict):
|
||||
for key, val in self.deg_shells[ish][l].iteritems():
|
||||
s+=' '+key+('*' if val[1] else '')+':\n'
|
||||
s+=' '+str(val[0]).replace('\n','\n ')+'\n'
|
||||
else:
|
||||
for key in self.deg_shells[ish][l]:
|
||||
s+=' '+key+'\n'
|
||||
return s
|
||||
|
||||
from pytriqs.archive.hdf_archive_schemes import register_class
|
||||
|
10
python/converters/CMakeLists.txt
Normal file
10
python/converters/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Create a temporary copy of the python modules so that we can run before installation with the test
|
||||
FILE(GLOB PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
|
||||
foreach(f ${PYTHON_SOURCES})
|
||||
configure_file(${f} ${f} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
# install files
|
||||
install(FILES ${PYTHON_SOURCES} DESTINATION ${PYTHON_LIB_DEST}/converters)
|
||||
|
||||
add_subdirectory(plovasp)
|
@ -19,10 +19,8 @@
|
||||
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##########################################################################
|
||||
from pytriqs.cmake_info import hdf5_command_path
|
||||
import pytriqs.utility.mpi as mpi
|
||||
|
||||
|
||||
class ConverterTools:
|
||||
|
||||
def __init__(self):
|
||||
@ -73,7 +71,7 @@ class ConverterTools:
|
||||
mpi.report("Repacking the file %s" % self.hdf_file)
|
||||
|
||||
retcode = subprocess.call(
|
||||
[hdf5_command_path + "/h5repack", "-i%s" % self.hdf_file, "-otemphgfrt.h5"])
|
||||
["h5repack", "-i%s" % self.hdf_file, "-otemphgfrt.h5"])
|
||||
if retcode != 0:
|
||||
mpi.report("h5repack failed!")
|
||||
else:
|
||||
|
@ -1,11 +1,19 @@
|
||||
set(python_destination pytriqs/applications/dft/converters/plovasp)
|
||||
# === Build and install atm module
|
||||
add_cpp2py_module(atm)
|
||||
target_link_libraries(atm atm_c triqs)
|
||||
target_compile_options(atm PRIVATE -std=c++17)
|
||||
target_include_directories(atm PRIVATE ${CMAKE_SOURCE_DIR}/c++)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${TRIQS_INCLUDE_ALL})
|
||||
triqs_python_extension(atm ${python_destination})
|
||||
target_link_libraries(atm atm_c ${TRIQS_LIBRARY_ALL})
|
||||
triqs_set_rpath_for_target(atm)
|
||||
install(TARGETS atm DESTINATION ${PYTHON_LIB_DEST}/converters/plovasp)
|
||||
|
||||
# === Copy Python files to current build directory and register for install
|
||||
set(PYTHON_SOURCES __init__.py converter.py elstruct.py inpconf.py plotools.py proj_group.py proj_shell.py sc_dmft.py vaspio.py)
|
||||
foreach(f ${PYTHON_SOURCES})
|
||||
configure_file(${f} ${f} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
# install files
|
||||
install(FILES ${PYTHON_SOURCES} DESTINATION ${PYTHON_LIB_DEST}/converters/plovasp)
|
||||
|
||||
# This we need in order for tests to work
|
||||
add_custom_command(TARGET atm POST_BUILD COMMAND ln -fs ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}/atm.so ${CMAKE_BINARY_DIR}/python/dft/converters/plovasp)
|
||||
|
||||
install (TARGETS atm DESTINATION ${TRIQS_PYTHON_LIB_DEST_ROOT}/${python_destination})
|
||||
#add_custom_command(TARGET atm POST_BUILD COMMAND ln -fs ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}/atm.so ${CMAKE_BINARY_DIR}/python/dft/converters/plovasp)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Generated automatically using the command :
|
||||
# c++2py.py -m atm -o atm --moduledoc "Analytical Tetrahedron Method for DOS" ../../../c++/plovasp/atm/dos_tetra3d.hpp
|
||||
from wrap_generator import *
|
||||
from cpp2py.wrap_generator import *
|
||||
|
||||
# The module
|
||||
module = module_(full_name = "atm", doc = "Analytical Tetrahedron Method for calculating DOS", app_name = "atm")
|
||||
@ -8,11 +8,11 @@ module = module_(full_name = "atm", doc = "Analytical Tetrahedron Method for cal
|
||||
# All the triqs C++/Python modules
|
||||
|
||||
# Add here all includes beyond what is automatically included by the triqs modules
|
||||
module.add_include("../../../c++/plovasp/atm/dos_tetra3d.hpp")
|
||||
module.add_include("plovasp/atm/dos_tetra3d.hpp")
|
||||
|
||||
# Add here anything to add in the C++ code at the start, e.g. namespace using
|
||||
module.add_preamble("""
|
||||
#include <triqs/python_tools/converters/arrays.hpp>
|
||||
#include <triqs/cpp2py_converters/arrays.hpp>
|
||||
""")
|
||||
|
||||
module.add_function ("array_view<double,2> dos_tetra_weights_3d (array_view<double,1> eigk, double en, array_view<long,2> itt)", doc = """DOS of a band by analytical tetrahedron method\n\n Returns corner weights for all tetrahedra for a given band and real energy.""")
|
||||
|
@ -21,9 +21,9 @@
|
||||
################################################################################
|
||||
|
||||
from types import *
|
||||
#from pytriqs.applications.dft.U_matrix import *
|
||||
#from triqs_dft_tools.U_matrix import *
|
||||
from U_matrix import *
|
||||
from pytriqs.gf.local import *
|
||||
from pytriqs.gf import *
|
||||
#from hubbard_I import gf_hi_fullu, sigma_atomic_fullu
|
||||
import pytriqs.utility.mpi as mpi
|
||||