OptimizeDeviceConfiguration

class OptimizeDeviceConfiguration(device_configuration, filename, object_id, calculator=None, optimization_region_length=None, optimization_region_center=None, passivate_electrode_surfaces=None, optimize_geometry_parameters=None, log_filename_prefix=None)

Class for optimizing a device configuration.

Parameters:
  • device_configuration (DeviceConfiguration) – The device configuration to optimize.
  • filename (str) – The full or relative filename path the Study object should be saved to. See nlsave().
  • object_id (str) – The name of the study that the Study object should be saved to within the file. This needs to be a unique name in this file. See nlsave().
  • calculator (Calculator) – The bulk calculator to use for the optimization of the central region of the device.
    Default: A bulk calculator with settings similar to the calculator set on the given device_configuration.
  • optimization_region_length (PhysicalQuantity of type length) – The length along the transport direction of the region to be optimized within the central region of the device. Note that the length of the optimization region is automatically capped to keep the given electrode extensions fixed on either side.
    Default: 10.0 * Angstrom
  • optimization_region_center (PhysicalQuantity of type length) – The position along the transport direction of the center of the optimization region.
    Default: The center along the transport direction of the central region of the device after the left and right electrode extensions have been removed. The maximum valid number of repeats of the minimal electrodes are used to calculate the electrode extensions.
  • passivate_electrode_surfaces (sequence (size 2) of bool) – Whether the left and right surfaces of the central region of the device along the transport direction should be passivated when extracting the central region for optimization.
    Default: (True, True)
  • optimize_geometry_parameters (OptimizeGeometryParameters) – The parameters to use for optimizing the geometry. Note that constraints, pre_step_hook and```post_step_hook`` must be left unset. Also note that max_stress and target_stress do not have any effect since stress is not optimized.
    Default: OptimizeGeometryParameters()
  • log_filename_prefix (str | LogToStdOut) – Filename prefix for the logging output of the calculations, each to be stored in a separate file. If LogToStdOut, all logging will instead be sent to standard output.
    Default: 'optimizedeviceconfiguration'
calculator()
Returns:The bulk calculator used for optimizing the geometry.
Return type:Calculator
deviceCalculator()
Returns:The device calculator.
Return type:Calculator
filename()
Returns:The filename where the study object is stored.
Return type:str
logFilenamePrefix()
Returns:The filename prefix for the logging output of the study.
Return type:str | LogToStdOut
nlprint(stream=<open file '<stdout>', mode 'w'>)

Print a string containing an ASCII table summarizing the available results for the study.

Parameters:stream (file-like) – The stream to write to. This should be an object that supports strings being written to it using a write method.
Default: sys.stdout
numberOfProcessesPerTask()
Returns:The number of processes to be used to execute each task. If None, all available processes should execute each task collaboratively.
Return type:int | None
objectId()
Returns:The name of the study object in the file.
Return type:str
optimizationRegionCenter()
Returns:The position along the transport direction of the center of the optimization region.
Return type:PhysicalQuantity of type length
optimizationRegionLength()
Returns:The length along the transport direction of the optimization region. Note that the optimization region might be capped in order to keep at least one repeat of the minimal electrode fixed on either side.
Return type:PhysicalQuantity of type length
optimizeGeometryParameters()
Returns:The parameters used for optimizing the geometry.
Return type:OptimizeGeometryParameters
passivateElectrodeSurfaces()
Returns:Whether the left and right surfaces of the central region of the device along the transport direction are passivated when extracting the central region for optimization.
Return type:tuple (size 2) of bool
result()

Retrieve the optimized device configuration.

Returns:The optimized device configuration. If not available, returns None.
Return type:DeviceConfiguration | None
update()

Run the calculations for the study object.

After all the tasks have been executed by the Workflow runner, the results of the tasks are added to the data cache.

Notes

Note

Study objects behave differently from analysis objects. See the Study object overview for more details.

The OptimizeDeviceConfiguration object can be used to optimize a device configuration using the so-called Bulk Rigid Relaxation (BRR) method. In the BRR method, after building the device configuration, the central region bulk is extracted and relaxed with FixAtomConstraints constraints on the atoms belonging to the left electrode extension, and RigidBody constraints on the atoms belonging to the right electrode extension (i.e., the central region can expand or contract along the transport direction during the optimization). The device is then reassembled from the optimized central region bulk. This is a computationally efficient approach and will usually capture a large fraction of the required geometry relaxation.

Note that the length and position of the region to be relaxed within the device’s central region can be controlled with optimization_region_length and optimization_region_center. The contrained regions on either side must at least cover the electrode extensions, but might extend beyond this.

After performing the calculation, the resulting optimized device configuration can be retrieved by calling the result method.

Note

The BRR method does not calculate the total energy using a full device geometry, hence the reassembled device may not be exactly in the global minimum-energy geometry. Some types of electronic structure calculations may be sensitive to this difference, others may not.

Usage Examples

This example shows how to perform an optimization of a carbon nanotube device.

First, we define the device system. This is given in the following file (for clarity, we split this from the OptimizeDeviceConfiguration study itself):

setup_cnt_device.py

We can now proceed with the study. Note that this example is only intended to give an overview of the usage of OptimizeDeviceConfiguration. The SingleZeta basis set used in this example should not be used for a proper, physical device configuration optimization.

# Read the device configuration with an attached calculator.
device_configuration = nlread('setup_cnt_device.py', DeviceConfiguration)[0]

# Set up parameters for the device configuration optimization.
optimize_geometry_parameters = OptimizeGeometryParameters(
     max_forces=0.2 * eV / Angstrom,
     max_stress=0.8 * GPa,
     max_steps=200,
     max_step_length=0.2 * Angstrom,
     optimizer_method=LBFGS(),
)

# Set up the object and perform the relaxation.
optimize_device_configuration = OptimizeDeviceConfiguration(
    device_configuration=device_configuration,
    filename=u'optimize_cnt_device.hdf5',
    object_id='optimizedeviceconfiguration',
    optimization_region_length=10.0 * Angstrom,
    passivate_electrode_surfaces=(True, True),
    optimize_geometry_parameters=optimize_geometry_parameters,
    log_filename_prefix='optimize_cnt_device',
)
optimize_device_configuration.update()

# Fetch the resulting device configuration after optimization.
optimized_device = optimize_device_configuration.result()

# Print a report.
nlprint(optimize_device_configuration)

optimize_cnt_device.py

Here is the resulting report from the nlprint command:

+------------------------------------------------------------------------------+
| Optimize Device Configuration Report                                         |
+------------------------------------------------------------------------------+
| Device configuration:                                                        |
+------------------------------------------------------------------------------+
| Central region (including electrode extensions):                             |
|     Length (before optimization): 16.34 Ang                                  |
|     Length (after optimization): 16.47 Ang                                   |
|     Number of atoms: 96                                                      |
| Electrode extensions:                                                        |
|     Length (left): 7.10 Ang                                                  |
|     Length (right): 7.10 Ang                                                 |
|     Number of atoms (left): 42                                               |
|     Number of atoms (right): 42                                              |
+------------------------------------------------------------------------------+
| Optimization details:                                                        |
+------------------------------------------------------------------------------+
| Optimization region:                                                         |
|     Length: 2.13 Ang                                                         |
|     Left edge position: 7.10 Ang                                             |
|     Right edge position: 9.24 Ang                                            |
|     Number of atoms: 12                                                      |
| Constrained regions:                                                         |
|     Length (left): 7.10 Ang                                                  |
|     Length (right): 7.10 Ang                                                 |
|     Number of atoms (left): 42                                               |
|     Number of atoms (right): 42                                              |
+------------------------------------------------------------------------------+