├── LICENSE ├── README.md ├── doc ├── .keep ├── I-ReaxFF_Manual.md ├── gulp │ ├── .keep │ ├── GULP分子动力学模拟.md │ └── GULP并行安装.md ├── lammps │ ├── .keep │ └── 并行安装lammps.md ├── octave.md ├── qe │ ├── .keep │ └── 并行编译qe.md ├── siesta │ ├── .keep │ ├── Al.psf │ ├── C.psf │ ├── F.psf │ ├── H.psf │ ├── N.psf │ ├── O.psf │ ├── in.fdf │ └── 并行编译siesta.md ├── 图1.png ├── 图2.png └── 图3.png ├── examples ├── Readme.md ├── example_al │ └── .keep ├── example_ch4h2o │ ├── .keep │ ├── Readme.md │ ├── aimd_ch4w2 │ │ ├── .keep │ │ ├── ch4w2-0 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ │ ├── ch4w2-1 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ │ └── ch4w2-2 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ ├── aimd_h22 │ │ ├── .keep │ │ ├── h22-0.traj │ │ ├── h22-0 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ ├── md.traj │ │ │ └── siesta_h22.out │ │ ├── h22-1 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ ├── siesta.bib │ │ │ └── siesta.out │ │ ├── h22-2 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ ├── md.traj │ │ │ └── siesta.out │ │ ├── h22-3 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ffield.json │ │ │ ├── h22.traj │ │ │ ├── in.fdf │ │ │ ├── md.traj │ │ │ └── siesta.out │ │ ├── h22-4 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ └── siesta.out │ │ ├── h22-5 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ └── siesta.out │ │ ├── h22-6 │ │ │ ├── SinglePointEnergies.log │ │ │ └── h22.traj │ │ ├── h22-7 │ │ │ ├── SinglePointEnergies.log │ │ │ └── h22.traj │ │ ├── h22-8 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h22.traj │ │ │ └── md.traj │ │ └── h22-v.traj │ ├── aimd_h2o16 │ │ ├── .keep │ │ ├── h2o16-0 │ │ │ ├── C.psf │ │ │ ├── Cl.psf │ │ │ ├── H.psf │ │ │ ├── N.psf │ │ │ ├── O.psf │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o16.traj │ │ │ └── in.fdf │ │ ├── h2o16-1 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o16.traj │ │ │ └── in.fdf │ │ ├── h2o16-2 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o16.traj │ │ │ └── in.fdf │ │ ├── h2o16-3 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o16.traj │ │ │ └── in.fdf │ │ └── h2o16-4 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o16.traj │ │ │ └── in.fdf │ ├── aimd_h2o2 │ │ ├── .keep │ │ ├── h2o2-0 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o2.traj │ │ │ ├── siesta-1.out │ │ │ ├── siesta-11.out │ │ │ ├── siesta-2.out │ │ │ ├── siesta-4.out │ │ │ ├── siesta-6.out │ │ │ └── siesta-8.out │ │ ├── h2o2-1 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o2.traj │ │ │ └── siesta-50.out │ │ ├── h2o2-2 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o2.traj │ │ │ └── siesta-50.out │ │ ├── h2o2-3 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o2.traj │ │ │ └── siesta-50.out │ │ └── h2o2-4 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── h2o2.traj │ │ │ ├── in.fdf │ │ │ └── siesta-31.out │ ├── ch4w2.gen │ ├── ffield.json │ ├── gmd.py │ ├── h22.gen │ ├── h2o16.gen │ ├── h2o2.gen │ ├── json_to_ffield.py │ ├── json_to_lib.py │ ├── lm.py │ ├── ml_train.py │ ├── pseudo │ │ ├── .keep │ │ ├── C.psf │ │ ├── H.psf │ │ ├── N.psf │ │ └── O.psf │ ├── rotate.py │ ├── stretch.py │ ├── train.py │ └── train_without_force.py ├── example_fc_lammps │ └── .keep ├── example_fox │ ├── .keep │ ├── README.md │ ├── aimd_fox7 │ │ ├── fox7-0 │ │ │ ├── C.psf │ │ │ ├── H.psf │ │ │ ├── N.psf │ │ │ ├── O.psf │ │ │ ├── fox7.traj │ │ │ └── in.fdf │ │ ├── fox7-1 │ │ │ ├── SinglePointEnergies.log │ │ │ └── fox7.traj │ │ └── fox7-2 │ │ │ ├── C.psf │ │ │ ├── H.psf │ │ │ ├── N.psf │ │ │ ├── O.psf │ │ │ ├── SinglePointEnergies.log │ │ │ ├── fox7.traj │ │ │ └── siesta-18.out │ ├── ffield.json │ ├── fox7.png │ ├── lm.py │ ├── pseudo │ │ ├── .keep │ │ ├── Al.psf │ │ ├── C.psf │ │ ├── Cl.psf │ │ ├── H.psf │ │ ├── N.psf │ │ └── O.psf │ └── train.py ├── example_graph │ ├── .keep │ └── ml_train_reax.py ├── example_phonon │ ├── .keep │ ├── ph_gulp.py │ ├── readme.md │ └── reaxff_nn.lib ├── example_reax │ ├── .keep │ ├── aimd_tkx │ │ ├── tkx-0 │ │ │ └── tkx.traj │ │ ├── tkx-1 │ │ │ └── tkx.traj │ │ ├── tkx-2 │ │ │ └── tkx.traj │ │ ├── tkx-3 │ │ │ └── tkx.traj │ │ ├── tkx-4 │ │ │ └── tkx.traj │ │ ├── tkx-5 │ │ │ └── tkx.traj │ │ └── tkx-6 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── in.fdf │ │ │ └── tkx.traj │ ├── aimd_tkx2 │ │ ├── tkx2-0 │ │ │ └── tkx2.traj │ │ ├── tkx2-1 │ │ │ └── tkx2.traj │ │ ├── tkx2-2 │ │ │ └── tkx2.traj │ │ ├── tkx2-3 │ │ │ └── tkx2.traj │ │ └── tkx2-4 │ │ │ └── tkx2.traj │ ├── ffield.json │ ├── ffield_to_json.py │ ├── json_to_ffield.py │ ├── lmd.py │ ├── ml_train_reax.py │ ├── readme.md │ ├── tkx2.gen │ └── train_reax.py ├── example_torch │ ├── .keep │ ├── aimd_ch4w2 │ │ ├── ch4w2-0 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ │ ├── ch4w2-1 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ │ └── ch4w2-2 │ │ │ ├── SinglePointEnergies.log │ │ │ ├── ch4w2.traj │ │ │ └── in.fdf │ └── train.py └── train.png ├── irff ├── .keep ├── AtomDance.py ├── LearningMachine.py ├── RadiusCutOff.py ├── __init__.py ├── data │ ├── .keep │ ├── ColData.py │ ├── __init__.py │ ├── dpdata.py │ ├── mdtodata.py │ ├── prep_data.py │ └── qeout_to_traj.py ├── deb │ ├── .keep │ ├── __init__.py │ ├── compare_energies.py │ ├── deb_bde.py │ ├── hbdeb.py │ ├── ird.py │ ├── irdeb.py │ ├── irffdeb.py │ ├── irnan.py │ ├── mpdeb.py │ ├── reax_debug.py │ ├── reax_gulp.py │ └── theta.py ├── dft │ ├── .keep │ ├── CheckEmol.py │ ├── SinglePointEnergy.py │ ├── __init__.py │ ├── cpmd.py │ ├── dftb.py │ ├── nwchem.py │ ├── qe.py │ ├── siesta.py │ ├── siesta_zmatix_constrain.py │ └── smd_server.py ├── dingtalk.py ├── emdk.py ├── getNeighbor.pyx ├── getNeighbors.py ├── intCheck.py ├── irff.py ├── irff_autograd.py ├── irff_np.py ├── libs │ ├── .keep │ └── __init__.py ├── link.py ├── md │ ├── .keep │ ├── ReactionCapture.py │ ├── __init__.py │ ├── gofr.py │ ├── gulp.py │ ├── hugoniot.py │ ├── irmd.py │ └── lammps.py ├── ml │ ├── .keep │ ├── __init__.py │ ├── data.py │ ├── evaluate_data.py │ ├── evolution.py │ ├── ffield.py │ ├── fit.py │ ├── fluctuation.py │ ├── gaqeq.py │ ├── genetic.py │ ├── gpfit_tfv2.py │ ├── harmonic.py │ ├── nn.py │ ├── reax_funcs.py │ └── train.py ├── mlqeq.py ├── molecule.py ├── mpnn.py ├── neighbor.pyx ├── neighbors.py ├── plot │ ├── .keep │ ├── BondEnergy.py │ ├── CheckAng.py │ ├── LearningResults.py │ ├── LearningResultsAng.py │ ├── MessagePassing.py │ ├── __init__.py │ ├── abc.py │ ├── angel_to_bond.py │ ├── bde.py │ ├── compare_energies.py │ ├── fingerprint.py │ ├── gofr.py │ ├── irnn_plot.py │ ├── label_md.py │ ├── labels.py │ ├── morse.py │ ├── morse_taper.py │ ├── mpbd.py │ ├── mpnn_plbd.py │ ├── nx.py │ ├── pdf.py │ ├── plbd.py │ ├── plbo.py │ ├── ple.py │ ├── plea.py │ ├── pleb.py │ ├── pleo.py │ ├── plev.py │ ├── plevdw.py │ ├── plf.py │ ├── plot_atoms.py │ ├── plot_atoms_matplot.py │ ├── plot_atoms_momenta.py │ ├── plot_bond_energy.py │ ├── plot_charge.py │ ├── plot_energy.py │ ├── plot_eover.py │ ├── plot_eover_atom.py │ ├── plot_functions.py │ ├── plot_morse.py │ ├── plot_pes.py │ ├── plot_pressure.py │ ├── plot_zmat_pes.py │ ├── plotenergy.py │ ├── plotenergy_bond.py │ ├── pltp.py │ ├── reax_plbd.py │ ├── reax_pldd.py │ ├── reax_plot.py │ ├── reax_plov.py │ ├── rffbd.py │ ├── sigmoid.py │ ├── vdw_taper.py │ └── view.py ├── prop │ ├── .keep │ ├── __init__.py │ └── gofr.py ├── qeq.py ├── reax.py ├── reax_data.py ├── reax_force_data.py ├── reax_nn.py ├── reaxff_jax.py ├── reaxff_torch.py ├── reaxfflib.py ├── set_matrix_tensor.py ├── spectra.py ├── structures │ ├── .keep │ ├── Al.gen │ ├── C2C4.gen │ ├── HMX_MOL.gen │ ├── NM.gen │ ├── __init__.py │ ├── ball.py │ ├── ball_bulk.py │ ├── diamond.py │ ├── fox7.gen │ └── nm3.gen ├── tools │ ├── .keep │ ├── __init__.py │ ├── eos_opt.py │ ├── epstopdf.py │ ├── ffieldtolib.py │ ├── fingerprint.py │ ├── fit_hugoniot_state.py │ ├── fitnn.py │ ├── json_to_ffield.py │ ├── load_individuals.py │ ├── morse_taper.py │ ├── pre_opt.py │ ├── prepare_ffield.py │ ├── pressure.py │ ├── pseudo_gen.py │ ├── rsetff.py │ ├── setwb.py │ ├── vdw.py │ └── zmat_to_atoms.py ├── trainer.py └── zmatrix.py ├── setup.py ├── test ├── .keep ├── ffield.json ├── gp4-0.traj ├── gp4-1.traj ├── md.traj ├── test_force_nn.py ├── test_reax_force.py ├── test_reax_gulp.py ├── test_reax_nn.py ├── test_train_tf_force.py └── train_with_force.py └── tools ├── .keep ├── README.md ├── add_element.py ├── add_layer.py ├── apprun.py ├── atoms_to_poscar.py ├── atoms_to_yaml.py ├── axial_strain.py ├── bend.py ├── c3_zmat_pes.py ├── checkoffd.py ├── cif_to_poscar.py ├── cifs_to_traj.py ├── cnt.py ├── collision.py ├── compare_dft.py ├── continous.py ├── control_to_poscar.py ├── cplib.py ├── data ├── .keep ├── ase_convert_dpmd.py ├── gen_to_csv.py └── md_to_traj.py ├── de.py ├── deb ├── .keep ├── compare_energies.py ├── deb_bd.py ├── deb_bo.py ├── deb_delta.py ├── deb_energies.py ├── deb_eover.py ├── deb_thet.py ├── dinfo.py └── mp_deb.py ├── dft ├── .keep ├── ebind_smd.py ├── nw.py ├── qmd.py └── smd.py ├── diff_fnn.py ├── ffield_to_csv.py ├── ffield_to_json.py ├── fitmorse.py ├── fitnn.py ├── gaussian.py ├── get_forces.py ├── gp.py ├── gulp_time.py ├── harmonic.py ├── init_ffield_fit.py ├── integrate.py ├── json_to_ffield.py ├── json_to_lib.py ├── md ├── .keep ├── gmd.py ├── lam2xyz.f ├── lmd.py ├── lopt.py ├── md.py ├── pack_poscar.py ├── scale.py └── scale_mol.py ├── merge.py ├── ml ├── .keep ├── gp_uncertainty.py ├── invariance.py └── invariance_info.py ├── ml_optimize_coulomb.py ├── ml_train.py ├── ml_train_coul.py ├── ml_train_reax.py ├── moment.py ├── nomb.py ├── notebooks ├── .keep ├── deb_angle.ipynb ├── deb_bo.ipynb ├── deb_energies.ipynb └── deb_manybody.ipynb ├── out_to_traj.py ├── pes ├── .keep ├── zmat_stretch.py ├── zmatpes.py └── zmatpes_cbd2.py ├── phonon_force.py ├── phonopy ├── .keep ├── af_flow_scale.py ├── generate_displacements.py ├── ph_flow.py └── ph_flow_lammps.py ├── plot ├── .keep ├── hbond.py ├── hbond_component.py ├── kappa_plot.py ├── plevdw.py ├── plot_convergence_af.py ├── plot_ebind.py ├── plot_msd.py ├── plot_result.py ├── plot_thermal.py ├── plot_time.py ├── plotatoms.py ├── plotatoms_bondorder.py ├── plotband.py ├── trajplot.py ├── trajplot_gulp.py └── trajplot_lammps.py ├── pm.py ├── prior_bo_fit.py ├── qeout_to_traj.py ├── rmsave.py ├── rotate.py ├── rotator.py ├── sample_traj.py ├── select_element.py ├── single_point.py ├── sort_atoms.py ├── stretch.py ├── stretch_zmat.py ├── structure.py ├── supercell.py ├── swing.py ├── test_reax.py ├── theta.py ├── torsion.py ├── train_nn.py ├── train_reax.py ├── uspex ├── .keep ├── calc_individuals.py ├── density.py ├── ebind_gulp.py ├── ebind_smd.py ├── gen_to_csv.py ├── hbond.py ├── hbond_bind.py ├── hbond_gen.py ├── hbond_poscar.py ├── individuals_to_poscars.py ├── individuals_to_traj.py ├── mdflow.py ├── mlflow.py ├── mols.py ├── pack_poscars.py ├── plot_hbond.py ├── plot_individuals.py ├── plot_individuals_gmm.py ├── plot_individuals_kmean.py ├── plot_surface.py ├── sort_atoms_mol.py ├── sort_poscars.py ├── uspex_zmat.py └── zmat_match.py └── zmat.py /README.md: -------------------------------------------------------------------------------- 1 | # I-ReaxFF: stand for Intelligent-Reactive Force Field 2 | 3 | - I-ReaxFF is a differentiable ReaxFF framework based on TensorFlow, with which we can get the first and high order derivatives of energies, and also can optimize **ReaxFF** and **ReaxFF-nn** (Reactive Force Field with Neural Networks) parameters with integrated optimizers in TensorFlow. 4 | 5 | --- 6 | 7 | * ffield.json: the parameter file from machine learning 8 | * reaxff_nn.lib the parameter file converted from ffield.json for usage with GULP 9 | 10 | ## Requirement 11 | the following package need to be installed 12 | 1. TensorFlow, pip install tensorflow --user or conda install tensorflow 13 | 2. Numpy,pip install numpy --user 14 | 3. matplotlib, pip install matplotlib --user 15 | 16 | Install this package after download this package and run commond in shell ``` python setup install --user ```. 17 | or using new command 18 | ```shell 19 | pip install . 20 | ``` 21 | Alternatively, this package can be install without download the package through pip 22 | ``` pip install --user irff ```. 23 | 24 | 25 | ## Refference 26 | 1. Feng Guo et.al., Intelligent-ReaxFF: Evaluating the reactive force field parameters with machine learning, Computational Materials Science 172, 109393, 2020. 27 | 28 | 2. Feng Guo et.al., ReaxFF-MPNN machine learning potential: a combination of reactive force field and message passing neural networks,Physical Chemistry Chemical Physics, 23, 19457-19464, 2021. 29 | 30 | 3. Feng Guo et.al., ReaxFF-nn: A Reactive Machine Learning Potential in GULP/LAMMPS and the Applications in the Thermal Conductivity Calculations of Carbon Nanostructures, Physical Chemistry Chemical Physics, 27, 10571-10579, 2025. 31 | 32 | ### Use ReaxFF-nn with LAMMPS: 33 | https://gitee.com/fenggo/ReaxFF-nn_for_lammps 34 | 35 | https://github.com/fenggo/ReaxFF-nn_for_lammps 36 | 37 | -------------------------------------------------------------------------------- /doc/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/.keep -------------------------------------------------------------------------------- /doc/gulp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/gulp/.keep -------------------------------------------------------------------------------- /doc/gulp/GULP分子动力学模拟.md: -------------------------------------------------------------------------------- 1 | ## GULP分子动力学模拟 2 | ### 1、对结构进仿真模拟之前,最好优化一下分子结构及晶胞,使用如下命令: 3 | 4 | ```bash 5 | ./gmd.py opt --s=5000 --g=xxx.gen --l=1 # 或者 6 | ``` 7 | "--l=1" 表示对晶格(lattice)进行优化,"--l=0"表示不优,默认对晶格不优化。优化完成后,"gulp.cif"为优化完成后的晶体结构,将其重命、保存,以进行下一步仿真、模拟。 8 | 9 | ### 2、使用“gmd.py”脚本制作GULP输入文件: 10 | ```bash 11 | ./gmd.py nvt --s=1 --g=xxx.gen # 或者 ./gmd.py nvt --s=1 --g=xxx.cif 12 | ``` 13 | 其中“xxx.gen”和“xxx.cif”均为晶体结构文件。 14 | 15 | 扩展超胞 16 | 17 | ```bash 18 | ./gmd.py nvt --s=1 --g=xxx.gen --x=2 --y=2 --z=2 19 | ``` 20 | 扩展后为 2 $\times$ 2 $\times$ 2 超晶胞 21 | 22 | 脚本执行完毕可生成inp-gulp输入文件,其中“xxx.gen”为结构文件。根据需要编辑“inp-gulp”文件,使用 23 | ```bash 24 | nohup mpirun -n 8 gulpgulp.out 2>&1 & 25 | ``` 26 | 并行运行命令进行分子动力学模拟。 27 | 28 | ### 3、使用“gmd.py”脚本绘制温度、势能、压强随时间变化曲线: 29 | ```bash 30 | ./gmd.py plot --o=gulp.out 31 | ``` -------------------------------------------------------------------------------- /doc/gulp/GULP并行安装.md: -------------------------------------------------------------------------------- 1 | 下载地址:https://gulp.curtin.edu.au/gulp 2 | 3 | To install GULP on most Unix/Linux machines : 4 | 5 | (1) Go to Src/ 6 | 7 | (2) Type "./mkgulp -h" 该命令会列出所有可用选项 8 | 9 | NB: There are several flags that can be added depending on what options are required. The main options are: 10 | * -h => print help text to list the options below 11 | * -m => parallel compilation with MPI 12 | * -d => compile with debug options 13 | * -f => compile with FFTW3 for Smooth Particle Mesh Ewald 14 | * -k => compile with OpenKIM 15 | * -p => compile with Plumed plug-in 16 | * -c ARG => change the compiler to "ARG". gfortran (default) and intel are supported. 17 | * -j ARG => specify the number of cores to be used for task (i.e. make -j) 18 | * -t ARG => change the task to ARG. gulp (default), clean, lib, tar, fox-clean 19 | 20 | (3)找到下面部分内容, 修改“mkgulp”脚本内容: 21 | 22 | ```bash 23 | case $compiler in 24 | gfortran) 25 | ... 26 | # 215行,else后面的USER部分 27 | #--USER--Start 28 | echo 'SLIBS= -L/home/feng/mathlib/scalapack -lscalapack' >> makefile 29 | echo 'MLIBS= -L/home/feng/mathlib/lapack -llapack -ltmglib -lrefblas' >> makefile 30 | #--USER--End 31 | ``` 32 | 33 | (上面的库在“并行编译siesta.md”里面已经有编译方法,如果siesta编译好了,找到库文件所在路径就行了。OpenMPI编译参见“并行编译siesta.md”。) 34 | 35 | (4) 运行“mkgulp”脚本,加“-m”选项进行并行编译: 36 | 37 | ```bash 38 | ./mkgulp -m 39 | ``` 40 | 41 | (5) 测试GULP 42 | 43 | ```bash 44 | nohup mpirun -n 8 gulpgulp.out 2>&1 & 45 | ``` 46 | 47 | 其中 "-n"选项后面数字为CPU核心数,根据自己计算机(或工作站)实际情况设置。 -------------------------------------------------------------------------------- /doc/lammps/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/lammps/.keep -------------------------------------------------------------------------------- /doc/lammps/并行安装lammps.md: -------------------------------------------------------------------------------- 1 | 一、编译LAMMPS可执行文件 2 | 1. 安装依赖的库文件,打开终端,在终端中输入命令: 3 | ```shell 4 | sudo apt install libfftw3-3 libfftw3-dev libjpeg-dev libpng-dev 5 | ``` 6 | 如果软件名字对不上,可以使用"sudo apt search libfftw3"命令,搜索相近库,进行安装。 7 | 8 | 2. 将lammps/src/MAKE/MACHINES文件夹中的“Makefile.ubuntu”拷贝到lammps/src/MAKE/目录下。 9 | 10 | 3. 在lammps/src目录中运行命令 11 | ```shell 12 | make yes-reaxff 13 | make ubuntu 14 | ``` 15 | 二、编译LAMMPS Python接口 16 | 1. 在lammps/src目录中运行命令 17 | ```shell 18 | make ubuntu mode=shlib 19 | make install-python 20 | ``` 21 | 在python环境下运行 22 | ```python 23 | from lammps import lammps 24 | ``` 25 | 如能加载没有报错信息,安装成功。 -------------------------------------------------------------------------------- /doc/octave.md: -------------------------------------------------------------------------------- 1 | * 安装必要依赖 2 | sudo apt-get install libreadline-dev 3 | sudo apt install gnuplot 4 | sudo apt-get install texinfo 5 | 6 | 7 | ./configure 8 | 9 | make 10 | 11 | ./run_octave 12 | 13 | -------------------------------------------------------------------------------- /doc/qe/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/qe/.keep -------------------------------------------------------------------------------- /doc/qe/并行编译qe.md: -------------------------------------------------------------------------------- 1 | # 使用gfortran和openmpi并行编译QE 2 | 3 | ## QE下载 4 | https://github.com/QEF/q-e/releases 5 | 6 | ## 安装必要的编译软件 7 | (默认使用deepin linux系统) 8 | ``` 9 | sudo apt install build-essential 10 | sudo apt install g++ 11 | sudo apt install gfortran 12 | ``` 13 | 14 | ## Openmpi安装 15 | ``` 16 | 1 ./configure --prefix=/home/feng/siesta/mathlib/openmpi-gnu CC=gcc CXX=g++ F77=gfortran FC=gfortran 17 | 对于intel ./configure --prefix=/home/feng/siesta/mathlib/openmpi-intel CC=icc CXX=icpc F77=ifort FC=ifort 18 | 2 make all 19 | 3 make install 20 | 4 打开 ~/.bashrc 添加环境变量,用vi打开 21 | vi ~/.bashrc 22 | export PATH=/home/feng/siesta/mathlib/openmpi-gnu/bin:$PATH 23 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/feng/siesta/mathlib/openmpi-gnu/lib 24 | 25 | 5 source ~/.bashrc(重新打开终) 并验证 which mpicc 26 | which mpicc++ 27 | which mpif77 28 | which mpif90 29 | ``` 30 | 也可以使用命令安装openmpi, 不建议,推荐下载编译openmpi-2.0版本。 31 | 32 | ## QE安装 33 | ``` 34 | ./configure 35 | make all 36 | ``` 37 | ## 设置环境变量,将qe作为系统软件 38 | 打开 ~/.bashrc 文件(在主目录下,隐藏文件,可用vi打开 ``` vi ~/.bashrc ``` ),并添加下面一行代码: 39 | ``` 40 | export PATH=/QE文件夹的路径/qe-6.8/bin:$PATH 41 | ``` -------------------------------------------------------------------------------- /doc/siesta/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/siesta/.keep -------------------------------------------------------------------------------- /doc/图1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/图1.png -------------------------------------------------------------------------------- /doc/图2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/图2.png -------------------------------------------------------------------------------- /doc/图3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/doc/图3.png -------------------------------------------------------------------------------- /examples/example_al/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_al/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_ch4w2/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-0/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 9 MLP: -9.68196 DFT: -1153.10330 Diff: 1143.421341 dE: 0.0066 d2E: 0.0005 2 | 19 MLP: -9.77989 DFT: -1153.09500 Diff: 1143.315113 dE: 0.0127 d2E: 0.0007 3 | 29 MLP: -9.94254 DFT: -1153.03960 Diff: 1143.097062 dE: 0.0188 d2E: 0.0003 4 | 39 MLP: -10.13554 DFT: -1152.85950 Diff: 1142.723963 dE: 0.0193 d2E: 0.0001 5 | 49 MLP: -10.33333 DFT: -1152.48640 Diff: 1142.153072 dE: 0.0201 d2E: 0.0000 6 | 52 MLP: -10.39401 DFT: -1152.32990 Diff: 1141.935887 dE: 0.0203 d2E: 0.0001 7 | 59 MLP: -10.53189 DFT: -1151.88140 Diff: 1141.349507 dE: 0.0195 d2E: 0.0001 8 | 69 MLP: -10.72218 DFT: -1151.04310 Diff: 1140.320918 dE: 0.0186 d2E: 0.0001 9 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-0/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_ch4w2/ch4w2-0/ch4w2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 7 MLP: -1128.34806 DFT: -1153.10930 Diff: 24.761244 dE: 0.0009 d2E: 0.0002 2 | 14 MLP: -1128.35923 DFT: -1153.00740 Diff: 24.648173 dE: 0.0020 d2E: 0.0001 3 | 21 MLP: -1128.37604 DFT: -1152.72240 Diff: 24.346361 dE: 0.0027 d2E: 0.0001 4 | 28 MLP: -1128.39811 DFT: -1152.33920 Diff: 23.941095 dE: 0.0035 d2E: 0.0001 5 | 35 MLP: -1128.41920 DFT: -1151.90860 Diff: 23.489401 dE: 0.0020 d2E: 0.0000 6 | 42 MLP: -1128.43931 DFT: -1151.46150 Diff: 23.022195 dE: 0.0043 d2E: 0.0009 7 | 50 MLP: -1128.52449 DFT: -1150.95530 Diff: 22.430809 dE: 0.0177 d2E: 0.0024 8 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-1/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_ch4w2/ch4w2-1/ch4w2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -17.82988 DFT: -1153.41830 Diff: 1135.588421 dE: 0.0000 d2E: 0.0717 2 | 50 MLP: -18.48547 DFT: -1153.60310 Diff: 1135.117626 dE: 0.0030 d2E: 0.0019 3 | 100 MLP: -18.55694 DFT: -1153.63290 Diff: 1135.075965 dE: 0.0009 d2E: 0.0017 4 | 150 MLP: -18.58572 DFT: -1153.66190 Diff: 1135.076184 dE: 0.0006 d2E: 0.0002 5 | 200 MLP: -18.60323 DFT: -1153.67570 Diff: 1135.072467 dE: 0.0002 d2E: 0.0002 6 | 250 MLP: -18.61303 DFT: -1153.69020 Diff: 1135.077170 dE: 0.0002 d2E: 0.0001 7 | 272 MLP: -18.82216 DFT: -1153.29300 Diff: 1134.470836 dE: 0.1631 d2E: 0.1004 8 | 301 MLP: -19.31235 DFT: -1153.46850 Diff: 1134.156148 dE: 0.0001 d2E: 0.0000 9 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_ch4w2/ch4w2-2/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_ch4w2/ch4w2-2/ch4w2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-0.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-0.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-0/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -64.17250 DFT: -61.01370 Diff: 3.158796 dE: 0.0049 d2E: 0.0020 2 | 5 MLP: -64.17865 DFT: -61.69970 Diff: 2.478945 dE: 0.0006 d2E: 0.0002 3 | 10 MLP: -64.17943 DFT: -62.17770 Diff: 2.001731 dE: 0.0000 d2E: 0.0000 4 | 15 MLP: -64.17948 DFT: -62.41950 Diff: 1.759980 dE: 0.0000 d2E: 0.0000 5 | 20 MLP: -64.17948 DFT: -62.53240 Diff: 1.647078 dE: 0.0000 d2E: 0.0000 6 | 25 MLP: -64.17948 DFT: -62.58060 Diff: 1.598875 dE: 0.0000 d2E: 0.0000 7 | 30 MLP: -64.17947 DFT: -62.59760 Diff: 1.581874 dE: 0.0000 d2E: 0.0000 8 | 35 MLP: -64.17947 DFT: -62.60000 Diff: 1.579474 dE: 0.0000 d2E: 0.0000 9 | 40 MLP: -64.17947 DFT: -62.59950 Diff: 1.579973 dE: 0.0000 d2E: 0.0000 10 | 45 MLP: -64.17947 DFT: -62.60000 Diff: 1.579474 dE: 0.0000 d2E: 0.0000 11 | 50 MLP: -64.17947 DFT: -62.59960 Diff: 1.579874 dE: 0.0000 d2E: 0.0000 12 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-0/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-0/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-0/md.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-0/md.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -61.69494 DFT: -60.81310 Diff: 0.881845 dE: 0.1285 d2E: 0.0108 2 | 2 MLP: -61.81271 DFT: -60.93320 Diff: 0.879512 dE: 0.1178 d2E: 0.0100 3 | 3 MLP: -61.92051 DFT: -61.04700 Diff: 0.873514 dE: 0.1078 d2E: 0.0092 4 | 5 MLP: -62.10914 DFT: -61.25680 Diff: 0.852340 dE: 0.0900 d2E: 0.0079 5 | 10 MLP: -62.45225 DFT: -61.68970 Diff: 0.762551 dE: 0.0561 d2E: 0.0053 6 | 15 MLP: -62.66061 DFT: -62.01280 Diff: 0.647811 dE: 0.0333 d2E: 0.0036 7 | 20 MLP: -62.77876 DFT: -62.24810 Diff: 0.530659 dE: 0.0180 d2E: 0.0024 8 | 25 MLP: -62.83725 DFT: -62.41250 Diff: 0.424747 dE: 0.0080 d2E: 0.0015 9 | 30 MLP: -62.85699 DFT: -62.51950 Diff: 0.337491 dE: 0.0016 d2E: 0.0010 10 | 35 MLP: -62.85226 DFT: -62.57980 Diff: 0.272455 dE: 0.0024 d2E: 0.0006 11 | 40 MLP: -62.83271 DFT: -62.60200 Diff: 0.230708 dE: 0.0047 d2E: 0.0003 12 | 45 MLP: -62.80484 DFT: -62.59300 Diff: 0.211844 dE: 0.0060 d2E: 0.0002 13 | 50 MLP: -62.77296 DFT: -62.55830 Diff: 0.214664 dE: 0.0065 d2E: 0.0001 14 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-1/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-1/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-1/siesta.bib: -------------------------------------------------------------------------------- 1 | # This file contains the papers that you should cite in case of publishing a paper. 2 | # Each entry corresponds to using a feature that has been enabled via FDF-flags 3 | # and which is based on a development paper as indicated. 4 | 5 | # Primary SIESTA paper 6 | @article{Soler2002, 7 | journal = {{Journal of Physics: Condensed Matter}}, 8 | year = {2002}, 9 | volume = {14}, 10 | issue = {11}, 11 | doi = {10.1088/0953-8984/14/11/302}, 12 | } 13 | 14 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -61.23423 DFT: -62.14120 Diff: 0.906971 dE: 0.0240 d2E: 0.0018 2 | 5 MLP: -61.31299 DFT: -62.23160 Diff: 0.918610 dE: 0.0173 d2E: 0.0014 3 | 10 MLP: -61.37972 DFT: -62.31850 Diff: 0.938785 dE: 0.0110 d2E: 0.0010 4 | 15 MLP: -61.42132 DFT: -62.38290 Diff: 0.961581 dE: 0.0068 d2E: 0.0007 5 | 20 MLP: -61.44633 DFT: -62.43030 Diff: 0.983968 dE: 0.0040 d2E: 0.0004 6 | 25 MLP: -61.46081 DFT: -62.46550 Diff: 1.004694 dE: 0.0023 d2E: 0.0003 7 | 30 MLP: -61.46881 DFT: -62.49200 Diff: 1.023193 dE: 0.0012 d2E: 0.0002 8 | 35 MLP: -61.47293 DFT: -62.51210 Diff: 1.039169 dE: 0.0006 d2E: 0.0001 9 | 40 MLP: -61.47481 DFT: -62.52730 Diff: 1.052489 dE: 0.0002 d2E: 0.0000 10 | 45 MLP: -61.47543 DFT: -62.53850 Diff: 1.063066 dE: 0.0001 d2E: 0.0000 11 | 50 MLP: -61.47538 DFT: -62.54580 Diff: 1.070415 dE: 0.0000 d2E: 0.0000 12 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-2/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-2/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-2/md.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-2/md.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-3/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 4 MLP: -57.55072 DFT: -61.83110 Diff: 4.280377 dE: 0.0370 d2E: 0.0032 2 | 8 MLP: -57.38777 DFT: -62.17180 Diff: 4.784026 dE: 0.0400 d2E: 4.1649 3 | 12 MLP: -61.65287 DFT: -62.35630 Diff: 0.703433 dE: 0.1025 d2E: 0.0648 4 | 16 MLP: -61.59873 DFT: -62.45430 Diff: 0.855571 dE: 0.0545 d2E: 0.0785 5 | 20 MLP: -61.81755 DFT: -62.50760 Diff: 0.690054 dE: 0.0360 d2E: 0.0077 6 | 25 MLP: -61.87011 DFT: -62.54160 Diff: 0.671490 dE: 0.0541 d2E: 0.0082 7 | 29 MLP: -62.55647 DFT: -62.55030 Diff: 0.006167 dE: 0.1660 d2E: 0.0343 8 | 33 MLP: -62.88732 DFT: -62.54800 Diff: 0.339319 dE: 0.0410 d2E: 0.0156 9 | 37 MLP: -62.94043 DFT: -62.54490 Diff: 0.395530 dE: 0.0043 d2E: 0.0024 10 | 41 MLP: -62.94243 DFT: -62.54550 Diff: 0.396932 dE: 0.0012 d2E: 0.0001 11 | 45 MLP: -62.93893 DFT: -62.54750 Diff: 0.391433 dE: 0.0007 d2E: 0.0001 12 | 50 MLP: -62.93639 DFT: -62.54730 Diff: 0.389087 dE: 0.0004 d2E: 0.0001 13 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-3/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-3/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-3/in.fdf: -------------------------------------------------------------------------------- 1 | 2 | ################## Species and atoms ################## 3 | SystemName siesta 4 | SystemLabel siesta 5 | NumberOfSpecies 1 6 | NumberOfAtoms 4 7 | 8 | 9 | %block ChemicalSpeciesLabel 10 | 1 1 H 11 | %endblock ChemicalSpeciesLabel 12 | 13 | 14 | SolutionMethod Diagon # ## OrderN or Diagon 15 | MaxSCFIterations 500 16 | PAO.BasisType split 17 | %block PAO.Basis 18 | H 2 19 | n=1 0 2 S .7020340 20 | 4.4302740 0.0 21 | 1.000 1.000 22 | n=2 1 1 23 | 4.7841521 24 | 1.000 25 | %endblock PAO.Basis 26 | SpinPolarized F 27 | 28 | 29 | DM.MixingWeight 0.4 30 | DM.NumberPulay 9 31 | DM.Tolerance 1.d-4 32 | 33 | 34 | 35 | 36 | ################### FUNCTIONAL ################### 37 | XC.functional GGA # Exchange-correlation functional type 38 | XC.Authors PBE # Particular parametrization of xc func 39 | 40 | 41 | MeshCutoff 200. Ry # Equivalent planewave cutoff for the grid 42 | KgridCutoff 12.000000 Ang 43 | 44 | 45 | WriteCoorInitial T 46 | WriteCoorXmol T 47 | WriteMDhistory T 48 | WriteMullikenPop 1 49 | WriteForces T 50 | 51 | ################### GEOMETRY ################### 52 | 53 | LatticeConstant 1.00 Ang 54 | %block LatticeVectors 55 | 12.0 0.0 0.0 56 | 0.0 12.0 0.0 57 | 0.0 0.0 12.0 58 | %endblock LatticeVectors 59 | 60 | AtomicCoordinatesFormat Ang 61 | 62 | %block AtomicCoordinatesAndAtomicSpecies 63 | 3.917083774935344 3.69373315051698 4.12065573346065 1 64 | 4.414896644052805 3.520936319033012 4.593231714151679 1 65 | 1.5272302974573169 4.389944011723035 2.446173387879595 1 66 | 1.0657249670679318 4.519232132337925 1.9308927458173581 1 67 | %endblock AtomicCoordinatesAndAtomicSpecies 68 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-3/md.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-3/md.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-4/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -60.41887 DFT: -61.21440 Diff: 0.795527 dE: 0.3960 d2E: 0.0525 2 | 2 MLP: -60.76245 DFT: -61.64650 Diff: 0.884046 dE: 0.3436 d2E: 0.0531 3 | 3 MLP: -61.05292 DFT: -61.96880 Diff: 0.915878 dE: 0.2905 d2E: 0.0542 4 | 4 MLP: -61.28915 DFT: -62.20320 Diff: 0.914048 dE: 0.2362 d2E: 0.0555 5 | 5 MLP: -61.46992 DFT: -62.36670 Diff: 0.896783 dE: 0.1808 d2E: 0.0561 6 | 6 MLP: -61.59457 DFT: -62.47280 Diff: 0.878227 dE: 0.1247 d2E: 0.0549 7 | 7 MLP: -61.66437 DFT: -62.53220 Diff: 0.867830 dE: 0.0698 d2E: 0.0496 8 | 8 MLP: -61.68460 DFT: -62.55350 Diff: 0.868900 dE: 0.0202 d2E: 0.0374 9 | 10 MLP: -61.63427 DFT: -62.50770 Diff: 0.873426 dE: 0.0332 d2E: 0.0128 10 | 12 MLP: -61.63291 DFT: -62.37650 Diff: 0.743591 dE: 0.0190 d2E: 0.0496 11 | 15 MLP: -61.92977 DFT: -62.07730 Diff: 0.147532 dE: 0.1219 d2E: 0.0008 12 | 17 MLP: -62.16443 DFT: -61.83530 Diff: 0.329129 dE: 0.1135 d2E: 0.0090 13 | 20 MLP: -62.45218 DFT: -61.43670 Diff: 1.015476 dE: 0.0875 d2E: 0.0076 14 | 22 MLP: -62.60515 DFT: -61.15840 Diff: 1.446749 dE: 0.0730 d2E: 0.0064 15 | 25 MLP: -62.78783 DFT: -60.73480 Diff: 2.053034 dE: 0.0553 d2E: 0.0050 16 | 27 MLP: -62.88402 DFT: -60.45370 Diff: 2.430324 dE: 0.0458 d2E: 0.0042 17 | 30 MLP: -62.99772 DFT: -60.04070 Diff: 2.957022 dE: 0.0343 d2E: 0.0032 18 | 32 MLP: -63.05684 DFT: -59.77390 Diff: 3.282941 dE: 0.0281 d2E: 0.0027 19 | 35 MLP: -63.12568 DFT: -59.39000 Diff: 3.735684 dE: 0.0206 d2E: 0.0021 20 | 37 MLP: -63.16082 DFT: -59.14640 Diff: 4.014416 dE: 0.0166 d2E: 0.0017 21 | 40 MLP: -63.20080 DFT: -58.80050 Diff: 4.400296 dE: 0.0118 d2E: 0.0013 22 | 42 MLP: -63.22059 DFT: -58.58330 Diff: 4.637291 dE: 0.0093 d2E: 0.0011 23 | 45 MLP: -63.24225 DFT: -58.27750 Diff: 4.964753 dE: 0.0063 d2E: 0.0008 24 | 47 MLP: -63.25240 DFT: -58.08690 Diff: 5.165503 dE: 0.0047 d2E: 0.0007 25 | 50 MLP: -63.26266 DFT: -57.82030 Diff: 5.442364 dE: 0.0028 d2E: 0.0006 26 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-4/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-4/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-5/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -62.53284 DFT: -62.54800 Diff: 0.015156 dE: 0.0785 d2E: 0.0091 2 | 4 MLP: -62.71647 DFT: -62.55030 Diff: 0.166173 dE: 0.0533 d2E: 0.0071 3 | 8 MLP: -62.86475 DFT: -62.54700 Diff: 0.317751 dE: 0.0285 d2E: 0.0049 4 | 12 MLP: -62.93362 DFT: -62.54460 Diff: 0.389019 dE: 0.0113 d2E: 0.0033 5 | 16 MLP: -62.94845 DFT: -62.54560 Diff: 0.402850 dE: 0.0002 d2E: 0.0022 6 | 20 MLP: -62.92777 DFT: -62.54750 Diff: 0.380273 dE: 0.0077 d2E: 0.0014 7 | 25 MLP: -62.87200 DFT: -62.54730 Diff: 0.324701 dE: 0.0130 d2E: 0.0007 8 | 29 MLP: -62.81462 DFT: -62.54540 Diff: 0.269218 dE: 0.0150 d2E: 0.0003 9 | 33 MLP: -62.75267 DFT: -62.54310 Diff: 0.209565 dE: 0.0157 d2E: 0.0000 10 | 37 MLP: -62.69028 DFT: -62.54050 Diff: 0.149779 dE: 0.0155 d2E: 0.0001 11 | 41 MLP: -62.63017 DFT: -62.53730 Diff: 0.092875 dE: 0.0147 d2E: 0.0003 12 | 45 MLP: -62.57402 DFT: -62.53420 Diff: 0.039822 dE: 0.0136 d2E: 0.0003 13 | 50 MLP: -62.51076 DFT: -62.53150 Diff: 0.020742 dE: 0.0120 d2E: 0.0003 14 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-5/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-5/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-6/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -59.66185 DFT: -61.59990 Diff: 1.938047 dE: 0.2031 d2E: 0.3757 2 | 2 MLP: -60.24062 DFT: -61.72710 Diff: 1.486484 dE: 0.5788 d2E: 0.0373 3 | 3 MLP: -60.85671 DFT: -61.83940 Diff: 0.982690 dE: 0.6161 d2E: 0.3644 4 | 4 MLP: -61.10844 DFT: -61.93870 Diff: 0.830261 dE: 0.2517 d2E: 0.2432 5 | 5 MLP: -61.11700 DFT: -62.02640 Diff: 0.909396 dE: 0.0086 d2E: 0.0439 6 | 8 MLP: -61.01803 DFT: -62.23220 Diff: 1.214174 dE: 0.0332 d2E: 0.0127 7 | 16 MLP: -61.17081 DFT: -62.50450 Diff: 1.333694 dE: 0.0680 d2E: 0.0388 8 | 25 MLP: -61.17155 DFT: -62.58930 Diff: 1.417750 dE: 0.0009 d2E: 0.0002 9 | 33 MLP: -61.17234 DFT: -62.60010 Diff: 1.427758 dE: 0.0003 d2E: 0.0000 10 | 41 MLP: -61.16911 DFT: -62.59950 Diff: 1.430389 dE: 0.0004 d2E: 0.0000 11 | 50 MLP: -61.16585 DFT: -62.59960 Diff: 1.433755 dE: 0.0003 d2E: 0.0000 12 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-6/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-6/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-7/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 2 MLP: -59.49960 DFT: -61.08790 Diff: 1.588302 dE: 0.0317 d2E: 0.0245 2 | 5 MLP: -59.73780 DFT: -61.04350 Diff: 1.305696 dE: 0.1022 d2E: 0.0208 3 | 7 MLP: -60.00260 DFT: -60.98850 Diff: 0.985903 dE: 0.1419 d2E: 0.0170 4 | 10 MLP: -60.52267 DFT: -60.84910 Diff: 0.326429 dE: 0.1872 d2E: 0.0116 5 | 12 MLP: -60.93055 DFT: -60.70990 Diff: 0.220654 dE: 0.2090 d2E: 0.0089 6 | 15 MLP: -61.60346 DFT: -60.42680 Diff: 1.176657 dE: 0.2299 d2E: 0.0048 7 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-7/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-7/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-8/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 8 MLP: -60.76567 DFT: -61.32320 Diff: 0.557532 dE: 0.0089 d2E: 0.0002 2 | 16 MLP: -60.68638 DFT: -61.38180 Diff: 0.695423 dE: 0.0107 d2E: 0.0002 3 | 25 MLP: -60.57845 DFT: -61.43530 Diff: 0.856855 dE: 0.0130 d2E: 0.0003 4 | 33 MLP: -60.46375 DFT: -61.46990 Diff: 1.006148 dE: 0.0154 d2E: 0.0003 5 | 41 MLP: -60.32857 DFT: -61.49000 Diff: 1.161427 dE: 0.0181 d2E: 0.0004 6 | 50 MLP: -60.14718 DFT: -61.49190 Diff: 1.344724 dE: 0.0218 d2E: 0.0004 7 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-8/h22.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-8/h22.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-8/md.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-8/md.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h22/h22-v.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h22/h22-v.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-0/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -80.35093 DFT: -7476.01510 Diff: 7395.664165 dE: 0.2855 d2E: 0.2429 2 | 3 MLP: -80.91574 DFT: -7476.93100 Diff: 7396.015264 dE: 0.5222 d2E: 0.5411 3 | 5 MLP: -81.46119 DFT: -7477.37190 Diff: 7395.910714 dE: 0.5643 d2E: 0.9012 4 | 7 MLP: -81.37798 DFT: -7476.52040 Diff: 7395.142419 dE: 0.2537 d2E: 0.0668 5 | 10 MLP: -81.87453 DFT: -7477.84070 Diff: 7395.966169 dE: 0.2729 d2E: 0.2014 6 | 12 MLP: -81.98587 DFT: -7477.55260 Diff: 7395.566733 dE: 0.0399 d2E: 0.0547 7 | 14 MLP: -82.28534 DFT: -7478.21360 Diff: 7395.928255 dE: 0.3143 d2E: 0.5721 8 | 16 MLP: -82.38787 DFT: -7478.14540 Diff: 7395.757527 dE: 0.3604 d2E: 0.5698 9 | 18 MLP: -82.45661 DFT: -7476.89550 Diff: 7394.438893 dE: 0.2781 d2E: 0.1971 10 | 20 MLP: -82.59043 DFT: -7475.67560 Diff: 7393.085165 dE: 0.0528 d2E: 0.1801 11 | 21 MLP: -82.46312 DFT: -7475.61970 Diff: 7393.156585 dE: 0.1273 d2E: 0.3589 12 | 24 MLP: -82.81246 DFT: -7475.15460 Diff: 7392.342141 dE: 0.1094 d2E: 0.3794 13 | 27 MLP: -82.29997 DFT: -7475.63390 Diff: 7393.333930 dE: 0.1754 d2E: 0.2847 14 | 29 MLP: -82.37203 DFT: -7474.18930 Diff: 7391.817269 dE: 0.0372 d2E: 0.0510 15 | 31 MLP: -82.73540 DFT: -7475.07440 Diff: 7392.339002 dE: 0.3495 d2E: 0.4114 16 | 32 MLP: -82.67355 DFT: -7474.99360 Diff: 7392.320052 dE: 0.0619 d2E: 0.2704 17 | 34 MLP: -83.10328 DFT: -7475.67120 Diff: 7392.567922 dE: 0.2212 d2E: 0.4020 18 | 37 MLP: -82.64505 DFT: -7475.93140 Diff: 7393.286346 dE: 0.1897 d2E: 0.1492 19 | 38 MLP: -82.60458 DFT: -7476.34230 Diff: 7393.737717 dE: 0.0405 d2E: 0.2776 20 | 40 MLP: -81.96946 DFT: -7476.46650 Diff: 7394.497036 dE: 0.3171 d2E: 0.9850 21 | 42 MLP: -82.43414 DFT: -7476.12040 Diff: 7393.686260 dE: 0.2033 d2E: 0.4211 22 | 43 MLP: -82.65191 DFT: -7475.83060 Diff: 7393.178692 dE: 0.2178 d2E: 0.3702 23 | 45 MLP: -82.50006 DFT: -7475.65070 Diff: 7393.150641 dE: 0.0006 d2E: 0.0993 24 | 47 MLP: -82.06450 DFT: -7474.92340 Diff: 7392.858898 dE: 0.3368 d2E: 0.2867 25 | 49 MLP: -82.28447 DFT: -7473.62200 Diff: 7391.337527 dE: 0.2701 d2E: 0.3202 26 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-0/h2o16.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/h2o16-0/h2o16.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -79.94551 DFT: -7476.27960 Diff: 7396.334085 dE: 0.2717 d2E: 0.4913 2 | 4 MLP: -81.14178 DFT: -7478.07350 Diff: 7396.931718 dE: 0.1780 d2E: 0.3538 3 | 7 MLP: -80.72534 DFT: -7477.26950 Diff: 7396.544162 dE: 0.3744 d2E: 0.2766 4 | 10 MLP: -81.28935 DFT: -7477.24630 Diff: 7395.956946 dE: 0.3536 d2E: 0.1955 5 | 13 MLP: -80.71875 DFT: -7476.12170 Diff: 7395.402947 dE: 0.2073 d2E: 0.2492 6 | 14 MLP: -81.17526 DFT: -7476.81120 Diff: 7395.635938 dE: 0.4565 d2E: 0.0871 7 | 17 MLP: -81.46744 DFT: -7477.75140 Diff: 7396.283959 dE: 0.3419 d2E: 0.3179 8 | 20 MLP: -81.92556 DFT: -7478.14790 Diff: 7396.222338 dE: 0.2190 d2E: 0.2548 9 | 21 MLP: -81.88970 DFT: -7478.03600 Diff: 7396.146299 dE: 0.0359 d2E: 0.1771 10 | 24 MLP: -81.75397 DFT: -7477.50410 Diff: 7395.750128 dE: 0.0774 d2E: 0.1469 11 | 27 MLP: -81.67249 DFT: -7477.45470 Diff: 7395.782213 dE: 0.0625 d2E: 0.2353 12 | 28 MLP: -81.84534 DFT: -7477.66520 Diff: 7395.819860 dE: 0.1729 d2E: 0.1715 13 | 33 MLP: -81.81283 DFT: -7477.62910 Diff: 7395.816266 dE: 0.2958 d2E: 0.3506 14 | 35 MLP: -82.08830 DFT: -7478.02140 Diff: 7395.933102 dE: 0.2206 d2E: 0.1174 15 | 39 MLP: -81.85404 DFT: -7477.16740 Diff: 7395.313364 dE: 0.2021 d2E: 0.3248 16 | 42 MLP: -82.21832 DFT: -7477.70530 Diff: 7395.486976 dE: 0.0832 d2E: 0.0244 17 | 45 MLP: -82.05275 DFT: -7477.64180 Diff: 7395.589055 dE: 0.1191 d2E: 0.2339 18 | 48 MLP: -82.58795 DFT: -7478.30130 Diff: 7395.713354 dE: 0.1557 d2E: 0.2433 19 | 49 MLP: -82.50034 DFT: -7478.17870 Diff: 7395.678361 dE: 0.0876 d2E: 0.2433 20 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-1/h2o16.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/h2o16-1/h2o16.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -108.62236 DFT: -7481.38100 Diff: 7372.758636 dE: 0.4782 d2E: 0.4153 2 | 7 MLP: -108.76223 DFT: -7481.77680 Diff: 7373.014566 dE: 0.0083 d2E: 0.0010 3 | 14 MLP: -108.80177 DFT: -7481.88790 Diff: 7373.086126 dE: 0.0042 d2E: 0.0003 4 | 21 MLP: -108.82805 DFT: -7481.93500 Diff: 7373.106952 dE: 0.0041 d2E: 0.0035 5 | 28 MLP: -108.87390 DFT: -7482.04050 Diff: 7373.166605 dE: 0.0047 d2E: 0.0003 6 | 35 MLP: -108.89130 DFT: -7482.08260 Diff: 7373.191301 dE: 0.0021 d2E: 0.0002 7 | 42 MLP: -108.92082 DFT: -7482.14070 Diff: 7373.219883 dE: 0.0045 d2E: 0.0004 8 | 49 MLP: -108.95111 DFT: -7482.19320 Diff: 7373.242089 dE: 0.0046 d2E: 0.0002 9 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-2/h2o16.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/h2o16-2/h2o16.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-3/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -106.16046 DFT: -7479.20380 Diff: 7373.043337 dE: 0.1825 d2E: 0.1611 2 | 4 MLP: -106.47558 DFT: -7479.53300 Diff: 7373.057417 dE: 0.0975 d2E: 0.1113 3 | 7 MLP: -106.74661 DFT: -7479.82710 Diff: 7373.080493 dE: 0.1868 d2E: 0.5650 4 | 11 MLP: -105.96152 DFT: -7477.98760 Diff: 7372.026078 dE: 0.2775 d2E: 0.2361 5 | 14 MLP: -106.45769 DFT: -7479.38680 Diff: 7372.929110 dE: 0.2356 d2E: 0.2553 6 | 18 MLP: -106.65806 DFT: -7479.84870 Diff: 7373.190637 dE: 0.0250 d2E: 0.1135 7 | 21 MLP: -106.22858 DFT: -7479.24700 Diff: 7373.018417 dE: 0.1838 d2E: 0.1185 8 | 25 MLP: -106.48979 DFT: -7479.54970 Diff: 7373.059910 dE: 0.1971 d2E: 0.0577 9 | 28 MLP: -106.54166 DFT: -7479.72340 Diff: 7373.181743 dE: 0.1328 d2E: 0.2834 10 | 31 MLP: -106.62392 DFT: -7479.73230 Diff: 7373.108382 dE: 0.1582 d2E: 0.1260 11 | 34 MLP: -106.55039 DFT: -7479.22010 Diff: 7372.669714 dE: 0.1162 d2E: 0.2543 12 | 35 MLP: -106.41230 DFT: -7479.01700 Diff: 7372.604697 dE: 0.1381 d2E: 0.1061 13 | 38 MLP: -106.67218 DFT: -7479.47710 Diff: 7372.804924 dE: 0.1317 d2E: 0.2714 14 | 41 MLP: -106.77467 DFT: -7479.86100 Diff: 7373.086327 dE: 0.2616 d2E: 0.2477 15 | 42 MLP: -106.78855 DFT: -7479.92160 Diff: 7373.133054 dE: 0.0139 d2E: 0.2593 16 | 45 MLP: -106.63727 DFT: -7479.63450 Diff: 7372.997235 dE: 0.1199 d2E: 0.0751 17 | 48 MLP: -106.44966 DFT: -7479.53530 Diff: 7373.085639 dE: 0.1169 d2E: 0.1904 18 | 49 MLP: -106.52314 DFT: -7479.60320 Diff: 7373.080065 dE: 0.0735 d2E: 0.1904 19 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-3/h2o16.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/h2o16-3/h2o16.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-4/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -107.75443 DFT: -7480.38110 Diff: 7372.626668 dE: 1.5078 d2E: 1.1798 2 | 4 MLP: -108.38660 DFT: -7480.90840 Diff: 7372.521796 dE: 0.1231 d2E: 0.0275 3 | 7 MLP: -108.63516 DFT: -7481.17550 Diff: 7372.540339 dE: 0.0632 d2E: 0.0270 4 | 14 MLP: -108.77885 DFT: -7481.42660 Diff: 7372.647748 dE: 0.0286 d2E: 0.0013 5 | 21 MLP: -108.88070 DFT: -7481.66180 Diff: 7372.781101 dE: 0.0151 d2E: 0.0058 6 | 28 MLP: -108.96993 DFT: -7481.80510 Diff: 7372.835168 dE: 0.0033 d2E: 0.0004 7 | 35 MLP: -109.07944 DFT: -7481.83380 Diff: 7372.754356 dE: 0.0411 d2E: 0.0043 8 | 42 MLP: -109.17821 DFT: -7481.89940 Diff: 7372.721189 dE: 0.0072 d2E: 0.0001 9 | 49 MLP: -109.23458 DFT: -7482.04340 Diff: 7372.808824 dE: 0.0029 d2E: 0.0006 10 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o16/h2o16-4/h2o16.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o16/h2o16-4/h2o16.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-0/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -1.60714 DFT: -934.35380 Diff: 932.746663 dE: 0.0000 d2E: 0.1927 2 | 2 MLP: -1.79987 DFT: -934.34160 Diff: 932.541730 dE: 0.1927 d2E: 0.1426 3 | 4 MLP: -1.94074 DFT: -933.72580 Diff: 931.785057 dE: 0.0908 d2E: 0.0394 4 | 6 MLP: -1.99781 DFT: -932.25100 Diff: 930.253192 dE: 0.0057 d2E: 0.0390 5 | 8 MLP: -2.04690 DFT: -932.33050 Diff: 930.283602 dE: 0.0044 d2E: 0.0009 6 | 11 MLP: -2.11983 DFT: -930.15310 Diff: 928.033274 dE: 0.0369 d2E: 0.0062 7 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-0/h2o2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/h2o2-0/h2o2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -912.64780 DFT: -934.36800 Diff: 21.720196 dE: 0.0103 d2E: 0.0013 2 | 7 MLP: -912.60885 DFT: -934.32320 Diff: 21.714346 dE: 0.0045 d2E: 0.0012 3 | 14 MLP: -912.58185 DFT: -934.09540 Diff: 21.513547 dE: 0.0019 d2E: 0.0007 4 | 21 MLP: -912.58863 DFT: -933.75950 Diff: 21.170866 dE: 0.0029 d2E: 0.0005 5 | 28 MLP: -912.62247 DFT: -933.36990 Diff: 20.747432 dE: 0.0060 d2E: 0.0003 6 | 35 MLP: -912.67031 DFT: -932.95670 Diff: 20.286393 dE: 0.0072 d2E: 0.0000 7 | 42 MLP: -912.71944 DFT: -932.54490 Diff: 19.825461 dE: 0.0067 d2E: 0.0002 8 | 50 MLP: -912.76471 DFT: -932.09140 Diff: 19.326693 dE: 0.0048 d2E: 0.0003 9 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-1/h2o2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/h2o2-1/h2o2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -912.99024 DFT: -934.51360 Diff: 21.523364 dE: 0.0536 d2E: 0.0138 2 | 6 MLP: -913.10646 DFT: -934.62170 Diff: 21.515238 dE: 0.0006 d2E: 0.0018 3 | 7 MLP: -913.10524 DFT: -934.63790 Diff: 21.532661 dE: 0.0012 d2E: 0.0001 4 | 14 MLP: -913.09355 DFT: -934.71530 Diff: 21.621751 dE: 0.0020 d2E: 0.0001 5 | 21 MLP: -913.07752 DFT: -934.75200 Diff: 21.674479 dE: 0.0025 d2E: 0.0001 6 | 28 MLP: -913.05825 DFT: -934.76150 Diff: 21.703250 dE: 0.0029 d2E: 0.0001 7 | 35 MLP: -913.03639 DFT: -934.75670 Diff: 21.720306 dE: 0.0033 d2E: 0.0000 8 | 42 MLP: -913.01243 DFT: -934.74760 Diff: 21.735169 dE: 0.0035 d2E: 0.0001 9 | 50 MLP: -912.98269 DFT: -934.73060 Diff: 21.747908 dE: 0.0038 d2E: 0.0000 10 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-2/h2o2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/h2o2-2/h2o2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-3/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -912.84869 DFT: -934.74840 Diff: 21.899712 dE: 0.0057 d2E: 0.0005 2 | 5 MLP: -912.83015 DFT: -934.73000 Diff: 21.899850 dE: 0.0040 d2E: 0.0014 3 | 7 MLP: -912.81949 DFT: -934.69230 Diff: 21.872805 dE: 0.0053 d2E: 0.0000 4 | 14 MLP: -912.78354 DFT: -934.45320 Diff: 21.669656 dE: 0.0050 d2E: 0.0000 5 | 21 MLP: -912.75011 DFT: -934.10460 Diff: 21.354489 dE: 0.0046 d2E: 0.0001 6 | 28 MLP: -912.71955 DFT: -933.69800 Diff: 20.978446 dE: 0.0042 d2E: 0.0001 7 | 35 MLP: -912.69208 DFT: -933.26600 Diff: 20.573924 dE: 0.0037 d2E: 0.0001 8 | 42 MLP: -912.66803 DFT: -932.82960 Diff: 20.161567 dE: 0.0032 d2E: 0.0001 9 | 50 MLP: -912.64604 DFT: -932.34240 Diff: 19.696356 dE: 0.0023 d2E: 0.0001 10 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-3/h2o2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/h2o2-3/h2o2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-4/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -2.39137 DFT: -934.35380 Diff: 931.962429 dE: 0.0000 d2E: 0.4231 2 | 4 MLP: -2.98109 DFT: -934.36170 Diff: 931.380610 dE: 0.0420 d2E: 0.0207 3 | 8 MLP: -3.11230 DFT: -933.99620 Diff: 930.883896 dE: 0.0031 d2E: 0.0267 4 | 13 MLP: -3.16746 DFT: -933.67660 Diff: 930.509136 dE: 0.0002 d2E: 0.0013 5 | 17 MLP: -3.19596 DFT: -933.46880 Diff: 930.272843 dE: 0.0123 d2E: 0.0021 6 | 22 MLP: -3.22605 DFT: -933.11670 Diff: 929.890648 dE: 0.0021 d2E: 0.0019 7 | 26 MLP: -3.23942 DFT: -933.23420 Diff: 929.994781 dE: 0.0046 d2E: 0.0004 8 | 31 MLP: -3.25092 DFT: -933.18830 Diff: 929.937376 dE: 0.0007 d2E: 0.0002 9 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-4/h2o2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/aimd_h2o2/h2o2-4/h2o2.traj -------------------------------------------------------------------------------- /examples/example_ch4h2o/aimd_h2o2/h2o2-4/in.fdf: -------------------------------------------------------------------------------- 1 | 2 | ################## Species and atoms ################## 3 | SystemName siesta 4 | SystemLabel siesta 5 | NumberOfSpecies 2 6 | NumberOfAtoms 6 7 | 8 | 9 | %block ChemicalSpeciesLabel 10 | 1 8 O 11 | 2 1 H 12 | %endblock ChemicalSpeciesLabel 13 | 14 | 15 | SolutionMethod Diagon # ## OrderN or Diagon 16 | PAO.BasisType split 17 | %block PAO.Basis 18 | O 3 19 | n=2 0 2 S .3704717 20 | 5.1368012 0.0 21 | 1.000 1.000 22 | n=2 1 2 S .5000000 23 | 5.7187560 0.0 24 | 1.000 1.000 25 | n=3 2 1 26 | 3.0328434 27 | 1.000 28 | H 2 29 | n=1 0 2 S .7020340 30 | 4.4302740 0.0 31 | 1.000 1.000 32 | n=2 1 1 33 | 4.7841521 34 | 1.000 35 | %endblock PAO.Basis 36 | 37 | SpinPolarized F 38 | 39 | DM.MixingWeight 0.4 40 | DM.NumberPulay 9 41 | DM.Tolerance 1.d-4 42 | 43 | 44 | 45 | 46 | ################### FUNCTIONAL ################### 47 | XC.functional GGA # Exchange-correlation functional type 48 | XC.Authors PBE # Particular parametrization of xc func 49 | 50 | 51 | MeshCutoff 200. Ry # Equivalent planewave cutoff for the grid 52 | KgridCutoff 10.000000 Ang 53 | 54 | 55 | WriteCoorInitial T 56 | WriteCoorXmol T 57 | WriteMDhistory T 58 | WriteMullikenPop 1 59 | WriteForces T 60 | 61 | ################### GEOMETRY ################### 62 | 63 | LatticeConstant 1.00 Ang 64 | %block LatticeVectors 65 | 10.0 0.0 0.0 66 | 0.0 10.0 0.0 67 | 0.0 0.0 10.0 68 | %endblock LatticeVectors 69 | 70 | AtomicCoordinatesFormat Ang 71 | 72 | %block AtomicCoordinatesAndAtomicSpecies 73 | 5.58517994 5.01423095 5.355920764 1 74 | 5.118169226 5.411781474 5.894422172 2 75 | 5.040498106 4.755444213 4.566582468 2 76 | 3.621495458 4.676485574 3.919873548 1 77 | 2.932962005 4.915738665 4.366178472 2 78 | 3.305411438 4.339141928 3.125830519 2 79 | %endblock AtomicCoordinatesAndAtomicSpecies 80 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/ch4w2.gen: -------------------------------------------------------------------------------- 1 | 11 S 2 | H O C 3 | 1 1 3.611931293925431 4.940602059954144 6.460928437193730 4 | 2 2 4.331720802925431 4.294581313954144 6.203695685193730 5 | 3 1 4.067015006925431 3.781041638954144 6.994480649193730 6 | 4 1 3.511056046000000 3.619131107000000 4.128018747000000 7 | 5 2 3.634828392000000 2.742112305000000 4.624964480000000 8 | 6 1 4.129138189000000 3.257674399000000 5.302892115000000 9 | 7 1 5.147141569000000 3.241268366000000 6.891447014000000 10 | 8 3 4.736426546000000 2.734241539000000 7.724414618000000 11 | 9 1 5.529343404000000 2.413202769000000 8.368676399000000 12 | 10 1 4.179449512000000 1.883564162000000 7.396963870000000 13 | 11 1 4.096573925000000 3.398279860000000 8.271057382000000 14 | 0.000000000000000 0.000000000000000 0.000000000000000 15 | 10.000000000000000 0.000000000000000 0.000000000000000 16 | 0.000000000000000 10.000000000000000 0.000000000000000 17 | 0.000000000000000 0.000000000000000 10.000000000000000 18 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/h22.gen: -------------------------------------------------------------------------------- 1 | 4 S 2 | H 3 | 1 1 4.032945545570579 3.286415653518892 4.186117036473773 4 | 2 1 3.686661848162135 3.921252641757740 4.070286636695920 5 | 3 1 2.887801229343690 3.972618039241185 3.419559170503191 6 | 4 1 2.459896267573239 4.187462603791312 2.860740595070991 7 | 0.000000000000000 0.000000000000000 0.000000000000000 8 | 12.000000000000000 0.000000000000000 0.000000000000000 9 | 0.000000000000000 12.000000000000000 0.000000000000000 10 | 0.000000000000000 0.000000000000000 12.000000000000000 11 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/h2o2.gen: -------------------------------------------------------------------------------- 1 | 6 S 2 | O H 3 | 1 1 5.585179940065935 5.014230950463548 5.355920764367299 4 | 2 2 5.036505092326785 5.496798080859664 6.050459017212695 5 | 3 2 4.944843734219984 4.899891767170433 4.621433540092696 6 | 4 1 3.795344989148755 4.491408593628356 3.809651379432693 7 | 5 2 3.246670141409604 4.973975724024476 4.504189632278091 8 | 6 2 3.155008783302804 4.377069410335239 3.075164155158081 9 | 0.000000000000000 0.000000000000000 0.000000000000000 10 | 10.000000000000000 0.000000000000000 0.000000000000000 11 | 0.000000000000000 10.000000000000000 0.000000000000000 12 | 0.000000000000000 0.000000000000000 10.000000000000000 13 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/json_to_ffield.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_ffield,write_ffield 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import argh 6 | import argparse 7 | import json as js 8 | from os import environ,system 9 | import csv 10 | import pandas as pd 11 | from os.path import isfile 12 | 13 | 14 | 15 | def jsontoffield(): 16 | lf = open('ffield.json','r') 17 | j = js.load(lf) 18 | p_ = j['p'] 19 | m_ = j['m'] 20 | mf_layer = j['mf_layer'] 21 | be_layer = j['be_layer'] 22 | lf.close() 23 | 24 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 25 | write_ffield(p_,spec,bonds,offd,angs,torp,hbs, 26 | m=m_,mf_layer=mf_layer,be_layer=be_layer, 27 | libfile='ffield') 28 | 29 | 30 | def init_bonds(p_): 31 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 32 | for key in p_: 33 | # key = key.encode('raw_unicode_escape') 34 | # print(key) 35 | k = key.split('_') 36 | if k[0]=='bo1': 37 | bonds.append(k[1]) 38 | elif k[0]=='rosi': 39 | kk = k[1].split('-') 40 | # print(kk) 41 | if len(kk)==2: 42 | if kk[0]!=kk[1]: 43 | offd.append(k[1]) 44 | elif len(kk)==1: 45 | spec.append(k[1]) 46 | elif k[0]=='theta0': 47 | angs.append(k[1]) 48 | elif k[0]=='tor1': 49 | torp.append(k[1]) 50 | elif k[0]=='rohb': 51 | hbs.append(k[1]) 52 | return spec,bonds,offd,angs,torp,hbs 53 | 54 | 55 | if __name__ == '__main__': 56 | jsontoffield() 57 | 58 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/json_to_lib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_ffield,write_lib,write_lib 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import argh 6 | import argparse 7 | import json as js 8 | from os import environ,system 9 | import csv 10 | import pandas as pd 11 | from os.path import isfile 12 | 13 | 14 | 15 | def ffieldtolib(): 16 | lf = open('ffield.json','r') 17 | j = js.load(lf) 18 | p_ = j['p'] 19 | m_ = j['m'] 20 | vdw_layer = j['vdw_layer'] 21 | mf_layer = j['mf_layer'] 22 | be_layer = j['be_layer'] 23 | lf.close() 24 | 25 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 26 | write_lib(p_,spec,bonds,offd,angs,torp,hbs,m=m_,mf_layer=mf_layer, 27 | be_layer=be_layer,vdw_layer=vdw_layer, 28 | libfile='reaxff_nn.lib') 29 | 30 | 31 | def init_bonds(p_): 32 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 33 | for key in p_: 34 | # key = key.encode('raw_unicode_escape') 35 | # print(key) 36 | k = key.split('_') 37 | if k[0]=='bo1': 38 | bonds.append(k[1]) 39 | elif k[0]=='rosi': 40 | kk = k[1].split('-') 41 | # print(kk) 42 | if len(kk)==2: 43 | if kk[0]!=kk[1]: 44 | offd.append(k[1]) 45 | elif len(kk)==1: 46 | spec.append(k[1]) 47 | elif k[0]=='theta0': 48 | angs.append(k[1]) 49 | elif k[0]=='tor1': 50 | torp.append(k[1]) 51 | elif k[0]=='rohb': 52 | hbs.append(k[1]) 53 | return spec,bonds,offd,angs,torp,hbs 54 | 55 | 56 | if __name__ == '__main__': 57 | ffieldtolib() 58 | 59 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/lm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import matplotlib 3 | matplotlib.use('Agg') 4 | from irff.LearningMachine import LearningMachine 5 | from irff.data.ColData import ColData 6 | from irff.dft.CheckEmol import check_emol 7 | from train import clip,strucs,cons,weight,bo_clip,pi_clip 8 | 9 | dataset = {'h22-v':'aimd_h22/h22-v.traj', 10 | # 'dia-0':'data/dia-0.traj', 11 | # 'gp2-0':'data/gp2-0.traj', 12 | # 'gp2-1':'data/gp2-1.traj', 13 | } 14 | 15 | getdata = ColData() 16 | 17 | 18 | batch = 50 19 | batchs = {'others':batch } 20 | 21 | for mol in strucs: 22 | b = batchs[mol] if mol in batchs else batchs['others'] 23 | trajs = getdata(label=mol,batch=b) 24 | dataset.update(trajs) 25 | check_emol(dataset) 26 | 27 | 28 | lm = LearningMachine(config='hc11.gen', 29 | dataset=dataset,ncpu=8,batch=batch, 30 | maxiter=0, 31 | step=20000,col_frame=8,col_min_interval=5, 32 | T=2000, 33 | lossCriteria=3.0,accCriteria=0.5, 34 | CheckZmat=True, 35 | pi_clip=pi_clip, 36 | bo_clip=bo_clip, 37 | lambda_reg=0.001,lambda_bd=100.0,lambda_me=0.001, 38 | learn_method=2,dft_step=4, 39 | # beta=0.9,FirstAtom=30,FreeAtoms=[19,18,30,31], 40 | EngTole=0.01,dEtole=0.1,dEstop=2.0, 41 | EnergyFunction=1,MessageFunction=3, 42 | mf_layer=[9,1],be_layer=[9,1], 43 | mf_universal_nn=None, # ['C'], 44 | be_universal_nn=None, # ['C-C','C-O'], 45 | weight=weight, 46 | optword='nocoul',cons=cons,clip=clip, # nocoul-nolone-nounder-noover 47 | writelib=1000,convergence=0.04, 48 | dft='siesta',xcf='GGA',xca='PBE',basistype='split') 49 | lm.run() 50 | lm.close() 51 | 52 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/pseudo/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_ch4h2o/pseudo/.keep -------------------------------------------------------------------------------- /examples/example_ch4h2o/rotate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance 7 | import sys 8 | import argh 9 | import argparse 10 | 11 | 12 | parser = argparse.ArgumentParser(description='./rotate.py --g=md.traj --i=0 --j=1 --d=30.0 ') 13 | parser.add_argument('--g',default='poscar.gen',type=str, help='atomic configuration') 14 | parser.add_argument('--i',default=0,type=int, help='atoms i of the angle') 15 | parser.add_argument('--j',default=1,type=int, help='atoms j of the angle') 16 | parser.add_argument('--o',default=2,type=int, help='atoms k of the angle') 17 | parser.add_argument('--f',default=-1,type=int, help='number of trajectory frame') 18 | parser.add_argument('--d',default=90.0,type=float, help='angle rotate degree') 19 | 20 | args = parser.parse_args(sys.argv[1:]) 21 | atoms = read(args.g,index=args.f) 22 | ad = AtomDance(atoms) 23 | #images = ad.rotate(axis=[8,10],o=21,atms=[20,32,33],rang=30,nbin=50,traj='md.traj') 24 | images = ad.rotate(axis=[args.i,args.j],o=args.o,rang=args.d,nbin=50,traj='md.traj') 25 | ad.close() 26 | # view(atoms) 27 | 28 | 29 | ''' 30 | run this script using commond: 31 | ./rotate.py --g=nm.gen --i=0 --j=1 --d=30.0 32 | ''' 33 | 34 | -------------------------------------------------------------------------------- /examples/example_ch4h2o/stretch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance,get_group 7 | import sys 8 | import argh 9 | import argparse 10 | 11 | help_ = './stretch.py --g=md.traj --i=0 --j=1 --s=1.4 --e=1.9 --f=0' 12 | parser = argparse.ArgumentParser(description=help_) 13 | parser.add_argument('--g',default='poscar.gen',type=str, help='training steps') 14 | parser.add_argument('--i',default=0,type=int, help='learning rate') 15 | parser.add_argument('--j',default=1,type=int, help='learning rate') 16 | parser.add_argument('--s',default=1.4,type=float, help='learning rate') 17 | parser.add_argument('--e',default=1.9,type=float, help='learning rate') 18 | parser.add_argument('--f',default=-1,type=int, help='the trajectory frame') 19 | 20 | args = parser.parse_args(sys.argv[1:]) 21 | 22 | 23 | atoms = read(args.g,index=args.f) 24 | ad = AtomDance(atoms=atoms) 25 | images = ad.stretch([args.i,args.j],nbin=50,rst=args.s,red=args.e,scale=1.26,traj='md.traj') 26 | ad.close() 27 | 28 | 29 | ''' 30 | run this script using commond: 31 | ./stretch.py --g=md.traj --i=0 --j=1 --s=1.4 --e=1.9 --f=0 32 | ''' 33 | -------------------------------------------------------------------------------- /examples/example_fc_lammps/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fc_lammps/.keep -------------------------------------------------------------------------------- /examples/example_fox/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/.keep -------------------------------------------------------------------------------- /examples/example_fox/README.md: -------------------------------------------------------------------------------- 1 | ## Training machine learning model with atomic forces 2 | ![crystal structure and forces on atoms](fox7.png) 3 | ### 1. prepare data for the training 4 | 5 | The training data can calculate by any method, but data must in ASE trajectory format. A convenient way to prepare '.traj' file is using ASE calculator(refer to ASE manual for details), after calculations the trajectory file will generated automatically. Another way is using our learning machine (as show the 'lm.py' script in this directory), but only support SIESTA currently. 6 | 7 | (The ASE trajectory object must contain energies and forces attribute for forces learning.) 8 | 9 | ### 2. training the machine learning model with data collected in step 1. 10 | 11 | Using script 'train.py' to train the model, type the following command in the Linux shell: 12 | ```shell 13 | ./train.py 14 | ``` 15 | 16 | a typical output is like following: 17 | ```shell 18 | - step: 60 loss: 0.0015 accs: 0.94 fox-7: 0.97 cl20-0: 0.91 force: 0.112 pen: 32.27 me: 8.40 time: 5.14 19 | - step: 70 loss: 0.0015 accs: 0.95 fox-7: 0.97 cl20-0: 0.92 force: 0.112 pen: 32.32 me: 8.40 time: 5.17 20 | - step: 80 loss: 0.0015 accs: 0.95 fox-7: 0.97 cl20-0: 0.92 force: 0.112 pen: 32.24 me: 8.40 time: 5.26 21 | ``` 22 | 23 | where 24 | ```shell 25 | loss : energy loss per atom, energy in unit eV; 26 | accs : the total accuracy of the model, the value is in range 0~1; 27 | force: forces loss per atom, forces in unit eV/angstrom; 28 | pen : sum of penalty terms, such as regularize therm of parameters, bond-order should be zero at the bond cutoff; 29 | me : structure energy, it should be neglected, no real meaning; 30 | time : time usage till last print out. 31 | fox-7/cl20-0: accuracy for every structure, the value is in range 0~1; 32 | ``` -------------------------------------------------------------------------------- /examples/example_fox/aimd_fox7/fox7-0/fox7.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/aimd_fox7/fox7-0/fox7.traj -------------------------------------------------------------------------------- /examples/example_fox/aimd_fox7/fox7-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -141.67868 DFT: -12756.63990 Diff: 12614.961225 dE: 0.7525 d2E: 0.4002 2 | 2 MLP: -142.03103 DFT: -12756.05490 Diff: 12614.023870 dE: 0.3524 d2E: 0.1238 3 | 3 MLP: -142.25956 DFT: -12756.25060 Diff: 12613.991042 dE: 0.2285 d2E: 0.1238 4 | -------------------------------------------------------------------------------- /examples/example_fox/aimd_fox7/fox7-1/fox7.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/aimd_fox7/fox7-1/fox7.traj -------------------------------------------------------------------------------- /examples/example_fox/aimd_fox7/fox7-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 0 MLP: -97.79425 DFT: -12755.44800 Diff: 12657.653751 dE: 0.0000 d2E: 0.0000 2 | 1 MLP: -100.80849 DFT: -12757.78210 Diff: 12656.973607 dE: 3.0142 d2E: 4.2156 3 | 2 MLP: -99.60718 DFT: -12756.31320 Diff: 12656.706023 dE: 1.2013 d2E: 2.0485 4 | 3 MLP: -100.45436 DFT: -12756.70990 Diff: 12656.255538 dE: 0.8472 d2E: 1.4571 5 | 4 MLP: -99.84445 DFT: -12756.56750 Diff: 12656.723055 dE: 0.6099 d2E: 0.7226 6 | 5 MLP: -99.95716 DFT: -12755.99220 Diff: 12656.035042 dE: 0.1127 d2E: 0.6662 7 | 6 MLP: -99.40367 DFT: -12755.46260 Diff: 12656.058933 dE: 0.5535 d2E: 0.6784 8 | 7 MLP: -99.52857 DFT: -12754.93870 Diff: 12655.410130 dE: 0.1249 d2E: 0.0713 9 | 8 MLP: -99.72481 DFT: -12755.28970 Diff: 12655.564893 dE: 0.1962 d2E: 0.4617 10 | 9 MLP: -99.45933 DFT: -12755.59580 Diff: 12656.136474 dE: 0.2655 d2E: 0.8305 11 | 10 MLP: -100.02431 DFT: -12756.34960 Diff: 12656.325292 dE: 0.5650 d2E: 0.2985 12 | 11 MLP: -100.29079 DFT: -12756.39920 Diff: 12656.108409 dE: 0.2665 d2E: 0.8508 13 | 12 MLP: -99.70652 DFT: -12755.85800 Diff: 12656.151484 dE: 0.5843 d2E: 0.3850 14 | 13 MLP: -99.50719 DFT: -12755.60100 Diff: 12656.093809 dE: 0.1993 d2E: 0.0927 15 | 14 MLP: -99.21521 DFT: -12754.98120 Diff: 12655.765990 dE: 0.2920 d2E: 1.4387 16 | 15 MLP: -100.36190 DFT: -12756.25090 Diff: 12655.889004 dE: 1.1467 d2E: 1.7304 17 | 16 MLP: -99.77822 DFT: -12756.01210 Diff: 12656.233877 dE: 0.5837 d2E: 0.2111 18 | 17 MLP: -98.98344 DFT: -12754.80660 Diff: 12655.823164 dE: 0.7948 d2E: 2.1535 19 | 18 MLP: -100.34220 DFT: -12755.68040 Diff: 12655.338205 dE: 1.3588 d2E: 2.5761 20 | 19 MLP: -99.12482 DFT: -12755.00100 Diff: 12655.876183 dE: 1.2174 d2E: 2.2578 21 | 20 MLP: -100.16520 DFT: -12755.18860 Diff: 12655.023401 dE: 1.0404 d2E: 2.2578 22 | -------------------------------------------------------------------------------- /examples/example_fox/aimd_fox7/fox7-2/fox7.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/aimd_fox7/fox7-2/fox7.traj -------------------------------------------------------------------------------- /examples/example_fox/fox7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/fox7.png -------------------------------------------------------------------------------- /examples/example_fox/lm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import matplotlib 3 | matplotlib.use('Agg') 4 | from irff.LearningMachine import LearningMachine 5 | from irff.data.ColData import ColData 6 | from irff.dft.CheckEmol import check_emol 7 | from train import clip,cons,batch,dataset,weight,mf_layer 8 | 9 | # check_emol(dataset) 10 | 11 | lm = LearningMachine(config='cf13.gen', 12 | dataset=dataset,ncpu=8,batch=batch, 13 | maxiter=5, 14 | step=10000,md_step=50,col_frame=10,col_min_interval=4, 15 | lossCriteria=6.5,accCriteria=0.5, 16 | CheckZmat=False, 17 | lambda_reg=0.005,lambda_bd=1000.0,lambda_me=0.01, 18 | learn_method=2,dft_step=20, 19 | EngTole=0.01,dEtole=0.1,dEstop=2.0, 20 | EnergyFunction=1,MessageFunction=3, 21 | mf_layer=mf_layer,be_layer=[9,1], 22 | mf_univeral_nn=None,#['C'], 23 | be_univeral_nn=None,#['C-C','C-O'], 24 | weight=weight, 25 | #pi_clip=pi_clip, 26 | #be_clip=be_clip, 27 | cons=cons,clip=clip, 28 | writelib=1000,convergence=0.000001, 29 | trainer=2, 30 | dft='siesta',xcf='GGA',xca='PBE',basistype='split') 31 | lm.run() 32 | lm.close() 33 | 34 | # Use commond like: nohup ./lm.py >py.log 2>&1 & 35 | # to run it 36 | # 37 | -------------------------------------------------------------------------------- /examples/example_fox/pseudo/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_fox/pseudo/.keep -------------------------------------------------------------------------------- /examples/example_graph/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_graph/.keep -------------------------------------------------------------------------------- /examples/example_phonon/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_phonon/.keep -------------------------------------------------------------------------------- /examples/example_phonon/ph_gulp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import system #,popen 3 | 4 | #先将结构文件转换为siesta输入文件 5 | system('./smd.py wi --g=POSCAR') 6 | 7 | #生成位移文件 8 | system('phonopy --siesta -c=in.fdf -d --dim="8 8 1" --amplitude=0.02') 9 | system('./phonon_force.py --n=1') 10 | # system('cp force.0 lammps_forces_gp.0') 11 | 12 | system('phonopy -f Forces-001.FA --siesta') 13 | system('phonopy --siesta -c in.fdf -p --dim="6 6 1" --band="0.0 0.0 0.0 1/4 0.0 0.0 0.5 0.0 0.0 2/3 -1/3 1/2 1/3 -1/6 0.0 0.0 0.0 0.0"') 14 | 15 | system('phonopy-bandplot --gnuplot band.yaml > band.dat') 16 | system('phonopy --writefc --full-fc') # write FORCE_CONSTANT_2ND 17 | 18 | system('mv band.dat band-nn-gulp.dat') 19 | system('./plotband.py') 20 | 21 | -------------------------------------------------------------------------------- /examples/example_reax/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/.keep -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-0/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-0/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-1/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-1/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-2/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-2/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-3/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-3/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-4/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-4/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-5/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-5/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-6/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 0 MLP: -46.13350 DFT: -9737.37300 Diff: 9691.239502 dE: 0.0000 d2E: 0.0000 2 | 1 MLP: -47.02113 DFT: -9738.28570 Diff: 9691.264567 dE: 0.8876 d2E: 0.4261 3 | 2 MLP: -48.33488 DFT: -9739.14400 Diff: 9690.809115 dE: 1.3138 d2E: 1.6442 4 | 3 MLP: -48.00444 DFT: -9738.84030 Diff: 9690.835856 dE: 0.3304 d2E: 1.6442 5 | -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx/tkx-6/tkx.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx/tkx-6/tkx.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx2/tkx2-0/tkx2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx2/tkx2-0/tkx2.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx2/tkx2-1/tkx2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx2/tkx2-1/tkx2.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx2/tkx2-2/tkx2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx2/tkx2-2/tkx2.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx2/tkx2-3/tkx2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx2/tkx2-3/tkx2.traj -------------------------------------------------------------------------------- /examples/example_reax/aimd_tkx2/tkx2-4/tkx2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_reax/aimd_tkx2/tkx2-4/tkx2.traj -------------------------------------------------------------------------------- /examples/example_reax/ffield_to_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | import json as js 4 | from os import environ,system 5 | from ase.io import read 6 | from irff.reaxfflib import read_ffield,write_lib 7 | # from irff.irnnlib_new import write_lib 8 | from irff.qeq import qeq 9 | 10 | 11 | def ffieldtojson(): 12 | p,zpe,spec,bonds,offd,angs,torp,hbs= read_ffield(libfile='ffield') 13 | 14 | fj = open('ffield.json','w') 15 | # j = {'p':p,'m':[],'bo_layer':[],'zpe':[]} 16 | for key in p: 17 | # print(p[key]) 18 | if isinstance(p[key],np.float32): 19 | p[key]= float(p[key]) 20 | j = {'p':p,'m':None, 21 | 'EnergyFunction':0, 22 | 'VdwFunction':0, 23 | 'MessageFunction':0, 24 | 'messages':1, 25 | 'mf_layer':None, 26 | 'be_layer':None, 27 | 'vdw_layer':None, 28 | 'MolEnergy':{} , 29 | 'rcut':None, 30 | 'rEquilibrium':None, 31 | 'rcutBond':None} 32 | js.dump(j,fj,sort_keys=True,indent=2) 33 | fj.close() 34 | 35 | 36 | if __name__ == '__main__': 37 | ffieldtojson() 38 | 39 | -------------------------------------------------------------------------------- /examples/example_reax/json_to_ffield.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_ffield,write_ffield 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import argh 6 | import argparse 7 | import json as js 8 | from os import environ,system 9 | import csv 10 | import pandas as pd 11 | from os.path import isfile 12 | 13 | 14 | def jsontoffield(): 15 | lf = open('ffield.json','r') 16 | j = js.load(lf) 17 | p_ = j['p'] 18 | m_ = j['m'] 19 | mf_layer = j['mf_layer'] 20 | be_layer = j['be_layer'] 21 | lf.close() 22 | 23 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 24 | write_ffield(p_,spec,bonds,offd,angs,torp,hbs, 25 | m=m_,mf_layer=mf_layer,be_layer=be_layer, 26 | libfile='ffield') 27 | 28 | def init_bonds(p_): 29 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 30 | for key in p_: 31 | # key = key.encode('raw_unicode_escape') 32 | # print(key) 33 | k = key.split('_') 34 | if k[0]=='bo1': 35 | bonds.append(k[1]) 36 | elif k[0]=='rosi': 37 | kk = k[1].split('-') 38 | # print(kk) 39 | if len(kk)==2: 40 | if kk[0]!=kk[1]: 41 | offd.append(k[1]) 42 | elif len(kk)==1: 43 | spec.append(k[1]) 44 | elif k[0]=='theta0': 45 | angs.append(k[1]) 46 | elif k[0]=='tor1': 47 | torp.append(k[1]) 48 | elif k[0]=='rohb': 49 | hbs.append(k[1]) 50 | return spec,bonds,offd,angs,torp,hbs 51 | 52 | 53 | if __name__ == '__main__': 54 | jsontoffield() 55 | 56 | -------------------------------------------------------------------------------- /examples/example_reax/readme.md: -------------------------------------------------------------------------------- 1 | ### Example of Train ReaxFF 2 | 3 | 1. ml_train_reax.py: python script use machine learning algorithm for training ReaxFF. 4 | ```shell 5 | ./ml_train_reax.py --s=10000 6 | ``` 7 | 2. train_reax.py: python script use gradient based algorithm for training ReaxFF. 8 | 9 | usage: 10 | ```shell 11 | ./train_reax.py --s=10000 12 | ``` 13 | 3. json_to_ffiled.py: python script convert ffield.json file to ffield and control file, which is used by lammps. 14 | 15 | usage: 16 | ```shell 17 | ./json_to_ffield.py 18 | ``` 19 | 4. lmd.py: python script call lammps to run MD. 20 | 21 | usage: 22 | ```shell 23 | ./lmd.py nvt --s=3000 --g=tkx2.gen --m=reaxff --n=4 24 | ``` -------------------------------------------------------------------------------- /examples/example_torch/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_torch/.keep -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-0/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 9 MLP: -9.68196 DFT: -1153.10330 Diff: 1143.421341 dE: 0.0066 d2E: 0.0005 2 | 19 MLP: -9.77989 DFT: -1153.09500 Diff: 1143.315113 dE: 0.0127 d2E: 0.0007 3 | 29 MLP: -9.94254 DFT: -1153.03960 Diff: 1143.097062 dE: 0.0188 d2E: 0.0003 4 | 39 MLP: -10.13554 DFT: -1152.85950 Diff: 1142.723963 dE: 0.0193 d2E: 0.0001 5 | 49 MLP: -10.33333 DFT: -1152.48640 Diff: 1142.153072 dE: 0.0201 d2E: 0.0000 6 | 52 MLP: -10.39401 DFT: -1152.32990 Diff: 1141.935887 dE: 0.0203 d2E: 0.0001 7 | 59 MLP: -10.53189 DFT: -1151.88140 Diff: 1141.349507 dE: 0.0195 d2E: 0.0001 8 | 69 MLP: -10.72218 DFT: -1151.04310 Diff: 1140.320918 dE: 0.0186 d2E: 0.0001 9 | -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-0/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_torch/aimd_ch4w2/ch4w2-0/ch4w2.traj -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-1/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 7 MLP: -1128.34806 DFT: -1153.10930 Diff: 24.761244 dE: 0.0009 d2E: 0.0002 2 | 14 MLP: -1128.35923 DFT: -1153.00740 Diff: 24.648173 dE: 0.0020 d2E: 0.0001 3 | 21 MLP: -1128.37604 DFT: -1152.72240 Diff: 24.346361 dE: 0.0027 d2E: 0.0001 4 | 28 MLP: -1128.39811 DFT: -1152.33920 Diff: 23.941095 dE: 0.0035 d2E: 0.0001 5 | 35 MLP: -1128.41920 DFT: -1151.90860 Diff: 23.489401 dE: 0.0020 d2E: 0.0000 6 | 42 MLP: -1128.43931 DFT: -1151.46150 Diff: 23.022195 dE: 0.0043 d2E: 0.0009 7 | 50 MLP: -1128.52449 DFT: -1150.95530 Diff: 22.430809 dE: 0.0177 d2E: 0.0024 8 | -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-1/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_torch/aimd_ch4w2/ch4w2-1/ch4w2.traj -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-2/SinglePointEnergies.log: -------------------------------------------------------------------------------- 1 | 1 MLP: -17.82988 DFT: -1153.41830 Diff: 1135.588421 dE: 0.0000 d2E: 0.0717 2 | 50 MLP: -18.48547 DFT: -1153.60310 Diff: 1135.117626 dE: 0.0030 d2E: 0.0019 3 | 100 MLP: -18.55694 DFT: -1153.63290 Diff: 1135.075965 dE: 0.0009 d2E: 0.0017 4 | 150 MLP: -18.58572 DFT: -1153.66190 Diff: 1135.076184 dE: 0.0006 d2E: 0.0002 5 | 200 MLP: -18.60323 DFT: -1153.67570 Diff: 1135.072467 dE: 0.0002 d2E: 0.0002 6 | 250 MLP: -18.61303 DFT: -1153.69020 Diff: 1135.077170 dE: 0.0002 d2E: 0.0001 7 | 272 MLP: -18.82216 DFT: -1153.29300 Diff: 1134.470836 dE: 0.1631 d2E: 0.1004 8 | 301 MLP: -19.31235 DFT: -1153.46850 Diff: 1134.156148 dE: 0.0001 d2E: 0.0000 9 | -------------------------------------------------------------------------------- /examples/example_torch/aimd_ch4w2/ch4w2-2/ch4w2.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/example_torch/aimd_ch4w2/ch4w2-2/ch4w2.traj -------------------------------------------------------------------------------- /examples/train.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/examples/train.png -------------------------------------------------------------------------------- /irff/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/.keep -------------------------------------------------------------------------------- /irff/__init__.py: -------------------------------------------------------------------------------- 1 | ## 2 | 3 | -------------------------------------------------------------------------------- /irff/data/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/data/.keep -------------------------------------------------------------------------------- /irff/data/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IRFF: Intelligent Reactive Force Filed, A ReaxFF developing tool kit. 3 | Authored by FengGo. 4 | email: fengguo@lcu.edu.cn 5 | gfeng.alan@foxmail.com 6 | 7 | This software package is under academic license. 8 | 9 | 2019-05-06: 10 | version 3.3 fix bugs of NLP, PBO calculation 11 | Delta_angle index error 12 | 2019-04-16 13 | version 3.2 weight added 14 | 2019-04-02: 15 | version 3.1 change log, test of torsion energies, 16 | found eover and eunder bugs(fixed) 17 | add penalty for case of bond-order to small 18 | 19 | ''' 20 | 21 | -------------------------------------------------------------------------------- /irff/data/dpdata.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | 4 | 5 | positions = np.load('trainData/set.000/coord.npy') 6 | box = np.load('trainData/set.000/box.npy') 7 | energies = np.load('trainData/set.000/energy.npy') 8 | forces = np.load('trainData/set.000/force.npy') 9 | 10 | 11 | print('\n- positions -\n',positions.shape) 12 | print('\n- boxes -\n',box.shape) 13 | print('\n- energies -\n',energies.shape) 14 | print('\n- forces -\n',forces.shape) 15 | 16 | # for b in box: 17 | # print(b) 18 | 19 | -------------------------------------------------------------------------------- /irff/data/qeout_to_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from ase.io.trajectory import TrajectoryWriter,Trajectory 4 | from ase.io.espresso import read_espresso_in,parse_pwo_start,get_atomic_positions,label_to_symbol,get_constraint 5 | from ase.visualize import view 6 | from ase.units import create_units 7 | from ase.dft.kpoints import kpoint_convert 8 | from ase.calculators.singlepoint import SinglePointDFTCalculator,SinglePointKPoint 9 | from ase.atoms import Atoms 10 | from irff.dft.qe import read_espresso_out 11 | import numpy as np 12 | 13 | 14 | his = TrajectoryWriter('pw.traj',mode='w') 15 | 16 | # atoms = read_espresso_in('2C.in') 17 | images = read_espresso_out('2B.out') 18 | images_ = [] 19 | for a in images: 20 | his.write(atoms=a) 21 | images_.append(a) 22 | 23 | his.close() 24 | # view(images_) 25 | -------------------------------------------------------------------------------- /irff/deb/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/deb/.keep -------------------------------------------------------------------------------- /irff/deb/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IRFF: Intelligent Reactive Force Filed, A ReaxFF developing tool kit. 3 | Authored by FengGo. 4 | email: fengguo@lcu.edu.cn 5 | gfeng.alan@foxmail.com 6 | 7 | This software package is under academic license. 8 | 9 | 2019-05-06: 10 | version 3.3 fix bugs of NLP, PBO calculation 11 | Delta_angle index error 12 | 2019-04-16 13 | version 3.2 weight added 14 | 2019-04-02: 15 | version 3.1 change log, test of torsion energies, 16 | found eover and eunder bugs(fixed) 17 | add penalty for case of bond-order to small 18 | 19 | ''' 20 | 21 | -------------------------------------------------------------------------------- /irff/deb/irnan.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.irff import IRFF 3 | from irff.irff_np import IRFF_NP 4 | from ase.io import read,write 5 | import numpy as np 6 | from ase.io.trajectory import Trajectory,TrajectoryWriter 7 | 8 | 9 | def irff_deb(gen='poscar.gen'): 10 | atoms = read(gen) 11 | ir = IRFF(atoms=atoms, 12 | libfile='ffield.json', 13 | nn=True, 14 | autograd=True) 15 | ir.calculate(atoms) 16 | print(ir.grad) 17 | 18 | ir_ = IRFF_TF(atoms=atoms, 19 | libfile='ffield.json', 20 | nn=True) 21 | ir_.calculate(atoms) 22 | print(ir_.grad.numpy()) 23 | 24 | 25 | if __name__ == '__main__': 26 | ''' use commond like ./mpnn.py to run it 27 | use --h to see options 28 | ''' 29 | irff_deb(gen='md.traj') 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /irff/dft/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/dft/.keep -------------------------------------------------------------------------------- /irff/dft/CheckEmol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | import matplotlib 5 | matplotlib.use('Agg') 6 | from os import system, getcwd, chdir,listdir 7 | from os.path import isfile # exists 8 | from irff.irff_np import IRFF_NP 9 | from irff.AtomDance import AtomDance 10 | import numpy as np 11 | import matplotlib.pyplot as plt 12 | from ase import Atoms 13 | from ase.io.trajectory import Trajectory 14 | from ase.io import read 15 | import tensorflow as tf 16 | import json as js 17 | 18 | 19 | def check_emol(direcs,ffield='ffield.json'): 20 | with open('ffield.json','r') as lf: 21 | j = js.load(lf) 22 | 23 | for mol in direcs: 24 | mol_ = mol.split('-')[0] 25 | if j['MolEnergy'] is None: 26 | j['MolEnergy'][mol_] = get_mole(traj=direcs[mol]) 27 | else: 28 | if mol_ not in j['MolEnergy']: 29 | j['MolEnergy'][mol_] = get_mole(traj=direcs[mol]) 30 | 31 | with open('ffield.json','w') as fj: 32 | js.dump(j,fj,sort_keys=True,indent=2) 33 | 34 | 35 | def get_mole(traj='nm-0.traj'): 36 | images = Trajectory(traj) 37 | tframe = len(images) 38 | x_ = [i for i in range(tframe)] 39 | e,e_ = [],[] 40 | mol_ = traj.split('.')[0] 41 | mol = mol_.split('-')[0] 42 | 43 | ir = IRFF_NP(atoms=images[0], 44 | libfile='ffield.json', 45 | rcut=None, 46 | nn=True,vdwnn=True) 47 | 48 | for i,atoms in enumerate(images): 49 | energy = atoms.get_potential_energy() 50 | ir.calculate(atoms) 51 | e_.append(ir.E) 52 | e.append(energy) 53 | 54 | emol = np.mean(e) - np.mean(e_) 55 | print('- recommended molecular energy for %s is :' %mol,emol) 56 | return emol 57 | 58 | 59 | 60 | if __name__ == '__main__': 61 | ''' use commond like ./bp.py to run it 62 | pb: plot bo uncorrected 63 | t: train the whole net 64 | ''' 65 | get_mole() 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /irff/dft/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IRFF: Intelligent Reactive Force Filed, A ReaxFF developing tool kit. 3 | Authored by FengGo. 4 | email: fengguo@lcu.edu.cn 5 | gfeng.alan@foxmail.com 6 | 7 | This software package is under academic license. 8 | 9 | 2019-05-06: 10 | version 3.3 fix bugs of NLP, PBO calculation 11 | Delta_angle index error 12 | 2019-04-16 13 | version 3.2 weight added 14 | 2019-04-02: 15 | version 3.1 change log, test of torsion energies, 16 | found eover and eunder bugs(fixed) 17 | add penalty for case of bond-order to small 18 | 19 | ''' 20 | 21 | -------------------------------------------------------------------------------- /irff/dingtalk.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | from email.mime.text import MIMEText 3 | # from dingtalkchatbot.chatbot import DingtalkChatbot 4 | from os import popen,getcwd 5 | import re 6 | 7 | 8 | # webhook='https://oapi.dingtalk.com/robot/send?access_token=9a567ecf401bbd43a7b63bafe36c30f5c88b660a7831c326ad4f6291c9460cce' 9 | # dlam = DingtalkChatbot(webhook) 10 | 11 | class DLAM(object): 12 | def __init__(self): 13 | ''' fake DingtalkChatbot ''' 14 | 15 | def send_markdown(self,title='Learning Information: ',text=' '): 16 | print('------------------------------------------------------------------------') 17 | print(' * ',title) 18 | # print(' ') 19 | print(' * ',text) 20 | print('------------------------------------------------------------------------') 21 | 22 | dlam = DLAM() 23 | 24 | 25 | def valid_ip(ip): 26 | if ("255" in ip) or ( ip == "127.0.0.1") or ( ip == "0.0.0.0" ) or ( ip == "127.0.1.1"): 27 | return False 28 | else: 29 | return True 30 | 31 | # def get_ip(valid_ip): 32 | # ipss = ''.join(popen('ifconfig').readlines()) 33 | # match = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" 34 | # ips = re.findall(match, ipss, flags=re.M) 35 | # ip = filter(valid_ip, ips) 36 | # IP = '' 37 | # for i,I in enumerate(ip): 38 | # if i==0: 39 | # IP = I 40 | # else: 41 | # IP += '/'+I 42 | # return IP 43 | 44 | # ip = get_ip(valid_ip) 45 | # hn=''.join(popen('hostname').readlines()) 46 | # hostname = hn[:-1] 47 | 48 | 49 | def send_msg(msg): 50 | cwd=getcwd() 51 | # msg = '#### MY Master:\n'+'----------------\n '+ msg 52 | # msg += '\n\n----------------\n' 53 | # msg += '\n From: '+hostname+'@'+ip+'\n' #\nmy master 54 | msg += '\n * (directory: '+cwd+')' 55 | # try: 56 | dlam.send_markdown(title='Learning Information: ',text=msg) 57 | # except: 58 | # send_mail(msg) 59 | # print('- warning massage send failed.') 60 | 61 | -------------------------------------------------------------------------------- /irff/libs/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/libs/.keep -------------------------------------------------------------------------------- /irff/libs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/libs/__init__.py -------------------------------------------------------------------------------- /irff/md/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/md/.keep -------------------------------------------------------------------------------- /irff/ml/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/ml/.keep -------------------------------------------------------------------------------- /irff/ml/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /irff/plot/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/plot/.keep -------------------------------------------------------------------------------- /irff/plot/BondEnergy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from irff.checkLoneAtom import checkLoneAtoms,checkLoneAtom 4 | from irff.irff_np import IRFF_NP 5 | from ase.io import read,write 6 | from ase.io.trajectory import Trajectory 7 | from ase.visualize import view 8 | from irff.prep_data import prep_data 9 | import matplotlib.pyplot as plt 10 | import matplotlib.mlab as mlab 11 | from mpl_toolkits.mplot3d import Axes3D 12 | from matplotlib import cm 13 | import matplotlib.colors as col 14 | import numpy as np 15 | get_ipython().run_line_magic('matplotlib', 'inline') 16 | 17 | 18 | images = Trajectory('md.traj') 19 | view(images) 20 | atoms = images[-1] 21 | 22 | 23 | 24 | ir = IRFF_NP(atoms=atoms, 25 | libfile='ffield.json', 26 | rcut=None, 27 | nn=True) 28 | # ir.get_pot_energy(atoms) 29 | # ir.logout() 30 | ir.calculate_Delta(atoms) 31 | # print(ir.ebond) 32 | 33 | 34 | 35 | fig = plt.figure() 36 | ax = fig.gca(projection='3d') 37 | 38 | # set figure information 39 | ax.set_title("Bond Energy") 40 | ax.set_xlabel("X") 41 | ax.set_ylabel("Y") 42 | ax.set_zlabel("Z") 43 | mine = np.min(ir.ebond) 44 | 45 | print(mine) 46 | cmap = cm.ScalarMappable(col.Normalize(mine,0.0), cm.rainbow) 47 | 48 | for i in range(ir.natom-1): 49 | for j in range(i+1,ir.natom): 50 | if ir.ebond[i][j]<-1.0: 51 | # print(ir.ebond[i][j]) 52 | x = [atoms.positions[i][0],atoms.positions[j][0]] 53 | y = [atoms.positions[i][1],atoms.positions[j][1]] 54 | z = [atoms.positions[i][2],atoms.positions[j][2]] 55 | ax.plot(x,y,z,c=cmap.to_rgba(ir.ebond[i][j]),linewidth=3) 56 | 57 | ca = np.linspace(mine,0,100) 58 | cmap.set_array(ca) 59 | plt.colorbar(cmap,label='Color Map(Unit: eV)') 60 | plt.show() 61 | # plt.savefig('bondEnergy.eps') 62 | 63 | -------------------------------------------------------------------------------- /irff/plot/LearningResults.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from ase.optimize import BFGS 3 | from ase.md.velocitydistribution import MaxwellBoltzmannDistribution 4 | from ase.md.verlet import VelocityVerlet 5 | from ase.io.trajectory import Trajectory,TrajectoryWriter 6 | from ase.calculators.singlepoint import SinglePointCalculator 7 | from ase.io import read,write 8 | from ase import units 9 | from ase.visualize import view 10 | from irff.irff_np import IRFF_NP 11 | from irff.irff import IRFF 12 | import matplotlib.pyplot as plt 13 | 14 | 15 | def learning_result(ffield='ffield.json',nn='T',traj='C2H4.traj'): 16 | images = Trajectory(traj) 17 | traj_ = TrajectoryWriter(traj[:-5]+'_.traj',mode='w') 18 | atoms = images[0] 19 | nn_=True if nn=='T' else False 20 | 21 | ir = IRFF_NP(atoms=atoms, 22 | libfile=ffield, 23 | nn=nn_) 24 | natom = ir.natom 25 | 26 | Empnn,Esiesta = [],[] 27 | eb,eb_ = [],[] 28 | # images_= [] 29 | # for _ in range(10,11): 30 | for atoms in images: 31 | ir.calculate(atoms) 32 | Empnn.append(ir.E) 33 | Esiesta.append(atoms.get_potential_energy()) 34 | atoms_ = atoms.copy() 35 | atoms_.set_initial_charges(charges=ir.q) 36 | calc = SinglePointCalculator(atoms_,energy=ir.E) 37 | atoms_.set_calculator(calc) 38 | traj_.write(atoms=atoms_) 39 | 40 | traj_.close() 41 | fig, ax = plt.subplots() 42 | 43 | plt.plot(Empnn,label=r'$E_{MPNN}$', color='blue', linewidth=2, linestyle='-.') 44 | plt.plot(Esiesta,label=r'$E_{SIESTA}$', color='r', linewidth=2, linestyle='-') 45 | plt.legend(loc='best',edgecolor='yellowgreen') 46 | 47 | # plt.savefig('result-%s.pdf' %traj[:-4]) 48 | plt.show() 49 | plt.close() 50 | 51 | 52 | # learning_result(traj='nmr.traj') 53 | 54 | -------------------------------------------------------------------------------- /irff/plot/__init__.py: -------------------------------------------------------------------------------- 1 | # https://scikit-learn.org/stable/auto_examples/ensemble/plot_random_forest_regression_multioutput.html 2 | # sphx-glr-auto-examples-ensemble-plot-random-forest-regression-multioutput-py 3 | -------------------------------------------------------------------------------- /irff/plot/plbd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_lib,write_lib 3 | from irff.plot.reax_plot import get_p,get_bo 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | import matplotlib.mlab as mlab 7 | import argh 8 | import argparse 9 | 10 | 11 | def get_ebond(bo,be1,be2,De): 12 | powb = np.power(bo,be2) 13 | expb = np.exp(be1*(1.0-powb)) 14 | eb = De*bo*expb*4.3364432032e-2 15 | return eb 16 | 17 | 18 | def peb(bd='C-C'): 19 | p,bonds = get_p('ffield.json') 20 | bo = np.arange(0.1,1.0,0.05) 21 | 22 | plt.figure() 23 | plt.ylabel( '%s Bond Energy (eV)' %bd) 24 | plt.xlabel(r'$Bond-Order$') 25 | # plt.xlim(0,2.5) 26 | # plt.ylim(0,1.01) 27 | # for i,bd in enumerate(bonds): 28 | 29 | print(bd,'be1:',p['be1_'+bd],'be2:',p['be2_'+bd]) 30 | eb = get_ebond(bo,p['be1_'+bd],p['be2_'+bd],p['Desi_'+bd]) 31 | 32 | plt.plot(bo,eb,label=r'$Bond-Energy$', 33 | color='r', linewidth=2, linestyle='-') 34 | 35 | plt.legend() 36 | plt.savefig('ebond_%s.eps' %bd) 37 | plt.close() 38 | 39 | 40 | if __name__ == '__main__': 41 | ''' use commond like ./plbo.py pb --bd=C-C to run it 42 | ''' 43 | parser = argparse.ArgumentParser() 44 | argh.add_commands(parser, [pbo,peb]) 45 | argh.dispatch(parser) 46 | 47 | -------------------------------------------------------------------------------- /irff/plot/pleb.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | import matplotlib 5 | matplotlib.use('Agg') 6 | from os import system, getcwd, chdir,listdir 7 | from os.path import isfile # exists 8 | from irff.irff_np import IRFF_NP 9 | from irff.AtomDance import AtomDance 10 | import argh 11 | import argparse 12 | import numpy as np 13 | import matplotlib.pyplot as plt 14 | from ase import Atoms 15 | from ase.io.trajectory import Trajectory 16 | from ase.io import read 17 | import tensorflow as tf 18 | 19 | 20 | 21 | colors = ['darkviolet','darkcyan','fuchsia','chartreuse', 22 | 'midnightblue','red','deeppink','agua','blue', 23 | 'cornflowerblue','orangered','lime','magenta', 24 | 'mediumturquoise','aqua','cyan','deepskyblue', 25 | 'firebrick','mediumslateblue','khaki','gold','k'] 26 | 27 | 28 | def pleb(atomi=0,atomj=1,traj='md.traj'): 29 | images = Trajectory(traj) 30 | ir = IRFF_NP(atoms=images[0], 31 | libfile='ffield.json', 32 | rcut=None, 33 | nn=True) 34 | 35 | e_,r_ = [],[] 36 | for atoms in images: 37 | ir.calculate(atoms) 38 | r_.append(ir.r[atomi][atomj]) 39 | e_.append(ir.ebond[atomi][atomj]) 40 | 41 | fig, ax = plt.subplots() 42 | plt.plot(r_,e_,label=r'$E_{Bond}$ VS $Radius$', color='blue', 43 | linewidth=2, linestyle='-') 44 | 45 | plt.legend(loc='best',edgecolor='yellowgreen') 46 | plt.savefig('Ebond.eps') 47 | plt.close() 48 | 49 | 50 | if __name__ == '__main__': 51 | ''' use commond like ./bp.py to run it 52 | pb: plot bo uncorrected 53 | t: train the whole net 54 | ''' 55 | pleb(atomi=0,atomj=5) 56 | 57 | -------------------------------------------------------------------------------- /irff/plot/plev.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | import matplotlib 5 | matplotlib.use('Agg') 6 | from os import system, getcwd, chdir,listdir 7 | from os.path import isfile # exists 8 | from irff.irff_np import IRFF_NP 9 | from irff.AtomDance import AtomDance 10 | import argh 11 | import argparse 12 | import numpy as np 13 | import matplotlib.pyplot as plt 14 | from ase import Atoms 15 | from ase.io.trajectory import Trajectory 16 | from ase.io import read 17 | 18 | 19 | 20 | colors = ['darkviolet','darkcyan','fuchsia','chartreuse', 21 | 'midnightblue','red','deeppink','agua','blue', 22 | 'cornflowerblue','orangered','lime','magenta', 23 | 'mediumturquoise','aqua','cyan','deepskyblue', 24 | 'firebrick','mediumslateblue','khaki','gold','k'] 25 | 26 | 27 | def plev(): 28 | atoms = Atoms('H2', 29 | positions=[(0, 0, 0), (r, 0, 0)], 30 | cell=[10.0, 10.0, 10.0], 31 | pbc=[1, 1, 1]) 32 | ao = AtomDance(atoms) 33 | pairs = [0,1] 34 | images = ao.stretch(pairs,nbin=50,st=0.6,ed=5.0,scale=1.25,traj='evdw.traj') 35 | ao.close() 36 | # view(images) 37 | ir = IRFF_NP(atoms=atoms, 38 | libfile='ffield.json', 39 | rcut=None, 40 | nn=True) 41 | 42 | ev_,r_ = [],[] 43 | for atoms in images: 44 | ir.calculate(atoms) 45 | r_.append(ir.r[0][1]) 46 | ev_.append(ir.Evdw) 47 | 48 | 49 | fig, ax = plt.subplots() 50 | plt.plot(r_,ev_,label=r'$Evdw$ VS $r$', color='blue', 51 | linewidth=2, linestyle='-') 52 | 53 | plt.legend(loc='best',edgecolor='yellowgreen') 54 | plt.savefig('Evdw.eps') 55 | plt.close() 56 | 57 | 58 | if __name__ == '__main__': 59 | ''' use commond like ./bp.py to run it 60 | pb: plot bo uncorrected 61 | t: train the whole net 62 | ''' 63 | plev('f2.gen') 64 | 65 | -------------------------------------------------------------------------------- /irff/plot/plevdw.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import json as js 4 | import matplotlib.pyplot as plt 5 | import argh 6 | import argparse 7 | import numpy as np 8 | from ase import Atoms 9 | from ase.io.trajectory import Trajectory 10 | from ase.io import read 11 | from irff.tools.vdw import vdw 12 | 13 | with open('ffield.json','r') as lf: 14 | j = js.load(lf) 15 | p = j['p'] 16 | 17 | bd = 'O-Fe' 18 | b = bd.split('-') 19 | atomi,atomj = b 20 | gammaw = np.sqrt(p['gammaw_'+atomi]*p['gammaw_'+atomj]) 21 | gamma = np.sqrt(p['gamma_'+atomi]*p['gamma_'+atomj]) 22 | alfa = p['alfa_'+bd] 23 | #alfa = np.sqrt(p['alfa_'+atomi]*p['alfa_'+atomj]) 24 | vdw1 = p['vdw1'] 25 | rvdw = p['rvdw_'+bd] 26 | # rvdw = np.sqrt(p['rvdw_'+atomi]*p['rvdw_'+atomj]) 27 | Devdw = p['Devdw_'+bd] 28 | # Devdw = np.sqrt(p['Devdw_'+atomi]*p['Devdw_'+atomj]) 29 | 30 | print ('Devdw: {:6.4f} '.format(Devdw)) 31 | print ('Gamma: {:6.4f} '.format(gamma)) 32 | print ('Gammaw: {:6.4f} '.format(gammaw)) 33 | print ('alfa: {:6.4f} '.format(alfa)) 34 | print ('vdw1: {:6.4f} '.format(vdw1)) 35 | print ('rvdw: {:6.4f} '.format(rvdw)) 36 | 37 | #rint(Devdw*vdw1) 38 | # print(rvdw*vdw1) 39 | 40 | r = np.linspace(2.0,3.0,50) 41 | ev = vdw(r,Devdw=Devdw,gamma=gamma,gammaw=gammaw,vdw1=vdw1,rvdw=rvdw) 42 | # print(ev) 43 | 44 | plt.figure() 45 | plt.plot(r,ev,alpha=0.8,linewidth=2,linestyle='-',color='r', 46 | label=r'$E_{vdw}$') 47 | plt.legend(loc='best',edgecolor='yellowgreen') 48 | #plt.savefig('vdw_energy_{:s}.pdf'.format(bd)) 49 | plt.show() 50 | plt.close() 51 | -------------------------------------------------------------------------------- /irff/plot/plot_bond_energy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance 7 | import matplotlib.pyplot as plt 8 | import numpy as np 9 | 10 | 11 | def get_array(x): 12 | return np.array(x) - np.min(x) 13 | 14 | e_nm,e_h1,e_h2 = [],[],[] 15 | r_nm,r_h1,r_h2 = [],[],[] 16 | 17 | images = Trajectory('md-nm.traj') 18 | for i,atoms in enumerate(images): 19 | e_nm.append(atoms.get_potential_energy()) 20 | v = atoms.positions[0]-atoms.positions[1] 21 | r_nm.append(np.sqrt(np.sum(np.square(v)))) 22 | e_nm = get_array(e_nm) 23 | 24 | images = Trajectory('md-hmx1.traj') 25 | for i,atoms in enumerate(images): 26 | e_h1.append(atoms.get_potential_energy()) 27 | v = atoms.positions[0]-atoms.positions[1] 28 | r_h1.append(np.sqrt(np.sum(np.square(v)))) 29 | e_h1 = get_array(e_h1) 30 | 31 | images = Trajectory('md-hmx2.traj') 32 | for i,atoms in enumerate(images): 33 | e_h2.append(atoms.get_potential_energy()) 34 | v = atoms.positions[0]-atoms.positions[1] 35 | r_h2.append(np.sqrt(np.sum(np.square(v)))) 36 | e_h2 = get_array(e_h2) 37 | 38 | plt.figure() 39 | plt.ylabel(r'$Total$ $Energy$ ($eV$)') 40 | plt.xlabel(r'$Radius$ $(\AA)$') 41 | 42 | plt.plot(r_nm,e_nm,alpha=0.9, 43 | linestyle='-',# marker='o',markerfacecolor='k',markersize=5, 44 | color='k',label='Nitromethane') 45 | 46 | plt.plot(r_h1,e_h1,alpha=0.9, 47 | linestyle='-',# marker='o',markerfacecolor='k',markersize=5, 48 | color='b',label=r'$NO_2N(CH_3)_2$') 49 | 50 | plt.plot(r_h2,e_h2,alpha=0.9, 51 | linestyle='-',# marker='o',markerfacecolor='k',markersize=5, 52 | color='r',label=r'$NO_2NCH_3CH_2NH_2$') 53 | 54 | plt.legend(loc='best',edgecolor='yellowgreen') # lower left upper right 55 | plt.savefig('BondEnergy.pdf',transparent=True) 56 | plt.close() 57 | -------------------------------------------------------------------------------- /irff/plot/plot_charge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.mdtodata import MDtoData 3 | from irff.qeq import qeq 4 | from irff.reaxfflib import read_lib,write_lib 5 | from os import getcwd 6 | import numpy as np 7 | import matplotlib.pyplot as plt 8 | import matplotlib.mlab as mlab 9 | from mpl_toolkits.mplot3d import Axes3D 10 | # import handout 11 | 12 | 13 | # doc = handout.Handout('./') 14 | 15 | # cwd = getcwd() 16 | iatom = 0 17 | direc = '/home/gfeng/siesta/train/nm7_9' 18 | d = MDtoData(structure='siesta',dft='siesta',direc=direc,batch=100) 19 | images = d.get_images() 20 | q = d.qs[:,iatom] 21 | 22 | p,zpe,spec,bonds,offd,angs,torp,hbs= read_lib(libfile='ffield') 23 | Qe= qeq(p=p,atoms=images[0]) 24 | 25 | q_ = [] 26 | for A in images: 27 | # print('* get charges of batch {0}/{1} ...\r'.format(nf,self.batch),end='\r') 28 | Qe.calc(A) 29 | qr = Qe.q[:-1] 30 | q_.append(qr[iatom]) 31 | 32 | 33 | 34 | p,zpe,spec,bonds,offd,angs,torp,hbs= read_lib(libfile='ffield_best') 35 | Qe= qeq(p=p,atoms=images[0]) 36 | 37 | qb = [] 38 | for A in images: 39 | # print('* get charges of batch {0}/{1} ...\r'.format(nf,self.batch),end='\r') 40 | Qe.calc(A) 41 | qr = Qe.q[:-1] 42 | qb.append(qr[iatom]) 43 | 44 | # print(d.qs.shape) 45 | 46 | 47 | 48 | plt.figure() 49 | plt.ylabel('Charges Distribution of %s' %d.atom_name[iatom]) 50 | plt.xlabel('Molecular Configuration') 51 | 52 | plt.plot(q,label='Mulliken charges from SIESTA', 53 | color='r', linewidth=2, linestyle='--') 54 | plt.plot(q_,label='Qeq charges from ReaxFF', 55 | color='b', linewidth=2, linestyle=':') 56 | plt.plot(qb,label='Qeq charges from ReaxFF(after train)', 57 | color='g', linewidth=2, linestyle=':') 58 | 59 | plt.legend(loc='best',edgecolor='yellowgreen') # lower left 60 | plt.savefig('charge.eps',transparent=True) 61 | plt.close() 62 | 63 | 64 | d.close() 65 | # doc.show() 66 | 67 | -------------------------------------------------------------------------------- /irff/plot/plot_morse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import numpy as np 4 | import matplotlib 5 | matplotlib.use('Agg') 6 | import matplotlib.pyplot as plt 7 | from scipy.optimize import minimize_scalar 8 | 9 | 10 | def morse(r,rosi=0.6,alfa=0.5): 11 | r_ = r/rosi 12 | mors_exp1 = np.exp(alfa*(r_-1.0)) ## Morse should be: 1.0 - r 13 | mors_exp2 = np.square(mors_exp1) 14 | emorse = mors_exp2 - 2.0*mors_exp1 15 | return emorse 16 | 17 | 18 | def plot_morse(): 19 | x = np.linspace(0.0,1.2,100) 20 | s = morse(x) 21 | # for r,m in zip(x,s): 22 | # print(r,m) 23 | # print(np.min(s),np.max(s)) 24 | 25 | plt.figure() 26 | plt.ylabel(r'$Morse Potential$') 27 | plt.xlabel(r'$x$') 28 | 29 | ax = plt.gca() 30 | ax.spines['right'].set_color('none') 31 | ax.spines['top'].set_color('none') 32 | ax.spines['left'].set_position(('data',0)) 33 | ax.spines['bottom'].set_position(('data', 0)) 34 | 35 | plt.plot(x,s,label=r'$Morse$', 36 | color='b', linewidth=2, linestyle='-') 37 | 38 | plt.legend() 39 | plt.savefig('Morse.pdf') 40 | plt.close() 41 | 42 | 43 | def func(x): 44 | s = morse(x) 45 | return s**2 46 | 47 | 48 | def resolve(): 49 | res = minimize_scalar(func,method='brent') 50 | print(res.x) 51 | 52 | #t = morse(0.8813735870089523) 53 | #print(t*t) 54 | 55 | 56 | if __name__ == '__main__': 57 | ''' use commond like ./bp.py to run it 58 | z: optimize zpe 59 | t: train the whole net 60 | ''' 61 | plot_morse() 62 | # resolve() 63 | 64 | -------------------------------------------------------------------------------- /irff/plot/sigmoid.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import numpy as np 4 | import matplotlib 5 | matplotlib.use('Agg') 6 | import matplotlib.pyplot as plt 7 | from scipy.optimize import minimize_scalar 8 | 9 | 10 | def sigmoid(x): 11 | # sigmoid_alpha = 1.0 12 | # s = np.log(1.0+np.exp(sigmoid_alpha*x))/sigmoid_alpha 13 | s = 1.0/(1.0+np.exp(-x)) 14 | return s 15 | 16 | 17 | def plot_s(): 18 | x = np.linspace(-5.0,5.0,100) 19 | s = sigmoid(x) 20 | 21 | plt.figure() 22 | plt.ylabel(r'$Sigmoid$') 23 | plt.xlabel(r'$x$') 24 | 25 | ax = plt.gca() 26 | ax.spines['right'].set_color('none') 27 | ax.spines['top'].set_color('none') 28 | ax.spines['left'].set_position(('data',0)) 29 | ax.spines['bottom'].set_position(('data', 0)) 30 | 31 | plt.plot(x,s,label=r'$Sigmoid$ $Neuron$', 32 | color='b', linewidth=2, linestyle='-') 33 | 34 | plt.legend() 35 | plt.savefig('sigmoid.eps') 36 | plt.close() 37 | 38 | 39 | def func(x): 40 | s = sigmoid(x) 41 | return (s*s - 0.5)**2 42 | 43 | 44 | def resolve(): 45 | res = minimize_scalar(func,method='brent') 46 | print(res.x) 47 | 48 | t = sigmoid(0.8813735870089523) 49 | print(t*t) 50 | 51 | 52 | if __name__ == '__main__': 53 | ''' use commond like ./bp.py to run it 54 | z: optimize zpe 55 | t: train the whole net 56 | ''' 57 | plot_s() 58 | 59 | 60 | -------------------------------------------------------------------------------- /irff/prop/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/prop/.keep -------------------------------------------------------------------------------- /irff/prop/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IRFF: Intelligent Reactive Force Filed, A ReaxFF developing tool kit. 3 | Authored by FengGo. 4 | email: fengguo@lcu.edu.cn 5 | gfeng.alan@foxmail.com 6 | 7 | This software package is under academic license. 8 | 9 | 2019-05-06: 10 | version 3.3 fix bugs of NLP, PBO calculation 11 | Delta_angle index error 12 | 2019-04-16 13 | version 3.2 weight added 14 | 2019-04-02: 15 | version 3.1 change log, test of torsion energies, 16 | found eover and eunder bugs(fixed) 17 | add penalty for case of bond-order to small 18 | 19 | ''' 20 | 21 | -------------------------------------------------------------------------------- /irff/structures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/structures/.keep -------------------------------------------------------------------------------- /irff/structures/Al.gen: -------------------------------------------------------------------------------- 1 | 4 S 2 | Al 3 | 1 1 0.000000000000000 0.000000000000000 0.000000000000000 4 | 2 1 0.000000000000000 2.025000000000000 2.025000000000000 5 | 3 1 2.025000000000000 0.000000000000000 2.025000000000000 6 | 4 1 2.025000000000000 2.025000000000000 0.000000000000000 7 | 0.000000000000000 0.000000000000000 0.000000000000000 8 | 4.050000000000000 0.000000000000000 0.000000000000000 9 | 0.000000000000000 4.050000000000000 0.000000000000000 10 | 0.000000000000000 0.000000000000000 4.050000000000000 11 | -------------------------------------------------------------------------------- /irff/structures/C2C4.gen: -------------------------------------------------------------------------------- 1 | 6 S 2 | C 3 | 1 1 3.858859592131164 3.184084899416688 3.807311327242221 4 | 2 1 4.391859592131162 2.256084899416687 3.807311327242221 5 | 3 1 2.788859592131163 3.184084899416688 3.807311327242221 6 | 4 1 4.534859592131162 4.359084899416704 3.807311327242221 7 | 5 1 4.000859592131164 5.286084899416700 3.807311327242221 8 | 6 1 5.604859592131158 4.359084899416704 3.807311327242221 9 | 0.000000000000000 0.000000000000000 0.000000000000000 10 | 8.528219999999999 0.000000000000000 0.000000000000000 11 | 0.000000000000000 8.385439999999999 0.000000000000000 12 | 0.000000000000000 0.000000000000000 8.653760000000000 13 | -------------------------------------------------------------------------------- /irff/structures/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from os.path import isfile 3 | from ase import Atoms 4 | from ase.io import read,write 5 | import os 6 | 7 | 8 | def structure(gen): 9 | _root = os.path.abspath(os.path.dirname(__file__)) 10 | if isfile(_root+'/'+gen+'.gen'): 11 | A = read(_root+'/'+gen+'.gen') 12 | elif isfile(_root+'/'+gen+'.cif'): 13 | A = read(_root+'/'+gen+'.cif') 14 | else: 15 | raise RuntimeError('Structure is not found!') 16 | return A 17 | 18 | 19 | -------------------------------------------------------------------------------- /irff/structures/diamond.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | import argh 5 | import argparse 6 | import numpy as np 7 | import json 8 | from ase import units 9 | from ase.spacegroup import crystal 10 | from ase.build import bulk 11 | from flare.gp import GaussianProcess 12 | from flare.utils.parameter_helper import ParameterHelper 13 | from ase.calculators.siesta import Siesta 14 | from ase.calculators.siesta.parameters import Species, PAOBasisBlock 15 | from ase.units import Ry 16 | from flare.ase.calculator import FLARE_Calculator 17 | from ase import units 18 | from ase.io import read 19 | from ase.io.trajectory import TrajectoryWriter 20 | 21 | 22 | 23 | def diamond(supercell=[1,1,1],write_=False): 24 | a = 3.52678 25 | super_cell = bulk('C', 'diamond', a=a, cubic=True) 26 | super_cell = super_cell*supercell# [2,2,2] 27 | if write_: 28 | super_cell.write('diamond.gen') 29 | return super_cell 30 | 31 | 32 | if __name__ == '__main__': 33 | diamond() 34 | 35 | -------------------------------------------------------------------------------- /irff/structures/nm3.gen: -------------------------------------------------------------------------------- 1 | 21 S 2 | C N O H 3 | 1 1 6.176825186867148 1.849305573098204 2.632977730913833 4 | 2 2 5.524048840000000 3.346482360000000 1.836397456000000 5 | 3 3 4.488014080000000 3.835091968000000 1.206684984000000 6 | 4 3 6.456092472000000 3.843426304000000 2.548136920000000 7 | 5 4 2.053670347836237 1.650928887868471 3.256710983250413 8 | 6 4 5.555666930867148 2.079496965098204 3.594848738913833 9 | 7 4 6.059737642867148 0.753225485098204 2.390797786913833 10 | 8 1 2.457641435836234 0.904176223868471 3.987813559250413 11 | 9 2 3.572801571836245 1.668797855868471 4.641173695250414 12 | 10 3 4.163038312970526 2.644291522110522 4.417496977909530 13 | 11 3 4.522011451718785 0.873975221042620 5.289671422062201 14 | 12 4 2.778914371836232 -0.122961472131533 3.667475175250413 15 | 13 4 7.422050106867149 1.904981181098204 2.933404154913833 16 | 14 4 1.612996555836242 0.896594783868471 4.688164295250414 17 | 15 1 3.400593072000000 5.690966656000000 3.609735000000000 18 | 16 2 4.373822688000000 5.567081168000000 4.706918128000000 19 | 17 3 3.837353248000000 5.814201976000000 5.784274344000000 20 | 18 3 5.465852648000000 5.089990760000000 4.632640128000000 21 | 19 4 3.955645032000000 5.935428360000000 2.723515992000000 22 | 20 4 2.837771168000000 4.764140208000000 3.423837952000000 23 | 21 4 2.790227480000000 6.501172048000000 3.922247888000000 24 | 0.000000000000000 0.000000000000000 0.000000000000000 25 | 8.000000000000000 0.000000000000000 0.000000000000000 26 | 0.000000000000000 8.000000000000000 0.000000000000000 27 | 0.000000000000000 0.000000000000000 8.000000000000000 28 | -------------------------------------------------------------------------------- /irff/tools/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/irff/tools/.keep -------------------------------------------------------------------------------- /irff/tools/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | IRFF: Intelligent Reactive Force Filed, A ReaxFF developing tool kit. 3 | Authored by FengGo. 4 | email: fengguo@lcu.edu.cn 5 | gfeng.alan@foxmail.com 6 | 7 | This software package is under academic license. 8 | 9 | 2019-05-06: 10 | version 3.3 fix bugs of NLP, PBO calculation 11 | Delta_angle index error 12 | 2019-04-16 13 | version 3.2 weight added 14 | 2019-04-02: 15 | version 3.1 change log, test of torsion energies, 16 | found eover and eunder bugs(fixed) 17 | add penalty for case of bond-order to small 18 | 19 | ''' 20 | 21 | -------------------------------------------------------------------------------- /irff/tools/eos_opt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase.io import read 3 | from ase.units import kJ 4 | from ase.eos import EquationOfState 5 | from ase.optimize import BFGS,QuasiNewton,FIRE 6 | from irff.md import opt,bhopt 7 | from ase.io.trajectory import TrajectoryWriter 8 | 9 | 10 | # configs = read('Ag.traj@0:5') # read 5 configurations 11 | # # Extract volumes and energies: 12 | # volumes = [ag.get_volume() for ag in configs] 13 | # energies = [ag.get_potential_energy() for ag in configs] 14 | # eos = EquationOfState(volumes, energies) 15 | # v0, e0, B = eos.fit() 16 | # print(B / kJ * 1.0e24, 'GPa')365222 17 | # eos.plot('nm-eos.png') 18 | traj = TrajectoryWriter('eos_opt.traj',mode='w') 19 | 20 | atoms = read('NM.gen') 21 | cell = atoms.get_cell() 22 | atoms_ = atoms.copy() 23 | # atoms_ = opt(atoms=atoms_,fmax=0.01,step=200) 24 | configs = [] 25 | s = 1.1 26 | i = 0 27 | while s>0.70: 28 | print(' * lattice step:',i) 29 | f= s**(1.0/3.0) 30 | cell_ = cell.copy() 31 | cell_ = cell*f 32 | atoms_.set_cell(cell_) 33 | # if i>9 and i<15: 34 | atoms_ = opt(atoms=atoms_,fmax=0.02,step=120,optimizer=FIRE) 35 | # else: 36 | # atoms_ = bhopt(atoms=atoms_,fmax=0.02,step=120,temperature=30,optimizer=BFGS) 37 | 38 | configs.append(atoms_) 39 | traj.write(atoms=atoms_) 40 | s= s*0.98 41 | i += 1 42 | 43 | -------------------------------------------------------------------------------- /irff/tools/epstopdf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | from os import system,listdir,getcwd 4 | 5 | 6 | 7 | eps = listdir(getcwd()) 8 | 9 | for fil in eps: 10 | if fil.find('.eps')>=0: 11 | system('epstopdf '+fil) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /irff/tools/ffieldtolib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase.io import read 3 | import argh 4 | import argparse 5 | import json as js 6 | from os import environ,system 7 | import csv 8 | import pandas as pd 9 | from os.path import isfile 10 | from ..reaxfflib import read_ffield,write_lib,write_lib 11 | from ..qeq import qeq 12 | 13 | 14 | def ffieldtolib(): 15 | lf = open('ffield.json','r') 16 | j = js.load(lf) 17 | p_ = j['p'] 18 | m_ = j['m'] 19 | vdw_layer = j['vdw_layer'] 20 | mf_layer = j['mf_layer'] 21 | be_layer = j['be_layer'] 22 | lf.close() 23 | 24 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 25 | write_lib(p_,spec,bonds,offd,angs,torp,hbs,m=m_,mf_layer=mf_layer, 26 | be_layer=be_layer,vdw_layer=vdw_layer, 27 | libfile='reaxff_nn.lib') 28 | 29 | 30 | def init_bonds(p_): 31 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 32 | for key in p_: 33 | # key = key.encode('raw_unicode_escape') 34 | # print(key) 35 | k = key.split('_') 36 | if k[0]=='bo1': 37 | bonds.append(k[1]) 38 | elif k[0]=='rosi': 39 | kk = k[1].split('-') 40 | # print(kk) 41 | if len(kk)==2: 42 | if kk[0]!=kk[1]: 43 | offd.append(k[1]) 44 | elif len(kk)==1: 45 | spec.append(k[1]) 46 | elif k[0]=='theta0': 47 | angs.append(k[1]) 48 | elif k[0]=='tor1': 49 | torp.append(k[1]) 50 | elif k[0]=='rohb': 51 | hbs.append(k[1]) 52 | return spec,bonds,offd,angs,torp,hbs 53 | 54 | 55 | if __name__ == '__main__': 56 | ffieldtolib() 57 | 58 | -------------------------------------------------------------------------------- /irff/tools/fingerprint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import numpy as np 4 | from ase.structure import molecule 5 | from ase import Atoms 6 | import os 7 | 8 | atoms = molecule('H2O') 9 | atoms.rotate('y', -np.pi/2.) 10 | atoms.set_pbc(False) 11 | displacements = np.linspace(0.9, 8.0, 20) 12 | vec = atoms[2].position - atoms[0].position 13 | 14 | images = [] 15 | for displacement in displacements: 16 | atoms = Atoms(atoms) 17 | atoms[2].position = (atoms[0].position + vec * displacement) 18 | images.append(atoms) 19 | 20 | # Fingerprint using Amp. 21 | from amp.descriptor.gaussian import Gaussian 22 | descriptor = Gaussian() 23 | from amp.utilities import hash_images 24 | images = hash_images(images, ordered=True) 25 | descriptor.calculate_fingerprints(images) 26 | 27 | # Plot the data. 28 | from matplotlib import pyplot 29 | 30 | def barplot(hash, name, title): 31 | """Makes a barplot of the fingerprint about the O atom.""" 32 | fp = descriptor.fingerprints[hash][0] 33 | fig, ax = pyplot.subplots() 34 | ax.bar(range(len(fp[1])), fp[1]) 35 | ax.set_title(title) 36 | ax.set_ylim(0., 2.) 37 | ax.set_xlabel('fingerprint') 38 | ax.set_ylabel('value') 39 | fig.savefig(name) 40 | 41 | for index, hash in enumerate(images.keys()): 42 | barplot(hash, 'bplot-%02i.png' % index, 43 | '%.2f$\\times$ equilibrium O-H bondlength' 44 | % displacements[index]) 45 | 46 | # For fun, make an animated gif. 47 | 48 | filenames = ['bplot-%02i.png' % index for index in range(len(images))] 49 | command = ('convert -delay 100 %s -loop 0 animation.gif' % 50 | ' '.join(filenames)) 51 | os.system(command) 52 | -------------------------------------------------------------------------------- /irff/tools/json_to_ffield.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_lib,write_lib 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import argh 6 | import argparse 7 | import json as js 8 | from os import environ,system 9 | import csv 10 | import pandas as pd 11 | from os.path import isfile 12 | 13 | 14 | 15 | def jsontoffield(): 16 | lf = open('ffield.json','r') 17 | j = js.load(lf) 18 | p_ = j['p'] 19 | m_ = j['m'] 20 | bo_layer_ = j['bo_layer'] 21 | lf.close() 22 | 23 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 24 | write_lib(p_,spec,bonds,offd,angs,torp,hbs,libfile='ffield') 25 | 26 | 27 | def init_bonds(p_): 28 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 29 | for key in p_: 30 | # key = key.encode('raw_unicode_escape') 31 | # print(key) 32 | k = key.split('_') 33 | if k[0]=='bo1': 34 | bonds.append(k[1]) 35 | elif k[0]=='rosi': 36 | kk = k[1].split('-') 37 | # print(kk) 38 | if len(kk)==2: 39 | if kk[0]!=kk[1]: 40 | offd.append(k[1]) 41 | elif len(kk)==1: 42 | spec.append(k[1]) 43 | elif k[0]=='theta0': 44 | angs.append(k[1]) 45 | elif k[0]=='tor1': 46 | torp.append(k[1]) 47 | elif k[0]=='rohb': 48 | hbs.append(k[1]) 49 | return spec,bonds,offd,angs,torp,hbs 50 | 51 | 52 | if __name__ == '__main__': 53 | jsontoffield() 54 | 55 | -------------------------------------------------------------------------------- /irff/tools/pre_opt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase.io import read 3 | # from ase.units import kJ,GPa 4 | from ase.eos import EquationOfState 5 | from ase.optimize import BFGS,FIRE 6 | from irff.md import opt 7 | from irff.irff import IRFF 8 | from ase.io.trajectory import TrajectoryWriter 9 | import matplotlib.pyplot as plt 10 | 11 | 12 | traj = TrajectoryWriter('pre_opt.traj',mode='w') 13 | 14 | atoms = read('sc.gen') 15 | cell = atoms.get_cell() 16 | atoms_ = atoms.copy() 17 | configs= [] 18 | GPa = 1.60217662*1.0e2 19 | s = 1.0 20 | i = 0 21 | ir = IRFF(atoms=atoms_,libfile='ffield.json',nn=True) 22 | 23 | v_,p = [],[] 24 | v0 = atoms.get_volume() 25 | 26 | while s>0.59: 27 | print(' * lattice step:',i) 28 | f= s**(1.0/3.0) 29 | cell_ = cell.copy() 30 | cell_ = cell*f 31 | atoms_.set_cell(cell_) 32 | atoms_ = opt(atoms=atoms_,fmax=0.02,step=120,optimizer=FIRE) 33 | configs.append(atoms_) 34 | traj.write(atoms=atoms_) 35 | ir.calculate(atoms=atoms_,CalStress=True) 36 | stress = ir.results['stress'] 37 | 38 | nonzero = 0 39 | stre_ = 0.0 40 | for _ in range(3): 41 | if abs(stress[_])>0.0000001: 42 | nonzero += 1 43 | stre_ += -stress[_] 44 | pressure = stre_*GPa/nonzero 45 | 46 | p.append(pressure) 47 | v = atoms_.get_volume() 48 | v_.append(v/v0) 49 | print(' * V/V0',v_[-1],v,pressure) 50 | 51 | s= s*0.98 52 | i += 1 53 | 54 | fig, ax = plt.subplots() 55 | plt.ylabel(r'$Pressure$ ($GPa$)') 56 | plt.xlabel(r'$V/V_0$') 57 | plt.plot(v_,p,label=r'$IRFF-MPNN$', color='blue', 58 | marker='o',markerfacecolor='none', 59 | markeredgewidth=1, 60 | ms=5,alpha=0.8, 61 | linewidth=1, linestyle='-') 62 | 63 | plt.legend(loc='best',edgecolor='yellowgreen') 64 | plt.savefig('pv.pdf') 65 | plt.close() 66 | -------------------------------------------------------------------------------- /irff/tools/pressure.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase.io import read 3 | from ase.units import kJ # ,GPa 4 | from ase.eos import EquationOfState 5 | from ase.optimize import BFGS,FIRE 6 | from irff.md import opt 7 | from irff.irff import IRFF 8 | from ase.io.trajectory import Trajectory 9 | import matplotlib.pyplot as plt 10 | 11 | 12 | images = Trajectory('pre_opt.traj',mode='r') 13 | 14 | ir = IRFF(atoms=images[0], 15 | libfile='ffield.json', 16 | rcut=None, 17 | nn=True) 18 | GPa = 1.60217662*1.0e2 19 | 20 | v_,p = [],[] 21 | v0 = images[0].get_volume() 22 | 23 | for atoms_ in images: 24 | ir.calculate(atoms=atoms_,CalStress=True) 25 | stress = ir.results['stress'] 26 | 27 | nonzero = 0 28 | stre_ = 0.0 29 | for _ in range(3): 30 | if abs(stress[_])>0.0000001: 31 | nonzero += 1 32 | stre_ += -stress[_] 33 | pressure = stre_*GPa/nonzero 34 | 35 | p.append(pressure) 36 | v = atoms_.get_volume() 37 | v_.append(v/v0) 38 | print(' * V/V0',v_[-1],v,pressure) 39 | 40 | 41 | fig, ax = plt.subplots() 42 | plt.ylabel(r'$Pressure$ ($GPa$)') 43 | plt.xlabel(r'$V/V_0$') 44 | plt.plot(v_,p,label=r'$IRFF-MPNN$', color='blue', 45 | marker='o',markerfacecolor='none', 46 | markeredgewidth=1, 47 | ms=5,alpha=0.8, 48 | linewidth=1, linestyle='-') 49 | # plt.fill_between(X_plot[:, 0], y_gpr - y_std, y_gpr + y_std, color='darkorange', 50 | # alpha=0.2) 51 | plt.legend(loc='best',edgecolor='yellowgreen') 52 | plt.savefig('pv.pdf') 53 | plt.close() 54 | -------------------------------------------------------------------------------- /irff/tools/vdw.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def taper(r,vdwcut=10.0): 5 | tp = 1.0+np.divide(-35.0,np.power(vdwcut,4.0))*np.power(r,4.0)+ \ 6 | np.divide(84.0,np.power(vdwcut,5.0))*np.power(r,5.0)+ \ 7 | np.divide(-70.0,np.power(vdwcut,6.0))*np.power(r,6.0)+ \ 8 | np.divide(20.0,np.power(vdwcut,7.0))*np.power(r,7.0) 9 | return tp 10 | 11 | 12 | def vdw(r,Devdw=0.01,gamma=1.0,gammaw=1.0,vdw1=1.0,rvdw=2.0,alfa=12.0): 13 | gm3 = np.power(1.0/gamma,3.0) 14 | r3 = np.power(r,3.0) 15 | 16 | rr = np.power(r,vdw1) + np.power(1.0/gammaw,vdw1) 17 | f13 = np.power(rr,1.0/vdw1) 18 | tpv = taper(r) 19 | 20 | expvdw1 = np.exp(0.5*alfa*(1.0-np.divide(f13,2.0*rvdw))) 21 | expvdw2 = np.square(expvdw1) 22 | evdw = tpv*Devdw*(expvdw2-2.0*expvdw1) 23 | return evdw 24 | 25 | -------------------------------------------------------------------------------- /irff/tools/zmat_to_atoms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from ase.calculators.singlepoint import SinglePointCalculator 7 | from irff.AtomDance import AtomDance 8 | from irff.zmatrix import zmat_to_atoms 9 | # get_ipython().run_line_magic('matplotlib', 'inline') 10 | 11 | 12 | zmat = [ 13 | [ 'O', 6, -1, -1, -1, 0.0000, 0.0000, 0.0000 ], 14 | [ 'N', 4, 6, -1, -1, 1.4901, 0.0000, 0.0000 ], 15 | [ 'N', 5, 4, 6, -1, 1.3554,120.1679, 0.0000 ], 16 | [ 'O', 7, 4, 6, 5, 1.2807,118.8074, 2.7061 ], 17 | [ 'C', 0, 5, 4, 6, 1.4933,128.1317, 163.3464 ], 18 | [ 'H', 2, 0, 5, 4, 1.0941,117.1877, -45.5241 ], 19 | [ 'H', 3, 0, 5, 4, 1.2500,116.6197,-167.4330 ], 20 | [ 'H', 8, 0, 5, 4, 1.0964,118.7857, 80.5217 ], 21 | [ 'C', 1, 5, 4, 6, 1.5971,123.6618, -4.8899 ], 22 | [ 'H', 9, 1, 5, 4, 1.0874,115.2583, 50.7324 ], 23 | [ 'N', 10, 1, 5, 4, 1.4651,137.2663,-179.6538 ], 24 | [ 'H', 11, 10, 1, 5, 1.0583,133.5558, 167.7767 ], 25 | [ 'H', 12, 10, 1, 5, 1.0660,117.1625, 15.0633 ], 26 | [ 'H', 13, 1, 5, 4, 1.1038,107.3054, -50.3790 ], 27 | ] 28 | 29 | atoms = zmat_to_atoms(zmat,resort=False) 30 | 31 | atoms.write('hmx2-0.gen') 32 | # view(atoms) 33 | 34 | 35 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | # from distutils.core import setup 3 | from Cython.Distutils import build_ext 4 | from Cython.Build import cythonize 5 | 6 | 7 | ''' 8 | install with commond 9 | "python setup.py build_ext --inplace" 10 | "python setup install --user" 11 | or with command 12 | * version 1.7.2 13 | Correct the usage of batch size. 14 | * version 1.7.1 15 | Remove of dependence of pandas. 16 | 17 | * version 1.7.0 18 | Force learning with TensorFlow. 19 | 20 | * version 1.6.2 21 | Bus fixes. 22 | 23 | * version 1.6.1 24 | Add force learning and PyTorch backend. 25 | 26 | * version 1.6 27 | Add a penalty term for translation-invariant. 28 | ''' 29 | 30 | 31 | __version__ = '1.7.2' 32 | install_requires = ['numpy','ase'] # ,'tensorflow','matplotlib','paramiko','argh','scikit-learn','cython'] 33 | url = "https://gitee.com/fenggo/I-ReaxFF" 34 | 35 | 36 | setup(name="irff", 37 | version=__version__, 38 | description="Intelligent Reactive Force Field", 39 | author="FengGo", 40 | author_email='fengguo@lcu.edu.cn', 41 | url=url, 42 | download_url='{}/archive/{}.tar.gz'.format(url, __version__), 43 | license="LGPL", 44 | packages= find_packages(), 45 | package_data={'': ['*.gen','*.json','*.pyx']}, 46 | ext_modules=cythonize(['irff/neighbor.pyx','irff/getNeighbor.pyx'],annotate=True)) 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/test/.keep -------------------------------------------------------------------------------- /test/gp4-0.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/test/gp4-0.traj -------------------------------------------------------------------------------- /test/gp4-1.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/test/gp4-1.traj -------------------------------------------------------------------------------- /test/md.traj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/test/md.traj -------------------------------------------------------------------------------- /test/test_train_tf_force.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import torch 3 | from ase import Atoms 4 | from irff.reax_nn import ReaxFF_nn 5 | from irff.data.ColData import ColData 6 | 7 | getdata = ColData() 8 | 9 | 10 | rn = ReaxFF_nn(dataset={'gp4-0':'gp4-0.traj', 11 | 'gp4-1':'gp4-1.traj'}, 12 | libfile='ffield.json', 13 | screen=True) 14 | rn.run(learning_rate=0.0001,step=1000) 15 | 16 | -------------------------------------------------------------------------------- /tools/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/.keep -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | ### Introduction for tools scripts 2 | 1. add_layer.py 3 | Add new neural networks to current models, suppose the current parameter file is 'ffield.json', you should make a copy of it named 'ffieldData.json', after running the script by: 4 | ```bash 5 | ./add_layer.py 6 | ``` 7 | add assuming that the loss is very small, such as 0.001, the parameter file will be 'ffield.json' with new hidden layers with defination. -------------------------------------------------------------------------------- /tools/add_element.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.tools.prepare_ffield import add_elements 3 | 4 | if __name__ == "__main__": 5 | # app.run(select_elements) 6 | add_elements('H',ffield='ffield-Thompson') 7 | -------------------------------------------------------------------------------- /tools/add_layer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import tensorflow as tf 3 | from irff.ml.data import get_data,get_bond_data,get_md_data 4 | from irff.ml.fit import train as train_nn 5 | from train import dataset 6 | tf.compat.v1.disable_eager_execution() 7 | 8 | 9 | ''' 10 | Add neural network layer for current MLP models 11 | ''' 12 | 13 | 14 | bonds = ['C-C'] 15 | D,Bp,B,R,E = get_data(dataset=dataset,bonds=bonds, 16 | message_function=3, 17 | ffield='ffieldData.json') 18 | 19 | train_nn(Bp,D,B,E,bonds=bonds,step=100000,fitobj='BO', 20 | layer=(9,6), 21 | learning_rate=0.0001) 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tools/atoms_to_poscar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import argparse 4 | from ase.io import read 5 | from pymatgen.core import Structure 6 | from pymatgen.io.ase import AseAtomsAdaptor 7 | 8 | parser = argparse.ArgumentParser(description='./atoms_to_poscar.py --g=siesta.traj') 9 | parser.add_argument('--gen',default='md.traj', help='atomic configuration') 10 | parser.add_argument('--i',default=-1,type=int, help='the index in atomic configurations') 11 | args = parser.parse_args(sys.argv[1:]) 12 | 13 | atoms = read(args.gen,index=args.i) 14 | structure = AseAtomsAdaptor.get_structure(atoms) 15 | 16 | cell = atoms.get_cell() 17 | angles = cell.angles() 18 | lengths = cell.lengths() 19 | 20 | structure.to(filename="POSCAR") 21 | 22 | with open('POSCAR','r') as f: 23 | lines = f.readlines() 24 | 25 | with open('POSCAR','w') as f: 26 | card = False 27 | for i,line in enumerate(lines): 28 | if line.find('direct')>=0: 29 | card = True 30 | if card and line.find('direct')<0: 31 | print(line[:-3],file=f) 32 | elif i==0: 33 | print('EA {:.6f} {:.6f} {:.6f} {:.3f} {:.3f} {:.3f} Sym.group: 1'.format(lengths[0], 34 | lengths[1],lengths[2], 35 | angles[0],angles[1],angles[2]),file=f) 36 | else: 37 | print(line[:-1],file=f) 38 | -------------------------------------------------------------------------------- /tools/atoms_to_yaml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import argparse 4 | import numpy as np 5 | from ase.io import read 6 | #from pymatgen.core import Structure 7 | #from pymatgen.io.ase import AseAtomsAdaptor 8 | 9 | parser = argparse.ArgumentParser(description='./atoms_to_poscar.py --g=siesta.traj') 10 | parser.add_argument('--gen',default='md.traj', help='atomic configuration') 11 | parser.add_argument('--i',default=-1,type=int, help='the index in atomic configurations') 12 | args = parser.parse_args(sys.argv[1:]) 13 | 14 | atoms = read(args.gen,index=args.i) 15 | # atoms.write('poscar.yaml') 16 | 17 | cell = atoms.get_cell() 18 | cell = cell[:].astype(dtype=np.float32) 19 | rcell = np.linalg.inv(cell).astype(dtype=np.float32) 20 | positions = atoms.get_positions() 21 | xf = np.dot(positions,rcell) 22 | xf = np.mod(xf,1.0) 23 | fy = args.gen[:-4] + '.yaml' 24 | 25 | with open(fy,'w') as f: 26 | print('unit_cell:',file=f) 27 | print(' lattice:',file=f) 28 | print(' - [{:f},{:f},{:f}] '.format(cell[0][0],cell[0][1],cell[0][2],),file=f) 29 | print(' - [{:f},{:f},{:f}] '.format(cell[1][0],cell[1][1],cell[1][2],),file=f) 30 | print(' - [{:f},{:f},{:f}] '.format(cell[2][0],cell[2][1],cell[2][2],),file=f) 31 | print(' points:',file=f) 32 | symbols = atoms.get_chemical_symbols() 33 | for i,x in enumerate(xf): 34 | print(' - symbol: {:s}'.format(symbols[i]),file=f) 35 | print(' coordinates: [{:f},{:f},{:f}] '.format(x[0],x[1],x[2]),file=f) 36 | -------------------------------------------------------------------------------- /tools/axial_strain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import argh 4 | import argparse 5 | from ase.io import read,write 6 | import numpy as np 7 | from ase.calculators.singlepoint import SinglePointCalculator 8 | from ase.md.verlet import VelocityVerlet 9 | from ase.io.trajectory import TrajectoryWriter 10 | from ase import units 11 | from ase.visualize import view 12 | from irff.md.gulp import opt 13 | 14 | 15 | atoms = read('gulp.cif') 16 | # cell = atoms.get_cell()[:] 17 | 18 | #cell[2] = cell[2]*0.9996 19 | #print(cell) 20 | #atoms.set_cell(cell) 21 | #view(atoms) 22 | his = TrajectoryWriter('axial_strain.traj', mode='w') 23 | 24 | for i in range(5): 25 | cell = atoms.get_cell()[:] 26 | cell[2] = cell[2]*1.001 # 0.999 27 | atoms.set_cell(cell) 28 | 29 | e,atoms = opt(atoms=atoms,step=200,lib='reaxff_nn') 30 | calc = SinglePointCalculator(atoms, energy=e) 31 | atoms.set_calculator(calc) 32 | his.write(atoms=atoms) 33 | 34 | his.close() 35 | 36 | -------------------------------------------------------------------------------- /tools/bend.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance 7 | import sys 8 | import argh 9 | import argparse 10 | 11 | 12 | help_ ='./bend.py --g=nm.gen --i=0 --j=1 --k=2 --a=30.0' 13 | 14 | parser = argparse.ArgumentParser(description=help_) 15 | parser.add_argument('--g',default='poscar.gen',type=str, help='atomic configuration') 16 | parser.add_argument('--i',default=0,type=int, help='atoms i of the angle') 17 | parser.add_argument('--j',default=1,type=int, help='atoms j of the angle') 18 | parser.add_argument('--k',default=2,type=int, help='atoms k of the angle') 19 | parser.add_argument('--f',default=-1,type=int, help='atoms index of the trajectory') 20 | parser.add_argument('--ar',default=30.0,type=float, help='angle range') 21 | 22 | args = parser.parse_args(sys.argv[1:]) 23 | 24 | atoms = read(args.g,index=args.f) 25 | # traj.write(atoms=atoms) 26 | 27 | ad = AtomDance(atoms) 28 | images = ad.swing_group([args.i,args.j,args.k],rang=args.ar,nbin=50,traj='md.traj') 29 | # images = ad.bend([args.i,args.j,args.k],rang=args.ar,nbin=30,traj='md.traj') 30 | # images = ad.rotate(atms=[0,1,2,3,4,5],axis=[6,7],o=6,rang=30.0,nbin=20,wtraj=True) 31 | # ad.zmat_to_cartation(atoms,ad.InitZmat) 32 | ad.close() 33 | # view(atoms) 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tools/c3_zmat_pes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import matplotlib.pyplot as plt 4 | import matplotlib.mlab as mlab 5 | from mpl_toolkits.mplot3d import Axes3D 6 | import numpy as np 7 | from ase.visualize import view 8 | from ase.io import read 9 | from ase.io.trajectory import TrajectoryWriter,Trajectory 10 | from ase.calculators.singlepoint import SinglePointCalculator 11 | from irff.AtomDance import AtomDance 12 | from irff.zmatrix import zmat_to_atoms 13 | # get_ipython().run_line_magic('matplotlib', 'inline') 14 | 15 | zmat = [[ 'C', 0, -1, -1, -1, 0.0000, 0.0000, 0.0000 ], 16 | [ 'C', 1, 0, -1, -1, 1.5401, 0.0000, 0.0000 ], 17 | [ 'C', 2, 1, 0, -1, 1.3748,135.4097, 0.0000 ]] 18 | atoms = zmat_to_atoms(zmat) 19 | 20 | 21 | # atoms = read('c3.gen',index=-1) 22 | ad = AtomDance(atoms=atoms,rmax=1.33) 23 | images = ad.stretch([0,1],nbin=30,rst=1.1,red=1.7,scale=1.26,traj='md-c3.traj') 24 | ad.close() 25 | 26 | 27 | zmat = [[ 'C', 0, -1, -1, -1, 0.0000, 0.0000, 0.0000 ], 28 | [ 'C', 1, 0, -1, -1, 1.5401, 0.0000, 0.0000 ]] 29 | atoms = zmat_to_atoms(zmat) 30 | # atoms = read('c3.gen',index=-1) 31 | ad = AtomDance(atoms=atoms,rmax=1.33) 32 | images = ad.stretch([0,1],nbin=30,rst=1.1,red=1.7,scale=1.26,traj='md-c2.traj') 33 | ad.close() 34 | 35 | # view(images) 36 | 37 | -------------------------------------------------------------------------------- /tools/checkoffd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_lib,write_lib 3 | # from irff.irnnlib_new import write_lib 4 | from irff.qeq import qeq 5 | from ase.io import read 6 | import argh 7 | import argparse 8 | import json as js 9 | from os import environ,system 10 | 11 | 12 | def checkoffd(): 13 | p,zpe,spec,bonds,offd,angs,torp,hbs= read_lib(libfile='ffield') 14 | 15 | for key in p: # check minus ropi ropp parameters 16 | k = key.split('_') 17 | if k[0] == 'ropi': 18 | bd = k[1] 19 | b = bd.split('-') 20 | if len(b) == 1: 21 | bd_ = b[0]+'-'+b[0] 22 | else: 23 | bd_ = bd 24 | 25 | if p['ropi_'+bd] < 0.0: 26 | p['ropi_'+bd] = 0.3*p['rosi_'+bd] 27 | p['bo3_'+bd_] = -50.0 28 | p['bo4_'+bd_] = 0.0 29 | if p['ropp_'+bd] < 0.0: 30 | p['ropp_'+bd] = 0.2*p['rosi_'+bd] 31 | p['bo5_'+bd_] = -50.0 32 | p['bo6_'+bd_] = 0.0 33 | 34 | write_lib(p,spec,bonds,offd,angs,torp,hbs,libfile='ffield-new') 35 | 36 | 37 | 38 | if __name__ == '__main__': 39 | checkoffd() 40 | 41 | -------------------------------------------------------------------------------- /tools/cif_to_poscar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import argparse 4 | import pymatgen.core as pmg 5 | # Integrated symmetry analysis tools from spglib 6 | from pymatgen.symmetry.analyzer import SpacegroupAnalyzer 7 | 8 | parser = argparse.ArgumentParser(description='eos by scale crystal box') 9 | parser.add_argument('--g', default='Individuals.traj',type=str, help='trajectory file') 10 | args = parser.parse_args(sys.argv[1:]) 11 | 12 | structure = pmg.Structure.from_file(args.g) 13 | 14 | finder = SpacegroupAnalyzer(structure) 15 | sp = finder.get_space_group_symbol() 16 | print(sp) 17 | 18 | structure.to_file('POSCAR') 19 | 20 | -------------------------------------------------------------------------------- /tools/cifs_to_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import getcwd,listdir 3 | from ase.io import read 4 | from ase.io.trajectory import TrajectoryWriter 5 | from ase.calculators.singlepoint import SinglePointCalculator 6 | 7 | 8 | def cifs_to_traj(): 9 | traj = TrajectoryWriter('structures.traj',mode='w') 10 | current_dir = getcwd() 11 | cifs = listdir(current_dir) 12 | 13 | for cif_ in cifs: 14 | if cif_.endswith('.cif'): 15 | atoms = read(cif_) 16 | calc = SinglePointCalculator(atoms,energy=0.0) 17 | atoms.calc = calc 18 | traj.write(atoms=atoms) 19 | 20 | traj.close() 21 | 22 | 23 | if __name__=='__main__': 24 | cifs_to_traj() 25 | 26 | 27 | -------------------------------------------------------------------------------- /tools/cnt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase.build import nanotube 3 | # cnt1 = nanotube(6, 0, length=4) 4 | 5 | cnt = nanotube(3, 3, length=3, bond=1.4, symbol='C') 6 | cnt.write('cnt333.gen') 7 | 8 | 9 | -------------------------------------------------------------------------------- /tools/collision.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | import argh 5 | import argparse 6 | from ase.visualize import view 7 | from ase.io import read 8 | from ase.io.trajectory import TrajectoryWriter,Trajectory 9 | from ase.constraints import FixAtoms 10 | from irff.irff import IRFF 11 | from irff.AtomDance import AtomDance 12 | from irff.md.irmd import IRMD 13 | 14 | 15 | ''' 16 | usage: 17 | ./collision.py --i=2 --j=7 --g=md.traj --T=2000 18 | use ./collision.py --h to see all options 19 | ''' 20 | 21 | parser = argparse.ArgumentParser(description='Molecular Collision') 22 | parser.add_argument('--g',default='poscar.gen',type=str, help='atomic configuration file name') 23 | parser.add_argument('--i',default=0,type=int, help='index of atom i') 24 | parser.add_argument('--j',default=1,type=int, help='index of atom j') 25 | parser.add_argument('--f',default=-1,type=int, help='index of atom trajectory') 26 | parser.add_argument('--step',default=100,type=int, help='time step of MD simulation') 27 | parser.add_argument('--direction',default=1,type=int, help='Collision direction, 1 or -1') 28 | parser.add_argument('--T',default=2000.0,type=float, help='Temperature of the simulation system') 29 | args = parser.parse_args(sys.argv[1:]) 30 | 31 | atoms = read(args.g,index=-1) 32 | ad = AtomDance(atoms=atoms) 33 | 34 | atoms,gi,gj = ad.set_bond_momenta(args.i,args.j,atoms,sign=args.direction) 35 | 36 | irmd = IRMD(atoms=atoms,time_step=0.1,totstep=args.step,Tmax=10000, 37 | learnpair=(args.i,args.j),beta=0.8,groupi=gi,groupj=gj, 38 | ro=0.8,rmin=0.5,initT=args.T) 39 | irmd.run() 40 | 41 | irmd.close() 42 | ad.close() 43 | 44 | -------------------------------------------------------------------------------- /tools/compare_dft.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | #from ase import Atoms 4 | from ase.io.trajectory import Trajectory 5 | from irff.plot.deb_bde import compare_dft_energy 6 | import sys 7 | import argparse 8 | 9 | parser = argparse.ArgumentParser(description='plot energies') 10 | parser.add_argument('--i',default=0,type=int,help='the id of atom i') 11 | parser.add_argument('--j',default=1,type=int,help='the id of atom j') 12 | parser.add_argument('--traj',default='md.traj',type=str,help='the dft ') 13 | parser.add_argument('--csv',default=0,type=int,help='whether save the .csv data file') 14 | parser.add_argument('--s',default=1,type=int,help='show the figure, if False, then save figure to pdf') 15 | args = parser.parse_args(sys.argv[1:]) 16 | 17 | 18 | images = Trajectory(args.traj) 19 | #e = deb_energy(images,atomi=0,atomj=1,r_is_x=True,show=args.s,nn=True,figsize=(8,8),savecsv=args.csv) 20 | e = compare_dft_energy(images,atomi=args.i,atomj=args.j,show=args.s,nn=True) 21 | 22 | ''' Usage: ./compare_dft.py --t=md.traj --i=0 --j=1 ''' 23 | 24 | -------------------------------------------------------------------------------- /tools/control_to_poscar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def control_to_poscar(): 4 | with open('CONTROL','r') as f: 5 | lines = f.readlines() 6 | element = [] 7 | lattvec = [] 8 | positions = [] 9 | for line in lines: 10 | if line.find('elements=\"')>=0: 11 | l = line.split('\"') 12 | element.append(l[1]) 13 | elif line.find('lattvec(:')>=0: 14 | l = line.split('=')[1].split(',')[0] 15 | lattvec.append(l) 16 | elif line.find('natoms=')>=0: 17 | l = line.split('=')[1].split(',')[0] 18 | natom = l 19 | elif line.find('positions(:')>=0: 20 | l = line.split('=')[1].split(',')[0] 21 | positions.append(l) 22 | 23 | with open('POSCAR','w') as f: 24 | for e in element: 25 | print(e,end=' ',file=f) 26 | print(' ',file=f) 27 | print(1.0,file=f) 28 | for v in lattvec: 29 | print(v,file=f) 30 | for e in element: 31 | print(e,end=' ',file=f) 32 | print(' ',file=f) 33 | print(natom,file=f) 34 | print('Direc',file=f) 35 | for p in positions: 36 | print(p,file=f) 37 | 38 | if __name__=='__main__': 39 | control_to_poscar() 40 | -------------------------------------------------------------------------------- /tools/data/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/data/.keep -------------------------------------------------------------------------------- /tools/data/ase_convert_dpmd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import dpdata 3 | import numpy as np 4 | from ase.io import read, write 5 | from ase.io.trajectory import Trajectory 6 | import os 7 | 8 | 9 | 10 | ms = dpdata.MultiSystems() 11 | path = './' 12 | path_list = os.listdir(path) 13 | path_list.sort() 14 | for filename in path_list: 15 | file = os.path.join(path, filename) 16 | fil = file.split()[0] 17 | print(file) 18 | if file.endswith('.traj'): 19 | sys = dpdata.MultiSystems.from_file(file_name=file, fmt='ase/structure') 20 | print(sys.systems) 21 | ms.append(sys) 22 | # sys.to_deepmd_npy('training_data/') 23 | sys.to_deepmd_npy('dp_data/{:s}'.format(fil)) 24 | 25 | 26 | 27 | print(ms.systems) 28 | print('\n# the multisystems contains %d systems' % len(ms)) 29 | print("# the information of the MultiSystems is:\n", ms) 30 | 31 | 32 | -------------------------------------------------------------------------------- /tools/data/gen_to_csv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import getcwd,chdir,listdir,system 3 | import numpy as np 4 | from tqdm import tqdm 5 | from ase.io.trajectory import Trajectory 6 | from ase.io import read 7 | from pymatgen.io.ase import AseAtomsAdaptor 8 | from ase.io import read 9 | # from irff.deb.compare_energies import deb_gulp_energy 10 | from irff.md.gulp import write_gulp_in,get_reax_energy 11 | # from irff.molecule import press_mol 12 | 13 | cdir = getcwd() 14 | files = listdir(cdir) 15 | poscars = [gen for gen in files if gen.endswith('.gen') ] 16 | images = [] 17 | ncpu = 1 18 | 19 | f = open('train.csv','w') 20 | print(',material_id,energy,density,hydrogen_bond_energy,cif,volume',file=f) 21 | 22 | for i in tqdm(range(len(poscars))): 23 | gen = poscars[i] 24 | gen_ = gen.split('.')[0] 25 | atoms = read(gen) 26 | images.append(atoms.copy()) 27 | 28 | write_gulp_in(atoms,runword='gradient nosymmetry conv qite verb', 29 | lib='reaxff_nn.lib') 30 | if ncpu==1: 31 | system('gulpout') 32 | else: 33 | system('mpirun -n {:d} gulpout'.format(ncpu)) 34 | 35 | (e,eb_,el_,eo_,eu_,ea_,ep_, 36 | etc_,et_,ef_,ev_,ehb,ecl_,esl_)= get_reax_energy(fo='out') 37 | 38 | structure = AseAtomsAdaptor.get_structure(atoms) 39 | structure.to(filename="POSCAR") 40 | 41 | masses = np.sum(atoms.get_masses()) 42 | volume = atoms.get_volume() 43 | density = masses/volume/0.602214129 44 | # print('loading structures {:d}/{:d} ...\r'.format(i,n_images),end='\r') 45 | structure = AseAtomsAdaptor.get_structure(atoms) 46 | structure.to(filename="{:s}.cif".format(gen_)) 47 | 48 | print('{:d},{:s},{:f},{:f},{:f},\"'.format(i,gen_, 49 | e,density,ehb),end='',file=f) 50 | with open("{:s}.cif".format(gen_),'r') as fc: 51 | for line in fc.readlines(): 52 | print(line.strip(),file=f) 53 | print('\",{:f}'.format(volume),file=f) 54 | 55 | f.close() 56 | -------------------------------------------------------------------------------- /tools/data/md_to_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | # import argh 4 | import argparse 5 | # from os import getcwd,listdir 6 | from irff.dft.siesta import siesta_traj 7 | from ase.io.trajectory import TrajectoryWriter 8 | 9 | def md_out_to_traj(traj): 10 | ''' siesta MD out to traj 11 | ''' 12 | traj = TrajectoryWriter(traj,mode='w') 13 | # current_dir = getcwd() 14 | images = siesta_traj(label='Carbonate',fdf='INPUT.fdf',out='log.out') 15 | for atoms in images: 16 | traj.write(atoms=atoms) 17 | traj.close() 18 | 19 | 20 | if __name__=='__main__': 21 | md_out_to_traj('md.traj') -------------------------------------------------------------------------------- /tools/deb/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/deb/.keep -------------------------------------------------------------------------------- /tools/deb/deb_bd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import print_function 3 | import argh 4 | import argparse 5 | from os import environ,system,getcwd 6 | from os.path import exists 7 | from ase.io import read,write 8 | from ase.io.trajectory import Trajectory,TrajectoryWriter 9 | from ase.calculators.singlepoint import SinglePointCalculator 10 | from ase import Atoms 11 | import numpy as np 12 | from irff.irff import IRFF 13 | from irff.irff_np import IRFF_NP 14 | from irff.data.ColData import ColData 15 | from irff.dft.CheckEmol import check_emol 16 | from irff.mpnn import MPNN 17 | import matplotlib.pyplot as plt 18 | 19 | 20 | ffield = 'ffield.json' 21 | frame = -1 22 | 23 | images = Trajectory('gulp.traj') 24 | batch_size = (len(images)) 25 | atoms = images[frame] 26 | 27 | ir = IRFF_NP(atoms=atoms, 28 | libfile=ffield, 29 | nn=True) 30 | ir.calculate(atoms) 31 | natom = ir.natom 32 | 33 | ea = ir.eang 34 | f7 = ir.f_7 35 | f8 = ir.f_8 36 | expang = ir.expang 37 | theta = ir.theta 38 | theta0 = ir.thet0 39 | sbo3 = ir.SBO3 40 | sbo = ir.SBO 41 | pbo = ir.pbo 42 | rnlp = ir.rnlp 43 | # fa = open('ang.txt','w') 44 | eb = ir.bo0 45 | D = ir.Deltap 46 | 47 | print('\n bo: \n') 48 | for i in range(natom): 49 | print('{:10d}'.format(i+1),end=' ') 50 | print() 51 | for i,eb_ in enumerate(eb): 52 | for e in eb_: 53 | print('{:10.6f}'.format(e),end=' ') 54 | print('{:4d}'.format(i+1)) 55 | 56 | bop = ir.bop 57 | 58 | print('\n bop: \n') 59 | for i in range(natom): 60 | print('{:10d}'.format(i+1),end=' ') 61 | print() 62 | 63 | for i,b_ in enumerate(bop): 64 | for b in b_: 65 | print('{:10.6f}'.format(b),end=' ') 66 | print('{:4d}'.format(i+1)) 67 | 68 | print('\n D: \n') 69 | for i,d in enumerate(D): 70 | print('{:4d} {:10.6f}'.format(i+1,d-ir.P['val'][i])) 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /tools/deb/deb_bo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | import argparse 5 | import numpy as np 6 | from ase.io.trajectory import TrajectoryWriter,Trajectory 7 | from irff.AtomDance import AtomDance 8 | from ase.calculators.singlepoint import SinglePointCalculator 9 | from ase.io import read,write 10 | from ase import units,Atoms 11 | from ase.visualize import view 12 | from irff.irff_np import IRFF_NP 13 | # from irff.tools import deb_energy 14 | import matplotlib.pyplot as plt 15 | from irff.deb.deb_bde import deb_bp,deb_bo # ,deb_vdw 16 | # get_ipython().run_line_magic('matplotlib', 'inline') 17 | 18 | 19 | help_ = ''' Plot bond-order and others \n 20 | Usage: ./deb_bo.py --e=HH --rmin=0.9 --rmax=1.6 \n 21 | ./deb_bo.py --t=md.traj --i=0 --j=1 22 | ''' 23 | parser = argparse.ArgumentParser(description=help_) 24 | parser.add_argument('--rmin',default=1.2,type=float,help='the minimus radius') 25 | parser.add_argument('--rmax',default=2.0,type=float,help='the maximus radius') 26 | parser.add_argument('--elements',default='CC',type=str,help='the element pair') 27 | parser.add_argument('--traj',default=None,type=str,help='the trajectory name') 28 | parser.add_argument('--i',default=0,type=int,help='id of atom i') 29 | parser.add_argument('--j',default=1,type=int,help='id of atom j') 30 | parser.add_argument('--d',default=1,type=int,help='show the value of Delta') 31 | parser.add_argument('--s',default=1,type=int,help='show the figure, if False, then save figure to pdf') 32 | args = parser.parse_args(sys.argv[1:]) 33 | 34 | r = args.rmin 35 | if args.traj is None: 36 | images = [] 37 | while r the frame of *.traj contains then 42 | equal the number of frame of *.traj contains 43 | cpu : number of cpu to be parallelly used 44 | ''' 45 | # SinglePointEnergies('swing.traj',label='nm2-s',frame=10,dft='qe',cpu=4) 46 | parser = argparse.ArgumentParser() 47 | argh.add_commands(parser, [md,opt,traj]) 48 | argh.dispatch(parser) 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tools/ffield_to_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | import json as js 4 | from os import environ,system 5 | from ase.io import read 6 | from irff.reaxfflib import read_ffield,write_lib 7 | # from irff.irnnlib_new import write_lib 8 | from irff.qeq import qeq 9 | 10 | 11 | def ffieldtojson(): 12 | p,zpe,spec,bonds,offd,angs,torp,hbs= read_ffield(libfile='ffield') 13 | 14 | fj = open('ffield.json','w') 15 | # j = {'p':p,'m':[],'bo_layer':[],'zpe':[]} 16 | for key in p: 17 | # print(p[key]) 18 | if isinstance(p[key],np.float32): 19 | p[key]= float(p[key]) 20 | j = {'p':p,'m':None, 21 | 'EnergyFunction':0, 22 | 'VdwFunction':0, 23 | 'MessageFunction':0, 24 | 'messages':1, 25 | 'mf_layer':None, 26 | 'be_layer':None, 27 | 'vdw_layer':None, 28 | 'MolEnergy':{} , 29 | 'rcut':None, 30 | 'rEquilibrium':None, 31 | 'rcutBond':None} 32 | js.dump(j,fj,sort_keys=True,indent=2) 33 | fj.close() 34 | 35 | 36 | if __name__ == '__main__': 37 | ffieldtojson() 38 | 39 | -------------------------------------------------------------------------------- /tools/fitmorse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | import sys 4 | import argparse 5 | import matplotlib.pyplot as plt 6 | from ase.io.trajectory import Trajectory 7 | from scipy.optimize import leastsq 8 | 9 | parser = argparse.ArgumentParser(description='fit a morse potential model') 10 | parser.add_argument('--i',default=0,type=int, help='i atom') 11 | parser.add_argument('--j',default=1,type=int, help='j atom') 12 | args = parser.parse_args(sys.argv[1:]) 13 | 14 | def fmorse(x,p=[1.518,1.0,8.0,0.0]): 15 | ro,De,alpha,e0 = p 16 | r_ = x - ro 17 | return De*(np.exp(-2.0*alpha*r_)-2.0*np.exp(-alpha*r_)) + e0 18 | 19 | def residuals(p, y, x): 20 | """ 21 | 计算目标值y和拟合值之间的代价 22 | :param p: 拟合用到的参数 23 | :param y: 样本结果 24 | :param x: 训练样本 25 | :return: 目标值y和拟合值之间的差 26 | """ 27 | return y - fmorse(x, p) 28 | 29 | 30 | images = Trajectory('md.traj') 31 | i = args.i 32 | j = args.j 33 | X = [] 34 | Y = [] 35 | for atoms in images: 36 | positions = atoms.get_positions() 37 | vr = positions[i] - positions[j] 38 | r = np.sqrt(np.sum(vr*vr,axis=0)) 39 | X.append(r) 40 | Y.append(atoms.get_potential_energy()) 41 | X = np.array(X) 42 | Y = np.array(Y) 43 | 44 | e0 = max(Y) 45 | p0 = [1.518,1.0,8.0,e0] 46 | p = leastsq(residuals,p0,args=(Y, X)) 47 | print('The optimal paramter is ro={:f}, De={:f}, alpha={:f}.'.format(p[0][0],p[0][1],p[0][2])) 48 | 49 | 50 | Y_ = fmorse(X,p[0]) 51 | 52 | plt.figure() 53 | plt.plot(X,Y,alpha=0.8,linewidth=2,linestyle='-',color='y',label=r'$Energy$') 54 | plt.plot(X,Y_,alpha=0.8,linewidth=2,linestyle='-',color='r',label=r'$E_{morse}(fitted)$') 55 | 56 | plt.legend(loc='best',edgecolor='yellowgreen') 57 | plt.show() # if show else plt.savefig('deb_bo.pdf') 58 | plt.close() 59 | 60 | -------------------------------------------------------------------------------- /tools/gaussian.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from sklearn.gaussian_process import GaussianProcessRegressor 4 | from sklearn.gaussian_process.kernels import ConstantKernel, RBF 5 | 6 | def f(x): 7 | y = np.exp(-(x - 2)**2) + np.exp(-(x - 6)**2/10) + 1/ (x**2 + 1) 8 | return y 9 | 10 | # X_train = np.array([-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).reshape(-1, 1) 11 | X_train = np.array([-2, 0, 2, 4, 6, 8]).reshape(-1, 1) 12 | y_train = f(X_train) 13 | X_test = np.linspace(-2, 10, 10000).reshape(-1, 1) 14 | 15 | kernel = ConstantKernel(constant_value=1,constant_value_bounds=(1e-5, 1e5)) + \ 16 | RBF(length_scale=1, length_scale_bounds=(1e-5, 1e5)) 17 | # kernel = ConstantKernel(constant_value=1,constant_value_bounds="fixed") * \ 18 | # RBF(length_scale=1, length_scale_bounds="fixed") 19 | gpr = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=9) 20 | gpr.fit(X_train, y_train) 21 | mu, cov = gpr.predict(X_test, return_cov=True) 22 | y_test = mu.ravel() 23 | uncertainty = 1.96 * np.sqrt(np.diag(cov)) # 95%置信区间 24 | 25 | plt.figure() 26 | plt.title("l=%.1f sigma_f=%.1f" % (gpr.kernel_.k2.length_scale, gpr.kernel_.k1.constant_value)) 27 | plt.fill_between(X_test.ravel(), y_test + uncertainty, y_test - uncertainty, alpha=0.1) 28 | plt.plot(X_test, f(X_test), c="y", label="true") 29 | plt.plot(X_test, y_test, label="predict") 30 | plt.scatter(X_train, y_train, label="train", c="red", marker="D") 31 | plt.legend() 32 | 33 | -------------------------------------------------------------------------------- /tools/get_forces.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from ase.calculators.singlepoint import SinglePointCalculator 4 | from ase.io.trajectory import Trajectory,TrajectoryWriter 5 | from irff.md.gulp import get_gulp_forces 6 | from irff.irff_autograd import IRFF 7 | 8 | images = Trajectory('md.traj') 9 | atoms = get_gulp_forces(images) 10 | his = TrajectoryWriter('auto_diff.traj',mode='w') 11 | ir_ = IRFF(atoms=images[0],libfile='ffield.json',nn=True) 12 | 13 | for img in images: 14 | ir_.calculate(atoms=img) 15 | forces = ir_.results['forces'] 16 | img.calc = SinglePointCalculator(atoms, energy=ir_.E,forces=forces) 17 | his.write(atoms=img) 18 | 19 | his.close() 20 | 21 | #images = Trajectory('md.traj') 22 | # atoms = images[0] 23 | # forces = atoms.get_forces() 24 | # print('\n autograde: \n') 25 | # for f in forces: 26 | # print(f) 27 | 28 | # print('\n gulp: \n') 29 | # # images = Trajectory('gulp_force.traj') 30 | # # atoms = images[0] 31 | # forces = atoms.get_forces() 32 | # for f in forces: 33 | # print(f) 34 | -------------------------------------------------------------------------------- /tools/gulp_time.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.md.gulp import opt,nvt 3 | from ase.io import read 4 | from ase.io.trajectory import TrajectoryWriter,Trajectory 5 | 6 | 7 | # atoms = read('md.traj',index=-1) 8 | # his = TrajectoryWriter('opt.traj', mode='w') 9 | fd = open('time_reaxnn.txt','w') 10 | 11 | for i in [8,9,10,12]: # 2,3,4,5,6,7 12 | atoms = read('gpp.gen',index=-1)*(i,i,1) 13 | natom = len(atoms) 14 | nvt(atoms=atoms,T=300,time_step=0.1,tot_step=5000, 15 | keyword='md qiterative conv',movieFrequency=10, 16 | ncpu=8,lib='reaxff_nn') 17 | 18 | with open('gulp.out','r') as f: 19 | for line in f.readlines(): 20 | if line.find('Total CPU time')>=0: 21 | t = float(line.split()[3]) 22 | print('natom: {:d} use time: {:f} '.format(natom,t)) 23 | fd.write('{:d} {:f} \n'.format(natom,t)) 24 | 25 | fd.close() 26 | 27 | -------------------------------------------------------------------------------- /tools/json_to_ffield.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_ffield,write_ffield 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import argh 6 | import argparse 7 | import json as js 8 | from os import environ,system 9 | import csv 10 | import pandas as pd 11 | from os.path import isfile 12 | 13 | 14 | 15 | def jsontoffield(): 16 | lf = open('ffield.json','r') 17 | j = js.load(lf) 18 | p_ = j['p'] 19 | m_ = j['m'] 20 | mf_layer = j['mf_layer'] 21 | be_layer = j['be_layer'] 22 | lf.close() 23 | 24 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 25 | write_ffield(p_,spec,bonds,offd,angs,torp,hbs, 26 | m=m_,mf_layer=mf_layer,be_layer=be_layer, 27 | libfile='ffield') 28 | 29 | 30 | def init_bonds(p_): 31 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 32 | for key in p_: 33 | # key = key.encode('raw_unicode_escape') 34 | # print(key) 35 | k = key.split('_') 36 | if k[0]=='bo1': 37 | bonds.append(k[1]) 38 | elif k[0]=='rosi': 39 | kk = k[1].split('-') 40 | # print(kk) 41 | if len(kk)==2: 42 | if kk[0]!=kk[1]: 43 | offd.append(k[1]) 44 | elif len(kk)==1: 45 | spec.append(k[1]) 46 | elif k[0]=='theta0': 47 | angs.append(k[1]) 48 | elif k[0]=='tor1': 49 | torp.append(k[1]) 50 | elif k[0]=='rohb': 51 | hbs.append(k[1]) 52 | return spec,bonds,offd,angs,torp,hbs 53 | 54 | 55 | if __name__ == '__main__': 56 | jsontoffield() 57 | 58 | -------------------------------------------------------------------------------- /tools/json_to_lib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.reaxfflib import read_ffield,write_lib,write_lib 3 | from irff.qeq import qeq 4 | from ase.io import read 5 | import json as js 6 | from os import environ,system 7 | from os.path import isfile 8 | 9 | 10 | def ffieldtolib(): 11 | lf = open('ffield.json','r') 12 | j = js.load(lf) 13 | p_ = j['p'] 14 | m_ = j['m'] 15 | vdw_layer = j['vdw_layer'] 16 | mf_layer = j['mf_layer'] 17 | be_layer = j['be_layer'] if j['EnergyFunction']!=0 else (0,0) 18 | lf.close() 19 | 20 | spec,bonds,offd,angs,torp,hbs = init_bonds(p_) 21 | write_lib(p_,spec,bonds,offd,angs,torp,hbs,m=m_,mf_layer=mf_layer, 22 | be_layer=be_layer,vdw_layer=vdw_layer, 23 | libfile='reaxff_nn.lib') 24 | 25 | 26 | def init_bonds(p_): 27 | spec,bonds,offd,angs,torp,hbs = [],[],[],[],[],[] 28 | for key in p_: 29 | # key = key.encode('raw_unicode_escape') 30 | # print(key) 31 | k = key.split('_') 32 | if k[0]=='bo1': 33 | bonds.append(k[1]) 34 | elif k[0]=='rosi': 35 | kk = k[1].split('-') 36 | # print(kk) 37 | if len(kk)==2: 38 | if kk[0]!=kk[1]: 39 | offd.append(k[1]) 40 | elif len(kk)==1: 41 | spec.append(k[1]) 42 | elif k[0]=='theta0': 43 | angs.append(k[1]) 44 | elif k[0]=='tor1': 45 | torp.append(k[1]) 46 | elif k[0]=='rohb': 47 | hbs.append(k[1]) 48 | return spec,bonds,offd,angs,torp,hbs 49 | 50 | 51 | if __name__ == '__main__': 52 | ffieldtolib() 53 | 54 | -------------------------------------------------------------------------------- /tools/md/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/md/.keep -------------------------------------------------------------------------------- /tools/md/pack_poscar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import glob 3 | from ase.io import read 4 | from ase.io.trajectory import TrajectoryWriter 5 | from ase.calculators.singlepoint import SinglePointCalculator 6 | from irff.irff_np import IRFF_NP 7 | # from irff.molecule import press_mol 8 | 9 | poscars = glob.glob('*.gen') 10 | traj = TrajectoryWriter('md.traj',mode='w') 11 | 12 | atoms = read(poscars[0]) 13 | ir = IRFF_NP(atoms=atoms,libfile='ffield.json',nn=True) 14 | 15 | for p in poscars: 16 | atoms = read(p) 17 | ir.calculate(atoms) 18 | atoms.calc = SinglePointCalculator(atoms,energy=ir.E) 19 | traj.write(atoms=atoms) 20 | 21 | traj.close() 22 | -------------------------------------------------------------------------------- /tools/md/scale_mol.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | import argparse 5 | import numpy as np 6 | import copy 7 | import json as js 8 | from ase.io import read 9 | from ase.io.trajectory import TrajectoryWriter #,Trajectory 10 | from ase.calculators.singlepoint import SinglePointCalculator 11 | from irff.molecule import Molecules,enlarge # SuperCell,moltoatoms 12 | #from irff.md.lammps import writeLammpsData 13 | from irff.irff_np import IRFF_NP 14 | from irff.molecule import press_mol 15 | 16 | ''' scale the crystal box, while keep the molecule structure unchanged 17 | ''' 18 | 19 | parser = argparse.ArgumentParser(description='eos by scale crystal box') 20 | parser.add_argument('--g', default='md.traj',type=str, help='trajectory file') 21 | parser.add_argument('--i', default=-1,type=int, help='index of trajectory') 22 | args = parser.parse_args(sys.argv[1:]) 23 | 24 | lf = open('ffield.json','r') 25 | j = js.load(lf) 26 | lf.close() 27 | 28 | A = read(args.g,index=args.i) 29 | A = press_mol(A) 30 | x = A.get_positions() 31 | m = np.min(x,axis=0) 32 | x_ = x - m 33 | A.set_positions(x_) 34 | 35 | # print(j['rcutBond']) 36 | 37 | m_ = Molecules(A,rcut={"H-O":1.2,"H-C":1.2,"H-H":0.8,"H-N":1.2, 38 | "O-N":1.45,"O-C":1.45,"O-O":1.4, 39 | "N-C":1.68,"N-N":1.68, 40 | "C-C":1.68, 41 | "others": 1.8},check=True) 42 | nmol = len(m_) 43 | 44 | ir = IRFF_NP(atoms=A, 45 | libfile='ffield.json', 46 | nn=True) 47 | 48 | print('\nnumber of molecules:',nmol) 49 | 50 | ff = [0.94,0.96,0.98,1.0,1.02,1.04,1.06,1.08,1.1] 51 | # ff = [3] 52 | cell = A.get_cell() 53 | 54 | with TrajectoryWriter('md.traj',mode='w') as his: 55 | for f in ff: 56 | m = copy.deepcopy(m_) 57 | _,A = enlarge(m,cell=cell,fac=f,supercell=[1,1,1]) 58 | ir.calculate(A) 59 | A.calc = SinglePointCalculator(A,energy=ir.E) 60 | his.write(atoms=A) 61 | -------------------------------------------------------------------------------- /tools/merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argh 3 | import argparse 4 | import sys 5 | from os import getcwd,listdir # system, chdir, 6 | from os.path import isfile,exists,isdir 7 | from ase import Atoms 8 | from ase.io.trajectory import TrajectoryWriter,Trajectory 9 | 10 | 11 | def merge(t1='O7H20C2.traj',t2='O7H20C2opt.traj'): 12 | his = TrajectoryWriter('merged.traj',mode='w') 13 | trajs=[t1,t2] 14 | for traj in trajs: 15 | images = Trajectory(traj) 16 | for atoms in images: 17 | his.write(atoms=atoms) 18 | his.close() 19 | 20 | 21 | if __name__ == '__main__': 22 | ''' 23 | Usage: ./merge.py --t1=md.traj --t2=out.traj 24 | ''' 25 | parser = argparse.ArgumentParser(description='merg the molecular dynamics trajectory') 26 | parser.add_argument('--t1',default='md1.traj',type=str, help='trajectory 1 file name') 27 | parser.add_argument('--t2',default='md2.traj',type=str, help='trajectory 2 file name') 28 | args = parser.parse_args(sys.argv[1:]) 29 | merge(t1=args.t1,t2=args.t2) 30 | 31 | -------------------------------------------------------------------------------- /tools/ml/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/ml/.keep -------------------------------------------------------------------------------- /tools/ml/invariance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import json as js 3 | import numpy as np 4 | from scipy.optimize import leastsq # minimize # minimize_scalar 5 | from irff.data.ColData import ColData 6 | from irff.ml.fit import train 7 | from irff.ml.data import get_data,get_md_data_invariance # ,get_bond_data 8 | from sklearn.gaussian_process import GaussianProcessRegressor 9 | from sklearn.ensemble import RandomForestRegressor 10 | from sklearn.gaussian_process.kernels import RBF 11 | from train import dataset 12 | 13 | 14 | bonds = ['C-H','C-C','H-H'] 15 | D,Bp,B,R,E = get_data(dataset=dataset,bonds=bonds,ffield='ffieldData.json') 16 | 17 | 18 | trajs = ['md.traj'] 19 | for traj in trajs: 20 | D_md,Bp_md,B_md,R_md,E_md = get_md_data_invariance(traj=traj, 21 | bonds=bonds, 22 | ffield='ffieldData.json') 23 | # D1,Bp1,B1,R1,E1 = get_bond_data(5,19, traj='md.traj', 24 | # bonds=bonds, 25 | # ffield='ffieldData.json') 26 | for bd in bonds: 27 | if bd not in D: 28 | continue 29 | if bd not in D_md: 30 | continue 31 | 32 | D[bd].extend(D_md[bd]) 33 | B[bd].extend(B_md[bd]) 34 | Bp[bd].extend(Bp_md[bd]) 35 | 36 | train(Bp,D,B,E,bonds=bonds,step=10000,fitobj='BO',learning_rate=0.0001) 37 | 38 | -------------------------------------------------------------------------------- /tools/moment.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | # import argh 5 | import argparse 6 | from ase.visualize import view 7 | from ase.io import read 8 | from ase.io.trajectory import TrajectoryWriter,Trajectory 9 | from irff.irff import IRFF 10 | from irff.AtomDance import AtomDance 11 | from irff.md.irmd import IRMD 12 | 13 | 14 | parser = argparse.ArgumentParser(description='Create a momentum between a pair atoms') 15 | parser.add_argument('--g',default='poscar.gen',type=str, help='geomentry file') 16 | parser.add_argument('--i',default=0,type=int, help='i atom') 17 | parser.add_argument('--j',default=1,type=int, help='j atom') 18 | parser.add_argument('--d',default=1,type=int, help='direction') 19 | parser.add_argument('--s',default=100,type=int, help='md step') 20 | parser.add_argument('--T',default=2000,type=float, help='moment temperature') 21 | parser.add_argument('--b',default=0.96,type=float,help='the relax parameter') 22 | parser.add_argument('--f',default=[],type=list,help='free atoms') 23 | args = parser.parse_args(sys.argv[1:]) 24 | 25 | atoms = read(args.g,index=-1) 26 | ad = AtomDance(atoms=atoms) 27 | # pairs = [[1,2],[13,7],[5,26]] 28 | # images = ad.stretch([3,2],nbin=30,st=0.85,ed=1.25,scale=1.2,traj='md.traj') 29 | ad.set_bond_momenta(args.i,args.j,atoms,sign=args.d) 30 | ad.close() 31 | 32 | f_= args.f if args.f else None 33 | 34 | irmd = IRMD(atoms=atoms,time_step=0.1,totstep=args.s,Tmax=10000, 35 | freeatoms=f_,beta=args.b, 36 | ro=0.75,initT=args.T) 37 | irmd.run() 38 | mdsteps= irmd.step 39 | Emd = irmd.Epot 40 | irmd.close() 41 | 42 | ''' run commond: ./moment.py --i=0 --j=1 --g=poscar.gen --T=2000 ''' 43 | -------------------------------------------------------------------------------- /tools/notebooks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/notebooks/.keep -------------------------------------------------------------------------------- /tools/out_to_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | # import argh 4 | import argparse 5 | from os import getcwd,listdir 6 | from irff.dft.siesta import parse_out 7 | from ase.io.trajectory import TrajectoryWriter 8 | 9 | def siesta_out_to_traj(traj): 10 | traj = TrajectoryWriter(traj,mode='w') 11 | current_dir = getcwd() 12 | outs = listdir(current_dir) 13 | 14 | for o_ in outs: 15 | if o_.endswith('.out'): 16 | atoms = parse_out(outfile=o_) 17 | traj.write(atoms=atoms) 18 | 19 | traj.close() 20 | 21 | 22 | help_ = 'run with commond: ./out_to_traj.py --t=md.traj' 23 | parser = argparse.ArgumentParser(description=help_) 24 | parser.add_argument('--t',default='md.traj',type=str, help='Trajectory file name') 25 | args = parser.parse_args(sys.argv[1:]) 26 | 27 | if __name__=='__main__': 28 | siesta_out_to_traj(args.t) 29 | 30 | -------------------------------------------------------------------------------- /tools/pes/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/pes/.keep -------------------------------------------------------------------------------- /tools/pes/zmat_stretch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argh 3 | import argparse 4 | import matplotlib.pyplot as plt 5 | import matplotlib.mlab as mlab 6 | from mpl_toolkits.mplot3d import Axes3D 7 | import numpy as np 8 | import pickle 9 | from ase.visualize import view 10 | from ase.io import read 11 | from ase.io.trajectory import TrajectoryWriter,Trajectory 12 | from ase.calculators.singlepoint import SinglePointCalculator 13 | from irff.AtomDance import AtomDance 14 | from irff.zmatrix import zmat_to_atoms 15 | 16 | # get_ipython().run_line_magic('matplotlib', 'inline') 17 | 18 | # zmat = [ 19 | # [ 'O', 0, -1, -1, -1, 0.0000, 0.0000, 0.0000 ], 20 | # [ 'C', 1, 0, -1, -1, 1.5336, 0.0000, 0.0000 ], 21 | # [ 'O', 2, 1, 0, -1, 1.5138, 180.0, 0.0000 ] ] 22 | # atoms = zmat_to_atoms(zmat) 23 | 24 | # view(atoms) 25 | 26 | # with open('zmat.pkl','w') as f: 27 | # pickle.dump(zmat,f) 28 | # data = pickle.load(f) 29 | 30 | def wz(gen='cbd.gen',i=-1): 31 | atoms = read(gen,index=i) 32 | ad = AtomDance(atoms=atoms,rmax=1.25) 33 | zmat = ad.InitZmat 34 | ad.write_zmat(zmat) 35 | ad.close() 36 | 37 | 38 | def pes(gen='cbd.gen',i=-1): 39 | atoms = read(gen,index=i) 40 | ad = AtomDance(atoms=atoms,rmax=1.25) 41 | zmat = ad.InitZmat 42 | traj = TrajectoryWriter('md.traj',mode='w') 43 | # view(atoms) 44 | r = 1.47 45 | for i_ in range(23): 46 | zmat[46][0] = r+0.01*i_ 47 | atoms = ad.zmat_to_cartation(atoms,zmat) 48 | ad.ir.calculate(atoms) 49 | 50 | atoms.calc = SinglePointCalculator(atoms,energy=ad.ir.E) 51 | traj.write(atoms=atoms) 52 | 53 | 54 | if __name__ == '__main__': 55 | ''' use commond like ./zmat_pes.py w --T=2800 to run it''' 56 | parser = argparse.ArgumentParser() 57 | argh.add_commands(parser, [wz,pes]) 58 | argh.dispatch(parser) 59 | -------------------------------------------------------------------------------- /tools/phonon_force.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from os import system 4 | import sys 5 | import argparse 6 | import numpy as np 7 | from ase.io import read # ,write 8 | from ase.visualize import view 9 | from irff.md.gulp import get_gulp_forces 10 | from irff.md.lammps import get_lammps_forces 11 | from irff.dft.siesta import parse_fdf,parse_fdf_species,write_siesta_in 12 | from irff.irff import IRFF 13 | 14 | 15 | parser = argparse.ArgumentParser(description='stretch molecules') 16 | parser.add_argument('--n',default=1,type=int, help='displacement number') 17 | parser.add_argument('--f',default='in.fdf',type=str, help='fdf file name') 18 | parser.add_argument('--g',default='POSCAR',type=str, help='geomentry file name') 19 | parser.add_argument('--c',default='gulp',type=str, help='calculator name') 20 | args = parser.parse_args(sys.argv[1:]) 21 | 22 | # system('cp geo.genS-00{:d} geo-s{:d}.gen'.format(args.n,args.n)) 23 | # atoms = read(args.g) 24 | # write_siesta_in(atoms, coord='cart',md=False, opt='CG', 25 | # VariableCell='true', xcf='VDW', xca='DRSLL', 26 | # basistype='DZP') 27 | 28 | spec = parse_fdf_species(fdf='in.fdf') 29 | atoms = parse_fdf('supercell-00{:d}'.format(args.n),spec=spec) 30 | #view(atoms) 31 | 32 | if args.c=='gulp': 33 | atoms = get_gulp_forces([atoms]) 34 | elif args.c=='gap': 35 | atoms = get_lammps_forces(atoms,pair_style='quip', 36 | pair_coeff='* * Carbon_GAP_20_potential/Carbon_GAP_20.xml "" 6', 37 | units='metal',atom_style='atomic') 38 | else: 39 | atoms = get_lammps_forces(atoms) 40 | forces = atoms.get_forces() 41 | 42 | with open('Forces.FA', 'w') as ff: 43 | print(len(atoms), file=ff) 44 | for i, f in enumerate(forces): 45 | print('{:4d} {:12.8f} {:12.8f} {:12.8f}'.format( 46 | i+1, f[0], f[1], f[2]), file=ff) 47 | 48 | system('mv Forces.FA Forces-00{:d}.FA'.format(args.n)) 49 | 50 | -------------------------------------------------------------------------------- /tools/phonopy/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/phonopy/.keep -------------------------------------------------------------------------------- /tools/phonopy/af_flow_scale.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import system, listdir #,popen 3 | from os import getcwd,chdir 4 | from os.path import isfile 5 | import numpy as np 6 | from ase.io import read # ,write 7 | from irff.md.gulp import opt,phonon 8 | from irff.molecule import press_mol 9 | 10 | '''phonon compute work flow''' 11 | 12 | # 0、 拷贝参数文件 13 | # system('cp ../../ffield.json ffield.json') 14 | # system('./json_to_lib.py') 15 | 16 | def get_kappa(f): 17 | ''' ''' 18 | with open(f) as f: 19 | for line in f: 20 | if 'Allen-Feldman' in line: 21 | return float(line.split()[4]) 22 | 23 | ncpu = 8 24 | opt(gen='POSCAR.unitcell',step=500,l=1,t=0.0000001,n=ncpu, x=1,y=1,z=8) 25 | # system('cp POSCAR.unitcell POSCAR.uc') 26 | atoms = read('POSCAR.unitcell') 27 | atoms = press_mol(atoms) 28 | cell = atoms.get_cell() 29 | cell_ = cell.copy() 30 | atoms.write('POSCAR') 31 | # x = atoms.get_positions() 32 | # m = np.min(x,axis=0) 33 | # x_ = x - m 34 | # atoms.set_positions(x_) 35 | 36 | for i in [1.0,1.05,1.1,1.15,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0]: 37 | # i = 18 38 | # 1、 优化结构 39 | # 2 、使用GULP计算二阶力常数 40 | cell_[0] = cell[0]*i 41 | cell_[1] = cell[1]*i 42 | 43 | atoms.set_cell(cell_) 44 | atoms.write('POSCAR.{:f}'.format(i)) 45 | 46 | opt(gen='POSCAR',step=100,l=0,t=0.0000001,n=ncpu, x=1,y=1,z=8) 47 | phonon(gen='POSCAR.unitcell',T=300,step=300,t=0.0000001,n=ncpu, x=1,y=1,z=22) 48 | system('cp phonon.out phonon_{:f}.out'.format(i)) 49 | 50 | k = get_kappa('phonon.out') 51 | with open('af_cnt.txt','a') as f: 52 | print(i,k,file=f) 53 | 54 | 55 | -------------------------------------------------------------------------------- /tools/phonopy/generate_displacements.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """A script to generate supercells with displacements for LAMMPS.""" 3 | import numpy as np 4 | from ase.io import read 5 | import phonopy 6 | from phonopy.interface.calculator import write_supercells_with_displacements 7 | from phonopy.interface.phonopy_yaml import read_cell_yaml 8 | 9 | 10 | atoms = read('POSCAR.unitcell') 11 | # atoms.write('poscar.yaml') 12 | 13 | cell = atoms.get_cell() 14 | cell = cell[:].astype(dtype=np.float32) 15 | rcell = np.linalg.inv(cell).astype(dtype=np.float32) 16 | positions = atoms.get_positions() 17 | xf = np.dot(positions,rcell) 18 | xf = np.mod(xf,1.0) 19 | fy = 'unitcell.yaml' 20 | 21 | with open(fy,'w') as f: 22 | print('unit_cell:',file=f) 23 | print(' lattice:',file=f) 24 | print(' - [{:f},{:f},{:f}] '.format(cell[0][0],cell[0][1],cell[0][2],),file=f) 25 | print(' - [{:f},{:f},{:f}] '.format(cell[1][0],cell[1][1],cell[1][2],),file=f) 26 | print(' - [{:f},{:f},{:f}] '.format(cell[2][0],cell[2][1],cell[2][2],),file=f) 27 | print(' points:',file=f) 28 | symbols = atoms.get_chemical_symbols() 29 | for i,x in enumerate(xf): 30 | print(' - symbol: {:s}'.format(symbols[i]),file=f) 31 | print(' coordinates: [{:f},{:f},{:f}] '.format(x[0],x[1],x[2]),file=f) 32 | 33 | cell = read_cell_yaml("unitcell.yaml") 34 | ph = phonopy.load( 35 | unitcell=cell, 36 | primitive_matrix="auto", 37 | supercell_matrix=[8, 8, 1], 38 | calculator="lammps", 39 | ) 40 | ph.generate_displacements() 41 | ph.save("phonopy_disp.yaml") 42 | write_supercells_with_displacements( 43 | "lammps", ph.supercell, ph.supercells_with_displacements 44 | ) 45 | -------------------------------------------------------------------------------- /tools/phonopy/ph_flow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import system, listdir #,popen 3 | 4 | '''phonon compute work flow''' 5 | 6 | # 1、 优化结构 7 | system('./gmd.py opt --s=1000 --g=POSCAR.unitcell --n=4 --x=8 --y=8 --l=1') 8 | system('./gmd.py opt --s=1 --g=POSCAR.unitcell --n=4 --output=shengbte') 9 | 10 | # 2 、先将结构文件转换为siesta输入文件 11 | system('./smd.py wi --g=POSCAR.unitcell') 12 | 13 | # 3 、生成位移文件 14 | system('rm supercell-00*.fdf') 15 | system('phonopy --siesta -c=in.fdf -d --dim="8 8 1" --amplitude=0.02') 16 | 17 | n = 0 18 | files = listdir() 19 | for f in files: 20 | if f.startswith('supercell-') and f.endswith('.fdf'): 21 | n += 1 22 | 23 | for i in range(n): 24 | system('./phonon_force.py --n={:d}'.format(i+1)) 25 | # system('cp force.0 lammps_forces_gp.0') 26 | 27 | fs = ['Forces-00{:d}.FA'.format(i) for i in range(1,n+1)] 28 | fs = ' '.join(fs) 29 | 30 | system('phonopy -f {:s} --siesta'.format(fs)) 31 | system('phonopy --siesta -c in.fdf -p --dim="8 8 1" --band="0.0 0.0 0.0 1/4 0.0 0.0 0.5 0.0 0.0 2/3 -1/3 1/2 1/3 -1/6 0.0 0.0 0.0 0.0"') 32 | 33 | system('phonopy-bandplot --gnuplot band.yaml > band.dat') 34 | 35 | system('mv band.dat band-nn-gulp.dat') 36 | system('./plotband.py') 37 | 38 | # 使用Phonopy计算二阶力常数 39 | system('phonopy --writefc --full-fc') 40 | 41 | # 此时计算的二阶力常数的长度单位是Unit of length: au 转换成 AA 42 | system('./force_unit.py') 43 | 44 | # 计算三阶力常数 45 | # system('./thirdorder_gulp.py sow 8 8 1 1 ') # (最后一个1:指1nm,即截断半径10埃) 46 | # system('./thirdorder_gulp.py reap 8 8 1 1 ') 47 | -------------------------------------------------------------------------------- /tools/plot/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/plot/.keep -------------------------------------------------------------------------------- /tools/plot/plot_convergence_af.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import random 4 | #import matplotlib as mpl 5 | import matplotlib.pyplot as plt 6 | import numpy as np 7 | 8 | # data = np.loadtxt('kappa_vs_qgrid_gp.txt') 9 | data = np.loadtxt('af.txt') 10 | 11 | x = data[:,0] 12 | y = data[:,1]*10/3.35 # (3.609*0.53) 13 | 14 | print('x\n',x) 15 | print('y\n',y) 16 | 17 | plt.figure(figsize=(8,6)) 18 | 19 | ax = plt.subplot() 20 | 21 | ax.set_ylabel(r"$\kappa$", weight="medium",fontdict={"fontsize":18}) 22 | ax.set_xticks([8, 10, 12, 14,16,18,20,22,24,26,28]) 23 | ax.set_xticklabels([r"$8 \times 8$", r"$10 \times 10 $", 24 | r"$12 \times 12 $", r"$14 \times 14 $", 25 | r"$16 \times 16 $", r"$18 \times 18 $", 26 | r"$20 \times 20 $", r"$22 \times 22 $", 27 | r"$24 \times 24 $", r"$26 \times 26 $", 28 | r"$28 \times 28 $"],rotation=45) 29 | 30 | plt.xticks(fontsize=10) 31 | 32 | plt.plot(x,y,alpha=0.8, 33 | linestyle='-',marker='s',markerfacecolor='none', 34 | markeredgewidth=1,markeredgecolor='r',markersize=10, 35 | color='r',label=r'$\kappa$ ($Graphene$)') 36 | plt.legend(loc='best',edgecolor='yellowgreen',fontsize=16) 37 | plt.savefig('convergence.pdf') 38 | plt.show() 39 | 40 | -------------------------------------------------------------------------------- /tools/plot/plot_msd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argparse 3 | import sys 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | help_ = 'run commond with: ./plot_msd.py --f=msd.data' 8 | 9 | parser = argparse.ArgumentParser(description=help_) 10 | parser.add_argument('--f',default='msd.data',type=str, help='force field file name') 11 | args = parser.parse_args(sys.argv[1:]) 12 | 13 | data = np.loadtxt(args.f) 14 | 15 | t = data[:,0]*0.00001 16 | msd_x = data[:,1] 17 | msd_y = data[:,2] 18 | msd_z = data[:,3] 19 | msd = data[:,4] 20 | 21 | print('the average msd: ',np.mean(msd)) 22 | 23 | plt.figure() 24 | plt.plot(t,msd_x,alpha=0.8,linewidth=1,linestyle='-',color='k', 25 | marker='v', markeredgecolor='b', markeredgewidth=1,markersize=5,markerfacecolor='none', 26 | label=r'$msd@X$') 27 | plt.plot(t,msd_y,alpha=0.8,linewidth=1,linestyle='-',color='k', 28 | marker='>', markeredgecolor='g', markeredgewidth=1,markersize=5,markerfacecolor='none', 29 | label=r'$msd@Y$') 30 | plt.plot(t,msd_z,alpha=0.8,linewidth=1,linestyle='-',color='k', 31 | marker='<', markeredgecolor='y', markeredgewidth=1,markersize=5,markerfacecolor='none', 32 | label=r'$msd@Z$') 33 | plt.plot(t,msd,alpha=0.8,linewidth=2,linestyle='-',color='r', 34 | marker='o', markeredgecolor='r', markeredgewidth=1,markersize=5,markerfacecolor='none', 35 | label=r'$msd@Average$') 36 | plt.legend(loc='best',edgecolor='yellowgreen') 37 | plt.savefig('msd.pdf') 38 | # plt.show() 39 | plt.close() 40 | 41 | -------------------------------------------------------------------------------- /tools/plot/plot_result.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import matplotlib.pyplot as plt 3 | from matplotlib import cm 4 | import numpy as np 5 | # import csv 6 | import pandas as pd 7 | 8 | d = pd.read_csv('Results.csv') 9 | Y = d['Edft'] 10 | Yp = d['Epred'] 11 | 12 | c = np.abs(Y-Yp) 13 | # c_max = np.max(c) 14 | # c = c_max -c # 1.0 - c/(c_max*2.0) 15 | # print(c) 16 | 17 | cmap = plt.get_cmap("Reds") # cm.coolwarm # 18 | 19 | plt.figure() 20 | plt.xlabel('E(DFT)',fontsize=14) 21 | plt.ylabel('E(ReaxFF-nn)',fontsize=14) 22 | cb = plt.scatter(Y, Yp, 23 | marker='o', edgecolor='r', s=25, 24 | color='none',# cmap=cmap, c=c, # zorder=-10, 25 | alpha=0.6, label=r'$E(DFT)$ $V.S.$ $E(ReaxFF-nn)$') 26 | #plt.colorbar(cb) 27 | 28 | # loc = lower left upper right best 29 | plt.legend(loc='best', edgecolor='yellowgreen') 30 | plt.savefig('Result.svg', transparent=True) 31 | plt.close() 32 | -------------------------------------------------------------------------------- /tools/plot/plot_thermal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argparse 3 | import sys 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | def plot_thermal(): 8 | plt.figure() 9 | plt.ylabel(r'$Energy$ ($eV$)') 10 | plt.xlabel(r'$Step$') 11 | 12 | vs = ['2.5','2.8','3.0'] 13 | cs = ['r','b','g'] 14 | 15 | for i,v in enumerate(vs): 16 | fil = 'thermo-{:s}.log'.format(v) 17 | data = np.loadtxt(fil) 18 | steps = data[:,0] 19 | e = data[:,2] 20 | 21 | # plt.scatter(ph[i],vh[i],marker = 'o', color = cmap.to_rgba(t), s=50, alpha=0.4) 22 | plt.plot(steps,e,label=r'$v={:5.2f}$'.format(float(v)), color=cs[i], linewidth=1.5, 23 | linestyle='-') 24 | 25 | plt.legend() 26 | plt.savefig('energy.pdf') 27 | plt.close() 28 | 29 | 30 | 31 | if __name__=='__main__': 32 | plot_thermal() 33 | 34 | -------------------------------------------------------------------------------- /tools/plot/plot_time.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import getcwd, chdir,listdir 3 | from os.path import isfile,isdir 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | 7 | 8 | data = np.loadtxt('md_time1.txt') 9 | natom = data[:,0] # supercell size 10 | t_gulp_nn = data[:,1] 11 | t_gulp = data[:,2] 12 | t_lammps = data[:,3] 13 | t_lammps_nn = data[:,4] 14 | 15 | plt.figure() 16 | 17 | plt.ylabel(r'$Running$ $time$ $of$ $a$ $single$ $MD$ $step$ $Unit:(s)$') 18 | plt.yticks([0.00000000],labels=[' ']) 19 | 20 | plt.xticks([]) 21 | 22 | plt.subplot(2,1,1) 23 | 24 | # plt.title(r'$Running$ $time$ $of$ $a$ $single$ $MD$ $step$ $Unit:(s)$') 25 | 26 | 27 | plt.plot(natom,t_gulp,alpha=0.9, 28 | linestyle='-',marker='^',markerfacecolor='none', 29 | markeredgewidth=1,markeredgecolor='r',markersize=7, 30 | color='r',label=r'$ReaxFF(GULP)$' ) 31 | plt.plot(natom,t_gulp_nn,alpha=0.9, 32 | linestyle='-',marker='s',markerfacecolor='none', 33 | markeredgewidth=1,markeredgecolor='b',markersize=7, 34 | color='b',label=r'$ReaxFF-nn(GULP)$' ) 35 | plt.legend(loc='best',edgecolor='yellowgreen') # lower left upper right 36 | 37 | plt.subplot(2,1,2) 38 | 39 | plt.xlabel(r'$Number$ $of$ $Atoms$') 40 | plt.plot(natom,t_lammps,alpha=0.9, 41 | linestyle='-',marker='^',markerfacecolor='none', 42 | markeredgewidth=1,markeredgecolor='r',markersize=7, 43 | color='r',label=r'$ReaxFF(LAMMPS)$' ) 44 | plt.plot(natom,t_lammps_nn,alpha=0.9, 45 | linestyle='-',marker='s',markerfacecolor='none', 46 | markeredgewidth=1,markeredgecolor='b',markersize=7, 47 | color='b',label=r'$ReaxFF-nn(LAMMPS)$' ) 48 | 49 | plt.legend(loc='best',edgecolor='yellowgreen') # lower left upper right 50 | 51 | 52 | 53 | plt.savefig('md_time.pdf',transparent=True) 54 | plt.close() 55 | 56 | -------------------------------------------------------------------------------- /tools/pm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.molecule import packmol 3 | 4 | 5 | 6 | 7 | packmol(strucs=['h2o','h2o','h2o','h2o','h2o','h2o','h2o','h2o','h2o', 8 | 'ch4','h2o','ch4','ethane','ethane'], 9 | supercell=[3,3,2], 10 | w=True) 11 | 12 | -------------------------------------------------------------------------------- /tools/prior_bo_fit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argh 3 | import argparse 4 | import tensorflow as tf 5 | import numpy as np 6 | from irff.data.ColData import ColData 7 | from irff.ml.data import get_data,get_bond_data 8 | from train import dataset 9 | from irff.ml.fit import train 10 | 11 | tf.compat.v1.disable_eager_execution() 12 | 13 | 14 | def fit(step=1000,obj='BO',pairs=[(0,1)],trajs=['md.traj'],bd=None,dataset={}): 15 | unit = 4.3364432032e-2 16 | Desi = 424.95 17 | 18 | bonds = ['C-C','C-H','C-N','H-O','C-O','H-H','H-N','N-N','O-N','O-O'] 19 | D,Bp,B,R,E = get_data(dataset=dataset,bonds=bonds,ffield='ffield.json') 20 | 21 | 22 | for pair,traj in zip(pairs,trajs): 23 | i,j = pair 24 | D_, Bp_, B_, R_, E_ = get_bond_data(i,j,traj=traj) 25 | for d,bp,b in zip(D_,Bp_,B_): 26 | D[bd].append(d) 27 | Bp[bd].append(bp) 28 | B[bd].append([0.0,0.0,0.0]) 29 | 30 | train(Bp,D,B,E,bonds=bonds,step=step,fitobj=obj) 31 | 32 | if __name__ == '__main__': 33 | # parser = argparse.ArgumentParser() 34 | # argh.add_commands(parser, [fit]) 35 | # argh.dispatch(parser) 36 | fit(pairs=[(0,10)],step=2000,obj='BO',dataset=dataset,trajs=['md.traj'],bd='C-C') 37 | -------------------------------------------------------------------------------- /tools/qeout_to_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from ase.io.trajectory import TrajectoryWriter,Trajectory 4 | from ase.visualize import view 5 | from ase.units import create_units 6 | from ase.dft.kpoints import kpoint_convert 7 | from ase.calculators.singlepoint import SinglePointDFTCalculator,SinglePointKPoint 8 | from ase.atoms import Atoms 9 | from irff.dft.qe import read_espresso_out 10 | import numpy as np 11 | import os 12 | 13 | 14 | ###获取所有out文件的文件名########################################## 15 | def getSuffixFileName(path,suffix): 16 | # 获取指定目录下的所有指定后缀的文件名 17 | SuffixFileName=[] 18 | f_list = os.listdir(path)#返回文件名 19 | for i in f_list: 20 | # os.path.splitext():分离文件名与扩展名 21 | if os.path.splitext(i)[1] ==suffix: 22 | SuffixFileName.append(i) 23 | #print(i) 24 | return SuffixFileName 25 | 26 | path=os.getcwd() 27 | suffix='.out' 28 | 29 | SuffixFileName=getSuffixFileName(path,suffix) 30 | print(SuffixFileName) 31 | 32 | ###定义格式转换函数############################################### 33 | def trans_Qeout_to_traj(filename): 34 | file_title=filename.split('.') 35 | output_filename=file_title[0]+'.traj' 36 | 37 | his = TrajectoryWriter(output_filename,mode='w') 38 | images = read_espresso_out(filename) 39 | #images_ = [] 40 | for image in images: 41 | his.write(atoms=image) 42 | #images_.append(image) 43 | 44 | his.close() 45 | #view(images_) 46 | 47 | ####同时对所有out文件进行格式转换####################################### 48 | for FileName in SuffixFileName: 49 | trans_Qeout_to_traj(FileName) 50 | -------------------------------------------------------------------------------- /tools/rmsave.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from os import system,listdir,getcwd,chdir 4 | from os.path import isdir,isfile 5 | 6 | 7 | root_dir = getcwd() 8 | # outs = listdir(root_dir) 9 | 10 | def rm_save(direc=None): 11 | direc_ = direc + '/' 12 | # chdir(direc) 13 | # print('Now in direc: ',getcwd()) 14 | if isdir('pwscf.save'): 15 | system('rm -r pwscf.save') 16 | print('Find pwscf.save in dir {:s}'.format(direc)) 17 | 18 | # cdir = getcwd() 19 | outs = listdir(direc_) 20 | # print(outs) 21 | for d in outs: 22 | d_ = direc+'/'+d 23 | if isdir(d_): 24 | rm_save(direc=d_) 25 | elif isfile(d_): 26 | if d_.startswith('pwscf.'): 27 | system('rm {:s}'.format(d_)) 28 | chdir(direc_) 29 | # return direc_ 30 | 31 | rm_save(direc=root_dir) 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tools/rotate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance 7 | import sys 8 | import argh 9 | import argparse 10 | 11 | 12 | parser = argparse.ArgumentParser(description='stretch molecules') 13 | parser.add_argument('--g',default='poscar.gen',type=str, help='atomic configuration') 14 | parser.add_argument('--i',default=0,type=int, help='atoms i of the angle') 15 | parser.add_argument('--j',default=1,type=int, help='atoms j of the angle') 16 | #parser.add_argument('--o',default=2,type=int, help='atoms k of the angle') 17 | parser.add_argument('--f',default=-1,type=int, help='number of trajectory frame') 18 | parser.add_argument('--d',default=90.0,type=float, help='angle rotate degree') 19 | 20 | args = parser.parse_args(sys.argv[1:]) 21 | atoms = read(args.g,index=args.f) 22 | ad = AtomDance(atoms) 23 | images = ad.rotate(axis=[args.i,args.j],o=args.j,rang=args.d,nbin=50,traj='md.traj') 24 | ad.close() 25 | # view(atoms) 26 | 27 | 28 | ''' 29 | run this script using commond: 30 | ./rotate.py --g=nm.gen --i=0 --j=1 --d=30.0 31 | ''' 32 | 33 | -------------------------------------------------------------------------------- /tools/rotator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | from ase.io import read 4 | from irff.molecule import press_mol 5 | 6 | ''' 7 | rotae matrix 8 | cos_x -sin_x 9 | sin_x cos_x 10 | ''' 11 | 12 | 13 | A = read('md.traj',index=-1) 14 | A = press_mol(A) 15 | x = A.get_positions() 16 | m = np.min(x,axis=0) 17 | x_ = x - m 18 | 19 | natom = len(A) 20 | 21 | rotater = np.array([[[1.0,0.0,0.0], 22 | [ 0.0,0.0,-1.0], 23 | [ 0.0,1.0,0.0] ]]) 24 | 25 | x_ = np.matmul(x_.reshape([natom,1,3]),rotater) 26 | print(x_.shape) 27 | 28 | cell = A.get_cell() 29 | cell_ = np.matmul(cell.reshape([3,1,3]),rotater) 30 | 31 | A.set_positions(x_.reshape([natom,3])) 32 | A.set_cell(cell_.reshape([3,3])) 33 | A.write('POSCAR') 34 | -------------------------------------------------------------------------------- /tools/sample_traj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from ase import Atoms 3 | from ase.io.trajectory import TrajectoryWriter,Trajectory 4 | from os import getcwd,listdir,system #, chdir, 5 | from os.path import isfile,exists,isdir 6 | import argh 7 | import argparse 8 | import sys 9 | 10 | def collect(traj='md.traj',start=0,end=36,o=None,frames='',interval=1): 11 | if o is None: 12 | newt= traj.replace('.traj','_.traj') 13 | else: 14 | newt = o 15 | # system('cp '+traj +' ' + traj_) 16 | images = Trajectory(traj) 17 | if end > len(images): 18 | end = len(images) 19 | his = TrajectoryWriter(newt,mode='w') 20 | if frames: 21 | frames = [int(i) for i in frames.split()] 22 | for i in frames: 23 | his.write(atoms=images[i]) 24 | else: 25 | for i in range(start,end): 26 | if i%interval==0: 27 | his.write(atoms=images[i]) 28 | his.close() 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | ''' 34 | select frames in all trajectoies 35 | ''' 36 | help_ = 'Run with commond: ./coltraj.py --t=md.traj --s=0 --e=50 --o=out.traj' 37 | parser = argparse.ArgumentParser(description=help_) 38 | parser.add_argument('--start',default=0,type=int, help='the start frame') 39 | parser.add_argument('--end',default=1000,type=int, help='the end frame') 40 | parser.add_argument('--i',default=1,type=int, help='collect interval') 41 | parser.add_argument('--f',default='',type=str, help='frames to collect') 42 | parser.add_argument('--traj',default='md.traj',type=str, help='trajectory file name') 43 | parser.add_argument('--o',default='output.traj',type=str, help='output trajectory file name') 44 | args = parser.parse_args(sys.argv[1:]) 45 | 46 | collect(traj=args.traj,start=args.start,end=args.end,o=args.o, 47 | frames=args.f, 48 | interval=args.i) 49 | 50 | -------------------------------------------------------------------------------- /tools/select_element.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.tools.prepare_ffield import select_elements 3 | 4 | if __name__ == "__main__": 5 | # app.run(select_elements) 6 | select_elements(['Fe','O','H']) 7 | -------------------------------------------------------------------------------- /tools/single_point.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from irff.dft.SinglePointEnergy import SinglePointEnergies 4 | from ase.io import read 5 | 6 | 7 | if __name__ == '__main__': 8 | '''' 9 | *.traj: contains the structure to be calculated by DFT 10 | label : the trajectory name include the energies and sturcutres calculated by DFT 11 | frame : number of frames to be collected to calculate the energy, if frame> the frame of *.traj contains then 12 | equal the number of frame of *.traj contains 13 | cpu : number of cpu to be parallelly used 14 | ''' 15 | SinglePointEnergies('swing.traj',label='nm2-s',frame=10,dft='qe',cpu=4) 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /tools/sort_atoms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import argparse 3 | from ase.io import read # ,write 4 | #from ase.io.trajectory import Trajectory 5 | from ase import Atoms 6 | #import matplotlib.pyplot as plt 7 | import numpy as np 8 | from irff.irff_np import IRFF_NP 9 | from irff.molecule import press_mol 10 | import sys 11 | import argparse 12 | 13 | 14 | if __name__ == '__main__': 15 | ''' use commond like ./tplot.py to run it''' 16 | 17 | parser = argparse.ArgumentParser(description='stretch molecules') 18 | parser.add_argument('--g', default='gulp.traj',type=str, help='trajectory file') 19 | args = parser.parse_args(sys.argv[1:]) 20 | atoms = read(args.g) 21 | atoms = press_mol(atoms) 22 | 23 | # ir = IRFF_NP(atoms=atoms, 24 | # libfile='ffield.json', 25 | # nn=True) 26 | 27 | # ir.calculate(atoms) 28 | # print(ir.E) 29 | order = ['C','O','N','H'] 30 | 31 | spes = [] 32 | pos = [] 33 | 34 | cell = atoms.get_cell() 35 | position = atoms.get_positions() 36 | 37 | spec = atoms.get_chemical_symbols() 38 | 39 | for sp in order: 40 | for i,s in enumerate(spec): 41 | if s==sp: 42 | spes.append(s) 43 | pos.append(position[i]) 44 | 45 | A = Atoms(spes,pos,cell=cell,pbc=[True,True,True]) 46 | A.write('POSCAR') 47 | 48 | 49 | -------------------------------------------------------------------------------- /tools/stretch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | # import argh 5 | import argparse 6 | from ase.visualize import view 7 | from ase.io import read 8 | from ase.io.trajectory import TrajectoryWriter,Trajectory 9 | from irff.AtomDance import AtomDance,get_group 10 | 11 | 12 | help_ = 'run with commond: ./stretch.py --g=nm.gen --i=0 --j=1 --s=1.4 --e=1.9' 13 | parser = argparse.ArgumentParser(description=help_) 14 | parser.add_argument('--g',default='poscar.gen',type=str, help='training steps') 15 | parser.add_argument('--i',default=0,type=int, help='iatom') 16 | parser.add_argument('--j',default=1,type=int, help='jatom') 17 | parser.add_argument('--s',default=1.4,type=float, help='start radius') 18 | parser.add_argument('--e',default=1.9,type=float, help='end radius') 19 | parser.add_argument('--auto',default=1,type=int, help='automaticly determin the moving group') 20 | parser.add_argument('--f',default=-1,type=int, help='the trajectory frame') 21 | parser.add_argument('--n',default=9,type=int, help='the number of trajectory frame') 22 | args = parser.parse_args(sys.argv[1:]) 23 | 24 | 25 | atoms = read(args.g,index=args.f) 26 | ad = AtomDance(atoms=atoms,rmax=1.2, 27 | rcut={"C-H":1.22,"H-O":1.22,"H-H":1.2,"O-O":1.4, 28 | "others": 1.8}) 29 | 30 | if args.auto: 31 | to_move = None 32 | else: 33 | to_move = [args.j] 34 | 35 | images = ad.stretch([args.i,args.j],nbin=args.n,rst=args.s,red=args.e, 36 | ToBeMoved=to_move,traj='md.traj') 37 | ad.close() 38 | 39 | 40 | -------------------------------------------------------------------------------- /tools/structure.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.structures import structure 3 | from ase.visualize import view 4 | 5 | atoms = structure('cl20') 6 | view(atoms) 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tools/supercell.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from irff.molecule import packmol 3 | from ase.io import read,write 4 | from ase import build 5 | 6 | 7 | A = read('POSCAR') 8 | # build.make_supercell(A,[2,2,2]) 9 | write('poscar.gen',A*(2,2,2)) 10 | 11 | packmol(strucs=['poscar.gen'], 12 | supercell=[3,3,2], 13 | w=True) 14 | -------------------------------------------------------------------------------- /tools/swing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from irff.AtomDance import AtomDance 7 | import sys 8 | import argh 9 | import argparse 10 | 11 | 12 | parser = argparse.ArgumentParser(description='./rotate.py --g=md.traj --i=0 --j=1 --d=30.0 ') 13 | parser.add_argument('--g',default='poscar.gen',type=str, help='atomic configuration') 14 | parser.add_argument('--i',default=0,type=int, help='atoms i of the angle') 15 | parser.add_argument('--j',default=1,type=int, help='atoms j of the angle') 16 | parser.add_argument('--o',default=2,type=int, help='atoms k of the angle') 17 | parser.add_argument('--f',default=-1,type=int, help='number of trajectory frame') 18 | parser.add_argument('--n',default=7,type=int, help='n bin') 19 | parser.add_argument('--d',default=90.0,type=float, help='angle rotate degree') 20 | parser.add_argument('--a',default=' ',type=str, help='atom IDs') 21 | 22 | args = parser.parse_args(sys.argv[1:]) 23 | atms = [int(a) for a in args.a.split()] 24 | atoms = read(args.g,index=args.f) 25 | ad = AtomDance(atoms) 26 | images = ad.rotate(axis=[args.i,args.j],o=args.o,atms=atms,rang=10, 27 | nbin=args.n,traj='md.traj') 28 | # images = ad.rotate(axis=[args.i,args.j],o=args.o,rang=args.d,nbin=50,traj='md.traj') 29 | ad.close() 30 | # view(atoms) 31 | 32 | 33 | ''' 34 | run this script using commond: 35 | ./rotate.py --g=nm.gen --i=0 --j=1 --d=30.0 36 | ''' 37 | 38 | -------------------------------------------------------------------------------- /tools/test_reax.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import system, getcwd, chdir,listdir 3 | # from train_reaxff_perfect20181028 import test_reax 4 | from irff.reax import test_reax 5 | 6 | # system('rm *.pkl') 7 | system('./r2lreax.lib') 8 | dirc={'hb6':'/home/gfeng/siesta/train/hb6'} 9 | test_reax(direcs=dirc,dft='siesta',batch_size=50) 10 | 11 | -------------------------------------------------------------------------------- /tools/uspex/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fenggo/I-ReaxFF/d7f0d15a280cf1052696eb0eb07209fff253862d/tools/uspex/.keep -------------------------------------------------------------------------------- /tools/uspex/density.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import argparse 4 | import numpy as np 5 | from ase.io import read 6 | from ase.io.trajectory import Trajectory 7 | from ase.data import chemical_symbols 8 | 9 | parser = argparse.ArgumentParser(description='./atoms_to_poscar.py --g=siesta.traj') 10 | parser.add_argument('--gen',default='md.traj', help='atomic configuration') 11 | parser.add_argument('--i',default=-1,type=int, help='the index in atomic configurations') 12 | args = parser.parse_args(sys.argv[1:]) 13 | 14 | atoms = read(args.gen,index=args.i) 15 | 16 | masses = np.sum(atoms.get_masses()) 17 | volume = atoms.get_volume() 18 | density = masses/volume/0.602214129 19 | 20 | print('Volume: ',volume, 'Masses: ',masses,'Density: ',density) 21 | 22 | -------------------------------------------------------------------------------- /tools/uspex/gen_to_csv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os import getcwd,chdir,listdir,system 3 | import numpy as np 4 | from ase.io.trajectory import Trajectory 5 | from ase.io import read 6 | from pymatgen.io.ase import AseAtomsAdaptor 7 | from ase.io import read 8 | from irff.deb.compare_energies import deb_gulp_energy 9 | # from irff.molecule import press_mol 10 | 11 | cdir = getcwd() 12 | files = listdir(cdir) 13 | poscars = [gen for gen in files if gen.endswith('.gen') ] 14 | images = [] 15 | 16 | for gen in poscars: 17 | gen_ = gen.split('.')[0] 18 | atoms = read(gen) 19 | images.append(atoms.copy()) 20 | 21 | (e,ebond_,eunder_,eover_,elone_,eang_,etcon_,epen_, 22 | etor_,efcon_,ev,ehb,ec) = deb_gulp_energy(images, ffield='reaxff_nn') 23 | n_images = len(images) 24 | 25 | f = open('train.csv','w') 26 | print(',material_id,energy,density,hydrogen_bond_energy,cif,volume',file=f) 27 | 28 | for i,atoms in enumerate(images): 29 | gen_ = poscars[i].split('.')[0] 30 | structure = AseAtomsAdaptor.get_structure(atoms) 31 | structure.to(filename="POSCAR") 32 | 33 | masses = np.sum(atoms.get_masses()) 34 | volume = atoms.get_volume() 35 | density = masses/volume/0.602214129 36 | print('loading structures {:d}/{:d} ...\r'.format(i,n_images),end='\r') 37 | structure = AseAtomsAdaptor.get_structure(atoms) 38 | structure.to(filename="{:s}.cif".format(gen_)) 39 | 40 | 41 | print('{:d}, {:s}, {:f}, {:f}, {:f}, \"'.format(i,gen_, 42 | e[i],density,ehb[i]),end=' ',file=f) 43 | with open("{:s}.cif".format(gen_),'r') as fc: 44 | for line in fc.readlines(): 45 | print(line.strip(),file=f) 46 | print('\",{:f}'.format(volume),file=f) 47 | 48 | f.close() 49 | -------------------------------------------------------------------------------- /tools/uspex/individuals_to_poscars.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | from ase.io.trajectory import Trajectory 4 | from ase.io import read 5 | from pymatgen.io.ase import AseAtomsAdaptor 6 | from ase.io import read 7 | # from irff.molecule import press_mol 8 | 9 | density = 1.4 10 | inds = [i for i in range(71)] 11 | 12 | ########### pack to poscars ########## 13 | images = Trajectory('Individuals.traj') 14 | 15 | fposcars = open('POSCARS','a') 16 | for i_,atoms in enumerate(images): 17 | masses = np.sum(atoms.get_masses()) 18 | volume = atoms.get_volume() 19 | density_ = masses/volume/0.602214129 20 | if density_=0: 34 | card = True 35 | if card and line.find('direct')<0: 36 | print(line[:-3],file=fposcars) 37 | elif i==0: 38 | print('EA{:d} {:.6f} {:.6f} {:.6f} {:.3f} {:.3f} {:.3f} Sym.group: 1'.format(i_, 39 | lengths[0],lengths[1],lengths[2], 40 | angles[0],angles[1],angles[2]),file=fposcars) 41 | else: 42 | print(line[:-1],file=fposcars) 43 | 44 | # print('{:s}'.format(i_)) 45 | fposcars.close() 46 | 47 | -------------------------------------------------------------------------------- /tools/uspex/mlflow.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from os.path import isfile 3 | from os import system, getcwd,listdir 4 | import sys 5 | import argparse 6 | import numpy as np 7 | from ase.io import read 8 | 9 | ''' A work flow in combination with USPEX ''' 10 | 11 | parser = argparse.ArgumentParser(description='./atoms_to_poscar.py --g=siesta.traj') 12 | parser.add_argument('--n',default=1,type=int, help='the number of cpu used in this calculation') 13 | parser.add_argument('--d',default=1.85,type=float, help='the minimal density') 14 | args = parser.parse_args(sys.argv[1:]) 15 | 16 | 17 | def run_gulp(n=1,inp='input'): 18 | if n==1: 19 | system('gulp<{:s}>output'.format(inp)) 20 | else: 21 | system('mpirun -n {:d} gulp<{:s}>output'.format(n,inp)) # get initial crystal structure 22 | 23 | def write_input(inp='inp-grad'): 24 | with open('input','r') as f: 25 | lines = f.readlines() 26 | with open(inp,'w') as f: 27 | for i,line in enumerate(lines): 28 | if i==0 : 29 | print('grad nosymmetry conv qiterative',file=f) 30 | # elif line.find('maxcyc')>=0: 31 | # print('maxcyc 0',file=f) 32 | else: 33 | print(line.rstrip(),file=f) 34 | def write_output(): 35 | with open('output','r') as f: 36 | for line in f.readlines(): 37 | if line.find('Total lattice energy')>=0 and line.find('eV')>0: 38 | e = float(line.split()[4]) 39 | with open('output','w') as f: 40 | print(' Cycle: 0 Energy: {:f}'.format(e),file=f) 41 | 42 | 43 | 44 | write_input(inp='inp-grad') 45 | run_gulp(n=args.n,inp='inp-grad') 46 | write_output() 47 | 48 | atoms = read('gulp.cif') 49 | masses = np.sum(atoms.get_masses()) 50 | volume = atoms.get_volume() 51 | density = masses/volume/0.602214129 52 | 53 | if density <= args.d: 54 | run_gulp(n=args.n,inp='input') 55 | -------------------------------------------------------------------------------- /tools/uspex/mols.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | import sys 4 | import argparse 5 | import numpy as np 6 | import copy 7 | import json as js 8 | from os import system 9 | from ase.io import read 10 | from ase.io.trajectory import TrajectoryWriter #,Trajectory 11 | from ase.calculators.singlepoint import SinglePointCalculator 12 | from irff.molecule import Molecules,moltoatoms 13 | #from irff.md.lammps import writeLammpsData 14 | from irff.irff_np import IRFF_NP 15 | from irff.molecule import press_mol 16 | from irff.md.gulp import write_gulp_in,get_reax_energy 17 | from irff.md.gulp import opt 18 | 19 | ''' scale the crystal box, while keep the molecule structure unchanged 20 | ''' 21 | 22 | parser = argparse.ArgumentParser(description='eos by scale crystal box') 23 | parser.add_argument('--g', default='md.traj',type=str, help='trajectory file') 24 | parser.add_argument('--i', default=0,type=int, help='index of atomic frame') 25 | parser.add_argument('--n', default=8,type=int, help='ncpu') 26 | args = parser.parse_args(sys.argv[1:]) 27 | 28 | 29 | A = read(args.g,index=args.i) 30 | m_ = Molecules(A,rcut={"H-O":1.12,"H-N":1.22,"H-C":1.22,"O-O":1.35,"others": 1.62},check=True) 31 | nmol = len(m_) 32 | print('\nnumber of molecules:',nmol) 33 | 34 | cell = A.get_cell() 35 | emolecules = 0.0 36 | 37 | for i,m in enumerate(m_): 38 | atoms = moltoatoms([m]) 39 | atoms.write('mol_{:d}.gen'.format(i)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /tools/uspex/sort_poscars.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | with open('POSCARS','r') as f: 4 | lines = f.readlines() 5 | 6 | with open('POSCARS','w') as f: 7 | card = False 8 | for i,line in enumerate(lines): 9 | if line.find('direct')>=0 or line.find('Direct')>=0: 10 | card = True 11 | elif line.find('EA')>=0 and line.find('Sym.group')>=0: 12 | card = True 13 | if card and line.find('direct')<0 and line.find('Direct')<0: 14 | l = line.split() 15 | print(l[0],l[1],l[2],file=f) 16 | else: 17 | print(line.rstrip(),file=f) 18 | -------------------------------------------------------------------------------- /tools/uspex/uspex_zmat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | import argparse 4 | from ase.io import read 5 | from irff.AtomDance import AtomDance 6 | 7 | parser = argparse.ArgumentParser(description='write the uspex style Z-matrix infomation') 8 | parser.add_argument('--geo',default='POSCAR',type=str, help='geomentry file name') 9 | parser.add_argument('--i',default=0,type=int, help='the i_th frame in traj file') 10 | args = parser.parse_args(sys.argv[1:]) 11 | 12 | atoms = read(args.geo,index=args.i) 13 | ad = AtomDance(atoms=atoms,rmax=1.2) 14 | zmat = ad.InitZmat 15 | 16 | ad.write_zmat(zmat,uspex=True) 17 | ad.close() 18 | 19 | 20 | ''' 21 | run the script with command: 22 | ./uspex_zmat.py --g=structure.gen 23 | ''' 24 | -------------------------------------------------------------------------------- /tools/zmat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | from ase.visualize import view 4 | from ase.io import read 5 | from ase.io.trajectory import TrajectoryWriter,Trajectory 6 | from ase.calculators.singlepoint import SinglePointCalculator 7 | from irff.AtomDance import AtomDance 8 | 9 | 10 | atoms = read('cl1.gen',index=0) 11 | ad = AtomDance(atoms=atoms,rmax=1.33) 12 | ad.write_zmat(ad.InitZmat) 13 | zmat = ad.InitZmat 14 | # zmat[2][1] = 109.0 15 | # print(zmat) 16 | 17 | images = [] 18 | his = TrajectoryWriter('md.traj',mode='w') 19 | ang = 90.0 20 | 21 | for j in range(40): 22 | ang += 1.0 23 | zmat[9][1] = ang 24 | atoms = ad.zmat_to_cartation(atoms,zmat) 25 | ad.ir.calculate(atoms) 26 | atoms.calc = SinglePointCalculator(atoms,energy=ad.ir.E) 27 | his.write(atoms=atoms) 28 | images.append(atoms.copy()) 29 | 30 | his.close() 31 | ad.close() 32 | view(images) 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------