File: basics.rst

package info (click to toggle)
python-ase 3.26.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (175 lines) | stat: -rw-r--r-- 5,279 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
=======================================
ase-gui basics and command line options
=======================================

General use
-----------

Visualizing a system with ASE's GUI is straight-forward using a regular
mouse. The scroll function allows to change the magnification, the
left mouse button selects atoms, the right mouse button allows to
rotate, and the middle button allows to translate the system on the
screen.

Depending on the number of selected atoms, :ref:`ase-gui` automatically measures
different quantities:

================================= ======================================
Selection                         measurement
================================= ======================================
single atom                       xyz position and atomic symbol
two atoms                         interatomic distance and symbols
three atoms                       all three internal angles and
                                  symbols
four atoms, selected sequentially Measures the dihedral angle,
                                  e.g. the angle between bonds 12 and 34
more than four atoms              chemical composition of selection.
================================= ======================================


Files
-----

The :ref:`ase-gui` program can read all the file formats the ASE's
:func:`~ase.io.read` function can understand.

::

  $ ase gui N2Fe110-path.traj


Selecting part of a trajectory
------------------------------

A Python-like syntax for selecting a subset of configurations can be
used.  Instead of the Python syntax ``list[start:stop:step]``, you use
:file:`filaname@start:stop:step`::

  $ ase gui x.traj@0:10:1  # first 10 images
  $ ase gui x.traj@0:10    # first 10 images
  $ ase gui x.traj@:10     # first 10 images
  $ ase gui x.traj@-10:    # last 10 images
  $ ase gui x.traj@0       # first image
  $ ase gui x.traj@-1      # last image
  $ ase gui x.traj@::2     # every second image

If you want to select the same range from many files, the you can use
the ``-n`` or ``--image-number`` option::

  $ ase gui -n -1 *.traj   # last image from all files
  $ ase gui -n 0 *.traj    # first image from all files

.. tip::

  Type :command:`ase gui -h` for a description of all command line options.


Writing files
-------------

::

  $ ase gui -n -1 a*.traj -o new.traj

Possible formats are: ``traj``, ``xyz``, ``cube``, ``pdb``, ``eps``,
``png``, and ``pov``.  For details, see the :mod:`~ase.io` module
documentation.


Interactive use
---------------

The :ref:`ase-gui` program can also be launched directly from a Python
script or interactive session:

>>> from ase import *
>>> atoms = ...
>>> view(atoms)

or

>>> view(atoms, repeat=(3, 3, 2))

or, to keep changes to your atoms:

>>> atoms.edit()

Use :meth:`ase.gui.gui.GUI.repeat_poll` to interact programmatically
with the GUI, for example to monitor an ongoing calculation
and update the display on the fly.

.. automethod:: ase.gui.gui.GUI.repeat_poll

NEB calculations
----------------

Use :menuselection:`Tools --> NEB` to plot energy barrier.

::

  $ ase gui --interpolate 3 initial.xyz final.xyz -o interpolated_path.traj


Plotting data from the command line
-----------------------------------
Plot the energy relative to the energy of the first image as a
function of the distance between atom 0 and 5::

  $ ase gui -g "d(0,5),e-E[0]" x.traj
  $ ase gui -t -g "d(0,5),e-E[0]" x.traj > x.dat  # No GUI, write data to stdout

The symbols are the same as used in the plotting data function.


Defaults
--------

Using a file ``~/.ase/gui.py``, certain defaults can be set. If it exists,
this file is executed after initializing the variables and colors
normally used in ASE. One can change the default graphs that are
plotted, and the default radii for displaying specific atoms. This
example will display the energy evolution and the maximal force in a
graph and also display Cu atoms (Z=29) with a radius of 1.6 Angstrom.

::

  gui_default_settings['gui_graphs_string'] = "i, e - min(E), fmax"
  gui_default_settings['covalent_radii'] = [[29,1.6]]


.. _high contrast:

High contrast settings
----------------------

In revision 2600 or later, it is possible to change the foreground and
background colors used to draw the atoms, for instance to draw white
graphics on a black background. This can be done in ``~/.ase/gui.py``.

::

  gui_default_settings['gui_foreground_color'] = '#ffffff' #white
  gui_default_settings['gui_background_color'] = '#000000' #black

To change the color scheme of graphs it is necessary to change the
default behaviour of Matplotlib in a similar way by using a file
``~/.matplotlib/matplotlibrc``.

::

  patch.edgecolor  : white
  text.color       : white
  axes.facecolor   : black
  axes.edgecolor   : white
  axes.labelcolor  : white
  axes.color_cycle : b, g, r, c, m, y, w
  xtick.color      : white
  ytick.color      : white
  grid.color       : white
  figure.facecolor : 0.1
  figure.edgecolor : black

Finally, the color scheme of the windows themselves (i.e. menus, buttons
and text etc.) can be changed by choosing a different desktop theme. In
Ubuntu it is possible to get white on a dark background by selecting the
theme HighContrastInverse under Appearances in the system settings dialog.