-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheigen.view.ts
More file actions
184 lines (166 loc) · 4.59 KB
/
eigen.view.ts
File metadata and controls
184 lines (166 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
namespace $.$$ {
const Bands_matrix = $mol_data_record({
bands: $mol_data_array( $mol_data_array( $mol_data_number ) ),
kpoints: $mol_data_array( $mol_data_array( $mol_data_number ) ),
})
type Bands_matrix = ReturnType<typeof Bands_matrix>
const Dos_matrix = $mol_data_record({
dos: $mol_data_array( $mol_data_number ),
levels: $mol_data_array( $mol_data_number ),
})
type Dos_matrix = ReturnType<typeof Dos_matrix>
export const $mpds_visavis_plot_eigen_json = $mol_data_record( {
sample: $mol_data_record( {
material: $mol_data_record( {
chemical_formula: $mol_data_string,
chemical_elements: $mol_data_array( $mol_data_string ),
condition: $mol_data_array( $mol_data_record( {
scalar: $mol_data_array( $mol_data_record( { value: $mol_data_number } ) ),
name: $mol_data_string,
units: $mol_data_optional( $mol_data_string ),
}) ),
phase: $mol_data_string,
phase_id: $mol_data_number,
entry: $mol_data_string,
object_repr: $mol_data_optional( $mol_data_string),
}),
measurement: $mol_data_array( $mol_data_record( {
data_type: $mol_data_string, //enum: ["peer_reviewed", "machine_learning", "ab_initio"]
property: $mol_data_record( {
units: $mol_data_string,
scalar: $mol_data_optional( $mol_data_variant( $mol_data_string, $mol_data_number ) ),
matrix: $mol_data_variant(
Bands_matrix,
Dos_matrix,
),
name: $mol_data_string,
category: $mol_data_string,
domain: $mol_data_string,
}),
condition: $mol_data_optional( $mol_data_array( $mol_data_record( {
units: $mol_data_string,
scalar: $mol_data_number,
// range: {},
name: $mol_data_string,
refers_to: $mol_data_optional( $mol_data_string ),
} ) ) ),
raw_data: $mol_data_optional( $mol_data_string ),
}) ),
}),
version: $mol_data_string,
object_type: $mol_data_string,
reference: $mol_data_record( {
entry: $mol_data_string,
phase: $mol_data_optional( $mol_data_string ),
}),
})
export class $mpds_visavis_plot_eigen extends $.$mpds_visavis_plot_eigen {
json() {
return $mpds_visavis_plot_eigen_json( this.plot_raw().jsons()[0] )
}
@ $mol_mem
bands_matrix(): Bands_matrix | null {
const matrix = this.json().sample.measurement[0].property.matrix as Bands_matrix;
if (matrix.bands){
return matrix
} else {
return null
}
}
@ $mol_mem
dos_matrix(): Dos_matrix | null {
const matrix = this.json().sample.measurement[0].property.matrix as Dos_matrix;
if (matrix.dos){
return matrix
} else {
return null
}
}
@ $mol_mem
data() {
const dataset = [];
const bands_matrix = this.bands_matrix()
const dos_matrix = this.dos_matrix()
if (bands_matrix){
for (let i = 0; i < bands_matrix.bands.length; i++){
dataset.push({
x: $mpds_visavis_lib_plotly.d3.range(bands_matrix.bands[i].length),
y: bands_matrix.bands[i],
mode: "lines",
type: "scatter",
marker: {color: "#000"}
});
};
} else if (dos_matrix) {
dataset.push({
x: dos_matrix.levels,
y: dos_matrix.dos,
mode: "lines",
type: "scatter",
marker: {color: "#000"}
});
} else {
// return notify('Cannot get plot data, please, try again');
// ^ it will be validated id $mpds_visavis_plot_eigen_json()
}
return dataset
}
@ $mol_mem
layout() {
const bands_matrix = this.bands_matrix()
let xaxis: Object = {}
let x_title = ''
let y_title = ''
if (bands_matrix){
const x_labels = [];
for (let i = 0; i < bands_matrix.kpoints.length; i++){
x_labels.push( (bands_matrix.kpoints[i][0] == 0 && bands_matrix.kpoints[i][1] == 0 && bands_matrix.kpoints[i][2] == 0) ? 'Г' : '' );
}
x_title = 'k'
y_title = 'E - E<sub>F</sub>, eV'
xaxis = {
showline: true,
zeroline: false,
showgrid: false,
tickmode: 'array',
tickvals: $mpds_visavis_lib_plotly.d3.range(bands_matrix.kpoints.length),
ticktext: x_labels,
tickfont: {
size: 20,
},
};
} else {
x_title = 'E - E<sub>F</sub>, eV'
y_title = 'Total density of states'
xaxis = {
showline: true,
zeroline: false,
showgrid: true,
autorange: true,
showticklabels: true,
ticklen: 4,
title: x_title
};
}
return {
showlegend: false,
xaxis: xaxis,
yaxis: {
autorange: true,
showgrid: false,
showline: true,
showticklabels: true,
zeroline: true,
zerolinecolor: '#6cf',
zerolinewidth: 3,
ticklen: 4,
title: y_title
},
font: {
family: 'inherit',
size: 13,
},
}
}
}
}