# Example 1: Multi-Level Ensemble Refinement
This tutorial reproduces the **Ensemble Refinement** case study described in the paper. The goal is to refine a large ensemble of a flexible molecule generated by CREST (or any other conformational search tool existing).
::::{tab-set}
:::{tab-item} **Command**
This command launches the refinement process using 8 CPU cores. The `-e` flag specifies the input ensemble, and `-p` points to our custom JSON protocol.
```
ensemble_analyzer -e ensemble.xyz -p protocol_refinement.json -cpu 8
```
:::
:::{tab-item} **Protocol**
```json
{
"0": {
"functional": "ExtOpt",
"basis": "def2-mTZVP",
"add_input": "\n%method ProgExt '/path/to/orca-external-tools/gxtb.py' end\n"
},
"1": {
"functional": "r2SCAN-3c",
"basis": "def2-mTZVPP",
"opt": true,
"freq": true,
"skip_opt_fail": true
},
"2":{
"functional": "wB97X-D4rev",
"basis": "def2-QZVPP",
"add_input": "\n! tightscf defgrid3\n",
"read_orbitals": 1
}
}
```
:::
:::{tab-item} **Geometries (example **Vitamin C**)**
```{literalinclude} ../_static/ensemble_ex_1.xyz
:language: text
```
:::
:::{tab-item} **Output (example **Vitamin C**)**
```{literalinclude} ../_static/output_vit_c_ex_1.out
:language: text
```
:::
::::
The protocol effectively reduces the number of structures by identifying duplicates and high-energy conformers.
The table below summarizes the retention rates achieved using this protocol on various flexible molecules, demonstrating the efficiency of the pruning strategy (results from **Table 1** of the manuscript).
| Molecule | Starting Ensemble | Protocol 1
g-xTB | Protocol 2
r$^2$SCAN-3c | Protocol 3
ωB97X-D4rev/def2-QZVPP | Final Retention Rate |
| :---: | :---: | :---: | :---: | :---: | :---: |
| **Diethyl Phthalate** | 156 | 151 | 35 | 35 | 22 % |
| **Guaiol** | 118 | 109 | 34 | 34 | 29 % |
| **Penicillin V** | 136 | 71 | 12 | 12 | 9 % |
| **Permethrin** | 304 | 304 | 101 | 101 | 33 % |
| **Rivaroxaban** | 110 | 110 | 30 | 30 | 27 % |
| **Sitagliptin** | 428 | 343 | 142 | 142 | 33 % |
| **Tamiflu** | 836 | 527 | 100 | 99 | 12 % |
| **Ascorbic acid** | 134 | 68 | 45 | 45 | 33 % |