# Load the monomers into memory
styrene = nlread('Styrene.hdf5', class_type=MoleculeConfiguration)[-1]
vinyl_chloride = nlread('Vinyl_Chloride.hdf5', class_type=MoleculeConfiguration)[-1]

# Define a phenyl endgroup
# Define elements
elements = [Carbon, Carbon, Carbon, Carbon, Carbon, Carbon, Hydrogen, Hydrogen,
            Hydrogen, Hydrogen, Hydrogen, Hydrogen]

# Define coordinates
cartesian_coordinates = [[ 0.            , -0.000000000011, -1.399795      ],
                         [ 0.            ,  1.212252999995, -0.699760000009],
                         [ 0.            ,  1.212253000005,  0.699759999991],
                         [ 0.            ,  0.000000000011,  1.399795      ],
                         [-0.            , -1.212252999995,  0.699760000009],
                         [-0.            , -1.212253000005, -0.699759999991],
                         [ 0.            , -0.000000000019, -2.500678      ],
                         [ 0.            ,  2.165670999991, -1.250363000016],
                         [ 0.            ,  2.165671000009,  1.250362999984],
                         [ 0.            ,  0.000000000019,  2.500678      ],
                         [-0.            , -2.165670999991,  1.250363000016],
                         [-0.            , -2.165671000009, -1.250362999984]]*Angstrom

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

# Add tags
phenyl.addTags('HEAD_CONNECT', [2])
phenyl.addTags('HEAD_GROUP_A', [8])
phenyl.addTags('TAIL_CONNECT', [2])
phenyl.addTags('TAIL_GROUP_A', [8])

# Add bonds
bonds = [[ 0,  1],
         [ 0,  5],
         [ 0,  6],
         [ 1,  2],
         [ 1,  7],
         [ 2,  3],
         [ 2,  8],
         [ 3,  4],
         [ 3,  9],
         [ 4,  5],
         [ 4, 10],
         [ 5, 11]]
phenyl.setBonds(bonds)

# Create the sequence made of 25% styrene and 75% vinyl chloride monomers randomly
# arranged.  Also cap the polymer with the phenyl group.
sequence = PolymerSequence(
    [styrene, vinyl_chloride],
    number_of_monomers=40,
    number_of_chains=20,
    monomer_ratios=[0.25, 0.75],
    omega_group=phenyl,
)
