296
302
"Run directory CO_GS\n",
297
303
"Executing command: mpirun -np 4 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n rmult:8.0 -s Yes\n"
309
"{0: <BigDFT.Logfiles.Logfile instance at 0x7fdac7d69368>,\n",
310
" 1: <BigDFT.Logfiles.Logfile instance at 0x7fda93752cb0>,\n",
311
" 2: <BigDFT.Logfiles.Logfile instance at 0x7fda936bffc8>,\n",
312
" 3: <BigDFT.Logfiles.Logfile instance at 0x7fdac41bfef0>}"
315
"execution_count": 26,
317
"output_type": "execute_result"
302
"# DIFFERENCE BETWEEN RUN AND PROCESS_RUN????\n",
303
"results = study.run()"
308
"execution_count": 14,
312
"# why does not use OMP_NUM_THREADS=2????????"
319
"Results is a dictionary that contains as key the cardinal value of the appended run and as value the instance of the log class of the associated computation"
324
"execution_count": 15,
325
"cell_type": "markdown",
328
"The class member study.results contain a dictionary with the logfiles of the computations performed by the run method. The cardinal key respects the order of the append_run"
333
"execution_count": 30,
330
"{0: <BigDFT.Logfiles.Logfile instance at 0x7f0e3bd59830>,\n",
331
" 1: <BigDFT.Logfiles.Logfile instance at 0x7f0e07725248>,\n",
332
" 2: <BigDFT.Logfiles.Logfile instance at 0x7f0e07b68440>,\n",
333
" 3: <BigDFT.Logfiles.Logfile instance at 0x7f0e381af908>}"
339
"{0: <BigDFT.Logfiles.Logfile instance at 0x7fdac7d69368>,\n",
340
" 1: <BigDFT.Logfiles.Logfile instance at 0x7fda93752cb0>,\n",
341
" 2: <BigDFT.Logfiles.Logfile instance at 0x7fda936bffc8>,\n",
342
" 3: <BigDFT.Logfiles.Logfile instance at 0x7fdac41bfef0>}"
336
"execution_count": 15,
345
"execution_count": 30,
338
347
"output_type": "execute_result"
351
"results = study.results\n",
909
"execution_count": 3,
915
"inp=I.Inputfile({'dft': {'rmult': [3,8]}})"
920
"execution_count": 4,
927
"output_type": "stream",
929
"Initialize a Calculator with OMP_NUM_THREADS=2 and command mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft\n"
934
"code=C.SystemCalculator(omp=2,mpi_run='mpirun -np 2')"
939
"execution_count": 5,
945
"<module 'BigDFT.Datasets' from '/home/marco/Applications/BigDFT/binaries/v1.8.3/install/lib/python2.7/site-packages/BigDFT/Datasets.pyc'>"
948
"execution_count": 5,
950
"output_type": "execute_result"
959
"execution_count": 6,
963
"study=D.Dataset(label='CO',run_dir='CO',posinp=CO)"
968
"execution_count": 7,
972
"inp.set_rmult(coarse=3)\n",
973
"study.append_run(id={'crmult': 3}, runner= code, input=inp,skip=False)\n",
974
"inp.set_rmult(coarse=4)\n",
975
"study.append_run(id={'crmult': 4}, runner= code, input=inp)\n",
976
"inp.set_rmult(coarse=5)\n",
977
"study.append_run(id={'crmult': 5}, runner= code, input=inp)"
982
"execution_count": 8,
986
"code.update_global_options(skip=False)"
991
"execution_count": 9,
996
"output_type": "stream",
998
"Creating the yaml input file \"CO/crmult:3.yaml\"\n",
999
"Run directory CO\n",
1000
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n crmult:3\n",
1001
"Creating the yaml input file \"CO/crmult:4.yaml\"\n",
1002
"Run directory CO\n",
1003
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n crmult:4\n",
1004
"Creating the yaml input file \"CO/crmult:5.yaml\"\n",
1005
"Run directory CO\n",
1006
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n crmult:5\n"
1015
"cell_type": "code",
1016
"execution_count": 10,
1022
"[-21.611635946132814, -21.64835568408899, -21.651311269276533]"
1025
"execution_count": 10,
1027
"output_type": "execute_result"
1031
"study.fetch_results(attribute='energy')"
1035
"cell_type": "code",
1036
"execution_count": 11,
1041
"output_type": "stream",
1043
"{'run_dir': 'CO', 'input': {'dft': {'rmult': [3, 8.0]}}, 'posinp': {'units': 'angstroem', 'positions': [{'C': [0.0, 0.0, 0.0], 'sym': 'C'}, {'O': [0.0, 0.0, 1.1282], 'sym': 'O'}], 'global monopole': 0.0}, 'skip': False, 'label': 'CO'}\n",
1045
"{'run_dir': 'CO', 'input': {'dft': {'rmult': [4, 8.0]}}, 'posinp': {'units': 'angstroem', 'positions': [{'C': [0.0, 0.0, 0.0], 'sym': 'C'}, {'O': [0.0, 0.0, 1.1282], 'sym': 'O'}], 'global monopole': 0.0}, 'label': 'CO'}\n",
1047
"{'run_dir': 'CO', 'input': {'dft': {'rmult': [5, 8.0]}}, 'posinp': {'units': 'angstroem', 'positions': [{'C': [0.0, 0.0, 0.0], 'sym': 'C'}, {'O': [0.0, 0.0, 1.1282], 'sym': 'O'}], 'global monopole': 0.0}, 'label': 'CO'}\n",
1053
"for d in range(len(study.runs)):\n",
1054
" print study.runs[d]\n",
1055
" print study.results[d].energy"
1059
891
"cell_type": "markdown",
1062
"# Polarizability tensor of a molecule"
1066
"cell_type": "code",
1067
"execution_count": 87,
1072
"output_type": "stream",
1074
"Creating the yaml input file \"./CO-GS.yaml\"\n",
1075
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n CO-GS\n"
1080
"inp=I.Inputfile()\n",
1081
"mol=Molecules.Molecule('CO')\n",
1082
"#mol['positions'][1]['O']=[0.0,0.0,1.12016] #our positions\n",
1083
"inp.set_xc('PBE')\n",
1084
"inp.set_hgrid('0.37')\n",
1085
"inp.set_rmult(coarse=11)\n",
1086
"logGS=code.run(input=inp,posinp=mol,name='CO-GS')"
1090
"cell_type": "code",
1091
"execution_count": 88,
1095
"import numpy as np\n",
1096
"intensity=-1.e-2\n",
1097
"PolTensor=D.Dataset(label='Poltensor',run_dir='polt',input=inp,posinp=mol,d0=logGS.dipole,F=intensity)\n",
1098
"for idir,coord in enumerate(['x','y','z']):\n",
1099
" el=np.zeros(3)\n",
1100
" el[idir]=intensity\n",
1101
" inp.apply_electric_field(el.tolist())\n",
1102
" PolTensor.append_run({'id': coord,'F':intensity},code,input=inp)"
1106
"cell_type": "code",
1107
"execution_count": 89,
1111
"def extract_alpha(PolT):\n",
1112
" d0=np.array(PolT.get_global_option('d0'))\n",
1113
" F=PolT.get_global_option('F')\n",
1114
" ds=PolT.fetch_results(attribute='dipole')\n",
1115
" alpha=np.mat(np.zeros(9)).reshape(3,3)\n",
1116
" for idir in range(3):\n",
1117
" alpha[idir]=(np.array(ds[idir])-d0)/F\n",
1122
"cell_type": "code",
1123
"execution_count": 90,
1127
"code.update_global_options(skip=False)"
1131
"cell_type": "code",
1132
"execution_count": 91,
1136
"PolTensor.set_postprocessing_function(extract_alpha)"
1140
"cell_type": "code",
1141
"execution_count": 92,
1146
"output_type": "stream",
1148
"Creating the yaml input file \"polt/F:-0.01,id:x.yaml\"\n",
1149
"Run directory polt\n",
1150
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n F:-0.01,id:x\n",
1151
"Creating the yaml input file \"polt/F:-0.01,id:y.yaml\"\n",
1152
"Run directory polt\n",
1153
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n F:-0.01,id:y\n",
1154
"Creating the yaml input file \"polt/F:-0.01,id:z.yaml\"\n",
1155
"Run directory polt\n",
1156
"Executing command: mpirun -np 2 /home/marco/Applications/BigDFT/binaries/v1.8.3/install/bin/bigdft -n F:-0.01,id:z\n"
1161
"alpha=PolTensor.run()"
1165
"cell_type": "code",
1166
"execution_count": 50,
1174
"cell_type": "code",
1175
"execution_count": 51,
1181
"matrix([[ 1.26423306e+01, 3.50890610e-03, -3.31700000e-02],\n",
1182
" [ 3.50890610e-03, 1.26423306e+01, -3.31700000e-02],\n",
1183
" [ 3.70690000e-05, 3.70690000e-05, 1.58543700e+01]])"
1186
"execution_count": 51,
1188
"output_type": "execute_result"
1196
"cell_type": "code",
1197
"execution_count": 64,
1205
"cell_type": "code",
1206
"execution_count": 65,
1212
"matrix([[ 1.26423306e+01, 3.50890610e-03, -3.31700000e-02],\n",
1213
" [ 3.50890610e-03, 1.26423306e+01, -3.31700000e-02],\n",
1214
" [ 3.70690000e-05, 3.70690000e-05, 1.58543700e+01]])"
1217
"execution_count": 65,
1219
"output_type": "execute_result"
1227
"cell_type": "code",
1228
"execution_count": 57,
1234
"{0: <BigDFT.Logfiles.Logfile instance at 0x7f02c026f950>,\n",
1235
" 1: <BigDFT.Logfiles.Logfile instance at 0x7f02c026f7a0>,\n",
1236
" 2: <BigDFT.Logfiles.Logfile instance at 0x7f0291a53128>}"
1239
"execution_count": 57,
1241
"output_type": "execute_result"
1249
"cell_type": "code",
1250
"execution_count": 85,
1256
"matrix([[ 1.26686738e+01, -3.23449840e-03, 3.77370000e-02],\n",
1257
" [-3.23449840e-03, 1.26686738e+01, 3.77370000e-02],\n",
1258
" [-1.11158900e-03, -1.11158900e-03, 1.58224360e+01]])"
1261
"execution_count": 85,
1263
"output_type": "execute_result"
1271
"cell_type": "code",
1272
"execution_count": 68,
1276
"a=0.5*(alpha1+alpha2)"
1280
"cell_type": "code",
1281
"execution_count": 93,
1287
"2.1334035481704943"
1290
"execution_count": 93,
1292
"output_type": "execute_result"
1296
"np.mean(np.diag(alpha))*(0.529177**3)"
894
"so this analysis can be easily performed for other cases."