Skip to content

Commit fe85267

Browse files
committed
Remove island checks
1 parent f679ffd commit fe85267

6 files changed

Lines changed: 12 additions & 114 deletions

File tree

‎GridKit/Model/OptimalPowerFlow/Branch/Branch.hpp‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ namespace GridKit
8585
[[gnu::always_inline]] void internalConstraints(const ScalarT* x, const ScalarT* external, ScalarT* g) const override;
8686
[[gnu::always_inline]] void externalConstraints(const ScalarT* x, const ScalarT* external, ScalarT* g) const override;
8787

88-
bool inService() const
89-
{
90-
return in_service_;
91-
}
92-
9388
private:
9489
void initializeParameters(const ModelDataT& data);
9590
void setDerivedParameters();

‎GridKit/Model/OptimalPowerFlow/Bus/Bus.hpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ namespace GridKit
7979

8080
[[gnu::always_inline]] void internalConstraints(const ScalarT* x, const ScalarT* external, ScalarT* g) const override;
8181

82-
/// Angle reference, with zero imaginary voltage
83-
bool reference() const
84-
{
85-
return reference_;
86-
}
87-
8882
private:
8983
void initializeParameters(const ModelDataT& data);
9084

‎GridKit/Model/OptimalPowerFlow/README.md‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variable bounds $x_l \le x \le x_u$. The objective and each constraint sum
1010
component contributions. Each constraint and variable bound belongs to one
1111
component, which tags the constraint as an inequality or leaves it an equality
1212
with $g_l = g_u = 0$. An inequality without a finite limit has infinite bounds.
13-
Every island needs a reference bus.
13+
Every island needs a reference bus, which the system does not check.
1414

1515
Cartesian voltages make a solution directly a starting point for a phasor
1616
dynamics simulation. Branch power is quadratic in these voltages; ZIP
@@ -57,13 +57,9 @@ are added to the owning constraints; they are not separate constraints. For
5757
example, a generator contributes power to a bus's balance without reading its
5858
voltage.
5959

60-
Case bus numbers are resolved when constructing the system. Electrical islands
61-
follow in-service branches, independently of component dependencies.
62-
63-
`SystemModel` also accepts a vector of owned components for direct composition.
64-
That constructor validates component parameters and connections. Electrical
65-
island and reference checks use the network metadata supplied by the case-data
66-
constructor.
60+
Case bus numbers are resolved when constructing the system. `SystemModel` also
61+
accepts a vector of owned components for direct composition. That constructor
62+
validates component parameters and connections.
6763

6864
## Derivatives
6965

‎GridKit/Model/OptimalPowerFlow/SystemModel.hpp‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ namespace GridKit
2121
template <typename scalar_type, typename index_type>
2222
class Bus;
2323

24-
template <typename scalar_type, typename index_type>
25-
class Branch;
26-
2724
/**
2825
* @brief AC optimal power flow in Cartesian coordinates
2926
*
@@ -46,7 +43,6 @@ namespace GridKit
4643
using IndexVectorT = LinearAlgebra::Vector<IdxT, IdxT>;
4744
using CsrMatrixT = typename EvaluatorT::CsrMatrixT;
4845
using BusT = Bus<ScalarT, IdxT>;
49-
using BranchT = Branch<ScalarT, IdxT>;
5046
using Block = typename ComponentT::Block;
5147
using CooBufferT = typename ComponentT::CooBuffer;
5248

@@ -92,12 +88,11 @@ namespace GridKit
9288
void addBus(const BusData<RealT, IdxT>& data);
9389

9490
template <typename ModelT, typename DataT>
95-
ModelT& addDevice(const DataT& data);
91+
void addDevice(const DataT& data);
9692

97-
int compose();
98-
int bind(ComponentT& component, const Block& offset);
99-
std::vector<IdxT> unreferencedIslands() const;
100-
int allocateDerivatives();
93+
int compose();
94+
int bind(ComponentT& component, const Block& offset);
95+
int allocateDerivatives();
10196

10297
std::unique_ptr<CsrMatrixT> assemble(IdxT rows, IdxT cols, Assembly& assembly) const;
10398
int refill(CsrMatrixT& matrix, const Assembly& assembly) const;
@@ -108,9 +103,6 @@ namespace GridKit
108103
/// Buses by number
109104
std::map<IdxT, BusT*> buses_;
110105

111-
/// Electrical connectivity, independent of component dependencies
112-
std::vector<BranchT*> branches_;
113-
114106
Assembly jacobian_assembly_;
115107
Assembly hessian_assembly_;
116108
};

‎GridKit/Model/OptimalPowerFlow/SystemModelImpl.hpp‎

Lines changed: 3 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#pragma once
77

88
#include <format>
9-
#include <map>
109
#include <set>
1110
#include <stdexcept>
1211
#include <string>
@@ -43,7 +42,7 @@ namespace GridKit
4342

4443
for (const auto& branch : data.branch)
4544
{
46-
branches_.push_back(&addDevice<BranchT>(branch));
45+
addDevice<Branch<ScalarT, IdxT>>(branch);
4746
}
4847

4948
for (const auto& generator : data.generator)
@@ -71,8 +70,7 @@ namespace GridKit
7170
}
7271

7372
/**
74-
* @brief Every problem with the data, including an island without a
75-
* reference bus
73+
* @brief Every problem with the data
7674
*/
7775
template <typename scalar_type, typename index_type>
7876
Model::ConfigurationChecks SystemModel<scalar_type, index_type>::verify() const
@@ -91,11 +89,6 @@ namespace GridKit
9189
std::format("{}: invalid bus number", bus->id()));
9290
}
9391

94-
for (const IdxT number : unreferencedIslands())
95-
{
96-
checks.fail(std::format("OptimalPowerFlow::SystemModel: the island of bus {} has no reference bus", number));
97-
}
98-
9992
std::set<std::string> ids;
10093
for (const auto& component : components_)
10194
{
@@ -274,7 +267,7 @@ namespace GridKit
274267
*/
275268
template <typename scalar_type, typename index_type>
276269
template <typename ModelT, typename DataT>
277-
ModelT& SystemModel<scalar_type, index_type>::addDevice(const DataT& data)
270+
void SystemModel<scalar_type, index_type>::addDevice(const DataT& data)
278271
{
279272
using Ports = typename DataT::Ports;
280273
static_assert(ModelT::NUM_PORT_VARIABLES.size() == Utilities::enum_size<Ports>());
@@ -302,9 +295,7 @@ namespace GridKit
302295
}
303296
}
304297

305-
ModelT& added = *device;
306298
components_.push_back(std::move(device));
307-
return added;
308299
}
309300

310301
/**
@@ -371,61 +362,5 @@ namespace GridKit
371362
component.bound_ = true;
372363
return 0;
373364
}
374-
375-
/**
376-
* @brief Lowest bus number of each island without a reference bus
377-
*
378-
* In-service branches connect the buses of their ports.
379-
*/
380-
template <typename scalar_type, typename index_type>
381-
std::vector<index_type> SystemModel<scalar_type, index_type>::unreferencedIslands() const
382-
{
383-
// Each bus points toward the root bus of its island
384-
std::map<const ComponentT*, const ComponentT*> parent;
385-
for (const auto& [number, bus] : buses_)
386-
{
387-
parent[bus] = bus;
388-
}
389-
390-
const auto root = [&parent](const ComponentT* bus)
391-
{
392-
while (parent.at(bus) != bus)
393-
{
394-
bus = parent.at(bus);
395-
}
396-
return bus;
397-
};
398-
399-
for (const auto* branch : branches_)
400-
{
401-
const auto& ports = branch->ports();
402-
if (!branch->inService() || ports[0].component == nullptr || ports[1].component == nullptr)
403-
{
404-
continue;
405-
}
406-
parent[root(ports[1].component)] = root(ports[0].component);
407-
}
408-
409-
std::set<const ComponentT*> referenced;
410-
for (const auto& [number, bus] : buses_)
411-
{
412-
if (bus->reference())
413-
{
414-
referenced.insert(root(bus));
415-
}
416-
}
417-
418-
std::vector<IdxT> unreferenced;
419-
std::set<const ComponentT*> reported;
420-
for (const auto& [number, bus] : buses_)
421-
{
422-
const auto* island = root(bus);
423-
if (!referenced.contains(island) && reported.insert(island).second)
424-
{
425-
unreferenced.push_back(number);
426-
}
427-
}
428-
return unreferenced;
429-
}
430365
} // namespace OptimalPowerFlow
431366
} // namespace GridKit

‎tests/UnitTests/OptimalPowerFlow/SystemTests.hpp‎

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,11 @@ namespace GridKit
273273
return success.report(__func__);
274274
}
275275

276-
/// Invalid bus numbers, connections, and islands are rejected
276+
/// Invalid bus numbers and connections are rejected
277277
TestOutcome configuration()
278278
{
279279
TestStatus success = true;
280280

281-
auto no_reference = SystemTestData::data();
282-
no_reference.bus[0].parameters[OPF::BusParameters::reference] = false;
283-
284-
success *= configurationRejected([&]()
285-
{ return SystemT(no_reference).verify(); });
286-
287-
// Out-of-service branches 2-3 and 1-3 leave bus 3 an island without a reference bus
288-
auto island = SystemTestData::data();
289-
island.branch[1].parameters[OPF::BranchParameters::in_service] = false;
290-
island.branch[2].parameters[OPF::BranchParameters::in_service] = false;
291-
292-
success *= configurationRejected([&]()
293-
{ return SystemT(island).verify(); });
294-
295281
auto repeated = SystemTestData::data();
296282
repeated.bus[1].number = 1;
297283

0 commit comments

Comments
 (0)