Spaces:
Sleeping
Sleeping
File size: 7,927 Bytes
2678c29 3edc1f3 2678c29 3edc1f3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
import streamlit as st
import numpy as np
st.set_page_config(page_title="Tesla-Inspired Valve: Flow Modeling", layout="wide")
st.title("Tesla-Inspired Valve: Flow Modeling with Hemolysis Risk Indicator")
st.markdown("This tool allows you to model your Tesla valve design and estimate its performance, including hemolysis risk and overall efficiency. Adjust the parameters below to find an optimal configuration.")
# Constants (fixed)
rho = 1060 # Density (kg/m³)
mu = 0.0035 # Viscosity (Pa·s)
tau_limit = 150 # Pa, Hemolysis shear stress limit
D_annulus_cm = 3.5 # cm, Mitral valve annulus diameter
st.sidebar.title("🔒 Fixed Constants")
st.sidebar.markdown(f"**Blood Density (ρ):** {rho} kg/m³")
st.sidebar.markdown(f"**Viscosity (μ):** {mu} Pa·s")
st.sidebar.markdown(f"**Hemolysis Limit (τ):** {tau_limit} Pa")
st.sidebar.markdown(f"**Mitral Annulus Diameter:** {D_annulus_cm} cm")
# --- User Inputs ---
st.header("🔬 Design Parameters")
st.markdown("Adjust these sliders to define your Tesla valve's geometry and performance.")
col_design1, col_design2, col_design3 = st.columns(3)
with col_design1:
num_valves = st.slider("Number of Tesla Valve Units", 1, 100, 10, help="Total number of individual Tesla valve units.")
with col_design2:
valve_width_mm = st.slider("Single Valve Width (mm)", 4, 20, 12, help="The width of a single Tesla valve unit's footprint.")
with col_design3:
diodicity = st.slider("Diodicity (Di)", 1.0, 50.0, 20.0, help="The ratio of reverse pressure drop to forward pressure drop.")
# --- Physiological Parameters ---
st.header("🩺 Physiological Conditions")
st.markdown("These values represent typical heart function under which your device must operate.")
col_phys1, col_phys2 = st.columns(2)
with col_phys1:
deltaP_rev_mmHg = st.slider("Max Reverse Pressure (mmHg)", 60, 160, 100, help="The pressure drop across the valve during systole.")
deltaP_fwd_mmHg = st.slider("Forward Pressure (mmHg)", 2, 20, 5, help="The pressure gradient that drives forward flow (filling).")
t_rev = st.slider("Systole Time (s)", 0.2, 0.4, 0.3, 0.05, help="Duration of ventricular contraction.")
with col_phys2:
V_LV_mL = st.slider("Required Forward Volume (mL)", 50, 100, 70, help="The volume of blood the ventricle needs to fill.")
HR = st.slider("Heart Rate (BPM)", 50, 120, 70, help="The heart rate in beats per minute.")
# --- Calculations ---
t_fwd = (60 / HR) - t_rev
deltaP_rev = deltaP_rev_mmHg * 133.322 # Convert mmHg to Pa
deltaP_fwd = deltaP_fwd_mmHg * 133.322
# Calculate maximum possible valve width based on annulus area and valve count
valve_area_total_cm2 = np.pi * (D_annulus_cm / 2)**2
valve_width_max_mm = np.sqrt(valve_area_total_cm2 / (num_valves * np.pi)) * 2 * 10
# Note: This is a simplified calculation, but it provides a good estimate.
st.markdown("---")
st.header("🧮 Results & Analysis")
# --- Reverse Flow Calculations ---
st.subheader("🔁 Reverse Flow (Regurgitation)")
# We use Diodicity to calculate the reverse flow
# Assuming a simplified relationship based on the design parameters
# A_single is the equivalent cross-sectional area of a single valve's channels
A_valve_cross_section_mm2 = (np.pi * (D_annulus_cm / 2)**2 * 100) / num_valves
A_single = A_valve_cross_section_mm2 / 1000000
# Calculate equivalent pressure drop in forward flow
deltaP_fwd_equiv = deltaP_rev / diodicity
# Estimate reverse velocity based on forward pressure drop and equivalent area
# Using a simplified orifice flow model for the effective pressure drop
v_rev = np.sqrt(2 * deltaP_fwd_equiv / rho)
Q_rev = A_single * num_valves * v_rev
V_rev_L = Q_rev * t_rev * 1000
# Calculate Regurgitant Fraction (RF)
RF = (V_rev_L / (V_LV_mL / 1000)) * 100
# Hemolysis Risk (Shear Stress)
# This is a highly simplified model; real CFD is needed.
# We'll assume shear stress is proportional to velocity and inversely proportional to valve width
tau = rho * v_rev * v_rev / (valve_width_mm / 1000)
rf_status = "✅" if RF < 5 else "❌"
shear_status = "✅" if tau < tau_limit else "❌"
st.write(f"Total Reverse Flow Volume: **{V_rev_L:.2f} L**")
st.write(f"Regurgitant Fraction (RF): **{RF:.2f}%** {rf_status}")
st.write(f"Estimated Peak Shear Stress: **{tau:.1f} Pa** {shear_status}")
if tau >= tau_limit:
st.warning(f"**Warning:** The estimated shear stress ({tau:.1f} Pa) exceeds the hemolysis limit of {tau_limit} Pa. This could cause red blood cell damage. Consider increasing the valve width or the number of valves.")
# --- Forward Flow Calculations ---
st.subheader("✅ Forward Flow")
v_fwd = np.sqrt(2 * deltaP_fwd / rho)
Q_fwd = A_single * num_valves * v_fwd
V_fwd_L = Q_fwd * t_fwd * 1000
forward_status = "✅" if V_fwd_L * 1000 >= V_LV_mL else "❌"
tau_fwd = rho * v_fwd * v_fwd / (valve_width_mm / 1000)
st.write(f"Total Forward Flow Volume: **{V_fwd_L * 1000:.2f} mL**")
st.write(f"Required Volume to Fill: **{V_LV_mL:.2f} mL** {forward_status}")
st.write(f"Estimated Shear Stress: **{tau_fwd:.1f} Pa**")
if V_fwd_L * 1000 < V_LV_mL:
st.warning("The forward flow volume is insufficient. Consider increasing the number of valves or their width to improve heart filling.")
st.markdown("---")
st.subheader("📢 Design Guidance")
st.write(f"Maximum theoretical width for a single valve unit is **{valve_width_max_mm:.2f} mm** to fit all {num_valves} valves within the annulus.")
st.write("A good design will have all checkmarks (✅) and minimize the Regurgitant Fraction.")
st.markdown("---")
st.header("📖 Parameter Explanations")
st.subheader("User Inputs (Design & Physiological)")
st.markdown("""
- **Number of Tesla Valve Units:** The total number of individual Tesla valve units that make up the complete valve. More units can improve overall flow but require a smaller footprint for each.
- **Single Valve Width (mm):** The physical width of a single Tesla valve unit's footprint. This is a crucial design parameter that influences shear stress and manufacturability.
- **Diodicity (Di):** The primary performance metric for a Tesla valve. It's the ratio of the pressure drop in the reverse direction to the pressure drop in the forward direction. A higher number indicates a more effective valve.
- **Max Reverse Pressure (mmHg):** The maximum pressure difference between the left ventricle and left atrium during systole, which drives the regurgitant flow.
- **Forward Pressure (mmHg):** The pressure gradient that drives the flow of blood from the left atrium to the left ventricle during diastole. This should be minimal to ensure proper filling.
- **Systole Time (s):** The duration of the heart's contraction phase, during which regurgitation can occur.
- **Required Forward Volume (mL):** The volume of blood the left ventricle needs to receive from the left atrium in a single heartbeat to function effectively.
- **Heart Rate (BPM):** The number of times the heart beats per minute. This determines the total time for the cardiac cycle.
""")
st.subheader("Outputs (Results & Analysis)")
st.markdown("""
- **Total Reverse Flow Volume (L):** The total volume of blood that is estimated to leak back into the left atrium per heartbeat. This is what you want to minimize.
- **Regurgitant Fraction (RF):** The percentage of the total blood pumped by the heart that leaks backward. A value less than 5% is generally considered non-pathological.
- **Estimated Peak Shear Stress (Pa):** The estimated maximum shear force on red blood cells within the valve's channels. Values above 150 Pa are a significant hemolysis risk.
- **Total Forward Flow Volume (mL):** The total volume of blood that is estimated to flow from the left atrium into the left ventricle. This should be sufficient to meet the required forward volume.
- **Design Guidance:** Provides a maximum theoretical width for your valve units and summarizes the overall health of your design based on the chosen parameters.
""")
|