comparison src/p2_deco.c @ 657:c2e97f94c55f default tip

bump to 10.93 / 3.32
author heinrichsweikamp
date Tue, 27 Jan 2026 11:01:04 +0100
parents 8af5aefbcdaf
children
comparison
equal deleted inserted replaced
656:8af5aefbcdaf 657:c2e97f94c55f
2050 2050
2051 // also clear any time++ request 2051 // also clear any time++ request
2052 char_I_sim_advance_time = 0; 2052 char_I_sim_advance_time = 0;
2053 } 2053 }
2054 2054
2055 //////////////////////////////////////////////////////////////////////////////
2056 // calc_GF_surface
2057 //
2058 // Calculates the instantaneous surface GF (GF_surf) for the leading compartment.
2059 //
2060 // Definition:
2061 // GF_surf = (P_tissue - pres_surface) / (M_surf - pres_surface)
2062 //
2063 // - P_tissue : current inert gas tissue pressure (N2 + He) in bar
2064 // - pres_surface : pres_surface (Ambient pressure at the surface, in bar)
2065 // - M_surf : M-value on the surface (per calc_M_value_at_pressure)
2066 //
2067 // The maximum across all compartments is taken as GF_surf.
2068 // The result is written in percent (0..250) in int_O_GF_surface.
2069 //
2070 static float calc_M_value_at_pressure(float pres_surface)
2071 {
2072 float a, b;
2073 read_Buhlmann_coefficients();
2074 #ifdef _helium
2075 adopt_Buhlmann_coefficients();
2076 a = var_a;
2077 b = var_b;
2078 #else
2079 a = var_N2_a;
2080 b = var_N2_b;
2081 #endif
2082 return a + b * pres_surface;
2083 }
2084
2085 static void calc_GF_surface(void) 2055 static void calc_GF_surface(void)
2086 { 2056 {
2087 overlay float P_tissue; 2057 overlay float P_tissue;
2088 overlay float M_surf; 2058 overlay float M_surf;
2089 overlay float gf_surf; 2059 overlay float gf_surf;
2090 overlay float gf_surf_max = 0.0f; 2060 overlay float gf_surf_max = 0.0f;
2091 2061 float a, b;
2062
2092 // Pass through all compartments 2063 // Pass through all compartments
2093 for (ci = 0; ci < NUM_COMP; ci++) 2064 for (ci = 0; ci < NUM_COMP; ci++)
2094 { 2065 {
2095 #ifdef _helium 2066 #ifdef _helium
2096 P_tissue = real_pres_tissue_N2[ci] + real_pres_tissue_He[ci]; 2067 P_tissue = real_pres_tissue_N2[ci] + real_pres_tissue_He[ci];
2097 #else 2068 #else
2098 P_tissue = real_pres_tissue_N2[ci]; 2069 P_tissue = real_pres_tissue_N2[ci];
2099 #endif 2070 #endif
2100 2071
2072 read_Buhlmann_coefficients();
2073
2074 #ifdef _helium
2075 adopt_Buhlmann_coefficients();
2076 a = var_a;
2077 b = var_b;
2078 #else
2079 a = var_N2_a;
2080 b = var_N2_b;
2081 #endif
2082
2101 // M-value on the surface for this compartment 2083 // M-value on the surface for this compartment
2102 M_surf = calc_M_value_at_pressure(pres_surface); 2084 M_surf = pres_surface / b + a;
2103 2085
2104 // Filtering out unnecessary cases 2086 // Filtering out unnecessary cases
2105 if (M_surf <= pres_surface) 2087 if (M_surf <= pres_surface)
2106 continue; 2088 continue;
2107 2089
2108 // Surface-GF of this compartment 2090 // Surface-GF of this compartment
2118 { 2100 {
2119 int_O_GF_surface = 0; 2101 int_O_GF_surface = 0;
2120 } 2102 }
2121 else 2103 else
2122 { 2104 {
2123 unsigned int tmp; 2105 int_O_GF_surface = (unsigned int)(gf_surf_max * 100.0f + 0.5f);
2124 2106
2125 tmp = (unsigned int)(gf_surf_max * 100.0f + 0.5f); 2107 if (int_O_GF_surface > 999)
2126 2108 int_O_GF_surface = 999;
2127 if (tmp > 999) 2109
2128 tmp = 999;
2129
2130 int_O_GF_surface = tmp;
2131 } 2110 }
2132 } 2111 }
2133 2112
2134 ////////////////////////////////////////////////////////////////////////////// 2113 //////////////////////////////////////////////////////////////////////////////
2135 // Reset all tissues to surface pressure equilibrium state 2114 // Reset all tissues to surface pressure equilibrium state