Displaying AiiDA data types#

import io
from os import path
from aiida.plugins import DataFactory
from aiidalab_widgets_base import viewer

Dict#

Dict = DataFactory('core.dict')
p = Dict(dict={
    'Parameter'   :'super long string '*4,
    'parameter 2' :'value 2',
    'parameter 3' : 1,
    'parameter 4' : 2,
})
vwr = viewer(p.store(), downloadable=True)
display(vwr)
# create molecule
from ase.build import molecule
m = molecule('H2O')
m.center(vacuum=2.0)

CifData#

CifData = DataFactory('core.cif')
s = CifData(ase=m)
vwr = viewer(s.store(), configuration_tabs=['Selection', 'Appearance', 'Cell', 'Download'])
display(vwr)

StructureData#

StructureData = DataFactory('core.structure')
s = StructureData(ase=m)
vwr = viewer(s.store())
display(vwr)

BandsData#

import numpy as np
BandsData = DataFactory('core.array.bands')
bs = BandsData()
kpoints = np.array([[0.    , 0.    , 0.    ], # array shape is 12 * 3
       [0.1   , 0.    , 0.1   ],
       [0.2   , 0.    , 0.2   ],
       [0.3   , 0.    , 0.3   ],
       [0.4   , 0.    , 0.4   ],
       [0.5   , 0.    , 0.5   ],
       [0.5   , 0.    , 0.5   ],
       [0.525 , 0.05  , 0.525 ],
       [0.55  , 0.1   , 0.55  ],
       [0.575 , 0.15  , 0.575 ],
       [0.6   , 0.2   , 0.6   ],
       [0.625 , 0.25  , 0.625 ]])

bands = np.array([
    [-5.64024889,  6.66929678,  6.66929678,  6.66929678,  8.91047649], # array shape is 12 * 5, where 12 is the size of the kpoints mesh
    [-5.46976726,  5.76113772,  5.97844699,  5.97844699,  8.48186734], # and 5 is the number of states
    [-4.93870761,  4.06179965,  4.97235487,  4.97235488,  7.68276008],
    [-4.05318686,  2.21579935,  4.18048674,  4.18048675,  7.04145185],
    [-2.83974972,  0.37738276,  3.69024464,  3.69024465,  6.75053465],
    [-1.34041116, -1.34041115,  3.52500177,  3.52500178,  6.92381041],
    [-1.34041116, -1.34041115,  3.52500177,  3.52500178,  6.92381041],
    [-1.34599146, -1.31663872,  3.34867603,  3.54390139,  6.93928289],
    [-1.36769345, -1.24523403,  2.94149041,  3.6004033 ,  6.98809593],
    [-1.42050683, -1.12604118,  2.48497007,  3.69389815,  7.07537154],
    [-1.52788845, -0.95900776,  2.09104321,  3.82330632,  7.20537566],
    [-1.71354964, -0.74425095,  1.82242466,  3.98697455,  7.37979746]])
bs.set_kpoints(kpoints)
bs.set_bands(bands)
labels = [(0, u'GAMMA'),
          (5, u'X'),
          (6, u'Z'),
          (11, u'U')]
bs.labels = labels
vwr = viewer(bs.store(), downloadable=True)
display(vwr)

FolderData#

FolderData = DataFactory('core.folder')
fd = FolderData()
with io.StringIO('content of test1 filelike') as fobj:
    fd.put_object_from_filelike(fobj, path='test1.txt')
with io.StringIO('content of test2 filelike') as fobj:
    fd.put_object_from_filelike(fobj, path='test2.txt')
with io.StringIO(u'content of test_long file'*1000) as fobj:
    fd.put_object_from_filelike(fobj, path='test_long.txt')
vwr = viewer(fd.store(), downloadable=True)
display(vwr)

Workfunctions and Calcfunctions#

from aiida.workflows.arithmetic.add_multiply import add, add_multiply
from aiida.engine import run_get_node
from aiida.orm import Int
result, workfunction = run_get_node(add_multiply, Int(3), Int(4), Int(5))
display(viewer(workfunction))
result, calcfunction = run_get_node(add, Int(3), Int(4))
display(viewer(calcfunction))