Author Topic: DFT+MD with electric field  (Read 4341 times)

0 Members and 1 Guest are viewing this topic.

Offline kaypu

  • QuantumATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
DFT+MD with electric field
« on: May 15, 2019, 11:34 »
Dear QuantumWise staffs:
Using a 'post-step-hook' hook function,  as shown in https://forum.quantumatk.com/index.php?topic=4696.msg20375#msg20375,  the corresponding script as follows:
*********************************************************************
charges = PartialCharges(bulk_configuration).evaluate()
field = [0.01, 0.0, 0.0]*Volt/Ang
class ElectricFieldHook(object):
   def __init__(self, charges, electric_field):
      # Store the charges and the electric field.
      charges = charges.reshape(-1, 1)
      field = electric_field.reshape(1, 3)
      self.efield_forces = (charges*field).convertTo(eV/Ang)

   def __call__(self, step, time, configuration, forces, stress):
        # Add the electric field forces to the forces vector.
      forces += self.efield_forces

electric_field_hook = ElectricFieldHook(
    charges=partial_charges,
    electric_field=field
)

# -------------------------------------------------------------
# Molecular Dynamics
# -------------------------------------------------------------

initial_velocity = None

method = NVTBerendsen(
    time_step=1*femtoSecond,
    reservoir_temperature=300*Kelvin,
    thermostat_timescale=100*femtoSecond,
    initial_velocity=initial_velocity,
    heating_rate=0*Kelvin/picoSecond,
)

rigid_indices_0 = [203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
                   213, 214, 215, 216, 217, 218, 219, 220, 221, 222,
                   223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
                   233, 234, 235, 236, 237, 238, 239, 240, 241, 242]
rigid_indices_1 = [ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
                   13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                   26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
                   39]

constraints = [RigidBody(rigid_indices_0),
               RigidBody(rigid_indices_1)]

md_trajectory = MolecularDynamics(
    bulk_configuration,
    constraints=constraints,
    trajectory_filename='trajectory.nc',
    steps=200,
    log_interval=1,
    post_step_hook=electric_field_hook,
    method=method
)

bulk_configuration = md_trajectory.lastImage()
nlsave('Device-AGNR-Tran1-MDopt.nc', md_trajectory)
*****************************************************************************
it doesn't work,  the error message is "NL.ComputerScienceUtilities.Exceptions.NLTypeError: The LCAOCalculator does not
support calculation of PartialCharges."
how to deal with it? Thanks

Offline Jess Wellendorff

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 933
  • Country: dk
  • Reputation: 29
    • View Profile
Re: DFT+MD with electric field
« Reply #1 on: May 20, 2019, 15:15 »
The DFT-LCAO engine does not support partil charge analysis. This is also clear if you search for PertialCharges in the online documentation:
https://docs.quantumatk.com/manual/Types/PartialCharges/PartialCharges.html
"... an attached classical calculator"

So you need to define a ForceField calculator and attach it to the bulk configuration.