From 1dadea3d9c48e825cc2c8a53f2a4c021c7462035 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Mon, 18 Mar 2024 00:26:57 +0100 Subject: [PATCH] Added the electric_field method for AMSJob classes --- src/tcutility/job/ams.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tcutility/job/ams.py b/src/tcutility/job/ams.py index 306807eb..c856fdb6 100644 --- a/src/tcutility/job/ams.py +++ b/src/tcutility/job/ams.py @@ -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 @@ -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.