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
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Formulieren der Optimierungsgleichung in pymoo Formulieren der Optimierungsgleichung in pymoo
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Es gilt die Kontinuitätsgleichung: Es gilt die Kontinuitätsgleichung:
$ \Sigma \dot{V}_k(t) = O$ $ \Sigma \dot{V}_k(t) = O$
und die aus der Topologie resultierende Inzidenzmatrix $A_i$ und die aus der Topologie resultierende Inzidenzmatrix $A_i$
sowie die aus dem Pumpenkennfeld folgende Beziehung: 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}}] $ $\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$ $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: 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 )$ $\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. nun soll für einen Gegebenen Volumenstrom $Q$ eine Optimale Drehzahl bestimmt werden, welche die Pumpenlesitung minimiert.
$$ $$
\begin{align*} \begin{align*}
\mathrm{min} \sum_{p \in \mathcal{P}} Po_{p} \\ \mathrm{min} \sum_{p \in \mathcal{P}} Po_{p} \\
Q_p = Q_{\mathrm{target}, i} \\ Q_p = Q_{\mathrm{target}, i} \\
Q_p Q_p
, n\epsilon [n_{min},n_{max}] \\ , n\epsilon [n_{min},n_{max}] \\
\overrightarrow{n} = (1,n,n^2,n^3)^T \\ \overrightarrow{n} = (1,n,n^2,n^3)^T \\
min P = A \overrightarrow{n} \\ min P = A \overrightarrow{n} \\
-n\leq n_{min} \\ -n\leq n_{min} \\
n\leq n_{max} n\leq n_{max}
\end{align*} \end{align*}
$$ $$
Förderhöhe als constraint continuität fomulieren pro strang Förderhöhe als constraint continuität fomulieren pro strang
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
!pip install pyomo !pip install pyomo
``` ```
%% Output %% Output
Defaulting to user installation because normal site-packages is not writeable Defaulting to user installation because normal site-packages is not writeable
Collecting pyomo Collecting pyomo
Downloading Pyomo-6.8.2-py3-none-any.whl.metadata (8.0 kB) Downloading Pyomo-6.8.2-py3-none-any.whl.metadata (8.0 kB)
Collecting ply (from pyomo) Collecting ply (from pyomo)
Downloading ply-3.11-py2.py3-none-any.whl.metadata (844 bytes) Downloading ply-3.11-py2.py3-none-any.whl.metadata (844 bytes)
Downloading Pyomo-6.8.2-py3-none-any.whl (3.7 MB) Downloading Pyomo-6.8.2-py3-none-any.whl (3.7 MB)
---------------------------------------- 0.0/3.7 MB ? eta -:--:-- ---------------------------------------- 0.0/3.7 MB ? eta -:--:--
---------------------------------------- 3.7/3.7 MB 73.6 MB/s eta 0:00:00 ---------------------------------------- 3.7/3.7 MB 73.6 MB/s eta 0:00:00
Downloading ply-3.11-py2.py3-none-any.whl (49 kB) Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
Installing collected packages: ply, pyomo Installing collected packages: ply, pyomo
Successfully installed ply-3.11 pyomo-6.8.2 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. 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. 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] 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 [notice] To update, run: C:\Program Files\Python312\python.exe -m pip install --upgrade pip
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#Pump-Powercurve and Pump-Hightcurve #Pump-Powercurve and Pump-Hightcurve
import regression_own import regression_own
(LR_H,LR_P)=regression_own.regress_pump() (LR_H,LR_P)=regression_own.regress_pump()
print(LR_H,LR_P) print(LR_H,LR_P)
``` ```
%% Output %% Output
R^20.9998289611292903 R^20.9998289611292903
R^20.9994449560888792 R^20.9994449560888792
LinearRegression(fit_intercept=False) LinearRegression() LinearRegression(fit_intercept=False) LinearRegression()
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#Graph constroctor #Graph constroctor
import multiDiGraph as gr import multiDiGraph as gr
nodes =['source','pump1','pump2','valveA','valveB','valveC'] nodes =['source','pump1','pump2','valveA','valveB','valveC']
graph = gr.construct_graph('source',('source','pump1'),('pump1','valveC'), graph = gr.construct_graph('source',('source','pump1'),('pump1','valveC'),
('pump1','pump2'),('pump2','valveA'),('pump2','valveB'),('valveA','source'),('valveB','source'),('valveC','source')) ('pump1','pump2'),('pump2','valveA'),('pump2','valveB'),('valveA','source'),('valveB','source'),('valveC','source'))
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import networkx as nx import networkx as nx
Mtrx= nx.incidence_matrix(graph,nodes) Mtrx= nx.incidence_matrix(graph,nodes)
print(Mtrx) print(Mtrx)
``` ```
%% Output %% Output
<Compressed Sparse Column sparse array of dtype 'float64' <Compressed Sparse Column sparse array of dtype 'float64'
with 16 stored elements and shape (6, 8)> with 16 stored elements and shape (6, 8)>
Coords Values Coords Values
(0, 0) 1.0 (0, 0) 1.0
(1, 0) 1.0 (1, 0) 1.0
(1, 1) 1.0 (1, 1) 1.0
(5, 1) 1.0 (5, 1) 1.0
(1, 2) 1.0 (1, 2) 1.0
(2, 2) 1.0 (2, 2) 1.0
(0, 3) 1.0 (0, 3) 1.0
(5, 3) 1.0 (5, 3) 1.0
(2, 4) 1.0 (2, 4) 1.0
(3, 4) 1.0 (3, 4) 1.0
(2, 5) 1.0 (2, 5) 1.0
(4, 5) 1.0 (4, 5) 1.0
(0, 6) 1.0 (0, 6) 1.0
(3, 6) 1.0 (3, 6) 1.0
(0, 7) 1.0 (0, 7) 1.0
(4, 7) 1.0 (4, 7) 1.0
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Durchfluss aus Incidenzmatrix beerechnen Durchfluss aus Incidenzmatrix beerechnen
Zeilen = knoten Zeilen = knoten
Spalten = kanten Spalten = kanten
Summe pro knoten = 0 Summe pro knoten = 0
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#defining abstract modell for given Network #defining abstract modell for given Network
import pyomo.environ as pyo import pyomo.environ as pyo
import numpy as np import numpy as np
from sklearn.linear_model import LinearRegression from sklearn.linear_model import LinearRegression
modell = pyo.AbstractModel() modell = pyo.AbstractModel()
#notwendige Mengen zur Berechnung der Constraints #notwendige Mengen zur Berechnung der Constraints
modell.nodes = pyo.Set() modell.nodes = pyo.Set()
modell.pumps = pyo.Set() modell.pumps = pyo.Set()
modell.valves = pyo.Set() modell.valves = pyo.Set()
#Parameter zur berechnung #Parameter zur berechnung
modell.Q = pyo.Param(modell.nodes) modell.Q = pyo.Param(modell.nodes)
modell.n = pyo.Param(modell.pumps) modell.n = pyo.Param(modell.pumps)
#Optimierungsvariable #Optimierungsvariable
modell.P = pyo.Var(modell.pumps) modell.P = pyo.Var(modell.pumps)
#constraints #constraints
def PumpPower(modell): 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) 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) modell.Power_Constraint = pyo.Objective(rule=PumpPower,sense=min)
def continuityRule(modell,node): 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)) 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) modell.pump_constraint = pyo.Objective(modell.nodes,rule=continuityRule)
TestData={None:{'G':{None:graph},'LR':{None:LR_H}}} TestData={None:{'G':{None:graph},'LR':{None:LR_H}}}
#[node for node in graph.nodes if 'pump' in node]
#Optimierungsgleichung #Optimierungsgleichung
#instance=modell.create_instance(graph,LR_H) #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) #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: %% Cell type:markdown id: tags:
Frage: gibt es nur eine Lösung für Drehzahl? Frage: gibt es nur eine Lösung für Drehzahl?
Bsp. Optimierung nach Dezentraler Pumpe um modell zu prüfen 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