Skip to content
Snippets Groups Projects
Commit 3cdccb21 authored by Steinmann's avatar Steinmann
Browse files

added expression for all pumps in graph.nodes

parent ba6abf31
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
Formulieren der Optimierungsgleichung in pymoo
%% Cell type:markdown id: tags:
Es gilt die Kontinuitätsgleichung:
$ \Sigma \dot{V}_k(t) = O$
und die aus der Topologie resultierende Inzidenzmatrix $A_i$
sowie die aus dem Pumpenkennfeld folgende Beziehung:
$\Delta p=\alpha_1 Q^2+\alpha_2 Q n+\alpha_3 n^2 : n \in \{0\} \cup [n_{\mathrm{min}},n_{\mathrm{max}}] $
$P=\beta_1 Q^3+\beta_2 Q^2 n+\beta_3 Q n^2+\beta_4n^3+\beta_5$
und die beziehung für den Druckverlust an den Ventilen:
$\Delta p_{\mathrm{loss}} = - \frac{1}{2} \varrho \zeta \left(\frac{Q}{A}\right)^2 = -l Q^2 :l\in [l_{\mathrm{min}}:\infty )$
nun soll für einen Gegebenen Volumenstrom $Q$ eine Optimale Drehzahl bestimmt werden, welche die Pumpenlesitung minimiert.
$$
\begin{align*}
\mathrm{min} \sum_{p \in \mathcal{P}} Po_{p} \\
Q_p = Q_{\mathrm{target}, i} \\
Q_p
, n\epsilon [n_{min},n_{max}] \\
\overrightarrow{n} = (1,n,n^2,n^3)^T \\
min P = A \overrightarrow{n} \\
-n\leq n_{min} \\
n\leq n_{max}
\end{align*}
$$
Förderhöhe als constraint continuität fomulieren pro strang
%% Cell type:code id: tags:
``` python
!pip install pyomo
```
%% Output
Defaulting to user installation because normal site-packages is not writeable
Collecting pyomo
Downloading Pyomo-6.8.2-py3-none-any.whl.metadata (8.0 kB)
Collecting ply (from pyomo)
Downloading ply-3.11-py2.py3-none-any.whl.metadata (844 bytes)
Downloading Pyomo-6.8.2-py3-none-any.whl (3.7 MB)
---------------------------------------- 0.0/3.7 MB ? eta -:--:--
---------------------------------------- 3.7/3.7 MB 73.6 MB/s eta 0:00:00
Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
Installing collected packages: ply, pyomo
Successfully installed ply-3.11 pyomo-6.8.2
WARNING: The script pyomo.exe is installed in 'C:\Users\steinmann\AppData\Roaming\Python\Python312\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: C:\Program Files\Python312\python.exe -m pip install --upgrade pip
%% Cell type:code id: tags:
``` python
#Pump-Powercurve and Pump-Hightcurve
import regression_own
(LR_H,LR_P)=regression_own.regress_pump()
print(LR_H,LR_P)
```
%% Output
R^20.9998289611292903
R^20.9994449560888792
LinearRegression(fit_intercept=False) LinearRegression()
%% Cell type:code id: tags:
``` python
#Graph constroctor
import multiDiGraph as gr
nodes =['source','pump1','pump2','valveA','valveB','valveC']
graph = gr.construct_graph('source',('source','pump1'),('pump1','valveC'),
('pump1','pump2'),('pump2','valveA'),('pump2','valveB'),('valveA','source'),('valveB','source'),('valveC','source'))
```
%% Output
%% Cell type:code id: tags:
``` python
import networkx as nx
Mtrx= nx.incidence_matrix(graph,nodes)
print(Mtrx)
```
%% Output
<Compressed Sparse Column sparse array of dtype 'float64'
with 16 stored elements and shape (6, 8)>
Coords Values
(0, 0) 1.0
(1, 0) 1.0
(1, 1) 1.0
(5, 1) 1.0
(1, 2) 1.0
(2, 2) 1.0
(0, 3) 1.0
(5, 3) 1.0
(2, 4) 1.0
(3, 4) 1.0
(2, 5) 1.0
(4, 5) 1.0
(0, 6) 1.0
(3, 6) 1.0
(0, 7) 1.0
(4, 7) 1.0
%% Cell type:markdown id: tags:
Durchfluss aus Incidenzmatrix beerechnen
Zeilen = knoten
Spalten = kanten
Summe pro knoten = 0
%% Cell type:code id: tags:
``` python
#defining abstract modell for given Network
import pyomo.environ as pyo
import numpy as np
from sklearn.linear_model import LinearRegression
modell = pyo.AbstractModel()
#notwendige Mengen zur Berechnung der Constraints
modell.nodes = pyo.Set()
modell.pumps = pyo.Set()
modell.valves = pyo.Set()
#Parameter zur berechnung
modell.Q = pyo.Param(modell.nodes)
modell.n = pyo.Param(modell.pumps)
#Optimierungsvariable
modell.P = pyo.Var(modell.pumps)
#constraints
def PumpPower(modell):
return sum(np.dot(np.array([modell.Q[i]**3,(modell.Q[i]**2)*modell.n[i],modell.Q[i]*modell.n[i]**2,modell.n[i]**3]),LR_P.coef_) for i in modell.pumps)
modell.Power_Constraint = pyo.Objective(rule=PumpPower,sense=min)
def continuityRule(modell,node):
return sum(modell.Q[i] for i in graph.predecessors(node))==sum(modell.Q[i] for i in graph.successors(node))
modell.pump_constraint = pyo.Objective(modell.nodes,rule=continuityRule)
TestData={None:{'G':{None:graph},'LR':{None:LR_H}}}
#[node for node in graph.nodes if 'pump' in node]
#Optimierungsgleichung
#instance=modell.create_instance(graph,LR_H)
#instance.obj = pyo.Objective(expr=sum(PumpPower(modell.Q[i],modell.n[i],LR_P) for i in modell.pumps),sense=min)
```
%% Cell type:markdown id: tags:
Frage: gibt es nur eine Lösung für Drehzahl?
Bsp. Optimierung nach Dezentraler Pumpe um modell zu prüfen
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment