How-to guides

The tools of ASR can be combined to perform complicated tasks with little effort. Below you will find the recommended procedures to perform common tasks within the ASR framework.

How-to: Collect a tree to folders and open in browser

Suppose you have a set of folders with a structure like:

tree/A/Mn/
tree/AB/MnI2/
tree/*/*/
etc.

Then collect the database with:

$ asr run "database.fromtree tree/*/*/"

And open a local web server with:

$ asr run "database.app database.db"

Now browse it with:

$ firefox localhost:5000

How-to: Submit a recipe with MyQueue

It is also recommended to use these recipes together with the myqueue job managing package. We assume that you have installed the myqueue-package and are familiar with its usage. If you are not, then take a look at its excellent documentation. To submit a job that relaxes a structure simply do:

$ mq submit asr.relax -R 24:10h

You can also specify arguments with:

$ mq submit "asr.relax --allow-symmetry-breaking" -R 24:10h

How-to: Generate figures from a certain recipe

Let’s assume that the bandstructure has been calculated and you want to display the results. Then it’s as simple as using the asr results cli sub-command:

$ asr results asr.bandstructure

which will save any figures generated by the webpanel associated with asr.bandstructure in the current folder.

How-to: Continue working on a packaged project

Suppose that you want to continue working on a previously packaged project, for example, to calculate a new property. Suppose the project is packaged as project.db, and that you only want to unpack the ground state results since your new recipe does not need other results in the database.

To unpack the project do:

$ asr run "database.totree project.db --run --patterns results-asr.gs.json,gs.gpw"

Then perform the calculations needed in the unpacked folders. When calculations are done package them and merge the databases:

$ asr run "database.fromtree tree/*/*/*/"
$ asr run "database.merge project.db database.db merged.db"

The databases have now been merged into a new database called merged.db.

How-to: Save and instantiate result objects

Here we are creating results object, converting it to a dict and converting it back to a result object

>>> import numpy as np
>>> from asr.core import decode_object
>>> from asr.piezoelectrictensor import Result
>>> result = Result.fromdata(eps_vvv=np.ones((3, 3, 3), float), eps_clamped_vvv=np.ones((3, 3, 3), float))
>>> dct = result.format_as('dict')
>>> result = decode_object(dct)

How-to: Select rows in database with results from specific recipe

When a database has been collected with asr.database.fromtree it automatically saves a special key-value-pair named as has_asr_recipename. Concretely if asr.gs@calculate is calculated for the specific row then it will have the has_asr_gs_calculate key-value-pair defined. To select all rows where asr.gs@calculate is done then simply do

$ ase db database.db has_asr_gs_calculate

to select those rows.

How-to: Retrive results from database

Suppose you have a database database.db from which you want to extract some results for further treatment. Suppose that data is the results of the asr.bandstructure recipe. Then do

from ase.db import connect
from asr.database import parse_row_data
db = connect('database.db')

bandstructure_results = []
for row in db.select('has_asr_bandstructure'):
    data = parse_row_data(row.data)
    bs = data['results-asr.bandstructure.json']
    bandstructure_results.append(bs)

>