Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
86787903
Commit
86787903
authored
3 months ago
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inv eval 2024-12-31 15:34
parent
ab0bf15a
master
develop
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
26 deletions
+82
-26
ems.py
unify_api/algo/ems/ems.py
+18
-22
ems_cps.py
unify_api/modules/inv_eval/components/ems_cps.py
+4
-1
ems_srv.py
unify_api/modules/inv_eval/service/ems_srv.py
+8
-2
ems.py
unify_api/modules/inv_eval/views/ems.py
+52
-1
No files found.
unify_api/algo/ems/ems.py
View file @
86787903
...
...
@@ -54,12 +54,12 @@ class EnergyModel:
if
m
.
status
==
GRB
.
OPTIMAL
:
IOR
=
IOR
.
x
irr
=
calculate_irr
(
revenue_year
,
Investment_Cost
.
getValue
(),
max_invest_year
)
self
.
max_invest_year
)
if
IOR
>
self
.
max_invest_year
:
return
{
"Error"
:
f
"当前区域的投资回报比(IOR = {IOR:.2f})高于"
f
"设置的投资上限,建议不要投资。"
}
else
:
re
sult
=
{
re
turn
{
'pv'
:
0
,
'es_p'
:
P_ES
.
x
,
'es_cap'
:
P_ES
.
x
*
2
,
'cg'
:
P_CG
.
x
,
...
...
@@ -69,7 +69,6 @@ class EnergyModel:
'cost_kWh'
:
round
(
cost_kWh
,
2
),
'irr'
:
irr
}
return
result
else
:
return
{
"Error"
:
"当前限制条件不合理"
}
...
...
@@ -128,12 +127,13 @@ class EnergyModel:
if
m
.
status
==
GRB
.
OPTIMAL
:
IOR
=
IOR
.
x
irr
=
calculate_irr
(
revenue_year
.
getValue
(),
Investment_Cost
.
getValue
(),
max_invest_year
)
Investment_Cost
.
getValue
(),
self
.
max_invest_year
)
if
IOR
>
self
.
max_invest_year
:
return
{
"Error"
:
f
"当前区域的投资回报比(IOR = {IOR:.2f})高于"
f
"设置的投资上限,建议不要投资。"
}
else
:
re
sult
=
{
re
turn
{
'pv'
:
P_PV
.
x
,
'es_p'
:
P_ES
.
x
,
'es_cap'
:
P_ES
.
x
*
2
,
'cg'
:
P_CG
.
x
,
...
...
@@ -143,7 +143,6 @@ class EnergyModel:
'cost_kWh'
:
round
(
cost_kWh
,
2
),
'irr'
:
irr
}
return
result
else
:
return
{
"Error"
:
"当前限制条件不合理"
}
...
...
@@ -210,11 +209,10 @@ class EnergyModel:
Investment_Cost
.
getValue
(),
max_invest_year
)
if
IOR
>
self
.
max_invest_year
:
return
{
"Error"
:
f
"当前区域的投资回报比(IOR = {IOR:.2f})高于"
f
"设置的投资上限,建议不要投资。"
}
return
{
"Error"
:
f
"当前区域的投资回报比(IOR = {IOR:.2f})"
f
"高于设置的投资上限,建议不要投资。"
}
else
:
re
sult
=
{
re
turn
{
'pv'
:
P_PV
.
x
,
'es_p'
:
P_ES
.
x
,
'es_cap'
:
P_ES
.
x
*
2
,
'cg'
:
P_CG
.
x
,
...
...
@@ -224,16 +222,14 @@ class EnergyModel:
'cost_kWh'
:
round
(
cost_kWh
,
2
),
'irr'
:
irr
}
return
result
except
:
rlt_all
=
ems_model
.
all_calculate
(
dict
(
pv_cost
=
pv_cost
,
sun_hrs_year
=
sun_hrs_year
,
max_load
=
max_load
,
min_load
=
min_load
,
pv_eff
=
pv_eff
,
pv_area
=
pv_area
,
pv_limit
=
pv_limit
))
return
rlt_all
return
self
.
all_calculate
(
dict
(
pv_cost
=
pv_cost
,
sun_hrs_year
=
sun_hrs_year
,
max_load
=
max_load
,
min_load
=
min_load
,
pv_eff
=
pv_eff
,
pv_area
=
pv_area
,
pv_limit
=
pv_limit
))
def
com_strategy
(
self
,
d_params
):
pv_cost
=
d_params
[
"pv_cost"
]
...
...
@@ -292,12 +288,13 @@ class EnergyModel:
if
m
.
status
==
GRB
.
OPTIMAL
:
IOR
=
Investment_Cost
.
getValue
()
/
revenue_year
.
getValue
()
irr
=
calculate_irr
(
revenue_year
.
getValue
(),
Investment_Cost
.
getValue
(),
max_invest_year
)
Investment_Cost
.
getValue
(),
self
.
max_invest_year
)
if
IOR
>
self
.
max_invest_year
:
return
{
"Error"
:
f
"当前区域的投资回报比(IOR = {IOR:.2f})高于"
f
"设置的投资上限,建议不要投资。"
}
else
:
re
sult
=
{
re
turn
{
'pv'
:
P_PV
.
x
,
'es_p'
:
P_ES
.
x
,
'es_cap'
:
P_ES
.
x
*
2
,
...
...
@@ -308,7 +305,6 @@ class EnergyModel:
'cost_kWh'
:
round
(
cost_kWh
,
2
),
'irr'
:
irr
}
return
result
else
:
return
{
"Error"
:
"当前限制条件不合理"
}
...
...
This diff is collapsed.
Click to expand it.
unify_api/modules/inv_eval/components/ems_cps.py
View file @
86787903
...
...
@@ -15,7 +15,8 @@ class EmsInvEvalReq(Model):
es_cost
:
float
=
Opt
(
Float
(
"储能成本 元/kw"
)
.
eg
(
1500
))
pv_cost
:
float
=
Opt
(
Float
(
"年均负荷(kw)"
)
.
eg
(
800
))
ele_price
:
float
=
Opt
(
Float
(
"电价"
)
.
eg
(
1.4
))
cg_cost
:
float
=
Opt
(
Float
(
"煤制气成本加上燃料成本 元/kw"
)
.
eg
(
8000
))
cg_cost
:
float
=
Opt
(
Float
(
"煤制气设备成本"
)
.
eg
(
8000
))
cg_fuel_cost
:
float
=
Opt
(
Float
(
"煤制气燃料成本"
)
.
eg
(
8000
))
sale_price
:
float
=
Opt
(
Float
(
"售电价格"
)
.
eg
(
1000
))
sale_cost
:
float
=
Opt
(
Float
(
"售电成本价格"
)
.
eg
(
0.5
))
work_hours_year
:
float
=
Opt
(
Float
(
"每年的工作时长"
)
.
eg
(
2000
))
...
...
@@ -29,6 +30,8 @@ class EmsInvEvalReq(Model):
sale_limit
:
float
=
Opt
(
Float
(
"售电限制kw*h"
)
.
eg
(
100000
))
cg_eff
:
float
=
Opt
(
Float
(
"煤制气效率"
)
.
eg
(
0.8
))
es_eff
:
float
=
Opt
(
Float
(
"充电效率"
)
.
eg
(
0.8
))
pv_deg_rate
:
float
=
Opt
(
Float
(
"光伏衰减率"
)
.
eg
(
0.8
))
es_deg_rate
:
float
=
Opt
(
Float
(
"储能衰减率"
)
.
eg
(
0.8
))
goal
:
int
=
Int
(
"1保重要负荷2保所有负荷3可联网售电4综合成本最优"
)
.
eg
(
1
)
...
...
This diff is collapsed.
Click to expand it.
unify_api/modules/inv_eval/service/ems_srv.py
View file @
86787903
...
...
@@ -26,16 +26,22 @@ async def inv_eval(d_params):
sale_price
=
d_params
[
"sale_price"
]
sale_limit
=
d_params
[
"sale_limit"
]
sale_cost
=
d_params
[
"sale_cost"
]
cg_fuel_cost
=
d_params
[
"cg_fuel_cost"
]
pv_deg_rate
=
d_params
[
"pv_deg_rate"
]
es_deg_rate
=
d_params
[
"es_deg_rate"
]
goal
=
d_params
[
"goal"
]
rlt_cfg
=
{}
ems_model
=
EnergyModel
(
dict
(
load_year
=
load_year
,
imp_load_year
=
imp_load_year
,
es_cost
=
es_cost
,
ele_price
=
ele_price
,
cg_cost
=
cg_cost
,
cg_cost
=
cg_cost
,
cg_fuel_cost
=
cg_fuel_cost
,
work_hours_year
=
work_hours_year
,
max_invest_year
=
max_invest_year
,
cg_eff
=
cg_eff
,
es_eff
=
es_eff
))
cg_eff
=
cg_eff
,
es_eff
=
es_eff
,
pv_deg_rate
=
pv_deg_rate
,
es_deg_rate
=
es_deg_rate
))
if
goal
==
1
:
rlt_cfg
=
ems_model
.
cri_calculate
()
...
...
This diff is collapsed.
Click to expand it.
unify_api/modules/inv_eval/views/ems.py
View file @
86787903
...
...
@@ -4,6 +4,7 @@ DATE:2024/12/30 10:15
"""
from
pot_libs.sanic_api
import
summary
from
pot_libs.logger
import
log
from
unify_api.modules.inv_eval.service.ems_srv
import
inv_eval
from
unify_api.modules.inv_eval.components.ems_cps
import
(
EmsInvEvalReq
,
EmsInvEvalRsp
...
...
@@ -19,6 +20,7 @@ async def post_inv_eval(req, body: EmsInvEvalReq) -> EmsInvEvalRsp:
pv_cost
=
body
.
pv_cost
or
0
ele_price
=
body
.
ele_price
or
0
cg_cost
=
body
.
cg_cost
or
0
cg_fuel_cost
=
body
.
cg_fuel_cost
or
0
sale_price
=
body
.
sale_price
or
0
sale_cost
=
body
.
sale_cost
or
0
work_hours_year
=
body
.
work_hours_year
or
0
...
...
@@ -32,16 +34,20 @@ async def post_inv_eval(req, body: EmsInvEvalReq) -> EmsInvEvalRsp:
sale_limit
=
body
.
sale_limit
or
0
cg_eff
=
body
.
cg_eff
or
0.8
es_eff
=
body
.
es_eff
or
0.8
pv_deg_rate
=
body
.
pv_deg_rate
or
0.6
es_deg_rate
=
body
.
es_deg_rate
or
2.1
goal
=
body
.
goal
d_params
=
dict
(
load_year
=
load_year
,
imp_load_year
=
imp_load_year
,
es_cost
=
es_cost
,
pv_cost
=
pv_cost
,
ele_price
=
ele_price
,
cg_cost
=
cg_cost
,
work_hours_year
=
work_hours_year
,
cg_cost
=
cg_cost
,
cg_fuel_cost
=
cg_fuel_cost
,
work_hours_year
=
work_hours_year
,
max_invest_year
=
max_invest_year
,
cg_eff
=
cg_eff
,
es_eff
=
es_eff
,
sun_hrs_year
=
sun_hrs_year
,
max_load
=
max_load
,
min_load
=
min_load
,
pv_eff
=
pv_eff
,
pv_area
=
pv_area
,
pv_limit
=
pv_limit
,
sale_price
=
sale_price
,
sale_limit
=
sale_limit
,
pv_deg_rate
=
pv_deg_rate
,
es_deg_rate
=
es_deg_rate
,
sale_cost
=
sale_cost
,
goal
=
goal
)
cfg
=
await
inv_eval
(
d_params
)
if
"Error"
in
cfg
:
...
...
@@ -55,5 +61,50 @@ async def post_inv_eval(req, body: EmsInvEvalReq) -> EmsInvEvalRsp:
irr
=
cfg
.
get
(
"irr"
,
0
),
ior
=
cfg
.
get
(
"ior"
,
0
),
cost_kWh
=
cfg
.
get
(
"cost_kWh"
,
0
),
)
except
Exception
as
e
:
log
.
error
(
f
"cal ems inv eval error, e:{e}"
)
return
EmsInvEvalRsp
(
pv
=
0
,
es_p
=
0
,
es_cap
=
0
,
cg
=
0
,
income_year
=
0
,
total_inv_cost
=
0
,
irr
=
0
,
ior
=
0
,
cost_kWh
=
0
)
#
# async def main():
# load_year = 2500 # 年均负荷(kw)
# imp_load_year = 1500 # 年均重要负荷(kw)
# es_cost = 1500 # 储能成本 元/kw
# pv_cost = 800 # 光伏成本 元/kw
# ele_price = 1.4 # 电价
# cg_cost = 6000 # 煤制气设备成本元/kw
# cg_fuel_cost = 100 # 煤制气燃料成本元/kw
# sale_price = 50 # 售电价格元
# sale_cost = 0.5 # 售电价格元
# work_hours_year = 2000 # 每年的工作时长为2000小时
# sun_hrs_year = 1300 # 每年的光照时长为1300小时
# max_load = 6000 # kw
# min_load = 1000 # kw
# pv_area = 5000000 # 当前场地的光伏建设面积最大面积平方米
# pv_eff = 0.8 # 光伏效率
# max_invest_year = 5 # 当前投资收益最大限制
# pv_limit = 7000 # 光伏最大限制
# sale_limit = 2400000 # 售电限制kw*h
# pv_deg_rate = 0.6
# es_deg_rate = 2.1
# goal = 4
# d_params = dict(load_year=load_year, imp_load_year=imp_load_year,
# es_cost=es_cost, pv_cost=pv_cost, ele_price=ele_price,
# cg_cost=cg_cost, cg_fuel_cost=cg_fuel_cost,
# work_hours_year=work_hours_year,
# max_invest_year=max_invest_year,
# cg_eff=0.8, es_eff=0.8,
# sun_hrs_year=sun_hrs_year,
# max_load=max_load, min_load=min_load,
# pv_eff=pv_eff, pv_area=pv_area, pv_limit=pv_limit,
# sale_price=sale_price, sale_limit=sale_limit,
# pv_deg_rate=pv_deg_rate, es_deg_rate=es_deg_rate,
# sale_cost=sale_cost, goal=goal)
# cfg = await inv_eval(d_params)
# print(cfg)
#
#
# if __name__ == '__main__':
# import asyncio
#
# asyncio.run(main())
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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