md.angle¶
Overview
md.angle.harmonic 
Harmonic angle potential. 
md.angle.cosinesq 
Cosine squared angle potential. 
md.angle.table 
Tabulated angle potential. 
Details
Angle potentials.
Angles add forces between specified triplets of particles and are typically used to model chemical angles between two bonds.
By themselves, angles that have been specified in an initial configuration do nothing. Only when you specify an angle force (i.e. angle.harmonic), are forces actually calculated between the listed particles.

class
hoomd.md.angle.
coeff
¶ Define angle coefficients.
The coefficients for all angle force are specified using this class. Coefficients are specified per angle type.
There are two ways to set the coefficients for a particular angle potential. The first way is to save the angle potential in a variable and call
set()
directly. See below for an example of this.The second method is to build the coeff class first and then assign it to the angle potential. There are some advantages to this method in that you could specify a complicated set of angle potential coefficients in a separate python file and import it into your job script.
Example:
my_coeffs = hoomd.md.angle.coeff(); my_angle_force.angle_coeff.set('polymer', k=330.0, r=0.84) my_angle_force.angle_coeff.set('backbone', k=330.0, r=0.84)

set
(type, **coeffs)¶ Sets parameters for angle types.
Parameters:  type (str) – Type of angle (or a list of type names)
 coeffs – Named coefficients (see below for examples)
Calling
set()
results in one or more parameters being set for a angle type. Types are identified by name, and parameters are also added by name. Which parameters you need to specify depends on the angle potential you are setting these coefficients for, see the corresponding documentation.All possible angle types as defined in the simulation box must be specified before executing run(). You will receive an error if you fail to do so. It is not an error, however, to specify coefficients for angle types that do not exist in the simulation. This can be useful in defining a potential field for many different types of angles even when some simulations only include a subset.
Examples:
my_angle_force.angle_coeff.set('polymer', k=330.0, r0=0.84) my_angle_force.angle_coeff.set('backbone', k=1000.0, r0=1.0) my_angle_force.angle_coeff.set(['angleA','angleB'], k=100, r0=0.0)
Note
Single parameters can be updated. If both
k
andr0
have already been set for a particle type, then executingcoeff.set('polymer', r0=1.0)
will update the value ofr0
and leave the other parameters as they were previously set.


class
hoomd.md.angle.
cosinesq
¶ Cosine squared angle potential.
The command angle.cosinesq specifies a cosine squared potential energy between every triplet of particles with an angle specified between them.
\[V(\theta) = \frac{1}{2} k \left( \cos\theta  \cos\theta_0 \right)^2\]where \(\theta\) is the angle between the triplet of particles. This angle style is also known as g96, since they were used in the gromos96 force field. These are also the types of angles used with the coarsegrained MARTINI force field.
Coefficients:
 \(\theta_0\)  rest angle
t0
(in radians)  \(k\)  potential constant
k
(in units of energy)
Coefficients \(k\) and \(\theta_0\) must be set for each type of angle in the simulation using the method
angle_coeff.set()
. Note that the value of \(k\) for this angle potential is not comparable to the value of \(k\) for harmonic angles, as they have different units.Examples:
cosinesq = angle.cosinesq() cosinesq.angle_coeff.set('polymer', k=3.0, t0=0.7851) cosinesq.angle_coeff.set('backbone', k=100.0, t0=1.0)

disable
(log=False)¶ Disable the force.
Parameters: log (bool) – Set to True if you plan to continue logging the potential energy associated with this force. Examples:
force.disable() force.disable(log=True)
Executing the disable command will remove the force from the simulation. Any
hoomd.run()
command executed after disabling a force will not calculate or use the force during the simulation. A disabled force can be reenabled withenable()
.By setting log to True, the values of the force can be logged even though the forces are not applied in the simulation. For forces that use cutoff radii, setting log=True will cause the correct r_cut values to be used throughout the simulation, and therefore possibly drive the neighbor list size larger than it otherwise would be. If log is left False, the potential energy associated with this force will not be available for logging.

get_energy
(group)¶ Get the energy of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the energy for.Returns: The last computed energy for the members in the group. Examples:
g = group.all() energy = force.get_energy(g)

get_net_force
(group)¶ Get the force of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the force for.Returns: The last computed force for the members in the group. Examples
g = group.all() force = force.get_net_force(g)

get_net_virial
(group)¶ Get the virial of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the virial for.Returns: The last computed virial for the members in the group. Examples
g = group.all() virial = force.get_net_virial(g)
 \(\theta_0\)  rest angle

class
hoomd.md.angle.
harmonic
¶ Harmonic angle potential.
The command angle.harmonic specifies a harmonic potential energy between every triplet of particles with an angle specified between them.
\[V(\theta) = \frac{1}{2} k \left( \theta  \theta_0 \right)^2\]where \(\theta\) is the angle between the triplet of particles.
Coefficients:
 \(\theta_0\)  rest angle
t0
(in radians)  \(k\)  potential constant
k
(in units of energy/radians^2)
Coefficients \(k\) and \(\theta_0\) must be set for each type of angle in the simulation using the method
angle_coeff.set()
.Examples:
harmonic = angle.harmonic() harmonic.angle_coeff.set('polymer', k=3.0, t0=0.7851) harmonic.angle_coeff.set('backbone', k=100.0, t0=1.0)

disable
(log=False)¶ Disable the force.
Parameters: log (bool) – Set to True if you plan to continue logging the potential energy associated with this force. Examples:
force.disable() force.disable(log=True)
Executing the disable command will remove the force from the simulation. Any
hoomd.run()
command executed after disabling a force will not calculate or use the force during the simulation. A disabled force can be reenabled withenable()
.By setting log to True, the values of the force can be logged even though the forces are not applied in the simulation. For forces that use cutoff radii, setting log=True will cause the correct r_cut values to be used throughout the simulation, and therefore possibly drive the neighbor list size larger than it otherwise would be. If log is left False, the potential energy associated with this force will not be available for logging.

get_energy
(group)¶ Get the energy of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the energy for.Returns: The last computed energy for the members in the group. Examples:
g = group.all() energy = force.get_energy(g)

get_net_force
(group)¶ Get the force of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the force for.Returns: The last computed force for the members in the group. Examples
g = group.all() force = force.get_net_force(g)

get_net_virial
(group)¶ Get the virial of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the virial for.Returns: The last computed virial for the members in the group. Examples
g = group.all() virial = force.get_net_virial(g)
 \(\theta_0\)  rest angle

class
hoomd.md.angle.
table
(width, name=None)¶ Tabulated angle potential.
Parameters: table
specifies that a tabulated angle potential should be added to every bonded triple of particles in the simulation.The torque \(T\) is (in units of force * distance) and the potential \(V(\theta)\) is (in energy units):
\[\begin{split}T(\theta) = & T_{\mathrm{user}}(\theta) \\ V(\theta) = & V_{\mathrm{user}}(\theta)\end{split}\]where \(\theta\) is the angle from AB to BC in the triple.
\(T_{\mathrm{user}}(\theta)\) and \(V_{\mathrm{user}}(\theta)\) are evaluated on width grid points between \(0\) and \(\pi\). Values are interpolated linearly between grid points. For correctness, you must specify: \(T = \frac{\partial V}{\partial \theta}\)
Parameters:
 \(T_{\mathrm{user}}(\theta)\) and \(V_{\mathrm{user}}(\theta)\)  evaluated by func (see example)
 coefficients passed to func  coeff (see example)
The table width is set once when
table
is specified. There are two ways to specify the other parameters.Set table from a given function
When you have a functional form for T and F, you can enter that directly into python.
table
will evaluate the given function over width points between \(0\) and \(\pi\) and use the resulting values in the table:def harmonic(theta, kappa, theta_0): V = 0.5 * kappa * (thetatheta_0)**2; T = kappa*(thetatheta_0); return (V, T) btable = angle.table(width=1000) btable.angle_coeff.set('angle1', func=harmonic, coeff=dict(kappa=330, theta_0=0)) btable.angle_coeff.set('angle2', func=harmonic,coeff=dict(kappa=30, theta_0=0.1))
Set a table from a file
When you have no function for for T or F, or you otherwise have the data listed in a file,
table
can use the given values directly. You must first specify the number of rows in your tables when initializingtable
. Then useset_from_file()
to read the file:btable = angle.table(width=1000) btable.set_from_file('polymer', 'angle.dat')

disable
(log=False)¶ Disable the force.
Parameters: log (bool) – Set to True if you plan to continue logging the potential energy associated with this force. Examples:
force.disable() force.disable(log=True)
Executing the disable command will remove the force from the simulation. Any
hoomd.run()
command executed after disabling a force will not calculate or use the force during the simulation. A disabled force can be reenabled withenable()
.By setting log to True, the values of the force can be logged even though the forces are not applied in the simulation. For forces that use cutoff radii, setting log=True will cause the correct r_cut values to be used throughout the simulation, and therefore possibly drive the neighbor list size larger than it otherwise would be. If log is left False, the potential energy associated with this force will not be available for logging.

get_energy
(group)¶ Get the energy of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the energy for.Returns: The last computed energy for the members in the group. Examples:
g = group.all() energy = force.get_energy(g)

get_net_force
(group)¶ Get the force of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the force for.Returns: The last computed force for the members in the group. Examples
g = group.all() force = force.get_net_force(g)

get_net_virial
(group)¶ Get the virial of a particle group.
Parameters: group ( hoomd.group
) – The particle group to query the virial for.Returns: The last computed virial for the members in the group. Examples
g = group.all() virial = force.get_net_virial(g)

set_from_file
(anglename, filename)¶ Set a angle pair interaction from a file.
Parameters: The provided file specifies V and F at equally spaced theta values:
#t V T 0.0 2.0 3.0 1.5707 3.0 4.0 3.1414 2.0 3.0
Warning
The theta values are not used by the code. It is assumed that a table that has N rows will start at 0, end at \(\pi\) and that \(\delta \theta = \pi/(N1)\). The table is read directly into the grid points used to evaluate \(T_{\mathrm{user}}(\theta)\) and \(V_{\mathrm{user}}(\theta)\).