QuantumATK > Scripts, Tutorials and Applications
Fixing atoms during the optimization
(1/1)
gayani2025:
Dear All,
I have generated below file to do the geometry optimization with fix W atom. If I want to just fix the W atom without moving is this the correct way of doing this. Pls advice. Thnaks
# Set up lattice
vector_a = [3.29, 0.0, 0.0]*Angstrom
vector_b = [-1.645, 2.849223578450803, 0.0]*Angstrom
vector_c = [0.0, 0.0, 22.97]*Angstrom
lattice = UnitCell(vector_a, vector_b, vector_c)
# Define elements
elements = [Selenium, Tungsten, Selenium]
# Define coordinates
fractional_coordinates = [[ 0. , 0. , 0.418969960818],
[ 0.333333333333, 0.666666666667, 0.49180975185 ],
[ 0. , 0. , 0.564649542882]]
# Set up configuration
wse2_0001 = BulkConfiguration(
bravais_lattice=lattice,
elements=elements,
fractional_coordinates=fractional_coordinates
)
# Add tags
wse2_0001.addTags('W', [1])
wse2_0001_name = "wse2_0001"
# %% Set LCAOCalculator
# %% LCAOCalculator
# ----------------------------------------
# Exchange-Correlation
# ----------------------------------------
exchange_correlation = GGA.BLYP
correction_extension = GrimmeDFTD3(exchange_correlation=exchange_correlation)
k_point_sampling = MonkhorstPackGrid(na=1, nb=1, nc=1)
numerical_accuracy_parameters = NumericalAccuracyParameters(
density_mesh_cutoff=500.0 * eV,
k_point_sampling=k_point_sampling,
occupation_method=GaussianSmearing(broadening=600.0 * Kelvin),
)
calculator = LCAOCalculator(
exchange_correlation=exchange_correlation,
numerical_accuracy_parameters=numerical_accuracy_parameters,
checkpoint_handler=NoCheckpointHandler,
correction_extension=correction_extension,
)
# %% Set Calculator
wse2_0001.setCalculator(calculator)
nlsave('WSe2_0001_results.hdf5', wse2_0001)
# %% OptimizeGeometry
fix_atom_indices_0 = wse2_0001.indicesFromTags(['W'])
constraints = [FixAtomConstraints(fix_atom_indices_0)]
restart_strategy = RestartFromTrajectory(
trajectory_filename='WSe2_0001_resultsopt.hdf5', object_id='optimize_trajectory'
)
optimized_configuration = OptimizeGeometry(
configuration=wse2_0001,
constraints=constraints,
trajectory_filename='WSe2_0001_resultsopt.hdf5',
trajectory_object_id='optimize_trajectory',
restart_strategy=restart_strategy,
)
nlsave('WSe2_0001_resultsopt.hdf5', optimized_configuration, object_id='optgeom')
AsifShah:
Hi,
Looks right.
But out of curiosity, why would you keep W as fixed in WS2?
gayani2025:
Thank you very much for the reply. :)
No I just want to check whether I have done this correctly. So started with a simple example.
Navigation
[0] Message Index
Go to full version