Defining a new potential

109 views
Skip to first unread message

PaulH

unread,
Mar 10, 2021, 3:32:57 PM3/10/21
to hoomd-users

Hi,
I have two questions:

1. Could define a new potential that depends on distance in one axis
For instance, We have V = k (z-z0)^2, so that force F = -k z \hat{z}

2. Once we define a new potential how do we use this new potential?
Normally I'd do:
harmonic = md.bond.harmonic()
harmonic.bond_coeff.set('A', k=100, r0=1.0)
    

Thanks,
 
def harmonic(r, rmin, rmax, kappa, r0): V = 0.5 * kappa * (r-r0)**2; F = -kappa*(r-r0); return (V, F) btable = bond.table(width=1000) btable.bond_coeff.set('bond1', func=harmonic, rmin=0.2, rmax=5.0, coeff=dict(kappa=330, r0=0.84)) btable.bond_coeff.set('bond2', func=harmonic, rmin=0.2, rmax=5.0, coeff=dict(kappa=30, r0=1.0))                   

Joshua Anderson

unread,
Mar 11, 2021, 6:30:58 AM3/11/21
to hoomd...@googlegroups.com
Paul,

`V = k (z-z0)^2` would be an external potential. You can implement new external potentials in C++ and add a Python class to interface with it. You would use this new potential using the Python class you write.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
> --
> You received this message because you are subscribed to the Google Groups "hoomd-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/972acb0e-7fc8-46f5-afc9-69288e924afan%40googlegroups.com.

Michael Howard

unread,
Mar 11, 2021, 9:12:57 AM3/11/21
to hoomd-users
Hi Paul,

I have a plugin that will harmonically restrain particles to a plane. It is in this package that you can install alongside hoomd:


Specifically, here is the class you need:


To restrain all particles to a plane containing the point (0,0,z0) and normal in the +z direction (0,0,1) you would add:

azplugins.restrain.plane(group=hoomd.group.all(), point=(0,0,z0), normal=(0,0,1), k=10.0)

Note this potential uses the standard harmonic form u(d) = k/2 d^2, so you need to double the spring constant to get your potential. Also, there are a couple caveats about unwrapped vs. wrapped particle position, which are documented in the plugin.

Regards,
Mike

Paul Hanakata

unread,
Mar 11, 2021, 9:55:31 AM3/11/21
to hoomd...@googlegroups.com
Thanks for the explanation. Is there a short documentation detailing this?
How do I recompile HOOMD after adding a new potential to the source code?
Do I need to reinstall HOOMD?

Many thanks!



You received this message because you are subscribed to a topic in the Google Groups "hoomd-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hoomd-users/9f1uPrPaOE4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/F9C7CFB7-137A-4B97-96D9-8CA7C80EFFD3%40umich.edu.

Paul Hanakata

unread,
Mar 11, 2021, 9:56:39 AM3/11/21
to hoomd...@googlegroups.com
Hi Mike,

Thanks for sharing this plugin. I will give a try and email you if I have further questions.

antoni...@googlemail.com

unread,
Mar 12, 2021, 7:53:34 PM3/12/21
to hoomd-users
Dear Paul,

You can compile the plugin two different ways, as external or internal plugin, see detailed instructions here. If you choose the internal plugin method you will have to recompile hoomd, if you compile it as external plugin you would not.  Documentation for the feature Mike mentioned is here.  Let us know if you have any further questions or issues. 

Best,
Antonia

Reply all
Reply to author
Forward
0 new messages