Skip to content

Instantly share code, notes, and snippets.

@cortner
Last active June 23, 2017 22:49
Show Gist options
  • Save cortner/fd56e5282c71c29d64c4036de4f78192 to your computer and use it in GitHub Desktop.
Save cortner/fd56e5282c71c29d64c4036de4f78192 to your computer and use it in GitHub Desktop.
break kumagai calculator
from numpy import *
import atomistica
from ase.atoms import *
X=array([1.42588,-3.44239,0.0,2.73662,-1.97199,1.3575,1.28782,-0.724414,2.715,2.59344,0.745918,4.0725,4.18105,-3.22103,2.715,5.49312,-1.74281,4.0725,4.04571,-0.49763,0.0,5.35298,0.981145,1.3575,1.1371,1.98901,0.0,2.43615,3.45883,1.3575,0.9722,4.69833,2.715,2.263,6.16731,4.0725,3.89681,2.22019,2.715,5.1976,3.69884,4.0725,3.73204,4.93248,0.0,5.02423,6.41037,1.3575,0.792067,7.40456,0.0,2.07289,8.87273,1.3575,0.596638,10.1094,2.715,1.86617,11.5773,4.0725,3.54938,7.64001,2.715,4.8305,9.11683,4.0725,3.34779,10.3446,0.0,4.61557,11.8207,1.3575,0.387448,12.8151,0.0,1.64536,14.2836,1.3575,0.168044,15.524,2.715,1.41555,16.9944,4.0725,3.12829,13.0491,2.715,4.38163,14.5256,4.0725,2.8949,15.7567,0.0,4.13502,17.2353,1.3575,0.0561522,25.2023,0.0,1.53117,26.4442,1.3575,0.278721,27.9135,2.715,1.75727,29.1525,4.0725,2.77516,24.9699,2.715,4.25935,26.2028,4.0725,3.01295,27.6802,0.0,4.50068,28.9098,1.3575,0.493591,30.6205,0.0,1.97151,31.8576,1.3575,0.696213,33.3255,2.715,2.17009,34.5622,4.0725,3.24011,30.3858,2.715,4.72563,31.6136,4.0725,3.45095,33.09,0.0,4.93001,34.3184,1.3575,0.884072,36.0308,0.0,2.35165,37.2689,1.3575,1.0565,38.7384,2.715,2.51668,39.9795,4.0725,3.64305,35.7957,2.715,5.11333,37.0272,4.0725,3.81655,38.5055,0.0,5.27737,39.7417,1.3575,1.21414,41.4496,0.0,2.66667,42.6949,1.3575,1.35833,44.1653,2.715,2.80352,45.4153,4.0725,3.9731,41.2205,2.715,5.42479,42.4626,4.0725,4.11494,43.9412,0.0,5.55831,45.1895,1.3575,6.93511,-2.99082,0.0,8.24829,-1.50388,1.3575,6.8037,-0.259729,2.715,8.11261,1.22884,4.0725,9.68643,-2.75267,2.715,11.0001,-1.25644,4.0725,9.56004,-0.011055,0.0,10.8702,1.48852,1.3575,7.04616,3.45244,-2.33118e-13,8.06379,4.40704,1.31681,6.48466,5.3206,2.78834,7.81928,6.81696,4.02698,9.58628,3.37526,2.70648,10.8854,4.69486,4.06903,9.35859,5.80433,0.0402617,10.6193,7.19114,1.35678,6.30221,7.93013,0.120104,7.58305,9.44821,1.37883,6.08007,10.6125,2.76459,7.348,12.104,4.03275,9.11519,8.30954,2.75184,10.4469,9.79489,4.04201,8.85759,10.939,0.0925711,10.121,12.4406,1.36982,5.85222,13.3038,0.0782112,7.06837,14.7868,1.38422,5.56405,16.0087,2.72875,6.76335,17.4479,4.05055,8.58524,13.5946,2.73378,9.82321,15.0793,4.0268,8.29821,16.2582,0.0855285,9.52171,17.6975,1.37567,5.58807,24.7911,0.0713178,7.02407,25.9896,1.39521,5.73911,27.434,2.74389,7.246,28.647,4.03516,8.25952,24.5679,2.73324,9.76639,25.7144,4.01868,8.51255,27.1837,0.081095,10.0164,28.374,1.38214,5.98915,30.1204,0.0656274,7.46663,31.3197,1.38347,6.18511,32.8072,2.71585,7.67961,33.9815,4.03013,8.74193,29.8432,2.72123,10.2535,31.0271,4.02531,8.96622,32.4989,0.066973,10.4643,33.6802,1.37916,6.40146,35.4816,0.0327384,7.85358,36.6369,1.37905,6.57566,38.1498,2.67189,7.88162,39.2349,4.25923,9.15916,35.1537,2.7009,10.6442,36.3165,4.04369,9.29399,37.7079,-0.0380042,10.866,38.7233,1.28522,6.73289,40.9791,0.0,8.18221,42.2192,1.3575,6.87098,43.707,2.715,8.31123,44.9551,4.0725,9.49182,40.7252,2.715,10.9369,41.9656,4.0725,9.62478,43.4636,0.0,11.0605,44.7137,1.3575,12.433,-2.50865,0.0,13.7463,-1.00318,1.3575,12.3123,0.246752,2.715,13.6227,1.75793,4.0725,15.1727,-2.26229,2.715,16.4842,-0.748767,4.0725,15.0576,0.510049,0.0,16.3666,2.03207,1.3575,12.2671,3.41138,0.0102097,13.5656,4.76735,1.38136,12.1649,6.0476,2.70961,13.451,7.51486,4.07964,15.0038,3.53519,2.69809,16.2715,5.04091,4.02327,14.8893,6.25584,-0.0429402,16.2273,7.82192,1.37191,11.9312,8.67102,-0.034865,13.257,10.2088,1.36591,11.6827,11.3075,2.71625,12.9408,12.8095,4.00512,14.732,9.01057,2.72293,16.0103,10.5285,3.9932,14.5009,11.7011,0.0927515,15.7502,13.2199,1.36112,11.37,13.9333,0.0765388,12.594,15.4389,1.37428,11.0284,16.5695,2.71638,12.1848,18.0493,4.03608,14.1728,14.322,2.71852,15.4108,15.8382,3.99133,13.8096,16.9405,0.086359,15.0082,18.4243,1.36301,11.0522,24.255,0.0618358,12.5222,25.417,1.38397,11.2746,26.8954,2.71952,12.7978,28.0634,4.02337,13.7173,23.9603,2.72146,15.2705,25.0541,4.00186,14.0483,26.5673,0.0748396,15.5828,27.7062,1.38541,11.5288,29.5481,0.0725635,13.0415,30.7184,1.38296,11.7568,32.2042,2.71015,13.2563,33.3987,4.01589,14.3171,29.2192,2.70593,15.8284,30.3968,4.00875,14.5409,31.9054,0.07422,16.0335,33.0965,1.38449,11.9631,34.8647,0.0663637,13.4588,36.0568,1.37721,12.1616,37.464,2.7335,13.5076,38.8016,4.05675,14.7455,34.5926,2.70347,16.195,35.849,4.00056,14.8854,37.325,0.0685438,16.3497,38.5846,1.35091,12.2473,40.4603,0.0,13.686,41.7045,1.3575,12.3741,43.2128,2.715,13.8039,44.468,4.0725,14.996,40.1876,2.715,16.4267,41.4406,4.0725,15.1164,42.9582,0.0,16.5394,44.2223,1.3575,17.9037,-2.01877,0.0,19.212,-0.499857,1.3575,17.793,0.772628,2.715,19.0985,2.30252,4.0725,20.6252,-1.78458,2.715,21.9294,-0.264407,4.0725,20.5168,1.02588,0.0,21.8175,2.55819,1.3575,17.7337,3.61225,0.130976,19.0199,5.15808,1.38868,17.6118,6.50381,2.72558,18.9026,8.02874,3.98502,20.417,3.81895,2.76535,21.7097,5.3835,3.99088,20.3132,6.70247,0.135361,21.5969,8.24819,1.3791,17.4903,9.31533,0.112713,18.7521,10.8399,1.3663,17.2734,12.0589,2.72973,18.5473,13.6312,3.95815,20.1829,9.56247,2.73177,21.4542,11.1267,3.96617,20.0193,12.4034,0.129724,21.2787,13.9807,1.36233,17.0148,14.7734,0.109978,18.2559,16.369,1.35085,16.5856,17.3716,2.69108,17.6862,18.9106,4.00109,19.7982,15.2207,2.72296,21.072,16.8867,3.86842,19.5342,18.0508,0.212577,20.865,19.7232,1.28308,16.5081,23.5447,0.0694446,18.0431,24.6139,1.39975,16.8257,26.1694,2.69859,18.3735,27.2985,4.00011,19.1712,23.0474,2.68879,20.8536,23.9649,3.94315,19.6245,25.6809,0.090568,21.1564,26.8109,1.40565,17.1037,28.8615,0.0761829,18.6099,30.0256,1.39178,17.3229,31.5742,2.69025,18.7835,32.8074,3.9955,19.8896,28.4408,2.67382,21.3568,29.6723,3.97881,20.0703,31.2521,0.0791828,21.5157,32.5048,1.38481,17.4871,34.3348,0.0765229,18.9337,35.584,1.38418,17.6386,37.1009,2.69279,19.0341,38.3961,4.0048,20.2268,34.0518,2.68237,21.6494,35.3298,3.98696,20.352,36.8639,0.0761461,21.7669,38.1672,1.3742,17.7342,39.9141,0.0,19.1564,41.1815,1.3575,17.8494,42.7056,2.715,19.2657,43.9826,4.0725,20.4596,39.6496,2.715,21.8745,40.9365,4.0725,20.572,42.4624,0.0,21.9825,43.7556,1.3575,23.3379,-1.56652,0.0,24.6382,-0.0500624,1.3575,23.2297,1.2602,2.715,24.5255,2.7879,4.0725,26.0441,-1.37032,2.715,27.3418,0.137707,4.0725,25.9347,1.46751,0.0,27.2277,2.98399,1.3575,23.12,4.06251,0.139622,24.4052,5.5949,1.38976,22.9976,6.92525,2.73919,24.2792,8.47391,3.98207,25.8127,4.2734,2.75667,27.1028,5.80391,3.99979,25.6863,7.12706,0.129693,26.9714,8.65436,1.38495,22.8696,9.8007,0.130132,24.1419,11.35,1.378,22.7172,12.6832,2.7165,23.9722,14.2695,3.9451,25.5555,10.0061,2.71904,26.8314,11.545,3.97006,25.4037,12.9047,0.126099,26.6741,14.4445,1.38319,22.5303,15.5989,0.159945,23.7814,17.1992,1.38524,22.3038,18.5498,2.68381,23.5396,20.2196,3.86665,25.2303,15.8284,2.6922,26.5207,17.3608,3.94034,25.0537,18.7762,0.147912,26.4006,20.2802,1.38689,22.0271,21.6786,0.384012,23.5714,23.2783,1.39451,22.3923,25.0963,2.62785,23.8593,26.3896,3.91907,24.9626,21.7361,2.6779,26.4025,23.1886,3.897,25.0568,24.7096,0.175208,26.5465,26.1411,1.36638,22.6201,28.0509,0.0968811,24.0586,29.35,1.38338,22.7957,30.9369,2.67183,24.2243,32.2313,3.97076,25.3039,27.7406,2.6646,26.7449,29.0897,3.93797,25.4881,30.6617,0.0884431,26.9084,32.0045,1.36598,22.9389,33.7846,0.0753584,24.3535,35.0882,1.3737,23.0605,36.621,2.67788,24.4637,37.8989,4.00075,25.6368,33.548,2.6745,27.0544,34.8684,3.96651,25.7645,36.3893,0.0663241,27.1761,37.7184,1.35168,23.1726,39.4056,0.0,24.5829,40.7149,1.3575,23.2847,42.2367,2.715,24.6916,43.5479,4.0725,25.8769,39.1921,2.715,27.2858,40.523,4.0725,25.9904,42.0351,0.0,27.3958,43.3641,1.3575,28.7471,-1.1994,0.0,30.0444,0.296749,1.3575,28.6368,1.6434,2.715,29.93,3.1443,4.0725,31.4506,-1.05446,2.715,32.7496,0.428093,4.0725,31.3405,1.78778,0.0,32.6371,3.27157,1.3575,28.5208,4.47978,0.10604,29.806,5.95942,1.39035,28.3864,7.30748,2.72375,29.6781,8.81527,3.98367,31.2185,4.60549,2.73779,32.5234,6.09531,3.99648,31.0964,7.44619,0.111119,32.3958,8.93012,1.38082,28.2516,10.1706,0.116746,29.5406,11.6796,1.38132,28.1087,13.0616,2.69776,29.414,14.5586,3.95878,30.9685,10.3035,2.70241,32.2805,11.7816,3.96883,30.845,13.1607,0.105257,32.1655,14.6333,1.3728,27.9704,15.9516,0.117981,29.2932,17.4375,1.37847,27.8487,18.8516,2.67929,29.2246,20.3023,3.93347,30.7314,16.0319,2.68367,32.0838,17.4794,3.94985,30.6512,18.8828,0.107507,32.0367,20.3159,1.36333,27.7971,21.7296,0.137666,29.2309,23.1625,1.36471,27.8632,24.6233,2.68372,29.3108,26.0364,3.92124,30.6278,21.7306,2.67975,32.0387,23.1493,3.93251,30.6568,24.577,0.112583,32.0973,25.9887,1.3499,27.9999,27.5336,0.115898,29.451,28.9342,1.35427,28.1754,30.4597,2.67583,29.6077,31.822,3.94523,30.7588,27.4439,2.68147,32.1981,28.8404,3.93154,30.8884,30.3157,0.0926825,32.3241,31.7052,1.3457,28.3298,33.3414,0.0785217,29.747,34.6978,1.35338,28.4622,36.2041,2.6752,29.8677,37.5248,3.97994,31.0315,33.1939,2.67702,32.4571,34.5601,3.94659,31.1637,36.0453,0.0678651,32.5847,37.4146,1.33205,28.5785,39.014,0.0,29.9882,40.3631,1.3575,28.6929,41.8617,2.715,30.0986,43.2062,4.0725,31.2827,38.8707,2.715,32.6942,40.2334,4.0725,31.3965,41.7168,0.0,32.8034,43.0738,1.3575,34.1573,-0.933912,0.0,35.4599,0.534894,1.3575,34.0494,1.9038,2.715,35.3514,3.37115,4.0725,36.8688,-0.834787,2.715,38.1763,0.621185,4.0725,36.7648,1.99613,0.0,38.0735,3.44894,1.3575,33.9429,4.73739,0.091914,35.2427,6.18872,1.38363,33.8195,7.55948,2.70529,35.136,9.02378,3.97372,36.6524,4.8099,2.72676,37.971,6.26875,3.99474,36.5511,7.63775,0.0883902,37.8816,9.10013,1.34674,33.7031,10.3932,0.0966409,35.0242,11.8552,1.36766,33.596,13.2409,2.6855,34.9361,14.6848,3.95676,36.4514,10.4716,2.68329,37.7706,11.904,3.97735,36.3551,13.2909,0.0797691,37.7089,14.7326,1.34261,33.5067,16.0746,0.0927769,34.8671,17.5102,1.35964,33.451,18.9091,2.67764,34.8337,20.328,3.94339,36.2843,16.1151,2.67538,37.6316,17.5257,3.96957,36.2349,18.9246,0.0782754,37.6273,20.3426,1.33482,33.4287,21.7313,0.0943602,34.84,23.1424,1.34835,33.4613,24.5566,2.67833,34.8828,25.9605,3.9322,36.2281,21.7359,2.67393,37.612,23.1314,3.95779,36.2468,24.5424,0.0794933,37.674,25.9479,1.32484,33.5267,27.3883,0.0929713,34.9629,28.7893,1.33996,33.6345,30.2354,2.67836,35.0665,31.6228,3.9357,36.3097,27.3588,2.67477,37.7201,28.7462,3.94984,36.3904,30.1787,0.0774204,37.8292,31.577,1.32205,33.7534,33.0828,0.0799129,35.1812,34.4669,1.34083,33.8775,35.9336,2.67612,35.2892,37.291,3.96365,36.4966,33.0115,2.67593,37.9088,34.3879,3.95582,36.6044,35.8443,0.0746678,38.0314,37.2316,1.3346,33.9933,38.7581,0.0,35.4062,40.1299,1.3575,34.104,41.5982,2.715,35.5124,42.9644,4.0725,36.7115,38.6701,2.715,38.1252,40.0476,4.0725,36.8173,41.5022,0.0,38.2266,42.8747,1.3575,39.5859,-0.753617,0.0,40.8988,0.690965,1.3575,39.4872,2.06961,2.715,40.8026,3.51012,4.0725,42.3085,-0.68705,2.715,43.6269,0.747734,4.0725,42.2157,2.12846,0.0,43.5377,3.55885,1.3575,39.3872,4.89284,0.0,40.7073,6.32781,1.3575,39.2884,7.71435,2.715,40.6158,9.14226,4.0725,42.1236,4.9427,2.715,43.451,6.36762,4.0725,42.0346,7.75421,0.0,43.3696,9.17275,1.3575,39.1943,10.532,0.0,40.5324,11.9517,1.3575,39.1106,13.3436,2.715,40.4631,14.7547,4.0725,41.9521,10.5614,2.715,43.2974,11.9731,4.0725,41.8808,13.3632,0.0,43.2388,14.768,1.3575,39.0448,16.1479,0.0,40.4145,17.5514,1.3575,39.0047,18.9455,2.715,40.3924,20.3435,4.0725,41.8263,16.159,2.715,43.1985,17.5581,4.0725,41.7938,18.9499,0.0,43.1805,20.3448,1.3575,38.9964,21.7397,0.0,40.3999,23.1347,1.3575,39.0211,24.5351,2.715,40.4358,25.9287,4.0725,41.7871,21.7383,2.715,43.1866,23.1308,4.0725,41.807,24.5276,0.0,43.2161,25.9189,1.3575,39.075,27.3359,0.0,40.4956,28.7285,1.3575,39.1507,30.1439,2.715,40.5727,31.5348,4.0725,41.8511,27.3207,2.715,43.2661,28.7113,4.0725,41.9147,30.1195,0.0,43.3321,31.5089,1.3575,39.2404,32.9587,0.0,40.6608,34.3469,1.3575,39.3375,35.7786,2.715,40.7547,37.1632,4.0725,41.9922,32.924,2.715,43.4094,34.3118,4.0725,42.0785,35.7336,0.0,43.4938,37.1189,1.3575,39.4372,38.6012,0.0,40.8507,39.9819,1.3575,39.5368,41.4246,2.715,40.9466,42.8012,4.0725,42.1695,38.5467,2.715,43.5821,39.929,4.0725,42.2622,41.3617,0.0,43.6718,42.7408,1.3575])
X = X.reshape(512, 3)
clamp = array([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,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512])
clamp -= 1
at = Atoms(symbols="Si512", positions = X)
at.set_calculator(atomistica.Kumagai())
at.set_cell([43.44, 43.44, 5.43])
E0 = at.get_potential_energy()
f = at.get_forces()
f[clamp, :] = 0.0
print("|f| = ", max(abs(f.flatten())))
for h in [1e-10, 1e-8, 1e-6, 1e-4]:
at.set_positions(X + h * f)
E1 = at.get_potential_energy()
print("E1 - E0: ", E1 - E0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment