# # MoleCuilder - creates and alters molecular systems # Copyright (C) 2017 Frederik Heber # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ### testing potential fitting from an MD simulation of water # perform test with PoolWorkers using molecuilder_poolworker AT_SETUP([Potential Fitting - water with harmonic bond and angle potential]) AT_KEYWORDS([fit-potential water harmonic_bond harmonic_angle]) # check that ports are unique over all tests such that they may run in parallel WORKERPORT=12300 CONTROLLERPORT=12301 WORKERLISTENPORT=12302 # start service in background ${AUTOTEST_PATH}/molecuilder_server --workerport $WORKERPORT --controllerport $CONTROLLERPORT --timeout 3 & server_pid=$! AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid]) AT_CHECK([kill -s 0 $server_pid], 0, [ignore], [ignore], [kill $server_pid]) # enlist a worker to work on jobs ../../molecuilder_poolworker -v 5 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & worker_script_pid=$! worker_pid=`ps -ef | grep molecuilder_poolworker | grep $worker_script_pid | awk '{print $2}'` AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) AT_CHECK([kill -s 0 $worker_pid], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) # create jobs via molecuilder molfile="water.pdb" outputfile="water.data" AT_CHECK([cp -f ${abs_top_srcdir}/tests/integration/PotentialFitting/pre/$molfile $molfile], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) AT_CHECK([chmod +rw $molfile], 0) AT_CHECK([../../molecuilder \ -i $molfile \ -o tremolo \ --set-tremolo-atomdata "Id type x=3 u=3 F=3 neighbors=2" \ --select-all-atoms \ --set-random-number-distribution "uniform_real" \ --random-number-distribution-parameters "min=0;max=1;" \ --set-random-number-engine "lagged_fibonacci607" \ --random-number-engine-parameters "seed=5;" \ --random-perturbation 0.1 \ --center-in-box "10,0,10,0,0,10" \ --set-boundary-conditions Wrap Wrap Wrap \ --update-molecules \ --set-parser-parameters mpqc \ --parser-parameters "theory=CLHF;basis=3-21G;" \ --molecular-dynamics \ --keep-bondgraph 1 \ --parse-state-files 0 \ --deltat 0.5 \ --steps 30 \ --order 1 \ --grid-level 4 \ --server-address 127.0.0.1 \ --server-port ${CONTROLLERPORT} \ --DoLongrange 0 \ --save-homologies water.homologies], 0, [stdout], [ignore], [kill $server_pid $worker_pid]) # send removeall to server such that all workers shutdown AT_CHECK([${AUTOTEST_PATH}/molecuilder_controller --server 127.0.0.1:$CONTROLLERPORT --command removeall], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) # check that worker is truely down AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $worker_pid $server_pid]) AT_CHECK([kill $worker_pid], 1, [ignore], [ignore], [kill $server_pid]) # shutdown controller socket AT_CHECK([${AUTOTEST_PATH}/molecuilder_controller --server 127.0.0.1:$CONTROLLERPORT --command shutdown], 0, [stdout], [ignore], [kill $server_pid]) # check that server is truely down AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid]) AT_CHECK([kill $server_pid], 1, [ignore], [ignore]) # NOTE that due the limited number of steps we will not get any good parameters # This is mostly a test whether save-homologies afte the MD works, we can parse in # all the steps we made (different configurations) and perform some potential to it. # fit potential harmonic_bond AT_CHECK([../../molecuilder \ --parse-homologies water.homologies \ --set-random-number-engine "lagged_fibonacci607" \ --random-number-engine-parameters "seed=1;" \ --set-random-number-distribution "uniform_real" \ --random-number-distribution-parameters "min=0;max=1;" \ --fit-potential \ --potential-type "harmonic_bond" \ --potential-charges 8 1 \ --fragment-charges 1 8 1 \ --set-threshold 6e-4 \ --save-potentials harmonic.potentials], 0, [stdout], [ignore], [kill $server_pid $worker_pid]) # check that L_2 error is below desired threshold AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 6e-4) exit 1}'], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) # check parameters to printed precision AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.22.*,.*equilibrium_distance=1.8.*;" harmonic.potentials], 0, [ignore], [ignore]) # fit potential harmonic_angle AT_CHECK([../../molecuilder \ --parse-homologies water.homologies \ --set-random-number-engine "lagged_fibonacci607" \ --random-number-engine-parameters "seed=1;" \ --set-random-number-distribution "uniform_real" \ --random-number-distribution-parameters "min=0;max=1;" \ --fit-potential \ --potential-type "harmonic_angle" \ --potential-charges 1 8 1 \ --fragment-charges 1 8 1 \ --set-threshold 4e-3 \ --save-potentials angle.potentials], 0, [stdout], [ignore], [kill $server_pid $worker_pid]) # check that L_2 error is below threshold AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 4e-3) exit 1}'], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) # check parameters to printed precision AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.03.*,.*equilibrium_distance=-0.3.*;" angle.potentials], 0, [ignore], [ignore]) AT_CLEANUP