Hi, we're trying to make a little simulation / calculation of blood pressure, but it's a bit janky at the minute. Here's the python code:

# Systolic Pressure:
# A factor of:
# stroke volume (SV), the amount of blood ejected by the heart with each beat.
# heart rate (hr), higher HR increases systolic pressure due to pumping more frequently.
# vascular resistance (vr), resistance in the arteries due to narrowing or widening of the blood vessels.
# Elastisity (vessel flexibility) how much your arteries stretch. Stiff arteries increase systeolic pressure.

# Diastolic Pressure:
# vascular resistance (vr)
# blood volume (BV) - more blood in those arteries increases the force exterted on the artery walls.
# VF - Stiff arteries also increase diastolic pressure as they don't relax as much.

# SP = (HR * SV * VR) / VF
# DP = (VR * BV) / VF

def calculate_systolic_pressure(heart_rate, stroke_volume_liters, vascular_resistance, vessel_flexibility):
    """
    Calculate systolic blood pressure based on the main physiological factors.

    heart_rate: Number of beats per minute (HR)
    stroke_volume_liters: Volume of blood pumped per beat (normally in liters)
    vascular_resistance: Resistance to blood flow (neutral = 1.0)
    vessel_flexibility: Elasticity of the blood vessels (neutral = 1.0)
    """

    # Base calculation for systolic pressure (scaling stroke volume and heart rate)
    base_pressure = (heart_rate * stroke_volume_liters * vascular_resistance) / vessel_flexibility

    # Scaling factor to adjust systolic pressure into mmHg range
    systolic_bp = base_pressure * 23  # Adjust scaling factor to match expected range

    return systolic_bp


def calculate_diastolic_pressure(blood_volume_liters, vascular_resistance, vessel_flexibility):
    """
    Calculate diastolic blood pressure based on the main physiological factors.

    blood_volume_liters: Total liters of blood in the body (normally around 5 liters)
    vascular_resistance: Resistance to blood flow (neutral = 1.0)
    vessel_flexibility: Elasticity of the blood vessels (neutral = 1.0)
    """

    # Base calculation for diastolic pressure
    base_pressure = blood_volume_liters * vascular_resistance

    # Adjust for vessel flexibility: stiff vessels increase pressure
    diastolic_bp = base_pressure / vessel_flexibility

    # Scaling factor to get the result into mmHg range
    diastolic_bp *= 15  # This scaling factor can be adjusted for more precision

    return diastolic_bp


# Baseline NPC values
npc_heart_rate = 75  # Beats per minute
npc_blood_volume_liters = 5.0 # Blood volume in liters
npc_stroke_volume_liters = 0.07  # Stroke volume in liters (70 mL)
npc_vascular_resistance = 1.0  # Neutral vascular resistance
npc_vessel_flexibility = 1.0  # Normal vessel flexibility

# Calculate systolic pressure
systolic_bp = calculate_systolic_pressure(npc_heart_rate, npc_stroke_volume_liters, npc_vascular_resistance, npc_vessel_flexibility)

print(f"NPC Systolic Pressure (Baseline): {systolic_bp} mmHg")

# Calculate diastolic pressure
diastolic_bp = calculate_diastolic_pressure(npc_blood_volume_liters, npc_vascular_resistance, npc_vessel_flexibility)

print(f"NPC Diastolic Pressure (Baseline): {diastolic_bp} mmHg")


Can you take a look?