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
81e9061b
Commit
81e9061b
authored
May 24, 2017
by
Georg Martin Reinke
Browse files
add test for comparing operation with/without VILLAS interface
parent
0a28e4f3
Changes
3
Show whitespace changes
Inline
Side-by-side
Source/DPsimMain.cpp
View file @
81e9061b
...
...
@@ -15,6 +15,7 @@ int main(int argc, char* argv[]) {
//villasExample();
villasDistributedExample
(
argc
,
argv
);
//villasDistributedRef();
//simulationExample1();
//simulationExample2();
//simulationExample3();
...
...
Source/Examples/VillasTest.cpp
View file @
81e9061b
...
...
@@ -46,7 +46,7 @@ void DPsim::villasExample()
void
DPsim
::
villasDistributedExample
(
int
argc
,
char
*
argv
[])
{
// Testing the interface with
the sam
e circuit
as above
,
// Testing the interface with
a simpl
e circuit,
// but the load is simulated in a different instance.
// Values are exchanged using the ideal transformator model: an ideal
// current source on the supply side and an ideal voltage source on the
...
...
@@ -62,21 +62,19 @@ void DPsim::villasDistributedExample(int argc, char *argv[])
if
(
!
strcmp
(
argv
[
1
],
"0"
))
{
comps
.
push_back
(
new
VoltSourceRes
(
"v_s"
,
1
,
0
,
10000
,
0
,
1
));
comps
.
push_back
(
new
LinearResistor
(
"r_line"
,
1
,
2
,
1
));
comps
.
push_back
(
new
Inductor
(
"l_line"
,
2
,
3
,
1
));
ExternalCurrentSource
*
ecs
=
new
ExternalCurrentSource
(
"i_s"
,
1
,
0
,
0
,
0
);
comps
.
push_back
(
ecs
);
villas
=
new
VillasInterface
(
"/villas0"
);
villas
->
registerCurrentSource
(
ecs
,
0
,
1
);
villas
->
registerExportedVoltage
(
1
,
0
,
0
,
1
);
}
else
if
(
!
strcmp
(
argv
[
1
],
"1"
))
{
ExternalVoltageSource
*
evs
=
new
ExternalVoltageSource
(
"v_s"
,
1
,
0
,
0
,
0
,
1
);
comps
.
push_back
(
new
Inductor
(
"l_1"
,
1
,
2
,
1e-3
));
ExternalVoltageSource
*
evs
=
new
ExternalVoltageSource
(
"v_t"
,
2
,
0
,
0
,
0
,
1
);
comps
.
push_back
(
evs
);
comps
.
push_back
(
new
LinearResistor
(
"r_load"
,
1
,
2
,
100
));
comps
.
push_back
(
new
Inductor
(
"l_load"
,
2
,
0
,
0.1
));
villas
=
new
VillasInterface
(
"/villas1"
);
villas
=
new
VillasInterface
(
"/villas0"
);
villas
->
registerVoltageSource
(
evs
,
0
,
1
);
villas
->
registerExportedCurrent
(
evs
,
0
,
1
);
}
else
if
(
!
strcmp
(
argv
[
1
],
"1"
))
{
ExternalCurrentSource
*
ecs
=
new
ExternalCurrentSource
(
"v_s"
,
1
,
0
,
0
,
0
);
comps
.
push_back
(
ecs
);
comps
.
push_back
(
new
LinearResistor
(
"r_2"
,
1
,
0
,
1
));
villas
=
new
VillasInterface
(
"/villas1"
);
villas
->
registerCurrentSource
(
ecs
,
0
,
1
);
villas
->
registerExportedVoltage
(
1
,
0
,
0
,
1
);
}
else
{
std
::
cerr
<<
"invalid test number"
<<
std
::
endl
;
std
::
exit
(
1
);
...
...
@@ -103,3 +101,33 @@ void DPsim::villasDistributedExample(int argc, char *argv[])
}
delete
villas
;
}
void
DPsim
::
villasDistributedRef
()
{
// Same circuit as above, but the simulation is done normally in one instance.
Logger
log
,
llog
,
rlog
;
std
::
vector
<
BaseComponent
*>
comps
;
comps
.
push_back
(
new
VoltSourceRes
(
"v_s"
,
1
,
0
,
10000
,
0
,
1
));
comps
.
push_back
(
new
Inductor
(
"l_1"
,
1
,
2
,
1e-3
));
comps
.
push_back
(
new
LinearResistor
(
"r_2"
,
2
,
0
,
1
));
// Set up simulation
Real
timeStep
=
0.001
;
Simulation
newSim
(
comps
,
2.0
*
M_PI
*
50.0
,
timeStep
,
0.3
,
log
);
// Main Simulation Loop
std
::
cout
<<
"Start simulation."
<<
std
::
endl
;
while
(
newSim
.
step
(
log
,
llog
,
rlog
))
{
newSim
.
increaseByTimeStep
();
updateProgressBar
(
newSim
.
getTime
(),
newSim
.
getFinalTime
());
}
std
::
cout
<<
"Simulation finished."
<<
std
::
endl
;
log
.
WriteLogToFile
(
"output.log"
);
rlog
.
WriteLogToFile
(
"rvector.log"
);
llog
.
WriteLogToFile
(
"lvector.log"
);
for
(
auto
comp
:
comps
)
{
delete
comp
;
}
}
Source/Examples/VillasTest.h
View file @
81e9061b
...
...
@@ -5,6 +5,7 @@ namespace DPsim {
void
villasExample
();
void
villasDistributedExample
(
int
argc
,
char
*
argv
[]);
void
villasDistributedRef
();
}
#endif
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