Skip to content

Commit

Permalink
Merge branch 'development_efrem'
Browse files Browse the repository at this point in the history
  • Loading branch information
efrembernuz committed Mar 11, 2021
2 parents 7a884cc + 35f49b8 commit 1bdb3f4
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 98 deletions.
40 changes: 34 additions & 6 deletions cosymlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def print_electronic_density_measure(self, group, axis=None, axis2=None, center=

output.write(txt)

def print_wnfsym_sym_matrices(self, group, axis=None, axis2=None, center=None, output=sys.stdout):
def print_esym_matrices(self, group, axis=None, axis2=None, center=None, output=sys.stdout):

txt = ''
for molecule in self._molecules:
Expand Down Expand Up @@ -441,7 +441,7 @@ def print_wnfsym_sym_matrices(self, group, axis=None, axis2=None, center=None, o
array2[0], array2[1], array2[2])
output.write(txt)

def print_wnfsym_sym_ovelap(self, group, axis=None, axis2=None, center=None, output=sys.stdout):
def print_esym_sym_overlaps(self, group, axis=None, axis2=None, center=None, output=sys.stdout):

txt = ''
for molecule in self._molecules:
Expand Down Expand Up @@ -509,8 +509,7 @@ def print_wnfsym_sym_ovelap(self, group, axis=None, axis2=None, center=None, out

output.write(txt)

def print_wnfsym_irreducible_repr(self, group, axis=None, axis2=None, center=None, show_axes=True,
output=sys.stdout):
def print_esym_irreducible_repr(self, group, axis=None, axis2=None, center=None, show_axes=True, output=sys.stdout):

txt = ''
for molecule in self._molecules:
Expand All @@ -537,8 +536,8 @@ def print_wnfsym_irreducible_repr(self, group, axis=None, axis2=None, center=Non

output.write(txt)

def print_wnfsym_mo_irreducible_repr(self, group, axis=None, axis2=None, center=None, show_axes=True,
output=sys.stdout):
def print_esym_mo_irreducible_repr(self, group, axis=None, axis2=None, center=None, show_axes=True,
output=sys.stdout):

txt = ''
for molecule in self._molecules:
Expand Down Expand Up @@ -589,6 +588,35 @@ def print_wnfsym_mo_irreducible_repr(self, group, axis=None, axis2=None, center=

output.write(txt)

def print_esym_orientation(self, group, axis=None, axis2=None, center=None, output=sys.stdout):
"""
Prints down an xyz file of the molecule with the orientation_axis
:param group: Symmetry group
:type group: string
:param axis: Main symmetry axis of group
:type axis: list
:param axis2: Secondary symmetry axis of group
:type axis2: list
:param center: Center
:type center: list
:param output: Display hook
:type output: hook
"""

txt = ''
for molecule in self._molecules:
txt += file_io.get_file_xyz_txt(molecule.geometry)
txt = txt.replace(str(molecule.geometry.get_n_atoms()), str(molecule.geometry.get_n_atoms() + 3), 1)
axis_info = molecule.get_symmetry_axes(group, axis=axis, axis2=axis2, center=center)
txt += 'X1 ' + ' '.join(['{:11.6f}'.format(s) for s in axis_info['center']])
txt += '\n'
txt += 'X2 ' + ' '.join(['{:11.6f}'.format(s) for s in axis_info['axis']])
txt += '\n'
txt += 'X2 ' + ' '.join(['{:11.6f}'.format(s) for s in axis_info['axis2']])
txt += '\n'
output.write(txt)

def plot_mo_diagram(self, group, axis=None, axis2=None, center=None):
"""
Plots Molecular orbitals diagram
Expand Down
6 changes: 3 additions & 3 deletions examples/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def print_csm(data):
print('\n\n***********{}************'.format('print_info()'))
molecules_set.print_info()
print('\n\n***********{}************'.format('print_wnfsym_irreducible_repr()'))
molecules_set.print_wnfsym_irreducible_repr('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
molecules_set.print_esym_irreducible_repr('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
print('\n\n***********{}************'.format('print_wnfsym_sym_ovelap()'))
molecules_set.print_wnfsym_sym_ovelap('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
molecules_set.print_esym_sym_overlaps('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
print('\n\n***********{}************'.format('print_wnfsym_sym_matrices()'))
molecules_set.print_wnfsym_sym_matrices('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
molecules_set.print_esym_matrices('C2v', axis=[0, 0, 1], center=[0.0, 0.0, 0.0])
25 changes: 14 additions & 11 deletions scripts/chirality
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ parser.add_argument(type=str,
# Main options
parser.add_argument('-m', '--measure',
dest='measure',
metavar='SG',
default=0,
type=int,
action='store_true',
default=False,
help='compute the chiral symmetry measure of the input structures')
parser.add_argument('-order',
dest='order',
default=1,
type=int,
help='max order of Sn calculation')
parser.add_argument('-o', '--output',
dest='output_name',
metavar='filename',
Expand Down Expand Up @@ -87,18 +91,17 @@ if args.info:
print_input_info(structure_set.get_geometries(), output=common_output)
exit()

if args.measure == 0:
reference = ['Ci', 'Cs']
elif args.measure == 1:
if args.order == 1:
reference = ['Cs']
elif args.measure == 2:
elif args.order == 2:
reference = ['Ci']
elif int(args.measure) % 2 != 0:
raise ValueError('For Sn chirality measure choose an even value between 2-n')
elif int(args.order) > 8:
raise ValueError('Maximum value available for Sn chirality measure is 8')
else:
for n in range(4, args.measure + 1):
reference = ['Cs', 'Ci']
for n in range(3, args.order + 1):
if n%2 == 0:
reference = ['Ci', 'Cs', 'S'+str(n)]
reference.append('S'+str(n))

reference = [r.lower() for r in reference]

Expand Down
83 changes: 53 additions & 30 deletions scripts/cosym
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ parser.add_argument('-v', '--version', dest='version', action='store_true', defa

parser.add_argument('-c', '--central_atom', action='store', dest='central_atom',
type=int, default=0, help='position of the central atom if exist')
parser.add_argument('-cref', '--custom_ref', action='store', dest='custom_ref', default=None,
help='take a given structure from the file and use it as reference')
parser.add_argument('-shp_m_custom', '--shp_measure_custom', action='store', dest='shp_measure_custom', default=None,
help='define filename containing the structure/s to be used as reference')
parser.add_argument('-fix_perm', '--fix_permutation', dest='fix_permutation', action='store_true', default=False,
help='use the given permutation to perform a calculation')
parser.add_argument('-no_labels', '--ignore_atom_labels', dest='ignore_atom_labels', action='store_true', default=False,
Expand Down Expand Up @@ -118,12 +118,12 @@ group_qsym.add_argument('-qsym_wfn',
dest='qsym_wfn',
action='store',
default=False,
help='Wfnsym measure of input structure with reference group')
help='wavefunction symmetry measure of input structure with reference group')
group_qsym.add_argument('-qsym_dens',
dest='qsym_dens',
action='store',
default=False,
help='Density measure of input structure with reference group')
help='Density symmetry measure of input structure with reference group')
group_qsym.add_argument('-qsym_mos',
dest='qsym_mos',
action='store',
Expand All @@ -146,6 +146,11 @@ parser.add_argument('--qsym_mo_overlaps',
default=False,
action='store_true',
help='print the molecular orbitals overlap')
parser.add_argument('--esym_add_axes',
dest='esym_add_axes',
action='store_true',
default=False,
help='create an xyz file of the molecule with axes orientation as dummies')
parser.add_argument('-mo_diagram', dest="mo_diagram", action='store_true', default=False,
help='Perform the calculations with the command file')

Expand Down Expand Up @@ -204,16 +209,25 @@ if args.shp_labels:
print(tools.get_shape_label_info(n_atoms))

reference = []
if args.shp_measure == 'custom':
if args.custom_ref is not None:
reference = file_io.get_geometry_from_file_xyz(args.custom_ref, read_multiple=True)
[x.set_positions(args.central_atom - 1) for x in reference]
else:
sys.exit('Custom reference file not defined (use -cref or --custom_ref filename)')
# if args.shp_measure == 'custom':
# if args.custom_ref is not None:
# reference = file_io.get_geometry_from_file_xyz(args.custom_ref, read_multiple=True)
# [x.set_positions(args.central_atom - 1) for x in reference]
# else:
# sys.exit('Custom reference file not defined (use -cref or --custom_ref filename)')
# elif args.shp_measure == 'all':
# reference = tools.get_structure_references(vertices)
# else:
# reference = [args.shp_measure]

if args.shp_measure_custom:
reference = file_io.read_generic_structure_file(args.shp_measure_custom, read_multiple=True)
[x.set_positions(args.central_atom - 1) for x in reference]
args.shp_measure = 'custom'
elif args.shp_measure == 'all':
reference = tools.get_structure_references(vertices)
else:
reference = args.shp_measure
elif args.shp_measure:
reference = [args.shp_measure]

if args.shp_structure:
if common_output is sys.stdout:
Expand Down Expand Up @@ -261,28 +275,28 @@ if args.qsym_wfn:
args.axis, args.axis2 = orthogonal_c4(args.axis, args.axis2)

if args.qsym_molecular_orbitals:
symobj.print_wnfsym_mo_irreducible_repr(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
show_axes=False,
output=common_output)

symobj.print_wnfsym_irreducible_repr(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)
symobj.print_esym_mo_irreducible_repr(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
show_axes=False,
output=common_output)

symobj.print_esym_irreducible_repr(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)

if args.qsym_trans_matrices:
symobj.print_wnfsym_sym_matrices(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)
symobj.print_esym_matrices(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)

if args.qsym_mo_overlaps:
symobj.print_wnfsym_sym_ovelap(args.qsym_wfn,
symobj.print_esym_sym_overlaps(args.qsym_wfn,
axis=args.axis,
axis2=args.axis2,
center=args.center,
Expand All @@ -295,6 +309,15 @@ if args.qsym_wfn:
axis2=args.axis2,
center=args.center)

if args.esym_add_axes:
file_name, file_extension = os.path.splitext(args.input_file)
output_str = open(file_name + '_orient.xyz', 'w')
symobj.print_esym_orientation(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=output_str)

# Pointgroup command
if args.pointgroup:
for idm, pg in enumerate(symobj.get_point_group()):
Expand Down
51 changes: 33 additions & 18 deletions scripts/esym
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from cosymlib.symmetry.tools import print_symmetry_labels
from cosymlib.symmetry.tools import orthogonal_c4
import argparse
import sys
import os
import yaml
import numpy as np

Expand Down Expand Up @@ -88,6 +89,11 @@ parser.add_argument('-axis2',
default=None,
nargs=3,
help='set secondary symmetry axis')
parser.add_argument('--add_axes',
dest='add_axes',
action='store_true',
default=False,
help='create an xyz file of the molecule with axes orientation as dummies')
parser.add_argument('-c3_c4',
dest='c3_c4',
action='store_true',
Expand Down Expand Up @@ -143,30 +149,39 @@ if args.measure:
args.axis, args.axis2 = orthogonal_c4(args.axis, args.axis2)

if args.molecular_orbitals:
structure_set.print_wnfsym_mo_irreducible_repr(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
show_axes=False,
output=common_output)

structure_set.print_wnfsym_irreducible_repr(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)
structure_set.print_esym_mo_irreducible_repr(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
show_axes=False,
output=common_output)

structure_set.print_esym_irreducible_repr(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)
if args.trans_matrices:
structure_set.print_wnfsym_sym_matrices(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)
structure_set.print_esym_matrices(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)

if args.mo_overlaps:
structure_set.print_wnfsym_sym_ovelap(args.measure,
structure_set.print_esym_sym_overlaps(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=common_output)

if args.add_axes:
file_name, file_extension = os.path.splitext(args.input_file)
output_str = open(file_name + '_orient.xyz', 'w')
structure_set.print_esym_orientation(args.measure,
axis=args.axis,
axis2=args.axis2,
center=args.center,
output=output_str)

print_footer(common_output)
18 changes: 8 additions & 10 deletions scripts/shape
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ parser.add_argument('-r', '--references',
action='store_true',
default=False,
help='store the coordinates of the reference polyhedra in a file')
parser.add_argument('-cref', '--custom_ref',
dest='custom_ref',
parser.add_argument('-m_custom', '--measure_custom',
dest='measure_custom',
metavar='filename',
default=None,
help='define filename containing the structure/s to be used as reference (requires -m custom)')
help='define filename containing the structure/s to be used as reference')

# Extra options
parser.add_argument('-l', '--labels', action='store_true',
Expand Down Expand Up @@ -147,16 +147,14 @@ if args.labels:
common_output.write(tools.get_shape_label_info(n_atoms, with_central_atom=args.central_atom))
exit()

if args.measure == 'custom':
if args.custom_ref is not None:
reference = file_io.read_generic_structure_file(args.custom_ref, read_multiple=True)
[x.set_positions(args.central_atom - 1) for x in reference]
else:
sys.exit('Custom reference file not selected (use -cref or --custom_ref filename)')
if args.measure_custom:
reference = file_io.read_generic_structure_file(args.measure_custom, read_multiple=True)
[x.set_positions(args.central_atom - 1) for x in reference]
args.measure = 'custom'
elif args.measure == 'all':
reference = tools.get_structure_references(vertices)
else:
reference = args.measure
reference = [args.measure]

if args.structure:
if common_output is sys.stdout:
Expand Down

0 comments on commit 1bdb3f4

Please sign in to comment.