diff --git a/parser/parser-asap/constraint_conversion.py b/parser/parser-asap/constraint_conversion.py index a3591b390a45fe39789970cc9475cc9040004436..ddd2f56e7e2f5ae970d94543c642a1d4086192b9 100644 --- a/parser/parser-asap/constraint_conversion.py +++ b/parser/parser-asap/constraint_conversion.py @@ -5,6 +5,12 @@ names_plane = {0: 'fix_yz', 1: 'fix_xz', 2: 'fix_xy'} names_line = {0: 'fix_x', 1: 'fix_y', 2: 'fix_z'} def get_index(v): + """ Try to guess the Nomad name + Parameters: + v: (3,) arraylike + vector perpedicular to the plane + or the direction of the line. + """ v /= np.linalg.norm(v) v2 = v * v perm = v2.argsort() @@ -15,11 +21,14 @@ def get_nomad_name(c): """This tries to find the appropriate named name from the constaints giving by a direction""" constraint = c.todict() - if constraint['name'] == 'FixedPlane': + name = str(constraint.get('name')) + if name == 'FixedPlane': d = get_index(c.dir) return names_plane[d] - elif constraint['name'] == 'FixedLine': + elif name == 'FixedLine': d = get_index(c.dir) return names_line[d] - elif constraint['name'] == 'FixedAtoms': + elif name == 'FixAtoms': return 'fix_xyz' + else: + return name