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.1.tar.gz (12.8 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.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypoly_reactor-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 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.1.tar.gz
Algorithm Hash digest
SHA256 271b676cf36b8aae797dd8cb0e5922f54ac44348b217dc234d246709c7e629cd
MD5 a767e4847c1ae0f5c4b56a24decebae0
BLAKE2b-256 64b0184165b82ac7b74c5bc650ccbd6aedcc2958844007a8baef009ec9ddf3c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypoly_reactor-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16c1c070341473eb67205ace4539c448e2d9be86858d2155316ed8377e7e24b0
MD5 ddc84d9e5626da426a2c418879281fc2
BLAKE2b-256 ff08c27ce69f4f34ea028ad63f945bde623f28c46160ec18d4009f33ad22f435

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