Author Topic: MD with electric field  (Read 3942 times)

0 Members and 1 Guest are viewing this topic.

Offline ramkrishna

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 253
  • Country: us
  • Reputation: 5
    • View Profile
MD with electric field
« on: October 18, 2016, 19:05 »
Hi,
Is it possible to execute MD under electric field in ATK?

Thanks
Ramkrishna

Offline Daniele Stradi

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 286
  • Country: dk
  • Reputation: 3
    • View Profile
Re: MD with electric field
« Reply #1 on: October 19, 2016, 09:15 »
Which kind of MD? Classical or Quantum (DFT, Tight-Binding)? For the latter, there is no technical limitation about running dynamics including an E-field.

Offline ramkrishna

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 253
  • Country: us
  • Reputation: 5
    • View Profile
Re: MD with electric field
« Reply #2 on: October 19, 2016, 18:44 »
Hi Daniele,
Thank you for your reply. Is there any possibility for the classical potentials?

Thanks
Ramkrishna

Offline Julian Schneider

  • QuantumATK Staff
  • QuantumATK Guru
  • *****
  • Posts: 163
  • Country: dk
  • Reputation: 25
    • View Profile
Re: MD with electric field
« Reply #3 on: October 20, 2016, 10:59 »
Yes, you can do this using a hook function, in this case a 'post-step-hook', because you want to modify the forces acting on the partticles (see http://docs.quantumwise.com/manuals/Types/MolecularDynamics/MolecularDynamics.html#moleculardynamics-f) First you set up your MD simulation as ususal. Send the simulation to the Editor to get the python script. You need to modify your script as shown in the attached example script. First you need to specify the charges of the atoms. If you are using a potential that uses electrostatics, you can use the partial charges defined in the potential by using the PartialCharges analysis object. However, you can also define any other arbitrary partial charges on the atoms.
Code
partial_charges = PartialCharges(bulk_configuration).evaluate()

# If the potential does not define partial charges, you can define charges yourself.
# Note that they only will be used to interact with the external electric field.
# e.g. partial_charges = [0.5, 0.5, -0.5, -0.5, ...]*elementary_charge
Then you need to define an electric field, which has the units Volt/Meter or Volt/Ang, etc.
Code
# Define the electric field.
field = [0.0, 0.0, 1.0]*Volt/nm
Then you need to define a hook class, which adds the forces due to the electric field i.e. F=q*E to the vector of atomic forces. Create an object of this class that will be passed to the MolecularDynamics function.
Code
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
)
This hook object needs to be passed as post_step_hook to the MolecularDynamics function.
Code
md_trajectory = MolecularDynamics(
    bulk_configuration,
    constraints=[],
    trajectory_filename='efield_trajectory.nc',
    steps=2000,
    log_interval=20,
    post_step_hook=electric_field_hook,
    method=method
)
« Last Edit: October 20, 2016, 14:47 by Julian Schneider »

Offline ramkrishna

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 253
  • Country: us
  • Reputation: 5
    • View Profile
Re: MD with electric field
« Reply #4 on: October 21, 2016, 00:11 »
Hello Julian ,
Thank you very much for the script. It will certainly help me a lot. If I find any difficulty in running the script, I will let you know.

Thanks
Ramkrishna