# `07_GelSystems`

`07_GelSystems` contains PNIPAAm gel tracing, degree-of-swelling fits, binary
mixed-solvent comparisons, and network-model comparisons. It builds on the
parameter and polymer-solution workflows in the earlier directories.

## Prerequisites

Install and activate the repository environment from
[`../README.md`](../README.md). Run scripts from this directory because many of
them read or write relative paths such as `figures/`, `tables/`, and the local
optimization result folders.

## Scripts And Files

- [`gel_tracer_binary.py`](gel_tracer_binary.py) and
  [`gel_tracer_ternary.py`](gel_tracer_ternary.py): shared gel tracing helpers
  used by the plotting and optimization scripts
- [`plot_gel_lle_different_elastics.py`](plot_gel_lle_different_elastics.py):
  compares Flory, phantom, and Miao elasticity models
- [`plot_gel_lle_different_m.py`](plot_gel_lle_different_m.py): compares
  polymer molar-mass effects
- [`plot_gel_lle_different_water_models.py`](plot_gel_lle_different_water_models.py):
  compares gel predictions across water parameterizations
- [`plot_gel_lle_binaries_wa_aa.py`](plot_gel_lle_binaries_wa_aa.py),
  [`plot_gel_lle_binaries_aa_ba.py`](plot_gel_lle_binaries_aa_ba.py), and
  [`plot_gel_lle_binaries_ba_bu.py`](plot_gel_lle_binaries_ba_bu.py): binary
  solvent-swelling comparisons that consume archived fitted parameter sets
- [`example_tracing_ternary.py`](example_tracing_ternary.py): PNIPAAm-water-
  ethanol polymer/gel tracing example
- [`random_walk_2d.py`](random_walk_2d.py): random-walk schematic used for the
  polymer-coil illustration
- [`optimize_parameters_gel_water_systems.py`](optimize_parameters_gel_water_systems.py):
  PNIPAAm-water gel model comparison and scoring workflow
- [`optimize_parameters_example_gels_wa_aa.py`](optimize_parameters_example_gels_wa_aa.py),
  [`optimize_parameters_example_gels_aa_ba.py`](optimize_parameters_example_gels_aa_ba.py), and
  [`optimize_parameters_example_gels_ba_bu.py`](optimize_parameters_example_gels_ba_bu.py):
  cross-solvent gel fitting scripts
- [`params_pnipaam_water.json`](params_pnipaam_water.json) and
  [`params_pnipaam_water_ethanol.json`](params_pnipaam_water_ethanol.json):
  saved parameter snapshots kept with the gel workflow

## Commands

Generate the main comparison figures:

```bash
cd 07_GelSystems
python plot_gel_lle_different_elastics.py
python plot_gel_lle_different_m.py
python plot_gel_lle_different_water_models.py
python plot_gel_lle_binaries_wa_aa.py
python plot_gel_lle_binaries_aa_ba.py
python plot_gel_lle_binaries_ba_bu.py
```

Generate the supporting example figures:

```bash
cd 07_GelSystems
python example_tracing_ternary.py
python random_walk_2d.py
```

Refresh fitted parameter archives only when intentionally rerunning the
optimizers:

```bash
cd 07_GelSystems
python optimize_parameters_gel_water_systems.py
python optimize_parameters_example_gels_wa_aa.py
python optimize_parameters_example_gels_aa_ba.py
python optimize_parameters_example_gels_ba_bu.py
```

## Outputs

- [`figures/`](figures/): gel-system manuscript figures, helper/export figures,
  and the `random_walk_2d.png` schematic
- [`tables/`](tables/): binary gel comparison tables
- [`optimize_parameters_gel_water_systems/`](optimize_parameters_gel_water_systems/README.md):
  curated PNIPAAm-water gel fit results and score tables
- [`optimize_parameter_gel_other_solvents/`](optimize_parameter_gel_other_solvents/README.md):
  curated cross-solvent parameter sets, optimizer histories, and traced-state
  arrays

## Notes

- The binary plot scripts depend on archived JSON and NPY assets in
  `optimize_parameter_gel_other_solvents/`.
- Some optimizer scripts write candidate files in the current working directory
  before those results are curated into the archive folders.
- Several scripts are tuned for publication figures rather than general-purpose
  command-line use, so model choices are often hard-coded near the top of the
  file.
