Hi,
I'm sure there is a simple answer to this question. I am trying to use force balance to force match a force field using AmberMD as an engine. It seems that the code is able to handle this, at least according to the manual. I started with the studies/001_water_tutorial, and changed the input file, very_simple.in and changed the following line:
simtype abinitio_gmx
to
simtype AbInitio_AMBER
I assumed this would give me an error eventually, but when I ran "ForceBalance.py very_simple.in" I got the following error, which was unexpected:
/usr/local/lib/python2.7/site-packages/forcebalance/contact.py:58: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
if box == None:
Traceback (most recent call last):
File "/usr/local/bin/ForceBalance.py", line 39, in Run_ForceBalance
objective = Objective(options, tgt_opts, forcefield)
File "/usr/local/lib/python2.7/site-packages/forcebalance/objective.py", line 134, in __init__
else: Tgt = Implemented_Targets[opts['type']](options,opts,forcefield)
File "/usr/local/lib/python2.7/site-packages/forcebalance/amberio.py", line 173, in __init__
super(AbInitio_AMBER,self).__init__(options,tgt_opts,forcefield)
File "/usr/local/lib/python2.7/site-packages/forcebalance/abinitio.py", line 155, in __init__
self.engine = self.engine_(target=self, mol=self.mol, **engine_args)
AttributeError: 'AbInitio_AMBER' object has no attribute 'engine_'
The sticking point seems to be the last part. I'm not sure where to go from here, so any insight would be appreciated.
Thanks for your help,
Isaiah
ForceBalance and Amber
- Lee-Ping Wang
- Posts: 102
- Joined: Sun Jun 19, 2011 5:14 pm
Re: ForceBalance and Amber
Hi Isaiah,
Thanks for your message. I'm glad you're interested in using ForceBalance. ForceBalance does support AMBER for parameterizing force fields, but it can't convert a GROMACS force field format to AMBER. If you change AbInitio_GMX to AbInitio_AMBER, you also need to change some files in forcefield and targets.
I've just updated the master branch with an example (studies/014_chromophore) that does energy + force matching along with RESP in AMBER. The molecule is parameterized starting from a .mol2 and .frcmod file that you can create using Antechamber. The files in "targets" are generated from quantum chemistry calculations.
Let me know if this works for you.
Thanks,
- Lee-Ping
Thanks for your message. I'm glad you're interested in using ForceBalance. ForceBalance does support AMBER for parameterizing force fields, but it can't convert a GROMACS force field format to AMBER. If you change AbInitio_GMX to AbInitio_AMBER, you also need to change some files in forcefield and targets.
I've just updated the master branch with an example (studies/014_chromophore) that does energy + force matching along with RESP in AMBER. The molecule is parameterized starting from a .mol2 and .frcmod file that you can create using Antechamber. The files in "targets" are generated from quantum chemistry calculations.
Let me know if this works for you.
Thanks,
- Lee-Ping
- Isaiah Sumner
- Posts: 4
- Joined: Tue May 19, 2015 1:36 pm
Re: ForceBalance and Amber
Hi Lee-Ping,
Thanks for your reply! I'll test it out and let you know how it goes.
Isaiah
Thanks for your reply! I'll test it out and let you know how it goes.
Isaiah
- Isaiah Sumner
- Posts: 4
- Joined: Tue May 19, 2015 1:36 pm
Re: ForceBalance and Amber
Hi Lee-Ping,
Let me preface this by saying that I am not a python programmer. So, I'm sure this is another easy fix. When I downloaded the latest branch with your example (/usr/local/bin/ForceBalance optimize.in), I get the following error:
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/amberio.py", line 995, in energy_force
return np.hstack((Result["Energy"].reshape(-1,1), Result["Force"]))
File "/usr/local/lib/python2.7/site-packages/numpy/core/shape_base.py", line 277, in hstack
return _nx.concatenate(arrs, 1)
ValueError: all the input arrays must have same number of dimensions
I can "fix" this (again, not a python programmer so it's possible this was wrong) by making the following change in amberio.py:
return np.hstack((Result["Energy"].reshape(-1,1), Result["Force"])) ====> return np.column_stack((Result["Energy"].reshape(-1,1), Result["Force"]))
I rerun it, and get a new error. This error is an amber error, I believe. Amber will not overwrite forcedump.dat. I fixed that error by putting in the following command:
os.system("rm -f forcedump.dat")
just before Amber is called (self.callamber("sander...
This results in this error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/EGG-INFO/scripts/ForceBalance.py", line 43, in Run_ForceBalance
optimizer.Run()
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 305, in Run
xk = self.OptTab[self.jobtype]()
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 887, in NewtonRaphson
return self.MainOptimizer(b_BFGS=0)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 471, in MainOptimizer
data = self.Objective.Full(xk,Ord,verbose=True)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/objective.py", line 271, in Full
Objective = self.Target_Terms(mvals, Order, verbose, customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/objective.py", line 213, in Target_Terms
Ans = Funcs[Order](mvals, customdir=customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/target.py", line 310, in get_H
Ans = self.meta_get(mvals,1,1,customdir=customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/target.py", line 565, in meta_get
Answer = self.get(mvals, AGrad, AHess)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/abinitio.py", line 1281, in get
Answer_EF = self.get_energy_force(mvals, AGrad, AHess)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/abinitio.py", line 771, in get_energy_force
dM_all[:,p,:], ddM_all[:,p,:] = f12d3p(fdwrap(callM, mvals, p), h = self.h, f0 = M_all)
ValueError: could not broadcast input array from shape (0,211) into shape (100,211)
I don't know where to go from here. I am using Python 2.7.6 and the current version of the code from github.
Please let me know if you want or need more information.
Thanks for your help,
Isaiah
Let me preface this by saying that I am not a python programmer. So, I'm sure this is another easy fix. When I downloaded the latest branch with your example (/usr/local/bin/ForceBalance optimize.in), I get the following error:
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/amberio.py", line 995, in energy_force
return np.hstack((Result["Energy"].reshape(-1,1), Result["Force"]))
File "/usr/local/lib/python2.7/site-packages/numpy/core/shape_base.py", line 277, in hstack
return _nx.concatenate(arrs, 1)
ValueError: all the input arrays must have same number of dimensions
I can "fix" this (again, not a python programmer so it's possible this was wrong) by making the following change in amberio.py:
return np.hstack((Result["Energy"].reshape(-1,1), Result["Force"])) ====> return np.column_stack((Result["Energy"].reshape(-1,1), Result["Force"]))
I rerun it, and get a new error. This error is an amber error, I believe. Amber will not overwrite forcedump.dat. I fixed that error by putting in the following command:
os.system("rm -f forcedump.dat")
just before Amber is called (self.callamber("sander...
This results in this error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/EGG-INFO/scripts/ForceBalance.py", line 43, in Run_ForceBalance
optimizer.Run()
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 305, in Run
xk = self.OptTab[self.jobtype]()
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 887, in NewtonRaphson
return self.MainOptimizer(b_BFGS=0)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/optimizer.py", line 471, in MainOptimizer
data = self.Objective.Full(xk,Ord,verbose=True)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/objective.py", line 271, in Full
Objective = self.Target_Terms(mvals, Order, verbose, customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/objective.py", line 213, in Target_Terms
Ans = Funcs[Order](mvals, customdir=customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/target.py", line 310, in get_H
Ans = self.meta_get(mvals,1,1,customdir=customdir)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/target.py", line 565, in meta_get
Answer = self.get(mvals, AGrad, AHess)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/abinitio.py", line 1281, in get
Answer_EF = self.get_energy_force(mvals, AGrad, AHess)
File "/usr/local/lib/python2.7/site-packages/forcebalance-1.3.2-py2.7-linux-x86_64.egg/forcebalance/abinitio.py", line 771, in get_energy_force
dM_all[:,p,:], ddM_all[:,p,:] = f12d3p(fdwrap(callM, mvals, p), h = self.h, f0 = M_all)
ValueError: could not broadcast input array from shape (0,211) into shape (100,211)
I don't know where to go from here. I am using Python 2.7.6 and the current version of the code from github.
Please let me know if you want or need more information.
Thanks for your help,
Isaiah
- Lee-Ping Wang
- Posts: 102
- Joined: Sun Jun 19, 2011 5:14 pm
Re: ForceBalance and Amber
Ahh, I think I know what's going on. Thanks for the error report.
With the current AMBER version, I don't think it correctly loops over the whole trajectory when writing the forces; instead it just writes the first force and quits. Additionally, it prints out the force components (i.e. bond, angle etc.) which ForceBalance does not need. I worked around this by patching the sander source and recompiling it, but I have yet to document it.
The patch file is here: https://dl.dropboxusercontent.com/u/538 ... -patch.txt
To apply the patch, make sure you're using AmberTools 15 (the newest version), go into the $AMBERHOME folder (containing AmberTools) and type "patch -p1 < force-patch.txt".
You should see this output:
After recompiling AmberTools (specifically sander), the error should go away.
Just to be sure: Can you look at the dimensions of the array to ensure they are really incompatible? There's supposed to be a 1-D array for the energy containing "ns" elements (i.e. number of snapshots), and a 2D array for the energy containing (ns, 3N) elements.
With the current AMBER version, I don't think it correctly loops over the whole trajectory when writing the forces; instead it just writes the first force and quits. Additionally, it prints out the force components (i.e. bond, angle etc.) which ForceBalance does not need. I worked around this by patching the sander source and recompiling it, but I have yet to document it.
The patch file is here: https://dl.dropboxusercontent.com/u/538 ... -patch.txt
To apply the patch, make sure you're using AmberTools 15 (the newest version), go into the $AMBERHOME folder (containing AmberTools) and type "patch -p1 < force-patch.txt".
You should see this output:
Code: Select all
leeping@leeping:~/opt/amber$ patch -p1 < force-patch.txt
patching file AmberTools/src/sander/debug.F90
patching file AmberTools/src/sander/trajene.F90
Just to be sure: Can you look at the dimensions of the array to ensure they are really incompatible? There's supposed to be a 1-D array for the energy containing "ns" elements (i.e. number of snapshots), and a 2D array for the energy containing (ns, 3N) elements.
- Isaiah Sumner
- Posts: 4
- Joined: Tue May 19, 2015 1:36 pm
Re: ForceBalance and Amber
It seems to be working now. I'll poke around and get you the other information you requested. If I manage to break it again, I'll let you know.
Thanks,
Isaiah
Thanks,
Isaiah
- Lee-Ping Wang
- Posts: 102
- Joined: Sun Jun 19, 2011 5:14 pm
Re: ForceBalance and Amber
Glad to hear it. Yes, please stay in touch.
- Lee-Ping
- Lee-Ping