[ase-users] ase-users Digest, Vol 114, Issue 11

Ask Hjorth Larsen asklarsen at gmail.com
Sun Dec 10 12:58:00 CET 2017


2017-12-10 12:00 GMT+01:00 fabian <Fabian.T89 at web.de>:
> Dear Eric,
>
> Thanks once again for your help.
>
> Now i am left with the problem that the cell information and the constraints
> are not written, wich i would
> like to keep.

Oh right, oops.

Actually:

import numpy as np
indices = np.arange(len(atoms))
indices[n_atom] = 0
indices[0] = n_atom
atoms = atoms[indices]

This is the most general way to reorder atoms objects: Creating an
array of indices and slicing the atoms object with the array.

This will preserve the maximum amount of info on the atoms object,
including FixAtoms constraints.

Best regards
Ask

>
> It is easy to just rewrite the cell parameter, but to reflect the
> constraints correctly they have to be
> shifted in the list of constraints depending on whether the poped atom had
> constraints or not.
>
> Unfortunately my code posted below gives me the error:
>
> TypeError: unsupported operand type(s) for +: 'instance' and 'int'
>
> Is it somehow possible to access the list of constaints directly with the
> FixAtoms method and later rewrite them via:
>
> indices = shifted_list
> constraint = FixAtoms(indices=indices)
> atoms.set_constraint(constraints)
>
> or
>
> atoms.set_constraint([FixAtoms(indices=shifted_list)]+new_position)
>
>
> Here is the code that doesnt work:
>
> from ase.io import read, write
> from ase import Atom
> from ase.atoms import Atoms
> from ase.constraints import FixAtoms
>
> n_atom=390
> Filename='CONTCAR'
> atoms = read(Filename)
> cell = atoms.get_cell()
> atoms.resort = None
> constraints=atoms.constraints
> #indices=FixAtoms(constraints).indicies
>
>
> print(constraints)
> print (type(constraints))
> if n_atom not in constraints:
>     print ("yes")
>     #shift_constraints=[x+1 for x in constraints]
>     map(lambda x:x+1, constraints)
> elif n_atom in constraints:
>     pass # n_atom has to be deleted from constraints. And constraints have
> to be shifted by +1.
>            # 0 has to be added to list of constraints
> atoms = Atoms([atoms.pop(n_atom)]) + atoms
>
>
> atoms.set_cell(cell)
> atoms.set_constraint(constraints)
> write('POSCAR', atoms, vasp5=True, sort=False,
> direct=True,long_format=True,format='vasp')
>
>
> Thanks in advance
>
> fabian
>
>
>
> Am 09.12.2017 um 20:34 schrieb Ask Hjorth Larsen:
>>
>> Hi,
>>
>> 2017-12-09 12:16 GMT+01:00 fabian via ase-users
>> <ase-users at listserv.fysik.dtu.dk>:
>>>
>>> Dear Eric,
>>>
>>> Thank you for the clarification!
>>>
>>>
>>> Unfortunately if i try to use your solution like this:
>>>
>>> from ase.io import read, write
>>> from ase import Atom
>>> from ase.atoms import Atoms
>>> from ase.constraints import FixAtoms
>>> n_atom=379
>>> Filename='CONTCAR'
>>> atoms = read(Filename)
>>> atoms = atoms.pop(n_atom) + atoms
>>> write('POSCAR', atoms, vasp5=True, sort=False,
>>> direct=True,long_format=True,
>>> format='vasp')
>>>
>>>
>>> i get the following error:
>>>
>>>
>>> TypeError: unsupported operand type(s) for +: 'Atom' and 'Atoms'
>>
>> Right, the first is an Atom and the second is an Atoms object.  They
>> both need to be Atoms.  Maybe the natural way is something like:
>>
>> atoms = read(Filename)
>> atoms = Atoms([atoms.pop(n_atom)]) + atoms
>>
>> Best regards
>> Ask
>>
>>
>>
>>>
>>> Do you have any suggestion how to resolve this issue?
>>>
>>> All the best and thank you for your reply
>>>
>>>
>>> fabian
>>>
>>>
>>>
>>> Am 08.12.2017 um 23:26 schrieb ase-users-request at listserv.fysik.dtu.dk:
>>>>
>>>> Send ase-users mailing list submissions to
>>>>          ase-users at listserv.fysik.dtu.dk
>>>>
>>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>>          https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>> or, via email, send a message with subject or body 'help' to
>>>>          ase-users-request at listserv.fysik.dtu.dk
>>>>
>>>> You can reach the person managing the list at
>>>>          ase-users-owner at listserv.fysik.dtu.dk
>>>>
>>>> When replying, please edit your Subject line so it is more specific
>>>> than "Re: Contents of ase-users digest..."
>>>>
>>>>
>>>> Today's Topics:
>>>>
>>>>      1. Re: From CIF files to XYZ (Eric Hermes)
>>>>      2. Re: Resort atoms object by atom number (Eric Hermes)
>>>>      3. Re: Thermochemistry (Eric Hermes)
>>>>      4. saxis in vasp calculator (Protik Das)
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>>
>>>> Message: 1
>>>> Date: Fri, 8 Dec 2017 19:08:01 +0000
>>>> From: Eric Hermes <ehermes at chem.wisc.edu>
>>>> To: "ase-users at listserv.fysik.dtu.dk"
>>>>          <ase-users at listserv.fysik.dtu.dk>
>>>> Subject: Re: [ase-users] From CIF files to XYZ
>>>> Message-ID: <1512760079.4568.1.camel at wisc.edu>
>>>> Content-Type: text/plain; charset="utf-8"
>>>>
>>>> On Fri, 2017-12-08 at 18:48 +0000, Landi, Alessandro via ase-users
>>>> wrote:
>>>>>
>>>>> Hello.
>>>>>
>>>>> Obviously, I typed it wrong.
>>>>>
>>>>> Here the right command lines I use:
>>>>>
>>>>> atoms_ase=ase.io.read('filename.cif')
>>>>> ase.io.write('filename.xyz', atoms_ase)
>>>>>
>>>>> Anyway, I have the problem that the xyz file is wrong as I explained
>>>>> in my first e-mail: the molecules need to be reconnected (see files
>>>>> attached).
>>>>
>>>> I don't understand what you mean by "reconnected". Neither xyz file
>>>> that you uploaded contains any information regarding connectivity, and
>>>> ASE doesn't have any conception of connectivity anyway (aside from a
>>>> distance-based metric used in the ASE GUI to draw sticks between nearby
>>>> atoms). The atom ordering produced by ASE is more consistent than the
>>>> "realstructure.xyz" file as compared to the original cif ordering. It
>>>> might be that whatever program you are using with the xyz files expects
>>>> connected atoms to be contiguous; to the best of my knowledge this is
>>>> not typical. If you want to ensure this ordering within ASE, you will
>>>> need to manually rearrange the Atoms object.
>>>>
>>>> Eric
>>>>
>>>>> "pentacene.cif" is the cif file that I give as input to ASE;
>>>>> "pentacene.xyz" is the xyz file written by ASE;
>>>>> "realstructure.xyz" is the structure of the reconnected molecules
>>>>> (obtained using CCDC Mercury)
>>>>>
>>>>> Any suggestions?
>>>>>
>>>>> Best regards,
>>>>> Alessandro
>>>>>
>>>>> Da: Oscar Xavier Guerrero <oscarxavier.ox at gmail.com>
>>>>> Inviato: venerd? 8 dicembre 2017 18:36:10
>>>>> A: Landi, Alessandro
>>>>> Cc: ase-users at listserv.fysik.dtu.dk
>>>>> Oggetto: Re: [ase-users] From CIF files to XYZ
>>>>> ?
>>>>> Hello,
>>>>>
>>>>> When you read the structure an Atoms object is created. You need to
>>>>> store that object on a variable and then you can write that one. As
>>>>> so:
>>>>>
>>>>> First read the data:
>>>>> from ase.io import read, write
>>>>> atoms = read('filename.cif')
>>>>> Then write:
>>>>> write('filename.xyz', atoms)
>>>>> or you can use:
>>>>> atoms.write('filename.xyz')
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 2017-12-08 12:19 GMT+00:00 Landi, Alessandro via ase-users <ase-users
>>>>> @listserv.fysik.dtu.dk>:
>>>>>>
>>>>>> Hello everyone.
>>>>>>
>>>>>> I am using ASE to read some CIF files and (among other things) to
>>>>>> convert the structure in xyz format.
>>>>>>
>>>>>> However using the following commands:
>>>>>>
>>>>>> ase.io.read('filename.cif', atoms_ase)
>>>>>> ase.io.write('filename.xyz', atoms_ase)
>>>>>>
>>>>>> I obtain a wrong structure, since the molecules need to be
>>>>>> reconnected. This happens for all the molecules I have tested
>>>>>> (about 20).
>>>>>>
>>>>>> Could you please explain me what I am doing wrong?
>>>>>>
>>>>>> If could be of any help, I attached an example:
>>>>>> "pentacene.cif" is the cif file that I give as input to ASE;
>>>>>> "pentacene.xyz" is the xyz file written by ASE;
>>>>>> "realstructure.xyz" is the structure of the reconnected molecules
>>>>>> (obtained using CCDC Mercury)
>>>>>>
>>>>>> Best regards,
>>>>>> Alessandro
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> ase-users mailing list
>>>>>> ase-users at listserv.fysik.dtu.dk
>>>>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>>>>
>>>>> _______________________________________________
>>>>> ase-users mailing list
>>>>> ase-users at listserv.fysik.dtu.dk
>>>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 2
>>>> Date: Fri, 8 Dec 2017 19:15:01 +0000
>>>> From: Eric Hermes <ehermes at chem.wisc.edu>
>>>> To: "ase-users at listserv.fysik.dtu.dk"
>>>>          <ase-users at listserv.fysik.dtu.dk>
>>>> Subject: Re: [ase-users] Resort atoms object by atom number
>>>> Message-ID: <1512760499.4568.3.camel at wisc.edu>
>>>> Content-Type: text/plain; charset="utf-8"
>>>>
>>>> On Fri, 2017-12-08 at 19:47 +0100, fabian via ase-users wrote:
>>>>>
>>>>> Dear all,
>>>>> I read a POSCAR file into an atoms object via
>>>>> atoms = read("POSCAR")
>>>>> now i want to resort the atoms object such that the atom with the
>>>>> Number n_atom is moved from its postion to the index 0?
>>>>> (1 if not counted the pythonic way), such that it is later writen as
>>>>> the first entry? into the atoms object.?
>>>>> later i want to write the object via:
>>>>> write('POSCAR', atoms, vasp5=True, sort=False,
>>>>> direct=True,long_format=True, format='vasp')
>>>>> and have the entry corresponding to n_atom as the first Atom in the
>>>>> POSCAR file. I found a dirty workaround with temp files but
>>>>> this means i have to convert each initial structure to the right
>>>>> format . Else i create wrong files.
>>>>> Is this possible within ASE?
>>>>> On a side not if i pop an atom via:
>>>>> atoms.pop( n_atom)
>>>>>
>>>>> is n_atom defined the pythonic way and starting at 0?
>>>>
>>>> To start by answering your last question: yes, everything in ASE is 0-
>>>> indexed. Note that this is not only the Pythonic way, it is a common
>>>> standard used by most languages with some notable exceptions (Fortran,
>>>> Julia, and R probably being the most relevant).
>>>>
>>>> In fact, you should be able to use Atoms.pop() to do exactly what you
>>>> want. Try the following:
>>>>
>>>> atoms = atoms.pop(n_atom) + atoms
>>>>
>>>> One other thing is that when ASE sorts VASP POSCAR files, the first
>>>> atom will never change place, so sort=False is not completely necessary
>>>> (you can still use it if you want to though).
>>>>
>>>> Eric
>>>>
>>>>> Al the best
>>>>> fabian
>>>>> ?_______________________________________________
>>>>> ase-users mailing list
>>>>> ase-users at listserv.fysik.dtu.dk
>>>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 3
>>>> Date: Fri, 8 Dec 2017 19:25:11 +0000
>>>> From: Eric Hermes <ehermes at chem.wisc.edu>
>>>> To: "ase-users at listserv.fysik.dtu.dk"
>>>>          <ase-users at listserv.fysik.dtu.dk>
>>>> Subject: Re: [ase-users] Thermochemistry
>>>> Message-ID: <1512761110.4568.5.camel at wisc.edu>
>>>> Content-Type: text/plain; charset="utf-8"
>>>>
>>>> On Fri, 2017-12-08 at 14:53 +0300, Alexander Romanov via ase-users
>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I investigate diffusion of atoms on metal surfaces and want to use
>>>>> thermochemistry module for energy estimation of transition states.
>>>>> What can I do with imaginary frequencies?? If I understand properly,
>>>>> Gaussian simply subtract them from calculation, but ase module can't
>>>>> do this automatically.? Can I do the same manually??
>>>>
>>>> Which frequencies you pass to the Thermo classes is up to you. You are
>>>> free to exclude any imaginary frequencies returned by the Vibrations
>>>> class from the list you pass to the Thermo class if you want.
>>>>
>>>> However, be aware of what you are doing by excluding certain
>>>> frequencies from the Thermo classes. You need to ensure that you are
>>>> considering all 3N degrees of freedom of your system.
>>>>
>>>> For an ideal gas, 5 or 6 of those are translations/rotations, so 5 or 6
>>>> of your vibrational frequencies should be small and potentially
>>>> imaginary (since you will capture the effects of those modes with a
>>>> rigid rotor/particle in a box model separately).
>>>>
>>>> In the context of transition state theory, you actually are removing a
>>>> degree of freedom from your system, so the imaginary mode of a
>>>> transition state corresponding to the reaction coordinate should be
>>>> removed from the thermodynamic analysis.
>>>>
>>>> In most other cases, simply removing a vibrational frequency will
>>>> result in significant errors in the system entropy, which is very
>>>> important if you are trying to compare the free energy of two system
>>>> configurations.
>>>>
>>>> Eric
>>>>
>>>>> Best regards,
>>>>> Alex
>>>>> _______________________________________________
>>>>> ase-users mailing list
>>>>> ase-users at listserv.fysik.dtu.dk
>>>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>>
>>>>
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 4
>>>> Date: Fri, 8 Dec 2017 14:25:43 -0800
>>>> From: Protik Das <protik77 at gmail.com>
>>>> To: Eric Hermes via ase-users <ase-users at listserv.fysik.dtu.dk>
>>>> Subject: [ase-users] saxis in vasp calculator
>>>> Message-ID:
>>>>
>>>> <CADFNK8Urug3oj5h342dv2JAhLAjbMkVJa-rUYSCX6aoz2Ysxfw at mail.gmail.com>
>>>> Content-Type: text/plain; charset="utf-8"
>>>>
>>>> Hi all,
>>>>
>>>> I am trying to set saxis keyword using the vasp calculator of ase. But
>>>> unfortunately the INCAR file does not have the keyword. I tried giving a
>>>> numpy array and a list as input but no luck.
>>>>
>>>> With the saxis in the calculator object, there is an empty line in the
>>>> INCAR file which is not there without the keyword. I am using ASE 3.15.0
>>>> with python 3.6.3.
>>>>
>>>> Any help regarding this will be really appreciated.
>>>>
>>> _______________________________________________
>>> ase-users mailing list
>>> ase-users at listserv.fysik.dtu.dk
>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
>


More information about the ase-users mailing list