polychrom.forcekits module

Forcekits (new in polychrom)

The goal of the forcekits is two-fold. First, sometimes communication between forces is required. Since explicit is better than implicit, according to The Zen of Python, we are trying to avoid communication between forces using hidden variables (as done in openmm-polymer), and make it explicit. Forcekits are the tool to implement groups of forces that go together, as to avoid hidden communication between forces. Second, some structures can be realized using many different forces: e.g. polymer chain connectivity can be done using harmonic bond force, FENE bonds, etc. Forcekits help avoid duplicating code, and allow swapping one force for another and keeping the topology/geometry of the system the same

The only forcekit that we have now implements polymer chain connectivity. It then explicitly adds exclusions for all the polymer bonds into the nonbonded force, without using hidden variables for communication between forces. It also allows using any bond force, any angle force, and any nonbonded force, allowing for easy swapping of one force for another without duplicating code.

polychrom.forcekits.polymer_chains(sim_object, chains=[(0, None, False)], bond_force_func=<function harmonic_bonds>, bond_force_kwargs={'bondLength': 1.0, 'bondWiggleDistance': 0.05}, angle_force_func=<function angle_force>, angle_force_kwargs={'k': 0.05}, nonbonded_force_func=<function polynomial_repulsive>, nonbonded_force_kwargs={'radiusMult': 1.0, 'trunc': 3.0}, except_bonds=True, extra_bonds=None, extra_triplets=None, override_checks=False)[source]

Adds harmonic bonds connecting polymer chains

Parameters
  • chains (list of tuples) – The list of chains in format [(start, end, isRing)]. The particle range should be semi-open, i.e. a chain (0,3,0) links the particles 0, 1 and 2. If bool(isRing) is True than the first and the last particles of the chain are linked into a ring. The default value links all particles of the system into one chain.

  • except_bonds (bool) – If True then do not calculate non-bonded forces between the particles connected by a bond. True by default.

  • extra_bonds (None or list) – [(i,j)] list of extra bonds. Same for extra_triplets.

  • override_checks (bool) – If True then do not check that all monomers are a member of exactly one chain. False by default. Note that overriding checks does not get automatically “passed on” to bond/angle force functions so you may need to specify override_checks=True in the respective kwargs as well.