Commit 8a54434e authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Improved the default view shown by StructureViewer, added check for empty band/dos data.

parent add64443
......@@ -173,20 +173,26 @@ export default function DFTEntryOverview({data}) {
for (let i = sccs.length - 1; i > -1; --i) {
const scc = sccs[i]
if (!e_dos && scc.section_dos) {
if (scc.section_dos[scc.section_dos.length - 1].dos_kind !== 'vibrational') {
e_dos = {
'section_system': scc.single_configuration_calculation_to_system_ref,
'section_method': scc.single_configuration_calculation_to_system_ref,
'section_dos': scc.section_dos[scc.section_dos.length - 1]
const first_dos = scc.section_dos[scc.section_dos.length - 1]
if (!_.isEmpty(first_dos)) {
if (first_dos.dos_kind !== 'vibrational') {
e_dos = {
'section_system': scc.single_configuration_calculation_to_system_ref,
'section_method': scc.single_configuration_calculation_to_system_ref,
'section_dos': scc.section_dos[scc.section_dos.length - 1]
}
}
}
}
if (!e_bs && scc.section_k_band) {
if (scc.section_k_band[scc.section_k_band.length - 1].band_structure_kind !== 'vibrational') {
e_bs = {
'section_system': scc.single_configuration_calculation_to_system_ref,
'section_method': scc.single_configuration_calculation_to_system_ref,
'section_k_band': scc.section_k_band[scc.section_k_band.length - 1]
const first_band = scc.section_k_band[scc.section_k_band.length - 1]
if (!_.isEmpty(first_band)) {
if (first_band.band_structure_kind !== 'vibrational') {
e_bs = {
'section_system': scc.single_configuration_calculation_to_system_ref,
'section_method': scc.single_configuration_calculation_to_system_ref,
'section_k_band': scc.section_k_band[scc.section_k_band.length - 1]
}
}
}
}
......@@ -500,7 +506,7 @@ export default function DFTEntryOverview({data}) {
</Box>
</Grid>
<Grid item xs={7} style={{marginTop: '-2rem'}}>
<Structure systems={structures} aspectRatio={1.5} />
<Structure systems={structures} materialType={data?.dft?.system} aspectRatio={1.5} />
</Grid>
</Grid>
</PropertyCard>
......
......@@ -51,7 +51,7 @@ function ElectronicStructureOverview({data, range, className, classes, raiseErro
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
alignItems: 'flex-start',
width: '100%',
height: '100%',
flexWrap: 'wrap'
......
......@@ -53,6 +53,7 @@ export const Structure = withErrorHandler(({
system,
systems,
options,
materialType,
viewer,
captureName,
aspectRatio,
......@@ -210,10 +211,9 @@ export const Structure = withErrorHandler(({
}
// Systems with non-empty cell are centered on the cell center and
// orientation is defined by the cell vectors.
const opts = {}
if (system.cell !== undefined) {
refViewer.current.setOptions({layout: {
viewCenter: 'COC',
periodicity: 'wrap',
opts.layout = {
viewRotation: {
alignments: [
['up', 'c'],
......@@ -224,19 +224,25 @@ export const Structure = withErrorHandler(({
[1, 0, 0, 30]
]
}
}}, false, false)
// Systems without cell are centered on the center of positions
}
} else {
refViewer.current.setOptions({layout: {
viewCenter: 'COP',
opts.layout = {
viewRotation: {
rotations: [
[0, 1, 0, 60],
[1, 0, 0, 30]
]
}
}}, false, false)
}
}
if (system.cell !== undefined && materialType === 'bulk') {
opts.layout.viewCenter = 'COC'
opts.layout.periodicity = 'wrap'
// Systems without cell are centered on the center of positions
} else {
opts.layout.viewCenter = 'COP'
}
refViewer.current.setOptions(opts, false, false)
refViewer.current.load(system)
refViewer.current.fitToCanvas()
refViewer.current.saveReset()
......@@ -443,6 +449,7 @@ Structure.propTypes = {
system: PropTypes.object, // The system to display in the native materia-format
systems: PropTypes.object, // Set of systems that can be switched
options: PropTypes.object, // Viewer options
materialType: PropTypes.string, // The material type, affects the visualization layout.
captureName: PropTypes.string, // Name of the file that the user can download
aspectRatio: PropTypes.number, // Fixed aspect ratio for the viewer canvas
positionsOnly: PropTypes.bool, // Whether to update only positions. This is much faster than loading the entire structure.
......
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