# Define a configuration of silicon carbide 4H.
lattice = Hexagonal(3.08051*Angstrom, 10.0848*Angstrom)

elements = [Carbon, Carbon, Silicon, Silicon, Carbon, Carbon, Silicon, Silicon]

fractional_coordinates = [[ 0.25          ,  0.25          ,  0.719485      ],
                          [ 0.25          ,  0.25          ,  0.219485      ],
                          [ 0.25          ,  0.25          ,  0.531645      ],
                          [ 0.25          ,  0.25          ,  0.031645      ],
                          [ 0.916666666667,  0.583333333333,  0.968355      ],
                          [ 0.583333333333,  0.916666666667,  0.468355      ],
                          [ 0.916666666667,  0.583333333333,  0.781465      ],
                          [ 0.583333333333,  0.916666666667,  0.281465      ]]

silicon_carbide = BulkConfiguration(
    bravais_lattice=lattice,
    elements=elements,
    fractional_coordinates=fractional_coordinates
)

# Create the TremoloX potential set
potential_set = TremoloXPotentialSet(name='SiC MTP Potential')

# Add the silicon particle type to the potential set
potential_set.addParticleType(ParticleType(
    symbol='Si',
    mass=28.0855*atomic_mass_unit,
    charge=None,
    atomicNumber=14,
))

# Add the carbon particle type to the potential set
potential_set.addParticleType(ParticleType(
    symbol='C',
    mass=12.0107*atomic_mass_unit,
    charge=None,
    atomicNumber=6,
))

# Add the MTP potential parameters contained in the SiC_MTP_Parameters.mtp file.
mtp_potential = MTPPotential(
    file='SiC_MTP_Parameters.mtp',
    suppress_intercept=False,
    group_name='',
)
potential_set.addPotential(mtp_potential)

# Create the Forcefield calculator and add it to the configuration.
calculator = TremoloXCalculator(parameters=potential_set)
silicon_carbide.setCalculator(calculator)
