[ase-users] Superimpose a structural model onto slices through a CHGCAR file (Ga?l Donval)
fabian
Fabian.T89 at web.de
Fri May 19 11:22:48 CEST 2017
Dear Ga?l
Thank you for your tips!
Unfortunatley neither
atoms = read('CHGDIFF', format="vasp")
atoms.wrap()
nor
atoms = read('CHGDIFF', format="vasp")
atoms.set_scaled_positions(atoms.get_scaled_positions())
solve the problem of atoms appearing outside of the unit cell. Is there
any other way to fix this?
I can now supperimose the atom positions, If i plot the atoms like this:
for atom in atoms_filtered:
color = my_colors[atom.number]
radius = radii[atom.number]
struc = pylab.plot(atom.x, atom.y, color=color, linestyle='dashed',
marker='o', markerfacecolor="none", markersize=radius*3,alpha=0.45)
I can superimpose them since my slice has the same xy dimension as the
unit cell. IF i zoom in on the data the marker change their size tough,
but this might be a matplotlib related problem.
If if get the cell infomration via "cell_orig = atoms.get_cell()" and
pass it to the filtered atoms "atoms_filtered.set_cell(cell_orig)" i
still only get an image with the filtered atoms if i plot the
filtered atoms on their own though. Thank you for your Software
recommendations
I know VESTA but i do not like that there is very limited control of the
colormap and you can not superimpose the structure onto slices of the
data i think. I will look into the other solutions you provided.
All the best
Fabian
Am 18.05.2017 um 11:05 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. Superimpose a structural model onto slices through a CHGCAR
> file (fabian)
> 2. Re: Superimpose a structural model onto slices through a
> CHGCAR file (Ga?l Donval)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 17 May 2017 17:38:58 +0200
> From: fabian <Fabian.T89 at web.de>
> To: ase-users at listserv.fysik.dtu.dk
> Subject: [ase-users] Superimpose a structural model onto slices
> through a CHGCAR file
> Message-ID: <b586beab-ee0a-ac00-5ac6-e5cb038571d4 at web.de>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> Dear all,
>
> I want to superimpose a structural model onto slices through a CHGCAR
> file or differences of CHGCAR files.
> Theses slices are displayed with the contour plot from matplotlib.
> My first question is, if there is a script in existence that does this
> which somebody would be willing to share?
>
> At the moment i am trying to plot circles based on the atoms object i
> get from my data. I do want to limit the
> amount of atoms from the structure to only include those which are
> necessary and roughly of the same hightas the slice in question. This is
> were i currently am
> wicht my code:
>
> import numpyas np
> from matplotlibimport pyplot
> from aseimport Atom
> from ase.atomsimport Atoms
> from ase.dataimport covalent_radiias radii
> from ase.data.colorsimport jmol_colors
> from matplotlib.patchesimport Circle
> from ase.ioimport read, write
> fig, ax= pyplot.subplots()
>
>
> atoms= read('CHGDIFF', format="vasp")
> Z_POS=25.5
> maxi= max(a.zfor ain atoms)
> mini= min(a.zfor ain atoms)
> percent=40
> add= ((maxi-mini)/100)*percent
>
>
> if min(a.zfor ain atoms) < Z_POS< max(a.zfor ain atoms):
> filter = [a.indexfor ain atomsif Z_POS-add< a.z<= Z_POS+add]
> atoms_filtered= Atoms([afor ain atomsif a.indexin filter])
>
>
>
> for atomin atoms_filtered:
> color= jmol_colors[atom.number]
> #color = "None"
> radius= radii[atom.number]
> circle= Circle((atom.x, atom.y), (radius/2.5), facecolor=color,edgecolor='k', linewidth=0.4)#alpha=10)
> ax.add_patch(circle)
>
>
>
> ax.axis('equal')
> ax.set_xticks([])
> ax.set_yticks([])
> ax.axis('off')
>
> fig.savefig('out.png',dpi=300)
>
>
>
>
>
>
>
>
> There are a few problems, however.
>
> a) Some atoms are not in the unit cell any more but appear as mirrors on
> the other side after the calculation? Can i shift them back somehow?
> b) if i limit with the "percent" variable the amount of atoms i display
> to not include the slab any more, the plotted picture does not have the
> size of the unicell any more? Can i somehow force it to this size anyways?
> How do i make sure, that i can to a superposition in a way that the
> atoms are always at the corect position with in the slice thru the
> CHGCAR file?
> c) i use jmol_colors to color my structure i would however want to
> change only the colour of the atoms in my slab ( Cu) to be transparent.
> Can i change the corresponding entry in the array
> color = jmol_colors[atom.number] somehow?
> d) Can i somehow connect only the centres of those circles from a
> certain specie such that the molecular structure becomes visible?
> e) I suppose there are much better ways to do this? Could somebody point
> my in the right direction should this be the case?
>
> All the best and thank you in advance
>
> Fabian
>
>
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20170517/02a44fe3/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 18 May 2017 09:05:00 +0000
> From: Ga?l Donval <G.Donval at bath.ac.uk>
> To: "ase-users at listserv.fysik.dtu.dk"
> <ase-users at listserv.fysik.dtu.dk>
> Subject: Re: [ase-users] Superimpose a structural model onto slices
> through a CHGCAR file
> Message-ID: <1495098300.8288.1.camel at bath.ac.uk>
> Content-Type: text/plain; charset="utf-8"
>
>> Dear all,
>>
>> I want to superimpose a structural model onto slices through a
>> CHGCAR
>> file or differences of CHGCAR files.
>> Theses slices are displayed with the contour plot from matplotlib.
>> My first question is, if there is a script in existence that does
>> this
>> which somebody would be willing to share?
> There might be but I am not aware of it. Alternatively, you could try
> to export your structure + density as a cube file and read it in
> Paraview for instance. Paraview would show you the structure and allow
> you to slice your data and do many more things.
>
> But I am quite sure other tools can do it.
>
>> At the moment i am trying to plot circles based on the atoms object
>> i
>> get from my data. I do want to limit the
>> amount of atoms from the structure to only include those which are
>> necessary and roughly of the same hightas the slice in question. This
>> is
>> were i currently am
>> wicht my code:
>>
>> import numpyas np
>> from matplotlibimport pyplot
>> from aseimport Atom
>> from ase.atomsimport Atoms
>> from ase.dataimport covalent_radiias radii
>> from ase.data.colorsimport jmol_colors
>> from matplotlib.patchesimport Circle
>> from ase.ioimport read, write
>> fig, ax= pyplot.subplots()
>>
>>
>> atoms= read('CHGDIFF', format="vasp")
>> Z_POS=25.5
>> maxi= max(a.zfor ain atoms)
>> mini= min(a.zfor ain atoms)
>> percent=40
>> add= ((maxi-mini)/100)*percent
>>
>>
>> if min(a.zfor ain atoms) < Z_POS< max(a.zfor ain atoms):
>> filter = [a.indexfor ain atomsif Z_POS-
>> add< a.z<= Z_POS+add]
>> atoms_filtered= Atoms([afor ain atomsif a.indexin filter])
>>
>>
>>
>> for atomin atoms_filtered:
>> color= jmol_colors[atom.number]
>> #color = "None"
>> radius= radii[atom.number]
>> circle= Circle((atom.x, atom.y), (radius/2.5), facecolor=co
>> lor,edgecolor='k', linewidth=0.4)#alpha=10)
>> ax.add_patch(circle)
>>
>>
>>
>> ax.axis('equal')
>> ax.set_xticks([])
>> ax.set_yticks([])
>> ax.axis('off')
>>
>> fig.savefig('out.png',dpi=300)
> You could directly use matplotlib markers instead of drawing circles
> (you can select the round ones and specify a size).
>
>>
>>
>>
>>
>>
>>
>>
>> There are a few problems, however.
>>
>> a) Some atoms are not in the unit cell any more but appear as mirrors
>> on
>> the other side after the calculation? Can i shift them back somehow?
> atom.wrap() in general, otherwise you will have to play with positions.
>
>
>> b) if i limit with the "percent" variable the amount of atoms i
>> display
>> to not include the slab any more, the plotted picture does not have
>> the
>> size of the unicell any more?
> It would... if only you gave it in your atom constructor. ASE is not
> magical, if you give it:
> Atoms([a for a in atoms if a.index in filter])
> it won't relate that to what you did before because the cell
> information is contained in the `Atoms` object, not in the `Atom` one.
>
>> Can i somehow force it to this size anyways?
> So either specify the cell size upon instanciation or use slicing on
> your `atoms` variable instead of building everything yourself.
>
>> How do i make sure, that i can to a superposition in a way that the
>> atoms are always at the corect position with in the slice thru the
>> CHGCAR file?
> You can make sure of it by checking it.
>
>> c) i use jmol_colors to color my structure i would however want to
>> change only the colour of the atoms in my slab ( Cu) to be
>> transparent.
>> Can i change the corresponding entry in the array
>> color = jmol_colors[atom.number] somehow?
> Yes you can, but I suggest instead that you color the structure
> yourself. That way you can easily use predefined colors in jmol_colors
> while special-casing slab Cu.
>
>> d) Can i somehow connect only the centres of those circles from a
>> certain specie such that the molecular structure becomes visible?
> Yes you can: Python is a proper programming language and matplotlib a
> very capable plotting library. But if your question is actually "can I
> do that without providing any effort", the answer is most likely "no".
> ASE is a toolkit: it is more powerful that almost anything else I know
> of as long as one is willing to dive into it. That's difficult at first
> but then becomes easier and easier.
>
>
>> e) I suppose there are much better ways to do this? Could somebody
>> point
>> my in the right direction should this be the case?
> As I already said, Paraview could be a solution, though it also
> requires (different) work and training to get there. Note also that it
> is not a tool dedicated to chemistry and might seem weird because of
> that. As well, I suppose Vesta, Avogadro, VDM, PyMOL and others are all
> capable to do exactly what you want but it is going to require some
> work.
>
> Regards,
> Ga?l
>
>> All the best and thank you in advance
>>
>> Fabian
>>
>>
>>
>>
>>
>> _______________________________________________
>> ase-users mailing list
>> ase-users at listserv.fysik.dtu.dk
>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 3199 bytes
> Desc: not available
> URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20170518/3cb6001d/attachment.bin>
>
> ------------------------------
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
> End of ase-users Digest, Vol 107, Issue 19
> ******************************************
More information about the ase-users
mailing list