""" IPA Roller Compaction Synthetic Dataset Generator v1.0 ======================================================== Generates a physically plausible synthetic dataset based on: - Johanson rolling theory (Johanson, 1965) for nip angle & pressure - Heckel equation for powder densification under pressure - Empirical twin-feed-screw effect on ribbon uniformity THIS IS SYNTHETIC EDUCATIONAL DATA. NOT REAL CUSTOMER OR LAB DATA. Generated by Innovative Process Applications (IPA) for teaching DOE/RSM. """ import numpy as np import pandas as pd rng = np.random.default_rng(seed=42) # reproducible # ---- Physical constants & realistic ranges ---- # Grounded in published roller compaction literature for pharma excipients # (microcrystalline cellulose / lactose blends on lab-to-pilot scale rolls) N_RUNS = 600 # enough for DOE/RSM teaching, small enough to inspect by eye # Process parameter ranges (realistic for IPA CL-series lab/pilot compactors) ROLL_FORCE_KN_CM = (2.0, 14.0) # kN/cm of roll width ROLL_SPEED_RPM = (1.0, 12.0) # roll rotation speed FEED_SCREW_RPM = (10.0, 120.0) # twin feed screw speed ROLL_GAP_MM = (1.5, 4.5) # ribbon thickness target # Material parameters (MCC-lactose blend, representative) RHO_TRUE = 1.55 # true density, g/cc RHO_BULK = 0.45 # tapped bulk density, g/cc HECKEL_K = 0.018 # 1/MPa, Heckel compressibility constant HECKEL_A = 0.62 # Heckel intercept (related to initial packing) # Machine geometry (representative of CL2x6 class roller compactor) ROLL_DIAMETER_MM = 150.0 ROLL_WIDTH_MM = 50.0 def johanson_pressure_mpa(force_kn_per_cm, gap_mm): """ Approximation of peak nip pressure from Johanson rolling theory. Pressure scales with force/(contact area), and contact area grows with sqrt(R * (gap_entry - gap)). """ # Effective contact length proxy (mm): sqrt(R * delta_gap) # Assume entry gap ~ 3x exit gap for MCC-like materials contact_len_mm = np.sqrt(ROLL_DIAMETER_MM/2 * 2.0 * gap_mm) # Force per unit area: (kN/cm * 10 N/mm) / (contact_len_mm) -> MPa-ish pressure = (force_kn_per_cm * 100.0) / contact_len_mm return pressure # MPa def heckel_relative_density(pressure_mpa): """Heckel equation: ln(1/(1-D)) = K*P + A => D = 1 - exp(-(K*P + A))""" return 1.0 - np.exp(-(HECKEL_K * pressure_mpa + HECKEL_A)) def feed_ratio_effect(feed_rpm, roll_rpm): """ Twin feed screw effect: under-feeding starves the nip (low density, high variability); over-feeding causes slip and pre-compaction. Optimal ratio roughly 8-15 for twin screws on MCC. """ ratio = feed_rpm / roll_rpm # Gaussian-like response centered at ratio=11 optimality = np.exp(-((ratio - 11.0) ** 2) / (2 * 6.0**2)) return optimality # 0..1 # ---- Generate runs ---- roll_force = rng.uniform(*ROLL_FORCE_KN_CM, N_RUNS) roll_speed = rng.uniform(*ROLL_SPEED_RPM, N_RUNS) feed_speed = rng.uniform(*FEED_SCREW_RPM, N_RUNS) roll_gap = rng.uniform(*ROLL_GAP_MM, N_RUNS) # Physics peak_pressure = johanson_pressure_mpa(roll_force, roll_gap) base_rel_density = heckel_relative_density(peak_pressure) feed_opt = feed_ratio_effect(feed_speed, roll_speed) # Combine: good feed ratio lets you reach base density; poor ratio penalizes relative_density = base_rel_density * (0.85 + 0.15 * feed_opt) # Add realistic measurement noise (~1.5% relative) relative_density += rng.normal(0, 0.015, N_RUNS) relative_density = np.clip(relative_density, 0.40, 0.95) ribbon_density = relative_density * RHO_TRUE # g/cc porosity = 1.0 - relative_density # fraction # Ribbon uniformity: twin feed screws give lower CV across roll width # when feed ratio is in the sweet spot; degrades otherwise density_cv_pct = (2.0 + 4.5 * (1 - feed_opt)) + rng.normal(0, 0.4, N_RUNS) density_cv_pct = np.clip(density_cv_pct, 1.0, 10.0) throughput_kg_hr = ( roll_speed * roll_gap * ROLL_WIDTH_MM * ribbon_density * 60 / 1000 * 0.85 ) + rng.normal(0, 1.5, N_RUNS) throughput_kg_hr = np.clip(throughput_kg_hr, 0, None) df = pd.DataFrame({ "run_id": np.arange(1, N_RUNS + 1), "roll_force_kN_per_cm": np.round(roll_force, 2), "roll_speed_rpm": np.round(roll_speed, 2), "feed_screw_rpm": np.round(feed_speed, 1), "roll_gap_mm": np.round(roll_gap, 2), "peak_pressure_MPa": np.round(peak_pressure, 1), "ribbon_rel_density": np.round(relative_density, 4), "ribbon_density_g_cc": np.round(ribbon_density, 4), "ribbon_porosity": np.round(porosity, 4), "density_CV_percent": np.round(density_cv_pct, 2), "throughput_kg_hr": np.round(throughput_kg_hr, 2), }) df.to_csv("ribbon_density_v1.0.csv", index=False) print(f"Wrote {len(df)} rows") print(df.describe().round(3))