# -------------------------------------------------------------
# Bulk configuration
# -------------------------------------------------------------

# Set up lattice
lattice = FaceCenteredCubic(5.4306*Angstrom)

# Define elements
elements = [Silicon, Silicon]

# Define coordinates
fractional_coordinates = [[ 0.  ,  0.  ,  0.  ],
                          [ 0.25,  0.25,  0.25]]

# Set up configuration
bulk_configuration = BulkConfiguration(
    bravais_lattice=lattice,
    elements=elements,
    fractional_coordinates=fractional_coordinates
    )

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(7, 7, 7),
    density_mesh_cutoff=75.0*Hartree,
    )

calculator = LCAOCalculator(
    numerical_accuracy_parameters=numerical_accuracy_parameters,
    )

bulk_configuration.setCalculator(calculator)
nlprint(bulk_configuration)
bulk_configuration.update()

# -------------------------------------------------------------
# Local bandstructure
# -------------------------------------------------------------
directions_cartesian = [[0.0, 0.0, 1.0],
                        [1.0, 1.0, 0.0],
                        [1.0, 1.0, 1.0]]*Angstrom**-1

local_bandstructure = LocalBandstructure(
    configuration=bulk_configuration,
    directions_cartesian=directions_cartesian,
    kpoint_fractional=[0.5, 0.5, 0.5],
    bands_below_fermi_level=1,
    bands_above_fermi_level=0,
    stencil_order=5,
    delta=0.001*Angstrom**-1,
    points_per_segment=20
    )

nlprint(local_bandstructure)

# Evaluation of the local bandstructure parameters.
effective_mass, nonparabolicity_parameter = local_bandstructure.evaluate(
    spin=Spin.Up,
    band=0,
    direction=2
    )

eff_mass = effective_mass[0,0,0].inUnitsOf(electron_mass)
nonpara = nonparabolicity_parameter[0,0,0].inUnitsOf(eV**-1)

print('Effective mass: %.2f me' % (eff_mass))
print('Non-parabolicity parameter: %.4f 1/eV' % (nonpara))