votca-csg-1.2.4/admin/0000755000175000001440000000000012400714673014422 5ustar christophusersvotca-csg-1.2.4/admin/README0000644000175000001440000000011512400714673015277 0ustar christophusersThis spec file is used on openSUSE Build Service (http://build.opensuse.org) votca-csg-1.2.4/admin/votca-csg-rpmlintrc0000644000175000001440000000005012400714673020236 0ustar christophusersaddFilter("shlib-policy-name-error .*") votca-csg-1.2.4/admin/votca-csg.spec0000644000175000001440000001247512400714673017175 0ustar christophusers# # votca-csg.spec # # Originally written by Jussi Lehtola # Fixed for multi-distro build by Klaus Kaempf # # Licensed under the Apache Software License (ASL 2.0) # Name: votca-csg Version: 1.0.1 Release: 1%{?dist} Summary: VOTCA coarse-graining engine %if 0%{?suse_version} Group: Productivity/Scientific/Chemistry %else Group: Applications/Engineering %endif License: ASL 2.0 URL: http://www.votca.org Source0: http://votca.googlecode.com/files/%{name}-%{version}.tar.bz2 Source1: http://votca.googlecode.com/files/votca-tutorials.tar.bz2 Patch: votca-csg-1.0.1.dif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gromacs-devel BuildRequires: gcc-c++ libstdc++-devel %if 0%{?suse_version} BuildRequires: pkg-config BuildRequires: libexpat-devel %else BuildRequires: pkgconfig BuildRequires: expat-devel %endif BuildRequires: fftw-devel BuildRequires: gsl-devel BuildRequires: boost-devel BuildRequires: libvotca-tools0-devel = %{version} Requires: %{name}-common = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} %description Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. This package contains the Coarse Graining Engine of VOTCA package. %package libs Summary: Libraries for VOTCA coarse graining engine %if 0%{?suse_version} Group: Productivity/Scientific/Chemistry %else Group: System Environment/Libraries %endif %description libs Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. This package contains libraries for the Coarse Graining Engine of VOTCA package. %package devel Summary: Development headers and libraries for VOTCA Coarse Graining Engine %if 0%{?suse_version} Group: Development/Libraries/C and C++ %else Group: Development/Libraries %endif Requires: %{name}-libs = %{version}-%{release} Requires: votca-tools-devel = %{version} %description devel This package contains development headers and libraries for the Coarse Graining Engine of VOTCA. %package common Summary: Architecture independent data files for VOTCA CSG %if 0%{?suse_version} Group: Productivity/Scientific/Chemistry %else Group: Applications/Engineering %endif BuildArch: noarch %description common Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. This package contains architecture independent data files for VOTCA CSG. %package tutorials Summary: Tutorial documentation for VOTCA Coarse Graining Engine %if 0%{?suse_version} Group: Productivity/Scientific/Chemistry %else Group: Applications/Engineering %endif BuildArch: noarch %description tutorials Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. This package contains tutorial documentation and sample data %package bash Summary: Bash completion for votca %if 0%{?suse_version} Group: Productivity/Other %else Group: System Environment/Shells %endif Requires: %{name} = %{version}-%{release} Requires: bash-completion BuildArch: noarch %description bash Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. Iterative methods are implemented using bash + perl. This package contains bash completion support for votca-csg. %prep %setup -q tar -xjf %{S:1} rm -rf tutorials/.hg* %patch -p1 autoreconf -f -i %build %if 0%{?suse_version} %configure --disable-static --disable-la-files --disable-rc-files %else %configure --disable-static --disable-la-files --disable-rc-files %endif make %{?_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} # Move bash completion file to correct location mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d cp scripts/csg-completion.bash %{buildroot}%{_sysconfdir}/bash_completion.d/votca %if 0%{?suse_version} %define pkgdocdir %{_docdir}/%{name} %else %define pkgdocdir %{_docdir}/%{name}-%{version} %endif %clean rm -rf %{buildroot} %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig %files %defattr(-,root,root,-) %doc CHANGELOG NOTICE README LICENSE %{_bindir}/csg_* %{_bindir}/multi_g_* %files tutorials %defattr(-,root,root,-) %doc tutorials %files common %defattr(-,root,root,-) %{_datadir}/votca %files libs %defattr(-,root,root,-) %doc LICENSE %{_libdir}/libvotca_csg.so.* %files devel %defattr(-,root,root,-) %{_includedir}/votca/csg/ %{_libdir}/libvotca_csg.so %{_libdir}/pkgconfig/libvotca_csg.pc %files bash %defattr(-,root,root,-) %{_sysconfdir}/bash_completion.d/votca %changelog * Thu Nov 30 2010 Christoph Junghans - 1.0.1-1 - Minor cleanup. * Thu Nov 25 2010 Jussi Lehtola - 1.0-1 - First release. votca-csg-1.2.4/ChangeLog0000644000175000001440000001321012400714674015102 0ustar christophusersVersion 1.2.4 (released 31.08.14) * support for Gromacs 5.0 * support for Boost 1.53 * fixed use of nawk instead of gawk under MacOs * fixed python shebang * fixed linking issue under Fedora * fixed thermforce calculation for xsplit case Version 1.2.3 (released 14.08.12) * improved AIX support * fixed install on 64-bit linux systems * fixed a bug in histogram class * fixed rdf calculation for r_min > 0 (histogram bug) * updated documentation Version 1.2.2 (released 10.01.12) * added numpy solver for IMC * cmake: updated FindGROMACS.cmake * fixed coredump in csg_property (issue 114) * fixed namespace in Fedora * fixed problem with newlines in csg_property * cmake: allow static fftw and gsl * added dummy c function for cmake * fixed conflicting type headers (real was defined) Version 1.2.1 (released 25.08.11) * csg_inverse: improve initial guess of the potential * csg_inverse: fixes for min!=0 * table_extrapolate.pl: fixed flags and first point * fixed tf iteration for multiple components * fixed round-off error in grid search and csg_calc * csg_inverse: typo fixed and additional checks * fixed soname of libs * improved cmake checks and error messages * fixed pkg-config file Version 1.2 "SuperDoris" (released 17.06.11) * changed buildsystem to cmake * added thermforce iteration method * added csg_density * a lot of framework clean up * added type selector name:* * allow long and restart of simulations * added database class through sqlite3 Version 1.1.2 (released 04.04.11) * csg_fmatch: added support for known forces (--trj-force option) * fixed head of votca.7 manpage Version 1.1.1 (released 01.03.11) * fixed csg_inverse --clean * make postupdate pressure work again * fixed bug when reading exclusions from tpr * end with error in csg_stat if bead type does not exist (issue 77) Version 1.1 "SuperAnn" (released 18.02.11) * added support for gromacs 5.0 * csg_dump: can dump exclusion * added boundarycondition class * added man pages, man7 and man1 for all bins * csg_inverse: renamed ibm to ibi * csg_inverse: many internal improvements * csg_stat: added thread support, read exclusions from tpr file, uses grid search by default * csg_inverse: added convergence check, postadd plot, better logging and weaker die * csg_resample: added boundary conditions option and akima spline support * csg_stat or csg_fmatch give an error if trj not given (issue 29) * csg_get_interaction_property knows about defaults * fixed segfault in mapping (Fixes issue 27) * fixed bug in gromacs writer (frame.bX = true) * fixed segfault in gromacs writer (issue 54) * added thread class * added spline class, with akima spline, linear spline * random.cc: avoid calling of exit() * added lexical cast class Version 1.0.1 (released 01.12.10) * fixed custom md programs in sim scripts (issue 1) * completion file is back from tools * issue #21: fixed strange kink when pot.in was provided * added --disable-rc-files to configure * csg_call/csg_inverse: added installdir as failback for CSGSHARE * fixed a bug in VOTCARC.csh for empty LD_LIBRARY_PATH * completion file has moved back to csg * added --disable-rc-files to configure * updated bundled libtool to 2.2.10 Version 1.0 (released 30.09.10) * added postupdate script for scaling the update * added options to perform analysis without giving a mapping file (--no-map). No need for dummy mapping file in IMC and csg_stat anymore. * allow comments in tables * fixed bug in pressure correction when p is negative * added support for gromacs devel version * fixed a bug when compiling with gcc-4.4 * fixed a bug that pot.cur was change at every step * added application class for easy implementation of analysis programs * fixed bug if initial potential was given and not used * restart points in iterative procedure are not anymore deleted after step finished * preliminary reader for ESPResSo Blockfiles and ESPResSo as Simulation program for csg_inverse * preliminary reader for LAMMPS dump files (very limited features) * allow compling without gromacs * a lot new xml optionsfull support for gromacs 4.5 * added libvotca_expat to allow compiling without expat * allow comments in tables * added application class to create standardized applications * all boost dependecy are now in tools * fixes in table format, flags is always last row now * allow compling without fftw (needed for csg_boltzmann only) * allow compling without gsl (needed for csg_resample and csg_fmatch) Version 1.0_rc5 (released 16.03.10) * fixed --first-frame option (--first-frame 1 before started at second frame) * fixed compatibility issue when using gromacs development version * updated configure, see --help * added multi_g_density * CSGRC is replaced by VOTCARC of votca_tools * using libexpat instead of libxml2 * added libvotca_boost to allow compiling without boost * using pkg-config to detect package flags * compiles under AIX with xlC * added VOTCARC to initialize all votca parts * updated configure, see --help Version 1.0_rc4 (released 08.02.10) * using libtool to build shared libs\ * fixed a bug in error calculation of multi_g_rdf Version 1.0_rc3 (released 29.01.10) * added option --wall-time to csg_inverse if run on a queueing system * added option for IBI to run in parallel * multi_g_rdf, a multiplexed version of g_rdf was added * added some options to csg_call * csg_resample now also calc derivatives * fixed a bug in reading stuff from mpd file * corrected bug in tokenizer * fixed a bug in calculation of version string * some fixes concerning autotools Version 1.0_rc2 (released 16.12.09) * added version string to scripts * fixed typo in calculation of version string * added NOTICE and LICENSE to the dist tarball Version 1.0_rc1 (released 11.12.09) * initial version votca-csg-1.2.4/CMakeLists.txt0000644000175000001440000001074212400714673016076 0ustar christophuserscmake_minimum_required(VERSION 2.6) project(votca-csg) set(PROJECT_VERSION "1.2.4") set(PROJECT_CONTACT "bugs@votca.org") string(REGEX REPLACE "^[1-9]+\\.([1-9]+).*$" "\\1" SOVERSION "${PROJECT_VERSION}") if (NOT ${SOVERSION} MATCHES "[1-9]+") message(FATAL_ERROR "Could not determind SOVERSION from ${PROJECT_VERSION}") endif (NOT ${SOVERSION} MATCHES "[1-9]+") # Cmake modules/macros are in a subdirectory to keep this file cleaner set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) if(NOT CMAKE_BUILD_TYPE) #Release comes with -O3 by default set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif(NOT CMAKE_BUILD_TYPE) enable_language(CXX) ###################################################################### # compiler tests # these need ot be done early (before further tests). ##################################################################### include(CheckCXXCompilerFlag) ######################################################################## # User input options # ######################################################################## option(BUILD_SHARED_LIBS "Build shared libs" ON) if (NOT DEFINED LIB) set(LIB "lib") endif(NOT DEFINED LIB) if (NOT DEFINED MAN) set(MAN "share/man") endif(NOT DEFINED MAN) if (NOT DEFINED DATA) set(DATA "share/votca") endif(NOT DEFINED DATA) # this has to be the include specification! include_directories(${CMAKE_SOURCE_DIR}/include) ######################################################################## #Find external packages ######################################################################## find_package(Threads REQUIRED) set(THREAD_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) find_package(TXT2TAGS) option(EXTERNAL_BOOST "Use external boost" ON) if (EXTERNAL_BOOST) find_package(Boost 1.39.0 COMPONENTS program_options ) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost not found, make sure you have also installed boost and it's dev package or use our internal replacement, if you have built tools with -DEXTERNAL_BOOST=OFF and set it here as well") endif(NOT Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) set (BOOST_LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY}) set (BOOST_PKG) set (BOOST_CFLAGS_PKG "-I${Boost_INCLUDE_DIRS}") string(REGEX REPLACE "^(.*)/lib([^/]*)\\.[^.]*$" "-L\\1 -l\\2" BOOST_LIBS_PKG ${BOOST_LIBRARIES}) else(EXTERNAL_BOOST) find_package(VOTCA_BOOST REQUIRED) include_directories(${VOTCA_BOOST_INCLUDE_DIRS}) set (BOOST_LIBRARIES ${VOTCA_BOOST_LIBRARIES}) set (BOOST_PKG "libvotca_boost") set (BOOST_INCLUDE_DIR_PKG) set (BOOST_LIB_PKG) set (BOOST_LIB_DIR_PKG) endif(EXTERNAL_BOOST) find_package(VOTCA_TOOLS REQUIRED) include_directories(${VOTCA_TOOLS_INCLUDE_DIRS}) find_package(UnixCommands) ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # ######################################################################## include(CheckIncludeFile) foreach(HEADER assert.h) check_include_file(${HEADER} FOUND_${HEADER}) if(NOT FOUND_${HEADER}) message(FATAL_ERROR "Could not find needed header - ${HEADER}") endif(NOT FOUND_${HEADER}) endforeach(HEADER) include(CheckIncludeFileCXX) foreach(HEADER algorithm fstream iomanip iostream list map numeric sstream stdexcept string vector cstdlib) check_include_file_cxx(${HEADER} FOUND_${HEADER}) if(NOT FOUND_${HEADER}) message(FATAL_ERROR "Could not find needed header - ${HEADER}") endif(NOT FOUND_${HEADER}) endforeach(HEADER) set(MATH_LIBRARIES "m" CACHE STRING "math library") mark_as_advanced( MATH_LIBRARIES ) include(CheckLibraryExists) foreach(FUNC sqrt) check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES}) if(NOT FOUND_${FUNC}_${MATH_LIBRARIES}) message(FATAL_ERROR "Could not find needed math function - ${FUNC}") endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES}) endforeach(FUNC) ###################################### # Include the following subdirectory # ###################################### add_custom_target(manpages ALL) add_subdirectory(scripts) add_subdirectory(src) add_subdirectory(include/votca/csg) add_subdirectory(share) configure_file(${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) votca-csg-1.2.4/CMakeModules/0000755000175000001440000000000012400714673015643 5ustar christophusersvotca-csg-1.2.4/CMakeModules/hgversion.cmake0000644000175000001440000000133512400714673020653 0ustar christophusersset(CMAKE_MODULE_PATH ${TOP_SOURCE_DIR}/CMakeModules) find_package(Mercurial) if (MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) MERCURIAL_HG_INFO(${TOP_SOURCE_DIR} THIS) MESSAGE("Current revision is ${THIS_HG_ID}") set (THIS_HG_ID "hgid: ${THIS_HG_ID}") else (MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) set (THIS_HG_ID) endif (MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) set (HG_HEADER "hgversion.h") set (NEW_HG_HEADER "new_hgversion.h") file(WRITE ${NEW_HG_HEADER} "static const std::string hgversion = \"${THIS_HG_ID}\";\n") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NEW_HG_HEADER} ${HG_HEADER}) execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${NEW_HG_HEADER}) votca-csg-1.2.4/CMakeModules/cmake_uninstall.cmake.in0000644000175000001440000000165512400714673022432 0ustar christophusersIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file) votca-csg-1.2.4/CMakeModules/hgscript.cmake0000644000175000001440000000131312400714673020466 0ustar christophusersset(CMAKE_MODULE_PATH ${TOP_SOURCE_DIR}/CMakeModules) find_package(Mercurial) if (MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) MERCURIAL_HG_INFO(${TOP_SOURCE_DIR} THIS) MESSAGE("Current revision is ${THIS_HG_ID}") set (THIS_HG_ID "hgid: ${THIS_HG_ID}") else(MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) set (THIS_HG_ID) endif(MERCURIAL_FOUND AND IS_DIRECTORY ${TOP_SOURCE_DIR}/.hg) file(READ ${INPUT} CONTENT) string(REGEX REPLACE "#CSG_HG_ID#" "${THIS_HG_ID}" NEW_CONTENT "${CONTENT}") file(WRITE "${OUTPUT}.tmp" "${NEW_CONTENT}") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OUTPUT}.tmp ${OUTPUT}) execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${OUTPUT}.tmp) votca-csg-1.2.4/CMakeModules/FindPkgConfig.cmake0000644000175000001440000003520512400714673021322 0ustar christophusers# - a pkg-config module for CMake # # Usage: # pkg_check_modules( [REQUIRED] []*) # checks for all the given modules # # pkg_search_module( [REQUIRED] []*) # checks for given modules and uses the first working one # # When the 'REQUIRED' argument was set, macros will fail with an error # when module(s) could not be found # # It sets the following variables: # PKG_CONFIG_FOUND ... true if pkg-config works on the system # PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program # _FOUND ... set to 1 if module(s) exist # # For the following variables two sets of values exist; first one is the # common one and has the given PREFIX. The second set contains flags # which are given out when pkgconfig was called with the '--static' # option. # _LIBRARIES ... only the libraries (w/o the '-l') # _LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') # _LDFLAGS ... all required linker flags # _LDFLAGS_OTHER ... all other linker flags # _INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') # _CFLAGS ... all required cflags # _CFLAGS_OTHER ... the other compiler flags # # = for common case # = _STATIC for static linking # # There are some special variables whose prefix depends on the count # of given modules. When there is only one module, stays # unchanged. When there are multiple modules, the prefix will be # changed to _: # _VERSION ... version of the module # _PREFIX ... prefix-directory of the module # _INCLUDEDIR ... include-dir of the module # _LIBDIR ... lib-dir of the module # # = when |MODULES| == 1, else # = _ # # A parameter can have the following formats: # {MODNAME} ... matches any version # {MODNAME}>={VERSION} ... at least version is required # {MODNAME}={VERSION} ... exactly version is required # {MODNAME}<={VERSION} ... modules must not be newer than # # Examples # pkg_check_modules (GLIB2 glib-2.0) # # pkg_check_modules (GLIB2 glib-2.0>=2.10) # requires at least version 2.10 of glib2 and defines e.g. # GLIB2_VERSION=2.10.3 # # pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) # requires both glib2 and gtk2, and defines e.g. # FOO_glib-2.0_VERSION=2.10.3 # FOO_gtk+-2.0_VERSION=2.8.20 # # pkg_check_modules (XRENDER REQUIRED xrender) # defines e.g.: # XRENDER_LIBRARIES=Xrender;X11 # XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp # # pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006 Enrico Scholz # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) ### Common stuff #### set(PKG_CONFIG_VERSION 1) set(PKG_CONFIG_FOUND 0) find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) if(PKG_CONFIG_EXECUTABLE) set(PKG_CONFIG_FOUND 1) endif(PKG_CONFIG_EXECUTABLE) # Unsets the given variables macro(_pkgconfig_unset var) set(${var} "" CACHE INTERNAL "") endmacro(_pkgconfig_unset) macro(_pkgconfig_set var value) set(${var} ${value} CACHE INTERNAL "") endmacro(_pkgconfig_set) # Invokes pkgconfig, cleans up the result and sets variables macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) set(_pkgconfig_invoke_result) execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist} OUTPUT_VARIABLE _pkgconfig_invoke_result RESULT_VARIABLE _pkgconfig_failed) if (_pkgconfig_failed) set(_pkgconfig_${_varname} "") _pkgconfig_unset(${_prefix}_${_varname}) else(_pkgconfig_failed) string(REGEX REPLACE "[\r\n]" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") string(REGEX REPLACE " +$" "" _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") if (NOT ${_regexp} STREQUAL "") string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") endif(NOT ${_regexp} STREQUAL "") separate_arguments(_pkgconfig_invoke_result) #message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}") set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result}) _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}") endif(_pkgconfig_failed) endmacro(_pkgconfig_invoke) # Invokes pkgconfig two times; once without '--static' and once with # '--static' macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) _pkgconfig_invoke("${_pkglist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN}) _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static ${ARGN}) endmacro(_pkgconfig_invoke_dyn) # Splits given arguments into options and a package list macro(_pkgconfig_parse_options _result _is_req) set(${_is_req} 0) foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") set(${_is_req} 1) endif (_pkg STREQUAL "REQUIRED") endforeach(_pkg ${ARGN}) set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") endmacro(_pkgconfig_parse_options) ### macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) _pkgconfig_unset(${_prefix}_INCLUDEDIR) _pkgconfig_unset(${_prefix}_LIBDIR) _pkgconfig_unset(${_prefix}_LIBS) _pkgconfig_unset(${_prefix}_LIBS_L) _pkgconfig_unset(${_prefix}_LIBS_PATHS) _pkgconfig_unset(${_prefix}_LIBS_OTHER) _pkgconfig_unset(${_prefix}_CFLAGS) _pkgconfig_unset(${_prefix}_CFLAGS_I) _pkgconfig_unset(${_prefix}_CFLAGS_OTHER) _pkgconfig_unset(${_prefix}_STATIC_LIBDIR) _pkgconfig_unset(${_prefix}_STATIC_LIBS) _pkgconfig_unset(${_prefix}_STATIC_LIBS_L) _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS) _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER) _pkgconfig_unset(${_prefix}_STATIC_CFLAGS) _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I) _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER) # create a better addressable variable of the modules and calculate its size set(_pkg_check_modules_list ${ARGN}) list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt) if(PKG_CONFIG_EXECUTABLE) # give out status message telling checked module if (NOT ${_is_silent}) if (_pkg_check_modules_cnt EQUAL 1) message(STATUS "checking for module '${_pkg_check_modules_list}'") else(_pkg_check_modules_cnt EQUAL 1) message(STATUS "checking for modules '${_pkg_check_modules_list}'") endif(_pkg_check_modules_cnt EQUAL 1) endif(NOT ${_is_silent}) set(_pkg_check_modules_packages) set(_pkg_check_modules_failed) # iterate through module list and check whether they exist and match the required version foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) set(_pkg_check_modules_exist_query) # check whether version is given if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}") string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}") else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}") set(_pkg_check_modules_pkg_op) set(_pkg_check_modules_pkg_ver) endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*") # handle the operands if (_pkg_check_modules_pkg_op STREQUAL ">=") list(APPEND _pkg_check_modules_exist_query --atleast-version) endif(_pkg_check_modules_pkg_op STREQUAL ">=") if (_pkg_check_modules_pkg_op STREQUAL "=") list(APPEND _pkg_check_modules_exist_query --exact-version) endif(_pkg_check_modules_pkg_op STREQUAL "=") if (_pkg_check_modules_pkg_op STREQUAL "<=") list(APPEND _pkg_check_modules_exist_query --max-version) endif(_pkg_check_modules_pkg_op STREQUAL "<=") # create the final query which is of the format: # * --atleast-version # * --exact-version # * --max-version # * --exists if (_pkg_check_modules_pkg_op) list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}") else(_pkg_check_modules_pkg_op) list(APPEND _pkg_check_modules_exist_query --exists) endif(_pkg_check_modules_pkg_op) _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION) _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX) _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR) _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR) list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}") list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}") # execute the query execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query} RESULT_VARIABLE _pkgconfig_retval) # evaluate result and tell failures if (_pkgconfig_retval) if(NOT ${_is_silent}) message(STATUS " package '${_pkg_check_modules_pkg}' not found") endif(NOT ${_is_silent}) set(_pkg_check_modules_failed 1) endif(_pkgconfig_retval) endforeach(_pkg_check_modules_pkg) if(_pkg_check_modules_failed) # fail when requested if (${_is_required}) message(SEND_ERROR "A required package was not found") endif (${_is_required}) else(_pkg_check_modules_failed) # when we are here, we checked whether requested modules # exist. Now, go through them and set variables _pkgconfig_set(${_prefix}_FOUND 1) list(LENGTH _pkg_check_modules_packages pkg_count) # iterate through all modules again and set individual variables foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages}) # handle case when there is only one package required if (pkg_count EQUAL 1) set(_pkg_check_prefix "${_prefix}") else(pkg_count EQUAL 1) set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}") endif(pkg_count EQUAL 1) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION "" --modversion ) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX "" --variable=prefix ) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir ) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") endforeach(_pkg_check_modules_pkg) # set variables which are combined for multiple modules _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES "(^| )-l" --libs-only-l ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) endif(_pkg_check_modules_failed) else(PKG_CONFIG_EXECUTABLE) if (${_is_required}) message(SEND_ERROR "pkg-config tool not found") endif (${_is_required}) endif(PKG_CONFIG_EXECUTABLE) endmacro(_pkg_check_modules_internal) ### ### User visible macros start here ### ### macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) _pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN}) _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) endmacro(pkg_check_modules) ### macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN}) message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") endif(NOT _pkg_modules_found) if (${_prefix}_FOUND) set(_pkg_modules_found 1) endif(${_prefix}_FOUND) endforeach(_pkg_alt) if (NOT ${_prefix}_FOUND) if(${_pkg_is_required}) message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found") endif(${_pkg_is_required}) endif(NOT ${_prefix}_FOUND) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) endmacro(pkg_search_module) ### Local Variables: ### mode: cmake ### End: votca-csg-1.2.4/CMakeModules/FindDoxygen.cmake0000644000175000001440000001150212400714673021062 0ustar christophusers# - This module looks for Doxygen and the path to Graphviz's dot # Doxygen is a documentation generation tool. Please see # http://www.doxygen.org # # This module accepts the following optional variables: # # DOXYGEN_SKIP_DOT = If true this module will skip trying to find Dot # (an optional component often used by Doxygen) # # This modules defines the following variables: # # DOXYGEN_EXECUTABLE = The path to the doxygen command. # DOXYGEN_FOUND = Was Doxygen found or not? # # DOXYGEN_DOT_EXECUTABLE = The path to the dot program used by doxygen. # DOXYGEN_DOT_FOUND = Was Dot found or not? # DOXYGEN_DOT_PATH = The path to dot not including the executable # # #============================================================================= # Copyright 2001-2009 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) # For backwards compatibility support IF(Doxygen_FIND_QUIETLY) SET(DOXYGEN_FIND_QUIETLY TRUE) ENDIF(Doxygen_FIND_QUIETLY) # ===== Rationale for OS X AppBundle mods below ===== # With the OS X GUI version, Doxygen likes to be installed to /Applications and # it contains the doxygen executable in the bundle. In the versions I've # seen, it is located in Resources, but in general, more often binaries are # located in MacOS. # # NOTE: The official Doxygen.app that is distributed for OS X uses non-standard # conventions. Instead of the command-line "doxygen" tool being placed in # Doxygen.app/Contents/MacOS, "Doxywizard" is placed there instead and # "doxygen" is placed in Contents/Resources. This is most likely done # so that something happens when people double-click on the Doxygen.app # package. Unfortunately, CMake gets confused by this as when it sees the # bundle it uses "Doxywizard" as the executable to use instead of # "doxygen". Therefore to work-around this issue we temporarily disable # the app-bundle feature, just for this CMake module: if(APPLE) # Save the old setting SET(TEMP_DOXYGEN_SAVE_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE}) # Disable the App-bundle detection feature SET(CMAKE_FIND_APPBUNDLE "NEVER") endif() # FYI: # In the older versions of OS X Doxygen, dot was included with the # Doxygen bundle. But the new versions require you to download # Graphviz.app which contains "dot" in it's bundle. # ============== End OSX stuff ================ # # Find Doxygen... # FIND_PROGRAM(DOXYGEN_EXECUTABLE NAMES doxygen PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\doxygen_is1;Inno Setup: App Path]/bin" /Applications/Doxygen.app/Contents/Resources /Applications/Doxygen.app/Contents/MacOS DOC "Doxygen documentation generation tool (http://www.doxygen.org)" ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Doxygen DEFAULT_MSG DOXYGEN_EXECUTABLE) # # Find Dot... # IF(NOT DOXYGEN_SKIP_DOT) FIND_PROGRAM(DOXYGEN_DOT_EXECUTABLE NAMES dot PATHS "$ENV{ProgramFiles}/Graphviz 2.21/bin" "C:/Program Files/Graphviz 2.21/bin" "$ENV{ProgramFiles}/ATT/Graphviz/bin" "C:/Program Files/ATT/Graphviz/bin" [HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin /Applications/Graphviz.app/Contents/MacOS /Applications/Doxygen.app/Contents/Resources /Applications/Doxygen.app/Contents/MacOS DOC "Graphviz Dot tool for using Doxygen" ) if(DOXYGEN_DOT_EXECUTABLE) set(DOXYGEN_DOT_FOUND TRUE) # The Doxyfile wants the path to Dot, not the entire path and executable get_filename_component(DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}" PATH CACHE) endif() endif(NOT DOXYGEN_SKIP_DOT) # # Backwards compatibility... # if(APPLE) # Restore the old app-bundle setting setting SET(CMAKE_FIND_APPBUNDLE ${TEMP_DOXYGEN_SAVE_CMAKE_FIND_APPBUNDLE}) endif() # Maintain the _FOUND variables as "YES" or "NO" for backwards compatibility # (allows people to stuff them directly into Doxyfile with configure_file()) if(DOXYGEN_FOUND) set(DOXYGEN_FOUND "YES") else() set(DOXYGEN_FOUND "NO") endif() if(DOXYGEN_DOT_FOUND) set(DOXYGEN_DOT_FOUND "YES") else() set(DOXYGEN_DOT_FOUND "NO") endif() # For backwards compatibility support SET (DOXYGEN ${DOXYGEN_EXECUTABLE} ) SET (DOT ${DOXYGEN_DOT_EXECUTABLE} ) MARK_AS_ADVANCED( DOXYGEN_EXECUTABLE DOXYGEN_DOT_EXECUTABLE DOXYGEN_DOT_PATH ) votca-csg-1.2.4/CMakeModules/FindTXT2TAGS.cmake0000644000175000001440000000401112400714673020662 0ustar christophusers# Copyright (C) 2011 Votca Development Team # # This file was derived from FindGnuplot.cmake shipped with CMake 2.6.3. # # - this module looks for txt2tags # # Once done this will define # # TXT2TAGS_FOUND - system has txt2tags # TXT2TAGS_EXECUTABLE - the txt2tags executable # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #============================================================================= # Copyright 2002-2009 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) FIND_PROGRAM(TXT2TAGS_EXECUTABLE NAMES txt2tags txt2tags-2.5 txt2tags-2.6 PATHS ${CYGWIN_INSTALL_PATH}/bin ) # handle the QUIETLY and REQUIRED arguments and set TXT2TAGS_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TXT2TAGS DEFAULT_MSG TXT2TAGS_EXECUTABLE) IF(NOT TXT2TAGS_FOUND) message("txt2tags not found, help cmake to find it by setting TXT2TAGS_EXECUTABLE") ENDIF(NOT TXT2TAGS_FOUND) MARK_AS_ADVANCED( TXT2TAGS_EXECUTABLE ) votca-csg-1.2.4/CMakeModules/FindMercurial.cmake0000644000175000001440000001414212400714673021373 0ustar christophusers# - Extract information from a Mercurial repository # The module defines the following variables: # MERCURIAL_EXECUTABLE - path to mercurial executable # MERCURIAL_VERSION - mercurial version # MERCURIAL_FOUND - true if mercurial was found # If the mercurial executable is found the macro # MERCURIAL_HG_INFO( ) # is defined to extract information of a mercurial repository at # a given location. The macro defines the following variables: # _HG_ID - global revision id of the working copy (at ) # _HG_CHANGESET - changeset id of the working copy # _HG_AUTHOR - commit author of this changeset # _HG_DATE - commit date of this changeset # _HG_TAGS - tags belonging to this changeset # _HG_BRANCH - (non-default) branch name of this changeset # _HG_SUMMARY - commit message summary of this changeset # Example usage: # FIND_PACKAGE(Mercurial) # IF(MERCURIAL_FOUND) # MERCURIAL_HG_INFO(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Current revision is ${Project_HG_ID}") # ENDIF(MERCURIAL_FOUND) # Copyright (C) 2008 Peter Colberg # # This file was derived from FindSubversion.cmake shipped with CMake 2.4.7. # # Copyright (c) 2006, Tristan Carel # 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. # * Neither the name of the University of California, Berkeley nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS AND 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. FIND_PROGRAM(MERCURIAL_EXECUTABLE hg DOC "Mercurial Distributed SCM executable") MARK_AS_ADVANCED(MERCURIAL_EXECUTABLE) IF(MERCURIAL_EXECUTABLE) SET(MERCURIAL_FOUND TRUE) MACRO(MERCURIAL_COMMAND dir command) EXECUTE_PROCESS(COMMAND ${MERCURIAL_EXECUTABLE} ${command} ${ARGN} WORKING_DIRECTORY ${dir} OUTPUT_VARIABLE MERCURIAL_${command}_OUTPUT ERROR_VARIABLE MERCURIAL_${command}_ERROR RESULT_VARIABLE MERCURIAL_${command}_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${MERCURIAL_${command}_RESULT} EQUAL 0) SET(cmdline "${MERCURIAL_EXECUTABLE} ${command}") FOREACH(arg ${ARGN}) SET(cmdline "${cmdline} ${arg}") ENDFOREACH(arg ${ARGN}) MESSAGE(SEND_ERROR "Command \"${cmdline}\" failed with output:\n${MERCURIAL_${command}_ERROR}") SET(MERCURIAL_${command}_OUTPUT) ENDIF(NOT ${MERCURIAL_${command}_RESULT} EQUAL 0) ENDMACRO(MERCURIAL_COMMAND dir command) MACRO(MERCURIAL_HG_INFO dir prefix) IF(IS_DIRECTORY "${dir}") MERCURIAL_COMMAND(${dir} id -i) IF(MERCURIAL_id_OUTPUT) # global revision id of the working copy SET(${prefix}_HG_ID "${MERCURIAL_id_OUTPUT}") # changeset id of the working copy STRING(REGEX REPLACE "^([0-9a-f]+).*" "\\1" ${prefix}_HG_CHANGESET "${MERCURIAL_id_OUTPUT}") MERCURIAL_COMMAND(${dir} log -r ${${prefix}_HG_CHANGESET}) STRING(REGEX REPLACE ";" "\\\\;" MERCURIAL_log_OUTPUT "${MERCURIAL_log_OUTPUT}") STRING(REGEX REPLACE "\n" ";" MERCURIAL_log_OUTPUT "${MERCURIAL_log_OUTPUT}") FOREACH(line ${MERCURIAL_log_OUTPUT}) # commit author of this changeset IF(line MATCHES "^user:") STRING(REGEX REPLACE "^user:[ ]+(.+)" "\\1" ${prefix}_HG_AUTHOR "${line}") ENDIF(line MATCHES "^user:") # commit date of this changeset IF(line MATCHES "^date:") STRING(REGEX REPLACE "^date:[ ]+(.+)" "\\1" ${prefix}_HG_DATE "${line}") ENDIF(line MATCHES "^date:") # tags belonging to this changeset IF(line MATCHES "^tag:") STRING(REGEX REPLACE "^tag:[ ]+(.+)" "\\1" tag "${line}") STRING(REGEX REPLACE ";" "\\\\;" tag "${tag}") LIST(APPEND ${prefix}_HG_TAGS "${tag}") ENDIF(line MATCHES "^tag:") # (non-default) branch name of this changeset IF(line MATCHES "^branch:") STRING(REGEX REPLACE "^branch:[ ]+(.+)" "\\1" ${prefix}_HG_BRANCH "${line}") ENDIF(line MATCHES "^branch:") # commit message summary of this changeset IF(line MATCHES "^summary:") STRING(REGEX REPLACE "^summary:[ ]+(.+)" "\\1" ${prefix}_HG_SUMMARY "${line}") ENDIF(line MATCHES "^summary:") ENDFOREACH(line ${MERCURIAL_log_OUTPUT}) ENDIF(MERCURIAL_id_OUTPUT) ELSE(IS_DIRECTORY "${dir}") MESSAGE(SEND_ERROR "Invalid MERCURIAL_HG_INFO directory \"${dir}\"") ENDIF(IS_DIRECTORY "${dir}") ENDMACRO(MERCURIAL_HG_INFO dir prefix) # mercurial version MERCURIAL_COMMAND(${CMAKE_BINARY_DIR} version) STRING(REGEX REPLACE "^Mercurial Distributed SCM \\(version ([.0-9]+)\\).*" "\\1" MERCURIAL_VERSION "${MERCURIAL_version_OUTPUT}") ENDIF(MERCURIAL_EXECUTABLE) IF(NOT MERCURIAL_FOUND) IF(NOT MERCURIAL_FIND_QUIETLY) MESSAGE(STATUS "Mercurial was not found.") ELSE(NOT MERCURIAL_FIND_QUIETLY) IF(MERCURIAL_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Mercurial was not found.") ENDIF(MERCURIAL_FIND_REQUIRED) ENDIF(NOT MERCURIAL_FIND_QUIETLY) ENDIF(NOT MERCURIAL_FOUND) votca-csg-1.2.4/CMakeModules/FindVOTCA_BOOST.cmake0000644000175000001440000000305612400714673021274 0ustar christophusers# - Find libvotca_boost # Find the native libvotca_boost headers and libraries. # # VOTCA_BOOST_INCLUDE_DIRS - where to find headers etc. # VOTCA_BOOST_LIBRARIES - List of libraries when using expat. # VOTCA_BOOST_FOUND - True if expat found. # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) pkg_check_modules(PC_VOTCA_BOOST libvotca_boost) find_path(VOTCA_BOOST_INCLUDE_DIR boost/algorithm/string/trim.hpp HINTS ${PC_VOTCA_BOOST_INCLUDE_DIRS} ) find_library(VOTCA_BOOST_LIBRARY NAMES votca_boost HINTS ${PC_VOTCA_BOOST_LIBRARY_DIRS} ) set(VOTCA_BOOST_LIBRARIES "${VOTCA_BOOST_LIBRARY}" ) set(VOTCA_BOOST_INCLUDE_DIRS "${VOTCA_BOOST_INCLUDE_DIR}" ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set VOTCA_BOOST_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(VOTCA_BOOST DEFAULT_MSG VOTCA_BOOST_LIBRARY VOTCA_BOOST_INCLUDE_DIR) mark_as_advanced(VOTCA_BOOST_INCLUDE_DIR VOTCA_BOOST_LIBRARY ) votca-csg-1.2.4/CMakeModules/FindBoost.cmake0000644000175000001440000012252512400714673020543 0ustar christophusers# - Try to find Boost include dirs and libraries # Usage of this module as follows: # # NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable below. # Due to Boost naming conventions and limitations in CMake this find # module is NOT future safe with respect to Boost version numbers, # and may break. # # == Using Header-Only libraries from within Boost: == # # find_package( Boost 1.36.0 ) # if(Boost_FOUND) # include_directories(${Boost_INCLUDE_DIRS}) # add_executable(foo foo.cc) # endif() # # # == Using actual libraries from within Boost: == # # set(Boost_USE_STATIC_LIBS ON) # set(Boost_USE_MULTITHREADED ON) # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... ) # # if(Boost_FOUND) # include_directories(${Boost_INCLUDE_DIRS}) # add_executable(foo foo.cc) # target_link_libraries(foo ${Boost_LIBRARIES}) # endif() # # # The components list needs to contain actual names of boost libraries only, # such as "date_time" for "libboost_date_time". If you're using parts of # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # # You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need # to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below). # # NOTE for Visual Studio Users: # Automatic linking is used on MSVC & Borland compilers by default when # #including things in Boost. It's important to note that setting # Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking, # should you need this feature. Automatic linking typically uses static # libraries with a few exceptions (Boost.Python is one). # # Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for # more details. Adding a TARGET_LINK_LIBRARIES() as shown in the example # above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS # gets set to OFF. It is suggested you avoid automatic linking since it # will make your application less portable. # # =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============ # # OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of # boost version numbers that should be taken into account when searching # for Boost. Unfortunately boost puts the version number into the # actual filename for the libraries, so this variable will certainly be needed # in the future when new Boost versions are released. # # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, # 1.40, 1.40.0, 1.41, 1.41.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories # omit the 3rd version number from include paths if it is 0 although not all # binary Boost releases do so. # SET(Boost_ADDITIONAL_VERSIONS "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42") # # ===================================== ============= ======================== # # Variables used by this module, they can change the default behaviour and # need to be set before calling find_package: # # Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded # boost libraries. If not specified, defaults # to ON. # # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static # boost libraries. Defaults to OFF. # # Other Variables used by this module which you may want to set. # # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching # the boost include directory. Please see # the documentation above regarding this # annoying, but necessary variable :( # # Boost_DEBUG Set this to TRUE to enable debugging output # of FindBoost.cmake if you are having problems. # Please enable this before filing any bug # reports. # # Boost_DETAILED_FAILURE_MSG FindBoost doesn't output detailed information # about why it failed or how to fix the problem # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] # # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation # # These last three variables are available also as environment variables: # # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for # Boost. Set this if the module has problems finding # the proper Boost installation. # # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation # # BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the # module has problems finding the proper Boost installation # # Variables defined by this module: # # Boost_FOUND System has Boost, this means the include dir was # found, as well as all the libraries specified in # the COMPONENTS list. # # Boost_INCLUDE_DIRS Boost include directories: not cached # # Boost_INCLUDE_DIR This is almost the same as above, but this one is # cached and may be modified by advanced users # # Boost_LIBRARIES Link to these to use the Boost libraries that you # specified: not cached # # Boost_LIBRARY_DIRS The path to where the Boost library files are. # # Boost_VERSION The version number of the boost libraries that # have been found, same as in version.hpp from Boost # # Boost_LIB_VERSION The version number in filename form as # it's appended to the library filenames # # Boost_MAJOR_VERSION major version number of boost # Boost_MINOR_VERSION minor version number of boost # Boost_SUBMINOR_VERSION subminor version number of boost # # Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call # add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) # to have diagnostic information about Boost's # automatic linking outputted during compilation time. # # For each component you specify in find_package(), the following (UPPER-CASE) # variables are set. You can use these variables if you would like to pick and # choose components for your targets instead of just using Boost_LIBRARIES. # # Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found. # # Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost # "component" (includes debug and optimized keywords # when needed). #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006-2008 Andreas Schneider # Copyright 2007 Wengo # Copyright 2007 Mike Jackson # Copyright 2008 Andreas Pakulat # Copyright 2008-2009 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) #------------------------------------------------------------------------------- # FindBoost functions & macros # ############################################ # # Check the existence of the libraries. # ############################################ # This macro was taken directly from the FindQt4.cmake file that is included # with the CMake distribution. This is NOT my work. All work was done by the # original authors of the FindQt4.cmake file. Only minor modifications were # made to remove references to Qt and make this file more generally applicable # And ELSE/ENDIF pairs were removed for readability. ######################################################################### MACRO (_Boost_ADJUST_LIB_VARS basename) IF (Boost_INCLUDE_DIR ) IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) # if the generator supports configuration types then set # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) ELSE() # if there are no configuration types and CMAKE_BUILD_TYPE has no value # then just use the release libraries SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) ENDIF() # FIXME: This probably should be set for both cases SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) ENDIF() # if only the release version was found, set the debug variable also to the release version IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) ENDIF() # if only the debug version was found, set the release variable also to the debug version IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) ENDIF() IF (Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") # Remove superfluous "debug" / "optimized" keywords from # Boost_LIBRARY_DIRS FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY}) GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH) LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) ENDFOREACH() LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory") SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") ENDIF(Boost_${basename}_LIBRARY) ENDIF (Boost_INCLUDE_DIR ) # Make variables changeble to the advanced user MARK_AS_ADVANCED( Boost_${basename}_LIBRARY Boost_${basename}_LIBRARY_RELEASE Boost_${basename}_LIBRARY_DEBUG ) ENDMACRO (_Boost_ADJUST_LIB_VARS) #------------------------------------------------------------------------------- # # Runs compiler with "-dumpversion" and parses major/minor # version with a regex. # FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE _boost_COMPILER_VERSION ) STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) ENDFUNCTION() # # A convenience function for marking desired components # as found or not # function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) foreach(COMPONENT ${Boost_FIND_COMPONENTS}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE) endforeach() endfunction() # # End functions/macros # #------------------------------------------------------------------------------- IF(NOT DEFINED Boost_USE_MULTITHREADED) SET(Boost_USE_MULTITHREADED TRUE) ENDIF() if(Boost_FIND_VERSION_EXACT) # The version may appear in a directory with or without the patch # level, even when the patch level is non-zero. set(_boost_TEST_VERSIONS "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}" "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") set(_boost_TEST_VERSIONS) if(Boost_FIND_VERSION) set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") # Select acceptable versions. foreach(version ${_Boost_KNOWN_VERSIONS}) if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}") # This version is high enough. list(APPEND _boost_TEST_VERSIONS "${version}") elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99") # This version is a short-form for the requested version with # the patch level dropped. list(APPEND _boost_TEST_VERSIONS "${version}") endif() endforeach(version) else(Boost_FIND_VERSION) # Any version is acceptable. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}") endif(Boost_FIND_VERSION) endif(Boost_FIND_VERSION_EXACT) # The reason that we failed to find Boost. This will be set to a # user-friendly message when we fail to find some necessary piece of # Boost. set(Boost_ERROR_REASON) SET( _boost_IN_CACHE TRUE) IF(Boost_INCLUDE_DIR) # On versions < 1.35, remove the System library from the considered list # since it wasn't added until 1.35. if(Boost_VERSION AND Boost_FIND_COMPONENTS) math(EXPR _boost_maj "${Boost_VERSION} / 100000") math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000") if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35) list(REMOVE_ITEM Boost_FIND_COMPONENTS system) endif() endif() FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) STRING(TOUPPER ${COMPONENT} COMPONENT) IF(NOT Boost_${COMPONENT}_FOUND) SET( _boost_IN_CACHE FALSE) ENDIF(NOT Boost_${COMPONENT}_FOUND) ENDFOREACH(COMPONENT) ELSE(Boost_INCLUDE_DIR) SET( _boost_IN_CACHE FALSE) ENDIF(Boost_INCLUDE_DIR) IF (_boost_IN_CACHE) # in cache already SET(Boost_FOUND TRUE) FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) STRING(TOUPPER ${COMPONENT} COMPONENT) _Boost_ADJUST_LIB_VARS( ${COMPONENT} ) SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY}) ENDFOREACH(COMPONENT) SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} " "is already in the cache. For debugging messages, please clear the cache.") endif() ELSE (_boost_IN_CACHE) # Need to search for boost if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost not in cache") # Output some of their choices message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") endif() IF(WIN32) # In windows, automatic linking is performed, so you do not have # to specify the libraries. If you are linking to a dynamic # runtime, then you can choose to link to either a static or a # dynamic Boost library, the default is to do a static link. You # can alter this for a specific library "whatever" by defining # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be # linked dynamically. Alternatively you can force all Boost # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. # This feature can be disabled for Boost library "whatever" by # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining # BOOST_ALL_NO_LIB. # If you want to observe which libraries are being linked against # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking # code to emit a #pragma message each time a library is selected # for linking. SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") ENDIF(WIN32) SET(_boost_INCLUDE_SEARCH_DIRS C:/boost/include C:/boost "$ENV{ProgramFiles}/boost/include" "$ENV{ProgramFiles}/boost" /sw/local/include ) # If BOOST_ROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOST_ROOT}) endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") # If BOOSTROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOSTROOT}) endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") # If BOOST_INCLUDEDIR was defined in the environment, use it. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR}) ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) # If BOOST_LIBRARYDIR was defined in the environment, use it. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR}) ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) IF( BOOST_ROOT ) file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT) ENDIF( BOOST_ROOT ) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Declared as CMake or Environmental Variables:") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " " BOOST_ROOT = ${BOOST_ROOT}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") endif() IF( BOOST_ROOT ) SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS}) ENDIF( BOOST_ROOT ) IF( BOOST_INCLUDEDIR ) file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) ENDIF( BOOST_INCLUDEDIR ) # ------------------------------------------------------------------------ # Search for Boost include DIR # ------------------------------------------------------------------------ # Try to find Boost by stepping backwards through the Boost versions # we know about. IF( NOT Boost_INCLUDE_DIR ) # Build a list of path suffixes for each version. SET(_boost_PATH_SUFFIXES) FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) # Add in a path suffix, based on the required version, ideally # we could read this from version.hpp, but for that to work we'd # need to know the include dir already set(_boost_BOOSTIFIED_VERSION) # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_BOOSTIFIED_VERSION ${_boost_VER}) ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+") STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_BOOSTIFIED_VERSION ${_boost_VER}) ENDIF() list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") if(WIN32) # For BoostPro's underscores (and others?) list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") endif() ENDFOREACH(_boost_VER) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Include debugging info:") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}") endif() # Look for a standard boost header file. FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp HINTS ${_boost_INCLUDE_SEARCH_DIRS} PATH_SUFFIXES ${_boost_PATH_SUFFIXES} ) ENDIF( NOT Boost_INCLUDE_DIR ) # ------------------------------------------------------------------------ # Extract version information from version.hpp # ------------------------------------------------------------------------ IF(Boost_INCLUDE_DIR) # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp # Read the whole file: # SET(BOOST_VERSION 0) SET(BOOST_LIB_VERSION "") FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") endif() STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") IF(NOT "${Boost_VERSION}" STREQUAL "0") MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") ENDIF(NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "version.hpp reveals boost " "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") endif() ELSE(Boost_INCLUDE_DIR) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") ENDIF(Boost_INCLUDE_DIR) # ------------------------------------------------------------------------ # Suffix initialization and compiler suffix detection. # ------------------------------------------------------------------------ # Setting some more suffixes for the library SET (Boost_LIB_PREFIX "") if ( WIN32 AND Boost_USE_STATIC_LIBS ) SET (Boost_LIB_PREFIX "lib") endif() if (Boost_COMPILER) set(_boost_COMPILER ${Boost_COMPILER}) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "using user-specified Boost_COMPILER = ${_boost_COMPILER}") endif() else(Boost_COMPILER) # Attempt to guess the compiler suffix # NOTE: this is not perfect yet, if you experience any issues # please report them and use the Boost_COMPILER variable # to work around the problems. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") if(WIN32) set (_boost_COMPILER "-iw") else() set (_boost_COMPILER "-il") endif() elseif (MSVC90) SET (_boost_COMPILER "-vc90") elseif (MSVC10) SET (_boost_COMPILER "-vc100") elseif (MSVC80) SET (_boost_COMPILER "-vc80") elseif (MSVC71) SET (_boost_COMPILER "-vc71") elseif (MSVC70) # Good luck! SET (_boost_COMPILER "-vc7") # yes, this is correct elseif (MSVC60) # Good luck! SET (_boost_COMPILER "-vc6") # yes, this is correct elseif (BORLAND) SET (_boost_COMPILER "-bcb") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro") set(_boost_COMPILER "-sw") elseif (MINGW) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") endif() elseif (UNIX) if (CMAKE_COMPILER_IS_GNUCXX) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) # Determine which version of GCC we have. IF(APPLE) IF(Boost_MINOR_VERSION) IF(${Boost_MINOR_VERSION} GREATER 35) # In Boost 1.36.0 and newer, the mangled compiler name used # on Mac OS X/Darwin is "xgcc". SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") ELSE(${Boost_MINOR_VERSION} GREATER 35) # In Boost <= 1.35.0, there is no mangled compiler name for # the Mac OS X/Darwin version of GCC. SET(_boost_COMPILER "") ENDIF(${Boost_MINOR_VERSION} GREATER 35) ELSE(Boost_MINOR_VERSION) # We don't know the Boost version, so assume it's # pre-1.36.0. SET(_boost_COMPILER "") ENDIF(Boost_MINOR_VERSION) ELSE() SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") ENDIF() endif() endif (CMAKE_COMPILER_IS_GNUCXX) endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "guessed _boost_COMPILER = ${_boost_COMPILER}") endif() endif(Boost_COMPILER) SET (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") endif() SET( _boost_STATIC_TAG "") set( _boost_ABI_TAG "") IF (WIN32) IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") SET (_boost_ABI_TAG "g") ENDIF() IF( Boost_USE_STATIC_LIBS ) SET( _boost_STATIC_TAG "-s") ENDIF( Boost_USE_STATIC_LIBS ) ENDIF(WIN32) SET (_boost_ABI_TAG "${_boost_ABI_TAG}d") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_STATIC_TAG = ${_boost_STATIC_TAG}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_ABI_TAG = ${_boost_ABI_TAG}") endif() # ------------------------------------------------------------------------ # Begin finding boost libraries # ------------------------------------------------------------------------ SET(_boost_LIBRARIES_SEARCH_DIRS ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib C:/boost/lib C:/boost "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib" "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib" "$ENV{ProgramFiles}/boost/lib" "$ENV{ProgramFiles}/boost" /sw/local/lib ) IF( BOOST_ROOT ) SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib ${_boost_LIBRARIES_SEARCH_DIRS}) ENDIF( BOOST_ROOT ) IF( BOOST_LIBRARYDIR ) file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) ENDIF( BOOST_LIBRARYDIR ) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}") endif() FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES IF( Boost_USE_STATIC_LIBS ) SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) IF(WIN32) SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) ELSE(WIN32) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) ENDIF(WIN32) ENDIF( Boost_USE_STATIC_LIBS ) FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT} HINTS ${_boost_LIBRARIES_SEARCH_DIRS} ) FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} HINTS ${_boost_LIBRARIES_SEARCH_DIRS} ) _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) IF( Boost_USE_STATIC_LIBS ) SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) ENDIF( Boost_USE_STATIC_LIBS ) ENDFOREACH(COMPONENT) # ------------------------------------------------------------------------ # End finding boost libraries # ------------------------------------------------------------------------ SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR} ) SET(Boost_FOUND FALSE) IF(Boost_INCLUDE_DIR) SET( Boost_FOUND TRUE ) # Check the version of Boost against the requested version. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34") endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) set( Boost_FOUND FALSE ) set(_Boost_VERSION_AGE "old") elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) set( Boost_FOUND FALSE ) set(_Boost_VERSION_AGE "old") elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" ) set( Boost_FOUND FALSE ) set(_Boost_VERSION_AGE "old") endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" ) endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) if (NOT Boost_FOUND) _Boost_MARK_COMPONENTS_FOUND(OFF) endif() if (Boost_FOUND AND Boost_FIND_VERSION_EXACT) # If the user requested an exact version of Boost, check # that. We already know that the Boost version we have is >= the # requested version. set(_Boost_VERSION_AGE "new") # If the user didn't specify a patchlevel, it's 0. if (NOT Boost_FIND_VERSION_PATCH) set(Boost_FIND_VERSION_PATCH 0) endif (NOT Boost_FIND_VERSION_PATCH) # We'll set Boost_FOUND true again if we have an exact version match. set(Boost_FOUND FALSE) _Boost_MARK_COMPONENTS_FOUND(OFF) if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) set( Boost_FOUND TRUE ) _Boost_MARK_COMPONENTS_FOUND(ON) endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT) if(NOT Boost_FOUND) # State that we found a version of Boost that is too new or too old. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") if (Boost_FIND_VERSION_PATCH) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") endif (Boost_FIND_VERSION_PATCH) if (NOT Boost_FIND_VERSION_EXACT) set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)") endif (NOT Boost_FIND_VERSION_EXACT) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") endif (NOT Boost_FOUND) # Always check for missing components set(_boost_CHECKED_COMPONENT FALSE) set(_Boost_MISSING_COMPONENTS "") foreach(COMPONENT ${Boost_FIND_COMPONENTS}) string(TOUPPER ${COMPONENT} COMPONENT) set(_boost_CHECKED_COMPONENT TRUE) if(NOT Boost_${COMPONENT}_FOUND) string(TOLOWER ${COMPONENT} COMPONENT) list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) set( Boost_FOUND FALSE) endif(NOT Boost_${COMPONENT}_FOUND) endforeach(COMPONENT) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") endif() if (_Boost_MISSING_COMPONENTS) # We were unable to find some libraries, so generate a sensible # error message that lists the libraries we were unable to find. set(Boost_ERROR_REASON "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n") foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) set(Boost_ERROR_REASON "${Boost_ERROR_REASON} boost_${COMPONENT}\n") endforeach(COMPONENT) list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) endif (_Boost_MISSING_COMPONENTS) IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) # Compatibility Code for backwards compatibility with CMake # 2.4's FindBoost module. # Look for the boost library path. # Note that the user may not have installed any libraries # so it is quite possible the Boost_LIBRARY_PATH may not exist. SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") IF("${_boost_LIB_DIR}" MATCHES "/include$") # Strip off the trailing "/include" in the path. GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) ENDIF("${_boost_LIB_DIR}" MATCHES "/include$") IF(EXISTS "${_boost_LIB_DIR}/lib") SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib) ELSE(EXISTS "${_boost_LIB_DIR}/lib") IF(EXISTS "${_boost_LIB_DIR}/stage/lib") SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib") SET(_boost_LIB_DIR "") ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib") ENDIF(EXISTS "${_boost_LIB_DIR}/lib") IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) ELSE(Boost_INCLUDE_DIR) SET( Boost_FOUND FALSE) ENDIF(Boost_INCLUDE_DIR) IF (Boost_FOUND) IF (NOT Boost_FIND_QUIETLY) MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") if(Boost_FIND_COMPONENTS) message(STATUS "Found the following Boost libraries:") endif() ENDIF(NOT Boost_FIND_QUIETLY) FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} ) STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT ) IF ( Boost_${UPPERCOMPONENT}_FOUND ) IF (NOT Boost_FIND_QUIETLY) MESSAGE (STATUS " ${COMPONENT}") ENDIF(NOT Boost_FIND_QUIETLY) SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) ENDIF ( Boost_${UPPERCOMPONENT}_FOUND ) ENDFOREACH(COMPONENT) else() if(Boost_FIND_REQUIRED) message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") else() if(NOT Boost_FIND_QUIETLY) # we opt not to automatically output Boost_ERROR_REASON here as # it could be quite lengthy and somewhat imposing in it's requests # Since Boost is not always a required dependency we'll leave this # up to the end-user. if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG) message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}") else() message(STATUS "Could NOT find Boost") endif() endif() endif(Boost_FIND_REQUIRED) endif() # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view MARK_AS_ADVANCED(Boost_INCLUDE_DIR Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS ) ENDIF(_boost_IN_CACHE) votca-csg-1.2.4/CMakeModules/FindGROMACS.cmake0000644000175000001440000001163512400714673020547 0ustar christophusers# - Finds parts of gromacs # Find the native gromacs compents headers and libraries. # # GROMACS_INCLUDE_DIRS - where to find gromacs headers. # GROMACS_LIBRARIES - List of libraries when used by gromacs. # GROMACS_FOUND - True if all gromacs componets were found. # GROMACS_DEFINITIONS - Extra definies needed by gromacs # GROMACS_PKG - The name of the pkg-config package needed # GROMACS_VERSION - Gromacs lib interface version # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) list(LENGTH GROMACS_FIND_COMPONENTS GROMACS_NUM_COMPONENTS_WANTED) if(${GROMACS_NUM_COMPONENTS_WANTED} LESS 1) message(FATAL_ERROR "No gromacs component to search given") elseif(${GROMACS_NUM_COMPONENTS_WANTED} GREATER 1) message(FATAL_ERROR "We only support finding one gromacs component at this point, go and implement it ;-)") elseif(${GROMACS_FIND_COMPONENTS} MATCHES "^lib(gmx|gromacs)(_d)?$") if(NOT GROMACS_PKG_OVERWRITE) set(GROMACS_PKG "${GROMACS_FIND_COMPONENTS}") else() set(GROMACS_PKG "${GROMACS_PKG_OVERWRITE}") endif() string(REGEX REPLACE "^lib(.*)" "\\1" GROMACS_LIBRARY_NAME "${GROMACS_PKG}") else() message(FATAL_ERROR "We do not support finding ${GROMACS_FIND_COMPONENTS}, go and implement it ;-)") endif() pkg_check_modules(PC_GROMACS ${GROMACS_PKG}) find_library(GROMACS_LIBRARY NAMES ${GROMACS_LIBRARY_NAME} HINTS ${PC_GROMACS_LIBRARY_DIRS} ) if (GROMACS_LIBRARY) include(CheckLibraryExists) check_library_exists("${GROMACS_LIBRARY}" GromacsVersion "" FOUND_GROMACS_VERSION) if(NOT FOUND_GROMACS_VERSION) message(FATAL_ERROR "Could not find GromacsVersion in ${GROMACS_LIBRARY}, take look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you don't have pkg-config installed you will most likely have to set GROMACS_LIBRARY by hand which sets the gromacs lib and it's dependencies (i.e. -DGROMACS_LIBRARY='/path/to/libgmx.so;/path/to/libblas.so;/path/to/libm.so')!") endif(NOT FOUND_GROMACS_VERSION) check_library_exists("${GROMACS_LIBRARY}" init_mtop "" FOUND_GROMACS_INIT_MTOP) if(NOT FOUND_GROMACS_INIT_MTOP) message(FATAL_ERROR "Could not find init_mtop in the gromacs library, take look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. This most likely means that your gromacs version is too old, we need at least gromacs 4.0.7.") endif(NOT FOUND_GROMACS_INIT_MTOP) set(GMX_VERSION 40) check_library_exists("${GROMACS_LIBRARY}" output_env_init "" FOUND_GROMACS_OUTPUT_ENV_INIT) if(FOUND_GROMACS_OUTPUT_ENV_INIT) set(GMX_VERSION 45) endif(FOUND_GROMACS_OUTPUT_ENV_INIT) check_library_exists("${GROMACS_LIBRARY}" init_domdec_vsites "" FOUND_GROMACS_INIT_DOMDEC_VSITES) if(FOUND_GROMACS_INIT_DOMDEC_VSITES) set(GMX_VERSION 50) endif(FOUND_GROMACS_INIT_DOMDEC_VSITES) set(GROMACS_VERSION ${GMX_VERSION}) #Only set GROMACS_DEFINITIONS if GROMACS_LIBRARY was found if ("${GROMACS_LIBRARY}" MATCHES "lib[^/]*_d\\.[^.]*$") list(APPEND GMX_DEFS "-DGMX_DOUBLE") endif ("${GROMACS_LIBRARY}" MATCHES "lib[^/]*_d\\.[^.]*$") if (PC_GROMACS_CFLAGS_OTHER) foreach(DEF ${PC_GROMACS_CFLAGS_OTHER}) if (${DEF} MATCHES "^-D") list(APPEND GMX_DEFS ${DEF}) endif (${DEF} MATCHES "^-D") endforeach(DEF) list(REMOVE_DUPLICATES GMX_DEFS) endif (PC_GROMACS_CFLAGS_OTHER) set(GROMACS_DEFINITIONS "${GMX_DEFS}") else(GROMACS_LIBRARY) set(GMX_VERSION 45) endif (GROMACS_LIBRARY) if ("${GROMACS_PKG}" MATCHES "libgmx") if (${GMX_VERSION} EQUAL 40) find_path(GROMACS_INCLUDE_DIR tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) else(${GMX_VERSION} EQUAL 40) find_path(GROMACS_INCLUDE_DIR gromacs/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) endif(${GMX_VERSION} EQUAL 40) elseif("${GROMACS_PKG}" MATCHES "libgromacs") find_path(GROMACS_INCLUDE_DIR gromacs/fileio/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) endif("${GROMACS_PKG}" MATCHES "libgmx") set(GROMACS_LIBRARIES "${GROMACS_LIBRARY}" ) set(GROMACS_INCLUDE_DIRS ${GROMACS_INCLUDE_DIR} ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set GROMACS_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(GROMACS DEFAULT_MSG GROMACS_LIBRARY GROMACS_INCLUDE_DIR) mark_as_advanced(GROMACS_INCLUDE_DIR GROMACS_LIBRARY GROMACS_PKG) votca-csg-1.2.4/CMakeModules/FindVOTCA_TOOLS.cmake0000644000175000001440000000631512400714673021307 0ustar christophusers# - Find libvotca_tools # Find the native libvotca_tools headers and libraries. # # VOTCA_TOOLS_INCLUDE_DIRS - where to find votca/tools/version.h, etc. # VOTCA_TOOLS_LIBRARIES - List of libraries when using expat. # VOTCA_TOOLS_FOUND - True if expat found. # VOTCA_TOOLS_HAS_SQLITE3 - True if votca tools was build with sqlite3 support # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) pkg_check_modules(PC_VOTCA_TOOLS libvotca_tools) find_path(VOTCA_TOOLS_INCLUDE_DIR votca/tools/version.h HINTS ${PC_VOTCA_TOOLS_INCLUDE_DIRS}) find_path(VOTCA_TOOLS_HAS_SQLITE3 votca/tools/database.h HINTS ${PC_VOTCA_TOOLS_INCLUDE_DIRS}) find_library(VOTCA_TOOLS_LIBRARY NAMES votca_tools HINTS ${PC_VOTCA_TOOLS_LIBRARY_DIRS} ) if("${VOTCA_TOOLS_LIBRARY}" MATCHES "libvotca_tools[^;]*\\.a") if(PC_VOTCA_TOOLS_LIBRARIES) list(REMOVE_ITEM PC_VOTCA_TOOLS_LIBRARIES votca_tools) foreach (LIB ${PC_VOTCA_TOOLS_LIBRARIES}) find_library(VOTCA_TOOLS_${LIB} NAMES ${LIB} HINTS ${PC_VOTCA_TOOLS_LIBRARY_DIRS} ) list(APPEND VT_DEP_LIBRARIES ${VOTCA_TOOLS_${LIB}}) unset(VOTCA_TOOLS_${LIB} CACHE) endforeach(LIB) endif(PC_VOTCA_TOOLS_LIBRARIES) set(VOTCA_TOOLS_DEP_LIBRARIES "${VT_DEP_LIBRARIES}" CACHE FILEPATH "votca tools depency libs (only needed for static (.a) libvotca_tools") endif("${VOTCA_TOOLS_LIBRARY}" MATCHES "libvotca_tools[^;]*\\.a") set(VOTCA_TOOLS_LIBRARIES "${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}" ) set(VOTCA_TOOLS_INCLUDE_DIRS "${VOTCA_TOOLS_INCLUDE_DIR}" ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set VOTCA_TOOLS_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(VOTCA_TOOLS DEFAULT_MSG VOTCA_TOOLS_LIBRARY VOTCA_TOOLS_INCLUDE_DIR ) if (VOTCA_TOOLS_FOUND) include(CheckLibraryExists) check_library_exists("${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}" VotcaToolsFromC "" FOUND_VOTCA_TOOLS_VERSION) if(NOT FOUND_VOTCA_TOOLS_VERSION) message(FATAL_ERROR "Could not find VotcaToolsFromC in ${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}, take look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you don't have pkg-config installed you will most likely have to set VOTCA_TOOLS_LIBRARY and VOTCA_TOOLS_DEP_LIBRARIES by hand, which set votca_tools lib it's depencies (i.e. -DVOTCA_TOOLS_LIBRARY='/path/to/libvotca_tools.so' -DVOTCA_TOOLS_DEP_LIBRARIES='/path/to/libgsl.so;/path/to/libm.so') !") endif(NOT FOUND_VOTCA_TOOLS_VERSION) endif (VOTCA_TOOLS_FOUND) mark_as_advanced(VOTCA_TOOLS_INCLUDE_DIR VOTCA_TOOLS_LIBRARY ) votca-csg-1.2.4/include/0000755000175000001440000000000012400714673014755 5ustar christophusersvotca-csg-1.2.4/include/votca/0000755000175000001440000000000012400714673016071 5ustar christophusersvotca-csg-1.2.4/include/votca/csg/0000755000175000001440000000000012400714673016645 5ustar christophusersvotca-csg-1.2.4/include/votca/csg/nematicorder.h0000644000175000001440000000240112400714673021467 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _NEMATICORDER_H #define _NEMATICORDER_H #include "topology.h" #include "topology.h" #include namespace votca { namespace csg { using namespace votca::tools; class NematicOrder { public: NematicOrder() {} ~NematicOrder() {} void Process(Topology &top, const string &filter = "*"); matrix::eigensystem_t &NematicU() {return _nemat_u; } matrix::eigensystem_t &NematicV() {return _nemat_v; } matrix::eigensystem_t &NematicW() {return _nemat_w; } private: matrix _mu,_mv,_mw; matrix::eigensystem_t _nemat_u, _nemat_v, _nemat_w; }; }} #endif /* _NEMATICORDER_H */ votca-csg-1.2.4/include/votca/csg/topologyreader.h0000644000175000001440000000247412400714673022064 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _TOPOLOGYREADER_H #define _TOPOLOGYREADER_H #include #include "topology.h" #include "fileformatfactory.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; class TopologyReader { public: virtual ~TopologyReader() {} /// open a trejectory file virtual bool ReadTopology(string file, Topology &top) = 0; static void RegisterPlugins(void); }; // important - singleton pattern, make sure factory is created before accessed inline FileFormatFactory &TopReaderFactory() { static FileFormatFactory _TopReaderFactory; return _TopReaderFactory; } }} #endif /* _TOPOLOGYREADER_H */ votca-csg-1.2.4/include/votca/csg/boundarycondition.h0000644000175000001440000000325412400714673022554 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_BOUNDARYCONDITION_H #define __VOTCA_BOUNDARYCONDITION_H #include namespace votca { namespace csg { using namespace std; using namespace votca::tools; class BoundaryCondition { public: /** * set the simulation box * \param box triclinic box matrix */ void setBox(const matrix &box) { _box = box; }; /** * get the simulation box * \return triclinic box matrix */ const matrix &getBox() { return _box; }; /** * get the volume of the box * \return box volume as double */ virtual double BoxVolume(); /** * get shortest connection vector between r_i and r_j with respect to the (periodic) box * \return shortest distance vector */ virtual vec BCShortestConnection(const vec &r_i, const vec &r_j) const = 0; enum eBoxtype { typeAuto = 0, typeTriclinic, typeOrthorhombic, typeOpen }; virtual eBoxtype getBoxType() = 0; protected: matrix _box; }; }} #endif /* BOUNDARYCONDITION_H */ votca-csg-1.2.4/include/votca/csg/triclinicbox.h0000644000175000001440000000204612400714673021511 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TRICLINICBOX_H #define __VOTCA_TRICLINICBOX_H #include "boundarycondition.h" namespace votca { namespace csg { using namespace std; using namespace votca::tools; class TriclinicBox : public BoundaryCondition { public: vec BCShortestConnection(const vec &r_i, const vec &r_j) const; eBoxtype getBoxType() { return typeTriclinic; } protected: }; }} #endif /* TRICLINICBOX_H */ votca-csg-1.2.4/include/votca/csg/molecule.h0000644000175000001440000000572612400714673020635 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _MOLECULE_H #define _MOLECULE_H #include #include #include #include #include "topologyitem.h" #include "bead.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; class Interaction; /** \brief information about molecules The Molecule class stores which beads belong to a molecule. The organization of beads into molecules is needed for the CG mapping. \todo sort atoms in molecule */ class Molecule : public TopologyItem { public: /// get the molecule ID int getId() const { return _id; } /// get the name of the molecule const string &getName() const { return _name; } /// set the name of the molecule void setName(const string &name) { _name=name; } /// Add a bead to the molecule void AddBead(Bead *bead, const string &name); /// get the id of a bead in the molecule Bead *getBead(int bead) { return _beads[bead]; } int getBeadId(int bead) { return _beads[bead]->getId(); } int getBeadIdByName(const string &name); /// get the number of beads in the molecule int BeadCount() const { return _beads.size(); } /// find a bead by it's name int getBeadByName(const string &name); string getBeadName(int bead) {return _bead_names[bead]; } /// Add an interaction to the molecule void AddInteraction(Interaction *ic) { _interactions.push_back(ic); } vector Interactions() { return _interactions; } template void setUserData(T *userdata) { _userdata = (void*)userdata; } template T *getUserData() { return (T *)_userdata; } private: // maps a name to a bead id map _beadmap; vector _interactions; // id of the molecules int _id; // name of the molecule string _name; // the beads in the molecule vector _beads; vector _bead_names; void *_userdata; /// constructor Molecule(Topology *parent, int id, string name) : TopologyItem(parent), _id(id), _name(name) {} friend class Topology; }; inline int Molecule::getBeadIdByName(const string &name) { int i = getBeadByName(name); if(i<0) return i; return _beads[i]->getId(); } }} #endif /* _Molecule_H */ votca-csg-1.2.4/include/votca/csg/map.h0000644000175000001440000000556712400714673017610 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _map_H #define _map_H #include #include #include #include #include "molecule.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; class BeadMap; /******************************************************* Mapper class, collection of maps *******************************************************/ class Map { public: Map(Molecule &in, Molecule &out) : _in(in), _out(out) {} ~Map(); void AddBeadMap(BeadMap *bmap) { _maps.push_back(bmap); } void Apply(); protected: Molecule _in, _out; vector _maps; }; /******************************************************* Interface for all maps *******************************************************/ class BeadMap { public: virtual ~BeadMap() {}; virtual void Apply() = 0; virtual void Initialize(Molecule *in, Bead *out, Property *opts_map, Property *opts_bead); protected: Molecule *_in; Bead *_out; Property *_opts_map; Property *_opts_bead; }; inline void BeadMap::Initialize(Molecule *in, Bead *out, Property *opts_bead, Property *opts_map) { _in = in; _out = out; _opts_map = opts_map; _opts_bead = opts_bead; } /******************************************************* Linear map for spherical beads *******************************************************/ class Map_Sphere : public BeadMap { public: Map_Sphere() {} void Apply(); void Initialize(Molecule *in, Bead *out, Property *opts_bead, Property *opts_map); protected: void AddElem(Bead *in, double weight, double force_weight); struct element_t { Bead *_in; double _weight; double _force_weight; }; vector _matrix; }; inline void Map_Sphere::AddElem(Bead *in, double weight, double force_weight) { element_t el; el._in = in; el._weight = weight; el._force_weight = force_weight; _matrix.push_back(el); } /******************************************************* Linear map for ellipsoidal bead *******************************************************/ class Map_Ellipsoid : public Map_Sphere { public: Map_Ellipsoid() { } void Apply(); protected: }; }} #endif /* _map_H */ votca-csg-1.2.4/include/votca/csg/cgobserver.h0000644000175000001440000000275512400714673021170 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _CGOBSERVER_H #define _CGOBSERVER_H #include "topology.h" namespace votca { namespace csg { using namespace votca::tools; /** \brief Observer class for analysis hook Each application which performs analysis operations should use CGEngine. It offers a hook (callback class) during the coarse-graining process to evaluate each frame. The user does not have to take care about mapping and other stoff. Just oberload this class and analyze properties of interest. */ class CGObserver { public: /// \brief called before the first frame virtual void BeginCG(Topology *top, Topology *top_atom = 0) = 0; /// \brief called after the last frame virtual void EndCG() = 0; // \brief called for each frame which is mapped virtual void EvalConfiguration(Topology *top, Topology *top_atom = 0) = 0; }; }} #endif /* _CGOBSERVER_H */ votca-csg-1.2.4/include/votca/csg/trajectorywriter.h0000644000175000001440000000261612400714673022446 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _trajectorywriter_H #define _trajectorywriter_H #include #include "fileformatfactory.h" #include "topology.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; class TrajectoryWriter { public: TrajectoryWriter() {} virtual ~TrajectoryWriter() {} virtual void Open(string file, bool bAppend = false) {} virtual void Close() {}; virtual void Write(Topology *top) {} static void RegisterPlugins(void); }; // important - singleton pattern, make sure factory is created before accessed inline FileFormatFactory &TrjWriterFactory() { static FileFormatFactory _TrjWriterFactory; return _TrjWriterFactory; } }} #endif /* _trajectorywriter_H */ votca-csg-1.2.4/include/votca/csg/version.h0000644000175000001440000000472412400714673020512 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** \mainpage VOTCA C++ reference \section intro_sec Introduction This page is the C++ code documentation of the VOTCA package (http://www.votca.org). The main target of VOTCA is the implementation of systematic coarse-graining techniques. However, it offers a powerful, object-oriented framework to develop analysis tools for particle based molecular simulations. \section started_sec Getting started To start developing custom analysis tools, a good place to start is the csgapps repository: http://code.google.com/p/votca/source/browse/?repo=csgapps It contains several small analysis tools which were implemented based upon the VOTCA framework. We highly recomment to use an IDE such as Netbeans for development since it offers lots of guides to get started with new code (code completion, code documentation popups, navigation thourh code, ...). The main container for the whole structure is the Topology, so it is a good advise to get comfortable with this class. Also the standard applications in csg/src/tools might help. \section beginner_sec For beginners: how to avoid frustration For those not familiar with object oriented code: don't try to dig into every single function in order to understand what exactly is going on. This strategy only works for very small projects and is not intended for oject oriented programs. Think about the code in layers of abstraction! Your main focus should be on the global structure and understand how objects relate to each other. The code was designed that you don't have to redo and understand all the nasty details! */ #ifndef _csg_version_H #define _csg_version_H #include namespace votca { namespace csg { const std::string & CsgVersionStr(); void HelpTextHeader(const std::string &tool_name); }} #endif /* _tools_version_H */ votca-csg-1.2.4/include/votca/csg/CMakeLists.txt0000644000175000001440000000014312400714673021403 0ustar christophusersfile(GLOB_RECURSE VOTCA_HEADERS *.h) install(FILES ${VOTCA_HEADERS} DESTINATION include/votca/csg) votca-csg-1.2.4/include/votca/csg/orthorhombicbox.h0000644000175000001440000000206512400714673022231 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_ORTHORHOMBICBOX_H #define __VOTCA_ORTHORHOMBICBOX_H #include "boundarycondition.h" namespace votca { namespace csg { using namespace std; using namespace votca::tools; class OrthorhombicBox : public BoundaryCondition { public: vec BCShortestConnection(const vec &r_i, const vec &r_j) const; eBoxtype getBoxType() { return typeOrthorhombic; } protected: }; }} #endif /* ORTHORHOMBICBOX_H */ votca-csg-1.2.4/include/votca/csg/residue.h0000644000175000001440000000303012400714673020452 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _residue_H #define _residue_H #include #include "topologyitem.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief class for a residue The Residue class describes a residue. When reading in the atoms, all beads belong to a residue. Later on, the molecules can be organized into molecules based on their residue. */ class Residue : public TopologyItem { public: /// get the name of the residue const string &getName(); /// get the name of the residue const int &getId() const { return _id; } private: int _id; string _name; private: /// constructor Residue(Topology *parent, int id, const string &name) : TopologyItem(parent), _id(id), _name(name) {} friend class Topology; }; inline const string &Residue::getName() { return _name; } }} #endif /* _residue_H */ votca-csg-1.2.4/include/votca/csg/exclusionlist.h0000644000175000001440000000404312400714673021724 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _exclusionlist_H #define _exclusionlist_H #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; /// \todo fill _excl_by_bead /// \todo no ids but pointers, use PairList class Topology; class ExclusionList { public: ExclusionList() {} ~ExclusionList() { Clear(); } void Clear(void); void ExcludeAll(int N); void Remove(list l); void ExcludeList(list l); struct exclusion_t { int _atom; list _exclude; }; void CreateExclusions(Topology *top); exclusion_t *GetExclusions(int bead); typedef list< exclusion_t * >::iterator iterator; iterator begin() { return _exclusions.begin(); } iterator end() { return _exclusions.end(); } bool IsExcluded(int bead1, int bead2); void InsertExclusion(int index, list l); private: list< exclusion_t * > _exclusions; map _excl_by_bead; friend std::ostream &operator<<(std::ostream &out, ExclusionList& exl); }; inline ExclusionList::exclusion_t * ExclusionList::GetExclusions(int bead) { map::iterator iter = _excl_by_bead.find(bead); if(iter == _excl_by_bead.end()) return NULL; return (*iter).second; } std::ostream &operator<<(std::ostream &out,ExclusionList& ex); }} #endif /* _exclusionlist_H */ votca-csg-1.2.4/include/votca/csg/topology.h0000644000175000001440000002444512400714673020703 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _topology_H #define _topology_H #include #include #include #include #include #include #include #include "exclusionlist.h" #include "bead.h" #include "molecule.h" #include "residue.h" #include "beadtype.h" #include "boundarycondition.h" #include "triclinicbox.h" #include "orthorhombicbox.h" #include "openbox.h" namespace votca { namespace csg { using namespace votca::tools; class Interaction; class ExclusionList; typedef vector MoleculeContainer; typedef vector BeadContainer; typedef vector BeadTypeContainer; typedef vector ResidueContainer; typedef vector InteractionContainer; using namespace std; /** \brief topology of the whole system The Topology class stores the topology of the system like the beads, bonds, molecules and residues. \todo internal management for ids and indices **/ class Topology { public: /// constructor Topology() { _bc = new OpenBox(); } virtual ~Topology(); /** * \brief cleans up all the stored data */ virtual void Cleanup(); /** * \brief creates a new Bead * * \param symmetry symmetry of the bead, 1: spherical 3: ellipsoidal * \param name name of the bead * \param type bead type * \param resnr residue number * \param m mass * \param q charge * \return pointer to created bead * * The function creates a new bead and adds it to the list of beads. */ virtual Bead *CreateBead(byte_t symmetry, string name, BeadType *type, int resnr, double m, double q); /** * \brief get bead type or create it * \param name typename * \return pointer to bead type * * Returns an existing bead type or creates one if it doesn't exist yet */ virtual BeadType *GetOrCreateBeadType(string name); /** * \brief creates a new molecule * \param name name of the molecule * \return pointer to created molecule */ virtual Molecule *CreateMolecule(string name); /** * \brief checks weather molecules with the same name really contain the same number of beads */ void CheckMoleculeNaming(void); /** * \brief create a new resiude * @param name residue name * @return created residue */ virtual Residue *CreateResidue(string name); /** * \brief create molecules based on the residue * * This function scans the topology and creates molecules based on the resiude id. * All beads with the same resid are put int one molecule. */ void CreateMoleculesByResidue(); /** * \brief put the whole topology in one molecule * \param name name of the new molecule * * This function creates one big molecule for all beads in the topology. */ void CreateOneBigMolecule(string name); /** * \brief create molecules based on blocks of atoms * \param name molecule name * \param first first bead * \param nbeads number of beads per molecule * \param nmolecules number of molecules */ void CreateMoleculesByRange(string name, int first, int nbeads, int nmolecules); /** * \brief number of molecules in the system * @return number of molecule in topology */ int MoleculeCount() { return _molecules.size(); } /** * number of beads in the system * @return number of beads in the system */ int BeadCount() { return _beads.size(); } /** * number of residues in the system * \return number of residues */ int ResidueCount() { return _residues.size(); } /** * get molecule by index * @param index molecule number * @return pointer to molecule */ Molecule *MoleculeByIndex(int index); /** * access containter with all beads * @return bead container */ BeadContainer &Beads() { return _beads; } /** * access containter with all molecules * @return molecule container */ MoleculeContainer &Molecules() { return _molecules; } /** * access containter with all bonded interactions * @return bonded interaction container */ InteractionContainer &BondedInteractions() { return _interactions; } void AddBondedInteraction(Interaction *ic); std::list InteractionsInGroup(const string &group); BeadType *getBeadType(const int i) const { return _beadtypes[i]; } Bead *getBead(const int i) const { return _beads[i]; } Residue *getResidue(const int i) const { return _residues[i]; } Molecule *getMolecule(const int i) const { return _molecules[i]; } /** * delete all molecule information */ void ClearMoleculeList(){ _molecules.clear(); } /** * \brief adds all the beads+molecules+residues from other topology * \param top topology to add */ void Add(Topology *top); /** * \brief copy topology data of different topology * \param top topology to copy from */ void CopyTopologyData(Topology *top); /** * \brief rename all the molecules in range * \param range range string of type 1:2:10 = 1, 3, 5, 7, ... * \param name new name of molecule * range is a string which is parsed by RangeParser, */ void RenameMolecules(string range, string name); /** * set the simulation box * \param box triclinic box matrix */ void setBox(const matrix &box, BoundaryCondition::eBoxtype boxtype=BoundaryCondition::typeAuto) { // determine box type automatically in case boxtype==typeAuto if(boxtype==BoundaryCondition::typeAuto) { boxtype = autoDetectBoxType(box); } if(_bc) { delete (_bc); } switch(boxtype) { case BoundaryCondition::typeTriclinic: _bc = new TriclinicBox(); break; case BoundaryCondition::typeOrthorhombic: _bc = new OrthorhombicBox(); break; default: _bc = new OpenBox(); break; } _bc->setBox(box); }; /** * get the simulation box * \return triclinic box matrix */ const matrix &getBox() { return _bc->getBox(); }; /** * set the time of current frame * \param t simulation time in ns */ void setTime(double t) { _time = t; }; /** * get the time of current frame * \return simulation time in ns */ double getTime() { return _time; }; /** * set the step number of current frame * \param s step number */ void setStep(int s) { _step = s; }; /** * get the step number of current frame * \return step number */ int getStep() { return _step; }; /** * \brief pbc correct distance of two beads * \param bead1 index of first bead * \param bead2 index of second bead * \return distance vector * * calculates the smallest distance between two beads with correct treatment * of pbc */ vec getDist(int bead1, int bead2) const; /** * \brief calculate shortest vector connecting two points * \param r1 first point * \param r2 second point * \return distance vector * * calculates the smallest distance between two points with correct treatment * of pbc */ vec BCShortestConnection(const vec &r1, const vec &r2) const; /** * \brief return the shortest box size * \return shortest size * * Calculates the shortest length to connect two sides of the box */ double ShortestBoxSize(); /** * calculates the box volume * \return box volume */ double BoxVolume(); /** * rebuild exclusion list */ void RebuildExclusions(); /** * access exclusion list * \return exclusion list */ ExclusionList &getExclusions() { return _exclusions; } BoundaryCondition::eBoxtype getBoxType() { return _bc->getBoxType(); } void InsertExclusion(int i, list l); protected: BoundaryCondition *_bc; BoundaryCondition::eBoxtype autoDetectBoxType(const matrix &box); /// bead types in the topology BeadTypeContainer _beadtypes; /// beads in the topology BeadContainer _beads; /// molecules in the topology MoleculeContainer _molecules; /// residues in the topology ResidueContainer _residues; /// bonded interactions in the topology InteractionContainer _interactions; ExclusionList _exclusions; map _interaction_groups; map _beadtype_map; map > _interactions_by_group; double _time; int _step; }; inline Bead *Topology::CreateBead(byte_t symmetry, string name, BeadType *type, int resnr, double m, double q) { Bead *b = new Bead(this, _beads.size(), type, symmetry, name, resnr, m, q); _beads.push_back(b); return b; } inline Molecule *Topology::CreateMolecule(string name) { Molecule *mol = new Molecule(this, _molecules.size(), name); _molecules.push_back(mol); return mol; } inline Residue *Topology::CreateResidue(string name) { Residue *res = new Residue(this, _molecules.size(), name); _residues.push_back(res); return res; } inline Molecule *Topology::MoleculeByIndex(int index) { return _molecules[index]; } inline void Topology::InsertExclusion(int i, list l) { _exclusions.InsertExclusion(i,l); } }} #include "interaction.h" #endif /* _topology_H */ votca-csg-1.2.4/include/votca/csg/fileformatfactory.h0000644000175000001440000000267112400714673022544 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _FILEFORMATFACTORY_H #define _FILEFORMATFACTORY_H #include #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; template class FileFormatFactory : public ObjectFactory { public: FileFormatFactory() {} T *Create(const string &file); }; template T *FileFormatFactory::Create(const string &file) { string filetype = ""; Tokenizer tok(file, "."); for(Tokenizer::iterator iter=tok.begin();iter!=tok.end();iter++) filetype = *iter; try { return ObjectFactory::Create(filetype); } catch(std::exception &error) {} return NULL; } }} #endif /* _FILEFORMATFACTORY_H */ votca-csg-1.2.4/include/votca/csg/bead.h0000644000175000001440000002575012400714673017722 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _bead_H #define _bead_H #include #include #include #include #include #include "beadtype.h" #include "topologyitem.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; class Molecule; /** \brief information about a bead The Bead class describes an atom or a coarse grained bead. It stores information like the id, the name, the mass, the charge and the residue it belongs to. The coordinates are stored in the configuration class. \todo change resnr to pointer \todo make sure bead belongs to topology */ class Bead : public TopologyItem { public: /** * destructor */ virtual ~Bead() {} /** * get the id of the bead * * \return bead id */ const int &getId() const { return _id; } /** * get bead name * \return bead name */ const string &getName() const { return _name; } /** * get the bead type * \return bead type object */ const BeadType *getType() const { return _type; } /** * get the residu number of the bead * \return residue id */ const int &getResnr() const { return _resnr; } /** * get the mass of the bead * \return bead mass */ const double &getM() const { return _m; } /** * get the charge of the bead * \return bead charge */ const double &getQ() const { return _q; } /** * set the mass of the bead * \param m bead mass */ void setM(const double &m) { _m=m; } /** * set the charge of the bead * \param q bead charge */ void setQ(const double &q) { _q=q; } /** * \brief get the symmetry of the bead * * Returns the number of unique axis of the bead, it can be * 1 for a spherical bead * 3 for an ellipsoidal bead * 2 (currently not used), could be disk like particle * * \return bead symmetry */ byte_t getSymmetry() const { return _symmetry; } /** * set the position of the bead * \param r bead position */ void setPos(const vec &r); /** * get the position of the bead * \return bead position */ const vec &getPos() const; /** * set the velocity of the bead * @param r bead velocity */ void setVel(const vec &r); /** * get the velocity of the bead * \return bead velocity */ const vec &getVel() const; /** * \brief set first orientation (normal vector) vector of bead * * see getU for details * * @param u bead orientation u */ void setU(const vec &u); /** * \brief get first orientation (normal vector) vector of bead * * Non-spherical beads (symmetry 3) have a internal coordinates system and the * axes are denoted as u, v and w. Currently the non-spherical mapping is hardcoded and * the axis u is calculated by the eigenvector with the lowest eigenvector of * the mapped beads and has the meaning of a normal vector if the reference beads * have a disc like shape. The sign of the normal vector is determined in combination * with the vectors v and w to build up a right handed (??) coordinate system. * * \return bead orientation u */ const vec &getU() const; /** * \brief set second orientation vector of bead * * see getV for details * * @param v bead orientation v */ void setV(const vec &v); /** * \brief get second orientation vector of bead * * Non-spherical beads (symmetry 3) have a internal coordinates system and the * axes are denoted as u, v and w. Currently the non-spherical mapping is hardcoded and * the axis v is the vector which connects first and second reference atom * in the mapping (only orthogonal component to u). * * \return bead orientation u */ const vec &getV() const; /** * \brief set third orientation vector of bead * * see getW for details * * @param w bead orientation w */ void setW(const vec &w); /** * \brief get third orientation vector of bead * * Non-spherical beads (symmetry 3) have a internal coordinates system and the * axes are denoted as u, v and w. Currently the non-spherical mapping is hardcoded and * the axis w is orthogonal to u and v. * * \return bead orientation w */ const vec &getW() const; /** * direct access (read/write) to the position of the bead * \return reference to position */ vec &Pos() { return _pos; } /** * direct access (read/write) to the velocity of the bead * \return reference to velocity */ vec &Vel() { return _vel; } /** * direct access (read/write) to orientation u of the bead * \return reference to u */ vec &U() { return _u; } /** * direct access (read/write) to the orientation v of the bead * \return reference to v */ vec &V() { return _v; } /** * direct access (read/write) to the orientation w of the bead * \return reference to w */ vec &W() { return _w; } /** * direct access (read/write) to the force of the bead * \return reference to force */ vec &F() { return _f; } /** * set force acting on bead * @param F force */ void setF(const vec &F); /** * \brief get the force acting on the bead * * Forces have to be provided by the trajectory. If beads are mapped, forces * of coarse-grained beads are also calculated. * * \return force on bead */ const vec &getF() const; /** does this configuration store positions? */ bool HasPos() {return _bPos; } /** does this configuration store velocities? */ bool HasVel() {return _bVel; } /** does this configuration store forces? */ bool HasF() {return _bF; } /** does this configuration store u-orientations? */ bool HasU() {return _bU; } /** does this configuration store v-orientations? */ bool HasV() {return _bV; } /** does this configuration store w-orientations? */ bool HasW() {return _bW; } /** dos the bead store a position */ void HasPos(bool b); /** dos the bead store a velocity */ void HasVel(bool b); /** dos the bead store a force */ void HasF(bool b); /** doe the bead store an orientation u */ void HasU(bool b); /** doe the bead store an orientation v */ void HasV(bool b); /** doe the bead store an orientation w */ void HasW(bool b); /** * molecule the bead belongs to * \return Molecule object */ Molecule *getMolecule() { return _mol; } /** * If it is a mapped beads, returns te bead id the cg bead was created from * \return vector of bead ids of reference atoms */ vector &ParentBeads() { return _parent_beads; }; /** * \brief Function to add arbitrary user data to bead * * The user can attach pointers to own created objects to beads. Currently * the user has to take care about deletion of the objects at the end. * * \todo change this to shared_pointer * * \param userdata userdata */ template void setUserData(T *userdata) { _userdata = (void*)userdata; } /** * get userdata attached to bead * @return pointer to userdata */ template T *getUserData() { return (T *)_userdata; } /** * \brief Additional options of bead * * The options object stores additional options which can be attached to * the bead. For mapped beads, it contains all the values which were specified * in the xml mapping file. This allows to at user defined options to the xml * which are automatically read in on creation of the coare-grained bead. * * \return Property object containing options */ Property &Options() { return *_options; } /** * update pointer to options object of bead * \param options pointer to options object of bead */ void setOptions(Property &options) { _options = &options; } protected: int _id; vector _parent_beads; BeadType *_type; Molecule *_mol; // TODO: this is so far a pointer. this should change! each bead should have own options. Property *_options; byte_t _symmetry; string _name; int _resnr; double _m; double _q; vec _pos, _vel, _f, _u, _v, _w, _eigenvec1, _eigenvec2,_eigenvec3; double _val1,_val2,_val3; bool _bPos; bool _bVel; bool _bU; bool _bV; bool _bW; bool _bF; bool _b1,_b2,_b3; /// constructur Bead(Topology *owner, int id, BeadType *type, byte_t symmetry, string name, int resnr, double m, double q) : TopologyItem(owner), _id(id), _type(type), _symmetry(symmetry), _name(name), _resnr(resnr), _m(m), _q(q) {_bPos=false; _bVel=false; _bU=false; _bV=false; _bW=false; _bF=false; _b1=false; _b2=false; _b3=false;} void *_userdata; friend class Topology; friend class Molecule; }; inline void Bead::setPos(const vec &r) { _bPos=true; _pos = r; } inline const vec &Bead::getPos() const { assert(_bPos); return _pos; } inline void Bead::setVel(const vec &r) { _bVel=true; _vel = r; } inline const vec &Bead::getVel() const { assert(_bVel); return _vel; } inline void Bead::setU(const vec &u) { _bU=true; _u = u; } inline const vec &Bead::getU() const { assert(_bU); return _u; } inline void Bead::setV(const vec &v) { _bV=true; _v = v; } inline const vec &Bead::getV() const { assert(_bV); return _v; } inline void Bead::setW(const vec &w) { _bW=true; _w = w; } inline const vec &Bead::getW() const { assert(_bW); return _w; } inline void Bead::setF(const vec &F) { _bF=true; _f = F; } inline const vec &Bead::getF() const { assert(_bF); return _f; } inline void Bead::HasPos(bool b) { _bPos=b; } inline void Bead::HasVel(bool b) { _bVel=b; } inline void Bead::HasF(bool b) { _bF=b; } inline void Bead::HasU(bool b) { _bU=b; } inline void Bead::HasV(bool b) { _bV=b; } inline void Bead::HasW(bool b) { _bW=b; } }} #endif /* _beadinfo_H */ votca-csg-1.2.4/include/votca/csg/csgapplication.h0000644000175000001440000001412712400714673022023 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_CSGAPPLICATION_H #define __VOTCA_CSGAPPLICATION_H #include #include "topology.h" #include "topologymap.h" #include "cgobserver.h" #include #include #include "trajectoryreader.h" namespace votca { namespace csg { using namespace votca::tools; class CsgApplication : public Application { public: CsgApplication(); ~CsgApplication(); void Initialize(); bool EvaluateOptions(); void Run(void); void ShowHelpText(std::ostream &out); /// \brief overload and return true to enable mapping command line options virtual bool DoMapping(void) { return false; } /// \brief if DoMapping is true, will by default require mapping or not virtual bool DoMappingDefault(void) { return true; } /// \brief overload and return true to enable trajectory command line options virtual bool DoTrajectory(void) { return false; } /* \brief overload and return true to enable threaded calculations */ virtual bool DoThreaded(void) { return false; } /* \brief overload and return false to disable synchronized (while threaded) calculations */ virtual bool SynchronizeThreads(void) { if (DoThreaded()) return true; else return false; } /// \brief called after topology was loaded virtual bool EvaluateTopology(Topology *top, Topology *top_ref = 0) { return true; } void AddObserver(CGObserver *observer); /// \brief called before the first frame virtual void BeginEvaluate(Topology *top, Topology *top_ref = 0); /// \brief called after the last frame virtual void EndEvaluate(); // \brief called for each frame which is mapped virtual void EvalConfiguration(Topology *top, Topology *top_ref = 0); // thread related stuff follows /** \brief Worker, derived from Thread, does the work. * * Worker holds the information about the current frame, either in its * own copy (e.g. Topology), or, by reference, from the parent CsgApplication. * The computation is shifted from Run() into EvalConfiguration. The * user is required to overload ForkWorker and Mergeworker and thereby * define the initialization and merging of workers. By default, workers * will be executed in correct order according to the frames. Also, * output will follow the same order. * Mutexes handle the locking of input/output and are also used to impose * the correct order of frames for in/output. * */ class Worker : public Thread { public: Worker(); ~Worker(); /// \brief overload with the actual computation virtual void EvalConfiguration(Topology *top, Topology *top_ref = 0) = 0; /// \brief returns worker id int getId() { return _id; } protected: CsgApplication *_app; Topology _top, _top_cg; TopologyMap * _map; int _id; void Run(void); void setApplication(CsgApplication *app) { _app = app; } void setId(int id) { _id = id; } friend class CsgApplication; }; /** * \brief Gets frames from TrajectoryReader in an ordered way and, if successful, * calls Worker::EvalConfiguration for that frame. * * @param worker * @return True if frames left for calculation, else False */ bool ProcessData(Worker * worker); /** * * User is required to overload ForkWorker and initialize workers. * @return worker */ virtual Worker *ForkWorker(void); /** * User is required to overload MergeWorker and merge data from each worker. * @param worker */ virtual void MergeWorker(Worker *worker); protected: list _observers; bool _do_mapping; std::vector _myWorkers; int _nframes; bool _is_first_frame; int _nthreads; Mutex _nframesMutex; Mutex _traj_readerMutex; /// \brief stores Mutexes used to impose order for input std::vector _threadsMutexesIn; /// \brief stores Mutexes used to impose order for output std::vector _threadsMutexesOut; TrajectoryReader * _traj_reader; }; inline void CsgApplication::AddObserver(CGObserver *observer) { _observers.push_back(observer); } inline CsgApplication::Worker::Worker() : _app(NULL), _map(NULL) , _id(-1) { } } } #endif /* __VOTCA_CSGAPPLICATION_H */ votca-csg-1.2.4/include/votca/csg/openbox.h0000644000175000001440000000200112400714673020461 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_OPENBOX_H #define __VOTCA_OPENBOX_H #include "boundarycondition.h" namespace votca { namespace csg { using namespace std; using namespace votca::tools; class OpenBox : public BoundaryCondition { public: vec BCShortestConnection(const vec &r_i, const vec &r_j) const; eBoxtype getBoxType() { return typeOpen; } }; }} #endif /* OPENBOX_H */ votca-csg-1.2.4/include/votca/csg/pairlist.h0000644000175000001440000000647212400714673020656 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _PAIRLIST_H #define _PAIRLIST_H #include #include namespace votca { namespace csg { using namespace std; template class PairList { public: PairList() {} virtual ~PairList() { Cleanup(); } //void Generate(BeadList *list1, BeadList *list2 = NULL); void AddPair(pair_type *p); typedef typename std::list::iterator iterator; typedef typename std::map partners; iterator begin() { return _pairs.begin(); } iterator end() { return _pairs.end(); } typename list::size_type size() { return _pairs.size(); } pair_type *front() { return _pairs.front(); } pair_type *back() { return _pairs.back(); } bool empty() { return _pairs.empty(); } void Cleanup(); pair_type *FindPair(element_type e1, element_type e2); partners *FindPartners(element_type e1); typedef element_type element_t; typedef pair_type pair_t; protected: list _pairs; map< element_type , map > _pair_map; }; template inline void PairList::AddPair(pair_type *p) { /// \todo be careful, same pair object is used, some values might change (e.g. sign of distance vector) _pair_map[ p->first ][ p->second ] = p; _pair_map[ p->second ][ p->first ] = p; /// \todo check if unique _pairs.push_back(p); } template inline void PairList::Cleanup() { for(iterator iter = _pairs.begin(); iter!=_pairs.end(); ++iter) delete *iter; _pairs.clear(); _pair_map.clear(); } template inline pair_type *PairList::FindPair(element_type e1, element_type e2) { typename std::map< element_type , map< element_type, pair_type * > >::iterator iter1; iter1 = _pair_map.find(e1); if(iter1==_pair_map.end()) return NULL; //typename map::iterator iter2; typename partners::iterator iter2; iter2 = iter1->second.find(e2); if(iter2 == iter1->second.end()) return NULL; return iter2->second; } template typename PairList::partners *PairList::FindPartners(element_type e1) { typename map< element_type , map >::iterator iter; if((iter=_pair_map.find(e1)) == _pair_map.end()) return NULL; return &(iter->second); } }} #endif /* _PAIRLIST_H */ votca-csg-1.2.4/include/votca/csg/nblist.h0000644000175000001440000001245212400714673020315 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _NBLIST_H #define _NBLIST_H #include "beadlist.h" #include "beadpair.h" #include "pairlist.h" #include "exclusionlist.h" namespace votca { namespace csg { using namespace votca::tools; /** * \brief Neighbour list class * * Implements a simple N^2 neighbour search and stores neigbourlist with pair * structure. User defined criteria can be added by SetMatchFunction. To only * get every pair listed once, the SetMatchFunction can be used and always return * that the pair is not stored. * */ class NBList : public PairList { public: NBList(); virtual ~NBList(); /// Generate the neighbour list based on two bead lists (e.g. bead types) virtual void Generate(BeadList &list1, BeadList &list2, bool do_exclusions = true); /// Generate the neighbour list based on a single bead list virtual void Generate(BeadList &list, bool do_exclusions = true) { Generate(list, list, do_exclusions); } /// set the cutoff for the neighbour search void setCutoff(double cutoff) { _cutoff = cutoff; } /// get the cutoff for the neighbour search double getCutoff() { return _cutoff; } /** * \brief match function for class member functions * * SetMatchFunction can be used to specify additional criteria, weather two * beads are added to the list of pairs or not. The function gets the two * two beads and the distance vector as argument. If a pair should be added, * the function should return true, otherwise false. * * This function can also be used, in a situation where each pair needs only * to be processed once, but the total number of pairs is to big to be stored * in memory, e.g. to calculate rdf for huge systems. In this case, set a * match function which always returns false (->no pair is added), and do * the processing in the match function. */ template void SetMatchFunction(T *object, bool (T::*fkt)(Bead *, Bead *, const vec &, const double dist)); /// \brief match function for static member functions or plain functions void SetMatchFunction(bool (*fkt)(Bead *, Bead *, const vec &, const double dist)); /// standard match function static bool match_always(Bead *b1, Bead *b2, const vec &r, const double dist) { return true; } /// function to use a user defined pair type template void setPairType(); protected: /// cutoff double _cutoff; /// take into account exclusions from topolgoy bool _do_exclusions; /// policy function to create new bead types template static BeadPair *beadpair_create_policy(Bead *bead1, Bead *bead2, const vec &r) { return dynamic_cast(new pair_type(bead1, bead2, r)); } typedef BeadPair* (*pair_creator_t)(Bead *bead1, Bead *bead2, const vec &r); /// the current bead pair creator function pair_creator_t _pair_creator; protected: /// Functor for match function to be able to set member and non-member functions class Functor { public: Functor() {} virtual bool operator()(Bead *, Bead *, const vec &, const double dist) = 0; }; /// Functor for member functions template class FunctorMember : public Functor { public: typedef bool (T::*fkt_t)(Bead *, Bead *, const vec &, const double dist); FunctorMember(T* cls, fkt_t fkt) : _cls(cls), _fkt(fkt) {} bool operator()(Bead *b1, Bead *b2, const vec &r, const double dist) { return (_cls->*_fkt)(b1, b2, r, dist); } private: T* _cls; fkt_t _fkt; }; /// Functor for non-member functions class FunctorNonMember : public Functor { public: typedef bool (*fkt_t)(Bead *, Bead *, const vec &, const double dist); FunctorNonMember(fkt_t fkt) : _fkt(fkt) {} bool operator()(Bead *b1, Bead *b2, const vec &r, const double dist) { return (*_fkt)(b1, b2, r, dist); } private: fkt_t _fkt; }; Functor * _match_function; }; template void NBList::setPairType() { _pair_creator = NBList::beadpair_create_policy; } template inline void NBList::SetMatchFunction(T *object, bool (T::*fkt)(Bead *, Bead *, const vec &, const double)) { if(_match_function) delete _match_function; _match_function = dynamic_cast(new FunctorMember(object, fkt)); } inline void NBList::SetMatchFunction(bool (*fkt)(Bead *, Bead *, const vec &, const double)) { if(_match_function) delete _match_function; _match_function = dynamic_cast(new FunctorNonMember(fkt)); } }} #endif /* _NBLIST_H */ votca-csg-1.2.4/include/votca/csg/topologymap.h0000644000175000001440000000246412400714673021376 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _topologymap_H #define _topologymap_H #include "map.h" #include "topology.h" #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; class TopologyMap { public: ~TopologyMap(); TopologyMap(Topology *in, Topology *out); void AddMoleculeMap(Map *map); void Apply(); private: Topology *_in; Topology *_out; typedef vector MapContainer; MapContainer _maps; }; inline TopologyMap::TopologyMap(Topology *in, Topology *out) : _in(in), _out(out) {} inline void TopologyMap::AddMoleculeMap(Map *map) { _maps.push_back(map); } }} #endif /* _topologymap_H */ votca-csg-1.2.4/include/votca/csg/imcio.h0000644000175000001440000000302212400714673020113 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _IMCIO_H #define _IMCIO_H #include #include #include #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; void imcio_write_dS(const string &file, ub::vector &r, ub::vector &dS, std::list *list=NULL); void imcio_write_matrix(const string &file, ub::matrix &gmc, std::list *list=NULL); void imcio_write_index(const string &file, vector &names, vector &ranges); void imcio_read_dS(const string &file, ub::vector &r, ub::vector &dS); void imcio_read_matrix(const string &file, ub::matrix &gmc); void imcio_read_index(const string &file, vector &names, vector &ranges); }} #endif /* _IMCIO_H */ votca-csg-1.2.4/include/votca/csg/beadtype.h0000644000175000001440000000247012400714673020616 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _BEADTYPE_H #define _BEADTYPE_H #include #include "topologyitem.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief Bead Type informaton Each bead has a type. While the bead name should be unique, several beads can share the same type. */ class BeadType : public TopologyItem { public: const int &getId() const { return _id; } const string &getName() const { return _name; } private: int _id; string _name; BeadType(Topology *parent, int id, const string &name) : TopologyItem(parent), _id(id), _name(name) {} friend class Topology; }; }} #endif /* _BEADTYPE_H */ votca-csg-1.2.4/include/votca/csg/nblistgrid.h0000644000175000001440000000327512400714673021166 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _NBLISTGRID_H #define _NBLISTGRID_H #include #include #include "nblist.h" #include namespace votca { namespace csg { using namespace votca::tools; class NBListGrid : public NBList { public: void Generate(BeadList &list1, BeadList &list2, bool do_exclusions = true); void Generate(BeadList &list, bool do_exclusions = true); protected: struct cell_t { BeadList _beads; std::vector _neighbours; }; vec _box_a, _box_b, _box_c; vec _norm_a, _norm_b, _norm_c; int _box_Na, _box_Nb, _box_Nc; std::vector _grid; Topology *_top; void InitializeGrid(const matrix &box); cell_t &getCell(const vec &r); cell_t &getCell(const int &a, const int &b, const int &c); void TestBead(cell_t &cell, Bead *bead); void TestCell(cell_t &cell, Bead *bead); }; inline NBListGrid::cell_t &NBListGrid::getCell(const int &a, const int &b, const int &c) { return _grid[a + _box_Na*b + _box_Na*_box_Nb*c]; } }} #endif /* _NBLISTGRID_H */ votca-csg-1.2.4/include/votca/csg/cgmoleculedef.h0000644000175000001440000000466212400714673021624 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _cgmoleculedef_H #define _cgmoleculedef_H #include #include #include #include #include #include "map.h" #include #include "exclusionlist.h" #include "molecule.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief definition of a coarse grained molecule This class is to define a coarse grained molecule, which includes the topology, mapping, ... \todo clean up this class, do the bonded interactions right!!!! \todo check for consistency of xml file, seperate xml parser and class!! */ class CGMoleculeDef { public: CGMoleculeDef() {} ~CGMoleculeDef(); Molecule *CreateMolecule(Topology & top); Map *CreateMap(Molecule &in, Molecule &out); void Load(string filename); const string &getName() { return _name; } const string &getIdent() { return _ident; } private: Property _options; struct beaddef_t { string _name; string _type; byte_t _symmetry; string _mapping; vector _subbeads; Property *_options; }; // name of the coarse grained molecule string _name; // name of the molecule to coarse grain string _ident; // beads of the cg molecule vector _beads; map _beads_by_name; // mapping schemes map _maps; list _bonded; void ParseTopology(Property &options); void ParseBeads(Property &options); void ParseBonded(Property &options); void ParseMapping(Property &options); beaddef_t *getBeadByName(const string &name); Property *getMapByName(const string &name); }; }} #endif /* _cgmoleculedef_H */ votca-csg-1.2.4/include/votca/csg/trajectoryreader.h0000644000175000001440000000317412400714673022374 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _trajectoryreader_H #define _trajectoryreader_H #include #include "topology.h" #include "fileformatfactory.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief trajectoryreader interface This class defines the interface a trajectory reader has to implement */ class TrajectoryReader { public: virtual ~TrajectoryReader() {} /// open a trejectory file virtual bool Open(const string &file) = 0; virtual void Close() {}; /// read in the first frame virtual bool FirstFrame(Topology &top) = 0; /// read in the next frame virtual bool NextFrame(Topology &top) = 0; static void RegisterPlugins(void); }; // important - singleton pattern, make sure factory is created before accessed inline FileFormatFactory &TrjReaderFactory() { static FileFormatFactory _TrjReaderFactory; return _TrjReaderFactory; } }} #endif /* _trajectoryreader_H */ votca-csg-1.2.4/include/votca/csg/interaction.h0000644000175000001440000001403612400714673021341 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _interaction_H #define _interaction_H #include #include #include "topology.h" #include "bead.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief base calss for all interactions This is the base class for all interactions. \todo double names/groups right, add molecules!! */ class Interaction { public: virtual ~Interaction() { } virtual double EvaluateVar(const Topology &top) = 0; void setName(const string &name) { _name = name; } string getName() const { return _name; } void setGroup(const string &group) { _group = group; RebuildName(); } const string &getGroup() const { return _group; } // the group id is set by topology, when interaction is added to it // \todo if the group name is changed later, group id should be updated by topology int getGroupId() { return _group_id; } void setGroupId(int id) { _group_id = id; } void setIndex(const int &index) { _index = index; RebuildName(); } const int &getIndex() const { return _index; } void setMolecule(const int &mol) { _mol = mol; RebuildName(); } const int &getMolecule() const { return _mol; } virtual vec Grad(const Topology &top, int bead) = 0; int BeadCount() { return _beads.size(); } int getBeadId(int bead) { return _beads[bead]; } protected: int _index; string _group; int _group_id; string _name; int _mol; vector _beads; void RebuildName(); }; inline void Interaction::RebuildName() { stringstream s; s << _mol+1 << ":" << _group << ":" << _index+1; _name = s.str(); } /** \brief bond interaction */ class IBond : public Interaction { public: IBond(int bead1, int bead2) { _beads.resize(2); _beads[0] = bead1; _beads[1] = bead2; } IBond(list &beads) { _beads.resize(2); for(int i=0; i<2; ++i) { _beads[i] = beads.front(); beads.pop_front(); }} double EvaluateVar(const Topology &top); vec Grad(const Topology &top, int bead); private: }; /** \brief angle interaction */ class IAngle : public Interaction { public: IAngle(int bead1, int bead2, int bead3) { _beads.resize(3); _beads[0] = bead1; _beads[1] = bead2; _beads[2] = bead3;} IAngle(list &beads) { _beads.resize(3); for(int i=0; i<3; ++i) { _beads[i] = beads.front(); beads.pop_front(); }} double EvaluateVar(const Topology &top); vec Grad(const Topology &top, int bead); private: }; /** \brief dihedral interaction */ class IDihedral : public Interaction { public: IDihedral(int bead1, int bead2, int bead3, int bead4) { _beads.resize(4); _beads[0] = bead1; _beads[1] = bead2; _beads[2] = bead3; _beads[3] = bead4;} IDihedral(list &beads) { _beads.resize(4); for(int i=0; i<4; ++i) { _beads[i] = beads.front(); beads.pop_front(); }} double EvaluateVar(const Topology &top); vec Grad(const Topology &top, int bead) { assert(false); return vec(0,0,0); } // not implemented private: }; inline double IBond::EvaluateVar(const Topology &top) { return abs(top.getDist(_beads[0], _beads[1])); } inline vec IBond::Grad(const Topology &top, int bead) { vec r = top.getDist(_beads[0], _beads[1]); r.normalize(); return (bead == 0) ? -r : r; } inline double IAngle::EvaluateVar(const Topology &top) { vec v1(top.getDist(_beads[1], _beads[0])); vec v2(top.getDist(_beads[1], _beads[2])); return acos(v1*v2/sqrt((v1*v1) * (v2*v2))); } inline vec IAngle::Grad(const Topology &top, int bead) { /*vec v1(top.getDist(_beads[1], _beads[0])); vec v2(top.getDist(_beads[1], _beads[2])); double av1 = abs(v1); double av2 = abs(v2); double cosphi = v1*v2 / (av1*av2); double acos_prime = -1.0 / (sqrt(1 - (cosphi*cosphi) )); switch (bead) { case (0): return acos_prime * (v2 / (av1*av2) - v1*cosphi/(av1*av1)); break; case (1): return -acos_prime * ( (v1+v2)/(av1 * av2)) - cosphi * ( v1/(av1*av1) + v2/(av2*av2) ); break; case (2): return acos_prime * (v1 / (av1*av2) - v2*cosphi/(av2*av2)); break; } return 0; */ vec v1(top.getDist(_beads[1], _beads[0])); vec v2(top.getDist(_beads[1], _beads[2])); double acos_prime = 1.0 / (sqrt(1 - (v1*v2) * (v1*v2)/( abs(v1) * abs(v2) * abs(v1) * abs(v2) ) )); switch (bead) { case (0): return acos_prime * (-v2 / ( abs(v1)*abs(v2) ) + (v1*v2) * v1 / ( abs(v2)*abs(v1)*abs(v1)*abs(v1) ) ); break; case (1): return acos_prime * ( (v1+v2)/(abs(v1) * abs(v2)) - (v1 * v2) * ((v2*v2) * v1 + (v1*v1) * v2 ) / ( abs(v1)*abs(v1)*abs(v1)*abs(v2)*abs(v2)*abs(v2) ) ); break; case (2): return acos_prime * (-v1 / ( abs(v1)*abs(v2) ) + (v1*v2) * v2 / ( abs(v1)*abs(v2)*abs(v2)*abs(v2) ) ); break; } // should never reach this assert(false); return vec(0,0,0); } inline double IDihedral::EvaluateVar(const Topology &top) { vec v1(top.getDist(_beads[0], _beads[1])); vec v2(top.getDist(_beads[1], _beads[2])); vec v3(top.getDist(_beads[2], _beads[3])); vec n1, n2; n1 = v1^v2; // calculate the normal vector n2 = v2^v3; // calculate the normal vector double sign = (v1*n2 < 0) ? -1 : 1; return sign*acos(n1*n2/sqrt((n1*n1) * (n2*n2))); //return sign*acos(n1*n2/sqrt((n1*n1) * (n2*n2))) + 1; //return pow(acos(n1*n2/sqrt((n1*n1) * (n2*n2))), 2); } }} #endif /* _interaction_H */ votca-csg-1.2.4/include/votca/csg/cgengine.h0000644000175000001440000000567312400714673020610 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _cgengine_H #define _cgengine_H #include #include #include #include "topology.h" #include "cgmoleculedef.h" #include #include "topologymap.h" #include "cgobserver.h" #include #include "cgmoleculedef.h" #include "cgengine.h" #include "molecule.h" #include "topologyreader.h" #include "trajectorywriter.h" #include "trajectoryreader.h" #include #include #include "nematicorder.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief coarse graining engine This class manages the coarse graining, at the moment it does the measurement stuff TODO: split this into an additional VotcaApplication object */ class CGEngine { public: CGEngine(); ~CGEngine(); /** create a coarse grained topolgy based on a given topology */ TopologyMap *CreateCGTopology(Topology &in, Topology &out); /** load molecule type from file */ void LoadMoleculeType(string filename); CGMoleculeDef *getMoleculeDef(string name); /** * \brief ignores molecule in mapping process * \param pattern glob pattern for molecule ident */ void AddIgnore(string pattern) { _ignores.push_back(pattern); } /** * \brief checks whether molecule is ignored * \param ident identifyier of molecule * \return true if is ignored */ bool IsIgnored(string ident); private: map _molecule_defs; std::list _ignores; }; inline CGMoleculeDef *CGEngine::getMoleculeDef(string name) { map::iterator iter; // if there is only 1 molecule definition, don't care about the name if(_molecule_defs.size()==1 && name == "unnamed") { return (*(_molecule_defs.begin())).second; } iter = _molecule_defs.find(name); if(iter == _molecule_defs.end()) return NULL; return (*iter).second; } inline bool CGEngine::IsIgnored(string ident) { for(std::list::iterator iter=_ignores.begin(); iter!=_ignores.end(); ++iter) { if(wildcmp(iter->c_str(), ident.c_str())) return true; } return false; } }} #endif /* _cgengine_H */ votca-csg-1.2.4/include/votca/csg/beadlist.h0000644000175000001440000000273612400714673020615 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _BEADLIST_H #define _BEADLIST_H #include #include #include "topology.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief Generate lists of beads This class generates a list of beads based on some criteria, currently only the bead type. */ class BeadList : public list { public: BeadList() {}; ~BeadList() {} /// \brief Select all beads of type withn a radius of reference vector int GenerateInSphericalSubvolume(Topology &top, const string &select, vec ref, double radius); Topology *getTopology() {return _topology; } private: Topology *_topology; }; }} #endif /* _BEADLIST_H */ votca-csg-1.2.4/include/votca/csg/topologyitem.h0000644000175000001440000000200312400714673021544 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _TOPOLOGYITEM_H #define _TOPOLOGYITEM_H namespace votca { namespace csg { class Topology; class TopologyItem { public: virtual ~TopologyItem() {} Topology *getParent() { return _parent; } protected: TopologyItem(Topology *parent) : _parent(parent) {} Topology *_parent; friend class Topology; }; }} #endif /* _TOPOLOGYITEM_H */ votca-csg-1.2.4/include/votca/csg/beadpair.h0000644000175000001440000000260612400714673020571 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _BEADPAIR_H #define _BEADPAIR_H namespace votca { namespace csg { using namespace votca::tools; /** \brief A particle pair This class defines a particle pair. The future plan is, that the Pair class can be overloaded and Particle list creates these inherited pairs. */ class BeadPair : public std::pair { public: BeadPair() {} BeadPair(Bead *bead1, Bead *bead2, vec r) : std::pair(bead1, bead2), _r(r), _dist(abs(r)) {} virtual ~BeadPair() {} /// \brief the vector connecting two beads vec &r() { return _r; } /// \brief the distance of the beads double &dist() { return _dist; } protected: vec _r; double _dist; }; }} #endif /* _PAIR_H */ votca-csg-1.2.4/LICENSE0000644000175000001440000002613612400714673014347 0ustar christophusers Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. votca-csg-1.2.4/NOTICE0000644000175000001440000000050612400714673014237 0ustar christophusersVersatile Object-oriented Toolkit for Coarse-graining Applications Copyright 2009-2011 The VOTCA Development Team This product includes software developed at The VOTCA Development Team (http://www.votca.org). This software contains code, in particular function_inverse.sh, derived from a script collection by C. Junghans. votca-csg-1.2.4/README0000644000175000001440000000105512400714673014213 0ustar christophusersFurther information on VOTCA can be found at http://www.votca.org The development of VOTCA is mainly funded by academic research grants. If you use this package, please cite the VOTCA paper: * Versatile Object-oriented Toolkit for Coarse-graining Applications, V.Ruehle, C. Junghans, A. Lukyanov, K. Kremer, D. Andrienko, J. Chem. Theo. Comp. 5 (12), 3211 (2009) In case of questions, please post them in the google discussion group for votca at http://groups.google.com/group/votca You can contact the VOTCA Development Team at devs@votca.org. votca-csg-1.2.4/scripts/0000755000175000001440000000000012400714673015021 5ustar christophusersvotca-csg-1.2.4/scripts/csg.rc.csh.in0000644000175000001440000000123712400714673017307 0ustar christophusers# # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # setenv CSGSHARE "@CMAKE_INSTALL_PREFIX@/@DATA@" votca-csg-1.2.4/scripts/CMakeLists.txt0000644000175000001440000000430112400714673017557 0ustar christophusersconfigure_file(help2t2t.in ${CMAKE_CURRENT_BINARY_DIR}/help2t2t.out @ONLY) add_custom_command(OUTPUT help2t2t DEPENDS help2t2t) add_custom_target(help2t2t ALL COMMAND ${CMAKE_COMMAND} -DINPUT="help2t2t.out" -DOUTPUT="help2t2t" -DTOP_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -P ${CMAKE_MODULE_PATH}/hgscript.cmake DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/help2t2t.out) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES help2t2t) foreach(SCRIPT csg_call csg_inverse multi_g_rdf) configure_file(${SCRIPT}.in ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT}.out @ONLY) add_custom_command(OUTPUT ${SCRIPT} DEPENDS ${SCRIPT}) add_custom_target(${SCRIPT} ALL COMMAND ${CMAKE_COMMAND} -DINPUT="${SCRIPT}.out" -DOUTPUT="${SCRIPT}" -DTOP_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -P ${CMAKE_MODULE_PATH}/hgscript.cmake DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT}.out) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${SCRIPT}) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT} DESTINATION bin) if (TXT2TAGS_FOUND AND BASH) add_custom_command(OUTPUT ${SCRIPT}.man COMMAND CSGSHARE=${CMAKE_SOURCE_DIR}/share ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT} --help > ${SCRIPT}.help COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/help2t2t ${SCRIPT}.help > ${SCRIPT}.t2t COMMAND ${TXT2TAGS_EXECUTABLE} -q -t man -i ${SCRIPT}.t2t -o ${SCRIPT}.man DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT} ${CMAKE_CURRENT_BINARY_DIR}/help2t2t) add_custom_target(${SCRIPT}_manpage DEPENDS ${SCRIPT}.man) add_dependencies(manpages ${SCRIPT}_manpage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SCRIPT}.man DESTINATION ${MAN}/man1 RENAME ${SCRIPT}.1) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${SCRIPT}.help ${SCRIPT}.t2t) endif(TXT2TAGS_FOUND AND BASH) endforeach(SCRIPT) option(WITH_RC_FILES "Install votca rc files, no need when installing under /usr" ON) if (WITH_RC_FILES) foreach(RC csg.rc.bash csg.rc.csh) configure_file(${RC}.in ${CMAKE_CURRENT_BINARY_DIR}/${RC} @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RC} DESTINATION ${DATA}/rc) endforeach(RC) endif (WITH_RC_FILES) install(FILES csg-completion.bash DESTINATION ${DATA}/rc) votca-csg-1.2.4/scripts/multi_g_rdf.in0000644000175000001440000001343412400714673017651 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # g_cmd=${0##*/} g_cmd=${g_cmd#multi_} fbase=${g_cmd#g_} quiet="no" begin=0 end="" np=8 index="index.ndx" out="${fbase}.xvg" version="@PROJECT_VERSION@ #CSG_HG_ID#" single="no" debug="no" die() { echo -e "$*" exit 1 } qecho() { [ "$quiet" = "yes" ] || echo -e "$*" } decho() { [ "$debug" = "yes" ] && echo -e "$*" } show_help () { cat << eof ================================================== ======== VOTCA (http://www.votca.org) ======== ================================================== please submit bugs to bugs@votca.org ${0##*/}, version ${version} This is a multiplexed version of $g_cmd Usage: ${0##*/} [OPTIONS] -- [${g_cmd}_options] Allowed options: -N, --NN Number of tasks Default: $np -b TIME Begin time Default: $begin -e TIME End time -n FILE Name of the index file Default: $index -o FILE.xvg Name of the total output file Default: $out --soutput FILE.xvg Name of the single output files Default: ${out%.xvg}_NP.xvg (used trunc of name given by -o) (where NP is replaced later by the number of the process) --log FILE Name of logfile Default: ${out%.xvg}_NP.log" (used trunc of name given by -o) (where NP is replaced later by the number of the process) --cmd CMD Change the gromacs command to run Default: ${g_cmd} --single Run only one task at the time --debug Enable debug output -q, --quiet Be a little bit quiet -h, --help Show this help Examples: * ${0##*/} -e 1 * ${0##*/} -e 1 -- -bin 0.05 eof } while [ "${1#-}" != "$1" ]; do if [ "${1#--}" = "$1" ] && [ -n "${1:2}" ]; then #short opt with arguments here: fc if [ "${1#-[ebo]}" != "${1}" ]; then set -- "${1:0:2}" "${1:2}" "${@:2}" else set -- "${1:0:2}" "-${1:2}" "${@:2}" fi fi case $1 in -[0-9]* | --[0-9]**) np=${1#-} np=${np#-} [ -z "${np//[0-9]}" ] || die "$1 could not be convert to a number" shift ;; -b) begin="$2" shift 2;; -o) out="$2" [ -z "${out%%*.xvg}" ] || die "Outfile has to end with xvg" shift 2;; -n) index="$2" shift 2;; -e) end="$2" shift 2;; --soutput) sout="$2" [ -z "${sout%%*.xvg}" ] || die "Outfile has to end with xvg" shift 2;; -q | --quiet) quiet="yes" shift ;; --single) single="yes" shift ;; --cmd) g_cmd="$2" shift 2;; --debug) debug="yes" shift ;; -h | --help) show_help exit 0;; --) shift break;; *) die "Unknown option '$1'";; esac done #defaults [ -z "$sout" ] && sout="${out%.xvg}_NP.xvg" [ -z "$logfile" ] && logfile="${out%.xvg}_NP.log" [ -z "$end" ] && die "-e option is missing!\nHelp with --help" for i in $g_cmd paste awk sed; do [ -n "$(type $i)" ] || die "$i not found" done dt="$(awk -v b="$begin" -v e="$end" -v np="$np" 'BEGIN{print (e-b)/np}')" [ -z "$dt" ] && die "Could not calculate dt" [ -f "$index" ] || die "Indexfile $index not found" echo "Select a reference group and 1 group" sed -n 's/.*\[\(.*\)\].*/\1/p' $index | awk '{print "Group",NR-1,"(",$0,")"}' echo -n "Select a group: " read -r || die "Wrong input" input="${REPLY}" echo -n "Select a group: " read -r || die "Wrong input" input="${input}\n${REPLY}" qecho "" qecho "Selected: $input" b="$begin" for ((i=0;i<$np;i++)); do np0="$(printf "%02i" $i)" this_log="${logfile/NP/$np0}" this_out="${sout/NP/$np0}" e="$(awk -v b="$begin" -v dt="$dt" -v i="$i" 'BEGIN{print dt*(i+1)+b}')" echo -e "$input" | $g_cmd -b $b -e $e -n $index -o $this_out $* &> $this_log & pid="$!" qecho "Calculation of $fbase from $b ps to $e ps started (pid $pid, logfile $this_log)" b="$e" if [ "$single" = "yes" ]; then wait $pid || die "The $fbase calculation with pid $failed failed" else pids="${pids} $pid" fi done if [ "$single" = "no" ]; then qecho "Waiting for single $fbase calculations to finish" failed="" for i in $pids; do wait $i || failed="$failed $i" done [ -z "$failed" ] || die "The $fbase calculations with pids $failed failed" fi qecho "Checking output" lines="" for ((i=0;i<$np;i++)); do np0="$(printf "%02i" $i)" this_out="${sout/NP/$np0}" [ -f "$this_out" ] || die "Could not find $this_out" this_lines="$(sed -n '$=' "$this_out")" || die "linecount of $this_out failed" [ -z "$this_lines" ] && die "linecount of $this_out was empty" [ -z "$lines" ] && lines="$this_lines" [ $this_lines -eq $lines ] || die "Number of data lines differs for $fbase nr $i - $this_lines vs $lines lines" done qecho "Calculating average" pasteline= mean="0" mean2="0" mco="\$$((2*$np+1))" for ((i=0;i<$np;i++)); do np0="$(printf "%02i" $i)" this_out="${sout/NP/$np0}" co="\$$((2 * $i + 2 ))" pasteline="$pasteline $this_out" mean="${mean}+${co}" mean2="${mean2}+($co-$mco)**2" done awkprog="/[@#]/{next;}{print \$0,($mean)/$np}" awkprog2="/[@#]/{next;}{print \$1,$mco,sqrt(($mean2)/$(($np*($np-1))))}" decho "awk code to calc mean: $awkprog" decho "awk code to calc block error: $awkprog2" paste $pasteline | awk "$awkprog" | awk "$awkprog2" > $out votca-csg-1.2.4/scripts/csg_inverse.in0000644000175000001440000000414012400714673017657 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # version='@PROJECT_VERSION@ #CSG_HG_ID#' if [ -n "$(type -p csg_call 2> /dev/null)" ]; then #in case we have an old version of csg_call without --show-share tmp="$(csg_call --show-share 2> /dev/null)" && export CSGSHARE="$tmp" unset tmp fi #we leave --help here to have it even when #CSGSHARE is not defined if [[ $1 = "--help" || $1 = "-h" ]]; then cat << eof ================================================== ======== VOTCA (http://www.votca.org) ======== ================================================== please submit bugs to bugs@votca.org eof if [[ -f ${CSGSHARE}/scripts/inverse/inverse.sh ]]; then exec ${CSGSHARE}/scripts/inverse/inverse.sh --help | \ sed -e "s/inverse\.sh/${0##*/}/g" -e "s/%version%/${version}/" exit 0 fi cat << eof ${0##*/}, version ${version} Start the script (inverse.sh) to run IBM, IMC, etc. Usage: ${0##*/} [OPTIONS] --options settings.xml Allowed options: -h, --help Show this help NOTE: this is a short help, please source VOTCARC.bash or VOTCARC.csh or export CSGSHARE to get the full help. eof exit 0 fi #we don't know if it was done above if [[ -n "$(type -p csg_call)" ]]; then CSGSHARE="$(csg_call --show-share)" || exit 1 export CSGSHARE else echo "Could not find csg_call" >&2 exit 1 fi if [[ -f ${CSGSHARE}/scripts/inverse/inverse.sh ]]; then exec ${CSGSHARE}/scripts/inverse/inverse.sh $@ exit 0 else echo "${0##*/}: Could not run \${CSGSHARE}/scripts/inverse/inverse.sh $@" >&2 exit 1 fi votca-csg-1.2.4/scripts/help2t2t.in0000644000175000001440000000765712400714673017034 0ustar christophusers#! /bin/bash -e # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # version='@PROJECT_VERSION@ #CSG_HG_ID#' die() { echo -e "$*" >&2 exit 1 } assert() { local x pipestatus=${PIPESTATUS[*]} for x in $pipestatus; do [[ $x -eq 0 ]] || die "$@" done } [ -z "$1" ] && die "Usage: ${0##*/} helpfile" prog="${1%.*}" [ -f "$1" ] || die "${0##*/}: $1 not found" #trash the header helpmsg="$(sed -e '1,10d' $1)" || die "$prog --help failed" #first block is descprition desc="$(echo "$helpmsg" | sed -n '1,/^[[:space:]]*$/p')" assert "parse of desc failed" [ -z "$desc" ] && die "Failed to fetch desc" helpmsg="$(echo "$helpmsg" | sed '1,/^[[:space:]]*$/d')" assert "cut of help msg failed" #second block can be usage line usage="$(echo "$helpmsg" | sed -n '1s/Usage:[[:space:]]*\(.*\)$/\1/p')" assert "parse of usage failed" if [ -z "$usage" ]; then usage="**$prog** \"\"[\"\"//OPTION//\"\"]\"\" \"\"[\"\"//OPTIONPARAMETERS//\"\"]\"\"" else usage="$(echo "$usage" | sed -e 's/^/**/' -e 's/ /** /' -e 's/\([][]\)/""\1""/g')" assert "parse part 2 of usage failed" helpmsg="$(echo "$helpmsg" | sed '1,/^[[:space:]]*$/d')" assert "cut of help msg failed" fi #try to find examples block exam="$(echo "$helpmsg" | sed -n '/^Examples:/,/^[[:space:]]*$/p')" || die "parse of exam failed" if [ -n "$exam" ]; then exam="$(echo "$exam" | \ sed -e '1d' \ -e '/^\* /s/\( \{2\}\|$\)/``/' \ -e '/^\*.*``/s/^\*[[:space:]]*/- ``/')" assert "parse part 2 of exam failed" helpmsg="$(echo "$helpmsg" | sed '/^Examples:/,/^[[:space:]]*$/d')" assert "cut of help msg failed" fi #write t2t file cat < - ``--option`` text #-usageline -> usage: ``code`` #-extra empty line before new section to close itemize #-examplelines (^*) -> - ``line`` #-remove NEEDS and OPTINAL, ... line #-added newline before new option block echo -e "$helpmsg" | sed \ -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//' \ -e '/^-[^ ]/s/ \{2,\}/**\n/' \ -e '/^-[^ ].*\*\*/s/^/: **/' \ -e '/^\* /s/\( \{2\}\|$\)/``/' \ -e '/^\*.*``/s/^\*[[:space:]]*/- ``/' \ -e '/^\(NEEDS\|OPTIONAL\|USES\|PROVIDES\)/d' \ -e 's/^[A-Za-z]* options:/\n&/' assert "sed of options failed" if [ -n "$exam" ]; then cat < This Manual Page was converted from t2t format to the this format by [txt2tags http://txt2tags.org] ! The t2t file was extracted from '$prog --help' by ${0##*/} (version $version) = COPYRIGHT = Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. EOF votca-csg-1.2.4/scripts/csg.rc.bash.in0000644000175000001440000000133312400714673017444 0ustar christophusers# # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #Make it simple so that sh can also understand it CSGSHARE="@CMAKE_INSTALL_PREFIX@/@DATA@" export CSGSHARE votca-csg-1.2.4/scripts/csg_call.in0000644000175000001440000001226312400714673017124 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # version='@PROJECT_VERSION@ #CSG_HG_ID#' ext_cmd="" simprog="" log="" show_share="no" #unset stuff from enviorment unset CSGXMLFILE CSGDEBUG bondtype bondname #failback define die() { echo -e "$*" >&2 exit 1 } show_help () { cat << eof ================================================== ======== VOTCA (http://www.votca.org) ======== ================================================== please submit bugs to bugs@votca.org ${0##*/}, version ${version} This script calls scripts for the iterative framework Usage: ${0##*/} [OPTIONS] key1 key2 Allowed options: -l, --list Show list of all script --cat Show the content of the script --show Show the path to the script --show-share Shows the used CSGSHARE dir and exits --scriptdir DIR Set the user script dir (Used if no optins xml file is given) Default: empty --simprog PROG Set the simprog (Used if no options xml file is given) Default: empty --options FILE Specify the options xml file to use --log FILE Specify the log file to use Default: stdout --ia-type type Specify the interaction type to use --ia-name name Specify the interaction name to use --nocolor Disable colors --debug Enable debug mode with a lot of information -h, --help Show this help Examples: * ${0##*/} table smooth [ARGUMENTS] * ${0##*/} --show run gromacs eof } while [[ ${1#-} != $1 ]]; do if [[ ${1#--} = $1 && -n ${1:2} ]]; then #short opt with arguments here: fc if [[ ${1#-[fc]} != ${1} ]]; then set -- "${1:0:2}" "${1:2}" "${@:2}" else set -- "${1:0:2}" "-${1:2}" "${@:2}" fi fi case $1 in -l | --list) ext_cmd="show_csg_tables" shift ;; --scriptdir) scriptdir="$2" shift 2;; --simprog) simprog="$2" shift 2;; --options) export CSGXMLFILE="$2" [ -f "$CSGXMLFILE" ] || die "options xml file '$CSGXMLFILE' not found" shift 2;; --log) log="$2" shift 2;; --ia-type) export bondtype="$2" shift 2;; --ia-name) export bondname="$2" shift 2;; --cat) ext_cmd="cat_external" shift;; --show) ext_cmd="source_wrapper" shift;; --show-share) show_share="yes" shift;; --nocolor) export CSGNOCOLOR="yes" shift;; -h | --help) show_help exit 0;; --debug) export CSGDEBUG="yes" shift;; -v | --version) echo "${0##*/}, version $version" exit 0;; *) die "Unknown option '$1'";; esac done if [[ -z ${CSGSHARE} ]]; then if [ -f "${0%/*}/../share/votca/scripts/inverse/inverse.sh" ]; then #transform it to a global path export CSGSHARE="$(cd ${0%/*}/../share/votca;pwd)" elif [ -f "@CMAKE_INSTALL_PREFIX@/@DATA@/scripts/inverse/inverse.sh" ]; then export CSGSHARE="@CMAKE_INSTALL_PREFIX@/@DATA@" else echo "Error: Environment value CSGSHARE is not defined and could not be guessed" >&2 echo "Export CSGSHARE or source VOTCARC.bash or VOTCARC.csh" >&2 exit 1 fi else if [[ ! -f ${CSGSHARE}/scripts/inverse/inverse.sh ]]; then echo "Error: Environment value CSGSHARE seems to be wrong" >&2 echo "Could not find \${CSGSHARE}/scripts/inverse/inverse.sh" >&2 echo "Export CSGSHARE or source VOTCARC.bash or VOTCARC.csh" >&2 exit 1 fi fi if [ "$show_share" = "yes" ]; then echo "${CSGSHARE}" exit 0 fi if [[ -f ${CSGSHARE}/scripts/inverse/start_framework.sh ]]; then source ${CSGSHARE}/scripts/inverse/start_framework.sh || die "Could not source start_framework.sh" else die "Could not find start_framework.sh" fi [[ -n ${CSGXMLFILE} ]] && scriptdir="$(csg_get_property --allow-empty cg.inverse.scriptdir "$scriptdir")" [[ -n ${scriptdir} ]] && add_to_csgshare "$scriptdir" [[ -n ${CSGXMLFILE} ]] && simprog="$(csg_get_property --allow-empty cg.inverse.program "$simprog")" [[ -n ${simprog} ]] && source_function $simprog if [[ $ext_cmd = show_csg_tables ]]; then $ext_cmd exit $? fi [[ -z $1 || -z $2 ]] && die "${0##*/}: Missing argument" if [[ -n $ext_cmd ]]; then $ext_cmd $1 $2 exit $? fi #help of scripts should always work and be quiet if [[ $3 = --help ]]; then cat < /dev/null | sed -e '/--/!d' \ -e 's/.*?\(--[A-Za-z0-9]\+\).*/\1/' | sort -u ) COMPREPLY=( $( compgen -W '$myopt' -- $cur ) ) fi } complete -F _votca_csg_common_opts -f \ csg_boltzmann csg_dump csg_gmxtopol csg_inverse csg_part_dist csg_resample \ csg_call csg_fmatch csg_imcrepack csg_map csg_property csg_stat \ csg_density votca-csg-1.2.4/share/0000755000175000001440000000000012400714673014434 5ustar christophusersvotca-csg-1.2.4/share/template/0000755000175000001440000000000012400714673016247 5ustar christophusersvotca-csg-1.2.4/share/template/CMakeLists.txt0000644000175000001440000000132712400714673021012 0ustar christophusersadd_custom_command(OUTPUT votca/csg COMMAND ${CMAKE_COMMAND} -E make_directory votca COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/include votca/csg ) add_custom_target(csg_include_links DEPENDS votca/csg) set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM TRUE) include_directories(${CMAKE_CURRENT_BINARY_DIR}) foreach(PROG template_serial template_threaded) file(GLOB ${PROG}_SOURCES ${PROG}.cc) add_executable(${PROG} ${${PROG}_SOURCES}) add_dependencies(${PROG} csg_include_links) target_link_libraries(${PROG} votca_csg) install(FILES ${${PROG}_SOURCES} DESTINATION ${DATA}/template) endforeach(PROG) install(FILES CMakeLists.txt.template DESTINATION ${DATA}/template RENAME CMakeLists.txt) votca-csg-1.2.4/share/template/CMakeLists.txt.template0000644000175000001440000000166412400714673022630 0ustar christophusers#change the name here or run cmake -DNAME="XXX" set(NAME "template_serial" CACHE STRING "Name of the csg app") cmake_minimum_required(VERSION 2.6) project(${NAME}) enable_language(CXX) FIND_PACKAGE(PkgConfig) #only check for libvotca_csg, because it depends on libvotca_tools #do not use find_package to avoid extra dependencies #do not use REQUIRED here, we have a better error message then pkgconfig PKG_CHECK_MODULES(VOTCA_CSG libvotca_csg) if (NOT VOTCA_CSG_FOUND) message(FATAL_ERROR "libvotca_csg not found, source VOTCARC.") endif (NOT VOTCA_CSG_FOUND) find_library(LIB_CSG votca_csg HINTS ${VOTCA_CSG_LIBRARY_DIRS}) include_directories( ${VOTCA_CSG_INCLUDE_DIRS} ) file(GLOB ${NAME}_SOURCES ${NAME}*.cc) #add extra source files here add_executable(${NAME} ${${NAME}_SOURCES}) target_link_libraries(${NAME} ${LIB_CSG}) install(TARGETS ${NAME} RUNTIME DESTINATION bin) set_target_properties(${NAME} PROPERTIES OUTPUT_NAME csg_${NAME}) votca-csg-1.2.4/share/template/template_threaded.cc0000644000175000001440000001417412400714673022240 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include using namespace std; using namespace votca::csg; // comments were mainly added to explain the "overhead" needed for threaded // calculations/analyzations // to sum it up: instead of having one "thread" doing all your work (the whole tracetory), // you may split it into single frames and distribute it among many "workers". // a solid choice is: number of cores = number of workers. // you, as the user, are required to define how to initialize and merge your workers. // the main part of the program, EvalConfiguration, is shifted to the Worker class // but other than that stays untouched compared to a non-threaded version class CsgTestApp : public CsgApplication { string ProgramName() { return "template_threaded_rdf"; } void HelpText(ostream &out) { out << "template for threaded rdf calculations"; } void Initialize(); bool DoTrajectory() { return true; } // explicitly turn on threaded mode by overriding DoThreaded() and returning true // note that threads will be started and merged in an ordered way by default // this has the disadvantage of slowing everything down a bit (you will likely not // notice a decrease of performance), but the advantage of processing frames in // their original order // in most cases, you want that // in some cases, where reading and writing/merging does not have to occur in order, // you may consider switching SynchronizeThreads() off // in this example, where an rdf-like value is calculated, ordered reading/writing is not // neccessary. however, leave it untouched to prevent future mistakes bool DoThreaded() { return true; } // are you sure? really? // bool SynchronizeThreads() { // return false; // } void BeginEvaluate(Topology *top, Topology *top_ref); void EndEvaluate(); // ForkWorker is the function you need to override and initialize your workers CsgApplication::Worker *ForkWorker(void); // MergeWorker needs you to define how to merge different workers and their data void MergeWorker(Worker *worker); protected: // data belonging to the main class CsgTestApp HistogramNew _rdf; double _cut_off; }; // derive from CsgApplication::Worker and define your worker class RDFWorker : public CsgApplication::Worker { public: ~RDFWorker(){}; // override EvalConfiguration with your analysis routine void EvalConfiguration(Topology *top, Topology *top_ref); // data belonging to this particular worker HistogramNew _rdf; double _cut_off; }; int main(int argc, char** argv) { CsgTestApp app; return app.Exec(argc, argv); } void CsgTestApp::Initialize() { CsgApplication::Initialize(); AddProgramOptions("RDF options") ("c", boost::program_options::value()->default_value(1.0), "the cutoff"); } void CsgTestApp::BeginEvaluate(Topology *top, Topology *top_ref) { _cut_off = OptionsMap()["c"].as(); _rdf.Initialize(0, _cut_off, 50); } // create and initialize single workers // ForkWorker() will be called as often as the parameter '--nt NTHREADS' // it creates a new worker and the user is required to initialize variables etc. // (if needed) CsgApplication::Worker * CsgTestApp::ForkWorker() { RDFWorker *worker; worker = new RDFWorker(); // initialize worker->_cut_off = OptionsMap()["c"].as(); worker->_rdf.Initialize(0, worker->_cut_off, 50); return worker; } // EvalConfiguration does the actual calculation // you won't see any explicit threaded stuff here void RDFWorker::EvalConfiguration(Topology *top, Topology *top_ref) { BeadList b; b.Generate(*top, "*"); NBListGrid nb; nb.setCutoff(_cut_off); nb.Generate(b); NBList::iterator i; for (i = nb.begin(); i != nb.end(); ++i) { _rdf.Process((*i)->dist()); } } // the user is required to define how to merge the single data // belonging to each thread into the main data belonging to CsgTestApp void CsgTestApp::MergeWorker(Worker *worker) { RDFWorker * myRDFWorker; // cast generel Worker into your derived worker class(here RDFWorker) myRDFWorker = dynamic_cast (worker); // the next comment block explains how mutexes are used internally for this function: // mutexes are used to exclusively work on data // e.g., if you read or write global data, make sure that nobody else (i.e. no other worker) // works on that very same piece of data at the same time; otherwise, // you will end up with wrong results that you struggle to understand // the parent class handles a "merging mutex" for you internally; this is what happens: // first, a mutex is created, e.g. // Mutex rdfMutex; // then, for each worker, the mutex is first locked // rdfMutex.Lock()) // and MergeWorker(worker) is called (i.e. the code you define here is executed) // after MergeWorker exits, the mutex is unlocked // rdfMutex.Unlock(); // and allows other threads to get a lock and start merging // now follows your code // merging of data in this simple example is easy and does not have to follow // the original order of frames (since plain summing is commutative) _rdf.data().y() = _rdf.data().y() + myRDFWorker->_rdf.data().y(); } void CsgTestApp::EndEvaluate() { _rdf.data().y() = element_div(_rdf.data().y(), element_prod(_rdf.data().x(), _rdf.data().x()) ); _rdf.data().Save("rdf.dat"); } votca-csg-1.2.4/share/template/template_serial.cc0000644000175000001440000000417312400714673021735 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include //using namespace votca::tools; using namespace std; using namespace votca::csg; class CsgTestApp : public CsgApplication { string ProgramName() { return "template_nblist"; } void HelpText(ostream &out) { out << "rough template for rdf calculations"; } void Initialize(); bool DoTrajectory() {return true;} void BeginEvaluate(Topology *top, Topology *top_ref); void EvalConfiguration(Topology *top, Topology *top_ref); void EndEvaluate(); protected: HistogramNew _rdf; double _cut_off; }; int main(int argc, char** argv) { CsgTestApp app; return app.Exec(argc, argv); } void CsgTestApp::EvalConfiguration(Topology *top, Topology *top_ref) { BeadList b; b.Generate(*top, "*"); NBListGrid nb; nb.setCutoff(_cut_off); nb.Generate(b); NBList::iterator i; for(i=nb.begin(); i!=nb.end(); ++i) _rdf.Process((*i)->dist()); } void CsgTestApp::Initialize() { CsgApplication::Initialize(); AddProgramOptions("RDF options") ("c", boost::program_options::value()->default_value(1.0), "the cutoff"); } void CsgTestApp::BeginEvaluate(Topology *top, Topology *top_ref) { _cut_off = OptionsMap()["c"].as(); _rdf.Initialize(0, _cut_off, 50); } void CsgTestApp::EndEvaluate() { _rdf.data().Save("rdf.dat"); } votca-csg-1.2.4/share/CMakeLists.txt0000644000175000001440000000017712400714673017201 0ustar christophusersadd_subdirectory(man) add_subdirectory(xml) add_subdirectory(doc) add_subdirectory(scripts/inverse) add_subdirectory(template) votca-csg-1.2.4/share/man/0000755000175000001440000000000012400714673015207 5ustar christophusersvotca-csg-1.2.4/share/man/CMakeLists.txt0000644000175000001440000000067612400714673017760 0ustar christophusersif (TXT2TAGS_FOUND) add_custom_command(OUTPUT votca-csg.man COMMAND ${TXT2TAGS_EXECUTABLE} -q -t man -i ${CMAKE_CURRENT_SOURCE_DIR}/votca-csg.t2t -o votca-csg.man COMMENT "Building votca-csg manpage") add_custom_target(votca-csg_manpage DEPENDS votca-csg.man) add_dependencies(manpages votca-csg_manpage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/votca-csg.man DESTINATION ${MAN}/man7 RENAME votca-csg.7) endif (TXT2TAGS_FOUND) votca-csg-1.2.4/share/man/votca-csg.t2t0000644000175000001440000000522412400714673017533 0ustar christophusersvotca-csg VOTCA Development Team %%mtime(%d/%m/%Y) %make the manpage type 7, txt2tags does 1 by default %!postproc(man): "^(\.TH.*) 1 " "\1 7 " = NAME = votca-csg - The VOTCA coarse-graining engine = DESCRIPTION = Versatile Object-oriented Toolkit for Coarse-graining Applications (VOTCA) is a package intended to reduce the amount of routine work when doing systematic coarse-graining of various systems. The core is written in C++. Iterative methods are implemented using bash + perl. Please visit the program site at __http://www.votca.org__. = SYNOPSIS = The following commands make up the votca-csg suite. Please refer to their individual man pages for further details. : **csg_boltzmann** Performs tasks that are needed for simple Boltzmann inversion in an interactive environment. : **csg_call** Calls script from the interactive framework for the user. : **csg_density** Calculates all kind of density profiles. : **csg_dump** Prints atoms that are read from a topology file to help debug atom naming. : **csg_fmatch** Performs force matching (also called //multiscale coarse-graining//). : **csg_gmxtopol** Create skeleton for gromacs topology based on atomistic topology and a mapping file. : **csg_imcrepack** Is internally called by inversion scripts to kick out zero entries in the matrix for inverse Monte Carlo (imc). : **csg_inverse** Starts the script to run iterative Boltzmann inverse (ibi) or inverse Monte Carlo (imc), etc. : **csg_map** Map a reference trajectory to a coarse-grained trajectory. : **csg_part_dist** Outputs the time-averaged number of particles, listed by particle types. : **csg_property** Helper program called by inverse scripts to parse xml file. : **csg_resample** Changes grid + interval and interpolated any sort of table files. : **csg_stat** Calculates all kind of distribuions (bonded + non-bonded). : **multi_g_rdf** A multiplexed version of g_rdf = AUTHORS = Written and maintained by the VOTCA Development Team This Manual Page converted from t2t format to the this format by [txt2tags http://txt2tags.org] ! = COPYRIGHT = Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. votca-csg-1.2.4/share/scripts/0000755000175000001440000000000012400714673016123 5ustar christophusersvotca-csg-1.2.4/share/scripts/inverse/0000755000175000001440000000000012400714673017576 5ustar christophusersvotca-csg-1.2.4/share/scripts/inverse/resample_target.sh0000755000175000001440000000350712400714673023320 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <&4 echo -e "$*" >&2 else echo -e "${color}$*${off}" >&2 fi else [[ -z $* ]] && return if [[ -n ${CSGLOG} ]]; then echo -e "${color}$*${off}" >&3 echo -e "$*" else echo -e "${color}$*${off}" fi fi } export -f msg unset -f die die () { #make the iterative frame work stopp local pid pids c msg --color red --to-stderr "$(csg_banner "ERROR:" "$@")" [[ -z $CSGLOG ]] || msg --color blue "For details see $CSGLOG" if [[ -n ${CSG_MASTER_PID} ]]; then #grabbing the pid group would be easier, but it would not work on AIX pid="$$" pids="$$" c=0 #find the parent of pid until we reach CSG_MASTER_PID until [[ ${CSG_MASTER_PID} -eq $pid ]]; do #get the parent pid using BSD style due to AIX pid=$(ps -o ppid= -p "$pid" 2>/dev/null) #store them in inverse order to kill parents before the child pids="$pid $pids" ((c++)) #at max 10000 iterations if [[ $c -eq 10000 ]]; then #failback to default, see comment below pids="0" break fi done if [[ -n ${CSGLOG} ]]; then echo "die: (called from $$) CSG_MASTER_PID is $CSG_MASTER_PID" >&2 echo "die: pids to kill: $pids" >&2 fi kill $pids else #send kill signal to all process within the process groups kill 0 fi exit 1 } export -f die cat_external() { #takes a two tags and shows content of the according script local script script="$(source_wrapper $1 $2)" || die "cat_external: source_wrapper $1 $2 failed" cat "${script/ *}" } export -f cat_external do_external() { #takes two tags, find the according script and excute it local script tags quiet="no" [[ $1 = "-q" ]] && quiet="yes" && shift script="$(source_wrapper $1 $2)" || die "do_external: source_wrapper $1 $2 failed" tags="$1 $2" shift 2 [[ $quiet = "no" ]] && echo "Running subscript '${script##*/} $*'(from tags $tags)" if [[ -n $CSGDEBUG && -n "$(sed -n '1s@bash@XXX@p' "$script")" ]]; then bash -x $script "$@" elif [[ -n $CSGDEBUG && -n "$(sed -n '1s@perl@XXX@p' "$script")" ]]; then local perl_debug="$(mktemp perl_debug.XXX)" ret PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2 LineInfo=$perl_debug" perl -dS $script "$@" ret=$? cat "$perl_debug" 2>&1 [[ $ret -eq 0 ]] else $script "$@" fi || die "do_external: subscript $script $* (from tags $tags) failed" } export -f do_external critical() { #executes arguments as command and calls die if not succesful local quiet="no" [[ $1 = "-q" ]] && quiet="yes" && shift [[ -z $1 ]] && die "critical: missing argument" #print this message to stderr because $(critical something) is used very often [[ $quiet = "no" ]] && echo "Running critical command '$*'" >&2 "$@" || die "critical: '$*' failed" } export -f critical for_all (){ #do something for all interactions (1st argument) local bondtype name interactions quiet="no" [[ $1 = "-q" ]] && quiet="yes" && shift [[ -z $1 || -z $2 ]] && "for_all need at least two arguments" bondtype="$1" shift #check that type is bonded or non-bonded if [[ $bondtype != "non-bonded" ]]; then die "for_all: Argmuent 1 '$bondtype' is not non-bonded" fi [[ $quiet = "no" ]] && echo "For all $bondtype" >&2 check_for_duplicated_interactions interactions="$(csg_get_property cg.non-bonded.name)" for name in $interactions; do #print this message to stderr to avoid problem with $(for_all something) [[ $quiet = no ]] && echo "for_all: run '$*'" >&2 #we need to use bash -c here to allow things like $(csg_get_interaction_property name) in arguments #write variable defines in the front is better, that export #no need to run unset afterwards bondtype="$bondtype" \ bondname="$name" \ bash -c "$*" || die "for_all: bash -c '$*' failed for bondname '$name'" done } export -f for_all check_for_duplicated_interactions() { #checks for duplicated interactions local i j names=( $(csg_get_property cg.non-bonded.name) ) for ((i=0;i<${#names[@]};i++)); do for ((j=i+1;j<${#names[@]};j++)); do [[ ${names[$i]} = ${names[$j]} ]] && die "for_all: the interaction name '${names[$i]}' appeared twice, this is not allowed" done done } export -f check_for_duplicated_interactions csg_get_interaction_property () { #gets an interaction property from the xml file, should only be called from inside a for_all loop local ret allow_empty cmd if [[ $1 = "--allow-empty" ]]; then shift allow_empty="yes" else allow_empty="no" fi [[ -n $1 ]] || die "csg_get_interaction_property: Missing argument" [[ -n $bondtype ]] || die "csg_get_interaction_property: bondtype is undefined (when calling from csg_call set it by --ia-type option)" #bondtype is special -> dirty hack - removed whenever issue 13 is fixed #make these this case work even without name (called by csg_call) [[ $1 = "bondtype" ]] && echo "$bondtype" && return 0 [[ -n $bondname ]] || die "csg_get_interaction_property: bondname is undefined (when calling from csg_call set it by --ia-name option)" #make these this case work even without xml file (called by csg_call) [[ $1 = "name" ]] && echo "$bondname" && return 0 [[ -n $CSGXMLFILE ]] || die "csg_get_interaction_property: CSGXMLFILE is undefined (when calling from csg_call set it by --options option)" [[ -n "$(type -p csg_property)" ]] || die "csg_get_interaction_property: Could not find csg_property" cmd="csg_property --file $CSGXMLFILE --short --path cg.${bondtype} --filter name=$bondname --print $1" #the --filter option will make csg_property fail if $1 does not exist, don't stop if we have an default if ! ret="$($cmd)"; then [[ $allow_empty = "no" && -z $2 ]] && \ die "csg_get_interaction_property:\n'$cmd'\nfailed geting '$1' for interaction '$bondname' with error msg:\n $ret\n and no default for $1" #ret has error message ret="" fi ret="$(echo "$ret" | trim_all)" [[ $allow_empty = no && -z $ret && -n $2 ]] && ret="$2" [[ $allow_empty = no && -z $ret ]] && die "csg_get_interaction_property: Could not get '$1' for interaction '$bondname'\nResult of '$cmd' was empty" echo "${ret}" } export -f csg_get_interaction_property csg_get_property () { #get an property from the xml file local ret allow_empty cmd if [[ $1 = "--allow-empty" ]]; then shift allow_empty="yes" else allow_empty="no" fi [[ -n $1 ]] || die "csg_get_property: Missing argument" [[ -n $CSGXMLFILE ]] || die "csg_get_property: CSGXMLFILE is undefined (when calling from csg_call set it by --options option)" [[ -n "$(type -p csg_property)" ]] || die "csg_get_property: Could not find csg_property" cmd="csg_property --file $CSGXMLFILE --path ${1} --short --print ." #csg_property only fails if xml file is bad otherwise result is empty ret="$(critical -q $cmd)" ret="$(echo "$ret" | trim_all)" [[ -z $ret && -n $2 ]] && ret="$2" [[ $allow_empty = "no" && -z $ret ]] && die "csg_get_property: Could not get '$1'\nResult of '$cmd' was empty" echo "${ret}" } export -f csg_get_property trim_all() { #strips white space from beginning and the end of all args tr '\n' ' ' | sed -e s'/^[[:space:]]*//' -e s'/[[:space:]]*$//' || die "${FUNCNAME[0]}: sed of argument $i failed" } export -f trim_all mark_done () { #mark a task (1st argument) as done in the restart file local file [[ -n $1 ]] || die "mark_done: Missing argument" file="$(get_restart_file)" is_done "$1" || echo "$1 done" >> "${file}" } export -f mark_done is_done () { #checks if something is already do in the restart file local file [[ -n $1 ]] || die "is_done: Missing argument" file="$(get_restart_file)" [[ -f ${file} ]] || return 1 [[ -n "$(sed -n "/^$1 done\$/p" ${file})" ]] && return 0 return 1 } export -f is_done int_check() { #checks if 1st argument is a integer or calls die with error message (2nd argument) [[ -n $2 ]] || die "int_check: Missing argument" [[ -n $1 && -z ${1//[0-9]} ]] && return 0 shift die "$*" } export -f int_check num_check() { #checks if 1st argument is a number or calls die with error message (2nd argument) local res [[ -n $1 || -n $2 ]] || die "num_check: Missing argument" res=$(awk -v x="$1" 'BEGIN{ print ( x+0==x ) }') [[ $res -eq 1 ]] && return 0 shift die "$*" } export -f num_check get_stepname() { #get the dir name of a certain step number (1st argument) local name [[ -n $1 ]] || die "get_stepname: Missing argument" if [[ $1 = "--trunc" ]]; then echo "step_" return 0 fi int_check "${1#-}" "get_stepname: needs a int as argument, but was $1" name="$(printf step_%03i "$1")" [[ -z $name ]] && die "get_stepname: Could not get stepname" echo "$name" } export -f get_stepname update_stepnames(){ #updated the current working step to a certain number (1st argument) local thisstep laststep nr [[ -n $1 ]] || die "update_stepnames: Missing argument" nr="$1" int_check "$nr" "update_stepnames: needs a int as argument" [[ -z $CSG_MAINDIR ]] && die "update_stepnames: CSG_MAINDIR is undefined" [[ -d $CSG_MAINDIR ]] || die "update_stepnames: $CSG_MAINDIR is not dir" thisstep="$(get_stepname $nr)" laststep="$(get_stepname $((nr-1)) )" export CSG_THISSTEP="$CSG_MAINDIR/$thisstep" export CSG_LASTSTEP="$CSG_MAINDIR/$laststep" } export -f update_stepnames get_current_step_dir() { #print the directory of the current step [[ -z $CSG_THISSTEP ]] && die "get_current_step_dir: \$CSG_THISSTEP is undefined (when calling from csg_call export it yourself)" if [[ $1 = "--no-check" ]]; then : else [[ -d $CSG_THISSTEP ]] || die "get_last_step_dir: $CSG_THISSTEP is not dir" fi echo "$CSG_THISSTEP" } export -f get_current_step_dir get_last_step_dir() { #print the directory of the last step [[ -z $CSG_LASTSTEP ]] && die "get_last_step_dir: CSG_LASTSTEP is undefined (when calling from csg_call export it yourself)" [[ -d $CSG_LASTSTEP ]] || die "get_last_step_dir: $CSG_LASTSTEP is not dir" echo "$CSG_LASTSTEP" } export -f get_last_step_dir get_main_dir() { #print the main directory [[ -z $CSG_MAINDIR ]] && die "get_main_dir: CSG_MAINDIR is defined" [[ -d $CSG_MAINDIR ]] || die "update_stepnames: $CSG_MAINDIR is not dir" echo "$CSG_MAINDIR" } export -f get_main_dir get_current_step_nr() { #print the main directory local name nr name=$(get_current_step_dir) nr=$(get_step_nr $name) echo "$nr" } export -f get_current_step_nr get_step_nr() { #print the number of a certain step directory (1st argument) local nr trunc trunc=$(get_stepname --trunc) [[ -n $1 ]] || die "get_step_nr: Missing argument" nr=${1##*/} nr=${nr#$trunc} #convert to base 10 and cut leading zeros nr=$((10#$nr)) int_check "$nr" "get_step_nr: Could not fetch step nr" echo "$nr" } export -f get_step_nr cp_from_main_dir() { #copy something from the main directory if [[ $1 = "--rename" ]]; then shift [[ $# -eq 2 && -n $1 && -n $2 ]] || die "cp_from_main_dir: with --rename option has to be called with exactly 2 (non-empty) arguments" echo "cp_from_main_dir: '$1' to '$2'" critical pushd "$(get_main_dir)" critical cp $1 "$(dirs -l +1)/$2" critical popd else echo "cp_from_main_dir: '$@'" critical pushd "$(get_main_dir)" critical cp $@ "$(dirs -l +1)" critical popd fi } export -f cp_from_main_dir cp_from_last_step() { #copy something from the last step if [[ $1 = "--rename" ]]; then shift [[ $# -eq 2 && -n $1 && -n $2 ]] || die "cp_from_last_step: with --rename option has to be called with exactly 2 (non-empty) arguments" echo "cp_from_last_step: '$1' to '$2'" critical pushd "$(get_last_step_dir)" critical cp $1 "$(dirs -l +1)/$2" critical popd else echo "cp_from_last_step: '$@'" critical pushd "$(get_last_step_dir)" critical cp $@ "$(dirs -l +1)" critical popd fi } export -f cp_from_last_step get_time() { date +%s || die "get_time: date +%s failed" } export -f get_time get_number_tasks() { #get the number of possible tasks from the xml file or determine it automatically under linux local tasks tasks="$(csg_get_property cg.inverse.simulation.tasks "auto")" [[ $tasks = "auto" ]] && tasks=0 int_check "$tasks" "get_number_tasks: cg.inverse.parallel.tasks needs to be a number or 'auto'" #this only work for linux if [[ $tasks -eq 0 && -r /proc/cpuinfo ]]; then tasks=$(sed -n '/processor/p' /proc/cpuinfo | sed -n '$=') [[ -z ${tasks//[0-9]} ]] || tasks=1 fi [[ $tasks -le 1 ]] && tasks=1 echo "$tasks" } export -f get_number_tasks get_table_comment() { #get comment lines from a table and add common information, which include the hgid and other information local version co [[ -n "$(type -p csg_call)" ]] || die "get_defaults_comment: Could not find csg_version" version="$(csg_call --version)" || die "get_defaults_comment: csg_call --version failed" echo "Created on $(date) by $USER@$HOSTNAME" echo "called from $version" | sed "s/csg_call/${0##*/}/" [[ -n ${CSGXMLFILE} ]] && echo "settings file: $(globalize_file $CSGXMLFILE)" echo "working directory: $PWD" if [[ -f $1 ]]; then co=$(sed -n 's/^[#@][[:space:]]*//p' "$1") || die "get_table_comment: sed failed" [[ -n $co ]] && echo "Comments from $(globalize_file $1):\n$co" fi } export -f get_table_comment csg_inverse_clean() { #clean out the main directory local i files log log="$(csg_get_property cg.inverse.log_file "inverse.log")" echo -e "So, you want to clean?\n" echo "I will remove:" files="$(ls -d done ${log} $(get_stepname --trunc)* *~ 2>/dev/null)" if [[ -z $files ]]; then echo "Nothing to clean" else msg --color red $files msg --color blue "\nCTRL-C to stop it" for ((i=10;i>0;i--)); do echo -n "$i " sleep 1 done rm -rf $files msg --color green "\n\nDone, hope you are happy now" fi } export -f csg_inverse_clean add_to_csgshare() { #added an directory to the csg internal search directories local dir for dir in "$@"; do [[ -z $dir ]] && die "add_to_csgshare: Missing argument" #dir maybe contains $PWD or something eval dir="$dir" dir="$(globalize_dir "$dir")" export CSGSHARE="$dir${CSGSHARE:+:}$CSGSHARE" export PERL5LIB="$dir${PERL5LIB:+:}$PERL5LIB" done } export -f add_to_csgshare globalize_dir() { #convert a local directory to a global one [[ -z $1 ]] && die "globalize_dir: missing argument" [[ -d $1 ]] || die "globalize_dir: '$1' is not a dir" cd "$1" pwd } export -f globalize_dir globalize_file() { #convert a local file name to a global one [[ -z $1 ]] && die "globalize_file: missing argument" [[ -f $1 ]] || die "globalize_file: '$1' is not a file" local dir [[ ${1%/*} = ${1} ]] && dir="." || dir="${1%/*}" echo "$(globalize_dir "$dir")/${1##*/}" } export -f globalize_file source_function() { #source an extra function file local function_file [[ -n $1 ]] || die "source_function: Missing argument" function_file=$(source_wrapper functions $1) || die "source_function: source_wrapper functions $1 failed" source ${function_file} || die "source_function: source ${function_file} failed" } export -f source_function csg_banner() { #print a big banner local i l=0 list=() [[ -z $1 ]] && return 0 for i in "$@"; do while [[ -n $i && -z ${i/*\\n*} ]]; do list[$l]="${i%%\\n*}" ((l++)) i="${i#*\\n}" done list[$l]=$i ((l++)) done l="1" for i in "${list[@]}"; do [[ ${#l} -lt ${#i} ]] && l="${i}" done echo "####${l//?/#}" echo "# ${l//?/ } #" for i in "${list[@]}"; do printf "# %-${#l}s #\n" "$i" done echo "# ${l//?/ } #" echo "####${l//?/#}" } export -f csg_banner csg_calc() { #simple calculator, a + b, ... local res ret=0 err="1e-2" [[ -z $1 || -z $2 || -z $3 ]] && die "csg_calc: Needs 3 arguments, but got '$*'" num_check "$1" "csg_calc: First argument should be a number, but found '$1'" num_check "$3" "csg_calc: Third argument should be a number, but found '$3'" [[ -n "$(type -p awk)" ]] || die "csg_calc: Could not find awk" #we use awk -v because then " 1 " or "1\n" is equal to 1 case "$2" in "+"|"-"|'*'|"/"|"^") res="$(awk -v x="$1" -v y="$3" "BEGIN{print ( x $2 y ) }")" || die "csg_calc: awk -v x='$1' -v y='$3' 'BEGIN{print ( x $2 y ) }' failed" true;; '>'|'<' ) res="$(awk -v x="$1" -v y="$3" "BEGIN{print ( x $2 y )}")" || die "csg_calc: awk -v x='$1' -v y='$3' 'BEGIN{print ( x $2 y )}' failed" #awk return 1 for true and 0 for false, shell exit codes are the other way around ret="$((1-$res))" #return value matters res="" true;; "="|"==") #we expect that x and y are close together res="$(awk -v x="$1" -v y="$3" "BEGIN{print ( sqrt(((x-y)/x)^2) < $err )}")" || die "csg_calc: awk -v x='$1' -v y='$3' 'BEGIN{print ( sqrt(((x-y)/x)^2) < $err )}' failed" #awk return 1 for true and 0 for false, shell exit codes are the other way around ret="$((1-$res))" #return value matters res="" true;; *) die "csg_calc: unknow operation" true;; esac [[ -n $res ]] && echo "$res" return $ret } export -f csg_calc show_csg_tables() { #show all concatinated csg tables local old_IFS dir old_IFS="$IFS" IFS=":" echo "#The order in which scripts get called" for dir in ${CSGSHARE}; do [[ -f $dir/csg_table ]] || continue echo "#From: $dir/csg_table" #remove comments and empty line, trim begin and end, tab to spaces sed -e '/^#/d' -e '/^[[:space:]]*$/d' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\+/ /g' "$dir/csg_table" done IFS="$old_IFS" } export -f show_csg_tables get_command_from_csg_tables() { #print the name of script belonging to certain tags (1st, 2nd argument) [[ -z $1 || -z $2 ]] && die "get_command_from_csg_tables: Needs two tags" show_csg_tables | \ sed -e '/^#/d' | \ sed -n "s/^$1 $2 \(.*\)$/\1/p" | \ sed -n '1p' } export -f get_command_from_csg_tables source_wrapper() { #print the full name of a script belonging to two tags (1st, 2nd argument) [[ -z $1 || -z $2 ]] && die "source_wrapper: Needs two tags" local cmd script cmd=$(get_command_from_csg_tables "$1" "$2") || die [[ -z $cmd ]] && die "source_wrapper: Could not get any script from tags '$1' '$2'" script="${cmd/* }" real_script="$(find_in_csgshare "$script")" echo "${cmd/${script}/${real_script}}" } export -f source_wrapper find_in_csgshare() { #find a script in csg script search path [[ -z $1 ]] && die "find_in_csgshare: missing argument" #global path if [[ -z ${1##/*} ]]; then [[ -f $1 ]] || die "find_in_csgshare: $1 is a script with global path, but was not found" echo "$1" && return fi local old_IFS dir old_IFS="$IFS" IFS=":" for dir in ${CSGSHARE}; do [[ -f $dir/$1 ]] && break done IFS="$old_IFS" [[ -f $dir/$1 ]] && echo "$dir/$1" && return die "find_in_csgshare: Could not find script $1 in $CSGSHARE" } export -f find_in_csgshare if [ -z "$(type -p mktemp)" ]; then #do not document this mktemp() { [[ -z $1 ]] && die "mktemp: missing argument" [[ -z ${1##*X} ]] || die "mktemp: argument has to end at least with X" local end trunc i l tmp newend end=${1##*[^X]} trunc=${1%${end}} l=${end//[^X]} l=${#l} while true; do newend="$end" for ((i=0;i<$l;i++)); do newend="${newend/X/${RANDOM:0:1}}" done tmp="${trunc}${newend}" [[ -f $tmp ]] || break done echo "$tmp" } export -f mktemp fi enable_logging() { #enables the logging to a certain file (1st argument) or the logfile taken from the xml file local log if [[ -z $1 ]]; then log="$(csg_get_property cg.inverse.log_file "inverse.log")" else log="$1" fi log="${PWD}/${log##*/}" export CSGLOG="$log" if [[ -f $CSGLOG ]]; then exec 3>&1 4>&2 >> "$CSGLOG" 2>&1 echo "\n\n#################################" echo "# Appending to existing logfile #" echo "#################################\n\n" msg --color blue "Appending to existing logfile ${CSGLOG##*/}" else exec 3>&1 4>&2 >> "$CSGLOG" 2>&1 msg "For a more verbose log see: ${CSGLOG##*/}" fi } export -f enable_logging get_restart_file() { #print the name of the restart file to use local file file="$(csg_get_property cg.inverse.restart_file "restart_points.log")" [[ -z ${file/*\/*} ]] && die "get_restart_file: cg.inverse.restart_file has to be a local file with slash '/'" echo "$file" } export -f get_restart_file check_for_obsolete_xml_options() { #check xml file for obsolete options local i for i in cg.inverse.mpi.tasks cg.inverse.mpi.cmd cg.inverse.parallel.tasks cg.inverse.parallel.cmd \ cg.inverse.gromacs.mdrun.bin cg.inverse.espresso.bin; do [[ -z "$(csg_get_property --allow-empty $i)" ]] && continue #filter me away case $i in cg.inverse.parallel.cmd|cg.inverse.mpi.cmd) new="";; cg.inverse.mpi.tasks|cg.inverse.parallel.tasks) new="cg.inverse.simulation.tasks";; cg.inverse.gromacs.mdrun.bin|cg.inverse.espresso.bin) new="${i/bin/command}";; *) die "check_for_obsolete_xml_options: Unknown new name for obsolete xml option '$i'";; esac [[ -n $new ]] && new="has been renamed to $new" || new="has been removed" die "The xml option $i $new\nPlease remove the obsolete options from the xmlfile" done } export -f check_for_obsolete_xml_options command_not_found_handle() { #print and error message if a command or a function was not found die "Command/function $1 not found (when calling from csg_call you might need to add --simprog option or set cg.inverse.program in the xml file)" } export -f command_not_found_handle #in bash4 this is not needed, but for older bash we add add a failback from most important simulation functions for i in simulation_finish checkpoint_exist get_simulation_setting; do eval $i\(\) { command_not_found_handle $i\; } eval export -f $i done unset i votca-csg-1.2.4/share/scripts/inverse/CsgFunctions.pm0000644000175000001440000001474612400714673022555 0ustar christophuserspackage CsgFunctions; # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; require Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(csg_function_help csg_get_property csg_get_interaction_property readin_table readin_data saveto_table saveto_table_err readin_table_err); sub csg_function_help() { print <; while(){ $value.=$_; } $value="$_[1]" if ((not defined($value)) and defined($_[1])); defined($value) || die "csg_get_property: Could not get value $_[0] and no default given\n"; close(CSG) || die "csg_get_property: error from csg_property\n"; $value =~ s/\n/ /mg; $value =~ s/^\s*//; $value =~ s/\s*$//; return undef if ($value =~ /^\s*$/); return $value; } sub csg_get_interaction_property($;$){ ( my $bondname=$ENV{'bondname'} ) || die "bondname: ENV{'bondname'} was undefined\n"; ( my $bondtype=$ENV{'bondtype'} ) || die "bondtype: ENV{'bondtype'} was undefined\n"; ( my $xmlfile=$ENV{'CSGXMLFILE'} ) || die "csg_get_property: ENV{'CSGXMLFILE'} was undefined\n"; defined($_[0]) || die "csg_get_interaction_property: Missing argument\n"; open(CSG,"csg_property --file $xmlfile --short --path cg.$bondtype --filter \"name=$bondname\" --print $_[0] 2>&1 |") || die "csg_get_interaction_property: Could not open pipe\n"; my $value=; while(){ $value.=$_; } if (close(CSG)){ #we do not have a return errors $value="$_[1]" if (($value =~ /^\s*$/) and (defined($_[1]))); } else { #we do have a return errors if (defined($_[1])) { $value="$_[1]"; } else { die "csg_get_interaction_property: csg_property failed on getting value $_[0] and no default given\n"; } } $value =~ s/\n/ /mg; $value =~ s/^\s*//; $value =~ s/\s*$//; return undef if ($value =~ /^\s*$/); return $value; } sub readin_table($\@\@\@;\$) { defined($_[3]) || die "readin_table: Missing argument\n"; open(TAB,"$_[0]") || die "readin_table: could not open file $_[0]\n"; my $line=0; while (){ $line++; ${$_[4]}.=$_ if (defined($_[4]) and (/^[#@]/)); next if /^[#@]/; # remove leading spacees for split $_ =~ s/^\s*//; next if /^\s*$/; my @parts=split(/\s+/); defined($parts[2]) || die "readin_table: Not enought columns in line $line in file $_[0]\n"; ($parts[$#parts] =~ /[iou]/) || die "readin_table: Wrong flag($parts[$#parts]) for r=$parts[0] in file $_[0]\n"; #very trick array dereference (@) of pointer to an array $_[.] stored in an array $_ push(@{$_[1]},$parts[0]); push(@{$_[2]},$parts[1]); push(@{$_[3]},$parts[$#parts]); } close(TAB) || die "readin_table: could not close file $_[0]\n"; return $line; } sub readin_table_err($\@\@\@\@;\$) { defined($_[4]) || die "readin_table_err: Missing argument\n"; open(TAB,"$_[0]") || die "readin_table_err: could not open file $_[0]\n"; my $line=0; while (){ $line++; ${$_[5]}.=$_ if (defined($_[4]) and (/^[#@]/)); # remove leading spacees for split $_ =~ s/^\s*//; next if /^[#@]/; next if /^\s*$/; my @parts=split(/\s+/); defined($parts[3]) || die "readin_table_err: Not enought columns in line $line in file $_[0]\n"; ($parts[$#parts] =~ /[iou]/) || die "readin_table_err: Wrong flag($parts[$#parts]) for r=$parts[0] in file $_[0]\n"; #very trick array dereference (@) of pointer to an array $_[.] stored in an array $_ push(@{$_[1]},$parts[0]); push(@{$_[2]},$parts[1]); push(@{$_[3]},$parts[2]); push(@{$_[4]},$parts[$#parts]); } close(TAB) || die "readin_table_err: could not close file $_[0]\n"; return $line; } sub readin_data($$\@\@) { defined($_[3]) || die "readin_data: Missing argument\n"; open(TAB,"$_[0]") || die "readin_table: could not open file $_[0]\n"; my $line=0; my $column=int($_[1]); while (){ $line++; # remove leading spacees for split $_ =~ s/^\s*//; next if /^[#@]/; next if /^\s*$/; my @parts=split(/\s+/); defined($parts[1]) || die "readin_table: Not enought columns in line $line in file $_[0]\n"; die "readin_data: Can't read column $column\n" unless (defined($parts[$column])); #very trick array dereference (@) of pointer to an array $_[.] stored in an array $_ push(@{$_[2]},$parts[0]); push(@{$_[3]},$parts[$column]); } close(TAB) || die "readin_table: could not close file $_[0]\n"; return $line; } sub saveto_table($\@\@\@;$) { defined($_[3]) || die "saveto_table: Missing argument\n"; open(OUTFILE,"> $_[0]") or die "saveto_table: could not open $_[0] \n"; print OUTFILE "$_[4]" if (defined $_[4]); for(my $i=0;$i<=$#{$_[1]};$i++){ print OUTFILE "${$_[1]}[$i] ${$_[2]}[$i] ${$_[3]}[$i]\n"; } close(OUTFILE) or die "Error at closing $_[0]\n"; return 1; } sub saveto_table_err($\@\@\@\@;$) { defined($_[3]) || die "saveto_table: Missing argument\n"; open(OUTFILE,"> $_[0]") or die "saveto_table: could not open $_[0] \n"; print OUTFILE "$_[5]" if (defined $_[5]); for(my $i=0;$i<=$#{$_[1]};$i++){ print OUTFILE "${$_[1]}[$i] ${$_[2]}[$i] ${$_[3]}[$i] ${$_[4]}[$i]\n"; } close(OUTFILE) or die "Error at closing $_[0]\n"; return 1; } #important 1; votca-csg-1.2.4/share/scripts/inverse/dummy.sh0000755000175000001440000000145512400714673021275 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")){ print <$gmx_max; $pot[$i]=-$gmx_max if $pot[$i]<-$gmx_max; } } my @force; #calc force for (my $i=1;$i<$#r;$i++){ $force[$i]=-($pot[$i+1]-$pot[$i-1])/($r[$i+1]-$r[$i-1]); } if ( "$type" eq "dihedral" ) { $force[0]=-($pot[1]-$pot[$#r-1])/($r[1]-$r[0]+$r[$#r]-$r[$#r-1]); $force[$#r]=$force[0]; } else { $force[0]=0; $force[$#r]=0.0; } open(OUTFILE,"> $outfile") or die "saveto_table: could not open $outfile\n"; my $fmt=undef; my $begin=0; my $end=undef; if (( "$type" eq "non-bonded" ) or ("$type" eq "C12" )) { $fmt=sprintf("%%15.10e %15.10e %15.10e %15.10e %15.10e %%15.10e %%15.10e\n",0,0,0,0); } elsif ( "$type" eq "C6" ){ $fmt=sprintf("%%15.10e %15.10e %15.10e %%15.10e %%15.10e %15.10e %15.10e\n",0,0,0,0); } elsif ( "$type" eq "bonded" ){ $fmt="%15.10e %15.10e %15.10e\n"; } elsif ( "$type" eq "angle" ){ $fmt="%15.10e %15.10e %15.10e\n"; $end=180; } elsif ( "$type" eq "dihedral" ){ $fmt="%15.10e %15.10e %15.10e\n"; $begin=-180; $end=180; } elsif ( "$type" eq "thermforce" ){ $fmt="%15.10e %15.10e %15.10e\n"; } else{ die "$progname: Unsupported type of interatction: $type -> go and implement it\n"; } die "$progname: table for type $type should begin with $begin, but I found $r[0]\n" if(abs($begin-$r[0]) > 1e-3); die "$progname: table for type $type should end with $end, but I found $r[$#r]\n" if(($end) and (abs($end-$r[$#r]) > 1e-3)); print OUTFILE "$comments" if (defined($comments)); for(my $i=0;$i<=$#r;$i++){ printf(OUTFILE "$fmt",$r[$i],$pot[$i], $force[$i]); } close(OUTFILE) or die "Error at closing $outfile\n"; votca-csg-1.2.4/share/scripts/inverse/table_to_tab.pl0000755000175000001440000000521712400714673022562 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print < $outfile") or die "saveto_table: could not open $outfile\n"; # espresso specific header - no other starting comments my $num_bins = $table_end/$table_bins; printf(OUTFILE "#%d 0 %f\n", $num_bins, $table_end); for(my $i=0;$i<=$#r;$i++){ printf(OUTFILE "%15.10e %15.10e %15.10e\n", $r[$i], $force[$i], $pot[$i]); } close(OUTFILE) or die "Error at closing $outfile\n"; votca-csg-1.2.4/share/scripts/inverse/RDF_to_POT.pl0000755000175000001440000000551012400714673021776 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print <1e-10) { $pot[$i]=-$pref*log($rdf[$i]); } else { $pot[$i]="nan"; $flag[$i]="u"; } # } } #find first defined value (begining for r=0) #but it is more stable to search first undefined value begin #beginning form large r my $first_undef_bin=-1; for (my $i=$#pot;$i>=0;$i--){ if ($flag[$i] eq "u") { $first_undef_bin=$i; last; } } die "All data points from file '$infile' are invalid after Boltzmann inversion, please check if your distribution is a valid rdf.\n" if ($first_undef_bin==$#pot); #find i which is the cutoff my $i_cut=$#r; for (my $nr=0;$nr<=$#r;$nr++){ if ($r[$nr]>=$r_cut) { $i_cut=$nr; last; } } #shift potential so that it is zero at cutoff #first do the shift, then extrapolation for (my $i=0;$i<=$i_cut;$i++){ $pot[$i]-=$pot[$i_cut] unless ($flag[$i] =~ /[u]/); } #quadratic extrapolation at the begining my $slope=$pot[$first_undef_bin+1]-$pot[$first_undef_bin+2]; for (my $i=$first_undef_bin;$i>=0;$i--){ $slope+=$slope; $pot[$i]=$pot[$i+1]+$slope; $flag[$i]="o"; } # set end of the potential to zero for (my $i=$i_cut;$i<$#flag;$i++) { $pot[$i]=0; $flag[$i]="o"; } saveto_table($outfile,@r,@pot,@flag) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/prepare_generic.sh0000755000175000001440000000175412400714673023276 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <$p_target){ $pref=-0.1*$kBT; } else { $pref=0.1*$kBT; } #Determine pressure factor my $p_factor=($p_now-$p_target)*$scale_factor; $p_factor=-$p_factor if $p_factor<0; #Only use pressure factor if not too big #max is 0.1kbT $pref*=$p_factor if $p_factor<1; my @r; my @pot; my @flag; my $outfile="$ARGV[1]"; my $comment="#$progname: p_now=$p_now, p_target=$p_target, prefactor=$pref\n"; for(my $i=$min/$delta_r;$i<=$max/$delta_r;$i++){ $r[$i]=$i*$delta_r; $pot[$i]=$pref*(1-$r[$i]/$max); $flag[$i]="i"; } saveto_table($outfile,@r,@pot,@flag,$comment) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/dpot_shift_nb.pl0000755000175000001440000000263012400714673022761 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print < \n" if ($#ARGV<1); use CsgFunctions; my $infile="$ARGV[0]"; my $outfile="$ARGV[1]"; # read in the current dpot my @r; my @dpot; my @flag; my $comments; (readin_table($infile,@r,@dpot,@flag,$comments)) || die "$progname: error at readin_table\n"; # bring end to zero for(my $i=0; $i<=$#r; $i++) { $dpot[$i] -= $dpot[$#r]; } # save to file saveto_table($outfile,@r,@dpot,@flag,$comments) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/table_get_value.pl0000755000175000001440000000360612400714673023265 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; $_=$0; s#^.*/##; my $progname=$_; my $usage="Usage: $progname [OPTIONS] X infile"; # read program arguments while ((defined ($ARGV[0])) and ($ARGV[0] =~ /^-./)) { if (($ARGV[0] !~ /^--/) and (length($ARGV[0])>2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < 0; use CsgFunctions; my $X="$ARGV[0]"; my $infile="$ARGV[1]"; my @x; my @y; my @flag; (readin_table($infile,@x,@y,@flag)) || die "$progname: error at readin_table\n"; my $value=$y[0]; for(my $i=1; $i<=$#x; $i++) { if($x[$i]<$X) { $value=$y[$i]; } else { $value=$y[$i] unless (($x[$i]-$X)>($X-$x[$i-1])); print "$value\n"; exit 0; } } die "$progname: value $X not found\n"; votca-csg-1.2.4/share/scripts/inverse/potential_to_gromacs.sh0000755000175000001440000000763512400714673024364 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat < cg.inverse.gromacs.table_end ($tablend)" [[ -z $tablend ]] && tablend=$(csg_calc "$rlist" + "$tabext") elif [[ -z $tablend ]]; then die "${0##*/}: cg.inverse.gromacs.table_end was not defined in xml seeting file" fi elif [[ $tabtype = "bonded" || $tabtype = "thermforce" ]]; then tablend="$(csg_get_property cg.inverse.gromacs.table_end)" elif [[ $tabtype = "angle" ]]; then tablend=180 elif [[ $tabtype = "dihedral" ]]; then zero="-180" tablend=180 fi gromacs_bins="$(csg_get_property cg.inverse.gromacs.table_bins)" comment="$(get_table_comment $input)" smooth="$(critical mktemp ${name}.pot.smooth.XXXXX)" critical csg_resample --in ${input} --out "$smooth" --grid "${zero}:${gromacs_bins}:${tablend}" --comment "$comment" extrapol="$(critical mktemp ${name}.pot.extrapol.XXXXX)" tshift="$(critical mktemp ${name}.pot.shift.XXXXX)" if [[ $tabtype = "non-bonded" || $tabtype = "C6" || $tabtype = "C12" ]]; then extrapol1="$(critical mktemp ${name}.pot.extrapol2.XXXXX)" do_external table extrapolate --function exponential --avgpoints 5 --region left "${smooth}" "${extrapol1}" do_external table extrapolate --function constant --avgpoints 1 --region right "${extrapol1}" "${extrapol}" do_external pot shift_nonbonded "${extrapol}" "${tshift}" elif [[ $tabtype = "thermforce" ]]; then do_external table extrapolate --function constant --avgpoints 5 --region leftright "${smooth}" "${extrapol}" do_external pot shift_bonded "${extrapol}" "${tshift}" else do_external table extrapolate --function exponential --avgpoints 5 --region leftright "${smooth}" "${extrapol}" do_external pot shift_bonded "${extrapol}" "${tshift}" fi potmax="$(csg_get_property --allow-empty cg.inverse.gromacs.pot_max)" [[ -n ${potmax} ]] && potmax="--max ${potmax}" do_external convert_potential xvg ${potmax} --type "${tabtype}" "${tshift}" "${output}" votca-csg-1.2.4/share/scripts/inverse/update_ibi.sh0000755000175000001440000000167612400714673022254 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < Used external packages: matlab EOF exit 0 fi [[ -z $1 || -z $1 ]] && die "${0##*/}: Missing arguments" # initialize & run the matlab file cat_external solve matlab | sed -e "s/\$name_out/$2/" -e "s/\$name/$1/" > solve_$1.m || die "${0##*/}: sed failed" matlab="$(csg_get_property cg.inverse.imc.matlab.bin "matlab")" [ -n "$(type -p $matlab)" ] || die "${0##*/}: matlab binary '$matlab' not found" #matlab does not like -_. etc in filenames critical cp solve_$1.m solve.m critical $matlab -r solve -nosplash -nodesktop rm -f solve.m [[ -f $2 ]] || die "Matlab failed" # temporary compatibility issue critical sed -ie 's/NaN/0.0/' "$2" critical sed -ie 's/Inf/0.0/' "$2" votca-csg-1.2.4/share/scripts/inverse/linsolve.m0000644000175000001440000000017612400714673021613 0ustar christophusersA = load('$name.gmc'); b = load('$name.imc'); x(:,1)=b(:,1); x(:,2) = -linsolve(A,b(:,2)); save '$name_out' x '-ascii' quit votca-csg-1.2.4/share/scripts/inverse/calc_thermforce.sh0000755000175000001440000000655612400714673023271 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < 0.0); die "Different end potential point \n" if ( $#r_aim != $#r_cur ); my $outfile="$ARGV[3]"; my @dpot; my @flag; my $value=0.0; #start from the end to make the begining have the last value for (my $i=$#r_aim;$i>=0;$i--){ if (($rdf_aim[$i] > 1e-10) && ($rdf_cur[$i] > 1e-10)) { $dpot[$i]=log($rdf_cur[$i]/$rdf_aim[$i])*$pref; $flag[$i]="i"; } else { $dpot[$i]=$value; $flag[$i]="o"; } if($pot_flags_cur[$i] =~ /[u]/) { $dpot[$i]=$value; $flag[$i]="o"; } else { $value=$dpot[$i]; } } saveto_table($outfile,@r_aim,@dpot,@flag) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/density_symmetrize.py0000755000175000001440000000525312400714673024127 0ustar christophusers#!/usr/bin/env python2 # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys import getopt import os import math firstx = [] firsty = [] secondx = [] secondy = [] outfile = "" options = ["adressc=", "infile=", "outfile=","help"] try: opts, args = getopt.getopt(sys.argv[1:], "", options) except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" print options sys.exit(2) for o, a in opts: if o == "--help": print """%(name)s, version %(ver)s This script symmetrizes the density around --adressc for thermodynamic force iteration Usage: %(name)s Allowed options: --adressc X.X center of the adress zone (x-value) --infile FILE input file --outfile FILE output file """ % {'name': os.path.basename(sys.argv[0]),'ver': '%version%'} sys.exit(0) elif o == "-v": verbose = True elif o == "--adressc": adressc = float(a) elif o in ("--infile"): infile = a elif o in ("--outfile"): outfile = a else: print options assert False, "unhandled option" for line in open(infile,"r").readlines(): if line[0] != "@" and line[0] != "#": values = line.split() if float(values[0]) <= adressc: firstx.append(float(values[0])) firsty.append(float(values[1])) if float(values[0]) == adressc: secondx.append(float(values[0])) secondy.append(float(values[1])) else: if len(firstx)-1-len(secondx) >= 0 and (len(firstx)-1-len(secondx)) < len (firsty): secondx.append(float(values[0])) secondy.append( 0.5*(firsty[len(firstx)-len(secondx)]+(float(values[1]))) ) else: print "Warning: symmetrize_density.pl : adressc not in center of data", line print "index", len(firstx)-len(secondx) f = open(outfile,"w") i=0 for x in secondx: f.write('%15.10e %15.10e i\n' % (x, secondy[i])) i=i+1 votca-csg-1.2.4/share/scripts/inverse/update_imc.sh0000755000175000001440000000263612400714673022256 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < Used external packages: octave EOF exit 0 fi [[ -z $1 || -z $2 ]] && die "${0##*/}: Missing arguments" # initialize & run the octave file cat_external solve octave | sed -e "s/\$name_out/$2/" -e "s/\$name/$1/" > solve_$1.octave || die "${0##*/}: sed failed" octave="$(csg_get_property cg.inverse.imc.octave.bin "octave")" [ -n "$(type -p $octave)" ] || die "${0##*/}: octave binary '$octave' not found" critical $octave solve_$1.octave [[ -f $2 ]] || die "Octave failed" # temporary compatibility issue critical sed -ie 's/NaN/0.0/' "$2" critical sed -ie 's/Inf/0.0/' "$2" votca-csg-1.2.4/share/scripts/inverse/table_smooth_borders.py0000755000175000001440000000515312400714673024357 0ustar christophusers#!/usr/bin/env python2 # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys import getopt import math import os xvalues = [] yvalues = [] outfile = "" doresample =False dosmoothtorho_0 = False dowritedpotf = False #TODO hardcoded weight function def weight(x): c = math.cos(math.pi/(2*(xstop-xstart)*0.1)*x) return c*c options = ["xstart=", "xstop=", "infile=", "outfile=","help"] try: opts, args = getopt.getopt(sys.argv[1:], "", options) except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" print options sys.exit(2) for o, a in opts: if o == "--help": print """%(name)s, version %(ver)s This script smooths the border for thermodynamic force iteration Usage: %(name)s Allowed options: --xstart X.X where the smoothing starts --xstop X.X where the smoothing stops --infile FILE input file --outfile FILE output file """ % {'name': os.path.basename(sys.argv[0]),'ver': '%version%'} sys.exit(0) elif o == "-v": verbose = True elif o == "--xstart": xstart = float(a) elif o == "--xstop": xstop = float(a) elif o in ("--infile"): infile = a elif o in ("--outfile"): outfile = a else: print options assert False, "unhandled option" for line in open(infile,"r").readlines(): if line[0] != "@" and line[0] != "#": values = line.split() if float(values[0]) >= xstart and float(values[0]) <= xstop: xvalues.append(float(values[0])) yvalues.append(float(values[1])) f = open(outfile,"w") i = 0 tempx = [] tempy = [] for x in xvalues: tempx.append (x) if x-xstart < 0.1*(xstop-xstart): tempy.append ((1-weight(math.fabs(x-xstart)))*yvalues[i]) elif x-xstart > 0.9*(xstop-xstart): tempy.append ((1-weight(math.fabs(xstop-x)))*yvalues[i]) else: tempy.append(yvalues[i]) i=i+1 i = 0 for x in tempx: f.write('%15.10e %15.10e i\n' % (x, tempy[i])) i=i+1 votca-csg-1.2.4/share/scripts/inverse/calc_rdf_generic.sh0000755000175000001440000000335712400714673023376 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <" "$rvdw" && die "Error in interaction '$bondname': rvdw ($rvdw) in $1 is smaller than max ($max)\n\ To ignore this check set cg.inverse.gromacs.cutoff_check to 'no'" return 0 } export -f check_cutoff check_temp() { #compares k_B T in xml with temp in mpd file local kbt kbt2 temp [[ "$(csg_get_property cg.inverse.gromacs.temp_check "yes")" = "no" ]] && return 0 #kbt in energy unit kbt="$(csg_get_property cg.inverse.kBT)" temp="$(get_simulation_setting ref_t)" #0.00831451 is k_b in gromacs untis see gmx manual chapter 2 kbt2=$(csg_calc "$temp" "*" 0.00831451) csg_calc "$kbt" "=" "$kbt2" || die "Error: cg.inverse.kBT ($kbt) in xml seetings file differs from 0.00831451*ref_t ($temp) in $1\n\ To ignore this check set cg.inverse.gromacs.temp_check to 'no'" return 0 } export -f check_temp simulation_finish() { #checks if simulation is finished local ext traj confout ext=$(csg_get_property cg.inverse.gromacs.traj_type "xtc") traj="traj.${ext}" confout="$(csg_get_property cg.inverse.gromacs.conf_out "confout.gro")" [ -f "$traj" ] && [ -f "$confout" ] && return 0 return 1 } export -f simulation_finish checkpoint_exist() { #check if a checkpoint exists local checkpoint checkpoint="$(csg_get_property cg.inverse.gromacs.mdrun.checkpoint "state.cpt")" [ -f "$checkpoint" ] && return 0 return 1 } export -f checkpoint_exist calc_begin_time() { #return the max of dt*frames and eqtime local dt equi_time first_frame dt=$(get_simulation_setting dt) first_frame="$(csg_get_property cg.inverse.gromacs.first_frame 0)" equi_time="$(csg_get_property cg.inverse.gromacs.equi_time 0)" t1=$(csg_calc "$dt" "*" "$first_frame") csg_calc "$t1" '>' "$equi_time" && echo "$t1" || echo "$equi_time" } export -f calc_begin_time calc_end_time() { #return dt * nsteps local dt steps dt=$(get_simulation_setting dt) steps=$(get_simulation_setting nsteps) csg_calc "$dt" "*" "$steps" } export -f calc_end_time votca-csg-1.2.4/share/scripts/inverse/dpot_shift_bo.pl0000755000175000001440000000321212400714673022757 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print < \n" if ($#ARGV<1); use CsgFunctions; my $infile="$ARGV[0]"; my $outfile="$ARGV[1]"; # read in the current dpot my @r; my @dpot; my @flag; my $comments; (readin_table($infile,@r,@dpot,@flag,$comments)) || die "$progname: error at readin_table\n"; my $min=undef; # bring end to zero for(my $i=0; $i<=$#r; $i++) { $min=$dpot[$i] if (($flag[$i] =~ /[i]/) and not defined($min)); $min=$dpot[$i] if (($flag[$i] =~ /[i]/) and ($dpot[$i]<$min)); } die "No valid value found in $infile" unless defined($min); # bring end to zero for(my $i=0; $i<=$#r; $i++) { $dpot[$i] -= $min; } # save to file saveto_table($outfile,@r,@dpot,@flag,$comments) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/table_extrapolate.pl0000755000175000001440000001417012400714673023640 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # sub extrapolate_constant($$$$) { my $y0 = $_[1]; return $y0; } sub extrapolate_linear($$$$) { my $x0 = $_[0]; my $y0 = $_[1]; my $m = $_[2]; my $x = $_[3]; return $m*($x - $x0) + $y0; } sub sasha_shit($$$$) { my $x0 = $_[0]; my $y0 = $_[1]; my $m = $_[2]; my $x = $_[3]; my $a = ($m**2)/(4*$y0); my $b = $x0 - 2*$y0/$m; #my $b = $x0 + 2*$y0/$m; #my $a = $m/(2*($x0-$b)); return $a*($x-$b)**2; } sub extrapolate_quad($$$$) { my $x0 = $_[0]; my $y0 = $_[1]; my $m = $_[2]; my $x = $_[3]; # $curv is a global variable my $a = 0.5*$m/$curv - $x0; my $b = $y0 - 0.25*$m*$m/$curv; return $curv*($x + $a)**2 + $b } sub extrapolate_exp($$$$) { my $x0 = $_[0]; my $y0 = $_[1]; my $m = $_[2]; my $x = $_[3]; my $a = $y0*exp(-$m*$x0 / $y0); my $b = $m/$y0; return $a*exp($b*$x); } use strict; $_=$0; s#^.*/##; my $progname=$_; my $usage="Usage: $progname [OPTIONS] "; my $avgpoints = 3; my $function="quadratic"; my $region = "leftright"; my $flag_update ="yes"; our $curv = 10000.0; # curvature for quadratic extrapolation # read program arguments while ((defined ($ARGV[0])) and ($ARGV[0] =~ /^-./)) { if (($ARGV[0] !~ /^--/) and (length($ARGV[0])>2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if($ARGV[0] eq "--avgpoints") { $avgpoints = $ARGV[1]; shift(@ARGV); shift(@ARGV); } elsif($ARGV[0] eq "--function") { $function = $ARGV[1]; shift(@ARGV); shift(@ARGV); } elsif($ARGV[0] eq "--region") { $region = $ARGV[1]; shift(@ARGV); shift(@ARGV); } elsif($ARGV[0] eq "--curvature") { $curv = $ARGV[1]; shift(@ARGV); shift(@ARGV); } elsif($ARGV[0] eq "--no-flagupdate") { shift(@ARGV); $flag_update="no"; } elsif (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < 0; use CsgFunctions; my $infile="$ARGV[0]"; my @r; my @val; my @flag; my $comments; (readin_table($infile,@r,@val,@flag,$comments)) || die "$progname: error at readin_table\n"; my $outfile="$ARGV[1]"; #============== my ($do_left, $do_right); # parse $region: decide where to extrapolate if ($region eq "left") { $do_left = 1; $do_right = 0; } elsif ($region eq "right") { $do_left = 0; $do_right = 1; } elsif ($region eq "leftright") { $do_left = 1; $do_right = 1; } else { die "$progname: Unknown region: $region !\n"; } my $extrap_method; # parse $function: decide which method to use if ($function eq "constant") { $extrap_method = \&extrapolate_constant; } elsif ($function eq "linear") { $extrap_method = \&extrapolate_linear; } elsif ($function eq "quadratic") { $extrap_method = \&extrapolate_quad; } elsif ($function eq "exponential") { $extrap_method = \&extrapolate_exp; } elsif ($function eq "sasha") { $extrap_method = \&sasha_shit; } else { die "$progname: Unknown extrapolation function: $function !\n"; } # do extrapolation: left if ($do_left) { # find beginning my $first; for ($first=0;$first<=$#r;$first++) { last if($flag[$first] eq "i"); } # grad of beginning my $grad_beg; if ($function eq "constant") { $grad_beg = 0; } else { $grad_beg = ($val[$first + $avgpoints] - $val[$first])/($r[$first + $avgpoints] - $r[$first]); } # now extrapolate beginning for(my $i=$first-1; $i >= 0; $i--) { $val[$i] = &{$extrap_method}($r[$first], $val[$first], $grad_beg, $r[$i]); $flag[$i]="i" if ($flag_update eq "yes"); } } # do extrapolation: right if ($do_right) { # find end my $last; for ($last=$#r;$last>0;$last--) { last if($flag[$last] eq "i"); } # grad of end my $grad_end; if ($function eq "constant") { $grad_end = 0; } else { $grad_end = ($val[$last] - $val[$last - $avgpoints])/($r[$last] - $r[$last-$avgpoints]); } # now extrapolate ends for(my $i=$last+1; $i <= $#r; $i++) { $val[$i] = &{$extrap_method}($r[$last], $val[$last], $grad_end, $r[$i]); $flag[$i]="i" if ($flag_update eq "yes"); } } #============== saveto_table($outfile,@r,@val,@flag,$comments) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/potential_to_espresso.sh0000755000175000001440000000245512400714673024567 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < $tmp1 critical csg_resample --in ${name}.${dist}.new --out $tmp2 --grid "$min:$step:$max" critical sed -e '/^#/d' -e 's/nan/0.0/g' $tmp2 > $tmp3 [ $(sed -n '$=' $tmp1) -eq $(sed -n '$=' $tmp3) ] || \ die "${0##*/}: linenumber of ${name}.${dist}.tgt differs from ${name}.${dist}.new" critical paste $tmp1 $tmp3 > $tmp4 critical awk '{if ($4!=$1){print "x column differs in line",NR;exit 1;}}' $tmp4 echo "Calc convergence for ${name} with weight $weight" critical awk -v bin=$step -v w=$weight -v dist=$dist '{sum+=($5-$2)^2;}END{print dist,sqrt(sum*bin*w);}' $tmp4 >> $tmp done critical awk '{sum+=$2;}END{print sum;}' $tmp > ${name}.conv votca-csg-1.2.4/share/scripts/inverse/prepare_imc.sh0000755000175000001440000000200212400714673022415 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < 0) { my $file_cur="$ARGV[0]"; my @r_cur; my @val_cur; my @flag_cur; (readin_table($file_cur,@r_cur,@val_cur,@flag_cur)) || die "$progname: error at readin_table\n"; #should never happen, but .... die "Different grids\n" if (($r_delta[1]-$r_delta[0]-$r_cur[1]+$r_cur[0])>0.0001); die "Different start potential point \n" if (($r_delta[0]-$r_cur[0]) > 0.0); die "Different end potential point \n" if ( $#r_cur != $#r_delta ); for (my $i=0;$i<=$#r_cur;$i++) { $err[$i] += ($val_cur[$i] - $val_full[$i])**2; # is already nan or we don't change } shift @ARGV; $nblocks = $nblocks + 1; } for (my $i=0;$i<=$#r_full;$i++) { $err[$i]=sqrt(($nblocks-1)/$nblocks*$err[$i]); } saveto_table_err($outfile,@r_full,@val_full,@flag_full,@err) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/initialize_step_generic_espresso.sh0000755000175000001440000000250312400714673026750 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat < $tmpfile echo "$max 0" >> $tmpfile comment="$(get_table_comment)" critical csg_resample --type linear --in ${tmpfile} --out "${2}" --grid "${1}" --comment "${comment}" votca-csg-1.2.4/share/scripts/inverse/table_getsubset.py0000755000175000001440000000440612400714673023333 0ustar christophusers#!/usr/bin/env python2 # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import sys import os #import pygsl.sf import getopt #from pygsl import spline #from pygsl import _numobj as numx import math xvalues = [] yvalues = [] outfile = "" options = ["xstart=", "xstop=", "infile=", "outfile=","help"] try: opts, args = getopt.getopt(sys.argv[1:], "", options) except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" print options sys.exit(2) for o, a in opts: if o == "--help": print """%(name)s, version %(ver)s This script get the a subset of a table Usage: %(name)s Allowed options: --xstart X.X x value where the subset starts --xstop X.X x value where the subset stops --infile FILE input file --outfile FILE output file """ % {'name': os.path.basename(sys.argv[0]),'ver': '%version%'} sys.exit(0) elif o == "-v": verbose = True elif o == "--xstart": xstart = float(a) elif o == "--xstop": xstop = float(a) elif o in ("--infile"): infile = a elif o in ("--outfile"): outfile = a else: print options assert False, "unhandled option" for line in open(infile,"r").readlines(): if line[0] != "@" and line[0] != "#": values = line.split() if float(values[0]) >= xstart and float(values[0]) <= xstop: xvalues.append(float(values[0])) yvalues.append(float(values[1])) f = open(outfile,"w") i = 0 tempx = [] tempy = [] for x in xvalues: tempx.append (x) tempy.append(yvalues[i]) i=i+1 i = 0 for x in tempx: f.write('%15.10e %15.10e i\n' % (x-xstart, tempy[i])) i=i+1 votca-csg-1.2.4/share/scripts/inverse/apply_prefactor.pl0000755000175000001440000000442312400714673023333 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; $_=$0; s#^.*/##; my $progname=$_; my $usage="Usage: $progname [OPTIONS] "; # read program arguments while ((defined ($ARGV[0])) and ($ARGV[0] =~ /^-./)) { if (($ARGV[0] !~ /^--/) and (length($ARGV[0])>2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < 0; use CsgFunctions; my $do_interpolate = 0; my $infile="$ARGV[0]"; my @r; my @val; my @flag; my $comments; (readin_table($infile,@r,@val,@flag,$comments)) || die "$progname: error at readin_table\n"; my $outfile="$ARGV[1]"; my @out; my $prefactor="$ARGV[2]"; my $prefactor_cg = 0; if (defined $ARGV[3]){ $prefactor_cg = "$ARGV[3]"; $do_interpolate = 1; } my $min = 0; my $i=0; for (;$i<=$#r;$i++){ $out[$i]=$val[$i]; } if (!$do_interpolate){ for ($i=0;$i<=$#r;$i++){ # just multiply $out[$i]=$out[$i]*$prefactor; } } else { for ($i=0;$i<=$#r;$i++){ # do a linear interpoltation between the prefactors $out[$i]=$i/$#r*$out[$i]*$prefactor_cg+(1-$i/$#r)*$out[$i]*$prefactor; } } saveto_table($outfile,@r,@out,@flag,$comments) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/add_POT.pl0000755000175000001440000000502112400714673021406 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print <0.0001); die "Different start potential point \n" if (($r_delta[0]-$r_cur[0]) > 0.0); die "Different end potential point \n" if ( $#r_cur != $#r_delta ); my $outfile="$ARGV[2]"; my @pot; my @flag; # TODO: think about addition rules # now I did it like that to always maintain interval of interest in all potentials # shount that just be a < instead of <= ?? for (my $i=0;$i<=$#r_cur;$i++){ if($flag_cur[$i] eq "u" || $flag_delta[$i] eq "u") { $pot[$i] = $pot_cur[$i]; # is already nan or we don't change $flag[$i] = "u"; } else { $pot[$i]=$pot_cur[$i]+$pot_delta[$i]; $flag[$i] = $flag_cur[$i]; } #if ($flag_cur[$i] eq "i"){ # if ($flag_delta[$i] eq "i"){ # $pot[$i]=$pot_cur[$i]+$pot_delta[$i]; # } else { # $pot[$i]=$pot_cur[$i]; # } # $flag[$i]="i"; #} else { # $pot[$i]="nan"; # $flag[$i]="u"; #} } saveto_table($outfile,@r_cur,@pot,@flag) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/inverse.sh0000755000175000001440000002162012400714673021611 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # show_help () { cat << eof ${0##*/}, version %version% Start the script to run ibi, imc, etc. or clean out current dir Usage: ${0##*/} [OPTIONS] --options settings.xml [clean] Allowed options: -h, --help show this help -N, --do-iterations N only do N iterations --wall-time SEK Set wall clock time --options FILE Specify the options xml file to use --debug enable debug mode with a lot of information --nocolor disable colors Examples: * ${0##*/} --options cg.xml * ${0##*/} -6 --options cg.xml eof } #--help should always work so leave it here if [[ $1 = "--help" ]]; then show_help exit 0 fi #do all start up checks option stuff source "${0%/*}/start_framework.sh" || exit 1 #defaults for options do_iterations="" #unset stuff from enviorment unset CSGXMLFILE CSGENDING CSGDEBUG ### begin parsing options shopt -s extglob while [[ ${1#-} != $1 ]]; do if [[ ${1#--} = $1 && -n ${1:2} ]]; then #short opt with arguments here: fc if [[ ${1#-[fc]} != ${1} ]]; then set -- "${1:0:2}" "${1:2}" "${@:2}" else set -- "${1:0:2}" "-${1:2}" "${@:2}" fi fi case $1 in --do-iterations) do_iterations="$2" int_check "$do_iterations" "inverse.sh: --do-iterations need a number as agrument" shift 2 ;; --wall-time) int_check "$2" "inverse.sh: --wall-time need a number as agrument" export CSGENDING=$(( $(get_time) + $2 )) shift 2 ;; -[0-9]*) do_iterations=${1#-} shift ;; --options) CSGXMLFILE="$2" [[ -f $CSGXMLFILE ]] || die "options xml file '$CSGXMLFILE' not found" export CSGXMLFILE="$(globalize_file "${CSGXMLFILE}")" shift 2;; --nocolor) export CSGNOCOLOR="yes" shift;; --debug) export CSGDEBUG="yes" shift;; -h | --help) show_help exit 0;; *) die "Unknown option '$1'";; esac done ### end parsing options #old style, inform user [[ -z ${CSGXMLFILE} ]] && die "Please add your setting xml file behind the --options option (like for all other votca programs) !" [[ $1 = "clean" ]] && { csg_inverse_clean; exit $?; } enable_logging [[ -n $CSGDEBUG ]] && set -x check_for_obsolete_xml_options echo "Sim started $(date)" method="$(csg_get_property cg.inverse.method)" msg "We are doing Method: $method" sim_prog="$(csg_get_property cg.inverse.program)" echo "We are using Sim Program: $sim_prog" source_function $sim_prog iterations_max="$(csg_get_property cg.inverse.iterations_max)" int_check "$iterations_max" "inverse.sh: cg.inverse.iterations_max needs to be a number" echo "We are doing $iterations_max iterations (0=inf)." convergence_check="$(csg_get_property cg.inverse.convergence_check "none")" [[ $convergence_check = none ]] || echo "After every iteration we will do the following check: $convergence_check" filelist="$(csg_get_property --allow-empty cg.inverse.filelist)" [[ -z $filelist ]] || echo "We extra cp '$filelist' to every step to run the simulation" cleanlist="$(csg_get_property --allow-empty cg.inverse.cleanlist)" [[ -z $cleanlist ]] || echo "We extra clean '$cleanlist' after a step is done" scriptdir="$(csg_get_property --allow-empty cg.inverse.scriptdir)" [[ -n $scriptdir ]] && add_to_csgshare "$scriptdir" show_csg_tables #main script [[ -f done ]] && { msg "Job is already done (remove the file named 'done' if you want to go on)"; exit 0; } ######## BEGIN STEP 0 ############ update_stepnames 0 restart_file="$(get_restart_file)" this_dir=$(get_current_step_dir --no-check) if [[ -d $this_dir && -f "$this_dir/done" ]]; then msg "step 0 is already done - skipping" else echo ------------------------ msg --color blue "Prepare (dir ${this_dir##*/})" echo ------------------------ if [[ -d $this_dir ]]; then msg "Incomplete step 0" [[ -f "${this_dir}/${restart_file}" ]] || die "No restart file found (remove stepdir '${this_dir##*/}' if you don't know what to do - you will lose the prepare step)" else mkdir -p $this_dir || die "mkdir -p $this_dir failed" fi cd $this_dir || die "cd $this_dir failed" mark_done "stepdir" if is_done "Prepare"; then msg "Prepare of potentials already done" else do_external prepare $method mark_done "Prepare" fi touch "done" msg "step 0 done" cd $(get_main_dir) fi ######## END STEP 0 ############ begin=1 trunc=$(get_stepname --trunc) for i in ${trunc}*; do [[ -d $i ]] || continue nr=${i#$trunc} if [[ -n $nr && -z ${nr//[0-9]} ]]; then #convert to base 10, otherwise 008 is interpreted as octal nr=$((10#$nr)) [[ $nr -gt $begin ]] && begin="$nr" fi done unset nr trunc [[ $begin -gt 1 ]] && msg "Jumping in at iteration $begin" avg_steptime=0 steps_done=0 [[ $iterations_max -eq 0 ]] && iterations=$begin || iterations=$iterations_max for ((i=$begin;i<$iterations+1;i++)); do [ $iterations_max -eq 0 ] && ((iterations++)) step_starttime="$(get_time)" update_stepnames $i last_dir=$(get_last_step_dir) this_dir=$(get_current_step_dir --no-check) echo ------------------------------- msg --color blue "Doing iteration $i (dir ${this_dir##*/})" echo ------------------------------- if [[ -d $this_dir ]]; then if [[ -f "$this_dir/done" ]]; then msg "step $i is already done - skipping" continue else msg "Incomplete step $i" [[ -f ${this_dir}/${restart_file} ]] || die "No restart file found (remove stepdir '${this_dir##*/}' if you don't know what to do - you will lose one iteration)" fi else echo "Step $i started at $(date)" mkdir -p $this_dir || die "mkdir -p $this_dir failed" fi cd $this_dir || die "cd $this_dir failed" mark_done "stepdir" if is_done "Initialize"; then echo "Initialization already done" else #get need files cp_from_main_dir "$filelist" #get files from last step, init sim_prog and ... do_external initstep $method mark_done "Initialize" fi if is_done "Simulation"; then echo "Simulation is already done" else msg "Simulation with $sim_prog" do_external run $sim_prog fi if simulation_finish; then mark_done "Simulation" elif [ "$(csg_get_property cg.inverse.simulation.background "no")" = "yes" ]; then msg "Simulation is suppose to run in background, which we cannot check." msg "Stopping now, resume csg_inverse whenever the simulation is done." exit 0 elif [[ -n ${CSGENDING} ]] && checkpoint_exist; then msg "Simulation is not finished, but a checkpoint was found, so it seems" msg "walltime is nearly up, stopping now, resume csg_inverse whenever you want." exit 0 else die "Simulation is in a strange state, it has no checkpoint and is not finished, check ${this_dir##*/} by hand" fi msg "Make update" do_external update $method msg "Post update" do_external post_update $method msg "Adding up potential" do_external add_pot $method msg "Post add" do_external post add msg "Clean up" for cleanfile in ${cleanlist}; do rm -f $cleanfile done unset cleanfile step_time="$(( $(get_time) - $step_starttime ))" msg "\nstep $i done, needed $step_time secs" ((steps_done++)) touch "done" if [[ $convergence_check = none ]]; then echo "No convergence check to be done" else msg "Doing convergence check: $convergence_check" [[ -f stop ]] && rm -f stop do_external convergence_check "$convergence_check" if [[ -f stop ]]; then msg "Iterations are converged, stopping" touch "done" exit 0 else msg "Iterations are not converged, going on" fi fi if [[ -n $CSGENDING ]]; then avg_steptime="$(( ( ( $steps_done-1 ) * $avg_steptime + $step_time ) / $steps_done + 1 ))" echo "New average steptime $avg_steptime" if [[ $(( $(get_time) + $avg_steptime )) -gt ${CSGENDING} ]]; then msg "We will not manage another step, stopping" exit 0 else msg "We can go for another $(( ( ${CSGENDING} - $(get_time) ) / $avg_steptime - 1 )) steps" fi fi if [[ -n $do_iterations ]]; then if [[ $do_iterations -ge $steps_done ]] ; then msg "Stopping at step $i, user requested to take some rest after this amount of iterations" exit 0 else msg "Going on for another $(( $do_iterations - $steps_done )) steps" fi fi cd $(get_main_dir) || die "cd $(get_main_dir) failed" done touch "done" echo "All done at $(date)" exit 0 votca-csg-1.2.4/share/scripts/inverse/update_ibi_single.sh0000755000175000001440000000303212400714673023601 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < -1; $withflag = $ARGV[0]; } else { die "Unknow option '".$ARGV[0]."' !\n"; } shift(@ARGV); } #Print usage die "missing parameters\n$usage\n" unless $#ARGV >= 1; use CsgFunctions; my $infile="$ARGV[0]"; my $outfile="$ARGV[1]"; my @r; my @val; my @flag; (readin_table($infile,@r,@val,@flag)) || die "$progname: error at readin_table\n"; # find last u/o my $i_first; # TODO: look for at least 3 successive points with i for($i_first=0; ($i_first<$#r) && ($flag[$i_first] =~ /[uo]/); $i_first++) {} my $ncrop=0; while($i_first + $ncrop<=$#r-3) { my $i = $i_first + $ncrop; my $delta_1 = $val[$i] - $val[$i + 1]; my $delta_2 = $val[$i + 1 ] - $val[$i + 2]; # do both deltas have the same sign? if($delta_1 * $delta_2 > 0) { last; } elsif (abs($val[$i]) < 0.5 && abs($val[$i+1]) < 0.5) { last; } $flag[$i]='o'; $ncrop++; if($ncrop > 3) { print "error: need to crop more than 3 points in $infile. think about sampleing/grid interval."; exit 1; } } if($ncrop > 0) { print "warnng, I cropped $ncrop points at the beginning\n"; } saveto_table($outfile,@r,@val,@flag) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/postadd_copyback.sh0000755000175000001440000000241612400714673023451 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < $tmpfile spmin=$(sed -n -e '1p' $tmpfile | awk '{print $1}') spmax=$(sed -n -e '$p' $tmpfile | awk '{print $1}') spstep=$(csg_get_interaction_property inverse.post_update_options.splinesmooth.step) comment="$(get_table_comment)" critical csg_resample --in $tmpfile --out "$2" --grid $min:$step:$max --type cubic --fitgrid $spmin:$spstep:$spmax --comment "$comment" votca-csg-1.2.4/share/scripts/inverse/prepare_generic_single.sh0000755000175000001440000000570212400714673024634 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat <> "${name}.aconv" votca-csg-1.2.4/share/scripts/inverse/calc_rdf_gromacs.sh0000755000175000001440000000601712400714673023411 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicale law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat < gnuplot_lock" if flock -n -x $fd; then rm -rf gnuplot_pipe mkfifo gnuplot_pipe while true; do if read /dev/null #gnuplot is in laststep_dir echo "cd '$PWD'" > $(get_main_dir)/gnuplot_pipe || die "piping to gnuplot_pipe failed" cat $script > $(get_main_dir)/gnuplot_pipe || die "piping to gnuplot_pipe failed" else killall $what_to_kill $gnuplot $opts $script fi votca-csg-1.2.4/share/scripts/inverse/convergence_check_default.sh0000755000175000001440000000254312400714673025300 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat <" "$limit" || touch 'stop' votca-csg-1.2.4/share/scripts/inverse/calc_pressure_espresso.sh0000755000175000001440000000370712400714673024721 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < $esp_script < "$1" votca-csg-1.2.4/share/scripts/inverse/calc_pressure_gromacs.sh0000755000175000001440000000336012400714673024504 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat < "$1" votca-csg-1.2.4/share/scripts/inverse/merge_tables.pl0000755000175000001440000000651212400714673022573 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; $_=$0; s#^.*/##; my $progname=$_; my $usage="Usage: $progname [OPTIONS] "; #Defaults my $noflags='no'; my $novalues='no'; my $withflag=undef; while ((defined ($ARGV[0])) and ($ARGV[0] =~ /^-./)) { if (($ARGV[0] !~ /^--/) and (length($ARGV[0])>2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < -1; $withflag = $ARGV[0]; } else { die "Unknow option '".$ARGV[0]."' !\n"; } shift(@ARGV); } #Print usage die "missing parameters\n$usage\n" unless $#ARGV > 1; use CsgFunctions; my $src="$ARGV[0]"; my $dst="$ARGV[1]"; my $out="$ARGV[2]"; print "tables $src $dst $out\n"; my @r_src; my @val_src; my @flag_src; my $comments1; (readin_table($src,@r_src,@val_src,@flag_src,$comments1)) || die "$progname: error at readin_table\n"; my @r_dst; my @val_dst; my @flag_dst; my $comments2; (readin_table($dst,@r_dst,@val_dst,@flag_dst,$comments2)) || die "$progname: error at readin_table\n"; my $idst=0; for(my $i=0; $i<=$#r_src; $i++) { # skip if flag does not match if($withflag) { if(!($flag_src[$i] =~ m/[$withflag]/)) { next; } } # advance in dst till same r while($r_dst[$idst] < $r_src[$i] - 1e-15) { $idst++; if ($idst > $#r_dst) { die "merge_tables.pl: destination table is too short"; } } my $tmp= $r_src[$i]-$r_dst[$idst]; die "error: grid mismatch" if(abs($r_dst[$idst] - $r_src[$i]) > 1e-15); if($novalues eq 'no') { $val_dst[$idst] = $val_src[$i]; } if($noflags eq 'no') { $flag_dst[$idst] = $flag_src[$i]; } } my $comments="# $progname: merged $src with $dst to $out\n"; $comments.="$comments1" if (defined($comments1)); $comments.="$comments2" if (defined($comments2)); saveto_table($out,@r_dst,@val_dst,@flag_dst,$comments) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/initialize_step_generic_gromacs.sh0000755000175000001440000000310512400714673026537 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [[ $1 = "--help" ]]; then cat < $esp_script < [expr 2 + $equi_snapshots] } { analyze append # if there's only one molecule, otherwise if { \$num_molecules == 1 } { set rdf [analyze [set $index1] [set $index2] $min $max \$numbins] } else { set rdf [analyze [set $index1] [set $index2] $min $max \$numbins] } } incr bf_count } close \$in foreach value [lindex \$rdf 1] { lappend rlist [lindex \$value 0] lappend rdflist [lindex \$value 1] } set out [open $name.dist.new.tab w] foreach r \$rlist rdf \$rdflist { puts \$out "\$r \$rdf" } close \$out puts "Calculation finished." set out [open $esp_success w] close \$out EOF critical $esp_bin $esp_script [ -f "$esp_success" ] || die "${0##*/}: Espresso calc rdf did not end successfully. Check log." comment="$(get_table_comment)" critical csg_resample --in ${name}.dist.new.tab --out ${name}.dist.new --grid ${min}:${binsize}:${max} --comment "$comment" mark_done "rdf-$name" fi votca-csg-1.2.4/share/scripts/inverse/tag_file.sh0000755000175000001440000000226012400714673021707 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < "$output" || die "${0##*/}: sed failed" cat "$input" >> "$output" || die "${0##*/}: sed failed" votca-csg-1.2.4/share/scripts/inverse/run_espresso.sh0000755000175000001440000001157612400714673022676 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < $esp_script < $espout" w] blockfile \$out write variable all blockfile \$out write interactions blockfile \$out write thermostat blockfile \$out write tclvariable num_molecules blockfile \$out write tclvariable num_atoms blockfile \$out write tclvariable {$index_vars} if { [has_feature "MASS"] } { blockfile \$out write particles {id type molecule mass pos v} } else { blockfile \$out write particles {id type molecule pos v} } blockfile \$out write bonds close \$out set out [open $esp_success w] close \$out EOF critical $esp_bin $esp_script votca-csg-1.2.4/share/scripts/inverse/imcdata_from_blocks.octave0000644000175000001440000000147112400714673024766 0ustar christophusersname='CG-CG' blocks=load(strcat(name, '.blocks')); corr_avg = load(strcat(name, '_', num2str(blocks(1)), '.cor')); S_avg = load(strcat(name, '_', num2str(blocks(1)), '.S')); dS_avg = load(strcat(name, '_', num2str(blocks(1)), '.imc')); for i = 2:length(blocks) corr_file=strcat(name, '_', num2str(blocks(i)), '.cor'); S_file=strcat(name, '_', num2str(blocks(i)), '.S'); dS_file=strcat(name, '_', num2str(blocks(i)), '.imc'); corr=load(corr_file); S=load(S_file); dS=load(dS_file); corr_avg += corr; S_avg(:,2) += S(:,2); dS_avg(:,2) += S(:,2); end; corr_avg = corr_avg/length(blocks); S_avg = S_avg/length(blocks); gmc = -(corr_avg - reshape(kron(S_avg(:,2),S_avg(:,2)), size(corr_avg))); save('-ascii', strcat(name, '.gmc.block'), 'gmc'); save('-ascii', strcat(name, '.imc.block'), 'dS'); #quit votca-csg-1.2.4/share/scripts/inverse/postupd_scale.sh0000755000175000001440000000220112400714673022775 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <&2; exit 1; } #check for CSGSHARE [[ -n $CSGSHARE ]] || die "Error: CSGSHARE not definded" [[ -d $CSGSHARE ]] || die "CSGSHARE '$CSGSHARE' is not a dir" [[ -d ${CSGSHARE}/scripts/inverse ]] || die "\$CSGSHARE/scripts/inverse is not found. Is CSGSHARE set corectly?" [[ -f ${CSGSHARE}/scripts/inverse/inverse.sh ]] || die "Could not find inverse.sh, \$CSGSHARE/scripts/inverse seem to point to the wrong place!" [[ -f ${CSGSHARE}/scripts/inverse/functions_common.sh ]] || die "Could not find default common framework functions (functions_common.sh)" source "${CSGSHARE}/scripts/inverse/functions_common.sh" || exit 1 #this is need by die later export CSG_MASTER_PID="$$" export CSG_MAINDIR="$PWD" add_to_csgshare "${CSGSHARE}/scripts/inverse" votca-csg-1.2.4/share/scripts/inverse/table_integrate.pl0000755000175000001440000000760612400714673023300 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; $_=$0; s#^.*/##; my $progname=$_; my $usage="Usage: $progname [OPTIONS] "; my $with_errors="no"; my $with_entropie="no"; my $kbT=undef; # read program arguments while ((defined ($ARGV[0])) and ($ARGV[0] =~ /^-./)) { if (($ARGV[0] !~ /^--/) and (length($ARGV[0])>2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < 0; use CsgFunctions; my $infile="$ARGV[0]"; my @r; my @force; my @flag; my @force_errors; if ("$with_errors" eq "yes") { (readin_table_err($infile,@r,@force,@force_errors,@flag)) || die "$progname: error at readin_table\n"; } else { (readin_table($infile,@r,@force,@flag)) || die "$progname: error at readin_table\n"; } if ("$with_entropie" eq "yes"){ die "$progname: kbT not defined specify it with --kbT option\n" unless defined($kbT); for (my $i=$#r;$i>=0;$i--){ if ($r[$i]>0) { $force[$i] += 2*$kbT/$r[$i]; } } } my $outfile="$ARGV[1]"; my @pot; my @pot_errors; my @ww; #calc pot with trapez rule #int_j= sum_i^j (r_i+1 - r_i)*(f_i+f_i+1)/2 #int_j+1= int_j + (r_i+1 - r_i)*(f_i+f_i+1)/2 #int_j= int_j+1 - (r_i+1 - r_i)*(f_i+f_i+1)/2 #begin from end to make pot(max)=0 $pot[$#r]=0; $ww[$#r]=0; for (my $i=$#r-1;$i>=0;$i--){ #hh = delta x /2 my $hh=0.5*($r[$i+1]-$r[$i]); $pot[$i]=$pot[$i+1] - $hh*($force[$i+1]+$force[$i]); $ww[$i]+= $hh; $ww[$i+1]+= $hh; } #ww contains w_i=(r_i+1-r_i-1)/2 if ("$with_errors" eq "yes") { #all error are independent(we assume that) #resort sum (only one force per summand) # U_j= sum_i ^j = sum_i^j f_i(r_i+1 - r_i-1)/2 + randterm # o^2(U_j)=sum_i o^2(f_i)*(r_i+1 - r_i-1)/2 + o^2(randterm) my $var_int = ($ww[$#r]*$force_errors[$#r])**2; $pot_errors[$#r]=sqrt($var_int); for(my $i=$#r-1; $i>=0;$i--) { my $hh = 0.5*($r[$i+1] - $r[$i]); $pot_errors[$i] = sqrt($var_int + ($hh*$force_errors[$i])**2); $var_int += ($ww[$i]*$force_errors[$i])**2; } } if ("$with_errors" eq "yes") { saveto_table_err($outfile,@r,@pot,@pot_errors,@flag) || die "$progname: error at save table\n"; }else { saveto_table($outfile,@r,@pot,@flag) || die "$progname: error at save table\n"; } votca-csg-1.2.4/share/scripts/inverse/pressure_cor_wjk.pl0000755000175000001440000000540612400714673023531 0ustar christophusers#! /usr/bin/perl -w # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; ( my $progname = $0 ) =~ s#^.*/##; if (defined($ARGV[0])&&("$ARGV[0]" eq "--help")){ print < 0.1*$kBT){ if ($pref >0){ $pref=0.1*$kBT; }else{ $pref=-0.1*$kBT; } } $pref=$pref*$scale_factor; print "Pressure correction factor: A=$pref\n"; my @r; my @pot; my @flag; my $outfile="$ARGV[1]"; my $comment="#$progname: p_now=$p_now, p_target=$p_target, prefactor=$pref\n"; for(my $i=$min/$delta_r;$i<=$max/$delta_r;$i++){ $r[$i]=$i*$delta_r; $pot[$i]=$pref*(1-$r[$i]/$max); $flag[$i]="i"; } saveto_table($outfile,@r,@pot,@flag,$comment) || die "$progname: error at save table\n"; votca-csg-1.2.4/share/scripts/inverse/solve_numpy.sh0000755000175000001440000000266312400714673022524 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < Used external packages: numpy EOF exit 0 fi [[ -z $1 || -z $2 ]] && die "${0##*/}: Missing arguments" # initialize & run the octave file cat_external solve numpy | sed -e "s/\$name_out/$2/" -e "s/\$name/$1/" > solve_$1.sh || die "${0##*/}: sed failed" #this check is not sufficient for numpy! check for numpy package! py="$(csg_get_property cg.inverse.imc.numpy.bin "python2")" [ -n "$(type -p $py)" ] || die "${0##*/}: python binary '$py' not found" critical $py solve_$1.sh [[ -f $2 ]] || die "Python failed" # temporary compatibility issue echo "TODO: check these lines!" critical sed -ie 's/NaN/0.0/' "$2" critical sed -ie 's/Inf/0.0/' "$2" votca-csg-1.2.4/share/scripts/inverse/prepare_generic_gromacs.sh0000755000175000001440000000171012400714673025001 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat <2)){ $_=shift(@ARGV); #short opt having agruments examples fo if ( $_ =~ /^-[fo]/ ) { unshift(@ARGV,substr($_,0,2),substr($_,2)); } else{ unshift(@ARGV,substr($_,0,2),"-".substr($_,2)); } } if (($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")) { print < -1; $withflag = shift(@ARGV); } elsif ($ARGV[0] eq "--with-errors"){ shift(@ARGV); $with_errors="yes"; } else { die "Unknow option '".$ARGV[0]."' !\n"; } } #Print usage die "missing parameters\n$usage\n" unless $#ARGV >= 3; my $a = $ARGV[2]; my $b = $ARGV[3]; use CsgFunctions; my $file="$ARGV[0]"; my $outfile="$ARGV[1]"; print "$progname: $file to $outfile with y' = $a*y + $b \n"; my @r; my @val; my @flag; my @errors; my $comments=""; if ("$with_errors" eq "yes") { (readin_table_err($file,@r,@val,@errors,@flag,$comments)) || die "$progname: error at readin_table\n"; } else { (readin_table($file,@r,@val,@flag,$comments)) || die "$progname: error at readin_table\n"; } for(my $i=0; $i<=$#r; $i++) { # skip if flag does not match if($withflag) { if(!($flag[$i] =~ m/[$withflag]/)) { next; } } $val[$i] = $a*$val[$i] + $b; if ("$with_errors" eq "yes") { $errors[$i] = $a*$errors[$i]; } } $comments.="# $progname: $file -> $outfile y' = $a*y + $b\n"; if ("$with_errors" eq "yes") { saveto_table_err($outfile,@r,@val,@errors,@flag,$comments) || die "$progname: error at save table\n"; }else { saveto_table($outfile,@r,@val,@flag,$comments) || die "$progname: error at save table\n"; } votca-csg-1.2.4/share/scripts/inverse/post_add_single.sh0000755000175000001440000000263612400714673023302 0ustar christophusers#! /bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # if [ "$1" = "--help" ]; then cat < $tmp awk "{printf(\"%s %.16e %s\\n\", \$1,($n*\$2 + \$5)/($n+1),\$3);}" $tmp > $outfile n=$((n+1)) shift done rm $tmp } average_imc() { octave $CSGINVERSE/imcdata_from_blocks.octave sed -e '/^[#@]/d' $name.gmc.block > $1.gmc sed -e '/^[#@]/d' $name.imc.block > $1.imc } calc_dpot_ibm() { update_POT="$($SOURCE_WRAPPER update ibm_pot)" \ || die "${0##*/}: $SOURCE_WRAPPER update ibm_pot failed" run_or_exit ${update_POT} ${name}.dist.tgt \ $1.dist.new ${name}.pot.cur $1.dpot.new } all_dist="" all_dpot="" for block in $(seq 1 $nblocks); do echo "skipping block $block" all_dpot="$all_dpot ${name}_no_$block.dpot.new" all_dist="$all_dist ${name}_$block.dist.new" case $method in ibm) in_dist="" for i in $(seq 1 $nblocks | sed "/^${block}\$/d"); do in_dist="$in_dist ${name}_$i.dist.new" done #begin_block $block average_tables ${name}_no_$block.dist.new $in_dist calc_dpot_ibm ${name}_no_$block #end_block $block ;; imc) seq 1 $nblocks | sed "/^${block}\$/d" > $name.blocks average_imc ${name}_no_$block $CSGINVERSE/solve_octave.sh ${name}_no_$block $name.pot.cur ;; esac done case $method in ibm) average_tables ${name}.dist.new $all_dist calc_dpot_ibm ${name} ;; imc) seq 1 $nblocks > $name.blocks average_imc ${name} $CSGINVERSE/solve_octave.sh ${name} $name.pot.cur ;; esac ~/src/csg/scripts/csg_call.sh tables jackknife $name.dpot.err CG-CG.dpot.new $all_dpot #case "$method" in # ibm) # ;; # imc) # ;; #esac #run_or_exit ${update_POT} ${name}.dist.tgt ${name}.dist.new ${name}.pot.cur ${name}.dpot.tmpvotca-csg-1.2.4/share/scripts/still_dirty/do_errorplot.sh0000755000175000001440000000200412400714673023532 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # do_errors() { csg_imc --top topol.tpr --trj traj.xtc --cg ../water_cg.xml --options ../cg.xml \ --do-imc --begin 100 \ --write-every $1 --do-blocks --nframes $((16*$1)) ~/src/csg/share/scripts/inverse/errorbars.sh ibm cp CG-CG.dpot.err ibm.err.$i ~/src/csg/share/scripts/inverse/errorbars.sh imc cp CG-CG.dpot.err imc.err.$i } for i in $(seq 1 250); do do_errors $i done votca-csg-1.2.4/share/scripts/still_dirty/eval_errors.sh0000755000175000001440000000160712400714673023353 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # rm errors.ibm rm errors.imc for i in $(seq 1 250); do sed -e '/[uo]/d' ibm.err.$i | sed -e '1d' | awk "{sum+=\$4;n++;}END{print $i*16, sum/n}" >> errors.ibm sed -e '/[uo]/d' imc.err.$i | sed -e '1d' | awk "{sum+=\$4;n++;}END{print $i*16, sum/n}" >> errors.imc done votca-csg-1.2.4/share/scripts/still_dirty/convergence.sh0000755000175000001440000000161412400714673023324 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # i=0 for step in step_?? step_???; do if [ -e $step/CG-CG.dist.new ]; then echo -n "$i " paste $step/CG-CG.dist.tgt $step/CG-CG.dist.new | sed -e 's/nan/0.0/' | awk '{old = new; new=$1; sum+=($5-$2)**2;i++;}END{print sqrt(sum*(new-old));}' fi i=$((i+1)) done votca-csg-1.2.4/share/doc/0000755000175000001440000000000012400714673015201 5ustar christophusersvotca-csg-1.2.4/share/doc/CMakeLists.txt0000644000175000001440000000036412400714673017744 0ustar christophusersfind_package(Doxygen) if (DOXYGEN_FOUND) configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(html COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Build doxygen documentation") endif (DOXYGEN_FOUND) votca-csg-1.2.4/share/doc/Doxyfile.in0000644000175000001440000017424012400714673017324 0ustar christophusers# Doxyfile 1.5.9 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = @CMAKE_PROJECT_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will rougly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_SOURCE_DIR@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */.hg/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # disables this behavior completely. For backwards compatibility with previous # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # respectively. GENERATE_TREEVIEW = NONE # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO votca-csg-1.2.4/share/xml/0000755000175000001440000000000012400714673015234 5ustar christophusersvotca-csg-1.2.4/share/xml/CMakeLists.txt0000644000175000001440000000012712400714673017774 0ustar christophusersfile(GLOB_RECURSE VOTCA_XML *.xml) install(FILES ${VOTCA_XML} DESTINATION ${DATA}/xml) votca-csg-1.2.4/share/xml/cginteraction.xml0000644000175000001440000002551012400714673020612 0ustar christophusers name Name of the interaction. The name can be arbitrary but should be unique. For bonded interactions, this should match the name specified in the mapping file. type1 Only for non-bonded. **Bead** type 1 of non-bonded interaction. type2 Only for non-bonded. **Bead** type 2 of non-bonded interaction. bondtype Internal alias for non-bonded and bonded, set automatically min lower bound of interval for potential table in which calculations are performed. Should be set based on reference distributions. max upper bound of interval for potential table in which calculations are performed. Should be set based on reference distributions. step step size of interval for potential table in which calculations are performed. If step site is too small, lots of statistics is needed ( long runs ). If it's too big, features in the distribtuion/potentials might get lost. inverseContains all information relevant to iterative process inverse.target target distribution (e.g. rdf) which is tried to match during iterations to match inverse.do_potential 1 Update cycle for the potential update. 1 means update, 0 don't update. 1 1 0 means update 2 iterations, then don't update, then repeat. inverse.post_update Additional post-processing of dU before added to potential. This is a list of scripts separated by spaces which are called. See section on iterative framework for details. inverse.post_add Additional post processing of U after dU added to potential. This is a list of scripts separated by spaces which are called. See section on iterative framework for details. inverse.post_add_optionsContains all options of post add scripts inverse.post_add_options.overwriteContains all options of the overwrite postadd scripts inverse.post_add_options.overwrite.do pattern for overwrite postadd script (1 do, 0 do not). inverse.p_target partial pressure of this species inverse.particle_dens particle density of this species (for wjk pressure correction) inverse.post_update_optionsContains all options of post update scripts inverse.post_update_options.pressureContains all options of the pressure correction scripts inverse.post_update_options.pressure.do pattern for pressure correction (1 do, 0 do not). To do pressure correction every third step specify "0 0 1", similar to inverse.do_update inverse.post_update_options.pressure.type Pressure correction algoritm, can be simple or wjk inverse.post_update_options.pressure.simpleContains all options of the simple pressure correction script inverse.post_update_options.pressure.simple.scale slope of the simple pressure correction inverse.post_update_options.pressure.wjkContains all options of the wjk pressure correction script inverse.post_update_options.pressure.wjk.scale extra scaling factor of pressure correction inverse.post_update_options.smoothContains all options of the smooth script inverse.post_update_options.smooth.iterations number of iterations for triangular smooth inverse.post_update_options.splinesmoothContains all options of the spline smooth script inverse.post_update_options.splinesmooth.step grid spacing for spline fit when doing spline smoothing inverse.post_update_options.scale scale factor for the update inverse.post_add_options This section contains all options for post add scripts. inverse.post_add_options.copyback.filelist list of files to copy to the main dir inverse.post_add_options.convergence.weight weight factors for the convergence of the interaction, should be a list of same length as inverse.post_add_options.convergence.what (default 1) inverse.post_add_options.convergence.what list for what to calc the convergence: dist pot, .. (default dist) inverse.post_add_options.plot.gnuplot_bin gnuplot binary to use (default gnuplot) inverse.post_add_options.plot.gnuplot_opts extra options to give to gnuplot_bin (e.g. -persist, if one uses kill) inverse.post_add_options.plot.fd file descriptor to use (default 8), make it unique if you want to plot multiple things inverse.post_add_options.plot.script plot script to give to gnuplot inverse.post_add_options.plot.kill kill all processes with that name before ploting (e.g. gnuplot_x11), this is more reliable than using multiplot inverse.imc Section containing inverse monte carlo specific options. inverse.imc.group Group of interaction. Cross-correlations of all members of a group are taken into account for calculating the update. If no cross correlations should be calculated, interactions have to be put into different groups. inverse.gromacs This section contains gromacs specific options in case gromacs is used as simulation program. inverse.gromacs.table Name of file for tabulated potential of this interaction. This fill will be created from the internal tabulated potential format for every run. inverse.gromacs.grp1 Name of energy group of bead type1 using in the g_rdf index file. inverse.gromacs.grp2 Name of energy group of bead type2 using in the g_rdf index file. inverse.espresso This section contains espresso specific options in case espresso is used as simulation program. inverse.espresso.table Name of file for tabulated potential of this interaction. This file will be created from the internal tabulated potential format for every run. Note, though, that the original espresso blockfile needs to contain the name of that table as the tabulated interaction (see tutorial methanol ibi_espresso for details). inverse.espresso.index1 Index list of type1 -- Name of the Tcl variable containing all index1 particles that is contained in the espresso blockfile. inverse.espresso.index2 Index list of type2 -- Name of the Tcl variable containing all index2 particles that is contained in the espresso blockfile. fmatch Force matching options fmatch.min Minimum value of interval for distribution sampled in atomistic MD simulation. One can get this number by looking at the distribution function for this interaction. For non-bonded interactions it's the distance to the rdf start. For CG bonds and angles the variable has the similar meaning ( note, that for angles it is specified in radians ). fmatch.max Maximum value of interval for distribution sampled in atomistic MD simulation. One can get this number by looking at the distribution function for this interaction. For non-bonded interactions it's the cut-off of the interaction. fmatch.step grid spacing for the spline, which represents the interaction. This parameter should not be too big, otherwise you might lose some features of the interaction potential, and not too small either, otherwise you will have unsampled bins which result in an ill-defined equation system and NaNs in the output. fmatch.out_step Grid spacing for the output grid. Normally, one wants to have this parameter smaller than fmatch.step, to have a smooth curve, without additional spline interpolation. As a rule of thumb we normally use fmatch.out_step which is approximately 5 times smaller than fmatch.step. tfContains all information relevant to thermoforce iteration tf.spline_startStart of the spline used to smooth the density tf.spline_endEnd of the spline used to smooth the density tf.spline_stepGrid of the spline used to smooth the density tf.molnameMolecule name of this gropu used in gromacs topology tf.prefactorPrefactor for the thermoforce (f=-prefactor * grad density) tf.cg_prefactorSecond Prefactor for the thermoforce will be linear interpolated with tf.prefactor votca-csg-1.2.4/share/xml/mapping.xml0000644000175000001440000000747312400714673017424 0ustar christophusers name Name of molecule in coarse-grained representation. ident Molecule name in reference topology. topology Section containing definition of coarse grained topology of molecule. topology.cg_beads Section defining coarse grained beads of molecule. topology.cg_beads.cg_bead Definition of a coarse grained bead. topology.cg_beads.cg_bead.name Name of coarse grained bead. topology.cg_beads.cg_bead.type Type of coarse grained bead. topology.cg_beads.cg_bead.mapping Mapping scheme to be used for this bead (specified in section mapping) to map from reference system. topology.cg_beads.cg_bead.beads The beads section lists all atoms of the reference system that are mapped to this particular coarse grained bead. The syntax is RESID:RESNAME:ATOMNAME, the beads are separated by spaces. topology.cg_bonded The cg_bonded section contains all bonded interaction of the molecule. Those can be bond, angle or dihedral. An entry for each group of bonded interaction can be specified, e.g. several groups (types) of bonds can be specified. A specific bonded interaction can be later on addressed by MOLECULE:NAME:NUMBER, where MOLECULE is the molecule ID in the whole topology, NAME the name of the interaction group and NUMBER addresses the interaction in the group. topology.cg_bonded.bond Definition of a group of bonds. topology.cg_bonded.bond.name Name of the group. topology.cg_bonded.bond.beads List of pair of beads that define a bond. Names specified in cg_beads, separated by commas. topology.cg_bonded.angle Definition of a group of angles. topology.cg_bonded.angle.name Name of the group. topology.cg_bonded.angle.beads List of triples of beads that define a bond. Names specified in cg_beads, separated by commas. topology.cg_bonded.dihedral Definition of a group of dihedrals. Since the exact functional form does not matter, this combines proper as well as improper dihedrals. topology.cg_bonded.dihedral.name Name of the group. topology.cg_bonded.dihedral.beads List of quadruples of beads that define a bond. Names specified in cg_beads, separated by commas. maps Section containing definitions of mapping schemes. maps.map Section for a mapping for 1 bead. maps.map.name Name of the mapping. maps.map.weights Weights of the mapping matrix. Entries are normalized to 1, number of entries must match the number of reference beads in a coarse-grained bead. votca-csg-1.2.4/share/xml/cgoptions.xml0000644000175000001440000002436612400714673017776 0ustar christophusers cg Head option, which contains all coarse-graining options cg.non-bonded Section for a non-bonded interaction. Most of the items in here are identical to items in cg.bonded, so they will be described in the same section. cg.bonded Section for a bonded interaction. Most of the items in here are identical to items in cg.bonded, so they will be described in the same section. cg.nbsearchGrid search algorithm, simple (N square search) or grid (default is grid) cg.inverse
general options for inverse script cg.inverse.kBT kBT (300*0.00831451 gromacs units) cg.inverse.programsimulation package to be used cg.inverse.initial_configurationwhat initial configuration to use in every step: maindir/laststep (default laststep) cg.inverse.$sim_prog generic simulation program (e.g. GROMACS) options cg.inverse.$sim_prog.equi_time0.0 begin analysis after this time cg.inverse.$sim_prog.first_frame0 trash the given number of frames at the beginning of trajectory cg.inverse.gromacs gromacs specific options cg.inverse.gromacs.confName of the coordinate file read by grompp (default conf.gro) cg.inverse.gromacs.conf_outName of the original outcome coordinate written by mdrun (default confout.gro) cg.inverse.gromacs.gmxrcGMXRC to source at the startup cg.inverse.gromacs.equi_time0.0 begin analysis after this time when using gromacs cg.inverse.gromacs.first_frame0 trash the given number of frames at the beginning of trajectory cg.inverse.gromacs.topol binary Gromacs topology file to use, default topol.tpr cg.inverse.gromacs.traj_type Gromacs trajectory type (xtc/trr) file to use, default xtc cg.inverse.gromacs.mdp Gromacs mdp fie to use, default grompp.mdp cg.inverse.gromacs.grompp.index Gromacs grompp index file to use, default index.ndx cg.inverse.gromacs.grompp.topol Text Gromacs toplogy file to use, default topol.top cg.inverse.gromacs.grompp.bin Name (or absolute path) of the grompp binary cg.inverse.gromacs.grompp.opts Additional options to Gromacs grompp (e.g. -maxwarn 1) cg.inverse.gromacs.g_rdf.index Gromacs g_rdf index file to use, default index.ndx cg.inverse.gromacs.g_rdf.topol Gromacs g_rdf topol file to use, default topol.tpr cg.inverse.gromacs.g_rdf.bin Name (or absolute path) of the g_rdf binary cg.inverse.gromacs.g_rdf.opts Additional options for Gromacs g_rdf (e.g. -nopbc) cg.inverse.gromacs.mdrun.commandCommand to run mdrun (name or absolute path or mpirun mdrun..) cg.inverse.gromacs.mdrun.opts Additional options to Gromacs mdrun (e.g. -nosum) cg.inverse.gromacs.mdrun.checkpointName of the checkpint to use in case of restarted simulation (default state.cpt) cg.inverse.gromacs.g_energy.topol Gromacs g_rdf topol file to use, default topol.tpr cg.inverse.gromacs.g_energy.bin Name (or absolute path) of the g_energy binary cg.inverse.gromacs.g_energy.opts Additional options to Gromacs g_rdf (e.g. -P 1) cg.inverse.gromacs.table_bins grid for table*.xvg ! cg.inverse.gromacs.pot_max cut the potential at this value (gromacs bug) cg.inverse.gromacs.table_end extend the tables to this value cg.inverse.gromacs.cutoff_check check interaction cutoffs against rvdw in mdp file: yes/no (default yes) cg.inverse.gromacs.temp_check check temperture against t_ref in mdp file: yes/no (default yes) cg.inverse.gromacs.rdf.topol Gromacs topol file to be used for csg_stat default topol.tpr cg.inverse.espresso.blockfileName of the original blockfile read by Espresso (default conf.esp.gz) cg.inverse.espresso.blockfile_outName of the original outcome blockfile written by Espresso (default confout.esp.gz) cg.inverse.espresso.commandCommand to run espresso (name or absolute path or mpirun espresso..) cg.inverse.espresso.rdf_commandEspresso command to run when calculating the rdf (name or absolute path or mpirun espresso..) cg.inverse.espresso.pressure_commandEspresso command to run when calculating the pressure (name or absolute path or mpirun espresso..) cg.inverse.espresso.first_framerash the given number of frames at the beginning of trajectory cg.inverse.espresso.table_bins grid for tabulated potentials cg.inverse.espresso.traj Name of the output Espresso trajectory file cg.inverse.espresso.n_steps number of steps to integrate before a snapshot cg.inverse.espresso.n_snapshots number of snapshots. Total time = n_steps * n_snapshots cg.inverse.espresso.debug debug Espresso (yes/no) cg.inverse.espresso.table_end Espresso end of table cg.inverse.espresso.exclusions Espresso stuff to exclude cg.inverse.espresso.meta_cmd Espresso metadynamics command to call [experimental] cg.inverse.espresso.success File to create if Espresso simulation was successfull cg.inverse.espresso.meta_min_sampling Espresso metadynamics minimal number of sampling [experimental] cg.inverse.espresso.scriptdiroverwrite ESPRESSO_SCRIPTS from environment with this dir cg.inverse.filelist these files are copied for each new run cg.inverse.cleanlist these files are removed after each new run cg.inverse.iterations_max do the given number of iterations (0=inf) cg.inverse.convergence_checktype of convergence check to do cg.inverse.convergence_check_optionsoptions for the convergence check cg.inverse.convergence_check_options.limitlower limit to stop cg.inverse.convergence_check_options.name_globfiles to check for number (default *.conv) cg.inverse.method ibi: inverse boltzmann imc: inverse monte carlo cg.inverse.scriptdir directory for user scripts (e.g. $PWD) cg.inverse.log_file write log to this file cg.inverse.simulationsimulation options cg.inverse.simulation.tasksnumber of tasks (0/auto = automatic detect on linux) cg.inverse.simulation.backgroundtell csg_inverse that simulation was send to the backgroud (default no) cg.inverse.restart_file Name of the restart file in case a step has to be resumed cg.inverse.imc general imc specific options cg.inverse.imc.solver solver for solving a linear equation system, can be octave or matlab cg.inverse.imc.octave.bin Name (or absolute path) of the octave binary cg.inverse.imc.numpy.bin Name (or absolute path) of the python binary used by the numpy solver cg.inverse.imc.matlab.bin Name (or absolute path) of the matlab binary cg.fmatch Force matching options cg.fmatch.frames_per_block number of frames, being used for block averaging. Atomistic trajectory, specified with --trj option, is divided into blocks and the force matching equations are solved separately for each block. Coarse-grained force-field, which one gets on the output is averaged over those blocks. cg.fmatch.constrainedLS boolean variable: false - simple least squares, true - constrained least squares. For details see the VOTCA paper. Practically, both algorithms give the same results, but simple least squares is faster. If you are a mathematician and you think that a spline can only then be called a spline if it has continuous first and second derivatives, use constrained least squares. votca-csg-1.2.4/share/misc/0000755000175000001440000000000012400714673015367 5ustar christophusersvotca-csg-1.2.4/share/misc/do_errorplot.sh0000755000175000001440000000200412400714673020434 0ustar christophusers#!/bin/bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # do_errors() { csg_imc --top topol.tpr --trj traj.xtc --cg ../water_cg.xml --options ../cg.xml \ --do-imc --begin 100 \ --write-every $1 --do-blocks --nframes $((16*$1)) ~/src/csg/share/scripts/inverse/errorbars.sh ibm cp CG-CG.dpot.err ibm.err.$i ~/src/csg/share/scripts/inverse/errorbars.sh imc cp CG-CG.dpot.err imc.err.$i } for i in $(seq 1 250); do do_errors $i done votca-csg-1.2.4/src/0000755000175000001440000000000012400714674014122 5ustar christophusersvotca-csg-1.2.4/src/CMakeLists.txt0000644000175000001440000000012112400714673016653 0ustar christophusersadd_subdirectory(libcsg) add_subdirectory(tools) add_subdirectory(csg_boltzmann) votca-csg-1.2.4/src/libcsg/0000755000175000001440000000000012400714674015365 5ustar christophusersvotca-csg-1.2.4/src/libcsg/triclinicbox.cc0000644000175000001440000000210512400714674020363 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace csg { vec TriclinicBox::BCShortestConnection(const vec &r_i, const vec &r_j) const { vec r_tp, r_dp, r_sp, r_ij; vec a = _box.getCol(0); vec b = _box.getCol(1); vec c = _box.getCol(2); r_tp = r_j - r_i; r_dp = r_tp - c*round(r_tp.getZ()/c.getZ()); r_sp = r_dp - b*round(r_dp.getY()/b.getY()); r_ij = r_sp - a*round(r_sp.getX()/a.getX()); return r_ij; } }} votca-csg-1.2.4/src/libcsg/default.doxygen0000644000175000001440000001713012400714673020411 0ustar christophusers# Doxyfile 1.3-rc2 #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = testproject PROJECT_NUMBER = OUTPUT_DIRECTORY = OUTPUT_LANGUAGE = English EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO VERBATIM_HEADERS = YES SHOW_INCLUDE_FILES = YES JAVADOC_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = YES INHERIT_DOCS = NO INLINE_INFO = YES SORT_MEMBER_DOCS = NO DISTRIBUTE_GROUP_DOC = YES TAB_SIZE = 8 GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ALIASES = ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_FORMAT = "$file($line): $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = . FILE_PATTERNS = *.cpp \ *.c \ *.h \ *.cxx \ *.idl RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = YES INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 4 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = doxydoc HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = YES LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_SCHEMA = XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO CLASS_GRAPH = YES COLLABORATION_GRAPH = YES TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES GRAPHICAL_HIERARCHY = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO CGI_NAME = search.cgi CGI_URL = DOC_URL = DOC_ABSPATH = BIN_ABSPATH = /usr/local/bin/ EXT_DOC_PATHS = votca-csg-1.2.4/src/libcsg/map.cc0000644000175000001440000002223612400714673016455 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include namespace votca { namespace csg { using namespace std; Map::~Map() { vector::iterator iter; for(iter=_maps.begin();iter!=_maps.end();++iter) delete (*iter); _maps.clear(); } void Map::Apply() { vector::iterator iter; for(iter=_maps.begin();iter!=_maps.end();++iter) (*iter)->Apply(); } void Map_Sphere::Initialize(Molecule *in, Bead *out, Property *opts_bead, Property *opts_map) { BeadMap::Initialize(in, out, opts_bead, opts_map); vector beads; vector weights; vector fweights; // get the beads string s(_opts_bead->get("beads").value()); Tokenizer tok_beads(s, " \n\t"); tok_beads.ToVector(beads); // get vector of weights Tokenizer tok_weights(_opts_map->get("weights").value(), " \n\t"); tok_weights.ConvertToVector(weights); // check weather weights and # beads matches if (beads.size() != weights.size()) throw runtime_error(string("number of subbeads in " + opts_bead->get("name").as() + " and number of weights in map " + opts_map->get("name").as() + " do not match")); // normalize the weights double norm = 1./ std::accumulate(weights.begin(), weights.end(), 0.); transform(weights.begin(), weights.end(), weights.begin(), bind2nd(multiplies(), norm)); // get the d vector if exists or initialize same as weights vector d; if(_opts_map->exists("d")) { Tokenizer tok_weights(_opts_map->get("d").value(), " \n\t"); tok_weights.ConvertToVector(d); // normalize d coefficients norm = 1./std::accumulate(d.begin(), d.end(), 0.); transform(d.begin(), d.end(), d.begin(), bind2nd(multiplies(), norm)); } else { // initialize force-weights with weights d.resize(weights.size()); copy(weights.begin(), weights.end(), d.begin()); } // check weather number of d coeffs is correct if (beads.size() != d.size()) { throw runtime_error(string("number of subbeads in " + opts_bead->get("name").as() + " and number of d-coefficients in map " + opts_map->get("name").as() + " do not match")); } fweights.resize(weights.size()); // calculate force weights by d_i/w_i for(size_t i=0; iget("name").as()); } if(weights[i] != 0) fweights[i] = d[i] / weights[i]; else fweights[i] = 0; } for (size_t i = 0; i < beads.size(); ++i) { int iin = in->getBeadByName(beads[i]); if (iin < 0) throw std::runtime_error(string("mapping error: molecule " + beads[i] + " does not exist")); AddElem(in->getBead(iin), weights[i], fweights[i]); } } void Map_Sphere::Apply() { vector::iterator iter; vec cg(0., 0., 0.), f(0.,0.,0.), vel(0.,0.,0.); bool bPos, bVel, bF; bPos=bVel=bF=false; _out->ParentBeads().clear(); // the following is needed for pbc treatment Topology *top = _out->getParent(); double max_dist = 0.5*top->ShortestBoxSize(); vec r0 = vec(0,0,0); string name0; int id0; if(_matrix.size() > 0) { if(_matrix.front()._in->HasPos()) { r0=_matrix.front()._in->getPos(); name0 = _matrix.front()._in->getName(); id0 = _matrix.front()._in->getId(); } } double M = 0; for(iter = _matrix.begin(); iter != _matrix.end(); ++iter) { Bead *bead = iter->_in; _out->ParentBeads().push_back(bead->getId()); M+=bead->getM(); if(bead->HasPos()) { vec r = top->BCShortestConnection(r0, bead->getPos()); if(abs(r) > max_dist) { cout << r0 << " " << bead->getPos() << endl; throw std::runtime_error("coarse-grained bead is bigger than half the box \n (atoms " + name0 + " (id " + boost::lexical_cast(id0+1) + ")" + ", " + bead->getName() + " (id " + boost::lexical_cast(bead->getId()+1) + ")" + +" , molecule " + boost::lexical_cast(bead->getMolecule()->getId()+1) + ")" ); } cg += (*iter)._weight * (r+r0); bPos=true; } if(bead->HasVel()) { vel += (*iter)._weight * bead->getVel(); bVel = true; } if(bead->HasF()) { f += (*iter)._force_weight * bead->getF(); bF = true; } } _out->setM(M); if(bPos) _out->setPos(cg); if(bVel) _out->setVel(vel); if(bF) _out->setF(f); } /// \todo implement this function void Map_Ellipsoid::Apply() { vector::iterator iter; vec cg(0., 0., 0.), c(0., 0., 0.), f(0.,0.,0.), vel(0.,0.,0.); matrix m(0.); bool bPos, bVel, bF; bPos=bVel=bF=false; // the following is needed for pbc treatment Topology *top = _out->getParent(); double max_dist = 0.5*top->ShortestBoxSize(); vec r0 = vec(0,0,0); if(_matrix.size() > 0) { if(_matrix.front()._in->HasPos()) { r0=_matrix.front()._in->getPos(); } } int n; n = 0; _out->ParentBeads().clear(); for(iter = _matrix.begin(); iter != _matrix.end(); ++iter) { Bead *bead = iter->_in; _out->ParentBeads().push_back(bead->getId()); if(bead->HasPos()) { vec r = top->BCShortestConnection(r0, bead->getPos()); if(abs(r) > max_dist) throw std::runtime_error("coarse-grained bead is bigger than half the box"); cg += (*iter)._weight * (r+r0); bPos=true; } if(bead->HasVel() == true) { vel += (*iter)._weight * bead->getVel(); bVel = true; } if(bead->HasF()) { /// \todo fix me, right calculation should be F_i = m_cg / sum(w_i) * sum(w_i/m_i*F_i) //f += (*iter)._weight * _in->getBeadF((*iter)._in); f += (*iter)._force_weight * bead->getF(); bF = true; } if((*iter)._weight>0 && bead->HasPos()) { c += bead->getPos(); n++; } } if(bPos) _out->setPos(cg); if(bVel) _out->setVel(vel); if(bF) _out->setF(f); if(!_matrix[0]._in->HasPos()) { _out->setU(vec(1.0,0,0)); _out->setV(vec(.0,1,0)); _out->setW(vec(.0,0,1)); return; } // calculate the tensor of gyration c=c/(double)n; for(iter = _matrix.begin(); iter != _matrix.end(); ++iter) { if((*iter)._weight == 0) continue; Bead *bead = iter->_in; vec v = bead->getPos() - c; //v = vec(1, 0.5, 0) * 0.*(drand48()-0.5) // + vec(0.5, -1, 0) * (drand48()-0.5) // + vec(0, 0, 1) * (drand48()-0.5); //Normalize the tensor with 1/number_of_atoms_per_bead m[0][0] += v.getX()*v.getX()/(double)_matrix.size(); m[0][1] += v.getX()*v.getY()/(double)_matrix.size(); m[0][2] += v.getX()*v.getZ()/(double)_matrix.size(); m[1][1] += v.getY()*v.getY()/(double)_matrix.size(); m[1][2] += v.getY()*v.getZ()/(double)_matrix.size(); m[2][2] += v.getZ()*v.getZ()/(double)_matrix.size(); } m[1][0] = m[0][1]; m[2][0] = m[0][2]; m[2][1] = m[1][2]; // calculate the eigenvectors matrix::eigensystem_t es; m.SolveEigensystem(es); vec eigenv1=es.eigenvecs[0]; vec eigenv2=es.eigenvecs[1]; vec eigenv3=es.eigenvecs[2]; /* _out->seteigenvec1(eigenv1); _out->seteigenvec2(eigenv2); _out->seteigenvec3(eigenv3); */ vec u = es.eigenvecs[0]; vec v = _matrix[1]._in->getPos() - _matrix[0]._in->getPos(); v.normalize(); _out->setV(v); vec w = _matrix[2]._in->getPos() - _matrix[0]._in->getPos(); w.normalize(); if((v^w)*u < 0) u=vec(0.,0.,0.)-u; _out->setU(u); //write out w w=u^v; w.normalize(); _out->setW(w); //out.BeadV(_out) = v; //out.BeadW(_out) = es.eigenvecs[2]; } }} votca-csg-1.2.4/src/libcsg/nematicorder.cc0000644000175000001440000000424012400714674020350 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace csg { void NematicOrder::Process(Topology &top, const string &filter) { _mu.ZeroMatrix(); _mv.ZeroMatrix(); _mw.ZeroMatrix(); int N=0; bool bU, bV, bW; bU=bV=bW = false; for(BeadContainer::iterator iter = top.Beads().begin(); iter!=top.Beads().end();++iter) { Bead *bead = *iter; if(!wildcmp(filter.c_str(), bead->getName().c_str())) continue; if( bead->getSymmetry() ==1 ) continue; if(bead->HasU()) { _mu += bead->getU()|bead->getU(); _mu[0][0] -= 1./3.; _mu[1][1] -= 1./3.; _mu[2][2] -= 1./3.; bU = true; } if(bead->HasV()) { _mv += bead->getV()|bead->getV(); _mv[0][0] -= 1./3.; _mv[1][1] -= 1./3.; _mv[2][2] -= 1./3.; bV = true; } if(bead->HasW()) { _mw += bead->getW()|bead->getW(); _mw[0][0] -= 1./3.; _mw[1][1] -= 1./3.; _mw[2][2] -= 1./3.; bW = true; } N++; } double f = 1./(double)N*3./2.; _mu = f*_mu;_mv = f*_mv;_mw = f*_mw; if(bU) _mu.SolveEigensystem(_nemat_u); if(bV) _mv.SolveEigensystem(_nemat_v); if(bW) _mw.SolveEigensystem(_nemat_w); } }} votca-csg-1.2.4/src/libcsg/trajectorywriter.cc0000644000175000001440000000245412400714674021324 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #include #include #include "modules/io/pdbwriter.h" #include "modules/io/xyzwriter.h" #ifdef GMX #include "modules/io/gmxtrajectorywriter.h" #include "modules/io/growriter.h" #endif namespace votca { namespace csg { using namespace std; void TrajectoryWriter::RegisterPlugins() { TrjWriterFactory().Register("pdb"); TrjWriterFactory().Register("xyz"); #ifdef GMX TrjWriterFactory().Register("trr"); TrjWriterFactory().Register("xtc"); TrjWriterFactory().Register("gro"); #endif } }} votca-csg-1.2.4/src/libcsg/nblistgrid.cc0000644000175000001440000001204412400714673020035 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace csg { void NBListGrid::Generate(BeadList &list1, BeadList &list2, bool do_exclusions) { BeadList::iterator iter; _do_exclusions = do_exclusions; if(list1.empty()) return; if(list2.empty()) return; assert(list1.getTopology() == list2.getTopology()); Topology *top = _top = list1.getTopology(); InitializeGrid(top->getBox()); // Add all beads of list1 for(iter = list1.begin(); iter != list1.end(); ++iter) getCell((*iter)->getPos())._beads.push_back(*iter); for(iter = list2.begin(); iter != list2.end(); ++iter) { cell_t &cell = getCell((*iter)->getPos()); TestBead(cell, *iter); } } void NBListGrid::Generate(BeadList &list, bool do_exclusions) { BeadList::iterator iter; _do_exclusions = do_exclusions; if(list.empty()) return; Topology *top = _top = list.getTopology(); InitializeGrid(top->getBox()); for(iter = list.begin(); iter != list.end(); ++iter) { cell_t &cell = getCell((*iter)->getPos()); TestBead(cell, *iter); getCell((*iter)->getPos())._beads.push_back(*iter); } } void NBListGrid::InitializeGrid(const matrix &box) { _box_a = box.getCol(0); _box_b = box.getCol(1); _box_c = box.getCol(2); // create plane normals _norm_a = _box_b ^ _box_c; _norm_b = _box_c ^ _box_a; _norm_c = _box_a ^ _box_b; _norm_a.normalize(); _norm_b.normalize(); _norm_c.normalize(); double la = _box_a * _norm_a; double lb = _box_b * _norm_b; double lc = _box_c * _norm_c; // calculate grid size, each grid has to be at least size of cut-off _box_Na = max((int)(fabs(la/_cutoff)), 1); _box_Nb = max((int)(fabs(lb/_cutoff)), 1); _box_Nc = max((int)(fabs(lc/_cutoff)), 1); _norm_a = _norm_a / (_box_a*_norm_a)*(double)_box_Na; _norm_b = _norm_b / (_box_b*_norm_b)*(double)_box_Nb; _norm_c = _norm_c / (_box_c*_norm_c)*(double)_box_Nc; //cout << "grid size: " << _box_Na << "x" << _box_Nb << "x" << _box_Nc << endl; _grid.resize(_box_Na*_box_Nb*_box_Nc); int a1,a2,b1,b2,c1,c2; a1 = b1 = c1 = -1; a2 = b2 = c2 = 1; if(_box_Na < 3) a2 = 0; if(_box_Nb < 3) b2 = 0; if(_box_Nc < 3) c2 = 0; if(_box_Na < 2) a1 = 0; if(_box_Nb < 2) b1 = 0; if(_box_Nc < 2) c1 = 0; // wow, setting up the neighbours is an ugly for construct! // loop from N..2*N to avoid if and only use % for(int a=_box_Na; a<2*_box_Na; ++a) for(int b=_box_Nb; b<2*_box_Nb; ++b) for(int c=_box_Nc; c<2*_box_Nc; ++c) { cell_t &cell = getCell(a%_box_Na, b%_box_Nb, c%_box_Nc); for(int aa=a+a1; aa<=a+a2; ++aa) for(int bb=b+b1; bb<=b+b2; ++bb) for(int cc=c+c1; cc<=c+c2; ++cc) { cell_t *c = &getCell(aa%_box_Na, bb%_box_Nb, cc%_box_Nc); if(c == &cell) continue; // ignore self cell._neighbours.push_back( &getCell(aa%_box_Na, bb%_box_Nb, cc%_box_Nc) ); } } } NBListGrid::cell_t &NBListGrid::getCell(const vec &r) { int a = (int)floor(r*_norm_a); int b = (int)floor(r*_norm_b); int c = (int)floor(r*_norm_c); if(a<0) a = _box_Na + a%_box_Na; a %= _box_Na; if(b<0) b = _box_Nb + b%_box_Nb; b %= _box_Nb; if(c<0) c = _box_Nc + c%_box_Nc; c %= _box_Nc; return getCell(a,b,c); } void NBListGrid::TestBead(NBListGrid::cell_t &cell, Bead *bead) { TestCell(cell, bead); for(vector::iterator iter=cell._neighbours.begin(); iter!=cell._neighbours.end(); ++iter) { TestCell(*(*iter), bead); } } void NBListGrid::TestCell(NBListGrid::cell_t &cell, Bead *bead) { BeadList::iterator iter; vec u = bead->getPos(); for(iter=cell._beads.begin(); iter!=cell._beads.end(); ++iter) { vec v = (*iter)->getPos(); vec r = _top->BCShortestConnection(v, u); double d = abs(r); if(d < _cutoff){ if(_do_exclusions) if(_top->getExclusions().IsExcluded((*iter)->getId(), bead->getId())) { continue; } if((*_match_function)(*iter, bead, r, d)) if(!FindPair(*iter, bead)) AddPair(_pair_creator(*iter, bead, r)); } } } }} votca-csg-1.2.4/src/libcsg/topologyreader.cc0000644000175000001440000000266512400714674020744 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #include #include "modules/io/esptopologyreader.h" #include "modules/io/lammpsreader.h" #include "modules/io/xmltopologyreader.h" #ifdef GMX #include "modules/io/gmxtopologyreader.h" #include "modules/io/grotopologyreader.h" #include "modules/io/pdbtopologyreader.h" #endif namespace votca { namespace csg { void TopologyReader::RegisterPlugins(void) { TopReaderFactory().Register("esp"); TopReaderFactory().Register("xml"); TopReaderFactory().Register("dump"); #ifdef GMX TopReaderFactory().Register("tpr"); TopReaderFactory().Register("gro"); TopReaderFactory().Register("pdb"); #endif } }} votca-csg-1.2.4/src/libcsg/CMakeLists.txt0000644000175000001440000000576212400714673020136 0ustar christophusersoption(WITH_GMX "Build gromacs reader/writer, disabling leads to reduced functionality!" ON) option(WITH_GMX_DEVEL "Build against gromacs devel version, very experimental!" OFF) option(GMX_DOUBLE "Use double precision version of gromacs" OFF) file(GLOB GMX_SOURCES modules/io/gmx*.cc modules/io/gro*.cc modules/io/pdbtopology*.cc) file(GLOB NOT_GMX_SOURCES modules/io/gmx_print_version.cc modules/io/gmx_version_nb.cc) list(REMOVE_ITEM GMX_SOURCES ${NOT_GMX_SOURCES}) file(GLOB IO_SOURCES modules/io/*.cc) file(GLOB NOT_IO_SOURCES modules/io/mdp*.cc) list(REMOVE_ITEM IO_SOURCES ${GMX_SOURCES} ${NOT_GMX_SOURCES} ${NOT_IO_SOURCES}) if (WITH_GMX) if (GMX_DOUBLE) set(GMX_SUFFIX "_d") endif(GMX_DOUBLE) if (WITH_GMX_DEVEL) message(WARNING " Using gromacs-5.0, this is very experimental, hope you know what you are doing") set(LIBGMX "libgromacs") else(WITH_GMX_DEVEL) set(LIBGMX "libgmx") endif(WITH_GMX_DEVEL) find_package(GROMACS COMPONENTS "${LIBGMX}${GMX_SUFFIX}") if (NOT GROMACS_FOUND) message(FATAL_ERROR "gromacs not found, make sure you have installed at least the gromacs-4.0.7 and it's dev package. If the gromacs module was not found above, make sure you have sourced GMXRC or set PKG_CONFIG_PATH yourself. If you have a double precision version of gromacs enable to build against it with -DGMX_DOUBLE=ON. If you have gromacs-5.0 installed enable to build against it with -DWITH_GMX_DEVEL=ON. Gromacs support can be disable it with -DWITH_GMX=OFF. ") endif(NOT GROMACS_FOUND) #general to a gmx builds add_definitions(${GROMACS_DEFINITIONS}) include_directories(${GROMACS_INCLUDE_DIRS}) set(GMX ${GROMACS_VERSION}) add_executable(gmx_print_version modules/io/gmx_print_version.cc) target_link_libraries(gmx_print_version ${GROMACS_LIBRARIES}) add_custom_command(OUTPUT gmx_libs_version.h COMMAND gmx_print_version > gmx_libs_version.h DEPENDS gmx_print_version) list(APPEND GMX_SOURCES gmx_libs_version.h) else(WITH_GMX) set(GMX) set(GMX_SOURCES) endif(WITH_GMX) configure_file(votca_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/votca_config.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_custom_target(hgversion COMMAND ${CMAKE_COMMAND} -DTOP_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -P ${CMAKE_MODULE_PATH}/hgversion.cmake) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES hgversion.h) file(GLOB VOTCA_SOURCES *.cc) file(GLOB NOT_VOTCA_SOURCES version_nb.cc test.cc) list(REMOVE_ITEM VOTCA_SOURCES ${NOT_VOTCA_SOURCES}) add_library(votca_csg ${VOTCA_SOURCES} ${GMX_SOURCES} ${IO_SOURCES}) add_dependencies(votca_csg hgversion) set_target_properties(votca_csg PROPERTIES SOVERSION ${SOVERSION}) target_link_libraries(votca_csg ${VOTCA_TOOLS_LIBRARIES} ${GROMACS_LIBRARIES} ${BOOST_LIBRARIES} ${THREAD_LIBRARIES}) install(TARGETS votca_csg LIBRARY DESTINATION ${LIB} ARCHIVE DESTINATION ${LIB}) configure_file(libvotca_csg.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libvotca_csg.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libvotca_csg.pc DESTINATION ${LIB}/pkgconfig) votca-csg-1.2.4/src/libcsg/orthorhombicbox.cc0000644000175000001440000000212112400714674021100 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace csg { vec OrthorhombicBox::BCShortestConnection(const vec &r_i, const vec &r_j) const { vec r_ij; double a = _box.get(0,0); double b = _box.get(1,1); double c = _box.get(2,2); r_ij = r_j - r_i; r_ij.setZ( r_ij.getZ() - c*round(r_ij.getZ()/c) ); r_ij.setY( r_ij.getY() - b*round(r_ij.getY()/b) ); r_ij.setX( r_ij.getX() - a*round(r_ij.getX()/a) ); return r_ij; } }} votca-csg-1.2.4/src/libcsg/molecule.cc0000644000175000001440000000236012400714673017501 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace csg { void Molecule::AddBead(Bead *bead, const string &name) { _beads.push_back(bead); _bead_names.push_back(name); _beadmap[name] = _beads.size()-1; bead->_mol = this; } int Molecule::getBeadByName(const string &name) { map::iterator iter = _beadmap.find(name); if(iter == _beadmap.end()) { std::cout << "cannot find: <" << name << "> in " << _name << "\n"; return -1; } //assert(iter != _beadmap.end()); //return (*iter).second; return _beadmap[name]; } }} votca-csg-1.2.4/src/libcsg/topologymap.cc0000644000175000001440000000214312400714674020246 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace csg { TopologyMap::~TopologyMap() { MapContainer::iterator i; for(i=_maps.begin();i!=_maps.end();++i) delete *i; _maps.clear(); } void TopologyMap::Apply() { MapContainer::iterator iter; _out->setStep(_in->getStep()); _out->setTime(_in->getTime()); _out->setBox(_in->getBox()); for(iter=_maps.begin();iter!=_maps.end();++iter) (*iter)->Apply(); } }} votca-csg-1.2.4/src/libcsg/nblist.cc0000644000175000001440000000420012400714673017162 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace csg { NBList::NBList() : _do_exclusions(false), _match_function(0) { setPairType(); SetMatchFunction(NBList::match_always); } NBList::~NBList() { // TODO: NBList destructor } void NBList::Generate(BeadList &list1, BeadList &list2, bool do_exclusions) { BeadList::iterator iter1; BeadList::iterator iter2; _do_exclusions = do_exclusions; if(list1.empty()) return; if(list2.empty()) return; assert(list1.getTopology() == list2.getTopology()); Topology *top = list1.getTopology(); for(iter1 = list1.begin(); iter1 != list1.end(); ++iter1) { if(&list1 == &list2) { iter2=iter1; ++iter2; } else iter2 = list2.begin(); if(*iter1 == *iter2) continue; for(; iter2 != list2.end(); ++iter2) { vec u = (*iter1)->getPos(); vec v = (*iter2)->getPos(); vec r = top->BCShortestConnection(u, v); double d = abs(r); if(d < _cutoff){ if(_do_exclusions) if(top->getExclusions().IsExcluded((*iter1)->getId(), (*iter2)->getId())) { continue; } if((*_match_function)(*iter1, *iter2, r, d)) if(!FindPair(*iter1, *iter2)) AddPair( _pair_creator(*iter1, *iter2, r)); } } } } }} votca-csg-1.2.4/src/libcsg/beadlist.cc0000644000175000001440000000470712400714673017472 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace csg { int BeadList::Generate(Topology &top, const string &select) { BeadContainer::iterator iter; _topology = ⊤ bool selectByName=false; string pSelect; //parsed selection string if (select.substr(0, 5)=="name:"){ //select according to bead name instead of type pSelect=select.substr(5); selectByName=true; }else{ pSelect=select; } for(iter=top.Beads().begin(); iter!=top.Beads().end();++iter) { if (!selectByName){ if(wildcmp(pSelect.c_str(), (*iter)->getType()->getName().c_str())) { push_back(*iter); } }else{ if(wildcmp(pSelect.c_str(), (*iter)->getName().c_str())) { push_back(*iter); } } } return size(); } int BeadList::GenerateInSphericalSubvolume(Topology &top, const string &select, vec ref, double radius) { BeadContainer::iterator iter; _topology = ⊤ bool selectByName=false; string pSelect; //parsed selection string if (select.substr(0, 5)=="name:"){ //select according to bead name instead of type pSelect=select.substr(5); selectByName=true; }else{ pSelect=select; } for(iter=top.Beads().begin(); iter!=top.Beads().end();++iter) { if (abs(_topology->BCShortestConnection(ref, (*iter)->getPos())) > radius) continue; if (!selectByName){ if(wildcmp(pSelect.c_str(), (*iter)->getType()->getName().c_str())) { push_back(*iter); } }else{ if(wildcmp(pSelect.c_str(), (*iter)->getName().c_str())) { push_back(*iter); } } } return size(); } }} votca-csg-1.2.4/src/libcsg/version.cc0000644000175000001440000000405612400714674017366 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #if GMX == 50 #include #elif GMX == 45 #include #elif GMX == 40 extern "C" { #include } #endif #ifdef GMX // this one is needed because of bool is defined in one of the headers included by gmx #undef bool #endif extern "C" { void VotcaCsgFromC(){ //do nothing - this is just that we have a c function for autotools } } namespace votca { namespace csg { //defines hgversion #include "hgversion.h" static const std::string version_str = std::string(VERSION) + " " + hgversion + " (compiled " __DATE__ ", " __TIME__ ")"; const std::string &CsgVersionStr() { return version_str; } void HelpTextHeader(const std::string &tool_name) { std::cout << "==================================================\n" << "======== VOTCA (http://www.votca.org) ========\n" << "==================================================\n\n" << "please submit bugs to " PACKAGE_BUGREPORT "\n\n" << tool_name << ", version " << votca::csg::CsgVersionStr() << "\nvotca_tools, version " << votca::tools::ToolsVersionStr() #ifdef GMX << "\ngromacs, " << GromacsVersion() #ifdef GMX_DOUBLE << " (double precision)" #else << " (single precision)" #endif #else << "\n" #endif << "\n\n"; } }} votca-csg-1.2.4/src/libcsg/trajectoryreader.cc0000644000175000001440000000250712400714674021251 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #include #include "modules/io/esptrajectoryreader.h" #include "modules/io/lammpsreader.h" #ifdef GMX #include "modules/io/gmxtrajectoryreader.h" #endif namespace votca { namespace csg { void TrajectoryReader::RegisterPlugins(void) { TrjReaderFactory().Register("esp"); TrjReaderFactory().Register("dump"); #ifdef GMX TrjReaderFactory().Register("trr"); TrjReaderFactory().Register("xtc"); TrjReaderFactory().Register("gro"); TrjReaderFactory().Register("pdb"); #endif } }} votca-csg-1.2.4/src/libcsg/csgapplication.cc0000644000175000001440000004012212400714673020672 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include namespace votca { namespace csg { CsgApplication::CsgApplication(void) { } CsgApplication::~CsgApplication(void) { } void CsgApplication::Initialize(void) { // register all io plugins TrajectoryWriter::RegisterPlugins(); TrajectoryReader::RegisterPlugins(); TopologyReader::RegisterPlugins(); AddProgramOptions() ("top", boost::program_options::value (), " atomistic topology file"); if (DoMapping()) { if (DoMappingDefault()) { AddProgramOptions("Mapping options") ("cg", boost::program_options::value (), " coarse graining mapping definitions (xml-file)") ("map-ignore", boost::program_options::value(), " list of molecules to ignore separated by ;") ("no-map", " disable mapping and act on original trajectory"); } else { AddProgramOptions("Mapping options") ("cg", boost::program_options::value (), " [OPTIONAL] coarse graining mapping definitions\n" " (xml-file). If no file is given, program acts on original trajectory"); } } if (DoTrajectory()) AddProgramOptions("Trajectory options") ("trj", boost::program_options::value (), " atomistic trajectory file") ("begin", boost::program_options::value()->default_value(0.0), " skip frames before this time") ("first-frame", boost::program_options::value()->default_value(0), " start with this frame") ("nframes", boost::program_options::value(), " process the given number of frames") ; if (DoThreaded()) /* * TODO default value of 1 for nt is not smart */ AddProgramOptions("Threading options") ("nt", boost::program_options::value()->default_value(1), " number of threads") ; } bool CsgApplication::EvaluateOptions(void) { _do_mapping = false; CheckRequired("top", "no topology file specified"); // check for mapping options if (DoMapping()) { // default mapping is on if (DoMappingDefault()) { // if the user does not explicitly ask to turn it off, cg is needed if (OptionsMap().count("no-map") == 0) { CheckRequired("cg", "no coarse graining definition specified"); _do_mapping = true; } }// default mapping is off, if user gives cg, then do mapping else if (OptionsMap().count("cg")) { _do_mapping = true; } } /* check threading options */ if (DoThreaded()) { _nthreads = _op_vm["nt"].as (); /* TODO * does the number of threads make sense? * which criteria should be used? smaller than system's cores? */ } return true; } void CsgApplication::ShowHelpText(std::ostream &out) { string name = ProgramName(); if (VersionString() != "") name = name + ", version " + VersionString(); HelpTextHeader(name); HelpText(out); out << "\n\n" << OptionsDesc() << endl; } void CsgApplication::Worker::Run(void) { while (_app->ProcessData(this)) { if (_app->SynchronizeThreads()) { int id = getId(); _app->_threadsMutexesOut[id]->Lock(); _app->MergeWorker(this); _app->_threadsMutexesOut[(id + 1) % _app->_nthreads]->Unlock(); } } } bool CsgApplication::ProcessData(Worker * worker) { int id; id = worker->getId(); if (SynchronizeThreads()) { //wait til its your turn _threadsMutexesIn[id]->Lock(); } _traj_readerMutex.Lock(); if (_nframes == 0) { _traj_readerMutex.Unlock(); if (SynchronizeThreads()) { //done processing? don't forget to unlock next worker anyway _threadsMutexesIn[(id + 1) % _nthreads]->Unlock(); } return false; } _nframes--; if (!_is_first_frame || worker->getId() != 0) { //get frame bool tmpRes = _traj_reader->NextFrame(worker->_top); if (!tmpRes) { _traj_readerMutex.Unlock(); if (SynchronizeThreads()) _threadsMutexesIn[(id + 1) % _nthreads]->Unlock(); return false; } } if (worker->getId() == 0) _is_first_frame = false; _traj_readerMutex.Unlock(); if (SynchronizeThreads()) { //unlock next frame for input _threadsMutexesIn[(id + 1) % _nthreads]->Unlock(); } //evaluate if (_do_mapping) { worker->_map->Apply(); worker->EvalConfiguration(&worker->_top_cg, &worker->_top); } else worker->EvalConfiguration(&worker->_top); return true; } void CsgApplication::Run(void) { TopologyReader *reader; // create reader for atomistic topology reader = TopReaderFactory().Create(_op_vm["top"].as ()); if (reader == NULL) throw runtime_error(string("input format not supported: ") + _op_vm["top"].as ()); class DummyWorker : public Worker { public: void EvalConfiguration(Topology *top, Topology *top_ref) { _app->EvalConfiguration(top, top_ref); } }; // create the master worker Worker *master = NULL; if (DoThreaded()) master = ForkWorker(); else master = new DummyWorker(); master->setApplication(this); master->setId(0); _myWorkers.push_back(master); CGEngine cg; ////////////////////////////////////////////////// // read in the topology for master ////////////////////////////////////////////////// reader->ReadTopology(_op_vm["top"].as (), master->_top); cout << "I have " << master->_top.BeadCount() << " beads in " << master->_top.MoleculeCount() << " molecules" << endl; master->_top.CheckMoleculeNaming(); if (_do_mapping) { // read in the coarse graining definitions (xml files) cg.LoadMoleculeType(_op_vm["cg"].as ()); // create the mapping + cg topology if(_op_vm.count("map-ignore") != 0) { Tokenizer tok(_op_vm["map-ignore"].as(), ";"); Tokenizer::iterator iter; for(iter=tok.begin(); iter!=tok.end(); ++iter) { string str=*iter; boost::trim(str); if(str.length() > 0) cg.AddIgnore(str); } } master->_map = cg.CreateCGTopology(master->_top, master->_top_cg); cout << "I have " << master->_top_cg.BeadCount() << " beads in " << master->_top_cg.MoleculeCount() << " molecules for the coarsegraining" << endl; master->_map->Apply(); if (!EvaluateTopology(&master->_top_cg, &master->_top)) return; } else if (!EvaluateTopology(&master->_top)) return; ////////////////////////////////////////////////// // Here trajectory parsing starts ////////////////////////////////////////////////// if (DoTrajectory() && _op_vm.count("trj")) { double begin; int first_frame; bool has_begin = false; if (_op_vm.count("begin")) { has_begin = true; begin = _op_vm["begin"].as(); } _nframes = -1; if (_op_vm.count("nframes")) { _nframes = _op_vm["nframes"].as(); } first_frame = _op_vm["first-frame"].as(); // create reader for trajectory _traj_reader = TrjReaderFactory().Create(_op_vm["trj"].as ()); if (_traj_reader == NULL) throw runtime_error(string("input format not supported: ") + _op_vm["trj"].as ()); // open the trajectory _traj_reader->Open(_op_vm["trj"].as ()); ////////////////////////////////////////////////// // Create all the workers /////////////////verbose///////////////////////////////// for (int thread = 1; thread < _nthreads && DoThreaded(); thread++) { Worker *myWorker = ForkWorker(); myWorker->setApplication(this); myWorker->setId(thread); _myWorkers.push_back(myWorker); // this will be changed to CopyTopologyData // read in the topology reader->ReadTopology(_op_vm["top"].as (), myWorker->_top); myWorker->_top.CheckMoleculeNaming(); if (_do_mapping) { // create the mapping + cg topology myWorker->_map = cg.CreateCGTopology(myWorker->_top, myWorker->_top_cg); } } ////////////////////////////////////////////////// // Proceed to first frame of interest ////////////////////////////////////////////////// _traj_reader->FirstFrame(master->_top); if(master->_top.getBoxType()==BoundaryCondition::typeOpen) { cout << "NOTE: You are using OpenBox boundary conditions. Check if this is intended.\n" << endl; } //seek first frame, let thread0 do that bool bok; for (bok = true; bok == true; bok = _traj_reader->NextFrame(master->_top)) { if (((master->_top.getTime() < begin) && has_begin) || first_frame > 1) { first_frame--; continue; } break; } if (!bok) { // trajectory was too short and we did not proceed to first frame _traj_reader->Close(); delete _traj_reader; throw std::runtime_error("trajectory was too short, did not process a single frame"); } // notify all observers that coarse graining has begun if (_do_mapping) { master->_map->Apply(); BeginEvaluate(&master->_top_cg, &master->_top); } else BeginEvaluate(&master->_top); _is_first_frame = true; ///////////////////////////////////////////////////////////////////////// //start threads if (DoThreaded()) { for (size_t thread = 0; thread < _myWorkers.size(); thread++) { if (SynchronizeThreads()) { Mutex *myMutexIn = new Mutex; _threadsMutexesIn.push_back(myMutexIn); // lock each worker for input myMutexIn->Lock(); Mutex *myMutexOut = new Mutex; _threadsMutexesOut.push_back(myMutexOut); // lock each worker for output myMutexOut->Lock(); } } for (size_t thread = 0; thread < _myWorkers.size(); thread++) _myWorkers[thread]->Start(); if (SynchronizeThreads()) { //unlock first thread and start ordered input/output _threadsMutexesIn[0]->Unlock(); _threadsMutexesOut[0]->Unlock(); } // mutex needed for merging if SynchronizeThreads()==False Mutex mergeMutex; for (size_t thread = 0; thread < _myWorkers.size(); thread++) { _myWorkers[thread]->WaitDone(); if (!SynchronizeThreads()) { mergeMutex.Lock(); MergeWorker(_myWorkers[thread]); mergeMutex.Unlock(); } delete _myWorkers[thread]; } for (size_t thread = 0; thread < _threadsMutexesIn.size(); ++thread) { delete _threadsMutexesIn[thread]; delete _threadsMutexesOut[thread]; } } else { master->Run(); delete master; } EndEvaluate(); _myWorkers.clear(); _threadsMutexesIn.clear(); _threadsMutexesOut.clear(); _traj_reader->Close(); delete _traj_reader; } delete reader; } CsgApplication::Worker::~Worker() { if (_map) delete _map; } void CsgApplication::BeginEvaluate(Topology *top, Topology * top_ref) { list::iterator iter; for (iter = _observers.begin(); iter != _observers.end(); ++iter) (*iter)->BeginCG(top, top_ref); } void CsgApplication::EndEvaluate() { list::iterator iter; for (iter = _observers.begin(); iter != _observers.end(); ++iter) (*iter)->EndCG(); } void CsgApplication::EvalConfiguration(Topology *top, Topology * top_ref) { list::iterator iter; for (iter = _observers.begin(); iter != _observers.end(); ++iter) (*iter)->EvalConfiguration(top, top_ref); } CsgApplication::Worker *CsgApplication::ForkWorker(void) { throw std::runtime_error("ForkWorker not implemented in application"); return NULL; } void CsgApplication::MergeWorker(CsgApplication::Worker *worker) { throw std::runtime_error("MergeWorker not implemented in application"); } } } votca-csg-1.2.4/src/libcsg/boundarycondition.cc0000644000175000001440000000156712400714673021436 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace csg { double BoundaryCondition::BoxVolume() { vec a = _box.getCol(0); vec b = _box.getCol(1); vec c = _box.getCol(2); return (a^b)*c; } }} votca-csg-1.2.4/src/libcsg/version_nb.cc0000644000175000001440000000231112400714674020035 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace csg { static const std::string version_str = "VERSION NOT SET (compiled " __DATE__ ", " __TIME__ ")"; const std::string &CsgVersionStr() { return version_str; } void HelpTextHeader(const std::string &tool_name) { std::cout << "\t------ VOTCA ( http://www.votca.org ) ------\n" << tool_name << ", version " << votca::csg::CsgVersionStr() << "\nvotca_tools, version " << votca::tools::ToolsVersionStr() << "\n\n"; } }} votca-csg-1.2.4/src/libcsg/topology.cc0000644000175000001440000002330712400714674017555 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace csg { Topology::~Topology() { Cleanup(); if(_bc) delete (_bc); _bc = NULL; } void Topology::Cleanup() { // cleanup beads { BeadContainer::iterator i; for(i=_beads.begin();i<_beads.end();++i) delete *i; _beads.clear(); } // cleanup molecules { MoleculeContainer::iterator i; for(i=_molecules.begin();i<_molecules.end();++i) delete *i; _molecules.clear(); } // cleanup residues { ResidueContainer::iterator i; for(i=_residues.begin();i<_residues.end();++i) delete (*i); _residues.clear(); } // cleanup interactions { InteractionContainer::iterator i; for(i=_interactions.begin();i<_interactions.end();++i) delete (*i); _interactions.clear(); } // cleanup _bc object if(_bc) delete (_bc); _bc = new OpenBox(); } /// \todo implement checking!! void Topology::CreateMoleculesByRange(string name, int first, int nbeads, int nmolecules) { Molecule *mol = CreateMolecule(name); int beadcount=0; BeadContainer::iterator bead; for(bead=_beads.begin(); bead!=_beads.end(); ++bead) { while(--first > 0) continue; string bname = //lexical_cast(mol->getId()) + ":" //lexical_cast(bead->Residue()) + ":" //+ (*bead)->getName(); mol->AddBead((*bead), bname); if(++beadcount == nbeads) { if(--nmolecules <= 0) break; mol = CreateMolecule(name); beadcount = 0; } } } /// \todo clean up CreateMoleculesByResidue! void Topology::CreateMoleculesByResidue() { // first create a molecule for each residue ResidueContainer::iterator res; for(res=_residues.begin(); res!=_residues.end(); ++res) { CreateMolecule((*res)->getName()); } // add the beads to the corresponding molecules based on their resid BeadContainer::iterator bead; for(bead=_beads.begin(); bead!=_beads.end(); ++bead) { //MoleculeByIndex((*bead)->getResnr())->AddBead((*bead)->getId(), (*bead)->getName()); MoleculeByIndex((*bead)->getResnr())->AddBead((*bead), string("1:TRI:") + (*bead)->getName()); } /// \todo sort beads in molecules that all beads are stored in the same order. This is needed for the mapping! } void Topology::CreateOneBigMolecule(string name) { Molecule *mi = CreateMolecule(name); BeadContainer::iterator bead; for(bead=_beads.begin(); bead!=_beads.end(); ++bead) { stringstream n(""); n << (*bead)->getResnr() +1 << ":" << _residues[(*bead)->getResnr()]->getName() << ":" << (*bead)->getName(); //cout << n.str() << endl; mi->AddBead((*bead), n.str()); } } void Topology::Add(Topology *top) { BeadContainer::iterator bead; ResidueContainer::iterator res; MoleculeContainer::iterator mol; int res0=ResidueCount(); for(bead=top->_beads.begin(); bead!=top->_beads.end(); ++bead) { Bead *bi = *bead; BeadType *type = GetOrCreateBeadType(bi->getType()->getName()); CreateBead(bi->getSymmetry(), bi->getName(), type, bi->getResnr()+res0, bi->getM(), bi->getQ()); } for(res=top->_residues.begin();res!=top->_residues.end(); ++res) { CreateResidue((*res)->getName()); } // \todo beadnames in molecules!! for(mol=top->_molecules.begin();mol!=top->_molecules.end(); ++mol) { Molecule *mi = CreateMolecule((*mol)->getName()); for(int i=0; iBeadCount(); i++) { mi->AddBead(mi->getBead(i), "invalid"); } } } void Topology::CopyTopologyData(Topology *top) { BeadContainer::iterator it_bead; ResidueContainer::iterator it_res; MoleculeContainer::iterator it_mol; InteractionContainer::iterator it_ia; _bc->setBox(top->getBox()); _time = top->_time; _step = top->_step; // cleanup old data Cleanup(); // copy all residues for(it_res=top->_residues.begin();it_res!=top->_residues.end(); ++it_res) { CreateResidue((*it_res)->getName()); } // create all beads for(it_bead=top->_beads.begin(); it_bead!=top->_beads.end(); ++it_bead) { Bead *bi = *it_bead; BeadType *type = GetOrCreateBeadType(bi->getType()->getName()); Bead *bn = CreateBead(bi->getSymmetry(), bi->getName(), type, bi->getResnr(), bi->getM(), bi->getQ()); bn->setOptions(bi->Options()); } // copy all molecules for(it_mol=top->_molecules.begin();it_mol!=top->_molecules.end(); ++it_mol) { Molecule *mi = CreateMolecule((*it_mol)->getName()); for(int i=0; i<(*it_mol)->BeadCount(); i++) { int beadid = (*it_mol)->getBead(i)->getId(); mi->AddBead(_beads[beadid], (*it_mol)->getBeadName(i)); } } // TODO: copy interactions //for(it_ia=top->_interaction.begin();it_ia=top->_interactions.end();++it_ia) { //} } void Topology::RenameMolecules(string range, string name) { RangeParser rp; RangeParser::iterator i; rp.Parse(range); for(i=rp.begin();i!=rp.end();++i) { if((unsigned int)*i > _molecules.size()) throw runtime_error(string("RenameMolecules: num molecules smaller than")); getMolecule(*i-1)->setName(name); } } void Topology::CheckMoleculeNaming(void) { map nbeads; for(MoleculeContainer::iterator iter = _molecules.begin(); iter!=_molecules.end(); ++iter) { map::iterator entry = nbeads.find((*iter)->getName()); if(entry != nbeads.end()) { if(entry->second != (*iter)->BeadCount()) throw runtime_error("There are molecules which have the same name but different number of bead " "please check the section manual topology handling in the votca manual"); continue; } nbeads[(*iter)->getName()] = (*iter)->BeadCount(); } } void Topology::AddBondedInteraction(Interaction *ic) { map::iterator iter; iter = _interaction_groups.find(ic->getGroup()); if(iter!=_interaction_groups.end()) ic->setGroupId((*iter).second); else { int i= _interaction_groups.size(); _interaction_groups[ic->getGroup()] = i; ic->setGroupId(i); } _interactions.push_back(ic); _interactions_by_group[ic->getGroup()].push_back(ic); } std::list Topology::InteractionsInGroup(const string &group) { map >::iterator iter; iter = _interactions_by_group.find(group); if(iter == _interactions_by_group.end()) return list(); return iter->second; } BeadType *Topology::GetOrCreateBeadType(string name) { map::iterator iter; iter = _beadtype_map.find(name); if(iter == _beadtype_map.end()) { BeadType *bt = new BeadType(this, _beadtypes.size(), name); _beadtypes.push_back(bt); _beadtype_map[name] = bt->getId(); return bt; } else { return _beadtypes[(*iter).second]; } return NULL; } vec Topology::BCShortestConnection(const vec &r_i, const vec &r_j) const { return _bc->BCShortestConnection(r_i, r_j); } vec Topology::getDist(int bead1, int bead2) const { return BCShortestConnection( getBead(bead1)->getPos(), getBead(bead2)->getPos()); } double Topology::BoxVolume() { return _bc->BoxVolume(); } void Topology::RebuildExclusions() { _exclusions.CreateExclusions(this); } BoundaryCondition::eBoxtype Topology::autoDetectBoxType(const matrix &box) { // set the box type to OpenBox in case "box" is the zero matrix, // to OrthorhombicBox in case "box" is a diagonal matrix, // or to TriclinicBox otherwise if(box.get(0,0)==0 && box.get(0,1)==0 && box.get(0,2)==0 && box.get(1,0)==0 && box.get(1,1)==0 && box.get(1,2)==0 && box.get(2,0)==0 && box.get(2,1)==0 && box.get(2,2)==0) { //cout << "box open\n"; return BoundaryCondition::typeOpen; } else if(box.get(0,1)==0 && box.get(0,2)==0 && box.get(1,0)==0 && box.get(1,2)==0 && box.get(2,0)==0 && box.get(2,1)==0) { //cout << "box orth\n"; return BoundaryCondition::typeOrthorhombic; } else { //cout << "box tric\n"; return BoundaryCondition::typeTriclinic; } return BoundaryCondition::typeOpen; } double Topology::ShortestBoxSize() { vec _box_a = getBox().getCol(0); vec _box_b = getBox().getCol(1); vec _box_c = getBox().getCol(2); // create plane normals vec _norm_a = _box_b ^ _box_c; vec _norm_b = _box_c ^ _box_a; vec _norm_c = _box_a ^ _box_b; _norm_a.normalize(); _norm_b.normalize(); _norm_c.normalize(); double la = _box_a * _norm_a; double lb = _box_b * _norm_b; double lc = _box_c * _norm_c; return min(la, min(lb, lc)); } }} votca-csg-1.2.4/src/libcsg/imcio.cc0000644000175000001440000001266712400714673017007 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include #include namespace votca { namespace csg { typedef ub::matrix group_matrix; using namespace std; void imcio_write_dS(const string &file, ub::vector &r, ub::vector &dS, std::list *list) { // write the dS ofstream out_dS; out_dS.open(file.c_str()); out_dS << setprecision(8); if (!out_dS) throw runtime_error(string("error, cannot open file ") + file); if(list == NULL) { for (size_t i = 0; i < dS.size(); ++i) { out_dS << r[i] << " " << dS[i] << endl; } } else { for(std::list::iterator i = list->begin(); i!=list->end(); ++i) { out_dS << r[*i] << " " << dS[*i] << endl; } } out_dS.close(); cout << "written " << file << endl; } void imcio_write_matrix(const string &file, ub::matrix &gmc, std::list *list) { ofstream out_A; out_A.open(file.c_str()); out_A << setprecision(8); if (!out_A) throw runtime_error(string("error, cannot open file ") + file); if(list == NULL) { for (group_matrix::size_type i = 0; i < gmc.size1(); ++i) { for (group_matrix::size_type j = 0; j < gmc.size2(); ++j) { out_A << gmc(min(i,j), max(i,j)) << " "; } out_A << endl; } } else { for(std::list::iterator i = list->begin(); i!=list->end(); ++i) { for(std::list::iterator j = list->begin(); j!=list->end(); ++j) { out_A << gmc(*i, *j) << " "; } out_A << endl; } } out_A.close(); cout << "written " << file << endl; } void imcio_write_index(const string &file, vector &names, vector &ranges) { // write the index ofstream out_idx; out_idx.open(file.c_str()); if (!out_idx) throw runtime_error(string("error, cannot open file ") + file); for (size_t i = 0; i < names.size(); ++i) out_idx << names[i] << " " << ranges[i] << endl; out_idx.close(); cout << "written " << file << endl; } void imcio_read_dS(const string &filename, ub::vector &r, ub::vector &dS) { Table tbl; tbl.Load(filename); r.resize(tbl.size()); dS.resize(tbl.size()); for(int i=0; i &gmc) { ifstream in; in.open(filename.c_str()); bool is_initialized = false; if(!in) throw runtime_error(string("error, cannot open file ") + filename); size_t line_count =0; string line; // read till the first data line while(getline(in, line)) { // remove comments and xmgrace stuff line = line.substr(0, line.find("#")); line = line.substr(0, line.find("@")); // tokenize string and put it to vector Tokenizer tok(line, " \t"); vector tokens; tok.ToVector(tokens); // skip empty lines if(tokens.size()==0) continue; if(!is_initialized) gmc.resize(tokens.size(),tokens.size()); is_initialized=true; if(gmc.size1()!=tokens.size()) throw runtime_error(string("error loading ") + filename + ": size mismatchm, number of columns differ"); for(size_t i=0; i(tokens[i]); ++line_count; } if(line_count != gmc.size1()) throw runtime_error(string("error loading ") + filename + ": size mismatch, not enough lines"); in.close(); } void imcio_read_index(const string &filename, vector &names, vector &ranges) { ifstream in; in.open(filename.c_str()); if(!in) throw runtime_error(string("error, cannot open file ") + filename); names.clear(); ranges.clear(); string line; // read till the first data line while(getline(in, line)) { // remove comments and xmgrace stuff line = line.substr(0, line.find("#")); line = line.substr(0, line.find("@")); boost::trim(line); size_t found; found = line.find(" "); if(found==string::npos) throw runtime_error(string("wrong format in ") + filename); string name = line.substr(0, found); string range = line.substr(found); RangeParser rp; rp.Parse(range); names.push_back(name); ranges.push_back(rp); } in.close(); } }} votca-csg-1.2.4/src/libcsg/cgengine.cc0000644000175000001440000000511712400714673017456 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace csg { namespace po = boost::program_options; CGEngine::CGEngine() { } CGEngine::~CGEngine() { map::iterator i; for(i=_molecule_defs.begin(); i!=_molecule_defs.end();++i) delete (*i).second; _molecule_defs.clear(); } /** \todo melts with different molecules */ TopologyMap *CGEngine::CreateCGTopology(Topology &in, Topology &out) { MoleculeContainer &mols = in.Molecules(); MoleculeContainer::iterator iter; TopologyMap *m = new TopologyMap(&in, &out); for(iter=mols.begin(); iter!=mols.end(); ++iter) { Molecule *mol = *iter; if(IsIgnored(mol->getName())) continue; CGMoleculeDef *def = getMoleculeDef(mol->getName()); if(!def) { cout << "--------------------------------------\n" << "WARNING: unknown molecule \"" << mol->getName() << "\" with id " << mol->getId() << " in topology" << endl << "molecule will not be mapped to CG representation\n" << "Check weather a mapping file for all molecule exists, was specified in --cg " << "separated by ; and the ident tag in xml-file matches the molecule name\n" << "--------------------------------------\n"; continue; } Molecule *mcg = def->CreateMolecule(out); Map *map = def->CreateMap(*mol, *mcg); m->AddMoleculeMap(map); } out.RebuildExclusions(); return m; } void CGEngine::LoadMoleculeType(string filename) { Tokenizer tok(filename, ";"); Tokenizer::iterator iter; for(iter=tok.begin(); iter!=tok.end(); ++iter) { CGMoleculeDef *def = new CGMoleculeDef(); string file = *iter; boost::trim(file); def->Load(file); _molecule_defs[def->getIdent()] = def; } } }} votca-csg-1.2.4/src/libcsg/openbox.cc0000644000175000001440000000155312400714674017352 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace csg { vec OpenBox::BCShortestConnection(const vec &r_i, const vec &r_j) const { vec r_ij; r_ij = r_j - r_i; //cout << abs(r_ij) << endl; return r_ij; } }} votca-csg-1.2.4/src/libcsg/libvotca_csg.pc.in0000644000175000001440000000056512400714673020762 0ustar christophusersprefix=@CMAKE_INSTALL_PREFIX@ libdir=${prefix}/@LIB@ includedir=${prefix}/include Name: libvotca_csg Description: csg functions of the votca package URL: http://www.votca.org Version: @VERSION@ Requires: libvotca_tools @GROMACS_PKG@ @BOOST_PKG@ Libs: -L${libdir} -lvotca_csg @BOOST_LIBS_PKG@ @THREAD_LIBRARIES@ Libs.private: -lm Cflags: -I${includedir} @BOOST_CFLAGS_PKG@ votca-csg-1.2.4/src/libcsg/modules/0000755000175000001440000000000012400714673017034 5ustar christophusersvotca-csg-1.2.4/src/libcsg/modules/io/0000755000175000001440000000000012400714673017443 5ustar christophusersvotca-csg-1.2.4/src/libcsg/modules/io/gmxtrajectoryreader.h0000644000175000001440000000512312400714673023702 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _gmxtrajectoryreader_H #define _gmxtrajectoryreader_H #ifndef HAVE_NO_CONFIG #include #endif #include #include #include "gmx_version_check.h" #if GMX == 50 #include #elif GMX == 45 #include #include #include #include #include #include #include #elif GMX == 40 extern "C" { #include #include #include #include #include #include #include } #else #error Unsupported GMX version #endif // this one is needed because of bool is defined in one of the headers included by gmx #undef bool namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief class for reading gromacs trajectory files This class provides the TrajectoryReader interface and encapsulates the trajectory reading function of gromacs */ class GMXTrajectoryReader : public TrajectoryReader { public: GMXTrajectoryReader() { gmx::CheckVersion(); } /// open a trejectory file bool Open(const string &file); /// read in the first frame bool FirstFrame(Topology &top); /// read in the next frame bool NextFrame(Topology &top); void Close(); private: string _filename; // gmx status used in read_first_frame and _read_next_frame; #if GMX == 50 t_trxstatus* _gmx_status; #elif GMX == 45 t_trxstatus* _gmx_status; #elif GMX == 40 int _gmx_status; #else #error Unsupported GMX version #endif /// gmx frame t_trxframe _gmx_frame; }; }} #endif /* _gmxtrajectoryreader_H */ votca-csg-1.2.4/src/libcsg/modules/io/lammpsreader.cc0000644000175000001440000001144112400714673022427 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "lammpsreader.h" namespace votca { namespace csg { using namespace boost; using namespace std; bool LAMMPSReader::ReadTopology(string file, Topology &top) { _topology = true; top.Cleanup(); _fl.open(file.c_str()); if(!_fl.is_open()) throw std::ios_base::failure("Error on open topologyl file: " + file); NextFrame(top); _fl.close(); return true; } bool LAMMPSReader::Open(const string &file) { _fl.open(file.c_str()); if(!_fl.is_open()) throw std::ios_base::failure("Error on open topologyl file: " + file); return true; } void LAMMPSReader::Close() { _fl.close(); } bool LAMMPSReader::FirstFrame(Topology &top) { _topology = false; NextFrame(top); return true; } bool LAMMPSReader::NextFrame(Topology &top) { string line; getline(_fl, line); while(!_fl.eof()) { if(line.substr(0, 5) != "ITEM:") throw std::ios_base::failure("unexpected line in lammps file:\n"+line); if(line.substr(6) == "TIMESTEP") { ReadTimestep(top, line); } else if(line.substr(6) == "NUMBER OF ATOMS") { ReadNumAtoms(top, line); } else if(line.substr(6) == "BOX BOUNDS") { ReadBox(top, line); } else if(line.substr(6, 5) == "ATOMS") { ReadAtoms(top, line); break; } else { throw std::ios_base::failure("unknown item lammps file : " + line.substr(6)); } getline(_fl, line); } return !_fl.eof();; } void LAMMPSReader::ReadTimestep(Topology &top, string itemline) { string s; getline(_fl, s); top.setStep(boost::lexical_cast(s)); cout << "Reading frame, timestep " << top.getStep() << endl; } void LAMMPSReader::ReadBox(Topology &top, string itemline) { string s; matrix m; m.ZeroMatrix(); for(int i=0; i<3; ++i) { getline(_fl, s); Tokenizer tok(s, " "); vector v; tok.ConvertToVector(v); if(v.size()!=2) throw std::ios_base::failure("invalid box format"); m[i][i] = v[1] - v[0]; } top.setBox(m ); } void LAMMPSReader::ReadNumAtoms(Topology &top, string itemline) { string s; getline(_fl, s); _natoms = boost::lexical_cast(s); if(!_topology && _natoms !=top.BeadCount()) std::runtime_error("number of beads in topology and trajectory difffer"); } void LAMMPSReader::ReadAtoms(Topology &top, string itemline) { top.CreateResidue("dum"); bool pos=false; bool force=false; vector fields; { Tokenizer tok(itemline.substr(12), " "); tok.ToVector(fields); for(Tokenizer::iterator i=tok.begin(); i!=tok.end(); ++i) { if(*i == "x" || *i == "y" || *i == "z") pos =true; else if(*i == "fx" || *i == "fy" || *i == "fz") force=true; } } for(int i=0; i<_natoms; ++i) { string s; getline(_fl, s); Bead *b; if(_topology) b = top.CreateBead(1, "", top.GetOrCreateBeadType("no"), 0, 0, 0); else b = top.getBead(i); b->HasPos(pos); b->HasF(force); Tokenizer tok(s, " "); Tokenizer::iterator itok= tok.begin(); for(size_t j=0; itok!=tok.end(); ++itok, ++j) { if(j == fields.size()) throw std::runtime_error("error, wrong number of columns in atoms section"); else if(fields[j] == "x") b->Pos().x() = boost::lexical_cast(*itok); else if(fields[j] == "y") b->Pos().y() = boost::lexical_cast(*itok); else if(fields[j] == "z") b->Pos().z() = boost::lexical_cast(*itok); else if(fields[j] == "fx") b->F().x() = boost::lexical_cast(*itok); else if(fields[j] == "fy") b->F().y() = boost::lexical_cast(*itok); else if(fields[j] == "fz") b->F().z() = boost::lexical_cast(*itok); } } } }} votca-csg-1.2.4/src/libcsg/modules/io/grotopologyreader.h0000644000175000001440000000227312400714673023367 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _GROTOPOLOGYREADER_H #define _GROTOPOLOGYREADER_H #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief reader for gromacs topology files This class encapsulates the gromacs reading functions and provides an interface to fill a topolgy class */ class GROTopologyReader : public TopologyReader { public: /// read a topology file bool ReadTopology(string file, Topology &top); private: }; }} #endif /* _GROTOPOLOGYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/pdbwriter.cc0000644000175000001440000000625312400714673021762 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "pdbwriter.h" namespace votca { namespace csg { using namespace std; void PDBWriter::Open(string file, bool bAppend) { _out = fopen(file.c_str(), bAppend ? "at" : "wt"); } void PDBWriter::Close() { fclose(_out); } void PDBWriter::Write(Topology *conf) { Topology *top = conf; fprintf(_out, "MODEL %4d\n", conf->getStep()); for(BeadContainer::iterator iter=conf->Beads().begin(); iter!=conf->Beads().end(); ++iter) { Bead *bi = *iter; vec r = bi->getPos(); //truncate strings if necessary string resname=""; if(top->getResidue(bi->getResnr())) resname = top->getResidue(bi->getResnr())->getName(); string atomname = bi->getName(); if (resname.size() > 3) { resname = resname.substr(0,3); } if (atomname.size() > 4) { atomname = atomname.substr(0,4); } fprintf(_out, "ATOM %5d %4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f\n", (bi->getId()+1)%100000, // atom serial number atomname.c_str(), // atom name resname.c_str(), // residue name " ", // chain identifier 1 char bi->getResnr()+1, // residue sequence number 10.*r.x(), 10.*r.y(), 10.*r.z(), bi->getQ(), bi->getM()); // is this correct?? if(bi->getSymmetry()>=2) { vec ru = 0.1*bi->getU() + r; fprintf(_out, "HETATM%5d %4s %3s %1s%4d %8.3f%8.3f%8.4f%6.2f%6.2f\n", bi->getId()+1, // atom serial number bi->getName().c_str(), // atom name "REU", // residue name " ", // chain identifier 1 char bi->getResnr()+1, // residue sequence number 10.*ru.x(), 10.*ru.y(), 10.*ru.z(), 0., 0.); // is this correct?? } if(bi->getSymmetry()>=3) { vec rv = 0.1*bi->getV() + r; fprintf(_out, "HETATM%5d %4s %3s %1s%4d %8.3f%8.3f%8.4f%6.2f%6.2f\n", bi->getId()+1, // atom serial number bi->getName().c_str(), // atom name "REV", // residue name " ", // chain identifier 1 char bi->getResnr()+1, // residue sequence number 10.*rv.x(), 10.*rv.y(), 10.*rv.z(), 0.,0.); // is this correct?? /**/ } } fprintf(_out, "ENDMDL\n"); fflush(_out); } }}votca-csg-1.2.4/src/libcsg/modules/io/gmx_version.h0000644000175000001440000000146012400714673022155 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _gmx_version_H #define _gmx_version_H #include namespace votca { namespace csg { const std::string & GmxVersionStr(); }} #endif /* _gmx_version_H */ votca-csg-1.2.4/src/libcsg/modules/io/growriter.cc0000644000175000001440000000540212400714673021777 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "growriter.h" namespace votca { namespace csg { using namespace std; void GROWriter::Open(string file, bool bAppend) { _out = fopen(file.c_str(), bAppend ? "at" : "wt"); } void GROWriter::Close() { fclose(_out); } void GROWriter::Write(Topology *conf) { char format[100]; int i,resnr,l,vpr; Topology *top = conf; fprintf (_out,"%s\n","what a nice title"); fprintf (_out,"%5d\n",top->BeadCount()); bool v = false; // we don't write velocities! int pr = 3; // precision of writeout /* build format string for printing, something like "%8.3f" for x and "%8.4f" for v */ /*if (pr<0) pr=0; if (pr>30) pr=30;*/ l=pr+5; vpr=pr+1; if (v) sprintf(format,"%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", l,pr,l,pr,l,pr,l,vpr,l,vpr,l,vpr); else sprintf(format,"%%%d.%df%%%d.%df%%%d.%df\n",l,pr,l,pr,l,pr); for (i=0; i< top->BeadCount(); i++) { resnr=top->getBead(i)->getResnr(); string resname = top->getResidue(resnr)->getName(); string atomname = top->getBead(i)->getName(); fprintf(_out,"%5d%-5.5s%5.5s%5d", (resnr+1)%100000,resname.c_str(),atomname.c_str(),(i+1)%100000); /* next fprintf uses built format string */ vec r = conf->getBead(i)->getPos(); vec vv = vec(0,0,0); if (v) fprintf(_out,format, r.getX(), r.getY(), r.getZ(), vv.getX(), vv.getY(), vv.getZ()); else fprintf(_out,format, r.getX(), r.getY(), r.getZ()); } // write the boy matrix box = conf->getBox(); if (pr<5) pr=5; l=pr+5; if (box[0][1] || box[0][2] || box[1][0] || box[1][2] || box[2][0] || box[2][1]) { sprintf(format,"%%%d.%df%%%d.%df%%%d.%df" "%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr); fprintf(_out,format, box[0][0],box[1][1],box[2][2], box[0][1],box[0][2],box[1][0], box[1][2],box[2][0],box[2][1]); } else { sprintf(format,"%%%d.%df%%%d.%df%%%d.%df\n",l,pr,l,pr,l,pr); fprintf(_out,format, box[0][0],box[1][1],box[2][2]); } fflush(_out); } }} votca-csg-1.2.4/src/libcsg/modules/io/xyzwriter.h0000644000175000001440000000222212400714673021701 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_CSG_XYZWRITER_H #define __VOTCA_CSG_XYZWRITER_H #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; class XYZWriter : public TrajectoryWriter { public: void Open(string file, bool bAppend = false); void Close(); void RegisteredAt(ObjectFactory &factory) {} void Write(Topology *conf); private: FILE *_out; }; }} #endif votca-csg-1.2.4/src/libcsg/modules/io/mdptopologyreader.cc0000644000175000001440000000646312400714673023523 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include "mdptopologyreader.h" #include #include bool MDPTopologyReader::ReadTopology(string file, Topology &top) { FILE *fl; long I4; float R4; double R8; fl = fopen(file.substr(0, file.length()-4).c_str(), "rb"); if(!fl) return false; /* * The header line looks as follows (in fortran binary out, so with record blocks): * * I4 0/1 has velocities? * R8 dt * 3*R8 box size (Angstr) * R8 unit in m (10^-10 for Angstr) * I4 number if mol types * for each molecule: * I4 nspec (number of molecules of this type) * I4 nsites (number of atoms in molecule) * L4 true ?? * * */ // read record begin fread(&I4, sizeof(I4), 1, fl); // read ivel fread(&I4, sizeof(I4), 1, fl); cout << "I have " << (I4 ? "" : "no ") << "velocities\n"; double dt, unit; vec box; long moltypes; fread(&dt, sizeof(dt), 1, fl); fread(&box, sizeof(box), 1, fl); fread(&unit, sizeof(unit), 1, fl); fread(&moltypes, sizeof(moltypes), 1, fl); cout << dt << " " << box << " " << unit << " " << moltypes << endl; vector nmols; vector natoms; for(int i=0; i masses; for(int atom=0; atom(type+1)); for(int atom=0; atomAddBead(top.CreateBead(1, "", top.GetOrCreateBeadType("no"), 0, R8, 0)->getId(), boost::lexical_cast(atom+1)); } } } // read record begin fread(&I4, sizeof(I4), 1, fl); fclose(fl); return true; } votca-csg-1.2.4/src/libcsg/modules/io/gmx_version_check.h0000644000175000001440000000145412400714673023315 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_VERSIONCHECK_H #define __VOTCA_VERSIONCHECK_H namespace votca { namespace csg { namespace gmx { void CheckVersion(); }}} #endif /* VERSIONCHECK_H */ votca-csg-1.2.4/src/libcsg/modules/io/pdbtopologyreader.h0000644000175000001440000000246412400714673023347 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _PDBTOPOLOGYREADER_H #define _PDBTOPOLOGYREADER_H #include #include #include #include "gmx_version_check.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief reader for gromacs topology files This class encapsulates the gromacs reading functions and provides an interface to fill a topolgy class */ class PDBTopologyReader : public TopologyReader { public: PDBTopologyReader() { gmx::CheckVersion(); } /// read a topology file bool ReadTopology(string file, Topology &top); private: }; }} #endif /* _PDBTOPOLOGYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/esptrajectoryreader.h0000644000175000001440000000250612400714673023700 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _ESPTRAJECTORYREADER_H #define _ESPTRAJECTORYREADER_H #include namespace votca { namespace csg { using namespace std; class ESPTrajectoryReader : public TrajectoryReader { public: /// open a trajectory file bool Open(const string &file); /// read in the first frame bool FirstFrame(Topology &top); /// read in the next frame bool NextFrame(Topology &top); void Close(); TrajectoryReader *Clone() { return dynamic_cast(new ESPTrajectoryReader()); } private: string _fl; string _temp_nextframe; }; }} #endif /* _ESPTRAJECTORYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/gmxtrajectoryreader.cc0000644000175000001440000001077212400714673024046 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include "gmxtrajectoryreader.h" namespace votca { namespace csg { using namespace std; bool GMXTrajectoryReader::Open(const string &file) { _filename = file; return true; } void GMXTrajectoryReader::Close() { close_trx(_gmx_status); } bool GMXTrajectoryReader::FirstFrame(Topology &conf) { #if GMX == 50 output_env_t oenv; // _snew("oenv", oenv, 1); //oenv = (output_env_t)malloc(sizeof(*oenv)); output_env_init_default (&oenv); if(!read_first_frame(oenv, &_gmx_status,(char*)_filename.c_str(),&_gmx_frame,TRX_READ_X | TRX_READ_V | TRX_READ_F)) throw std::runtime_error(string("cannot open ") + _filename); //sfree(oenv); free(oenv); #elif GMX == 45 set_program_name("VOTCA"); output_env_t oenv; // _snew("oenv", oenv, 1); oenv = (output_env_t)malloc(sizeof(*oenv)); output_env_init_default (oenv); if(!read_first_frame(oenv, &_gmx_status,(char*)_filename.c_str(),&_gmx_frame,TRX_READ_X | TRX_READ_V | TRX_READ_F)) throw std::runtime_error(string("cannot open ") + _filename); //sfree(oenv); free(oenv); #elif GMX == 40 set_program_name("VOTCA"); if(!read_first_frame(&_gmx_status,(char*)_filename.c_str(),&_gmx_frame,TRX_READ_X | TRX_READ_V | TRX_READ_F)) throw std::runtime_error(string("cannot open ") + _filename); #else #error Unsupported GMX version #endif matrix m; for(int i=0; i<3; i++) for(int j=0; j<3; j++) m[i][j] = _gmx_frame.box[j][i]; conf.setBox(m); conf.setTime(_gmx_frame.time); conf.setStep(_gmx_frame.step); cout << endl; if(_gmx_frame.natoms != (int)conf.Beads().size()) throw std::runtime_error("number of beads in trajectory do not match topology"); //conf.HasPos(true); //conf.HasF(_gmx_frame.bF); for(int i=0; i<_gmx_frame.natoms; i++) { double r[3] = { _gmx_frame.x[i][XX], _gmx_frame.x[i][YY], _gmx_frame.x[i][ZZ] }; conf.getBead(i)->setPos(r); if(_gmx_frame.bF) { double f[3] = { _gmx_frame.f[i][XX], _gmx_frame.f[i][YY], _gmx_frame.f[i][ZZ] }; conf.getBead(i)->setF(f); } if(_gmx_frame.bV) { double v[3] = { _gmx_frame.v[i][XX], _gmx_frame.v[i][YY], _gmx_frame.v[i][ZZ] }; conf.getBead(i)->setVel(v); } } return true; } bool GMXTrajectoryReader::NextFrame(Topology &conf) { #if GMX == 50 output_env_t oenv; //_snew("oenv", oenv, 1); //oenv = (output_env_t)malloc(sizeof(*oenv)); output_env_init_default (&oenv); if(!read_next_frame(oenv, _gmx_status,&_gmx_frame)) return false; //sfree(oenv); free(oenv); #elif GMX == 45 output_env_t oenv; //_snew("oenv", oenv, 1); oenv = (output_env_t)malloc(sizeof(*oenv)); output_env_init_default (oenv); if(!read_next_frame(oenv, _gmx_status,&_gmx_frame)) return false; //sfree(oenv); free(oenv); #elif GMX == 40 if(!read_next_frame(_gmx_status,&_gmx_frame)) return false; #else #error Unsupported GMX version #endif matrix m; for(int i=0; i<3; i++) for(int j=0; j<3; j++) m[i][j] = _gmx_frame.box[j][i]; conf.setTime(_gmx_frame.time); conf.setStep(_gmx_frame.step); conf.setBox(m); //conf.HasF(_gmx_frame.bF); for(int i=0; i<_gmx_frame.natoms; i++) { double r[3] = { _gmx_frame.x[i][XX], _gmx_frame.x[i][YY], _gmx_frame.x[i][ZZ] }; conf.getBead(i)->setPos(r); if(_gmx_frame.bF) { double f[3] = { _gmx_frame.f[i][XX], _gmx_frame.f[i][YY], _gmx_frame.f[i][ZZ] }; conf.getBead(i)->setF(f); } if(_gmx_frame.bV) { double v[3] = { _gmx_frame.v[i][XX], _gmx_frame.v[i][YY], _gmx_frame.v[i][ZZ] }; conf.getBead(i)->setVel(v); } } return true; } }} votca-csg-1.2.4/src/libcsg/modules/io/pdbtopologyreader.cc0000644000175000001440000000522612400714673023504 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #include #include "pdbtopologyreader.h" #if GMX == 50 #include #include #include #elif GMX == 45 #include #include #include #include #include #include #include #include #elif GMX == 40 extern "C" { #include #include #include #include #include #include #include #include } #else #error Unsupported GMX version #endif // this one is needed because of bool is defined in one of the headers included by gmx #undef bool #define snew2(ptr,nelem) (ptr)=(rvec*)save_calloc(#ptr,__FILE__,__LINE__,\ (nelem),sizeof(*(ptr))) namespace votca { namespace csg { bool PDBTopologyReader::ReadTopology(string file, Topology &top) { char title[512]; rvec *x, *v; ::matrix box; int ePBC; t_atoms atoms; #if GMX != 50 set_program_name("VOTCA"); #endif //snew(atoms,1); get_stx_coordnum((char*)file.c_str(),&(atoms.nr)); init_t_atoms(&atoms,atoms.nr,TRUE); snew2(x,atoms.nr); snew2(v,atoms.nr); fprintf(stderr,"\nReading structure file\n"); read_stx_conf((char*)file.c_str(), title,&atoms, x,NULL,&ePBC,box); Residue *res = top.CreateResidue("no"); // read the atoms for(int i=0; i < atoms.nr; i++) { t_atom *a; a = &(atoms.atom[i]); BeadType *type = top.GetOrCreateBeadType("no"); top.CreateBead(1, *(atoms.atomname[i]), type, res->getId(), a->m, a->q); //cout << *(gtp.atoms.atomname[i]) << " residue: " << a->resnr << endl; } return true; } }} votca-csg-1.2.4/src/libcsg/modules/io/gmxtopologyreader.cc0000644000175000001440000001163312400714673023531 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #include #include "gmxtopologyreader.h" #if GMX == 50 #include #elif GMX == 45 #include #include #include #include #include #include #include #elif GMX == 40 extern "C" { #include #include #include #include #include #include #include } #else #error Unsupported GMX version #endif // this one is needed because of bool is defined in one of the headers included by gmx #undef bool namespace votca { namespace csg { bool GMXTopologyReader::ReadTopology(string file, Topology &top) { gmx_mtop_t mtop; int natoms; // cleanup topology to store new data top.Cleanup(); #if GMX == 50 t_inputrec ir; ::matrix gbox; (void)read_tpx((char *)file.c_str(),&ir,gbox,&natoms,NULL,NULL,NULL,&mtop); #elif GMX == 45 set_program_name("VOTCA"); t_inputrec ir; ::matrix gbox; (void)read_tpx((char *)file.c_str(),&ir,gbox,&natoms,NULL,NULL,NULL,&mtop); #elif GMX == 40 set_program_name("VOTCA"); int sss; // wtf is this ::real ttt,lll; // wtf is this (void)read_tpx((char *)file.c_str(),&sss,&ttt,&lll,NULL,NULL,&natoms,NULL,NULL,NULL,&mtop); #else #error Unsupported GMX version #endif int count=0; for(int iblock=0; iblockname); int res_offset = top.ResidueCount(); t_atoms *atoms=&(mol->atoms); for(int i=0; i < atoms->nres; i++) { #if GMX == 50 top.CreateResidue(*(atoms->resinfo[i].name)); #elif GMX == 45 top.CreateResidue(*(atoms->resinfo[i].name)); #elif GMX == 40 top.CreateResidue(*(atoms->resname[i])); #else #error Unsupported GMX version #endif } int ifirstatom = 0; for(int imol=0; imolatom[iatom]); // read exclusions t_blocka * excl = &(mol->excls); // insert exclusions list excl_list; for(int k=excl->index[iatom]; kindex[iatom+1]; k++) { excl_list.push_back(excl->a[k]+ifirstatom); } top.InsertExclusion(iatom+ifirstatom, excl_list); BeadType *type = top.GetOrCreateBeadType(*(atoms->atomtype[iatom])); #if GMX == 50 Bead *bead = top.CreateBead(1, *(atoms->atomname[iatom]), type, a->resind, a->m, a->q); #elif GMX == 45 Bead *bead = top.CreateBead(1, *(atoms->atomname[iatom]), type, a->resind, a->m, a->q); #elif GMX == 40 Bead *bead = top.CreateBead(1, *(atoms->atomname[iatom]), type, a->resnr, a->m, a->q); #else #error Unsupported GMX version #endif stringstream nm; nm << bead->getResnr() + 1 << ":" << top.getResidue(res_offset + bead->getResnr())->getName() << ":" << bead->getName(); mi->AddBead(bead, nm.str()); } ifirstatom+=mtop.molblock[iblock].natoms_mol; } } #if GMX != 40 matrix m; for(int i=0; i<3; i++) for(int j=0; j<3; j++) m[i][j] = gbox[j][i]; top.setBox(m); #endif return true; } }} votca-csg-1.2.4/src/libcsg/modules/io/gmxtopologyreader.h0000644000175000001440000000243012400714673023366 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _gmxtopologyreader_H #define _gmxtopologyreader_H #include #include #include "gmx_version_check.h" namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief reader for gromacs topology files This class encapsulates the gromacs reading functions and provides an interface to fill a topolgy class */ class GMXTopologyReader : public TopologyReader { public: GMXTopologyReader() { gmx::CheckVersion(); } /// read a topology file bool ReadTopology(string file, Topology &top); private: }; }} #endif /* _gmxtopologyreader_H */ votca-csg-1.2.4/src/libcsg/modules/io/gmxtrajectorywriter.cc0000644000175000001440000000400112400714673024104 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include "gmxtrajectorywriter.h" namespace votca { namespace csg { void GMXTrajectoryWriter::Open(string file, bool bAppend) { #if GMX != 50 set_program_name("VOTCA"); #endif //char c[1] = bAppend ? "a" : "w"; _file = open_trx((char *)file.c_str(), "w"); } void GMXTrajectoryWriter::Close() { close_trx(_file); } void GMXTrajectoryWriter::Write(Topology *conf) { static int step=0; int N = conf->BeadCount(); t_trxframe frame; rvec *x = new rvec[N]; matrix box = conf->getBox(); frame.natoms = N; frame.bTime = true; frame.time = conf->getTime(); frame.bStep = true; frame.step = conf->getStep();; frame.x = x; frame.bTitle=false; frame.bLambda=false; frame.bAtoms=false; frame.bPrec=false; frame.bX = true; frame.bV=false; frame.bF=false; frame.bBox=true; for(int i=0; i<3; i++) for(int j=0; j<3; j++) frame.box[i][j] = box[i][j]; for(int i=0; igetBead(i)->getPos(); x[i][0] = v.getX(); x[i][1] = v.getY(); x[i][2] = v.getZ(); } #if GMX == 50 write_trxframe(_file, &frame, NULL); #elif GMX == 45 write_trxframe(_file, &frame, NULL); #elif GMX == 40 write_trxframe(_file, &frame); #else #error Unsupported GMX version #endif step++; delete[] x; } }} votca-csg-1.2.4/src/libcsg/modules/io/esptopologyreader.h0000644000175000001440000000240412400714673023363 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _ESPTOPOLOGYREADER_H #define _ESPTOPOLOGYREADER_H #include #include namespace votca { namespace csg { using namespace std; /** \brief reader for espresso blockfiles This class encapsulates the espresso reading functions and provides an interface to fill a topolgy class */ class ESPTopologyReader : public TopologyReader { public: /// read a topology file bool ReadTopology(string file, Topology &top); private: /// extract variable from input line string ReadBlockfileLine(string input_line, string variable); }; }} #endif /* _ESPTOPOLOGYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/esptopologyreader.cc0000644000175000001440000001470512400714673023530 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include "esptopologyreader.h" namespace votca { namespace csg { bool ESPTopologyReader::ReadTopology(string file, Topology &top) { // cleanup topology to store new data ifstream fl; string parse_line, type, mass, tmp, virt; unsigned int white_space1, white_space2; int num_molecules; unsigned int check_name, check_name2; int *num_atoms = NULL; double box_x,box_y,box_z; bool HasMass, HasVirtual; top.Cleanup(); fl.open(file.c_str()); if(!fl.is_open()) return false; // 'box_l' variable for box geometry //////////////////////////////////// getline(fl, parse_line); parse_line = ReadBlockfileLine(parse_line, "box_l"); white_space1 = parse_line.find(' '); if (white_space1 != string::npos) { white_space2 = parse_line.find(' ',white_space1+1); if (white_space2 != string::npos) { box_x = atof(parse_line.substr(0,white_space1).c_str()); box_y = atof(parse_line.substr(white_space1+1,white_space2).c_str()); box_z = atof(parse_line.substr(white_space2).c_str()); } else { cerr << "Error in parsing blockfile (box_l).\n"; return false; } } else { cerr << "Error in parsing blockfile (box_l).\n"; return false; } top.setBox(matrix(vec(box_x, 0, 0), vec(0, box_y, 0), vec(0, 0, box_z))); //cout << "Box geometry: " << box_x << " " << box_y << " " << box_z << endl; // 'num_molecules' tclvariable for total number of molecules //////////////////////////////////////////////////////////// getline(fl, parse_line); parse_line = ReadBlockfileLine(parse_line, "num_molecules"); num_molecules = atof(parse_line.c_str()); //cout << "Number of molecules: " << num_molecules << endl; // 'num_atoms' tclvariable for list of number of atoms (for each molecule) ////////////////////////////////////////////////////////////////////////// num_atoms = (int*) calloc(num_molecules,sizeof(int)); getline(fl, parse_line); parse_line = ReadBlockfileLine(parse_line, "num_atoms"); for (int i=0; i(mol)); for (int atom=0; atom> tmp; fl >> type; fl >> tmp; if (HasMass) fl >> mass; else mass = string("1.0"); mi->AddBead(top.CreateBead(1, "", top.GetOrCreateBeadType(type), 0, atoi(mass.c_str()), 0), boost::lexical_cast(atom)); getline(fl, parse_line); } } // Check that we've reached the end of the 'particles' variable getline(fl, parse_line); if (parse_line != "}") { cerr << "'num_molecules' and 'num_atoms' do not correspond to " "number of particles. Check .esp file.\n"; return false; } free(num_atoms); fl.close(); cout << "WARNING: topology created from .esp file, charges aren't loaded!\n"; return true; } string ESPTopologyReader::ReadBlockfileLine(string input_line, string variable) { unsigned int pos_openvar, pos_closevar; string str_find = "{" + variable; pos_openvar = input_line.find(str_find); if (pos_openvar == string::npos) { throw runtime_error("Can't find '" + variable + "' variable in blockfile.\n"); } input_line = input_line.substr(pos_openvar+variable.length()+2); pos_closevar = input_line.find('}'); if (pos_closevar == string::npos) { throw runtime_error("Can't find '}' character in closing '" + variable + "' variable of the blockfile.\n"); } input_line = input_line.substr(0,pos_closevar); return input_line; } }} votca-csg-1.2.4/src/libcsg/modules/io/xyzwriter.cc0000644000175000001440000000323012400714673022037 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "xyzwriter.h" namespace votca { namespace csg { using namespace std; void XYZWriter::Open(string file, bool bAppend) { _out = fopen(file.c_str(), bAppend ? "at" : "wt"); } void XYZWriter::Close() { fclose(_out); } void XYZWriter::Write(Topology *conf) { Topology *top = conf; fprintf(_out, "%lu\n", top->Beads().size()); fprintf(_out, "frame: %d time: %f\n", top->getStep()+1, top->getTime()); for(BeadContainer::iterator iter=conf->Beads().begin(); iter!=conf->Beads().end(); ++iter) { Bead *bi = *iter; vec r = bi->getPos(); //truncate strings if necessary string atomname = bi->getName(); if (atomname.size() > 3) { atomname = atomname.substr(0,3); } while(atomname.size()<3) atomname=" " + atomname; fprintf(_out, "%s%10.5f%10.5f%10.5f\n", atomname.c_str(), 10.*r.getX(), 10.*r.getY(), 10.*r.getZ() ); } fflush(_out); } }} votca-csg-1.2.4/src/libcsg/modules/io/lammpsreader.h0000644000175000001440000000357512400714673022302 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _lammpsreader_H #define _lammpsreader_H #include #include #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** \brief class for reading lammps dump files This class provides the TrajectoryReader + Topology reader interface for lammps dump files */ class LAMMPSReader : public TrajectoryReader, public TopologyReader { public: LAMMPSReader() {} ~LAMMPSReader() {} /// open a topology file bool ReadTopology(string file, Topology &top); /// open a trejectory file bool Open(const string &file); /// read in the first frame bool FirstFrame(Topology &top); /// read in the next frame bool NextFrame(Topology &top); void Close(); private: void ReadTimestep(Topology &top, string itemline); void ReadBox(Topology &top, string itemline); void ReadNumAtoms(Topology &top, string itemline); void ReadAtoms(Topology &top, string itemline); ifstream _fl; bool _topology; int _natoms; }; }} #endif /* _gmxtrajectoryreader_H */ votca-csg-1.2.4/src/libcsg/modules/io/xmltopologyreader.h0000644000175000001440000000304212400714673023373 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _XMLTOPOLOGYREADER_H #define _XMLTOPOLOGYREADER_H #include #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; /** * Reads in an xml topology * * \todo this is a sloppy implementation using expat, is just reads attributes * \todo should be extended to also read beads, ... * */ class XMLTopologyReader : public TopologyReader { public: /// read a topology file bool ReadTopology(string file, Topology &top); private: void ReadTopolFile(string file); void ParseRoot(const string &el, map &attr); void ParseTopology(const string &el, map &attr); void ParseMolecules(const string &el, map &attr); private: ParseXML _parser; Topology *_top; }; }} #endif /* _PDBTOPOLOGYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/grotopologyreader.cc0000644000175000001440000000346312400714673023527 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include "grotopologyreader.h" namespace votca { namespace csg { bool GROTopologyReader::ReadTopology(string file, Topology &top) { // cleanup topology to store new data ifstream fl; string tmp; top.Cleanup(); fl.open(file.c_str()); if(!fl.is_open()) return false; string title; getline(fl, title); getline(fl, tmp); int natoms = atoi(tmp.c_str()); for(;natoms>0; natoms--) { char c[6]; fl.read(c, 5); c[5] = 0; string resname; fl >> resname; int resnr = atoi(c); if(resnr > top.ResidueCount()) { top.CreateResidue(resname); // cout << " created residue " << resnr << resname<<"-\n"; } string atomname; string x, y, z; fl >> atomname; fl >> tmp; fl >> x; fl >> y; fl >> z; top.CreateBead(1, atomname, top.GetOrCreateBeadType("no"), resnr, 1., 0.); getline(fl, tmp); } fl.close(); cout << "WARNING: topology created from .gro file, masses and charges are wrong!\n"; return true; } }} votca-csg-1.2.4/src/libcsg/modules/io/xmltopologyreader.cc0000644000175000001440000000552212400714673023536 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include "xmltopologyreader.h" namespace votca { namespace csg { bool XMLTopologyReader::ReadTopology(string filename, Topology &top) { _top = ⊤ _parser.NextHandler(this, &XMLTopologyReader::ParseRoot); _parser.Open(filename); return true; } void XMLTopologyReader::ReadTopolFile(string file) { TopologyReader *reader; reader = TopReaderFactory().Create(file); if(!reader) throw runtime_error(file + ": unknown topology format"); reader->ReadTopology(file, *_top); delete reader; } void XMLTopologyReader::ParseRoot(const string &el, map &attr) { if(el == "topology") { if(attr["base"] != "") ReadTopolFile(attr["base"]); _parser.NextHandler(this, &XMLTopologyReader::ParseTopology); } else { throw std::runtime_error("wrong root node in xml topology file"); } } void XMLTopologyReader::ParseTopology(const string &el, map &attr) { if(el == "molecules") _parser.NextHandler(this, &XMLTopologyReader::ParseMolecules); } void XMLTopologyReader::ParseMolecules(const string &el, map &attr) { map::iterator iter; if (el == "clear") { _top->ClearMoleculeList(); _parser.IgnoreChilds(); } else if (el == "rename") { string molname = attr["name"]; string range = attr["range"]; if (molname == "" || range == "") throw runtime_error("invalid rename tag"); _top->RenameMolecules(range, molname); _parser.IgnoreChilds(); } if (el == "define") { string molname = attr["name"]; string first = attr["first"]; string nbeads = attr["nbeads"]; string nmols = attr["nmols"]; if (molname == "" && first == "" && nbeads == "" && nmols == "") throw runtime_error("invalid define tag"); _top->CreateMoleculesByRange(molname, boost::lexical_cast(first), boost::lexical_cast(nbeads), boost::lexical_cast(nmols)); _parser.IgnoreChilds(); } } }} votca-csg-1.2.4/src/libcsg/modules/io/pdbwriter.h0000644000175000001440000000222012400714673021612 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _PDBWRITER_H #define _PDBWRITER_H #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; class PDBWriter : public TrajectoryWriter { public: void Open(string file, bool bAppend = false); void Close(); void RegisteredAt(ObjectFactory &factory) {} void Write(Topology *conf); private: FILE *_out; }; }} #endif /* _PDBWRITER_H */ votca-csg-1.2.4/src/libcsg/modules/io/mdptrajectoryreader.h0000644000175000001440000000251712400714673023673 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _MDPTRAJECTORYREADER_H #define _MDPTRAJECTORYREADER_H #include #include "trajectoryreader.h" class MDPTrajectoryReader : public TrajectoryReader { public: /// open a trejectory file bool Open(const string &file); /// read in the first frame bool FirstFrame(Configuration &conf); /// read in the next frame bool NextFrame(Configuration &conf); void Close(); TrajectoryReader *Clone() { return dynamic_cast(new MDPTrajectoryReader()); } private: FILE *_fl; int _moltypes; vector _nmols; vector _natoms; }; #endif /* _MDPTRAJECTORYREADER_H */ votca-csg-1.2.4/src/libcsg/modules/io/gmx_version_nb.cc0000644000175000001440000000153012400714673022770 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include //only used by NetBeans namespace votca { namespace csg { static const std::string gmx_version_str = "VERSION NOT SET"; const std::string &GmxVersionStr() { return gmx_version_str; } }} votca-csg-1.2.4/src/libcsg/modules/io/gmx_version_check.cc0000644000175000001440000000365312400714673023456 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef HAVE_NO_CONFIG #include #endif #if GMX == 50 #include #elif GMX == 45 #include #elif GMX == 40 extern "C" { #include } #endif #ifdef GMX // this one is needed because of bool is defined in one of the headers included by gmx #undef bool #endif #include "gmx_version_check.h" #include "gmx_version.h" #include namespace votca { namespace csg { namespace gmx { using namespace votca::csg; void CheckVersion() { std::string GromacsVersionString = #ifdef GMX GromacsVersion() #ifdef GMX_DOUBLE + std::string(" (double precision)"); #else + std::string(" (single precision)"); #endif #endif if(GmxVersionStr()==std::string("VERSION NOT SET")) { std::cout << "WARNING: GROMACS version string not set." << std::endl; } else if(GmxVersionStr() != GromacsVersionString) { std::cout << "WARNING: VOTCA was compiled using a different Gromacs library version\n" << "compiled: " << GmxVersionStr() << "\nloaded:" << GromacsVersionString << "\nTry to source another GMXRC or be prepared for unexpectred behaviour." << std::endl; } } }}} votca-csg-1.2.4/src/libcsg/modules/io/gmx_print_version.cc0000644000175000001440000000240712400714673023531 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #if GMX == 50 #include #elif GMX == 45 #include #elif GMX == 40 extern "C" { #include } #endif #ifdef GMX // this one is needed because of bool is defined in one of the headers included by gmx #undef bool #endif using namespace std; int main(int argc, char** argv) { cout << "static const std::string gmx_version = \"" #ifdef GMX << GromacsVersion() #ifdef GMX_DOUBLE << " (double precision)" #else << " (single precision)" #endif #else << "UNDEFINED" #endif << "\";\n"; return 0; } votca-csg-1.2.4/src/libcsg/modules/io/growriter.h0000644000175000001440000000211112400714673021633 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _GROWRITER_H #define _GROWRITER_H #include #include #include namespace votca { namespace csg { using namespace votca::tools; using namespace std; class GROWriter : public TrajectoryWriter { public: void Open(string file, bool bAppend = false); void Close(); void Write(Topology *conf); private: FILE *_out; }; }} #endif /* _GROWRITER_H */ votca-csg-1.2.4/src/libcsg/modules/io/gmx_version.cc0000644000175000001440000000151612400714673022315 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace csg { //defines gmx_version #include "gmx_libs_version.h" const std::string &GmxVersionStr() { return gmx_version; } }} votca-csg-1.2.4/src/libcsg/modules/io/esptrajectoryreader.cc0000644000175000001440000001456012400714673024041 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "esptrajectoryreader.h" namespace votca { namespace csg { bool ESPTrajectoryReader::Open(const string &file) { _fl = file; _temp_nextframe = string("tmp_nf_" + file); return true; } void ESPTrajectoryReader::Close() { // Nothing to do - but define function since class herits from // virtual class TrajectoryReader. } bool ESPTrajectoryReader::FirstFrame(Topology &top) { ifstream file; ofstream out; string parse_line, tmp; int atom; unsigned int check_name, check_name2; double r[3], v[3]; bool HasMass, HasVirtual; file.open(_fl.c_str()); if(!file.is_open()) return false; // Skip first 3 lines: variables 'box_l', 'num_molecules', // and 'num_atoms' read by ESPTopologyReader. getline(file, parse_line); getline(file, parse_line); getline(file, parse_line); // Check that the next line contains 'particles' getline(file, parse_line); check_name = parse_line.find("{particles"); if (check_name == string::npos) { cerr << "Can't find particles variable in blockfile.\n"; return false; } check_name = parse_line.find("mass"); check_name2 = parse_line.find("virtual"); if (check_name != string::npos) { HasMass = 1; if (check_name2 != string::npos) { HasVirtual = 1; // make sure the format is correct check_name = parse_line.find("{id type molecule mass virtual pos v}"); check_name2 = parse_line.find("{id type molecule mass virtual folded_position v}"); } else { HasVirtual = 0; // make sure the format is correct check_name = parse_line.find("{id type molecule mass pos v}"); check_name2 = parse_line.find("{id type molecule mass folded_position v}"); } } else { HasMass = 0; if (check_name2 != string::npos) { HasVirtual = 1; // make sure the format is correct check_name = parse_line.find("{id type molecule virtual pos v}"); check_name2 = parse_line.find("{id type molecule virtual folded_position v}"); } else { HasVirtual = 0; // make sure the format is correct check_name = parse_line.find("{id type molecule pos v}"); check_name2 = parse_line.find("{id type molecule folded_position v}"); } } if (check_name == string::npos && check_name2 == string::npos) { cerr << "Check format of particles variable in blockfile.\n" "Should be {id type molecule [mass] pos v}.\n" "Instead: " << parse_line << endl; return false; } for (atom = 0; atom < top.BeadCount(); ++atom) { file >> tmp; file >> tmp; file >> tmp; if (HasMass) file >> tmp; if (HasVirtual) file >> tmp; // read particle position file >> r[0]; file >> r[1]; file >> r[2]; // read particle velocities file >> v[0]; file >> v[1]; file >> v[2]; file >> tmp; // Update particle properties top.getBead(atom)->setPos(r); top.getBead(atom)->setVel(v); getline(file,parse_line); } // Check that we've reached the end of the 'particles' variable getline(file, parse_line); if (parse_line != "}") { cerr << "'num_molecules' and 'num_atoms' do not correspond to " "number of particles. Check .esp file.\n"; return false; } getline(file, parse_line); // Now that we've parsed the data for the first frame, // save the rest of the data into a new file (which will // be read by NextFrame(top). out.open(_temp_nextframe.c_str()); while (!file.eof()) { out << parse_line << endl; getline(file, parse_line); } out.close(); file.close(); return true; } bool ESPTrajectoryReader::NextFrame(Topology &top) { ifstream file; ofstream out; string parse_line, tmp; int atom; unsigned int check_name; bool HasMass; double r[3], v[3]; file.open(_temp_nextframe.c_str()); if(!file.is_open()) return false; if(file.eof()) return false; // Check that the next line contains 'particles' getline(file, parse_line); if (parse_line == "") return false; check_name = parse_line.find("{particles"); if (check_name == string::npos) { cerr << "Can't find particles variable in blockfile.\n"; return false; } if (check_name != string::npos) { HasMass = 1; // make sure the format is correct check_name = parse_line.find("{id type molecule mass pos v}"); } else { HasMass = 0; // make sure the format is correct check_name = parse_line.find("{id type molecule pos v}"); } if (check_name == string::npos) { cerr << "Check format of particles variable in blockfile.\n" "Should be {id type molecule [mass] pos v}.\n" "Instead: " << parse_line << endl; return false; } for (atom = 0; atom < top.BeadCount(); ++atom) { file >> tmp; file >> tmp; file >> tmp; if (HasMass) file >> tmp; // read particle position file >> r[0]; file >> r[1]; file >> r[2]; // read particle velocities file >> v[0]; file >> v[1]; file >> v[2]; file >> tmp; // Update particle properties top.getBead(atom)->setPos(r); top.getBead(atom)->setVel(v); getline(file,parse_line); } // Check that we've reached the end of the 'particles' variable getline(file, parse_line); if (parse_line != "}") { cerr << "'num_molecules' and 'num_atoms' do not correspond to " "number of particles. Check .esp file.\n"; return false; } getline(file, parse_line); // Now that we've parsed the data for the first frame, // save the rest of the data into a new file (which will // be read by NextFrame(top). out.open(_temp_nextframe.c_str()); while (!file.eof()) { out << parse_line << endl; getline(file, parse_line); } out.close(); file.close(); return true; } }} votca-csg-1.2.4/src/libcsg/modules/io/mdptrajectoryreader.cc0000644000175000001440000001360112400714673024025 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include "mdptrajectoryreader.h" #include "configuration.h" bool MDPTrajectoryReader::Open(const string &file) { _fl = fopen(file.c_str(), "rb"); if(!_fl) throw string("cannot open " + file); } void MDPTrajectoryReader::Close() { fclose(_fl); _nmols.clear(); _natoms.clear(); } bool MDPTrajectoryReader::FirstFrame(Configuration &conf) { FILE *fl = _fl; long I4; float R4; double R8; conf.HasPos(true); /* * The header line looks as follows (in fortran binary out, so with record blocks): * * I4 0/1 has velocities? * R8 dt * 3*R8 box size (Angstr) * R8 unit in m (10^-10 for Angstr) * I4 number if mol types * for each molecule: * I4 nspec (number of molecules of this type) * I4 nsites (number of atoms in molecule) * L4 true ?? * * */ // read record begin fread(&I4, sizeof(I4), 1, fl); // read ivel fread(&I4, sizeof(I4), 1, fl); double dt, unit; vec box; fread(&dt, sizeof(dt), 1, fl); fread(&box, sizeof(box), 1, fl); fread(&unit, sizeof(unit), 1, fl); fread(&_moltypes, sizeof(_moltypes), 1, fl); for(int i=0; i<_moltypes; ++i) { fread(&I4, sizeof(I4), 1, fl); _nmols.push_back(I4); fread(&I4, 1, sizeof(I4), fl); _natoms.push_back(I4); fread(&I4, sizeof(I4), 1, fl); } // read record end fread(&I4, sizeof(I4), 1, fl); // now read in the molecule types /* * for each type * for each atom * R8 mass * I4 ? List (0: has coordinates, 1: no coordinates) */ fread(&I4, sizeof(I4), 1, fl); for(int type=0; type<_moltypes; ++type) { for(int atom=0; atom<_natoms[type]; ++atom) { fread(&R8, sizeof(R8), 1, fl); cout << R8 << endl; } // is molecule read in trajectory? fread(&I4, sizeof(I4), 1, fl); cout << I4 << endl; } // read record end fread(&I4, sizeof(I4), 1, fl); return NextFrame(conf); } bool MDPTrajectoryReader::NextFrame(Configuration &conf) { long I4; float R4; double R8; FILE *fl = _fl; if(feof(fl)) return false; /* record * * I4 ivel, 0/1, has velocity? * R8 time * R8 comtime (averages, ..)? * R8 temperature * R8 pressure * R8 Epot * 3*R8 box size * L4 list: included in file? * */ long iVel; long rec; // read in record marker, to skip list, was buggy in fotran code... fread(&rec, sizeof(rec), 1, fl); // begin record fread(&iVel, sizeof(iVel), 1, fl); conf.HasVel(iVel == 1 ? true : false); double t; fread(&t, sizeof(t), 1, fl); conf.setTime(t); fread(&R8, sizeof(R8), 1, fl); // comtime fread(&R8, sizeof(R8), 1, fl); // temperature fread(&R8, sizeof(R8), 1, fl); // pressure fread(&R8, sizeof(R8), 1, fl); // Epot vec box; fread(&box, sizeof(box), 1, fl); cout << box << endl; conf.setBox(matrix(vec(box.x(), 0, 0), vec(0, box.y(), 0), vec(0, 0, box.y()))); I4 = rec + 1; while(I4!=rec) // skip everything to end of record fread(&I4, sizeof(I4), 1, fl); // end record /* for each moleculetype record (if list) * record * 3*R4*natoms*ntypes pos * * record if ivel * 3*R4*natoms*ntypes vel * */ int ind=0; for(int i=0; i<_moltypes; ++i) { fread(&rec, sizeof(rec), 1, fl); // begin record for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.Pos(a+ind).x() = f*0.1; } for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.Pos(a+ind).y() = f*0.1; } for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.Pos(a+ind).z() = f*0.1; } ind+=_nmols[i]*_natoms[i]; I4 = rec + 1; while(I4!=rec) // skip everything to end of record fread(&I4, sizeof(I4), 1, fl); // end record if(iVel == 1) { fread(&rec, sizeof(rec), 1, fl); // begin record for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.V(a+ind).x() = f*0.1; } for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.V(a+ind).y() = f*0.1; } for(int a=0; a<_nmols[i]*_natoms[i]; a++) { float f; fread(&f, sizeof(float), 1, fl); conf.V(a+ind).z() = f*0.1; } I4 = rec + 1; while(I4!=rec) // skip everything to end of record fread(&I4, sizeof(I4), 1, fl); // end record } } if(feof(fl)) return false; return true; } votca-csg-1.2.4/src/libcsg/modules/io/gmxtrajectorywriter.h0000644000175000001440000000412012400714673023750 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _GMXTRAJECTORYWRITER_H #define _GMXTRAJECTORYWRITER_H #ifndef HAVE_NO_CONFIG #include #endif #include #include #include "gmx_version_check.h" #if GMX == 50 #include #elif GMX == 45 #include #include #include #include #include #include #include #elif GMX == 40 extern "C" { #include #include #include #include #include #include #include } #else #error Unsupported GMX version #endif // this one is needed because of bool is defined in one of the headers included by gmx #undef bool namespace votca { namespace csg { using namespace votca::tools; using namespace std; class GMXTrajectoryWriter : public TrajectoryWriter { public: GMXTrajectoryWriter() { gmx::CheckVersion(); } void Open(string file, bool bAppend = false); void Close(); void Write(Topology *conf); private: #if GMX == 50 t_trxstatus* _file; #elif GMX == 45 t_trxstatus* _file; #elif GMX == 40 int _file; #else #error Unsupported GMX version #endif }; }} #endif /* _GMXTRAJECTORYWRITER_H */ votca-csg-1.2.4/src/libcsg/modules/io/mdptopologyreader.h0000644000175000001440000000205012400714673023351 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _MDPTOPOLOGYREADER_H #define _MDPTOPOLOGYREADER_H #include "topologyreader.h" /** \brief reader for Alexander Lyubartsev's md format */ class MDPTopologyReader : public TopologyReader { public: /// read a topology file bool ReadTopology(string file, Topology &top); TopologyReader *Clone() { return new MDPTopologyReader(); } private: }; #endif /* _MDPTOPOLOGYREADER_H */ votca-csg-1.2.4/src/libcsg/votca_config.h.in0000644000175000001440000000030712400714674020604 0ustar christophusers/* Used gromacs version */ #cmakedefine GMX @GMX@ /* Version number of package */ #define VERSION "@PROJECT_VERSION@" /* Contact address of package */ #define PACKAGE_BUGREPORT "@PROJECT_CONTACT@" votca-csg-1.2.4/src/libcsg/exclusionlist.cc0000644000175000001440000001174412400714673020607 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace csg { void ExclusionList::Clear(void) { list< exclusion_t *>::iterator iter; for(iter=_exclusions.begin();iter!=_exclusions.end();++iter) delete *iter; _exclusions.clear(); } void ExclusionList::ExcludeAll(int N) { Clear(); for(int i=0; i_atom = i; for(int j=i+1; j_exclude.push_back(j); } _exclusions.push_back(e); } } void ExclusionList::Remove(list l) { l.sort(); list::iterator i, j; list::iterator ex; for(i=l.begin(); i!=l.end(); i++) { for(ex=_exclusions.begin(); ex!=_exclusions.end(); ++ex) if((*ex)->_atom == *i) break; if(ex==_exclusions.end()) continue; j = i; for(++j; j!=l.end(); j++) (*ex)->_exclude.remove(*j); if((*ex)->_exclude.empty()) { // delete *ex; (*ex)=NULL; _exclusions.erase(ex); } } _exclusions.remove(NULL); } void ExclusionList::ExcludeList( list l ) { l.sort(); list::iterator i, j, k; list::iterator ex; for ( i = l.begin(); i != l.end(); ++i ) { for (ex = _exclusions.begin(); ex != _exclusions.end(); ++ex) if ( (*ex)->_atom == (*i) ) break; if (ex==_exclusions.end()) { // so far there are no exclusions for i exclusion_t *e = new exclusion_t; e->_atom = (*i); j = i; for (++j; j != l.end(); ++j) e->_exclude.push_back( (*j) ); _exclusions.push_back(e); } else { // there are some exclusions for i already. Add new exclusions if they are // not there yet! j = i; for (++j; j != l.end(); ++j) { for ( k = (*ex)->_exclude.begin(); k != (*ex)->_exclude.end(); ++k ) if ( (*j) == (*k) ) break; if ( k == (*ex)->_exclude.end() ) (*ex)->_exclude.push_back( (*j) ); } } } } void ExclusionList::CreateExclusions(Topology *top) { InteractionContainer &ic = top->BondedInteractions(); InteractionContainer::iterator ia; list l; for (ia = ic.begin(); ia != ic.end(); ++ia) { int beads_in_int = (*ia)->BeadCount(); l.clear(); for (int ibead = 0; ibead < beads_in_int; ibead ++) { int ii = (*ia)->getBeadId(ibead); l.push_back(ii); } ExcludeList(l); } // Create map list< exclusion_t * >::iterator it; for ( it = _exclusions.begin(); it != _exclusions.end(); ++it ) { int iatom = (*it)->_atom; _excl_by_bead[ iatom ] = (*it); } } bool ExclusionList::IsExcluded(int bead1, int bead2) { exclusion_t *excl; if (bead2 < bead1) swap(bead1, bead2); if ((excl = GetExclusions(bead1))) { if(find(excl->_exclude.begin(), excl->_exclude.end(), bead2) != excl->_exclude.end()) return true; } return false; } std::ostream &operator<<(std::ostream &out, ExclusionList& exl) { list::iterator ex; for(ex=exl._exclusions.begin();ex!=exl._exclusions.end();++ex) { list::iterator i; out << (int)((*ex)->_atom) + 1; for(i=(*ex)->_exclude.begin(); i!=(*ex)->_exclude.end(); ++i) { out << " " << ((*i)+1); } out << endl; } return out; } void ExclusionList::InsertExclusion(int index, list l) { list::iterator i; //cout << "atom " << index << endl; for(i=l.begin(); i!=l.end(); ++i) { int bead1 = index; int bead2 = *i; if (bead2 < bead1) swap(bead1, bead2); if(bead1==bead2) continue; if(IsExcluded(bead1, bead2)) continue; exclusion_t *e; if((e = GetExclusions(bead1)) == NULL) { e = new exclusion_t; e->_atom = bead1; _exclusions.push_back(e); _excl_by_bead[ bead1 ] = e; } e->_exclude.push_back(bead2); //cout << (*i) << " " << endl; } //cout << endl; } }} votca-csg-1.2.4/src/libcsg/cgmoleculedef.cc0000644000175000001440000001610012400714673020467 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include namespace votca { namespace csg { using boost::lexical_cast; CGMoleculeDef::~CGMoleculeDef() { { vector::iterator i; for(i=_beads.begin();i!=_beads.end();++i) delete *i; _beads.clear(); } } void CGMoleculeDef::Load(string filename) { load_property_from_xml(_options, filename); // parse xml tree _name = _options.get("cg_molecule.name").as(); _ident = _options.get("cg_molecule.ident").as(); ParseTopology(_options.get("cg_molecule.topology")); ParseMapping(_options.get("cg_molecule.maps")); } void CGMoleculeDef::ParseTopology(Property &options) { ParseBeads(options.get("cg_beads")); if(options.exists("cg_bonded")) ParseBonded(options.get("cg_bonded")); } void CGMoleculeDef::ParseBeads(Property &options) { list beads = options.Select("cg_bead"); for (list::iterator iter = beads.begin(); iter != beads.end(); ++iter) { Property *p = *iter; beaddef_t *beaddef = new beaddef_t; beaddef->_options = p; beaddef->_name = p->get("name").as(); beaddef->_type = p->get("type").as(); beaddef->_mapping = p->get("mapping").as(); if (p->exists("symmetry")) beaddef->_symmetry = p->get("symmetry").as(); else beaddef->_symmetry = 1; if (_beads_by_name.find(beaddef->_name) != _beads_by_name.end()) throw std::runtime_error(string("bead name ") + beaddef->_name + " not unique in mapping"); _beads.push_back(beaddef); _beads_by_name[beaddef->_name] = beaddef; } } void CGMoleculeDef::ParseBonded(Property &options) { _bonded = options.Select("*"); } void CGMoleculeDef::ParseMapping(Property &options) { list maps = options.Select("map"); for(list::iterator iter=maps.begin(); iter!=maps.end(); ++iter) _maps[(*iter)->get("name").as()] = *iter; } Molecule * CGMoleculeDef::CreateMolecule(Topology & top) { // add the residue names Residue *res = top.CreateResidue(_name); Molecule *minfo = top.CreateMolecule(_name); // create the atoms vector::iterator iter; for(iter = _beads.begin(); iter != _beads.end(); ++iter) { Bead *bead; BeadType *bt = top.GetOrCreateBeadType((*iter)->_type); bead = top.CreateBead((*iter)->_symmetry, (*iter)->_name, bt, res->getId(), 0, 0); minfo->AddBead(bead, bead->getName()); bead->setOptions(*(*iter)->_options); } // create the bonds list::iterator ibnd; map had_iagroup; for(ibnd = _bonded.begin(); ibnd!=_bonded.end(); ++ibnd) { list atoms; string iagroup = (*ibnd)->get("name").as(); if(had_iagroup[iagroup] == "yes") throw runtime_error( string("double occurence of interactions with name ") + iagroup); had_iagroup[iagroup] = "yes"; Tokenizer tok((*ibnd)->get("beads").value(), " \n\t"); for (Tokenizer::iterator atom = tok.begin(); atom != tok.end(); ++atom) { int i = minfo->getBeadIdByName(*atom); if(i < 0) throw runtime_error(string("error while trying to create bonded interaction, " "bead " + *atom + " not found")); atoms.push_back(i); } int index=0; while(!atoms.empty()) { Interaction *ic; if((*ibnd)->name() == "bond") ic = new IBond(atoms); else if((*ibnd)->name() == "angle") ic = new IAngle(atoms); else if((*ibnd)->name() == "dihedral") ic = new IDihedral(atoms); else throw runtime_error("unknown bonded type in map: " + (*ibnd)->name()); ic->setGroup(iagroup); ic->setIndex(index); ic->setMolecule(minfo->getId()); top.AddBondedInteraction(ic); minfo->AddInteraction(ic); index++; } } return minfo; } Map *CGMoleculeDef::CreateMap(Molecule &in, Molecule &out) { if((unsigned int)out.BeadCount() != _beads.size()) { throw runtime_error("number of beads for cg molecule and mapping definition do " "not match, check your molecule naming."); } Map *map = new Map(in, out); for(vector::iterator def = _beads.begin(); def != _beads.end(); ++def) { int iout = out.getBeadByName((*def)->_name); if(iout < 0) throw runtime_error(string("mapping error: reference molecule " + (*def)->_name + " does not exist")); Property *mdef = getMapByName((*def)->_mapping); if(!mdef) throw runtime_error(string("mapping " + (*def)->_mapping + " not found")); /// TODO: change this to factory, do not hardcode!! BeadMap *bmap; switch((*def)->_symmetry) { case 1: bmap = new Map_Sphere(); break; case 3: bmap = new Map_Ellipsoid(); break; default: throw runtime_error(string("unknown symmetry in bead definition!")); } //////////////////////////////////////////////////// bmap->Initialize(&in, out.getBead(iout), ((*def)->_options), mdef); map->AddBeadMap(bmap); } return map; } CGMoleculeDef::beaddef_t *CGMoleculeDef::getBeadByName(const string &name) { map::iterator iter = _beads_by_name.find(name); if(iter == _beads_by_name.end()) { std::cout << "cannot find: <" << name << "> in " << _name << "\n"; return NULL; } //assert(iter != _beadmap.end()); //return (*iter).second; return (*iter).second; } Property *CGMoleculeDef::getMapByName(const string &name) { map::iterator iter = _maps.find(name); if(iter == _maps.end()) { std::cout << "cannot find map " << name << "\n"; return NULL; } //assert(iter != _beadmap.end()); //return (*iter).second; return (*iter).second; } }} votca-csg-1.2.4/src/tools/0000755000175000001440000000000012400714674015262 5ustar christophusersvotca-csg-1.2.4/src/tools/csg_stat_imc.cc0000644000175000001440000005340512400714674020237 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include "csg_stat_imc.h" #include namespace votca { namespace csg { Imc::Imc() : _write_every(0), _do_blocks(false), _do_imc(false), _processed_some_frames(false) { } Imc::~Imc() { } // begin the coarse graining process // here the data structures are prepared to handle all the data void Imc::Initialize() { // do some output if(_do_imc) cout << "begin to calculate inverse monte carlo parameters\n"; else cout << "begin to calculate distribution functions\n"; cout << "# of bonded interactions: " << _bonded.size() << endl; cout << "# of non-bonded interactions: " << _nonbonded.size() << endl; if ( _bonded.size()+_nonbonded.size() == 0 ) throw std::runtime_error("No interactions defined in options xml-file - nothing to be done"); // initialize non-bonded structures for (list::iterator iter = _nonbonded.begin(); iter != _nonbonded.end(); ++iter) { interaction_t *i = AddInteraction(*iter); i->_is_bonded = false; } // initialize non-bonded structures for (list::iterator iter = _bonded.begin(); iter != _bonded.end(); ++iter) { interaction_t *i = AddInteraction(*iter); i->_is_bonded = true; } // initialize the group structures if(_do_imc) InitializeGroups(); }; void Imc::BeginEvaluate(Topology *top, Topology *top_atom) { // we didn't process any frames so far _nframes = 0; _nblock = 0; _processed_some_frames=false; // initialize non-bonded structures for (list::iterator iter = _nonbonded.begin(); iter != _nonbonded.end(); ++iter) { string name = (*iter)->get("name").value(); interaction_t &i = *_interactions[name]; // generate the bead lists BeadList beads1, beads2; beads1.Generate(*top, (*iter)->get("type1").value()); beads2.Generate(*top, (*iter)->get("type2").value()); if(beads1.size() == 0) throw std::runtime_error("Topology does not have beads of type \"" + (*iter)->get("type1").value() + "\"\n" "This was specified in type1 of interaction \"" + name+ "\""); if(beads2.size() == 0) throw std::runtime_error("Topology does not have beads of type \"" + (*iter)->get("type2").value() + "\"\n" "This was specified in type2 of interaction \"" + name + "\""); // calculate normalization factor for rdf if ((*iter)->get("type1").value() == (*iter)->get("type2").value()) i._norm = 1. / (beads1.size()*(beads2.size()) / 2.); else i._norm = 1. / (beads1.size() * beads2.size()); } } // create an entry for interactions Imc::interaction_t *Imc::AddInteraction(Property *p) { string name = p->get("name").value(); string group; if(_do_imc) group = p->get("inverse.imc.group").value(); else group = "none"; interaction_t *i = new interaction_t; i->_index = _interactions.size(); _interactions[name] = i; getGroup(group)->_interactions.push_back(i); i->_step = p->get("step").as(); i->_min = p->get("min").as(); i->_max = p->get("max").as(); i->_norm = 1.0; i->_p=p; // initialize the current and average histogram int n = (int)((i->_max - i->_min) / i->_step + 1.000000001); i->_average.Initialize(i->_min, i->_max+i->_step, n); return i; } // end of trajectory, post processing data void Imc::EndEvaluate() { if(_nframes > 0) { if(!_do_blocks) { WriteDist(); if(_do_imc) WriteIMCData(); } } // clear interactions and groups _interactions.clear(); _groups.clear(); if(!_processed_some_frames) throw std::runtime_error("no frames were processed. Please check your input"); } // load options from xml file void Imc::LoadOptions(const string &file) { load_property_from_xml(_options, file); _bonded = _options.Select("cg.bonded"); _nonbonded = _options.Select("cg.non-bonded"); } // evaluate current conformation void Imc::Worker::EvalConfiguration(Topology *top, Topology *top_atom) { _cur_vol = top->BoxVolume(); // process non-bonded interactions DoNonbonded(top); // process bonded interactions DoBonded(top); } void Imc::ClearAverages() { map::iterator ic_iter; map::iterator group_iter; _nframes = 0; for (ic_iter = _interactions.begin(); ic_iter != _interactions.end(); ++ic_iter) ic_iter->second->_average.Clear(); for (group_iter = _groups.begin(); group_iter != _groups.end(); ++group_iter) group_iter->second->_corr.clear(); } class IMCNBSearchHandler { public: IMCNBSearchHandler(HistogramNew *hist) : _hist(hist) {} HistogramNew *_hist; bool FoundPair(Bead *b1, Bead *b2, const vec &r, const double dist) { _hist->Process(dist); return false; } }; // process non-bonded interactions for current frame void Imc::Worker::DoNonbonded(Topology *top) { for (list::iterator iter = _imc->_nonbonded.begin(); iter != _imc->_nonbonded.end(); ++iter) { string name = (*iter)->get("name").value(); interaction_t &i = *_imc->_interactions[name]; // generate the bead lists BeadList beads1, beads2; beads1.Generate(*top, (*iter)->get("type1").value()); beads2.Generate(*top, (*iter)->get("type2").value()); // generate the neighbour list NBList *nb; bool gridsearch=true; if(_imc->_options.exists("cg.nbsearch")) { if(_imc->_options.get("cg.nbsearch").as() == "grid") gridsearch=true; else if(_imc->_options.get("cg.nbsearch").as() == "simple") gridsearch=false; else throw std::runtime_error("cg.nbsearch invalid, can be grid or simple"); } if(gridsearch) nb = new NBListGrid(); else nb = new NBList(); nb->setCutoff(i._max + i._step); // clear the current histogram _current_hists[i._index].Clear(); IMCNBSearchHandler h(&(_current_hists[i._index])); nb->SetMatchFunction(&h, &IMCNBSearchHandler::FoundPair); // is it same types or different types? if((*iter)->get("type1").value() == (*iter)->get("type2").value()) nb->Generate(beads1); else nb->Generate(beads1, beads2); // process all pairs /*NBList::iterator pair_iter; for(pair_iter = nb->begin(); pair_iter!=nb->end();++pair_iter) { _current_hists[i._index].Process((*pair_iter)->dist()); }*/ delete nb; } } // process non-bonded interactions for current frame void Imc::Worker::DoBonded(Topology *top) { for (list::iterator iter = _imc->_bonded.begin(); iter != _imc->_bonded.end(); ++iter) { string name = (*iter)->get("name").value(); interaction_t &i = *_imc->_interactions[name]; // clear the current histogram _current_hists[i._index].Clear(); // now fill with new data std::list list = top->InteractionsInGroup(name); std::list::iterator ic_iter; for(ic_iter=list.begin(); ic_iter!=list.end(); ++ic_iter) { Interaction *ic = *ic_iter; double v = ic->EvaluateVar(*top); _current_hists[i._index].Process(v); } } } // returns a group, creates it if doesn't exist Imc::group_t *Imc::getGroup(const string &name) { map::iterator iter; iter = _groups.find(name); if(iter == _groups.end()) { return _groups[name] = new group_t; } return (*iter).second; } // initialize the groups after interactions are added void Imc::InitializeGroups() { if(!_do_imc) return; map::iterator group_iter; // clear all the pairs // iterator over all groups for (group_iter = _groups.begin(); group_iter != _groups.end(); ++group_iter) { group_t *grp = (*group_iter).second; grp->_pairs.clear(); int n = 0; // count number of bins needed in matrix for (list::iterator i1 = grp->_interactions.begin(); i1 != grp->_interactions.end(); ++i1) n+=(*i1)->_average.getNBins(); // handy access to matrix group_matrix &M = grp->_corr; // initialize matrix with zeroes M.resize(n,n); M = ub::zero_matrix(n, n); // now create references to the sub matrices int i, j; i=0;j=0; // iterate over all possible compinations of pairs for (list::iterator i1 = grp->_interactions.begin(); i1 != grp->_interactions.end(); ++i1) { int n1 = (*i1)->_average.getNBins(); j = i; for (list::iterator i2 = i1; i2 != grp->_interactions.end(); ++i2) { int n2 = (*i2)->_average.getNBins(); // create matrix proxy with sub-matrix pair_matrix corr(M, ub::range(i, i+n1), ub::range(j, j+n2)); // add the pair grp->_pairs.push_back(pair_t(*i1, *i2, i, j, corr)); j+=n2; } i+=n1; } } } // update the correlation matrix void Imc::DoCorrelations(Imc::Worker *worker) { if(!_do_imc) return; vector::iterator pair; map::iterator group_iter; for (group_iter = _groups.begin(); group_iter != _groups.end(); ++group_iter) { group_t *grp = (*group_iter).second; // update correlation for all pairs for (pair = grp->_pairs.begin(); pair != grp->_pairs.end(); ++pair) { ub::vector &a = worker->_current_hists[pair->_i1->_index].data().y(); ub::vector &b = worker->_current_hists[pair->_i2->_index].data().y(); pair_matrix &M = pair->_corr; // M_ij += a_i*b_j //for(int i=0; i::iterator iter; // for all interactions for (iter = _interactions.begin(); iter != _interactions.end(); ++iter) { // calculate the rdf Table &t = iter->second->_average.data(); Table dist(t); if(!iter->second->_is_bonded) { // normalization is calculated using exact shell volume (difference of spheres) for(int i=0; isecond->_step; double x2 = x1 + iter->second->_step; if(x1<0) { dist.y()[i]=0; } else { dist.y()[i] = _avg_vol.getAvg()*iter->second->_norm * dist.y()[i]/(4./3.*M_PI*(x2*x2*x2 - x1*x1*x1)); } } } else { dist.y() = iter->second->_norm * dist.y(); } dist.Save((iter->first) + suffix + ".dist.new"); cout << "written " << (iter->first) + suffix + ".dist.new\n"; } } /** * Here the inverse monte carlo matrix is calculated and written out * * steps: * - calculate th */ void Imc::WriteIMCData(const string &suffix) { if(!_do_imc) return; //map::iterator ic_iter; map::iterator group_iter; // iterate over all groups for(group_iter = _groups.begin(); group_iter!=_groups.end(); ++group_iter) { group_t *grp = (*group_iter).second; string grp_name = (*group_iter).first; list::iterator iter; // number of total bins for all interactions in group is matrix dimension int n=grp->_corr.size1(); // build full set of equations + copy some data to make // code better to read group_matrix gmc(grp->_corr); ub::vector dS(n); ub::vector r(n); // the next two variables are to later extract the individual parts // from the whole data after solving equations vector ranges; // sizes of the individual interactions vector names; // names of the interactions // copy all averages+r of group to one vector n=0; int begin=1; for(iter=grp->_interactions.begin(); iter != grp->_interactions.end(); ++iter) { interaction_t *ic = *iter; // sub vector for dS ub::vector_range< ub::vector > sub_dS(dS, ub::range(n, n + ic->_average.getNBins())); // sub vector for r ub::vector_range< ub::vector > sub_r(r, ub::range(n, n + ic->_average.getNBins())); // read in target and calculate dS CalcDeltaS(ic, sub_dS); // copy r sub_r = ic->_average.data().x(); // save size RangeParser rp; int end = begin + ic->_average.getNBins() -1; rp.Add(begin, end); ranges.push_back(rp); begin = end+1; // save name names.push_back(ic->_p->get("name").as()); // shift subrange by size of current n+=ic->_average.getNBins(); } // now we need to calculate the // A_ij = - * vector::iterator pair; for (pair = grp->_pairs.begin(); pair != grp->_pairs.end(); ++pair) { interaction_t *i1 = pair->_i1; interaction_t *i2 = pair->_i2; // make reference to ub::vector &a = i1->_average.data().y(); // make reference to ub::vector &b = i2->_average.data().y(); int i=pair->_offset_i; int j=pair->_offset_j; int n1=i1->_average.getNBins(); int n2=i2->_average.getNBins(); // sub matrix for these two interactions // we only need to take care about one sub-matrix and not the mirrored // one since ublas makes sure the matrix is symmetric pair_matrix M(gmc, ub::range(i, i+n1), ub::range(j, j+n2)); // A_ij = -( - *) //for(i=0; i > &dS) { const string &name = interaction->_p->get("name").as(); Table target; target.Load(name + ".dist.tgt"); if(!interaction->_is_bonded) { for(int i=0; i_step; double x2 = x1 + interaction->_step; if(x1<0) x1=x2=0; target.y()[i] = 1./(_avg_vol.getAvg()*interaction->_norm) * target.y()[i] * (4./3.*M_PI*(x2*x2*x2 - x1*x1*x1)); } } else { target.y() = (1.0 / interaction->_norm)*target.y(); } if(target.y().size() != interaction->_average.data().y().size()) throw std::runtime_error("number of grid points in target does not match the grid"); dS = interaction->_average.data().y() - target.y(); } void Imc::WriteIMCBlock(const string &suffix) { if(!_do_imc) return; //map::iterator ic_iter; map::iterator group_iter; // iterate over all groups for(group_iter = _groups.begin(); group_iter!=_groups.end(); ++group_iter) { group_t *grp = (*group_iter).second; string grp_name = (*group_iter).first; list::iterator iter; // number of total bins for all interactions in group is matrix dimension int n=grp->_corr.size1(); // build full set of equations + copy some data to make // code better to read group_matrix gmc(grp->_corr); ub::vector dS(n); ub::vector r(n); // the next two variables are to later extract the individual parts // from the whole data after solving equations vector sizes; // sizes of the individual interactions vector names; // names of the interactions // copy all averages+r of group to one vector n=0; for(iter=grp->_interactions.begin(); iter != grp->_interactions.end(); ++iter) { interaction_t *ic = *iter; // sub vector for dS ub::vector_range< ub::vector > sub_dS(dS, ub::range(n, n + ic->_average.getNBins())); // sub vector for r ub::vector_range< ub::vector > sub_r(r, ub::range(n, n + ic->_average.getNBins())); // read in target and calculate dS sub_dS = ic->_average.data().y(); // copy r sub_r = ic->_average.data().x(); // save size sizes.push_back(ic->_average.getNBins()); // save name names.push_back(ic->_p->get("name").as()); // shift subrange by size of current n+=ic->_average.getNBins(); } // write the dS ofstream out_dS; string name_dS = grp_name + suffix + ".S"; out_dS.open(name_dS.c_str()); out_dS << setprecision(8); if(!out_dS) throw runtime_error(string("error, cannot open file ") + name_dS); for(size_t i=0; i_corr.size1(); ++i) { for(group_matrix::size_type j=0; j_corr.size2(); ++j) { out_cor << grp->_corr(i, j) << " "; } out_cor << endl; } out_cor.close(); cout << "written " << name_cor << endl; } } CsgApplication::Worker *Imc::ForkWorker() { Imc::Worker *worker; worker = new Imc::Worker; map::iterator ic_iter; worker->_current_hists.resize(_interactions.size()); worker->_imc = this; for (ic_iter = _interactions.begin(); ic_iter != _interactions.end(); ++ic_iter) { interaction_t *i = ic_iter->second; worker->_current_hists[i->_index].Initialize( i->_average.getMin(), i->_average.getMax(), i->_average.getNBins()); } return worker; } void Imc::MergeWorker(CsgApplication::Worker* worker_) { _processed_some_frames = true; Imc::Worker *worker = dynamic_cast(worker_); // update the average map::iterator ic_iter; //map::iterator group_iter; ++_nframes; _avg_vol.Process(worker->_cur_vol); for (ic_iter = _interactions.begin(); ic_iter != _interactions.end(); ++ic_iter) { interaction_t *i=ic_iter->second; i->_average.data().y() = (((double)_nframes-1.0)*i->_average.data().y() + worker->_current_hists[i->_index].data().y())/(double)_nframes; } // update correlation matrices if(_do_imc) DoCorrelations(worker); if(_write_every != 0) { if((_nframes % _write_every)==0) { _nblock++; string suffix = string("_") + boost::lexical_cast(_nblock); WriteDist(suffix); WriteIMCData(suffix); WriteIMCBlock(suffix); if(_do_blocks) ClearAverages(); } } } }} votca-csg-1.2.4/src/tools/csg_imcrepack.cc0000644000175000001440000001067212400714674020371 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /* * csg_imcrepack repacks the matri for the imc update. It either removes zero line entries (pack) * or extracts the dU from the big file (unpack) * */ #include #include #include #include #include #include using namespace votca::csg; using namespace votca::tools; void help_text(void) { votca::csg::HelpTextHeader("csg_imcrepack"); cout << "This program is internally called by inversion scripts to kick out\n" "zero entries in matrix for inverse Monte Carlo. It also extracts the\n" "single potential updates out of the full solution.\n\n"; } using namespace std; namespace po = boost::program_options; void check_option(po::options_description &desc, po::variables_map &vm, const string &option) { if(!vm.count(option)) { cout << "csg_imcrepack \n\n"; cout << desc << endl << "parameter " << option << " is not specified\n"; exit(1); } } int main(int argc, char** argv) { string name_in, name_out, name_unpack; // program options po::options_description desc("Allowed options"); desc.add_options() ("in", po::value(&name_in), "files to read") ("out", po::value(&name_out), "files to write") ("unpack", po::value(&name_unpack), "extract all tables from this file") ("help", "display help message"); po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); } catch(po::error err) { cout << "error parsing command line: " << err.what() << endl; return -1; } // does the user want help? if (vm.count("help")) { help_text(); cout << desc << endl; return 0; } check_option(desc, vm, "in"); ub::vector r; ub::vector dS; ub::matrix gmc; vector names; vector ranges; imcio_read_index(name_in + ".idx", names, ranges); if(vm.count("unpack")) { RangeParser *cur_rp; Table tbl_in; tbl_in.Load(name_unpack); vector::iterator iter_name = names.begin(); vector::iterator iter_range = ranges.begin(); while(iter_name != names.end()) { cur_rp = &(*iter_range); Table tbl; for(RangeParser::iterator ir=cur_rp->begin(); ir!=cur_rp->end(); ++ir) { tbl.push_back(tbl_in.x(*ir-1), tbl_in.y(*ir-1), 'i'); } tbl.Save(*iter_name + ".dpot.imc"); ++iter_name; ++iter_range; } } else { check_option(desc, vm, "out"); RangeParser *cur_rp; vector::iterator iter_name = names.begin(); vector::iterator iter_range = ranges.begin(); int beg=1; int end=0; list list; imcio_read_dS(name_in + ".imc", r, dS); imcio_read_matrix(name_in + ".gmc", gmc); while(iter_name != names.end()) { cur_rp = &(*iter_range); for(RangeParser::iterator ir=cur_rp->begin(); ir!=cur_rp->end(); ++ir) { for(size_t i=0; i 1e-8) { list.push_back(*ir-1); end++; break; } } RangeParser new_rp; new_rp.Add(beg, end); beg=end+1; *iter_range = new_rp; ++iter_name; ++iter_range; } imcio_write_dS(name_out + ".imc", r, dS, &list); imcio_write_matrix(name_out + ".gmc", gmc, &list); imcio_write_index(name_out + ".idx", names, ranges); } } votca-csg-1.2.4/src/tools/csg_stat.cc0000644000175000001440000000636712400714674017414 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include "csg_stat_imc.h" #include #include //using namespace votca::tools; using namespace std; using namespace votca::csg; class CsgStatApp : public CsgApplication { public: CsgStatApp() : _write_every(0) {} string ProgramName() { return "csg_stat"; } void HelpText(ostream &out); bool DoTrajectory() {return true;} bool DoMapping() {return true;} bool DoMappingDefault(void) { return false; } bool DoThreaded() {return true; } bool SynchronizeThreads() {return true;} void Initialize(); bool EvaluateOptions(); void BeginEvaluate(Topology *top, Topology *top_ref); void EndEvaluate(); CsgApplication::Worker *ForkWorker() { return _imc.ForkWorker(); } void MergeWorker(CsgApplication::Worker *worker) { _imc.MergeWorker(worker); } public: Imc _imc; int _write_every; }; void CsgStatApp::HelpText(ostream &out) { out << "Calculate all distributions (bonded and non-bonded) specified in options file.\n" "Optionally calculates update matrix for invere Monte Carlo. This program\n" "is called inside the inverse scripts. Unlike csg_boltzmann, big systems\n" "can be treated as well as non-bonded interactions can be evaluated."; } void CsgStatApp::Initialize() { CsgApplication::Initialize(); AddProgramOptions("Specific options") ("options", boost::program_options::value(), " options file for coarse graining") ("do-imc", " write out Inverse Monte Carlo data") ("write-every", boost::program_options::value(&_write_every), " write after every block of this length, " \ "if --blocking is set, the averages are cleared after every output") ("do-blocks", " write output for blocking analysis"); } bool CsgStatApp::EvaluateOptions() { CsgApplication::EvaluateOptions(); CheckRequired("options"); CheckRequired("trj", "no trajectory file specified"); _imc.LoadOptions(OptionsMap()["options"].as()); _imc.WriteEvery(_write_every); if(OptionsMap().count("do-blocks")) _imc.DoBlocks(true); if(OptionsMap().count("do-imc")) _imc.DoImc(true); _imc.Initialize(); return true; } void CsgStatApp::BeginEvaluate(Topology *top, Topology *top_ref) { _imc.BeginEvaluate(top, top_ref); } void CsgStatApp::EndEvaluate() { _imc.EndEvaluate(); } int main(int argc, char** argv) { CsgStatApp app; return app.Exec(argc, argv); } votca-csg-1.2.4/src/tools/CMakeLists.txt0000644000175000001440000000176512400714674020033 0ustar christophusersforeach(PROG csg_map csg_dump csg_property csg_resample csg_stat csg_fmatch csg_imcrepack csg_gmxtopol csg_part_dist csg_density) file(GLOB ${PROG}_SOURCES ${PROG}*.cc) add_executable(${PROG} ${${PROG}_SOURCES}) target_link_libraries(${PROG} votca_csg) install(TARGETS ${PROG} RUNTIME DESTINATION bin) if (TXT2TAGS_FOUND AND BASH) add_custom_command(OUTPUT ${PROG}.man COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${PROG} --help > ${PROG}.help COMMAND ${BASH} ${CMAKE_BINARY_DIR}/scripts/help2t2t ${PROG}.help > ${PROG}.t2t COMMAND ${TXT2TAGS_EXECUTABLE} -q -t man -i ${PROG}.t2t -o ${PROG}.man DEPENDS scripts/help2t2t ${PROG}) add_custom_target(${PROG}_manpage DEPENDS ${PROG}.man) add_dependencies(manpages ${PROG}_manpage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROG}.man DESTINATION ${MAN}/man1 RENAME ${PROG}.1) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${PROG}.help ${PROG}.t2t) endif(TXT2TAGS_FOUND AND BASH) endforeach(PROG) votca-csg-1.2.4/src/tools/csg_map.cc0000644000175000001440000000470312400714674017206 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include using namespace std; using namespace votca::csg; class CsgMapApp : public CsgApplication { public: string ProgramName() { return "csg_map"; } void HelpText(ostream &out) { out << "Map a reference trajectory to a coarse-grained trajectory.\n" "This program can be used to map a whole trajectory or to\n" "create an initial configuration for a coarse-grained run only."; } bool DoTrajectory() { return true;} bool DoMapping() { return true;} void Initialize() { CsgApplication::Initialize(); AddProgramOptions() ("out", boost::program_options::value(), " output file for coarse-grained trajectory"); } bool EvaluateOptions() { CsgApplication::EvaluateOptions(); CheckRequired("trj", "no trajectory file specified"); CheckRequired("out", "need to specify output trajectory"); return true; } void BeginEvaluate(Topology *top, Topology *top_ref); void EvalConfiguration(Topology *top, Topology *top_ref) { _writer->Write(top); } void EndEvaluate() { _writer->Close(); delete _writer; } protected: TrajectoryWriter *_writer; }; void CsgMapApp::BeginEvaluate(Topology *top, Topology *top_atom) { string out = OptionsMap()["out"].as(); cout << "writing coarse-grained trajectory to " << out << endl; _writer = TrjWriterFactory().Create(out); if(_writer == NULL) throw runtime_error("output format not supported: " + out); _writer->Open(out); }; int main(int argc, char **argv) { CsgMapApp app; return app.Exec(argc, argv); } votca-csg-1.2.4/src/tools/csg_resample.cc0000644000175000001440000002162612400714674020244 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include using namespace std; namespace po = boost::program_options; using namespace votca::csg; using namespace votca::tools; void help_text() { votca::csg::HelpTextHeader("csg_resample"); cout << "Change grid and interval of any sort of table files.\n" "Mainly called internally by inverse script, can also be\n" "used to manually prepare input files for coarse-grained\n" "simulations.\n\n"; } void check_option(po::options_description &desc, po::variables_map &vm, const string &option) { if(!vm.count(option)) { cout << "csg_resample \n\n"; cout << desc << endl << "parameter " << option << " is not specified\n"; exit(1); } } int main(int argc, char** argv) { string in_file, out_file, grid, fitgrid, comment, type, boundaries; Spline *spline; Table in, out, der; // program options po::options_description desc("Allowed options"); desc.add_options() ("help", "produce this help message") ("in", po::value(&in_file), "table to read") ("out", po::value(&out_file), "table to write") ("derivative", po::value(), "table to write") ("grid", po::value(&grid), "new grid spacing (min:step:max). If 'grid' is specified only, interpolation is performed.") ("type", po::value(&type)->default_value("akima"), "[cubic|akima|linear]. If option is not specified, the default type 'akima' is assumed.") ("fitgrid", po::value(&fitgrid), "specify fit grid (min:step:max). If 'grid' and 'fitgrid' are specified, a fit is performed.") ("nocut", "Option for fitgrid: Normally, values out of fitgrid boundaries are cut off. If they shouldn't, choose --nocut.") ("comment", po::value(&comment), "store a comment in the output table") ("boundaries", po::value(&boundaries), "(natural|periodic|derivativezero) sets boundary conditions"); po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); } catch(po::error err) { cout << "error parsing command line: " << err.what() << endl; return -1; } try { // does the user want help? if (vm.count("help")) { help_text(); cout << desc << endl; return 0; } check_option(desc, vm, "in"); check_option(desc, vm, "out"); if(!(vm.count("grid") || vm.count("fitgrid"))) { cout << "Need grid for interpolation or fitgrid for fit.\n"; return 1; } if((!vm.count("grid")) && vm.count("fitgrid")) { cout << "Need a grid for fitting as well.\n"; return 1; } double min, max, step; { Tokenizer tok(grid, ":"); vector toks; tok.ToVector(toks); if(toks.size()!=3) { cout << "wrong range format, use min:step:max\n"; return 1; } min = boost::lexical_cast(toks[0]); step = boost::lexical_cast(toks[1]); max = boost::lexical_cast(toks[2]); } in.Load(in_file); if (vm.count("type")) { if(type=="cubic") { spline = new CubicSpline(); } else if(type=="akima") { spline = new AkimaSpline(); } else if(type=="linear") { spline = new LinSpline(); } else { throw std::runtime_error("unknown type"); } } spline->setBC(Spline::splineNormal); if (vm.count("boundaries")) { if(boundaries=="periodic") { spline->setBC(Spline::splinePeriodic); } if(boundaries=="derivativezero") { spline->setBC(Spline::splineDerivativeZero); } //default: normal } // in case fit is specified if (vm.count("fitgrid")) { Tokenizer tok(fitgrid, ":"); vector toks; tok.ToVector(toks); if(toks.size()!=3) { cout << "wrong range format in fitgrid, use min:step:max\n"; return 1; } double sp_min, sp_max, sp_step; sp_min = boost::lexical_cast(toks[0]); sp_step = boost::lexical_cast(toks[1]); sp_max = boost::lexical_cast(toks[2]); cout << "doing " << type << " fit " << sp_min << ":" << sp_step << ":" << sp_max << endl; // cut off any values out of fitgrid boundaries (exception: do nothing in case of --nocut) ub::vector x_copy; ub::vector y_copy; if (!vm.count("nocut")) { // determine vector size int minindex=-1, maxindex; for (size_t i=0; i(maxindex-minindex+1); y_copy = ub::zero_vector(maxindex-minindex+1); for (int i=minindex; i<=maxindex; i++) { x_copy(i-minindex) = in.x(i); y_copy(i-minindex) = in.y(i); } } // fitting spline->GenerateGrid(sp_min, sp_max, sp_step); try { if (vm.count("nocut")) { spline->Fit(in.x(), in.y()); } else { spline->Fit(x_copy, y_copy); } } catch (const char* message) { if(strcmp("qrsolve_zero_column_in_matrix",message)) { throw std::runtime_error("error in Linalg::linalg_qrsolve : Not enough data for fit, please adjust grid (zero row in fit matrix)"); } else if(strcmp("constrained_qrsolve_zero_column_in_matrix",message)) { throw std::runtime_error("error in Linalg::linalg_constrained_qrsolve : Not enough data for fit, please adjust grid (zero row in fit matrix)"); } else throw std::runtime_error("Unknown error in csg_resample while fitting."); } } else { // otherwise do interpolation (default = cubic) try { spline->Interpolate(in.x(), in.y()); } catch (const char* message) { if(strcmp("qrsolve_zero_column_in_matrix",message)) { throw std::runtime_error("error in Linalg::linalg_qrsolve : Not enough data, please adjust grid (zero row in fit matrix)"); } else if(strcmp("constrained_qrsolve_zero_column_in_matrix",message)) { throw std::runtime_error("error in Linalg::linalg_constrained_qrsolve : Not enough data, please adjust grid (zero row in fit matrix)"); } else throw std::runtime_error("Unknown error in csg_resample while interpolating."); } } out.GenerateGridSpacing(min, max, step); spline->Calculate(out.x(), out.y()); //store a comment line if (vm.count("comment")){ out.set_comment(comment); } out.y() = out.y(); out.flags() = ub::scalar_vector(out.flags().size(), 'o'); int i=0; for(i=0; out.x(i) < in.x(0) && i= out.x(i) || fabs(in.x(j)-out.x(i) ) < 1e-12) // fix for precison errors break; if(in.size() == j) break; out.flags(i) = in.flags(j); } out.Save(out_file); if (vm.count("derivative")) { der.GenerateGridSpacing(min, max, step); der.flags() = ub::scalar_vector(der.flags().size(), 'o'); spline->CalculateDerivative(der.x(), der.y()); der.Save(vm["derivative"].as()); } delete spline; } catch(std::exception &error) { cerr << "an error occurred:\n" << error.what() << endl; return -1; } return 0; } votca-csg-1.2.4/src/tools/csg_dump.cc0000644000175000001440000000423012400714674017371 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include using namespace std; using namespace votca::csg; class CsgDumpApp : public CsgApplication { string ProgramName() { return "csg_dump"; } void HelpText(ostream &out) { out << "Print atoms that are read from topology file to help" " debugging atom naming."; } void Initialize() { CsgApplication::Initialize(); AddProgramOptions("Specific options") ("excl", " display exclusion list instead of molecule list"); } bool EvaluateTopology(Topology *top, Topology *top_ref); bool DoMapping() {return true;} bool DoMappingDefault(void) { return false; } }; int main(int argc, char** argv) { CsgDumpApp app; return app.Exec(argc, argv); } bool CsgDumpApp::EvaluateTopology(Topology *top, Topology *top_ref) { if(!OptionsMap().count("excl")) { cout << "\nList of molecules:\n"; MoleculeContainer::iterator mol; for (mol = top->Molecules().begin(); mol != top->Molecules().end(); ++mol) { cout << "molecule: " << (*mol)->getId() + 1 << " " << (*mol)->getName() << " beads: " << (*mol)->BeadCount() << endl; for (int i = 0; i < (*mol)->BeadCount(); ++i) { cout << (*mol)->getBeadId(i) << " " << (*mol)->getBeadName(i) << " " << (*mol)->getBead(i)->getType()->getName() << endl; } } } else { cout << "\nList of exclusions:\n" << top->getExclusions(); } return true; } votca-csg-1.2.4/src/tools/csg_fmatch.h0000644000175000001440000001406512400714674017537 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _CSG_FMATCH_H #define _CSG_FMATCH_H #include #include #include #include #include #include #include using namespace votca::csg; using namespace std; /** \brief Implements force matching algorithm using cubic spline basis set * * Force matching method to obtain a coarse-grained force field is implemented * using cubic spline basis set. Block averaging over trajectory blocks * is used for calculating CG forces and their errors. * * \todo force matching needs a big cleanup! **/ class CGForceMatching : public CsgApplication { public: string ProgramName() { return "csg_fmatch"; } void HelpText(ostream &out) { out << "Perform force matching (also called multiscale coarse-graining)"; } bool DoTrajectory() {return true;} bool DoMapping() {return true;} void Initialize(void); bool EvaluateOptions(); /// \brief called before the first frame void BeginEvaluate(Topology *top, Topology *top_atom); /// \brief called after the last frame void EndEvaluate(); /// \brief called for each frame which is mapped void EvalConfiguration(Topology *conf, Topology *conf_atom = 0); /// \brief load options from the input file void LoadOptions(const string &file); protected: /// \brief structure, which contains CubicSpline object with related parameters struct SplineInfo { /// \brief constructor SplineInfo(int index, bool bonded_, int matr_pos_, Property *options); /// \brief number of spline functions int num_splinefun; /// \brief number of spline grid points int num_gridpoints; /// \brief number of grid points for output int num_outgrid; /// \brief interaction index int splineIndex; /// \brief true for bonded interactions, false for non-bonded bool bonded; /// \brief CubicSpline object CubicSpline Spline; /// \brief position in the _A matrix (first coloumn which is occupied with this particular spline) int matr_pos; /// \brief dx for output. Calculated in the code double dx_out; /// \brief only for non-bonded interactions (seems like it is not used?) pair beadTypes; /// \brief Result of 1 block calculation for f ub::vector block_res_f; /// \brief Result of 1 block calculation for f'' ub::vector block_res_f2; /// \brief Final result: average over all blocks ub::vector result; /// \brief accuracy of the final result ub::vector error; /// \brief sum of all block_res (used to calculate error) ub::vector resSum; /// \brief sum of all squares of block_res (used to calculate error) ub::vector resSum2; /// \brief Spline Name string splineName; /// \brief for non-bonded interactions: types of beads involved string type1, type2; // /// \brief pointer to Property object to hande input options Property *_options; }; /// \brief Property object to hande input options Property _options; /// \brief list of bonded interactions list _bonded; /// \brief list of non-bonded interactions list _nonbonded; typedef vector SplineContainer; /// \brief vector of SplineInfo * for all interactions SplineContainer _splines; /// \brief matrix used to store force matching equations ub::matrix _A; /// \brief vector used to store reference forces on CG beads (from atomistic simulations) ub::vector _b; /// \brief Solution of matrix equation _A * _x = _b : CG force-field parameters ub::vector _x; // /// \brief Additional matrix to handle constrained least squares fit /// contains constraints, which allow to get a real (smooth) spline (see VOTCA paper) ub::matrix _B_constr; /// \brief Counter for trajectory frames int _frame_counter; /// \brief Number of CG beads int _nbeads; /// \brief Flag: true for constrained least squares, false for simple least squares bool _constr_least_sq; /// \brief used in EvalConf to distinguish constrained and simple least squares int _least_sq_offset; /// \brief Number of frames used in one block for block averaging int _nframes; /// \brief Current number of blocks int _nblocks; /// \brief Counters for lines and coloumns in _B_constr int _line_cntr, _col_cntr; bool _has_existing_forces; /// \brief Solves FM equations for one block and stores the results for further processing void FmatchAccumulateData(); /// \brief Assigns smoothing conditions to matrices _A and _B_constr void FmatchAssignSmoothCondsToMatrix(ub::matrix &Matrix); /// \brief For each trajectory frame writes equations for bonded interactions to matrix _A void EvalBonded(Topology *conf, SplineInfo *sinfo); /// \brief For each trajectory frame writes equations for non-bonded interactions to matrix _A void EvalNonbonded(Topology *conf, SplineInfo *sinfo); /// \brief Write results to output files void WriteOutFiles(); void OpenForcesTrajectory(); Topology _top_force; TrajectoryReader *_trjreader_force; }; #endif /* _CSG_FMATCH_H */ votca-csg-1.2.4/src/tools/csg_stat_imc.h0000644000175000001440000001215712400714674020100 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _IMC_H #define _IMC_H #include #include #include #include #include #include #include #include #include #include namespace votca { namespace csg { using namespace votca::tools; /** * \brief class to calculate distribution functions and cross correlations for inverse monte carlo * * This class calculates distribution functions as well as cross-correlations for specific groups of * interactions based on a given trajectory. * */ class Imc { public: Imc(); ~Imc(); void Initialize(void); /// load cg definitions file void LoadOptions(const string &file); /// begin coarse graining a trajectory void BeginEvaluate(Topology *top, Topology *top_atom); /// end coarse graining a trajectory void EndEvaluate(); void WriteEvery(int write_every) { _write_every = write_every; } void DoBlocks(bool do_blocks) { _do_blocks = do_blocks; } void DoImc(bool do_imc) { _do_imc = do_imc; } protected: Average _avg_vol; typedef ub::matrix group_matrix; typedef ub::matrix_range< group_matrix > pair_matrix; /// struct to store collected information for interactions struct interaction_t { int _index; Property *_p; HistogramNew _average; double _min, _max, _step; double _norm; bool _is_bonded; }; // a pair of interactions which are correlated struct pair_t { interaction_t *_i1; interaction_t *_i2; int _offset_i, _offset_j; pair_matrix _corr; pair_t(interaction_t *i1, interaction_t *i2, int offset_i, int offset_j, const pair_matrix &corr); }; /// struct to store collected information for groups (e.g. crosscorrelations) struct group_t { list _interactions; group_matrix _corr; vector _pairs; }; /// the options parsed from cg definition file Property _options; // we want to write out every so many frames int _write_every; // we want do do block averaging -> clear averagings every write out bool _do_blocks; // calculate the inverse monte carlos parameters (cross correlations) bool _do_imc; // number of frames we processed int _nframes; int _nblock; /// list of bonded interactions list _bonded; /// list of non-bonded interactions list _nonbonded; /// map ineteractionm-name to interaction map _interactions; /// map group-name to group map _groups; /// create a new interaction entry based on given options interaction_t *AddInteraction(Property *p); /// get group by name, creates one if it doesn't exist group_t *getGroup(const string &name); /// initializes the group structs after interactions were added void InitializeGroups(); void WriteDist(const string &suffix=""); void WriteIMCData(const string &suffix=""); void WriteIMCBlock(const string &suffix); void CalcDeltaS(interaction_t *interaction, ub::vector_range< ub::vector > &dS); void ClearAverages(); class Worker : public CsgApplication::Worker { public: vector _current_hists; Imc *_imc; double _cur_vol; /// evaluate current conformation void EvalConfiguration(Topology *top, Topology *top_atom); /// process non-bonded interactions for given frame void DoNonbonded(Topology *top); /// process bonded interactions for given frame void DoBonded(Topology *top); }; /// update the correlations after interations were processed void DoCorrelations(Imc::Worker *worker); bool _processed_some_frames; public: CsgApplication::Worker *ForkWorker(); void MergeWorker(CsgApplication::Worker *worker); }; inline Imc::pair_t::pair_t(Imc::interaction_t *i1, Imc::interaction_t *i2, int offset_i, int offset_j, const pair_matrix &corr) : _i1(i1), _i2(i2), _offset_i(offset_i), _offset_j(offset_j), _corr(corr) {} }} #endif /* _IMC_H */ votca-csg-1.2.4/src/tools/csg_density.cc0000644000175000001440000001644212400714674020113 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include using namespace std; using namespace votca::csg; using namespace votca::tools; class CsgDensityApp : public CsgApplication { string ProgramName() { return "csg_density"; } void HelpText(ostream &out) { out << "Calculates the mass density distribution along a box axis or radial density profile from reference point"; } // some program options are added here void Initialize(); // we want to process a trajectory bool DoTrajectory() {return true;} bool DoMapping() {return true;} bool DoMappingDefault(void) { return false; } // write out results in EndEvaluate void EndEvaluate(); void BeginEvaluate(Topology *top, Topology *top_atom); void EvalConfiguration(Topology *top, Topology *top_ref); bool EvaluateOptions() { CsgApplication::EvaluateOptions(); CheckRequired("out", "no output topology specified"); CheckRequired("trj", "no trajectory file specified"); return true; }; protected: string _filter, _out; HistogramNew _dist; double _rmax; int _nbin; double _scale; int _frames; vec _ref; vec _axis; string _axisname; string _molname; double _area; }; int main(int argc, char** argv) { CsgDensityApp app; return app.Exec(argc, argv); } void CsgDensityApp::BeginEvaluate(Topology *top, Topology *top_atom) { matrix box = top->getBox(); vec a = box.getCol(0); vec b = box.getCol(1); vec c = box.getCol(2); _dist.setPeriodic(true); _axis=vec(0,0,0); _area=0; if(_axisname=="x") { _axis.setX(1); _rmax = abs(a); _area= abs(b^c); } else if(_axisname=="y") { _axis.setY(1); _rmax = abs(b); _area= abs(a^c); } else if(_axisname=="z") { _axis.setZ(1); _rmax = abs(c); _area= abs(a^b); } else if(_axisname=="r") { _dist.setPeriodic(false); _rmax = min(min(abs(a/2), abs(b/2)), abs(c/2)); } else { throw std::runtime_error("unknown axis type"); } if(OptionsMap().count("rmax")) _rmax = OptionsMap()["rmax"].as(); if (_axisname=="r") { if(!OptionsMap().count("ref")) _ref = a/2+b/2+c/2; cout << "Using referece point: " << _ref << endl; } else if(OptionsMap().count("ref")) throw std::runtime_error("reference center can only be used in case of spherical density"); _dist.Initialize(0, _rmax, _nbin); cout << "rmax: " << _rmax << endl; cout << "axis: " << _axisname << endl; cout << "Bins: " << _nbin << endl; _frames=0; } void CsgDensityApp::EvalConfiguration(Topology *top, Topology *top_ref) { // loop over all molecules bool did_something = false; for(MoleculeContainer::iterator imol=top->Molecules().begin(); imol!=top->Molecules().end(); ++imol) { Molecule *mol = *imol; if(!wildcmp(_molname.c_str(),mol->getName().c_str())) continue; int N = mol->BeadCount(); for(int i=0; igetBead(i); if(!wildcmp(_filter.c_str(), b->getName().c_str())) continue; double r; if (_axisname=="r") { r = abs(top->BCShortestConnection(_ref, b->getPos())); } else { r = b->getPos() * _axis; } _dist.Process(r, b->getM()); did_something = true; } } _frames++; if (!did_something) throw std::runtime_error("No molecule in selection"); } // output everything when processing frames is done void CsgDensityApp::EndEvaluate() { if (_axisname=="r") { _dist.data().y() = _scale/(_frames*_rmax/(double)_nbin *4*M_PI) * element_div( _dist.data().y(), element_prod(_dist.data().x(), _dist.data().x())); } else { _dist.data().y() = _scale/((double)_frames * _area * _rmax/ (double)_nbin ) *_dist.data().y(); } _dist.data().Save(_out); } // add our user program options void CsgDensityApp::Initialize() { CsgApplication::Initialize(); // add program option to pick molecule AddProgramOptions("Specific options:") ("axis", boost::program_options::value(&_axisname)->default_value("r"), "[x|y|z|r] density axis (r=spherical)") ("bins", boost::program_options::value(&_nbin)->default_value(50), "bins") ("out", boost::program_options::value(&_out), "Output file") ("rmax", boost::program_options::value(), "rmax (default for [r] =min of all box vectors/2, else l )") ("scale", boost::program_options::value(&_scale)->default_value(1.0), "scale factor for the density") ("molname", boost::program_options::value(&_molname)->default_value("*"), "molname") ("filter", boost::program_options::value(&_filter)->default_value("*"), "filter bead names") ("ref", boost::program_options::value(&_ref), "reference zero point"); } votca-csg-1.2.4/src/tools/csg_fmatch.cc0000644000175000001440000004467312400714674017705 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include #include #include #include "csg_fmatch.h" #include #include int main(int argc, char** argv) { CGForceMatching app; return app.Exec(argc, argv); } void CGForceMatching::Initialize(void) { CsgApplication::Initialize(); AddProgramOptions() ("options", boost::program_options::value(), " options file for coarse graining") ("trj-force", boost::program_options::value(), " coarse-grained trajectory containing forces of already known interactions"); } bool CGForceMatching::EvaluateOptions() { CsgApplication::EvaluateOptions(); CheckRequired("trj", "no trajectory file specified"); CheckRequired("options", "need to specify options file"); LoadOptions(OptionsMap()["options"].as()); _has_existing_forces = false; if(OptionsMap().count("trj-force")) _has_existing_forces = true; return true; } void CGForceMatching::BeginEvaluate(Topology *top, Topology *top_atom) { // set counters to zero value: _nblocks = 0; _line_cntr = _col_cntr = 0; // Number of CG beads in topology _nbeads = top->BeadCount(); // Set frame counter to zero _frame_counter = 0; // read _nframes from input file _nframes = _options.get("cg.fmatch.frames_per_block").as(); // read _constr_least_sq from input file _constr_least_sq = _options.get("cg.fmatch.constrainedLS").as(); // initializing bonded interactions for (list::iterator iter = _bonded.begin(); iter != _bonded.end(); ++iter) { SplineInfo *i = new SplineInfo(_splines.size(), true, _col_cntr, *iter); //adjust initial matrix dimensions: _line_cntr += i->num_gridpoints; _col_cntr += 2 * i->num_gridpoints; // add spline to container _splines.push_back(i); } // initializing non-bonded interactions for (list::iterator iter = _nonbonded.begin(); iter != _nonbonded.end(); ++iter) { SplineInfo *i = new SplineInfo(_splines.size(), false, _col_cntr, *iter); //adjust initial matrix dimensions: _line_cntr += i->num_gridpoints; _col_cntr += 2 * i->num_gridpoints; // add spline to container _splines.push_back(i); } cout << "\nYou are using VOTCA!\n"; cout << "\nhey, somebody wants to forcematch!\n"; // now initialize _A, _b, _x and probably _B_constr // depending on least-squares algorithm used if (_constr_least_sq) { // Constrained Least Squares cout << "\nUsing constrained Least Squares!\n " << endl; // assign _least_sq_offset _least_sq_offset = 0; // resize and clear _B_constr _B_constr.resize(_line_cntr, _col_cntr, false); _B_constr.clear(); // resize matrix _A _A.resize(3 * _nbeads *_nframes, _col_cntr, false); // resize vector _b _b.resize(3 * _nbeads *_nframes, false); // in case of constrained least squares smoothing conditions // are assigned to matrix _B_constr FmatchAssignSmoothCondsToMatrix(_B_constr); } else { // Simple Least Squares cout << "\nUsing simple Least Squares! " << endl; // assign _least_sq_offset _least_sq_offset = _line_cntr; // resize matrix _A _A.resize(_line_cntr + 3 * _nbeads *_nframes, _col_cntr, false); // resize vector _b _b.resize(_line_cntr + 3 * _nbeads *_nframes, false); // in case of simple least squares smoothing conditions // are assigned to matrix _A FmatchAssignSmoothCondsToMatrix(_A); // clear _b (only necessary in simple least squares) _b.clear(); } // resize and clear _x _x.resize(_col_cntr); _x.clear(); if(_has_existing_forces) { _top_force.CopyTopologyData(top); _trjreader_force = TrjReaderFactory().Create(_op_vm["trj-force"].as()); if(_trjreader_force == NULL) throw runtime_error(string("input format not supported: ") + _op_vm["trj-force"].as()); // open the trajectory _trjreader_force->Open(_op_vm["trj-force"].as()); // read in first frame _trjreader_force->FirstFrame(_top_force); } } CGForceMatching::SplineInfo::SplineInfo(int index, bool bonded_, int matr_pos_, Property *options) { // initialize standard data splineIndex = index; _options = options; splineName = options->get("name").value(); bonded = bonded_; // get non-bonded information if (!bonded) { type1 = options->get("type1").value(); type2 = options->get("type2").value(); } // initialize the grid double grid_min = options->get("fmatch.min").as(); double grid_max = options->get("fmatch.max").as(); double grid_step = options->get("fmatch.step").as(); // GenerateGrid returns number of grid points. We subtract 1 to get // the number of spline functions num_gridpoints = Spline.GenerateGrid(grid_min, grid_max, grid_step); num_splinefun = num_gridpoints - 1; cout << "Number of spline functions for the interaction " << splineName << ":" << num_splinefun << endl; matr_pos = matr_pos_; // initialize grid for block averaging dx_out = options->get("fmatch.out_step").as(); // number of output grid points num_outgrid = 1 + (int)((grid_max-grid_min)/dx_out); result.resize(num_outgrid, false); result.clear(); error.resize(num_outgrid, false); error.clear(); resSum.resize(num_outgrid, false); resSum.clear(); resSum2.resize(num_outgrid, false); resSum2.clear(); block_res_f.resize(num_gridpoints, false); block_res_f2.resize(num_gridpoints, false); } void CGForceMatching::EndEvaluate() { cout << "\nWe are done, thank you very much!" << endl; if(_has_existing_forces) { _trjreader_force->Close(); delete _trjreader_force; } } void CGForceMatching::WriteOutFiles() { // sanity check if (_nblocks == 0) { cerr << "\nERROR in csg_fmatch::EndCG - No blocks have been processed so far" << endl; cerr << "It might be that you are using trajectory, which is smaller than needed for one block" << endl; cerr << "Check your input!" << endl; exit(-1); } string file_extension = ".force"; string file_name; Table force_tab; // table with error column force_tab.SetHasYErr(true); SplineContainer::iterator is; for (is = _splines.begin(); is != _splines.end(); ++is) { // construct meaningful outfile name file_name = (*is)->splineName; file_name = file_name + file_extension; // resize table force_tab.resize((*is)->num_outgrid, false); // print output file names on stdout cout << "Updating file: " << file_name << endl; // loop over output grid points for (int i = 0; i < (*is)->num_outgrid; i++) { // average value (*is)->result[i] = (*is)->resSum[i] / _nblocks; // standard deviation of the average (*is)->error[i] = sqrt( ((*is)->resSum2[i] / _nblocks - (*is)->result[i] * (*is)->result[i])/_nblocks ); } // first output point = first grid point double out_x = (*is)->Spline.getGridPoint(0); // loop over output grid for (int i = 0; i < (*is)->num_outgrid; i++) { // put point, result, flag and accuracy at point out_x into the table force_tab.set(i, out_x, (-1.0) * (*is)->result[i], 'i', (*is)->error[i]); // update out_x for the next iteration out_x += (*is)->dx_out; } // save table in the file force_tab.Save(file_name); // clear the table for the next spline force_tab.clear(); } } void CGForceMatching::EvalConfiguration(Topology *conf, Topology *conf_atom) { SplineContainer::iterator spiter; if(_has_existing_forces) { if(conf->BeadCount() != _top_force.BeadCount()) throw std::runtime_error("number of beads in topology and force topology does not match"); for(int i=0; iBeadCount(); ++i) { conf->getBead(i)->F() -= _top_force.getBead(i)->getF(); vec d = conf->getBead(i)->getPos() - _top_force.getBead(i)->getPos(); if(abs(d) > 1e-6) throw std::runtime_error("One or more bead positions in mapped and reference force trajectory differ by more than 1e-6"); } } for (spiter = _splines.begin(); spiter != _splines.end(); ++spiter) { SplineInfo *sinfo = *spiter; if (sinfo->bonded) // bonded interaction EvalBonded(conf, sinfo); else // non-bonded interaction EvalNonbonded(conf, sinfo); } // loop for the forces vector: // hack, chage the Has functions.. if (conf->getBead(0)->HasF()) { vec Force(0., 0., 0.); for (int iatom = 0; iatom < _nbeads; ++iatom) { Force = conf->getBead(iatom)->getF(); _b(_least_sq_offset + 3 * _nbeads * _frame_counter + iatom) = Force.x(); _b(_least_sq_offset + 3 * _nbeads * _frame_counter + _nbeads + iatom) = Force.y(); _b(_least_sq_offset + 3 * _nbeads * _frame_counter + 2 * _nbeads + iatom) = Force.z(); } } else { cerr << "\nERROR in csg_fmatch::EvalConfiguration - No forces in configuration!\n" << endl; exit(-1); } // update the frame counter _frame_counter += 1; if (_frame_counter % _nframes == 0) { // at this point we processed _nframes frames, which is enough for one block // update block counter _nblocks++; // solve FM equations and accumulate the result FmatchAccumulateData(); // print status information cout << "\nBlock No" << _nblocks << " done!" << endl; // write results to output files WriteOutFiles(); // we must count frames from zero again for the next block _frame_counter = 0; if (_constr_least_sq) { //Constrained Least Squares // Matrices should be cleaned after each block is evaluated _A.clear(); _b.clear(); // clear and assign smoothing conditions to _B_constr FmatchAssignSmoothCondsToMatrix(_B_constr); } else { // Simple Least Squares // Matrices should be cleaned after each block is evaluated // clear and assign smoothing conditions to _A FmatchAssignSmoothCondsToMatrix(_A); _b.clear(); } } if(_has_existing_forces) _trjreader_force->NextFrame(_top_force); } void CGForceMatching::FmatchAccumulateData() { _x.clear(); if (_constr_least_sq) { // Constrained Least Squares // Solving linear equations system ub::matrix B_constr = _B_constr; votca::tools::linalg_constrained_qrsolve(_x, _A, _b, B_constr); _x = -_x; } else { // Simple Least Squares ub::vector residual(_b.size()); votca::tools::linalg_qrsolve(_x, _A, _b, &residual); // calculate FM residual - quality of FM // FM residual is initially calculated in (kJ/(mol*nm))^2 double fm_resid = 0; for (size_t i = 0; i < _b.size(); i++) fm_resid += residual(i) * residual(i); // strange number is units conversion -> now (kcal/(mol*angstrom))^2 fm_resid /= 3 * _nbeads * _frame_counter * 1750.5856; cout << endl; cout << "#### Force matching residual ####" << endl; cout << " Chi_2 = " << fm_resid << endl; cout << "#################################" << endl; cout << endl; } SplineContainer::iterator is; for (is = _splines.begin(); is != _splines.end(); ++is) { int &mp = (*is)->matr_pos; int &ngp = (*is)->num_gridpoints; // _x contains results for all splines. Here we cut the results for one spline for (int i = 0; i < ngp; i++) { (*is)->block_res_f[i] = _x[ i + mp ]; (*is)->block_res_f2[i] = _x[ i + mp + ngp]; } // result cutted before is assigned to the corresponding spline (*is)->Spline.setSplineData((*is)->block_res_f, (*is)->block_res_f2); // first output point = first grid point double out_x = (*is)->Spline.getGridPoint(0); // point in the middle of the output grid for printing debug information int grid_point_debug = (*is)->num_outgrid / 2; // loop over output grid for (int i = 0; i < (*is)->num_outgrid; i++) { // update resSum (add result of a particular block) (*is)->resSum[i] += (*is)->Spline.Calculate(out_x); // print useful debug information if (i == grid_point_debug) cout << "This should be a number: " << (*is)->Spline.Calculate(out_x) << " " << endl; // update resSum2 (add result of a particular block) (*is)->resSum2[i] += (*is)->Spline.Calculate(out_x) * (*is)->Spline.Calculate(out_x); // output point for the next iteration out_x += (*is)->dx_out; } } } void CGForceMatching::FmatchAssignSmoothCondsToMatrix(ub::matrix &Matrix) { // This function assigns Spline smoothing conditions to the Matrix. // For the simple least squares the function is used for matrix _A // For constrained least squares - for matrix _B_constr int line_tmp, col_tmp; line_tmp = 0; col_tmp = 0; Matrix.clear(); SplineContainer::iterator is; for (is = _splines.begin(); is != _splines.end(); ++is) { int sfnum = (*is)->num_splinefun; (*is)->Spline.AddBCToFitMatrix(Matrix, line_tmp, col_tmp); // update counters line_tmp += sfnum + 1; col_tmp += 2 * (sfnum + 1); } } void CGForceMatching::LoadOptions(const string &file) { load_property_from_xml(_options, file); _bonded = _options.Select("cg.bonded"); _nonbonded = _options.Select("cg.non-bonded"); } void CGForceMatching::EvalBonded(Topology *conf, SplineInfo *sinfo) { std::list interList; std::list::iterator interListIter; interList = conf->InteractionsInGroup(sinfo->splineName); for (interListIter = interList.begin(); interListIter != interList.end(); ++interListIter) { int beads_in_int = (*interListIter)->BeadCount(); // 2 for bonds, 3 for angles, 4 for dihedrals CubicSpline &SP = sinfo->Spline; int &mpos = sinfo->matr_pos; double var = (*interListIter)->EvaluateVar(*conf); // value of bond, angle, or dihedral for (int loop = 0; loop < beads_in_int; loop++) { int ii = (*interListIter)->getBeadId(loop); vec gradient = (*interListIter)->Grad(*conf, loop); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + ii, mpos, -gradient.x()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + _nbeads + ii, mpos, -gradient.y()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + 2 * _nbeads + ii, mpos, -gradient.z()); } } } void CGForceMatching::EvalNonbonded(Topology *conf, SplineInfo *sinfo) { // generate the neighbour list // generate the neighbour list NBList *nb; bool gridsearch=false; if(_options.exists("cg.nbsearch")) { if(_options.get("cg.nbsearch").as() == "grid") gridsearch=true; else if(_options.get("cg.nbsearch").as() == "simple") gridsearch=false; else throw std::runtime_error("cg.nbsearch invalid, can be grid or simple"); } if(gridsearch) nb = new NBListGrid(); else nb = new NBList(); nb->setCutoff(sinfo->_options->get("fmatch.max").as()); // implement different cutoffs for different interactions! // generate the bead lists BeadList beads1, beads2; beads1.Generate(*conf, sinfo->type1); beads2.Generate(*conf, sinfo->type2); // is it same types or different types? if (sinfo->type1 == sinfo->type2) nb->Generate(beads1, true); else nb->Generate(beads1, beads2, true); NBList::iterator pair_iter; // iterate over all pairs for (pair_iter = nb->begin(); pair_iter != nb->end(); ++pair_iter) { int iatom = (*pair_iter)->first->getId(); int jatom = (*pair_iter)->second->getId(); double var = (*pair_iter)->dist(); vec gradient = (*pair_iter)->r(); gradient.normalize(); CubicSpline &SP = sinfo->Spline; int &mpos = sinfo->matr_pos; // add iatom SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + iatom, mpos, gradient.x()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + _nbeads + iatom, mpos, gradient.y()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + 2 * _nbeads + iatom, mpos, gradient.z()); // add jatom SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + jatom, mpos, -gradient.x()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + _nbeads + jatom, mpos, -gradient.y()); SP.AddToFitMatrix(_A, var, _least_sq_offset + 3 * _nbeads * _frame_counter + 2 * _nbeads + jatom, mpos, -gradient.z()); } delete nb; } votca-csg-1.2.4/src/tools/csg_part_dist.cc0000644000175000001440000002417112400714674020423 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include using namespace std; namespace po = boost::program_options; using namespace votca::csg; using namespace votca::tools; /** * *** Analyze particle distribution as a function of a coordinate *** * * This program reads a topology and (set of) trajectory(ies). For every * binned value of a chose coordinate, it outputs the time-averaged number of * particles, listed by particle types. */ void help_text(void) { votca::csg::HelpTextHeader("csg_part_dist"); cout << "This program reads a topology and (set of) trajectory(ies). For every\n" "binned value of a chosen coordinate, it outputs the time-averaged number of\n" "particles, listed by particle types.\n\n"; } void check_option(po::options_description &desc, po::variables_map &vm, const string &option) { if(!vm.count(option)) { cout << "csg_part_dist \n\n"; cout << desc << endl << "parameter " << option << " is not specified\n"; exit(1); } } int main(int argc, char** argv) { string top_file, trj_file, ptypes_file, out_file, grid, comment, string_tmp, coordinate="z"; double min, max, step, coord, com(0.); vector ptypes; ifstream fl_ptypes; ofstream fl_out; Topology top; TopologyReader *reader; TrajectoryReader *trajreader; int part_type, n_bins, first_frame(0), last_frame(-1), flag_found(0), **p_occ = NULL, n_part(0), frame_id(0), analyzed_frames(0); bool moreframes(1), not_the_last(1); MoleculeContainer::iterator mol; // Load topology+trajectory formats TopologyReader::RegisterPlugins(); TrajectoryReader::RegisterPlugins(); // read program options namespace po = boost::program_options; // Declare the supported options. po::options_description desc("Allowed options"); // let cg_engine add some program options desc.add_options() ("top", po::value(&top_file), "topology file") ("trj", po::value(&trj_file), "trajectory file") ("grid", po::value(&grid), "output grid spacing (min:step:max)") ("out", po::value(&out_file), "output particle distribution table") ("ptypes", po::value(&ptypes_file), "particle types to include in the analysis\n" " arg: file - particle types separated by space" "\n default: all particle types") ("first_frame", po::value(&first_frame), "first frame considered for analysis") ("last_frame", po::value(&last_frame), "last frame considered for analysis") ("coord", po::value(&coordinate), "coordinate analyzed ('x', 'y', or 'z' (default))") ("shift_com", "shift center of mass to zero") ("comment", po::value(&comment), "store a comment in the output table") ("help", "produce this help message"); // now read in the command line po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); } catch(po::error err) { cout << "error parsing command line: " << err.what() << endl; return -1; } // does the user want help? if (vm.count("help")) { help_text(); cout << desc << endl; return 0; } check_option(desc, vm, "top"); check_option(desc, vm, "trj"); check_option(desc, vm, "out"); check_option(desc, vm, "grid"); if (coordinate.compare("x") != 0 && coordinate.compare("y") != 0 && coordinate.compare("z") != 0) { cout << "Bad format for coordinate: " << coordinate << endl; return 1; } // Parse grid Tokenizer tok(grid, ":"); vector toks; tok.ToVector(toks); if(toks.size()!=3) { cout << "Wrong range format, use min:step:max\n"; return 1; } min = boost::lexical_cast(toks[0]); step = boost::lexical_cast(toks[1]); max = boost::lexical_cast(toks[2]); // Calculate number of bins n_bins = (int)((max-min)/(1.*step)+1); try { // Load topology reader = TopReaderFactory().Create(vm["top"].as()); if(reader == NULL) throw std::runtime_error("input format not supported: " + vm["top"].as()); reader->ReadTopology(vm["top"].as(), top); // Read the particle types file and save to variable ptypes if(vm.count("ptypes")) { fl_ptypes.open(vm["ptypes"].as().c_str()); if(!fl_ptypes.is_open()) throw std::runtime_error("can't open " + vm["ptypes"].as()); // build the list of particle types if(fl_ptypes.eof()) throw std::runtime_error("file " + vm["ptypes"].as() + " is empty"); while (!fl_ptypes.eof()) { // Not very elegant, but makes sure we don't count the same element twice string_tmp = "__"; fl_ptypes >> string_tmp; if (string_tmp != "" && string_tmp != "__") { ptypes.push_back(atoi(string_tmp.c_str())); } } fl_ptypes.close(); } else { // Include all particle types for(mol=top.Molecules().begin(); mol!=top.Molecules().end();++mol) { for(int i=0; i<(*mol)->BeadCount(); ++i) { flag_found = 0; part_type = atoi((*mol)->getBead(i)->getType()->getName().c_str()); for (size_t j=0; j < ptypes.size(); ++j) { if (part_type == ptypes[j]) flag_found = 1; } if (!flag_found) ptypes.push_back(part_type); } } } // Allocate array used to store particle occupancy p_occ p_occ = (int**) calloc(ptypes.size(),sizeof(int*)); for (size_t i=0; i < ptypes.size(); ++i) p_occ[i] = (int*) calloc(n_bins,sizeof(int)); // If we need to shift the center of mass, calculate the number of // particles (only the ones that belong to the particle type index // ptypes) if (vm.count("shift_com")) { for(mol=top.Molecules().begin(); mol!=top.Molecules().end();++mol) { for(int i=0; i<(*mol)->BeadCount(); ++i) { part_type = atoi((*mol)->getBead(i)->getType()->getName().c_str()); for (size_t j=0; j < ptypes.size(); ++j) if (part_type == ptypes[j]) ++n_part; } } } // Now load trajectory trajreader = TrjReaderFactory().Create(vm["trj"].as()); if(trajreader == NULL) throw std::runtime_error("input format not supported: " + vm["trj"].as()); trajreader->Open(vm["trj"].as()); // Read the trajectory. Analyze each frame to obtain // particle occupancy as a function of coordinate z. while (moreframes) { // Read frame if (frame_id == 0) moreframes = trajreader->FirstFrame(top); else moreframes = trajreader->NextFrame(top); // Was this the last frame we read? if (last_frame == -1) not_the_last = 1; else { if (frame_id <= last_frame) not_the_last = 1; else not_the_last = 0; } // Calculate new center of mass position in the direction of 'coordinate' com = 0.; if (vm.count("shift_com")) { for(mol=top.Molecules().begin(); mol!=top.Molecules().end();++mol) { for(int i=0; i<(*mol)->BeadCount(); ++i) { part_type = atoi((*mol)->getBead(i)->getType()->getName().c_str()); for (size_t j=0; j < ptypes.size(); ++j) { if (part_type == ptypes[j]) { if (coordinate.compare("x") == 0) { com += (*mol)->getBead(i)->getPos().getX(); } else if (coordinate.compare("y") == 0) { com += (*mol)->getBead(i)->getPos().getY(); } else { com += (*mol)->getBead(i)->getPos().getZ(); } } } } } com /= n_part; } // Analyze frame if (moreframes && frame_id >= first_frame && not_the_last) { ++analyzed_frames; // Loop over each atom property for(mol=top.Molecules().begin(); mol!=top.Molecules().end();++mol) { for(int i=0; i<(*mol)->BeadCount(); ++i) { part_type = atoi((*mol)->getBead(i)->getType()->getName().c_str()); for (size_t j=0; j < ptypes.size(); ++j) { if (part_type == ptypes[j]) { if (coordinate.compare("x") == 0) coord = (*mol)->getBead(i)->getPos().getX(); else if (coordinate.compare("y") == 0) coord = (*mol)->getBead(i)->getPos().getY(); else coord = (*mol)->getBead(i)->getPos().getZ(); if (coord-com > min && coord-com < max) ++p_occ[j][(int)floor((coord-com-min)/step)]; } } } } } ++frame_id; } trajreader->Close(); } catch(std::exception &error) { cerr << "An error occured!" << endl << error.what() << endl; } // Output particle occupancy try { fl_out.open(vm["out"].as().c_str()); if(!fl_out.is_open()) throw std::runtime_error("can't open " + vm["out"].as()); fl_out << "#z\t" << flush; for (size_t i=0; i < ptypes.size(); ++i) fl_out << "type " << ptypes[i] << "\t" << flush; fl_out << endl; for (int k=0; k < n_bins; ++k) { fl_out << min+k*step << "\t" << flush; for (size_t j=0; j < ptypes.size(); ++j) { if (p_occ[j][k] == 0) fl_out << 0 << "\t" << flush; else fl_out << p_occ[j][k]/(1.*analyzed_frames) << "\t" << flush; } fl_out << endl; } fl_out.close(); } catch(std::exception &error) { cerr << "An error occured!" << endl << error.what() << endl; } for (size_t i=0; i < ptypes.size(); ++i) free(p_occ[i]); free(p_occ); cout << "The table was written to " << vm["out"].as() << endl; return 0; } votca-csg-1.2.4/src/tools/csg_gmxtopol.cc0000644000175000001440000000761512400714674020307 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include using namespace votca::csg; using namespace std; using boost::format; class GmxTopolApp : public CsgApplication { public: string ProgramName() { return "csg_gmxtopol"; } void HelpText(ostream &out) { out << "Create skeleton for gromacs topology based on atomistic topology\n" "and a mapping file. File still needs to be modified by the user."; } bool DoMapping(void) { return true; } void Initialize(void); bool EvaluateOptions(void) { CsgApplication::EvaluateOptions(); CheckRequired("out", "no output topology specified"); return true; } bool EvaluateTopology(Topology *top, Topology *top_ref); protected: void WriteAtoms(ostream &out, Molecule &cg); void WriteInteractions(ostream &out, Molecule &cg); void WriteMolecule(ostream &out, Molecule &cg); }; void GmxTopolApp::Initialize(void) { CsgApplication::Initialize(); AddProgramOptions() ("out", boost::program_options::value(), "output topology (will create .top and in future also .itp)"); } bool GmxTopolApp::EvaluateTopology(Topology *top, Topology *top_ref) { if(top->MoleculeCount() > 1) cout << "WARNING: cannot create topology for topology with" "multiple molecules, using only first molecule\n"; ofstream fl; fl.open((OptionsMap()["out"].as() + ".top").c_str()); WriteMolecule(fl, *(top->MoleculeByIndex(0))); fl.close(); return true; } void GmxTopolApp::WriteAtoms(ostream &out, Molecule &cg) { out << "[atoms]\n"; out << "; nr type resnr residue atom cgnr charge mass\n"; for(int i=0; igetType()->getName() % b->getName() % (i+1) % b->getQ() % b->getM(); } out << endl; } void GmxTopolApp::WriteInteractions(ostream &out, Molecule &cg) { int nb=-1; Interaction *ic; vector::iterator iter; InteractionContainer &ics=cg.getParent()->BondedInteractions(); for(iter=ics.begin(); iter!=ics.end(); ++iter) { ic = *iter; if(ic->getMolecule() != cg.getId()) continue; if(nb != ic->BeadCount()) { nb=ic->BeadCount(); switch(nb) { case 2: out << "\n[ bonds ]\n"; break; case 3: out << "\n[ angles ]\n"; break; case 4: out << "\n[ dihedrals ]\n"; break; default: throw runtime_error(string("cannot handle number of beads in interaction:") + ic->getName()); } } for(int i=0; igetBeadId(i)+1 << " "; out << " 1 ; " << ic->getName() << endl; } } void GmxTopolApp::WriteMolecule(ostream &out, Molecule &cg) { out << "[ moleculetype ]\n"; out << cg.getName() << " 3\n\n"; WriteAtoms(out, cg); WriteInteractions(out, cg); } int main(int argc, char** argv) { GmxTopolApp app; return app.Exec(argc, argv); } votca-csg-1.2.4/src/tools/csg_property.cc0000644000175000001440000000770712400714674020324 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include using namespace std; using namespace votca::csg; using namespace votca::tools; void help_text() { votca::csg::HelpTextHeader("csg_property"); cout << "Helper program called by inverse scripts to parse xml file.\n\n"; } int main(int argc, char** argv) { string filter, file, path, print; bool short_output = false; bool with_path = false; // lets read in some program options namespace po = boost::program_options; // Declare the supported options. po::options_description desc("Allowed options"); desc.add_options() ("help", "produce this help message") //("values", po::value(&filter)->default_value(""), // "list option values that match given criteria") ("path", po::value(&path)->default_value(""), "list option values that match given criteria") ("filter", po::value(&filter)->default_value(""), "list option values that match given criteria") ("print", po::value(&print)->default_value(". "), "list option values that match given criteria") ("file", po::value(&file), "xml file to parse") ("short", "short version of output") ("with-path", "include path of node in output"); // now read in the command line po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); } catch(po::error err) { cout << "error parsing command line: " << err.what() << endl; return -1; } // does the user want help? if (vm.count("help")) { help_text(); cout << desc << endl; return 0; } // file specified if (!vm.count("file")) { cout << "please specify file\n"; cout << desc << endl; return -1; } if(vm.count("short")) short_output = true; if(vm.count("with-path")) with_path = true; try { Property p; load_property_from_xml(p, file); list sel = p.Select(path); for(list::iterator iter = sel.begin(); iter!=sel.end(); ++iter) { if(filter!="") { Tokenizer tokenizer(filter, "="); Tokenizer::iterator tok; tok = tokenizer.begin(); if(tok == tokenizer.end()) throw std::invalid_argument("error, specified invalid filgter"); string field = *tok; ++tok; if(tok == tokenizer.end()) throw std::invalid_argument("error, specified invalid filgter"); string value = *tok; if(!wildcmp(value.c_str(), (*iter)->get(field).value().c_str())) continue; } Property *p=&((*iter)->get(print)); if(!short_output && with_path) cout << p->path() << "."; if(!short_output) cout << p->name() << " = "; if(!p->HasChilds()) cout << p->value(); cout << endl; } } catch(std::exception &error) { cerr << "an error occurred:\n" << error.what() << endl; return -1; } return 0; } votca-csg-1.2.4/src/csg_boltzmann/0000755000175000001440000000000012400714673016761 5ustar christophusersvotca-csg-1.2.4/src/csg_boltzmann/Makefile_nb0000644000175000001440000000433512400714673021105 0ustar christophusers# # There exist several targets which are by default empty and which can be # used for execution of your targets. These targets are usually executed # before and after some main targets. They are: # # .build-pre: called before 'build' target # .build-post: called after 'build' target # .clean-pre: called before 'clean' target # .clean-post: called after 'clean' target # .clobber-pre: called before 'clobber' target # .clobber-post: called after 'clobber' target # .all-pre: called before 'all' target # .all-post: called after 'all' target # .help-pre: called before 'help' target # .help-post: called after 'help' target # # Targets beginning with '.' are not intended to be called on their own. # # Main targets can be executed directly, and they are: # # build build a specific configuration # clean remove built files from a configuration # clobber remove all built files # all build all configurations # help print help mesage # # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and # .help-impl are implemented in nbproject/makefile-impl.mk. # # NOCDDL # Environment MKDIR=mkdir CP=cp CCADMIN=CCadmin RANLIB=ranlib # build build: .build-pre .build-impl .build-post .build-pre: # Add your pre 'build' code here... .build-post: # Add your post 'build' code here... # clean clean: .clean-pre .clean-impl .clean-post .clean-pre: # Add your pre 'clean' code here... .clean-post: # Add your post 'clean' code here... # clobber clobber: .clobber-pre .clobber-impl .clobber-post .clobber-pre: # Add your pre 'clobber' code here... .clobber-post: # Add your post 'clobber' code here... # all all: .all-pre .all-impl .all-post .all-pre: # Add your pre 'all' code here... .all-post: # Add your post 'all' code here... # help help: .help-pre .help-impl .help-post .help-pre: # Add your pre 'help' code here... .help-post: # Add your post 'help' code here... # include project implementation makefile include nbproject/Makefile-impl.mk votca-csg-1.2.4/src/csg_boltzmann/CMakeLists.txt0000644000175000001440000000167412400714673021531 0ustar christophusersfile(GLOB CSG_BO_SOURCES *.cc) add_executable(csg_boltzmann ${CSG_BO_SOURCES}) target_link_libraries(csg_boltzmann votca_csg) install(TARGETS csg_boltzmann RUNTIME DESTINATION bin) if (TXT2TAGS_FOUND AND BASH) add_custom_command(OUTPUT csg_boltzmann.man COMMAND ${CMAKE_CURRENT_BINARY_DIR}/csg_boltzmann --help > csg_boltzmann.help DEPENDS csg_boltzmann COMMAND ${BASH} ${CMAKE_BINARY_DIR}/scripts/help2t2t csg_boltzmann.help > csg_boltzmann.t2t COMMAND ${TXT2TAGS_EXECUTABLE} -q -t man -i csg_boltzmann.t2t -o csg_boltzmann.man DEPENDS scripts/help2t2t csg_boltzmann) add_custom_target(csg_boltzmann_manpage DEPENDS csg_boltzmann.man) add_dependencies(manpages csg_boltzmann_manpage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/csg_boltzmann.man DESTINATION ${MAN}/man1 RENAME csg_boltzmann.1) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES csg_boltzmann.help csg_boltzmann.t2t) endif(TXT2TAGS_FOUND AND BASH) votca-csg-1.2.4/src/csg_boltzmann/bondedstatistics.cc0000644000175000001440000000266012400714673022642 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include "bondedstatistics.h" void BondedStatistics::BeginCG(Topology *top, Topology *top_atom) { InteractionContainer &ic = top->BondedInteractions(); InteractionContainer::iterator ia; _bonded_values.clear(); for(ia=ic.begin(); ia!=ic.end(); ++ia) { _bonded_values.CreateArray((*ia)->getName()); } } void BondedStatistics::EndCG() { } void BondedStatistics::EvalConfiguration(Topology *conf, Topology *conv_atom) { InteractionContainer &ic = conf->BondedInteractions(); InteractionContainer::iterator ia; DataCollection::container::iterator is; for(ia=ic.begin(), is = _bonded_values.begin(); ia != ic.end(); ++ia, ++is) { // const string &name = (*ia)->getName(); (*is)->push_back((*ia)->EvaluateVar(*conf)); } } votca-csg-1.2.4/src/csg_boltzmann/stdanalysis.cc0000644000175000001440000001024112400714673021624 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include "analysistool.h" #include #include #include "bondedstatistics.h" #include "stdanalysis.h" void StdAnalysis::Register(map &lib) { lib["list"] = this; lib["vals"] = this; lib["cor"] = this; lib["autocor"] = this; } void StdAnalysis::Command(BondedStatistics &bs, string cmd, vector &args) { if(cmd == "vals") WriteValues(bs, args); if(cmd == "cor") WriteCorrelations(bs, args); if(cmd == "autocor") WriteAutocorrelation(bs, args); if(cmd == "list") { DataCollection::selection *sel = bs.BondedValues().select("*"); DataCollection::selection::iterator i; cout << "Available bonded interactions:" << endl; for(i=sel->begin(); i!=sel->end(); ++i) cout << (*i)->getName() << " "; // << "[" << (*i).second->size() << "]" << " "; cout << endl; delete sel; } } void StdAnalysis::Help(string cmd, vector &args) { if(cmd == "vals") { cout << "vals \n" << "write values to file. The first row is the frame number, then one " << "row for each interaction specified. The output can be used to generate " << "2D correlation plots.\n\n" << "example: vals angle *angle*\n"; } if(cmd == "cor") { cout << "cor \n" << "Calculate linear correlation coefficient of the first item in selection with all the other items\n" << "WARNING: for evaluating correlations in the system, it is not sufficient to calculate the " << "linear correlation coefficient, 2D histograms with data from the vals command should be used instead!\n"; } if(cmd == "autocor") { cout << "autocor \n" << "calculate autocorrelation function of first item in selection. The output is periodic since FFTW3 is used to " "calcualte correlations.\n"; } if(cmd == "list") { cout << "list\nlists all available interactions\n"; } } void StdAnalysis::WriteValues(BondedStatistics &bs, vector &args) { ofstream out; DataCollection::selection *sel = NULL; for(size_t i=1; isize() << " data rows to " << args[0] << endl; delete sel; } void StdAnalysis::WriteAutocorrelation(BondedStatistics &bs, vector &args) { ofstream out; DataCollection::selection *sel = NULL; for(size_t i=1; isize() << " data rows, written to " << args[0] << endl; delete sel; } void StdAnalysis::WriteCorrelations(BondedStatistics &bs, vector &args) { ofstream out; DataCollection::selection *sel = NULL; for(size_t i=1; isize() << " rows, written to " << args[0] << endl; delete sel; } votca-csg-1.2.4/src/csg_boltzmann/analysistool.h0000644000175000001440000000245612400714673021662 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _analasystool_H #define _analasystool_H #include #include #include #include "bondedstatistics.h" using namespace std; /** \brief base class for all analasys tools This is the base class for all analasys tool. \todo do option functions!!! */ class AnalysisTool { public: AnalysisTool() {} virtual ~AnalysisTool() {} virtual void Register(map &lib) {} virtual void Command(BondedStatistics &bs, string cmd, vector &args) {}; virtual void Help(string cmd, vector &args) {}; private: // map _options; }; #endif /* _analasystool_H */ votca-csg-1.2.4/src/csg_boltzmann/tabulatedpotential.cc0000644000175000001440000003004212400714673023154 0ustar christophusers/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include "analysistool.h" #include #include #include "bondedstatistics.h" #include "tabulatedpotential.h" using namespace std; using namespace boost; TabulatedPotential::TabulatedPotential() { _tab_smooth1 = _tab_smooth2 = 0; _T = 300; } void TabulatedPotential::Register(map &lib) { lib["tab"] = this; lib["hist"] = this; } void TabulatedPotential::Command(BondedStatistics &bs, string cmd, vector &args) { if(args[0] == "set") { if(cmd == "hist") SetOption(_hist_options, args); else if(cmd == "tab") { if(!SetOption(_tab_options, args)) { if(args.size() >2) { if(args[1] == "smooth_pdf") _tab_smooth1 = lexical_cast(args[2]); else if(args[1] == "smooth_pot") _tab_smooth2 = lexical_cast(args[2]); else if(args[1] == "T") _T = lexical_cast(args[2]); else { cout << "unknown option " << args[2] << endl; return; } } } if(args.size() <=2) { cout << "smooth_pdf: " << _tab_smooth1 << endl; cout << "smooth_pot: " << _tab_smooth2 << endl; cout << "T: " << _T << endl; } } } else if(args.size() >= 2) { if(cmd == "hist") WriteHistogram(bs, args); else if(cmd == "tab") WritePotential(bs, args); } else cout << "wrong number of arguments" << endl; } void TabulatedPotential::Help(string cmd, vector &args) { if(args.size() == 0) { if(cmd == "tab") { cout << "tab \n" << "Calculate tabulated potential by inverting the distribution function. " "Statistics is calculated using all interactions in selection.\n" "see also: help tab set\n\n" "example:\ntab set scale bond\ntab U_bond.txt *:bond:*\n"; } if(cmd == "hist") { cout << "hist \n" << "Calculate distribution function for selection. " "Statistics is calculated using all interactions in selection.\n" "see also: help hist set\n\n" "example:hist U_bond.txt *:bond:*\n"; } return; } if(args[0] == "set") { if(args.size() == 1) { cout << cmd << " set