Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VILLASdataprocessing
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
VILLASframework
VILLASdataprocessing
Commits
c670a080
Commit
c670a080
authored
7 years ago
by
Bichen Li
Browse files
Options
Downloads
Patches
Plain Diff
- Add more comments for the neplan readin function
- Add Error calculation function to the asssertion function
parent
b9faf9dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dataprocessing/readtools.py
+25
-14
25 additions, 14 deletions
dataprocessing/readtools.py
examples/CompareResults/compare_madelica_neplan.py
+11
-10
11 additions, 10 deletions
examples/CompareResults/compare_madelica_neplan.py
with
36 additions
and
24 deletions
dataprocessing/readtools.py
+
25
−
14
View file @
c670a080
...
...
@@ -162,13 +162,15 @@ def read_timeseries_dpsim_cmpl_separate(filename, timeseries_names=None):
return
timeseries_list
def
read_timeseries_NEPLAN_loadflow
1
(
file_name
,
timeseries_names
=
None
,
is_regex
=
False
):
def
read_timeseries_NEPLAN_loadflow
(
file_name
,
timeseries_names
=
None
,
is_regex
=
False
):
str_tmp
=
open
(
file_name
,
"
r
"
)
# Read in files
low
=
0
high
=
0
flag
=
True
seq
=
[]
value
=
[]
low
=
0
# flag for the start of a new data in str_cmp
high
=
0
# flag for the end of this new data in str_cmp
flag
=
True
# To judge if this the first line of the file, which will be the names for the data type
# Read in data from result file of neplan
seq
=
[]
# list for datatype names
value
=
[]
# list for data
i
=
0
namelist
=
[
'
Vpp
'
,
'
Vangle
'
,
'
I
'
,
'
Iangle
'
]
timeseries
=
[]
...
...
@@ -178,27 +180,33 @@ def read_timeseries_NEPLAN_loadflow1(file_name, timeseries_names = None, is_rege
high
-=
high
low
-=
low
del
value
[:]
for
letter
in
line
:
if
letter
==
"
"
or
letter
==
"
\n
"
:
# different data or end
if
low
is
not
high
:
#
not NONE
if
flag
:
#
seq
if
letter
==
"
"
or
letter
==
"
\n
"
:
# different data
( separated by ' ')
or end
(/n)
if
low
is
not
high
:
#
low is high, no data read in
if
flag
:
#
first line of the file, list for datatype name
seq
.
append
(
line
[
low
:
high
])
else
:
#
value
else
:
#
not first line of the file,list for data
if
isfloat
.
match
(
line
[
low
:
high
]):
value
.
append
(
float
(
line
[
low
:
high
]))
else
:
value
.
append
(
line
[
low
:
high
])
else
:
#
NONE
else
:
#
no data for this datatype
value
.
append
(
r
'
#
'
)
# No value, set as #
low
=
high
+
1
low
=
high
+
1
# refresh low flag
high
+=
1
"""
A typical load current in neplan has two parts from both end, so the calculation of the
current is necessary, which is the function of this part
"""
if
flag
is
False
:
i
+=
1
check_pass
=
True
# Check for current of the same component
if
value
[
0
]
==
'
0
'
:
if
value
[
0
]
==
'
0
'
:
# value[0] == '0', the data is for BUS voltage
for
m
in
range
(
2
):
timeseries
.
append
(
TimeSeries
(
value
[
1
]
+
'
.
'
+
namelist
[
m
],
0
,
value
[
m
+
6
]))
else
:
else
:
# Looking for current data
for
check
in
range
(
len
(
timeseries
)
-
1
):
if
timeseries
[
check
].
name
==
value
[
3
]
+
'
.
'
+
namelist
[
2
]:
check_pass
=
False
# Find current of the same component, Calculate the current using (r,tha)
...
...
@@ -206,11 +214,14 @@ def read_timeseries_NEPLAN_loadflow1(file_name, timeseries_names = None, is_rege
timeseries
[
check
+
1
].
values
/
180
*
cmath
.
pi
)
+
cmath
.
rect
(
value
[
10
],
value
[
11
]
/
180
*
cmath
.
pi
)
(
timeseries
[
check
].
values
,
timeseries
[
check
+
1
].
values
)
=
cmath
.
polar
(
result
)
timeseries
[
check
+
1
].
values
=
timeseries
[
check
+
1
].
values
/
cmath
.
pi
*
180
if
check_pass
:
for
m
in
range
(
2
,
4
):
timeseries
.
append
(
TimeSeries
(
value
[
3
]
+
'
.
'
+
namelist
[
m
],
0
,
value
[
m
+
8
]))
flag
=
False
str_tmp
.
close
()
line_del
=
[]
if
is_regex
is
True
:
# Read in variables which match with regex
...
...
This diff is collapsed.
Click to expand it.
examples/CompareResults/compare_madelica_neplan.py
+
11
−
10
View file @
c670a080
...
...
@@ -8,25 +8,23 @@ file_Neplan = r"C:\Users\admin\Desktop\Load_read\WCSS\Load_flow_WCSS.rlf"
file_Modelica
=
r
"
C:\Users\admin\Desktop\Load_read\WCSS.mat
"
result_neplan
=
read_timeseries_NEPLAN_loadflow1
(
file_Neplan
)
result_modelica
=
read_timeseries_Modelica
(
file_Modelica
)
f
=
open
(
r
"
C:\Users\admin\Desktop\Load_read\output_neplan.txt
"
,
"
w
"
)
f
_neplan
=
open
(
r
"
C:\Users\admin\Desktop\Load_read\output_neplan.txt
"
,
"
w
"
)
f_modelica
=
open
(
r
"
C:\Users\admin\Desktop\Load_read\output_modelica.txt
"
,
"
w
"
)
f_error
=
open
(
r
"
C:\Users\admin\Desktop\Load_read\output_error_modelica-neplan.txt
"
,
"
w
"
)
list_del
=
[]
for
i
in
range
(
len
(
result_neplan
)):
result_neplan
[
i
].
name
=
result_neplan
[
i
].
name
.
replace
(
'
'
,
''
)
result_neplan
[
i
].
name
=
result_neplan
[
i
].
name
.
upper
()
if
'
ANGLE
'
in
result_neplan
[
i
].
name
:
pass
elif
'
.P
'
in
result_neplan
[
i
].
name
or
'
.Q
'
in
result_neplan
[
i
].
name
:
# No need to compare Q,P since we have V,I,angle
list_del
.
append
(
i
)
else
:
result_neplan
[
i
].
values
=
result_neplan
[
i
].
values
*
1000
f
.
write
(
'
%s is %s
\n
'
%
(
result_neplan
[
i
].
name
,
result_neplan
[
i
].
values
))
# result as list of TimeSeries
'''
for num_to_del in range(len(list_del)):
del result_neplan[list_del[len(list_del) - num_to_del - 1]]
'''
f_neplan
.
write
(
'
%s is %s
\n
'
%
(
result_neplan
[
i
].
name
,
result_neplan
[
i
].
values
))
# result as list of TimeSeries
for
i
in
range
(
len
(
result_modelica
)):
result_modelica
[
i
].
name
=
result_modelica
[
i
].
name
.
upper
()
if
'
ANGLE
'
in
result_modelica
[
i
].
name
:
result_modelica
[
i
].
values
=
result_modelica
[
i
].
values
/
cmath
.
pi
*
180
f_modelica
.
write
(
'
%s is %s
\n
'
%
(
result_modelica
[
i
].
name
,
result_modelica
[
i
].
values
[
1
]))
timeseries_error
=
[]
...
...
@@ -36,10 +34,13 @@ for i in range(len(result_neplan)):
flag_NOT_found
=
False
for
j
in
range
(
len_limit
):
if
result_neplan
[
i
].
name
==
result_modelica
[
j
].
name
:
timeseries_error
.
append
(
TimeSeries
(
result_neplan
[
i
].
name
,
0
,
abs
(
result_modelica
[
j
].
values
[
1
]
-
result_neplan
[
i
].
values
)))
timeseries_error
.
append
(
TimeSeries
(
result_neplan
[
i
].
name
,
0
,
abs
(
result_modelica
[
j
].
values
[
1
]
-
result_neplan
[
i
].
values
)))
j
=
len_limit
+
1
flag_NOT_found
=
True
if
flag_NOT_found
==
False
:
if
not
flag_NOT_found
:
timeseries_error
.
append
(
TimeSeries
(
result_neplan
[
i
].
name
,
0
,
-
1
))
print
(
'
Error of %s is %f
'
%
(
timeseries_error
[
i
].
name
,
timeseries_error
[
i
].
values
))
f_error
.
write
(
'
Error of %s is %f
\n
Base value
'
'
of %s is %f
\n\n
'
%
(
timeseries_error
[
i
].
name
,
timeseries_error
[
i
].
values
,
timeseries_error
[
i
].
name
,
result_neplan
[
i
].
values
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment