Commit b59dc5a5 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed client documentation.

parent 684b3bad
......@@ -9,33 +9,22 @@ from nomad.metainfo import units
query = ArchiveQuery(
# url='http://nomad-lab.eu/prod/rae/beta/api',
query={
'$and': [
{'dft.code_name': 'VASP'},
{'$gte': {'n_atoms': 3}},
{'$lte': {'dft.workflow.section_relaxation.final_energy_difference': 1e-24}}
]
'dft.code_name': 'VASP'
},
required={
'section_workflow': {
'section_relaxation': {
'final_calculation_ref': {
'energy_total': '*',
'single_configuration_calculation_to_system_ref': {
'chemical_composition_reduced': '*'
}
}
}
'section_run': {
'section_single_configuration_calculation': '*',
'section_system': '*'
}
},
parallel=10,
per_page=1000,
max=10000)
per_page=10,
max=100)
print(query)
for i, result in enumerate(query):
if i < 10:
calc = result.section_workflow.section_relaxation.final_calculation_ref
calc = result.section_run[0].section_single_configuration_calculation[-1]
energy = calc.energy_total
formula = calc.single_configuration_calculation_to_system_ref.chemical_composition_reduced
print('%s: energy %s' % (formula, energy.to(units.hartree)))
print(query)
'''
A simple example that uses the NOMAD client library to access the archive.
'''
from nomad.client import ArchiveQuery
from nomad.metainfo import units
query = ArchiveQuery(
query={
'$and': [
{'dft.code_name': 'VASP'},
{'$gte': {'n_atoms': 3}},
{'$lte': {'dft.workflow.section_geometry_optimization.final_energy_difference': 1e-24}}
]
},
required={
'section_workflow': {
'calculation_result_ref': {
'energy_total': '*',
'single_configuration_calculation_to_system_ref': {
'chemical_composition_reduced': '*'
}
}
}
},
parallel=10,
per_page=10,
max=100)
for i, result in enumerate(query):
if i < 10:
calc = result.section_workflow.calculation_result_ref
energy = calc.energy_total
formula = calc.single_configuration_calculation_to_system_ref.chemical_composition_reduced
print('%s: energy %s' % (formula, energy.to(units.hartree)))
print(query)
......@@ -300,13 +300,19 @@ class ArchiveQueryResource(Resource):
per_page=per_page, page=page, order_by='upload_id')
except KeyError as e:
abort(400, str(e))
abort(400, 'The query part contained an unknown quantity or section: %s' % str(e))
try:
required_with_references = compute_required_with_referenced(required)
except KeyError as e:
abort(
400,
message='The required part contained an unknown quantity or section: %s' % str(e))
data = []
calcs = results['results']
upload_files = None
current_upload_id = None
required_with_references = compute_required_with_referenced(required)
archive_is_complete = False
if required_with_references is not None:
archive_is_complete = True
......
......@@ -35,7 +35,7 @@ source distribution
First example
_____________
.. literalinclude:: ../examples/client.py
.. literalinclude:: ../examples/archive/client.py
:language: python
This script should yield a result like this:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment