class UcteConverterHelper {

    public static double calculatePhaseDu(TwoWindingsTransformer twoWindingsTransformer) {
        double rhoMin = Double.MAX_VALUE;
        double rhoMax = -Double.MAX_VALUE;

        RatioTapChanger tapChanger = twoWindingsTransformer.getRatioTapChanger();
        for (int i = tapChanger.getLowTapPosition(); i <= tapChanger.getHighTapPosition(); ++i) {
            rhoMin = Double.min(rhoMin, tapChanger.getStep(i).getRho());
            rhoMax = Double.max(rhoMax, tapChanger.getStep(i).getRho());
        }

        double res = 100 * (1 / rhoMin - 1 / rhoMax) / (tapChanger.getStepCount() - 1);
        return BigDecimal.valueOf(res).setScale(4, RoundingMode.HALF_UP).doubleValue();
    }

    private  UcteConverterHelper();

}