FixCenterOfMass

class FixCenterOfMass(fix_cartesian_direction=None)

This constraint fixes the center-of-mass of the system in a MolecularDynamics() simulation.

Parameters:

fix_cartesian_direction (list(3) of bools) – Flags to apply the position constraints of this group of atoms only to the selected certain cartesian directions.
Default: [True, True, True]

frozenDegreesOfFreedom(local_atoms=None)
Parameters:

local_atoms (list of int | None) – The group of atoms from which the frozen degrees of freedom should be calculated, e.g. a thermalized group of atoms.
Default: All atoms.

Returns:

The number of degrees of freedom that are frozen by the constraints.

Return type:

int

uniqueString()

Return a unique string representing the state of the object.

Usage Examples

Run an MD simulation of a decane molecule with the center-of-mass of the molecule fixed.

# Define elements
elements = [Hydrogen, Carbon, Hydrogen, Hydrogen, Carbon, Hydrogen, Hydrogen,
            Carbon, Hydrogen, Hydrogen, Carbon, Hydrogen, Hydrogen, Carbon,
            Hydrogen, Hydrogen, Carbon, Hydrogen, Hydrogen, Carbon, Hydrogen,
            Hydrogen, Carbon, Hydrogen, Hydrogen, Carbon, Hydrogen, Hydrogen,
            Carbon, Hydrogen, Hydrogen, Hydrogen]

# Define coordinates
cartesian_coordinates = [[ 2.949218676646,  0.371893089344, -5.977841255567],
                         [ 2.0915751053  ,  0.325878896596, -5.255719576195],
                         [ 1.450283574002,  1.214213807408, -5.492967455154],
                         [ 1.451118166918, -0.526603584715, -5.601873618684],
                         [ 1.822966280268,  0.248365819288, -4.006203357873],
                         [ 2.452472374579, -0.657496389029, -3.794106921656],
                         [ 2.454588788042,  1.119399272419, -3.683412523973],
                         [ 1.11002977129 ,  0.182932682631, -2.941890060606],
                         [ 0.514074186602,  1.11809089051 , -3.137372769128],
                         [ 0.511494198217, -0.719003710087, -3.252072509036],
                         [ 0.842624096707,  0.10516011283 , -1.690762149425],
                         [ 1.491345296758, -0.78355395752 , -1.471599662887],
                         [ 1.494967653129,  0.95670152228 , -1.362236499313],
                         [ 0.132859680402,  0.039658959846, -0.626048074315],
                         [-0.482794358104,  0.9589027956  , -0.827177016793],
                         [-0.487026068393, -0.844146311539, -0.940982573926],
                         [-0.132380369437, -0.038781999777,  0.626344899449],
                         [ 0.483113914589, -0.95814352964 ,  0.827391526337],
                         [ 0.487761818334,  0.84474606991 ,  0.941323554846],
                         [-0.842177289594, -0.104271778821,  1.690893077731],
                         [-1.490395532317,  0.784892174015,  1.472217773116],
                         [-1.494937459238, -0.955400183967,  1.362016363174],
                         [-1.109932511965, -0.182939754747,  2.942043484298],
                         [-0.515413707857, -1.119341268799,  3.136533689731],
                         [-0.509862540826,  0.71770586625 ,  3.253250779134],
                         [-1.823114817881, -0.248387001392,  4.00605213455 ],
                         [-2.451181382366,  0.658629838415,  3.794745029733],
                         [-2.456019886489, -1.118078262521,  3.682204447835],
                         [-2.092097378568, -0.326797885494,  5.255445507069],
                         [-1.454808166348, -1.218140992161,  5.492314817703],
                         [-1.448149189819,  0.522735169126,  5.602345190585],
                         [-2.95020692258 , -0.368818356258,  5.97713874924 ]]*Angstrom

# Set up configuration
molecule_configuration = MoleculeConfiguration(
    elements=elements,
    cartesian_coordinates=cartesian_coordinates
    )

potentialSet = Tersoff_CH_2010()
calculator = TremoloXCalculator(parameters=potentialSet)

molecule_configuration.setCalculator(calculator)
molecule_configuration.update()

initial_velocity = MaxwellBoltzmannDistribution(
    temperature=300.0*Kelvin,
    remove_center_of_mass_momentum=False
)

method = Langevin(
    time_step=1*femtoSecond,
    reservoir_temperature=300*Kelvin,
    friction=0.01*femtoSecond**-1,
    initial_velocity=initial_velocity,
    heating_rate=0*Kelvin/picoSecond,
)

# Run MD with FixCenterOfMass constraint.
md_trajectory = MolecularDynamics(
    molecule_configuration,
    constraints=[FixCenterOfMass()],
    trajectory_filename='decane_fix_center_of_mass_md.nc',
    steps=500,
    log_interval=10,
    method=method
)

molecule_configuration = md_trajectory.lastImage()

Notes

  • FixCenterOfMass can be used in MolecularDynamics simulations to constrain the center-of-mass of the configuration.

  • In principle, it is sufficient to set remove_center_of_mass_momentum=False in the initial velocity object (e.g. MaxwellBoltzmannDistribution), to achieve this. Sometimes, however, numerical inaccuracies in the force calculation (e.g when using Ewald summation techniques, as in CoulombSPME) can give rise to a finite force on the center-of-mass, resulting in an unwanted drift of the system. In this case it may be convenient to apply a FixCenterOfMass constraint, to remove this effect.

  • When using the Langevin integrator, the stochastic force will cause a diffusion of the center-of-mass vector, which can be avoided by using a FixCenterOfMass constraint.

  • With the fix_cartesian_direction parameter you can fix individual cartesian components of the center-of-mass-vector.

  • FixCenterOfMass constraints cannot be used together with FixAtomConstraints in the same MD simulation.