# `05_SolventSystems`

`05_SolventSystems` contains the solvent-only esterification-system workflows
used before the polymer and gel calculations. The scripts compare PC-SAFT
parameterizations for water, n-butanol, butyl acetate, and acetic acid.

## Prerequisites

Install and activate the repository environment from
[`../README.md`](../README.md). Run scripts from this directory because they
use relative `figures/`, `tables/`, and `optimizer_histories/` paths.

## Scripts

- [`pure_components.py`](pure_components.py): compares archived pure-component
  calculations with experimental pure-component data and writes a summary table
- [`plot_esterification_systems_from_params.py`](plot_esterification_systems_from_params.py):
  traces the main binary and ternary solvent systems using literature and
  optimized parameter sets across multiple sources
- [`plot_esterification_systems_from_params_only_kij_aa.py`](plot_esterification_systems_from_params_only_kij_aa.py):
  alternate plotting workflow that focuses on fits where only interactions with
  acetic acid were refreshed
- [`optimize_parameters_esterification_system.py`](optimize_parameters_esterification_system.py):
  differential-evolution optimization for the solvent-system interaction
  parameters and archived fit variants

## Commands

Generate the checked-in comparison figures and tables:

```bash
cd 05_SolventSystems
python pure_components.py
python plot_esterification_systems_from_params.py
python plot_esterification_systems_from_params_only_kij_aa.py
```

> The following command will not run successfully with the files included in this repository:
>
> ```bash
> cd 05_SolventSystems
> python pure_components.py
> ```
>
> The required experimental vapor-pressure and liquid-density data are not open source and therefore cannot be published in this repository.
>
> To run the script, provide equivalent property data from a licensed source such as DIPPR or another suitable thermophysical-property database.

Refresh optimizer histories only when intentionally regenerating candidate
parameter sets:

```bash
cd 05_SolventSystems
python optimize_parameters_esterification_system.py
```

## Outputs

- [`figures/`](figures/): solvent-system PDFs from the main and `only_kij_aa`
  plotting workflows
- [`tables/`](tables/): pure-component summaries, system-error tables, and
  interaction-parameter tables for the archived fit variants
- [`optimizer_histories/`](optimizer_histories/README.md): differential-
  evolution histories for the solvent fits

## Notes

- The plotting scripts consume archived `CAL_*` records from
  [`../02_CalculationData/`](../02_CalculationData/README.md) and experimental
  `EXP_*` records from [`../03_ExperimentalData/`](../03_ExperimentalData/README.md).
- The optimizer writes histories for multiple fit labels, including full
  `Association`, `Dispersion`, and `Both` variants as well as
  `only_kij_with_AA` runs.
- History files are appended when an expected CSV already exists.
