Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hydraulicModel
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
刘乐
hydraulicModel
Commits
a818b0dd
Commit
a818b0dd
authored
Jun 09, 2020
by
刘乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,转inp接口增加水泵组件
parent
8db624db
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
255 additions
and
63 deletions
+255
-63
.gitignore
.gitignore
+8
-0
CivHydrCalc.cpp
pandaAnalysis/CivHydrCalc.cpp
+68
-27
CivHydrCalc.h
pandaAnalysis/CivHydrCalc.h
+2
-0
CivDbConnection.cpp
pandaDbManager/CivDbConnection.cpp
+90
-28
CivDbConnection.h
pandaDbManager/CivDbConnection.h
+27
-1
CivTypes.h
pandaDbManager/CivTypes.h
+60
-7
水力模型产品规划V1.0.xmind
建模文档/水力模型产品规划V1.0.xmind
+0
-0
No files found.
.gitignore
View file @
a818b0dd
...
...
@@ -8,3 +8,11 @@ pandaDbManager/x64/
/pandaHydrDemo/obj/Release
/pandaHydrDemo/bin/Debug
/EPNAET2/Release
.suo
.vs/hydraulicModel/v16/Browse.VC.db
.vs/hydraulicModel/v16/Browse.VC.db-shm
.vs/hydraulicModel/v16/Browse.VC.opendb
.vs/hydraulicModel/v16/Solution.VC.db
.vs/hydraulicModel/v16/Solution.VC.db-shm
.vs/hydraulicModel/v16/Solution.VC.db-wal
pandaAnalysis/CivHydrCalc.cpp
View file @
a818b0dd
...
...
@@ -99,29 +99,18 @@ bool CivHydrCalc::exportInp(char* fileName)
Tables
tables
=
mDbConn
->
getTables
(
mNetname
);
//2,解析管网组件
// 解析管网组件顺序: 管线放最后
CivInp
civInp
(
CivInp
::
HOURS
);
int
total
=
tables
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
std
::
string
table
=
tables
[
i
];
assemble
(
table
,
civInp
);
if
(
"管线"
==
table
)
continue
;
assemble
(
table
,
civInp
);
}
/*
UNITS LPS
TRIALS 40
ACCURACY 0.001
EMITTER EXPONENT 0.5
DAMPLIMIT 0
MAXCHECK 10
CHECKFREQ 2
SPECIFIC GRAVITY 0.998
HEADLOSS H-W
TOLERANCE 0.0166666666666667
QUALITY AGE
*/
assemble
(
"管线"
,
civInp
);
// 初始化选择
Options
options
;
options
.
units
=
Options
::
UNITS
::
LPS
;
...
...
@@ -154,8 +143,7 @@ QUALITY AGE
void
CivHydrCalc
::
assemble
(
const
std
::
string
&
table
,
CivInp
&
inp
)
{
std
::
string
utf8Table
=
CivCommonUtils
::
string_To_UTF8
(
table
);
Componets
comps
=
mDbConn
->
getComponets
(
utf8Table
);
// 根据组建类型解析字段
if
(
PIPELINE
==
table
)
...
...
@@ -163,12 +151,21 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
// 管线
//;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
// 必备参数
Componets
comps
=
mDbConn
->
getComponets
(
table
);
PipeFields
pipes
;
Civitems
items
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
// 过滤掉与阀门和水泵连接的管线
Str
number
=
comp
.
find
(
"编号"
)
->
second
;
FiledFilter
filter
=
mDbConn
->
getFilter
();
std
::
set
<
Str
>
lineFilter
=
filter
.
find
(
"管线"
)
->
second
;
if
(
lineFilter
.
count
(
number
)
>
0
)
continue
;
Str
id
=
comp
.
find
(
pipes
.
ID
)
->
second
;
Str
startNode
=
comp
.
find
(
pipes
.
Node1
)
->
second
;
Str
endNode
=
comp
.
find
(
pipes
.
Node2
)
->
second
;
...
...
@@ -195,6 +192,7 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
}
else
if
(
PIPENODE
==
table
)
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
// 节点参数
// ;ID Elev Demand Pattern
// 坐标
...
...
@@ -236,6 +234,7 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
}
else
if
(
RESIVOIR
==
table
)
// 水源
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
//;ID Head Pattern
Civitems
coordItems
;
Civitems
resirvoirItems
;
...
...
@@ -278,12 +277,58 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
else
if
(
PUMP
==
table
)
// 水泵
{
//;ID Node1 Node2 Parameters
Componets
comps
=
mDbConn
->
getLikelyPipes
(
table
);
PumpFields
fields
;
Civitems
pumpItems
;
int
total
=
comps
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
comp
=
comps
[
i
];
Str
id
=
comp
.
find
(
fields
.
ID
)
->
second
;
Str
node1
=
comp
.
find
(
fields
.
node1
)
->
second
;
Str
node2
=
comp
.
find
(
fields
.
node2
)
->
second
;
std
::
vector
<
Str
>
vec
;
Str
head
=
comp
.
find
(
fields
.
head
)
->
second
;
if
(
!
head
.
empty
())
vec
.
push_back
(
fields
.
head
+
" "
+
head
);
Str
power
=
comp
.
find
(
fields
.
power
)
->
second
;
if
(
!
power
.
empty
())
vec
.
push_back
(
fields
.
power
+
" "
+
power
);
Str
pattern
=
comp
.
find
(
fields
.
pattern
)
->
second
;
if
(
!
pattern
.
empty
())
vec
.
push_back
(
fields
.
pattern
+
" "
+
pattern
);
Str
speed
=
comp
.
find
(
fields
.
speed
)
->
second
;
if
(
!
speed
.
empty
())
vec
.
push_back
(
fields
.
speed
+
" "
+
speed
);
// 水池数据
CivItem
tankNode
;
tankNode
.
push_back
(
id
);
tankNode
.
push_back
(
node1
);
tankNode
.
push_back
(
node2
);
// 构建参数
char
param
[
128
]
=
" "
;
int
total
=
vec
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
strcat_s
(
param
,
vec
[
i
].
c_str
());
}
tankNode
.
push_back
(
param
);
pumpItems
.
push_back
(
tankNode
);
}
inp
.
writeComponet
(
pumpItems
,
_PUMPS
);
}
else
if
(
TANK
==
table
)
// 水池
{
Componets
comps
=
mDbConn
->
getComponets
(
table
);
// ; ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
TanksFields
tkfFileds
;
Civitems
nodeCoordItems
;
Civitems
tankItems
;
int
total
=
comps
.
size
();
...
...
@@ -298,8 +343,7 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
Str
diametor
=
comp
.
find
(
tkfFileds
.
Diameter
)
->
second
;
Str
minVol
=
comp
.
find
(
tkfFileds
.
MinVol
)
->
second
;
//Str volCurve = comp.find(tkfFileds.VolCurve)->second;
Str
x_coord
=
comp
.
find
(
tkfFileds
.
X_Coord
)
->
second
;
Str
y_coord
=
comp
.
find
(
tkfFileds
.
Y_Coord
)
->
second
;
...
...
@@ -312,8 +356,7 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
tankNode
.
push_back
(
maxLevel
);
tankNode
.
push_back
(
diametor
);
tankNode
.
push_back
(
minVol
);
// tankNode.push_back(volCurve);
tankItems
.
push_back
(
tankNode
);
// 2, 节点坐标
...
...
@@ -322,10 +365,8 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
nodeCoordItem
.
push_back
(
x_coord
);
nodeCoordItem
.
push_back
(
y_coord
);
nodeCoordItems
.
push_back
(
nodeCoordItem
);
nodeCoordItems
.
push_back
(
nodeCoordItem
);
}
inp
.
writeComponet
(
nodeCoordItems
,
_COORDS
);
inp
.
writeComponet
(
tankItems
,
_TANKS
);
}
...
...
pandaAnalysis/CivHydrCalc.h
View file @
a818b0dd
#pragma once
#include<string>
#include<set>
#include "CivInp.h"
#define DLLEXPORT __declspec(dllexport)
class
CivDbConnection
;
/**
* 水力计算类
*/
...
...
pandaDbManager/CivDbConnection.cpp
View file @
a818b0dd
...
...
@@ -183,16 +183,23 @@ Componets CivDbConnection::getComponets(StrQuote tableName) const
return
Nodes
();
std
::
string
sql
=
"select * from public.
\"
"
+
tableName
+
"
\"
"
;
PGresult
*
result
=
PQexec
(
mConn
,
sql
.
c_str
());
std
::
string
utf8Str
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
PGresult
*
result
=
PQexec
(
mConn
,
utf8Str
.
c_str
());
if
(
result
==
NULL
)
{
return
Nodes
();
}
// rows count
Componets
nodes
;
// 取数据到容器中
getData
(
result
,
nodes
);
PQclear
(
result
);
return
nodes
;
}
void
CivDbConnection
::
getData
(
PGresult
*
result
,
Componets
&
comp
)
const
{
int
rows
=
PQntuples
(
result
);
int
columns
=
PQnfields
(
result
);
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
...
...
@@ -208,55 +215,110 @@ Componets CivDbConnection::getComponets(StrQuote tableName) const
node
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
fieldStr
,
itemStr
));
}
nodes
.
push_back
(
node
);
comp
.
push_back
(
node
);
}
PQclear
(
result
);
return
nodes
;
}
Componets
CivDbConnection
::
getLi
kelyPipes
(
StrQuote
tableNam
e
)
const
Componets
CivDbConnection
::
getLi
neByCode
(
StrQuote
table
,
StrQuote
cod
e
)
const
{
if
(
!
isValid
())
return
Nodes
();
// 查询点数据
std
::
string
sql
=
"select * from public.
\"
"
+
tableName
+
"
\"
"
;
PGresult
*
result
=
PQexec
(
mConn
,
sql
.
c_str
());
char
sql
[
125
]
=
"select * from public.
\"
"
;
strcat_s
(
sql
,
table
.
c_str
());
strcat_s
(
sql
,
"where from_code = "
);
strcat_s
(
sql
,
code
.
c_str
());
strcat_s
(
sql
,
"or to_code="
);
strcat_s
(
sql
,
code
.
c_str
());
std
::
string
utfStr
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
PGresult
*
result
=
PQexec
(
mConn
,
utfStr
.
c_str
());
if
(
result
==
NULL
)
{
return
Nodes
();
}
// rows count
Componets
componets
;
getData
(
result
,
componets
);
PQclear
(
result
);
return
componets
;
}
Componets
CivDbConnection
::
getLikelyPipes
(
StrQuote
tableName
)
{
if
(
!
isValid
())
return
Componets
();
// 查询点数据
char
sql
[
256
]
=
"select * from
\"
"
;
strcat_s
(
sql
,
tableName
.
c_str
());
strcat_s
(
sql
,
"
\"
"
);
std
::
string
utfStr
=
CivCommonUtils
::
string_To_UTF8
(
sql
);
PGresult
*
result
=
PQexec
(
mConn
,
utfStr
.
c_str
());
if
(
result
==
NULL
)
{
return
Componets
();
}
Componets
nodes
;
std
::
vector
<
std
::
string
>
codes
;
int
rows
=
PQntuples
(
result
);
int
columns
=
PQnfields
(
result
);
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
getData
(
result
,
nodes
);
PQclear
(
result
);
// 查询线表
if
(
nodes
.
size
()
<=
0
)
return
Componets
();
// 根据点数据查询起点和终点,管径
int
total
=
nodes
.
size
();
for
(
int
i
=
0
;
i
<
total
;
i
++
)
{
Componet
node
;
for
(
int
j
=
0
;
j
<
columns
;
j
++
)
Componet
componet
=
nodes
[
i
];
Str
code
=
componet
.
find
(
"code"
)
->
second
;
Componets
lines
=
getLineByCode
(
"管线"
,
code
);
int
lTotal
=
lines
.
size
();
for
(
int
j
=
0
;
j
<
lTotal
;
j
++
)
{
char
*
item
=
PQgetvalue
(
result
,
i
,
j
);
char
*
fieldName
=
PQfname
(
result
,
j
);
// 获取列表字段名
if
(
"code"
==
fieldName
)
Componet
lin
=
lines
[
j
];
Str
from_code
=
lin
.
find
(
"from_code"
)
->
second
;
Str
to_code
=
lin
.
find
(
"to_code"
)
->
second
;
if
(
from_code
==
code
)
{
Str
lastPointNo
=
lin
.
find
(
"上点号"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"上点号"
,
lastPointNo
));
}
else
if
(
to_code
==
code
)
{
codes
.
push_back
(
fieldName
);
Str
pointNo
=
lin
.
find
(
"本点号"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"本点号"
,
pointNo
));
}
std
::
string
itemStr
=
CivCommonUtils
::
UTF8_To_string
(
item
)
;
std
::
string
fieldStr
=
CivCommonUtils
::
UTF8_To_string
(
fieldName
);
Str
diameter
=
lin
.
find
(
"管径"
)
->
second
;
componet
.
insert
(
std
::
pair
<
Str
,
Str
>
(
"管径"
,
diameter
));
node
.
insert
(
std
::
pair
<
std
::
string
,
std
::
string
>
(
fieldStr
,
itemStr
));
Str
number
=
lin
.
find
(
"编号"
)
->
second
;
addFilter
(
"管线"
,
number
);
}
nodes
.
push_back
(
node
)
;
nodes
[
i
]
=
componet
;
}
return
nodes
;
}
PQclear
(
result
);
void
CivDbConnection
::
addFilter
(
Str
type
,
Str
number
)
{
mFilter
[
type
].
insert
(
number
);
}
std
::
string
sql2
=
"select * from public.
\"
管线
\"
"
;
return
nodes
;
FiledFilter
CivDbConnection
::
getFilter
()
const
{
return
mFilter
;
}
bool
CivDbConnection
::
createTable
(
StrQuote
tableName
,
StrQuote
schema
)
...
...
pandaDbManager/CivDbConnection.h
View file @
a818b0dd
#pragma once
#include "CivTypes.h"
#include <vector>
#include <set>
#include <libpq-fe.h>
#define DLLEXPORT __declspec(dllexport)
// 字段过滤
#define FiledFilter std::map<Str,std::set<Str>>
class
CivDbConnection
;
/**
...
...
@@ -32,7 +35,8 @@ public:
*@brief 水泵,阀门 (节点转换为管线)
*@tableName: 组件表
*/
Componets
getLikelyPipes
(
StrQuote
tableName
)
const
;
Componets
getLikelyPipes
(
StrQuote
tableName
);
/**
*@brief 创建表格
...
...
@@ -53,9 +57,28 @@ public:
bool
open
();
void
close
();
void
addFilter
(
Str
type
,
Str
number
);
FiledFilter
getFilter
()
const
;
private
:
bool
isValid
()
const
;
/**
*@brief 查询与点连接的线
*@table: 线表
*@code:
*/
Componets
getLineByCode
(
StrQuote
table
,
StrQuote
code
)
const
;
/**
*@brief 从查询集取出数据
*@result: 查询结果集
*@comp: 数据容器
*/
void
getData
(
PGresult
*
result
,
Componets
&
comp
)
const
;
private
:
PGconn
*
mConn
;
bool
mIsOpen
=
false
;
...
...
@@ -65,4 +88,6 @@ private:
char
mLinkParam
[
256
];
char
mNodeParam
[
256
];
FiledFilter
mFilter
;
// 表名:对应的编号
};
\ No newline at end of file
pandaDbManager/CivTypes.h
View file @
a818b0dd
...
...
@@ -31,8 +31,37 @@ enum SectType {
_REACTIONS
,
_MIXING
,
_REPORT
,
_TIMES
,
_OPTIONS
,
_COORDS
,
_VERTICES
,
_LABELS
,
_BACKDROP
,
_TAGS
,
_END
};
// 数据库与inp文件所需字段的映射
// 阀门类型
enum
ValvesType
{
PRV
,
/* 减压阀 */
PSV
,
/* 稳压阀 */
PBV
,
/* 压力制动阀 */
FCV
,
/* 流量控制阀 */
TCV
,
/*节流控制阀 */
GPV
/* 常规阀门 */
};
// 阀门数据库的表
struct
ValvesTables
{
Str
PRV
=
"减压阀"
;
Str
PSV
=
"稳压阀"
;
Str
PBV
=
"压力制动阀"
;
Str
FCV
=
"流量控制阀"
;
Str
TCV
=
"节流控制阀"
;
Str
GPV
=
"常规阀门"
;
};
// 水泵参数
enum
PumpParameter
{
POWER
,
// 定速能量水泵的功率数值,hp(kW)
HEAD
,
// 描述了水泵扬程与流量关系的曲线ID
SPEED
,
// 相对速度设置(额定速度为1.0,0意味着水泵关闭)
PATTERN
// 时间模式的ID,描述了速度设置怎样随时间变化
};
// REACTIONS
// 定义对应于管网中与化学成分反应的参数。
...
...
@@ -42,7 +71,6 @@ struct Reactions {
// [REPORT]
// 描述模拟生成的输出报表内容。
// 描述模拟生成的输出报表内容
struct
Report
{
Str
PAGESIZES
;
Str
NODES
;
// NONE/ALL/node1 node2 ...
...
...
@@ -52,12 +80,37 @@ struct Report {
Str
ENERGY
;
};
/*
*/
// pump
/****************************** 管网物理组件,参数字段****************************************************/
// 水泵
//[PUMPS]
//; ID Node1 Node2 Parameters
struct
PumpFields
{
/**
* POWER——定速能量水泵的功率数值,hp(kW)
* HEAD——描述了水泵扬程与流量关系的曲线ID
* SPEED——相对速度设置(额定速度为1.0,0意味着水泵关闭)
* PATTERN——时间模式的ID,描述了速度设置怎样随时间变化
*/
Str
ID
=
"编号"
;
Str
node1
=
"本点号"
;
// 与水泵连接的输入段本点号
Str
node2
=
"上点号"
;
// 水泵连接的下游管段
Str
power
=
"功率"
;
// 定速能量水泵的功率数值,hp(kW)
Str
head
=
"扬程曲线"
;
Str
speed
=
"速度"
;
// 相对速度设置(额定速度为1.0,0意味着水泵关闭)
Str
pattern
=
"水泵曲线"
;
// 时间模式的ID,描述了速度设置怎样随时间变化
};
//[VALVES]
//; ID Node1 Node2 Diameter Type Setting MinorLoss
struct
ValvesFields
{
Str
ID
=
"编号"
;
// 水泵表的本点号
Str
node1
=
"上点号"
;
// 与水泵连接的输入段本点号
Str
node2
=
"本点号"
;
// 水泵连接的下游管段
Str
Diameter
=
"直径"
;
// 直径
Str
type
=
"类型"
;
// 阀门类型
Str
setting
=
" 参数设置"
;
// 不同阀门对应不同参数
Str
minorLoss
=
"局部损失系数"
;
};
// 水库字段
...
...
@@ -83,8 +136,6 @@ struct PipeFields {
Str
Status
=
Str
(
"状态"
);
};
// 节点
struct
JunctionsFields
{
Str
ID
=
"本点号"
;
...
...
@@ -111,6 +162,8 @@ struct TanksFields {
Str
Y_Coord
=
"纵坐标"
;
};
/********************************end **************************************************/
// 水力计算管点结果缓存
struct
NodeResultItem
{
...
...
建模文档/水力模型产品规划V1.0.xmind
View file @
a818b0dd
No preview for this file type
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