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
da0bad61
Commit
da0bad61
authored
6 years ago
by
Bichen Li
Browse files
Options
Downloads
Patches
Plain Diff
change the name of validationtool.py
parent
9a683852
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
Assert_Results.py
+1
-1
1 addition, 1 deletion
Assert_Results.py
dataprocessing/Validationtools.py
+0
-121
0 additions, 121 deletions
dataprocessing/Validationtools.py
with
1 addition
and
122 deletions
Assert_Results.py
+
1
−
1
View file @
da0bad61
...
...
@@ -2,7 +2,7 @@ import re
import
os
import
sys
from
dataprocessing.
V
alidationtools
import
*
from
dataprocessing.
v
alidationtools
import
*
from
dataprocessing.readtools
import
*
print
(
"
Test Start
"
)
# We need to extract all the result files from git now
...
...
This diff is collapsed.
Click to expand it.
dataprocessing/Validationtools.py
deleted
100644 → 0
+
0
−
121
View file @
9a683852
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import
os
from
dataprocessing.readtools
import
*
def
mapping_modcelica_neplan
(
neplan_timeseries
):
"""
Mapping the variable names between modelica and neplan
- Voltage: change *.U and *.ANGLEU to *.V and *.Vangle
- Current: remove unnecessary current variables
:param neplan_timeseries: result of neplan in timeseries
:return: a mapped neplan_timeseries
"""
line_del
=
[]
# remove all the line current
# Find current of the same component, which means the current needn't to be validated
for
check
in
range
(
len
(
neplan_timeseries
)):
if
neplan_timeseries
[
check
].
values
[
0
]
==
'
#
'
:
line_del
.
append
(
check
)
if
'
.P
'
in
neplan_timeseries
[
check
].
name
:
line_del
.
append
(
check
)
if
'
.Q
'
in
neplan_timeseries
[
check
].
name
:
line_del
.
append
(
check
)
for
i
in
range
(
check
+
1
,
len
(
neplan_timeseries
)):
if
neplan_timeseries
[
check
].
name
==
neplan_timeseries
[
i
].
name
:
line_del
.
append
(
check
)
# delete list of the unnecessary data
line_del
.
append
(
i
)
line_del
=
sorted
(
set
(
line_del
))
for
num_to_del
in
range
(
len
(
line_del
)):
del
neplan_timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
# Change the unit of variables to keep consistent with those in modelica
for
i
in
range
(
len
(
neplan_timeseries
)):
if
'
ANGLE
'
in
neplan_timeseries
[
i
].
name
:
neplan_timeseries
[
i
].
values
=
neplan_timeseries
[
i
].
values
/
180
*
cmath
.
pi
# unification of the unit
elif
'
.U
'
in
neplan_timeseries
[
i
].
name
or
'
.I
'
in
neplan_timeseries
[
i
].
name
:
neplan_timeseries
[
i
].
values
=
neplan_timeseries
[
i
].
values
*
1000
# Change the name of variables to keep consistent with those in modelica
for
i
in
range
(
len
(
neplan_timeseries
)):
neplan_timeseries
[
i
].
name
=
neplan_timeseries
[
i
].
name
.
replace
(
'
'
,
''
)
neplan_timeseries
[
i
].
name
=
neplan_timeseries
[
i
].
name
.
replace
(
'
.ANGLEU
'
,
'
.Vangle
'
)
neplan_timeseries
[
i
].
name
=
neplan_timeseries
[
i
].
name
.
replace
(
'
.U
'
,
'
.Vpp
'
)
neplan_timeseries
[
i
].
name
=
neplan_timeseries
[
i
].
name
.
replace
(
'
.ANGLEI
'
,
'
.Iangle
'
)
return
neplan_timeseries
def
compare_modelica_neplan
(
modelica_res
,
neplan_res
):
# compare the result file from NEPLAN and Modelica
"""
Compare Results from modelic and neplan, the name of the components should be kept consistent.
:param modelica_res: the path of the modelica result file, whose suffix should be .mat
:param neplan_res: the path of the neplan result file, whose suffix should be .rlf
:return:
"""
# Read in original neplan result file
file_Neplan
=
os
.
path
.
abspath
(
neplan_res
)
# Read in original Modelica result file
file_Modelica
=
os
.
path
.
abspath
(
modelica_res
)
result_neplan
=
mapping_modcelica_neplan
(
read_timeseries_NEPLAN_loadflow
(
file_Neplan
))
result_modelica
=
read_timeseries_Modelica
(
file_Modelica
)
# Unification of the variable names and units of the voltage and current
for
i
in
range
(
len
(
result_neplan
)):
result_neplan
[
i
].
name
=
result_neplan
[
i
].
name
.
upper
()
if
'
ANGLE
'
in
result_neplan
[
i
].
name
:
result_neplan
[
i
].
values
=
result_neplan
[
i
].
values
/
cmath
.
pi
*
180
# transfer the angle unit to degree
# Unification of the units of the angle
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
# transfer the angle unit to degree
timeseries_names
=
[]
# list for names of components
timeseries_error
=
[]
# list for error
len_limit
=
len
(
result_modelica
)
# Match the components in result files, and compare them
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
:
# Find the same variable
timeseries_names
.
append
(
result_neplan
[
i
].
name
)
timeseries_error
.
append
(
TimeSeries
.
rmse
(
result_modelica
[
j
],
result_neplan
[
i
]))
flag_not_found
=
True
if
flag_not_found
is
False
:
# No such variable in Modelica model, set the error to -1
timeseries_error
.
append
(
-
1
)
return
dict
(
zip
(
timeseries_names
,
timeseries_error
))
def
assert_modelia_neplan_results
(
net_name
,
modelica_res
,
neplan_res
):
# Assert the model using the function above
"""
Assert the result in Modelica according to the results from neplan
:param net_name: The name of the net should be clarified manually
:param modelica_res: the path of the modelica result file, whose suffix should be .mat
:param neplan_res: the path of the neplan result file, whose suffix should be .rlf
:return:
"""
fail_list
=
[]
# List for all the failed test
error
=
compare_modelica_neplan
(
modelica_res
,
neplan_res
)
# the limitations are set to 0.5
for
name
in
error
.
keys
():
if
abs
(
error
[
name
])
>
0.5
:
fail_list
.
append
(
name
)
else
:
print
(
"
Test on %s Passed
"
%
name
)
# fail_list is 0, which means all the tests are passed
if
len
(
fail_list
)
is
0
:
print
(
"
\033
[1;36;40mModel %s Passed
\033
[0m
"
%
net_name
)
else
:
for
name
in
fail_list
:
print
(
"
\033
[1;31;40mTest on %s of %s Failed
\033
[0m
"
%
(
name
,
net_name
))
raise
ValueError
(
'
Test on %s is not passed!
'
%
net_name
)
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