Skip to content

Commit

Permalink
Merge branch 'main' into rename_model_model
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <laurent.issertial@rte-france.com>
  • Loading branch information
Lisrte committed Jun 22, 2023
1 parent 21c0a7d commit e86140d
Show file tree
Hide file tree
Showing 121 changed files with 1,596 additions and 650 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import java.util.function.Consumer
abstract class AbstractEquipmentGroovyExtension<T> {

protected static final String MODELS_CONFIG = "models.cfg"
protected static final String MODELS_PROPERTIES = "properties"
protected static final String MODEL_PREFIX = "prefix"
protected static final String MODEL_PROPERTIES = "properties"

protected final List<EquipmentConfig> equipmentConfigs

Expand All @@ -29,7 +30,11 @@ abstract class AbstractEquipmentGroovyExtension<T> {
protected AbstractEquipmentGroovyExtension(String modelTag, URL modelConfigUrl) {
ConfigSlurper config = new ConfigSlurper()
equipmentConfigs = config.parse(modelConfigUrl).get(modelTag).collect {
new EquipmentConfig(it.key as String, it.value.get(MODELS_PROPERTIES).collect{it.toUpperCase()} as String[])
new EquipmentConfig(
it.key as String,
it.value.get(MODEL_PREFIX) as String,
it.value.get(MODEL_PROPERTIES).collect { it.toUpperCase() } as String[]
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,31 @@ package com.powsybl.dynawaltz.dsl
class EquipmentConfig {

static final String CONTROLLABLE_PROPERTY = "CONTROLLABLE"
static final String DANGLING_PROPERTY = "DANGLING"
static final String SYNCHRONIZED_PROPERTY = "SYNCHRONIZED"

String lib
List<String> properties
final String lib
final String prefix
final List<String> properties

EquipmentConfig(String lib) {
this.lib = lib
this.properties = []
}

EquipmentConfig(String lib, String... properties) {
EquipmentConfig(String lib, String prefix, String... properties) {
this.lib = lib
this.prefix = prefix
this.properties = properties
}

boolean isControllable() {
properties.contains(CONTROLLABLE_PROPERTY)
}

boolean isDangling() {
properties.contains(DANGLING_PROPERTY)
}

boolean isSynchronized() {
properties.contains(SYNCHRONIZED_PROPERTY)
}

boolean hasProperty(String property) {
properties.contains(property)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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.dynawaltz.dsl.models.generators

import com.google.auto.service.AutoService
import com.powsybl.dynamicsimulation.DynamicModel
import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension
import com.powsybl.dynawaltz.dsl.EquipmentConfig
import com.powsybl.dynawaltz.models.generators.GridFormingConverter
import com.powsybl.iidm.network.Network

/**
* @author Laurent Issertial <laurent.issertial at rte-france.com>
*/
@AutoService(DynamicModelGroovyExtension.class)
class GridFormingConverterGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel> implements DynamicModelGroovyExtension {

private static final String GRID_FORMING_CONVERTER = "gridFormingConverter"

GridFormingConverterGroovyExtension() {
super(GRID_FORMING_CONVERTER)
}

@Override
protected GridFormingConverterBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) {
new GridFormingConverterBuilder(network, equipmentConfig)
}

static class GridFormingConverterBuilder extends AbstractGeneratorBuilder {

EquipmentConfig equipmentConfig

GridFormingConverterBuilder(Network network, EquipmentConfig equipmentConfig) {
super(network)
this.equipmentConfig = equipmentConfig
}

@Override
GridFormingConverter build() {
checkData()
new GridFormingConverter(dynamicModelId, generator, parameterSetId, equipmentConfig.lib)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class SynchronizedGeneratorGroovyExtension extends AbstractEquipmentGroovyExtens
super(SYNCHRONIZED_GENERATORS)
}

protected SynchronizedGeneratorGroovyExtension(URL config) {
super(SYNCHRONIZED_GENERATORS, config)
}

@Override
protected SynchronizedGeneratorBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) {
new SynchronizedGeneratorBuilder(network, equipmentConfig)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* 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.dynawaltz.dsl.models.generators

import com.google.auto.service.AutoService
import com.powsybl.dynamicsimulation.DynamicModel
import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension
import com.powsybl.dynawaltz.dsl.EquipmentConfig
import com.powsybl.dynawaltz.models.generators.SynchronizedWeccGen
import com.powsybl.dynawaltz.models.generators.WeccGen
import com.powsybl.iidm.network.Network

/**
* @author Laurent Issertial <laurent.issertial at rte-france.com>
*/
@AutoService(DynamicModelGroovyExtension.class)
class WeccGenGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel> implements DynamicModelGroovyExtension {

private static final String WECC = "wecc"

WeccGenGroovyExtension() {
super(WECC)
}

@Override
protected WeccGenBuilder createBuilder(Network network, EquipmentConfig equipmentConfig) {
new WeccGenBuilder(network, equipmentConfig)
}

static class WeccGenBuilder extends AbstractGeneratorBuilder {

EquipmentConfig equipmentConfig

WeccGenBuilder(Network network, EquipmentConfig equipmentConfig) {
super(network)
this.equipmentConfig = equipmentConfig
}

@Override
WeccGen build() {
checkData()
if (equipmentConfig.isSynchronized()) {
new SynchronizedWeccGen(dynamicModelId, generator, parameterSetId, equipmentConfig.lib, equipmentConfig.prefix)
} else {
new WeccGen(dynamicModelId, generator, parameterSetId, equipmentConfig.lib, equipmentConfig.prefix)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
package com.powsybl.dynawaltz.dsl.models.hvdc

import com.powsybl.dsl.DslException
import com.powsybl.dynawaltz.dsl.EquipmentConfig
import com.powsybl.dynawaltz.dsl.models.builders.AbstractDynamicModelBuilder
import com.powsybl.dynawaltz.models.Side
import com.powsybl.dynawaltz.models.utils.SideConverter
import com.powsybl.iidm.network.Branch
import com.powsybl.iidm.network.HvdcLine
import com.powsybl.iidm.network.Network

Expand All @@ -18,9 +22,20 @@ import com.powsybl.iidm.network.Network
abstract class AbstractHvdcBuilder extends AbstractDynamicModelBuilder {

HvdcLine hvdc
EquipmentConfig equipmentConfig
Side danglingSide

AbstractHvdcBuilder(Network network) {
AbstractHvdcBuilder(Network network, EquipmentConfig equipmentConfig) {
super(network)
this.equipmentConfig = equipmentConfig
}

void dangling(Branch.Side danglingSide) {
if (equipmentConfig.isDangling()) {
this.danglingSide = SideConverter.convert(danglingSide)
} else {
throw new DslException("'dangling' field is set on a non dangling hvdc : ${equipmentConfig.lib}")
}
}

void checkData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension
import com.powsybl.dynawaltz.dsl.EquipmentConfig
import com.powsybl.dynawaltz.models.hvdc.HvdcPv
import com.powsybl.iidm.network.HvdcLine
import com.powsybl.dynawaltz.models.hvdc.HvdcPvDangling
import com.powsybl.iidm.network.Network

/**
Expand All @@ -39,17 +39,18 @@ class HvdcPvGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicMode

static class HvdcBuilder extends AbstractHvdcBuilder {

EquipmentConfig equipmentConfig

HvdcBuilder(Network network, EquipmentConfig equipmentConfig) {
super(network)
this.equipmentConfig = equipmentConfig
super(network, equipmentConfig)
}

@Override
HvdcPv build() {
checkData()
new HvdcPv(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib)
if (equipmentConfig.isDangling()) {
new HvdcPvDangling(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib, danglingSide)
} else {
new HvdcPv(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.dsl.AbstractEquipmentGroovyExtension
import com.powsybl.dynawaltz.dsl.EquipmentConfig
import com.powsybl.dynawaltz.models.hvdc.HvdcVsc
import com.powsybl.dynawaltz.models.hvdc.HvdcVscDangling
import com.powsybl.iidm.network.Network

/**
Expand All @@ -34,17 +35,18 @@ class HvdcVscGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicMod

static class HvdcBuilder extends AbstractHvdcBuilder {

EquipmentConfig equipmentConfig

HvdcBuilder(Network network, EquipmentConfig equipmentConfig) {
super(network)
this.equipmentConfig = equipmentConfig
super(network, equipmentConfig)
}

@Override
HvdcVsc build() {
checkData()
new HvdcVsc(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib)
if (equipmentConfig.isDangling()) {
new HvdcVscDangling(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib, danglingSide)
} else {
new HvdcVsc(dynamicModelId, hvdc, parameterSetId, equipmentConfig.lib)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.dynawaltz.dsl.models.svcs
package com.powsybl.dynawaltz.dsl.models.svarcs

import com.google.auto.service.AutoService
import com.powsybl.dsl.DslException
Expand All @@ -21,12 +21,12 @@ import com.powsybl.iidm.network.StaticVarCompensator
* @author Laurent Issertial <laurent.issertial at rte-france.com>
*/
@AutoService(DynamicModelGroovyExtension.class)
class SvcGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel> implements DynamicModelGroovyExtension {
class SvarcGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel> implements DynamicModelGroovyExtension {

protected static final String SVC = "staticVarCompensators"
protected static final String SVARC = "staticVarCompensators"

SvcGroovyExtension() {
super(SVC)
SvarcGroovyExtension() {
super(SVARC)
}

@Override
Expand All @@ -36,7 +36,7 @@ class SvcGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel>

static class SvcBuilder extends AbstractDynamicModelBuilder {

StaticVarCompensator svc
StaticVarCompensator svarc
EquipmentConfig equipmentConfig

SvcBuilder(Network network, EquipmentConfig equipmentConfig) {
Expand All @@ -46,16 +46,16 @@ class SvcGroovyExtension extends AbstractEquipmentGroovyExtension<DynamicModel>

void checkData() {
super.checkData()
svc = network.getStaticVarCompensator(staticId)
if (svc == null) {
svarc = network.getStaticVarCompensator(staticId)
if (svarc == null) {
throw new DslException("Static var compensator static id unknown: " + staticId)
}
}

@Override
com.powsybl.dynawaltz.models.svcs.StaticVarCompensator build() {
com.powsybl.dynawaltz.models.svarcs.StaticVarCompensator build() {
checkData()
new com.powsybl.dynawaltz.models.svcs.StaticVarCompensator(dynamicModelId, svc, parameterSetId, equipmentConfig.lib)
new com.powsybl.dynawaltz.models.svarcs.StaticVarCompensator(dynamicModelId, svarc, parameterSetId, equipmentConfig.lib)
}
}
}
33 changes: 33 additions & 0 deletions dynawaltz-dsl/src/main/resources/models.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ hvdcPv {
HvdcPVDiagramPQEmulationSet
HvdcPTanPhi
HvdcPTanPhiDiagramPQ
HvdcPVDangling.properties = ["Dangling"]
HvdcPVDanglingDiagramPQ.properties = ["Dangling"]
HvdcPTanPhiDangling.properties = ["Dangling"]
HvdcPTanPhiDanglingDiagramPQ.properties = ["Dangling"]
}

hvdcVsc {
HvdcVSC
HvdcVSCEmulation
HvdcVSCDanglingP.properties = ["Dangling"]
HvdcVSCDanglingUdc.properties = ["Dangling"]
}

infiniteBuses {
Expand Down Expand Up @@ -71,3 +77,30 @@ staticVarCompensators {
transformers {
TransformerFixedRatio
}

wecc {
WTG4AWeccCurrentSource {
prefix = "WTG4A"
properties = ["Synchronized"]
}
WTG4BWeccCurrentSource {
prefix = "WTG4B"
properties = ["Synchronized"]
}
WT4AWeccCurrentSource.prefix = "WT4A"
WT4BWeccCurrentSource.prefix = "WT4B"
PhotovoltaicsWeccCurrentSource {
prefix = "WTG4A"
properties = ["Synchronized"]
}
PhotovoltaicsWeccVoltageSource {
prefix = "photovoltaics"
properties = ["Synchronized"]
}
}

gridFormingConverter {
GridFormingConverterDroopControl.properties = ["Synchronized"]
GridFormingConverterMatchingControl.properties = ["Synchronized"]
GridFormingConverterDispatchableVirtualOscillatorControl.properties = ["Synchronized"]
}
Loading

0 comments on commit e86140d

Please sign in to comment.