mhoffman/kmos — Issue #3: Multi-line species representation
Author: MaximeVdB
Created: 2012-02-06 13:42:58+00:00
State: open

Hey,

When using get_ase_constructor, one commonly gets an Atoms string which spans multiple lines.
I have the impression that in the representation of species, only single quotes together with \ or \n\ will give the right result in the kmc_settings.py file.

it would be convenient, however, if one could simply use the multi-line string " " " <...> " " " , just like in the lattice representation.

Example:

pt.add_species(name='HYDR',
color='#000000',
representation = """Atoms(symbols='H',
pbc=np.array([False, False, False], dtype=bool),
cell=np.array(
[[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]]),
scaled_positions=np.array(
[[ 0. , 0. , 0.5]]))""")

With or without brackets around the Atoms(...), this would result in a representation of the species in kmc_settings.py with only single quotes, leading to the following error when starting the run (no errors during build):

Traceback (most recent call last):
File "kmos_api_speedtest.py", line 6, in
model = KMC_Model(print_rates=False, banner=False)
File "/home/maxime/.local/lib/python2.6/site-packages/kmos/run.py", line 87, in __init__
self.parameters = Model_Parameters(self.print_rates)
File "/home/maxime/.local/lib/python2.6/site-packages/kmos/run.py", line 565, in __init__
self.__dict__.update(settings.parameters)
AttributeError: 'NoneType' object has no attribute 'parameters'

If, however, the following is use instead:
pt.add_species(name='HYDR',
color='#000000',
representation = "Atoms(symbols='H',\
pbc=np.array([False, False, False], dtype=bool),\
cell=np.array(\
[[ 1., 0., 0.],\
[ 0., 1., 0.],\
[ 0., 0., 1.]]),\
scaled_positions=np.array(\
[[ 0. , 0. , 0.5]]))")

everything runs as it should.

Maxime