Some questions about running MC simulations using hpmc.pair.user.CPPPotential

Skip to first unread message


Apr 28, 2023, 12:33:11 PM4/28/23
to hoomd-users

I'm trying to customize the system in this tutorial for my purposes. I have a few questions regarding this:

1- Is the C++ code passed into hoomd as a python string optimized in the background? Or should I write this code as though I'm writing the most optimum version of the code? For instance, instead of evaluating cos(delta) every time patch orientations are checked, one could define 

const float cos_delta 

directly and use that. Also, one could first check if particle-particle distance is correct, and then proceed to calculate orientations. Should I worry about these things?

2- I would like to define two different sets of patches for two different types of particles. As far as I understand, I have to define mc.pair_potential in one go, right? I can't define them separately and then set particles of type 'A' to one type of potential, and type 'B' to another type, right? Would have to use "unsigned int type_i" to treat different types of particles in one go?

3- Is there an example for how to set up a box updater to run an NPT simulation in v3.x? 


Brandon Butler

May 1, 2023, 10:27:43 AM5/1/23

Hey Irem,

1. There is no optimization other than what the compiler provides for JIT code.

2. Yes you need to define the entire potential including type differences in the single function body.

3. The box updater is not for NPT simulations. In MC use the hoomd.hpmc.update.BoxMC to run NPT or the in MD for the NPT ensemble.



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
To view this discussion on the web visit
Brandon Butler
MolSSI Fellow
PhD Candidate, Chemical Engineering and Scientific Computing | Glotzer Lab, University of Michigan
Reply all
Reply to author
0 new messages