Skip to content

Commit

Permalink
Blog post: Exploring AiiDA databases - small formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Oct 18, 2024
1 parent 2d990d7 commit a17c546
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions docs/news/posts/2024-10-18-exploring-aiida-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,28 +220,27 @@ qb.append(
tag='bandgap_node'
)

# The previous node (tagged 'bandgap_node') is an outgoing node of a CalcFunctionNode,
# query also for this and tag it as 'bandgap_calc'. (As we're not projecting this, it won't
# show up in the final result, but we can use its tag to query other nodes.)
# Note, we also filter based on the 'function_name' we found earlier, for extra safety.
# The previous node (tagged 'bandgap_node') is an output of a CalcFunctionNode.
# Query also for this and tag it as 'bandgap_calc'. (As we're not projecting this,
# it won't show up in the final result, but we can use it to query related nodes.)
# Let's also filter on the 'function_name' we found earlier, for extra safety.
qb.append(
CalcFunctionNode,
filters={'attributes.function_name': 'get_bandgap_inline'},
with_outgoing='bandgap_node',
tag='bandgap_calc'
)

# Query also for the BandsData (band structure node in AiiDA), that's an input to bandgap_calc
# Query also for the BandsData (band structure), that's an input to bandgap_calc
qb.append(BandsData, with_outgoing='bandgap_calc', tag='band_structure')

# The BandsData was computed by a CalculationNode, query for it as well
qb.append(CalculationNode, with_outgoing='band_structure', tag='qe_calc')

# The previous CalculationNode has the StructureData as input that we want to return in the query.
# Project the whole AiiDA node (indicated with '*')
# The previous CalculationNode has the StructureData as input that we want to
# return in the final query. Project the whole AiiDA node (indicated with '*')
qb.append(StructureData, with_outgoing='qe_calc', project='*')

# So, summarizing, we are projecting two things: the band_gap value and the structure node.
# In summary, we are projecting two things: the band_gap value and the structure.
# Let's iterate over the query results, and print them.
for band_gap, structure in qb.all():
print("Band gap for {}: {:.3f} eV".format(structure.get_formula(), band_gap))
Expand Down

0 comments on commit a17c546

Please sign in to comment.