CyFES


NameCyFES JSON
Version 2.7 PyPI version JSON
download
home_pagehttps://gitee.com/dechin/cy-fes
SummaryCython Based Fast FES Calculation Toolkit.
upload_time2024-09-02 09:48:39
maintainerNone
docs_urlNone
authorDechin CHEN
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CyFES:GPU加速高性能数据透视工具

<img alt="Hex.pm" src="https://img.shields.io/badge/License-MIT-blue">
<img alt="Hex.pm" src="https://img.shields.io/badge/Language-Python-orange">
<img alt="Hex.pm" src="https://img.shields.io/badge/Language-Cython-orange">
<img alt="Hex.pm" src="https://img.shields.io/badge/Language-CUDA_C++-orange">
<img alt="Hex.pm" src="https://img.shields.io/badge/Device-GPU-green">

![](./docs/fes01.png)

## 介绍
这是一个使用Cython+CUDA+Python编写的高性能FES计算软件,可以用于加速数据透视的计算:

$$
E(x)=-kT\log\left(\frac{\sum_{j=1}^Ne^{\frac{V_j}{kT}}e^{-\frac{(x-n_j)^2}{2}}}{N\Pi_i\sqrt{2\pi}\sigma_i}\right)
$$

## 安装
### pip安装
本项目可以直接使用pip进行安装:
```bash
$ python3 -m pip install cyfes --user --upgrade -i https://pypi.org/simple
```

### 源码安装
首先将本仓库clone到本地:
```bash
$ git clone https://gitee.com/dechin/cy-fes.git && cd cy-fes/
```
然后直接运行`setup.py`进行安装:
```bash
$ python3 -m pip install .
```

### 安装测试
在本仓库的test路径下存放了一个测试用例,用于测试cyfes是否安装成功。用户可以直接简单的运行:
```bash
$ python3 tests/test_path_fes.py 
[0.00892185 0.         0.09578881 0.01997518]
[0.06397188 0.         0.09973657 0.04956698]
[0.04098002 0.10183226 0.03498954 0.        ]
```
若输出为多个数组,则表示安装成功。也可以使用单元测试运行,但是这需要在本地先安装`pytest`:
```bash
$ python3 -m pip install pytest
```
然后直接在仓库的根目录下运行:
```bash
$ py.test
=================================== test session starts ====================================
platform linux -- Python 3.7.5, pytest-7.4.4, pluggy-1.2.0
rootdir: /home/cy-fes
collected 3 items                                                                          

tests/test_path_fes.py ...                                                           [100%]

==================================== 3 passed in 5.39s =====================================
```
没有报错,则表示安装成功。

## 使用方法
在安装成功后,可以直接在Python脚本中调用:
```python
import numpy as np
from cyfes import PathFES
np.random.seed(0)

def test_path_fes():
    atoms = 4
    cvs = 10000
    crd = np.random.random((atoms, 3))
    cv = np.random.random((cvs, 3))
    bw = np.random.random(3)
    bias = np.random.random(cvs)-1

    fes = np.asarray(PathFES(crd, cv, bw, bias))
    print (fes)

if __name__ == '__main__':
    test_path_fes()
```

还可以使用命令行模式:
```bash
$ python3 -m cyfes --help
usage: __main__.py [-h] [-i I] [-ic IC] [-ib IB] [-s S] [-e E] [-g G] [-o O]
                   [-f32 F32] [-sigma SIGMA]

optional arguments:
  -h, --help    show this help message and exit
  -i I          Set the input record file path.
  -ic IC        Set the cv index of input record file. Default: 0,1,2
  -ib IB        Set the bias index of input record file. Default: 3
  -s S          CV length. Default: None
  -e E          Edge length. Default: 1.0
  -g G          Grid numbers. Default: 10,10,10
  -o O          Set the output FES file path.
  -f32 F32      Use float32. Default: false
  -sigma SIGMA  Sigma value when calculating FES. Default: 0.3
```
假如我们有一个三维的CV,那么最简单的运行方式为:
```bash
$ python3 -m cyfes -i /home/Data/xyz_bias.txt -o ./work_dir/z.cub
```
那么最后产生的文件内容为:
```bash
$ head -n 10 work_dir/z.cub
Generated by CyFES
Total	1000	grids
1	21.6622	19.8498	42.3652
10	6.40465	0	0
10	0	7.02147	0
10	0	0	6.33118
1	1.000000	53.6854	54.9571	74.0211
450	450	450	450	450	450	
450	450	450	450	450	450	
450	450	70.0855	70.848	450	450	
```
该cube格式的文件可以在支持的软件(如VMD)中进行可视化操作。

## 已知问题
1. 使用numpy==1.22.2的版本中会出现`ImportError: numpy.core.multiarray failed to import`问题。解决方案:升级numpy版本:`python3 -m pip install numpy --upgrade`。
2. 执行`python3 -m cyfes --help`报错`ModuleNotFoundError: No module named 'cyfes.wrapper'`,这是因为执行命令的目录下存在名为`cyfes`的文件夹,需要切换执行命令的位置。
3. 使用cyfes出现`Segmentation fault`段错误问题,是因为找不到编译好的动态链接库文件,大概率是系统环境下权限不足,没有site路径的权限,可以使用如下脚本进行检查:
```python
# check_dynamics.py
import os
import site
from pathlib import Path

site_path = Path(site.getsitepackages()[0])
site_file_path = site_path.parent.parent.parent / 'cyfes' / 'libcufes.so'
site_dynamics_path = str(site_file_path)

user_site_path = Path(site.USER_SITE)
user_file_path = user_site_path.parent.parent.parent / 'cyfes' / 'libcufes.so'
user_dynamics_path = str(user_file_path)

if not os.path.exists(site_dynamics_path) and not os.path.exists(user_dynamics_path):
    print ('Check dynamics complete, no libcufes.so file founded!')
else:
    print ('Installation of CyFES success!')
```
使用python3运行该脚本,即可判断动态链接库是否被正确安装。



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitee.com/dechin/cy-fes",
    "name": "CyFES",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Dechin CHEN",
    "author_email": "dechin.phy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/77/62/59a4fcdebaae99007761a008e0b4e9b471fbc6bfab35c02d9625312f4f65/CyFES-2.7.tar.gz",
    "platform": "any",
    "description": "# CyFES\uff1aGPU\u52a0\u901f\u9ad8\u6027\u80fd\u6570\u636e\u900f\u89c6\u5de5\u5177\n\n<img alt=\"Hex.pm\" src=\"https://img.shields.io/badge/License-MIT-blue\">\n<img alt=\"Hex.pm\" src=\"https://img.shields.io/badge/Language-Python-orange\">\n<img alt=\"Hex.pm\" src=\"https://img.shields.io/badge/Language-Cython-orange\">\n<img alt=\"Hex.pm\" src=\"https://img.shields.io/badge/Language-CUDA_C++-orange\">\n<img alt=\"Hex.pm\" src=\"https://img.shields.io/badge/Device-GPU-green\">\n\n![](./docs/fes01.png)\n\n## \u4ecb\u7ecd\n\u8fd9\u662f\u4e00\u4e2a\u4f7f\u7528Cython+CUDA+Python\u7f16\u5199\u7684\u9ad8\u6027\u80fdFES\u8ba1\u7b97\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u7528\u4e8e\u52a0\u901f\u6570\u636e\u900f\u89c6\u7684\u8ba1\u7b97\uff1a\n\n$$\nE(x)=-kT\\log\\left(\\frac{\\sum_{j=1}^Ne^{\\frac{V_j}{kT}}e^{-\\frac{(x-n_j)^2}{2}}}{N\\Pi_i\\sqrt{2\\pi}\\sigma_i}\\right)\n$$\n\n## \u5b89\u88c5\n### pip\u5b89\u88c5\n\u672c\u9879\u76ee\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a\n```bash\n$ python3 -m pip install cyfes --user --upgrade -i https://pypi.org/simple\n```\n\n### \u6e90\u7801\u5b89\u88c5\n\u9996\u5148\u5c06\u672c\u4ed3\u5e93clone\u5230\u672c\u5730\uff1a\n```bash\n$ git clone https://gitee.com/dechin/cy-fes.git && cd cy-fes/\n```\n\u7136\u540e\u76f4\u63a5\u8fd0\u884c`setup.py`\u8fdb\u884c\u5b89\u88c5\uff1a\n```bash\n$ python3 -m pip install .\n```\n\n### \u5b89\u88c5\u6d4b\u8bd5\n\u5728\u672c\u4ed3\u5e93\u7684test\u8def\u5f84\u4e0b\u5b58\u653e\u4e86\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c\u7528\u4e8e\u6d4b\u8bd5cyfes\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u7b80\u5355\u7684\u8fd0\u884c\uff1a\n```bash\n$ python3 tests/test_path_fes.py \n[0.00892185 0.         0.09578881 0.01997518]\n[0.06397188 0.         0.09973657 0.04956698]\n[0.04098002 0.10183226 0.03498954 0.        ]\n```\n\u82e5\u8f93\u51fa\u4e3a\u591a\u4e2a\u6570\u7ec4\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5355\u5143\u6d4b\u8bd5\u8fd0\u884c\uff0c\u4f46\u662f\u8fd9\u9700\u8981\u5728\u672c\u5730\u5148\u5b89\u88c5`pytest`\uff1a\n```bash\n$ python3 -m pip install pytest\n```\n\u7136\u540e\u76f4\u63a5\u5728\u4ed3\u5e93\u7684\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\uff1a\n```bash\n$ py.test\n=================================== test session starts ====================================\nplatform linux -- Python 3.7.5, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/cy-fes\ncollected 3 items                                                                          \n\ntests/test_path_fes.py ...                                                           [100%]\n\n==================================== 3 passed in 5.39s =====================================\n```\n\u6ca1\u6709\u62a5\u9519\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002\n\n## \u4f7f\u7528\u65b9\u6cd5\n\u5728\u5b89\u88c5\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728Python\u811a\u672c\u4e2d\u8c03\u7528\uff1a\n```python\nimport numpy as np\nfrom cyfes import PathFES\nnp.random.seed(0)\n\ndef test_path_fes():\n    atoms = 4\n    cvs = 10000\n    crd = np.random.random((atoms, 3))\n    cv = np.random.random((cvs, 3))\n    bw = np.random.random(3)\n    bias = np.random.random(cvs)-1\n\n    fes = np.asarray(PathFES(crd, cv, bw, bias))\n    print (fes)\n\nif __name__ == '__main__':\n    test_path_fes()\n```\n\n\u8fd8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u6a21\u5f0f\uff1a\n```bash\n$ python3 -m cyfes --help\nusage: __main__.py [-h] [-i I] [-ic IC] [-ib IB] [-s S] [-e E] [-g G] [-o O]\n                   [-f32 F32] [-sigma SIGMA]\n\noptional arguments:\n  -h, --help    show this help message and exit\n  -i I          Set the input record file path.\n  -ic IC        Set the cv index of input record file. Default: 0,1,2\n  -ib IB        Set the bias index of input record file. Default: 3\n  -s S          CV length. Default: None\n  -e E          Edge length. Default: 1.0\n  -g G          Grid numbers. Default: 10,10,10\n  -o O          Set the output FES file path.\n  -f32 F32      Use float32. Default: false\n  -sigma SIGMA  Sigma value when calculating FES. Default: 0.3\n```\n\u5047\u5982\u6211\u4eec\u6709\u4e00\u4e2a\u4e09\u7ef4\u7684CV\uff0c\u90a3\u4e48\u6700\u7b80\u5355\u7684\u8fd0\u884c\u65b9\u5f0f\u4e3a\uff1a\n```bash\n$ python3 -m cyfes -i /home/Data/xyz_bias.txt -o ./work_dir/z.cub\n```\n\u90a3\u4e48\u6700\u540e\u4ea7\u751f\u7684\u6587\u4ef6\u5185\u5bb9\u4e3a\uff1a\n```bash\n$ head -n 10 work_dir/z.cub\nGenerated by CyFES\nTotal\t1000\tgrids\n1\t21.6622\t19.8498\t42.3652\n10\t6.40465\t0\t0\n10\t0\t7.02147\t0\n10\t0\t0\t6.33118\n1\t1.000000\t53.6854\t54.9571\t74.0211\n450\t450\t450\t450\t450\t450\t\n450\t450\t450\t450\t450\t450\t\n450\t450\t70.0855\t70.848\t450\t450\t\n```\n\u8be5cube\u683c\u5f0f\u7684\u6587\u4ef6\u53ef\u4ee5\u5728\u652f\u6301\u7684\u8f6f\u4ef6\uff08\u5982VMD\uff09\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u64cd\u4f5c\u3002\n\n## \u5df2\u77e5\u95ee\u9898\n1. \u4f7f\u7528numpy==1.22.2\u7684\u7248\u672c\u4e2d\u4f1a\u51fa\u73b0`ImportError: numpy.core.multiarray failed to import`\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6848\uff1a\u5347\u7ea7numpy\u7248\u672c\uff1a`python3 -m pip install numpy --upgrade`\u3002\n2. \u6267\u884c`python3 -m cyfes --help`\u62a5\u9519`ModuleNotFoundError: No module named 'cyfes.wrapper'`\uff0c\u8fd9\u662f\u56e0\u4e3a\u6267\u884c\u547d\u4ee4\u7684\u76ee\u5f55\u4e0b\u5b58\u5728\u540d\u4e3a`cyfes`\u7684\u6587\u4ef6\u5939\uff0c\u9700\u8981\u5207\u6362\u6267\u884c\u547d\u4ee4\u7684\u4f4d\u7f6e\u3002\n3. \u4f7f\u7528cyfes\u51fa\u73b0`Segmentation fault`\u6bb5\u9519\u8bef\u95ee\u9898\uff0c\u662f\u56e0\u4e3a\u627e\u4e0d\u5230\u7f16\u8bd1\u597d\u7684\u52a8\u6001\u94fe\u63a5\u5e93\u6587\u4ef6\uff0c\u5927\u6982\u7387\u662f\u7cfb\u7edf\u73af\u5883\u4e0b\u6743\u9650\u4e0d\u8db3\uff0c\u6ca1\u6709site\u8def\u5f84\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u811a\u672c\u8fdb\u884c\u68c0\u67e5\uff1a\n```python\n# check_dynamics.py\nimport os\nimport site\nfrom pathlib import Path\n\nsite_path = Path(site.getsitepackages()[0])\nsite_file_path = site_path.parent.parent.parent / 'cyfes' / 'libcufes.so'\nsite_dynamics_path = str(site_file_path)\n\nuser_site_path = Path(site.USER_SITE)\nuser_file_path = user_site_path.parent.parent.parent / 'cyfes' / 'libcufes.so'\nuser_dynamics_path = str(user_file_path)\n\nif not os.path.exists(site_dynamics_path) and not os.path.exists(user_dynamics_path):\n    print ('Check dynamics complete, no libcufes.so file founded!')\nelse:\n    print ('Installation of CyFES success!')\n```\n\u4f7f\u7528python3\u8fd0\u884c\u8be5\u811a\u672c\uff0c\u5373\u53ef\u5224\u65ad\u52a8\u6001\u94fe\u63a5\u5e93\u662f\u5426\u88ab\u6b63\u786e\u5b89\u88c5\u3002\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cython Based Fast FES Calculation Toolkit.",
    "version": "2.7",
    "project_urls": {
        "Homepage": "https://gitee.com/dechin/cy-fes"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7353db88ecb6b77af1f5e8a6a898850ce228f2ba7e4cebe001ed2cd72a2368f7",
                "md5": "f8b07d703cfc8dd9d7093ab387804fed",
                "sha256": "9c7a27665ee191dcbbae4a2316ddcecd004b16e6b5b1d43894925dc79315dcb8"
            },
            "downloads": -1,
            "filename": "CyFES-2.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "f8b07d703cfc8dd9d7093ab387804fed",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": null,
            "size": 1658576,
            "upload_time": "2024-09-02T09:48:25",
            "upload_time_iso_8601": "2024-09-02T09:48:25.261930Z",
            "url": "https://files.pythonhosted.org/packages/73/53/db88ecb6b77af1f5e8a6a898850ce228f2ba7e4cebe001ed2cd72a2368f7/CyFES-2.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27355c192d9ce312963731495eaad21bf59c5bb10d81d13c800ee316639a1fbf",
                "md5": "7791139c2abb35dcbb9a3b5613705f42",
                "sha256": "6fd400d2811c9368dd3e232bffcfd423ba6757ec39e90e43ea967f896e276a38"
            },
            "downloads": -1,
            "filename": "CyFES-2.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "7791139c2abb35dcbb9a3b5613705f42",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 1622222,
            "upload_time": "2024-09-02T09:48:29",
            "upload_time_iso_8601": "2024-09-02T09:48:29.911974Z",
            "url": "https://files.pythonhosted.org/packages/27/35/5c192d9ce312963731495eaad21bf59c5bb10d81d13c800ee316639a1fbf/CyFES-2.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d81122bb35b1bb44cff3c11ef9e04a24811a048f44732356019c9e96d2fe3209",
                "md5": "bb20f19e11471f42353c67b0cf4f33be",
                "sha256": "e14c359ec516475cf7695d46cd7da00c886608ac965024c7fe03e38a482f8d7e"
            },
            "downloads": -1,
            "filename": "CyFES-2.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "bb20f19e11471f42353c67b0cf4f33be",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": null,
            "size": 1729455,
            "upload_time": "2024-09-02T09:48:33",
            "upload_time_iso_8601": "2024-09-02T09:48:33.208893Z",
            "url": "https://files.pythonhosted.org/packages/d8/11/22bb35b1bb44cff3c11ef9e04a24811a048f44732356019c9e96d2fe3209/CyFES-2.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54493e76513a6005de743b6678dccedd6b5eb11efdce99a7f3b188e28af0b536",
                "md5": "78fc1d42245fc53b2822f622484872ed",
                "sha256": "d1567e06fea883b4dba01d8ef4fff54cc7565a460ae94c7fc3d9761c78b7fbd4"
            },
            "downloads": -1,
            "filename": "CyFES-2.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "78fc1d42245fc53b2822f622484872ed",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": null,
            "size": 1662759,
            "upload_time": "2024-09-02T09:48:36",
            "upload_time_iso_8601": "2024-09-02T09:48:36.411280Z",
            "url": "https://files.pythonhosted.org/packages/54/49/3e76513a6005de743b6678dccedd6b5eb11efdce99a7f3b188e28af0b536/CyFES-2.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "776259a4fcdebaae99007761a008e0b4e9b471fbc6bfab35c02d9625312f4f65",
                "md5": "05a74d241b4380e5cb4d4e1e495bddf3",
                "sha256": "4e0cb8fd52696f2b4fbc9a9b7dd93d6d8d52091b41e74e05e20aa9361e462812"
            },
            "downloads": -1,
            "filename": "CyFES-2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "05a74d241b4380e5cb4d4e1e495bddf3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 345379,
            "upload_time": "2024-09-02T09:48:39",
            "upload_time_iso_8601": "2024-09-02T09:48:39.609075Z",
            "url": "https://files.pythonhosted.org/packages/77/62/59a4fcdebaae99007761a008e0b4e9b471fbc6bfab35c02d9625312f4f65/CyFES-2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-02 09:48:39",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cyfes"
}
        
Elapsed time: 0.63201s