[ase-users] castep interface
Glenn Jones
glenn.jones at ucl.ac.uk
Tue Sep 13 15:06:08 CEST 2011
Hi,
My version of python is old;
[gjones at Elrohir ~]$ python -V
Python 2.4.3
Having just tried to yum update python it gave me no options (I'm running
Centos 5.6). I have just looked at the internet (very briefly) and found a
few discussion boards suggesting python 2.6 needs to be installed in
parallel if it is needed
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=16800
Glenn
> Hi,
>
> thanks for the feedback (and the fixes)! From a first glance I think
> in fact most issues are related to the python version (as you said).
> However if these changes do not break "forward compatiblity" I see no
> good reason not to take them.
>
> @Glenn Jones: could you post which version of the python interpreter
> you are currently using ? (python -V will do). If that number is < 2.6
> couldn't hurt to update python.
>
> @Developers: is there any common rule as to how far back python
> versions should be supported?
>
> @Jens: I can test these changes and turn them into a *patch (much) later
> today.
>
> Cheers,
> Max.
>
> On Tue, Sep 13, 2011 at 1:17 PM, Glenn Jones <glenn.jones at ucl.ac.uk>
> wrote:
>> Hi,
>>
>> I have come across a few problems with the Castep interface - I have
>> tried
>> to find some solutions and in the end did manage to get the test
>> castep_interface.py to run. I have yet to try the interface with a full
>> calculation.
>>
>> Firstly, I tried to run the castep.py module to create
>> castep_keywords.py,
>> but came across what are either a couple of bugs or perhaps some
>> incompatibility in my version of python and the python syntax used. In
>> order to get keywords to be generated I made the following changes - I
>> hope the modifications I suggest don't change the intended logic of the
>> code:
>>
>> 1)
>>
>> from ..io.castep import write_cell
>>
>> I changed this to:
>>
>> from io.castep import write_cell
>>
>> 2)
>> File "castep.py", line 736
>> constraints = self.atoms.constraints if self.atoms else []
>> ^
>> SyntaxError: invalid syntax
>>
>> I changed this to a long winded way, which I think says what is intended
>> above:
>> if self.atoms:
>> constraints = self.atoms.constraints
>> else:
>> constraints = []
>>
>> 3)
>> File "castep.py", line 1026
>> interface_options = self._opt if self._export_settings else None
>> ^
>> SyntaxError: invalid syntax
>>
>> likewise, I changed this to:
>> if self._export_settings:
>> interface_options = self._opt
>> else:
>> interface_options =None
>>
>> 4)
>> File "castep.py", line 1881
>> opt_castep_command = ''.join(args) if args else ''
>>
>> Which I changed to:
>> if args:
>> opt_castep_command = ''.join(args)
>> else:
>> opt_castep_command = ''
>> ______________________________________________________
>>
>> After making the above changes keywords is created with an error, the
>> following line also appears to need to be changed:
>>
>> 5) CASTEP v5.502, fetched 370 keywords
>> invalid syntax (castep_keywords.py, line 4)
>> Ooops, something went wrong with the CASTEP keywords
>>
>> class Opt():
>> should perhaps be
>> class Opt:
>>
>> by modifying line 1415 to become:
>> fh.write('class Opt:\n')
>> _______________________________________________
>> I then tried to run castep_interface.py in the tests and came across
>> some
>> other issues (similar to the above), related to io.castep.py:
>> 6)
>> File "<stdin>", line 1, in ?
>> File "/home/gjones/ase/ase/io/castep.py", line 197
>> icomment = min([line.index(c) if c in line else len(line) for
>>
>> which I have changed to:
>> for c in comment_chars:
>> if c in line:
>> icomment = min(line.index(c))
>> else:
>> icomment = len(line)
>>
>> (I don't this is quite the same - but it didn't give an error)
>>
>> 7)
>> File "<stdin>", line 1, in ?
>> File "/home/gjones/ase/ase/io/castep.py", line 419
>> energy = energy_0K if energy_0K else energy_total
>>
>> which I have changed to:
>> if energy_0K:
>> energy = energy_0K
>> else:
>> energy = energy_total
>>
>> then castep_interface.py I need to be change:
>>
>> 8)
>> __import__(ase_castep_dir + ".io.castep")
>>
>> I changed to:
>>
>> __import__(ase_castep_dir_patched+".io.castep")
>>
>> 9)
>> Traceback (most recent call last):
>> File "castep_interface.py", line 60, in ?
>> assert False, 'Could not instantiate castep calculator'
>> AssertionError: Could not instantiate castep calculator
>>
>> so before line 60 I added:
>>
>> from ase.calculators.castep import Castep
>>
>> Which gave another problem:
>>
>> 10)
>> /usr/lib64/openmpi/1.4-gcc/bin/mpirun
>> /home/gjones/bin/castep-5.5.2c-openmpi
>> Traceback (most recent call last):
>> File "castep_interface.py", line 57, in ?
>> c = Castep(directory=tmp_dir, label='test_label')
>> File "/home/gjones/ase/ase/calculators/castep.py", line 344, in
>> __init__
>> from io.castep import write_cell
>> ImportError: No module named io.castep
>> No module named io.castep ,
>>
>> that I resolved by changing line 344 to:
>> from ase.io.castep import write_cell
>>
>>
>> ___________________________________________________
>>
>> With the above changes the test ran. However, with the changes I have
>> made
>> I am not totally confident that I haven't broken anything, or
>> unnecessarily modified something that could have been done in a more
>> simple manner.
>>
>> I have attached my modified files, if they are of any help.
>>
>> Best regards,
>>
>> Glenn
>>
>>
>> _______________________________________________
>> ase-users mailing list
>> ase-users at listserv.fysik.dtu.dk
>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>
>
>
>
> --
> Max J. Hoffmann
> Tel: +4989 289 13607 (office)
> Room CH63107
> TU München
> Lichtenbergstr. 4
> D-85747 Garching
>
More information about the ase-users
mailing list