Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
c2e857c
init: test BusSignal compile [skip ci]
lukelowry Jul 3, 2025
695154a
edit: source model class interaction with Signal [skip ci]
lukelowry Jul 3, 2025
5c16ba1
add: example TwoBusTgov1 new interface [skip ci]
lukelowry Jul 3, 2025
4ca42da
rem: old syntax [skip ci]
lukelowry Jul 3, 2025
16cb12c
add: correct constructor [skip ci]
lukelowry Jul 3, 2025
9e5311f
minor: type name [skip ci]
lukelowry Jul 3, 2025
284b379
cmake: reflect changes in SystemModel [skip ci]
lukelowry Jul 3, 2025
207d681
append: BusFactory [skip ci]
lukelowry Jul 3, 2025
52d22c3
cmake: more gov link [skip ci]
lukelowry Jul 3, 2025
2090fdd
edit: back support tengen [skip ci]
lukelowry Jul 3, 2025
4bcd715
add: gov link to sys [skip ci]
lukelowry Jul 3, 2025
533ecdb
edit: safe funcs pass by ref [skip ci]
lukelowry Jul 3, 2025
e707b12
syntax: readability [skip ci]
lukelowry Jul 3, 2025
befccef
read: const modifier preference [skip ci]
lukelowry Jul 3, 2025
4264ea4
add: initial value function to BusBase [skip ci]
lukelowry Jul 3, 2025
8b06e21
edit: default not init [skip ci]
lukelowry Jul 3, 2025
4388cd5
rem: consnt, odd behavior [skip ci]
lukelowry Jul 3, 2025
b4d1ef5
fix: resize bus vec [skip ci]
lukelowry Jul 3, 2025
db5283d
misc ref errors [skip ci]
lukelowry Jul 3, 2025
075608e
edit: init fixes [skip ci]
lukelowry Jul 3, 2025
965fd6f
edit: constructor error [skip ci]
lukelowry Jul 3, 2025
f52f352
edit: type consistancny [skip ci]
lukelowry Jul 3, 2025
90ef74f
edit: busbase make change too [skip ci]
lukelowry Jul 3, 2025
4cce9bf
rem: initialization check [skip ci]
lukelowry Jul 3, 2025
1aab2f2
misc edit [skip ci]
lukelowry Jul 3, 2025
c564e0e
edit: type hell [skip ci]
lukelowry Jul 3, 2025
c598da8
edit: init omega and change index [skip ci]
lukelowry Jul 3, 2025
ee375ac
edit: no funcs [skip ci]
lukelowry Jul 3, 2025
fcc3978
edit: syntax [skip ci]
lukelowry Jul 3, 2025
f4d316c
fix: rookie allocation mistake [skip ci]
lukelowry Jul 4, 2025
d8ff539
chore: variable names [skip ci]
lukelowry Jul 4, 2025
a880257
minor: incorrect constructor init [skip ci]
lukelowry Jul 4, 2025
d042463
fix: this pointer in genrou [skip ci]
lukelowry Jul 4, 2025
c37fb46
chore: pre rebase commit [skip ci]
lukelowry Jul 4, 2025
9a07614
init: test BusSignal compile [skip ci]
lukelowry Jul 3, 2025
4aa2eb4
edit: source model class interaction with Signal [skip ci]
lukelowry Jul 3, 2025
846e920
add: example TwoBusTgov1 new interface [skip ci]
lukelowry Jul 3, 2025
fc0ddea
rem: old syntax [skip ci]
lukelowry Jul 3, 2025
38571bb
add: correct constructor [skip ci]
lukelowry Jul 3, 2025
8db804d
minor: type name [skip ci]
lukelowry Jul 3, 2025
c710e83
cmake: reflect changes in SystemModel [skip ci]
lukelowry Jul 3, 2025
f56cff5
append: BusFactory [skip ci]
lukelowry Jul 3, 2025
b1a3892
cmake: more gov link [skip ci]
lukelowry Jul 3, 2025
c9e700d
edit: back support tengen [skip ci]
lukelowry Jul 3, 2025
e40b3a2
add: gov link to sys [skip ci]
lukelowry Jul 3, 2025
7e69b3f
edit: safe funcs pass by ref [skip ci]
lukelowry Jul 3, 2025
9377339
syntax: readability [skip ci]
lukelowry Jul 3, 2025
a8bc70c
read: const modifier preference [skip ci]
lukelowry Jul 3, 2025
bbff218
add: initial value function to BusBase [skip ci]
lukelowry Jul 3, 2025
0f575c2
edit: default not init [skip ci]
lukelowry Jul 3, 2025
09f5e2c
rem: consnt, odd behavior [skip ci]
lukelowry Jul 3, 2025
e6cfbc2
fix: resize bus vec [skip ci]
lukelowry Jul 3, 2025
24cc333
misc ref errors [skip ci]
lukelowry Jul 3, 2025
de6cce5
edit: init fixes [skip ci]
lukelowry Jul 3, 2025
82a348f
edit: constructor error [skip ci]
lukelowry Jul 3, 2025
833c77c
edit: type consistancny [skip ci]
lukelowry Jul 3, 2025
890a9af
edit: busbase make change too [skip ci]
lukelowry Jul 3, 2025
6e08355
rem: initialization check [skip ci]
lukelowry Jul 3, 2025
bcfb934
misc edit [skip ci]
lukelowry Jul 3, 2025
63dfc21
edit: type hell [skip ci]
lukelowry Jul 3, 2025
f832031
edit: init omega and change index [skip ci]
lukelowry Jul 3, 2025
3ef0281
edit: no funcs [skip ci]
lukelowry Jul 3, 2025
a11dc67
edit: syntax [skip ci]
lukelowry Jul 3, 2025
c263fa8
fix: rookie allocation mistake [skip ci]
lukelowry Jul 4, 2025
3046224
chore: variable names [skip ci]
lukelowry Jul 4, 2025
32922c9
minor: incorrect constructor init [skip ci]
lukelowry Jul 4, 2025
b24a8a6
fix: this pointer in genrou [skip ci]
lukelowry Jul 4, 2025
18163ca
chore: pre rebase commit [skip ci]
lukelowry Jul 4, 2025
9124244
Merge branch 'lukel/signal_bus_complete_dev' of https://github.com/OR…
lukelowry Jul 4, 2025
b647cb9
edit: post rebase safeInit and check [skip ci]
lukelowry Jul 4, 2025
b59024a
edit: remove adjoint items from BusSignal after Rebase [skip ci]
lukelowry Jul 4, 2025
085e3d2
rem: evalInteg from BusSig header [skip ci]
lukelowry Jul 4, 2025
1f1aff2
Merge branch 'develop' into lukel/signal_bus_complete_dev
lukelowry Jul 10, 2025
4429415
Apply pre-commmit fixes
lukelowry Jul 10, 2025
9588581
misc rebase fixes [skip ci]
lukelowry Jul 10, 2025
b67c6b6
genrou fixing after rebase [skip ci]
lukelowry Jul 10, 2025
fabe772
change implementation to GenrouPort style [skip ci]
lukelowry Jul 10, 2025
ae33c2b
correct genrou sys model [skip ci]
lukelowry Jul 10, 2025
89163c2
correct the Tgov1 example [skip ci]
lukelowry Jul 10, 2025
ab4f7cc
update cmake from gov sys impl [skip ci]
lukelowry Jul 10, 2025
3a82364
readd: legacy support TenGen example [skip ci]
lukelowry Jul 10, 2025
2c63f68
comment out known magic_enum bug [skip ci]
lukelowry Jul 10, 2025
73b1001
Sys level handle genrou without gov [skip ci]
lukelowry Jul 10, 2025
3b40ee6
edit: temporary sys model safe implementation [skip ci]
lukelowry Jul 10, 2025
ac4d8d0
minor: syntax error [skip ci]
lukelowry Jul 10, 2025
298b545
incorrect boolean logic in sys model [skip ci]
lukelowry Jul 10, 2025
c5495c2
edit: system model bug [skip ci]
lukelowry Jul 10, 2025
1213a9b
debug: output of genrou [skip ci]
lukelowry Jul 10, 2025
25b2c42
bug fixed: bus was not set in any example for new data struct [skip ci]
lukelowry Jul 10, 2025
5afcb8e
clean: pre rebase with modified implementation before further changes…
lukelowry Jul 10, 2025
8e95f1a
rename: bussignal send to write and safeWrite [skip ci]
lukelowry Jul 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target_link_libraries(TenGenClassical
GRIDKIT::phasor_dynamics_bus_fault
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_gen_classical
GRIDKIT::phasor_dynamics_governortgov1
GRIDKIT::phasor_dynamics_load
GRIDKIT::solvers_dyn)
install(TARGETS TenGenClassical RUNTIME DESTINATION bin)
Expand Down
1 change: 1 addition & 0 deletions examples/PhasorDynamics/Small/TenGen/Genrou/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target_link_libraries(TenGenGenrou
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_genrou
GRIDKIT::phasor_dynamics_gen_classical
GRIDKIT::phasor_dynamics_governortgov1
GRIDKIT::phasor_dynamics_load
GRIDKIT::solvers_dyn)
install(TARGETS TenGenGenrou RUNTIME DESTINATION bin)
Expand Down
1 change: 1 addition & 0 deletions examples/PhasorDynamics/Tiny/ThreeBus/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target_link_libraries(ThreeBusBasic
GRIDKIT::phasor_dynamics_bus_fault
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_genrou
GRIDKIT::phasor_dynamics_governortgov1
GRIDKIT::phasor_dynamics_gen_classical
GRIDKIT::phasor_dynamics_load
GRIDKIT::solvers_dyn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_link_libraries(ThreeBusClassical
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_genrou
GRIDKIT::phasor_dynamics_gen_classical
GRIDKIT::phasor_dynamics_governortgov1
GRIDKIT::phasor_dynamics_load
GRIDKIT::solvers_dyn)
install(TARGETS ThreeBusClassical RUNTIME DESTINATION bin)
Expand Down
1 change: 1 addition & 0 deletions examples/PhasorDynamics/Tiny/TwoBus/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target_link_libraries(TwoBusBasic
GRIDKIT::phasor_dynamics_bus_fault
GRIDKIT::phasor_dynamics_branch
GRIDKIT::phasor_dynamics_genrou
GRIDKIT::phasor_dynamics_governortgov1
GRIDKIT::phasor_dynamics_gen_classical
GRIDKIT::phasor_dynamics_load
GRIDKIT::solvers_dyn)
Expand Down
1 change: 1 addition & 0 deletions examples/PhasorDynamics/Tiny/TwoBus/Basic/TwoBusBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ int main()
// Set generator data
data.genrou.resize(1);

data.genrou[0].ports[GenrouPorts::bus] = data.bus[0].bus_id;
data.genrou[0].parameters[GenrouParameters::p0] = 1.;
data.genrou[0].parameters[GenrouParameters::q0] = 0.05013;
data.genrou[0].parameters[GenrouParameters::H] = 3.;
Expand Down
48 changes: 19 additions & 29 deletions examples/PhasorDynamics/Tiny/TwoBus/Tgov1/TwoBusTgov1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int main()
SystemModelData<scalar_type, index_type> data;

// Set bus data
data.bus.resize(2);
data.bus.resize(4);

data.bus[0].bus_id = 0;
data.bus[0].bus_type = BusType::DEFAULT;
Expand All @@ -61,6 +61,14 @@ int main()
data.bus[1].Vr0 = 1.0;
data.bus[1].Vi0 = 0.0;

// Pmech Signal Bus
data.bus[2].bus_id = 2;
data.bus[2].bus_type = BusType::SIGNAL;

// Speed Signal Bus
data.bus[3].bus_id = 3;
data.bus[3].bus_type = BusType::SIGNAL;

// Set branch data
data.branch.resize(1);

Expand All @@ -78,15 +86,13 @@ int main()
data.bus_fault[0].parameters[BusFaultParameters::X] = 1e-3;
data.bus_fault[0].parameters[BusFaultParameters::state0] = false;

//
// Instantiate system model
//

SystemModel<scalar_type, index_type> sys(data);

// Set generator data
data.genrou.resize(1);

data.genrou[0].ports[GenrouPorts::bus] = data.bus[0].bus_id;
data.genrou[0].ports[GenrouPorts::pmech_signal] = 2;
data.genrou[0].ports[GenrouPorts::speed_signal] = 3;
data.genrou[0].parameters[GenrouParameters::p0] = 1.;
data.genrou[0].parameters[GenrouParameters::q0] = 0.05013;
data.genrou[0].parameters[GenrouParameters::H] = 3.;
Expand All @@ -106,9 +112,11 @@ int main()
data.genrou[0].parameters[GenrouParameters::S10] = 0.;
data.genrou[0].parameters[GenrouParameters::S12] = 0.;

// Governor TODO use new data structure
data.gov.resize(1);

// Set Gov data (Default PW values)
data.gov[0].signal_speed = 3;
data.gov[0].signal_pmech = 2;
data.gov[0].R = 0.05;
data.gov[0].Pvmin = 0;
data.gov[0].Pvmax = 1.0;
Expand All @@ -117,27 +125,8 @@ int main()
data.gov[0].T3 = 7.5;
data.gov[0].Dt = 0;

// Manual add gen & gov components
// This is a hack since SignalBus not implemented

// Create Pointers first
Genrou<scalar_type, index_type>* gen;
Governor::Tgov1<scalar_type, index_type>* gov;

// Instatiate Genrou & add to system model
gen = new Genrou<scalar_type, index_type>(
sys.getBus(0),
data.genrou[0]);

// Instatiate GovernorTgov1 & add to system model
gov = new Governor::Tgov1<scalar_type, index_type>(
gen,
data.gov[0]);
gen->setgovenor(gov);

// Add Generator and Governor to System
sys.addComponent(gen);
sys.addComponent(gov);
// Instantiate system model
SystemModel<scalar_type, index_type> sys(data);

sys.allocate();

Expand Down Expand Up @@ -179,7 +168,8 @@ int main()
{
std::vector<scalar_type>& y_val = sys.y();

output.push_back(OutputData{t, y_val[0], y_val[1], y_val[3]});
// Note Omega of gen is at state index 5! (Each added signal shifted by 1)
output.push_back(OutputData{t, y_val[0], y_val[1], y_val[5]});
};

// Set up simulation
Expand Down
16 changes: 16 additions & 0 deletions src/Model/PhasorDynamics/Bus/Bus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ namespace GridKit
return BusTypeT::DEFAULT;
}

// TODO remove, uneeded
void initial_value(ScalarT) override
{
}

// TODO remove, uneeded
ScalarT& read() override
{
return y_[0];
}

// TODO remove, uneeded
void write(ScalarT&) override
{
}

virtual ScalarT& Vr() override
{
return y_[0];
Expand Down
1 change: 1 addition & 0 deletions src/Model/PhasorDynamics/Bus/BusData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace GridKit
INVALID,
DEFAULT,
SLACK,
SIGNAL
};

BusType bus_type{BusType::INVALID}; ///< The kind of bus this data is for
Expand Down
4 changes: 4 additions & 0 deletions src/Model/PhasorDynamics/Bus/BusFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Model/PhasorDynamics/Bus/Bus.hpp>
#include <Model/PhasorDynamics/Bus/BusData.hpp>
#include <Model/PhasorDynamics/Bus/BusInfinite.hpp>
#include <Model/PhasorDynamics/Bus/BusSignal.hpp>

namespace GridKit
{
Expand Down Expand Up @@ -31,6 +32,9 @@ namespace GridKit
case BusTypeT::SLACK:
bus = new BusInfinite<ScalarT, IdxT>(data);
break;
case BusTypeT::SIGNAL:
bus = new BusSignal<ScalarT, IdxT>(data);
break;
default:
// Throw exception
std::cout << "Bus type " << static_cast<int>(data.bus_type) << " unrecognized.\n";
Expand Down
16 changes: 16 additions & 0 deletions src/Model/PhasorDynamics/Bus/BusInfinite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ namespace GridKit
return BusTypeT::SLACK;
}

// TODO remove, uneeded
void initial_value(ScalarT) override
{
}

// TODO remove, uneeded
ScalarT& read() override
{
return y_[0];
}

// TODO remove, uneeded
void write(ScalarT&) override
{
}

virtual ScalarT& Vr() override
{
return Vr_;
Expand Down
80 changes: 80 additions & 0 deletions src/Model/PhasorDynamics/Bus/BusSignal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

#include "BusSignal.hpp"

#include <cmath>
#include <iostream>

#include <Model/PhasorDynamics/Bus/BusData.hpp>

namespace GridKit
{
namespace PhasorDynamics
{

template <class ScalarT, typename IdxT>
BusSignal<ScalarT, IdxT>::BusSignal(const DataT& data)
: BusBase<ScalarT, IdxT>(data.bus_id)
{
size_ = 1;
}

template <class ScalarT, typename IdxT>
int BusSignal<ScalarT, IdxT>::allocate()
{
// Temporary while we use std::vector in the code
size_t size = static_cast<size_t>(size_);

// Resize component model data
f_.resize(size);
y_.resize(size);
yp_.resize(size);
tag_.resize(size);

fB_.resize(size);
yB_.resize(size);
ypB_.resize(size);

return 0;
}

template <class ScalarT, typename IdxT>
int BusSignal<ScalarT, IdxT>::tagDifferentiable()
{
tag_[0] = false;
return 0;
}

template <class ScalarT, typename IdxT>
int BusSignal<ScalarT, IdxT>::initialize()
{
/// Possible since not being used it causes issue?
y_[0] = 0.0;
yp_[0] = 0.0;

return 0;
}

template <class ScalarT, typename IdxT>
int BusSignal<ScalarT, IdxT>::evaluateResidual()
{
// One side of equality of signal. Reference component
// must add to this residual after this function has been called.
f_[0] = -y_[0];

return 0;
}

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

// Available template instantiations
template class BusSignal<double, long int>;
template class BusSignal<double, size_t>;
template class BusSignal<DependencyTracking::Variable, long int>;
template class BusSignal<DependencyTracking::Variable, size_t>;

} // namespace PhasorDynamics
} // namespace GridKit
Loading