All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.powsybl.flow_decomposition.ReferenceNodalInjectionComputer Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2022, RTE (http://www.rte-france.com)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.powsybl.flow_decomposition;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.Identifiable;
import com.powsybl.iidm.network.Injection;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author Hugo Schindler {@literal }
 * @author Sebastien Murgey {@literal }
 */
class ReferenceNodalInjectionComputer {
    ReferenceNodalInjectionComputer() {
    }

    Map run(List> nodeList) {
        return nodeList.stream()
            .collect(Collectors.toMap(
                Identifiable::getId,
                this::getReferenceInjection
            ));
    }

    private double getReferenceInjection(Injection node) {
        double p = -node.getTerminal().getP();
        if (Double.isNaN(p)) {
            throw new PowsyblException(String.format("Reference nodal injection cannot be a Nan for node %s", node.getId()));
        }
        return p;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy