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
4b8822e5
Commit
4b8822e5
authored
Apr 28, 2017
by
Viviane
Browse files
started Pi Line model
parent
341966b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/Components.h
View file @
4b8822e5
...
@@ -18,5 +18,6 @@
...
@@ -18,5 +18,6 @@
#include
"Components/VoltSourceResEMT.h"
#include
"Components/VoltSourceResEMT.h"
#include
"Components/IdealVoltageSource.h"
#include
"Components/IdealVoltageSource.h"
#include
"Components/RxLine.h"
#include
"Components/RxLine.h"
#include
"Components/PiLine.h"
#endif // !COMPONENTS_H
#endif // !COMPONENTS_H
\ No newline at end of file
Source/Components/PiLine.cpp
View file @
4b8822e5
#include
"PiLine.h"
#include
"PiLine.h"
using
namespace
DPsim
;
PiLine
::
PiLine
(
std
::
string
name
,
int
node1
,
int
node2
,
int
node3
,
Real
resistance
,
Real
inductance
,
Real
capacitance
)
:
BaseComponent
(
name
,
node1
,
node2
,
node3
)
{
mResistance
=
resistance
;
mConductance
=
1.0
/
resistance
;
mInductance
=
inductance
;
mCapacitance
=
capacitance
/
2
;
}
void
PiLine
::
applySystemMatrixStamp
(
SystemModel
&
system
)
{
Real
a
=
system
.
getTimeStep
()
/
(
2.
*
mInductance
);
Real
b
=
system
.
getTimeStep
()
*
system
.
getOmega
()
/
2.
;
mGlr
=
a
/
(
1
+
b
*
b
);
mGli
=
-
a
*
b
/
(
1
+
b
*
b
);
mPrevCurFacRe
=
(
1
-
b
*
b
)
/
(
1
+
b
*
b
);
mPrevCurFacIm
=
-
2.
*
b
/
(
1
+
b
*
b
);
// Resistive part
// Set diagonal entries
if
(
mNode1
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode1
,
mNode1
,
mConductance
,
0
);
}
if
(
mNode3
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode3
,
mNode3
,
mConductance
,
0
);
}
// Set off diagonal entries
if
(
mNode1
>=
0
&&
mNode3
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode1
,
mNode3
,
-
mConductance
,
0
);
system
.
addCompToSystemMatrix
(
mNode3
,
mNode1
,
-
mConductance
,
0
);
}
// Inductance part
// Set diagonal entries
if
(
mNode3
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode3
,
mNode3
,
mGlr
,
mGli
);
}
if
(
mNode2
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode2
,
mNode2
,
mGlr
,
mGli
);
}
if
(
mNode3
>=
0
&&
mNode2
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode3
,
mNode2
,
-
mGlr
,
-
mGli
);
system
.
addCompToSystemMatrix
(
mNode2
,
mNode3
,
-
mGlr
,
-
mGli
);
}
//capacitive part
mGcr
=
2.0
*
mCapacitance
/
system
.
getTimeStep
();
mGci
=
system
.
getOmega
()
*
mCapacitance
;
if
(
mNode1
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode1
,
mNode1
,
mGcr
,
mGci
);
}
if
(
mNode2
>=
0
)
{
system
.
addCompToSystemMatrix
(
mNode2
,
mNode2
,
mGcr
,
mGci
);
}
}
void
PiLine
::
init
(
Real
om
,
Real
dt
)
{
// Initialize internal state
mCurrIndRe
=
0
;
mCurrIndIm
=
0
;
mCurrCapRe1
=
0
;
mCurrCapIm1
=
0
;
mCurrCapRe2
=
0
;
mCurrCapIm2
=
0
;
mCurEqIndRe
=
0
;
mCurEqIndIm
=
0
;
mCurEqCapRe1
=
0
;
mCurEqCapIm1
=
0
;
mCurEqCapRe2
=
0
;
mCurEqCapIm2
=
0
;
mDeltaVre
=
0
;
mDeltaVim
=
0
;
}
void
PiLine
::
step
(
SystemModel
&
system
,
Real
time
)
{
// Initialize internal state inductance
mCurEqIndRe
=
mGlr
*
mDeltaVre
-
mGli
*
mDeltaVim
+
mPrevCurFacRe
*
mCurrIndRe
-
mPrevCurFacIm
*
mCurrIndIm
;
mCurEqIndIm
=
mGli
*
mDeltaVre
+
mGlr
*
mDeltaVim
+
mPrevCurFacIm
*
mCurrIndRe
+
mPrevCurFacRe
*
mCurrIndIm
;
if
(
mNode3
>=
0
)
{
system
.
addCompToRightSideVector
(
mNode3
,
-
mCurEqIndRe
,
-
mCurEqIndIm
);
}
if
(
mNode2
>=
0
)
{
system
.
addCompToRightSideVector
(
mNode2
,
mCurEqIndRe
,
mCurEqIndIm
);
}
// Initialize internal state capacitance 1
mCurEqCapRe1
=
mCurrCapRe1
+
mGcr
*
mVoltageAtNode1Re
+
mGci
*
mVoltageAtNode1Im
;
mCurEqCapIm1
=
mCurrCapIm1
+
mGcr
*
mVoltageAtNode1Im
-
mGci
*
mVoltageAtNode1Re
;
if
(
mNode1
>=
0
)
{
system
.
addCompToRightSideVector
(
mNode1
,
mCurEqCapRe1
,
mCurEqCapIm1
);
}
// Initialize internal state capacitance 2
mCurEqCapRe2
=
mCurrCapRe2
+
mGcr
*
mVoltageAtNode2Re
+
mGci
*
mVoltageAtNode2Im
;
mCurEqCapIm2
=
mCurrCapIm2
+
mGcr
*
mVoltageAtNode2Im
-
mGci
*
mVoltageAtNode2Re
;
if
(
mNode2
>=
0
)
{
system
.
addCompToRightSideVector
(
mNode2
,
mCurEqCapRe2
,
mCurEqCapIm2
);
}
}
void
PiLine
::
postStep
(
SystemModel
&
system
)
{
Real
vposr
,
vnegr
,
vposi
,
vnegi
;
// extract solution
if
(
mNode3
>=
0
)
{
system
.
getRealFromLeftSideVector
(
mNode3
);
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
;
mCurrIndIm
=
mGli
*
mDeltaVre
+
mGlr
*
mDeltaVim
+
mCurEqIndIm
;
// extract solution
if
(
mNode1
>=
0
)
{
mVoltageAtNode1Re
=
system
.
getRealFromLeftSideVector
(
mNode1
);
mVoltageAtNode1Im
=
system
.
getImagFromLeftSideVector
(
mNode1
);
}
if
(
mNode2
>=
0
)
{
mVoltageAtNode2Re
=
system
.
getRealFromLeftSideVector
(
mNode2
);
mVoltageAtNode2Im
=
system
.
getImagFromLeftSideVector
(
mNode2
);
}
mCurrCapRe1
=
mGcr
*
mVoltageAtNode1Re
-
mGci
*
mVoltageAtNode1Im
-
mCurEqCapRe1
;
mCurrCapIm1
=
mGci
*
mVoltageAtNode1Re
+
mGcr
*
mVoltageAtNode1Im
-
mCurEqCapIm1
;
mCurrCapRe2
=
mGcr
*
mVoltageAtNode2Re
-
mGci
*
mVoltageAtNode2Im
-
mCurEqCapRe2
;
mCurrCapIm2
=
mGci
*
mVoltageAtNode2Re
+
mGcr
*
mVoltageAtNode2Im
-
mCurEqCapIm2
;
}
Source/Components/PiLine.h
View file @
4b8822e5
#pragma once
#ifndef PILINE_H
#define PILINE_H
#include
"../Components.h"
namespace
DPsim
{
class
PiLine
:
public
BaseComponent
{
protected:
///resistance in ohms
Real
mResistance
;
///Conductance
Real
mConductance
;
///Capacitance
Real
mCapacitance
;
///Inductance
Real
mInductance
;
Real
mVoltageAtNode1Re
;
Real
mVoltageAtNode1Im
;
Real
mVoltageAtNode2Re
;
Real
mVoltageAtNode2Im
;
Real
mDeltaVre
;
Real
mDeltaVim
;
Real
mCurrIndRe
;
Real
mCurrIndIm
;
Real
mCurrCapRe1
;
Real
mCurrCapIm1
;
Real
mCurrCapRe2
;
Real
mCurrCapIm2
;
Real
mCurEqIndRe
;
Real
mCurEqIndIm
;
Real
mCurEqCapRe1
;
Real
mCurEqCapIm1
;
Real
mCurEqCapRe2
;
Real
mCurEqCapIm2
;
Real
mGlr
;
Real
mGli
;
Real
mGcr
;
Real
mGci
;
Real
mPrevCurFacRe
;
Real
mPrevCurFacIm
;
public:
PiLine
()
{
};
//PiLine(std::string nam3e, int node1, int node2, Real resistance, Real inductance);
PiLine
(
std
::
string
name
,
int
node1
,
int
node2
,
int
node3
,
Real
resistance
,
Real
inductance
,
Real
capacitance
);
void
init
(
Real
om
,
Real
dt
);
void
applySystemMatrixStamp
(
SystemModel
&
system
);
void
applyRightSideVectorStamp
(
SystemModel
&
system
)
{
}
void
step
(
SystemModel
&
system
,
Real
time
);
void
postStep
(
SystemModel
&
system
);
};
}
#endif
\ No newline at end of file
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