PageRenderTime 63ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/lm7K/SRCbank/nc/test/test.nc

http://github.com/tkotani/ecalj
C Shell | 1663 lines | 1331 code | 208 blank | 124 comment | 191 complexity | 9896a7cdbbd85767f703e058bb554a6e MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. #!/bin/csh -f
  2. # This file is a shell script testing operation of noncollinear ASA package
  3. alias call 'set retcall = \!\!:2 ; set callarg = \!\!:3 ; goto \!\!:1'
  4. alias runjob 'set retcall = \!\!:1; set outfile = \!\!:2 ; set callarg = \!\!:3 ; goto runjob'
  5. alias runrdcmd 'set retcall = \!\!:1; set rdcmdfmt = \!\!:2 ; set outfile = \!\!:3 ; set callarg = \!\!:4 ; goto runrdcmd'
  6. alias findcmd 'set retcall = \!\!:1 ; set prog_cmd = \!\!:2 ; set path_name = \!\!:3 ; set make_path = \!\!:4 ; goto findcmd'
  7. alias query 'set retcall = \!\!:1 ; set retcall2 = \!\!:2 ; set callarg = \!\!:3 ; goto query'
  8. alias compare_res 'set retcall = \!\!:1; set keyword = \!\!:2 ; set testvar = \!\!:3 ; set refvar = \!\!:4 ; set tol = \!\!:5 ; set passvar = \!\!:6 ; goto compare_res'
  9. alias compare_res_0 'set retcall = \!\!:1; set keyword = \!\!:2 ; set testvar = \!\!:3 ; set tol = \!\!:4 ; set passvar = \!\!:5 ; goto compare_res_0'
  10. alias compare_resf 'set retcall = \!\!:1; set testvar = \!\!:2 ; set refvar = \!\!:3 ; set keyword = \!\!:4 ; set arg_number = \!\!:5 ; set occur_number = \!\!:6 ; set sed_strn = \!\!:7 ; goto compare_resf'
  11. alias cnvt_d_fmt 'set retcall = \!\!:1; set testvar = \!\!:2 ; set testval = \!\!:3 ; goto cnvt_d_fmt'
  12. set allargs = ($argv)
  13. set a
  14. set slow
  15. set testfile = $0
  16. set testdir = $testfile:h
  17. #set topdir = `cd $testdir/../..; pwd`
  18. set topdir = `$testdir/../../startup/absolute-path $testdir/../..`
  19. set maindir = $topdir/main
  20. set space = ' '
  21. set failed = 0
  22. alias zcat 'gunzip -c'
  23. set eojob
  24. # Prepend current working-directory, top-level dir and maindir to path
  25. set path = ($cwd $topdir $maindir $path)
  26. # --- Pick off switches ---
  27. while (`echo $1 | sed -e 's/\(.\).*/\1/' ` == "-")
  28. set arg1 = $1; shift
  29. if ($?verb) echo test.pgf: parsing switch $arg1
  30. switch ($arg1)
  31. case "--quiet":
  32. set quiet
  33. unset slow
  34. breaksw
  35. case "--clean":
  36. set clean
  37. breaksw
  38. case "--add0":
  39. set ladd0
  40. breaksw
  41. case "--no-iact*":
  42. unset slow
  43. breaksw
  44. case "--verb*":
  45. set verb = 1
  46. breaksw
  47. case "--all":
  48. echo " ... invoke $testdir/test.so for spin-orbit coupling checks ..."
  49. $testdir/test.so `echo $allargs | sed s/--all//g`
  50. set retval = $status
  51. echo " ... completed $testdir/test.so (spin-orbit coupling checks)"
  52. if ($retval != 0) then
  53. echo " $testfile : failed so tests ... aborting"
  54. exit -1
  55. endif
  56. set joblist
  57. while (`echo $1 | sed -e 's/\([0-9][0-9]*\)/-/'` == "-")
  58. set joblist = ($joblist $1)
  59. shift
  60. end
  61. set pass
  62. set failed
  63. $testfile `echo $allargs | sed s/--all//g | sed -e 's/\([0-9][0-9]*\)//g'` $joblist
  64. set retval = $status
  65. if ($retval != 0) then
  66. unset pass
  67. # set failed = ($failed $i)
  68. echo " $testfile : failed nc tests ... aborting"
  69. exit -1
  70. endif
  71. echo " ... $testfile : passed all checks (so, nc)"
  72. exit
  73. default:
  74. echo unrecognized switch $arg1
  75. goto usage
  76. endsw
  77. end
  78. set joblist = (`echo $argv | sed s/fe2//`)
  79. if ($#joblist == 0 ) set joblist = (1 2 3 4 5 6 7)
  80. echo $joblist | grep 1 >/dev/null
  81. if ($status) goto chk1e
  82. cat <<EOF
  83. --- Test case 1: 3k structure in fccfe ($testdir/ctrl.fccfe) ---
  84. Tests that equilibrium 3k structure is self-consistent.
  85. Test DESTROYS or overwrites *.fccfe
  86. EOF
  87. if ($?quiet) then
  88. else
  89. cat <<EOF
  90. Inspect input file for other magnetic structures to test.
  91. EOF
  92. endif
  93. set pass
  94. set refout=$testdir/out.fccfe.3k.equil.gz testout=out.fccfe
  95. echo ' '
  96. query chk11 chk1e 'run this test'
  97. chk11:
  98. # ... Look for executables
  99. findcmd chk11a rdcmd "$path" "$maindir"
  100. chk11a:
  101. findcmd chk11b lm "$path" "$topdir"
  102. chk11b:
  103. findcmd chk11c lmstr "$path" "$maindir"
  104. chk11c:
  105. echo "$space ... set up ASA strux and starting potential"
  106. echo "$space rm -f *.fccfe"
  107. rm -f *.fccfe
  108. if ($?clean) then
  109. echo "$space rm -f $testout"
  110. rm -f $testout
  111. goto chk1e
  112. endif
  113. echo "$space cp $testdir/ctrl.fccfe ."
  114. cp $testdir/ctrl.fccfe .
  115. runjob chk12 $testout "lmstr fccfe"
  116. chk12:
  117. runjob chk13 $testout "lm -vnit=0 -vsdyn=t --keepsignm fccfe --no-iactive"
  118. chk13:
  119. runjob chk14 $testout "lm -vnit=1 -vsdyn=t --keepsignm fccfe --no-iactive"
  120. chk14:
  121. echo "$space Program lm returned successfully."
  122. if ($?ladd0) then
  123. echo -n " ..." ; $testdir/add0 $testout
  124. endif
  125. set dq = `cat $testout | grep SV: | tail -1 | awk '{print $3}' | sed 's/D/e/'`
  126. awk '{if ($1 == "MAGTRQ:") {getline;{getline;if ($3*$3 > 1e-12) {exit -1}};{getline;if ($3*$3 > 1e-12) {exit -1}};{getline;if ($3*$3 > 1e-12) {exit -1}};{getline;if ($3*$3 > 1e-12) {exit -1}}}}' $testout
  127. set forcesmall = (! $status)
  128. if ($?quiet) then
  129. else
  130. echo ' '
  131. echo "$space ...show magnetic forces"
  132. awk '{if ($1 == "MAGTRQ:") {print;getline;print;getline;print;getline;print;getline;print;getline;print}}' $testout
  133. echo ' '
  134. call zdiffiles chk15 "CPU 1 $testout $refout"
  135. chk15:
  136. call showout chk15a SV
  137. chk15a:
  138. endif
  139. set refout=$testdir/out.fccfe.3k.ss.equil.gz testout=out.fccfe
  140. echo ' '
  141. echo "$space ... repeat, for 3k+SS"
  142. echo "$space rm -f *.fccfe"
  143. rm -f *.fccfe
  144. echo "$space cp $testdir/ctrl.fccfe ."
  145. cp $testdir/ctrl.fccfe .
  146. runjob chk16a $testout "lmstr fccfe"
  147. chk16a:
  148. runjob chk16b $testout "lm -vnit=0 fccfe -vqss=.5 --keepsignm -vsdyn=f fccfe --no-iactive"
  149. chk16b:
  150. runjob chk16c $testout "lm -vnit=1 fccfe -vqss=.5 --keepsignm -vsdyn=f fccfe --no-iactive"
  151. # runjob chk16c $testout "mpix -np=8 lm-MPIK -vmet=2 -vnit=1 fccfe -vqss=.5 --keepsignm -vsdyn=f fccfe --no-iactive"
  152. chk16c:
  153. echo "$space Program lm returned successfully."
  154. if ($?ladd0) then
  155. echo -n " ..." ; $testdir/add0 $testout
  156. endif
  157. set dqss = `cat $testout | grep SV: | tail -1 | awk '{print $3}' | sed 's/D/e/'`
  158. if ($?quiet) then
  159. else
  160. call showout chk18a SV
  161. chk18a:
  162. echo ' '
  163. call zdiffiles chk18 "CPU 1 $testout $refout"
  164. chk18:
  165. endif
  166. set refout=$testdir/out.fccfe.2ss.dnf.gz testout=out.fccfe
  167. echo ' '
  168. echo "$space ... Check ++-- spin structure using SS, downfolding Fe p orbitals"
  169. echo "$space rm -f *.fccfe"
  170. rm -f *.fccfe
  171. echo "$space cp $testdir/ctrl.fccfe ."
  172. cp $testdir/ctrl.fccfe .
  173. runjob chk19a $testout "lmstr fccfe -cstrx=2ss"
  174. chk19a:
  175. runjob chk19b $testout "lm -vnit=0 fccfe -vqss=0.5 -cstrx=2ss --keepsignm -vsdyn=f --iactiv=no -vnk=32 -vidxp=2"
  176. chk19b:
  177. # echo "$space cp a.fccfe a1.fccfe"
  178. # cp a.fccfe a1.fccfe
  179. # echo "$space cp a.fccfe a2.fccfe"
  180. # cp a.fccfe a2.fccfe
  181. runjob chk19c $testout "lm -vnit=1 fccfe -vqss=0.5 -cstrx=2ss --keepsignm -vsdyn=f --iactiv=no -vnk=32 -vidxp=2"
  182. # asa-soft-link-str fccfe
  183. # runjob chk19c $testout "mpix -np=8 lm-MPIK -vmet=2 -vnit=1 fccfe -vqss=0.5 -cstrx=2ss --keepsignm -vsdyn=f --iactiv=no -vnk=32 -vidxp=2"
  184. chk19c:
  185. echo "$space Program lm returned successfully."
  186. if ($?ladd0) then
  187. echo -n " ..." ; $testdir/add0 $testout
  188. endif
  189. set ehf2ss = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  190. set ehfref = `zcat $refout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  191. # set ehf2ss = `cat $testout | grep LM: | tail -1 | awk '{print $2}' | sed 's/ehf=//'`
  192. # set ehfref = `zcat $refout | grep LM: | tail -1 | awk '{print $2}' | sed 's/ehf=//'`
  193. set ehfref48 = -0.8884846
  194. set ediff = `echo $ehf2ss $ehfref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  195. set ediff48 = `echo $ehf2ss $ehfref48 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  196. if ($?quiet) then
  197. else
  198. echo " "
  199. echo "$space calculated harris energy = $ehf2ss"
  200. echo "$space compare to reference (32 divisions) $ehfref"
  201. echo "$space difference $ediff"
  202. echo "$space compare to reference (48 divisions) $ehfref48"
  203. echo "$space difference $ediff48"
  204. echo "$space NB: compare to total energy of ++-- spin configuration calculated from 4-atom structure (next test)"
  205. echo ' '
  206. call zdiffiles chk19d "CPU 1 $testout $refout"
  207. chk19d:
  208. endif
  209. set refout=$testdir/out.fccfe.4ss.dnf.gz testout=out.fccfe
  210. echo ' '
  211. echo "$space ... Check ++-- spin structure using 4-atom cell, downfolding Fe p orbitals."
  212. echo "$space Starting moments are identical to SS. Confirm that the 4-atom energy exactly doubles that"
  213. echo "$space of the 2-atom SS structure, and that the two are self-consistent in the same potential."
  214. echo "$space rm -f *.fccfe"
  215. rm -f *.fccfe
  216. echo "$space cp $testdir/ctrl.fccfe ."
  217. cp $testdir/ctrl.fccfe .
  218. runjob chk19e $testout "lmstr fccfe -cstrx=4ss"
  219. chk19e:
  220. runjob chk19f $testout "lm -vnit=0 fccfe -vqss=0.0 -cstrx=4ss --keepsignm -vsdyn=f --iactiv=no -vnk=32 -vidxp=2"
  221. chk19f:
  222. runjob chk19g $testout "lm -vnit=1 fccfe -vqss=0.0 -cstrx=4ss --keepsignm -vsdyn=f --iactiv=no -vnk=32 -vidxp=2"
  223. chk19g:
  224. echo "$space Program lm returned successfully."
  225. if ($?ladd0) then
  226. echo -n " ..." ; $testdir/add0 $testout
  227. endif
  228. set ehf4ss = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  229. set ehfref = `zcat $refout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  230. # set ehf4ss = `cat $testout | grep LM: | tail -1 | awk '{print $2}' | sed 's/ehf=//'`
  231. # set ehfref = `zcat $refout | grep LM: | tail -1 | awk '{print $2}' | sed 's/ehf=//'`
  232. set ehfref48 = -1.7769874
  233. set ediff4 = `echo $ehf4ss $ehfref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  234. set ediff48 = `echo $ehf4ss $ehfref48 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  235. if ($?quiet) then
  236. else
  237. echo " "
  238. echo "$space calculated harris energy = $ehf4ss"
  239. echo "$space compare to reference (32 divisions) $ehfref"
  240. echo "$space difference $ediff4"
  241. echo "$space compare to reference (48 divisions) $ehfref48"
  242. echo "$space difference $ediff48"
  243. echo "$space NB: last energy matches ++-- spin configuration calculated from 4ss structure"
  244. echo ' '
  245. call zdiffiles chk19h "CPU 1 $testout $refout"
  246. chk19h:
  247. endif
  248. # ... automatic pass checks
  249. chk1p:
  250. echo ' '
  251. call qprint chk1pa "$space ... automatic pass checks :"
  252. chk1pa:
  253. echo -n "$space rms dq (=$dq) < 1e-6 in 3k structure ? ... "
  254. if (`echo $dq | awk '{print ($1 < 1e-6)}'`) then
  255. echo yes
  256. else
  257. echo no
  258. unset pass
  259. endif
  260. echo -n "$space magnetic forces < 1e-6 in 3k structure ? ... "
  261. if ($forcesmall) then
  262. echo yes
  263. else
  264. echo no
  265. unset pass
  266. endif
  267. echo -n "$space rms dq (=$dqss) < 1e-6 in 3k+SS structure ? ... "
  268. if (`echo $dqss | awk '{print ($1 < 1e-6)}'`) then
  269. echo yes
  270. else
  271. echo no
  272. unset pass
  273. endif
  274. echo -n "$space difference in Harris energy for 2SS (=$ediff) < 2e-6 ? ... "
  275. if (`echo $ediff | awk '{print ($1 < 2e-6)}'`) then
  276. echo yes
  277. else
  278. echo no
  279. unset pass
  280. endif
  281. echo ' '
  282. if ($?pass) then
  283. echo "$space test 1 PASSED"
  284. else
  285. echo "$space test 1 FAILED"
  286. set failed = ($failed 1)
  287. endif
  288. chk1e:
  289. echo $joblist | grep 2 >/dev/null
  290. if ($status) goto chk2e
  291. cat <<EOF
  292. --- Test case 2: SD in 3k structure in fccfe ($testdir/ctrl.fccfe) ---
  293. Tests spin statics using sdmod=1 for 4 atoms/cell Fe.
  294. Test DESTROYS or overwrites *.fccfe.
  295. NB: the HF and HK energy functionals don't exactly agree because
  296. the atom potentials are artifically averaged (GRP2=1).
  297. EOF
  298. set eojob=chk2p sdmod=1 eulafile=eula.ran
  299. goto sdjob
  300. chk2p:
  301. if ($?clean) then
  302. goto chk2e
  303. endif
  304. echo ' '
  305. if ($?quiet) then
  306. else
  307. echo "$space ... automatic pass checks :"
  308. endif
  309. if ($?drmsqtol2 == 0) set drmsqtol2 = 1e-5
  310. compare_res chk2cb "last iter RMS dq" $dqn $dqnr $drmsqtol2 pass
  311. chk2cb:
  312. if ($?drmsetol2 == 0) set detol2 = 2e-6
  313. compare_res chk2cc "last iter ehf" $etest $eref $detol2 pass
  314. chk2cc:
  315. echo ' '
  316. if ($?pass) then
  317. echo "$space test 2 PASSED"
  318. else
  319. echo "$space test 2 FAILED"
  320. set failed = ($failed 2)
  321. endif
  322. chk2e:
  323. if ($eojob == "chk3p") goto chk3e
  324. if ($eojob == "chk4p") goto chk4e
  325. echo $joblist | grep 3 >/dev/null
  326. if ($status) goto chk3e
  327. cat <<EOF
  328. --- Test case 3: SD in 3k structure in fccfe ($testdir/ctrl.fccfe) ---
  329. Tests spin statics using sdmod=11 for 4 atoms/cell Fe.
  330. Test DESTROYS or overwrites *.fccfe
  331. NB: the HF and HK energy functionals don't exactly agree because
  332. the atom potentials are artifically averaged (GRP2=1).
  333. EOF
  334. set eojob=chk3p sdmod=11 eulafile=eula.ran
  335. goto sdjob
  336. chk3p:
  337. if ($?clean) then
  338. goto chk3e
  339. endif
  340. echo ' '
  341. if ($?quiet) then
  342. else
  343. echo "$space ... automatic pass checks :"
  344. endif
  345. if ($?drmsqtol3 == 0) set drmsqtol3 = 1e-5
  346. compare_res chk3cb "last iter RMS dq" $dqn $dqnr $drmsqtol3 pass
  347. chk3cb:
  348. if ($?drmsetol3 == 0) set detol3 = 1e-5
  349. compare_res chk3cc "last iter ehf" $etest $eref $detol3 pass
  350. chk3cc:
  351. echo ' '
  352. if ($?pass) then
  353. echo "$space test 3 PASSED"
  354. else
  355. echo "$space test 3 FAILED"
  356. set failed = ($failed 3)
  357. endif
  358. chk3e:
  359. echo $joblist | grep 4 >/dev/null
  360. if ($status) goto chk4e
  361. cat <<EOF
  362. --- Test case 4: SD in 3k structure in fccfe ($testdir/ctrl.fccfe) ---
  363. Tests spin statics using sdmod=1011 for 4 atoms/cell Fe.
  364. Test also uses l-dependent Euler angles.
  365. Test DESTROYS or overwrites *.fccfe
  366. EOF
  367. set eojob=chk4p sdmod=1011 eulafile=eula-l.ran
  368. goto sdjob
  369. chk4p:
  370. if ($?clean) then
  371. goto chk4e
  372. endif
  373. echo ' '
  374. if ($?quiet) then
  375. else
  376. echo "$space ... automatic pass checks :"
  377. endif
  378. if ($?drmsmtol4 == 0) set drmsmtol4 = 1e-5
  379. compare_res chk4cb "last iter RMS change in euler angles" $dmn $dmnr $drmsmtol4 pass
  380. chk4cb:
  381. if ($?drmsetol4 == 0) set detol4 = 1e-5
  382. compare_res chk4cc "last iter ehf" $etest $eref $detol4 pass
  383. chk4cc:
  384. echo ' '
  385. if ($?pass) then
  386. echo "$space test 4 PASSED"
  387. else
  388. echo "$space test 4 FAILED"
  389. set failed = ($failed 4)
  390. endif
  391. chk4e:
  392. echo $joblist | grep 5 >/dev/null
  393. if ($status) goto chk5e
  394. cat <<EOF
  395. --- Test case 5: Applied magnetic field ($testdir/ctrl.fe) ---
  396. Tests the application of an external magnetic field 4 atoms/cell Fe
  397. Test DESTROYS or overwrites *.fe
  398. See $testdir/Notes-testing-bfield for further checks.
  399. EOF
  400. set pass
  401. set refout=$testdir/out.fe.matchcoll.gz testout=out.fe
  402. echo ' '
  403. query chk51 chk5e 'run this test'
  404. chk51:
  405. # ... Look for executables
  406. findcmd chk51a rdcmd "$path" "$maindir"
  407. chk51a:
  408. findcmd chk51b lm "$path" "$topdir"
  409. chk51b:
  410. findcmd chk51c lmstr "$path" "$maindir"
  411. chk51c:
  412. echo "$space ... set up ASA strux and starting potential"
  413. echo "$space rm -f {ctrl,moms,wkp,site2,log,fe,fe2,eula,bfield,save,sdot,str,sv}.fe"
  414. rm -f {ctrl,moms,wkp,site2,log,fe,fe2,eula,bfield,save,sdot,str,sv}.fe
  415. if ($?clean) then
  416. echo "$space rm -f $testout"
  417. rm -f $testout
  418. goto chk5e
  419. endif
  420. echo "$space cp $testdir/{ctrl,site2}.fe ."
  421. cp $testdir/{ctrl,site2}.fe .
  422. runjob chk52a $testout "lmstr -vnit=0 fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=1 -vbf=1"
  423. chk52a:
  424. runjob chk52b $testout "lm -vnit=0 fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=1 -vbf=1"
  425. chk52b:
  426. echo ' '
  427. echo "$space ... Verify that collinear and noncollinear branches produce same result:"
  428. cat >eula.fe <<in
  429. .1 .2 .3
  430. .1 .2 .3
  431. in
  432. echo "$space using Euler angles file:"
  433. cat eula.fe
  434. runjob chk53a "$testout" "lm fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=0 -vbf=0 --quit=band"
  435. chk53a:
  436. runjob chk53b ">>$testout" "lm fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=1 -vbf=0 --quit=band"
  437. chk53b:
  438. set sumevc = `cat $testout | grep 'sumev=' | head -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  439. set sumev0 = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  440. set sumevr = `gunzip -c $refout | grep 'sumev=' | head -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  441. set ehf0 = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  442. set ehk0 = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  443. set ehfr = `gunzip -c $refout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  444. set ehkr = `gunzip -c $refout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  445. if (! $?quiet) then
  446. echo ' '
  447. echo "$space Magnetic moments from file $testout":
  448. $testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout
  449. endif
  450. set mz0 = `$testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout | awk '{if ($1 == "1") print $5}'`
  451. echo "$space collinear band structure energy = $sumevc"
  452. echo "$space noncollinear band structure energy = $sumev0"
  453. echo "$space reference band structure energy = $sumevr"
  454. set sevdiff = `echo $sumevc $sumevr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  455. echo "$space difference = $sevdiff"
  456. echo "$space noncollinear Harris energy = $ehf0"
  457. echo "$space reference Harris energy = $ehfr"
  458. set ehfdiff = `echo $ehf0 $ehfr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  459. echo "$space difference = $ehfdiff"
  460. echo "$space noncollinear Kohn-Sham energy = $ehk0"
  461. echo "$space reference Kohn-Sham energy = $ehkr"
  462. set ehkdiff = `echo $ehk0 $ehkr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  463. echo "$space difference = $ehkdiff"
  464. set ediff = `echo $ehf0 $ehk0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  465. echo "$space Harris - K-S difference = $ediff"
  466. echo ' '
  467. call qprint chk54a "$space ... automatic pass checks :"
  468. chk54a:
  469. set sevtol1 = 1e-6
  470. if ($?sevtol1 == 0) set sevtol1 = 1e-6
  471. echo -n "$space sumev within tol $sevtol1 of reference? ... "
  472. if (`echo $sumev0 $sumevr $sevtol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  473. echo yes
  474. else
  475. echo no
  476. unset pass
  477. endif
  478. set ehftol = 1e-6
  479. if ($?ehftol1 == 0) set ehftol1 = 1e-6
  480. echo -n "$space ehf within tol $ehftol1 of reference? ... "
  481. if (`echo $ehf0 $ehfr $ehftol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  482. echo yes
  483. else
  484. echo no
  485. unset pass
  486. endif
  487. call zdiffiles chk55a "CPU 1 $testout $refout"
  488. chk55a:
  489. # ... Stoner susceptibility
  490. set refout=$testdir/out.fe.stonerI.gz testout=out.fe
  491. echo ' '
  492. echo "$space ... Check longitudinal (Stoner susceptibility)"
  493. cat >eula.fe <<in
  494. 0 0 0
  495. 0 0 0
  496. in
  497. echo "$space using Euler angles file:"
  498. cat eula.fe
  499. cat >bfield.fe <<in
  500. 0 0 .001
  501. 0 0 0
  502. in
  503. echo "$space using B-field file:"
  504. cat bfield.fe
  505. gunzip -c $refout >$testout
  506. set mzref = `$testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout | awk '{if ($1 == "1") print $5}'`
  507. set sumevr = `cat $testout | grep 'sumev=' | head -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  508. set ehfr = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  509. set ehkr = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  510. runjob chk56a "$testout" "lm fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=1 -vbf=1 --quit=band"
  511. chk56a:
  512. set mz = `$testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout | awk '{if ($1 == "1") print $5}'`
  513. set sumev = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  514. set ehf = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  515. set ehk = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  516. if (! $?quiet) then
  517. echo ' '
  518. echo "$space Magnetic moments from file $testout":
  519. $testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout
  520. endif
  521. echo "$space noncollinear band structure energy = $sumev"
  522. echo "$space reference band structure energy = $sumevr"
  523. set sevdiff = `echo $sumev $sumevr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  524. echo "$space difference = $sevdiff"
  525. echo "$space noncollinear Harris energy = $ehf"
  526. echo "$space reference Harris energy = $ehfr"
  527. set ehfdiff = `echo $ehf $ehfr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  528. echo "$space difference = $ehfdiff"
  529. echo "$space noncollinear Kohn-Sham energy = $ehk"
  530. echo "$space reference Kohn-Sham energy = $ehkr"
  531. set ehkdiff = `echo $ehk $ehkr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  532. echo "$space difference = $ehkdiff"
  533. set ediff = `echo $ehf $ehk | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  534. echo "$space Harris - K-S difference = $ediff"
  535. echo "$space output moment on atom 1 = $mz"
  536. set mzdiff = `echo $mz $mz0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  537. echo "$space induced moment = M(B)-M(B=0) = $mzdiff"
  538. echo "$space reference output moment = $mzref"
  539. set mzdiff = `echo $mz $mzref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  540. echo "$space difference = $mzdiff"
  541. echo ' '
  542. call qprint chk57a "$space ... automatic pass checks :"
  543. chk57a:
  544. set sevtol1 = 1e-6
  545. if ($?sevtol1 == 0) set sevtol1 = 1e-6
  546. echo -n "$space sumev within tol $sevtol1 of reference? ... "
  547. if (`echo $sumev $sumevr $sevtol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  548. echo yes
  549. else
  550. echo no
  551. unset pass
  552. endif
  553. set ehftol = 1e-6
  554. if ($?ehftol1 == 0) set ehftol1 = 1e-6
  555. echo -n "$space ehf within tol $ehftol1 of reference? ... "
  556. if (`echo $ehf $ehfr $ehftol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  557. echo yes
  558. else
  559. echo no
  560. unset pass
  561. endif
  562. echo ' '
  563. call zdiffiles chk58a "CPU 1 $testout $refout"
  564. chk58a:
  565. # ... transverse susceptibility
  566. set refout=$testdir/out.fe.bfieldx.gz testout=out.fe
  567. echo ' '
  568. echo "$space ... Check transverse susceptibility"
  569. cat >eula.fe <<in
  570. 0 0 0
  571. 0 0 0
  572. in
  573. echo "$space using Euler angles file:"
  574. cat eula.fe
  575. cat >bfield.fe <<in
  576. .001 0 0
  577. 0 0 0
  578. in
  579. echo "$space using B-field file:"
  580. cat bfield.fe
  581. gunzip -c $refout >$testout
  582. set mzref = `$testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout | awk '{if ($1 == "1") print $3}'`
  583. set sumevr = `cat $testout | grep 'sumev=' | head -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  584. set ehfr = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  585. set ehkr = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  586. runjob chk59a "$testout" "lm fe --no-iactiv -vfile=2 -vnk=8 -vnl=3 -vnc=1 -vbf=1 --quit=band"
  587. chk59a:
  588. set mz = `$testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout | awk '{if ($1 == "1") print $3}'`
  589. set sumev = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"sumev=[^ ]*"); print substr($0,RSTART+6,RLENGTH-6)}'`
  590. set ehf = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  591. set ehk = `cat $testout | grep 'sumev=' | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  592. if (! $?quiet) then
  593. echo ' '
  594. echo "$space Magnetic moments from file $testout":
  595. $testdir/../../testing/extract-lines --quiet 'density matrix' "ehf=" 1 $testout
  596. endif
  597. echo "$space noncollinear band structure energy = $sumev"
  598. echo "$space reference band structure energy = $sumevr"
  599. set sevdiff = `echo $sumev $sumevr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  600. echo "$space difference = $sevdiff"
  601. echo "$space noncollinear Harris energy = $ehf"
  602. echo "$space reference Harris energy = $ehfr"
  603. set ehfdiff = `echo $ehf $ehfr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  604. echo "$space difference = $ehfdiff"
  605. echo "$space noncollinear Kohn-Sham energy = $ehk"
  606. echo "$space reference Kohn-Sham energy = $ehkr"
  607. set ehkdiff = `echo $ehk $ehkr | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  608. echo "$space difference = $ehkdiff"
  609. set ediff = `echo $ehf $ehk | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  610. echo "$space Harris - K-S difference = $ediff"
  611. echo "$space output moment on atom 1 = $mz"
  612. echo "$space output (induced) moment on atom 1 = $mz"
  613. echo "$space reference output moment = $mzref"
  614. set mzdiff = `echo $mz $mzref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  615. echo "$space difference = $mzdiff"
  616. echo ' '
  617. call qprint chk5aa "$space ... automatic pass checks :"
  618. chk5aa:
  619. set sevtol1 = 1e-6
  620. if ($?sevtol1 == 0) set sevtol1 = 1e-6
  621. echo -n "$space sumev within tol $sevtol1 of reference? ... "
  622. if (`echo $sumev $sumevr $sevtol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  623. echo yes
  624. else
  625. echo no
  626. unset pass
  627. endif
  628. set ehftol = 1e-6
  629. if ($?ehftol1 == 0) set ehftol1 = 1e-6
  630. echo -n "$space ehf within tol $ehftol1 of reference? ... "
  631. if (`echo $ehf $ehfr $ehftol1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=$3)}'`) then
  632. echo yes
  633. else
  634. echo no
  635. unset pass
  636. endif
  637. echo ' '
  638. call zdiffiles chk5ba "CPU 1 $testout $refout"
  639. chk5ba:
  640. echo ' '
  641. if ($?pass) then
  642. echo "$space test 5 PASSED"
  643. else
  644. echo "$space test 5 FAILED"
  645. set failed = ($failed 5)
  646. endif
  647. chk5e:
  648. echo $joblist | grep 6 >/dev/null
  649. if ($status) goto chk6e
  650. set ext = fe2
  651. cat <<EOF
  652. --- Test case 6: Exchange interactions ---
  653. Makes a small rotation of a spin in the presence of an external
  654. constraining field to zero out the d component of the spin density
  655. matrix. Calculation compared to rotation in the absence of
  656. constraining field. NB: a careful calculation would need to
  657. pay attention to k-point convergence.
  658. EOF
  659. if ($ext == "fe2") then
  660. cat <<EOF
  661. Test case Fe2 consists of 2 Fe atoms (simple cubic unit cell).
  662. One atom is rotated by -theta/2 about z; the other is rotated by theta/2.
  663. Constraining field is taken to be along x axis.
  664. EOF
  665. endif
  666. set pass
  667. set refout=$testdir/out.$ext.coll.gz testout=out.$ext
  668. if (! -e $refout) then
  669. echo "$space ... skipping test : missing reference file $refout"
  670. goto chk6e
  671. endif
  672. echo ' '
  673. query chk61 chk6e 'run this test'
  674. chk61:
  675. # ... Look for executables
  676. findcmd chk61a rdcmd "$path" "$maindir"
  677. chk61a:
  678. findcmd chk61b lm "$path" "$topdir"
  679. chk61b:
  680. findcmd chk61c lmstr "$path" "$maindir"
  681. chk61c:
  682. findcmd chk61d rdfile "$path" "no"
  683. chk61d:
  684. if ("$found" == "no") then
  685. echo "$space ... no rdfile in path ... skipping test"
  686. goto chk6e
  687. endif
  688. echo "$space ... set up ASA strux and starting potential"
  689. echo "$space rm -f {a,a2,eula0,b0,ctrl,site2,mixm,moms,log,wkp,bfield,eula,save,sdot,str,sv}.$ext"
  690. rm -f {a,a2,eula0,b0,ctrl,site2,mixm,moms,log,wkp,bfield,eula,save,sdot,str,sv}.$ext
  691. if ($?clean) then
  692. echo "$space rm -f $testout"
  693. rm -f $testout
  694. goto chk6e
  695. endif
  696. echo "$space cp $testdir/{eula0,b0,ctrl,site2}.$ext ."
  697. cp $testdir/{eula0,b0,ctrl,site2}.$ext .
  698. echo "$space ... generate total energy for collinear case"
  699. runrdcmd chk62a %11f $testout "-cat:JOBCOLL --noerr ctrl.$ext"
  700. chk62a:
  701. echo -n "$space shortening output ... "
  702. echo "$topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext"
  703. $topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext
  704. call zdiffiles chk62b "CPU 2 $testout $refout"
  705. chk62b:
  706. set ehf0ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  707. set ehk0ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  708. set ehf0 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  709. set ehk0 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  710. set ediffhk = `echo $ehk0 $ehk0ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  711. set ediffhf = `echo $ehf0 $ehf0ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  712. if (! $?quiet) then
  713. echo ' '
  714. echo "$space collinear ehk = $ehk0"
  715. echo "$space reference = $ehk0ref"
  716. echo "$space difference = $ediffhk"
  717. echo "$space collinear ehf = $ehf0"
  718. echo "$space reference = $ehf0ref"
  719. echo "$space difference = $ediffhf"
  720. echo ' '
  721. endif
  722. compare_res chk62c "ehk" $ehk0 $ehk0ref 1e-6 pass
  723. chk62c:
  724. compare_res chk62d "ehf" $ehf0 $ehf0ref 1e-6 pass
  725. chk62d:
  726. echo " "
  727. echo "$space ... rotation in the absence of constraining field"
  728. set refout=$testdir/out.$ext.nc1.gz
  729. echo "$space rm -f {a,a2,eula0,b0,ctrl,site2,mixm,log}.fe2"
  730. rm -f {a,a2,eula0,b0,ctrl,site2,mixm,log}.fe2
  731. echo "$space cp $testdir/{eula0,b0,ctrl,site2}.fe2 ."
  732. cp $testdir/{eula0,b0,ctrl,site2}.fe2 .
  733. runrdcmd chk63a %11f $testout "-cat:JOBNC1 --noerr ctrl.$ext"
  734. chk63a:
  735. echo -n "$space shortening output ... "
  736. echo "$topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext"
  737. $topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext
  738. call zdiffiles chk63b "CPU 1 $testout $refout"
  739. chk63b:
  740. set ehf1ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  741. set ehk1ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  742. set ehf1 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  743. set ehk1 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  744. set ediffhk = `echo $ehk1 $ehk1ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  745. set ediffhf = `echo $ehf1 $ehf1ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  746. set mx1in = `$topdir/startup/catf -start:n=1:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 \*' | awk '{print $3}'`
  747. set mx1dout = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 2' | awk '{print $3}'`
  748. set mx1doutl = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 2' | awk '{print $6}'`
  749. set mx1out = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 \*' | awk '{print $3}'`
  750. zcat $refout >$testout{}~
  751. set rmx1in = `$topdir/startup/catf -start:n=1:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 \*' | awk '{print $3}'`
  752. set rmx1dout = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 2' | awk '{print $3}'`
  753. set rmx1doutl = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 2' | awk '{print $6}'`
  754. set rmx1out = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 \*' | awk '{print $3}'`
  755. rm $testout{}~
  756. if (! $?quiet) then
  757. echo "$space input Mx = $mx1in"
  758. echo "$space output Mx = $mx1out"
  759. echo "$space output Mx(d) = $mx1dout"
  760. echo "$space in loc. coord = $mx1doutl"
  761. echo "$space reference = $rmx1doutl"
  762. echo ' '
  763. echo "$space ehk = $ehk1"
  764. echo "$space reference = $ehk1ref"
  765. echo "$space difference = $ediffhk"
  766. echo "$space ehk-ehk(coll) = "`echo $ehk1 $ehk0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  767. echo ' '
  768. echo "$space ehf = $ehf1"
  769. echo "$space reference = $ehf1ref"
  770. echo "$space difference = $ediffhf"
  771. echo "$space ehf-ehf(coll) = "`echo $ehf1 $ehf0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  772. echo ' '
  773. endif
  774. compare_res chk63c "ehk" $ehk1 $ehk1ref 1e-6 pass
  775. chk63c:
  776. compare_res chk63d "ehf" $ehf1 $ehf1ref 1e-6 pass
  777. chk63d:
  778. compare_res chk63e "Mx" $mx1out $rmx1out 1e-5 pass
  779. chk63e:
  780. compare_res chk63f "d part of Mx, local coordinates" $mx1doutl $rmx1doutl 1e-5 pass
  781. chk63f:
  782. echo " "
  783. echo "$space ... rotation in the presence of constraining field"
  784. set refout=$testdir/out.$ext.nc3.gz
  785. echo "$space rm -f {a,a2,eula0,b0,ctrl,site2,mixm,log}.fe2"
  786. rm -f {a,a2,eula0,b0,ctrl,site2,mixm,log}.fe2
  787. echo "$space cp $testdir/{eula0,b0,ctrl,site2}.fe2 ."
  788. cp $testdir/{eula0,b0,ctrl,site2}.fe2 .
  789. runrdcmd chk64a %11f $testout "-cat:JOBNC3 --noerr ctrl.$ext"
  790. chk64a:
  791. echo -n "$space shortening output ... "
  792. echo "$topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext"
  793. $topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext
  794. call zdiffiles chk64b "CPU 1 $testout $refout"
  795. chk64b:
  796. set ehf3ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  797. set ehk3ref = `zcat $refout | grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  798. set ehf3 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehf=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  799. set ehk3 = ` cat $testout| grep ehf | tail -1 | awk '{match($0,"ehk=[^ ]*"); print substr($0,RSTART+4,RLENGTH-4)}'`
  800. set ediffhk = `echo $ehk3 $ehk3ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  801. set ediffhf = `echo $ehf3 $ehf3ref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  802. set mx3in = `$topdir/startup/catf -start:n=1:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 \*' | awk '{print $3}'`
  803. set mx3dout = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 2' | awk '{print $3}'`
  804. set mx3doutl = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 2' | awk '{print $6}'`
  805. set mx3out = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout | grep -E '1 \*' | awk '{print $3}'`
  806. zcat $refout >$testout{}~
  807. set rmx3in = `$topdir/startup/catf -start:n=1:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 \*' | awk '{print $3}'`
  808. set rmx3dout = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 2' | awk '{print $3}'`
  809. set rmx3doutl = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 2' | awk '{print $6}'`
  810. set rmx3out = `$topdir/startup/catf -start:n=2:s=AMAGNC -stop:rel:l=6 $testout{}~ | grep -E '1 \*' | awk '{print $3}'`
  811. rm $testout{}~
  812. if (! $?quiet) then
  813. echo "$space input Mx = $mx3in"
  814. echo "$space output Mx = $mx3out"
  815. echo "$space output Mx(d) = $mx3dout"
  816. echo "$space in loc. coord = $mx3doutl"
  817. echo "$space reference = $rmx3doutl"
  818. echo ' '
  819. echo "$space ehk = $ehk3"
  820. echo "$space reference = $ehk3ref"
  821. echo "$space difference = $ediffhk"
  822. echo "$space ehk-ehk(coll) = "`echo $ehk3 $ehk0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  823. echo "$space ehk-ehk(noB) = "`echo $ehk3 $ehk1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  824. echo ' '
  825. echo "$space ehf = $ehf3"
  826. echo "$space reference = $ehf3ref"
  827. echo "$space difference = $ediffhf"
  828. echo "$space ehf-ehf(coll) = "`echo $ehf3 $ehf0 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  829. echo "$space ehf-ehf(noB) = "`echo $ehf3 $ehf1 | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  830. echo ' '
  831. endif
  832. compare_res chk64c "ehk" $ehk3 $ehk3ref 1e-6 pass
  833. chk64c:
  834. compare_res chk64d "ehf" $ehf3 $ehf3ref 1e-6 pass
  835. chk64d:
  836. compare_res chk64e "Mx" $mx3out $rmx3out 1e-5 pass
  837. chk64e:
  838. compare_res chk64f "d part of Mx, local coordinates" $mx3doutl $rmx3doutl 1e-5 pass
  839. chk64f:
  840. if ($?pass) then
  841. echo "$space test 6 PASSED ($ext)"
  842. else
  843. echo "$space test 6 FAILED ($ext)"
  844. set failed = ($failed 6)
  845. endif
  846. chk6e:
  847. echo $joblist | grep 7 >/dev/null
  848. if ($status) goto chk7e
  849. set ext = er
  850. cat <<EOF
  851. --- Test case 7: noncollinear LDA+U hamiltonian ---
  852. EOF
  853. if ($ext == "er") then
  854. cat <<EOF
  855. Test Er compares a collinear, antiferromagnetic ASA LDA+U
  856. calculation in hcp Er (one spin up, the other down) to a
  857. two kinds of equivalent noncollinear calculations:
  858. 1. Moments are equal and opposite in sign.
  859. Spins are aligned parallel, but not along z.
  860. 2. Moments are equal and identical in sign.
  861. The spinor of the second atom is rotated 180 degrees about y
  862. to recover the AFM result.
  863. EOF
  864. endif
  865. set pass
  866. set testout=out.lm.{$ext}.coll refout=$testdir/out.lm.$ext.coll.gz
  867. if (! -e $refout) then
  868. echo "$space ... skipping test : missing reference file $refout"
  869. goto chk7e
  870. endif
  871. echo ' '
  872. query chk71 chk7e 'run this test'
  873. chk71:
  874. # ... Look for executables
  875. findcmd chk71a rdcmd "$path" "$maindir"
  876. chk71a:
  877. findcmd chk71b lm "$path" "$topdir"
  878. chk71b:
  879. findcmd chk71c lmstr "$path" "$maindir"
  880. chk71c:
  881. # findcmd chk71d rdfile "$path" "no"
  882. # chk71d:
  883. # if ("$found" == "no") then
  884. # echo "$space ... no rdfile in path ... skipping test"
  885. # goto chk7e
  886. # endif
  887. echo "$space ... set up ASA strux and starting potential"
  888. touch ctrl.$ext
  889. echo "$space rm -f *.$ext"
  890. rm -f *.$ext
  891. if ($?clean) then
  892. echo "$space rm -f out.lm.{$ext}.coll out.lm.{$ext}.nc1 out.lm.{$ext}.nc2 specialspec1 atparms"
  893. rm -f out.lm.{$ext}.coll out.lm.{$ext}.nc1 out.lm.{$ext}.nc2 specialspec1 atparms
  894. goto chk7e
  895. endif
  896. echo "$space cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 $testdir/atparms ."
  897. cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 $testdir/atparms .
  898. echo "$space cp $testdir/dmats.$ext.afm dmats.$ext"
  899. cp $testdir/dmats.$ext.afm dmats.$ext
  900. echo "$space cp $testdir/rsta.$ext.afm rsta.$ext"
  901. cp $testdir/rsta.$ext.afm rsta.$ext
  902. echo " "
  903. echo "$space ... AFM calculation, collinear case"
  904. runrdcmd chk72a %11f $testout "-cat:JOBCOLL --noerr ctrl.$ext"
  905. chk72a:
  906. # echo -n "$space shortening output ... "
  907. # echo "$topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext"
  908. # $topdir/startup/catf --x -start:n=2:s=SECMAT -stop:s=BZWTS out.$ext >out.$ext{}~; mv out.$ext{}~ out.$ext
  909. # call zdiffiles chk72b "CPU 2 $testout $refout"
  910. # chk72b:
  911. call zdiffiles chk7c9 "CPU -1 $testout $refout"
  912. chk7c9:
  913. compare_resf chk7c1 efc efcref "Fermi" 4 0 ";"
  914. chk7c1:
  915. compare_resf chk7c2 sevc sevcref "sumev=" 4 0 "sumev="
  916. chk7c2:
  917. compare_resf chk7c3 ehkc ehkcref "LM:" 3 0 "ehk="
  918. chk7c3:
  919. compare_resf chk7c4 amomc amomcref "ATOM=" 6 0 mom=
  920. chk7c4:
  921. compare_res chk7c5 "Fermi level" $efc $efcref 1e-6 pass
  922. chk7c5:
  923. compare_res chk7c6 "Mag. moment" $amomc $amomcref 1e-5 pass
  924. chk7c6:
  925. compare_res chk7c7 "sum of evals" $sevc $sevcref 1e-6 pass
  926. chk7c7:
  927. compare_res chk7c8 "ehk" $ehkc $ehkcref 1e-6 pass
  928. chk7c8:
  929. echo " "
  930. echo "$space ... Equivalent AFM calculation, both spins rotated by a common (random) angle (see site.$ext)"
  931. set testout=out.lm.{$ext}.nc1 refout=$testdir/out.lm.$ext.nc1.gz
  932. echo "$space rm -f *.$ext"
  933. rm -f *.$ext
  934. echo "$space cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 ."
  935. cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 .
  936. echo "$space cp $testdir/dmats.$ext.afm dmats.$ext"
  937. cp $testdir/dmats.$ext.afm dmats.$ext
  938. echo "$space cp $testdir/rsta.$ext.afm rsta.$ext"
  939. cp $testdir/rsta.$ext.afm rsta.$ext
  940. runrdcmd chk7r0 %11f $testout "-cat:JOBNC1 --noerr ctrl.$ext"
  941. chk7r0:
  942. call zdiffiles chk7r9 "CPU -1 $testout $refout"
  943. chk7r9:
  944. compare_resf chk7r1 efr efrref "Fermi" 4 0 ";"
  945. chk7r1:
  946. compare_resf chk7r2 sevr sevrref "sumev=" 4 0 "sumev="
  947. chk7r2:
  948. compare_resf chk7r3 ehkr ehkrref "LM:" 3 0 "ehk="
  949. chk7r3:
  950. compare_resf chk7r4 amomr amomrref "ATOM=" 6 0 mom=
  951. chk7r4:
  952. compare_resf chk7r4a Myr Myrref "<My>=" 2 0 "<My>="
  953. chk7r4a:
  954. compare_res chk7r5 "Fermi level" $efr $efrref 1e-6 pass
  955. chk7r5:
  956. compare_res chk7r6 "Mag. moment" $amomr $amomrref 1e-5 pass
  957. chk7r6:
  958. compare_res chk7r7 "sum of evals" $sevr $sevrref 1e-6 pass
  959. chk7r7:
  960. compare_res chk7r8 "ehk" $ehkr $ehkrref 1e-6 pass
  961. chk7r8:
  962. echo " "
  963. echo "$space ... AFM calculation by noncollinear rotation second spin through 180 degrees"
  964. set testout=out.lm.{$ext}.nc2 refout=$testdir/out.lm.$ext.nc2.gz
  965. echo "$space rm -f *.$ext"
  966. rm -f *.$ext
  967. echo "$space cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 ."
  968. cp $testdir/{ctrl,site,syml}.$ext $testdir/specialspec1 .
  969. echo "$space cp $testdir/dmats.$ext.nc2 dmats.$ext"
  970. cp $testdir/dmats.$ext.nc2 dmats.$ext
  971. echo "$space cp $testdir/rsta.$ext.nc2 rsta.$ext"
  972. cp $testdir/rsta.$ext.nc2 rsta.$ext
  973. echo "$space cp $testdir/site.$ext.nc2 site.$ext"
  974. cp $testdir/site.$ext.nc2 site.$ext
  975. runrdcmd chk7n0 %11f $testout "-cat:JOBNC1 --noerr ctrl.$ext"
  976. chk7n0:
  977. call zdiffiles chk7n9 "CPU -1 $testout $refout"
  978. chk7n9:
  979. compare_resf chk7n1 efn efnref "Fermi" 4 0 ";"
  980. chk7n1:
  981. compare_resf chk7n2 sevn sevnref "sumev=" 4 0 "sumev="
  982. chk7n2:
  983. compare_resf chk7n3 ehkn ehknref "LM:" 3 0 "ehk="
  984. chk7n3:
  985. compare_resf chk7n4 amomn amomnref "ATOM=" 6 0 mom=
  986. chk7n4:
  987. compare_resf chk7n4a Myn Mynref "<My>=" 2 0 "<My>="
  988. chk7n4a:
  989. if (! $?quiet) then
  990. echo ' '
  991. echo "$space ... The following numbers are extracted from the last iteration:"
  992. echo "$space collinear Fermi level = $efc"
  993. echo "$space rotated collinear Fermi level = $efr"
  994. echo "$space noncollinear Fermi level = $efn"
  995. echo "$space reference = $efnref"
  996. set diff = `echo $efn $efnref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  997. echo "$space difference = $diff"
  998. echo ' '
  999. echo "$space collinear Er mag. moment = $amomc"
  1000. echo "$space rotated collinear Er mag. moment = $amomr"
  1001. echo "$space noncollinear Er mag. moment = $amomn"
  1002. echo "$space reference = $amomnref"
  1003. set diff = `echo $amomn $amomnref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  1004. echo "$space difference = $diff"
  1005. echo ' '
  1006. echo "$space rotated collinear Er <My> = $Myr"
  1007. echo "$space noncollinear Er <My> = $Myn"
  1008. echo ' '
  1009. echo "$space collinear sum of evals = $sevc"
  1010. echo "$space rotated collinear sum of evals = $sevr"
  1011. echo "$space noncollinear sum of evals = $sevn"
  1012. echo "$space reference = $sevnref"
  1013. set diff = `echo $sevn $sevnref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  1014. echo "$space difference = $diff"
  1015. echo ' '
  1016. echo "$space collinear ehk = $ehkc"
  1017. echo "$space rotated collinear ehk = $ehkr"
  1018. echo "$space noncollinear ehk = $ehkn"
  1019. echo "$space reference = $ehknref"
  1020. set diff = `echo $ehkn $ehknref | awk '{{k=($1-$2)>0?($1-$2):($2-$1);} print k}'`
  1021. echo "$space difference = $diff"
  1022. echo ' '
  1023. endif
  1024. compare_res chk7n5 "Fermi level" $efn $efnref 1e-6 pass
  1025. chk7n5:
  1026. compare_res chk7n6 "Mag. moment" $amomn $amomnref 1e-5 pass
  1027. chk7n6:
  1028. compare_res chk7n7 "sum of evals" $sevn $sevnref 1e-6 pass
  1029. chk7n7:
  1030. compare_res chk7n8 "ehk" $ehkn $ehknref 1e-6 pass
  1031. chk7n8:
  1032. if ($?pass) then
  1033. echo "$space test 7 PASSED ($ext)"
  1034. else
  1035. echo "$space test 7 FAILED ($ext)"
  1036. set failed = ($failed 7)
  1037. endif
  1038. chk7e:
  1039. echo ' '
  1040. if ($#failed <= 1) then
  1041. echo "$space $testfile : all tests PASSED"
  1042. echo " "
  1043. exit 0
  1044. else
  1045. shift failed
  1046. echo "$space $testfile : These tests FAILED:" $failed
  1047. echo " "
  1048. exit -1
  1049. endif
  1050. # ---------------- sdjob --------------
  1051. # runs sd test for input $sdmod; returns to label eojob
  1052. exit
  1053. sdjob:
  1054. if ($?quiet) then
  1055. else
  1056. endif
  1057. set pass
  1058. set refout=$testdir/out.fccfe.3k.sdmod=$sdmod.gz testout=out.fccfe
  1059. echo ' '
  1060. query chk21 chk2e 'run this test'
  1061. chk21:
  1062. # ... Look for executables
  1063. findcmd chk21a rdcmd "$path" "$maindir"
  1064. chk21a:
  1065. findcmd chk21b lm "$path" "$topdir"
  1066. chk21b:
  1067. findcmd chk21c lmstr "$path" "$maindir"
  1068. chk21c:
  1069. echo "$space ... set up ASA strux and starting potential"
  1070. echo "$space rm -f *.fccfe"
  1071. rm -f *.fccfe
  1072. if ($?clean) then
  1073. echo "$space rm -f $testout"
  1074. rm -f $testout
  1075. goto $eojob
  1076. endif
  1077. echo "$space cp $testdir/ctrl.fccfe ."
  1078. cp $testdir/ctrl.fccfe .
  1079. echo "$space cp $testdir/$eulafile eula.fccfe"
  1080. cp $testdir/$eulafile eula.fccfe
  1081. runjob chk22 $testout "lmstr fccfe"
  1082. chk22:
  1083. runjob chk23 $testout "lm -vnit=0 -vsdyn=t --keepsignm fccfe --no-iactive"
  1084. chk23:
  1085. runjob chk24 $testout "lm -vmet=1 -vnk=5 -vnit=15 -vsdmod=$sdmod -vsdyn=t --keepsignm fccfe --no-iactive"
  1086. #asa-soft-link-str fccfe
  1087. #runjob chk24 $testout "mpix -np=9 lm-MPIK -vmet=3 -vnk=5 -vnit=15 -vsdmod=$sdmod -vsdyn=t --keepsignm fccfe --no-iactive"
  1088. chk24:
  1089. set dqn = `cat $testout | grep 'RMS DQ=' | grep 'file mq' | tail -1 | awk '{sub(".*RMS DQ=","");sub("last it=.*",""); print $0}'`
  1090. set dmn = `cat $testout | grep 'RMS DQ=' | grep 'file ma' | tail -1 | awk '{sub(".*RMS DQ=","");sub("last it=.*",""); print $0}'`
  1091. set dqnr = `zcat $refout | grep 'RMS DQ=' | grep 'file mq' | tail -1 | awk '{sub(".*RMS DQ=","");sub("last it=.*",""); print $0}'`
  1092. set dmnr = `zcat $refout | grep 'RMS DQ=' | grep 'file ma' | tail -1 | awk '{sub(".*RMS DQ=","");sub("last it=.*",""); print $0}'`
  1093. #set etest = `grep "LM: it" $testout | awk '{print substr($6,5)}' | tail -1`
  1094. #set eref = `gunzip -c $refout | grep "LM: it" | awk '{print substr($6,5)}' | tail -1`
  1095. set etest = `grep ' ehf= ' $testout | grep -v last | awk '{print $6}' | tail -1`
  1096. set eref = `gunzip -c $refout | grep ' ehf= ' | grep -v last | awk '{print $6}' | tail -1`
  1097. # if ($sdmod >= 1000) then
  1098. # set dq = `grep 'file ma' $testout | tail -1 | awk '{print substr($9,4)}'`
  1099. # set etest = `grep 'ehf=' $testout | tail -1 | awk '{print substr($2,5)}'`
  1100. # set eref = `gunzip -c $refout | grep ehf= | tail -1 | awk '{print substr($2,5)}'`
  1101. # endif
  1102. if ($?quiet) then
  1103. else
  1104. echo ' '
  1105. echo "$space rms difference output-input charge dq, last iteration = $dqn"
  1106. echo "$space rms change in euler angles dm, last iteration = $dmn"
  1107. echo "$space ehf, last iteration = $etest"
  1108. echo ' '
  1109. echo "$space Compare mag. forces 1st iteration to $refout"
  1110. cat $testout | awk '{if ($1 == "MAGTRQ:") {print;getline;print;getline;print;getline;print;getline;print;getline;print}}' | head -6
  1111. echo ---
  1112. gunzip -c $refout | awk '{if ($1 == "MAGTRQ:") {print;getline;print;getline;print;getline;print;getline;print;getline;print}}' | head -6
  1113. echo ' '
  1114. echo "$space Compare last iterations of SV line to file $refout"
  1115. cat $testout | grep SV: | tail -5
  1116. echo "---"
  1117. gunzip -c $refout | grep SV: | tail -5
  1118. chk28a:
  1119. echo ' '
  1120. echo "$space Compare last iterations of av. mag. to file $refout"
  1121. cat $testout | grep amagnc | tail -5
  1122. echo "---"
  1123. gunzip -c $refout | grep amagnc | tail -5
  1124. chk28b:
  1125. call showout chk28c CPU
  1126. chk28c:
  1127. echo ' '
  1128. call zdiffiles chk28d "CPU 1 $testout $refout"
  1129. chk28d:
  1130. endif
  1131. goto $eojob
  1132. # ---------------- runjob --------------
  1133. exit
  1134. runjob:
  1135. set quitjob=$retcall
  1136. if ($outfile == ".") then
  1137. echo "$space $callarg"
  1138. echo " "
  1139. $callarg
  1140. set retval = $status
  1141. if ($retval != 0) goto cleanup
  1142. goto $quitjob
  1143. endif
  1144. if (`echo $outfile | awk '{print substr($1,1,2)}'` == '>>') then
  1145. set appfile = `echo $outfile | awk '{print substr($1,3)}'`
  1146. echo "$space $callarg >> $appfile"
  1147. $callarg >> $appfile
  1148. set retval = $status
  1149. else
  1150. echo "$space $callarg > $outfile"
  1151. $callarg > $outfile
  1152. set retval = $status
  1153. endif
  1154. if ($retval != 0) goto cleanup
  1155. goto $quitjob
  1156. # ---------------- runrdcmd --------------
  1157. exit
  1158. runrdcmd:
  1159. set quitjob=$retcall
  1160. if ($outfile == ".") then
  1161. $rdcmd -f:$rdcmdfmt $callarg
  1162. set retval = $status
  1163. echo ' '
  1164. if ($retval == 0) then
  1165. echo "$space Job(s) completed successfully"
  1166. goto $quitjob
  1167. endif
  1168. else
  1169. if (`echo $outfile | awk '{print substr($1,1,2)}'` == '>>') then
  1170. set appfile = `echo $outfile | awk '{print substr($1,3)}'`
  1171. echo "$space $callarg >> $appfile"
  1172. exit
  1173. # $callarg >> $appfile
  1174. set retval = $status
  1175. else
  1176. echo "$space Invoking rdcmd will execute the following job(s):"
  1177. $rdcmd -f:$rdcmdfmt --n $callarg
  1178. echo "$space $rdcmd '-f:#rdcmd:%2f' $callarg >& $outfile"
  1179. $rdcmd '-f:rdcmd:%2f' $callarg >& $outfile
  1180. set retval = $status
  1181. endif
  1182. endif
  1183. if ($retval == 0) then
  1184. echo "$space Job(s) completed successfully; output in $outfile"
  1185. if ($?ladd0) then
  1186. echo -n " ..." ; $testdir/add0 $testout
  1187. endif
  1188. goto $quitjob
  1189. else
  1190. echo "$space ...oops... the following command returned with nonzero exit status:"
  1191. echo -n "$space "
  1192. grep rdcmd: $outfile | tail -1 | sed 's/rdcmd: //'
  1193. goto cleanup
  1194. endif
  1195. # ---------------- cleanup --------------
  1196. exit
  1197. cleanup:
  1198. if ($retval != 0) echo "$space job returned with error status $retval"
  1199. if ($retval != 0) echo "$space ... $testfile aborting"
  1200. exit $retval
  1201. # ---------------- compare_res --------------
  1202. # Compares two numbers $testvar-$refvar and unsets $passvar if |testvar-refvar|<tol
  1203. # usage: compares_res retcall keyword testvar refvar tol passvar
  1204. # keyword : label (for printout)
  1205. # testvar : first number
  1206. # refvar : second number
  1207. # tol : tolerance
  1208. # passvar : $passvar is unset if |testvar-refvar|<tol
  1209. exit
  1210. compare_res:
  1211. set quitjob=$retcall
  1212. # echo $retcall $keyword $testvar $refvar $tol $passvar
  1213. echo -n "$space $keyword ($testvar) within tol ($tol) of reference ($refvar)? ... "
  1214. if (`echo $testvar $refvar | awk -v tol=$tol '{{k=($1-$2)>0?($1-$2):($2-$1);} print (k<=tol)}'`) then
  1215. echo yes
  1216. else
  1217. echo no
  1218. unset $passvar
  1219. endif
  1220. goto $quitjob
  1221. # ---------------- compare_res_0 --------------
  1222. # Compares a number $testvar and unsets $passvar if |testvar|<tol
  1223. # usage: compares_res_0 retcall keyword testvar tol passvar
  1224. # keyword : label (for printout)
  1225. # testvar : first number
  1226. # tol

Large files files are truncated, but you can click here to view the full file