Brillouin Zone Viewer¶
Try out the interactive visualizer below. Controls are as follows:
Rotate: Drag with left mouse button held down
Zoom: Mousewheel
Example¶
This piece of Javascript code shows an example of loading the viewer into a an
HTML element that has been given the id canvas
. This example assumes
that the global variable installation has been used, but it can be very simply
changed to also work with the module installation by adding the proper imports
and changing the BrillouinZoneViewer
constructor call.
// Find the element in which the visualizer will be embedded into. It
// determines the visualization canvas size.
let canvas = document.getElementById("canvas");
// Viewer options
let options = {
controls: {
enablePan: false
},
view: {
fitMargin: 0.075,
},
layout: {
viewRotation: {
alignments: [
["up", "a"],
["front", "segments"],
],
rotations: [
[0, 1, 0, 45],
[1, 0, 0, 25],
],
}
},
basis: {
color: "#fff",
},
kpoints: {
label: {
color: "#fff",
}
}
};
// Initialize viewer
let viewer = new materia.BrillouinZoneViewer(canvas, options);
// Define structure and load into viewer
let reciprocal = {
basis: [
[-0.15735, 0.15735, 0.15735],
[0.15735, -0.15735, 0.15735],
[0.15735, 0.15735, -0.15735]
],
segments: [
[
[0, 0, 0],
[0.5, 0, 0.5],
[0.5, 0.25, 0.75],
[0.375, 0.375, 0.75],
[0, 0, 0],
[0.5, 0.5, 0.5],
[0.625, 0.25, 0.625],
[0.5, 0.25, 0.75],
[0.5, 0.5, 0.5],
[0.375, 0.375, 0.75]
],
[
[0.625, 0.25, 0.625],
[0.5, 0, 0.5]
]
],
kpoints: [
["A", [0.0, 0.0, 0.0]],
["B", [0.5, 0.0, 0.5]],
["C", [0.5, 0.25, 0.75]],
["D", [0.375, 0.375, 0.75]],
["E", [0.5, 0.5, 0.5]],
["F", [0.625, 0.25, 0.625]],
]
}
// Load structure into viewer
viewer.load(reciprocal);
Loading a structure¶
You can load data to the viewer by calling the BrillouinZoneViewer.load()
method. Check the API for the supported parameters.
Options¶
The options that are given in the constructor are passed to the
BrillouinZoneViewer.setOptions()
method. These options are provided as a
nested Javascript object. Check the API for the supported parameters. At any
time you can also manually call this method to change the options. You can also
use this method to only update a subset of the options.
API¶
-
BrillouinZoneViewer.
load
(data)¶ Visualizes the first Brillouin zone of the given reciprocal lattice and optional k-path segments and k-point labels within it.
- Arguments
data (object) – A Javascript object containing the visualized structure. See below for the subparameters.
data.basis (Array.<Array.<number>>) – The basis vectors of the reciprocal cell as rows of a 3x3 array.
data.segments (Array.<Array.<number>>) – List containing lists of k-points, each sublist indicating a continuous segment within the Brillouin zone.
data.kpoints (*) – List of pairs of labels and reciprocal lattice coordinates for specific k-points that should be shown.
-
BrillouinZoneViewer.
setOptions
(options, render)¶ Used to setup the visualization options.
- Arguments
options (object) – A Javascript object containing the options. See below for the subparameters.
options.segments.color (string) – Segment color
options.segments.linewidth (number) – Segment linewidth
options.faces.color (string) – Face color
options.faces.opacity (number) – Face opacity
options.faces.outline.color (string) – Face outline color
options.faces.outline.width (number) – Face outline width
options.kpoints.label.color (string) – Label color
options.kpoints.label.size (number) – Label size
options.kpoints.label.font (string) – Label font
options.kpoints.label.offset2D (boolean) – Offset of the labels in the sprite’s 2D coordinate system. The offset is relative to the font size and the default [0, 0] corresponds to centered labels.
options.kpoints.point.color (string) – Point color
options.kpoints.point.size (number) – Point size
options.kpoints.stroke.width (string) – Label outline stroke width
options.kpoints.stroke.color (string) – Label outline stroke color
options.basis.color (string) – Font colour for basis labels. Applied as default to all labels, can be overridden individually for each basis.
options.basis.font (number) – Font size for basis labels. Applied as default to all labels, can be overridden individually for each basis.
options.basis.offset (number) – Offset for basis labels.
options.basis.stroke.width (number) – Label outline stroke width
options.basis.stroke.color (string) – Label outline stroke color
options.basis.a.color (string) – Color applied to the label of the first reciprocal lattice vector.
options.basis.a.font (string) – Font family applied to the label of the first reciprocal lattice vector.
options.basis.a.size (number) – Font size applied to the label of the first reciprocal lattice vector.
options.basis.a.stroke.width (number) – Outline stroke width applied to the label of the first reciprocal lattice vector.
options.basis.a.stroke.color (string) – Outline stroke color applied to the label of the first reciprocal lattice vector.
options.basis.b.color (string) – Color applied to the label of the second reciprocal lattice vector.
options.basis.b.font (string) – Font family applied to the label of the second reciprocal lattice vector.
options.basis.b.size (number) – Font size applied to the label of the second reciprocal lattice vector.
options.basis.b.stroke.width (number) – Outline stroke width applied to the label of the second reciprocal lattice vector.
options.basis.b.stroke.color (string) – Outline stroke color applied to the label of the second reciprocal lattice vector.
options.basis.c.color (string) – Color applied to the label of the third reciprocal lattice vector.
options.basis.c.font (string) – Font family applied to the label of the third reciprocal lattice vector.
options.basis.c.size (number) – Font size applied to the label of the third reciprocal lattice vector.
options.basis.c.stroke.width (number) – Outline stroke width applied to the label of the third reciprocal lattice vector.
options.basis.c.stroke.color (string) – Outline stroke color applied to the label of the third reciprocal lattice vector.
options.renderer.background.color (string) – Color of the background.
options.renderer.background.opacity (number) – Opacity of the background.
render (boolean) – Whether to perform a render after setting the options. Defaults to true. You should only disable this setting if you plan to do a render manually afterwards.