| 225 | } |
| 226 | |
| 227 | bool is_valid_first_derivative(const std::string& name, parameters& iOf, parameters& iWrt, parameters& iConstant) { |
| 228 | if (get_debug_level() > 5) { |
| 229 | std::cout << format("is_valid_first_derivative(%s)", name.c_str()); |
| 230 | } |
| 231 | // There should be exactly one / |
| 232 | // There should be exactly one | |
| 233 | |
| 234 | // Suppose we start with "d(P)/d(T)|Dmolar" |
| 235 | std::vector<std::string> split_at_bar = strsplit(name, '|'); // "d(P)/d(T)" and "Dmolar" |
| 236 | if (split_at_bar.size() != 2) { |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | std::vector<std::string> split_at_slash = strsplit(split_at_bar[0], '/'); // "d(P)" and "d(T)" |
| 241 | if (split_at_slash.size() != 2) { |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | std::size_t i0 = split_at_slash[0].find('('); |
| 246 | std::size_t i1 = split_at_slash[0].find(')', i0); |
| 247 | if (!((i0 > 0) && (i0 != std::string::npos) && (i1 > (i0 + 1)) && (i1 != std::string::npos))) { |
| 248 | return false; |
| 249 | } |
| 250 | std::string num = split_at_slash[0].substr(i0 + 1, i1 - i0 - 1); |
| 251 | |
| 252 | i0 = split_at_slash[1].find('('); |
| 253 | i1 = split_at_slash[1].find(')', i0); |
| 254 | if (!((i0 > 0) && (i0 != std::string::npos) && (i1 > (i0 + 1)) && (i1 != std::string::npos))) { |
| 255 | return false; |
| 256 | } |
| 257 | std::string den = split_at_slash[1].substr(i0 + 1, i1 - i0 - 1); |
| 258 | |
| 259 | parameters Of, Wrt, Constant; |
| 260 | if (is_valid_parameter(num, Of) && is_valid_parameter(den, Wrt) && is_valid_parameter(split_at_bar[1], Constant)) { |
| 261 | iOf = Of; |
| 262 | iWrt = Wrt; |
| 263 | iConstant = Constant; |
| 264 | return true; |
| 265 | } else { |
| 266 | return false; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | bool is_valid_first_saturation_derivative(const std::string& name, parameters& iOf, parameters& iWrt) { |
| 271 | if (get_debug_level() > 5) { |
no test coverage detected