Skip to content

Commit fc974dc

Browse files
committed
Merge 'develop' into 'nicholson/enzyme-usecase'.
2 parents 140c2b7 + 7bd2825 commit fc974dc

File tree

58 files changed

+1563
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1563
-348
lines changed

examples/AdjointSensitivity/AdjointSensitivity.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
#include <Model/PowerFlow/Bus/BusSlack.hpp>
6565
#include <Model/PowerFlow/Generator4/Generator4.hpp>
66-
#include <SystemModel.hpp>
66+
#include <Model/PowerFlow/SystemModel.hpp>
6767
#include <Solver/Dynamic/Ida.hpp>
6868
#include <Utilities/Testing.hpp>
6969

@@ -142,9 +142,9 @@ int main()
142142
const double eps = 2e-3;
143143

144144
// Compute gradient of the objective function numerically
145-
std::vector<double> dGdp(model->size_opt());
145+
std::vector<double> dGdp(model->sizeParams());
146146

147-
for (unsigned i=0; i<model->size_opt(); ++i)
147+
for (unsigned i=0; i<model->sizeParams(); ++i)
148148
{
149149
model->param()[i] += eps;
150150
idas->getSavedInitialCondition();
@@ -185,7 +185,7 @@ int main()
185185
int retval = 0;
186186
std::cout << "\n\nComparison of numerical and adjoint results:\n\n";
187187
double* neg_dGdp = idas->getAdjointIntegral();
188-
for (unsigned i=0; i<model->size_opt(); ++i)
188+
for (unsigned i=0; i<model->sizeParams(); ++i)
189189
{
190190
std::cout << "dG/dp" << i << " (numerical) = " << dGdp[i] << "\n";
191191
std::cout << "dG/dp" << i << " (adjoint) = " << -neg_dGdp[i] << "\n\n";

examples/DynamicConstrainedOpt/DynamicConstrainedOpt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
#include <Model/PowerFlow/Bus/BusSlack.hpp>
6565
#include <Model/PowerFlow/Generator2/Generator2.hpp>
66-
#include <SystemModel.hpp>
66+
#include <Model/PowerFlow/SystemModel.hpp>
6767
#include <Solver/Dynamic/Ida.hpp>
6868

6969
#include <IpIpoptApplication.hpp>
@@ -165,8 +165,8 @@ int main()
165165
}
166166

167167
// Store dynamic objective optimization results
168-
double* results = new double[model->size_opt()];
169-
for(unsigned i=0; i <model->size_opt(); ++i)
168+
double* results = new double[model->sizeParams()];
169+
for(unsigned i=0; i <model->sizeParams(); ++i)
170170
{
171171
results[i] = model->param()[i];
172172
}
@@ -193,7 +193,7 @@ int main()
193193

194194
// Compare results of the two optimization methods
195195
int retval = 0;
196-
for(unsigned i=0; i <model->size_opt(); ++i)
196+
for(unsigned i=0; i <model->sizeParams(); ++i)
197197
{
198198
if(!isEqual(results[i], model->param()[i], 10*tol))
199199
--retval;

examples/GenConstLoad/GenConstLoad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#include <Model/PowerFlow/Load/Load.hpp>
6666
#include <Model/PowerFlow/Generator4Governor/Generator4Governor.hpp>
6767
#include <Solver/Dynamic/Ida.hpp>
68-
#include <SystemModel.hpp>
68+
#include <Model/PowerFlow/SystemModel.hpp>
6969

7070
#include <IpIpoptApplication.hpp>
7171
#include <IpSolveStatistics.hpp>

examples/GenInfiniteBus/GenInfiniteBus.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
#include <Model/PowerFlow/Bus/BusSlack.hpp>
6565
#include <Model/PowerFlow/Generator4/Generator4.hpp>
66-
#include <SystemModel.hpp>
66+
#include <Model/PowerFlow/SystemModel.hpp>
6767
#include <Solver/Dynamic/Ida.hpp>
6868

6969
#include <IpIpoptApplication.hpp>
@@ -176,8 +176,8 @@ int main()
176176
new IpoptInterface::DynamicConstraint<double, size_t>(idas);
177177

178178
// Store dynamic objective optimization results
179-
double* results = new double[model->size_opt()];
180-
for(unsigned i=0; i <model->size_opt(); ++i)
179+
double* results = new double[model->sizeParams()];
180+
for(unsigned i=0; i <model->sizeParams(); ++i)
181181
{
182182
results[i] = model->param()[i];
183183
}
@@ -202,7 +202,7 @@ int main()
202202

203203
// Compare results of the two optimization methods
204204
int retval = 0;
205-
for(unsigned i=0; i <model->size_opt(); ++i)
205+
for(unsigned i=0; i <model->sizeParams(); ++i)
206206
{
207207
if(!isEqual(results[i], model->param()[i], 100*tol))
208208
--retval;

examples/ParameterEstimation/ParameterEstimation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
#include <Solver/Optimization/DynamicConstraint.hpp>
7070
#include <Model/PowerFlow/Bus/BusSlack.hpp>
7171
#include <Model/PowerFlow/Generator4Param/Generator4Param.hpp>
72-
#include <SystemModel.hpp>
72+
#include <Model/PowerFlow/SystemModel.hpp>
7373
#include <Solver/Dynamic/Ida.hpp>
7474

7575
#include <Utilities/FileIO.hpp>
@@ -178,8 +178,8 @@ int main()
178178
}
179179

180180
// Store dynamic objective optimization results
181-
double* results = new double[model->size_opt()];
182-
for(unsigned i=0; i <model->size_opt(); ++i)
181+
double* results = new double[model->sizeParams()];
182+
for(unsigned i=0; i <model->sizeParams(); ++i)
183183
{
184184
results[i] = model->param()[i];
185185
}
@@ -207,7 +207,7 @@ int main()
207207

208208
// Compare results of the two optimization methods
209209
int retval = 0;
210-
for(unsigned i=0; i <model->size_opt(); ++i)
210+
for(unsigned i=0; i <model->sizeParams(); ++i)
211211
{
212212
if(!isEqual(results[i], model->param()[i], 100*tol))
213213
--retval;

src/Model/EvaluatorDynamics.hpp renamed to src/Model/Evaluator.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ namespace Model
1313
*
1414
*/
1515
template <class ScalarT, typename IdxT>
16-
class EvaluatorDynamics
16+
class Evaluator
1717
{
1818
public:
1919
typedef typename GridKit::ScalarTraits<ScalarT>::real_type real_type;
2020

21-
EvaluatorDynamics(){}
22-
virtual ~EvaluatorDynamics(){}
21+
Evaluator(){}
22+
virtual ~Evaluator(){}
2323

2424
virtual int allocate() = 0;
2525
virtual int initialize() = 0;

src/Model/PhasorDynamics/Branch/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# [[
33
# Author(s):
44
# - Cameron Rutherford <[email protected]>
5+
# - Slaven Peles <[email protected]>
56
# ]]
67

78
gridkit_add_library(phasor_dynamics_branch

src/Model/PhasorDynamics/BusBase.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <vector>
4-
#include <Model/EvaluatorDynamics.hpp>
4+
#include <Model/Evaluator.hpp>
55

66
namespace GridKit
77
{
@@ -12,10 +12,10 @@ namespace PhasorDynamics
1212
*
1313
*/
1414
template <class ScalarT, typename IdxT>
15-
class BusBase : public Model::EvaluatorDynamics<ScalarT, IdxT>
15+
class BusBase : public Model::Evaluator<ScalarT, IdxT>
1616
{
1717
public:
18-
using real_type = typename Model::EvaluatorDynamics<ScalarT, IdxT>::real_type;
18+
using real_type = typename Model::Evaluator<ScalarT, IdxT>::real_type;
1919

2020
enum BusType{DEFAULT=1, SLACK};
2121

src/Model/PhasorDynamics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
add_subdirectory(Branch)
77
add_subdirectory(Bus)
88
add_subdirectory(Load)
9+
add_subdirectory(SynchronousMachine)

src/Model/PhasorDynamics/Component.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <vector>
4-
#include <Model/EvaluatorDynamics.hpp>
4+
#include <Model/Evaluator.hpp>
55

66
namespace GridKit
77
{
@@ -13,10 +13,10 @@ namespace PhasorDynamics
1313
*
1414
*/
1515
template <class ScalarT, typename IdxT>
16-
class Component : public Model::EvaluatorDynamics<ScalarT, IdxT>
16+
class Component : public Model::Evaluator<ScalarT, IdxT>
1717
{
1818
public:
19-
using real_type = typename Model::EvaluatorDynamics<ScalarT, IdxT>::real_type;
19+
using real_type = typename Model::Evaluator<ScalarT, IdxT>::real_type;
2020

2121
Component()
2222
: size_(0),
@@ -77,8 +77,8 @@ namespace PhasorDynamics
7777

7878
virtual void setTolerances(real_type& rtol, real_type& atol) const
7979
{
80-
rtol = rtol_;
81-
atol = atol_;
80+
rtol = rel_tol_;
81+
atol = abs_tol_;
8282
}
8383

8484
virtual void setMaxSteps(IdxT& msa) const
@@ -250,8 +250,8 @@ namespace PhasorDynamics
250250
real_type time_;
251251
real_type alpha_;
252252

253-
real_type rtol_;
254-
real_type atol_;
253+
real_type rel_tol_;
254+
real_type abs_tol_;
255255

256256
IdxT max_steps_;
257257

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# [[
3+
# Author(s):
4+
# - Cameron Rutherford <[email protected]>
5+
# - Slaven Peles <[email protected]>
6+
# ]]
7+
8+
gridkit_add_library(phasor_dynamics_synchronous_machine
9+
SOURCES
10+
SynchronousMachine.cpp
11+
OUTPUT_NAME
12+
gridkit_phasor_dynamics_synchronous_machine)
13+

0 commit comments

Comments
 (0)