############################## Define model structure ########################## ode <- " number_of_functional_nephrons = baseline_nephrons; ######################Systemic Hemodynamics ##################################### ###Whole body autoregulation mechanism wherein TPR adjusts to maintain constant organ blood flow (and thus constant cardiac output) #Modeled as Proportional-Integral controller of TPR, where the input signal is the cardiac output error signal tissue_autoregulation_signal = max(0.1,1+tissue_autoreg_scale*((Kp_CO/CO_scale_species)*(cardiac_output_delayed - CO_nom)+(Ki_CO/CO_scale_species)*CO_error)); ###Effect of the RAAS (AT1-bound AngII) on systemic vascular resistance. For now, the slope is set to zero, i.e. AngII does not directly affect SVR AT1_svr_int = 1 - AT1_svr_slope*nominal_equilibrium_AT1_bound_AngII; AT1_bound_AngII_effect_on_SVR = AT1_svr_int + AT1_svr_slope * AT1_bound_AngII; systemic_arterial_resistance = tissue_autoregulation_signal*(nom_systemic_arterial_resistance)*AT1_bound_AngII_effect_on_SVR; resistance_to_venous_return = ((8 * R_venous + systemic_arterial_resistance) / 31); ###Empirical relationship between ECF and Blood volume, taken from Karaaslan 2005; must be scaled for different species blood_volume_L = BV_scale_species*(4.56+2.43/(1+exp(-((extracellular_fluid_volume/ECF_scale_species-18.1))*0.474))); ###Empirical relationship between blood volume and mean filling pressure, taken from Karaaslan 2005; must be scaled for different species mean_filling_pressure = (((BV_filling_pressure_slope/BV_scale_species) * blood_volume_L - reference_BV_mean_filling_pressure)); venous_return = ((mean_filling_pressure) / resistance_to_venous_return); cardiac_output = venous_return; ###Empirical relationship between blood volume and right atrial pressure, taken from Karaaslan 2005; must be scaled for different species #Right atrial pressure is used as a signal for ANP and RSNA. For this purpose, this relationship is fine. However, a more complex model would be needed to truly model right atrial pressure right_atrial_pressure = (nom_right_atrial_pressure * exp(blood_volume_L - 5*BV_scale_species)); ######################################### ###Aldosterone bound to the mineralocorticoid receptor - normalized level. Aldosterone secretion is described later on. aldosterone_concentration = normalized_aldosterone_level* nominal_aldosterone_concentration; Aldo_MR_normalised_effect = normalized_aldosterone_level*MR_antagonist_effect_on_aldo_MR; ###Renal sympathetic nerve activity is assumed to be driven by changes in MAP and Right atrial pressure. The dominant effect is MAP, adn the effect of RAP is must less, at least in the normal physiologic range. #This would need to be revisited for heart failure MAP_effect_on_rsna = 0.5 + 1.0 / (1 + exp((pre_renal_blood_pressure - nominal_map_setpoint) / map_rsna_slope)); R_atrial_pressure_effect_on_rsna_int = 1+rap_rsna_slope*nom_right_atrial_pressure; R_atrial_pressure_effect_on_rsna = R_atrial_pressure_effect_on_rsna_int - rap_rsna_slope * right_atrial_pressure; renal_sympathetic_nerve_activity = nom_rsna*MAP_effect_on_rsna * R_atrial_pressure_effect_on_rsna; ###ANP release is driven by changes in right atrial pressure rap_anp_intercept = 1 + rap_anp_slope/2; normalized_atrial_NP_concentration = nom_ANP*((rap_anp_intercept - rap_anp_slope / (1 + exp(right_atrial_pressure - nom_right_atrial_pressure)))); ######Preafferent arteriole resistance###### #The resistance of the arcuate, interlobular arterioles, and other vasculature prior the afferent arterioles is represented by a single resistance - the preafferent arteriole resistance #The preafferent arterioles respond myogenically to changes in pressure, and also responds to AT1-bound AngII, RSNA, and ANP #AngII bound to the AT1 receptor constricts the preafferent vasculature AT1_preaff_int = 1-AT1_preaff_slope*nominal_equilibrium_AT1_bound_AngII; At1_effect_on_preaff_resistance = AT1_preaff_int + AT1_preaff_slope * AT1_bound_AngII; #ANP dilates the preafferent vasculature ANP_effect_on_preaff = 1 - anp_preaff_resistance_slope * (normalized_atrial_NP_concentration - nom_ANP); #RSNA constricts the preafferent vasculature rsna_preaff_intercept = 1-rsna_preaff_vmax/2; rsna_effect_on_preaff_resistance = rsna_preaff_intercept + rsna_preaff_vmax*(renal_sympathetic_nerve_activity^rsna_preaff_hill)/(rsna_preaff_EC50^rsna_preaff_hill + renal_sympathetic_nerve_activity^rsna_preaff_hill); #This multiplier represents the combined effect of AT1-bound AngII, ANP, RSNA, and the myogenic autoregulatory response, in the absence of saturation preaff_arteriole_signal_multiplier = At1_effect_on_preaff_resistance*rsna_effect_on_preaff_resistance*ANP_effect_on_preaff*(preafferent_pressure_autoreg_signal)*CCB_effect_on_preafferent_resistance; #This adjusted signal multiplier accounts for the fact that dilation/constriction of the arterioles is limited, and thus the effects must saturate preaff_arteriole_adjusted_signal_multiplier = (1/(1+exp(preaff_signal_nonlin_scale*(preaff_arteriole_signal_multiplier-1)))+0.5); #Preafferent resistance nom_effective_preaff_diameter = nom_preafferent_arteriole_resistance^(-0.25); preaff_diameter = nom_effective_preaff_diameter+preaff_diameter_range*(preaff_arteriole_adjusted_signal_multiplier-1); preafferent_arteriole_resistance = 1/(preaff_diameter ^4); AT1_aff_int = 1 - AT1_aff_slope*nominal_equilibrium_AT1_bound_AngII; AT1_effect_on_afferent_resistance = AT1_aff_int + AT1_aff_slope * AT1_bound_AngII; rsna_effect_on_aff_resistance = 1;#(renal_sympathetic_nerve_activity) ^ 2; ANP_effect_on_afferent = 1 - anp_aff_resistance_slope * (normalized_atrial_NP_concentration - nom_ANP); afferent_arteriole_signal_multiplier = rsna_effect_on_aff_resistance * tubulo_glomerular_feedback_effect * AT1_effect_on_afferent_resistance * ANP_effect_on_afferent*glomerular_pressure_autoreg_signal*CCB_effect_on_afferent_resistance; afferent_arteriole_adjusted_signal_multiplier = (1/(1+exp(afferent_signal_nonlin_scale*(afferent_arteriole_signal_multiplier-1)))+0.5); afferent_diameter = nom_afferent_diameter+afferent_diameter_range*(afferent_arteriole_adjusted_signal_multiplier-1); afferent_arteriole_resistance = L_m3*viscosity_length_constant/(afferent_diameter^4); AT1_eff_int = 1 - AT1_eff_slope*nominal_equilibrium_AT1_bound_AngII; AT1_bound_AngII_effect_on_efferent = AT1_eff_int + AT1_eff_slope * AT1_bound_AngII; ANP_effect_on_efferent_resistance = 1 + anp_eff_resistance_slope * (normalized_atrial_NP_concentration - nom_ANP); efferent_arteriole_signal_multiplier = (((AT1_bound_AngII_effect_on_efferent * ANP_effect_on_efferent_resistance ))*CCB_effect_on_efferent_resistance ); efferent_arteriole_adjusted_signal_multiplier = 1/(1+exp(efferent_signal_nonlin_scale*(efferent_arteriole_signal_multiplier-1)))+0.5; efferent_diameter = nom_efferent_diameter+efferent_diameter_range*(efferent_arteriole_adjusted_signal_multiplier-1); efferent_arteriole_resistance = L_m3*viscosity_length_constant/(efferent_diameter^4); RBF_autoreg_int = 1 - RBF_autoreg_scale/2; peritubular_autoreg_signal = RBF_autoreg_int + RBF_autoreg_scale/(1+exp((nom_renal_blood_flow_L_min - renal_blood_flow_L_min_delayed)/RBF_autoreg_steepness)); autoregulated_peritubular_resistance = peritubular_autoreg_signal*nom_peritubular_resistance; renal_vascular_resistance = (preafferent_arteriole_resistance + (afferent_arteriole_resistance + efferent_arteriole_resistance) / number_of_functional_nephrons + autoregulated_peritubular_resistance); total_peripheral_resistance_old = (systemic_arterial_resistance * renal_vascular_resistance / (systemic_arterial_resistance + renal_vascular_resistance) + R_venous); total_peripheral_resistance = systemic_arterial_resistance + R_venous; mean_arterial_pressure_MAP = (cardiac_output * total_peripheral_resistance); renal_blood_flow_L_min = ((mean_arterial_pressure_MAP - P_venous) / renal_vascular_resistance); renal_blood_flow_ml_hr = renal_blood_flow_L_min * 1000 * 60; preafferent_pressure = mean_arterial_pressure_MAP - renal_blood_flow_L_min*preafferent_arteriole_resistance; glomerular_pressure = (mean_arterial_pressure_MAP - renal_blood_flow_L_min * (preafferent_arteriole_resistance + afferent_arteriole_resistance / number_of_functional_nephrons)); postglomerular_pressure = (mean_arterial_pressure_MAP - renal_blood_flow_L_min * (preafferent_arteriole_resistance + (afferent_arteriole_resistance+efferent_arteriole_resistance) / number_of_functional_nephrons)); #Effect of high glomerular pressure on Kf (glomerular hypertrophy), #2mmHg buffer built in GP_effect_increasing_Kf = (maximal_glom_surface_area_increase - disease_effects_increasing_Kf) * max(glomerular_pressure/(nom_glomerular_pressure+2) - 1,0) / T_glomerular_pressure_increases_Kf; glomerular_hydrostatic_conductance_Kf = nom_Kf*(1+disease_effects_increasing_Kf); gp_autoreg_int = 1 - gp_autoreg_scale/2; preaff_autoreg_int = 1 - preaff_autoreg_scale/2; preafferent_pressure_autoreg_function = preaff_autoreg_int+preaff_autoreg_scale/(1+exp((nom_preafferent_pressure - preafferent_pressure)/myogenic_steepness)); glomerular_pressure_autoreg_function = gp_autoreg_int+gp_autoreg_scale/(1+exp((nom_glomerular_pressure - glomerular_pressure)/myogenic_steepness)); net_filtration_pressure = glomerular_pressure - oncotic_pressure_difference - P_bowmans; SNGFR_nL_min = glomerular_hydrostatic_conductance_Kf * (glomerular_pressure - oncotic_pressure_difference - P_bowmans); GFR = (SNGFR_nL_min / 1000 / 1000000 * number_of_functional_nephrons); GFR_ml_min = GFR * 1000; Oncotic_pressure_in = 1.629*plasma_protein_concentration+0.2935*(plasma_protein_concentration^2); SNRBF_nl_min = 1e6*1000*renal_blood_flow_L_min/number_of_functional_nephrons; plasma_protein_concentration_out = SNRBF_nl_min*plasma_protein_concentration/(SNRBF_nl_min-SNGFR_nL_min); Oncotic_pressure_out = 1.629*plasma_protein_concentration_out+0.2935*(plasma_protein_concentration_out^2); oncotic_pressure_avg = (Oncotic_pressure_in+Oncotic_pressure_out)/2; Na_concentration = (sodium_amount / extracellular_fluid_volume); Na_water_controller = Na_controller_gain*(Kp_VP*(Na_concentration - ref_Na_concentration)+Ki_VP*Na_concentration_error); normalized_vasopressin_concentration = 1 + Na_water_controller; vasopressin_concentration = nominal_vasopressin_conc * normalized_vasopressin_concentration; water_intake_vasopressin_int = 1-water_intake_vasopressin_scale/2; water_intake = water_intake_species_scale*(nom_water_intake/60/24)*(water_intake_vasopressin_int + water_intake_vasopressin_scale/(1+exp((normalized_vasopressin_concentration-1)/water_intake_vasopressin_slope))); daily_water_intake = (water_intake * 24 * 60); L_pt_s1 = L_pt_s1_nom*(1+tubular_length_increase); L_pt_s2 = L_pt_s2_nom*(1+tubular_length_increase); L_pt_s3 = L_pt_s3_nom*(1+tubular_length_increase); Dc_pt = Dc_pt_nom*(1+tubular_diameter_increase); L_pt = L_pt_s1+L_pt_s2 + L_pt_s3; SN_filtered_Na_load = (SNGFR_nL_min / 1000 / 1000000)*Na_concentration; filtered_Na_load = SN_filtered_Na_load*number_of_functional_nephrons; pressure_natriuresis_PT_int = 1 - pressure_natriuresis_PT_scale/2; pressure_natriuresis_PT_effect = max(0.001,pressure_natriuresis_PT_int + pressure_natriuresis_PT_scale / (1 + exp((mean_arterial_pressure_MAP- nominal_map_setpoint) / pressure_natriuresis_PT_slope))); pressure_natriuresis_LoH_int = 1 - pressure_natriuresis_LoH_scale/2; pressure_natriuresis_LoH_effect = max(0.001,pressure_natriuresis_LoH_int + pressure_natriuresis_LoH_scale / (1 + exp((mean_arterial_pressure_MAP - nominal_map_setpoint) / pressure_natriuresis_LoH_slope))); pressure_natriuresis_DCT_magnitude = max(0,pressure_natriuresis_DCT_scale ); pressure_natriuresis_DCT_int = 1 - pressure_natriuresis_DCT_magnitude/2; pressure_natriuresis_DCT_effect = max(0.001,pressure_natriuresis_DCT_int + pressure_natriuresis_DCT_magnitude/ (1 + exp((mean_arterial_pressure_MAP - nominal_map_setpoint) / pressure_natriuresis_DCT_slope))); pressure_natriuresis_CD_magnitude = max(0,pressure_natriuresis_CD_scale *(1+disease_effects_decreasing_CD_PN)); pressure_natriuresis_CD_int = 1 - pressure_natriuresis_CD_magnitude/2; pressure_natriuresis_CD_effect = max(0.001,pressure_natriuresis_CD_int + pressure_natriuresis_CD_magnitude/ (1 + exp((mean_arterial_pressure_MAP - nominal_map_setpoint) / pressure_natriuresis_CD_slope))); AT1_PT_int = 1 - AT1_PT_slope*nominal_equilibrium_AT1_bound_AngII; g_at = AT1_PT_int + AT1_PT_slope*AT1_bound_AngII; g_rsna_int = 1-pt_rsna_scale/2; g_rsna = g_rsna_int + pt_rsna_scale/ (1 + exp((1 - renal_sympathetic_nerve_activity) / pt_rsna_slope)); e_pt_sodreab = nominal_pt_na_reabsorption * g_at * g_rsna*pressure_natriuresis_PT_effect*CA_inhibitor; ##################################### Proximal Tubule ######################################### ###Glucose Filtration and reabsorption in PT #Assume glucose reabsorption depends only on availability of SGLT1/2 #Assume constant amount of reabsorption per unit length through SGLT2 in convoluted PT #Assume constant amount of reabsorption per unit length through SGLT1 in straight/recta PT #Chosen so that UGE becomes non-zero for plasma_glucose concentration ~8.5 mmol/l glucose_reabs_per_unit_length_s1 = nom_glucose_reabs_per_unit_length_s1*diabetic_adaptation*SGLT2_inhibition; glucose_reabs_per_unit_length_s2 = nom_glucose_reabs_per_unit_length_s2*diabetic_adaptation*SGLT2_inhibition; glucose_reabs_per_unit_length_s3 = nom_glucose_reabs_per_unit_length_s3*diabetic_adaptation*SGLT1_inhibition; SN_filtered_glucose_load = glucose_concentration*SNGFR_nL_min / 1000 / 1000000; #mmol/min glucose_pt_out_s1 = max(0,SN_filtered_glucose_load-glucose_reabs_per_unit_length_s1*L_pt_s1); #mmol/min glucose_pt_out_s2 = max(0,glucose_pt_out_s1-glucose_reabs_per_unit_length_s2*L_pt_s2); #mmol/min glucose_pt_out_s3 = max(0,glucose_pt_out_s2-glucose_reabs_per_unit_length_s3*L_pt_s3); #mmol/min uge = glucose_pt_out_s3*2e6*24*60*180/1000; #UGE in g/day RUGE = glucose_pt_out_s3*number_of_functional_nephrons*180; ###PT Sodium filtration and reabsorption # Sodium reabsorbed 1:1 with glucose in S1 and S2 # Sodium reabsorbed 2:1 with glucose in S3 # Assume for non-SGLT reabsorption, sodium reabsorbed at a constant RATE along the tubule # (represents glomerulotubular balance) SN_filtered_Na_load = (SNGFR_nL_min / 1000 / 1000000)*Na_concentration; #mmol/min SGTL2_Na_reabs_mmol_s1 = SN_filtered_glucose_load-glucose_pt_out_s1; #mmol/min SGTL2_Na_reabs_mmol_s2 = glucose_pt_out_s1-glucose_pt_out_s2; #mmol/min SGTL1_Na_reabs_mmol = 2*(glucose_pt_out_s2-glucose_pt_out_s3); #mmol/min total_SGLT2_Na_reabs = SGTL2_Na_reabs_mmol_s1+SGTL2_Na_reabs_mmol_s2+SGTL1_Na_reabs_mmol; #mmol/min #Under normal conditions, 3.9% of Na absorbed through SGLT2 (total_SGLT2_Na_reabs/SN_filtered_Na_load) #Thus, this amount is subtracted to obtain the adjusted fractional reabsorption rate separate from SGLT2 e_pt_sodreab_adj = e_pt_sodreab - 0.039; Na_reabs_per_unit_length = -log(1-e_pt_sodreab)/(L_pt_s1+L_pt_s2+L_pt_s3); #non-SGLT2 reabs #mmol/min Na_pt_out_s1 = SN_filtered_Na_load*exp(-Na_reabs_per_unit_length*L_pt_s1) - SGTL2_Na_reabs_mmol_s1 ; Na_pt_out_s2 = Na_pt_out_s1*exp(-Na_reabs_per_unit_length*L_pt_s2) - SGTL2_Na_reabs_mmol_s2 ; Na_pt_out_s3 = Na_pt_out_s2*exp(-Na_reabs_per_unit_length*L_pt_s3) - SGTL1_Na_reabs_mmol; PT_Na_reabs_fraction = 1-Na_pt_out_s3/SN_filtered_Na_load; ###PT Urea filtration and reabsorption SN_filtered_urea_load = (SNGFR_nL_min / 1000 / 1000000)*plasma_urea; urea_out_s1 = SN_filtered_urea_load - urea_permeability_PT*(SN_filtered_urea_load/(0.5*((SNGFR_nL_min / 1000 / 1000000)+water_out_s1_delayed))-plasma_urea)*water_out_s1_delayed; #For now, assuming only reabsorbed at the end urea_out_s2 = urea_out_s1 - urea_permeability_PT*(urea_out_s1/(0.5*(water_out_s1_delayed+water_out_s2_delayed))-plasma_urea)*water_out_s2_delayed; #For now, assuming only reabsorbed at the end urea_out_s3 = urea_out_s2 - urea_permeability_PT*(urea_out_s2/(0.5*(water_out_s2_delayed+water_out_s3_delayed))-plasma_urea)*water_out_s3_delayed; #For now, assuming only reabsorbed at the end urea_reabsorption_fraction = 1-urea_out_s3/SN_filtered_urea_load; ###PT Water Reabsorption osmoles_out_s1 = 2*Na_pt_out_s1 + glucose_pt_out_s1 + urea_out_s1; water_out_s1 = (((SNGFR_nL_min / 1000 / 1000000)/(2*SN_filtered_Na_load+SN_filtered_glucose_load+ SN_filtered_urea_load)))*osmoles_out_s1; osmoles_out_s2 = 2*Na_pt_out_s2 + glucose_pt_out_s2 + urea_out_s2; water_out_s2 = (water_out_s1/osmoles_out_s1)*osmoles_out_s2; osmoles_out_s3 = 2*Na_pt_out_s3 + glucose_pt_out_s3 + urea_out_s3; water_out_s3 = (water_out_s2/osmoles_out_s2)*osmoles_out_s3; PT_water_reabs_fraction = 1-water_out_s3/(SNGFR_nL_min / 1000 / 1000000); ###Concentrations out of PT Na_concentration_out_s1 = Na_pt_out_s1/water_out_s1; Na_concentration_out_s2 = Na_pt_out_s2/water_out_s2; Na_concentration_out_s3 = Na_pt_out_s3/water_out_s3; glucose_concentration_out_s1 = glucose_pt_out_s1/water_out_s1; glucose_concentration_out_s2 = glucose_pt_out_s2/water_out_s2; glucose_concentration_out_s3 = glucose_pt_out_s3/water_out_s3; urea_concentration_out_s1 = urea_out_s1/water_out_s1; urea_concentration_out_s2 = urea_out_s2/water_out_s2; urea_concentration_out_s3 = urea_out_s3/water_out_s3; osmolality_out_s1 = osmoles_out_s1/water_out_s1; osmolality_out_s2 = osmoles_out_s1/water_out_s2; osmolality_out_s3 = osmoles_out_s1/water_out_s3; PT_Na_outflow = Na_pt_out_s3*number_of_functional_nephrons; #Tubular sodium reabsorption per unit SA as the driver of tubular hypertrophy ####This needs to be updated now that SGLT2 reabsorption is modeled directly PT_Na_reab_perUnitSA = SN_filtered_Na_load*e_pt_sodreab/(3.14*Dc_pt*(L_pt_s1+L_pt_s2+L_pt_s3)); normalized_PT_reabsorption_density = PT_Na_reab_perUnitSA/PT_Na_reab_perUnitSA_0; PT_Na_reabs_effect_increasing_tubular_length = 0;#(maximal_tubule_length_increase - tubular_length_increase) * max(normalized_PT_reabsorption_density - 1,0) / T_PT_Na_reabs_PT_length; PT_Na_reabs_effect_increasing_tubular_diameter = 0;#(maximal_tubule_diameter_increase - tubular_diameter_increase) * max(normalized_PT_reabsorption_density - 1,0) / T_PT_Na_reabs_PT_diameter; ##################################### Loop of Henle ######################################### #####Descending Loop of Henle water_in_DescLoH = water_out_s3; # L/min Na_in_DescLoH = Na_pt_out_s3; urea_in_DescLoH = urea_out_s3; glucose_in_DescLoH = glucose_pt_out_s3; osmoles_in_DescLoH = osmoles_out_s3; Na_concentration_in_DescLoH = Na_concentration_out_s3; Urea_concentration_in_DescLoH = urea_concentration_out_s3; glucose_concentration_in_DescLoH = glucose_concentration_out_s3; osmolality_in_DescLoH = osmoles_out_s3/water_out_s3; #No solute reabsorption in descending limb Na_out_DescLoH = Na_in_DescLoH; urea_out_DescLoH = urea_in_DescLoH; glucose_out_DescLoH = glucose_in_DescLoH; osmoles_out_DescLoH = osmoles_in_DescLoH; #For LoH, baseline osmoles reabsorbed per unit length is calculated from nominal fractional sodium reabsorption (see baseline parameters file) #The rate of reabsorption per unit length may be flow-dependent, and may be modulated by tubular pressure-natriuresis # If LoH_flow_dependence = 0, then no flow dependence. deltaLoH_NaFlow = LoH_flow_dependence*(Na_out_DescLoH-nom_Na_in_AscLoH); AscLoH_Reab_Rate =(2*nominal_loh_na_reabsorption*(nom_Na_in_AscLoH+deltaLoH_NaFlow))/L_lh_des; #osmoles reabsorbed per unit length per minute. factor of 2 because osmoles = 2 effective_AscLoH_Reab_Rate =AscLoH_Reab_Rate*pressure_natriuresis_LoH_effect; #osmoles reabsorbed per unit length per minute. factor of 2 because osmoles = 2*Na #Water reabsorption in Desc LoH and osmotic gradient down loop are a function of sodium reabsorption in the Asc LoH #Min function necesssary to ensure that the LoH does not reabsorb more Na than is delivered to it osmolality_out_DescLoH = osmolality_in_DescLoH*exp(min(effective_AscLoH_Reab_Rate*L_lh_des,2*Na_in_DescLoH)/(water_in_DescLoH*osmolality_in_DescLoH)); water_out_DescLoH = water_in_DescLoH*osmolality_in_DescLoH/osmolality_out_DescLoH; Na_concentration_out_DescLoH = Na_out_DescLoH/water_out_DescLoH; glucose_concentration_out_DescLoH = glucose_out_DescLoH/water_out_DescLoH; urea_concentration_out_DescLoH = urea_out_DescLoH/water_out_DescLoH; #####Ascending Loop of Henle Na_in_AscLoH = Na_out_DescLoH; urea_in_AscLoH_before_secretion = urea_out_DescLoH; glucose_in_AscLoH = glucose_out_DescLoH; osmoles_in_AscLoH_before_secretion = osmoles_out_DescLoH; water_in_AscLoH = water_out_DescLoH; #Urea Secretion --> Assume all urea reabsorbed and secreted only at tip of loop urea_in_AscLoH = urea_in_AscLoH_before_secretion + reabsorbed_urea_cd_delayed; urea_concentration_in_AscLoH = urea_in_AscLoH/water_out_DescLoH; osmoles_in_AscLoH = osmoles_in_AscLoH_before_secretion + reabsorbed_urea_cd_delayed; osmolality_in_AscLoH = osmoles_in_AscLoH/water_in_AscLoH; #Osmolality descreased due to sodium reabsorption along ascending loop #min function necessary so that LoH doesn't reabsorb more sodium than is delivered to it osmolality_out_AscLoH = osmolality_in_AscLoH - min(L_lh_des*effective_AscLoH_Reab_Rate, 2*Na_in_DescLoH)*(exp(min(L_lh_des*effective_AscLoH_Reab_Rate, 2*Na_in_DescLoH)/(water_in_DescLoH*osmolality_in_DescLoH))/water_in_DescLoH); osmoles_reabsorbed_AscLoH = (osmolality_in_AscLoH - osmolality_out_AscLoH)*water_in_AscLoH; Na_reabsorbed_AscLoH = osmoles_reabsorbed_AscLoH/2; Na_out_AscLoH = max(0,Na_in_AscLoH - Na_reabsorbed_AscLoH); #Water, glucose, and urea are not reabsorbed along the ascending limb urea_out_AscLoH = urea_in_AscLoH; #urea secretion accounted for above glucose_out_AscLoH = glucose_in_AscLoH; water_out_AscLoH = water_in_AscLoH; osmoles_out_AscLoH = osmolality_out_AscLoH*water_out_AscLoH; Na_concentration_out_AscLoH = Na_out_AscLoH/water_out_AscLoH; glucose_concentration_out_AscLoH = glucose_out_AscLoH/water_out_AscLoH; urea_concentration_out_AscLoH = urea_out_AscLoH/water_out_AscLoH; LoH_reabs_fraction = 1-Na_out_AscLoH/Na_in_AscLoH; SN_macula_densa_Na_flow = Na_out_AscLoH; MD_Na_concentration = Na_concentration_out_AscLoH; TGF0_tubulo_glomerular_feedback = 1 - S_tubulo_glomerular_feedback/2; tubulo_glomerular_feedback_signal = (TGF0_tubulo_glomerular_feedback + S_tubulo_glomerular_feedback / (1 + exp((MD_Na_concentration_setpoint - MD_Na_concentration)/ F_md_scale_tubulo_glomerular_feedback))); #############################Distal Convoluted Tubule ####################### psi_al = scale_aldo_DT * Aldo_MR_normalised_effect ^ hill_aldo_DT; e_dct_sodreab = nominal_dt_na_reabsorption * psi_al*HCTZ_effect_on_DT_Na_reabs*pressure_natriuresis_DCT_effect; water_in_DCT = water_out_AscLoH; Na_in_DCT = Na_out_AscLoH; urea_in_DCT = urea_out_AscLoH; glucose_in_DCT = glucose_out_AscLoH; osmoles_in_DCT = osmoles_out_AscLoH; Na_concentration_in_DCT = Na_concentration_out_AscLoH; urea_concentration_in_DCT = urea_concentration_out_AscLoH; glucose_concentration_in_DCT = glucose_concentration_out_AscLoH; osmolality_in_DCT = osmolality_out_AscLoH; #Assume only sodium reabsorbed along DCT, no water, glucose, or urea reabsorption urea_out_DCT = urea_in_DCT; glucose_out_DCT = glucose_in_DCT; water_out_DCT = water_in_DCT; urea_concentration_out_DCT = urea_out_DCT/water_out_DCT; glucose_concentration_out_DCT = glucose_out_DCT/water_out_DCT; #Allow adjustable flow-dependence of DCT Na reabsorption deltaDCT_NaFlow = DCT_flow_dependence*(Na_in_DCT-nom_Na_in_DCT); e_dct_sodreab_adj = max(0, min(1,(e_dct_sodreab*(nom_Na_in_DCT+deltaDCT_NaFlow))/Na_in_DCT)); #osmoles reabsorbed per unit length per minute. factor of 2 because osmoles = 2 #Assume sodium reabsorption at a constant fraction of delivery R_dct = -log(1-e_dct_sodreab_adj)/L_dct; Na_out_DCT = Na_in_DCT*exp(-R_dct*L_dct); Na_concentration_out_DCT = Na_out_DCT/water_out_DCT; osmolality_out_DCT = 2*Na_concentration_out_DCT + glucose_concentration_out_DescLoH + urea_concentration_in_AscLoH; osmoles_out_DCT = osmolality_out_DCT*water_out_DCT; DCT_Na_reabs_fraction = 1-Na_out_DCT/Na_in_DCT; ################################################Collecting Duct############################### lambda_anp = 1 - anp_cd_slope * (normalized_atrial_NP_concentration - 1); lambda_aldo_CD =scale_aldo_CD*((Aldo_MR_normalised_effect)^hill_aldo_CD); e_cd_sodreab = min(0.99,nominal_cd_na_reabsorption * lambda_anp *lambda_aldo_CD*pressure_natriuresis_CD_effect); water_in_CD = water_out_DCT; Na_in_CD = Na_out_DCT; urea_in_CD = urea_out_DCT; glucose_in_CD = glucose_out_DCT; osmoles_in_CD = osmoles_out_DCT; Na_concentration_in_CD = Na_concentration_out_DCT; urea_concentration_in_CD = urea_concentration_out_DCT; glucose_concentration_in_CD = glucose_concentration_out_DCT; osmolality_in_CD = osmolality_out_DCT; ####Assume sodium reabsorbed, then water follows #### Then urea reabsorbed at end #### Then additional water reabsorbed following urea reabsorption #Allow adjustable flow-dependence of CD Na reabsorption deltaCD_NaFlow = CD_flow_dependence*(Na_in_CD-nom_Na_in_CD); e_cd_sodreab_adj = max(0,min(1,(e_cd_sodreab*(nom_Na_in_CD+deltaCD_NaFlow))/Na_in_CD)); #osmoles reabsorbed per unit length per minute. factor of 2 because osmoles = 2 #Assume sodium reabsorbed at fractional rate eta R_cd = -log(1-e_cd_sodreab_adj)/L_cd; Na_out_CD = Na_in_CD*exp(-R_cd*L_cd); CD_Na_reabs_fraction = 1-Na_out_CD/Na_in_CD; ADH_water_permeability = min(1,max(0,nom_ADH_water_permeability*normalized_vasopressin_concentration)); ADH_urea_permeability = min(1,max(0,nom_ADH_urea_permeability*(1+ (normalized_vasopressin_concentration-1)/5))); #Water reabsorption follows gradient but is regulated by ADH max_water_reabs_CD = water_in_CD-(osmolality_in_CD*water_in_CD-2*Na_in_CD*(1-exp(-R_cd*L_cd)))/osmolality_in_AscLoH; water_out_CD_before_urea_reabs = max(0,water_in_CD - ADH_water_permeability*max_water_reabs_CD); osmoles_out_CD_before_urea_reabsorption = osmoles_in_CD-2*(Na_in_CD - Na_out_CD); osmolality_out_CD_before_urea_reabsorption = osmoles_out_CD_before_urea_reabsorption/water_out_CD_before_urea_reabs; urea_concentration_out_CD_before_reabsorption = urea_in_CD/water_out_CD_before_urea_reabs; reabsorbed_urea_cd = ADH_urea_permeability*(urea_concentration_out_CD_before_reabsorption - urea_concentration_out_DescLoH)*water_out_CD_before_urea_reabs; urea_out_CD = urea_in_CD - reabsorbed_urea_cd; urea_concentration_out_CD = urea_out_CD/water_out_CD_before_urea_reabs; osmoles_out_CD_after_urea_reabsorption = osmoles_out_CD_before_urea_reabsorption - reabsorbed_urea_cd; water_reabsorption_CD_after_urea_reabsorption = ADH_water_permeability*(water_out_CD_before_urea_reabs - osmoles_out_CD_after_urea_reabsorption/osmolality_in_AscLoH); water_out_CD_after_urea_reabsorption = max(0,water_out_CD_before_urea_reabs - water_reabsorption_CD_after_urea_reabsorption); osmolality_out_CD_after_urea_reabsorption = osmoles_out_CD_after_urea_reabsorption/water_out_CD_after_urea_reabsorption; min_urine_flow_rate = (water_in_CD-max_water_reabs_CD - water_reabsorption_CD_after_urea_reabsorption/ADH_water_permeability)*number_of_functional_nephrons*60*24; urine_flow_rate = water_out_CD_after_urea_reabsorption*number_of_functional_nephrons; daily_urine_flow = (urine_flow_rate * 60 * 24); Na_excretion_via_urine = Na_out_CD*number_of_functional_nephrons; Na_balance = Na_intake_rate - Na_excretion_via_urine; water_balance = daily_water_intake - daily_urine_flow; FENA = Na_excretion_via_urine/filtered_Na_load; PT_fractional_glucose_reabs = (SN_filtered_glucose_load - glucose_pt_out_s3)/SN_filtered_glucose_load; PT_fractional_Na_reabs = (SN_filtered_Na_load - Na_pt_out_s3)/SN_filtered_Na_load; PT_fractional_urea_reabs = ( SN_filtered_urea_load - urea_out_s3)/SN_filtered_urea_load; PT_fractional_water_reabs = ((SNGFR_nL_min / 1000 / 1000000) - water_out_s3)/(SNGFR_nL_min / 1000 / 1000000); LoH_fractional_Na_reabs = (Na_in_DescLoH - Na_out_AscLoH)/Na_in_DescLoH; LoH_fractional_water_reabs = (water_in_DescLoH - water_out_AscLoH)/water_in_DescLoH; DCT_fractional_Na_reabs = (Na_in_DCT - Na_out_DCT)/Na_in_DCT; CD_fractional_Na_reabs = (Na_in_CD - Na_out_CD)/Na_in_CD; CD_fractional_urea_reabs = (urea_in_CD - urea_out_CD)/urea_in_CD; CD_OM_fractional_water_reabs = (water_in_CD - water_out_CD_before_urea_reabs)/water_in_CD; CD_IM_fractional_water_reabs = (water_out_CD_before_urea_reabs - water_out_CD_after_urea_reabsorption)/water_out_CD_before_urea_reabs; #####################Renal Interstitial Hydrostatic pressure ######RIHP can be approximated from Starling's equation for the peritubular capillaries ### Flow out of the capillary = Kf_peritubular*(Peritubular pressure - RIHP - oncotic pressure difference) ### Assume that any fluid reabsorbed reenters the capillary. ### Therefore, RIHP = Peritubular Pressure - (oncotic pressure in peritubular capillary - interstitial oncotic pressure) + tubular reabsorption/KF #Peritubular pressure is assumed to equal postglomerular pressure #Oncotic pressure at the entrance to the peritubular circulation equals oncotic pressure at the exit of the glomerular Oncotic_pressure_peritubular_in = Oncotic_pressure_out; plasma_protein_concentration_peritubular_out = (SNRBF_nl_min)*plasma_protein_concentration/(SNRBF_nl_min-urine_flow_rate*1e6*1000/number_of_functional_nephrons); Oncotic_pressure_peritubular_out = 1.629*plasma_protein_concentration_peritubular_out+0.2935*(plasma_protein_concentration_peritubular_out^2); oncotic_pressure_peritubular_avg = (Oncotic_pressure_peritubular_in+Oncotic_pressure_peritubular_out)/2; #The amount of fluid reabsorbed is the difference between the amount filtered and the amount excreted tubular_reabsorption = GFR_ml_min/1000 - urine_flow_rate; #Renal Interstitial Hydrostatic Pressure RIHP = postglomerular_pressure - (oncotic_pressure_peritubular_avg - interstitial_oncotic_pressure) + tubular_reabsorption/nom_peritubular_cap_Kf; ################# Tubular Pressure ##################### #####See written documentation for derivation of the equations below #flow rates expressed in m3/min, rather than L/min mmHg_Nperm2_conv = 133.32; Pc_pt_s1 = Pc_pt_s1_mmHg*mmHg_Nperm2_conv; Pc_pt_s2 = Pc_pt_s2_mmHg*mmHg_Nperm2_conv; Pc_pt_s3 = Pc_pt_s3_mmHg*mmHg_Nperm2_conv; Pc_lh_des = Pc_lh_des_mmHg*mmHg_Nperm2_conv; Pc_lh_asc = Pc_lh_asc_mmHg*mmHg_Nperm2_conv; Pc_dt = Pc_dt_mmHg*mmHg_Nperm2_conv; Pc_cd = Pc_cd_mmHg*mmHg_Nperm2_conv; P_interstitial = 4.9*mmHg_Nperm2_conv;#(renal_interstitial_hydrostatic_pressure-5)*mmHg_Nperm2_conv; pi=3.14; ### B1 = (4*tubular_compliance+1)*128*gamma/pi; mean_cd_water_flow = (water_in_CD-water_out_CD_after_urea_reabsorption)/2; B2_cd = (Pc_cd^(4*tubular_compliance))/(Dc_cd^4); P_in_cd = (0^(4*tubular_compliance+1)+B1*B2_cd*(mean_cd_water_flow/1e3)*L_cd)^(1/(4*tubular_compliance+1)); P_in_cd_mmHg = (P_in_cd+P_interstitial)/mmHg_Nperm2_conv; ### DCT B2_dt = (Pc_dt^(4*tubular_compliance))/(Dc_dt^4); P_in_dt = (P_in_cd^(4*tubular_compliance+1)+B1*B2_dt*(water_in_DCT/1e3)*L_dct)^(1/(4*tubular_compliance+1)); P_in_dt_mmHg = (P_in_dt+P_interstitial)/mmHg_Nperm2_conv; ### Asc LoH B2_lh_asc = (Pc_lh_asc^(4*tubular_compliance))/(Dc_lh^4); P_in_lh_asc = (P_in_dt^(4*tubular_compliance+1)+B1*B2_lh_asc*(water_in_AscLoH/1e3)*L_lh_asc)^(1/(4*tubular_compliance+1)); P_in_lh_asc_mmHg = (P_in_lh_asc+P_interstitial)/mmHg_Nperm2_conv; ### Desc LoH A_lh_des = effective_AscLoH_Reab_Rate/(water_in_DescLoH*osmolality_in_DescLoH); B2_lh_des = (Pc_lh_des^(4*tubular_compliance))*(water_in_DescLoH/1e3)/((Dc_lh^4)*A_lh_des); P_in_lh_des = (P_in_lh_asc^(4*tubular_compliance+1)+B1*B2_lh_des*(1-exp(-A_lh_des*L_lh_des)))^(1/(4*tubular_compliance+1)); P_in_lh_des_mmHg = (P_in_lh_des+P_interstitial)/mmHg_Nperm2_conv; ### PT #Treat urea as if reabsorbed linearly along whole length of PT Rurea = (SN_filtered_urea_load - urea_out_s3)/(L_pt_s1+L_pt_s2+L_pt_s3); urea_in_s2 = SN_filtered_urea_load - Rurea*L_pt_s1; urea_in_s3 = SN_filtered_urea_load - Rurea*(L_pt_s1+L_pt_s2); A_na = Na_reabs_per_unit_length; flow_integral_s3 = 2*(Na_pt_out_s2/A_na)*(1-exp(-A_na*L_pt_s3)) - (3/2)*glucose_pt_out_s2*L_pt_s3^2 + urea_in_s3*L_pt_s3 - (1/2)*Rurea*(L_pt_s3^2); flow_integral_s2 = 2*(Na_pt_out_s1/A_na)*(1-exp(-A_na*L_pt_s2)) - (1/2)*glucose_pt_out_s1*L_pt_s2^2 + urea_in_s2*L_pt_s2 - (1/2)*Rurea*(L_pt_s2^2); flow_integral_s1 = 2*(SN_filtered_Na_load/A_na)*(1-exp(-A_na*L_pt_s1)) - (1/2)*SN_filtered_glucose_load*L_pt_s1^2 + SN_filtered_urea_load*L_pt_s1 - (1/2)*Rurea*(L_pt_s1^2); #S3 segment B2_pt_s3 = (Pc_pt_s3^(4*tubular_compliance))/(Dc_pt^4); B3_pt_s3 = (water_out_s2/1e3)/osmoles_out_s2; P_in_pt_s3= (P_in_lh_des^(4*tubular_compliance+1)+B1*B2_pt_s3*B3_pt_s3*flow_integral_s3)^(1/(4*tubular_compliance+1)); P_in_pt_s3_mmHg = (P_in_pt_s3+P_interstitial)/mmHg_Nperm2_conv; B2_pt_s2 = (Pc_pt_s3^(4*tubular_compliance))/(Dc_pt^4); B3_pt_s2 = (water_out_s1/1e3)/osmoles_out_s1; P_in_pt_s2= (P_in_pt_s3^(4*tubular_compliance+1)+B1*B2_pt_s2*B3_pt_s2*flow_integral_s2)^(1/(4*tubular_compliance+1)); P_in_pt_s2_mmHg = (P_in_pt_s2+P_interstitial)/mmHg_Nperm2_conv; B2_pt_s1 = (Pc_pt_s1^(4*tubular_compliance))/(Dc_pt^4); B3_pt_s1 = (SNGFR_nL_min / 1e12)/(2*SN_filtered_Na_load+SN_filtered_glucose_load+ SN_filtered_urea_load); P_in_pt_s1= (P_in_pt_s2^(4*tubular_compliance+1)+B1*B2_pt_s1*B3_pt_s1*flow_integral_s1)^(1/(4*tubular_compliance+1)); P_in_pt_s1_mmHg = (P_in_pt_s1+P_interstitial)/mmHg_Nperm2_conv; K_Na_ratio_effect_on_aldo = max(((potassium_concentration / Na_concentration) / 0.0034722) - 9.29,0); AT1_aldo_int = 1 - AT1_aldo_slope*nominal_equilibrium_AT1_bound_AngII; AngII_effect_on_aldo = AT1_aldo_int + AT1_aldo_slope*AT1_bound_AngII; N_als = (K_Na_ratio_effect_on_aldo * AngII_effect_on_aldo ); rsna_renin_intercept = 1-rsna_renin_slope; rnsa_effect_on_renin_secretion = rsna_renin_slope * renal_sympathetic_nerve_activity + rsna_renin_intercept; #md_renin_effect_low = max(0,md_renin_low_slope*(1/(SN_macula_densa_Na_flow*2e6)-1/(nom_LoH_Na_outflow))); #md_renin_effect_high = md_renin_high_slope*max(0,SN_macula_densa_Na_flow*2e6-nom_LoH_Na_outflow); #md_effect_on_renin_secretion = 1+md_renin_effect_high+md_renin_effect_low; md_effect_on_renin_secretion = md_renin_A*exp(-md_renin_tau*(SN_macula_densa_Na_flow*baseline_nephrons - nom_LoH_Na_outflow)); AT1_bound_AngII_effect_on_PRA = (10 ^ (AT1_PRC_slope * log10(AT1_bound_AngII / nominal_equilibrium_AT1_bound_AngII) + AT1_PRC_yint)); plasma_renin_activity = concentration_to_renin_activity_conversion_plasma* plasma_renin_concentration*DRI_effect_on_PRA; renin_secretion_rate = (log(2)/renin_half_life)*nominal_equilibrium_PRC*AT1_bound_AngII_effect_on_PRA*md_effect_on_renin_secretion*rnsa_effect_on_renin_secretion*HCTZ_effect_on_renin_secretion; renin_degradation_rate = log(2)/renin_half_life; AngI_degradation_rate = log(2)/AngI_half_life; AngII_degradation_rate = log(2)/AngII_half_life; AT1_bound_AngII_degradation_rate = log(2)/AT1_bound_AngII_half_life; AT2_bound_AngII_degradation_rate = log(2)/AT2_bound_AngII_half_life; ACE_activity = nominal_ACE_activity; chymase_activity = nominal_chymase_activity; AT1_receptor_binding_rate =nominal_AT1_receptor_binding_rate; AT2_receptor_binding_rate = nominal_AT2_receptor_binding_rate; d/dt(AngI) = plasma_renin_activity - (AngI) * (chymase_activity + ACE_activity) - (AngI) * AngI_degradation_rate; d/dt(AngII) = AngI * (chymase_activity + ACE_activity) - AngII * AngII_degradation_rate - AngII*AT1_receptor_binding_rate - AngII* (AT2_receptor_binding_rate); d/dt(AT1_bound_AngII) = AngII * (AT1_receptor_binding_rate) - AT1_bound_AngII_degradation_rate*AT1_bound_AngII; d/dt(AT2_bound_AngII) = AngII * (AT2_receptor_binding_rate) - AT2_bound_AngII_degradation_rate*AT2_bound_AngII; d/dt(plasma_renin_concentration) = renin_secretion_rate - plasma_renin_concentration * renin_degradation_rate; d/dt(pre_renal_blood_pressure) = C_prerenal_blood_pressure * (mean_arterial_pressure_MAP - pre_renal_blood_pressure); d/dt(extracellular_fluid_volume) = C_water_intake_ecf_volume * (water_intake) + C_urine_flow_ecf_volume * (urine_flow_rate); d/dt(sodium_amount) = C_na_excretion_na_amount * (Na_excretion_via_urine) + C_na_intake_na_amount * (Na_intake_rate); d/dt(tubulo_glomerular_feedback_effect) = C_tgf * (tubulo_glomerular_feedback_signal-tubulo_glomerular_feedback_effect); d/dt(normalized_aldosterone_level) = C_aldo_secretion * (N_als-normalized_aldosterone_level); d/dt(preafferent_pressure_autoreg_signal) = 500*(preafferent_pressure_autoreg_function - preafferent_pressure_autoreg_signal); d/dt(glomerular_pressure_autoreg_signal) = 500*(glomerular_pressure_autoreg_function - glomerular_pressure_autoreg_signal); d/dt(F_out_dt_delay) = 0;#100*(F_out_dt - F_out_dt_delay); d/dt(cardiac_output_delayed) = C_cardiac_output_delayed*(cardiac_output - cardiac_output_delayed); d/dt(CO_error) = C_co_error*(cardiac_output-CO_nom); d/dt(Na_concentration_error) = C_Na_error*(Na_concentration - ref_Na_concentration); d/dt(F0_TGF) = C_tgf_reset*(SN_macula_densa_Na_flow*baseline_nephrons - F0_TGF); d/dt(P_bowmans) = C_P_bowmans*(P_in_pt_s1_mmHg - P_bowmans); d/dt(oncotic_pressure_difference) = C_P_oncotic*(oncotic_pressure_avg - oncotic_pressure_difference); d/dt(renal_blood_flow_L_min_delayed)=C_rbf*(renal_blood_flow_L_min - renal_blood_flow_L_min_delayed); d/dt(renal_interstitial_hydrostatic_pressure) = C_rihp*(RIHP - renal_interstitial_hydrostatic_pressure); d/dt(disease_effects_increasing_Kf) = GP_effect_increasing_Kf; d/dt(disease_effects_decreasing_CD_PN) = CD_PN_loss_rate; d/dt(tubular_length_increase) = PT_Na_reabs_effect_increasing_tubular_length; d/dt(tubular_diameter_increase) = PT_Na_reabs_effect_increasing_tubular_diameter; d/dt(water_out_s1_delayed) = C_pt_water*(water_out_s1 - water_out_s1_delayed); d/dt(water_out_s2_delayed) = C_pt_water*(water_out_s2 - water_out_s2_delayed); d/dt(water_out_s3_delayed) = C_pt_water*(water_out_s3 - water_out_s3_delayed); d/dt(reabsorbed_urea_cd_delayed) = C_pt_water*(reabsorbed_urea_cd - reabsorbed_urea_cd_delayed); d/dt(UGE) = RUGE; d/dt(cumWaterExcretion) = urine_flow_rate; " save(ode, file = "model_struct.saved")