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

# Define coordinates
coordinates = [[ -3.67767153e-08,  -5.21170217e-07,  -1.77696852e-05],
               [  6.30525881e-01,  -8.91103633e-01,   2.66535938e-02],
               [ -6.29878738e-01,   2.68953440e-02,   8.91606540e-01],
               [ -6.30920686e-01,  -2.70480029e-02,  -8.90758789e-01],
               [  6.30273980e-01,   8.91262502e-01,  -2.72895999e-02]] * Angstrom

# Set up configuration
methane = MoleculeConfiguration(
    elements,
    coordinates
)

# --------------------------------------------------------------------------
# H2O
# --------------------------------------------------------------------------
# Define elements
elements = [Oxygen, Hydrogen, Hydrogen]

# Define coordinates
coordinates = [[  0.0,        4.0,  0.0],
               [  0.76923955, 4.0, -0.59357141],
               [ -0.76923955, 4.0, -0.59357141]] * Angstrom

# Set up configuration
water = MoleculeConfiguration(
    elements,
    coordinates
)

# Create a list of molecules and their numbers
molecules = [
    (methane, 10),
    (water, 40)
]

# Define the volume in which the molecules should be packed
u1, u2, u3 = numpy.diag([40.0] * 3) * Angstrom
cell = UnitCell(u1, u2, u3)

# Set the size of the buffer region
buffer_size = 2.0 * Angstrom

# Set Packmol parameters
tolerance = 2.0 * Angstrom
maximum_loops = 30

# Run the Packmol script to generate the packed configuration
packed_configuration, packing_successful, packmol_message = runPackmol(
    molecules,
    cell,
    tolerance,
    buffer_size,
    maximum_loops,
)

print(f'Packing successful: {packing_successful}')
print(f'Packmol message: {packmol_message}')
print(f'Returned configuration: {packed_configuration}')
