差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

ab_initio:subsetオブジェクト 2009/02/03 00:18 現在
ライン 1: ライン 1:
 +====== Subsetオブジェクト ======
 +
 +Using the Subset filter you can make a subset of a listofatoms object. You construct the filter like this:
 +<code python>
 +from ASE.Filters.Subset import Subset
 +m = Subset(atoms,mask=mask)
 +</code>
 +... or
 +<code python>
 +m = Subset(atoms,indices=indices)
 +</code>
 +mask is a list of length N, N being the number of atoms. A zero value for an element in mask signifies that this atoms is not included in the subset.
 +
 +indices is a list of indices for atoms which should be included in the subset.
 +
 +It can be usefull if you have many atoms, to use the tag attribute on the individual atoms then constructing the listofatoms object (see atoms).
 +
 +By setting a non zero tag (ex 117) on all the static atoms, the mask can be constructed like:
 +
 +<code python>
 +mask = [a.GetTag() != 117 for a in atoms]
 +</code>
 +
 +Example of use (freezing some degrees of freedom):
 +
 +<code python>
 +>>> from ASE import Atom, ListOfAtoms
 +>>> from ASE.Filters.Subset import Subset
 +>>> m = ListOfAtoms([Atom('O', (0, 0, 0), tag=117),
 +...                  Atom('H', (0.773, 0.600, 0)),
 +...                  Atom('H', (-0.773, 0.600, 0))])
 +>>> m1 = Subset(m, indices=[1, 2])
 +>>> m2 = Subset(m, mask=[0, 1, 1])
 +>>> mask=[a.GetChemicalSymbol() == 'H' for a in m]
 +>>> mask
 +[0, 1, 1]
 +>>> m3 = Subset(m, mask=mask)
 +>>> m4 = Subset(m, mask=[a.GetTag() != 117 for a in m])
 +>>>
 +>>> m5 = Subset(m, indices=[0])
 +>>> m6 = Subset(m, mask=[1, 0, 0])
 +>>> m7 = Subset(m, mask=[a.GetChemicalSymbol() == 'O' for a in m])
 +>>> m8 = Subset(m, mask=[a.GetTag() == 117 for a in m])
 +>>>
 +>>> m4.GetCartesianPositions()
 +array([[ 0.773,  0.6  ,  0.  ],
 +      [-0.773,  0.6  ,  0.  ]])
 +>>> m8.GetCartesianPositions()
 +array([      [ 0.,  0.,  0.]])
 +</code>
 +The first four filters are idential - they all behave like ListOfAtoms objects with only two hydrogen atoms. The last four filters all behave like ListOfAtoms objects with only one oxygen atom.
ab_initio/subsetオブジェクト.txt · 最終更新: 2009/02/03 00:18 by kimi
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0