Skip to content

Commit

Permalink
Merge branch 'development_efrem'
Browse files Browse the repository at this point in the history
# Conflicts:
#	cosymlib/__init__.py
  • Loading branch information
efrembernuz committed Mar 29, 2021
2 parents 3e11640 + cda134c commit 240abf0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 22 deletions.
59 changes: 38 additions & 21 deletions cosymlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def _get_table_format(labels, molecules_names, data):
names.append(name[:(max_len_name - 1)])
elif len(name) > 0:
names.append(name)
else:
names.append('No Name')

n = max_len_name - 3
for label in labels:
Expand Down Expand Up @@ -368,39 +366,58 @@ def _print_electronic_symmetry_measure(self, group, axis=None, axis2=None, cente
txt += '{:<9} '.format(molecule.name) + ' '.join(['{:7.3f}'.format(s) for s in wf_measure['csm']])
txt += '\n'
first = False

txt += _get_axis_info(molecule, group, axis, axis2, center)
axes_information = molecule.get_symmetry_axes(group, axis=axis, axis2=axis2, center=center)
txt += '\nSymmetry parameters\n'
txt += 'center: ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['center']])
txt += '\n'
txt += 'axis : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis']])
txt += '\n'
txt += 'axis2 : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis2']])
txt += '\n'

output.write(txt)

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

txt = ''
txt2 = ''
first = True
for molecule in self._molecules:
dens_measure = molecule.get_dens_symmetry(group, axis=axis, axis2=axis2, center=center)

if first:
sep_line = ' ' + '---------' * len(dens_measure['labels']) + '\n'

txt += '\nDensity: CSM-like values\n'
txt += sep_line
txt += ' ' + ' '.join(['{:^7}'.format(s) for s in dens_measure['labels']])
txt += '\n'
txt += sep_line
sep_line = ' ' + '---------' * len(dens_measure['labels']) + '\n'

txt2 += '--------------\n'
txt2 += 'Total CSM {}\n'.format(group)
txt2 += '--------------\n'
txt += '--------------------------------------\n'
txt += 'Atomic Coordinates (Angstroms)\n'
txt += '--------------------------------------\n'
for idp, position in enumerate(molecule.geometry.get_positions()):
txt += '{:2} {:11.6f} {:11.6f} {:11.6f}\n'.format(molecule.geometry.get_symbols()[idp],
position[0], position[1], position[2])
txt += '\nDensity: CSM-like values\n'
txt += sep_line
txt += ' ' + ' '.join(['{:^7}'.format(s) for s in dens_measure['labels']])
txt += '\n'
txt += sep_line

txt += '{:<9} '.format(molecule.name) + ' '.join(['{:7.3f}'.format(s) for s in dens_measure['csm_coef']])
txt += '\n\n'

axes_information = molecule.get_symmetry_axes(group, axis=axis, axis2=axis2, center=center)
txt += '----------------------------\n'
txt += 'Total density symmetry: {}\n'.format(group)
txt += '----------------------------\n'
txt += '{:<9} '.format(molecule.name) + '{:7.3f}\n'.format(dens_measure['csm'])

txt += '\nSelf Assembly: {:7.3f}\n\n'.format(dens_measure['self_assembly'])

txt += '\nSymmetry axes\n'
txt += 'center: ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['center']])
txt += '\n'
txt += 'axis : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis']])
txt += '\n'
txt += 'axis2 : ' + ' '.join(['{:12.8f}'.format(s) for s in axes_information['axis2']])
txt += '\n'
first = False
txt2 += '{:<9} '.format(molecule.name) + '{:7.3f}\n'.format(dens_measure['csm'])
txt2 += _get_axis_info(molecule, group, axis, axis2, center)

txt += '\n' + txt2
# txt += '\n'

output.write(txt)

Expand Down Expand Up @@ -815,7 +832,7 @@ def print_minimum_distortion_path_shape(self, shape_label1, shape_label2, centra
txt_params += '{:^8} {:^8}'.format('DevPath', 'GenCoord')
txt_params += '\n'

filter_mask = [min_dev < dv < max_dev and min_gco < gc < max_gco for dv, gc in zip(devpath, gen_coord)]
filter_mask = [min_dev <= dv <= max_dev and min_gco <= gc <= max_gco for dv, gc in zip(devpath, gen_coord)]

for idx, molecule in enumerate(self._molecules):
if not filter_mask[idx]:
Expand Down
14 changes: 14 additions & 0 deletions cosymlib/file_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def _non_blank_lines(f):
yield line


def no_name(file_name, n_title_structure):
if len(os.path.splitext(os.path.basename(file_name))[0]) > 8:
return os.path.splitext(os.path.basename(file_name))[0][:8] + '_' + str(n_title_structure)
else:
return os.path.splitext(os.path.basename(file_name))[0] + '_' + str(n_title_structure)


def check_geometries_vertices(geometries, file_name):
n_atoms = geometries[0].get_n_atoms()
for idg, geometry in enumerate(geometries):
Expand Down Expand Up @@ -61,6 +68,7 @@ def get_geometry_from_file_xyz(file_name, read_multiple=False):
geometries = []
n_atoms = None
n_atoms_line = 1
no_title_structures = 1
with open(file_name, mode='r') as lines:
for idl, line in enumerate(lines):
if line.lstrip().startswith(comment_line):
Expand All @@ -78,6 +86,10 @@ def get_geometry_from_file_xyz(file_name, read_multiple=False):
warnings.warn('Number of atoms in line {} and number '
'of atoms provided are not equal'.format(n_atoms_line),
errors.MissingAtomWarning)
if name == '':
name = no_name(file_name, no_title_structures)
no_title_structures += 1

geometries.append(Geometry(symbols=input_molecule[0],
positions=input_molecule[1],
name=name))
Expand All @@ -95,6 +107,8 @@ def get_geometry_from_file_xyz(file_name, read_multiple=False):
warnings.warn('Number of atoms in line {} and number '
'of atoms provided are not equal'.format(n_atoms_line),
errors.MissingAtomWarning)
if name == '':
name = no_name(file_name, no_title_structures)

geometries.append(Geometry(symbols=input_molecule[0],
positions=input_molecule[1],
Expand Down
3 changes: 2 additions & 1 deletion cosymlib/symmetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def dens_measure(self, group):
results = self._get_wfnsym_results(group)
return {'labels': results.SymLab,
'csm': results.csm_dens,
'csm_coef': results.csm_dens_coef}
'csm_coef': results.csm_dens_coef,
'self_assembly': results.self_assembly}

def axes(self, group):
results = self._get_wfnsym_results(group)
Expand Down

0 comments on commit 240abf0

Please sign in to comment.