OpenIslet

scripts/run_layer4_tissue_and_metabolic_twin.py

Layer 4: Multi-Scale Tissue, Vascular & Metabolic Digital Twin Plane (v0.8.0)

script Release v0.8.0 gen-eb955f8266035aba 713 KB · 47 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/run_layer4_tissue_and_metabolic_twin.py · SHA-256: 624a491d5e418a7d…

                    round(100.0 * (0.60 * 1.20) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0))), 2),
                ],
                "minimum_required_pdms_or_precipitate_ca2_plus_retention_pct": [
                    round(100.0 * (1.0 - (0.60 * 0.30) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0)))), 2),
                    round(100.0 * (1.0 - (0.60 * 1.20) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0)))), 2),
                ],
                "paired_sink_volume_retention_records_kimi31_r2": [
                    {
                        "sink_exchange_volume_72h_liters": 0.30,
                        "unretained_100pct_export_added_ca2_plus_mM": round((n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0))) / 0.30, 4),
                        "max_allowable_72h_ca2_plus_export_fraction_pct": round(100.0 * (0.60 * 0.30) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0))), 2),
                        "minimum_required_pdms_or_precipitate_ca2_plus_retention_pct": round(100.0 * (1.0 - (0.60 * 0.30) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0)))), 2),
                    },
                    {
                        "sink_exchange_volume_72h_liters": 1.20,
                        "unretained_100pct_export_added_ca2_plus_mM": round((n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0))) / 1.20, 4),
                        "max_allowable_72h_ca2_plus_export_fraction_pct": round(100.0 * (0.60 * 1.20) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0))), 2),
                        "minimum_required_pdms_or_precipitate_ca2_plus_retention_pct": round(100.0 * (1.0 - (0.60 * 1.20) / (n_cao2_mmol_dx * (1.0 - math.exp(-math.log(2.0) * 72.0 / 68.0)))), 2),
                    },
                ],
            },
            "pdms_phase_retention_and_stage0_gate": (
                "Hydrolyzing 52.0% of 10.9811 mmol CaO2 over 0-72h generates 5.70994 mmol Ca(OH)2 (5.71 mmol Ca2+ and 11.42 mmol OH-) "
                "inside the hydrophobic PDMS microbead phase; over the Stage-0 sink exchange volume of 0.5-2.0 mL/cm^2/day across 200 cm^2 "
                "for 3 days (0.30-1.20 L), 100% unretained export would add 19.0331-4.7583 mM Ca2+, so maintaining interstitial [Ca2+] <= 1.80 mM "
                "(above 1.20 mM basal medium, Delta <= 0.60 mM) requires <=3.15-12.61% cumulative 72-h Ca2+ export (>=87.39-96.85% solid-phase "
                "retention inside the hydrophobic PDMS matrix or an active chelator/buffer sink). Stage-0 bench qualification requires ICP-OES "
                "interstitial [Ca2+] <= 1.8 mM and negative Alizarin Red S / von Kossa hydrogel calcification across 14 days (AUDIT-REF & AUDIT-REF)."
            ),
        },
        "dynamic_viability_trapezoidal_vs_right_endpoint_sensitivity_astra_r1": {
            "passing_regimes_viability_fraction_all_quadratures": 1.0,
            "toxic_unbuffered_control_right_endpoint_dt_1p0h": 0.009126,
            "toxic_unbuffered_control_trapezoidal_dt_1p0h": 0.006403,
            "toxic_unbuffered_control_trapezoidal_dt_1p0h_current_hazard_exact": 0.006244,
            "toxic_unbuffered_control_fine_step_dt_0p03125h": 0.006383,
            "toxic_unbuffered_control_fine_step_right_endpoint_dt_0p03125h": 0.006383,
            "toxic_unbuffered_control_fine_step_trapezoidal_dt_0p03125h": 0.006308,
            "note": (
                "All passing lead and Design X regimes remain at 1.0000 viability under both right-endpoint and fine-step trapezoidal hazard quadrature; "
                "on the toxic unbuffered control, current hazard quadrature gives 0.009126 (dt = 1.0 h right-endpoint), 0.006244 (dt = 1.0 h trapezoidal; "
                "0.006403 legacy reference), 0.006383 (dt = 0.03125 h fine-step right-endpoint), and 0.006308 (dt = 0.03125 h fine-step trapezoidal; "
                "AUDIT-REF & AUDIT-REF)."
            ),
        },
        "host_gel_avascular_standoff_and_masked_lamina_perfusion_sensitivity_sonnet55_r1": {
            "avascular_standoff_delta_z_0um_cluster_surface_po2_gel_only_mmhg": 18.39,
            "avascular_standoff_delta_z_30um_cluster_surface_po2_gel_only_mmhg": 14.54,
            "avascular_standoff_delta_z_50um_cluster_surface_po2_gel_only_mmhg": 12.66,
            "avascular_standoff_delta_z_100um_cluster_surface_po2_gel_only_mmhg": 9.45,
            "chronic_post_inosculation_day7_14_robin_bc_120um_surface_and_core_po2_mmhg": {
                "delta_z_0um": {"min_slab_mmhg": 23.48, "surface_mmhg": 18.18, "core_mmhg": 6.97},
                "delta_z_30um": {"min_slab_mmhg": 20.39, "surface_mmhg": 15.15, "core_mmhg": 4.16},
                "delta_z_50um": {"min_slab_mmhg": 18.97, "surface_mmhg": 13.75, "core_mmhg": 2.94},
                "delta_z_100um": {"min_slab_mmhg": 16.80, "surface_mmhg": 11.63, "core_mmhg": 1.33},
            },
            "chronic_zero_source_live_nz201_bvp_standoff_table_d_o2_floor_9p40e_6_and_high_1p50e_5_mmhg": {
                f"delta_z_{int(dz_u)}um": {
                    "d_o2_floor_9p40e_6": (
                        lambda p_s: {
                            "min_slab_mmhg": round(p_s, 4),
                            "120um_surf_core_mmhg": _bvp_gel_surf_core_4dec(p_s, 0.0060, local_phi_dx, D_O2_HYDROGEL_CM2_S, 1.0),
                            "100um_dxb_surf_core_mmhg": _bvp_gel_surf_core_4dec(p_s, 0.0050, local_phi_dx, D_O2_HYDROGEL_CM2_S, 1.0),
                        }
                    )(_solve_chronic_zero_source_bvp_live(40.0, float(dz_u), 1.000, a_design_x, 0.14 * 0.97, D_O2_HYDROGEL_CM2_S)),
                    "d_o2_high_1p50e_5": (
                        lambda p_s: {
                            "min_slab_mmhg": round(p_s, 4),
                            "120um_surf_core_mmhg": _bvp_gel_surf_core_4dec(p_s, 0.0060, local_phi_dx, 1.50e-5, 1.0),
                            "100um_dxb_surf_core_mmhg": _bvp_gel_surf_core_4dec(p_s, 0.0050, local_phi_dx, 1.50e-5, 1.0),
                        }
                    )(_solve_chronic_zero_source_bvp_live(40.0, float(dz_u), 1.000, a_design_x, 0.14 * 0.97, 1.50e-5)),
                }
                for dz_u in (0, 30, 50, 100)
            },
            "masked_outer_annulus_perfusion_120um_cluster_surface_po2_gel_only_mmhg": 14.05,
            "masked_outer_annulus_perfusion_120um_core_po2_gel_only_mmhg": 3.19,
            "masked_outer_annulus_perfusion_120um_core_po2_localized_cat_mmhg": 3.12,
            "dx_b_100um_cluster_diameter_cap_masked_perfusion_surface_po2_mmhg": 15.60,
            "dx_b_100um_cluster_diameter_cap_masked_perfusion_core_po2_mmhg": 7.81,
            "dx_b_100um_cluster_diameter_cap_masked_perfusion_localized_cat_surface_and_core_mmhg": [15.51, 7.73],
            "dx_b_80um_cluster_diameter_cap_masked_perfusion_surface_po2_mmhg": 16.91,
            "dx_b_80um_cluster_diameter_cap_masked_perfusion_core_po2_mmhg": 11.87,
            "dx_b_80um_cluster_diameter_cap_masked_perfusion_localized_cat_surface_and_core_mmhg": [16.82, 11.78],
            "executable_parameter_support_in_pde_solver_sol61_r2": {
                "d_o2_hydrogel_override_cm2_s_supported": True,
                "perfusion_spatial_mode_outer_annulus_masked_supported": True,
                "external_standoff_um_robin_bc_supported": True,
            },
            "note": (
                "Quantifies two coupled physical boundary effects on Design X (exposed as executable parameters "
                "d_o2_hydrogel_override_cm2_s, perfusion_spatial_mode='outer_annulus_masked', and external_standoff_um in "
                "_run_single_pouch_pde_regime; AUDIT-REF): (1) adding an external avascular host-gel "
                "stand-off layer delta_z in {0, 30, 50, 100} um outside z = +/-175 um lowers 120 um cluster-surface pO2 from "
                "18.39 mmHg (0 um) to 14.54 mmHg (30 um), 12.66 mmHg (50 um), and 9.45 mmHg (100 um) under steady-state boundary flux subtraction "
                "(and to 18.18/6.97, 15.15/4.16, 13.75/2.94, and 11.63/1.33 mmHg surface/core under the post-inosculation Day 7-14 Robin-BC PDE); "
                "and (2) restricting host capillary perfusion k_perf(z) strictly to the outer cell-laden hydrogel bands (|z| > 50 um, zeroing vascular sink/supply "
                "inside the central PDMS-CaO2 lamina; min_slab_po2 = 19.27 mmHg uniform cat / 19.18 mmHg localized cat at t = 336 h) yields "
                "14.05 mmHg surface / 3.19 mmHg core pO2 (13.96 / 3.12 mmHg with localized k_1 = 7.56 s^-1) for 120 um (R = 60 um) clusters, "
                "whereas the Design X-b (DX-b) <=100 um (R <= 50 um) and 80 um (R = 40 um) AggreWell cluster-diameter caps restore "
                "masked-perfusion cluster-surface / core pO2 to 15.60 / 7.81 mmHg (15.51 / 7.73 localized cat) and 16.91 / 11.87 mmHg "
                "(16.82 / 11.78 localized cat), clearing the >=15.0 mmHg full first-phase GSIS threshold (AUDIT-REF, "
                "D4-PDE-FV-1, Q3-P3, Q4-P4, AUDIT-REF, & AUDIT-REF)."
            ),
        },
        "d_o2_hydrogel_provenance_and_stage0_time_lag_coupon_gate_sonnet55_r1": {
            "modeled_d_o2_hydrogel_cm2_s": D_O2_HYDROGEL_CM2_S,
            "minimum_model_qualification_floor_d_o2_cm2_s": D_O2_HYDROGEL_CM2_S,
            "high_permeability_target_d_o2_cm2_s": 1.50e-5,
            "modeled_alpha_bunsen_mol_cm3_mmhg": ALPHA_BUNSEN_MOL_CM3_MMHG,
            "coupon_thickness_mm": 1.5,
            "expected_time_lag_at_9p4e_6_cm2_s_seconds": 398.9,
            "expected_time_lag_at_1p5e_5_cm2_s_seconds": 250.0,
            "expected_time_lag_at_1p6e_5_cm2_s_seconds": 234.4,
            "spatial_ph_micro_optode_transect_max_delta_ph": 0.10,
            "bulk_medium_ph_qualification_band": [7.25, 7.45],
            "minimum_model_qualification_permeability_p_o2_mol_cm_s_mmhg": round(ALPHA_BUNSEN_MOL_CM3_MMHG * D_O2_HYDROGEL_CM2_S, 17),
            "high_permeability_target_p_o2_mol_cm_s_mmhg": round(ALPHA_BUNSEN_MOL_CM3_MMHG * 1.50e-5, 17),
            "stage0_gate_p05_diff0": (
                "Stage-0 Gate P05 (DIFF-0): 37 C optical-sensor permeation time-lag (t_lag = L^2 / (6*D_O2)) and steady-state "
                "flux assay across 1.5 mm cell-free hydrogel and composite central-lamina coupons before cell encapsulation, "
                "enforcing a two-tier threshold: (a) Minimum Model-Qualification Floor D_O2,gel >= 9.40e-6 cm^2/s (t_lag <= 398.9 s, "
                "P_O2 = alpha*D >= 1.26e-14 mol/(cm*s*mmHg), matching the conservative Layer-4 PDE baseline constant D_O2_HYDROGEL_CM2_S), "
                "and (b) High-Permeability Engineering Target D_O2,gel >= 1.50e-5 cm^2/s (t_lag <= 250.0 s, P_O2 >= 2.01e-14 mol/(cm*s*mmHg) "
                "at alpha = 1.34e-9 mol/(cm^3*mmHg), or >=1.20e-14 mol/(cm*s*mmHg) under conservative macromolecular salt-out solubility), "
                "paired with 336-h empirical CaO2 release kinetic-law fitting at 36, 72, 168, 240, and 336 h (first-order 96.74% vs reaction "
                "shrinking-core 100.0% at 329.62 h vs diffusion shrinking-core 89.58% at unified t_1/2 = 68.0 h) and spatial "
                "ratiometric pH micro-optode transects across the lamina-hydrogel boundary (Delta pH <= 0.10 across z in [0, L_half], bulk pH 7.25-7.45; "
                "AUDIT-REF, AUDIT-REF, AUDIT-REF, & AUDIT-REF)."
            ),
        },
        "joint_adverse_corner_stress_audit_muse_r1": {
            "description": (
                "Explicit multi-factor adverse corner stress audit combining Bruggeman D_O2,lamina = eps^1.5 * D_O2,gel, "
                "elevated OCR multiplier (1.10x), reduced boundary pO2 (32.5 and 30.0 mmHg), 0.25x catalase activity (k_1 = 1.89 s^-1), "
                "shrinking-core CaO2 kinetics, external avascular host-gel stand-off (delta_z = 30 um), and outer-annulus-masked "
                "host capillary perfusion (k_perf(z) = 0 for |z| <= 50 um)."
            ),
            "r60um_120um_cluster_combined_adverse_corner_status": "FAILS_15MMHG_SURFACE_GSIS_THRESHOLD_UNDER_COMBINED_STRESS",
            "dx_b_r40um_80um_cluster_cap_restores_oxygen_margin": True,
            "dx_b_r40um_80um_cluster_cap_restores_oxygen_margin_at_d_target_1p5e5": True,
            "dx_b_r40um_80um_cluster_cap_restores_oxygen_margin_at_d_floor_9p4e6_two_scale_t16h": False,
            "dx_b_r40um_80um_cluster_cap_restores_margin": True,
            "cat0p25x_peroxide_6p904uM_fails_5uM_and_2p5uM_gates": True,
            "pde_verified_corner_matrix_nz201_argon_r2": {
                "baseline_pb40_cat1x_fo_d_floor_9p4e6": {"min_slab_mmhg": 23.70, "max_h2o2_uM": 2.046, "r60_120um_surf_core_mmhg": [18.39, 7.17], "r50_100um_surf_core_mmhg": [19.99, 12.10], "r40_80um_surf_core_mmhg": [21.31, 16.24]},
                "baseline_pb40_cat1x_fo_d_target_1p5e5": {"min_slab_mmhg": 27.14, "min_slab_uniform_cat18_comparator_mmhg": 27.80, "min_slab_uniform_cat18_current_solver_mmhg": 27.19, "max_h2o2_uM": 2.046, "r60_120um_surf_core_mmhg": [24.08, 12.69], "r50_100um_surf_core_mmhg": [25.01, 17.06], "r40_80um_surf_core_mmhg": [25.77, 20.67]},
                "pb40_cat0p25x_1p89_sc_d_floor_9p4e6": {"min_slab_mmhg": 22.00, "max_h2o2_uM": 6.904, "passes_5uM_h2o2_gate": False, "r60_120um_surf_core_mmhg": [16.71, 5.60], "r50_100um_surf_core_mmhg": [18.30, 10.44], "r40_80um_surf_core_mmhg": [19.62, 14.56]},
                "pb32p5_cat0p25x_1p89_sc_d_floor_9p4e6": {"min_slab_mmhg": 14.76, "max_h2o2_uM": 6.904, "passes_5uM_h2o2_gate": False, "r60_120um_surf_core_mmhg": [9.77, 0.41], "r50_100um_surf_core_mmhg": [11.16, 3.63], "r40_80um_surf_core_mmhg": [12.42, 7.47]},
                "pb32p5_cat0p25x_1p89_sc_d_target_1p5e5": {"min_slab_mmhg": 19.50, "max_h2o2_uM": 6.904, "passes_5uM_h2o2_gate": False, "r60_120um_surf_core_mmhg": [16.49, 5.38], "r50_100um_surf_core_mmhg": [17.39, 9.56], "r40_80um_surf_core_mmhg": [18.15, 13.10]},
                "pb30_cat0p25x_1p89_sc_d_floor_9p4e6": {"min_slab_mmhg": 12.40, "max_h2o2_uM": 6.904, "passes_5uM_h2o2_gate": False, "r60_120um_surf_core_mmhg": [7.68, 0.08], "r50_100um_surf_core_mmhg": [8.88, 1.72], "r40_80um_surf_core_mmhg": [10.09, 5.22]},
                "pb30_cat0p25x_1p89_sc_d_target_1p5e5": {"min_slab_mmhg": 17.04, "max_h2o2_uM": 6.904, "passes_5uM_h2o2_gate": False, "r60_120um_surf_core_mmhg": [14.05, 3.20], "r50_100um_surf_core_mmhg": [14.94, 7.18], "r40_80um_surf_core_mmhg": [15.69, 10.67]},
                "masked_perf_standoff30um_ocr1p10x_pb40_d_floor_9p4e6": {"min_slab_mmhg": 14.12, "max_h2o2_uM": 2.046, "passes_5uM_h2o2_gate": True, "r60_120um_surf_core_mmhg": [8.76, 0.04], "r50_100um_surf_core_mmhg": [10.22, 2.02], "r40_80um_surf_core_mmhg": [11.58, 5.83]},
                "masked_perf_standoff30um_ocr1p10x_pb40_d_target_1p5e5": {"min_slab_mmhg": 18.01, "max_h2o2_uM": 2.045, "passes_5uM_h2o2_gate": True, "r60_120um_surf_core_mmhg": [14.74, 3.10], "r50_100um_surf_core_mmhg": [15.72, 7.25], "r40_80um_surf_core_mmhg": [16.55, 11.09]},
            },
            "two_scale_propagated_and_full_trajectory_hour16_extrema_astra_r2": {
                "masked_perf_standoff30um_ocr1p10x_pb40_d_floor_9p4e6_two_scale_propagated_t16h": {
                    "min_slab_mmhg_at_t16h": 9.21,
                    "min_slab_mmhg_at_t12h_coarse_sample": 14.12,
                    "r60_120um_surf_core_mmhg_at_t16h": [3.89, 0.0005],
                    "r50_100um_surf_core_mmhg_at_t16h": [5.14, 0.24],
                    "r40_80um_surf_core_mmhg_at_t16h": [6.57, 1.79],
                    "r40_80um_surf_core_mmhg_at_t16h_local_phi_1p0x_ocr_bvp": _bvp_gel_surf_core(9.21, 0.0040, local_phi_dx),
                },
                "masked_perf_standoff30um_ocr1p10x_pb40_d_target_1p5e5_two_scale_propagated_t16h": {
                    "min_slab_mmhg_at_t16h": 18.08,
                    "min_slab_mmhg_at_t336h_global_min": 18.08,
                    "min_slab_mmhg_at_t16h_snapshot_exact": 19.54,
                    "r60_120um_surf_core_mmhg_at_t16h": [14.81, 3.17],
                    "r60_120um_surf_core_mmhg_at_t336h_two_scale_propagated": [14.77, 3.17],
                    "r60_120um_surf_core_mmhg_at_t16h_snapshot_two_scale_propagated": [16.21, 4.39],
                    "r50_100um_surf_core_mmhg_at_t16h": [15.80, 7.33],
                    "r50_100um_surf_core_mmhg_at_t336h_two_scale_propagated": [15.75, 7.33],
                    "r50_100um_surf_core_mmhg_at_t16h_snapshot_two_scale_propagated": [17.20, 8.69],
                    "r40_80um_surf_core_mmhg_at_t16h": [16.63, 11.07],
                    "r40_80um_surf_core_mmhg_at_t336h_two_scale_propagated": [16.60, 11.07],
                    "r40_80um_surf_core_mmhg_at_t16h_snapshot_two_scale_propagated": [18.05, 12.50],
                    "r40_80um_surf_core_mmhg_at_t16h_local_phi_1p0x_ocr_bvp": _bvp_gel_surf_core(18.08, 0.0040, local_phi_dx, 1.50e-5),
                    "r40_80um_surf_core_mmhg_at_t16h_snapshot_local_phi_1p0x_ocr_bvp": _bvp_gel_surf_core(19.54, 0.0040, local_phi_dx, 1.50e-5),
                },
                "minimum_retained_catalase_fraction_for_2p5uM_bench_gate_first_order": {
                    "required_fraction_of_7p56_s_inv_design_x_loading": 0.8158,
                    "strict_unrounded_required_fraction_for_le_2p5000uM": 0.8159,
                    "required_effective_k1_s_inv_for_2p5uM_gate": 6.17,
                    "strict_unrounded_required_k1_s_inv_for_le_2p5000uM": 6.1682,
                    "required_fraction_for_5p0uM_model_screen": 0.40,
                    "required_effective_k1_s_inv_for_5p0uM_screen": 3.02,
                },
            },
            "stage0_mitigation_rule": (
                "Under stacked adverse corners (e.g., masked lamina perfusion + delta_z = 30 um stand-off + 1.10x OCR, or P_boundary = 32.5/30.0 mmHg "
                "+ 0.25x catalase + shrinking-core), at the conservative model floor D_O2 = 9.40e-6 cm^2/s, reducing cluster diameter from 120 um "
                "to 80-100 um (DX-b) protects the >=2.0 mmHg anoxic core floor on the 12-h coarse grid (core pO2 = 2.02-5.83 mmHg and 3.63-7.47 mmHg respectively, vs 0.04-0.41 mmHg "
                "at 120 um; whereas on the full 0.25-h trajectory at Hour 16 with 1.10x OCR and D_O2 propagated into the 3D spherical cluster solver, "