• R/O
  • HTTP
  • SSH
  • HTTPS

fermisurfer: Commit

fermisurfer Git


Commit MetaInfo

Revisionf9eec856c863fc117e8acb12140b5cc750185491 (tree)
Zeit2020-11-09 01:28:46
AutorMitsuaki Kawamura <kawamitsuaki@gmai...>
CommiterMitsuaki Kawamura

Log Message

Read local file

Ändern Zusammenfassung

Diff

--- a/javascript/fermisurfer.html
+++ b/javascript/fermisurfer.html
@@ -4,15 +4,18 @@
44 <title>FermiSurfer on Web</title>
55 </head>
66 <body>
7+ <script type="text/javascript" src="./fermisurfer.js"></script>
8+ File: <input type="file" id="inputfile" name="inputfile">
9+ <input type="button" value="read" onclick="read_file();">
710 <table border="0">
811 <tr align="left">
912 <td><canvas id="canvas" width="600" height="600" style="border:solid black 1px;"></canvas></td>
1013 <td>
1114 <table border="0">
1215 <tr align="left">
13- <td><input type="button" value="update" onclick=""></td>
16+ <td><input type="button" value="update" onclick="test();"></td>
1417 <td>Line width :</td>
15- <td><input type="number" name="linewidth" id="linewidth" value="1"></td>
18+ <td><input type="number" name="linewidth" id="linewidth" onclick="test();" value="1"></td>
1619 <td><input type="checkbox" name="ongamma" id="ongamma" value="ongamma" checked="checked">On Gamma</td>
1720 </tr>
1821 <tr align="left">
@@ -152,8 +155,8 @@
152155 </td>
153156 </tr>
154157 </table>
155-
156- <pre id="log" style="border: 1px solid #ccc;"></pre>
158+
159+ <pre id="log" style="border: 1px solid #ccc; max-width: 80em; overflow: auto; max-height: 10em;"></pre>
157160 <script type="text/javascript">
158161 function startup() {
159162 var el = document.getElementById("canvas");
--- a/javascript/fermisurfer.js
+++ b/javascript/fermisurfer.js
@@ -21,6 +21,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222 THE SOFTWARE.
2323 */
24+function test() {
25+ terminal("test");
26+}
27+function terminal(msg) {
28+ var p = document.getElementById('log');
29+ p.innerHTML += "\n" + msg;
30+}
2431 /**@file
2532 @brief Mathematical operations used in various step
2633 */
@@ -213,7 +220,7 @@ function check_bragg()
213220
214221 }/*for (ii = 0; ii < 2; ii++)*/
215222 }/*for (ibzl = 0; ibzl < nbzl; ibzl++)*/
216- terminal(" Number of corners of 1st BZ : " + toString(nbzcorner) + "\n");
223+ terminal(" Number of corners of 1st BZ : " + String(nbzcorner) + "\n");
217224 /**@brief
218225 Then, compute real number Bragg plane of 1st BZ (::nbragg),
219226 Re-order ::bragg and ::brnrm
@@ -232,7 +239,7 @@ function check_bragg()
232239 nbragg += 1;
233240 }
234241 }
235- terminal(" Number of plane of 1st BZ : " + toString(nbragg) + "\n");
242+ terminal(" Number of plane of 1st BZ : " + String(nbragg) + "\n");
236243 }/*function check_bragg*/
237244 /**
238245 @brief Compute Brillouin zone boundariy lines
@@ -321,7 +328,7 @@ function calc_nodeline()
321328 Allocation of nodeline
322329 */
323330 nnl[ib] = kvnl[ib].length;
324- terminal(" " + toString(ib + 1) + " " + toString(nnl[ib]) + "\n");
331+ terminal(" " + String(ib + 1) + " " + String(nnl[ib]) + "\n");
325332 }/*for (ib = 0; ib < nb; ib++)*/
326333 }/*function calc_nodeline()*/
327334 /**
@@ -937,7 +944,7 @@ function equator() {
937944 Sum node-lines in all threads
938945 */
939946 nequator.push(kveq[ib].size);
940- terminal(" " + toString(ib + 1) + " " + toString(nequator[ib])+ "\n");
947+ terminal(" " + String(ib + 1) + " " + String(nequator[ib])+ "\n");
941948 }/*for (ib = 0; ib < nb; ib++)*/
942949 }/*function equator()*/
943950 /**
@@ -1881,8 +1888,8 @@ function max_and_min()
18811888 }/*for (ib = 0; ib < nb; ib++)*/
18821889 }/*if (color_scale == 5 || color_scale == 6)*/
18831890
1884- document.getElementById("scalemin").value = toString(patch_min);
1885- document.getElementById("scalemax").value = toString(patch_max);
1891+ document.getElementById("scalemin").value = String(patch_min);
1892+ document.getElementById("scalemax").value = String(patch_max);
18861893 }/* max_and_min */
18871894 /**
18881895 @brief Compute Max. & Min. of matrix elements.
@@ -2302,7 +2309,7 @@ function bragg_vector()
23022309 for (ibr = 1; ibr < 26; ibr++) {
23032310 if (brnrm_min > brnrm[ibr]) brnrm_min = brnrm[ibr];
23042311 }
2305- terminal(" Minimum Bragg norm : " + toString(brnrm_min) + "\n");
2312+ terminal(" Minimum Bragg norm : " + String(brnrm_min) + "\n");
23062313 }/* bragg_vector */
23072314 /**
23082315 @brief Print max and minimum @f$\varepsilon_{n k}, \Delta_{n k}@f$
@@ -2332,8 +2339,8 @@ function max_and_min_bz()
23322339 }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/
23332340 }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/
23342341 }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/
2335- terminal(" " + toString(ib + 1) + " " + toString(eigmin) + " " +
2336- toString(eigmax) + " " + toString(matmin) + " " + toString(matmax) + "\n");
2342+ terminal(" " + String(ib + 1) + " " + String(eigmin) + " " +
2343+ String(eigmax) + " " + String(matmin) + " " + String(matmax) + "\n");
23372344 }/*for (ib = 0; ib < nb; ib++)*/
23382345 }/* max_and_min_bz */
23392346 /**
@@ -2672,31 +2679,31 @@ function button_update() {
26722679 side = Number(document.getElementById('lighting').mousedrag.value);
26732680 /**/
26742681 if (document.getElementById('barcolor').mousedrag.value == "rgb") {
2675- for (ii = 0; ii < 4; ii++) {
2676- BarColor[0][ii] = blue[ii];
2677- BarColor[1][ii] = cyan[ii];
2678- BarColor[2][ii] = green[ii];
2679- BarColor[3][ii] = yellow[ii];
2680- BarColor[4][ii] = red[ii];
2681- }
2682+ for (ii = 0; ii < 4; ii++) {
2683+ BarColor[0][ii] = blue[ii];
2684+ BarColor[1][ii] = cyan[ii];
2685+ BarColor[2][ii] = green[ii];
2686+ BarColor[3][ii] = yellow[ii];
2687+ BarColor[4][ii] = red[ii];
2688+ }
26822689 }
26832690 else if (document.getElementById('barcolor').mousedrag.value == "cmy") {
2684- for (ii = 0; ii < 4; ii++) {
2685- BarColor[0][ii] = cyan[ii];
2686- BarColor[1][ii] = blue[ii];
2687- BarColor[2][ii] = magenta[ii];
2688- BarColor[3][ii] = red[ii];
2689- BarColor[4][ii] = yellow[ii];
2690- }
2691+ for (ii = 0; ii < 4; ii++) {
2692+ BarColor[0][ii] = cyan[ii];
2693+ BarColor[1][ii] = blue[ii];
2694+ BarColor[2][ii] = magenta[ii];
2695+ BarColor[3][ii] = red[ii];
2696+ BarColor[4][ii] = yellow[ii];
2697+ }
26912698 }
26922699 else if (document.getElementById('barcolor').mousedrag.value == "mcy") {
2693- for (ii = 0; ii < 4; ii++) {
2694- BarColor[0][ii] = magenta[ii];
2695- BarColor[1][ii] = blue[ii];
2696- BarColor[2][ii] = cyan[ii];
2697- BarColor[3][ii] = green[ii];
2698- BarColor[4][ii] = yellow[ii];
2699- }
2700+ for (ii = 0; ii < 4; ii++) {
2701+ BarColor[0][ii] = magenta[ii];
2702+ BarColor[1][ii] = blue[ii];
2703+ BarColor[2][ii] = cyan[ii];
2704+ BarColor[3][ii] = green[ii];
2705+ BarColor[4][ii] = yellow[ii];
2706+ }
27002707 }
27012708 /**/
27022709 if (document.getElementById("band0")) draw_band[0] = 1;
@@ -2711,6 +2718,7 @@ function button_update() {
27112718
27122719 Modify : ::cx, ::cy, ::scl
27132720 */
2721+/*
27142722 function TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
27152723 {
27162724 static let dragging = 0;
@@ -2730,27 +2738,27 @@ function TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
27302738 }
27312739 else
27322740 {
2733- /*
2734- Translation of mousepointer from starting point
2735- */
2741+ //
2742+ // Translation of mousepointer from starting point
2743+ //
27362744 dx = (event.GetX() - last_x) * sx;
27372745 dy = (event.GetY() - last_y) * sy;
2738- /*
2739- Distanse from starting point
2740- */
2746+ //
2747+ // Distanse from starting point
2748+ //
27412749 a = Math.sqrt(dx * dx + dy * dy);
2742- /**/
2750+ //
27432751 if (lmouse == 1) {
2744- /**/
2752+ //
27452753 if (a != 0.0) {
2746- /*
2747- Compute rotational matrix from translation of mousepointer
2748- */
2754+ //
2755+ // Compute rotational matrix from translation of mousepointer
2756+ //
27492757 ax = -dy;
27502758 ay = dx;
2751- /**/
2759+ //
27522760 a = a * 10.0;
2753- /**/
2761+ //
27542762 rot0[0][0] = (ax * ax + ay * ay * Math.cos(a)) / (ax * ax + ay * ay);
27552763 rot0[0][1] = ax * ay * (Math.cos(a) - 1.0) / (ax * ax + ay * ay);
27562764 rot0[0][2] = ay * Math.sin(a) / Math.sqrt(ax * ax + ay * ay);
@@ -2760,9 +2768,9 @@ function TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
27602768 rot0[2][0] = -ay * Math.sin(a) / Math.sqrt(ax * ax + ay * ay);
27612769 rot0[2][1] = -ax * Math.sin(a) / Math.sqrt(ax * ax + ay * ay);
27622770 rot0[2][2] = Math.cos(a);
2763- /**/
2771+ //
27642772 for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) rot1[i][j] = rot[i][j];
2765- /**/
2773+ //
27662774 for (i = 0; i < 3; i++) {
27672775 for (j = 0; j < 3; j++) {
27682776 rot[i][j] = rot0[i][0] * rot1[0][j]
@@ -2770,9 +2778,9 @@ function TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
27702778 + rot0[i][2] * rot1[2][j];
27712779 }
27722780 }
2773- /*
2774- Print angle to text Box
2775- */
2781+ //
2782+ //Print angle to text Box
2783+ //
27762784 thetay = Math.asin(rot[0][2]);
27772785 if (Math.cos(thetay) != 0.0) {
27782786 if (-rot[1][2] / Math.cos(thetay) >= 0.0) thetax = Math.acos(rot[2][2] / Math.cos(thetay));
@@ -2843,6 +2851,7 @@ function TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
28432851 Refresh(false);
28442852 }
28452853 }
2854+*/
28462855 /*
28472856 Allocation of Kohn-Sham energies $ matrix elements
28482857 */
@@ -2865,8 +2874,8 @@ function allocate_griddata(
28652874
28662875 scl /= Math.sqrt(bvec[0][0] * bvec[0][0] + bvec[0][1] * bvec[0][1] + bvec[0][2] * bvec[0][2]);
28672876 linewidth /= scl;
2868- myf->textbox_scale->ChangeValue(wxString::Format(wxT("%f"), scl));
2869- myf->textbox_linewidth->ChangeValue(wxString::Format(wxT("%f"), linewidth));
2877+ document.getElementById("scale").value = String(scl);
2878+ document.getElementById("linewidth").value = String(linewidth);
28702879 /*
28712880 Direct lattice vector
28722881 */
@@ -2874,8 +2883,8 @@ function allocate_griddata(
28742883 for (j = 0; j < 3; ++j) avec[i][j] = 0.0;
28752884 avec[i][i] = 1.0;
28762885 solve3(bvec, avec[i]);
2877- terminal(" avec " + toString(i + 1) + " : " + toString(avec[i][0]) + " "
2878- + toString(avec[i][1]) + " " + toString(avec[i][2]) + " \n");
2886+ terminal(" avec " + String(i + 1) + " : " + String(avec[i][0]) + " "
2887+ + String(avec[i][1]) + " " + String(avec[i][2]) + " \n");
28792888 }/*for (i = 0; i < 3; ++i)*/
28802889 for (i = 0; i < 3; ++i) {
28812890 secvec[i] = bvec[2][i];
@@ -2924,98 +2933,65 @@ function read_file()
29242933 let ib, i, j, i0, i1, i2, ii0, ii1, ii2, iaxis, icount;
29252934 let lshift; //!< Switch for shifted Brillouin zone
29262935
2927- const selectedFile = document.getElementById('input').files[0];
2936+ const selectedFile = document.getElementById('inputfile').files[0];
29282937 var reader = new FileReader();
2929- reader.onload = function (evt) {
2930- console.log(evt.target.result);
2931- };
29322938 reader.readAsText(selectedFile);
2933-
2934- let datas = reader.result.replace('\n', '\s').split('\s+');
2935- icount = 0;
2936- /*
2937- Open input file.
2938- */
2939- terminal(" Openning ") << frmsf_file_name << wxT(" ...\n");
2940- if ((fp = fopen(frmsf_file_name.mb_str(), "r")) == NULL) {
2941- terminal("file open error!!\n");
2942- terminal(" Press any key to exit.\n");
2943- ierr = getchar();
2944- exit(EXIT_FAILURE);
2945- }
2946- terminal("\n");
2947- terminal(" ## Brillouin zone informations ###########\n");
2948- terminal("\n");
2949- /*
2950- k-point grid
2951- */
2952- for (i = 0; i < 3; i++) {
2953- ng0[i] = Number(datas[icount]);
2939+ reader.onload = function (event) {
2940+ var result = event.target.result;
2941+ let datas = result.replace(/\n/g, ' ').replace(/^ +/, '').split(/ +/);
2942+ icount = 0;
2943+ terminal("\n");
2944+ terminal(" ## Brillouin zone informations ###########\n");
2945+ terminal("\n");
2946+ /*
2947+ k-point grid
2948+ */
2949+ for (i = 0; i < 3; i++) {
2950+ ng0[i] = Number(datas[icount]);
2951+ icount += 1;
2952+ }
2953+ terminal(" k point grid : " + String(ng0[0]) + " " + String(ng0[1]) + " " + String(ng0[2]) + "\n");
2954+ /*
2955+ Shift of k-point grid
2956+ */
2957+ lshift = Number(datas[icount]);
29542958 icount += 1;
2955- }
29562959
2957- terminal(" k point grid : " + toString(ng0[0]) + " " + toString(ng0[1]) + " " + toString(ng0[2]) + "\n");
2958- /*
2959- Shift of k-point grid
2960- */
2961- lshift = Number(datas[icount]);
2962- icount += 1;
2963-
2964- if (lshift == 0) {
2965- terminal(" k point grid is the Monkhorst-Pack grid.\n");
2966- for (i = 0; i < 3; i++) shiftk[i] = (ng0[i] + 1) % 2;
2967- }
2968- else if (lshift == 1) {
2969- terminal(" k point grid starts from Gamma.\n");
2970- for (i = 0; i < 3; i++) shiftk[i] = 0;
2971- }
2972- else if (lshift == 2) {
2973- terminal(" k point grid starts from Gamma + a half grid.\n");
2974- for (i = 0; i < 3; i++) shiftk[i] = 1;
2975- }
2976- else {
2977- exit(0);
2978- }
2979- /*
2980- # of bands
2981- */
2982- nb = Number(datas[icount]);
2983- icount += 1;
2984- terminal(" # of bands : " + toString(nb) + "\n");
2985- /*
2986- Reciplocal lattice vectors
2987- */
2988- for (i = 0; i < 3; ++i) {
2989- for (j = 0; j < 3; j++) {
2990- bvec[i][j] = Number(datas[icount]);
2991- icount += 1;
2960+ if (lshift == 0) {
2961+ terminal(" k point grid is the Monkhorst-Pack grid.\n");
2962+ for (i = 0; i < 3; i++) shiftk[i] = (ng0[i] + 1) % 2;
29922963 }
2993- terminal(" bvec " + toString(i + 1) + " : " + toString(bvec[i][0]) + " " + toString(bvec[i][1]) + " " + toString(bvec[i][2]) + " \n");
2994- }/*for (i = 0; i < 3; ++i)*/
2995- allocate_griddata(ng, ng0);
2996- /*
2997- Kohn-Sham energies
2998- */
2999- for (ib = 0; ib < nb; ++ib) {
3000- for (i0 = 0; i0 < ng0[0]; ++i0) {
3001- if (lshift != 0) ii0 = i0;
3002- else ii0 = modulo(i0 + (ng0[0] + 1) / 2, ng0[0]);
3003- for (i1 = 0; i1 < ng0[1]; ++i1) {
3004- if (lshift != 0) ii1 = i1;
3005- else ii1 = modulo(i1 + (ng0[1] + 1) / 2, ng0[1]);
3006- for (i2 = 0; i2 < ng0[2]; ++i2) {
3007- if (lshift != 0) ii2 = i2;
3008- else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]);
3009- eig0[ib][ii0][ii1][ii2] = Number(datas[icount]);
3010- icount += 1;
3011- }
3012- }
2964+ else if (lshift == 1) {
2965+ terminal(" k point grid starts from Gamma.\n");
2966+ for (i = 0; i < 3; i++) shiftk[i] = 0;
30132967 }
3014- }
3015- /*
3016- Matrix elements
3017- */
3018- for (iaxis = 0; iaxis < 1; iaxis++) {
2968+ else if (lshift == 2) {
2969+ terminal(" k point grid starts from Gamma + a half grid.\n");
2970+ for (i = 0; i < 3; i++) shiftk[i] = 1;
2971+ }
2972+ else {
2973+ exit(0);
2974+ }
2975+ /*
2976+ # of bands
2977+ */
2978+ nb = Number(datas[icount]);
2979+ icount += 1;
2980+ terminal(" # of bands : " + String(nb) + "\n");
2981+ /*
2982+ Reciplocal lattice vectors
2983+ */
2984+ for (i = 0; i < 3; ++i) {
2985+ for (j = 0; j < 3; j++) {
2986+ bvec[i][j] = Number(datas[icount]);
2987+ icount += 1;
2988+ }
2989+ terminal(" bvec " + String(i + 1) + " : " + String(bvec[i][0]) + " " + String(bvec[i][1]) + " " + String(bvec[i][2]) + " \n");
2990+ }/*for (i = 0; i < 3; ++i)*/
2991+ allocate_griddata(ng, ng0);
2992+ /*
2993+ Kohn-Sham energies
2994+ */
30192995 for (ib = 0; ib < nb; ++ib) {
30202996 for (i0 = 0; i0 < ng0[0]; ++i0) {
30212997 if (lshift != 0) ii0 = i0;
@@ -3026,13 +3002,39 @@ function read_file()
30263002 for (i2 = 0; i2 < ng0[2]; ++i2) {
30273003 if (lshift != 0) ii2 = i2;
30283004 else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]);
3029- mat0[ib][ii0][ii1][ii2][iaxis] = Number(datas[icount]);
3005+ eig0[ib][ii0][ii1][ii2] = Number(datas[icount]);
30303006 icount += 1;
3031- }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/
3032- }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/
3033- }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/
3034- }/*for (ib = 0; ib < nb; ++ib)*/
3035- }
3007+ }
3008+ }
3009+ }
3010+ }
3011+ /*
3012+ Matrix elements
3013+ */
3014+ for (iaxis = 0; iaxis < 1; iaxis++) {
3015+ for (ib = 0; ib < nb; ++ib) {
3016+ for (i0 = 0; i0 < ng0[0]; ++i0) {
3017+ if (lshift != 0) ii0 = i0;
3018+ else ii0 = modulo(i0 + (ng0[0] + 1) / 2, ng0[0]);
3019+ for (i1 = 0; i1 < ng0[1]; ++i1) {
3020+ if (lshift != 0) ii1 = i1;
3021+ else ii1 = modulo(i1 + (ng0[1] + 1) / 2, ng0[1]);
3022+ for (i2 = 0; i2 < ng0[2]; ++i2) {
3023+ if (lshift != 0) ii2 = i2;
3024+ else ii2 = modulo(i2 + (ng0[2] + 1) / 2, ng0[2]);
3025+ mat0[ib][ii0][ii1][ii2][iaxis] = Number(datas[icount]);
3026+ icount += 1;
3027+ }/*for (i2 = 0; i2 < ng0[2]; ++i2)*/
3028+ }/*for (i1 = 0; i1 < ng0[1]; ++i1)*/
3029+ }/*for (i0 = 0; i0 < ng0[0]; ++i0)*/
3030+ }/*for (ib = 0; ib < nb; ++ib)*/
3031+ }
3032+ };
3033+ reader.onerror = function () {
3034+ terminal("File can not be loaded.");
3035+ };
3036+
3037+
30363038 return 1;
30373039 } /* read_file */
30383040 /**
@@ -3344,6 +3346,6 @@ function calc_section() {
33443346 */
33453347 n2d[ib] = kv2d[ib].length;
33463348
3347- terminal(" " + toString(ib + 1) + " " + toString(n2d[ib]) + "\n");
3349+ terminal(" " + String(ib + 1) + " " + String(n2d[ib]) + "\n");
33483350 }/*for (ib = 0; ib < nb; ib++)*/
33493351 }/*function calc_nodeline()*/
Show on old repository browser