How to use constant force and langevin?

116 views
Skip to first unread message

Iby2go

unread,
Jul 7, 2020, 8:17:45 AM7/7/20
to hoomd-users
I am new to Hoomd and I need help.

I would like to add a constant force to my current simulation that is using langevin integrator.

I added constant using the following command and as discribed in the following link, that doesn't seem to be working:

hoomd.md.force.constant(fvec=[2.5,5.0,2.1],group=all);


class hoomd.md.force.constant(fx=None, fy=None, fz=None, fvec=None, tvec=None, group=None, callback=None)

Constant force.

Parameters:
  • fvec (tuple) – force vector (in force units)
  • tvec (tuple) – torque vector (in torque units)
  • fx (float) – x component of force, retained for backwards compatibility
  • fy (float) – y component of force, retained for backwards compatibility
  • fz (float) – z component of force, retained for backwards compatibility
  • group (hoomd.group) – Group for which the force will be set.
  • callback (callable) – A python callback invoked every time the forces are computed

constant specifies that a constant force should be added to every particle in the simulation or optionally to all particles in a group.

Note

Forces are kept constant during the simulation. If a callback should re-compute particle forces every time step, it needs to overwrite the old forces of all particles with new values.

Ibrahim Guiagoussou

unread,
Jul 7, 2020, 12:05:51 PM7/7/20
to hoomd...@googlegroups.com
I also did tried force.active class with differenec is diffusion coefficient value... I am expecting different value for the diffusion coefficient value when using or not using the constant force...
What am I doing wrong?

class hoomd.md.force.active(seed, group, f_lst=None, t_lst=None, orientation_link=True, orientation_reverse_link=False, rotation_diff=0, constraint=None)

The following are the two commandes I tries:

Case I: uning force.constant...
hoomd.context.initialize();
snapshot = hoomd.data.make_snapshot(N=numberParticles, box=hoomd.data.boxdim(L=sizeBox), particle_types=['A']);
snapshot.particles.position[:,:] = positions;
snapshot.particles.velocity[:,:] = velocities;
system = hoomd.init.read_snapshot(snapshot);
# specify Lennard-Jones interactions between particle pairs
nl = hoomd.md.nlist.cell();
lj = hoomd.md.pair.lj(r_cut=2.5, nlist=nl);
lj.pair_coeff.set('A', 'A', epsilon=epsilon, sigma=sigma);
all = hoomd.group.all();
groupA = hoomd.group.type('A');
hoomd.md.integrate.mode_standard(dt=dt);
hoomd.md.force.constant(fvec=(2.5,5.0,2.1),group=all);
langevinIntegrator = hoomd.md.integrate.langevin(group=all, kT=kT, seed=seed);
langevinIntegrator.set_gamma('A', gamma=gamma);
hoomd.md.force.constant(fvec=(2.5,5.0,2.5),group=all);
#  hoomd.md.force.active( seed=2011, group=groupA, f_lst=forces, orientation_link=False);
hoomd.analyze.callback(callback=pullSystemConfigurationData(system, particleData), period=periodAnalyze);
hoomd.dump.gsd(f"{filename}.gsd", period=periodGSD, group=all, overwrite=True);
# run 100,000 time steps
hoomd.run(runTime);

Case I: uning force.active... saame code as before and using force.active(...) instead of force.constant(...)
...
#  hoomd.md.force.constant(fvec=(2.5,5.0,2.1),group=all);
hoomd.md.force.active( seed=2011, group=groupA, f_lst=forces, orientation_link=False);
...

What am I doing wrong?
Your help is very appreciated...


--
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/f9eb5b84-529d-4639-8984-c87e4aa8bb2dn%40googlegroups.com.


--
Ibrahim Guiagoussou
(403) 774-8444 / (403) 690-6868
Calgary, Alberta, Canada

Joshua Anderson

unread,
Jul 9, 2020, 8:33:25 AM7/9/20
to hoomd...@googlegroups.com
Ibrahim,

I can only guess since you don’t say how you are measuring diffusion or what values you get vs what you expect. What is the peclet number for your active matter simulation? Maybe your active and constant forces are too small to really effect a change over the Langevin damping. I would suggest trying different force magnitudes and visualizing the simulation trajectory to see how the behavior changes. 

------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

On Jul 7, 2020, at 12:06 PM, Ibrahim Guiagoussou <ibrahim.g...@gmail.com> wrote:



Ibrahim Guiagoussou

unread,
Aug 2, 2020, 2:34:46 PM8/2/20
to hoomd...@googlegroups.com
The script is working fine...
I was mistaken when I use a simple linear registration slope and the following equations
MSD(t) = 2Dt=slope.t and MSD(t) = <x^2>(t)-<x>^2(t)
Where MSD is the mean-square-displacement, <...> the average overall particles at a step t...
Thanks for all


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/_gw1p5b4s2A/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/E937E413-EBF8-461E-90BF-8AD23DCA3875%40umich.edu.

Avishek Kumar

unread,
May 19, 2023, 9:03:41 PM5/19/23
to hoomd-users
Hi,

Will you please let me know why you have written force.constant twice in the HOOMD script?

Thanks,
Avishek Kumar
Reply all
Reply to author
Forward
0 new messages