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
b15be9d0
Commit
b15be9d0
authored
Sep 18, 2017
by
Georg Martin Reinke
Browse files
remove old netlist code
Former-commit-id:
5e3d3b8a
parent
f8042150
Changes
4
Hide whitespace changes
Inline
Side-by-side
Source/NetlistSim.cpp
deleted
100644 → 0
View file @
f8042150
#include
"NetlistSim.h"
#include
"Utilities.h"
using
namespace
DPsim
;
void
DPsim
::
NetlistSim
(
int
argc
,
char
*
argv
[])
{
// Extract command line arguments
char
*
confFilename
=
nullptr
;
readCmdLineArguments
(
confFilename
,
argc
,
argv
);
// Read config file
std
::
ifstream
confFile
;
Config
conf
;
TopologyReader
topoReader
;
confFile
.
open
(
confFilename
);
if
(
topoReader
.
readConfig
(
confFile
,
conf
)
!=
0
||
conf
.
elements
.
size
()
==
0
)
{
std
::
cerr
<<
"netlist file or path invalid"
<<
std
::
endl
;
exit
(
1
);
}
// Parse config file
double
tf
,
dt
,
t
;
double
om
=
2.0
*
M_PI
*
50.0
;
std
::
vector
<
BaseComponent
*>
circElements
;
topoReader
.
parseConfig
(
conf
,
circElements
,
dt
,
tf
);
if
(
circElements
.
size
()
==
0
)
{
std
::
cerr
<<
"failed to parse netlist"
<<
std
::
endl
;
exit
(
1
);
}
// Define Object for saving data on a file
Logger
log
(
"log.txt"
),
vtLog
(
"data_vt.txt"
),
jLog
(
"data_j.txt"
);
// Add components to new simulation and create system matrix
std
::
cout
<<
std
::
endl
<<
"Create System matrix"
<<
std
::
endl
;
Simulation
newSim
(
circElements
,
om
,
dt
,
tf
,
log
);
std
::
cout
<<
"Initialization Completed"
<<
std
::
endl
;
std
::
cout
<<
"Entering Main Simulation Loop"
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
// Get Current Simulation Time
t
=
newSim
.
getTime
();
// Main Simulation Loop
while
(
newSim
.
step
(
log
))
{
// Save Simulation Step
vtLog
.
LogDataLine
(
newSim
.
getTime
(),
newSim
.
getLeftSideVector
());
jLog
.
LogDataLine
(
newSim
.
getTime
(),
newSim
.
getRightSideVector
());
// Get Current Simulation Time
t
=
newSim
.
getTime
();
updateProgressBar
(
t
,
tf
);
}
std
::
cout
<<
"####################### (100%)"
<<
std
::
endl
;;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"Simulation finished"
<<
std
::
endl
;
std
::
cout
<<
"Saved data points"
<<
std
::
endl
;
}
void
DPsim
::
readCmdLineArguments
(
char
*
&
confFilename
,
int
argc
,
char
*
argv
[])
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
// Find and extract netlist file path
if
(
!
std
::
string
(
argv
[
i
]).
compare
(
"-nl"
)
||
!
std
::
string
(
argv
[
i
]).
compare
(
"--netlist"
))
{
if
(
++
i
>=
argc
)
{
std
::
cerr
<<
"missing parameter for -nl/--netlist"
<<
std
::
endl
;
exit
(
1
);
}
confFilename
=
argv
[
i
];
}
else
{
std
::
cerr
<<
"unknown / invalid parameter "
<<
argv
[
i
]
<<
std
::
endl
;
exit
(
1
);
}
}
if
(
!
confFilename
)
{
std
::
cerr
<<
"no netlist file given"
<<
std
::
endl
;
exit
(
1
);
}
}
Source/NetlistSim.h
deleted
100644 → 0
View file @
f8042150
#ifndef NETLISTSIM_H
#define NETLISTSIM_H
#include
<iostream>
#include
<string>
#include
"MathLibrary.h"
#include
"Simulation.h"
#include
"Components.h"
#include
"Logger.h"
#include
"TopologyReader.h"
namespace
DPsim
{
void
readCmdLineArguments
(
char
*
&
confFilename
,
int
argc
,
char
*
argv
[]);
void
NetlistSim
(
int
argc
,
char
*
argv
[]);
}
#endif
Source/TopologyReader.cpp
deleted
100644 → 0
View file @
f8042150
#include
"TopologyReader.h"
#include
"Components.h"
using
namespace
DPsim
;
TopologyReader
::
TopologyReader
()
{
}
TopologyReader
::~
TopologyReader
()
{
}
int
TopologyReader
::
readConfig
(
std
::
ifstream
&
f
,
Config
&
conf
)
{
std
::
string
s
;
getline
(
f
,
s
);
if
(
!
s
.
empty
()
&&
s
[
0
]
==
'#'
)
getline
(
f
,
s
);
if
(
conf
.
timeStep
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
conf
.
timeStep
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
if
(
conf
.
finalTime
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
conf
.
finalTime
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
for
(
int
line
=
1
;
f
.
good
();
line
++
)
{
getline
(
f
,
s
);
if
(
!
s
.
empty
()
&&
s
[
0
]
==
'#'
)
continue
;
Element
element
;
for
(
int
elementIdx
=
1
;
s
.
find
(
','
)
!=
std
::
string
::
npos
;
elementIdx
++
)
{
if
(
element
.
type
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
element
.
type
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
else
if
(
element
.
name
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
element
.
name
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
else
if
(
element
.
node1
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
element
.
node1
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
else
if
(
element
.
node2
.
empty
())
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
element
.
node2
=
s
.
substr
(
0
,
p
);
s
.
erase
(
0
,
p
+
1
);
}
else
{
std
::
string
::
size_type
p
=
s
.
find
(
','
);
element
.
parameters
.
push_back
(
s
.
substr
(
0
,
p
));
s
.
erase
(
0
,
p
+
1
);
}
}
conf
.
elements
.
push_back
(
element
);
}
return
0
;
}
int
TopologyReader
::
parseConfig
(
Config
&
conf
,
std
::
vector
<
BaseComponent
*>
&
circElements
,
double
&
timeStep
,
double
&
finalTime
)
{
timeStep
=
std
::
stod
(
conf
.
timeStep
);
finalTime
=
std
::
stod
(
conf
.
finalTime
);
for
(
std
::
vector
<
Element
>::
iterator
it
=
conf
.
elements
.
begin
();
it
!=
conf
.
elements
.
end
();
++
it
)
{
BaseComponent
*
tmpCircElement
;
if
(
it
->
type
.
compare
(
"VoltageSourceWithResistance"
)
==
0
)
{
tmpCircElement
=
new
VoltSourceRes
(
it
->
name
,
std
::
stoi
(
it
->
node1
),
std
::
stoi
(
it
->
node2
),
std
::
stod
(
it
->
parameters
[
0
]),
std
::
stod
(
it
->
parameters
[
1
]),
std
::
stod
(
it
->
parameters
[
2
]));
}
else
if
(
it
->
type
.
compare
(
"Inductor"
)
==
0
)
{
tmpCircElement
=
new
Inductor
(
it
->
name
,
std
::
stoi
(
it
->
node1
),
std
::
stoi
(
it
->
node2
),
std
::
stod
(
it
->
parameters
[
0
]));
}
else
if
(
it
->
type
.
compare
(
"Capacitor"
)
==
0
)
{
tmpCircElement
=
new
Capacitor
(
it
->
name
,
std
::
stoi
(
it
->
node1
),
std
::
stoi
(
it
->
node2
),
std
::
stod
(
it
->
parameters
[
0
]));
}
else
if
(
it
->
type
.
compare
(
"LinearResistor"
)
==
0
)
{
tmpCircElement
=
new
LinearResistor
(
it
->
name
,
std
::
stoi
(
it
->
node1
),
std
::
stoi
(
it
->
node2
),
std
::
stod
(
it
->
parameters
[
0
]));
}
else
if
(
it
->
type
.
compare
(
"InterfacedInductor"
)
==
0
)
{
tmpCircElement
=
new
InterfacedInductor
(
it
->
name
,
std
::
stoi
(
it
->
node1
),
std
::
stoi
(
it
->
node2
),
std
::
stod
(
it
->
parameters
[
0
]));
}
else
{
}
circElements
.
push_back
(
tmpCircElement
);
}
return
0
;
}
\ No newline at end of file
Source/TopologyReader.h
deleted
100644 → 0
View file @
f8042150
#ifndef TOPOLOGYREADER_H
#define TOPOLOGYREADER_H
#include
<fstream>
#include
<vector>
#include
<string>
#include
"Simulation.h"
#include
"Components.h"
namespace
DPsim
{
typedef
struct
{
std
::
string
type
;
std
::
string
name
;
std
::
string
node1
;
std
::
string
node2
;
std
::
vector
<
std
::
string
>
parameters
;
}
Element
;
typedef
struct
{
std
::
string
timeStep
;
std
::
string
finalTime
;
std
::
vector
<
Element
>
elements
;
}
Config
;
class
TopologyReader
{
private:
public:
TopologyReader
();
~
TopologyReader
();
/// Parse topology file
/// @param f Openend stream containing the configuration file.
/// @param conf Configuration structure that is filled out during parsing.
/// @return 0 if successfull, nonzero otherwise.
int
readConfig
(
std
::
ifstream
&
f
,
Config
&
conf
);
/// Use the parsed configuration structure to create circuit elements
int
parseConfig
(
Config
&
conf
,
std
::
vector
<
BaseComponent
*>
&
circElements
,
double
&
timeStep
,
double
&
finalTime
);
};
}
#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