# Define the methyl methacrylate monomer.
# First define elements.
elements = [Carbon, Carbon, Hydrogen, Hydrogen, Hydrogen, Carbon, Hydrogen,
            Hydrogen, Hydrogen, Carbon, Hydrogen, Hydrogen, Hydrogen, Carbon,
            Oxygen, Oxygen, Carbon, Hydrogen, Hydrogen, Hydrogen]

# Define coordinates
cartesian_coordinates = [[ 0.000053397617,  0.759772999835, -0.            ],
                         [-0.000053397617, -0.759772999835,  0.            ],
                         [-1.029486689503, -1.169152751252,  0.            ],
                         [ 0.514760310502, -1.169153624436, -0.89158       ],
                         [ 0.514760310502, -1.169153624436,  0.89158       ],
                         [-0.702972150254,  1.318819958684, -1.217534630654],
                         [-1.778994926992,  1.349871730145, -1.034368525823],
                         [-0.338426412209,  2.328764163503, -1.416490865706],
                         [-0.498848545074,  0.68155340126 , -2.080342189714],
                         [-0.702972150254,  1.318819958684,  1.217534630654],
                         [-1.779477850521,  1.34478390329 ,  1.036425819709],
                         [-0.494517798241,  0.684267886286,  2.08145298674 ],
                         [-0.34232383993 ,  2.330614899434,  1.413534093682],
                         [ 1.40596301868 ,  1.318867926842, -0.            ],
                         [ 1.84446749371 ,  2.344022687006, -0.473701649871],
                         [ 2.276658987984,  0.518045908871,  0.638886174971],
                         [ 3.418813357507,  0.987763274498,  0.630284279326],
                         [ 3.36418399788 ,  2.078158275911,  0.650119210394],
                         [ 3.96408273255 ,  0.634713205819,  1.508066389582],
                         [ 3.938029190653,  0.665721116071, -0.274655366275]]*Angstrom

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

# Add tags
# Note that the tail groups are on the carbons of the methyl groups, not hydrogens.
methyl_methacrylate.addTags('HEAD_CONNECT', [1])
methyl_methacrylate.addTags('HEAD_GROUP_A', [4])
methyl_methacrylate.addTags('TAIL_CONNECT', [0])
methyl_methacrylate.addTags('TAIL_GROUP_A', [5])
methyl_methacrylate.addTags('TAIL_GROUP_B', [9])

# Add bonds
bonds = [[ 0,  1],
         [ 0,  5],
         [ 0,  9],
         [ 0, 13],
         [ 1,  2],
         [ 1,  3],
         [ 1,  4],
         [ 5,  6],
         [ 5,  7],
         [ 5,  8],
         [ 9, 10],
         [ 9, 11],
         [ 9, 12],
         [13, 14],
         [13, 15],
         [15, 16],
         [16, 17],
         [16, 18],
         [16, 19]]
methyl_methacrylate.setBonds(bonds)

# Create the sequence with a tactic ratio of 0, giving an isotactic sequence.
sequence = PolymerSequence(
    [methyl_methacrylate],
    number_of_monomers=40,
    number_of_chains=20,
    tactic_ratio=0,
)
