[ase-users] Superimpose a structural model onto slices through a CHGCAR file
Gaël Donval
G.Donval at bath.ac.uk
Thu May 18 11:05:00 CEST 2017
> 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-0001.bin>
More information about the ase-users
mailing list