Initial commit

This commit is contained in:
sakul-45 2022-02-20 18:39:04 +01:00
commit 211eaffcb4
8 changed files with 149 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

10
.idea/AMM.iml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.8 (AMM)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (AMM)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AMM.iml" filepath="$PROJECT_DIR$/.idea/AMM.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

32
exspectrum Normal file
View File

@ -0,0 +1,32 @@
# Excitation spectrum ; written at 2021-12-23 18:00:19
# Exc. energy (Eh) energy (eV) energy (cm-1) energy (nm) Osc.(vel) Osc.(len)
1 a 0.081632 2.22132 17916.184 558.155 0.59324546 0.63875147
2 a 0.097816 2.66170 21468.087 465.808 0.01013849 0.01104033
3 a 0.101932 2.77371 22371.482 446.998 0.18173513 0.19477660
4 a 0.119431 3.24989 26212.132 381.503 0.64359780 0.65859697
5 a 0.121826 3.31506 26737.749 374.003 0.07358580 0.07053363
6 a 0.124153 3.37836 27248.345 366.995 0.58084889 0.60692493
7 a 0.133071 3.62104 29205.673 342.399 0.44634456 0.45611903
8 a 0.136025 3.70142 29853.943 334.964 0.01543649 0.01724145
9 a 0.138425 3.76673 30380.708 329.156 0.06870782 0.06655899
10 a 0.139343 3.79172 30582.302 326.986 0.09547385 0.09610700
11 a 0.139697 3.80135 30659.928 326.159 0.31050776 0.32244116
12 a 0.141117 3.83998 30971.558 322.877 0.04646558 0.04287950
13 a 0.143354 3.90086 31462.590 317.838 0.00140278 0.00117080
14 a 0.143957 3.91727 31594.889 316.507 0.07233739 0.07315710
15 a 0.144246 3.92514 31658.403 315.872 0.00752599 0.00818926
16 a 0.144772 3.93944 31773.723 314.725 0.00168315 0.00167697
17 a 0.145201 3.95111 31867.834 313.796 0.00226231 0.00201420
18 a 0.145758 3.96629 31990.274 312.595 0.00003515 0.00003452
19 a 0.146169 3.97747 32080.469 311.716 0.00837502 0.00898456
20 a 0.146494 3.98631 32151.783 311.025 0.00974370 0.00905770
21 a 0.148519 4.04140 32596.061 306.786 0.23894747 0.26006671
22 a 0.149195 4.05981 32744.572 305.394 0.01999536 0.02004168
23 a 0.149254 4.06140 32757.367 305.275 0.00860917 0.00890324
24 a 0.149750 4.07490 32866.276 304.263 0.02541908 0.02508246
25 a 0.151961 4.13507 33351.586 299.836 0.00081672 0.00066642
26 a 0.152157 4.14040 33394.610 299.450 0.00012992 0.00013872
27 a 0.152234 4.14249 33411.414 299.299 0.00004462 0.00004261
28 a 0.153115 4.16647 33604.808 297.576 0.03615181 0.04035899
29 a 0.153534 4.17787 33696.766 296.764 0.00006776 0.00007273
30 a 0.154251 4.19738 33854.151 295.385 0.03348557 0.03561208

80
exspectrum_plotter.py Normal file
View File

@ -0,0 +1,80 @@
"""
Turbomole-Spectrum-Plotter
(c) 2022 Lukas Schank
This script will run through all subfolders of the given folder and plot excitation spectra of TDDFT calculations.
"""
import sys
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pathlib import Path
def exspectrum_plotter(data_folder: str, output_folder: str):
# convert input to path objects
data_folder = Path(data_folder)
output_folder = Path(output_folder)
if not output_folder.exists():
output_folder.mkdir()
# convert data to plot
for data_file in data_folder.glob('**/exspectrum'): # path.glob iterates through given folder for pattern
# read data
rawdata = pd.read_csv(
data_file,
sep='\s+', # seperator is one or more spaces
skiprows=2, # skip header rows
header=None # prevent getting first numbers as header
)
data_energy = np.array(rawdata.iloc[:, 3])
data_osc_strength = np.array(rawdata.iloc[:, 6])
# calculate gauss broadening for spectrum
def gauss_spectrum(energy, osc_strength, sigma, gauss_energy_range):
gauss_osc_strength = []
for E_i in gauss_energy_range:
tot = 0
for E_j, osc in zip(energy, osc_strength):
tot += osc * np.exp(-(((E_j - E_i) / sigma) ** 2))
gauss_osc_strength.append(tot)
return gauss_osc_strength
calc_energy_range = np.linspace(0, 6, num=500, endpoint=True) # x values for calculated spectrum
calc_sigma = 0.15 # std for gauss broadening
calc_osc_strength = gauss_spectrum(data_energy, data_osc_strength, calc_sigma, calc_energy_range)
# create plot
fig, ax = plt.subplots(dpi=300, figsize=(6, 4))
ax.plot(calc_energy_range, calc_osc_strength, "-k") # plot calculated spectrum
for plt_energy, plt_osc_strength in zip(data_energy, data_osc_strength):
ax.plot((plt_energy, plt_energy), (0, plt_osc_strength), c="k") # plot lines from data
ax.set_xlabel("Energy / eV", fontsize=16)
ax.set_ylabel("Osc. Strength / a.u.", fontsize=16)
ax.xaxis.set_tick_params(labelsize=14, width=1.5)
ax.yaxis.set_tick_params(labelsize=14, width=1.5)
for axis in ['top', 'bottom', 'left', 'right']:
ax.spines[axis].set_linewidth(1.5)
ax.set_xlim(1.5, 5)
plt.tight_layout()
# save plot
data_name = Path(data_file)
output_name = data_name.parts[data_folder.parts.__len__()]
for name in data_name.parts[(data_folder.parts.__len__() + 1):]:
output_name += "_" + name
output_name += ".pdf" # change here for pdf or png output
output_path = output_folder / output_name
plt.savefig(output_path)
plt.close(fig) # close plot
# getting commandline input and pass it to function
if __name__ == "__main__":
a = str(sys.argv[1])
b = str(sys.argv[2])
exspectrum_plotter(a, b)
# python exspectrum_plotter.py "C:\Path\to\Calculations" "C:\path\to\results"