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

com.powsybl.openloadflow.network.LfLoadModel Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2023, 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/.
 * SPDX-License-Identifier: MPL-2.0
 */
package com.powsybl.openloadflow.network;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * Generic load model as a sum of exponential terms: sum_i(ci * v^ni)
 *
 * @author Geoffroy Jamgotchian {@literal }
 */
public class LfLoadModel {

    public record ExpTerm(double c, double n) {
    }

    private final List expTermsP;

    private final List expTermsQ;

    public LfLoadModel(List expTermsP, List expTermsQ) {
        this.expTermsP = Objects.requireNonNull(expTermsP);
        this.expTermsQ = Objects.requireNonNull(expTermsQ);
    }

    public List getExpTermsP() {
        return expTermsP;
    }

    public Optional getExpTermP(double n) {
        return expTermsP.stream().filter(expTerm -> expTerm.n == n).findFirst();
    }

    public List getExpTermsQ() {
        return expTermsQ;
    }

    public Optional getExpTermQ(double n) {
        return expTermsQ.stream().filter(expTerm -> expTerm.n == n).findFirst();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LfLoadModel that = (LfLoadModel) o;
        return Objects.equals(expTermsP, that.expTermsP)
                && Objects.equals(expTermsQ, that.expTermsQ);
    }

    @Override
    public int hashCode() {
        return Objects.hash(expTermsP, expTermsQ);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy