-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor disconnection events (#197)
* Create Event disconnection in DSL with EventInjectionDisconnection and EventQuadripoleDisconnection * Add default model and quadripole disconnection for Transformer * Add disconnection UT * Handle default & dynamic model disconnection * Add default model Load * Add default model generator * Merge equipment and quadripole equipment disconnection event in DSL * Refactor event constructor Signed-off-by: lisrte <laurent.issertial@rte-france.com>
- Loading branch information
Showing
62 changed files
with
740 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...src/main/groovy/com/powsybl/dynawaltz/dsl/events/EventDisconnectionGroovyExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* 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.events | ||
|
||
import com.google.auto.service.AutoService | ||
import com.powsybl.dsl.DslException | ||
import com.powsybl.dynamicsimulation.EventModel | ||
import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension | ||
import com.powsybl.dynawaltz.dsl.AbstractPureDynamicGroovyExtension | ||
import com.powsybl.dynawaltz.models.events.AbstractEventModel | ||
import com.powsybl.dynawaltz.models.events.EventQuadripoleDisconnection | ||
import com.powsybl.dynawaltz.models.events.EventInjectionDisconnection | ||
import com.powsybl.iidm.network.Branch | ||
import com.powsybl.iidm.network.Identifiable | ||
import com.powsybl.iidm.network.IdentifiableType | ||
import com.powsybl.iidm.network.Network | ||
|
||
/** | ||
* @author Laurent Issertial <laurent.issertial at rte-france.com> | ||
*/ | ||
@AutoService(EventModelGroovyExtension.class) | ||
class EventDisconnectionGroovyExtension extends AbstractPureDynamicGroovyExtension<EventModel> implements EventModelGroovyExtension { | ||
|
||
private static final EnumSet<IdentifiableType> connectableEquipments = EnumSet.of(IdentifiableType.GENERATOR, IdentifiableType.LOAD) | ||
|
||
private static final EnumSet<IdentifiableType> connectableQuadripoleEquipments = EnumSet.of(IdentifiableType.LINE, IdentifiableType.TWO_WINDINGS_TRANSFORMER) | ||
|
||
EventDisconnectionGroovyExtension() { | ||
modelTags = ["Disconnect"] | ||
} | ||
|
||
@Override | ||
protected EventQuadripoleDisconnectionBuilder createBuilder(Network network) { | ||
new EventQuadripoleDisconnectionBuilder(network) | ||
} | ||
|
||
static class EventQuadripoleDisconnectionBuilder extends AbstractEventModelBuilder { | ||
|
||
boolean disconnectSide = false | ||
boolean isEquipment = false | ||
boolean isQuadripoleEquipment = false | ||
|
||
boolean disconnectOrigin = true | ||
boolean disconnectExtremity = true | ||
Identifiable<? extends Identifiable> identifiable | ||
|
||
EventQuadripoleDisconnectionBuilder(Network network) { | ||
super(network) | ||
} | ||
|
||
void disconnectOnly(Branch.Side side) { | ||
disconnectSide = true | ||
switch(side) { | ||
case Branch.Side.ONE : | ||
disconnectOrigin = true | ||
disconnectExtremity = false | ||
break | ||
case Branch.Side.TWO : | ||
disconnectOrigin = false | ||
disconnectExtremity = true | ||
break | ||
} | ||
} | ||
|
||
void checkData() { | ||
super.checkData() | ||
identifiable = network.getIdentifiable(staticId) | ||
if (identifiable == null) { | ||
throw new DslException("Identifiable static id unknown: " + getStaticId()) | ||
} | ||
isEquipment = connectableEquipments.contains(identifiable.getType()) | ||
isQuadripoleEquipment = connectableQuadripoleEquipments.contains(identifiable.getType()) | ||
if (!isEquipment && !isQuadripoleEquipment) { | ||
throw new DslException("Equipment ${getStaticId()} cannot be disconnected") | ||
} else if(isEquipment && disconnectSide) { | ||
throw new DslException("'disconnectSide' has been set but ${identifiable.getType() } ${getStaticId()} is not a quadripole with a disconnectable side") | ||
} | ||
} | ||
|
||
@Override | ||
AbstractEventModel build() { | ||
checkData() | ||
if(isEquipment) | ||
new EventInjectionDisconnection(identifiable, startTime) | ||
else if (isQuadripoleEquipment) | ||
new EventQuadripoleDisconnection(identifiable, startTime, disconnectOrigin, disconnectExtremity) | ||
} | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
...roovy/com/powsybl/dynawaltz/dsl/events/EventQuadripoleDisconnectionGroovyExtension.groovy
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
...c/main/groovy/com/powsybl/dynawaltz/dsl/events/EventSetPointBooleanGroovyExtension.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.