-
Notifications
You must be signed in to change notification settings - Fork 5
/
JointGridContainer.java
122 lines (106 loc) · 3.79 KB
/
JointGridContainer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.container;
import edu.ie3.datamodel.graph.SubGridTopologyGraph;
import edu.ie3.datamodel.utils.ContainerUtils;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Model class to hold input models for more than one galvanically separated subnet */
public class JointGridContainer extends GridContainer {
/** A graph describing the subnet dependencies */
private final SubGridTopologyGraph subGridTopologyGraph;
private static final Logger logger = LoggerFactory.getLogger(JointGridContainer.class);
public JointGridContainer(
String gridName,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
GraphicElements graphics) {
super(gridName, rawGrid, systemParticipants, graphics);
/* Build sub grid dependency */
this.subGridTopologyGraph =
ContainerUtils.buildSubGridTopologyGraph(
this.gridName, this.rawGrid, this.systemParticipants, this.graphics);
checkSubGridTopologyGraph(subGridTopologyGraph);
}
public JointGridContainer(
String gridName,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
GraphicElements graphics,
SubGridTopologyGraph subGridTopologyGraph) {
super(gridName, rawGrid, systemParticipants, graphics);
this.subGridTopologyGraph = subGridTopologyGraph;
checkSubGridTopologyGraph(this.subGridTopologyGraph);
}
/**
* Checks, if the sub grid topology graph has only one node.
*
* @param subGridTopologyGraph The graph to check
*/
private void checkSubGridTopologyGraph(SubGridTopologyGraph subGridTopologyGraph) {
if (subGridTopologyGraph.vertexSet().size() == 1) {
logger.warn(
"This joint grid model only contains one single grid. Consider using SubGridContainer.");
}
}
public SubGridTopologyGraph getSubGridTopologyGraph() {
return subGridTopologyGraph;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof JointGridContainer that)) return false;
if (!super.equals(o)) return false;
return subGridTopologyGraph.equals(that.subGridTopologyGraph);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), subGridTopologyGraph);
}
@Override
public String toString() {
return "JointGridContainer{" + "gridName='" + gridName + '\'' + '}';
}
@Override
public JointGridContainerCopyBuilder copy() {
return new JointGridContainerCopyBuilder(this);
}
/**
* A builder pattern based approach to create copies of {@link JointGridContainer} containers with
* altered field values. For detailed field descriptions refer to java docs of {@link
* JointGridContainer}
*
* @version 3.1
* @since 14.02.23
*/
public static class JointGridContainerCopyBuilder
extends GridContainerCopyBuilder<JointGridContainerCopyBuilder> {
private final SubGridTopologyGraph subGridTopologyGraph;
/**
* Constructor for {@link JointGridContainerCopyBuilder}
*
* @param jointGridContainer instance of {@link JointGridContainer}
*/
protected JointGridContainerCopyBuilder(JointGridContainer jointGridContainer) {
super(jointGridContainer);
this.subGridTopologyGraph = jointGridContainer.getSubGridTopologyGraph();
}
@Override
protected JointGridContainerCopyBuilder childInstance() {
return this;
}
@Override
JointGridContainer build() {
return new JointGridContainer(
getGridName(),
getRawGrid(),
getSystemParticipants(),
getGraphics(),
subGridTopologyGraph);
}
}
}