CrystalPropertyValidation¶
- class CrystalPropertyValidation(configuration, calculator, calculate_reference_data=True, calculate_volume_energy_plot=True, calculate_elastic_constants=True, calculate_phonon_bandstructure=True, calculate_delta_test=True, optimize_geometry_parameters=None, log_filename_prefix=None, dynamical_matrix_filename=None, dynamical_matrix_repetitions=(5, 5, 5))¶
Class for validating calculator accuracy based on properties of crystalline materials.
- Parameters:
configuration (
BulkConfiguration
) – A bulk reference configuration with the reference calculator attached.calculator (Calculator) – The calculator that should be validated.
calculate_reference_data (bool) – If the reference data should be calculated.
calculate_volume_energy_plot (bool) – If the equation of state should be calculated and compared.
calculate_elastic_constants (bool) – If the elastic moduli should be calculated and compared.
calculate_phonon_bandstructure (bool) – If the phonon bandstructure should be calculated and compared.
calculate_delta_test (bool) – If the
DeltaTest
should be calculated. Can only be done if the parameter calculate_reference_data is also True.optimize_geometry_parameters (
OptimizeGeometryParameters
| None) – Parameters to used to optimize the geometry.log_filename_prefix (str) – Filename prefix for the logging output of the tasks associated with this analysis. Default: None.
dynamical_matrix_filename – The full or relative path to save the results for the dynamical matrix calculation. A suffix is added for the reference calculator and the calculator to be validated so that results can be saved to two separate files. See
nlsave()
. Default: None.dynamical_matrix_repetitions (
Automatic
| list of ints) – The number of repetitions of the system in the A, B, and C-directions given as a list of three positive integers, e.g.[3, 3, 3]
, orAutomatic
. Ifuse_wigner_seitz_scheme
is set toTrue
the only values allowed for repetition are[1, 1, 1]
orAutomatic
. Default: [5, 5, 5]
- calculator()¶
- Returns:
The calculator to be validated.
- Return type:
- deltaTest()¶
- Returns:
The result of the delta test.
- Return type:
float
- dynamicalMatrixRepetitions()¶
- Returns:
The number of repetitions of the system in the A, B, and C-directions given as a list of three positive integers.
- Return type:
list of ints
- elastic()¶
- Returns:
Elastic constant calculated by the test calculator.
- Return type:
- energy()¶
- Returns:
List of energies calculated for different volumes by the test calculator.
- Return type:
list
- metatext()¶
- Returns:
The metatext of the object or None if no metatext is present.
- Return type:
str | None
- nlprint(stream=None)¶
Print a string containing an ASCII table useful for plotting the AnalysisSpin object.
- Parameters:
stream (python stream) – The stream the table should be written to. Default:
NLPrintLogger()
- optimizeGeometryParameters()¶
- Returns:
The optimize geometry parameters.
- Return type:
- phononBandstructure()¶
- Returns:
The phonon bandstructure obtained with the test calculator.
- Return type:
- plotEnergyvsVolume()¶
Show a plot of the equation of state (energy vs. volume) curve calculated with relative and reference calculators.
- referenceConfiguration()¶
- Returns:
The configuration used with the reference calculator.
- Return type:
- referenceElastic()¶
- Returns:
Elastic constant calculated by the reference calculator.
- Return type:
- referenceEnergy()¶
- Returns:
List of energies calculated for different volumes by the reference calculator.
- Return type:
list
- referencePhononBandstructure()¶
- Returns:
The phonon bandstructure obtained with the reference calculator.
- Return type:
- referenceVolume()¶
- Returns:
List of unit cell volumes included in the reference calculation.
- Return type:
list
- setCalculator(calculator)¶
Set the calculator that should be tested against the reference calculator and calculate the properties.
- Parameters:
calculator (Calculator) – The calculator that should be validated.
- setMetatext(metatext)¶
Set a given metatext string on the object.
- Parameters:
metatext (str | None) – The metatext string that should be set. A value of “None” can be given to remove the current metatext.
- testConfiguration()¶
- Returns:
The configuration used with the test calculator.
- Return type:
- uniqueString()¶
Return a unique string representing the state of the object.
- volume()¶
- Returns:
List of unit cell volumes included in the validation calculation.
- Return type:
list
Usage Examples¶
Calculate different properties of crystalline silicon with a Tersoff potential and a Moment Tensor Potential, print the results, and save the object to a hdf5 file:
# 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
)
# Setting up the reference calculator.
# A cheap force-field calculator is used so that this example script
# does not take too long.
potentialSet = Tersoff_Si_1988()
reference_calculator = TremoloXCalculator(parameters=potentialSet)
bulk_configuration.setCalculator(reference_calculator)
# Setting up the calculator that should be validated against the reference calcultor.
potentialSet = MTP_Si_2019b()
calculator = TremoloXCalculator(parameters=potentialSet)
crystal_property_validation = CrystalPropertyValidation(
bulk_configuration,
calculator,
calculate_reference_data=True,
calculate_volume_energy_plot=True,
calculate_elastic_constants=True,
calculate_phonon_bandstructure=True,
calculate_delta_test=True,
optimize_geometry_parameters=None,
log_filename_prefix=None,
dynamical_matrix_filename='dynamical_matrix.hdf5',
dynamical_matrix_repetitions=(5, 5, 5),
)
nlsave('crystal_property_validation.hdf5', crystal_property_validation)
nlprint(crystal_property_validation)
crystal_property_validation.plotEnergyvsVolume()
si_crystal_property_validation.py
This example script shows how to read the output file. The script also shows how to use existing data to validate with a number of different calculators.
crystal_property_validation = nlread('crystal_property_validation.hdf5')[0]
potentialSet = QuantumATK_MTP_Si_SiO2_2022()
calculator1 = TremoloXCalculator(parameters=potentialSet)
potentialSet = StillingerWeber_SiOCF_2005()
calculator2 = TremoloXCalculator(parameters=potentialSet)
for calculator in [calculator1, calculator2]:
crystal_property_validation.setCalculator(calculator)
nlsave('crystal_property_validation.hdf5', crystal_property_validation)
Notes¶
Crystal properties, such as lattice parameters and the bulk modulus can be calculated using a reference calculator and compared to one or more other calculators that needed to be validated. To view these results use the nlprint method.
Before calculating the crystal properties of a given BulkConfiguration, the cell vectors are optimized using the OptimizeGeometry function with the reference and relative calculators. The optimization parameter can be provided using OptimizeGeometryParameters.
The PhononBandstructure can be visualized by selecting the output file in the Lab Floor of QuantumATK unpack using Unpack and opening it using the Phonon Bandstructure Analyzer.
The equation of state can be plotted using the plotEnergyvsVolume
method or by unpacking in
the Lab Floor.
Note
This class is only intended for validating with bulk configurations. It can not be used with molecules or surfaces.