(* Kimball model and energy derived from Wolfram ChemicalData source, ES February 2013 *) 
Clear[tw,n2,n,nb,bc,bh,u,u1,u2,Vee,Vne,Vnn];

(*ChemicalData["Diazepam","MoleculePlot"]*)

(*t1=0.01889726*ChemicalData["Diazepam","AtomPositions"];*)
(*MatrixForm[t1]*)

(*u=ChemicalData["Diazepam","VertexTypes"]*)
t=1.889726*{{10.020,-8.146,1.212},{9.605,-8.719,0.070},{10.052,-8.236,-1.114},{10.792,-7.102,-1.172},{11.207,-6.530,-0.031},{10.876,-7.098,1.153},{9.648,-8.815,-2.253},{11.003,-6.470,-2.353},{11.831,-5.326,-0.073},{11.302,-6.534,2.292},{8.776,-9.853,-2.196},{9.964,-8.235,-3.440},{9.524,-8.785,-4.575},{10.559,-7.027,-3.493},{8.209,-10.228,-1.032},{8.337,-10.404,-3.332},{8.823,-9.928,-4.491},{8.296,-10.392,-5.597},{11.538,-5.229,-2.386},{9.477,-8.533,2.392},{8.648,-9.678,0.113},{8.040,-9.995,1.277},{12.217,-4.736,1.071},{11.955,-4.654,-1.239},{12.027,-5.388,2.235},{10.839,-7.006,3.478},{12.414,-4.800,3.370},{11.227,-6.417,4.614},{9.868,-7.938,3.531},{8.457,-9.420,2.424},{12.104,-5.404,4.530},{12.384,-4.760,5.636},{2.650,-12.697,-0.025},{3.324,-12.485,-1.167},{4.633,-12.142,-1.111},{5.233,-11.870,0.073},{4.559,-12.082,1.216},{3.294,-12.562,1.158},{5.309,-11.943,-2.250},{6.446,-11.265,0.114},{5.101,-11.688,2.394},{2.626,-12.786,2.298},{4.659,-12.059,-3.436},{6.570,-11.444,-2.195},{7.230,-11.201,-3.331},{7.106,-11.023,-1.032},{3.324,-12.242,-3.488},{5.319,-11.816,-4.572},{6.624,-11.512,-4.488},{7.230,-11.161,-5.597},{6.940,-10.787,1.278},{1.311,-12.908,-0.067},{2.656,-12.485,-2.348},{1.309,-12.601,-2.380},{4.412,-11.870,3.535},{6.263,-11.000,2.425},{3.221,-12.497,3.483},{1.310,-13.113,2.242},{2.541,-12.678,4.619},{0.631,-13.293,3.379},{0.631,-13.088,1.078},{0.633,-12.814,-1.232},{1.302,-13.189,4.536},{0.603,-13.250,5.643},{11.225,-3.002,-5.764},{10.807,-4.278,-5.763},{10.070,-4.735,-6.804},{9.631,-3.894,-7.771},{10.049,-2.618,-7.772},{10.902,-2.200,-6.806},{9.664,-6.011,-6.809},{8.676,-4.286,-8.650},{9.512,-1.738,-8.653},{11.330,-0.930,-6.814},{9.971,-6.810,-5.756},{8.794,-6.426,-7.766},{8.351,-7.687,-7.747},{8.233,-5.555,-8.628},{10.562,-6.316,-4.651},{9.528,-8.071,-5.737},{8.830,-8.508,-6.798},{8.300,-9.703,-6.717},{8.073,-3.388,-9.461},{11.846,-2.499,-4.668},{11.011,-5.048,-4.665},{11.542,-4.519,-3.540},{9.906,-0.453,-8.633},{8.494,-2.105,-9.463},{10.875,-0.083,-7.772},{12.052,-0.467,-5.763},{11.266,1.194,-7.757},{12.442,0.810,-5.748},{12.235,-1.213,-4.657},{11.963,-3.237,-3.541},{12.140,1.573,-6.810},{12.423,2.851,-6.733},{4.599,-4.374,-11.311},{5.267,-5.300,-10.605},{4.662,-6.476,-10.317},{3.353,-6.679,-10.604},{2.685,-5.753,-11.311},{3.335,-4.638,-11.720},{5.332,-7.407,-9.623},{2.680,-7.731,-10.076},{1.347,-5.882,-11.487},{2.672,-3.719,-12.437},{6.592,-7.135,-9.196},{4.676,-8.515,-9.195},{5.331,-9.423,-8.463},{3.342,-8.641,-9.339},{7.133,-5.909,-9.342},{7.246,-8.043,-8.465},{6.636,-9.214,-8.224},{7.236,-10.046,-7.407},{1.334,-7.807,-10.170},{5.145,-3.145,-11.489},{6.478,-4.994,-10.077},{6.976,-3.741,-10.174},{0.672,-4.938,-12.166},{0.663,-6.877,-10.880},{1.357,-3.912,-12.709},{3.272,-2.532,-12.711},{0.684,-2.978,-13.386},{2.598,-1.598,-13.387},{4.462,-2.206,-12.168},{6.305,-2.811,-10.884},{1.360,-1.899,-13.811},{0.666,-0.936,-14.368},{-0.701,-10.365,-7.765},{0.642,-10.373,-7.765},{1.301,-11.055,-6.798},{0.636,-11.608,-5.756},{-0.707,-11.602,-5.757},{-1.366,-11.041,-6.798},{2.641,-11.073,-6.805},{1.302,-12.045,-4.658},{-1.379,-12.031,-4.660},{-2.707,-11.046,-6.805},{3.308,-10.379,-7.762},{3.302,-11.617,-5.752},{4.638,-11.594,-5.734},{2.646,-12.020,-4.645},{2.659,-9.572,-8.625},{4.644,-10.358,-7.745},{5.273,-11.071,-6.796},{6.575,-10.947,-6.715},{0.634,-12.381,-3.533},{-1.367,-9.578,-8.645},{1.315,-9.591,-8.646},{0.653,-8.736,-9.457},{-2.723,-11.994,-4.646},{-0.715,-12.374,-3.533},{-3.373,-11.585,-5.753},{-3.368,-10.348,-7.763},{-4.702,-10.315,-7.747},{-2.711,-9.546,-8.624},{-0.696,-8.729,-9.457},{-5.337,-11.023,-6.799},{-6.639,-10.887,-6.720},{12.889,-1.407,-0.038},{12.892,-0.704,-1.182},{12.968,0.647,-1.127},{12.899,1.306,0.055},{12.895,0.603,1.199},{12.961,-0.750,1.144},{12.985,1.349,-2.267},{12.699,2.647,0.095},{12.692,1.242,2.377},{12.971,-1.452,2.286},{12.893,0.691,-3.451},{12.900,2.703,-2.214},{12.871,3.403,-3.351},{12.669,3.347,-1.052},{12.656,-0.634,-3.501},{12.865,1.392,-4.588},{12.256,4.641,-1.055},{12.978,2.728,-4.507},{12.457,4.704,-3.354},{12.830,3.411,-5.616},{12.403,3.269,1.259},{12.678,-2.747,-0.077},{12.685,-1.343,-2.359},{12.381,-2.660,-2.390},{12.654,0.534,3.519},{12.399,2.562,2.407},{12.883,-0.793,3.469},{12.876,-2.804,2.231},{12.847,-1.493,4.606},{12.238,1.116,4.674},{12.840,-3.504,3.369},{12.641,-3.446,1.069},{12.378,-3.366,-1.240},{12.428,-0.909,5.767},{12.950,-2.830,4.525},{12.795,-3.511,5.633},{12.431,4.663,-5.619},{12.391,-2.949,6.751},{6.589,-7.988,7.802},{5.500,-8.773,7.803},{5.362,-9.714,6.837},{6.227,-9.783,5.798},{7.316,-8.998,5.796},{7.525,-8.155,6.836},{4.281,-10.506,6.845},{5.940,-10.530,4.702},{8.114,-8.962,4.701},{8.618,-7.381,6.843},{3.335,-10.327,7.801},{4.062,-11.337,5.795},{2.963,-12.096,5.779},{4.833,-11.290,4.690},{3.393,-9.290,8.661},{2.236,-11.085,7.784},{2.141,-12.034,6.839},{1.010,-12.691,6.760},{6.683,-10.422,3.577},{6.672,-6.959,8.680},{4.498,-8.525,8.681},{2.294,-8.928,9.374},{9.186,-8.152,4.686},{7.777,-9.634,3.577},{9.476,-7.436,5.791},{8.748,-6.425,7.798},{10.542,-6.634,5.774},{9.816,-5.623,7.780},{7.747,-6.152,8.658},{7.752,-4.995,9.371},{5.634,-6.655,9.491},{9.821,-4.461,8.496},{10.745,-5.833,6.834},{11.725,-4.968,6.754},{-0.052,-12.341,7.450},{11.731,-3.849,7.443},{-4.649,-12.043,1.210},{-5.318,-11.824,0.067},{-4.716,-12.099,-1.115},{-3.411,-12.454,-1.171},{-2.741,-12.673,-0.028},{-3.387,-12.533,1.155},{-5.389,-11.893,-2.256},{-2.740,-12.460,-2.350},{-1.404,-12.896,-0.068},{-2.723,-12.763,2.295},{-6.646,-11.384,-2.201},{-4.737,-12.015,-3.440},{-5.393,-11.767,-4.576},{-3.404,-12.208,-3.491},{-7.183,-10.961,-1.040},{-7.302,-11.137,-3.339},{-6.696,-11.452,-4.495},{-8.404,-10.332,-3.341},{-7.298,-11.096,-5.602},{-1.395,-12.588,-2.381},{-5.190,-11.646,2.388},{-6.527,-11.210,0.107},{-7.023,-10.731,1.270},{-8.280,-10.160,-1.042},{-0.728,-13.082,1.078},{-0.723,-12.807,-1.233},{-1.410,-13.100,2.240},{-3.319,-12.470,3.479},{-0.734,-13.288,3.377},{-2.643,-12.657,4.616},{-4.506,-11.835,3.530},{-6.350,-10.952,2.419},{-1.408,-13.178,4.534},{-0.711,-13.245,5.642},{-8.359,-10.321,-5.606},{-1.116,-12.684,6.759},{-4.709,-11.551,-5.737},{-4.609,-4.335,-11.316},{-5.284,-5.255,-10.609},{-4.688,-6.435,-10.319},{-3.381,-6.649,-10.605},{-2.706,-5.729,-11.312},{-3.346,-4.608,-11.723},{-5.365,-7.359,-9.624},{-2.716,-7.705,-10.076},{-1.368,-5.869,-11.486},{-2.677,-3.696,-12.440},{-6.624,-7.078,-9.201},{-4.719,-8.473,-9.196},{-5.382,-9.374,-8.466},{-3.386,-8.609,-9.341},{-7.157,-5.848,-9.348},{-7.286,-7.979,-8.471},{-6.684,-9.155,-8.227},{-8.390,-7.616,-7.756},{-7.293,-9.983,-7.413},{-1.371,-7.795,-10.170},{-5.146,-3.103,-11.496},{-6.495,-4.939,-10.085},{-6.987,-3.683,-10.185},{-8.257,-5.486,-8.638},{-0.686,-4.932,-12.167},{-0.692,-6.871,-10.880},{-1.363,-3.901,-12.710},{-3.268,-2.505,-12.715},{-0.681,-2.972,-13.387},{-2.585,-1.577,-13.391},{-4.457,-2.170,-12.176},{-4.872,-0.876,-12.180},{-6.308,-2.759,-10.895},{-3.003,-0.277,-13.395},{-1.350,-1.888,-13.813},{-0.648,-0.931,-14.370},{-8.356,-9.632,-6.725},{-1.049,0.320,-14.374},{7.368,1.098,-10.612},{6.282,0.748,-11.318},{5.421,1.710,-11.729},{5.561,2.995,-11.323},{6.648,3.345,-10.617},{7.579,2.405,-10.327},{4.342,1.363,-12.445},{4.561,3.894,-11.502},{6.731,4.594,-10.094},{8.671,2.757,-9.634},{4.121,0.051,-12.713},{3.400,2.300,-12.719},{2.302,1.947,-13.395},{3.458,3.534,-12.180},{4.886,-0.916,-12.171},{3.024,-0.302,-13.389},{2.363,4.338,-12.185},{2.206,0.675,-13.815},{1.201,2.753,-13.398},{1.077,0.312,-14.371},{4.603,5.105,-10.902},{8.161,0.134,-10.083},{5.992,-0.565,-11.493},{6.728,-1.523,-10.885},{7.804,4.934,-9.358},{5.696,5.457,-10.193},{8.802,4.040,-9.211},{9.522,1.791,-9.205},{9.867,4.383,-8.481},{7.808,6.092,-8.647},{10.587,2.135,-8.476},{9.231,0.483,-9.348},{7.820,-1.171,-10.176},{9.872,5.546,-7.767},{10.792,3.441,-8.239},{11.770,3.757,-7.425},{0.017,1.089,-14.375},{11.776,4.876,-6.737},{0.020,2.277,-13.823},{12.154,5.310,-4.513},{10.803,5.750,-6.821},{10.755,-3.527,8.257},{-0.049,-11.313,8.264},{-2.243,-12.020,6.838},{-8.878,-8.434,-6.808},{-8.885,-9.853,-4.501},{10.561,-2.219,8.496},{8.758,-4.110,9.226},{8.637,-2.826,9.650},{6.681,-4.647,10.106},{4.539,-7.443,9.492},{5.638,-5.502,10.202},{6.607,-3.399,10.631},{4.548,-5.142,10.913},{1.132,-10.722,8.502},{-1.228,-10.716,8.503},{1.137,-9.603,9.231},{2.304,-7.802,10.109},{-0.043,-9.082,9.656},{1.143,-7.336,10.635},{3.444,-7.083,10.204},{3.449,-5.935,10.913},{-2.332,-11.072,7.785},{-3.063,-12.075,5.776},{-4.158,-11.308,5.791},{-4.926,-11.255,4.685},{-4.374,-10.477,6.843},{-6.769,-10.373,3.571},{-7.859,-9.577,3.569},{-8.118,-9.932,1.269},{-6.029,-10.487,4.697},{-6.313,-9.739,5.792},{-9.580,-8.708,-4.587},{-8.843,-9.780,-2.206},{-8.720,-9.608,0.103},{-9.710,-8.737,-2.265},{-8.535,-9.357,2.415},{-9.672,-8.643,0.058},{-9.576,-7.992,-5.749},{-8.825,-6.353,-7.776},{-9.695,-5.933,-6.822},{-8.693,-4.215,-8.663},{12.047,0.371,5.782},{12.118,-1.669,6.829},{11.247,-1.284,7.777},{11.859,2.405,4.685},{11.328,0.840,6.833},{11.984,3.143,3.559},{11.240,2.912,5.781},{11.574,4.429,3.556},{11.287,6.332,-4.600},{11.873,5.234,0.090},{12.072,5.295,-2.220},{11.357,6.447,-2.279},{11.258,6.442,0.045},{11.991,4.560,1.256},{11.578,5.139,2.402},{-8.083,-3.321,-9.475},{-9.647,-3.817,-7.786},{-8.498,-2.038,-9.480},{-6.723,-1.468,-10.900},{-2.179,0.693,-13.822},{-2.266,1.966,-13.402},{-4.099,0.085,-12.724},{-4.314,1.399,-12.456},{-5.977,-0.517,-11.505},{-7.815,-1.108,-10.194},{-6.259,0.799,-11.333},{-1.159,2.764,-13.403},{1.206,3.908,-12.727},{0.027,4.526,-12.460},{2.372,5.501,-11.511},{1.212,6.184,-11.337},{3.511,5.907,-10.906},{3.516,7.058,-10.201},{10.606,6.554,-5.762},{8.811,6.359,-7.787},{8.689,7.317,-6.833},{6.741,6.909,-8.672},{5.700,6.612,-9.484},{4.613,7.411,-9.488},{6.665,7.941,-7.796},{-10.019,-8.155,-3.452},{-10.011,-6.729,-5.769},{-1.225,-9.596,9.232},{-3.427,-10.306,7.801},{9.498,-1.867,9.224},{10.866,-0.003,7.792},{10.902,6.924,-3.466},{9.546,7.367,-5.781},{-1.156,3.919,-12.733},{-3.362,2.329,-12.731},{-5.449,-9.677,6.835},{-3.479,-9.269,8.661},{-2.379,-8.914,9.375},{-0.039,-7.933,10.348},{9.217,-0.557,9.368},{7.547,-2.466,10.344},{9.900,0.374,8.652},{10.909,2.113,6.823},{10.934,7.013,-1.140},{9.938,7.865,-3.521},{9.260,8.086,-4.678},{7.601,8.101,-6.830},{0.031,5.662,-11.746},{-2.311,4.358,-12.194},{-3.413,3.563,-12.193},{-5.390,1.754,-11.743},{-10.094,-4.653,-6.818},{-10.603,-6.231,-4.665},{-10.607,-6.943,-3.507},{-10.112,-8.155,-1.127},{-2.686,5.753,11.310},{-3.353,6.679,10.604},{-4.661,6.477,10.316},{-5.266,5.300,10.605},{-4.599,4.373,11.311},{-3.335,4.638,11.720},{-5.331,7.407,9.622},{-6.478,4.994,10.077},{-5.143,3.145,11.488},{-2.673,3.719,12.437},{-4.677,8.516,9.194},{-6.592,7.135,9.196},{-7.246,8.042,8.464},{-7.132,5.909,9.342},{-3.342,8.641,9.339},{-5.331,9.423,8.463},{-6.636,9.214,8.222},{-7.236,10.046,7.407},{-6.977,3.741,10.173},{-1.346,5.881,11.486},{-2.681,7.731,10.075},{-1.334,7.807,10.169},{-4.462,2.207,12.168},{-6.305,2.811,10.884},{-3.272,2.532,12.711},{-1.357,3.912,12.709},{-2.598,1.598,13.386},{-0.683,2.978,13.385},{-0.673,4.938,12.166},{-0.662,6.876,10.880},{-1.360,1.899,13.811},{-0.666,0.936,14.368},{0.708,11.602,5.756},{-0.636,11.608,5.756},{-1.301,11.055,6.798},{-0.642,10.373,7.765},{0.701,10.366,7.765},{1.366,11.041,6.798},{-2.641,11.072,6.804},{-1.314,9.591,8.645},{1.367,9.578,8.645},{2.707,11.046,6.805},{-3.302,11.616,5.751},{-3.308,10.379,7.762},{-4.644,10.357,7.744},{-2.659,9.572,8.624},{-2.646,12.021,4.645},{-4.638,11.594,5.734},{-5.272,11.071,6.795},{-6.575,10.947,6.715},{-0.652,8.735,9.456},{1.379,12.031,4.659},{-1.302,12.045,4.658},{-0.634,12.381,3.532},{2.711,9.546,8.624},{0.697,8.729,9.456},{3.368,10.348,7.763},{3.374,11.585,5.752},{4.703,10.314,7.746},{4.709,11.551,5.737},{2.723,11.994,4.646},{0.716,12.374,3.533},{5.338,11.022,6.799},{6.639,10.887,6.720},{-10.049,2.618,7.771},{-9.630,3.894,7.771},{-10.071,4.735,6.803},{-10.806,4.278,5.762},{-11.225,3.002,5.764},{-10.901,2.200,6.805},{-9.663,6.011,6.808},{-11.010,5.048,4.664},{-11.846,2.500,4.667},{-11.330,0.930,6.814},{-8.794,6.426,7.766},{-9.972,6.810,5.755},{-9.527,8.070,5.737},{-10.562,6.315,4.649},{-8.232,5.555,8.628},{-8.350,7.686,7.747},{-8.829,8.507,6.798},{-8.299,9.704,6.716},{-11.541,4.519,3.539},{-9.511,1.738,8.652},{-8.676,4.286,8.650},{-8.073,3.388,9.461},{-12.236,1.212,4.655},{-11.962,3.237,3.540},{-12.052,0.467,5.763},{-10.874,0.083,7.772},{-12.442,-0.810,5.748},{-11.266,-1.194,7.757},{-9.906,0.453,8.633},{-8.493,2.106,9.462},{-12.139,-1.574,6.810},{-12.422,-2.851,6.732},{-11.207,6.529,0.030},{-10.792,7.102,1.172},{-10.051,8.235,1.114},{-9.605,8.719,-0.070},{-10.020,8.145,-1.212},{-10.875,7.097,-1.154},{-9.648,8.814,2.252},{-8.648,9.678,-0.113},{-9.476,8.533,-2.392},{-11.301,6.534,-2.293},{-9.964,8.235,3.439},{-8.776,9.853,2.196},{-8.336,10.403,3.331},{-8.208,10.229,1.032},{-10.559,7.027,3.493},{-9.524,8.786,4.575},{-8.822,9.927,4.490},{-8.296,10.392,5.597},{-8.039,9.995,-1.278},{-11.831,5.326,0.073},{-11.003,6.470,2.353},{-11.538,5.229,2.386},{-9.868,7.938,-3.532},{-8.456,9.419,-2.424},{-10.840,7.006,-3.479},{-12.026,5.388,-2.237},{-11.227,6.417,-4.614},{-12.414,4.800,-3.372},{-12.217,4.737,-1.072},{-11.955,4.653,1.239},{-12.104,5.404,-4.530},{-12.383,4.759,-5.636},{-4.559,12.082,-1.216},{-5.233,11.870,-0.073},{-4.633,12.141,1.110},{-3.323,12.485,1.167},{-2.650,12.696,0.025},{-3.294,12.561,-1.159},{-5.309,11.942,2.250},{-2.656,12.486,2.347},{-1.311,12.909,0.066},{-2.626,12.786,-2.299},{-6.570,11.443,2.194},{-4.658,12.060,3.436},{-5.318,11.817,4.572},{-3.324,12.241,3.488},{-7.106,11.022,1.031},{-7.229,11.202,3.330},{-6.624,11.512,4.488},{-7.230,11.160,5.595},{-1.309,12.601,2.378},{-5.100,11.687,-2.395},{-6.446,11.265,-0.114},{-6.940,10.787,-1.278},{-0.630,13.087,-1.079},{-0.632,12.814,1.232},{-1.310,13.112,-2.243},{-3.221,12.497,-3.483},{-2.541,12.677,-4.620},{-4.412,11.869,-3.535},{-6.263,10.999,-2.426},{-1.302,13.189,-4.536},{-0.603,13.250,-5.643},{-6.281,-0.748,11.317},{-7.368,-1.098,10.611},{-7.578,-2.406,10.326},{-6.647,-3.345,10.616},{-5.560,-2.995,11.322},{-5.420,-1.710,11.727},{-8.670,-2.757,9.633},{-6.731,-4.594,10.092},{-4.561,-3.894,11.502},{-4.342,-1.363,12.443},{-9.522,-1.792,9.205},{-8.801,-4.040,9.210},{-9.866,-4.384,8.481},{-7.804,-4.934,9.358},{-9.230,-0.484,9.348},{-10.587,-2.135,8.476},{-7.808,-6.092,8.647},{-10.792,-3.442,8.238},{-9.871,-5.547,7.766},{-11.770,-3.757,7.425},{-5.695,-5.458,10.191},{-5.991,0.565,11.491},{-8.160,-0.134,10.082},{-7.820,1.172,10.175},{-3.458,-3.534,12.180},{-4.603,-5.106,10.902},{-3.399,-2.300,12.718},{-4.120,-0.052,12.713},{-2.302,-1.946,13.393},{-2.362,-4.338,12.184},{-3.023,0.301,13.388},{-4.885,0.916,12.169},{-6.728,1.523,10.885},{-1.201,-2.753,13.398},{-2.206,-0.675,13.815},{-1.076,-0.312,14.370},{-11.775,-4.877,6.737},{-0.017,-1.089,14.375},{4.610,4.334,11.316},{5.285,5.255,10.608},{4.688,6.436,10.319},{3.381,6.648,10.604},{2.706,5.728,11.311},{3.347,4.609,11.723},{5.366,7.358,9.624},{2.716,7.705,10.076},{1.368,5.869,11.486},{2.677,3.695,12.439},{6.625,7.078,9.200},{4.719,8.473,9.196},{5.381,9.374,8.465},{3.386,8.609,9.339},{7.157,5.848,9.348},{7.286,7.979,8.469},{6.685,9.155,8.227},{7.293,9.982,7.413},{1.371,7.795,10.169},{5.147,3.102,11.496},{6.495,4.938,10.084},{8.256,5.485,8.637},{0.686,4.931,12.166},{0.692,6.870,10.880},{1.362,3.901,12.709},{3.268,2.505,12.715},{0.681,2.972,13.386},{2.586,1.577,13.390},{4.457,2.170,12.176},{4.873,0.876,12.179},{6.309,2.758,10.895},{3.003,0.277,13.395},{1.349,1.888,13.812},{0.648,0.932,14.369},{8.356,9.633,6.725},{1.050,-0.320,14.374},{5.319,11.824,-0.068},{4.649,12.043,-1.210},{3.387,12.533,-1.155},{2.741,12.672,0.027},{3.411,12.454,1.171},{4.717,12.098,1.114},{2.723,12.763,-2.295},{1.404,12.896,0.068},{2.741,12.460,2.349},{5.388,11.893,2.255},{3.319,12.470,-3.480},{1.410,13.101,-2.241},{0.735,13.287,-3.378},{0.728,13.082,-1.078},{4.507,11.834,-3.531},{2.642,12.657,-4.617},{1.407,13.178,-4.535},{3.064,12.074,-5.777},{0.711,13.245,-5.643},{0.722,12.807,1.232},{6.527,11.210,-0.107},{5.191,11.646,-2.389},{6.351,10.951,-2.420},{4.926,11.255,-4.685},{3.404,12.208,3.491},{1.395,12.588,2.381},{4.737,12.015,3.440},{6.646,11.384,2.201},{5.393,11.767,4.576},{7.303,11.136,3.338},{7.183,10.961,1.039},{7.024,10.732,-1.271},{6.696,11.452,4.495},{7.298,11.096,5.602},{1.116,12.684,-6.760},{8.360,10.321,5.605},{-0.631,13.293,-3.379},{-6.589,7.988,-7.802},{-5.500,8.773,-7.803},{-5.362,9.713,-6.838},{-6.227,9.783,-5.798},{-7.316,8.998,-5.798},{-7.525,8.155,-6.836},{-4.282,10.506,-6.846},{-5.941,10.529,-4.703},{-8.114,8.963,-4.701},{-8.618,7.381,-6.843},{-3.335,10.326,-7.802},{-4.063,11.337,-5.795},{-2.963,12.096,-5.780},{-4.832,11.290,-4.691},{-3.392,9.290,-8.661},{-2.235,11.085,-7.785},{-2.141,12.035,-6.840},{-1.133,10.722,-8.503},{-1.010,12.690,-6.760},{-6.682,10.422,-3.578},{-6.671,6.958,-8.681},{-4.497,8.525,-8.682},{-4.539,7.444,-9.492},{-2.295,8.928,-9.376},{-9.187,8.152,-4.687},{-7.776,9.633,-3.577},{-9.475,7.436,-5.792},{-8.748,6.425,-7.799},{-10.543,6.633,-5.775},{-9.816,5.622,-7.781},{-7.747,6.151,-8.658},{-7.752,4.994,-9.371},{-5.633,6.655,-9.492},{-9.820,4.460,-8.497},{-10.745,5.833,-6.834},{-11.725,4.967,-6.754},{0.053,12.341,-7.451},{-11.730,3.849,-7.444},{-12.891,0.704,1.181},{-12.889,1.407,0.038},{-12.961,0.749,-1.145},{-12.895,-0.602,-1.199},{-12.899,-1.306,-0.057},{-12.969,-0.648,1.125},{-12.971,1.452,-2.286},{-12.692,-1.242,-2.378},{-12.699,-2.646,-0.095},{-12.985,-1.350,2.267},{-12.875,2.804,-2.232},{-12.882,0.793,-3.470},{-12.846,1.493,-4.607},{-12.655,-0.534,-3.520},{-12.640,3.446,-1.070},{-12.840,3.504,-3.369},{-12.238,-1.117,-4.675},{-12.950,2.830,-4.525},{-12.428,0.908,-5.767},{-12.794,3.511,-5.635},{-12.399,-2.562,-2.407},{-12.685,1.342,2.359},{-12.677,2.746,0.077},{-12.377,3.365,1.240},{-12.669,-3.347,1.052},{-12.403,-3.269,-1.259},{-12.900,-2.704,2.213},{-12.892,-0.692,3.451},{-12.872,-3.403,3.350},{-12.256,-4.641,1.055},{-12.865,-1.392,4.588},{-12.655,0.633,3.501},{-12.381,2.659,2.389},{-12.456,-4.703,3.354},{-12.978,-2.728,4.506},{-12.829,-3.411,5.615},{-12.391,2.949,-6.751},{-12.430,-4.662,5.618},{-12.118,1.669,-6.829},{-10.802,-5.751,6.820},{-12.154,-5.310,4.513},{2.178,-0.693,13.822},{8.878,8.433,6.807},{8.885,9.853,4.499},{0.049,11.313,-8.264},{2.243,12.020,-6.839},{2.266,-1.966,13.402},{4.100,-0.085,12.723},{4.313,-1.399,12.455},{5.978,0.517,11.504},{6.987,3.683,10.184},{6.723,1.468,10.900},{6.259,-0.799,11.332},{7.816,1.109,10.193},{8.391,7.616,7.754},{9.577,7.993,5.749},{8.826,6.352,7.775},{8.693,4.215,8.662},{9.695,5.932,6.822},{9.648,3.816,7.785},{8.084,3.322,9.475},{8.497,2.038,9.479},{9.580,8.707,4.586},{8.404,10.331,3.341},{8.843,9.780,2.206},{8.281,10.160,1.041},{9.710,8.736,2.265},{8.118,9.932,-1.269},{8.535,9.357,-2.416},{6.769,10.372,-3.572},{8.720,9.608,-0.103},{9.673,8.643,-0.059},{2.334,11.072,-7.786},{4.159,11.308,-5.792},{6.030,10.486,-4.697},{4.375,10.476,-6.843},{7.859,9.577,-3.570},{6.313,9.738,-5.793},{1.228,10.715,-8.503},{-1.136,9.602,-9.231},{0.043,9.081,-9.657},{-2.303,7.803,-10.110},{-1.205,-3.909,12.726},{-0.020,-2.277,13.823},{1.159,-2.764,13.403},{-2.371,-5.501,11.510},{-0.027,-4.527,12.459},{-3.510,-5.908,10.906},{-1.212,-6.184,11.337},{-3.515,-7.058,10.200},{-10.605,-6.554,5.762},{-6.740,-6.908,8.672},{-8.811,-6.358,7.786},{-8.689,-7.317,6.833},{-6.665,-7.941,7.796},{-5.700,-6.613,9.483},{-4.612,-7.412,9.487},{-3.444,7.082,-10.205},{-1.143,7.337,-10.635},{-3.448,5.934,-10.914},{-5.638,5.501,-10.204},{-10.755,3.526,-8.257},{-10.561,2.219,-8.496},{-8.757,4.109,-9.226},{-8.637,2.826,-9.651},{-6.681,4.647,-10.106},{-4.548,5.142,-10.913},{-6.607,3.398,-10.633},{-11.247,1.284,-7.777},{-12.047,-0.372,-5.782},{-11.328,-0.841,-6.834},{-11.859,-2.406,-4.686},{-11.240,-2.912,-5.781},{-11.984,-3.143,-3.560},{-11.574,-4.429,-3.558},{-11.287,-6.332,4.600},{-12.072,-5.295,2.218},{-11.356,-6.446,2.278},{-11.873,-5.234,-0.090},{-11.991,-4.561,-1.257},{-11.577,-5.139,-2.403},{-11.258,-6.442,-0.045},{3.427,10.305,-7.802},{1.225,9.596,-9.232},{10.012,6.729,5.768},{10.019,8.154,3.452},{3.363,-2.329,12.730},{1.156,-3.919,12.731},{-9.545,-7.366,5.781},{-10.902,-6.924,3.466},{-10.866,0.003,-7.793},{-9.498,1.867,-9.225},{10.112,8.155,1.126},{10.607,6.943,3.507},{10.604,6.231,4.665},{10.095,4.653,6.818},{3.414,-3.564,12.193},{5.391,-1.754,11.742},{2.311,-4.357,12.193},{-0.030,-5.663,11.746},{-7.601,-8.101,6.828},{-9.261,-8.086,4.677},{-9.938,-7.865,3.520},{-10.934,-7.014,1.140},{-10.909,-2.113,-6.824},{-9.899,-0.374,-8.653},{-9.216,0.557,-9.369},{-7.547,2.466,-10.344},{0.038,7.933,-10.349},{2.379,8.914,-9.376},{3.479,9.268,-8.661},{5.449,9.677,-6.835},{11.043,4.961,4.681},{11.050,6.384,2.368},{10.846,7.017,1.186},{10.086,8.069,-1.200},{8.195,8.905,-4.693},{9.549,8.462,-2.382},{7.397,8.946,-5.791},{5.582,8.734,-7.799},{4.579,8.495,-8.680},{2.380,7.787,-10.108},{1.217,7.328,-10.635},{-1.147,6.193,-11.341},{-2.312,5.520,-11.518},{-4.515,3.932,-11.516},{-5.521,3.040,-11.337},{-7.345,1.157,-10.629},{-8.147,0.199,-10.102},{-9.514,-1.662,-8.671},{-10.058,-2.538,-7.789},{-10.831,-4.191,-5.779},{-11.043,-4.960,-4.682},{-11.050,-6.384,-2.368},{-10.845,-7.018,-1.186},{-10.086,-8.069,1.200},{-9.548,-8.463,2.381},{-8.195,-8.905,4.693},{-7.397,-8.946,5.790},{-5.582,-8.735,7.799},{-4.579,-8.495,8.680},{-2.379,-7.786,10.108},{-1.216,-7.328,10.634},{1.148,-6.193,11.340},{2.312,-5.521,11.516},{4.515,-3.932,11.515},{5.522,-3.040,11.336},{7.346,-1.158,10.629},{8.148,-0.199,10.101},{9.515,1.663,8.671},{10.831,4.191,5.779},{10.058,2.537,7.789}};

n=960;

u=Table["C",{i,1,n}]

un=Table[If[u[[i]]=="H","Z",u[[i]]],{i,1,n}];

num=Table[i,{i,1,n}];

um=Table[{un[[i]],num[[i]]},{i,1,n}];

us=Sort[um];

num=Table[us[[i,2]],{i,1,n}];

For[i=1,i<n+1,i++,If[us[[i,1]]=="Z",us[[i,1]]="H"]];

u1=Table[If[us[[i,1]]=="C",0.255,If[us[[i,1]]=="H",0.1,If[us[[i,1]]=="N",0.24,If[us[[i,1]]=="O",0.178,If[us[[i,1]]=="Cl",0.5]]]]],{i,1,n}];
u2=Table[If[us[[i,1]]=="C",0.255,If[us[[i,1]]=="H",0.6,If[us[[i,1]]=="N",0.22522,If[us[[i,1]]=="O",0.178,If[us[[i,1]]=="Cl",0.5]]]]],{i,1,n}];

u=Table[us[[i,1]],{i,1,n}];

cn=Table[If[u[[i]]=="C",6.0,If[u[[i]]=="H",1.0,If[u[[i]]=="N",7.0,If[u[[i]]=="O",8.0,If[u[[i]]=="Cl",17.0]]]]],{i,1,n}];

bc=0;
For[i=1, i<n+1,i++,If[u[[i]]≠"H", bc=bc+1]];
bc
bh=n-bc

(*DeleteFile[ "C:\\Kimb_Mathem\\tmp3"];
For[i=1,i<n+1,i++,
{u[[i]],Extract[t1,{i}]}>>> "C:\\Kimb_Mathem\\tmp3"]
*)
(*ChemicalData["Diazepam","MolecularFormulaString"]*)

(*t= Table[t1[[num[[i]]]],{i,1,n}];*)

Plot1=Table[Graphics3D[{If[u[[i]]=="N",Lighter[Blue],If[u[[i]]=="O",Lighter[Red],If[u[[i]]=="Cl",Lighter[Green],If[u[[i]]=="B",Lighter[Orange],Darker[Green]]]]],Sphere[{t[[i,1]],t[[i,2]],t[[i,3]]},u1[[i]]]}],{i,1,n}];

Plot2=Table[Graphics3D[Text[i,{t[[i,1]]-0.6,t[[i,2]],t[[i,3]]} ,{1,0}]],{i,1,n}];

(*ChemicalData["Diazepam","CHStructureDiagram"]*)

x=Table[t[[i,1]],{i,1,n}];
y=Table[t[[i,2]],{i,1,n}];
z=Table[t[[i,3]],{i,1,n}];

(* Distance maTetrx Bohr *)
Dij=Table[If[i≥j,If[sq=Sqrt[(x[[i]]-x[[j]])^2+(y[[i]]-y[[j]])^2+(z[[i]]-z[[j]])^2]; (sq<3.0 ||(u[[i]]=="Cl" && j==10 && i== 17)),sq,0],0],{i,1,n},{j,1,n}];
(*MatrixForm[Dij]*)

For[i=1 ,i<n+1,i++,
For[j=1, j<i,j++,
If[(Dij[[i,j]]≠0 && u[[i]]== "H"),If[u[[j]]=="C",u2[[i]]=0.5693,If[u[[j]]=="F",u2[[i]]=0.5,If[u[[j]]=="N",u2[[i]]=0.5541,If[u[[j]]=="O",u2[[i]]=0.5241]]]]]]]
(*u2*)

Fij=Dij-u2;
(*MatrixForm[Fij];*)
Gij=Table[If[i≥j,If[Fij[[i,j]]>0,Fij[[i,j]],0]," "],{i,1,n},{j,1,n}];
(*MatrixForm[Gij];*)

Hij=Transpose[Gij];
(*MatrixForm[Hij];*)

Kij=Hij-u2;
(*MatrixForm[Kij];*)
Lij=Table[If[i≤j,If[Kij[[i,j]]>0,Kij[[i,j]],0]," "],{i,1,n},{j,1,n}];
(*MatrixForm[Lij];*)

Lij=Table[If[i≤j,If[Lij[[i,j]]>0,If[u[[j]]≠"H",0.5*Lij[[i,j]],Lij[[i,j]]],0]," "],{i,1,n},{j,1,n}];  
Qij=Lij;
(*MatrixForm[Lij];*)

Nij=Table[If[i≤j,If[Lij[[i,j]]>0,2.25/Lij[[i,j]]^2,0]," "],{i,1,n},{j,1,n}];
(*MatrixForm[Nij]*)

Tval=Sum[If[i≤j,Nij[[i,j]],0],{i,1,n},{j,1,n}]

Tcor=Sum[If[u[[i]]≠"H",2.25/u2[[i]]^2,0],{i,1,n}]

Ttot=Tval+Tcor  (* plus π and lone pairs: + 8.7616 *)

TvalH=Sum[If[(i≤j && u[[j]]== "H"),Nij[[i,j]],0],{i,1,n},{j,1,n}]

TvalC=Tval-TvalH

Mij=Prepend[Qij,u];
Oij=Transpose[Mij];
Pij=Prepend[Oij,Prepend[u," "]];

(*MatrixForm[Pij];*)

(* sigma bond cloud radii *)

(*For[i=2,i<n+2,i++,
For[j=2,j≤i,j++,
If[Pij[[i,j]]>0,Print[u[[i-1]],i-1," ",u[[j-1]],j-1,"  ",Extract[Pij,{i,j}]]]]]*)

DeleteFile[ "C:\\Kimb_Mathem\\tmp4"];
For[i=2,i<n+2,i++,
For[j=2,j≤i,j++,
If[Pij[[i,j]]>0,{i-1,j-1,Extract[Pij,{i,j}]}>>> "C:\\Kimb_Mathem\\tmp4"]]]

a=ReadList["C:\\Kimb_Mathem\\tmp4"]
nb=Length[a]
cw=nb-bh

wxc=Table[(a[[i,3]]+u2[[a[[i,1]]]])/(u2[[a[[i,1]]]]+2*a[[i,3]]+u2[[a[[i,2]]]])*(x[[a[[i,2]]]]-x[[a[[i,1]]]])+x[[a[[i,1]]]],{i,1,cw}];
wyc=Table[(a[[i,3]]+u2[[a[[i,1]]]])/(u2[[a[[i,1]]]]+2*a[[i,3]]+u2[[a[[i,2]]]])*(y[[a[[i,2]]]]-y[[a[[i,1]]]])+y[[a[[i,1]]]],{i,1,cw}];   
wzc=Table[(a[[i,3]]+u2[[a[[i,1]]]])/(u2[[a[[i,1]]]]+2*a[[i,3]]+u2[[a[[i,2]]]])*(z[[a[[i,2]]]]-z[[a[[i,1]]]])+z[[a[[i,1]]]],{i,1,cw}];

Plot7=Table[Graphics3D[{Lighter[Orange],{Opacity[0.2],If[wxc[[i]]≠0,Sphere[{wxc[[i]],wyc[[i]],wzc[[i]]},a[[i,3]]]]}}],{i,1,cw}];

wxh=Table[(a[[i,3]]+u2[[a[[i,2]]]])/(u2[[a[[i,1]]]]+a[[i,3]]+u2[[a[[i,2]]]])*(x[[a[[i,1]]]]-x[[a[[i,2]]]])+x[[a[[i,2]]]],{i,cw+1,nb}];
wyh=Table[(a[[i,3]]+u2[[a[[i,2]]]])/(u2[[a[[i,1]]]]+a[[i,3]]+u2[[a[[i,2]]]])*(y[[a[[i,1]]]]-y[[a[[i,2]]]])+y[[a[[i,2]]]],{i,cw+1,nb}];
wzh=Table[(a[[i,3]]+u2[[a[[i,2]]]])/(u2[[a[[i,1]]]]+a[[i,3]]+u2[[a[[i,2]]]])*(z[[a[[i,1]]]]-z[[a[[i,2]]]])+z[[a[[i,2]]]],{i,cw+1,nb}];

Plot8=Table[Graphics3D[{Opacity[0.5],Sphere[{wxh[[i]],wyh[[i]],wzh[[i]]},a[[i+cw,3]]]}],{i,1,bh}];

Plot9= Table[Graphics3D[{(*Darker[Red,0.8],*)Tube[{{x[[a[[i,1]]]],y[[a[[i,1]]]],z[[a[[i,1]]]]},{x[[a[[i,2]]]],y[[a[[i,2]]]],z[[a[[i,2]]]]}},0.15]}],{i,1,nb}];
Show[Plot1,Plot7,Plot8,Plot9,{AspectRatio->Automatic,Boxed->False, SphericalRegion->True}]
Show[Plot1,Plot2,Plot9,{AspectRatio->Automatic,Boxed->False, SphericalRegion->True}]

tc=Table[{x[[i]],y[[i]],z[[i]]},{i,1,bc}];   (* core clouds *)
twc=Table[{wxc[[i]],wyc[[i]],wzc[[i]]},{i,1,cw}];  (* Bond cöouds between cores *)
twh=Table[{wxh[[i]],wyh[[i]],wzh[[i]]},{i,1,bh}]; (* H-bonding clouds *)
tw=Join[tc,twc,twh];
bt=Length[tw]
(*MatrixForm[tw]*)
(* coordinates of clouds *)

dw=Table[Sqrt[(tw[[i,1]]-tw[[j,1]])^2+(tw[[i,2]]-tw[[j,2]])^2+(tw[[i,3]]-tw[[j,3]])^2],{i,1,bt},{j,1,bt}];
(*MatrixForm[dw]*)
(* cloud-cloud distances *)

dc=Table[Sqrt[(t[[i,1]]-t[[j,1]])^2+(t[[i,2]]-t[[j,2]])^2+(t[[i,3]]-t[[j,3]])^2],{i,1,n},{j,1,n}];
(*MatrixForm[dc]*)  (* nucleus-nucleus distances *)

tv1=Table[{x[[i]],y[[i]],z[[i]]},{i,1,bc}];
tv2=Table[{0,0,0},{i,1,cw}];
tv3= Table[{x[[i]],y[[i]],z[[i]]},{i,bc+1,n}];
tv  = Join[tv1,tv2,tv3];
(*MatrixForm[tv]*)

dcw=Table[sq=Sqrt[(tw[[i,1]]-tv[[j,1]])^2+(tw[[i,2]]-tv[[j,2]])^2+(tw[[i,3]]-tv[[j,3]])^2];If[sq> 0.1,-2/sq,0],{i,1,bt},{j,1,bt}];
dcw=Table[If[i== j,dcw[[i,j]]=0.0,dcw[[i,j]]],{i,1,bt},{j,1,bt}];
(*MatrixForm[dcw]*)  
(* nucleus-cloud distances *)

cnv=Join[Table[cn[[i]],{i,1,bc}],Table[0.0,{i,1,cw}],Table[cn[[i]],{i,bc+1,n}]];

Vee=0.0; Vnn=0.0;

(* all clouds repulsion *)
For[i=1,i<bt,i++,
For[j=i+1,j<bt+1,j++,
Vee=Vee+4/dw[[i,j]]]]
Vee

sc=0.24;   (* core clouds *)
For[i=1 ,i<bc+1,i++,Vee=Vee+3*sc/u2[[i]]]
sw=0.24;  (* bonding clouds *)
For[i=1 ,i<nb+1,i++,Vee=Vee+3*sw/a[[i,3]]]
Vee

(* all nuclei with all clouds, except i = j *)
Vne=Apply[Plus,cnv.dcw]

(* core nuclei in their cloud centers *)

For[i=1,i<bc+1,i++,Vne=Vne-3*cn[[i]]/u2[[i]]]
Vne

(* protons in their bonding cloud, distance u2[[a[[i,1]]]] to cloud center *)
For[i=cw+1,i<nb+1,i++,Vne=Vne-(3-(u2[[a[[i,1]]]]/a[[i,3]])^2)/a[[i,3]]]
Vne

(* nucleus-nucleus *)
For[i=1,i<n,i++,
For[j=i+1,j<n+1,j++,Vnn=Vnn+cn[[i]]*cn[[j]]/dc[[i,j]]]]
Vnn

Vee
Vnn
Vne
Vtot=Vne+Vee+Vnn
Ttot
-Vtot/Ttot
Etot=Ttot+Vtot