add test for pair style python

This commit is contained in:
Axel Kohlmeyer 2020-08-06 17:53:11 -04:00
parent ec0b3ae8d2
commit cd31006006
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
4 changed files with 209 additions and 6 deletions

View File

@ -62,7 +62,7 @@ endif()
foreach(TEST ${MOL_PAIR_TESTS})
string(REGEX REPLACE "^.*mol-pair-(.*)\.yaml" "MolPairStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_pair_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
# tests for metal-like atomic systems and related pair styles
@ -70,7 +70,7 @@ file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/atomic-p
foreach(TEST ${ATOMIC_PAIR_TESTS})
string(REGEX REPLACE "^.*atomic-pair-(.*)\.yaml" "AtomicPairStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_pair_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
# tests for Si-like manybody systems and related pair styles
@ -78,7 +78,7 @@ file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/manybo
foreach(TEST ${MANYBODY_PAIR_TESTS})
string(REGEX REPLACE "^.*manybody-pair-(.*)\.yaml" "ManybodyPairStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_pair_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
# bond style tester
@ -89,7 +89,7 @@ file(GLOB BOND_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/bond-*.yaml)
foreach(TEST ${BOND_TESTS})
string(REGEX REPLACE "^.*bond-(.*)\.yaml" "BondStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_bond_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
# angle style tester
@ -100,7 +100,7 @@ file(GLOB ANGLE_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/angle-*.yaml)
foreach(TEST ${ANGLE_TESTS})
string(REGEX REPLACE "^.*angle-(.*)\.yaml" "AngleStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_angle_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()
# kspace style tester, currently uses the pair style tool
@ -112,5 +112,5 @@ endif()
foreach(TEST ${KSPACE_TESTS})
string(REGEX REPLACE "^.*kspace-(.*)\.yaml" "KSpaceStyle:\\1" TNAME ${TEST})
add_test(NAME ${TNAME} COMMAND test_pair_style ${TEST} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};PYTHONPATH=${TEST_INPUT_FOLDER}:$ENV{PYTHONPATH}")
endforeach()

View File

@ -0,0 +1,86 @@
---
lammps_version: 21 Jul 2020
date_generated: Thu Aug 6 17:51:49 202
epsilon: 5e-14
prerequisites: ! |
atom full
pair python
pair coul/cut
pre_commands: ! ""
post_commands: ! ""
input_file: in.fourmol
pair_style: hybrid/overlay python 8.0 coul/cut 8.0
pair_coeff: ! |
* * coul/cut
* * python py_pot.LJCutFourMol 1 2 3 4 5
extract: ! ""
natoms: 29
init_vdwl: 769.435514792906
init_coul: -127.494586297384
init_stress: ! |2-
2.2678521911648518e+03 2.2247029630324569e+03 4.6668446509523028e+03 -7.1863043563709800e+02 6.6980305204573611e+01 6.6425623166019000e+02
init_forces: ! |2
1 -2.1092536751550838e+01 2.6988677795023693e+02 3.3315514703940988e+02
2 1.5859536284564558e+02 1.2807632081425649e+02 -1.8817302517163134e+02
3 -1.3530447776924242e+02 -3.8712937312564111e+02 -1.4565930021258393e+02
4 -7.8195508850233653e+00 2.1451963411659398e+00 -5.9041093605223853e+00
5 -2.9163771925406858e+00 -3.3469125795767778e+00 1.2074702271995733e+01
6 -8.2989064299109634e+02 9.6019333702746019e+02 1.1479368263554798e+03
7 5.7874599781327063e+01 -3.3534004899782047e+02 -1.7140666690005282e+03
8 1.4280515483302037e+02 -1.0509296835736738e+02 4.0233508916791158e+02
9 8.0984848509892984e+01 7.9600538879323949e+01 3.5197304953971440e+02
10 5.3089519971967525e+02 -6.0998490011292904e+02 -1.8376196110683102e+02
11 -3.3416542206126132e+00 -4.7793094014847872e+00 -1.0199052646182798e+01
12 2.0837669615663014e+01 9.8677112061723466e+00 -6.6548625608899110e+00
13 7.7163470869739150e+00 -3.2214585431240983e+00 -1.5772894334856402e-01
14 -4.6138099616924144e+00 1.1335989789523175e+00 -8.7660667871438278e+00
15 1.6301595500784468e-02 8.3212536519398910e+00 2.0473947103296677e+00
16 4.6221177665093472e+02 -3.3124468350620072e+02 -1.1865043968493005e+03
17 -4.5568762681260193e+02 3.2159241984961085e+02 1.1980753651190116e+03
18 1.2559123433128396e+00 6.6416960179537519e+00 -9.8828717188206667e+00
19 1.6184520957282682e+00 -1.6594111991037446e+00 5.6561124623691912e+00
20 -3.4526823182395812e+00 -3.1794193851328325e+00 4.2593067040140813e+00
21 -8.2751185858113629e+01 -9.5732287273212279e+01 2.5857356387351263e+02
22 -1.2725419712336426e+02 -3.0130047541865601e+01 -1.9525589883951992e+02
23 2.0949658126542045e+02 1.2461209659837752e+02 -6.2786639875874371e+01
24 4.1172843757271806e+01 -2.4243394722584179e+02 1.3127488363630286e+02
25 -1.7332727360429820e+02 2.5369868228593855e+01 -1.4477978328562156e+02
26 1.3122739460428667e+02 2.1617804360406279e+02 1.4617746318771184e+01
27 5.8858131514524516e+01 -2.5934658519982310e+02 1.0378659589349859e+02
28 -2.1004851662389484e+02 8.7061736878465183e+01 -1.4131944246679177e+02
29 1.5193395589309270e+02 1.7194075642255194e+02 3.8106025733269696e+01
run_vdwl: 145.774836401433
run_coul: -142.001672647389
run_stress: ! |2-
5.9383525774485156e+02 6.0808146948988235e+02 4.3447102407954065e+02 -3.1367656108012937e+02 -3.3473859201760604e+01 1.2397858084799522e+02
run_forces: ! |2
1 1.4832995973686170e+01 7.9776687213625252e+01 6.1502475376960476e+01
2 1.9653644405660430e+01 1.2276384921396586e+01 -2.5616350279108055e+01
3 -2.4593229040543631e+02 1.0324817388734876e+02 8.5000613152551139e+01
4 -8.7492562881244140e+00 3.2814846537200122e+00 -6.5557432751371865e+00
5 -2.2193986160004506e+00 -1.8736682348780977e+00 1.0432132523702611e+01
6 1.1567651108409385e+02 -9.9327087024067481e+01 -1.4166521367866525e+02
7 4.0383302895685285e+00 -1.0438666847173314e+01 -4.1479991151179689e+01
8 -2.0195494612421022e+01 2.2750024345139270e+01 5.6630890758924743e+01
9 1.3863634324490205e+01 6.0273384530541829e+00 5.3346856258210913e+01
10 6.4071029621033190e+01 -7.5538706154994941e+01 -7.5482377594635125e+01
11 -7.3938990739669297e+00 -6.6541891823595511e+00 -1.6954609981462021e+01
12 1.7782670476115754e+01 1.1436818682806711e+01 -6.8461323924619544e+00
13 7.0142523732388282e+00 -2.7743547704825042e+00 -2.2972569037802196e-01
14 -4.3951111547271191e+00 8.9351928590546470e-01 -7.0768324366602169e+00
15 -3.5776161647673893e-01 7.7391165764571905e+00 2.0440411346847966e+00
16 5.2356125055814530e+01 -6.8461465060623581e+01 1.4548920682036552e+01
17 -1.8339663864786544e+01 1.7659748258170925e+01 3.5971402502023636e+01
18 1.7393982522053547e-01 7.1073524680869795e+00 -8.1841236137870848e+00
19 2.0603004385900459e+00 -2.0735217551082559e+00 5.3320473022271813e+00
20 -3.2409845658166634e+00 -3.2645830355908463e+00 3.4324196803320355e+00
21 -8.1437559216355577e+00 -1.1349332196095922e+01 3.1674737849067995e+01
22 -1.7185201896219699e+01 -3.0425686380379369e+00 -2.4510915216827922e+01
23 2.4562355825010041e+01 1.3401421455896168e+01 -6.2894741072227554e+00
24 9.9751672213715388e+00 -2.8727909978269032e+01 2.2125945151340339e+01
25 -2.7882046939224672e+01 4.7174965096460877e+00 -2.2641592997635790e+01
26 1.5893787897689318e+01 2.4691263883074651e+01 1.0754239197674487e+00
27 1.4348611082706770e+00 -3.1909073783329251e+01 8.3825805242462721e+00
28 -2.1199284731841054e+01 8.0433746282727565e+00 -1.4196288516485287e+01
29 2.1844543766823431e+01 2.2384921438409787e+01 6.2288841155702457e+00
...

View File

@ -0,0 +1,84 @@
---
lammps_version: 21 Jul 2020
date_generated: Thu Aug 6 17:43:06 202
epsilon: 5e-14
prerequisites: ! |
atom full
pair python
pre_commands: ! ""
post_commands: ! ""
input_file: in.fourmol
pair_style: python 8.0
pair_coeff: ! |
* * py_pot.LJCutFourMol 1 2 3 4 5
extract: ! ""
natoms: 29
init_vdwl: 769.435514792906
init_coul: 0
init_stress: ! |2-
2.2946767381998088e+03 2.2678657381365460e+03 4.7243519151106429e+03 -7.1780988470145303e+02 7.4887575310966838e+01 6.6120102245877695e+02
init_forces: ! |2
1 -2.3333270280520782e+01 2.6994569437149914e+02 3.3272846064087634e+02
2 1.5828556356053875e+02 1.3025009039207578e+02 -1.8629678439291678e+02
3 -1.3528896794414970e+02 -3.8704310820833763e+02 -1.4568966779027681e+02
4 -7.8711065716056430e+00 2.1350514397069378e+00 -5.5954482385159006e+00
5 -2.5176574570051140e+00 -4.0521433317259099e+00 1.2152724590018760e+01
6 -8.3190663317166161e+02 9.6394164822795153e+02 1.1509102200593500e+03
7 5.8203450078528753e+01 -3.3609017296225795e+02 -1.7179625636751625e+03
8 1.4451394464402489e+02 -1.0927477621526437e+02 3.9990606645456256e+02
9 7.9156947434424282e+01 8.5273028784047639e+01 3.5032178044455560e+02
10 5.3118883961711572e+02 -6.1041002287850051e+02 -1.8355878726411987e+02
11 -2.3529706313965852e+00 -5.9077974372794309e+00 -9.6590949174142544e+00
12 1.7527250635128208e+01 1.0632931502183142e+01 -7.9255166790323432e+00
13 8.0986627188072777e+00 -3.2098926765474505e+00 -1.4901493314069347e-01
14 -3.3852521414277610e+00 6.8632949514631936e-01 -8.7507255016682191e+00
15 -2.0454999138132079e-01 8.4846157963955502e+00 3.0131699393822955e+00
16 4.6326335285928650e+02 -3.3087739742650905e+02 -1.1893031570576952e+03
17 -4.5334337404302812e+02 3.1554294172701657e+02 1.2058423549610932e+03
18 -1.8858386892154754e-02 -3.3413105589439551e-02 3.1031226584135881e-02
19 3.1903169470539515e-04 -2.3995298954361947e-04 1.7429914758179997e-03
20 -9.9753030064454588e-04 -1.0201208350586722e-03 3.6991953349520496e-04
21 -8.5242126636463254e+01 -9.7217080102121798e+01 2.6907710993670577e+02
22 -1.2875154769344783e+02 -3.1201315874597551e+01 -2.0199729243095209e+02
23 2.1398315790012467e+02 1.2843060575040113e+02 -6.7068408131976952e+01
24 4.3592624416079701e+01 -2.5230268792156562e+02 1.3363345473702583e+02
25 -1.7690767587278992e+02 2.8477944982261260e+01 -1.4872562964423125e+02
26 1.3330257356659547e+02 2.2381326293485043e+02 1.5068270996853208e+01
27 6.1705671019807909e+01 -2.7045854429300255e+02 1.0821183331233215e+02
28 -2.1489493703146951e+02 9.2352775183519000e+01 -1.4540033260735669e+02
29 1.5319756790138297e+02 1.7811269192006952e+02 3.7183833054110600e+01
run_vdwl: 144.99121733439
run_coul: 0
run_stress: ! |2-
6.1910947424358005e+02 6.6812349898828040e+02 4.8166005669601208e+02 -3.2243037433905363e+02 -3.1553495127500625e+01 1.2293864137610495e+02
run_forces: ! |2
1 1.2964191381427986e+01 8.0892463766898743e+01 6.0323463721142069e+01
2 1.8550239926888143e+01 1.4016238728353951e+01 -2.2757489148001437e+01
3 -2.4823730089528280e+02 1.0508783069196251e+02 8.6172505981756643e+01
4 -8.6006869865351767e+00 3.1744189165443339e+00 -6.2092108081116582e+00
5 -1.7308191055169313e+00 -2.5575674947797902e+00 1.0273486422902376e+01
6 1.1683405293890358e+02 -9.8726786219094180e+01 -1.4208733055613467e+02
7 3.8041958263985713e+00 -1.0704991988460705e+01 -4.2399846201367069e+01
8 -1.9935762534695186e+01 1.9886759828526795e+01 5.5348231962077570e+01
9 1.1205808704436020e+01 1.3198959164683011e+01 4.9879862371149436e+01
10 6.4812569038175369e+01 -7.6375096178338595e+01 -7.5660183712959508e+01
11 -6.2988185446946430e+00 -8.0952950149914233e+00 -1.6391435626117183e+01
12 1.4369525712683764e+01 1.2193091004148052e+01 -8.2528580195976922e+00
13 7.3377287957067914e+00 -2.7955925311462675e+00 -1.0304162098803582e-01
14 -2.7952228613619492e+00 4.3885108338982148e-01 -7.1101066312581809e+00
15 -3.9779877100946709e-01 8.1105950563503288e+00 3.0711189972946089e+00
16 5.2787573015811034e+01 -6.7733680417848447e+01 1.5088112278617384e+01
17 -1.4633314393749638e+01 1.0014097705511523e+01 4.0800217361197326e+01
18 -1.8057970282348051e-02 -3.1590780148621544e-02 2.9639566122554754e-02
19 2.5586453211434333e-04 -2.4342393239688300e-04 1.6748438254610368e-03
20 -8.8290898809219689e-04 -9.1225710977274350e-04 3.6051894590879177e-04
21 -9.0304081561032916e+00 -1.1103433454817829e+01 3.6299916176334428e+01
22 -1.6981581435543042e+01 -4.0761763782947185e+00 -2.7498400714898658e+01
23 2.5999992597280002e+01 1.5193231067436271e+01 -8.7883538971483457e+00
24 1.1753997481833450e+01 -3.3680929542642666e+01 2.2223889003823036e+01
25 -2.7860155418603220e+01 5.1330896626531599e+00 -2.3967009562126073e+01
26 1.6092479124198338e+01 2.8535719425627722e+01 1.7172356582298487e+00
27 2.7712739453658171e+00 -3.6389758020369179e+01 1.0673782030059142e+01
28 -2.3268224624332859e+01 1.0849152796202816e+01 -1.5722447060249483e+01
29 2.0505150253057547e+01 2.5547554803685497e+01 5.0442166654802838e+00
...

View File

@ -0,0 +1,33 @@
from __future__ import print_function
class LAMMPSPairPotential(object):
def __init__(self):
self.pmap=dict()
self.units='lj'
def map_coeff(self,name,ltype):
self.pmap[ltype]=name
def check_units(self,units):
if (units != self.units):
raise Exception("Conflicting units: %s vs. %s" % (self.units,units))
class LJCutFourMol(LAMMPSPairPotential):
def __init__(self):
super(LJCutFourMol,self).__init__()
self.units='real'
self.coeff={'1': {'1': (57220.458984375, 117.1875, 4768.37158203125, 19.53125), '2': (396.00240328788755, 6.89349609375, 33.00020027399063, 1.148916015625), '3': (275682.72513361875, 257.2233543675, 22973.560427801563, 42.870559061250006), '4': (193062.6401184066, 200.31803764867476, 16088.553343200549, 33.38633960811246), '5': (219401.24669848208, 213.54552859539564, 18283.437224873505, 35.590921432565935)}, '2': {'1': (396.00240328788755, 6.89349609375, 33.00020027399063, 1.148916015625), '2': (0.24, 0.12, 0.02, 0.02), '3': (3530.7972054655893, 20.583869040000007, 294.2331004554658, 3.430644840000001), '4': (5.859375e-05, 0.001875, 4.8828125e-06, 0.0003125), '5': (2726.0378943788915, 16.831463637644212, 227.1698245315743, 2.8052439396073683)}, '3': {'1': (275682.72513361875, 257.2233543675, 22973.560427801563, 42.870559061250006), '2': (3530.7972054655893, 20.583869040000007, 294.2331004554658, 3.430644840000001), '3': (1106804.6444225737, 515.3960755200002, 92233.72036854782, 85.89934592000003), '4': (793466.3439000695, 406.10205934924875, 66122.19532500578, 67.68367655820813), '5': (889052.2891953762, 429.8674775516488, 74087.69076628136, 71.64457959194146)}, '4': {'1': (193062.6401184066, 200.31803764867476, 16088.553343200549, 33.38633960811246), '2': (5.859375e-05, 0.001875, 4.8828125e-06, 0.0003125), '3': (793466.3439000695, 406.10205934924875, 66122.19532500578, 67.68367655820813), '4': (567117.2043277561, 319.50132516, 47259.767027313, 53.250220860000006), '5': (636596.9403948045, 338.50767978151515, 53049.74503290038, 56.41794663025252)}, '5': {'1': (219401.24669848208, 213.54552859539564, 18283.437224873505, 35.590921432565935), '2': (2726.0378943788915, 16.831463637644212, 227.1698245315743, 2.8052439396073683), '3': (889052.2891953762, 429.8674775516488, 74087.69076628136, 71.64457959194146), '4': (636596.9403948045, 338.50767978151515, 53049.74503290038, 56.41794663025252), '5': (713801.551928242, 358.44703841304585, 59483.46266068683, 59.74117306884097)}}
def compute_force(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
r2inv = 1.0/rsq
r6inv = r2inv*r2inv*r2inv
lj1 = coeff[0]
lj2 = coeff[1]
return (r6inv * (lj1*r6inv - lj2))*r2inv
def compute_energy(self,rsq,itype,jtype):
coeff = self.coeff[self.pmap[itype]][self.pmap[jtype]]
r2inv = 1.0/rsq
r6inv = r2inv*r2inv*r2inv
lj3 = coeff[2]
lj4 = coeff[3]
return (r6inv * (lj3*r6inv - lj4))