Author Topic: Atoms constraint partially relaxation in x-y-z directions.  (Read 5166 times)

0 Members and 1 Guest are viewing this topic.

Offline fangyongxinxi

  • QuantumATK Guru
  • ****
  • Posts: 143
  • Reputation: 0
    • View Profile
Dear,
I want to know how to set the atom constraints (NOT totally constraint, for exampel, I want the atoms just relax in z direction, constraints in x-y direction).

I remembered that in old-version atk, the following lines can do the job
but how to write the script in new version, e.g, 13.8.
Thanks.



x_constrained = [3,4]    
y_constrained = [3,4]
fixed_atoms = [0,1,2,5,6,7]  



fangyongxinxi
2013-11-28
« Last Edit: November 28, 2013, 09:34 by fangyongxinxi »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Atoms constraint partially relaxation in x-y-z directions.
« Reply #1 on: November 28, 2013, 10:02 »
I don't recall this ever being possible (although you may certainly be right if we go back very far in history) but it's a possibility we're working on supporting.

Offline fangyongxinxi

  • QuantumATK Guru
  • ****
  • Posts: 143
  • Reputation: 0
    • View Profile
Re: Atoms constraint partially relaxation in x-y-z directions.
« Reply #2 on: November 28, 2013, 12:58 »
from ATK.TwoProbe import *
from CalculateOptimizedTwoProbeGeometry import calculateOptimizedTwoProbeGeometry

def my_force_filter(forces):
    for i in range(len(forces)):
        forces[0] = 0.*eV/Ang
        forces[1] = 0.*eV/Ang
    return forces

from ATK.TwoProbe import *

# Li chain lattice constant
a = 2.90
# Construct the electrode unit cell
unit_cell = [ [3*a, 0.0, 0.0 ],
              [0.0, 3*a, 0.0 ],
              [0.0, 0.0, 4*a ] ] * Angstrom

# Define the electrode
electrode_Li = PeriodicAtomConfiguration(
    super_cell_vectors=unit_cell,
    elements=4*[Lithium],
    fractional_coordinates=[(0.5, 0.5, float(i)/4.0) for i in range(0,4)]
    )

# Setup the two-probe scattering region

# Distances between Li-H and H-H (found from relaxing a Li4H2 cluster)
dist_HH = 0.804
dist_LiH = 2.366

# The atoms in the central region
elements = 3*[Lithium] + 2*[Hydrogen] + 3*[Lithium]

positions = [
    (0.0, 0.0, 0*a),
    (0.0, 0.0, 1*a),
    (0.0, 0.0, 2*a),
    (0.2, 0.0, 2*a + dist_LiH),           # First H
    (0.0, 0.2, 2*a + dist_LiH + dist_HH), # Second H
    (0.0, 0.0, 2*a + dist_LiH + dist_HH + dist_LiH + 0*a),
    (0.0, 0.0, 2*a + dist_LiH + dist_HH + dist_LiH + 1*a),
    (0.0, 0.0, 2*a + dist_LiH + dist_HH + dist_LiH + 2*a)
    ] * Angstrom
   
# Combine electrode and scattering region
# into a two-probe system
two_probe_conf = TwoProbeConfiguration(
    electrodes = (electrode_Li,electrode_Li),
    scattering_region_elements              = elements,
    scattering_region_cartesian_coordinates = positions
    )

# Reduce basis set size for Li
basis_set_params = basisSetParameters(
    type = SingleZeta,
    element = Lithium
    )

# Set k-points for electrodes
bz_int_param = brillouinZoneIntegrationParameters( (1,1,20) )

# Create parameters for electrodes
electrode_params = ElectrodeParameters(
    brillouin_zone_integration_parameters = bz_int_param
    )

# Collect parameters into a two-probe calculation method
method = TwoProbeMethod(
    (electrode_params,electrode_params),
    basis_set_parameters = basis_set_params,
    electron_density_parameters = electronDensityParameters(mesh_cutoff = 70.0*Rydberg),
    iteration_control_parameters = iterationControlParameters(tolerance = 1e-3),
    electrode_voltages = (0.0, 0.0)*Volt
    )

# Specify verbosity and checkpoint file
runtime_params = runtimeParameters(
    verbosity_level = 1,
    checkpoint_filename = 'lih2li-scf_tst.nc'
    )
   
p = geometricOptimizationParameters (force_tolerance = 5.0e-2*eV/Ang, max_steps = 200)
   
x_constrained = [3,4]   
y_constrained = [3,4]
fixed_atoms = [0,1,2,5,6,7]   
   
# Perform SCF calculation with chosen parameters
relaxed_geometry,scf = calculateOptimizedTwoProbeGeometry (
        two_probe_configuration = two_probe_conf,
        method = method,
        optimization_parameters = p,
        runtime_parameters = runtime_params,
        initial_calculation = restoreSelfConsistentCalculation ('lih2li-scf.nc'),
        geometric_constraints = [x_constrained,y_constrained,[]],
        fixed_atoms = fixed_atoms,
    )

nlPrint(relaxed_geometry)

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Atoms constraint partially relaxation in x-y-z directions.
« Reply #3 on: November 28, 2013, 14:59 »
Yes, that's about how we would implement it. But this code is from 2007-2008 from the previous ATK generation, so it doesn't work in the newer versions.