fermisurfer Git
修訂 | 1954d1e00bd3287469b35c3ea9d258bd19b2a885 (tree) |
---|---|
時間 | 2020-11-11 23:07:30 |
作者 | Mitsuaki Kawamura <kawamitsuaki@gmai...> |
Commiter | Mitsuaki Kawamura |
Backup
@@ -60,9 +60,9 @@ function main() { | ||
60 | 60 | |
61 | 61 | // Apply lighting effect |
62 | 62 | |
63 | - highp vec3 ambientLight = vec3(0.6, 0.6, 0.6); | |
63 | + highp vec3 ambientLight = vec3(0.5, 0.5, 0.5); | |
64 | 64 | highp vec3 directionalLightColor = vec3(1, 1, 1); |
65 | - highp vec3 directionalVector = normalize(vec3(0.8, 0.8, 0.8)); | |
65 | + highp vec3 directionalVector = normalize(vec3(-1, -1, -1)); | |
66 | 66 | |
67 | 67 | highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0); |
68 | 68 |
@@ -107,99 +107,22 @@ function main() { | ||
107 | 107 | // Here's where we call the routine that builds all the |
108 | 108 | // objects we'll be drawing. |
109 | 109 | |
110 | - drawScene(programInfo, 0.5, 1.8); | |
110 | + drawScene(); | |
111 | 111 | |
112 | 112 | var el = document.getElementById("glcanvas"); |
113 | 113 | el.addEventListener("touchstart", handleStart, false); |
114 | 114 | el.addEventListener("touchend", handleEnd, false); |
115 | 115 | el.addEventListener("touchcancel", handleCancel, false); |
116 | 116 | el.addEventListener("touchmove", handleMove, false); |
117 | - el.addEventListener("mousemove", mouseMove, false); | |
117 | + //el.addEventListener("mousemove", mouseMove, false); | |
118 | 118 | |
119 | 119 | } |
120 | - | |
121 | -// | |
122 | -// initBuffers | |
123 | -// | |
124 | -// Initialize the buffers we'll need. For this demo, we just | |
125 | -// have one object -- a simple three-dimensional cube. | |
126 | -// | |
127 | -function initBuffers() { | |
128 | - let itri = 0; | |
129 | - | |
130 | - // Create a buffer for the cube's vertex positions. | |
131 | - // Select the positionBuffer as the one to apply buffer | |
132 | - // operations to from here out. | |
133 | - // Now create an array of positions for the cube. | |
134 | - | |
135 | - let nkvp = ntri[0] * 3 * 3; | |
136 | - let positions = new Float32Array(nkvp); | |
137 | - icount = 0; | |
138 | - for (itri = 0; itri < ntri[0]; itri++) { | |
139 | - for (ii = 0; ii < 3; ii++) { | |
140 | - for (jj = 0; jj < 3; jj++) { | |
141 | - positions[icount] = kvp[0][itri][ii][jj]; | |
142 | - icount += 1; | |
143 | - } | |
144 | - } | |
145 | - } | |
146 | - | |
147 | - // Now pass the list of positions into WebGL to build the | |
148 | - // shape. We do this by creating a Float32Array from the | |
149 | - // JavaScript array, then use it to fill the current buffer. | |
150 | - | |
151 | - let positionBuffer = gl.createBuffer(); | |
152 | - gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); | |
153 | - gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW); | |
154 | - | |
155 | - // Set up the normals for the vertices, so that we can compute lighting. | |
156 | - | |
157 | - let nnmlp = ntri[0] * 3 * 3; | |
158 | - let vertexNormals = new Float32Array(nnmlp); | |
159 | - icount = 0; | |
160 | - for (itri = 0; itri < ntri[0]; itri++) { | |
161 | - for (ii = 0; ii < 3; ii++) { | |
162 | - for (jj = 0; jj < 3; jj++) { | |
163 | - vertexNormals[icount] = nmlp[0][itri][ii][jj]; | |
164 | - icount += 1; | |
165 | - } | |
166 | - } | |
167 | - } | |
168 | - | |
169 | - let normalBuffer = gl.createBuffer(); | |
170 | - gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer); | |
171 | - gl.bufferData(gl.ARRAY_BUFFER, vertexNormals, gl.STATIC_DRAW); | |
172 | - | |
173 | - // Now set up the colors for the faces. We'll use solid colors | |
174 | - // for each face. | |
175 | - | |
176 | - let nclr = ntri[0] * 3 * 4; | |
177 | - let colors = new Float32Array(nclr); | |
178 | - icount = 0; | |
179 | - for (itri = 0; itri < ntri[0]; itri++) { | |
180 | - for (ii = 0; ii < 3; ii++) { | |
181 | - for (jj = 0; jj < 4; jj++) { | |
182 | - colors[icount] = clr[0][jj + 4 * ii + 12 * itri]; | |
183 | - icount += 1; | |
184 | - } | |
185 | - } | |
186 | - } | |
187 | - | |
188 | - let colorBuffer = gl.createBuffer(); | |
189 | - gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); | |
190 | - gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); | |
191 | - | |
192 | - return { | |
193 | - position: positionBuffer, | |
194 | - normal: normalBuffer, | |
195 | - color: colorBuffer, | |
196 | - }; | |
197 | -} | |
198 | - | |
199 | 120 | // |
200 | 121 | // Draw the scene. |
201 | 122 | // |
202 | -function drawScene(programInfo, rotatex, rotatey) { | |
123 | +function drawScene() { | |
124 | + let ib = 0, ii = 0, jj = 0; | |
125 | + | |
203 | 126 | gl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear to black, fully opaque |
204 | 127 | gl.clearDepth(1.0); // Clear everything |
205 | 128 | gl.enable(gl.DEPTH_TEST); // Enable depth testing |
@@ -252,7 +175,116 @@ function drawScene(programInfo, rotatex, rotatey) { | ||
252 | 175 | mat4.invert(normalMatrix, modelViewMatrix); |
253 | 176 | mat4.transpose(normalMatrix, normalMatrix); |
254 | 177 | |
255 | - buffers = initBuffers(); | |
178 | + { | |
179 | + let vertexCount = 0; | |
180 | + for (ib = 0; ib < nb; ib++) { | |
181 | + if (draw_band[ib] == 1) vertexCount += ntri[ib] * 3; | |
182 | + } | |
183 | + | |
184 | + let nkvp = vertexCount * 3; | |
185 | + let positions = new Float32Array(nkvp); | |
186 | + icount = 0; | |
187 | + for (ib = 0; ib < nb; ib++) { | |
188 | + for (itri = 0; itri < ntri[ib]; itri++) { | |
189 | + for (ii = 0; ii < 3; ii++) { | |
190 | + for (jj = 0; jj < 3; jj++) { | |
191 | + positions[icount] = ( | |
192 | + rot[jj][0] * kvp[ib][itri][ii][0] | |
193 | + + rot[jj][1] * kvp[ib][itri][ii][1] | |
194 | + + rot[jj][2] * kvp[ib][itri][ii][2]) * scl | |
195 | + + trans[jj]; | |
196 | + icount += 1; | |
197 | + } | |
198 | + } | |
199 | + } | |
200 | + } | |
201 | + | |
202 | + let nnmlp = vertexCount * 3; | |
203 | + let vertexNormals = new Float32Array(nnmlp); | |
204 | + icount = 0; | |
205 | + for (ib = 0; ib < nb; ib++) { | |
206 | + for (itri = 0; itri < ntri[ib]; itri++) { | |
207 | + for (ii = 0; ii < 3; ii++) { | |
208 | + for (jj = 0; jj < 3; jj++) { | |
209 | + vertexNormals[icount] = rot[jj][0] * nmlp[ib][itri][ii][0] | |
210 | + + rot[jj][1] * nmlp[ib][itri][ii][1] | |
211 | + + rot[jj][2] * nmlp[ib][itri][ii][2]; | |
212 | + icount += 1; | |
213 | + } | |
214 | + } | |
215 | + } | |
216 | + } | |
217 | + | |
218 | + let nclr = vertexCount * 4; | |
219 | + let colors = new Float32Array(nclr); | |
220 | + icount = 0; | |
221 | + for (ib = 0; ib < nb; ib++) { | |
222 | + for (itri = 0; itri < ntri[ib]; itri++) { | |
223 | + for (ii = 0; ii < 3; ii++) { | |
224 | + for (jj = 0; jj < 4; jj++) { | |
225 | + colors[icount] = clr[ib][jj + 4 * ii + 12 * itri]; | |
226 | + icount += 1; | |
227 | + } | |
228 | + } | |
229 | + } | |
230 | + } | |
231 | + | |
232 | + draw2(projectionMatrix, modelViewMatrix, normalMatrix, | |
233 | + vertexCount, gl.TRIANGLES, | |
234 | + positions, colors, vertexNormals); | |
235 | + } | |
236 | + | |
237 | + { | |
238 | + let ibzl = 0, i = 0, j = 0, icount = 0; | |
239 | + | |
240 | + let vertexCount = 2*nbzl; | |
241 | + let nkvp = vertexCount * 3; | |
242 | + let nnmlp = vertexCount * 3; | |
243 | + let nclr = vertexCount * 4; | |
244 | + let positions = new Float32Array(nkvp); | |
245 | + let colors = new Float32Array(nclr); | |
246 | + let vertexNormals = new Float32Array(nnmlp); | |
247 | + | |
248 | + // | |
249 | + //First Brillouin zone mode | |
250 | + // | |
251 | + icount = 0; | |
252 | + for (ibzl = 0; ibzl < nbzl; ++ibzl) { | |
253 | + for (i = 0; i < 2; ++i) { | |
254 | + vertexNormals[icount] = -1.0; | |
255 | + vertexNormals[icount + 1] = -1.0; | |
256 | + vertexNormals[icount + 2] = -1.0; | |
257 | + for (j = 0; j < 3; ++j) { | |
258 | + positions[icount] = (rot[j][0] * bzl[ibzl][i][0] | |
259 | + + rot[j][1] * bzl[ibzl][i][1] | |
260 | + + rot[j][2] * bzl[ibzl][i][2])*scl | |
261 | + + trans[j]; | |
262 | + icount += 1; | |
263 | + } | |
264 | + }//for (i = 0; i< 2; ++i) | |
265 | + }//for (ibzl = 0; ibzl < nbzl; ++ibzl) | |
266 | + for (i = 0; i < nclr; ++i) colors[i] = 1.0; | |
267 | + | |
268 | + draw2(projectionMatrix, modelViewMatrix, normalMatrix, | |
269 | + vertexCount, gl.LINES, | |
270 | + new Float32Array(positions), new Float32Array(colors), new Float32Array(vertexNormals)); | |
271 | + } | |
272 | +} | |
273 | +function draw2(projectionMatrix, modelViewMatrix, normalMatrix, | |
274 | + vertexCount, drawtype, | |
275 | + positions, colors, vertexNormals) { | |
276 | + | |
277 | + let positionBuffer = gl.createBuffer(); | |
278 | + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); | |
279 | + gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW); | |
280 | + | |
281 | + let colorBuffer = gl.createBuffer(); | |
282 | + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); | |
283 | + gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); | |
284 | + | |
285 | + let normalBuffer = gl.createBuffer(); | |
286 | + gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer); | |
287 | + gl.bufferData(gl.ARRAY_BUFFER, vertexNormals, gl.STATIC_DRAW); | |
256 | 288 | |
257 | 289 | // Tell WebGL how to pull out the positions from the position |
258 | 290 | // buffer into the vertexPosition attribute |
@@ -262,7 +294,7 @@ function drawScene(programInfo, rotatex, rotatey) { | ||
262 | 294 | let normalize = false; |
263 | 295 | let stride = 0; |
264 | 296 | let offset = 0; |
265 | - gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position); | |
297 | + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); | |
266 | 298 | gl.vertexAttribPointer( |
267 | 299 | programInfo.attribLocations.vertexPosition, |
268 | 300 | numComponents, |
@@ -282,7 +314,7 @@ function drawScene(programInfo, rotatex, rotatey) { | ||
282 | 314 | let normalize = false; |
283 | 315 | let stride = 0; |
284 | 316 | let offset = 0; |
285 | - gl.bindBuffer(gl.ARRAY_BUFFER, buffers.color); | |
317 | + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); | |
286 | 318 | gl.vertexAttribPointer( |
287 | 319 | programInfo.attribLocations.vertexColor, |
288 | 320 | numComponents, |
@@ -302,7 +334,7 @@ function drawScene(programInfo, rotatex, rotatey) { | ||
302 | 334 | let normalize = false; |
303 | 335 | let stride = 0; |
304 | 336 | let offset = 0; |
305 | - gl.bindBuffer(gl.ARRAY_BUFFER, buffers.normal); | |
337 | + gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer); | |
306 | 338 | gl.vertexAttribPointer( |
307 | 339 | programInfo.attribLocations.vertexNormal, |
308 | 340 | numComponents, |
@@ -334,12 +366,10 @@ function drawScene(programInfo, rotatex, rotatey) { | ||
334 | 366 | normalMatrix); |
335 | 367 | |
336 | 368 | { |
337 | - let vertexCount = ntri[0]*3; | |
338 | 369 | let offset = 0; |
339 | - gl.drawArrays(gl.TRIANGLE_STRIP, offset, vertexCount); | |
370 | + gl.drawArrays(drawtype, offset, vertexCount); | |
340 | 371 | } |
341 | 372 | } |
342 | - | |
343 | 373 | // |
344 | 374 | // Initialize a shader program, so WebGL knows how to draw our data |
345 | 375 | // |
@@ -363,7 +393,6 @@ function initShaderProgram(gl, vsSource, fsSource) { | ||
363 | 393 | |
364 | 394 | return shaderProgram; |
365 | 395 | } |
366 | - | |
367 | 396 | // |
368 | 397 | // creates a shader of the given type, uploads the source and |
369 | 398 | // compiles it. |
@@ -411,7 +440,7 @@ function handleMove(evt) { | ||
411 | 440 | if (idx == 0) { |
412 | 441 | rotatex += -0.01 * (touches[i].clientX - ongoingTouches[idx].clientX); |
413 | 442 | rotatey += 0.01 * (touches[i].clientY - ongoingTouches[idx].clientY); |
414 | - drawScene(programInfo, rotatex, rotatey); | |
443 | + drawScene(); | |
415 | 444 | ongoingTouches.splice(idx, 1, copyTouch(touches[i])); // swap in the new touch record |
416 | 445 | } |
417 | 446 | } |
@@ -453,27 +482,111 @@ function ongoingTouchIndexById(idToFind) { | ||
453 | 482 | return -1; // not found |
454 | 483 | } |
455 | 484 | |
456 | -function mouseMove(evt) { | |
457 | - rotatex += -0.01 * evt.movementX; | |
458 | - rotatey += 0.01 * evt.movementY; | |
459 | - drawScene(programInfo, rotatex, rotatey); | |
460 | -} | |
461 | - | |
462 | - | |
463 | - | |
464 | - | |
465 | - | |
466 | - | |
467 | - | |
468 | - | |
469 | - | |
485 | +let isDrawing = false; | |
486 | +let x = 0; | |
487 | +let y = 0; | |
488 | + | |
489 | +const myPics = document.getElementById('glcanvas'); | |
490 | + | |
491 | +myPics.addEventListener('mousedown', e => { | |
492 | + x = e.offsetX; | |
493 | + y = e.offsetY; | |
494 | + isDrawing = true; | |
495 | +}); | |
496 | + | |
497 | +myPics.addEventListener('mousemove', e => { | |
498 | + if (isDrawing === true) { | |
499 | + let dx = e.offsetX - x; | |
500 | + let dy = e.offsetY - y; | |
501 | + dx *= 0.001; | |
502 | + dy *= 0.001; | |
503 | + mouserotation(dx, dy) | |
504 | + drawScene(); | |
505 | + x = e.offsetX; | |
506 | + y = e.offsetY; | |
507 | + } | |
508 | +}); | |
509 | + | |
510 | +window.addEventListener('mouseup', e => { | |
511 | + if (isDrawing === true) { | |
512 | + let dx = e.offsetX - x; | |
513 | + let dy = e.offsetY - y; | |
514 | + dx *= 0.001; | |
515 | + dy *= 0.001; | |
516 | + mouserotation(dx, dy) | |
517 | + drawScene(); | |
518 | + x = 0; | |
519 | + y = 0; | |
520 | + isDrawing = false; | |
521 | + } | |
522 | +}); | |
470 | 523 | |
524 | +myPics.addEventListener('wheel', zoom); | |
471 | 525 | |
526 | +function zoom(evt) { | |
527 | + scl -= evt.deltaY*0.001; | |
528 | + document.getElementById("scale").value = String(scl); | |
529 | + drawScene(); | |
530 | +} | |
472 | 531 | |
532 | +function mouserotation(dx, dy) { | |
533 | + let i = 0, j = 0; | |
534 | + let a = Math.sqrt(dx * dx + dy * dy); | |
535 | + let rot0 = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]; | |
536 | + let rot1 = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]; | |
473 | 537 | |
474 | -function test() { | |
475 | - terminal("test"); | |
538 | + if (a != 0.0) { | |
539 | + // | |
540 | + // Compute rotational matrix from translation of mousepointer | |
541 | + // | |
542 | + let ax = -dy; | |
543 | + let ay = dx; | |
544 | + // | |
545 | + a = a * 10.0; | |
546 | + // | |
547 | + rot0[0][0] = (ax * ax + ay * ay * Math.cos(a)) / (ax * ax + ay * ay); | |
548 | + rot0[0][1] = ax * ay * (Math.cos(a) - 1.0) / (ax * ax + ay * ay); | |
549 | + rot0[0][2] = ay * Math.sin(a) / Math.sqrt(ax * ax + ay * ay); | |
550 | + rot0[1][0] = ax * ay * (Math.cos(a) - 1.0) / (ax * ax + ay * ay); | |
551 | + rot0[1][1] = (ax * ax * Math.cos(a) + ay * ay) / (ax * ax + ay * ay); | |
552 | + rot0[1][2] = ax * Math.sin(a) / Math.sqrt(ax * ax + ay * ay); | |
553 | + rot0[2][0] = -ay * Math.sin(a) / Math.sqrt(ax * ax + ay * ay); | |
554 | + rot0[2][1] = -ax * Math.sin(a) / Math.sqrt(ax * ax + ay * ay); | |
555 | + rot0[2][2] = Math.cos(a); | |
556 | + // | |
557 | + for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) rot1[i][j] = rot[i][j]; | |
558 | + // | |
559 | + for (i = 0; i < 3; i++) { | |
560 | + for (j = 0; j < 3; j++) { | |
561 | + rot[i][j] = rot0[i][0] * rot1[0][j] | |
562 | + + rot0[i][1] * rot1[1][j] | |
563 | + + rot0[i][2] * rot1[2][j]; | |
564 | + } | |
565 | + } | |
566 | + // | |
567 | + //Print angle to text Box | |
568 | + // | |
569 | + thetay = Math.asin(rot[0][2]); | |
570 | + if (Math.cos(thetay) != 0.0) { | |
571 | + if (-rot[1][2] / Math.cos(thetay) >= 0.0) thetax = Math.acos(rot[2][2] / Math.cos(thetay)); | |
572 | + else thetax = 2.0 * Math.PI - Math.acos(rot[2][2] / Math.cos(thetay)); | |
573 | + if (-rot[0][1] / Math.cos(thetay) >= 0.0) thetaz = Math.acos(rot[0][0] / Math.cos(thetay)); | |
574 | + else thetaz = 2.0 * Math.PI - Math.acos(rot[0][0] / Math.cos(thetay)); | |
575 | + } | |
576 | + else { | |
577 | + thetax = 0.0; | |
578 | + if (rot[1][0] >= 0.0) thetaz = Math.acos(rot[1][1]); | |
579 | + else thetaz = 2.0 * Math.PI - Math.acos(rot[1][1]); | |
580 | + } | |
581 | + thetax *= 180.0 / Math.PI; | |
582 | + thetay *= 180.0 / Math.PI; | |
583 | + thetaz *= 180.0 / Math.PI; | |
584 | + document.getElementById("rotatex").value = String(thetax); | |
585 | + document.getElementById("rotatey").value = String(thetay); | |
586 | + document.getElementById("rotatez").value = String(thetaz); | |
587 | + } | |
476 | 588 | } |
589 | + | |
477 | 590 | function terminal(msg) { |
478 | 591 | var p = document.getElementById('log'); |
479 | 592 | p.innerHTML += msg; |
@@ -3374,73 +3487,83 @@ function allocate_griddata( | ||
3374 | 3487 | } |
3375 | 3488 | } |
3376 | 3489 | } |
3377 | -/** | |
3378 | - @brief Input from Fermi surface file | |
3379 | -*/ | |
3380 | -function read_file() | |
3381 | -{ | |
3490 | +function read_from_text(datas) { | |
3382 | 3491 | let ib, i, j, i0, i1, i2, ii0, ii1, ii2, iaxis, icount; |
3383 | 3492 | let lshift; //!< Switch for shifted Brillouin zone |
3384 | 3493 | |
3385 | - const selectedFile = document.getElementById('inputfile').files[0]; | |
3386 | - var reader = new FileReader(); | |
3387 | - reader.readAsText(selectedFile); | |
3388 | - reader.onload = function (event) { | |
3389 | - var result = event.target.result; | |
3390 | - let datas = result.replace(/\n/g, ' ').replace(/^ +/, '').split(/ +/); | |
3391 | - icount = 0; | |
3392 | - terminal("\n"); | |
3393 | - terminal(" ## Brillouin zone informations ###########\n"); | |
3394 | - terminal("\n"); | |
3395 | - /* | |
3396 | - k-point grid | |
3397 | - */ | |
3398 | - for (i = 0; i < 3; i++) { | |
3399 | - ng0[i] = Number(datas[icount]); | |
3400 | - icount += 1; | |
3401 | - } | |
3402 | - terminal(" k point grid : " + String(ng0[0]) + " " + String(ng0[1]) + " " + String(ng0[2]) + "\n"); | |
3403 | - /* | |
3404 | - Shift of k-point grid | |
3405 | - */ | |
3406 | - lshift = Number(datas[icount]); | |
3494 | + icount = 0; | |
3495 | + terminal("\n"); | |
3496 | + terminal(" ## Brillouin zone informations ###########\n"); | |
3497 | + terminal("\n"); | |
3498 | + /* | |
3499 | + k-point grid | |
3500 | + */ | |
3501 | + for (i = 0; i < 3; i++) { | |
3502 | + ng0[i] = Number(datas[icount]); | |
3407 | 3503 | icount += 1; |
3504 | + } | |
3505 | + terminal(" k point grid : " + String(ng0[0]) + " " + String(ng0[1]) + " " + String(ng0[2]) + "\n"); | |
3506 | + /* | |
3507 | + Shift of k-point grid | |
3508 | + */ | |
3509 | + lshift = Number(datas[icount]); | |
3510 | + icount += 1; | |
3408 | 3511 | |
3409 | - if (lshift == 0) { | |
3410 | - terminal(" k point grid is the Monkhorst-Pack grid.\n"); | |
3411 | - for (i = 0; i < 3; i++) shiftk[i] = (ng0[i] + 1) % 2; | |
3412 | - } | |
3413 | - else if (lshift == 1) { | |
3414 | - terminal(" k point grid starts from Gamma.\n"); | |
3415 | - for (i = 0; i < 3; i++) shiftk[i] = 0; | |
3416 | - } | |
3417 | - else if (lshift == 2) { | |
3418 | - terminal(" k point grid starts from Gamma + a half grid.\n"); | |
3419 | - for (i = 0; i < 3; i++) shiftk[i] = 1; | |
3420 | - } | |
3421 | - else { | |
3422 | - exit(0); | |
3512 | + if (lshift == 0) { | |
3513 | + terminal(" k point grid is the Monkhorst-Pack grid.\n"); | |
3514 | + for (i = 0; i < 3; i++) shiftk[i] = (ng0[i] + 1) % 2; | |
3515 | + } | |
3516 | + else if (lshift == 1) { | |
3517 | + terminal(" k point grid starts from Gamma.\n"); | |
3518 | + for (i = 0; i < 3; i++) shiftk[i] = 0; | |
3519 | + } | |
3520 | + else if (lshift == 2) { | |
3521 | + terminal(" k point grid starts from Gamma + a half grid.\n"); | |
3522 | + for (i = 0; i < 3; i++) shiftk[i] = 1; | |
3523 | + } | |
3524 | + else { | |
3525 | + exit(0); | |
3526 | + } | |
3527 | + /* | |
3528 | + # of bands | |
3529 | + */ | |
3530 | + nb = Number(datas[icount]); | |
3531 | + icount += 1; | |
3532 | + terminal(" # of bands : " + String(nb) + "\n"); | |
3533 | + /* | |
3534 | + Reciplocal lattice vectors | |
3535 | + */ | |
3536 | + for (i = 0; i < 3; ++i) { | |
3537 | + for (j = 0; j < 3; j++) { | |
3538 | + bvec[i][j] = Number(datas[icount]); | |
3539 | + icount += 1; | |
3423 | 3540 | } |
3424 | - /* | |
3425 | - # of bands | |
3426 | - */ | |
3427 | - nb = Number(datas[icount]); | |
3428 | - icount += 1; | |
3429 | - terminal(" # of bands : " + String(nb) + "\n"); | |
3430 | - /* | |
3431 | - Reciplocal lattice vectors | |
3432 | - */ | |
3433 | - for (i = 0; i < 3; ++i) { | |
3434 | - for (j = 0; j < 3; j++) { | |
3435 | - bvec[i][j] = Number(datas[icount]); | |
3436 | - icount += 1; | |
3541 | + terminal(" bvec " + String(i + 1) + " : " + String(bvec[i][0]) + " " + String(bvec[i][1]) + " " + String(bvec[i][2]) + " \n"); | |
3542 | + }/*for (i = 0; i < 3; ++i)*/ | |
3543 | + allocate_griddata(ng, ng0); | |
3544 | + /* | |
3545 | + Kohn-Sham energies | |
3546 | + */ | |
3547 | + for (ib = 0; ib < nb; ++ib) { | |
3548 | + for (i0 = 0; i0 < ng0[0]; ++i0) { | |
3549 | + if (lshift != 0) ii0 = i0; | |
3550 | + else ii0 = modulo(i0 + (ng0[0] + 1) / 2, ng0[0]); | |
3551 | + for (i1 = 0; i1 < ng0[1]; ++i1) { | |
3552 | + if (lshift != 0) ii1 = i1; | |
3553 | + else ii1 = modulo(i1 + (ng0[1] + 1) / 2, ng0[1]); | |
3554 | + for (i2 = 0; i2 < ng0[2]; ++i2) { | |
3555 | + if (lshift != 0) ii2 = i2; | |
3556 | + else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]); | |
3557 | + eig0[ib][ii0][ii1][ii2] = Number(datas[icount]); | |
3558 | + icount += 1; | |
3559 | + } | |
3437 | 3560 | } |
3438 | - terminal(" bvec " + String(i + 1) + " : " + String(bvec[i][0]) + " " + String(bvec[i][1]) + " " + String(bvec[i][2]) + " \n"); | |
3439 | - }/*for (i = 0; i < 3; ++i)*/ | |
3440 | - allocate_griddata(ng, ng0); | |
3441 | - /* | |
3442 | - Kohn-Sham energies | |
3443 | - */ | |
3561 | + } | |
3562 | + } | |
3563 | + /* | |
3564 | + Matrix elements | |
3565 | + */ | |
3566 | + for (iaxis = 0; iaxis < 1; iaxis++) { | |
3444 | 3567 | for (ib = 0; ib < nb; ++ib) { |
3445 | 3568 | for (i0 = 0; i0 < ng0[0]; ++i0) { |
3446 | 3569 | if (lshift != 0) ii0 = i0; |
@@ -3451,49 +3574,42 @@ function read_file() | ||
3451 | 3574 | for (i2 = 0; i2 < ng0[2]; ++i2) { |
3452 | 3575 | if (lshift != 0) ii2 = i2; |
3453 | 3576 | else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]); |
3454 | - eig0[ib][ii0][ii1][ii2] = Number(datas[icount]); | |
3577 | + mat0[ib][ii0][ii1][ii2][iaxis] = Number(datas[icount]); | |
3455 | 3578 | icount += 1; |
3456 | - } | |
3457 | - } | |
3458 | - } | |
3459 | - } | |
3460 | - /* | |
3461 | - Matrix elements | |
3462 | - */ | |
3463 | - for (iaxis = 0; iaxis < 1; iaxis++) { | |
3464 | - for (ib = 0; ib < nb; ++ib) { | |
3465 | - for (i0 = 0; i0 < ng0[0]; ++i0) { | |
3466 | - if (lshift != 0) ii0 = i0; | |
3467 | - else ii0 = modulo(i0 + (ng0[0] + 1) / 2, ng0[0]); | |
3468 | - for (i1 = 0; i1 < ng0[1]; ++i1) { | |
3469 | - if (lshift != 0) ii1 = i1; | |
3470 | - else ii1 = modulo(i1 + (ng0[1] + 1) / 2, ng0[1]); | |
3471 | - for (i2 = 0; i2 < ng0[2]; ++i2) { | |
3472 | - if (lshift != 0) ii2 = i2; | |
3473 | - else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]); | |
3474 | - mat0[ib][ii0][ii1][ii2][iaxis] = Number(datas[icount]); | |
3475 | - icount += 1; | |
3476 | - }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/ | |
3477 | - }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/ | |
3478 | - }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/ | |
3479 | - }/*for (ib = 0; ib < nb; ++ib)*/ | |
3480 | - }//for (iaxis = 0; iaxis < 1; iaxis++) | |
3481 | - // | |
3482 | - interpol_energy(); | |
3483 | - init_corner(); | |
3484 | - bragg_vector(); | |
3485 | - // | |
3486 | - //Brillouin zone | |
3487 | - // | |
3488 | - bz_lines(); | |
3489 | - calc_2dbz(); | |
3490 | - // | |
3491 | - max_and_min_bz(); | |
3492 | - // | |
3493 | - compute_patch_segment(); | |
3579 | + }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/ | |
3580 | + }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/ | |
3581 | + }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/ | |
3582 | + }/*for (ib = 0; ib < nb; ++ib)*/ | |
3583 | + }//for (iaxis = 0; iaxis < 1; iaxis++) | |
3584 | + // | |
3585 | + interpol_energy(); | |
3586 | + init_corner(); | |
3587 | + bragg_vector(); | |
3588 | + // | |
3589 | + //Brillouin zone | |
3590 | + // | |
3591 | + bz_lines(); | |
3592 | + calc_2dbz(); | |
3593 | + // | |
3594 | + max_and_min_bz(); | |
3595 | + // | |
3596 | + compute_patch_segment(); | |
3494 | 3597 | |
3495 | - main(); | |
3598 | + main(); | |
3599 | +} | |
3600 | +/** | |
3601 | + @brief Input from Fermi surface file | |
3602 | +*/ | |
3603 | +function read_file() | |
3604 | +{ | |
3605 | + const selectedFile = document.getElementById('inputfile').files[0]; | |
3606 | + var reader = new FileReader(); | |
3607 | + reader.readAsText(selectedFile); | |
3608 | + reader.onload = function (event) { | |
3609 | + var result = event.target.result; | |
3610 | + let datas = result.replace(/\n/g, ' ').replace(/^ +/, '').split(/ +/); | |
3496 | 3611 | |
3612 | + read_from_text(datas); | |
3497 | 3613 | }; |
3498 | 3614 | reader.onerror = function () { |
3499 | 3615 | terminal("File can not be loaded."); |
@@ -3820,3 +3936,8 @@ function calc_section() { | ||
3820 | 3936 | terminal(" " + String(ib + 1) + " " + String(n2d[ib]) + "\n"); |
3821 | 3937 | }/*for (ib = 0; ib < nb; ib++)*/ |
3822 | 3938 | }/*function calc_nodeline()*/ |
3939 | + | |
3940 | +if (frmsf != "") { | |
3941 | + let datas = frmsf.replace(/\n/g, ' ').replace(/^ +/, '').split(/ +/); | |
3942 | + read_from_text(datas); | |
3943 | +} | |
\ No newline at end of file |
@@ -0,0 +1,172 @@ | ||
1 | +<!DOCTYPE html> | |
2 | +<html> | |
3 | +<head> | |
4 | + <title>FermiSurfer on Web</title> | |
5 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js" | |
6 | + integrity="sha512-zhHQR0/H5SEBL3Wn6yYSaTTZej12z0hVZKOv3TwCUXT1z5qeqGcXJLLrbERYRScEDDpYIJhPC1fk31gqR783iQ==" | |
7 | + crossorigin="anonymous" defer> | |
8 | + </script> | |
9 | + <?php if ($_GET['frmsf'] == ""): ?> | |
10 | + <script type="text/javascript"> | |
11 | + var frmsf = ""; | |
12 | + </script> | |
13 | + <?php else: ?> | |
14 | + <script type="text/javascript" src="<?=$_GET['frmsf']?>"></script> | |
15 | + <?php endif; ?> | |
16 | + <script type="text/javascript" src="./fermisurfer.js" defer></script> | |
17 | +</head> | |
18 | + <body> | |
19 | + File: <input type="file" id="inputfile" name="inputfile"> | |
20 | + <input type="button" value="read" onclick="read_file();"> | |
21 | + <table border="0"> | |
22 | + <tr align="left"> | |
23 | + <td><canvas id="glcanvas" width="600" height="600" style="border:solid black 1px;"></canvas></td> | |
24 | + <td> | |
25 | + <table border="0"> | |
26 | + <tr align="left"> | |
27 | + <td><input type="button" value="update"></td> | |
28 | + <td>Line width :</td> | |
29 | + <td><input type="number" name="linewidth" id="linewidth" value="1"></td> | |
30 | + <td><input type="checkbox" name="ongamma" id="ongamma" value="ongamma" checked="checked">On Gamma</td> | |
31 | + </tr> | |
32 | + <tr align="left"> | |
33 | + <td>Section-v : </td> | |
34 | + <td><input type="number" name="sectionv0" id="sectionv0" value="0"></td> | |
35 | + <td><input type="number" name="sectionv1" id="sectionv1" value="0"></td> | |
36 | + <td><input type="number" name="sectionv2" id="sectionv2" value="1"></td> | |
37 | + </tr> | |
38 | + <tr align="left"> | |
39 | + <td>Equator-v : </td> | |
40 | + <td><input type="number" name="equatorv0" id="equatorv0" value="0"></td> | |
41 | + <td><input type="number" name="equatorv1" id="equatorv1" value="0"></td> | |
42 | + <td><input type="number" name="equatorv2" id="equatorv2" value="1"></td> | |
43 | + </tr> | |
44 | + <tr align="left"> | |
45 | + <td>Interpol ratio : </td> | |
46 | + <td><input type="number" name="interpol" id="interpol" value="1"></td> | |
47 | + <td>Fermi energy : </td> | |
48 | + <td><input type="number" name="fermienergy" id="fermienergy" value="0.0"></td> | |
49 | + </tr> | |
50 | + <tr align="left"> | |
51 | + <td>Min. of Scale : </td> | |
52 | + <td><input type="text" name="scalemin" id="scalemin" value=""></td> | |
53 | + <td>Max. of Scale : </td> | |
54 | + <td><input type="text" name="scalemax" id="scalemax" value=""></td> | |
55 | + </tr> | |
56 | + <tr align="left"> | |
57 | + <td>Tetrahedron : </td> | |
58 | + <td></td> | |
59 | + <td></td> | |
60 | + <td></td> | |
61 | + </tr> | |
62 | + <tr align="left"> | |
63 | + <form id="tetrahedron"> | |
64 | + <td><input type="radio" name="tetrahedron" value="1" checked="checked">1</td> | |
65 | + <td><input type="radio" name="tetrahedron" value="2">2</td> | |
66 | + <td><input type="radio" name="tetrahedron" value="3">3</td> | |
67 | + <td><input type="radio" name="tetrahedron" value="3">4</td> | |
68 | + </form> | |
69 | + </tr> | |
70 | + <tr align="left"> | |
71 | + <td>Color-scale mode : </td> | |
72 | + <td></td> | |
73 | + <td></td> | |
74 | + <td></td> | |
75 | + </tr> | |
76 | + <tr align="left"> | |
77 | + <form id="colorscalemode"> | |
78 | + <td><input type="radio" name="colorscalemode" value="1" checked="checked">Input(1D)</td> | |
79 | + <td><input type="radio" name="colorscalemode" value="2">Input(2D)</td> | |
80 | + <td><input type="radio" name="colorscalemode" value="3">Input(3D)</td> | |
81 | + <td><input type="radio" name="colorscalemode" value="4">Fermi velocity</td> | |
82 | + </form> | |
83 | + </tr> | |
84 | + <tr align="left"> | |
85 | + <td>Brillouin zone : </td> | |
86 | + <form id="brillouinzone"> | |
87 | + <td><input type="radio" name="brillouinzone" value="1" checked="checked">First</td> | |
88 | + <td><input type="radio" name="brillouinzone" value="-1">Premitive</td> | |
89 | + </form> | |
90 | + <td></td> | |
91 | + </tr> | |
92 | + <tr align="left"> | |
93 | + <td>Stereogram : </td> | |
94 | + <form id="stereogram"> | |
95 | + <td><input type="radio" name="stereogram" value="1" checked="checked">None</td> | |
96 | + <td><input type="radio" name="stereogram" value="2">Parallel</td> | |
97 | + <td><input type="radio" name="stereogram" value="3">Cross</td> | |
98 | + </form> | |
99 | + </tr> | |
100 | + <tr align="left"> | |
101 | + <td>Mouse drag : </td> | |
102 | + <form id="mousedrag"> | |
103 | + <td><input type="radio" name="mousedrag" value="1" checked="checked">Rotate</td> | |
104 | + <td><input type="radio" name="mousedrag" value="2">Scale</td> | |
105 | + <td><input type="radio" name="mousedrag" value="3">Translate</td> | |
106 | + </form> | |
107 | + </tr> | |
108 | + <tr align="left"> | |
109 | + <td>BZ number : </td> | |
110 | + <td><input type="number" name="bznumber1" id="bznumber0" value="1"></td> | |
111 | + <td><input type="number" name="bznumber2" id="bznumber1" value="1"></td> | |
112 | + <td><input type="number" name="bznumber3" id="bznumber2" value="1"></td> | |
113 | + </tr> | |
114 | + <tr align="left"> | |
115 | + <td>Backgraound (RGB) : </td> | |
116 | + <td><input type="number" name="backgraoundr" id="backgraoundr" value="0"></td> | |
117 | + <td><input type="number" name="backgraoundg" id="backgraoundg" value="0"></td> | |
118 | + <td><input type="number" name="backgraoundb" id="backgraoundb" value="0"></td> | |
119 | + </tr> | |
120 | + <tr align="left"> | |
121 | + <td>Line color (RGB) : </td> | |
122 | + <td><input type="number" name="linecolorr" id="linecolorr" value="1"></td> | |
123 | + <td><input type="number" name="linecolorg" id="linecolorg" value="1"></td> | |
124 | + <td><input type="number" name="linecolobr" id="linecolorb" value="1"></td> | |
125 | + </tr> | |
126 | + <tr align="left"> | |
127 | + <td><input type="button" value="Rotate"></td> | |
128 | + <td><input type="number" name="rotatex" id="rotatex" value="0"></td> | |
129 | + <td><input type="number" name="rotatey" id="rotatey" value="0"></td> | |
130 | + <td><input type="number" name="rotatez" id="rotatez" value="0"></td> | |
131 | + </tr> | |
132 | + <tr align="left"> | |
133 | + <td>Scale : <input type="number" name="scale" id="scale" value="1"></td> | |
134 | + <td>Position : </td> | |
135 | + <td><input type="number" name="positionx" id="positionx" value="0"></td> | |
136 | + <td><input type="number" name="positiony" id="positiony" value="0"></td> | |
137 | + </tr> | |
138 | + <tr align="left"> | |
139 | + <td><input type="checkbox" name="colorbar" id="colorbar" value="colorbar" checked="checked">Color bar</td> | |
140 | + <td><input type="checkbox" name="equator" id="equator" value="equator">Equator</td> | |
141 | + <td><input type="checkbox" name="nodalline" id="nodalline" value="nodalline">Nodal line</td> | |
142 | + <td><input type="checkbox" name="section" id="section" value="section">Section</td> | |
143 | + </tr> | |
144 | + <tr align="left"> | |
145 | + <td>Lighting : </td> | |
146 | + <form id="lighting"> | |
147 | + <td><input type="radio" name="lighting" value="1.0" checked="checked">Both</td> | |
148 | + <td><input type="radio" name="lighting" value="-1.0">Occupy</td> | |
149 | + <td><input type="radio" name="lighting" value="1.0">Unoccupy</td> | |
150 | + </form> | |
151 | + </tr> | |
152 | + <tr align="left"> | |
153 | + <form id="barcolor"> | |
154 | + <td><input type="radio" name="barcolor" value="bgr" checked="checked">BGR</td> | |
155 | + <td><input type="radio" name="barcolor" value="cmy">CMY</td> | |
156 | + <td><input type="radio" name="barcolor" value="mcy">MCY</td> | |
157 | + </form> | |
158 | + </tr> | |
159 | + <tr align="left"> | |
160 | + <td><input type="button" value="Section file"></td> | |
161 | + <td><input type="checkbox" name="band0" id="band0" value="band0" checked="checked">Band 0</td> | |
162 | + <td><input type="checkbox" name="band1" id="band1" value="band1" checked="checked">Band 1</td> | |
163 | + <td><input type="checkbox" name="band2" id="band2" value="band2" checked="checked">Band 2</td> | |
164 | + </tr> | |
165 | + </table> | |
166 | + </td> | |
167 | + </tr> | |
168 | + </table> | |
169 | + | |
170 | + <pre id="log" style="border: 1px solid #ccc; max-width: 80em; overflow: auto; max-height: 10em;"></pre> | |
171 | + </body> | |
172 | +</html> |