CrystalInterfaceTrainingParameters

class CrystalInterfaceTrainingParameters(reference_configurations, rattle=None, sample_size=None, atomic_rattling_amplitudes=None, random_seed=None, optimize=None, optimize_geometry_parameters=None, surface_termination_0=None, surface_termination_1=None, plane_0=None, plane_1=None, buffer_zone=None, vacuum=None, max_number_of_atoms=None, displacement_vector=None, thickness_max=None, strain_method=None, shortest_surface_lattice_vector=None, longest_surface_lattice_vector=None, minimum_surface_lattice_vector_angle=None, max_surface_area=None, grid_density=None, strain_max=None, angle_min=None, angle_max=None, angle_delta=None, layer_tolerance0=None, layer_tolerance1=None, configurational_descriptor_cutoff_0=None, configurational_descriptor_cutoff_1=None, log_filename_prefix=None)

Class for storing parameters for generating a set of interface training configurations.

Parameters:
  • reference_configurations (Sequence of [BulkConfiguration]) – Two reference configurations to be used to generate the training set.

  • rattle (bool) – Switch to turn on rattling of the interfaces to generate more configurations.
    Default: False.

  • sample_size (int) – The number of training configurations to generate for each atomic rattling amplitude.
    Default: 5.

  • atomic_rattling_amplitudes (PhysicalQuantity of type length | sequence of PhysicalQuantity of type length) – The list of maximum random displacements of the atomic positions.
    Default: 0.1 * Angstrom.

  • random_seed (int) – The random seed used for generating the displacements.
    Default: Generated automatically.

  • optimize (bool | Calculator) – Switch to turn on optimization of interface configurations using a fast LCAO calculator with SingleZeta basis, KpointDensity(density_a=1.0*Angstrom, density_c=0.0*Angstrom) and NumericalAccuracyParameters(density_mesh_cutoff=60.0*Hartree). Alternatively a calculator object might be supplied to replace the default one.
    Default: False.

  • optimize_geometry_parameters (OptimizeGeometryParameters or None) – Parameters to be passed to a OptimizeGeometry object.
    Default: None.

  • surface_termination_0 (list of PeriodicTableElement) – List of elements considered for terminations of the left interface.
    Default: all elements.

  • surface_termination_1 (list of PeriodicTableElement) – List of elements considered for terminations of the left interface.
    Default: all elements.

  • plane_0 (list of lists(3)) – Planes given by the Miller indices h, k, and l to cleave the left bulk system.
    Default: all low index planes with maximum index 1.

  • plane_1 (list of lists(3)) – Planes given by the Miller indices h, k, and l to cleave the right bulk system.
    Default: all low index planes with maximum index 1.

  • buffer_zone (PhysicalQuantity of type length) – Added spacing between interfaces. If the structures are rattled, the buffer should include the rattling amplitude.
    Default: 0.0 * Angstrom.

  • vacuum (None | PhysicalQuantity of type length) – Vacuum to be added around the interface.
    Default: 0.0 * Angstrom.

  • max_number_of_atoms (int) – Maximum number of atoms allowed in one interface configuration.
    Default: No restriction.

  • displacement_vector (PhysicalQuantity of type fractional length | None) – This vector is added to the coordinates of the second surface configuration.
    Default: [0.25, 0.25, 0.0].

  • thickness_max (PhysicalQuantity of type length) – Maximum thickness of either material in the final interface. This value is overwritten in case it is smaller than the thickness of two layers.
    Default: 9.0 * Angstrom.

  • strain_method (StrainFirst | StrainSecond | StrainBoth) – Specifies which layer should be strained. If StrainFirst is given, then the first layer will be strained and the second layer will have no strain, while the opposite is true if StrainSecond is chosen. If StrainBoth is given, then each layer is strained to an intermediate lattice.

  • shortest_surface_lattice_vector (PhysicalQuantity of type length) – The minimum length of either surface vector.
    Default: 0*Angstrom.

  • longest_surface_lattice_vector (PhysicalQuantity of type length) – The maximum length of either surface vector.
    Default: 50*Angstrom.

  • minimum_surface_lattice_vector_angle (PhysicalQuantity of type angle) – The smallest allowed angle between the surface lattice vectors.

  • max_surface_area (PhysicalQuantity of type length**2) – The maximum surface area.
    Default: 200.0*Angstrom.

  • grid_density (2-tuple of type int) – The number of times that the a and b lattice vectors of the first configuration should be repeated during the lattice match search. Larger values consider more possible repetitions.

  • strain_max (float) – The largest engineering strain that will be considered a valid match. The default value of 1 corresponds to a 100% deformation.
    Default: 1.0.

  • angle_min (PhysicalQuantity of type angle) – The minimum rotational angle of the second lattice with respect to the first.
    Default: 0.0 * Degrees.

  • angle_max (PhysicalQuantity of type angle) – The maximum rotational angle of the second lattice with respect to the first.
    Default: 180.0 * Degrees.

  • angle_delta (PhysicalQuantity of type angle) – The resolution of the rotational angles of the second lattice. Smaller values lead to a higher resolution search of rotational values.
    Default: 4.0 * Degrees.

  • layer_tolerance0 (int) – Layers are detected by grouping atoms by their z-coordinates. Increase this tolerance to combine nearby off-lattice atoms into the same layer. Range: [-10, 4].
    Default: -10.

  • layer_tolerance1 (int) – Layers are detected by grouping atoms by their z-coordinates. Increase this tolerance to combine nearby off-lattice atoms into the same layer. Range: [-10, 4].
    Default: -10.

  • configurational_descriptor_cutoff_0 (float) – Cut-off value of the ConfigurationalDescriptorBased duplicate detection for material 0. For crystals a large number is recommended to agressively filter duplicates. Range: (0, 1).
    Default: 0.9.

  • configurational_descriptor_cutoff_1 (float) – Cut-off value of the ConfigurationalDescriptorBased duplicate detection for material 1. For crystals a large number is recommended to agressively filter duplicates. Range: (0, 1).
    Default: 0.9.

  • log_filename_prefix (str) – Filename prefix for the logging output of the tasks associated with this set.
    Default: Defined by the MomentTensorPotentialTraining object.

angleDelta()
Returns:

The resolution of the rotational angles of the second lattice.

Return type:

PhysicalQuantity of type angle

angleMax()
Returns:

The maximum rotational angle of the second lattice with respect to the first.

Return type:

PhysicalQuantity of type angle

angleMin()
Returns:

The minimum rotational angle of the second lattice with respect to the first.

Return type:

PhysicalQuantity of type angle

atomicRattlingAmplitudes()
Returns:

Maximum rattling intensity.

Return type:

PhysicalQuantity of type length | None

bufferZone()
Returns:

Added spacing between interfaces.

Return type:

PhysicalQuantity of type length | None

cleavePlanes0()
Returns:

Planes given by the Miller indices h, k, and l to cleave the left bulk system.

Return type:

list of lists(3).

cleavePlanes1()
Returns:

Planes given by the Miller indices h, k, and l to cleave the right bulk system.

Return type:

list of lists(3).

configuration0()
Returns:

A configuration for the left half of the interface.

Return type:

configuration_0: BulkConfiguration

configuration1()
Returns:

A configuration for the right half of the interface.

Return type:

configuration_1: BulkConfiguration

configurationalDescriptorCutoff0()
Returns:

ConfigurationalDescriptorBased cut-off value.

Return type:

float

configurationalDescriptorCutoff1()
Returns:

ConfigurationalDescriptorBased cut-off value.

Return type:

float

dataTag()
Returns:

The selection tag added to the data in the training set.

Return type:

str

displacementVector()
Returns:

This vector is added to the coordinates of the second surface configuration.

Return type:

PhysicalQuantity of type fractional length

extractConfigurations()

Function that extracts the configurations generated by CrystalInterfaceTrainingParameters. The configurations can be inspected before being passed as TrainningSet to the MomentTensorPotentialTraining.

Returns:

Generated configurations.

Return type:

ConfigurationDataContainer

gridDensity()
Returns:

The number of times that the a and b lattice vectors of the first configuration should be repeated during the lattice match search.

Return type:

2-tuple of type int

layerTolerance0()
Returns:

Layers are detected by grouping atoms by their z-coordinates.

Return type:

int

layerTolerance1()
Returns:

Layers are detected by grouping atoms by their z-coordinates.

Return type:

int

logFilenameIdentifier()
Returns:

Filename identifier for the logging output of the tasks associated with this set, or None if it hasn’t been set yet.

Return type:

str | None

logFilenamePrefix()
Returns:

Filename prefix for the logging output of the tasks associated with this set, or None if it is to be defined by the MomentTensorPotentialTraining object.

Return type:

str | LogToStdOut | None

longestSurfaceLatticeVector()
Returns:

The maximum length of either surface vector.

Return type:

PhysicalQuantity of type length

maxNumberOfAtoms()
Returns:

Maximum number of atoms allowed in one interface configuration.

Return type:

int

maxSurfaceArea()
Returns:

The maximum surface area.

Return type:

PhysicalQuantity of type length**2

minimumSurfaceLatticeVectorAngle()
Returns:

The smallest allowed angle between the surface lattice vectors.

Return type:

PhysicalQuantity of type angle

optimize()
Returns:

Switch to turn on optimization of interface configurations using the LCAO calculator.

Return type:

bool

optimizeGeometryParameters()
Returns:

The optimize geometry parameters.

Return type:

OptimizeGeometryParameters

randomSeed()
Returns:

The random seed used for generating the displacements, or None if it should be generated automatically.

Return type:

int | None

rattle()
Returns:

Switch to turn on rattling of the interfaces to generate more configurations.

Return type:

bool | None

referenceConfigurations()
Returns:

The list of reference configurations to be used to generate the training set.

Return type:

list(2) of [BulkConfiguration]

sampleSize()
Returns:

The number of training configurations for each combination of list parameters.

Return type:

int

shortestSurfaceLatticeVector()
Returns:

The minimum length of either surface vector.

Return type:

PhysicalQuantity of type length

strainMax()
Returns:

The largest engineering strain that will be considered a valid match.

Return type:

float

strainMethod()
Returns:

Specifies which layer should be strained.

Return type:

StrainFirst | StrainSecond | StrainBoth

surfaceTerminations0()
Returns:

List of elements considered for terminations of the left interface.

Return type:

list of [PeriodicTableElement]

surfaceTerminations1()
Returns:

List of elements considered for terminations of the right interface.

Return type:

list of [PeriodicTableElement]

thicknessMax()
Returns:

Maximum thickness of either material in the final interface.

Return type:

PhysicalQuantity of type length

uniqueString()

Return a unique string representing the state of the object.

vacuum()
Returns:

Vacuum to be added around the interface.

Return type:

PhysicalQuantity of type length | None

Usage Examples

Setup of a training set for a copper/iron interface using CrystalInterfaceTrainingParameters.

Note

The particular force-field used for optimization in below script is only for demonstration purposes and should be replaced by a higher quality method in actual training.

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

# Define elements
elements = [Copper]

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

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

# Set up lattice
lattice = BodyCenteredCubic(2.8665*Angstrom)

# Define elements
elements = [Iron]

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

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

# Define calculator for pre-optimization calculations.
potentialSet = EAM_CuFeNi_2009()
calculator_ff = TremoloXCalculator(parameters=potentialSet)

optimize_geometry_parameters = OptimizeGeometryParameters(
    max_forces=0.1*eV/Ang,
    max_steps=1000,
    max_step_length=0.2*Ang,
    constraints=[FixStrain(x=True, y=True, z=False)],
    trajectory_interval=1,
    optimizer_method=FIRE(),
    enable_optimization_stop_file=True,
    restart_strategy=NoRestart,
    trajectory_filename='interface-optimization-trajectory.hdf5',
)

reference_configurations = [bulk_configuration_copper, bulk_configuration_iron]

training_set = CrystalInterfaceTrainingParameters(
         reference_configurations,
         optimize=calculator_ff,
         optimize_geometry_parameters=optimize_geometry_parameters,
         rattle=True,
         sample_size=2,
         atomic_rattling_amplitudes=[0.3] * Angstrom,
         buffer_zone=0.3 * Angstrom,
         surface_termination_0=Copper,
         surface_termination_1=Iron,
         plane_0=[[1, 1, 1], [0, 1, 1], [0, 0, 1]],
         plane_1=[[0, 1, 1]],
         vacuum=10 * Angstrom,
         max_number_of_atoms=150,
         thickness_max=9*Angstrom,
         shortest_surface_lattice_vector=5 * Angstrom,
         longest_surface_lattice_vector=12 * Angstrom,
         minimum_surface_lattice_vector_angle=60 * Degrees,
         strain_max=0.06,
)

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
k_point_sampling = KpointDensity(
    density_a=5.0*Angstrom,
    )
numerical_accuracy_parameters = NumericalAccuracyParameters(
    density_mesh_cutoff=100.0*Hartree,
    k_point_sampling=k_point_sampling,
    occupation_method=MethfesselPaxton(0.2*eV, 1),
    )

iteration_control_parameters = IterationControlParameters(
    tolerance=5e-05,
    damping_factor=0.3,
    number_of_history_steps=12,
    max_steps=200,
    non_convergence_behavior=StopCalculation(),
    )

algorithm_parameters = AlgorithmParameters(
    scf_restart_step_length=0.3*Angstrom,
    )

calculator = LCAOCalculator(
    numerical_accuracy_parameters=numerical_accuracy_parameters,
    iteration_control_parameters=iteration_control_parameters,
    algorithm_parameters=algorithm_parameters,
    )

# Set up non-linear coefficients with optimization.
non_linear_coefficients_parameters = NonLinearCoefficientsParameters(
   perform_optimization=True,
   energy_only=False,
)

# Set up parameters to use in the MTP fitting.
fitting_parameters = MomentTensorPotentialFittingParameters(
   basis_size=1000,
   outer_cutoff_radii=4.5*Angstrom,
   mtp_filename='mtp_Cu-Fe_interface.mtp',
   non_linear_coefficients_parameters=non_linear_coefficients_parameters,
)

# Set up MTP training.
moment_tensor_potential_training = MomentTensorPotentialTraining(
    filename='mtp_study',
    object_id='training',
    training_sets=training_set,
    calculator=calculator,
    calculate_stress=True,
    fitting_parameters_list=fitting_parameters,
    train_test_split=0.8,
    random_seed=13345,
    number_of_processes_per_task=8,
    log_filename_prefix='fit_mtp_Cu-Fe_interface',
)
moment_tensor_potential_training.update()
nlprint(moment_tensor_potential_training)

# The MTP calculator can now be extracted from the MomentTensorPotentialTraining object.
mtp_calculator = moment_tensor_potential_training.momentTensorPotentialCalculators()[0]

interface-training-sets.py

Notes

The CrystalInterfaceTrainingParameters class can be used to generate training configurations by building interfaces from two crystalline bulk materials using the InterfaceBuilder. All parameters of the interface builder are available. For a specific type of interface, cleave planes and surface terminations can be individually selected for each material. Additionally, bulk configurations with two interfaces or slabs with just one interface can be created by adding vacuum. The former approach effectively doubles the interfaces to train on.

For the actual training data generation, a CrystalInterfaceTrainingParameters object needs to be passed into a MomentTensorPotentialTraining object.

It is recommended to pre-optimize the automatically generated interface configurations by specifying a fast calculator and a OptimizeGeometryParameters object. By default the LCAO method with a single zeta basis set is used.

To achieve a more broadly applicable training set, the generated interfaces can be randomly displaced to increase the number of configurations. The original configuration is always part of the set, sample_size determines the number of rattled configurations added. Alternatively the crystalTrainingRandomDisplacements protocol can be used with the trajectory of optimized configurations.

In order to speed up the following DFT reference calculations, a maximum thickness and number of atoms can be specified. This provides a very efficient way to generate training data for crystal materials without having to run long, expensive ab-initio MD simulations.