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
9faa1ae3
Commit
9faa1ae3
authored
Nov 27, 2019
by
Markus Mirz
Browse files
Merge branch 'master' into multisampling
parents
dd3fa3f2
099b3d9e
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
libcps
@
6ac46f08
Compare
7c278824
...
6ac46f08
Subproject commit
7c278824545f3f67b89873a8500e91d7ffc63716
Subproject commit
6ac46f089d543665920cbb0ef8841f8bba98ca1a
Examples/Cxx/CMakeLists.txt
View file @
9faa1ae3
...
...
@@ -19,6 +19,7 @@ set(CIRCUIT_SOURCES
#Circuits/DP_ResVS_RL_Switch.cpp
# EMT examples
Circuits/EMT_CS_RL1.cpp
Circuits/EMT_VS_RL1.cpp
Circuits/EMT_Circuits.cpp
Circuits/DP_Basics_EMT_Sims.cpp
...
...
Examples/Cxx/Circuits/EMT_CS_RL1.cpp
0 → 100644
View file @
9faa1ae3
/** Reference Circuits
*
* @author Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
* @copyright 2019, Institute for Automation of Complex Power Systems, EONERC
*
* DPsim
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include
<DPsim.h>
using
namespace
DPsim
;
using
namespace
CPS
::
EMT
;
using
namespace
CPS
::
EMT
::
Ph1
;
int
main
(
int
argc
,
char
*
argv
[])
{
// Define simulation scenario
Real
timeStep
=
1e-4
;
Real
finalTime
=
1e-3
;
String
simName
=
"EMT_CS_RL1"
;
Logger
::
setLogDir
(
"logs/"
+
simName
);
// Nodes
auto
n1
=
Node
::
make
(
"n1"
,
PhaseType
::
Single
,
std
::
vector
<
Complex
>
{
2
});
// Components
auto
cs
=
CurrentSource
::
make
(
"cs"
,
Logger
::
Level
::
info
);
cs
->
setParameters
(
Complex
(
10
,
0
),
0
);
auto
r1
=
Resistor
::
make
(
"r_1"
);
r1
->
setParameters
(
0.2
);
auto
l1
=
Inductor
::
make
(
"l_1"
,
Logger
::
Level
::
info
);
l1
->
setParameters
(
0.001
);
// Topology
cs
->
connect
(
Node
::
List
{
Node
::
GND
,
n1
});
r1
->
connect
(
Node
::
List
{
n1
,
Node
::
GND
});
l1
->
connect
(
Node
::
List
{
n1
,
Node
::
GND
});
// Define system topology
auto
sys
=
SystemTopology
(
50
,
SystemNodeList
{
n1
},
SystemComponentList
{
cs
,
r1
,
l1
});
// Logger
auto
logger
=
DataLogger
::
make
(
simName
);
logger
->
addAttribute
(
"v1"
,
n1
->
attribute
(
"v"
));
logger
->
addAttribute
(
"iR1"
,
r1
->
attribute
(
"i_intf"
));
logger
->
addAttribute
(
"iL1"
,
l1
->
attribute
(
"i_intf"
));
Simulation
sim
(
simName
,
sys
,
timeStep
,
finalTime
,
Domain
::
EMT
);
sim
.
addLogger
(
logger
);
sim
.
run
();
return
0
;
}
Examples/Notebooks/Circuits/CS_RL1.ipynb
0 → 100644
View file @
9faa1ae3
This diff is collapsed.
Click to expand it.
Include/dpsim/Python/Node.h
View file @
9faa1ae3
...
...
@@ -53,11 +53,14 @@ namespace Python {
static
PyObject
*
voltage
(
PyObject
*
self
,
PyObject
*
args
);
static
PyObject
*
gnd
(
PyObject
*
self
,
PyObject
*
args
);
static
void
setInitialVoltage
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
);
static
const
char
*
name
;
static
const
char
*
doc
;
static
const
char
*
docInitialVoltage
;
static
const
char
*
docVoltage
;
static
const
char
*
docGND
;
static
const
char
*
docSetInitialVoltage
;
static
PyMethodDef
methods
[];
static
PyTypeObject
type
;
...
...
Source/Python/Node.cpp
View file @
9faa1ae3
...
...
@@ -158,11 +158,31 @@ PyObject * Python::Node<VarType>::gnd(PyObject *self, PyObject *args) {
return
Py_GND
;
}
template
<
typename
VarType
>
const
char
*
Python
::
Node
<
VarType
>::
docSetInitialVoltage
=
"set_initial_voltage
\n
"
"Set the initial voltage at this node.
\n
"
;
template
<
typename
VarType
>
void
Python
::
Node
<
VarType
>::
setInitialVoltage
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
Py_complex
initVoltage
;
CPS
::
Int
phaseIndex
;
static
const
char
*
kwlist
[]
=
{
"voltage"
,
"index"
,
nullptr
};
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"Di"
,
(
char
**
)
kwlist
,
&
initVoltage
,
&
phaseIndex
))
return
;
Python
::
Node
<
VarType
>*
pyNode
=
(
Python
::
Node
<
VarType
>*
)
self
;
pyNode
->
node
->
setInitialVoltage
(
CPS
::
Complex
(
initVoltage
.
real
,
initVoltage
.
imag
),
phaseIndex
);
}
template
<
typename
VarType
>
PyMethodDef
Python
::
Node
<
VarType
>::
methods
[]
=
{
{
"initial_voltage"
,
(
PyCFunction
)
Python
::
Node
<
VarType
>::
initialVoltage
,
METH_NOARGS
,
(
char
*
)
Python
::
Node
<
VarType
>::
docInitialVoltage
},
{
"voltage"
,
(
PyCFunction
)
Python
::
Node
<
VarType
>::
voltage
,
METH_NOARGS
,
(
char
*
)
Python
::
Node
<
VarType
>::
docVoltage
},
{
"GND"
,
(
PyCFunction
)
Python
::
Node
<
VarType
>::
gnd
,
METH_NOARGS
|
METH_STATIC
,
(
char
*
)
Python
::
Node
<
VarType
>::
docGND
},
{
"set_initial_voltage"
,
(
PyCFunction
)
Python
::
Node
<
VarType
>::
setInitialVoltage
,
METH_VARARGS
|
METH_KEYWORDS
,
(
char
*
)
Python
::
Node
<
VarType
>::
docSetInitialVoltage
},
{
nullptr
,
nullptr
,
0
,
nullptr
}
};
...
...
Markus Mirz
@markus.mirz
mentioned in commit
c86bbb42
·
Feb 13, 2020
mentioned in commit
c86bbb42
mentioned in commit c86bbb42a46f6c8babf7b0435f338070dcf29a97
Toggle commit list
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