克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

mech2d

mech2d is a python package that used to calculate the mechanics properties of two dimenional materials, including elstaic constant tensor, stress-strain curve and other relavant properties. mech2d is user friendly to generate deformed structures, submit DFT calculation tasks and process results.

For more information, check the document or paper

Installation

You may clone the source code from gitee

git clone git@gitee.com:haidi-hfut/mech2d.git 

or from

git clone git@github.com:haidi-ustc/mech2d.git

Before you install the mech2d. It is better to create a virtual python enviroment via conda

conda create -n mech2d python=3.10

After creating the virtual enviroment, activate it and install the mech2d

conda activate mech2d
cd mech2d 
pip install .

or directly download the source code zip package and then install it

wget https://gitee.com/haidi-hfut/mech2d/repository/archive/master.zip
unzip mech2d.zip
cd mech2d
pip install .

Method

Please refer to mech2d The polar plot of Young's modulus and Poisson's ratio is obtained by following equation:

\[ \begin{align*} v_{zz} & = \frac{C_{12}}{C_{22}} \\ d_1 & = \frac{C_{11}}{C_{22}} + 1 - \frac{C_{11} C_{22} - C_{12}^2}{C_{22} C_{66}} \\ d_2 & = -\left(2 \frac{C_{12}}{C_{22}} - \frac{C_{11} C_{22} - C_{12}^2}{C_{22} C_{66}}\right) \\ d_3 & = \frac{C_{11}}{C_{22}} \\ Y_{zz} & = \frac{C_{11} C_{22} - C_{12}^2}{C_{22}} \\ \theta & \in [0, 2\pi] \text{ with 360 points} \\ E(\theta) & = \frac{Y_{zz}}{\cos(\theta)^4 + d_2 \cos(\theta)^2 \sin(\theta)^2 + d_3 \sin(\theta)^4} \\ V(\theta) & = \frac{v_{zz} \cos(\theta)^4 - d_1 \cos(\theta)^2 \sin(\theta)^2 + v_{zz} \sin(\theta)^4}{\cos(\theta)^4 + d_2 \cos(\theta)^2 \sin(\theta)^2 + d_3 \sin(\theta)^4} \end{align*} \]

Usage

The calculation of mechanical properties can be divided into three stages:

init , run and post

all of operation in mech2d software is carried out by command line arguments, to get the help information by

m2d -h

it shows

usage: m2d [-h] [-v] {init,run,post} ...

Desctiption:
------------
mech2d is a convenient script that use to calculate the mechanical properties of
2D materials, including EOS, Stress-Strain Curve, elastic constants and revalant
properties. The script works based on several sub-commands with their own options.
To see the options for the sub-commands, type "m2d sub-command -h".

positional arguments:
  {init,run,post}
    init           Generating initial data for elastic systems.
    run            Run the DFT calculation for deformed structures.
    post           Post processing for elastic calculation.

optional arguments:
  -h, --help       show this help message and exit
  -v, --version    Display version
  • the init stage used to generate the deformed structures.

use subcomand to show the help information

m2d init -h

it shows

usage: m2d init [-h] [-c CONFIG] [-a {stress,energy}] [-m MAXS] [-n NUMBER] [-d {xx,yy,bi,xy} [{xx,yy,bi,xy} ...]] [-r RANGES [RANGES ...]]
                [-p {elc,ssc}] [-v] [-b]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        The structure filename. Supported format: ['.vasp','POSCAR','.cif','.xsf']
  -a {stress,energy}, --approach {stress,energy}
                        Support 'Energy' or 'Stress' approach.
  -m MAXS, --maxs MAXS  For elastic constant calculation, it stands for the maximum Lagrangian strain, suggested value is [0.030, 0.150] for
                        Energy approach, [0.0010, 0.0050] for Stress approach; for stress strain cuver calcuation, this value has no above
                        limitation
  -n NUMBER, --number NUMBER
                        The number of the deformed structures [odd number > 4].
  -d {xx,yy,bi,xy} [{xx,yy,bi,xy} ...], --direction {xx,yy,bi,xy} [{xx,yy,bi,xy} ...]
                        The direction used for stress strain curve, default value: 'xx'. 'xx' for 'x' direction; 'yy' for 'y' direction; 'bi'
                        for bi-axis strain and 'xy' for shear strain.
  -r RANGES [RANGES ...], --ranges RANGES [RANGES ...]
                        The Lagrangian strain range used for stress-strain curve calculation. e.g. 0.0 0.2
  -p {elc,ssc}, --properties {elc,ssc}
                        What do you want to calcuation? elastic constant or stress strain curve? default value: 'elc'.
  -v, --verbose         print verbose information or not.
  -b, --back            Whether back the old folder? default value: False.

To obtain the deformed structures according to different symmetry, a relaxed structure if needed. Suppose you have a POSCAR file in current folder, using the following command to generate the deformed structures by stress fitting approach:

m2d init -c POSCAR -n  9 -m 0.02 -a stress

After running this command, it will build a elc_stess folder with subfolders.

elc_stress/
├── Def_1
│   ├── Def_1_001
│   ├── Def_1_002
│   ├── Def_1_003
│   ├── Def_1_004
│   ├── Def_1_005
│   ├── Def_1_006
│   ├── Def_1_007
│   ├── Def_1_008
│   └── Def_1_009
└── Def_2
    ├── Def_2_001
    ├── Def_2_002
    ├── Def_2_003
    ├── Def_2_004
    ├── Def_2_005
    ├── Def_2_006
    ├── Def_2_007
    ├── Def_2_008
    └── Def_2_009

likewise, the deformed structures based on energy fitting approach can be obtained by:

m2d init -c POSCAR -n  9 -m 0.02 -a stress

the deformed structures used for stress strain curve calculation can be obtained by:

m2d init -c POSCAR -n 21 -r 0.0 0.2 -a stress -d 'xx' 'yy' -p ssc 

if the -r parameter exist, it means that Lagrangian stress will be set by a range, e.g. 0 0.2 if the -m parameter exist, it means the Lagrangian stress equals [-max,+max]

tips: .vasp .xsf .cif format files are all supported

  • the run stage used to conduct the DFT calculation.

use subcomand to show the help information

m2d run -h

it shows

usage: m2d run [-h] [-a {stress,energy}] [-p {elc,ssc}] [--manual] [-v] input

positional arguments:
  input                 input file for supplying information about DFT
                        calculation, json/yaml format. The 'machine', 'tasks',
                        'code', 'resources' should be supplied.

optional arguments:
  -h, --help            show this help message and exit
  -a {stress,energy}, --approach {stress,energy}
                        Support 'Energy' or 'Stress' approach.
  -p {elc,ssc}, --properties {elc,ssc}
                        What do you want to calcuation? elastic constant or
                        stress strain curve? default value: 'elc'.
  --manual              manual model, only for generating the input files
                        without runing
  -v, --verbose         print verbose information or not.

For this stage, the running command is :

m2d run -a stress input.yaml

the input.yaml use to set the configure file, it includes machine , resources , tasks and code.

  1. machine dict set the machine information, local or remote ? what kind of queue system will use ? what is the working directory
  2. resources dict set the queue task infomation, how many cores will use? which queue to use? and set the enviroment variables
  3. task dict set the task related infomation, the excutable command , the input files (forward_files) and necessary result files that need to be copied back (back_files)
  4. code dict set the DFT engine information. including code name, input file location

An example for input.yaml is shown below:

---
machine:
  batch_type: Slurm
  context_type: LocalContext
  local_root: "./work"
  remote_root: "./work"
  remote_profile:
    hostname: localhost
    username: wang
    port: 22
    timeout: 10
resources:
  number_node: 1
  cpu_per_node: 48
  gpu_per_node: 0
  queue_name: batch
  task_max: 10
  group_size: 1
  custom_flags: 
   - "ulimit -s unlimited"
  module_list: 
   - "vasp/5.4.1"
  
  #source_list:
  # - "/opt/intel/parallel_studio_xe_2020.2.108/psxevars.sh intel64"
  #envs:
  #  PATH: "/opt/soft/vasp541:$PATH"
tasks:
  command: "mpirun -np 48 vasp_std"
  task_work_path:
  forward_files:
  - INCAR
  - KPOINTS
  - POTCAR
  - POSCAR
  backward_files:
  - runlog
  - errlog
  - OUTCAR
  - OSZICAR
  - vasprun.xml
  - CONTCAR
  outlog: runlog
  errlog: errlog
code:
  name: vasp
  input:
    INCAR: "./INCAR"
    #KPOINTS: "./KPOINTS"
    KPOINTS:
      kspacing: 5000
      kgamma: false
    POTCAR: "./POTCAR"
    #vdw_kernel: vdw_kernel.bindat

The input.yaml can also be setted by JSON format, however it seems that Yaml format is much easier to read.

If you dont want to use the dpdispatcher to automatically submit the jobs, you can run the command: m2d run --manual input.yaml . In this way, only the input files of vasp tasks will be generated.

  • the post stage used analysis the result and plot the result.

use subcomand to show the help information

m2d post -h

it shows

usage: m2d post [-h] [-a {stress,energy}] [-i INPUTFILE] [-p {elc,ssc}]
                [--skip] [-o ORDER] [-f FMT] [-d DPI] [--plot] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -a {stress,energy}, --approach {stress,energy}
                        Support 'Energy' or 'Stress' approach.
  -i INPUTFILE, --inputfile INPUTFILE
                        Parsing elastic constant tensor from input file
  -p {elc,ssc}, --properties {elc,ssc}
                        What do you want to calcuation? elastic constant or
                        stress strain curve? default value: 'elc'.
  --skip                Whether skip the data parsing ? if true, it means the
                        Def_*_Energy.dat should be exists in corresponding
                        folder. default value: False.
  -o ORDER, --order ORDER
                        The order of polynomial for fitting. Default value: 4
                        for strain-stress approach and 3 for stress-strain
                        method
  -f FMT, --fmt FMT     The format of output figure. Default value: .jpg
  -d DPI, --dpi DPI     The resolution of output figure. Default value: 100
  --plot                plot the figures
  -v, --verbose         print verbose information or not.

For this stage, the running command is :

m2d post -a stress --plot

A figure named stress-EV.jpg will be generated.

EV

or for stress-strain calculation

m2d post -a stress -p ssc --plot

How to Cite

Wang, H.; Li, T.; Liu, X.; Zhu, W.; Chen, Z.; Li, Z.; Yang, J. mech2d: An Efficient Tool for High-Throughput Calculation of Mechanical Properties for Two-Dimensional Materials. Link

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

A usefull tool to to calculate the mechanics properties of two dimenional material. 展开 收起
Python 等 2 种语言
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化