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

com.powsybl.openloadflow.equations.AbstractEquationTerm Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2019, 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.equations;

import com.powsybl.math.matrix.DenseMatrix;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @author Geoffroy Jamgotchian {@literal }
 */
public abstract class AbstractEquationTerm & Quantity, E extends Enum & Quantity> implements EquationTerm {

    private Equation equation;

    private boolean active;

    protected StateVector sv;

    protected EquationTerm self = this;

    protected AbstractEquationTerm() {
        this(true);
    }

    protected AbstractEquationTerm(boolean active) {
        this.active = active;
    }

    @Override
    public void setStateVector(StateVector sv) {
        this.sv = Objects.requireNonNull(sv);
    }

    @Override
    public List> getChildren() {
        return Collections.emptyList();
    }

    @Override
    public Equation getEquation() {
        return equation;
    }

    @Override
    public void setEquation(Equation equation) {
        this.equation = Objects.requireNonNull(equation);
    }

    @Override
    public void setActive(boolean active) {
        if (this.active != active) {
            this.active = active;
            equation.getEquationSystem().notifyEquationTermChange(self, active ? EquationTermEventType.EQUATION_TERM_ACTIVATED
                                                                               : EquationTermEventType.EQUATION_TERM_DEACTIVATED);
        }
    }

    @Override
    public boolean isActive() {
        return active;
    }

    @Override
    public void setSelf(EquationTerm self) {
        this.self = Objects.requireNonNull(self);
    }

    @Override
    public double calculateSensi(DenseMatrix dx, int column) {
        throw new UnsupportedOperationException("Not implemented");
    }

    @Override
    public boolean hasRhs() {
        return false;
    }

    @Override
    public double rhs() {
        return 0;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy