# sTDA-xTB Setup Guide
I tested this guide in Ubuntu 20.04.
## 0. Install xTB (If not installed yet)
1. Download the latest version from GitHub ([v6.4.1](https://github.com/grimme-lab/xtb/releases/tag/v6.4.1))
```
wget https://github.com/grimme-lab/xtb/releases/download/v6.4.1/xtb-6.4.1-linux-x86_64.tar.xz
tar xvf xtb-6.4.1-linux-x86_64.tar.xz
```
3. Add `xtb` in `PATH`. For example, add the following line in `.bashrc`.
```
export PATH=$PATH:$HOME/xtb-6.4.1/bin
```
## 1. Install sTDA-xTB
1. Clone the sTDA-xTB repository https://github.com/grimme-lab/xtb4stda
```
git clone https://github.com/grimme-lab/xtb4stda.git
```
2. Create a `exe` directory.
```
mkdir xtb4stda/exe
```
3. Download the latest binary `xtb4stda` and `stda_v1.6.2` from the [Release page](https://github.com/grimme-lab/stda/releases/tag/v1.6.2) of sTDA and put them under `xtb4stda/exe/`.
```
cd xtb4stda/exe
wget https://github.com/grimme-lab/stda/releases/download/v1.6.2/xtb4stda
wget https://github.com/grimme-lab/stda/releases/download/v1.6.2/stda_v1.6.2
chmod +x *
```
4. Set up environment variables. For example, add the following lines in `.bashrc`.
```
export XTB4STDAHOME=$HOME/xtb4stda/
export PATH=$PATH:$XTB4STDAHOME/exe
```
## 2. Install SpecDis
1. Download the binary from the [Website](https://specdis-software.jimdofree.com/).
## 3. Test
1. Generate an arbitrary chiral molecule. For example, generate a structure of [L-Lactic acid](https://pubchem.ncbi.nlm.nih.gov/compound/L-Lactic-acid) by OpenBabel.
```
obabel -:"C[C@@H](C(=O)O)O" -O test.xyz --gen3d best
```

2. Optimize the structure by xTB.
```
xtb test.xyz --opt
```
This creates `xtbopt.xyz` and other files.

3. Run xtb4stda
```
xtb4stda xtbopt.xyz
```
This creates `wfn.xtb`.
4. Run sTDA (`-e` specifies energy threshold. See [Manual](https://github.com/grimme-lab/stda/releases/download/v1.6.2/stda_manual.pdf) for more details.)
```
stda_v1.6.2 -xtb wfn.xtb -e 10
```
5. Open `tda.dat` by SpecDis.
6.

6. Alternatively, you can process the spectrum by g_spec. You can download g_spec [here](https://www.chemie.uni-bonn.de/pctc/mulliken-center/software/stda/).
```
g_spec < tda.dat
```
It will generate two files, `spec.dat` and `rots.dat`. The first file contains the spectrum broadened by Gaussian curves, the latter one contains the pure oscillator/rotatory strengths that can be used to plot a stick spectrum.
`spec.dat`
```