Engee documentation
Notebook

Regulation of glucose levels in the human body

Introduction

In this example, the system of glucose level regulation is considered. When plasma glucose levels are elevated, insulin secretion is stimulated. This increases the level of insulin in the blood, which increases the absorption of glucose by tissues. Increased outflow of glucose from the blood and interstitial fluid leads to a decrease in glucose concentration, which, in turn, causes a decrease in insulin secretion.

Additional functions

To calculate the solution of the balance equation solve_glucose_equation.

In [ ]:
function solve_glucose_equation(v, lambda, beta, alpha, phi, Ql, mu, theta, interval_min, interval_max)
    # We check the case without an insulin response (x ≤ φ)
    x_low = Ql / lambda
    if interval_min < x_low <= phi && x_low > 0
        return x_low, 0.0
    end

    # A case with an insulin response, but without renal discharge (φ < x ≤ θ)
    a1 = v * beta / alpha
    b1 = lambda - (v * beta * phi) / alpha
    c1 = -Ql
    
    discriminant_1 = b1^2 - 4*a1*c1
    roots1 = []
    if discriminant_1 >= 0
        x1 = (-b1 + sqrt(discriminant_1)) / (2*a1)
        x2 = (-b1 - sqrt(discriminant_1)) / (2*a1)
        roots1 = filter(x -> phi < x <= theta && x > 0, [x1, x2])
    end

    # The case of insulin response and renal discharge (x > θ)
    a2 = v * beta / alpha
    b2 = lambda + mu - (v * beta * phi) / alpha
    c2 = -Ql - mu*theta
    
    discriminant_2 = b2^2 - 4*a2*c2
    roots2 = []
    if discriminant_2 >= 0
        x3 = (-b2 + sqrt(discriminant_2)) / (2*a2)
        x4 = (-b2 - sqrt(discriminant_2)) / (2*a2)
        roots2 = filter(x -> x > theta && x > 0, [x3, x4])
    end

    # Choosing the smallest root
    all_roots = vcat(roots1, roots2)
    valid_roots = filter(x -> interval_min < x <= interval_max, all_roots)
       
    x_sol = minimum(valid_roots)        # Choosing the smallest point
    y_sol = (beta / alpha) * max(x_sol - phi, 0)
    return x_sol, y_sol
end;

To calculate the regulation curves, use the calculate_curves function.:

In [ ]:
function calculate_curves(x_range, v, lambda, beta, alpha, phi, mu, theta, Ql)
    # Calculation of insulin and glucose curves
    y_insulin = (beta / alpha) * max.(x_range .- phi, 0)
    
    y_glucose = zeros(length(x_range))
    for (i, x) in enumerate(x_range)
        if x <= theta
            y_glucose[i] = (Ql - lambda*x) / (v*x)
        else
            y_glucose[i] = (Ql - lambda*x - mu*(x - theta)) / (v*x)
        end
    end
    
    # Limitation of Y values in the range [0, 0.5]
    y_insulin[y_insulin .< 0] .= NaN
    y_insulin[y_insulin .> 0.5] .= NaN
    
    y_glucose[y_glucose .< 0] .= NaN
    y_glucose[y_glucose .> 0.5] .= NaN
    
    return y_insulin, y_glucose
end;

Theoretical information

In this model, the total volume of blood and interstitial fluids is represented by a single large compartment (V ~ 15 liters in an adult), and that the steady-state glucose concentration in this compartment is (mg/ml). To maintain this x level constant, the total glucose inflow into the compartment must equal the total outflow from it. Under normal conditions, glucose enters the bloodstream through absorption from the gastrointestinal tract or through production by the liver. In this example, the output flow rate is denoted as (mg/hr). There are three main ways to remove glucose from the blood:

  • When exceeds a certain threshold glucose is excreted by the kidneys at a rate proportional to the gradient between  and  :

Glucose leaves the blood and enters most cells by facilitated diffusion. In some tissues, the rate of glucose utilization depends only on the extracellular/intracellular concentration gradient. In most cases, the intracellular concentration can be ignored.:

In certain types of cells, such as muscle and fat, insulin helps to stimulate the process of facilitated diffusion. Therefore, the rate of glucose uptake by these cells is proportional , as well as the concentration of insulin in the blood  :

In the above equations   and  they are constant coefficients of proportionality. By equating the inflow to the sum of the three outflows, we obtain the following mass balance equations for blood glucose:

Insulin is produced by the pancreas at a rate that depends on plasma glucose levels. However, if falls below a certain threshold , the production of insulin stops. Thus, we have:

Insulin is destroyed in a reaction involving the enzyme insulinase at a rate proportional to its concentration in the blood:

Combining the previously obtained equations, we derive the equation connecting the stationary level c :

The glucose regulation model

The parameter values used in this calculation correspond to the norm for an adult.

In [ ]:
# Model parameters (normal conditions)
theta = 2.5       # Threshold of renal glucose excretion (mg/mL)
mu = 7200         # Renal excretion rate (mL/h)
lambda_val = 2470 # Insulin-independent utilization rate (mL/h)
v_val = 139000    # Coefficient of insulin-dependent utilization (mU⁻1h⁻1)
phi_val = 0.51    # Insulin secretion threshold (mg/mL)
beta_val = 1390   # Sensitivity of the insulin response (mL.U mL mg⁻1 h⁻1)
alpha_val = 7600  # Insulin Breakdown Rate (mL/h)
Ql_val = 8400;    # Glucose intake rate (mg/h)

Let's calculate for three scenarios:

  • Normal process,

  • Type 1 diabetes,

  • Type 2 diabetes.

In [ ]:
# The normal process
x_normal, y_normal = solve_glucose_equation(v_val, lambda_val, beta_val, alpha_val, phi_val, Ql_val, mu, theta, 0.0, 10.0)

# Type 1 diabetes: decreased sensitivity of the insulin response
beta_d1 = 0.2 * beta_val  
x_d1, y_d1 = solve_glucose_equation(v_val, lambda_val, beta_d1, alpha_val, phi_val, Ql_val, mu, theta, 0.0, 10.0)

# Type 2 diabetes: decreased insulin-dependent utilization
v_d2 = 0.2 * v_val       
x_d2, y_d2 = solve_glucose_equation(v_d2, lambda_val, beta_val, alpha_val, phi_val, Ql_val, mu, theta, 0.0, 10.0);

The results of the analysis of the calculation of stationary glucose regulation points.

In [ ]:
# Output of results
println("Stationary glucose regulation points:")
println("------------------------------------")
println("Normal conditions (N):")
println("  Glucose = ", round(x_normal, digits=4), " mg/mL")
println("  Insulin = ", round(y_normal, digits=4), " mU/mL")
println("Type 1 diabetes (D1):")
println("  Glucose = ", round(x_d1, digits=4), " mg/mL")
println("  Insulin = ", round(y_d1, digits=4), " mU/mL")
println("Type 2 diabetes (D2):")
println("  Glucose = ", round(x_d2, digits=4), " mg/mL")
println("  Insulin = ", round(y_d2, digits=4), " mU/mL")
Стационарные точки регуляции глюкозы:
------------------------------------
Нормальные условия (N):
  Глюкоза = 0.8172 mg/mL
  Инсулин = 0.0562 mU/mL

Диабет 1-го типа (D1):
  Глюкоза = 1.2975 mg/mL
  Инсулин = 0.0288 mU/mL

Диабет 2-го типа (D2):
  Глюкоза = 1.2975 mg/mL
  Инсулин = 0.144 mU/mL

Calculation of graphs for three scenarios.

In [ ]:
x_range = 0.0:0.01:2.0  # Range of glucose concentrations

# Calculation for three scenarios
y_ins_norm, y_gluc_norm = calculate_curves(x_range, v_val, lambda_val, beta_val, alpha_val, phi_val, mu, theta, Ql_val)
y_ins_d1, y_gluc_d1 = calculate_curves(x_range, v_val, lambda_val, beta_d1, alpha_val, phi_val, mu, theta, Ql_val)
y_ins_d2, y_gluc_d2 = calculate_curves(x_range, v_d2, lambda_val, beta_val, alpha_val, phi_val, mu, theta, Ql_val);

Visualization of simulation results.

In [ ]:
p1 = plot(x_range, [y_ins_norm, y_gluc_norm], 
     label=["The insulin response" "Glucose balance"], 
     title="Normal conditions",
     xlabel="Glucose concentration (mg/mL)",
     ylabel="Insulin Concentration (mU/mL)",
     linewidth=2, 
     linestyle=[:solid :dash], 
     color=[:blue :red],
     xlims=(0.0, 2.0), 
     ylims=(0, 0.4), 
     legend=:topright)
scatter!([x_normal], [y_normal], label="Point N", color=:green, markersize=6)

p2 = plot(x_range, [y_ins_d1, y_gluc_d1], 
     label=["Insulin response type 1 diabetes" "Glucose balance"], 
     title="Type 1 diabetes",
     xlabel="Glucose concentration (mg/mL)",
     ylabel="Insulin Concentration (mU/mL)",
     linewidth=2, 
     linestyle=[:solid :dash], 
     color=[:blue :red],
     xlims=(0.0, 2.0), 
     ylims=(0, 0.4), 
     legend=:topright)
scatter!([x_d1], [y_d1], label="Point D1", color=:green, markersize=6)

p3 = plot(x_range, [y_ins_d2, y_gluc_d2], 
     label=["The insulin response" "Glucose balance Type 2 diabetes"], 
     title="Type 2 diabetes",
     xlabel="Glucose concentration (mg/mL)",
     ylabel="Insulin Concentration (mU/mL)",
     linewidth=2, 
     linestyle=[:solid :dash], 
     color=[:blue :red],
     xlims=(0.0, 2.0), 
     ylims=(0, 0.4), 
     legend=:topright)
scatter!([x_d2], [y_d2], label="Point D2", color=:green, markersize=6)

plot(p1, p2, p3, 
    layout=(3,1), 
    size=(1000, 1200),
    margin=40*Plots.px)
Out[0]:

Conclusion

Blood glucose regulation is a negative feedback system. An increase in glucose stimulates the secretion of insulin, which promotes its absorption by tissues, reducing concentration. The model describes the balance of glucose inflow and outflow, including non-linearities. Type 1 diabetes is modeled by a decrease in insulin production (), which leads to high glucose and low insulin levels. Type 2 diabetes is modeled by a decrease in tissue sensitivity to insulin (), which leads to high levels of both glucose and insulin.

List of sources used

1 - Stolwijk, J.A.J., and J.D. Hardy. "A Model for the Physiological Regulation of Blood Glucose Levels." 1974.