-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_html.py
178 lines (173 loc) · 10.5 KB
/
write_html.py
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
import json
names = ["B2Mg1-108064"]
json_file = open("data.json", "r")
data_json = json.load(json_file)
for name in data_json.keys():
eform = data_json[name]["eform"]
dosf = data_json[name]["dosf"]
magt = data_json[name]["magt"]
atom_type = data_json[name]["type"]
nat = 0
for atom in atom_type.keys():
nat += int(atom_type[atom]["nat"])
with open("/home/kawamura/work/xsf_icsd/" + str(name) + ".xsf") as f:
lattice = f.readlines()
lattice = "".join(lattice).replace("\n", "\\n")
with open("html/" + name + ".html", 'w') as f:
print("<html>", file=f)
print(" <head>", file=f)
print(" <title>" + name + "</title>", file=f)
print(" <meta charset=\"utf-8\">", file=f)
print(" <script type=\"text/javascript\" src=\"../JSmol.min.js\"></script>", file=f)
print(" <script type=\"text/javascript\"> ", file=f)
print("", file=f)
print("// supersimple2.htm - illustrating the use of jQuery(document).ready to ", file=f)
print("// populate all spans and divs AFTER the page is loaded.", file=f)
print("// This is good programming practice.", file=f)
print("", file=f)
print("$(document).ready(", file=f)
print("", file=f)
print("function() {", file=f)
print("", file=f)
print("Info = {", file=f)
print(" width: 600,", file=f)
print(" height: 600,", file=f)
print(" debug: false,", file=f)
print(" j2sPath: \"../j2s\",", file=f)
print(" color: \"0xC0C0C0\",", file=f)
print(" disableJ2SLoadMonitor: true,", file=f)
print(" disableInitialConsole: true,", file=f)
print(" addSelectionOptions: false,", file=f)
print(" serverURL: \"https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php\",", file=f)
print(" use: \"HTML5\",", file=f)
print(" readyFunction: null,", file=f)
print(" script: \"load INLINE \\\"" + lattice +
"\\\" {3,3,3}; set perspectiveDepth ON; select;set defaultLabelXYZ \\\"%e\\\"; set labelToggle; set labelAtom; set labelOffset 0 0; color labels black\"", file=f)
print("}", file=f)
print("", file=f)
print("$(\"#mydiv\").html(Jmol.getAppletHtml(\"jmolApplet0\",Info))", file=f)
print("}", file=f)
print(");", file=f)
print("", file=f)
print(" </script>", file=f)
print("", file=f)
print("<!-- gnuplot head start -->", file=f)
print(" <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">", file=f)
print(" <!--[if IE]><script type=\"text/javascript\" src=\"excanvas.js\"></script><![endif]-->", file=f)
print(" <script src=\"../gnuplot/canvastext.js\"></script>", file=f)
print(" <script src=\"../gnuplot/gnuplot_common.js\"></script>", file=f)
print(" <script src=\"../gnuplot/gnuplot_dashedlines.js\"></script>", file=f)
print(" <script src=\"../gnuplot/gnuplot_mouse.js\"></script>", file=f)
print(" <script type=\"text/javascript\"> gnuplot.help_URL = \"/canvas_help.html\"; </script>", file=f)
print(" <script type=\"text/javascript\">", file=f)
print("var canvas, ctx;", file=f)
print("gnuplot.grid_lines = true;", file=f)
print("gnuplot.zoomed = false;", file=f)
print("gnuplot.active_plot_name = \"gnuplot_canvas\";", file=f)
print(" </script>", file=f)
print(" <script src=\"../band/" + name + ".js\"></script>", file=f)
print(" <link type=\"text/css\" href=\"../gnuplot/gnuplot_mouse.css\" rel=\"stylesheet\">", file=f)
print(" <!-- gnuplot head end -->", file=f)
print(" </head>", file=f)
print(" <body bgcolor=\"CCFFCC\" onload=\"gnuplot_canvas(); gnuplot.init();\" oncontextmenu=\"return false;\">", file=f)
print("", file=f)
print(" <h1>" + name + "</h1>", file=f)
print(" ", file=f)
print(" <h2>Crystal structure</h2>", file=f)
print(" <span id=mydiv></span>", file=f)
print("", file=f)
print(" <h2>Properties</h2>", file=f)
print("", file=f)
print(" <p>Number of atoms per unit cell : " + str(nat) + "</p>", file=f)
print(" <p>Formation energy : " + str(eform) + " eV/atom</p>", file=f)
print(" <p>Magnetization : " + str(magt) + " μ<sub>B</sub>/atom</p>", file=f)
print(" <p>DOS at E<sub>F</sub> : " + str(dosf) + " /eV/atom (both spin)</p>", file=f)
print("", file=f)
print(" <h2>Band structure</h2>", file=f)
print(" <div class=\"gnuplot\">", file=f)
print(" <canvas id=\"Tile\" width=\"32\" height=\"32\" hidden></canvas>", file=f)
print(" <table class=\"mbleft\">", file=f)
print(" <tr>", file=f)
print(" <td class=\"mousebox\">", file=f)
print(" <table class=\"mousebox\" border=0>", file=f)
print(" <tr>", file=f)
print(" <td class=\"mousebox\">", file=f)
print(" <table class=\"mousebox\" id=\"gnuplot_mousebox\" border=0>", file=f)
print(" <tr><td class=\"mbh\"></td></tr>", file=f)
print(" <tr>", file=f)
print(" <td class=\"mbh\">", file=f)
print(" <table class=\"mousebox\">", file=f)
print(" <tr>", file=f)
print(" <td class=\"icon\"></td>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.toggle_grid><img src=\"../gnuplot/grid.png\" id=\"gnuplot_grid_icon\" class=\"icon-image\" alt=\"#\" title=\"toggle grid\"></td>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.unzoom><img src=\"../gnuplot/previouszoom.png\" id=\"gnuplot_unzoom_icon\" class=\"icon-image\" alt=\"unzoom\" title=\"unzoom\"></td>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.rezoom><img src=\"../gnuplot/nextzoom.png\" id=\"gnuplot_rezoom_icon\" class=\"icon-image\" alt=\"rezoom\" title=\"rezoom\"></td>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.toggle_zoom_text><img src=\"../gnuplot/textzoom.png\" id=\"gnuplot_textzoom_icon\" class=\"icon-image\" alt=\"zoom text\" title=\"zoom text with plot\"></td>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.popup_help()><img src=\"../gnuplot/help.png\" id=\"gnuplot_help_icon\" class=\"icon-image\" alt=\"?\" title=\"help\"></td>", file=f)
print(" </tr>", file=f)
print(" <tr>", file=f)
print(" <td class=\"icon\" onclick=gnuplot.toggle_plot(\"gp_plot_1\")>1</td>", file=f)
print(" <td class=\"icon\" > </td>", file=f)
print(" <td class=\"icon\" > </td>", file=f)
print(" <td class=\"icon\" > </td>", file=f)
print(" <td class=\"icon\" > </td>", file=f)
print(" <td class=\"icon\" > </td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </td>", file=f)
print(" </tr>", file=f)
print(" <tr>", file=f)
print(" <td class=\"mousebox\">", file=f)
print(" <table class=\"mousebox\" id=\"gnuplot_mousebox\" border=1>", file=f)
print(" <tr>", file=f)
print(" <td class=\"mb0\">x </td>", file=f)
print(" <td class=\"mb1\"><span id=\"gnuplot_canvas_x\"> </span></td>", file=f)
print(" </tr>", file=f)
print(" <tr>", file=f)
print(" <td class=\"mb0\">y </td>", file=f)
print(" <td class=\"mb1\"><span id=\"gnuplot_canvas_y\"> </span></td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </td>", file=f)
print(" <td>", file=f)
print(" <table class=\"plot\">", file=f)
print(" <tr>", file=f)
print(" <td>", file=f)
print(" <canvas id=\"gnuplot_canvas\" width=\"600\" height=\"400\" tabindex=\"0\">", file=f)
print(" Sorry, your browser seems not to support the HTML 5 canvas element", file=f)
print(" </canvas>", file=f)
print(" </td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </td>", file=f)
print(" </tr>", file=f)
print(" </table>", file=f)
print(" </div>", file=f)
print(" <h2>Fermi surface and PDOS (/eV/atom both spin)</h2>", file=f)
print(" ", file=f)
for atom in atom_type.keys():
for n in atom_type[atom].keys():
if not isinstance(atom_type[atom][n], dict):
continue
for l in atom_type[atom][n].keys():
orb = str(atom) + str(n) + str(l)
pdos0 = sum(atom_type[atom][n][l]["pdos"]) / nat
print(" <li><a href=\"../fermisurfer/index.php?frmsf=../fermi/"
+ name + "-" + orb + ".js\" ", file=f)
print(" target=\"_blank\">" + orb + "</a>", file=f)
print(" : " + str(pdos0) + "</li>", file=f)
print("", file=f)
print(" <h2>Input and output</h2>", file=f)
print(" <ul>", file=f)
print(" <li><a href=\"../scfin/scf_" + name + ".in\">SCF input</a></li>", file=f)
print(" <li><a href=\"../scfout/scf_" + name + ".out\">SCF output</a></li>", file=f)
print(" </ul>", file=f)
print("", file=f)
print(" </body>", file=f)
print("</html>", file=f)