Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
f6984dfc
Commit
f6984dfc
authored
Jun 08, 2020
by
Lauri Himanen
Browse files
Fixed issue with API, refactored BZ information into proper metainfo.
parent
63df2a63
Pipeline
#76266
passed with stages
in 22 minutes and 26 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/app/api/encyclopedia.py
View file @
f6984dfc
...
...
@@ -789,16 +789,16 @@ statistics = api.model("statistics", {
"histogram"
:
fields
.
Nested
(
histogram
)
})
statistics_result
=
api
.
model
(
"statistics_result"
,
{
"cell_volume"
:
fields
.
Nested
(
statistics
),
"atomic_density"
:
fields
.
Nested
(
statistics
),
"mass_density"
:
fields
.
Nested
(
statistics
),
"lattice_a"
:
fields
.
Nested
(
statistics
),
"lattice_b"
:
fields
.
Nested
(
statistics
),
"lattice_c"
:
fields
.
Nested
(
statistics
),
"alpha"
:
fields
.
Nested
(
statistics
),
"beta"
:
fields
.
Nested
(
statistics
),
"gamma"
:
fields
.
Nested
(
statistics
),
"band_gap"
:
fields
.
Nested
(
statistics
),
"cell_volume"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"atomic_density"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"mass_density"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"lattice_a"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"lattice_b"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"lattice_c"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"alpha"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"beta"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"gamma"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
"band_gap"
:
fields
.
Nested
(
statistics
,
skip_none
=
True
),
})
property_map
=
{
"cell_volume"
:
"encyclopedia.material.idealized_structure.cell_volume"
,
...
...
@@ -827,7 +827,6 @@ class EncStatisticsResource(Resource):
calculations.
"""
# Get query parameters as json
print
(
request
.
get_json
())
try
:
data
=
marshal
(
request
.
get_json
(),
statistics_query
)
except
Exception
as
e
:
...
...
@@ -908,7 +907,7 @@ wyckoff_set_result = api.model("wyckoff_set_result", {
"wyckoff_letter"
:
fields
.
String
,
"indices"
:
fields
.
List
(
fields
.
Integer
),
"element"
:
fields
.
String
,
"variables"
:
fields
.
List
(
fields
.
Nested
(
wyckoff_variables_result
)),
"variables"
:
fields
.
List
(
fields
.
Nested
(
wyckoff_variables_result
,
skip_none
=
True
)),
})
lattice_parameters
=
api
.
model
(
"lattice_parameters"
,
{
"a"
:
fields
.
Float
,
...
...
@@ -1033,21 +1032,22 @@ electronic_band_structure = api.model("electronic_band_structure", {
"reciprocal_cell"
:
fields
.
List
(
fields
.
List
(
fields
.
Float
)),
"brillouin_zone"
:
fields
.
Raw
,
"section_k_band_segment"
:
fields
.
Raw
,
"section_band_gap"
:
fields
.
Raw
,
})
electronic_dos
=
api
.
model
(
"electronic_dos"
,
{
"dos_energies"
:
fields
.
List
(
fields
.
Float
),
"dos_values"
:
fields
.
List
(
fields
.
Float
),
"dos_values"
:
fields
.
List
(
fields
.
List
(
fields
.
Float
)
)
,
})
calculation_property_result
=
api
.
model
(
"calculation_
query
"
,
{
"lattice_parameters"
:
fields
.
Nested
(
lattice_parameters
),
"energies"
:
fields
.
Nested
(
energies
),
calculation_property_result
=
api
.
model
(
"calculation_
property_result
"
,
{
"lattice_parameters"
:
fields
.
Nested
(
lattice_parameters
,
skip_none
=
True
),
"energies"
:
fields
.
Nested
(
energies
,
skip_none
=
True
),
"mass_density"
:
fields
.
Float
,
"atomic_density"
:
fields
.
Float
,
"cell_volume"
:
fields
.
Float
,
"wyckoff_sets"
:
fields
.
Nested
(
wyckoff_set_result
),
"band_gap"
:
fields
.
Float
(
wyckoff_set_result
)
,
"electronic_band_structure"
:
fields
.
Nested
(
electronic_band_structure
),
"electronic_dos"
:
fields
.
Nested
(
electronic_dos
),
"wyckoff_sets"
:
fields
.
Nested
(
wyckoff_set_result
,
skip_none
=
True
),
"band_gap"
:
fields
.
Float
,
"electronic_band_structure"
:
fields
.
Nested
(
electronic_band_structure
,
skip_none
=
True
),
"electronic_dos"
:
fields
.
Nested
(
electronic_dos
,
skip_none
=
True
),
})
...
...
@@ -1057,7 +1057,7 @@ class EncCalculationResource(Resource):
@
api
.
response
(
400
,
"Bad request"
)
@
api
.
response
(
200
,
"Metadata send"
,
fields
.
Raw
)
@
api
.
expect
(
calculation_property_query
,
validate
=
False
)
#
@api.marshal_with(calculation_property_result, skip_none=True)
@
api
.
marshal_with
(
calculation_property_result
,
skip_none
=
True
)
@
api
.
doc
(
"enc_calculation"
)
def
post
(
self
,
material_id
,
calc_id
):
"""Used to return calculation details. Some properties are not
...
...
nomad/datamodel/metainfo/public.py
View file @
f6984dfc
...
...
@@ -2269,6 +2269,28 @@ class section_band_gap(MSection):
)
class
section_brillouin_zone
(
MSection
):
'''Defines a polyhedra for the Brillouin zone in reciprocal space.
'''
m_def
=
Section
(
validate
=
False
,
a_legacy
=
LegacyDefinition
(
name
=
'section_brillouin_zone'
))
vertices
=
Quantity
(
type
=
np
.
dtype
(
np
.
float64
),
shape
=
[
3
,
"1..*"
],
description
=
'''
The vertices of the Brillouin zone corners as 3D coordinates in reciprocal space.
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'vertices'
))
faces
=
Quantity
(
type
=
np
.
dtype
(
np
.
int32
),
shape
=
[
"1..*"
,
"3..*"
],
description
=
'''
The faces of the Brillouin zone polyhedron as vertex indices. The
surface normal is determined by a right-hand ordering of the points.
'''
,
a_legacy
=
LegacyDefinition
(
name
=
'faces'
))
class
section_k_band
(
MSection
):
'''
This section stores information on a $k$-band (electronic or vibrational band
...
...
@@ -2297,22 +2319,10 @@ class section_k_band(MSection):
a_legacy
=
LegacyDefinition
(
name
=
'reciprocal_cell'
)
)
brillouin_zone
=
Quantity
(
type
=
str
,
description
=
"""
The Brillouin zone that corresponds to the reciprocal cell used in the
band calculation. The Brillouin Zone is defined as a list of vertices
and facets that are encoded with JSON. The vertices are 3D points in
the reciprocal space, and facets are determined by a chain of vertice
indices, with a right-hand ordering determining the surface normal
direction.
{
"vertices": [[3, 2, 1], ...]
"faces": [[0, 1, 2, 3], ...]
}
"""
,
a_legacy
=
LegacyDefinition
(
name
=
'brillouin_zone'
)
)
brillouin_zone
=
SubSection
(
sub_section
=
SectionProxy
(
'section_brillouin_zone'
),
repeats
=
False
,
a_legacy
=
LegacyDefinition
(
name
=
'section_k_band_segment'
))
section_band_gap
=
SubSection
(
sub_section
=
section_band_gap
.
m_def
,
...
...
nomad/normalizing/band_structure.py
View file @
f6984dfc
...
...
@@ -12,11 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
json
import
numpy
as
np
import
ase
from
nomad.datamodel.metainfo.public
import
section_k_band
,
section_band_gap
,
section_system
from
nomad.datamodel.metainfo.public
import
section_k_band
,
section_band_gap
,
section_system
,
section_brillouin_zone
from
nomad.normalizing.normalizer
import
Normalizer
from
nomad
import
config
,
atomutils
from
nomad.constants
import
pi
...
...
@@ -104,9 +103,10 @@ class BandStructureNormalizer(Normalizer):
self
.
logger
.
info
(
"Could not resolve Brillouin zone as reciprocal cell is missing."
)
return
brillouin_zone
=
atomutils
.
get_brillouin_zone
(
recip_cell
.
magnitude
)
bz_json
=
json
.
dumps
(
brillouin_zone
)
band
.
brillouin_zone
=
bz_json
brillouin_zone_data
=
atomutils
.
get_brillouin_zone
(
recip_cell
.
magnitude
)
section_bz
=
band
.
m_create
(
section_brillouin_zone
)
section_bz
.
vertices
=
brillouin_zone_data
[
"vertices"
]
section_bz
.
faces
=
brillouin_zone_data
[
"faces"
]
def
get_k_space_distance
(
self
,
reciprocal_cell
:
np
.
array
,
point1
:
np
.
array
,
point2
:
np
.
array
)
->
float
:
"""Used to calculate the Euclidean distance of two points in k-space,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment