Hello,
I want to create a Heat/GasLine object, similar to the electrical line. My current issue is to model the pressure loss.
The simplified pressure loss in pipes can be expressed (in case of turbulent flow and negligible changes in density):
delta_p = delta_p0*(m./m.0)^2 with delta_p0/m.0^2 = K
delta_p = K * m.^2
I already created a model using quadratic variables, but now also want to create a linear model using piece-wise linearisation.
Appended you find my quadratic code:
def pressure_relation(block):
for t in m.TIMESTEPS:
for n in group:
if O[n].slack is True:
self.pressure[O[n], t].value = 0
self.pressure[O[n], t].fix()
try:
lhs = m.flow[n, O[n], t]
rhs = 1/(n.conv_factor[t])*(
self.pressure[I[n], t] -
self.pressure[O[n], t])*(
self.pressure[I[n], t] -
self.pressure[O[n], t])
except:
raise ValueError("Error in constraint creation",
"of node {}".format(n.label))
block.pressure_flow.add((n, t), (lhs <= rhs))
block.pressure_flow.add((n, t), (lhs >= rhs))
block._equate_pressure_flows.add((n, t), (
m.flow[n, O[n], t] == m.flow[I[n], n, t]))
Has someone an idea how i can make rhs an piece-wise linear function?
I am glad for any feedback,
Philipp