Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OMEGAlpes
OMEGAlpes
Commits
7594899e
Commit
7594899e
authored
Feb 12, 2020
by
brugeron
Browse files
Resample feature added
parent
dbe62fb2
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/electrical_system_operation.py
View file @
7594899e
...
...
@@ -41,6 +41,7 @@ from omegalpes.energy.units.consumption_units import FixedConsumptionUnit
from
omegalpes.general.optimisation.model
import
OptimisationModel
from
omegalpes.general.time
import
TimeUnit
from
omegalpes.general.plots
import
plot_quantity
,
plt
from
omegalpes.general.utils
import
save_energy_flows
__docformat__
=
"restructuredtext en"
...
...
@@ -99,7 +100,7 @@ def main(work_path, op_cost_a, op_cost_b, consumption_file):
model
.
solve_and_update
()
# Run optimization and update values
return
model
,
time
,
dwelling_consumption
,
grid_production_a
,
\
grid_production_b
grid_production_b
,
elec_node
def
print_results
():
...
...
@@ -185,10 +186,13 @@ if __name__ == "__main__":
# *** RUN MAIN ***
MODEL
,
TIME
,
DWELLING_CONSUMPTION
,
GRID_PRODUCTION_A
,
\
GRID_PRODUCTION_B
=
main
(
work_path
=
WORK_PATH
,
GRID_PRODUCTION_B
,
NODE
=
main
(
work_path
=
WORK_PATH
,
op_cost_a
=
OPERATING_COSTS_A
,
op_cost_b
=
OPERATING_COSTS_B
,
consumption_file
=
CONSUMPTION_PROFILE
)
# Save energy flows into a CSV file
save_energy_flows
(
NODE
,
file_name
=
WORK_PATH
+
r
'\results\storage_design'
)
# *** SHOW RESULTS ***
print_results
()
omegalpes/general/optimisation/elements.py
View file @
7594899e
...
...
@@ -392,6 +392,67 @@ class HourlyDynamicConstraint(DynamicConstraint):
description
=
description
,
active
=
active
,
parent
=
parent
)
class
DailyDynamicConstraint
(
DynamicConstraint
):
"""
** Description **
Class that defines an dynamic contraint for a time range
Ex : Constraint applying between 7am and 10pm
ex_cst = HourlyDynamicConstraint(exp_t, time, init_h=7, final_h=22,
name='ex_cst')
**Attributes**
- name (str) : name of the constraint
- exp_t (str) : expression of the constraint
- init_h (int) : hour of beginning of the constraint [0-23]
- final_h (int) : hour of end of the constraint [1-24]
- description (str) : description of the constraint
- active (bool) : defines if the constraint is active or not
- parent (Unit) : parent of the constraint
"""
def
__init__
(
self
,
exp_t
,
time
,
init_h
:
int
=
0
,
final_h
:
int
=
24
,
name
=
'HDCST0'
,
description
=
'hourly dynamic constraint'
,
active
=
True
,
parent
=
None
):
if
init_h
>
final_h
:
raise
ValueError
(
'final_h {0} should be greater than init_h '
'{1}'
.
format
(
final_h
,
init_h
))
if
final_h
>
24
:
raise
ValueError
(
'final_h {} should be lower than '
'24'
.
format
(
final_h
))
index_list
=
[]
# Initializing the list of index
# For all days in the time periods, select the hour range
for
day
in
time
.
get_days
:
starting_date
=
datetime
.
datetime
(
year
=
day
.
year
,
month
=
day
.
month
,
day
=
day
.
day
,
hour
=
init_h
)
if
final_h
==
24
:
end
=
day
+
datetime
.
timedelta
(
days
=
1
)
else
:
end
=
datetime
.
datetime
(
year
=
day
.
year
,
month
=
day
.
month
,
day
=
day
.
day
,
hour
=
final_h
)
try
:
index_date
=
time
.
get_index_for_date_range
(
starting_date
=
starting_date
,
end
=
end
)
index_list
+=
index_date
except
ValueError
:
pass
# Exception when no values for the last day for instance
t_range
=
'for t in {}'
.
format
(
index_list
)
DynamicConstraint
.
__init__
(
self
,
exp_t
,
t_range
=
t_range
,
name
=
name
,
description
=
description
,
active
=
active
,
parent
=
parent
)
class
Objective
:
"""
...
...
omegalpes/general/utils.py
View file @
7594899e
This diff is collapsed.
Click to expand it.
tests/resample_testing.py
0 → 100644
View file @
7594899e
from
omegalpes.general.utils
import
resample_data
import
random
total
=
240
input_list
=
list
(
range
(
1
,
240
,
1
))
dt_origin
=
1.
dt_final
=
1.
/
2.
# for i in range(total):
# input_list.append(random.random())
output_list
=
resample_data
(
input_list
,
dt_origin
,
dt_final
)
print
(
output_list
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment