def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # fluid balance: num_fl * 3 # mass flow: 3 # energy balance: 1 self.num_eq = self.num_nw_fluids * 3 + 3 + 1 # enthalpy hot side 1 outlet (if not subcooling): 1 if self.subcooling.val is False: self.num_eq += 1 # enthalpy cold side outlet (if not overheating): 1 if self.overheating.val is False: self.num_eq += 1 for var in [ self.Q, self.pr1, self.pr2, self.pr3, self.zeta1, self.zeta2, self.zeta3, ]: if var.is_set is True: self.num_eq += 1 self.jacobian = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.residual = np.zeros(self.num_eq) pos = self.num_nw_fluids * 3 self.jacobian[0:pos] = self.fluid_deriv() self.jacobian[pos:pos + 3] = self.mass_flow_deriv()
def comp_init(self, nw): component.comp_init(self, nw) self.fl_deriv = self.fluid_deriv() self.m_deriv = self.mass_flow_deriv() self.h_deriv = self.enthalpy_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # mass flow: 1 # pressure: number of inlets + number of outlets - 1 # fluid: number of outlets * number of fluid_set # enthalpy: number of outlets self.num_eq = self.num_i + self.num_o * (2 + self.num_nw_fluids) self.mat_deriv = np.zeros(( self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.zeros(self.num_eq) self.mat_deriv[0:1] = self.mass_flow_deriv() end = self.num_i + self.num_o self.mat_deriv[1:end] = self.pressure_deriv() start = end end = start + self.num_o * self.num_nw_fluids self.mat_deriv[start:end] = self.fluid_deriv() start = end end = start + self.num_o self.mat_deriv[start:end] = self.enthalpy_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # fluid: num_inter * num_nw_fluids # mass flow: num_inter # pressure: num_inter # enthalpy: num_inter self.num_eq = (self.num_nw_fluids + 3) * self.num_i self.mat_deriv = np.zeros( (self.num_eq, 2 * self.num_i, self.num_nw_vars)) self.vec_res = np.ones(self.num_eq) stop = self.num_nw_fluids * self.num_i self.mat_deriv[0:stop] = self.fluid_deriv() start = stop stop = start + self.num_i self.mat_deriv[start:stop] = self.inout_deriv(0) start = stop stop = start + self.num_i self.mat_deriv[start:stop] = self.inout_deriv(1) start = stop stop = start + self.num_i self.mat_deriv[start:stop] = self.inout_deriv(2)
def comp_init(self, nw): component.comp_init(self, nw) self.fl_deriv = self.fluid_deriv() self.m_deriv = self.mass_flow_deriv() self.p_deriv = self.pressure_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # retrieve always constant derivatives self.fl_deriv = self.fluid_deriv() self.m_deriv = self.inout_deriv(0) self.p_deriv = self.inout_deriv(1) self.h_deriv = self.inout_deriv(2)
def comp_init(self, nw): component.comp_init(self, nw) # all derivatives are constants self.mat_deriv = np.zeros((2, 2, 3 + self.num_fl)) # derivatives for pressure self.mat_deriv[0, 0, 1] = 1 self.mat_deriv[0, 1, 1] = -1 # derivatives for enthalpy self.mat_deriv[1, 0, 2] = 1 self.mat_deriv[1, 1, 2] = -1
def comp_init(self, nw): if not self.P.is_set: self.set_attr(P='var') msg = ('The power output of cogeneration units must be set! ' 'We are adding the power output of component ' + self.label + ' as custom variable of the system.') logging.info(msg) component.comp_init(self, nw) o2 = [ x for x in nw.fluids if x in [a.replace(' ', '') for a in CP.get_aliases('O2')] ] if len(o2) == 0: msg = ('Missing oxygen in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires oxygen in network fluids.') logging.error(msg) raise ValueError(msg) else: self.o2 = o2[0] h2o = [ x for x in nw.fluids if x in [a.replace(' ', '') for a in CP.get_aliases('H2O')] ] if len(h2o) == 0: msg = ('Missing water in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires water in network fluids.') logging.error(msg) raise ValueError(msg) else: self.h2o = h2o[0] h2 = [ x for x in nw.fluids if x in [a.replace(' ', '') for a in CP.get_aliases('H2')] ] if len(h2) == 0: msg = ('Missing hydrogen in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires hydrogen in network fluids.') logging.error(msg) raise ValueError(msg) else: self.h2 = h2[0] self.e0 = self.calc_e0()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # pressure: 1 # enthalpy: 1 self.num_eq = 2 self.mat_deriv = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.ones(self.num_eq) # derivatives for pressure self.mat_deriv[0, 0, 1] = 1 self.mat_deriv[0, 1, 1] = -1 # derivatives for enthalpy self.mat_deriv[1, 0, 2] = 1 self.mat_deriv[1, 1, 2] = -1
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # mass flow: 1 # pressure: number of inlets + number of outlets - 1 # fluid: number of fluids # enthalpy: 1 self.num_eq = self.num_i + self.num_o + self.num_nw_fluids + 1 self.mat_deriv = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.zeros(self.num_eq) self.mat_deriv[0:1] = self.mass_flow_deriv() end = self.num_i + self.num_o self.mat_deriv[1:end] = self.pressure_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # fluid balance: num_fl * 2 # mass flow: 1 # pressure: 3 # enthalpy: 1 # saturated liquid outlet: 1 # saturated gas outlet: 1 self.num_eq = self.num_nw_fluids * 2 + 7 self.mat_deriv = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.zeros(self.num_eq) pos = self.num_nw_fluids * 2 self.mat_deriv[0:pos] = self.fluid_deriv() self.mat_deriv[pos:pos + 1] = self.mass_flow_deriv() self.mat_deriv[pos + 1:pos + 4] = self.pressure_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # fluid balance: num_fl # mass flow: 1 # enthalpy: 1 self.num_eq = self.num_nw_fluids + 2 for var in [self.pr, self.zeta, self.dp_char]: if var.is_set is True: self.num_eq += 1 self.jacobian = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.residual = np.zeros(self.num_eq) pos = self.num_nw_fluids self.jacobian[0:pos] = self.fluid_deriv() self.jacobian[pos:pos + 1] = self.mass_flow_deriv() self.jacobian[pos + 1:pos + 2] = self.enthalpy_deriv()
def comp_init(self, nw): component.comp_init(self, nw) # number of mandatroy equations for # mass flow: 1 # pressure: number of inlets + number of outlets - 1 # the number of fluid and enthalpy equations is variable for a node! self.num_eq = 1 + self.num_i + self.num_o - 1 # number of fluid equations self.num_eq += self.num_nw_fluids * self.num_o # number of enthalpy equations self.num_eq += self.num_o self.mat_deriv = np.zeros( (self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.zeros(self.num_eq) self.mat_deriv[0:1] = self.mass_flow_deriv() self.mat_deriv[1:self.num_i + self.num_o] = self.pressure_deriv()
def comp_init(self, nw): if not self.P.is_set: self.set_attr(P='var') msg = ('The power output of cogeneration units must be set! ' 'We are adding the power output of component ' + self.label + ' as custom variable of the system.') logging.info(msg) component.comp_init(self, nw) o2 = [x for x in nw.fluids if x in [ a.replace(' ', '') for a in CP.get_aliases('O2')]] if len(o2) == 0: msg = ('Missing oxygen in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires oxygen in network fluids.') logging.error(msg) raise ValueError(msg) else: self.o2 = o2[0] h2o = [x for x in nw.fluids if x in [ a.replace(' ', '') for a in CP.get_aliases('H2O')]] if len(h2o) == 0: msg = ('Missing water in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires water in network fluids.') logging.error(msg) raise ValueError(msg) else: self.h2o = h2o[0] h2 = [x for x in nw.fluids if x in [ a.replace(' ', '') for a in CP.get_aliases('H2')]] if len(h2) == 0: msg = ('Missing hydrogen in network fluids, component ' + self.label + ' of type ' + self.component() + ' requires hydrogen in network fluids.') logging.error(msg) raise ValueError(msg) else: self.h2 = h2[0] self.e0 = self.calc_e0() # number of mandatroy equations for # cooling loop fluids: num_fl # fluid composition at reactor inlets/outlets: 3 * num_fl # mass flow balances: 3 # pressure: 2 # energy balance: 1 # reactor outlet temperatures: 1 self.num_eq = self.num_nw_fluids * 4 + 7 for var in [self.e, self.eta, self.eta_char, self.Q, self.pr_c, self.zeta]: if var.is_set is True: self.num_eq += 1 self.mat_deriv = np.zeros(( self.num_eq, self.num_i + self.num_o + self.num_vars, self.num_nw_vars)) self.vec_res = np.zeros(self.num_eq) pos = self.num_nw_fluids * 4 self.mat_deriv[0:pos] = self.fluid_deriv() self.mat_deriv[pos:pos + 3] = self.mass_flow_deriv() self.mat_deriv[pos + 3:pos + 5] = self.pressure_deriv()