Skip to main content

Polymerization reactor modeling package using the method of moments

Project description

PyPoly Reactor

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

This distribution folder is intentionally simple. It contains only:

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:

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

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

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

Then import the model:

from pypoly import PolyRxn

For detailed installation instructions, see:

docs/installation.md

Quick Start

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

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:

python quick_start.py

Documentation

Detailed documentation is available in the docs/ folder:

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:

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

Each simulation file can import the model with:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypoly_reactor-0.1.2.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypoly_reactor-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pypoly_reactor-0.1.2.tar.gz.

File metadata

  • Download URL: pypoly_reactor-0.1.2.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pypoly_reactor-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64f149b75d4cef964035a534165aae7500dc70dc7bb1abef659b16b75f0c9c02
MD5 970dbecedca53dbd512427009b699ffa
BLAKE2b-256 5773577a1f8452a70a04cedbcd7f86f977f77d69e1ff9516f7470312a0b7a9ba

See more details on using hashes here.

File details

Details for the file pypoly_reactor-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pypoly_reactor-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pypoly_reactor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9dc5fce7452bdd6bb4e6d5259768c6ce6115eaf2c3e2c4dabb771fc9597666d
MD5 b9ee16f99dc45035e9354028f5670501
BLAKE2b-256 9090ca76782a93cce2d400ff9b5223f3394c998d9ff74e8700e1389b0e685c4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page