Software:forcebalance: Difference between revisions

From biowiki
Jump to navigation Jump to search
No edit summary
Liuchw (talk | contribs)
Line 18: Line 18:


After you have conda installed, FB can be easily installed through the following commands:
After you have conda installed, FB can be easily installed through the following commands:
<pre>  conda create --name FB17 python=3.7
<pre>  conda create --name FB17
   conda activate FB17
   conda activate FB17
   conda install --strict-channel-priority -c conda-forge forcebalance</pre>
   conda install forcebalance=1.7.5</pre>


Now ForceBalance is installed. You should be able to run (but not efficiently) FB jobs with the following settings.
Note that in the above we installed forcebalance version 1.7.5. If you need new features beyond this version, just remove "=1.7.5" in the above installation. Now ForceBalance is installed. You should be able to run (but not efficiently) FB jobs with the following settings.


&nbsp;
=='''<span style="font-size:large">ForceBalance input files</span>'''==
 
Alternatively (for AMOEBA only, not AMOEBA+), for GPU tinker modifications and cluster submission. Please read&nbsp;[https://github.com/bdw2292/Ren-Lab-Daemon/blob/main/README_HELP.MD https://github.com/bdw2292/Ren-Lab-Daemon/blob/main/README_HELP.MD] , the section titled'''&nbsp;Creating workers for ForceBalance cluster submission'''
 
== '''<span style="font-size:large">ForceBalance input files</span>''' ==


<font size="3">In the following I will use amoeba water as an example. All the files are located in Renlab cluster at</font>
<font size="3">In the following I will use amoeba water as an example. All the files are located in Renlab cluster at</font>
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>/home/liuchw/FB-demo/015_amoeba_tinker</code></div>  
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>/home/liuchw/FB-demo/015_amoeba_tinker</code></div>  
<font size="3">A&nbsp;&nbsp;typical job of ForceBalance folder looks like:&nbsp;</font>
<font size="3">A&nbsp;&nbsp;typical job of ForceBalance folder looks like:&nbsp;</font>
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>├── example.in<br/> ├── forcefield<br/> │&nbsp; &nbsp;└── water.prm<br/> └── targets<br/> &nbsp; &nbsp; ├── DimerMin<br/> &nbsp; &nbsp; ├── Interactions_CCSDT<br/> &nbsp; &nbsp; ├── Interactions_MP2<br/> &nbsp; &nbsp; ├── Liquid<br/> &nbsp; &nbsp; ├── Monomer_Moments<br/> &nbsp; &nbsp; ├── Monomer_Vibration<br/> &nbsp; &nbsp; ├── cluster-02<br/> &nbsp; &nbsp; ├── cluster-03</code></div>  
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>├── example.in<br /> ├── forcefield<br /> │&nbsp; &nbsp;└── water.prm<br /> └── targets<br /> &nbsp; &nbsp; ├── DimerMin<br /> &nbsp; &nbsp; ├── Interactions_CCSDT<br /> &nbsp; &nbsp; ├── Interactions_MP2<br/> &nbsp; &nbsp; ├── Liquid<br /> &nbsp; &nbsp; ├── Monomer_Moments<br /> &nbsp; &nbsp; ├── Monomer_Vibration<br /> &nbsp; &nbsp; ├── cluster-02<br /> &nbsp; &nbsp; ├── cluster-03</code></div>  
<font size="3">where example.in has the settings read by ForceBalance, forcefield directory contains the tinker parameter file, and targets folder contains lots of targets (both QM and Liquid).&nbsp;</font>
<font size="3">where example.in has the settings read by ForceBalance, forcefield directory contains the tinker parameter file, and targets folder contains lots of targets (both QM and Liquid).&nbsp;</font>


<font size="3">Inside the QM target is the tinker xyz and interactions.txt, interactions.key files Inside the Liquid target are the input files for Tinker (key and xyz) and experimental data (data.csv).&nbsp;</font>
<font size="3">Inside the QM target is the tinker xyz and interactions.txt, interactions.key files Inside the Liquid target are the input files for Tinker (key and xyz) and experimental data (data.csv).&nbsp;</font>
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>&nbsp;Liquid/<br/> ├── data.csv<br/> ├── gas.key<br/> ├── gas.xyz<br/> ├── liquid.key<br/> └── liquid.xyz</code></div>  
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>&nbsp;Liquid/<br /> ├── data.csv<br /> ├── gas.key<br /> ├── gas.xyz<br/> ├── liquid.key<br /> └── liquid.xyz</code></div>  
A cluster folder typically contains the XYZ files, interactions.key, and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA.
A cluster folder typically contains the XYZ files, interactions.key, and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA.


<font size="3">A QM target folder (showing below)&nbsp;typically contains xyz files, interactions.key and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA.&nbsp;</font>
<font size="3">A QM target folder (showing below)&nbsp;typically contains xyz files, interactions.key and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA.&nbsp;</font>
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>Interactions_CCSDT/<br/> ├── 01-Prism.xyz<br/> ├── 02-Cage.xyz<br/> ├── 03-Bag.xyz<br/> ├── 04-Cyclic-Chair.xyz<br/> ├── 05-Book-1.xyz<br/> ├── 06-Book-2.xyz<br/> ├── 07-Cyclic-Boat-1.xyz<br/> ├── 08-Cyclic-Boat-2.xyz<br/> ├── interactions.key<br/> ├── interactions.txt<br/> ├── monomer_exp.xyz<br/> ├── monomer_mp2.xyz<br/> ├── monomer_opt.xyz</code></div>  
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>Interactions_CCSDT/<br /> ├── 01-Prism.xyz<br /> ├── 02-Cage.xyz<br /> ├── 03-Bag.xyz<br /> ├── 04-Cyclic-Chair.xyz<br /> ├── 05-Book-1.xyz<br /> ├── 06-Book-2.xyz<br /> ├── 07-Cyclic-Boat-1.xyz<br /> ├── 08-Cyclic-Boat-2.xyz<br /> ├── interactions.key<br /> ├── interactions.txt<br /> ├── monomer_exp.xyz<br /> ├── monomer_mp2.xyz<br /> ├── monomer_opt.xyz</code></div>  
<span style="font-size:small;">After setting up the above files, you should be able to run ForceBalance using the simple command:</span>
<span style="font-size:small;">After setting up the above files, you should be able to run ForceBalance using the simple command:</span>
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code><span style="font-size:medium">ForceBalance example.in</span></code></div>  
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code><span style="font-size:medium">ForceBalance example.in</span></code></div>  
If ForceBalance jobs crash, check the error message and modify your setting.&nbsp; More information about settings in the example.in, please refer to ForceBalance manual file<span style="display: none">&nbsp;</span>
If ForceBalance jobs crash, check the error message and modify your setting.&nbsp; More information about settings in the example.in, please refer to ForceBalance manual file<span style="display: none">&nbsp;</span>


[http://leeping.github.io/forcebalance/doc/ForceBalance-Manual.pdf http://leeping.github.io/forcebalance/doc/ForceBalance-Manual.pdf]
http://leeping.github.io/forcebalance/doc/ForceBalance-Manual.pdf


=='''Customization and parallelization for AMOEBA(+)'''==
=='''Customization and parallelization for AMOEBA and AMOEBA+ force fields'''==


1. Backup original FB source files
1. Backup original FB source files
<pre>  export condaHOME = /home/liuchw/anaconda3/envs/FB17/lib/python3.7/site-packages/forcebalance
<pre>  export condaHOME = /home/liuchw/anaconda3/envs/FB17/lib/python3.7/site-packages/forcebalance (change this accordingly)
   cp $condaHOME/binding.py $condaHOME/binding.py_back
   cp $condaHOME/binding.py $condaHOME/binding.py_back
   cp $condaHOME/liquid.py $condaHOME/liquid.py_back
   cp $condaHOME/liquid.py $condaHOME/liquid.py_back
Line 69: Line 65:
The above customization mostly involves supports for AMOEBA+ keywords and parallelization of the serial jobs in:
The above customization mostly involves supports for AMOEBA+ keywords and parallelization of the serial jobs in:


*Tinker binding energy calculations (<code>minimize</code> and <code>analyze</code>)  
*Tinker binding energy calculations (<code>minimize</code> and <code>analyze</code>)
*Tinker post-MD&nbsp;<code>analyze</code>&nbsp;jobs  
*Tinker post-MD&nbsp;<code>analyze</code>&nbsp;jobs
*Tinker/Tinker-OpenMM&nbsp;<code>dynamic</code>&nbsp;jobs
*Tinker/Tinker9&nbsp;<code>dynamic</code>&nbsp;jobs
 
3. Set environmental variable TINKERPATH, and put the following files in the directory that $TINKERPATH points to
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;">analyze minimize dynamic optimize submitTinker.py nodes.dat</div>
where, `analyze`, `minimize`, `dynamic` and `optimize` are Tinker8 executables; `submitTinker.py` is downloaded from Software-mod in the previous step. This script is responsible for submitting Tinker CPU and GPU jobs on to Ren lab clusters. This script is reading node list from `nodes.dat` file, which looks like the following
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;">#===========================================
<nowiki>#</nowiki>   Any line starts with "#" will be ignored.
 
<nowiki>#</nowiki>   Only the first two columns matter !!
 
<nowiki>#</nowiki>   This file is used by submitTinker.py
 
<nowiki>#</nowiki>===========================================
 
<nowiki>###</nowiki> GPU nodes mainly use
 
GPU node152   4090    2
 
GPU node154   4090    2
 
<nowiki>#</nowiki>CPU nodes nthreads


3. An extra file besides the .in is needed in order to distribute the dynamic/dynamic_omm jobs on to different Renlab cluster nodes. Specify the node filename in the .in file as
CPU      node145  32
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>&nbsp;liquid_node yourfilename.node</code></div>
 
where the yourfilename.node should look like:
CPU      node146  32
<div style="background:#eeeeee;border:1px solid #cccccc;padding:5px 10px;"><code>Liquid_Methanol &nbsp; &nbsp; &nbsp; 278.15 node78<br/> Liquid_Methanol &nbsp; &nbsp; &nbsp; 298.15 node49<br/> Liquid_Methanol &nbsp; &nbsp; &nbsp; 318.15 node79<br/> Liquid_Ethanol &nbsp; &nbsp; &nbsp; &nbsp;278.15 node83<br/> Liquid_Ethanol &nbsp; &nbsp; &nbsp; &nbsp;298.15 node73<br/> Liquid_Ethanol &nbsp; &nbsp; &nbsp; &nbsp;318.15 node55<br/> Liquid_1-Propanol &nbsp; &nbsp; 278.15 node54<br/> Liquid_1-Propanol &nbsp; &nbsp; 298.15 node47<br/> Liquid_1-Propanol &nbsp; &nbsp; 318.15 node40<br/> Liquid_2-Propanol &nbsp; &nbsp; 278.15 node44<br/> Liquid_2-Propanol &nbsp; &nbsp; 298.15 node53<br/> Liquid_2-Propanol &nbsp; &nbsp; 318.15 node85<br/> Liquid_Methane &nbsp; &nbsp; &nbsp; &nbsp; 95.15 node72<br/> Liquid_Methane &nbsp; &nbsp; &nbsp; &nbsp;105.15 node61<br/> Liquid_Ethane &nbsp; &nbsp; &nbsp; &nbsp; 154.15 node43<br/> Liquid_Ethane &nbsp; &nbsp; &nbsp; &nbsp; 174.15 node42</code></div>
 
CPU      node152  64
 
CPU      node153  64
</div>4. Set the .forcebalance.bashrc, please change accordingly
  #!/usr/bin/bash
  source ~/.bashrc
  conda activate FB17
  export TINKERPATH=/home/liuchw/bin/TinkerGPU2022
  export PATH=$PATH:$TINKERPATH
  VAL=`nvidia-smi &> /dev/null; echo $?`
  # check existence
  if [ $VAL != 0 ]; then
    echo -e "  \e[101mCUDA utility not installed on `hostname`\e[0m"
  else
      export tk9home=/home/liuchw/Softwares/tinkers/Tinker9/2403/build
      export  DYNAMIC="$tk9home/dynamic9"
      export  ANALYZE="$tk9home/analyze9"
      export      BAR="$tk9home/bar9"
      export MINIMIZE="$tk9home/minimize9"
      export TESTGRAD="$tk9home/testgrad9"
  fi
  export JOBPOOL=/home/liuchw/bin/JobPool
where there is another directory `JOBPOOL` needs to be set. In that directory, there are `subCPU.py` and `subGPU.py` which are keeping submitting the `*.sh` files appear in that directory. Please see `/home/liuchw/bin/JobPool` for detail.

Revision as of 16:52, 2 April 2024

Background

ForceBalance is an automatic force field parametrization tool developed by Lee-Ping Wang et al. It allows one to use both quantum chemical data and experimental observables of the liquid phase. It has been applied to parameterize a bunch of water models and organic molecules. The following examples are some of them.

J. Phys. Chem. Lett., 2014, 5 (11), pp 1885–1891 (ForceBalance paper, TIP3P and TIP4P water as examples)

J. Phys. Chem. B, 2013, 117 (34), pp 9956–9972 (iAMOEBA paper)

J. Phys. Chem. B, 2015, 119 (29), pp 9423–9437 (AMOEBA14 paper)

Here, a brief tutorial on how to install, set up, parallelize and run FB is provided below.   

See "/home/liuchw/FB-demo" for local files.

ForceBalance Installation

ForceBalance can be installed in different ways. Here I recommend installing FB through conda software manager (either Anaconda or Miniconda). For how to install conda, please go to the anaconda download page (https://www.anaconda.com/products/individual).

After you have conda installed, FB can be easily installed through the following commands:

  conda create --name FB17
  conda activate FB17
  conda install forcebalance=1.7.5

Note that in the above we installed forcebalance version 1.7.5. If you need new features beyond this version, just remove "=1.7.5" in the above installation. Now ForceBalance is installed. You should be able to run (but not efficiently) FB jobs with the following settings.

ForceBalance input files

In the following I will use amoeba water as an example. All the files are located in Renlab cluster at

/home/liuchw/FB-demo/015_amoeba_tinker

A  typical job of ForceBalance folder looks like: 

├── example.in
├── forcefield
│   └── water.prm
└── targets
    ├── DimerMin
    ├── Interactions_CCSDT
    ├── Interactions_MP2
    ├── Liquid
    ├── Monomer_Moments
    ├── Monomer_Vibration
    ├── cluster-02
    ├── cluster-03

where example.in has the settings read by ForceBalance, forcefield directory contains the tinker parameter file, and targets folder contains lots of targets (both QM and Liquid). 

Inside the QM target is the tinker xyz and interactions.txt, interactions.key files Inside the Liquid target are the input files for Tinker (key and xyz) and experimental data (data.csv). 

 Liquid/
├── data.csv
├── gas.key
├── gas.xyz
├── liquid.key
└── liquid.xyz

A cluster folder typically contains the XYZ files, interactions.key, and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA.

A QM target folder (showing below) typically contains xyz files, interactions.key and interactions.txt, which defines the QM reference and how you calculate the interaction energy for AMOEBA. 

Interactions_CCSDT/
├── 01-Prism.xyz
├── 02-Cage.xyz
├── 03-Bag.xyz
├── 04-Cyclic-Chair.xyz
├── 05-Book-1.xyz
├── 06-Book-2.xyz
├── 07-Cyclic-Boat-1.xyz
├── 08-Cyclic-Boat-2.xyz
├── interactions.key
├── interactions.txt
├── monomer_exp.xyz
├── monomer_mp2.xyz
├── monomer_opt.xyz

After setting up the above files, you should be able to run ForceBalance using the simple command:

ForceBalance example.in

If ForceBalance jobs crash, check the error message and modify your setting.  More information about settings in the example.in, please refer to ForceBalance manual file 

http://leeping.github.io/forcebalance/doc/ForceBalance-Manual.pdf

Customization and parallelization for AMOEBA and AMOEBA+ force fields

1. Backup original FB source files

  export condaHOME = /home/liuchw/anaconda3/envs/FB17/lib/python3.7/site-packages/forcebalance (change this accordingly)
  cp $condaHOME/binding.py $condaHOME/binding.py_back
  cp $condaHOME/liquid.py $condaHOME/liquid.py_back
  cp $condaHOME/tinkerio.py $condaHOME/tinkerio.py_back
  cp $condaHOME/parser.py $condaHOME/parser.py_back
  cp $condaHOME/data/npt.py $condaHOME/data/npt.py_back

2. Download modified files and copy them to the anaconda lib directory

  git clone git@github.com:leucinw/Software-mod.git modcode
  export modfileHOME=/home/liuchw/modcode/forcebalance-1.7.5
  cp $modfileHOME/binding.py $condaHOME/binding.py
  cp $modfileHOME/liquid.py  $condaHOME/liquid.py
  cp $modfileHOME/tinkerio.py $condaHOME/tinkerio.py
  cp $modfileHOME/parser.py $condaHOME/parser.py
  cp $modfileHOME/data/npt.py $condaHOME/data/npt.py

The above customization mostly involves supports for AMOEBA+ keywords and parallelization of the serial jobs in:

  • Tinker binding energy calculations (minimize and analyze)
  • Tinker post-MD analyze jobs
  • Tinker/Tinker9 dynamic jobs

3. Set environmental variable TINKERPATH, and put the following files in the directory that $TINKERPATH points to

analyze minimize dynamic optimize submitTinker.py nodes.dat

where, `analyze`, `minimize`, `dynamic` and `optimize` are Tinker8 executables; `submitTinker.py` is downloaded from Software-mod in the previous step. This script is responsible for submitting Tinker CPU and GPU jobs on to Ren lab clusters. This script is reading node list from `nodes.dat` file, which looks like the following

#===========================================

#   Any line starts with "#" will be ignored.

#   Only the first two columns matter !!

#   This file is used by submitTinker.py

#===========================================

### GPU nodes mainly use

GPU node152   4090    2

GPU node154   4090    2

#CPU nodes nthreads

CPU      node145  32

CPU      node146  32

CPU      node152  64

CPU      node153  64

4. Set the .forcebalance.bashrc, please change accordingly

 #!/usr/bin/bash
 source ~/.bashrc
 conda activate FB17

 export TINKERPATH=/home/liuchw/bin/TinkerGPU2022
 export PATH=$PATH:$TINKERPATH

 VAL=`nvidia-smi &> /dev/null; echo $?`
 # check existence
 if [ $VAL != 0 ]; then
   echo -e "   \e[101mCUDA utility not installed on `hostname`\e[0m"
 else
     export tk9home=/home/liuchw/Softwares/tinkers/Tinker9/2403/build
     export  DYNAMIC="$tk9home/dynamic9"
     export  ANALYZE="$tk9home/analyze9"
     export      BAR="$tk9home/bar9"
     export MINIMIZE="$tk9home/minimize9"
     export TESTGRAD="$tk9home/testgrad9"
 fi


 export JOBPOOL=/home/liuchw/bin/JobPool

where there is another directory `JOBPOOL` needs to be set. In that directory, there are `subCPU.py` and `subGPU.py` which are keeping submitting the `*.sh` files appear in that directory. Please see `/home/liuchw/bin/JobPool` for detail.