# Open SourceMolecular Dynamics

### Site Tools

exercises:2019_conexs_newcastle:ex3

# Differences

This shows you the differences between two versions of the page.

 exercises:2019_conexs_newcastle:ex3 [2019/09/07 11:55]abussy exercises:2019_conexs_newcastle:ex3 [2019/09/13 10:57] (current)abussy [Part 2: XAS calculations] Both sides previous revision Previous revision 2019/09/13 10:57 abussy [Part 2: XAS calculations] 2019/09/12 09:30 abussy [Part 2: XAS calculations] 2019/09/12 06:21 abussy [Part 4: Changing basis set] 2019/09/10 16:49 abussy 2019/09/10 16:43 abussy [MgO] 2019/09/10 14:50 abussy [MgO] 2019/09/10 14:26 abussy [MgS] 2019/09/10 12:34 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/10 12:33 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/09 08:12 abussy [Part 4: Changing basis-set] 2019/09/09 08:11 abussy 2019/09/09 07:56 abussy 2019/09/09 07:53 abussy [MgO] 2019/09/09 07:48 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/09 07:44 abussy [Part 4: Changing basis-set] 2019/09/09 07:43 abussy 2019/09/08 07:17 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 12:06 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/07 11:59 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:55 abussy 2019/09/07 11:54 abussy [Part 2: XAS calculations] 2019/09/07 11:51 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:51 abussy [Part 2: XAS calculations] 2019/09/07 11:40 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:39 abussy 2019/09/07 09:35 abussy 2019/09/07 07:34 abussy created Next revision Previous revision 2019/09/13 10:57 abussy [Part 2: XAS calculations] 2019/09/12 09:30 abussy [Part 2: XAS calculations] 2019/09/12 06:21 abussy [Part 4: Changing basis set] 2019/09/10 16:49 abussy 2019/09/10 16:43 abussy [MgO] 2019/09/10 14:50 abussy [MgO] 2019/09/10 14:26 abussy [MgS] 2019/09/10 12:34 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/10 12:33 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/09 08:12 abussy [Part 4: Changing basis-set] 2019/09/09 08:11 abussy 2019/09/09 07:56 abussy 2019/09/09 07:53 abussy [MgO] 2019/09/09 07:48 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/09 07:44 abussy [Part 4: Changing basis-set] 2019/09/09 07:43 abussy 2019/09/08 07:17 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 12:06 abussy [MgS and MgO: Periodic systems and XAS] 2019/09/07 11:59 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:55 abussy 2019/09/07 11:54 abussy [Part 2: XAS calculations] 2019/09/07 11:51 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:51 abussy [Part 2: XAS calculations] 2019/09/07 11:40 abussy [Part 3: $\Delta$SCF calculations] 2019/09/07 11:39 abussy 2019/09/07 09:35 abussy 2019/09/07 07:34 abussy created Line 2: Line 2: - In this exercise we are going to compute near-edge X-ray absorption spectra of bulk MgS and MgO, performing all-electron calculations with GAPW method, using the Transition Potential ​approach. + In this exercise we are going to compute near-edge X-ray absorption spectra of bulk MgS and MgO, performing all-electron calculations with GAPW method, using the Transition Potential ​and $\Delta$SCF approaches. Our goal is to identify differences in the electronic structure, and as a consequence in the K-edge absorption spectrum, of the magnesium due to the different anions it is bounded to. We are also going to analyze the influence of basis set quality in the calculations. - Before ​start, it is recommended to create one directory for each system (MgO and MgS) and, within the system'​s directory, create the subfolders '​optimization',​ '​dscf'​ and '​xas'​. + Before ​starting, it is recommended to create one directory for each system (MgO and MgS) and, within the system'​s directory, create the subfolders '​optimization',​ '​dscf'​ and '​xas'​. Line 99: Line 99: ​ - Since we are going to perform calculations for bulk structures, and both systems have only two atoms in their unit cells, it is not necessary to have a separate .xyz file with the atomic positions. ​You can directly ​write the coordinates ​in the input file in the ''&​COORD''​ subsection. ​ + Since both systems have only two atoms in their unit cells it is not necessary to have a separate .xyz file with the atomic positions. ​To make it simple we are going to write the coordinates in the ''&​COORD''​ subsection ​of the input file. Do not forget to put in your work directory the files ''​GTH_POTENTIALS''​ and ''​GTH_BASIS_SETS'',​ which contain the parameters for the pseudopotentials and basis sets used in the calculations. Do not forget to put in your work directory the files ''​GTH_POTENTIALS''​ and ''​GTH_BASIS_SETS'',​ which contain the parameters for the pseudopotentials and basis sets used in the calculations. - To run the calculation, type in your terminal: + To run the calculation ​follow the instructions on the page [[exercises:2019_conexs_newcastle:​ex0|Connecting to the HPC cluster]]. - <​code>​ - ./cp2k.sopt -i MgO_opt.inp -o MgO_opt.out & -  ​ After the calculation is finished, you can check the files created in your directory. First open the output file ''​MgO_opt.out''​ and search for the following banner: ​ After the calculation is finished, you can check the files created in your directory. First open the output file ''​MgO_opt.out''​ and search for the following banner: ​ Line 121: Line 118: cp2k prints out the coordinates for each step of the calculation (they are indicated in the file by the index i, right below the number of atoms), so in order to use the optimized geometry in the following calculations,​ you should use the positions corresponding to the last iteration. cp2k prints out the coordinates for each step of the calculation (they are indicated in the file by the index i, right below the number of atoms), so in order to use the optimized geometry in the following calculations,​ you should use the positions corresponding to the last iteration. - It is also important to check for warnings in your output file. In the end of the output ​file you can find the following banner: + It is also important to check for warnings in your output file. In the end of the file you can find the following banner: <​code>​ <​code>​ Line 158: Line 155: ​ - These are the lengths of the vectors a, b and c of the MgS unit cell. Both systems have rhombohedral unit cells, so the angles $\alpha$, $\beta$ and $\gamma$ are the same. + In order to deal with a smaller number of atoms, we are declaring the structures of MgO and MgS using the rhombhedral unit cell, so the lengths of the lattice ​vectors ​//a//, //b// and //c//, so as the angles $\alpha$, $\beta$ and $\gamma$, are the same. The last modification that needs to be done is regarding the atomic types. In this case we do not have oxygen in the system anymore, so the subsection ''&​KIND O''​ can be renamed ''&​KIND S''​. The only modification that needs to be done is in the keyword ''​ELEMENT'',​ where ''​O''​ has to be replaced by ''​S''​. ​ The last modification that needs to be done is regarding the atomic types. In this case we do not have oxygen in the system anymore, so the subsection ''&​KIND O''​ can be renamed ''&​KIND S''​. The only modification that needs to be done is in the keyword ''​ELEMENT'',​ where ''​O''​ has to be replaced by ''​S''​. ​ Line 164: Line 161: ​Even though we are not changing the name of the basis set or pseupotential used, cp2k will use the parameters for the sulfur atom now, since the ''​ELEMENT''​ type is different. However, it is important to check in the ''​GTH_BASIS_SET''​ and ''​GTH_POTENTIALS''​ files whether the names are the same for different atoms.​Even though we are not changing the name of the basis set or pseupotential used, cp2k will use the parameters for the sulfur atom now, since the ''​ELEMENT''​ type is different. However, it is important to check in the ''​GTH_BASIS_SET''​ and ''​GTH_POTENTIALS''​ files whether the names are the same for different atoms.​ - Now the input is ready, and can be run in the same way as before, just changing ​the input and output files names. + Now the input is ready and it can be run in the same way as before, just remember to change ​the file ''​cp2k.sh''​. - + - <​code>​ + - ./cp2k.sopt -i MgS_opt.inp -o MgS_opt.out & + -  ​ + After the calculation is finished, open the output file ''​MgS_opt.out''​ and look for the same banner as before. The optimized atomic positions are written in the file ''​MgS-pos-1.xyz''​. After the calculation is finished, open the output file ''​MgS_opt.out''​ and look for the same banner as before. The optimized atomic positions are written in the file ''​MgS-pos-1.xyz''​. Line 179: Line 172: &GLOBAL &GLOBAL PROJECT_NAME MgX ! TASK: change X to O or S PROJECT_NAME MgX ! TASK: change X to O or S - RUN_TYPE ENERGY + RUN_TYPE ENERGY ​ PRINT_LEVEL LOW PRINT_LEVEL LOW FLUSH_SHOULD_FLUSH .TRUE. FLUSH_SHOULD_FLUSH .TRUE. Line 188: Line 181: &DFT &DFT - ​BASIS_SET_FILE_NAME ​ EMSL_BASIS_SETS ​! basis set file with all-electron basis set + !where to find all-electron basis sets and potentials - POTENTIAL_FILE_NAME ​ POTENTIAL ​! file with parameters for all-electron calculations + BASIS_SET_FILE_NAME ​ EMSL_BASIS_SETS + POTENTIAL_FILE_NAME ​ POTENTIAL ​ UKS UKS Line 216: Line 210: &SCF &SCF - MAX_SCF ​30 + MAX_SCF ​50 EPS_SCF 1.0E-5 EPS_SCF 1.0E-5 SCF_GUESS ATOMIC SCF_GUESS ATOMIC Line 226: Line 220: &END MIXING &END MIXING - &​OUTER_SCF - EPS_SCF 1.0E-5 - MAX_SCF 50 - &END OUTER_SCF &END SCF &END SCF Line 272: Line 262: ​ELECTRONIC_TEMPERATURE [K] 300 ​ELECTRONIC_TEMPERATURE [K] 300 ​METHOD FERMI_DIRAC ​METHOD FERMI_DIRAC - &END SMEAR + &END SMEAR &END SCF &END SCF Line 312: Line 302: ABC A B C ABC A B C &END CELL &END CELL - &KIND Mg &KIND Mg Line 333: Line 322: ​ - ====MgO==== + ====MgS==== - To compute the absorption spectra for the bulk MgO, first rename the input file changing the ''​X''​ to ''​O''​. It can be done by typing in the terminal: + To compute the absorption spectra for the bulk MgS, first rename the input file changing the ''​X''​ to ''​S''​. It can be done by typing in the terminal: <​code>​ <​code>​ - cp MgX_xas.inp ​MgO_xas.inp + cp MgX_xas.inp ​MgS_xas.inp ​ - Now change all the ''​X''​s in the input file to ''​O''​s. Move the new input file to the correct working directory. + Now change all the ''​X''​s in the input file to ''​S''​s. Move the new input file to the correct working directory. The next step is to add the optimized coordinates of the system, that you can find them in the ''​.xyz''​ file written by the program after the geometry optimization. Use the last iteration step values, and write them in the ''&​COORD''​ subsection. The final step is to add the correct values for the lattice vectors. You can copy it from the geometry optimization input file. The next step is to add the optimized coordinates of the system, that you can find them in the ''​.xyz''​ file written by the program after the geometry optimization. Use the last iteration step values, and write them in the ''&​COORD''​ subsection. The final step is to add the correct values for the lattice vectors. You can copy it from the geometry optimization input file. - To run this calculation type in terminal: + ​At ​this time we are using cartesian coordinates to indicate the position of the atoms, so the keyword ''​SCALED''​ should be removed.​ - <​code>​ + To run this calculation proceed as you did before. - ./cp2k.sopt -i MgO_xas.inp -o MgO_xas.out & + - ​ + This calculation should take longer than the geometry optimization to run. Once it is finished, check the number of warnings and if the calculation converged. Sometimes it does not converge within the maximum number of iterations we set in the input file. If this is the case, you can increase the number using the keyword ''​MAX_SCF''​. This calculation should take longer than the geometry optimization to run. Once it is finished, check the number of warnings and if the calculation converged. Sometimes it does not converge within the maximum number of iterations we set in the input file. If this is the case, you can increase the number using the keyword ''​MAX_SCF''​. - You can check in the working directory that some files were created. The absorption energies and intensities (oscillator strength) are written in the files named ''​MgO-xas_at1_st1.spectrum''​ and ''​MgO-xas_at2_st1.spectrum'',​ where the first one corresponds to the atom 1 in your input file, and the second one to atom number 2. + You can check in the working directory that some files were created. The absorption energies and intensities (oscillator strength) are written in the files named ''​MgS-xas_at1_st1.spectrum''​ and ''​MgS-xas_at2_st1.spectrum'',​ where the first one corresponds to the atom 1 in your input file, and the second one to atom number 2. The file looks like The file looks like Line 376: Line 363: ​ - As an output you are going to get two files: ''​spectrum.inp''​ and ''​spectrum.out''​. The first one contains the same information as the ''​MgO-xas_at1_st1.spectrum''​ file, and in the second one you will find you absorption spectrum for atom 1. Change the name of the files to ''​O_K-edge.inp''​ and ''​O_K-edge.out'',​ for example. You can now plot both absorption intensities from the file ''​O_K-edge.inp''​ and the convoluted spectrum from the file ''​O_K-edge.out''​. From the first one only the second and sixth columns need to be plotted.  ​ + As an output you are going to get two files: ''​spectrum.inp''​ and ''​spectrum.out''​. The first one contains the same information as the ''​Mgs-xas_at1_st1.spectrum''​ file, and in the second one you will find you absorption spectrum for atom 1. Change the name of the files to ''​S_K-edge.inp''​ and ''​S_K-edge.out'',​ for example. You can now plot both absorption intensities from the file ''​S_K-edge.inp''​ and the convoluted spectrum from the file ''​S_K-edge.out''​. From the first one only the second and sixth columns need to be plotted.  ​ - In order to obtain the spectrum for atom 2, you can open the file ''​get_average_spectrum.sh'',​ and replace ''​at1''​ by ''​at2''​in the line ''​for i in $(ls${DIR}/​*xas_at2*spectrum)''​. Run the script again and you will obtain the same two files again, but now with the absorption intensities and spectrum of atom 2. Change their names to ''​Mg_K-edge.inp''​ and ''​Mg_K-edge.out'',​ and plot the + In order to obtain the spectrum for atom 2, you can open the file ''​get_average_spectrum.sh'',​ and replace ''​at1''​ by ''​at2''​ in the line ''​for i in $(ls${DIR}/​*xas_at2*spectrum)''​. Run the script again and you will obtain the same two files again, but now with the absorption intensities and spectrum of atom 2. Change their names to ''​Mg_K-edge.inp''​ and ''​Mg_K-edge.out'',​ and plot the absorption spectrum. absorption spectrum. - - ====MgS==== - - The exact same procedure can be done for the MgS, but now replacing the ''​X''​s by ''​S''​s,​ and taking the lattice vectors and coordinates from the input and output files of the MgS system. Do not forget to put the input file in the correct directory. =====Part 3: $\Delta$SCF calculations===== =====Part 3: $\Delta$SCF calculations===== - Now, to finally finish the calculation,​ we need to get the an accurate energy for the first transition. In order to do that, we need to perform a $\Delta$SCF calculation. Copy the input file of the previous step to the '​dscf'​ directory. Change its name to ''​MgX_dscf.inp'',​ where ''​X''​ can be again ''​O''​ or ''​S''​. The only thing that needs to be changed in the input file is the keyword ''​METHOD''​ in the ''&​XAS''​ section. ​ Use now + Now, to finally finish the calculation,​ we need to get the an accurate energy for the first transition. In order to do that, we need to perform a $\Delta$SCF calculation. Copy the input file of the previous step to the '​dscf'​ directory. Change its name to ''​MgX_dscf.inp'',​ where ''​X''​ can be again ''​S''​ or ''​O''​. The only thing that needs to be changed in the input file is the keyword ''​METHOD''​ in the ''&​XAS''​ section. ​ Use now <​code>​ <​code>​ Line 394: Line 377: ​ - For the MgO system, for example, run the calculation ​typing ​ + instead of ''​TP_HH''​, and you can run the calculation ​in the same way as you did before. - <​code>​ + After the calculation ​is done, look for the message - ./cp2k.sopt -i MgO_dscf.inp -o MgO_dscf.out & + - ​ + - + - After the calculation ​ran, look for the message + <​code>​ <​code>​ - Ionization potential of the excited atom:                  -49.38227966446617 + Ionization potential of the excited atom:                  -92.73815588900608 ​ in the output file. The energy is given in Hartree, and to convert it to electron volts multiply the value by 27.211. This is the energy of the first transition, and you can use this value to rigidly shift your absorption spectrum. in the output file. The energy is given in Hartree, and to convert it to electron volts multiply the value by 27.211. This is the energy of the first transition, and you can use this value to rigidly shift your absorption spectrum. + + =====Part 4: Changing basis set===== + + Before performing the XAS calculations for the MgO system and compare the Mg absorption spectra, you can try to change the basis set you are using to run the absorption calculations to analyze differences it can bring to the description of the process. Try to perform the calculations using: + + * pc-0 (smaller basis set) + * pob-TZVP (basis set for solid-state calculations) + * DZVP-all + * Ahlrichs-def2-SVP ​ + + <​note>​ In this exercise we have obtained absorption spectra using a simple basis set, in order to performed the calculations on small machines and using a limited time. Therefore, careful tests on basis set size, XC functional etc have to be carried out for production runs to get more reliable spectra.  ​ + + + You can check the tutorial [[exercises:​2017_uzh_cp2k-tutorial:​gapw|Gaussian and Augmented Plane Wave Method]] in case you want to compute more absorption spectra. + + +