-
Notifications
You must be signed in to change notification settings - Fork 44
/
xff.html
118 lines (104 loc) · 38 KB
/
xff.html
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
<meta charset='utf-8'>
<style>
body { font: 1em/1.5 Consolas}
code {
font: bold 1em/1.2 Consolas, Monaco, monospace, SimHei;
overflow: auto;
background: #F5F2F0;
max-width: 100%;
color: #DD1144;
padding: 0;
border: 1.2px solid #E0DFCC;
margin: 0 .3em 0 0.3em;
}
.th {
color:#fff;
background-color: #EF6C00;
padding: 3px;
}
.btn {
font: bold 1em/1.2 Consolas, Monaco;
width: 100%;
height: 2em;
color:#fff; background-color:#00897B;
display: inline-block;
cursor: pointer;
vertical-align:middle;
text-align:center;
border: 2px solid #000;
}
</style>
<script src="https://jerkwin.github.io/jscss/ChemDoodleWeb.js"></script>
<div id='box' style='height:100%;width:100%;'>
<div id='container' style='height:100%;width:calc(80% - 5px);float:left;overflow:scroll'>
<table>
<tr><td colspan='3'>
<label class="btn">
<input type="file" id='hess' accept=".fchk, .fch" hidden>
Load GAUSSIAN fchk File
</label>
</td></tr>
<tr>
<td style="width:200px; height:500px;vertical-align:top">
<span class='th' style="display:inline-block;">#Atom: FFtype FFindex</span><br>
<textarea id="types" style="width:100%; height:500px"></textarea><br>
<input type="button" class='btn' value="Reset FFindex" onclick="reBond()">
</td>
<td style="width:500px; height:550px;vertical-align:top">
<script>
var Mol1=new ChemDoodle.TransformCanvas3D('Mol-1',500,400);
Mol1.specs.shapes_color = '#fff';
Mol1.specs.backgroundColor = 'black';
Mol1.specs.set3DRepresentation('Ball and Stick');
Mol1.specs.projectionPerspective_3D = false;
Mol1.specs.compass_display=true;
Mol1.dblclick=ChemDoodle.RotatorCanvas.prototype.dblclick;
Mol1.isRunning=ChemDoodle._AnimatorCanvas.prototype.isRunning;
Mol1.startAnimation=ChemDoodle._AnimatorCanvas.prototype.startAnimation;
Mol1.stopAnimation=ChemDoodle._AnimatorCanvas.prototype.stopAnimation;
Mol1.timeout=5;
Mol1.handle=null;
Mol1.nextFrame=function(delta){var matrix=[],change=delta*Math.PI/15000;ChemDoodle.lib.mat4.identity(matrix);ChemDoodle.lib.mat4.rotate(matrix,change,[1,0,0]);ChemDoodle.lib.mat4.rotate(matrix,change,[0,1,0]);ChemDoodle.lib.mat4.rotate(matrix,change,[0,0,1]);ChemDoodle.lib.mat4.multiply(this.rotationMatrix, matrix)};
Mol1.loadContent('');
Mol1.startAnimation();
Mol1.stopAnimation();
function show1() {Mol1.setupScene();Mol1.repaint()}
function setModel1(model){Mol1.specs.set3DRepresentation(model);show1()}
function setSpeed1(){Mol1.timeout=2000-document.getElementById('spd1').value;show1();
Mol1.startAnimation()}
</script>
<span class="code">View : <input type='checkbox' onclick='Mol1.specs.projectionPerspective_3D=this.checked;show1()'>perspective <input type='checkbox' onclick='Mol1.specs.atoms_displayLabels_3D=this.checked;Mol1.repaint()'>label atoms<br>Model: <input type='radio' name='model' onclick='setModel1('Ball and Stick')' checked=''>ball & stick <input type='radio' name='model' onclick='setModel1('van der Waals Spheres')'>covalent spheres<br> <input type='radio' name='model' onclick='setModel1('Stick')'>stick <input type='radio' name='model' onclick='setModel1('Wireframe')'>wireframe <input type='radio' name='model' onclick='setModel1('Line')'>line<br>Left : rotate Middle: zoom Alt+Left: move<br>Double-click: switch spin speed:</span> <input type='range' id='spd1' min='1' max='2000' onchange='setSpeed1()'/>
</td>
<td style="width:200px; height:500px;vertical-align:top">
<span class='th' style="display:inline-block;">#Atom: Bondingto</span><br>
<textarea id="bonds" style="width:100%; height:500px"></textarea><br>
<input type="button" class='btn' value="Reset Bonding" onclick="reBond()">
</td>
</tr>
<tr><td colspan='3'><span class='th'>Scaling Factor </span> <input type="box" value="1" id="Kscale" style='width:20%;font:bold 1em Consolas,"Courier New",Monaco;'> used to scale the calculated force constants</td></tr>
<tr><td colspan='3'><span class='th'>Selected Atoms </span> <input type="box" value="all" id="selatoms" style='width:20%;font:bold 1em Consolas,"Courier New",Monaco;'> 1-based index, <code>all</code>or<code>min:max:step</code>,<code>-</code>to invert</td></tr>
<tr><td colspan='3'><span class='th'>Diagonalization</span>
<input type='radio' name='eigen' id='qr' checked>QR
<input type='radio' name='eigen' id='jacobi'>Jacobi
</td></tr>
<tr><td colspan='3'>
<input type='button' class='btn' value='Generate GROMACS top File' onclick='gentop()' style='width:100%; height:30px'>
</td></tr>
<tr>
<td><input type='button' class='btn' value='Download conf.gro' onclick='saveFile("gro")' style='width:100%; height:30px'></td>
<td><input type='button' class='btn' value='Download topol.top' onclick='saveFile("top")' style='width:100%; height:30px'></td>
<td><input type='button' class='btn' value='Download grompp.mdp' onclick='saveFile("mdp")' style='width:100%; height:30px'></td>
</tr>
</table>
</div>
<div id='resize' style='width:5px; height:100%; background:skyblue; cursor: w-resize; float:left;'></div>
<div id='right' style='height:100%;width:20%;float:right;overflow:scroll;'>
<span class='th'>GROMACS top File</span><br>
<textarea id='top' style='width: 95%; height:80%; margin: 0px;'></textarea><br>
<span class='th'>HELP 2022-04-14</span><br>
<span class='btn'>Reset Bonding</span> reset the bonding with the provided information
</div>
</div>
<script>
"use strict";function trim(t){return t.replace(/^(\s|\u00A0)*\n*/,"").replace(/(\s|\u00A0)*\n*$/,"")}function wstrlen(t){return null==t?0:("string"!=typeof t&&(t+=""),t.replace(/[^\x00-\xff]/g,"12").length)}function printf(){function t(t,a){var r=Array(99).join(" ").substr(0,Math.abs(a)-wstrlen(t));return a>0?r+t:t+r}var a={s:function(a,r){return t(a,1*r)},d:function(a,r){return a=parseFloat(a).toFixed(0),t(a,r)},f:function(a,r){return r=r.split("."),a=parseFloat(a).toFixed(r[1]),t(a,r[0])},e:function(a,r){return r=r.split("."),a=parseFloat(a).toExponential(r[1]),t(a.toUpperCase(),r[0])}},r=Array.prototype.slice.call(arguments).slice();return r.shift().toString().replace(/%(-*\d*\.*\d*)([sdfe])/g,function(t,o,e){if(!r.length)throw new Error("Too few elements");return a[e](r.shift(),o)})}function extension(t){return t.substring(t.lastIndexOf(".")+1).toLowerCase()}function loadHess(t){var a=t.target.files[0];if(a){var r=new FileReader;r.onload=function(t){extension(a.name);Fchk=t.target.result,showMol()},r.readAsText(a)}else alert("Failed to load file")}function showMol(){IDat=Fchk.replace(/^[\s\S]*Atomic numbers.*/,"").replace(/[a-zA-Z]{2,}[\s\S]*/,"");var t=Fchk.replace(/^[\s\S]*Current cartesian coordinates.*/,"").replace(/[a-zA-Z]{2,}[\s\S]*/,""),a=Fchk.replace(/^[\s\S]*Cartesian Force Constants.*/,"").replace(/[a-zA-Z]{2,}[\s\S]*/,"");IDat=trim(IDat).split(/\s+/),t=trim(t).split(/\s+/),a=trim(a).split(/\s+/);var r,o;for(Natm=IDat.length,r=0;r<Natm;r++)o=3*r,Fatm[r]=r+1,Xatm[r]=[t[o]*bohr2A,t[o+1]*bohr2A,t[o+2]*bohr2A],Hfull[o]=[],Hfull[o+1]=[],Hfull[o+2]=[];var e,n=0;for(r=0;r<3*Natm;r++)for(o=0;o<=r;o++)e=parseFloat(a[n]),r!=o&&(e*=-1),Hfull[r][o]=e*Kau,Hfull[o][r]=e*Kau,n++;var i=0,f="",s="";for(r=0;r<Natm;r++)adj[r]=[];for(r=0;r<Natm;r++){for(adj[r][r]=0,Tatm[r]=ElmSyb(IDat[r]),f+=printf("%5d:",r+1),s+=printf("%5d: %3s %5d\n",r+1,Tatm[r],r+1),o=r+1;o<Natm;o++)adj[r][o]=0,norm(vij(r,o))<(Rcov(IDat[r])+Rcov(IDat[o]))*(1+Rtol)&&(i++,adj[r][o]=1,f+=printf("%3d",o+1)),adj[o][r]=adj[r][o];f+="\n"}$("types").value=s,$("bonds").value=f,reBond()}function reBond(){var t,a;for(t=0;t<Natm;t++)for(a=0;a<Natm;a++)adj[t][a]=0;var r,o=[];for(r=trim($("types").value).replace(/:/g," ").split(/\n/),t=0;t<r.length;t++)o=trim(r[t]).split(/\s+/),o.length>1&&(Tatm[o[0]-1]=o[1]),o.length>2&&(Fatm[o[0]-1]=o[2]);for(r=trim($("bonds").value).replace(/:/g," ").split(/\n/),t=0;t<r.length;t++)for(o=trim(r[t]).split(/\s+/),a=1;a<o.length;a++)o[a]<=Natm&&(adj[o[0]-1][o[a]-1]=1,adj[o[a]-1][o[0]-1]=1);var e=0;for(t=0;t<Natm;t++)for(a=t+1;a<Natm;a++)adj[t][a]&&e++;var n=printf("MOL Name\nMOL ID\nComment\n%3d%3d\n",Natm,e);for(t=0;t<Natm;t++)n+=printf("%10.4f%10.4f%10.4f%3s\n",Xatm[t][0],Xatm[t][1],Xatm[t][2],ElmSyb(IDat[t]));for(t=0;t<Natm;t++){for(a=t+1;a<Natm;a++)adj[t][a]&&(n+=printf(" %d %d 1\n",t+1,a+1));ChemDoodle.ELEMENT[ElmSyb(IDat[t])].vdWRadius=20*Rcov(IDat[t])}Mol1.loadContent([ChemDoodle.readMOL(n)])}function typeBAD(t){var a=t.length,r=[];return 2==a?(t.sort(),t[0]+"_"+t[1]):3==a?(r=[t[0],t[2]],r.sort(),r[0]+"_"+t[1]+"_"+r[1]):4==a?t[1]==t[2]?(r=[t[0],t[3]],r.sort(),r[0]+"_"+t[1]+"_"+t[2]+"_"+r[1]):t[1]<t[2]?t[0]+"_"+t[1]+"_"+t[2]+"_"+t[3]:t[3]+"_"+t[2]+"_"+t[1]+"_"+t[0]:void 0}function gentop(){reBond(),$("qr").checked&&(method=1),$("jacobi").checked&&(method=2);var t,a,r,o,e,n,i,f,s,l,m=[];for(t=0;t<Natm;t++)for(m[t]=[],a=0;a<Natm;a++)adj[t][a]&&m[t].push(a);var h=[],u=[],d=[];for(t=0;t<Natm;t++)for(a=t+1;a<Natm;a++)adj[t][a]&&(h.push([t,a]),s=typeBAD([Tatm[t],Tatm[a]]),s in u?u[s]++:(u[s]=1,d[s]=[0,0]));var c=[],v=[],p=[],M=[],b=[],g=[];for(a=0;a<Natm;a++)for(e=0;e<m[a].length;e++)for(t=m[a][e],n=e+1;n<m[a].length;n++)r=m[a][n],l=angle(vij(a,t),vij(a,r)),s=typeBAD([Tatm[t],Tatm[a],Tatm[r]]),Math.abs(l-180)>Rpi?(c.push([t,a,r]),s in v?v[s]++:(v[s]=1,p[s]=[0,0])):(M.push([t,a,r]),s+="_Linear",s in b?b[s]++:(b[s]=1,g[s]=[0,0]));var j=[],y=[],A=[];for(i=0;i<h.length;i++)for(a=h[i][0],r=h[i][1],e=0;e<m[a].length;e++)if((t=m[a][e])!=r)for(f=0;f<m[r].length;f++)(o=m[r][f])!=a&&t!=o&&(j.push([t,a,r,o]),s=typeBAD([Tatm[t],Tatm[a],Tatm[r],Tatm[o]]),s in y?y[s]++:(y[s]=1,A[s]=[0,0]));var w,E,D,N,S,T=[],F=[],I=[];for(t=0;t<Natm;t++)3==m[t].length&&(a=m[t][0],w=uij(t,a),r=m[t][1],E=uij(t,r),o=m[t][2],D=uij(t,o),N=unit(cross(w,E)),Math.abs(angle(N,D)-90)<Rpi&&(S=[(w[0]+E[0])/2,(w[1]+E[1])/2,(w[2]+E[2])/2],angle(S,D)>angle(w,E)/2&&(T.push([t,a,r,o]),s=typeBAD([Tatm[t],Tatm[a],Tatm[r],Tatm[o]])+"_imp",s in F?F[s]++:(F[s]=1,I[s]=[0,0]))));var H,B,L,R,C,K=trim($("selatoms").value),x=trim(K.replace(/ +: +/g,":")).split(/\s+/),k=[];for(t=0;t<Natm;t++)k[t]=!0;for(t=0;t<x.length;t++)if(-1==x[t].indexOf("all")){for(K=trim(x[t]).split(/:/),H=K.length,B=parseInt(K[0]),C=B>0,B=Math.abs(B),L=Natm,R=1,1==H&&(L=B),H>=2&&(L=Math.abs(parseInt(K[1]))),3==H&&(R=Math.abs(parseInt(K[2]))),B=Math.min(Math.max(1,B),Natm),L=Math.min(Math.max(1,L),Natm),a=B;a<=L;a+=R)k[a-1]=C;k[L-1]=C}else for(C=!0,-1!=x[t].indexOf("-all")&&(C=!1),a=0;a<Natm;a++)k[a]=C;var X="",V="[ moleculetype ]\n ;name nrexcl\n MOL 3\n\n###DEF###";for(V+="\n\t[ atoms ]\n ;# type res# res atom cg# charge mass comment\n",t=0;t<Natm;t++)a=IDat[t],k[t]&&(V+=printf(" %5d %-10s 1 MOL %-10s %4f %10.6f %10.6f ; %s%s\n",Fatm[t],Tatm[t],ElmSyb(a),t+1,0,ElmMass(a),ElmSyb(a),t+1));var q,O,P,U,_,J,G,Y;for(Kscale=parseFloat($("Kscale").value),Kscale*=Kscale,V+="\t[ bonds ]\n ;#i #j funtype r0(nm) k(kJ/mol/nm^2)\n",e=0;e<h.length;e++)q=h[e][0],O=h[e][1],Y=Kij(q,O,uij(q,O),!0)*Kscale*Kbgmx,l=norm(vij(q,O))*A2nm,s=typeBAD([Tatm[q],Tatm[O]]),d[s][0]+=l/u[s],d[s][1]+=Y/u[s],(k[q]||k[O])&&(V+=printf(" %5d %5d 1 %12.6f %15.6f ; %s ; %s\n",Fatm[q],Fatm[O],l,Y,s,ElmSyb(IDat[q])+(q+1)+"-"+ElmSyb(IDat[O])+(O+1)));for(s in u)X+=printf(" #define %-20s %12.6f %15.6f\n",s,d[s][0],d[s][1]);for(V+="\t[ angles ]\n ;#i #j #k funtype theta0(deg) k(kJ/mol/rad^2)\n",e=0;e<c.length;e++)q=c[e][0],O=c[e][1],P=c[e][2],l=angle(vij(q,O),vij(P,O)),s=typeBAD([Tatm[q],Tatm[O],Tatm[P]]),_=Kijk(q,O,P),J=Kijk(P,O,q),Y=(_+J)/2*Kscale*Kagmx,p[s][0]+=l/v[s],p[s][1]+=Y/v[s],(k[q]||k[O]||k[P])&&(V+=printf(" %5d %5d %5d 1 %12.6f %15.6f ; %s ; %s\n",Fatm[q],Fatm[O],Fatm[P],l,Y,s,ElmSyb(IDat[q])+(q+1)+"-"+ElmSyb(IDat[O])+(O+1)+"-"+ElmSyb(IDat[P])+(P+1)));for(e=0;e<M.length;e++)q=M[e][0],O=M[e][1],P=M[e][2],l=angle(vij(q,O),vij(P,O)),s=typeBAD([Tatm[q],Tatm[O],Tatm[P]])+"_Linear",Y=Ki(O,uij(q,P))*Kscale*Kbgmx,g[s][0]+=l/b[s],g[s][1]+=Y/b[s],(k[q]||k[O]||k[P])&&(V+=printf(" %5d %5d %5d 9 %12.6f %15.6f ; %s ; %s\n",Fatm[q],Fatm[O],Fatm[P],l,Y,s,ElmSyb(IDat[q])+(q+1)+"-"+ElmSyb(IDat[O])+(O+1)+"-"+ElmSyb(IDat[P])+(P+1)));for(s in v)X+=printf(" #define %-20s %12.6f %15.6f\n",s,p[s][0],p[s][1]);for(s in b)X+=printf(" #define %-20s %12.6f %15.6f\n",s,g[s][0],g[s][1]);for(V+="\t[ dihedrals ]\n ;#i #j #k #l funtype phi0(deg) k(kJ/mol/rad^2)\n",e=0;e<j.length;e++)q=j[e][0],O=j[e][1],P=j[e][2],U=j[e][3],_=Kijkl(q,O,P,U),J=Kijkl(U,P,O,q),Y=(_+J)/2*Kscale*Kagmx,l=angle(cross(uij(O,P),uij(O,q)),cross(uij(O,P),uij(O,U))),s=typeBAD([Tatm[q],Tatm[O],Tatm[P],Tatm[U]]),A[s][0]+=l/y[s],A[s][1]+=Y/y[s],(k[q]||k[O]||k[P]||k[U])&&(V+=printf(" %5d %5d %5d %5d 1 %12.6f %15.6f ; %s ; %s\n",q+1,O+1,P+1,U+1,l,Y,s,ElmSyb(IDat[q])+(q+1)+"-"+ElmSyb(IDat[O])+(O+1)+"-"+ElmSyb(IDat[P])+(P+1)+"-"+ElmSyb(IDat[U])+(U+1)));for(s in y)X+=printf(" #define %-20s %12.6f %15.6f\n",s,A[s][0],A[s][1]);for(V+="\t[ dihedrals ]\n ;#i #j #k #l funtype xi0(deg) k(kJ/mol/rad^2)\n",e=0;e<T.length;e++)q=T[e][0],O=T[e][1],P=T[e][2],U=T[e][3],N=unit(cross(uij(q,O),uij(q,P))),_=Kij(q,O,N,!0),J=Kij(q,P,N,!0),G=Kij(q,U,N,!0),l=norm(vij(q,O))*Math.sin(angle(uij(O,q),uij(O,P))*Math.PI/180),Y=(_+J+G)*Kscale*Kagmx*l*l,l=0,s=typeBAD([Tatm[q],Tatm[O],Tatm[P],Tatm[U]])+"_imp",I[s][0]+=l/F[s],I[s][1]+=Y/F[s],(k[q]||k[O]||k[P]||k[U])&&(V+=printf(" %5d %5d %5d %5d 1 %12.6f %15.6f ; %s ; %s\n",q+1,O+1,P+1,U+1,l,Y,s,ElmSyb(IDat[q])+(q+1)+"-"+ElmSyb(IDat[O])+(O+1)+"-"+ElmSyb(IDat[P])+(P+1)+"-"+ElmSyb(IDat[U])+(U+1)));for(s in F)X+=printf(" #define %-20s %12.6f %15.6f\n",s,I[s][0],I[s][1]);V=V.replace(/###DEF###/,X)+"\n[ system ]\n MOL XFF\n\t[ molecules ]\n MOL 1\n",$("top").value=V}function Ki(t,a){var r=3*t,o=[[],[],[]];o[0]=[Hfull[r][r],Hfull[r][r+1],Hfull[r][r+2]],o[1]=[Hfull[r+1][r],Hfull[r+1][r+1],Hfull[r+1][r+2]],o[2]=[Hfull[r+2][r],Hfull[r+2][r+1],Hfull[r+2][r+2]],2==method&&(o[0][1]=.5*(o[0][1]+o[1][0]),o[0][2]=.5*(o[0][2]+o[2][0]),o[1][2]=.5*(o[1][2]+o[2][1]),o[1][0]=o[0][1],o[2][0]=o[0][2],o[2][1]=o[1][2]);var e,n=[],i=[[],[],[]],f=[];return 0==method&&(e=eig(o)),1==method&&(e=eigReal(o)),2==method&&(e=Jacobi(o)),3==method&&(e=SVD(o)),f=e.L,i=e.V,n=unit([a[0],a[1],a[2]]),dot(f,[Math.sqrt(1-Math.pow(dot(n,i[0]),2)),Math.sqrt(1-Math.pow(dot(n,i[1]),2)),Math.sqrt(1-Math.pow(dot(n,i[2]),2))])}function Kij(t,a,r,o){var e=3*t,n=3*a,i=[[],[],[]];i[0]=[Hfull[e][n],Hfull[e][n+1],Hfull[e][n+2]],i[1]=[Hfull[e+1][n],Hfull[e+1][n+1],Hfull[e+1][n+2]],i[2]=[Hfull[e+2][n],Hfull[e+2][n+1],Hfull[e+2][n+2]],2==method&&(i[0][1]=.5*(i[0][1]+i[1][0]),i[0][2]=.5*(i[0][2]+i[2][0]),i[1][2]=.5*(i[1][2]+i[2][1]),i[1][0]=i[0][1],i[2][0]=i[0][2],i[2][1]=i[1][2]);var f,s,l=[],m=[[],[],[]],h=[];return 0==method&&(s=eig(i)),1==method&&(s=eigReal(i)),2==method&&(s=Jacobi(i)),3==method&&(s=SVD(i)),h=s.L,m=s.V,l=unit([r[0],r[1],r[2]]),f=dot(h,[Math.abs(dot(l,m[0])),Math.abs(dot(l,m[1])),Math.abs(dot(l,m[2]))]),o&&2!=method?(i[0]=[Hfull[n][e],Hfull[n][e+1],Hfull[n][e+2]],i[1]=[Hfull[n+1][e],Hfull[n+1][e+1],Hfull[n+1][e+2]],i[2]=[Hfull[n+2][e],Hfull[n+2][e+1],Hfull[n+2][e+2]],0==method&&(s=eig(i)),1==method&&(s=eigReal(i)),2==method&&(s=Jacobi(i)),3==method&&(s=SVD(i)),h=s.L,m=s.V,l=unit([-r[0],-r[1],-r[2]]),(f+=dot(h,[Math.abs(dot(l,m[0])),Math.abs(dot(l,m[1])),Math.abs(dot(l,m[2]))]))/2):f}function pAC(t,a,r,o){var e=uij(a,t),n=uij(a,r),i=unit(cross(e,n));return o==t?unit(cross(i,e)):o==r?unit(cross(n,i)):void 0}function Kijk(t,a,r){var o,e,n=vij(t,a),i=vij(r,a),f=pAC(t,a,r,t),s=pAC(t,a,r,r);o=Kij(t,a,f,!1)*dot(n,n),e=Kij(r,a,s,!1)*dot(i,i);var l,m,h,u,d=0,c=0,v=0,p=0;for(h=0;h<Natm;h++)h!=t&&h!=a&&h!=r&&adj[a][h]&&(Math.abs(angle(vij(a,t),vij(a,h))-180)>Rpi&&(d++,l=pAC(t,a,h,t),u=Math.abs(dot(f,l)),c+=u*u),Math.abs(angle(vij(a,r),vij(a,h))-180)>Rpi&&(v++,m=pAC(r,a,h,r),u=Math.abs(dot(s,m)),p+=u*u));return c=d>0?c/d:0,p=v>0?p/v:0,1/((1+c)/o+(1+p)/e)}function Kijkl(t,a,r,o){var e,n,i=vij(t,a),f=vij(r,o),s=uij(t,a),l=uij(r,o),m=uij(r,a),h=uij(a,r),u=uij(o,r),d=cross(s,h),c=cross(h,l),v=unit(cross(m,s)),p=unit(cross(u,h));return e=Kij(t,a,v,!1)*dot(i,i)*dot(d,d),n=Kij(o,r,p,!1)*dot(f,f)*dot(c,c),1/(1/e+1/n)}function norm(t){return Math.hypot(t[0],t[1],t[2])}function unit(t){var a=norm(t);return a>0?[t[0]/a,t[1]/a,t[2]/a]:[0,0,0]}function dot(t,a){return t[0]*a[0]+t[1]*a[1]+t[2]*a[2]}function cross(t,a){return[t[1]*a[2]-t[2]*a[1],t[2]*a[0]-t[0]*a[2],t[0]*a[1]-t[1]*a[0]]}function vij(t,a){return[Xatm[a][0]-Xatm[t][0],Xatm[a][1]-Xatm[t][1],Xatm[a][2]-Xatm[t][2]]}function uij(t,a){return unit(vij(t,a))}function angle(t,a){var r=norm(t),o=norm(a),e=[o*t[0],o*t[1],o*t[2]],n=[r*a[0],r*a[1],r*a[2]];return r=norm([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=norm([e[0]+n[0],e[1]+n[1],e[2]+n[2]]),360*Math.atan2(r,o)/Math.PI}function ElmSyb(t){var a="X H HE LI BE B C N O F NE NA MG AL SI P S CL AR K CA SC TI V CR MN FE CO NI CU ZN GA GE AS SE BR KR RB SR Y ZR NB MO TC RU RH PD AG CD IN SN SB TE I XE CS BA LA CE PR ND PM SM EU GD TB DY HO ER TM YB LU HF TA W RE OS IR PT AU HG TL PB BI PO AT RN FR RA AC TH PA U NP PU AM CM BK CF ES FM MD NO LR RF DB SG BH HS MT DS RG CN NH FL UP LV US UO ";return a=trim(a).split(/\s+/),t=trim(t),t.match(/^\d+$/)&&parseInt(t)<a.length?a[parseInt(t)]:t}function saveFile(t){var a="",r="";if("gro"==t){r="conf.gro";var o,e=Natm,n=0,i=0,f=0,s=0,l=0,m=0;for(o=0;o<e;o++)n+=Xatm[o][0]/e,i+=Xatm[o][1]/e,f+=Xatm[o][2]/e;for(o=0;o<e;o++)s=Math.max(s,Math.abs(Xatm[o][0]-n)),l=Math.max(l,Math.abs(Xatm[o][1]-i)),m=Math.max(m,Math.abs(Xatm[o][2]-f));for(s+=10,l+=10,m+=10,a="MOL\n "+e+"\n",o=0;o<e;o++)a+=printf("%-8s%7s%5f%8.3f%8.3f%8.3f\n"," 1MOL",Tatm[o],o,(Xatm[o][0]-n+s)/10,(Xatm[o][1]-i+l)/10,(Xatm[o][2]-f+m)/10);a+=printf("%12.6f %12.6f %12.6f\n",s/5,l/5,m/5)}"mdp"==t&&(r="grompp.mdp",a=";{ Preprocessing\n;===============================================================================\ninclude = ;\ndefine = ;\n ; -DPOSRES\n ; -DFLEXIBLE\n;}==============================================================================\n\n;{ Run control\n;===============================================================================\nintegrator = md ; md sd steep/cg/lbfgs\ndt = 2E-3 ;\nnsteps = 1000 ;\n\ncomm-mode = Linear ; None Linear Angular Linear-acceleration-correction\nnstcomm = 1 ;\ncomm-grps = system ;\n;}==============================================================================\n\n;{ Output control\n;===============================================================================\nnstxout = 10 ;\nnstvout = 10 ;\nnstfout = 10 ;\nnstxout-compressed = 10 ;\nnstlog = 10 ;\nnstenergy = 10 ;\nnstcalcenergy = 10 ;\n\nenergygrps = ;\ncompressed-x-precision = 1000 ;\n;}==============================================================================\n\n;{ Neighbor searching\n;===============================================================================\ncutoff-scheme = Verlet ; Verlet Group\nns-type = Grid ; Grid Simple\nnstlist = 1 ;\nrlist = 1.0 ;\nrvdw = 1.0 ;\nrcoulomb = 1.0 ;\n\npbc = XYZ ; XYZ XY No\nperiodic-molecules = No ; No Yes\n;}==============================================================================\n\n;{ Electrostatics and Van der Waals\n;===============================================================================\nvdwtype = Cut-off ;\ncoulombtype = PME ;\nDispCorr = No ; No Ener EnerPres\n;}==============================================================================\n\n;{ Velocity generation\n;===============================================================================\ngen-vel = Yes ; Yes No\ngen-temp = 298.15 ;\ngen-seed = -1 ;\n;}==============================================================================\n\n;{ Temperature coupling\n;===============================================================================\ntcoupl = V-rescale ; No V-rescale Nose-Hoover\ntc-grps = system ;\ntau-t = 2 ;\nref-t = 298.15 ;\n;}=============================================================================="),"top"==t&&(a=$("top").value,r="topol.top");var h;if("function"==typeof window.Blob)h=new Blob([a],{type:"text"});else{var u=window.BlobBuilder||window.MozBlobBuilder||window.WebKitBlobBuilder||window.MSBlobBuilder,d=new u;d.append(a),h=d.getBlob("text")}var c=window.URL||window.webkitURL,v=c.createObjectURL(h),p=document.createElement("a");if("download"in p){p.style.visibility="hidden",p.href=v,p.download=r,document.body.appendChild(p);var M=document.createEvent("MouseEvents");M.initEvent("click",!0,!0),p.dispatchEvent(M),document.body.removeChild(p)}else navigator.msSaveBlob?navigator.msSaveBlob(h,r):location.href=v}function ElmMass(t){return parseFloat(trim("0.0 1.00784 4.002602 6.938 9.0121831 10.806 12.0096 14.00643 15.99903 18.998403163 20.179 22.98976928 24.304 26.9815384 28.084 30.973761998 32.059 35.446 39.792 39.0983 40.078 44.955908 47.867 50.9415 51.9961 54.938043 55.845 58.933194 58.6934 63.546 65.38 69.723 72.630 74.921595 78.971 79.901 83.798 85.4678 87.62 88.90584 91.224 92.90637 95.95 98 101.07 102.90549 106.42 107.8682 112.414 114.818 118.710 121.760 127.60 126.90447 131.293132.90545196 137.327 138.90547 140.116 140.90766 144.242 145 150.36 151.964 157.25 158.925354 162.500 164.930328 167.259 168.934218 173.045 174.9668 178.49 180.94788 183.84 186.207 190.23 192.217 195.084 196.966570 200.592 204.382 207.2 208.98040 209 210 222 223 226 227 232.0377 231.03588 238.02891 237 244 243 247 247 251 252 257 258 259 266").split(/\s+/)[t])}function Rvdw(t){return.01*parseFloat(trim("0 110 140 214 169 168 160 153 143 138 154 238 200 192 193 188 181 178 163 252 227 215 211 207 206 205 204 200 197 196 201 203 205 208 194 192 184 261 242 232 223 218 217 216 213 210 210 211 218 221 223 224 216 211 216 275 259 243 242 240 239 238 236 235 234 233 231 230 229 227 226 224 223 222 215 216 216 213 213 214 223 227 237 238 249 236 243 315 283 247 245 243 241 239 237 235 CM BK CF ES FM MD NO LR RF DB SG BH HS MT DS RG CN NH FL UP LV US UO ").split(/\s+/)[t])}function Rcov(t){return parseFloat(trim("0 0.32 0.46 1.20 0.94 0.77 0.75 0.71 0.63 0.64 0.67 1.40 1.25 1.13 1.04 1.10 1.02 0.99 0.96 1.76 1.54 1.33 1.22 1.21 1.10 1.07 1.04 1.00 0.99 1.01 1.09 1.12 1.09 1.15 1.10 1.14 1.17 1.89 1.67 1.47 1.39 1.32 1.24 1.15 1.13 1.13 1.08 1.15 1.23 1.28 1.26 1.26 1.23 1.32 1.31 2.09 1.76 1.62 1.47 1.58 1.57 1.56 1.55 1.51 1.52 1.51 1.50 1.49 1.49 1.48 1.53 1.46 1.37 1.31 1.23 1.18 1.16 1.11 1.12 1.13 1.32 1.30 1.30 1.36 1.31 1.38 1.42 2.01 1.81 1.67 1.58 1.52 1.53 1.54 1.55 1.49 1.49 1.51 1.51 1.48 1.50 1.56 1.58 1.45 1.41 1.34 1.29 1.27 1.21 1.16 1.15 1.09 1.22 1.36 1.43 1.46 1.58 1.48 1.57 ").split(/\s+/)[t])}function testEig(){A=[[1,2,3],[4,5,6],[7,80,9]],console.log(A),balance(A),A=[[1e40,1e19,1e19],[1e19,1e20,1e9],[1e19,1e9,1]]}function tr(t){return t[0][0]+t[1][1]+t[2][2]}function det(t){return t[0][0]*(t[1][1]*t[2][2]-t[1][2]*t[2][1])-t[0][1]*(t[1][0]*t[2][2]-t[1][2]*t[2][0])+t[0][2]*(t[1][0]*t[2][1]-t[1][1]*t[2][0])}function AxB(t,a){var r,o,e,n=[],i=t.length,f=t[0].length,s=a[0].length;for(r=0;r<i;r++)for(n[r]=[],o=0;o<s;o++)for(n[r][o]=0,e=0;e<f;e++)n[r][o]+=t[r][e]*a[e][o];return n}function Axb(t,a){var r,o,e=[],n=t.length,i=a.length;for(r=0;r<n;r++)for(e[r]=0,o=0;o<i;o++)e[r]+=t[r][o]*a[o];return e}function eig(t){var a=[],r=AxB(t,t),o=tr(t),e=(o*o-tr(r))/2,n=det(t),i=o*o-3*e,f=2*o*o*o-9*o*e+27*n,s=(4*i*i*i-f*f)/27;s<eps&&(s=0);var l=(Math.atan(3*Math.sqrt(3*s)/f)-(Math.sign(f)-1)*Math.PI/2)/3;a[0]=(o+2*Math.sqrt(i)*Math.cos(l))/3,a[1]=(o+2*Math.sqrt(i)*Math.cos(l+2*Math.PI/3))/3,a[2]=(o+2*Math.sqrt(i)*Math.cos(l+4*Math.PI/3))/3,a.sort(function(t,a){return Math.abs(a)-Math.abs(t)}),console.log(o,e,n,i,f,s,l,a);var m=Math.abs(a[0]),h=Math.pow(8*eps*m,2),u=[[],[],[]];u[0]=eigv(t,a[0],h),console.log("L",a,h),console.log("V0",u[0]);var d,c,v,p,M,b,g=[[],[],[]];for(v=1;v<3;v++)if(Math.abs(a[v]-a[v-1])>Math.sqrt(h))u[v]=eigv(t,a[v],h),console.log("v"+v,u[v]);else{for(g[0]=[t[0][0]-a[v],t[0][1],t[0][2]],g[1]=[t[1][0],t[1][1]-a[v],t[1][2]],g[2]=[t[2][0],t[2][1],t[2][2]-a[v]],b=!1,d=0;d<3;d++)if((M=norm(g[d]))>h&&(u[v]=cross(u[v-1],g[d]),norm(u[v])>256*eps*256*eps*M)){u[v]=unit(u[v]),b=!0;break}if(!b)for(c=0;c<3;c++)if(Math.abs(u[v-1][c])>tol){p=(c+1)%3,M=1/Math.hypot(u[v-1][c],u[v-1][p]),u[v]=[u[v-1][p]*M,-u[v-1][c]*M,0];break}}return console.log("eig L V",a,u),{L:a,V:u}}function eigv(t,a,r){var o=[[],[],[]];if(o[0]=[t[0][0]-a,t[0][1],t[0][2]],o[1]=[t[1][0],t[1][1]-a,t[1][2]],o[2]=[t[2][0],t[2][1],t[2][2]-a],console.log(o[0],o[1],o[2]),norm(o[0])<=r)return[1,0,0];if(norm(o[1])<=r)return[0,1,0];if(norm(o[2])<=r)return[0,0,1];var e,n,i,f,s,l,m,h=[],u=[];for(m=0,i=0;i<3;i++){for(f=i+1;f<3;f++)h=cross(o[i],o[f]),(l=norm(h))>m&&(e=i,n=f,m=l,u=[h[0],h[1],h[2]]);console.log("tvmax",m,u,e,n)}if(console.log("tvmax",m,u,e,n),l=norm(o[e])*norm(o[n])*8*eps,m>l*l)return unit(u);var s;return l=o[n][0]*o[n][0],s=o[e][0]/o[n][0],o[n][1]*o[n][1]>l&&(l=o[n][1]*o[n][1],s=o[e][1]/o[n][1]),o[n][2]*o[n][2]>l&&(s=o[e][2]/o[n][2]),l=1/Math.sqrt(1+s*s),[l,-s*l,0]}function Jacobi(t){var a,r,o,e,n,i,f,s,l,m,h,u,d=Math.pow(2,-52),c=[[],[],[]],v=[],p=[];for(a=0;a<3;a++)for(r=0;r<3;r++)c[a][r]=t[a][r];for(a=0;a<3;a++)v[a]=c[a][a],p[a]=[],p[a][a]=1;for(a=0;a<3;a++)for(r=0;r<a;r++)p[a][r]=0,p[r][a]=0;for(var M=1;M<1e3;M++){for(m=0,a=0;a<3;a++)for(r=a+1;r<3;r++)m+=Math.abs(c[a][r]);if(Math.abs(m)<d){for(a=0;a<3;a++)for(r=0;r<2;r++)v[r]>v[r+1]&&(o=v[r],v[r]=v[r+1],v[r+1]=o,o=[p[r][0],p[r][1],p[r][2]],p[r]=p[r+1],p[r+1]=o);return p[0][0]*(p[1][1]*p[2][2]-p[1][2]*p[2][1])-p[0][1]*(p[1][0]*p[2][2]-p[1][2]*p[2][0])+p[0][2]*(p[1][0]*p[2][1]-p[1][1]*p[2][0])<0&&(p[0]=[-p[0][0],-p[0][1],-p[0][2]],p[1]=[-p[1][0],-p[1][1],-p[1][2]],p[2]=[-p[2][0],-p[2][1],-p[2][2]]),{L:v,V:p}}for(u=0,M<4&&(u=.2*m/9),a=0;a<3;a++)for(r=a+1;r<3;r++)if(f=100*Math.abs(c[a][r]),M>4&&Math.abs(v[a])+f==Math.abs(v[a])&&Math.abs(v[r])+f==Math.abs(v[r]))c[a][r]=0;else if(Math.abs(c[a][r])>u){for(s=v[r]-v[a],Math.abs(s)+f==Math.abs(s)?i=c[a][r]/s:(h=.5*s/c[a][r],i=1/(Math.abs(h)+Math.sqrt(1+h*h)),h<0&&(i=-i)),n=1/Math.sqrt(1+i*i),e=i*n,l=i*c[a][r],c[a][r]=0,v[a]-=l,v[r]+=l,o=0;o<a;o++)i=c[o][a],c[o][a]=n*i-e*c[o][r],c[o][r]=e*i+n*c[o][r];for(o=a+1;o<r;o++)i=c[a][o],c[a][o]=n*i-e*c[o][r],c[o][r]=e*i+n*c[o][r];for(o=r+1;o<3;o++)i=c[a][o],c[a][o]=n*i-e*c[r][o],c[r][o]=e*i+n*c[r][o];for(o=0;o<3;o++)i=p[a][o],p[a][o]=n*i-e*p[r][o],p[r][o]=e*i+n*p[r][o]}}return{L:v,V:p}}function SVD(t,a,r,o,e){if(a=void 0===a||a,r=void 0===r||r,o=o||Math.pow(2,-52),e=1e-64/o,!t)throw new TypeError("Matrix a is not defined");var n=t[0].length,i=t.length;if(i<n)throw new TypeError("Invalid matrix: m < n");var f=void 0,s=void 0,l=void 0,m=void 0,h=void 0,u=void 0,d=void 0,c=void 0,v=void 0,p=void 0,M=void 0,b=void 0,g=void 0;c=0,M=0;var j=[],y=[],A=[],w="f"===a?i:n;for(f=0;f<i;f++)y[f]=new Array(w).fill(0);for(f=0;f<n;f++)A[f]=new Array(n).fill(0);var E=new Array(n).fill(0);for(f=0;f<i;f++)for(s=0;s<n;s++)y[f][s]=t[f][s];for(f=0;f<n;f++){for(j[f]=c,p=0,m=f+1,s=f;s<i;s++)p+=Math.pow(y[s][f],2);if(p<e)c=0;else for(d=y[f][f],c=d<0?Math.sqrt(p):-Math.sqrt(p),v=d*c-p,y[f][f]=d-c,s=m;s<n;s++){for(p=0,l=f;l<i;l++)p+=y[l][f]*y[l][s];for(d=p/v,l=f;l<i;l++)y[l][s]=y[l][s]+d*y[l][f]}for(E[f]=c,p=0,s=m;s<n;s++)p+=Math.pow(y[f][s],2);if(p<e)c=0;else{for(d=y[f][f+1],c=d<0?Math.sqrt(p):-Math.sqrt(p),v=d*c-p,y[f][f+1]=d-c,s=m;s<n;s++)j[s]=y[f][s]/v;for(s=m;s<i;s++){for(p=0,l=m;l<n;l++)p+=y[s][l]*y[f][l];for(l=m;l<n;l++)y[s][l]=y[s][l]+p*j[l]}}b=Math.abs(E[f])+Math.abs(j[f]),b>M&&(M=b)}if(r)for(f=n-1;f>=0;f--){if(0!==c){for(v=y[f][f+1]*c,s=m;s<n;s++)A[s][f]=y[f][s]/v;for(s=m;s<n;s++){for(p=0,l=m;l<n;l++)p+=y[f][l]*A[l][s];for(l=m;l<n;l++)A[l][s]=A[l][s]+p*A[l][f]}}for(s=m;s<n;s++)A[f][s]=0,A[s][f]=0;A[f][f]=1,c=j[f],m=f}if(a){if("f"===a)for(f=n;f<i;f++){for(s=n;s<i;s++)y[f][s]=0;y[f][f]=1}for(f=n-1;f>=0;f--){for(m=f+1,c=E[f],s=m;s<w;s++)y[f][s]=0;if(0!==c){for(v=y[f][f]*c,s=m;s<w;s++){for(p=0,l=m;l<i;l++)p+=y[l][f]*y[l][s];for(d=p/v,l=f;l<i;l++)y[l][s]=y[l][s]+d*y[l][f]}for(s=f;s<i;s++)y[s][f]=y[s][f]/c}else for(s=f;s<i;s++)y[s][f]=0;y[f][f]=y[f][f]+1}}o*=M;var D=void 0;for(l=n-1;l>=0;l--)for(var N=0;N<50;N++){for(D=!1,m=l;m>=0;m--){if(Math.abs(j[m])<=o){D=!0;break}if(Math.abs(E[m-1])<=o)break}if(!D)for(u=0,p=1,h=m-1,f=m;f<l+1&&(d=p*j[f],j[f]=u*j[f],!(Math.abs(d)<=o));f++)if(c=E[f],E[f]=Math.sqrt(d*d+c*c),v=E[f],u=c/v,p=-d/v,a)for(s=0;s<i;s++)b=y[s][h],g=y[s][f],y[s][h]=b*u+g*p,y[s][f]=-b*p+g*u;if(g=E[l],m===l){if(g<0&&(E[l]=-g,r))for(s=0;s<n;s++)A[s][l]=-A[s][l];break}for(M=E[m],b=E[l-1],c=j[l-1],v=j[l],d=((b-g)*(b+g)+(c-v)*(c+v))/(2*v*b),c=Math.sqrt(d*d+1),d=((M-g)*(M+g)+v*(b/(d<0?d-c:d+c)-v))/M,u=1,p=1,f=m+1;f<l+1;f++){if(c=j[f],b=E[f],v=p*c,c*=u,g=Math.sqrt(d*d+v*v),j[f-1]=g,u=d/g,p=v/g,d=M*u+c*p,c=-M*p+c*u,v=b*p,b*=u,r)for(s=0;s<n;s++)M=A[s][f-1],g=A[s][f],A[s][f-1]=M*u+g*p,A[s][f]=-M*p+g*u;if(g=Math.sqrt(d*d+v*v),E[f-1]=g,u=d/g,p=v/g,d=u*c+p*b,M=-p*c+u*b,a)for(s=0;s<i;s++)b=y[s][f-1],g=y[s][f],y[s][f-1]=b*u+g*p,y[s][f]=-b*p+g*u}j[m]=0,j[l]=d,E[l]=M}for(f=0;f<n;f++)E[f]<o&&(E[f]=0);return console.log("SVD L V",E,A),{U:y,L:E,V:A}}function eigReal(t){var a,r,o=t.length,e=[],n=[],i=[];for(a=0;a<o;a++)e[a]=[];var f,s,l,m,h,u,d,c,v=new Array(o),p=new Array(o),M=0,b=o-1;for(c=b;c>=0;){m=0;for(var r=0;r<=b;r++)if(r!=c&&0!=t[c][r]){m=1;break}if(0==m){if(v[b]=c,c!=b){for(var a=0;a<=b;a++)s=t[a][c],t[a][c]=t[a][b],t[a][b]=s;for(var a=0;a<o;a++)s=t[c][a],t[c][a]=t[b][a],t[b][a]=s}if(0==b)break;c=--b}else c--}if(b>0){for(c=0;c<=b;){f=0;for(var a=M;a<=b;a++)if(a!=c&&0!=t[a][c]){f=1;break}if(0==f){if(v[M]=c,c!=M){for(var a=0;a<=b;a++)s=t[a][c],t[a][c]=t[a][M],t[a][M]=s;for(var a=M;a<o;a++)s=t[c][a],t[c][a]=t[M][a],t[M][a]=s}c=++M}else c++}for(var a=M;a<=b;a++)v[a]=1;do{c=0;for(var a=M;a<=b;a++){f=m=0;for(var r=M;r<=b;r++)r!=a&&(f+=Math.abs(t[r][a]),m+=Math.abs(t[a][r]));if(0!=f&&0!=m){for(l=m/2,s=1,h=f+m;f<l;)s*=2,f*=4;for(l=2*m;f>=l;)s/=2,f/=4;if((f+m)/s<.95*h){l=1/s,v[a]*=s,c=1;for(var r=M;r<o;r++)t[a][r]*=l;for(var r=0;r<=b;r++)t[r][a]*=s}}}}while(c)}d=M,u=b;for(var a=d+1;a<u;a++){M=a,f=0;for(var r=a;r<=u;r++)Math.abs(t[r][a-1])>Math.abs(f)&&(f=t[r][a-1],M=r);if(p[a]=M,M!=a){for(var r=a-1;r<o;r++)m=t[M][r],t[M][r]=t[a][r],t[a][r]=m;for(var r=0;r<=u;r++)m=t[r][M],t[r][M]=t[r][a],t[r][a]=m}if(0!=f)for(var g=a+1;g<=u;g++)if(0!=(m=t[g][a-1])){m=t[g][a-1]=m/f;for(var r=a;r<o;r++)t[g][r]+=-m*t[a][r];for(var r=0;r<=u;r++)t[r][a]+=m*t[r][g]}}for(var a=0;a<o;a++){for(var r=0;r<o;r++)e[a][r]=0;e[a][a]=1}for(var a=u-1;a>=d+1;a--){M=p[a];for(var r=a+1;r<=u;r++)e[r][a]=t[r][a-1];if(a!=M){for(var r=a;r<=u;r++)e[a][r]=e[M][r],e[M][r]=0;e[M][a]=1}}if(hqr2(o,t,e,d,u,i,n,void 0),d!=u)for(var a=d;a<=u;a++){h=v[a];for(var r=0;r<o;r++)e[a][r]*=h}for(var a=d-1;a>=0;a--)if((M=v[a])!=a)for(var r=0;r<o;r++)h=e[a][r],e[a][r]=e[M][r],e[M][r]=h;for(var a=u+1;a<o;a++)if((M=v[a])!=a)for(var r=0;r<o;r++)h=e[a][r],e[a][r]=e[M][r],e[M][r]=h;norVecC(o,e,i);var j=[[],[],[]];for(a=0;a<o;a++)for(r=0;r<o;r++)j[a][r]=e[r][a];return{L:n,V:j}}function cdivA(t,a,r,o,e,n,i,f){var s,l,m,h,u;s=Math.abs(r)+Math.abs(o),l=t/s,m=a/s,h=r/s,u=o/s,s=h*h+u*u,e[n][i]=(l*h+m*u)/s,e[n][f]=(-l*u+m*h)/s}function hqr2(t,a,r,o,e,n,i,f){for(var s,l,m,h,u,d,c,v,p,M,b,g,j,y,A,w,E,D,N,S,T,F=0,I=0,H=0,B=e,L=1,R=30*t,C=0;C<t;C++){for(var K=H;K<t;K++)F+=Math.abs(a[C][K]);H=C,(C<o||C>e)&&(n[C]=0,i[C]=a[C][C])}for(;B>=o;){L?(D=0,S=B-1,N=S-1):L=1;for(var C=o;C<=B&&(A=B+o-C)!=o&&(u=Math.abs(a[A-1][A-1])+Math.abs(a[A][A]),0==u&&(u=F),c=u,(v=c+Math.abs(a[A][A-1]))!=c);C++);if(g=a[B][B],A!=B)if(j=a[S][S],b=a[B][S]*a[S][B],A!=S){if(0==R)return void(f.outEr=B+1);if(10==D||20==D){I+=g;for(var C=o;C<=B;C++)a[C][C]+=-g;u=Math.abs(a[B][S])+Math.abs(a[S][N]),j=g=.75*u,b=-.4375*u*u}for(D++,R--,w=N;w>=A&&(y=a[w][w],h=-y+g,u=-y+j,s=(h*u-b)/a[w+1][w]+a[w][w+1],l=-(y+h+u)+a[w+1][w+1],h=a[w+2][w+1],u=Math.abs(s)+Math.abs(l)+Math.abs(h),s/=u,l/=u,h/=u,w!=A)&&(c=Math.abs(s)*(Math.abs(a[w-1][w-1])+Math.abs(y)+Math.abs(a[w+1][w+1])),v=c+Math.abs(a[w][w-1])*(Math.abs(l)+Math.abs(h)),c!=v);w--);E=w+2;for(var C=E;C<=B;C++)a[C][C-2]=0,C!=E&&(a[C][C-3]=0);for(var C=w;C<=S;C++){if(T=C!=S?1:0,C!=w){if(s=a[C][C-1],l=a[C+1][C-1],h=T?a[C+2][C-1]:0,0==(g=Math.abs(s)+Math.abs(l)+Math.abs(h)))continue;s/=g,l/=g,h/=g}if(u=Math.sqrt(s*s+l*l+h*h),s<0&&(u=-u),C!=w?a[C][C-1]=-u*g:A!=w&&(a[C][C-1]=-a[C][C-1]),s+=u,g=s/u,j=l/u,y=h/u,l/=s,h/=s,H=C+3<B?C+3:B,T){for(var K=C;K<t;K++)s=a[C][K]+l*a[C+1][K]+h*a[C+2][K],a[C][K]+=-s*g,a[C+1][K]+=-s*j,a[C+2][K]+=-s*y;for(var K=0;K<=H;K++)s=g*a[K][C]+j*a[K][C+1]+y*a[K][C+2],a[K][C]+=-s,a[K][C+1]+=-s*l,a[K][C+2]+=-s*h;for(var K=o;K<=e;K++)s=g*r[K][C]+j*r[K][C+1]+y*r[K][C+2],r[K][C]+=-s,r[K][C+1]+=-s*l,r[K][C+2]+=-s*h}else{for(var K=C;K<t;K++)s=a[C][K]+l*a[C+1][K],a[C][K]+=-s*g,a[C+1][K]+=-s*j;for(var K=0;K<=H;K++)s=g*a[K][C]+j*a[K][C+1],a[K][C]+=-s,a[K][C+1]+=-s*l;for(var K=o;K<=e;K++)s=g*r[K][C]+j*r[K][C+1],r[K][C]+=-s,r[K][C+1]+=-s*l}}L=0}else{if(s=(-g+j)/2,l=s*s+b,y=Math.sqrt(Math.abs(l)),g=a[B][B]=g+I,a[S][S]=j+I,l>=0){y=s<0?-y+s:s+y,i[B]=i[S]=g+y,0!=y&&(i[B]=-b/y+g),n[B]=n[S]=0,g=a[B][S],u=Math.abs(g)+Math.abs(y),s=g/u,l=y/u,h=Math.sqrt(s*s+l*l),s/=h,l/=h;for(var K=S;K<t;K++)y=a[S][K],a[S][K]=l*y+s*a[B][K],a[B][K]=-s*y+l*a[B][K];for(var K=0;K<=B;K++)y=a[K][S],a[K][S]=l*y+s*a[K][B],a[K][B]=-s*y+l*a[K][B];for(var K=o;K<=e;K++)y=r[K][S],r[K][S]=l*y+s*r[K][B],r[K][B]=-s*y+l*r[K][B]}else i[B]=i[S]=g+s,n[S]=y,n[B]=-y;B--,B--}else i[B]=a[B][B]=g+I,n[B]=0,B--}if(0!=F){for(B=t-1;B>=0;B--)if(s=i[B],l=n[B],S=B-1,!(l>0))if(0==l){w=B,a[B][B]=1;for(var K=S;K>=0;K--){b=-s+a[K][K],h=0;for(var x=w;x<=B;x++)h+=a[K][x]*a[x][B];if(n[K]<0)y=b,u=h;else{if(w=K,0==n[K]){if(0==(I=b)){I=c=F;do{I*=.01,v=F+I}while(v>c)}a[K][B]=-h/I}else g=a[K][K+1],j=a[K+1][K],l=(-s+i[K])*(-s+i[K])+n[K]*n[K],a[K][B]=I=(-y*h+g*u)/l,a[K+1][B]=Math.abs(g)>Math.abs(y)?-(h+b*I)/g:-(u+j*I)/y;if(0==(I=Math.abs(a[K][B])))continue;if(c=I,(v=c+1/c)>c)continue;for(var x=K;x<=B;x++)a[x][B]/=I}}}else{w=S,Math.abs(a[B][S])<=Math.abs(a[S][B])?cdivA(0,-a[S][B],-s+a[S][S],l,a,S,S,B):(a[S][S]=l/a[B][S],a[S][B]=-(-s+a[B][B])/a[B][S]),a[B][S]=0,a[B][B]=1;for(var K=S-1;K>=0;K--){b=-s+a[K][K],d=m=0;for(var x=w;x<=B;x++)m+=a[K][x]*a[x][S],d+=a[K][x]*a[x][B];if(n[K]<0)y=b,h=m,u=d;else{if(w=K,0==n[K])cdivA(-m,-d,b,l,a,K,S,B);else{if(g=a[K][K+1],j=a[K+1][K],M=-l*l+(-s+i[K])*(-s+i[K])+n[K]*n[K],p=2*(-s+i[K])*l,0==M&&0==p){c=F*(Math.abs(b)+Math.abs(l)+Math.abs(g)+Math.abs(j)+Math.abs(y)),M=c;do{M*=.01,v=c+M}while(v>c)}cdivA(-y*m+g*h+l*d,g*u-(y*d+l*m),M,p,a,K,S,B),Math.abs(g)>Math.abs(y)+Math.abs(l)?(a[K+1][S]=(-(m+b*a[K][S])+l*a[K][B])/g,a[K+1][B]=-(d+b*a[K][B]+l*a[K][S])/g):cdivA(-(h+j*a[K][S]),-(u+j*a[K][B]),y,l,a,K+1,S,B)}if(0!=(I=Math.abs(a[K][S])>=Math.abs(a[K][B])?Math.abs(a[K][S]):Math.abs(a[K][B]))&&(c=I,!((v=c+1/c)>c)))for(var x=K;x<=B;x++)a[x][S]/=I,a[x][B]/=I}}}for(var C=0;C<t;C++)if(C<o||C>e)for(var K=C;K<t;K++)r[C][K]=a[C][K];for(var C=t-1;C>=o;C--){w=C<e?C:e;for(var x=o;x<=e;x++){y=0;for(var k=o;k<=w;k++)y+=r[x][k]*a[k][C];r[x][C]=y}}}}function norVecC(t,a,r){for(var o,e,n,i,f,s=0;s<t;s++){o=0,e=1;for(var l=0;l<t;l++)0!=a[l][s]&&(n=Math.abs(a[l][s]),i=o/n,o<n?(e=1+e*i*i,o=n):e+=1/i/i);if(0!=r[s])for(var l=0;l<t;l++)0!=a[l][s+1]&&(n=Math.abs(a[l][s+1]),i=o/n,o<n?(e=1+e*i*i,o=n):e+=1/i/i);f=o*Math.sqrt(e);for(var l=0;l<t;l++)a[l][s]/=f;if(0!=r[s]){s++;for(var l=0;l<t;l++)a[l][s]/=f}}}var $=function(t){return document.getElementById(t)};window.onload=function(){var t=$("box"),a=$("resize"),r=$("container"),o=$("right");a.onmousedown=function(e){var n=e.clientX;return a.left=a.offsetLeft,document.onmousemove=function(e){var i=e.clientX,f=a.left+(i-n),s=t.clientWidth-a.offsetWidth;f<150&&(f=150),f>s-150&&(f=s-150),a.style.left=f,r.style.width=f+"px",o.style.width=t.clientWidth-f-5+"px"},document.onmouseup=function(t){document.onmousemove=null,document.onmouseup=null,a.releaseCapture&&a.releaseCapture()},a.setCapture&&a.setCapture(),!1}},window.File&&window.FileReader&&window.FileList&&window.Blob?$("hess").addEventListener("change",loadHess,!1):alert("The File APIs are not fully supported by your browser.");var pi=3.141592653589793,Na=6.02214076e23,Ang=1e-10,nm=1e-9,cal2J=4.184,J2cal=1/cal2J,ha=4.3597447222071e-18,bohr=5.29177210903e-11,kJmol=1e3/Na,kcal=kJmol*cal2J,bohr2A=bohr/Ang,A2nm=Ang/nm,bohr2nm=bohr/nm,Kau=ha/kJmol/(bohr2A*bohr2A),Kbgmx=1/(A2nm*A2nm),Kagmx=1,eps=Math.pow(2,-52),tol=Math.pow(2,-1074)/eps,Fchk,Natm,IDat,Rtol=.1,Rpi=.001,method=1,Kscale=1,Xatm=[],Tatm=[],Fatm=[],Hfull=[],adj=[];
</script>