Commit d2dc9513 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added metainfo link support for StructureViewer.

parent cbb5f5d5
......@@ -386,11 +386,18 @@ function Overview({section, def}) {
{
bands: {
width: '30rem',
height: '30rem'
height: '30rem',
margin: 'auto'
},
structure: {
width: '20rem',
height: '20rem',
margin: 'auto'
},
dos: {
width: '20rem',
height: '40rem'
height: '40rem',
margin: 'auto'
},
radio: {
display: 'flex',
......@@ -444,10 +451,26 @@ function Overview({section, def}) {
visualizedSystem.nAtoms = nAtoms
return <Structure
aspectRatio={1}
className={style.structure}
viewer={viewer}
system={system}
positionsOnly={true}
></Structure>
// Structure visualization for idealized_structure
} else if (def.name === 'IdealizedStructure') {
// The section is incomplete, we leave the overview empty
if (!section.atom_labels) {
return null
}
const system = {
species: section.atom_labels,
cell: section.lattice_vectors ? convertSI(section.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
positions: section.atom_positions,
fractional: true,
pbc: section.periodicity
}
return <Structure system={system} className={style.structure} aspectRatio={1}></Structure>
// Band structure plot for section_k_band
} else if (def.name === 'KBand') {
return section.band_structure_kind !== 'vibrational'
......@@ -498,7 +521,7 @@ function Overview({section, def}) {
} else if (def.name === 'Dos') {
return <DOS
className={style.dos}
layout={{yaxis: {autorange: false, range: convertSI(electronicRange, 'electron_volt', units, false)}}}
layout={section.dos_kind === 'vibrational' ? undefined : {yaxis: {autorange: false, range: convertSI(electronicRange, 'electron_volt', units, false)}}}
data={section}
aspectRatio={1 / 2}
unitsState={unitsState}
......
......@@ -246,10 +246,10 @@ export default function DFTEntryOverview({data}) {
let sys = calc?.single_configuration_calculation_to_system_ref
sys = resolveRef(sys, archive)
trajectory.push({
'species': sys.atom_species,
'cell': sys.lattice_vectors ? convertSI(sys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
'positions': convertSI(sys.atom_positions, 'meter', {length: 'angstrom'}, false),
'pbc': sys.configuration_periodic_dimensions
species: sys.atom_species,
cell: sys.lattice_vectors ? convertSI(sys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
positions: convertSI(sys.atom_positions, 'meter', {length: 'angstrom'}, false),
pbc: sys.configuration_periodic_dimensions
})
}
if (!failed) {
......@@ -268,16 +268,16 @@ export default function DFTEntryOverview({data}) {
let v_bs = null
if (scc) {
v_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],
'path': `${url}/${refPath(scc_ref)}/section_k_band:${scc.section_k_band.length - 1}`
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],
path: `${url}/${refPath(scc_ref)}/section_k_band:${scc.section_k_band.length - 1}`
}
v_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],
'path': `${url}/${refPath(scc_ref)}/section_dos:${scc.section_dos.length - 1}`
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],
path: `${url}/${refPath(scc_ref)}/section_dos:${scc.section_dos.length - 1}`
}
}
......@@ -290,19 +290,25 @@ export default function DFTEntryOverview({data}) {
if (sequence) {
const properties = sequence.section_thermodynamical_properties && sequence.section_thermodynamical_properties[0]
if (properties) {
heat_capacity = properties.thermodynamical_property_heat_capacity_C_v
free_energy = properties.vibrational_free_energy_at_constant_volume
heat_capacity = {
thermodynamical_property_heat_capacity_C_v: properties.thermodynamical_property_heat_capacity_C_v,
path: `${url}/section_run/section_frame_sequence:${sequences.length - 1}/section_thermodynamical_properties/thermodynamical_property_heat_capacity_C_v`
}
free_energy = {
vibrational_free_energy_at_constant_volume: properties.vibrational_free_energy_at_constant_volume,
path: `${url}/section_run/section_frame_sequence:${sequences.length - 1}/section_thermodynamical_properties/vibrational_free_energy_at_constant_volume`
}
temperature = properties.thermodynamical_property_temperature
}
}
if (v_dos || v_bs || free_energy || heat_capacity) {
setVibrationalData({
'dos': v_dos,
'bs': v_bs,
'free_energy': free_energy,
'heat_capacity': heat_capacity,
'temperature': temperature
dos: v_dos,
bs: v_bs,
free_energy: free_energy,
heat_capacity: heat_capacity,
temperature: temperature
})
}
}
......@@ -348,10 +354,11 @@ export default function DFTEntryOverview({data}) {
const sys = systems[i]
if (!reprSys && sys.is_representative) {
const reprSys = {
'species': sys.atom_species,
'cell': sys.lattice_vectors ? convertSI(sys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
'positions': convertSI(sys.atom_positions, 'meter', {length: 'angstrom'}, false),
'pbc': sys.configuration_periodic_dimensions
species: sys.atom_species,
cell: sys.lattice_vectors ? convertSI(sys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
positions: convertSI(sys.atom_positions, 'meter', {length: 'angstrom'}, false),
pbc: sys.configuration_periodic_dimensions,
path: `${url}/section_run/section_system:${i}`
}
structs.original = reprSys
break
......@@ -363,11 +370,12 @@ export default function DFTEntryOverview({data}) {
let idealSys = archive?.section_metadata?.encyclopedia?.material?.idealized_structure
if (idealSys && data?.dft?.system === 'bulk') {
const ideal = {
'species': idealSys.atom_labels,
'cell': idealSys.lattice_vectors ? convertSI(idealSys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
'positions': idealSys.atom_positions,
'fractional': true,
'pbc': idealSys.periodicity
species: idealSys.atom_labels,
cell: idealSys.lattice_vectors ? convertSI(idealSys.lattice_vectors, 'meter', {length: 'angstrom'}, false) : undefined,
positions: idealSys.atom_positions,
fractional: true,
pbc: idealSys.periodicity,
path: `${url}/section_metadata/encyclopedia/material/idealized_structure`
}
structs.conventional = ideal
}
......
......@@ -180,7 +180,7 @@ function BandStructure({data, layout, aspectRatio, className, classes, unitsStat
}
}
return mergeObjects(layout, defaultLayout)
}, [units, layout])
}, [layout])
// Compute layout that depends on data.
const computedLayout = useMemo(() => {
......
......@@ -105,7 +105,7 @@ export default function Plot({
}
}
})
const styles = useStyles(classes)
const styles = useStyles({classes: classes})
// Set the final layout
const finalLayout = useMemo(() => {
......
......@@ -32,7 +32,8 @@ import {
Fullscreen,
FullscreenExit,
CameraAlt,
Replay
Replay,
ViewList
} from '@material-ui/icons'
import { StructureViewer } from '@lauri-codes/materia'
import Floatable from './Floatable'
......@@ -40,6 +41,7 @@ import Placeholder from '../visualization/Placeholder'
import Actions from '../Actions'
import { mergeObjects } from '../../utils'
import { withErrorHandler, ErrorCard } from '../ErrorHandler'
import { useHistory } from 'react-router-dom'
import _ from 'lodash'
import clsx from 'clsx'
......@@ -75,6 +77,8 @@ export const Structure = withErrorHandler(({
const [shownSystem, setShownSystem] = useState(null)
const [finalSystem, setFinalSystem] = useState(system)
const history = useHistory()
// Variables
const open = Boolean(anchorEl)
const refViewer = useRef(null)
......@@ -355,9 +359,12 @@ export const Structure = withErrorHandler(({
const actions = [
{tooltip: 'Reset view', onClick: handleReset, content: <Replay/>},
{tooltip: 'Toggle fullscreen', onClick: toggleFullscreen, content: fullscreen ? <FullscreenExit/> : <Fullscreen/>},
{tooltip: 'Capture image', onClick: takeScreencapture, content: <CameraAlt/>},
{tooltip: 'Options', onClick: openMenu, content: <MoreVert/>}
{tooltip: 'Capture image', onClick: takeScreencapture, content: <CameraAlt/>}
]
if (finalSystem?.path) {
actions.push({tooltip: 'View data in the archive', onClick: () => { history.push(finalSystem.path) }, content: <ViewList/>})
}
actions.push({tooltip: 'Options', onClick: openMenu, content: <MoreVert/>})
const content = <Box className={styles.container}>
{fullscreen && <Typography className={styles.title} variant="h6">Structure</Typography>}
......@@ -448,6 +455,7 @@ Structure.propTypes = {
viewer: PropTypes.object, // Optional shared viewer instance.
system: PropTypes.object, // The system to display in the native materia-format
systems: PropTypes.object, // Set of systems that can be switched
metaInfoLink: PropTypes.string, // A link to the metainfo definition
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
......
......@@ -97,7 +97,7 @@ export default function VibrationalOverview({data, className, classes, raiseErro
const heatCapacityData = useMemo(() => {
return [{
x: data.temperature,
y: data.heat_capacity,
y: data.heat_capacity.thermodynamical_property_heat_capacity_C_v,
type: 'scatter',
mode: 'lines',
line: {
......@@ -122,7 +122,7 @@ export default function VibrationalOverview({data, className, classes, raiseErro
const freeEnergyData = useMemo(() => {
return [{
x: data.temperature,
y: data.free_energy,
y: data.free_energy.vibrational_free_energy_at_constant_volume,
type: 'scatter',
mode: 'lines',
line: {
......@@ -195,6 +195,7 @@ export default function VibrationalOverview({data, className, classes, raiseErro
layout={heatCapacityLayout}
aspectRatio={1}
floatTitle="Heat capacity"
metaInfoLink={data.heat_capacity.path}
>
</Plot>
</ErrorHandler>
......@@ -210,6 +211,7 @@ export default function VibrationalOverview({data, className, classes, raiseErro
layout={freeEnergyLayout}
aspectRatio={1}
floatTitle="Helmholtz free energy"
metaInfoLink={data.free_energy.path}
>
</Plot>
</ErrorHandler>
......
Supports Markdown
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