Skip to content

Commit

Permalink
Add Fermi level line and E-Ef (eV) to the band structure plot (#44)
Browse files Browse the repository at this point in the history
Add a line at the zero level, but it should be indicated how the zero level was chosen (e.g. E-Ef). Or E_VBM for insulators
  • Loading branch information
dou-du committed Apr 4, 2023
1 parent d43dc78 commit 7176296
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions js/lib/bandstructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ BandPlot.prototype.initChart = function (ticksData) {

var bandPlotObject = this;

if (this.showFermi === false) {
annotations = {};
}
else {
annotations = {
type: 'line',
id: 'band-fermi',
scaleID: 'bandA',
mode: 'horizontal',
value: 0,
borderColor: 'red',
borderWidth: 2
}
}

var chartOptions = {
type: 'scatter',
data: {
Expand Down Expand Up @@ -244,6 +259,7 @@ BandPlot.prototype.initChart = function (ticksData) {
}
}],
yAxes: [{
id: 'bandA',
display: true,
ticks: {
// change the label of the ticks
Expand All @@ -261,6 +277,9 @@ BandPlot.prototype.initChart = function (ticksData) {
}
}]
},
annotation: {
annotations: [ annotations ]
},
zoom: {
enabled: true,
mode: "y",
Expand Down Expand Up @@ -333,8 +352,8 @@ BandPlot.prototype.initDosChart = function (orientation = 'vertical') {
display: this.showLegend,
position: 'right',
labels: {
filter: function(item, chart) {
// remove the label for the dumb dataset of the y axis
filter: function (item, chart) {
// remove the label for the dumb dataset of the y axis
return !item.text.includes('y axis');
}
}
Expand Down Expand Up @@ -450,8 +469,8 @@ BandPlot.prototype.initDosChart = function (orientation = 'vertical') {
display: true,
position: 'right',
labels: {
filter: function(item, chart) {
// remove the label for the dumb dataset of the y axis
filter: function (item, chart) {
// remove the label for the dumb dataset of the y axis
return !item.text.includes('y axis');
}
}
Expand Down Expand Up @@ -772,7 +791,7 @@ BandPlot.prototype.updateBandPlot = function (bandPath, forceRedraw) {

bandPlotObject.yLabel = bandPlotObject.allData[0].Y_label;
if (bandPlotObject.yLabel === undefined) {
bandPlotObject.yLabel = 'Electronic bands (eV)';
bandPlotObject.yLabel = 'E - Ef (eV)';
}

if (bandPlotObject.myChart === undefined) {
Expand Down Expand Up @@ -806,13 +825,13 @@ BandPlot.prototype.updateDosPlot = function (orientation = 'vertical') {
// So the color fill will up to the Fermi level
dosx.forEach(function (data, k) {
if (orientation === 'vertical') {
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: 0, y: data - bandPlotObject.dosFermiEnergy });
};
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: 0, y: data - bandPlotObject.dosFermiEnergy });
};
} else {
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: data - bandPlotObject.dosFermiEnergy, y: 0 });
};
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: data - bandPlotObject.dosFermiEnergy, y: 0 });
};
};
});

Expand Down

0 comments on commit 7176296

Please sign in to comment.