| 438 | } |
| 439 | |
| 440 | PropertyPlot::Range2D PropertyPlot::get_axis_limits(CoolProp::parameters xkey, CoolProp::parameters ykey, bool autoscale) const { |
| 441 | if (xkey == CoolProp::parameters::iundefined_parameter) xkey = this->xkey_; |
| 442 | if (ykey == CoolProp::parameters::iundefined_parameter) ykey = this->ykey_; |
| 443 | |
| 444 | if (xkey != this->xkey_ || ykey != this->ykey_ || autoscale) { |
| 445 | Range2D tp_limits = get_Tp_limits(); |
| 446 | Range xrange = {std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest()}; |
| 447 | Range yrange = {std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest()}; |
| 448 | |
| 449 | for (double T : {tp_limits.T.min, tp_limits.T.max}) { |
| 450 | for (double p : {tp_limits.p.min, tp_limits.p.max}) { |
| 451 | try { |
| 452 | state_->update(CoolProp::PT_INPUTS, p, T); |
| 453 | double x = state_->keyed_output(xkey); |
| 454 | double y = state_->keyed_output(ykey); |
| 455 | xrange.min = std::min(xrange.min, x); |
| 456 | xrange.max = std::max(xrange.max, x); |
| 457 | yrange.min = std::min(yrange.min, y); |
| 458 | yrange.max = std::max(yrange.max, y); |
| 459 | } catch (...) { // NOLINT(bugprone-empty-catch) |
| 460 | // (T, p) outside the backend's valid region — this |
| 461 | // corner doesn't contribute to the bounding box. |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | return {xrange, yrange}; |
| 466 | } else { |
| 467 | return {xaxis.range, yaxis.range}; |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | } /* namespace Plot */ |
| 472 | } /* namespace CoolProp */ |
no test coverage detected