Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the electric_field method for AMSJob classes #173

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/tcutility/job/ams.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from tcutility import log
from tcutility.job.generic import Job
import os

import numpy as np
from typing import List

j = os.path.join

Expand Down Expand Up @@ -163,6 +164,21 @@ def charge(self, val: int):
'''
self.settings.input.ams.System.Charge = val

def electric_field(self, direction: List[float], magnitude: float = None):
'''
Set an electric field for this system.

Args:
direction: the vector with the direction and strength of the electric field.
magnitude: if given, the direction will be normalized and magnitude will be used as the field strength.
'''
# if magnitude is given we normalize the direction vector and give it the correct length
if magnitude is not None:
direction = np.array(direction)/np.linalg.norm(direction) * magnitude

ex, ey, ez = tuple(direction)
self.settings.input.ams.System.ElectrostaticEmbedding.ElectricField = f'{ex} {ey} {ez}'

def _setup_job(self):
'''
Set up the calculation. This will create the working directory and write the runscript and input file for ADF to use.
Expand Down
Loading