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

com.zepben.evolve.cim.iec61970.base.wires.PowerElectronicsConnection.kt Maven / Gradle / Ivy

There is a newer version: 0.24.0rc1
Show newest version
/*
 * Copyright 2021 Zeppelin Bend Pty Ltd
 *
 * 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 https://mozilla.org/MPL/2.0/.
 */

package com.zepben.evolve.cim.iec61970.base.wires

import com.zepben.evolve.cim.iec61970.base.wires.generation.production.PowerElectronicsUnit
import com.zepben.evolve.services.common.extensions.asUnmodifiable
import com.zepben.evolve.services.common.extensions.getByMRID
import com.zepben.evolve.services.common.extensions.typeNameAndMRID
import com.zepben.evolve.services.common.extensions.validateReference

/**
 * A connection to the AC network for energy production or consumption that uses power electronics rather than
 * rotating machines.
 *
 * @property maxIFault Maximum fault current this device will contribute, in per-unit of rated current, before the converter protection
 *                     will trip or bypass.
 * @property maxQ Maximum reactive power limit. This is the maximum (nameplate) limit for the unit.
 * @property minQ Minimum reactive power limit for the unit. This is the minimum (nameplate) limit for the unit.
 * @property p Active power injection. Load sign convention is used, i.e. positive sign means flow out from a node.
 *             Starting value for a steady state solution.
 * @property q Reactive power injection. Load sign convention is used, i.e. positive sign means flow out from a node.
 *             Starting value for a steady state solution.
 * @property ratedS Nameplate apparent power rating for the unit. The attribute shall have a positive value.
 * @property ratedU Rated voltage (nameplate data, Ur in IEC 60909-0). It is primarily used for short circuit data exchange according
 *                  to IEC 60909. The attribute shall be a positive value.
 * @property units An AC network connection may have several power electronics units connecting through it.
 * @property phases The individual units models for the power electronics connection.
 * @property inverterStandard  The standard this inverter follows, such as AS4777.2:2020
 * @property sustainOpOvervoltLimit  Indicates the sustained operation overvoltage limit in volts, when the average voltage for a 10-minute period exceeds the V¬nom-max.
 * @property stopAtOverFreq  Over frequency (stop) in Hz. Permitted range is between 51 and 52 (inclusive)
 * @property stopAtUnderFreq  Under frequency (stop) in Hz Permitted range is between 47 and 49 (inclusive)
 * @property invVoltWattRespMode Volt-Watt response mode allows an inverter to reduce is real power output depending on the measured voltage. This mode is further described in AS4777.2:2015, section 6.3.2.2. True implies the mode is enabled.
 * @property invWattRespV1  Set point 1 in volts for inverter Volt-Watt response mode. Permitted range is between 200 and 300 (inclusive).
 * @property invWattRespV2  Set point 2 in volts for inverter Volt-Watt response mode. Permitted range is between 216 and 230 (inclusive).
 * @property invWattRespV3  Set point 3 in volts for inverter Volt-Watt response mode. Permitted range is between 235 and 255 (inclusive).
 * @property invWattRespV4  Set point 4 in volts for inverter Volt-Watt response mode. Permitted range is between 244 and 265 (inclusive).
 * @property invWattRespPAtV1  Power output set point 1 as a percentage of rated output for inverter Volt-Watt response mode. Permitted range is between 0 and 1 (inclusive).
 * @property invWattRespPAtV2  Power output set point 2 as a percentage of rated output for inverter Volt-Watt response mode. Permitted range is between 0 and 1 (inclusive).
 * @property invWattRespPAtV3  Power output set point 3 as a percentage of rated output for inverter Volt-Watt response mode. Permitted range is between 0 and 1 (inclusive).
 * @property invWattRespPAtV4  Power output set point 4 as a percentage of rated output for inverter Volt-Watt response mode. Permitted range is between 0 and 0.2 (inclusive).
 * @property invVoltVarRespMode Volt-VAr response mode allows an inverter to consume (sink) or produce (source) reactive power depending on the measured voltage. This mode is further described in AS4777.2:2015, section 6.3.2.3. True implies the mode is enabled.
 * @property invVarRespV1  Set point 1 in volts for inverter Volt-VAr response mode. Permitted range is between 200 and 300 (inclusive).
 * @property invVarRespV2  Set point 2 in volts for inverter Volt-VAr response mode. Permitted range is between 200 and 300 (inclusive).
 * @property invVarRespV3  Set point 3 in volts for inverter Volt-VAr response mode. Permitted range is between 200 and 300 (inclusive).
 * @property invVarRespV4  Set point 4 in volts for inverter Volt-VAr response mode. Permitted range is between 200 and 300 (inclusive).
 * @property invVarRespQAtV1  Power output set point 1 as a percentage of rated output for inverter Volt-VAr response mode. Permitted range is between 0 and 0.6 (inclusive).
 * @property invVarRespQAtV2  Power output set point 2 as a percentage of rated output for inverter Volt-VAr response mode. Permitted range is between -1 and 1 (inclusive) with a negative number referring to a sink.
 * @property invVarRespQAtV3  Power output set point 3 as a percentage of rated output for inverter Volt-VAr response mode. Permitted range is between -1 and 1 (inclusive) with a negative number referring to a sink.
 * @property invVarRespQAtV4  Power output set point 4 as a percentage of rated output for inverter Volt-VAr response mode. Permitted range is between -0.6 and 0 (inclusive) with a negative number referring to a sink.
 * @property invReactivePowerMode If true, enables Static Reactive Power mode on the inverter. Note: It must be false if invVoltVarRespMode or InvVoltWattRespMode is true.
 * @property invFixReactivePower  Static Reactive Power, specified in a percentage output of the system. Permitted range is between -1.0 and 1.0 (inclusive), with a negative sign referring to “sink”.
 */
class PowerElectronicsConnection @JvmOverloads constructor(mRID: String = "") : RegulatingCondEq(mRID) {

    private var _powerElectronicsUnits: MutableList? = null
    private var _powerElectronicsConnectionPhases: MutableList? = null
    var maxIFault: Int? = null
    var maxQ: Double? = null
    var minQ: Double? = null
    var p: Double? = null
    var q: Double? = null
    var ratedS: Int? = null
    var ratedU: Int? = null
    var inverterStandard: String? = null
    var sustainOpOvervoltLimit: Int? = null
    var stopAtOverFreq: Float? = null
    var stopAtUnderFreq: Float? = null
    var invVoltWattRespMode: Boolean? = null
    var invWattRespV1: Int? = null
        set(value) {
            check(value == null || (value >= 200) && (value <= 300)) { "invWattRespV1 [$value] must be between 200 and 300." }
            field = value
        }

    var invWattRespV2: Int? = null
        set(value) {
            check(value == null || (value >= 216) && (value <= 230)) { "invWattRespV2 [$value] must be between 216 and 230." }
            field = value
        }
    var invWattRespV3: Int? = null
        set(value) {
            check(value == null || (value >= 235) && (value <= 255)) { "invWattRespV3 [$value] must be between 235 and 255." }
            field = value
        }
    var invWattRespV4: Int? = null
        set(value) {
            check(value == null || (value >= 244) && (value <= 265)) { "invWattRespV4 [$value] must be between 244 and 265." }
            field = value
        }

    var invWattRespPAtV1: Float? = null
        set(value) {
            check(value == null || (value >= 0.0f) && (value <= 1.0f)) { "invWattRespPAtV1 [$value] must be between 0.0 and 1.0." }
            field = value
        }

    var invWattRespPAtV2: Float? = null
        set(value) {
            check(value == null || (value >= 0.0f) && (value <= 1.0f)) { "invWattRespPAtV2 [$value] must be between 0.0 and 1.0." }
            field = value
        }

    var invWattRespPAtV3: Float? = null
        set(value) {
            check(value == null || (value >= 0.0f) && (value <= 1.0f)) { "invWattRespPAtV3 [$value] must be between 0.0 and 1.0." }
            field = value
        }

    var invWattRespPAtV4: Float? = null
        set(value) {
            check(value == null || (value >= 0.0f) && (value <= 0.2f)) { "invWattRespPAtV4 [$value] must be between 0.0 and 0.2." }
            field = value
        }

    var invVoltVarRespMode: Boolean? = null
    var invVarRespV1: Int? = null
        set(value) {
            check(value == null || (value >= 200) && (value <= 300)) { "invVarRespV1 [$value] must be between 200 and 300." }
            field = value
        }

    var invVarRespV2: Int? = null
        set(value) {
            check(value == null || (value >= 200) && (value <= 300)) { "invVarRespV2 [$value] must be between 200 and 300." }
            field = value
        }

    var invVarRespV3: Int? = null
        set(value) {
            check(value == null || (value >= 200) && (value <= 300)) { "invVarRespV3 [$value] must be between 200 and 300." }
            field = value
        }

    var invVarRespV4: Int? = null
        set(value) {
            check(value == null || (value >= 200) && (value <= 300)) { "invVarRespV4 [$value] must be between 200 and 300." }
            field = value
        }

    var invVarRespQAtV1: Float? = null
        set(value) {
            check(value == null || (value >= 0.0f) && (value <= 0.6f)) { "invVarRespQAtV1 [$value] must be between 0.0 and 0.6." }
            field = value
        }

    var invVarRespQAtV2: Float? = null
        set(value) {
            check(value == null || (value >= -1.0f) && (value <= 1.0f)) { "invVarRespQAtV2 [$value] must be between -1.0 and 1.0." }
            field = value
        }

    var invVarRespQAtV3: Float? = null
        set(value) {
            check(value == null || (value >= -1.0f) && (value <= 1.0f)) { "invVarRespQAtV3 [$value] must be between -1.0 and 1.0." }
            field = value
        }

    var invVarRespQAtV4: Float? = null
        set(value) {
            check(value == null || (value >= -0.6f) && (value <= 0.0f)) { "invVarRespQAtV4 [$value] must be between -0.6 and 0.0." }
            field = value
        }

    var invReactivePowerMode: Boolean? = null
    var invFixReactivePower: Float? = null

    /**
     * The units for this power electronics connection. The returned collection is read only.
     */
    val units: Collection get() = _powerElectronicsUnits.asUnmodifiable()

    /**
     * The phases for this power electronics connection. The returned collection is read only.
     */
    val phases: Collection get() = _powerElectronicsConnectionPhases.asUnmodifiable()


    /**
     * Get the number of entries in the [PowerElectronicsUnit] collection.
     */
    fun numUnits(): Int = _powerElectronicsUnits?.size ?: 0

    /**
     * The individual unit information of the power electronics connection.
     *
     * @param mRID the mRID of the required [PowerElectronicsUnit]
     * @return The [PowerElectronicsUnit] with the specified [mRID] if it exists, otherwise null
     */
    fun getUnit(mRID: String): PowerElectronicsUnit? = _powerElectronicsUnits?.getByMRID(mRID)

    fun addUnit(unit: PowerElectronicsUnit): PowerElectronicsConnection {
        if (validateReference(unit, ::getUnit, "An PowerElectronicsUnit"))
            return this

        _powerElectronicsUnits = _powerElectronicsUnits ?: mutableListOf()
        _powerElectronicsUnits!!.add(unit)

        return this
    }

    fun removeUnit(unit: PowerElectronicsUnit): Boolean {
        val ret = _powerElectronicsUnits?.remove(unit) == true
        if (_powerElectronicsUnits.isNullOrEmpty()) _powerElectronicsUnits = null
        return ret
    }

    fun clearUnits(): PowerElectronicsConnection {
        _powerElectronicsUnits = null
        return this
    }

    /**
     * Get the number of entries in the [PowerElectronicsConnectionPhase] collection.
     */
    fun numPhases(): Int = _powerElectronicsConnectionPhases?.size ?: 0

    /**
     * The individual phase information of the power electronics connection.
     *
     * @param mRID the mRID of the required [PowerElectronicsConnectionPhase]
     * @return The [PowerElectronicsConnectionPhase] with the specified [mRID] if it exists, otherwise null
     */
    fun getPhase(mRID: String): PowerElectronicsConnectionPhase? = _powerElectronicsConnectionPhases?.getByMRID(mRID)

    fun addPhase(phase: PowerElectronicsConnectionPhase): PowerElectronicsConnection {
        if (validateReference(phase, ::getPhase, "An PowerElectronicsConnectionPhase"))
            return this

        if (phase.powerElectronicsConnection == null)
            phase.powerElectronicsConnection = this

        require(phase.powerElectronicsConnection === this) {
            "${phase.typeNameAndMRID()} `powerElectronicsConnection` property references ${phase.powerElectronicsConnection!!.typeNameAndMRID()}, expected ${typeNameAndMRID()}."
        }

        _powerElectronicsConnectionPhases = _powerElectronicsConnectionPhases ?: mutableListOf()
        _powerElectronicsConnectionPhases!!.add(phase)

        return this
    }

    fun removePhase(phase: PowerElectronicsConnectionPhase): Boolean {
        val ret = _powerElectronicsConnectionPhases?.remove(phase) == true
        if (_powerElectronicsConnectionPhases.isNullOrEmpty()) _powerElectronicsConnectionPhases = null
        return ret
    }

    fun clearPhases(): PowerElectronicsConnection {
        _powerElectronicsConnectionPhases = null
        return this
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy