PolymerMonteCarloBuilder

class PolymerMonteCarloBuilder(polymer_sequence, density=None, host_configuration=None, random_seed=None, backbone_angle=None, monte_carlo_temperature=None, angle_sampling_points=None, included_molecules=None, self_avoiding=None, rotate_sidechains=None, repack_molecules=None, local_interacting_monomers=None, monte_carlo_steps_per_monomer=None, potential_builder=None)

Create a PolymerMonteCarloBuilder object, which is used to create polymer melt structures. Polymer chains of specified sequences are created with Monte Carlo randomized torsions.

Parameters:
  • polymer_sequence (PolymerSequence | list) – The polymer sequence. Can be a single sequence or a list of sequences, in which case a polymer blend of the given sequences would be generated.

  • density (PhysicalQuantity of type mass / volume | None) – Target density for the final polymer melt. Must be None if a host configuration is given.

  • host_configuration (BulkConfiguration | None) – The bulk configuration in which the chains are placed. Typically an empty configuration with the desired cell size, but it can also contain other molecules or particles. Must be None if a density value is given.

  • random_seed (int | None) – Seed for the random number generator.

  • backbone_angle (PhysicalQuantity of type angle | None | RandomAngle) – Set the backbone torsions to this angle. None means that the angles are sampled based on their torsion energy. RandomAngle sets the torsions randomly

  • monte_carlo_temperature (PhysicalQuantity of type temperature) – The temperature at which the backbone torsion angles are sampled.
    Default: 300 K.

  • angle_sampling_points (int) – The number of points that are used to map sample the backbone torsion energies.
    Default: 20

  • included_molecules (List of tuples of MoleculeConfiguration and int.) – List of tuples containing molecular configurations and numbers of each molecule to be included in the melt
    Default: None

  • self_avoiding (bool) – Whether or not the polymer is initially built to avoid overlapping itself.
    Default: True.

  • rotate_sidechains (bool) – Whether or not the torsions on the sidechains are randomized.
    Default: True.

  • repack_molecules (bool) – Whether or not the polymer chains are repacked with the Monte Carlo density algorithm.
    Default: True if a host configuration is included, False otherwise.

  • local_interacting_monomers (int) – The number of local monomers left and right to the central monomer, that are included in the Monte Carlo energy calculation.
    Default: 3

  • monte_carlo_steps_per_monomer (int) – Sets the number of additional Monte Carlo torsion randomization steps that are carried out based on the number of monomers for the chain
    Default: 0

  • potential_builder (DreidingPotentialBuilder | OPLSPotentialBuilder | UFFPotentialBuilder) – A potential builder object that creates the potential used in setting the torsions of the chains.
    Default: DreidingPotentialBuilder

buildPolymerConfiguration(attach_calculator=True)

Run the building process.

Parameters:

attach_calculator (bool) – A flag to tell if the full calculator should be attached to the configuration.

Returns:

The final configuration containing the polymer melt.

Return type:

BulkConfiguration

monomerList(sequence_index)

Returns the list of monomers in the given polymer sequence.

Parameters:

sequence_index (int) – The sequence index for the sequence that the monomers are from.

Returns:

The list of monomers.

Return type:

list

previewConfiguration()

Generates an unoptimized preview configuration that can be used in the Workflow Builder or to set up a force field.

Returns:

The preview configuration containing the same chemical composition as the final polymer.

Return type:

BulkConfiguration

Usage Examples

Create a configuration of a blend of poly(vinyl chloride) and poly(methyl methacrylate) using the OPLS-AA potential.


# ---------------------------------------------
# Monomer Molecule 1
# ---------------------------------------------

pvc_monomer = nlread('PVC_Monomer.hdf5')[-1]
pmma_monomer = nlread('PMMA_Monomer.hdf5')[-1]

# Create the polymer sequence object
polymer_sequence_pvc = PolymerSequence(
    monomer_configurations=[pvc_monomer],
    number_of_monomers=20,
    number_of_chains=10,
    tactic_ratio=0.5,
)

# Create the polymer sequence object
polymer_sequence_pmma = PolymerSequence(
    monomer_configurations=[pmma_monomer],
    number_of_monomers=20,
    number_of_chains=10,
    tactic_ratio=0.5,
)

# -------------------------------------------------------------
# Polymer Monte Carlo Builder
# -------------------------------------------------------------
potential_builder = OPLSPotentialBuilder(
    include_electrostatic=False
)

polymer_builder = PolymerMonteCarloBuilder(
    polymer_sequence=[polymer_sequence_pvc, polymer_sequence_pmma],
    density=1.3000*gram/cm**3,
    monte_carlo_temperature=300.0*Kelvin,
    angle_sampling_points=20,
    repack_molecules=False,
    potential_builder=potential_builder
)
bulk_configuration = polymer_builder.buildPolymerConfiguration()
nlsave('PVC_PMMA_Polymer.hdf5', bulk_configuration)

# -------------------------------------------------------------
# Force Capped Equilibration
# -------------------------------------------------------------
equilibration_method = ForceCappedEquilibration(
    temperature=300.00*Kelvin,
    md_steps_per_force_capped_simulation=40000,
    md_time_step=0.50*fs,
    force_capped_simulations=4,
    starting_factor=1.040,
    ending_factor=0.800,
)
bulk_configuration = equilibration_method.runEquilibration(bulk_configuration)
nlsave('PVC_PMMA_Polymer.hdf5', bulk_configuration)

Polymer_Blend_Example.py PVC_Monomer.hdf5 PMMA_Monomer.hdf5

Create an aluminum and teflon metal/polymer interface using the DREIDING potential.

# -------------------------------------------------------------
# Configurations
# -------------------------------------------------------------
surface_slab = nlread('Aluminum_Slab.hdf5')[-1]
teflon_monomer = nlread('Teflon_Monomer.hdf5')[-1]

# -------------------------------------------------------------
# Teflon Polymer Sequence
# -------------------------------------------------------------
polymer_sequence = PolymerSequence(
    monomer_configurations=[teflon_monomer],
    number_of_monomers=20,
    number_of_chains=9,
    tactic_ratio=0.5,
)

# -------------------------------------------------------------
# Polymer Monte Carlo Builder
# -------------------------------------------------------------
polymer_builder = PolymerMonteCarloBuilder(
    polymer_sequence=polymer_sequence,
    host_configuration=surface_slab,
    monte_carlo_temperature=300.0*Kelvin,
    angle_sampling_points=20,
    repack_molecules=True,
)
bulk_configuration = polymer_builder.buildPolymerConfiguration()
nlsave('Teflon_Aluminum_Interface.hdf5', bulk_configuration)

# -------------------------------------------------------------
# Force Capped Equilibration
# -------------------------------------------------------------
equilibration_method = ForceCappedEquilibration(
    temperature=300.00*Kelvin,
    md_steps_per_force_capped_simulation=40000,
    md_time_step=0.50*fs,
    force_capped_simulations=4,
    starting_factor=1.040,
    ending_factor=0.800,
    fixed_indices=bulk_configuration.indicesFromTags('HOST_CONFIGURATION'),
)
bulk_configuration = equilibration_method.runEquilibration(bulk_configuration)
nlsave('Teflon_Aluminum_Interface.hdf5', bulk_configuration)

Polymer_Surface_Interface_Example.py Aluminum_Slab.hdf5 Teflon_Monomer.hdf5

Notes

The PolymerMonteCarloBuilder class enables the generation of different types of polymer configurations. Structures such as polymer melts and blends, polymer/solid interfaces and polymers with included molecules can be built.

To create a configuration containing polymers, it is first necessary to create a PolymerSequence object for each type of polymer chain in the configuration. These define the types of polymers constructed by the PolymerMonteCarloBuilder. The polymers defined by the PolymerSequence can contain some randomness, so each chain is not always chemically identical. Any number of polymer sequences can be defined, allowing for the creation of different types of polymer blends.

Once the polymers in the configuration are defined, an instance of the PolymerMonteCarloBuilder is created. The constructor for this class contains a number of arguments that controls how the polymer system is to be built. One set of arguments determines the bulk cell and the components placed within the polymer configuration. in addition to the polymers defined by the list of PolymerSequence objects the polymer configurations can optionally contain a host configuration and included molecules. These are specified with the arguments host configuration and included_molecules respectively. The host_configuration takes a BulkConfiguration, and is typically used to create polymer/surface interfaces or polymers containing nanoparticles. The argument included_molecules takes a list of tuples containing a molecule configuration and the number of that molecule to be included in the polymer matrix. This can be used to add plasticizers or other molecules dissolved within the polymer.

When building the polymer system, if a host configuration not is provided then the size of the polymer bulk is determined by the polymer density. This is specified with the density argument. Here a cubic translation cell is constructed such that the final density of the polymer configuration matches the specified density. If a host configuration is given then the specified polymers and included molecules are placed directly within the host configuration. If a pure polymer configuration in a specific translation cell shape is desired, this can be created by giving an empty configuration as the host configuration. When using host configurations it is often necessary to include a repacking step. This can be done by setting the repack_molecules argument to True. This uses the RepackMoleculesMonteCarlo class to repack the polymer molecules so as to even out the density within the simulation cell[1][2]. This has the general effect of taking polymers out of surfaces or other solid structures where they may have been inserted, and placing them within the empty space in the host configuration. This step can also be added for configurations without an initial host.

There are also a number of options that control how individual polymer chains are built. By default the PolymerMonteCarloBuilder constructs polymers with randomized torsion angles. For each torsion angle several values are trialled and one is selected based on a Boltzmann weighting of the energy of each torsion angle. To prevent the ends of the polymer chain from attracting each other, when calculating the energy only a small number of monomers either side of the monomer being modified are included in the non-bonding calculation[3]. The number of monomers considered can be set with the argument local_interacting_monomers.

In the Monte Carlo process which modifies the torsion angles, the argument monte_carlo_temperature sets the temperature to be used for Boltzmann weighting each torsion. This determines how important changes in energy are in selecting a torsion angle. The number of torsion angles trialled for each bond is set with the argument angle_sampling_points. Non-bonding interactions can be ignored in calculating the energy of each torsion angle using the argument self_avoiding. If this is set to False, non-bonding interactions are ignored while valence bonding terms, including the bond torsion potential, are still included. The randomization of side-chain torsions, that is torsions not along the backbone of the polymer, is specified with the rotate_sidechains argument. This can be important in cases where polymers contain bulky and/or non-conjugated side groups. The Monte Carlo angle randomization can also be turned off completely using the backbone_angle argument. Giving an angle to this argument causes each polymer chain to be built with that torsion angle along the backbone. This can be used to create straight linear polymer chains. The torsion angles can also be uniformly randomized by passing the NLFlag RandomAngle to this argument.

The potential used to determine the torsional and non-bonded energies along each polymer chain can also be specified using the argument potential_builder. This argument takes an instance of one of the potential builder classes. The type of builder determines which potential is used. By default the DreidingPotentialBuilder is used, but it is also possible to use the OPLSPotentialBuilder or UFFPotentialBuilder classes. In general, due to the difficulty of correctly estimating electrostatic interactions in highly distorted structures, electrostatic interactions are ignored by both the PolymerMonteCarloBuilder class and also the ForceCappedEquilibration class. Moreover, it is recommended that potential builders should have electrostatic interactions explicitly excluded with the argument include_electrostatic set to False. This is to avoid calculating the QEqAtomicCharges (e.g. used within in the :class:` ~.DreidingPotentialBuilder` or UFFPotentialBuilder) on preliminary configurations with unfavorable close atom contacts, which may cause problems in some cases.

When using the Monte Carlo procedure to set the torsions for the polymer chain, the torsions are first adjusted for each monomer sequentially along the chain. After this initial randomization it is possible to perform additional Monte Carlo torsion moves on the torsions for each monomer. In this second cycle the ordering of the monomers is selected at random. This second cycle is enabled with the argument monte_carlo_steps_per_monomer. This takes an integer which represents the number of additional torsion randomization steps performed per monomer. This allows for longer polymer chains to have a number of Monte Carlo torsion steps in accordance with its length. Setting this parameter to either None or 0 skips these additional Monte Carlo torsion steps.

To aid in the analysis of polymer structures generated with the PolymerMonteCarloBuilder, tags describing different parts of the configuration are added. Each polymer molecule is tagged with the label POLYMER_MOLECULE_#, where # represents and index starting from zero. Included molecules are labeled with tag INCLUDED_MOLECULE_# where # is a counter of the types of molecules included. The label HOST_CONFIGURATION is added to atoms from an initial host configuration used as the starting point for the configuration. In addition to these components of the configuration the ends of each polymer chain, defined as the head and tail atoms of the monomers at the end of the chains, are labeled with the tags HEAD_CONNECT and TAIL_CONNECT. These polymer tags and end tags are used in some types of polymer structural analysis.

Once the PolymerMonteCarloBuilder class has been created, the polymer system can be built using the buildPolymerConfiguration() function. This returns a BulkConfiguration containing the polymer chains placed somewhat randomly in the cell. Due to the randomized placement atom overlaps may be present in the returned structure. These can be resolved by pre-equilibrating the structure using the ForceCappedEquilibration class. The calculator used to determine the torsional energies can also be attached to the returned configuration using the argument attach_calculator. As building large configurations can be time consuming, it is also possible to rapidly create a non-randomized preview configuration. This can be useful in providing a template for creating calculators with various potentials. The preview configuration is returned by the function previewConfiguration(). The single monomers defined in each polymer sequence can be returned with the function monomerList().