def __call__(self, t, **kwargs): pL = self.pL_leftPress pR = self.pR_rightPress q = self.q_flowThrough px = pR - pL io = self.io_func(t) return cond_assign(io > 0.0, px, q)
def __call__(self, t, **kwargs): pL = self.pL_leftPress dpL = self.dpL_leftPress pR = self.pR_rightPress dpR = self.dpR_rightPress q = self.q_flowThrough dq = self.dq_flowThrough io = self.io_func(t) by_io = minimum(self.by_io_func(t), io) ''' get target values ''' bar_pR = self.target_upper_pR(t) ubar_pL = minimum(bar_pR, self.target_lower_pL(t)) bar_ubar_q = self.target_q(t) ''' define conditions and target values ''' press_diff = pR - pL # target value: flow # cond = cond_assign(q > bar_ubar_q, press_diff, bar_ubar_q - q) cond = bar_ubar_q - q # target values: left and right pressure max_term = maximum(pR - bar_pR, ubar_pL - pL, pL - pR) cond = cond_assign( logical_or(logical_or(pR >= bar_pR, pL <= ubar_pL), pL >= pR), cond_assign(q <= 0.0, q, max_term), cond) # cond = cond_assign(q <= 0.0, cond_assign(logical_or(pR > bar_pR, pL < ubar_pL), q, cond), cond) # cond = cond_assign(pL >= pR, cond_assign(q <= 0.0, q, press_diff), cond) # mode determination cond = cond_assign(by_io > 0.01, press_diff, cond) cond = cond_assign(io < 0.01, q, cond) ''' return statement ''' return cond
def __call__(self, t, **kwargs): pL = self.pL_leftPress dpL = self.dpL_leftPress pR = self.pR_rightPress dpR = self.dpR_rightPress q = self.q_flowThrough dq = self.dq_flowThrough io = self.io_func(t) by_io = minimum(self.by_io_func(t), io) ''' get target values ''' bar_pR = self.target_upper_pR(t) ubar_pR = minimum(bar_pR, self.target_lower_pR(t)) bar_pL = maximum(ubar_pR, self.target_upper_pL(t)) ubar_pL = minimum(bar_pL, self.target_lower_pL(t)) bar_ubar_q = maximum(0.0, self.target_q(t)) ''' define conditions and target values ''' px = 100.0 * (pL - pR) - 0.001 cond = maximum(0.0, minimum(maximum(bar_ubar_q, 1000.0*(ubar_pR - pR), 1000.0*(pL - bar_pL)), 1000.0*(bar_pR - pR), 1000.0*(pL - ubar_pL), px)) - q # mode determination cond = cond_assign(by_io > 0.01, pR - pL, cond) # not needed due to shortpipe condition cond = cond_assign(io < 0.01, q, cond) ''' return statement ''' return cond
def __call__(self, t, **kwargs): pL = self.pL_leftPress dpL = self.dpL_leftPress pR = self.pR_rightPress dpR = self.dpR_rightPress q = self.q_flowThrough dq = self.dq_flowThrough io = self.io_func(t) by_io = minimum(self.by_io_func(t), io) ''' get target values ''' bar_pR = self.target_upper_pR(t) ubar_pL = minimum(bar_pR, self.target_lower_pL(t)) bar_ubar_q = self.target_q(t) ''' define conditions and target values ''' cond = bar_ubar_q - q # target flow cond = minimum(cond, pL - ubar_pL, bar_pR - pR) # target pressures cond = maximum(cond, 1000.0*(pL - pR), -1000.0*q) # principal necessities of compressors ''' mode determination ''' cond = cond_assign(by_io > 0.01, pR - pL, cond) cond = cond_assign(io < 0.01, q, cond) # cond = cond - 1.0e-3*(dpR - dpL + dq) # may or may not improve solvabillity of this element ''' return statement ''' return cond
def __call__(self, t, **kwargs): pL = self.pL_leftPress dpL = self.dpL_leftPress pR = self.pR_rightPress dpR = self.dpR_rightPress q = self.q_flowThrough dq = self.dq_flowThrough io = self.io_func(t) by_io = minimum(self.by_io_func(t), io) ''' get target values ''' bar_pR = self.target_upper_pR(t) ubar_pR = minimum(bar_pR, self.target_lower_pR(t)) bar_pL = maximum(ubar_pR, self.target_upper_pL(t)) ubar_pL = minimum(bar_pL, self.target_lower_pL(t)) bar_ubar_q = maximum(0.0, self.target_q(t)) ''' define conditions and target values ''' # # target value driven modelling # press_diff = pL - pR # # # target value: flow # # cond = bar_ubar_q - q # cond = cond_assign(q < bar_ubar_q, # cond_assign(logical_and(pL >= pR, q >= 0.0), # minimum(bar_ubar_q - q, press_diff), # q), # cond_assign(logical_and(pL >= pR, q >= 0.0), # bar_ubar_q - q, # q)) # bar_ubar_q - q) # # # target values: left upper and right lower pressure # max_term = maximum(ubar_pR - pR, pL - bar_pL) # cond = cond_assign(logical_or(pR <= ubar_pR, pL >= bar_pL), # cond_assign(logical_and(pL >= pR, q >= 0.0), # max_term, # q), # cond_assign(pL >= pR, # cond, # q)) # # # target values: left lower and right upper pressure # max_term = maximum(pR - bar_pR, ubar_pL - pL, pR - pL) # cond = cond_assign(logical_or(pR >= bar_pR, pL <= ubar_pL), # cond_assign(pL >= pR, # cond_assign(q > 0.0, # max_term, # q), # q), # cond_assign(pL >= pR, # cond, # q)) # # # cond = min(cond, press_diff) # cond_assign(logical_or(q < 0.0, pR > pL), press_diff, cond) # # # cond = cond_assign(q <= 0.0, cond_assign(logical_or(pR > bar_pR, pL < ubar_pL), q, cond), cond) # # cond = cond_assign(logical_or(pR >= pL, q <= 0.0), cond_assign(pR >= pL, q, cond), cond) # # cond = cond_assign(bar_ubar_q <= 0.0, q, cond) cond = cond_assign(pL >= pR, minimum(bar_ubar_q - q, pL - pR), q) cond = cond_assign( logical_or(pR <= ubar_pR, pL >= bar_pL), cond_assign(q < bar_ubar_q, cond, maximum(ubar_pR - pR, pL - bar_pL)), cond) cond = cond_assign( logical_or(logical_or(pR >= bar_pR, pL <= ubar_pL), pL <= pR), cond_assign( logical_or(q <= bar_ubar_q, logical_or(pR <= ubar_pR, pL >= bar_pL)), maximum(pR - bar_pR, ubar_pL - pL, pR - pL), cond), cond) cond = cond_assign( q == 0.0, cond_assign( logical_or(logical_or(pL < ubar_pL, pR > bar_pR), pL < pR), q, cond), cond_assign(q < 0.0, q, cond)) # cond = minimum(bar_ubar_q - q, pL - pR) # # cond = cond_assign(logical_or(pR <= ubar_pR, pL >= bar_pL), # cond_assign(q < bar_ubar_q, # cond, # maximum(ubar_pR - pR, pL - bar_pL)), # cond) # # cond = cond_assign(logical_or(pR >= bar_pR, pL <= ubar_pL), # cond_assign(logical_or(q <= bar_ubar_q, logical_or(pR <= ubar_pR, pL >= bar_pL)), # maximum(pR - bar_pR, ubar_pL - pL), # cond), # cond) # mode determination cond = cond_assign(by_io > 0.01, pR - pL, cond) # not needed due to shortpipe condition cond = cond_assign(io < 0.01, q, cond) ''' return statement ''' return cond