BasisSetOptimizer

class BasisSetOptimizer(bulk_configuration, kpoint_sampling=None, orbitals_per_shell_map=None, radial_cutoff_radius_map=None, confinement_start_radius_map=None, elements=None, energy_cutoff=None, confinement_strength=None, tolerance=None, max_number_of_iterations=None)

Class that know how to optimize a subset of a complete basis set w.r.t. a PlaneWave calculation.

Parameters:
  • bulk_configuration (BulkConfiguration) – A bulk configuration with an updated PlaneWave calculator attached.

  • kpoint_sampling (KpointDensity | MonkhorstPackGrid) – The k-point sampling to use for the optimization.

  • orbitals_per_shell_map (dict | list) – A map of type {element : [n0, n1, n2, n3]} where n0, n1, are the number of orbitals with angumar momentum 0, 1, 2,… to be used for the “complete basis set”. If a list of numbers is provided, that will be applied to all elements in the optimization.
    Default: [5, 5, 4, 3] applied to all elements.

  • radial_cutoff_radius_map (dict of floats) – For every element, this defines the radius at which the radial function grid stops.

  • confinement_start_radius_map (dict of floats) – For every element, this defines the radius at which the confining potential starts.

  • elements (list of strings) – The elements for which to optimize.

  • energy_cutoff (PhysicalQuantity of type energy.) – The energy cutoff decides how many plane-wave bands will be included when optimizating the basis set.

  • confinement_strength (Physical Quantitity of type energy.) – The strenght of the confining potential.

  • tolerance (float) – The tolerance determines the value of the spilling for each band at which the basis set is deemed converged.

  • max_number_of_iterations (int) – In the conjugate gradient optimizer for the basis set, the max number of iterations can be set. Beyond this it stops even if it isn’t converged.

optimize(spilling_criterion, size_criterion_map, print_spilling_per_band=False)

Run the basis set optimization.

Parameters:
  • spilling_criterion (float) – Tolerance for when to stop the optimization. When the maximum spilling is below the spilling criterion, the optimization will stop and return the smallest basis set fulfilling this criterion.

  • size_criterion_map (dict of type {element: int}) – A map of elements and maximum allowed basis set size.

  • print_spilling_per_band (bool) – Boolean controlling if band resolved spilling should be printed.
    Default: False

Returns:

List of optimized basis set for each element.

Return type:

list of BasisSet

optimizeForOrbitalConfiguration(subspace_sizes_map)

Optimize the basis set for a given ‘orbital configuration’, which is the number of orbitals you want in each shell for each element type.

Parameters:

subspace_sizes_map (dict of list of floats) – For every element type, a list containing the number of functions you want in the basis set for each angular momemntum channel

printCompleteSpilling()

Outputs the spilling of the complete basis set compared to the plane-wave calculation for the energy cutoff specified.

uniqueString()

Return a unique string representing the state of the object.

Usage Examples

The BasisSetOptimizer class is used to optimize the basis set for a given configuration. The basis set is optimized by by minimizing the spilling of the LCAO Basis set with respect to a reference plane-wave calculation performed with the same pseudo potential. It was developed to generate high quality basis sets to be used in GW calculations using the GWCalculator class.

The following example demonstrates how to optimize the basis set. First we define the 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)

Then we define a plane wave calculator to perform the reference calculation:

numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=MonkhorstPackGrid(9,9,9)
)
pw_calculator = PlaneWaveCalculator(
    wave_function_cutoff=50*Hartree,
    numerical_accuracy_parameters=numerical_accuracy_parameters,
    checkpoint_handler=NoCheckpointHandler)

bulk_configuration.setCalculator(pw_calculator)
bulk_configuration.update()

Then we define the basis set optimizer and optimize the basis set:

basis_set_optimizer = BasisSetOptimizer(
    bulk_configuration,
    orbitals_per_shell_map={Silicon: [6,6,5,4]},
    energy_cutoff=10*eV,
    tolerance=1.0e-5)

The energy cutoff decides up to what energy above the Fermi level the bands will be included for the spilling optimization. The orbitals per shell map is a dictionary that maps the elements to the number of orbitals per shell included in the ‘complete’ basis set, out of which the optimal subset will be selected. This input decides how many angular momentum shells will be included in the basis set optimization. In this example the ‘complete’ basis set will have 6 s-orbitals, 6 p-orbitals, 5 d-orbitals, and 4 f-orbitals.

Finally we optimize the basis set and save the optimized basis set:

opt_basis_set = basis_set_optimizer.optimize()
nlsave("opt_basis_set.hdf5", opt_basis_set)

doing this will choose the smallest optimal combination of orbitals that meets the tolerance criterium.

To find the optimal basis set with a given size, you can do the following:

subspace_sizes_map = {Silicon: [3,3,2,1]}
optimized_parameter_set = optimizer.optimizeForOrbitalConfiguration(
    subspace_sizes_map=subspace_sizes_map
)

This will find an optimal basis set with 3 s-orbitals, 3 p-orbitals, 2 d-orbitals, and 1 f-orbitals. To get a basis set object from the output of the optimization, you can do the following:

optimized_basis_set = optimizer._constructBasisSetFromParametersMap(
    parameters_map=optimized_parameter_set.parameters_map,
    subsize_sizes_map=subspace_sizes_map)
nlsave("opt_basis_set.hdf5", opt_basis_set)