Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified the ArkaneSpecies.update_xyz_string() method #1714

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions arkane/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import rmgpy.constants as constants
from rmgpy import __version__
from rmgpy.molecule.element import elementList
from rmgpy.molecule.element import elementList, getElement
from rmgpy.molecule.translator import toInChI, toInChIKey
from rmgpy.pdep.collision import SingleExponentialDown
from rmgpy.quantity import ScalarQuantity, ArrayQuantity
Expand Down Expand Up @@ -195,26 +195,22 @@ def update_species_attributes(self, species=None):

def update_xyz_string(self):
"""
Return an xyz string built from self.conformer
Generate an xyz string built from self.conformer, and standardize the result
Returns:
str: 3D coordinates in an XYZ format.
"""
xyz_list = list()
if self.conformer is not None and self.conformer.number is not None:
# generate the xyz-format string from the Conformer coordinates
xyz_string = '{0}\n{1}'.format(len(self.conformer.number.value_si), self.label)
for i, coorlist in enumerate(self.conformer.coordinates.value_si):
for element in elementList:
if element.number == int(self.conformer.number.value_si[i]):
element_symbol = element.symbol
break
else:
raise ValueError('Could not find element symbol corresponding to atom number {0}'.format(
self.conformer.number.value_si[i]))
xyz_string += '\n{0} {1} {2} {3}'.format(element_symbol,
coorlist[0],
coorlist[1],
coorlist[2])
else:
xyz_string = ''
return xyz_string
# generate the xyz-format string from self.conformer.coordinates and self.conformer.number
xyz_list.append(str(len(self.conformer.number.value_si)))
xyz_list.append(self.label)
for number, coordinate in zip(self.conformer.number.value_si, self.conformer.coordinates.value_si):
element_symbol = getElement(int(number)).symbol
row = '{0:4}'.format(element_symbol)
row += '{0:14.8f}{1:14.8f}{2:14.8f}'.format(*(coordinate * 1e10).tolist()) # convert m to Angstrom
xyz_list.append(row)
return '\n'.join(xyz_list)

def save_yaml(self, path):
"""
Expand Down
12 changes: 11 additions & 1 deletion arkane/commonTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,18 @@ def test_create_and_load_yaml(self):
self.assertEqual(arkane_spc.level_of_theory, 'cbs-qb3')
self.assertIsInstance(arkane_spc.thermo_data, ThermoData)
self.assertTrue(arkane_spc.use_hindered_rotors)
self.assertTrue('C 7.54e-14 1.193e-13 5.52e-14' in arkane_spc.xyz)
self.assertIsInstance(arkane_spc.chemkin_thermo_string, str)
expected_xyz = """8
C2H6
C 0.00075400 0.00119300 0.00055200
H 0.00074000 0.00117100 1.09413800
H 1.04376600 0.00117100 -0.32820200
H -0.44760300 0.94289500 -0.32825300
C -0.76014200 -1.20389600 -0.55748300
H -0.76012800 -1.20387400 -1.65106900
H -0.31178500 -2.14559800 -0.22867800
H -1.80315400 -1.20387400 -0.22872900"""
self.assertEqual(arkane_spc.xyz, expected_xyz)

def test_load_existing_yaml(self):
"""
Expand Down