mosdef-hub / gmso

Flexible storage of chemical topology for molecular simulation
https://gmso.mosdef.org
MIT License
52 stars 33 forks source link

Adding mixing rules and other LJ properties #65

Closed ahy3nz closed 2 years ago

ahy3nz commented 5 years ago

For the gsd writer #47 , one next step is to write out all FF parameters to an external python module that can be called from the actual hoomd run script. For example:

force_field.py

import hoomd
default_lj_coeffs = {'alpha': 1.0, 'r_on': 12, 'r_cut': 12}
lj_coeffs = hoomd.md.pair.coeff()
lj_coeffs.default_coeff = default_lj_coeffs
lj_coeffs.set('A', 'A', epsilon=10, sigma=5.0)

harmonic_bond_coeffs = hoomd.md.bond.coeff()
harmonic_bond_coeffs.set('A-A', r0=4, k=100)

run.py:

import hoomd
import hoomd.md

sim1 = hoomd.context.initialize("")
with sim1:
    import force_field
    system = hoomd.init.read_gsd('bonded.gsd')
    nl = hoomd.md.nlist.cell()
    nl.reset_exclusions(['1-3', '1-2'])
    lj_potential = hoomd.md.pair.lj(12, nl)
    lj_potential.pair_coeff= force_field.lj_coeffs
    lj_potential.pair_coeff.default_coeff = force_field.lj_coeffs.default_coeff

    harmonic_bonds = hoomd.md.bond.harmonic()
    harmonic_bonds.bond_coeff = force_field.harmonic_bond_coeffs
    harmonic_bonds.bond_coeff.default_coeff= force_field.harmonic_bond_coeffs.default_coeff
    hoomd.md.integrate.mode_standard(dt=0.01)
    all = hoomd.group.all()
    integrator = hoomd.md.integrate.nvt(all, 2.5, 3)
    hoomd.dump.gsd('traj.gsd', 10, all, overwrite=True)
    hoomd.run(1000)

To move further and write force_field.py from a Topology, we will need to account for these hoomd specifications (or smartly infer/guess):

mattwthompson commented 5 years ago

In the context of that PR I would rather have it merged as is, or after whatever fixes you want to the current behavior.

But more generally, this will be tricky because of how different engines treat things. In my view - because this is how LAMMPS and GROMACS does things - the cutoff isn't a property of the topology but rather a setting for the input file and therefore outside the scope of this project.

By the way, what are alpha/r_on?

ahy3nz commented 5 years ago

Okay i'll leave out anything specifying FF params in #47 - I could try to put in a GSD reader (or should this be a separate PR)?

https://hoomd-blue.readthedocs.io/en/stable/module-md-pair.html#hoomd.md.pair.lj For alpha/r_on

mattwthompson commented 5 years ago

Should be a separate PR if you want to take a stab at it. I'm in favor of smaller PRs that take small steps over huge PRs that try to do everything at once (which I am often guilty of doing)

daico007 commented 2 years ago

info included in forcefield class