Metadata-Version: 2.4
Name: pypoly-reactor
Version: 0.1.1
Summary: Polymerization reactor modeling package using the method of moments
Author: Dabin Yang
License-Expression: MIT
Keywords: polymerization,reactor modeling,method of moments,chemical engineering
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: matplotlib>=3.7
Dynamic: license-file

# PyPoly Reactor

`pypoly.py` is a single-file Python module for polymerization reactor simulations.

This distribution folder is intentionally simple. It contains only:

```text
README.md
pypoly.py
```

The module provides the `PolyRxn` class, which can be used for:

- Batch reactor simulation
- CSTR reactor simulation
- LDPE tubular PFR model construction

The model calculates polymer properties such as:

- Number-average molecular weight, `Mn`
- Weight-average molecular weight, `Mw`
- Polydispersity index, `PDI`

---

## Installation

This version is distributed as a single `.py` file. You do not need to build a Python package before using it.

Install the required Python packages in a Conda environment:

```bash
conda create -n poly python=3.10 numpy scipy matplotlib
conda activate poly
```

Place `pypoly.py` in the same folder as your simulation script:

```text
my_project/
├── pypoly.py
└── Sim_Batch.py
```

Then import the model:

```python
from pypoly import PolyRxn
```

For detailed installation instructions, see:

```text
docs/installation.md
```

---

## Quick Start

Create a file named `quick_start.py` in the same folder as `pypoly.py`:

```python
from pypoly import PolyRxn

model = PolyRxn(
    kd=0.8,
    kp=15.0,
    ktc=0.02,
    ktd=0.02,
    ktrm=15e-3,
    ktrp=10e-3,
    kca=5e-3,
    f=0.8,
    dH_p=-100 * 1000,
    Mw_mono=28.05,
)

R_gas = 8.3145
Mw_mono = 28.05
P_assu = 3000 * 1e5
T_assu = 150 + 273.15

model.set_batch_params(
    Tc_const=200 + 273.15,
    rho=Mw_mono * (P_assu / R_gas / T_assu),
    Cp_ass=42.9 / Mw_mono,
    U_heat=400,
    D=0.05,
)

result = model.run_batch(
    mono_0=8000.0,
    ini_0=50.0,
    CTA_0=50.0,
    T_0=200 + 273.15,
    t_end=5.0,
    dt=0.01,
)

print("Final Mn:", result["Mn_final"])
print("Final Mw:", result["Mw_final"])
print("Final PDI:", result["PDI_final"])
print("Final temperature:", result["T_final"])
```

Run:

```bash
python quick_start.py
```

---

## Documentation

Detailed documentation is available in the `docs/` folder:

```text
docs/
├── installation.md
├── batch.md
├── cstr.md
├── pfr.md
└── api_reference.md
```

Recommended reading order:

1. `docs/installation.md`
2. `docs/batch.md`
3. `docs/cstr.md`
4. `docs/pfr.md`
5. `docs/api_reference.md`

---

## Example Directory

For a simple single-file setup, use this structure:

```text
my_project/
├── pypoly.py
├── Sim_Batch.py
├── Sim_CSTR.py
└── Sim_PFR.py
```

Each simulation file can import the model with:

```python
from pypoly import PolyRxn
```

---

## Notes

- Keep `pypoly.py` in the same directory as your simulation script, or place it in a folder included in `PYTHONPATH`.
- This single-file distribution does not install command-line tools such as `pypoly-rl`.
- The single-file module focuses on reactor simulation code.
- Reinforcement-learning training scripts should be distributed separately if needed.
- Temperature values in the examples are in Kelvin.
- The kinetic constants in the examples are illustrative test values chosen for speed, not a calibrated LDPE data set.

---

## License

Use this file according to the license or distribution agreement provided by the project owner.
