Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually calculate the Raman Intensities #13

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

lipelopesoliveira
Copy link
Collaborator

@lipelopesoliveira lipelopesoliveira commented Apr 4, 2024

Manual Raman Intensity Calculation Using Small Displacements Approach

This pull request introduces a new set of tools designed to manually calculate Raman intensities (total, perpendicular, and parallel) using the small displacements approach. The calculation leverages the polarizability tensor, as outlined in issue #4, and incorporates symmetry analysis through the Phono3py package. This package is used to generate the dynamical matrix from atomic forces, enabling accurate vibrational mode analysis.

Key Features

  • Raman Intensity Calculation:
    • Implements manual calculation of Raman intensities (total, perpendicular, and parallel) based on small atomic displacements and the resulting polarizability tensor.
  • Phono3py Integration: Utilizes the Phono3py package for:
    • Generating the dynamical matrix from atomic forces.
    • Performing symmetry analysis critical for vibrational mode calculations.

After running the scripts, the following files and directories are produced:

  • VIBRATION_FILES

    • Contains displacement vectors for all vibrational modes. Files are named following the pattern:
      {FrameworkName}_{ModeNumber}_{IrreductiveRepresentation}_{Freq}.axsf
      These files can be visualized using VESTA.
  • All Displacements File:

    • A single file named {FrameworkName}_all.axsf that consolidates all displacement vectors. This file is suitable for visualization in XCrysDen.
  • Raman Data CSV:

    • A file called {FrameworkName}_RamanTable.csv that tabulates the computed Raman intensities and related data.
  • Normalized Raman Curve CSV:

    • A file named {FrameworkName}_RAMAN_Curve.csv that contains the normalized Raman curve, with intensities normalized by the total intensity and a given half width for the peaks.

Usage and Execution

  • Prepare Input Files:

    • Run generate_shift.py to create the necessary displacement input files. Note: The default command line for executing CP2K within this script can be modified to fit HPC cluster job submission requirements.
  • Run Simulations:

    • Execute the generated displacement files independently in three directions (x, y, z) and in two polarization (+, -). Each displacement is designed to run as a standalone simulation.
  • Parse and Analyze Results:

    • After simulations complete, run parse_phonon.py to:
      • Read simulation outputs.
      • Calculate vibrational modes and irreducible representations.
      • Compute Raman intensities and generate all output files described above.

Below there is an example of two scripts that can execute the workflow completely.

#!/bin/bash

# Define environment variables
export PATH=$PATH:/home/felipe/Github/electronic-structure-experiment/bin

export CP2K_DIR=/home/felipe/lib/cp2k-2023.2
export CP2K_DATA_DIR=${CP2K_DIR}/data

export OMP_NUM_THREADS=1

# Define specific variables
FrameworkName='HKUST_1'
OutputFolder=$PWD
NProcs=25

# Load the CP2K setup script
source ${CP2K_DIR}/tools/toolchain/install/setup

# First ensure that the CIF file has all atoms explicitly defined in a P1 primitive cell
echo -e "\nCreating primitive P1 cell..."
mv -v ${OutputFolder}/${FrameworkName}.cif ${OutputFolder}/${FrameworkName}_original.cif
pmg structure --convert --filename ${OutputFolder}/${FrameworkName}_original.cif ${OutputFolder}/${FrameworkName}_prim.cif
mv -v ${OutputFolder}/${FrameworkName}_prim.cif ${OutputFolder}/${FrameworkName}.cif

echo -e "\nCreating CP2K input file..."
generate_shift.py --FrameworkName ${FrameworkName} \
                  --Functional "PBE" \
                  --DispersionCorrection "DFTD3(BJ)" \
                  --PWCutoff 1200 \
                  --BasisSet "TZV2P" \
                  --UnitCell "1,1,1" \
                  --dR 0.005 \
                  --UseOT \
                  --CalculateRaman \
                  ${OutputFolder}

FOLDER_LIST=$(ls -d */)

# List the folders in the current directory and iterate over it
for folder in $FOLDER_LIST; do
    echo "Running the cp2k program for the folder $folder"
    # Change to the folder
    cd $folder
    # Remove the \ from the folder name
    folder=$(echo $folder | tr -d '/')
    # Run the cp2k program
    mpirun -np 25 $CP2K_DIR/exe/local/cp2k.psmp -i ${FrameworkName}_${folder}.inp -o ${FrameworkName}_${folder}.out
    # Return to the parent directory
    cd ..
done
#!/bin/bash

# Define environment variables
export PATH=$PATH:/home/felipe/Github/electronic-structure-experiment/bin

export CP2K_DIR=/home/felipe/lib/cp2k-2023.2
export CP2K_DATA_DIR=${CP2K_DIR}/data

export OMP_NUM_THREADS=1

# Define specific variables
FrameworkName='HKUST_1'
OutputFolder=$PWD
NProcs=25

# Load the CP2K setup script
source ${CP2K_DIR}/tools/toolchain/install/setup

echo -e "\nCreating RASPA P1 cell input file..."
parse_phonon.py --FrameworkName ${FrameworkName} \
                --UnitCell "1,1,1" \
                --dR 0.005 \
                --CalculateRaman \
                --SaveVecs \
                --CurveLimits '0,4000' \
                --Resolution 0.1 \
                --HalfWidth 5.0 \
                ${OutputFolder}

Closes #4

@lipelopesoliveira lipelopesoliveira added the enhancement New feature or request label Apr 4, 2024
@lipelopesoliveira lipelopesoliveira self-assigned this Apr 4, 2024
@lipelopesoliveira
Copy link
Collaborator Author

@pcostacarvalho can you test this new workflow for Raman simulations with the HKUST-1 structure on CCC? In case you need some help just let me know and we can schedule a meeting.

Copy link
Owner

@neumannrf neumannrf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @lipelopesoliveira !!! 👏 👏 👏

This will bring an amazing productivity gain. I would even suggest to include the Shell script in the PR description as a file in the repository. Maybe @pcostacarvalho can do that after figuring out the appropriate command for the LSF cluster we have.

bin/generate_shift.py Outdated Show resolved Hide resolved
bin/modules/calculate_properties.py Outdated Show resolved Hide resolved
bin/modules/calculate_properties.py Outdated Show resolved Hide resolved
bin/modules/calculate_properties.py Outdated Show resolved Hide resolved
bin/modules/constants.py Show resolved Hide resolved
bin/parse_phonon.py Outdated Show resolved Hide resolved
bin/parse_phonon.py Outdated Show resolved Hide resolved
@neumannrf
Copy link
Owner

neumannrf commented Apr 5, 2024

@lipelopesoliveira Which of these packages need to be added to environment.yml: phono3py or phonopy?

Even though you cited phono3py in the text above, the imports all point to phonopy.

@neumannrf
Copy link
Owner

@lipelopesoliveira Is it time already to merge this branch, or are you still working on it?

@lipelopesoliveira
Copy link
Collaborator Author

@lipelopesoliveira Is it time already to merge this branch, or are you still working on it?

I'm still working on this.

@lipelopesoliveira
Copy link
Collaborator Author

lipelopesoliveira commented Feb 9, 2025

@neumannrf This is a tentative for closing this PR. There is still two functionalities that are not implemented:

  • Calculation of IR spectra using the manual method
  • Independent calculation of phonon dispersion curves and thermodynamic properties
  • Use of symmetry to reduce the number of calculations

The first two are not urgent so I'll let it for the future. The third one could help a lot right now, but unfortunately implement it will require a lot more time than I anticipated, so maybe in a few weeks when I will have more time to dedicate to it I can come back and implement it.

I tested most of the things here on my computer and everything seems to be working. But if @pcostacarvalho have some time to spare it would be good to double check the code with some simple examples just to make sure that I didn't broke anything.

There still some things that I would like to implement, such as unit tests and a better documentation with more examples. But as people says: "The perfect is the enemy of the good..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility restart the vibrational modes calculation
2 participants