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
4794b6ef
Commit
4794b6ef
authored
May 08, 2017
by
Georg Martin Reinke
Browse files
implement getCurrent for LinearResistor
parent
8907783d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Components/LinearResistor.cpp
View file @
4794b6ef
...
...
@@ -23,5 +23,16 @@ void LinearResistor::applySystemMatrixStamp(SystemModel& system) {
}
}
Complex
LinearResistor
::
getCurrent
(
SystemModel
&
model
)
{
Real
realVolt
=
0
,
imagVolt
=
0
;
if
(
mNode1
>=
0
)
{
realVolt
+=
model
.
getRealFromLeftSideVector
(
mNode1
);
imagVolt
+=
model
.
getImagFromLeftSideVector
(
mNode2
);
}
if
(
mNode2
>=
0
)
{
realVolt
-=
model
.
getRealFromLeftSideVector
(
mNode1
);
imagVolt
-=
model
.
getImagFromLeftSideVector
(
mNode2
);
}
Complex
curr
(
realVolt
*
mConductance
,
imagVolt
*
mConductance
);
return
curr
;
}
Source/Components/LinearResistor.h
View file @
4794b6ef
...
...
@@ -36,6 +36,7 @@ namespace DPsim {
void
applyRightSideVectorStamp
(
SystemModel
&
system
)
{
}
void
step
(
SystemModel
&
system
,
Real
time
)
{
}
void
postStep
(
SystemModel
&
system
)
{
}
Complex
getCurrent
(
SystemModel
&
model
);
};
}
#endif
Source/Examples/VillasTest.cpp
View file @
4794b6ef
...
...
@@ -14,10 +14,12 @@ void DPsim::villasExample()
ExternalCurrentSource
*
ecs
=
new
ExternalCurrentSource
(
"i1"
,
1
,
0
);
comps
.
push_back
(
ecs
);
comps
.
push_back
(
new
LinearResistor
(
"r1"
,
1
,
2
,
1
));
comps
.
push_back
(
new
LinearResistor
(
"r2"
,
2
,
0
,
1
));
LinearResistor
*
r2
=
new
LinearResistor
(
"r2"
,
2
,
0
,
1
);
comps
.
push_back
(
r2
);
VillasInterface
*
villas
=
new
VillasInterface
(
"/villas1"
);
villas
->
registerCurrentSource
(
ecs
,
0
,
1
);
villas
->
registerExportedVoltage
(
1
,
2
,
0
,
1
);
villas
->
registerExportedVoltage
(
1
,
0
,
0
,
1
);
villas
->
registerExportedCurrent
(
r2
,
2
,
3
);
// Set up simulation
Real
timeStep
=
0.01
;
...
...
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