Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Power System Simulation and Optimization
DPsim
DPsim
Commits
23f7bf3d
Commit
23f7bf3d
authored
May 03, 2017
by
Viviane
Browse files
finished PiLine model
Former-commit-id:
e7db8b4a
parent
6a1b9be0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Source/Components/PiLine.cpp
View file @
23f7bf3d
...
...
@@ -82,6 +82,11 @@ void PiLine::init(Real om, Real dt) {
mDeltaVre
=
0
;
mDeltaVim
=
0
;
mVoltageAtNode1Re
=
0
;
mVoltageAtNode1Im
=
0
;
mVoltageAtNode2Re
=
0
;
mVoltageAtNode2Im
=
0
;
}
void
PiLine
::
step
(
SystemModel
&
system
,
Real
time
)
{
...
...
@@ -98,6 +103,7 @@ void PiLine::step(SystemModel& system, Real time) {
}
// Initialize internal state capacitance 1
mCurEqCapRe1
=
mCurrCapRe1
+
mGcr
*
mVoltageAtNode1Re
+
mGci
*
mVoltageAtNode1Im
;
mCurEqCapIm1
=
mCurrCapIm1
+
mGcr
*
mVoltageAtNode1Im
-
mGci
*
mVoltageAtNode1Re
;
...
...
@@ -122,20 +128,13 @@ void PiLine::postStep(SystemModel& system) {
vposr
=
system
.
getRealFromLeftSideVector
(
mNode3
);
vposi
=
system
.
getImagFromLeftSideVector
(
mNode3
);
}
else
{
vposr
=
0
;
vposi
=
0
;
}
if
(
mNode2
>=
0
)
{
system
.
getRealFromLeftSideVector
(
mNode2
);
vnegr
=
system
.
getRealFromLeftSideVector
(
mNode2
);
vnegi
=
system
.
getImagFromLeftSideVector
(
mNode2
);
}
else
{
vnegr
=
0
;
vnegi
=
0
;
}
mDeltaVre
=
vposr
-
vnegr
;
mDeltaVim
=
vposi
-
vnegi
;
mCurrIndRe
=
mGlr
*
mDeltaVre
-
mGli
*
mDeltaVim
+
mCurEqIndRe
;
...
...
Source/DPsimMain.cpp
View file @
23f7bf3d
...
...
@@ -12,15 +12,18 @@ int main(int argc, char* argv[]) {
simulationExample1
();
simulationExample2
();
simulationExample3
();
simulationExampleIdealVS
();
simulationExampleIdealVS2
();
simulationExampleIdealVS3
();
simulationExampleRXLine3
();
simulationExampleRXLine
();
simulationExampleRXLine2
();
//simulationExample1();
//simulationExample2();
//simulationExample3();
//simulationExampleIdealVS();
//simulationExampleIdealVS2();
//simulationExampleIdealVS3();
//simulationExampleRXLine3();
//simulationExampleRXLine();
//simulationExampleRXLine2();
simulationExamplePiLine
();
simulationExamplePiLine2
();
//NetlistSim(argc, argv);
...
...
Source/Examples/ReferenceCircuits.cpp
View file @
23f7bf3d
...
...
@@ -395,4 +395,87 @@ void DPsim::simulationExampleRXLine3()
log
.
WriteLogToFile
(
"Logs/Log_"
+
fileName
.
str
()
+
".log"
);
leftVectorLog
.
WriteLogToFile
(
"Logs/LeftVectorLog_"
+
fileName
.
str
()
+
".csv"
);
rightVectorLog
.
WriteLogToFile
(
"Logs/RightVectorLog_"
+
fileName
.
str
()
+
".csv"
);
}
void
DPsim
::
simulationExamplePiLine
()
{
// Define Object for saving data on a file
Logger
log
,
leftVectorLog
,
rightVectorLog
;
std
::
vector
<
BaseComponent
*>
circElements0
;
circElements0
.
push_back
(
new
IdealVoltageSource
(
"v_1"
,
1
,
0
,
345
,
0
,
1
));
circElements0
.
push_back
(
new
LinearResistor
(
"r1"
,
1
,
2
,
5
));
circElements0
.
push_back
(
new
PiLine
(
"PiLine1"
,
2
,
3
,
4
,
6.4
,
0.186
,
0.004
));
circElements0
.
push_back
(
new
LinearResistor
(
"r_load"
,
3
,
0
,
150
));
std
::
cout
<<
"The contents of circElements0 are:"
;
for
(
std
::
vector
<
BaseComponent
*>::
iterator
it
=
circElements0
.
begin
();
it
!=
circElements0
.
end
();
++
it
)
{
std
::
cout
<<
"Added "
<<
(
*
it
)
->
getName
()
<<
std
::
endl
;
}
std
::
cout
<<
'\n'
;
// Set up simulation
Real
timeStep
=
0.001
;
Simulation
newSim
(
circElements0
,
2.0
*
M_PI
*
50.0
,
timeStep
,
0.3
,
log
);
// Main Simulation Loop
std
::
cout
<<
"Start simulation."
<<
std
::
endl
;
while
(
newSim
.
step
(
log
,
leftVectorLog
,
rightVectorLog
))
{
newSim
.
increaseByTimeStep
();
updateProgressBar
(
newSim
.
getTime
(),
newSim
.
getFinalTime
());
}
std
::
cout
<<
"Simulation finished."
<<
std
::
endl
;
// Write simulation data to file
std
::
ostringstream
fileName
;
fileName
<<
"SimulationExamplePiLine_"
<<
timeStep
;
log
.
WriteLogToFile
(
"Logs/Log_"
+
fileName
.
str
()
+
".log"
);
leftVectorLog
.
WriteLogToFile
(
"Logs/LeftVectorLog_"
+
fileName
.
str
()
+
".csv"
);
rightVectorLog
.
WriteLogToFile
(
"Logs/RightVectorLog_"
+
fileName
.
str
()
+
".csv"
);
}
void
DPsim
::
simulationExamplePiLine2
()
{
// Define Object for saving data on a file
Logger
log
,
leftVectorLog
,
rightVectorLog
;
std
::
vector
<
BaseComponent
*>
circElements0
;
circElements0
.
push_back
(
new
IdealVoltageSource
(
"v_1"
,
1
,
0
,
345
,
0
,
1
));
circElements0
.
push_back
(
new
LinearResistor
(
"r1"
,
1
,
2
,
5
));
circElements0
.
push_back
(
new
Capacitor
(
"c_1"
,
2
,
0
,
0.002
));
circElements0
.
push_back
(
new
LinearResistor
(
"r_load"
,
2
,
4
,
6.4
));
circElements0
.
push_back
(
new
Inductor
(
"l_1"
,
4
,
3
,
0.186
));
circElements0
.
push_back
(
new
Capacitor
(
"c_2"
,
3
,
0
,
0.002
));
circElements0
.
push_back
(
new
LinearResistor
(
"r_load"
,
3
,
0
,
150
));
std
::
cout
<<
"The contents of circElements0 are:"
;
for
(
std
::
vector
<
BaseComponent
*>::
iterator
it
=
circElements0
.
begin
();
it
!=
circElements0
.
end
();
++
it
)
{
std
::
cout
<<
"Added "
<<
(
*
it
)
->
getName
()
<<
std
::
endl
;
}
std
::
cout
<<
'\n'
;
// Set up simulation
Real
timeStep
=
0.001
;
Simulation
newSim
(
circElements0
,
2.0
*
M_PI
*
50.0
,
timeStep
,
0.3
,
log
);
// Main Simulation Loop
std
::
cout
<<
"Start simulation."
<<
std
::
endl
;
while
(
newSim
.
step
(
log
,
leftVectorLog
,
rightVectorLog
))
{
newSim
.
increaseByTimeStep
();
updateProgressBar
(
newSim
.
getTime
(),
newSim
.
getFinalTime
());
}
std
::
cout
<<
"Simulation finished."
<<
std
::
endl
;
// Write simulation data to file
std
::
ostringstream
fileName
;
fileName
<<
"SimulationExamplePiLine2_"
<<
timeStep
;
log
.
WriteLogToFile
(
"Logs/Log_"
+
fileName
.
str
()
+
".log"
);
leftVectorLog
.
WriteLogToFile
(
"Logs/LeftVectorLog_"
+
fileName
.
str
()
+
".csv"
);
rightVectorLog
.
WriteLogToFile
(
"Logs/RightVectorLog_"
+
fileName
.
str
()
+
".csv"
);
}
\ No newline at end of file
Source/Examples/ReferenceCircuits.h
View file @
23f7bf3d
...
...
@@ -15,5 +15,7 @@ namespace DPsim {
void
simulationExampleRXLine
();
void
simulationExampleRXLine2
();
void
simulationExampleRXLine3
();
void
simulationExamplePiLine
();
void
simulationExamplePiLine2
();
}
#endif
Source/Simulation.cpp
View file @
23f7bf3d
...
...
@@ -47,7 +47,7 @@ Simulation::~Simulation() {
void
Simulation
::
initialize
(
std
::
vector
<
BaseComponent
*>
newElements
)
{
int
maxNode
=
0
;
Int
numIdealVS
=
0
;
int
num
Rx
Lines
=
0
;
int
numLines
=
0
;
mElementsVector
.
push_back
(
newElements
);
mElements
=
mElementsVector
[
0
];
...
...
@@ -65,15 +65,15 @@ void Simulation::initialize(std::vector<BaseComponent*> newElements) {
if
(
type
==
"class DPsim::IdealVoltageSource"
)
{
numIdealVS
=
numIdealVS
+
1
;
}
if
(
type
==
"class DPsim::RxLine"
)
{
if
(
type
==
"class DPsim::RxLine"
||
type
==
"class DPsim::PiLine"
)
{
if
((
*
it
)
->
getNode3
()
!=
-
1
)
{
num
Rx
Lines
=
num
Rx
Lines
+
1
;
numLines
=
numLines
+
1
;
}
}
}
Int
numNodes
=
maxNode
+
1
+
numIdealVS
+
num
Rx
Lines
;
Int
numNodes
=
maxNode
+
1
+
numIdealVS
+
numLines
;
mSystemModel
.
initialize
(
numNodes
,
numIdealVS
);
addSystemTopology
(
mElements
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment