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, perform_device_optimization=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 givendevice_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)
for LCAO, plane-wave and semi-empirical calculators;(False, False)
for forcefield calculators.optimize_geometry_parameters (
OptimizeGeometryParameters
) – The parameters to use for optimizing the geometry. Note thatpre_step_hook
andpost_step_hook
must be left unset. Also note thatmax_stress
,target_stress
,restart_strategy
andenable_optimization_stop_file
do not have any effect since stress is not optimized, and the restart mechanism withinOptimizeGeometry()
is disabled. Default:OptimizeGeometryParameters()
log_filename_prefix (str |
LogToStdOut
) – Filename prefix for the logging output of the calculations, each to be stored in a separate file. IfLogToStdOut
, all logging will instead be sent to standard output. Default:'optimizedeviceconfiguration'
perform_device_optimization (bool) – Whether to perform a relaxation using the device geometry obtained after the bulk rigid relaxation. When
True
,device_configuration
must have a calculator. The optimization region is determined byoptimization_region_center
andoptimization_region_length
. Default: False
- calculator()¶
- Returns:
The bulk calculator used for optimizing the geometry.
- Return type:
Calculator
- dependentStudies()¶
- Returns:
The list of dependent studies.
- Return type:
list of
Study
- 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=None)¶
Print a string containing an ASCII table useful for plotting the Study object.
- Parameters:
stream (python stream) – The stream the table should be written to. Default:
NLPrintLogger()
- 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 |
ProcessesPerNode
- numberOfProcessesPerTaskResolved()¶
- Returns:
The number of processes to be used to execute each task. Default values are resolved based on the current execution settings.
- Return type:
int
- 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:
- 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
- performDeviceOptimization()¶
- Returns:
Whether an additional optimization will be performed for the device configuration obtained after the bulk rigid relaxation.
- Return type:
bool
- result()¶
Retrieve the optimized device configuration.
- Returns:
The optimized device configuration. If not available, returns None.
- Return type:
DeviceConfiguration
| None
- saveToFileAfterUpdate()¶
- Returns:
Whether the study is automatically saved after it is updated.
- Return type:
bool
- uniqueString()¶
Return a unique string representing the state of the object.
- update()¶
Run the calculations for the study object.
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. If you want to ensure
that the reassembled device is in the minimum-energy geometry, set
perform_device_optimization=True
, and a geometry optimization will
be performed for the device using the calculator on the original
device_configuration
.
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):
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)
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 |
+------------------------------------------------------------------------------+
| Initial configuration 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 |
+------------------------------------------------------------------------------+
| Bulk rigid relaxation details: |
+------------------------------------------------------------------------------+
| Optimization region: |
| Length: 2.26 Ang |
| Left edge position: 7.10 Ang |
| Right edge position: 9.37 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 |
+------------------------------------------------------------------------------+
| Device optimization disabled |
+------------------------------------------------------------------------------+