-
Notifications
You must be signed in to change notification settings - Fork 47
Differentiable classical force field support #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
feat(admp): update the newest version to devel branch
feat(classical): support OpenMM-like HarmonicBond, HarmonicAngle and PeriodicTorsion
Conflicts: dmff/api.py dmff/classical/inter.py
* fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential
* get a preliminary result of point charge pme caclulation * correct gradient of coul * review api.py code * feat(classical): Support more Coulomb potentials (#9) * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * imporve colvalent_map support Co-authored-by: Roy Kid <lijichen365@126.com>
…arge GAFF molecule
* feat(classical): Support differentiable mscale & add test cases (#10) * Update PME code (#8) * get a preliminary result of point charge pme caclulation * correct gradient of coul * review api.py code * feat(classical): Support more Coulomb potentials (#9) * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * imporve colvalent_map support Co-authored-by: Roy Kid <lijichen365@126.com> * feat(classical): add testcases for NoCutoff Coulomb potential and a large GAFF molecule * feat(classical): Support differentiable 1-4 scale Co-authored-by: Roy Kid <lijichen365@126.com> * formate code; add example XML section to parseElement docstring Co-authored-by: Roy Kid <lijichen365@126.com>
dmff/classical/inter.py
Outdated
| @@ -1,5 +1,335 @@ | |||
| import sys | |||
|
|
|||
| sys.path.append("/home/lijichen/work/DMFF") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should be solved
KuangYu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in code.
dmff/classical/inter.py
Outdated
| from dmff.admp.recip import generate_pme_recip, Ck_1 | ||
|
|
||
|
|
||
| ONE_4PI_EPS0 = 138.935456 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the same constant in dmff.admp.pme, called DIELECTRIC, should we consider put all important constants together? Maybe add a constant.py file under dmff.
|
|
||
| return E | ||
|
|
||
| def get_energy(positions, box, pairs, epsilon, sigma, epsfix, sigfix): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like in the classical module, all positions/box are assumed to be in unit of nanometer. But in ADMP, all positions are assumed to be in Angstrom. We should discuss this unit conflicts...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to input position/box in nm & kJ/mol in API, and then transfer to angstrom when creating potential function like this:
class ADMPDispGenerator:
def createForce():
def potential_fn(positions, box, pairs, params):
position_ang = positions * 10.0
box_ang = box * 10.0
E_sr = pot_fn_sr(
position_ang, box_ang, pairs, mScales, a_list, b_list, q_list, c_list[0]
)
E_lr = pot_fn_lr(position_ang, box_ang, pairs, c_list.T, mScales)
return E_sr - E_lr
Then we don't need to touch parameter preparing process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good.
| E_excl = get_LJ_energy(dr_excl_vec, sig_excl, eps_excl, box) | ||
| E_excl = self.scale_exclusion * E_excl | ||
|
|
||
| return jnp.sum(E_inter) - jnp.sum(E_excl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may cause precision issues. The way in admp/pairwise.py might be better? Try to apply scaling factor directly on pairwise interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Making change now.
* fix(classical): fix import relationship * Update * feat(classical): make HarmonicBond and HarmonicAngle the same as GAFF * feat(classical): Support torsion force * fix(classical): use two attributes to save proper/improper dihedral separately * fix(classical): Jax the parameters when creating forces * fix(classical): fix a typo * fix(classical): use ndarray to save indexes * fix(classical): return sum of energies for torsion * feat(classical): support 4th order for torsion * feat(classical): Add UT for classical forcefields * fix(classical): Update PDB structures needed by test cases * fix(classical): Change atomtypes to be consistent with residues * feat(classical): add reference energies for test cases * fix(classical): decrease the decimal for energy comparision * feat(classical): Use the same way of openmm for dihedral typification * fix(classical): remove unused import * fix(classical): add order for impropers * fix(classical): use ndarray instead of list for index saving * fix(classical): Add import element * fix(classical): fix misusing between torsion.periodicity and torsion.phase * fix(classical): misusing between periodicity and phase * fix(classical): Correct bond connection in unit test pdb files * Fix pdb files in unittest * Update proper1.pdb * feat(classical): update reference energy for improper test * Update api.py * feat(classical): Add wildcard testcase for improper * set up LennardJones framework * feat(classical): Add test case for multiple dihedrals in one molecule * fix(classical): change the way of dihedral calculation * start to write LJ potential * feat(classical): Implement 12-6 potential without exclusion * feat(classical): Add exclusion pairs for LJ force * feat(classical): add simple test for LennardJonesForce * fix(classical): fix imp of nbfix * fix(classical): use more reasonable test case * fix(classical): add reference energy * draft for dev lj potential * fix Zonly typo in api.py:332 which not consistent with line 475 * reduce PME force to point charge calculation * get a preliminary result of point charge pme caclulation * feat(classical): support loading charge from residue card and NonbondedForce card * correct gradient of coul * feat(classical): Add setting for force switching * feat(classical): Add noPBC support on LJ potential * review api.py code * feat(classical): Use covalent map to generate exclusions * feat(classical): Call LJ in API * fix(classical): bug fix on misusing list and jnp.array * fix(classical): correctly support NoCutoff * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * feat(classical): Support more Coulomb potentials (#9) * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * imporve colvalent_map support * Update PME code (#8) * get a preliminary result of point charge pme caclulation * correct gradient of coul * review api.py code * feat(classical): Support more Coulomb potentials (#9) * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * imporve colvalent_map support Co-authored-by: Roy Kid <lijichen365@126.com> * feat(classical): add testcases for NoCutoff Coulomb potential and a large GAFF molecule * feat(classical): Support differentiable 1-4 scale * Devel (#9) * feat(classical): Support differentiable mscale & add test cases (#10) * Update PME code (#8) * get a preliminary result of point charge pme caclulation * correct gradient of coul * review api.py code * feat(classical): Support more Coulomb potentials (#9) * fix(classical): fix misusing variables * feat(classical): add a testcase for two LJ molecules * fix(classical): correct setting of LJ case * feat(classical): add a testcase for large molecule (including 1-4) interactions * feat(classical): Add support for reaction-field and no-cutoff in Coulomb potential * imporve colvalent_map support Co-authored-by: Roy Kid <lijichen365@126.com> * feat(classical): add testcases for NoCutoff Coulomb potential and a large GAFF molecule * feat(classical): Support differentiable 1-4 scale Co-authored-by: Roy Kid <lijichen365@126.com> * formate code; add example XML section to parseElement docstring Co-authored-by: Roy Kid <lijichen365@126.com> * feat(classical): add more GAFF2 test cases. * fix(classical): remove unnecessary lines Co-authored-by: Roy-Kid <42854324+Roy-Kid@users.noreply.github.com> Co-authored-by: Roy Kid <lijichen365@126.com> Co-authored-by: Roy-Kid <42854324+Roy-Kid@users.noreply.github.com> Co-authored-by: Roy Kid <lijichen365@126.com>
We propose to add the following features to DMFF:
The following generators are added to support related cards in OpenMM type XML forcefield.