Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d14c2d7
Add bus factory.
pelesh Oct 20, 2022
99c1aec
Parse load data from the input file.
pelesh Oct 20, 2022
dfb5212
Check load data when testing Matpower parser.
pelesh Oct 20, 2022
8c237b0
Do not store load data in bus data structure.
pelesh Oct 21, 2022
0a13036
Changed names and order of template parameters in power system data s…
pelesh Oct 21, 2022
b0b8f7a
More intuitieve data structures names
pelesh Oct 21, 2022
87153de
Pass correct scalar and real types to derived bus classes.
pelesh Oct 24, 2022
46c8d9d
Add generator base and slack classes.
pelesh Nov 30, 2022
f1e5271
Infrastructure for adding buses and generators to power flow models
pelesh Dec 14, 2022
e25b06c
Supporting infrastructure for Loads and Branches
pelesh Dec 15, 2022
57ca0f1
Updated Parsing Example
reid-g Jun 20, 2023
e09022d
Merge branch 'parsecomp-dev' into 'parser-dev'
reid-g Jun 20, 2023
a4efa0f
Fixed Memory Errors in KinSol and SystemSteadyStateModel
reid-g Jun 26, 2023
791b0e6
Prototype Example of Creating a RL Circuit
reid-g Jun 30, 2023
416dfeb
Release 0.0.7 updates
pelesh Jul 13, 2023
ea2cee1
Merge branch 'release-0.0.7' of https://code.ornl.gov/peles/GridKit i…
reid-g Jul 17, 2023
19abae6
Add New Components and Changes to Composition
reid-g Jul 27, 2023
78ca85c
Added COO Sparse Matrices, Component Jacobians, and Discrete Generator
reid-g Nov 16, 2023
f4b209a
Added Jacobian Assembly. Fixed and Added New Functionality to COO Mat…
reid-g Nov 20, 2023
b52d776
Jacobian Assembly, IDA + KLU Cmake, RL Circuit
reid-g Dec 11, 2023
cdb4662
Added the Transmission Line Component
reid-g Jan 30, 2024
7e7937c
Added Microgrid Example
reid-g Feb 19, 2024
77827fe
Working Microgrid (Finite Difference)
reid-g Feb 19, 2024
a3077eb
Fixed the Jacobian in Microgrid Example
reid-g Feb 22, 2024
bff1327
Added a max step size control for model objects
reid-g Feb 22, 2024
7919fb6
Working example with the scalable microgrid
reid-g Feb 26, 2024
5baeb03
Fixed N=2 case
reid-g Feb 26, 2024
2d4ad96
Multiple Scaled Problems with References
reid-g Feb 27, 2024
171db62
Add bus factory.
pelesh Oct 20, 2022
c6bb787
Parse load data from the input file.
pelesh Oct 20, 2022
7cf0b3e
Check load data when testing Matpower parser.
pelesh Oct 20, 2022
91c7c09
Do not store load data in bus data structure.
pelesh Oct 21, 2022
d8570d5
Changed names and order of template parameters in power system data s…
pelesh Oct 21, 2022
0873ac7
More intuitieve data structures names
pelesh Oct 21, 2022
f7733a6
Pass correct scalar and real types to derived bus classes.
pelesh Oct 24, 2022
5627c0a
Add generator base and slack classes.
pelesh Nov 30, 2022
c151339
Infrastructure for adding buses and generators to power flow models
pelesh Dec 14, 2022
da342bd
Supporting infrastructure for Loads and Branches
pelesh Dec 15, 2022
0caf79b
Updated Parsing Example
reid-g Jun 20, 2023
d1c58bd
Prototype Example of Creating a RL Circuit
reid-g Jun 30, 2023
426ab4c
Add New Components and Changes to Composition
reid-g Jul 27, 2023
b8f4106
Added COO Sparse Matrices, Component Jacobians, and Discrete Generator
reid-g Nov 16, 2023
d54de58
Added Jacobian Assembly. Fixed and Added New Functionality to COO Mat…
reid-g Nov 20, 2023
928452f
Jacobian Assembly, IDA + KLU Cmake, RL Circuit
reid-g Dec 11, 2023
86e23a0
Added the Transmission Line Component
reid-g Jan 30, 2024
5b89936
Added Microgrid Example
reid-g Feb 19, 2024
6625205
Working Microgrid (Finite Difference)
reid-g Feb 19, 2024
ae8a8bd
Fixed the Jacobian in Microgrid Example
reid-g Feb 22, 2024
742dc0d
Added a max step size control for model objects
reid-g Feb 22, 2024
a010111
Working example with the scalable microgrid
reid-g Feb 26, 2024
a2c22d4
Fixed N=2 case
reid-g Feb 26, 2024
9e92e66
Multiple Scaled Problems with References
reid-g Feb 27, 2024
6616ce5
Rebase Fixes of develop
reid-g May 7, 2024
3a54cc3
Merge branch 'back-scale-microgrid-dev' into scale-microgrid-dev
reid-g May 7, 2024
749f8d1
Updated Scale Microgrid for CMake Source
reid-g May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMake/FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ Author(s):
set(SUITESPARSE_MODULES
amd
colamd
klu)
klu
suitesparseconfig)

find_library(SUITESPARSE_LIBRARY
NAMES
suitesparseconfig
${SUITESPARSE_MODULES}
PATHS
${SUITESPARSE_DIR} $ENV{SUITESPARSE_DIR} ${SUITESPARSE_ROOT_DIR}
Expand All @@ -97,6 +97,7 @@ find_path(SUITESPARSE_INCLUDE_DIR
amd.h
colamd.h
klu.h
SuiteSparse_config.h
PATHS
${SUITESPARSE_DIR} $ENV{SUITESPARSE_DIR} ${SUITESPARSE_ROOT_DIR} ${SUITESPARSE_LIBRARY_DIR}/..
PATH_SUFFIXES
Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" ON)
option(GRIDKIT_ENABLE_SUNDIALS "Enable SUNDIALS support" ON)

# Enable KLU
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" OFF)
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" ON)


set(CMAKE_MACOSX_RPATH 1)

#Provide string to source
add_compile_definitions("SOURCE_ROOT=${CMAKE_SOURCE_DIR}")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)

# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath
Expand All @@ -110,7 +113,7 @@ endif("${isSystemDir}" STREQUAL "-1")


# TODO: Probably beter to set a debug interface target
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")

set(CMAKE_CXX_STANDARD 17)

Expand Down Expand Up @@ -143,6 +146,9 @@ add_subdirectory(ComponentLib)
# General Utilities and File IO
add_subdirectory(Utilities)

#Local Sparse matrix operations
add_subdirectory(SparseMatrix)

# Create solvers
add_subdirectory(Solver)

Expand Down
119 changes: 119 additions & 0 deletions CircuitGraph.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@


#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_set>
#include <map>

/**
* @brief A very basic hypergraph setup for circuit representation. This forms the hypergraph as a bipartite graph. Doesn't allow removing. Can only grab sets of connections to nodes
*
* @todo should replace with something better and more efficent. Should replace with a libraries setup instead. This would allow fast and easy partitioning of circuits
*
* @todo should replace N and E with Node and Component classes respectively
*
* @tparam IdxT
* @tparam Label
*/
template <typename N, typename E>
class CircuitGraph
{
private:
std::set<N> hypernodes;
std::set<E> hyperedges;
std::map<E, std::set<N>> edgestonodes;
public:
CircuitGraph();
~CircuitGraph();
bool addHyperEdge(E he);
bool addHyperNode(N hn);
bool addConnection(N hn, E he);
std::set<N> getHyperEdgeConnections(E he);
size_t amountHyperNodes();
size_t amountHyperEdges();
void printBiPartiteGraph(bool verbose = false);
};

template <typename N, typename E>
CircuitGraph<N, E>::CircuitGraph()
{
}

template <typename N, typename E>
CircuitGraph<N, E>::~CircuitGraph()
{
}

template <typename N, typename E>
bool CircuitGraph<N, E>::addHyperNode(N hn)
{
return this->hypernodes.insert(hn).second;
}

template <typename N, typename E>
bool CircuitGraph<N, E>::addHyperEdge(E he)
{
return this->hyperedges.insert(he).second;
}


template <typename N, typename E>
bool CircuitGraph<N, E>::addConnection(N hn, E he)
{
if(this->hyperedges.count(he) == 0 || this->hypernodes.count(hn) == 0)
{
return false;
}
return this->edgestonodes[he].insert(hn).second;
}


template <typename N, typename E>
std::set<N> CircuitGraph<N, E>::getHyperEdgeConnections(E he)
{
return this->edgestonodes[he];
}


template <typename N, typename E>
size_t CircuitGraph<N, E>::amountHyperNodes()
{
return this->hypernodes.size();
}


template <typename N, typename E>
size_t CircuitGraph<N, E>::amountHyperEdges()
{
return this->hyperedges.size();
}

/**
* @brief Printing
*
* @todo need to add verbose printing for connections display
*
* @tparam IdxT
* @param verbose
*/

template <typename N, typename E>
void CircuitGraph<N, E>::printBiPartiteGraph(bool verbose)
{

std::cout << "Amount of HyperNodes: " << this->amountHyperNodes() << std::endl;
std::cout << "Amount of HyperEdges: " << this->amountHyperEdges() << std::endl;
std::cout << "Connections per Edge:" << std::endl;
for (auto i : this->edgestonodes)
{
std::cout << i.first << " : {";
for (auto j : i.second){
std::cout << j << ", ";
}
std::cout << "}\n";

}


}
2 changes: 1 addition & 1 deletion ComponentLib/Bus/BusFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ namespace ModelLib {
}
};

} // namespace ModelLib
} // namespace ModelLib
2 changes: 1 addition & 1 deletion ComponentLib/Bus/BusPV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ template <class ScalarT, typename IdxT>
BusPV<ScalarT, IdxT>::BusPV(ScalarT V, ScalarT theta0)
: BaseBus<ScalarT, IdxT>(0), V_(V), theta0_(theta0)
{
//std::cout << "Create BusPV..." << std::endl;
//std::cout << "Create BusPV ..." << std::endl;
//std::cout << "Number of equations is " << size_ << std::endl;

size_ = 1;
Expand Down
2 changes: 2 additions & 0 deletions ComponentLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ add_subdirectory(Generator4Governor)
add_subdirectory(Generator4Param)
add_subdirectory(Load)
add_subdirectory(MiniGrid)
add_subdirectory(PowerElectronicsComponents)

8 changes: 2 additions & 6 deletions ComponentLib/Generator/GeneratorPV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,14 @@ namespace ModelLib
return P_;
}

/// @brief Reactive power excess on PV bus
/// @return reference to negative PV generator reactive power
virtual ScalarT& Q()
{
return (bus_->Q());
return bus_->Q();
}

/// @brief Reactive power excess on PV bus
/// @return const reference to negative PV generator reactive power
virtual const ScalarT& Q() const
{
return (bus_->Q());
return bus_->Q();
}

private:
Expand Down
14 changes: 14 additions & 0 deletions ComponentLib/PowerElectronicsComponents/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


add_subdirectory(Capacitor)
add_subdirectory(Resistor)
add_subdirectory(VoltageSource)
add_subdirectory(Inductor)
add_subdirectory(LinearTransformer)
add_subdirectory(InductionMotor)
add_subdirectory(SynchronousMachine)
add_subdirectory(DiscreteGenerator)
add_subdirectory(TransmissionLine)
add_subdirectory(MicrogridLoad)
add_subdirectory(MicrogridLine)
add_subdirectory(MicrogridBusDQ)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@



gridkit_add_library(powerelec_capacitor
SOURCES
Capacitor.cpp
OUTPUT_NAME
gridkit_powerelec_capacitor)
137 changes: 137 additions & 0 deletions ComponentLib/PowerElectronicsComponents/Capacitor/Capacitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@



#include <iostream>
#include <cmath>
#include <vector>
#include "Capacitor.hpp"

namespace ModelLib {

/*!
* @brief Constructor for a constant load model
*
* Calls default ModelEvaluatorImpl constructor.
*/

template <class ScalarT, typename IdxT>
Capacitor<ScalarT, IdxT>::Capacitor(IdxT id, ScalarT C)
: C_(C)
{
this->size_ = 3;
this->n_intern = 1;
this->n_extern = 2;
this->extern_indices = {0,1};
this->idc_ = id;
}

template <class ScalarT, typename IdxT>
Capacitor<ScalarT, IdxT>::~Capacitor()
{
}

/*!
* @brief allocate method computes sparsity pattern of the Jacobian.
*/
template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::allocate()
{
this->y_.resize(this->size_);
this->yp_.resize(this->size_);
this->f_.resize(this->size_);

return 0;
}

/**
* Initialization of the grid model
*/
template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::initialize()
{
return 0;
}

/*
* \brief Identify differential variables
*/
template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::tagDifferentiable()
{
return 0;
}

/**
* @brief Contributes to the bus residual.
*
* Must be connected to a PQ bus.
*/
template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateResidual()
{
//input
this->f_[0] = C_ * this->yp_[2];
//output
this->f_[1] = -C_ * this->yp_[2];

//internal
this->f_[2] = -C_ * this->yp_[2] + this->y_[0] - this->y_[1] - this->y_[2];
return 0;
}

template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateJacobian()
{
this->J_.zeroMatrix();
//Create dF/dy
std::vector<IdxT> rcord{2,2,2};
std::vector<IdxT> ccord{0,1,2};
std::vector<ScalarT> vals{1.0, -1.0, -1.0};
this->J_.setValues(rcord, ccord, vals);

//Create -dF/dy'
std::vector<IdxT> rcordder{0,1,2};
std::vector<IdxT> ccordder{2,2,2};
std::vector<ScalarT> valsder{C_, -C_, -this->C_};
COO_Matrix<ScalarT,IdxT> Jacder = COO_Matrix<ScalarT, IdxT>(rcordder, ccordder, valsder,3,3);

//Perform dF/dy + \alpha dF/dy'
this->J_.AXPY(this->alpha_, Jacder);

return 0;
}

template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateIntegrand()
{
return 0;
}

template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::initializeAdjoint()
{
return 0;
}

template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateAdjointResidual()
{
return 0;
}

template <class ScalarT, typename IdxT>
int Capacitor<ScalarT, IdxT>::evaluateAdjointIntegrand()
{
return 0;
}




// Available template instantiations
template class Capacitor<double, long int>;
template class Capacitor<double, size_t>;


} //namespace ModelLib

Loading