Skip to content
Snippets Groups Projects
Commit e5a31ee2 authored by Kai Sellschopp's avatar Kai Sellschopp
Browse files

Extra methods for adding boundary conditions to the AdAtom object

parent d4946215
No related branches found
No related tags found
No related merge requests found
import numpy as np
from ..utils.boundaryCondition import *
class AdAtom:
......@@ -10,10 +11,34 @@ class AdAtom:
self.mesh = []
def add_boundaryCondition(self, bc):
def add_boundary_condition(self, bc):
self.bcs.append(bc)
def add_position_condition(self, position_min=0.0, position_max=1.0):
pc = PositionCondition(self, position_min, position_max)
self.add_boundary_condition(pc)
def add_distance_condition(self, neighbour, distance_min=0.0, distance_max=np.infty):
dc = DistanceCondition(self, neighbour, distance_min, distance_max)
self.add_boundary_condition(dc)
def add_angle_condition(self, neighbourA, neighbourB, angle_min=0.0, angle_max=180.0, center=1):
if center==0:
ac = AngleCondition(neighbourA, self, neighbourB, angle_min, angle_max)
elif center==1:
ac = AngleCondition(self, neighbourA, neighbourB, angle_min, angle_max)
elif center==2:
ac = AngleCondition(neighbourA, neighbourB, self, angle_min, angle_max)
else:
print("ERROR! Invalid argument for center!")
return
self.add_boundary_condition(ac)
def get_position_conditions(self):
pos_bcs = []
for bc in self.bcs:
......
import numpy as np
from ase import Atoms
from adAtom import AdAtom
from .adAtom import AdAtom
from ..utils.boundaryCondition import *
......@@ -93,6 +93,9 @@ class CodeRed:
while self.current_index < self.n_adAtoms:
# get current atom
adatom = self.adAtoms[self.current_index]
# create some informative output
print("Creating positions for ad-atom with index {:d}, species: {:s}, label: {:s}".format(self.current_index, adatom.species, adatom.label))
# make sure it has a mesh
if (adatom.mesh==[] or len(adatom.mesh)==0):
......@@ -146,7 +149,12 @@ class CodeRed:
if len(self.combinations)==0:
return
# ...?
#TODO: include dihedral conditions
# finally increase current index by 1 (only happens if everything worked out)
self.current_index += 1
# generate informative output
print("Done! Generated {:d} structures in total.".format(len(self.combinations)))
return self.combinations
......@@ -66,7 +66,7 @@ class AngleCondition(BoundaryCondition):
"""
Derived class for angle boundary conditions.
"""
def __init__(self, atomA='X', atomB='Y', atomC='Z', minAng=0.0, maxAng=180.0, center=1):
def __init__(self, atomA='X', atomB='Y', atomC='Z', minAng=0.0, maxAng=180.0):
self.bc_type = 'ang'
self.atoms = [atomA, atomB, atomC]
self.minValue = minAng
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment