Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for cp in self.comps.index:
if cp.local_design is False:
# unset variables provided in .design attribute
for var in cp.design:
cp.get_attr(var).set_attr(is_set=False)
switched = False
msg = 'Set component attributes '
for var in cp.offdesign:
# set variables provided in .offdesign attribute
data = cp.get_attr(var)
data.set_attr(is_set=True)
# take nominal values from design point
if isinstance(data, dc.dc_cp):
cp.get_attr(var).val = cp.get_attr(var).design
switched = True
msg += var + ', '
if switched:
msg = (msg[:-2] + ' to design value at component ' +
cp.label + '.')
logging.debug(msg)
# start component initialisation
cp.comp_init(self)
cp.new_design = False
msg = 'Switched components from design to offdesign.'
logging.debug(msg)
def attr():
return {'P': dc_cp(min_val=0),
'Q': dc_cp(max_val=0),
'eta': dc_cp(min_val=0, max_val=1),
'e': dc_cp(),
'pr_c': dc_cp(max_val=1),
'zeta': dc_cp(min_val=0),
'eta_char': dc_cc(),
'S': dc_simple()}
def attr():
return {'P': dc_cp(min_val=0),
'Q': dc_cp(max_val=0),
'eta': dc_cp(min_val=0, max_val=1),
'e': dc_cp(),
'pr_c': dc_cp(max_val=1),
'zeta': dc_cp(min_val=0),
'eta_char': dc_cc(),
'S': dc_simple()}
# unset design parameters
for var in cp.design:
cp.get_attr(var).set_attr(is_set=False)
# set offdesign parameters
switched = False
msg = 'Set component attributes '
for var in cp.offdesign:
# set variables provided in .offdesign attribute
data = cp.get_attr(var)
data.set_attr(is_set=True)
# take nominal values from design point
if isinstance(data, dc.dc_cp):
cp.get_attr(var).val = cp.get_attr(var).design
switched = True
msg += var + ', '
if switched:
msg = (msg[:-2] + ' to design value at component ' +
cp.label + '.')
logging.debug(msg)
cp.new_design = False
else:
# switch connections to design mode
if self.redesign is True:
for var in cp.design:
cp.get_attr(var).set_attr(is_set=True)
def attr():
return {
'Q': dc_cp(max_val=0), 'kA': dc_cp(min_val=0),
'td_log': dc_cp(min_val=0),
'ttd_u': dc_cp(min_val=0), 'ttd_l': dc_cp(min_val=0),
'pr1': dc_cp(max_val=1), 'pr2': dc_cp(max_val=1),
'zeta1': dc_cp(min_val=0), 'zeta2': dc_cp(min_val=0),
'subcooling': dc_simple(val=False),
'kA_char': dc_simple(),
'kA_char1': dc_cc(param='m'), 'kA_char2': dc_cc(param='m'),
'SQ1': dc_simple(), 'SQ2': dc_simple(), 'Sirr': dc_simple(),
}
def attr():
return {'P': dc_cp(), 'pr': dc_cp(), 'Sirr': dc_simple()}
def attr():
return {
'P': dc_cp(min_val=0),
'eta_s': dc_cp(min_val=0, max_val=1),
'eta_s_char': dc_cc(param='m'),
'pr': dc_cp(min_val=1),
'igva': dc_cp(min_val=-90, max_val=90, d=1e-3, val=0),
'char_map': dc_cm(),
'Sirr': dc_simple()
}
def attr():
return {
'Q': dc_cp(max_val=0), 'kA': dc_cp(min_val=0),
'td_log': dc_cp(min_val=0),
'ttd_u': dc_cp(min_val=0), 'ttd_l': dc_cp(min_val=0),
'pr1': dc_cp(max_val=1), 'pr2': dc_cp(max_val=1),
'zeta1': dc_cp(min_val=0), 'zeta2': dc_cp(min_val=0),
'subcooling': dc_simple(val=False),
'kA_char': dc_simple(),
'kA_char1': dc_cc(param='m'), 'kA_char2': dc_cc(param='m'),
'SQ1': dc_simple(), 'SQ2': dc_simple(), 'Sirr': dc_simple(),
}
def attr():
return {
'P': dc_cp(max_val=0),
'eta_s': dc_cp(min_val=0, max_val=1),
'eta_s_char': dc_cc(param='m'),
'pr': dc_cp(min_val=0, max_val=1),
'cone': dc_simple(),
'Sirr': dc_simple()
}
def attr():
return {
'Q': dc_cp(),
'pr': dc_cp(min_val=1e-4, max_val=1), 'zeta': dc_cp(min_val=0),
'D': dc_cp(min_val=1e-2, max_val=2, d=1e-4),
'L': dc_cp(min_val=1e-1, d=1e-3),
'ks': dc_cp(val=1e-4, min_val=1e-7, max_val=1e-4, d=1e-8),
'E': dc_cp(min_val=0), 'A': dc_cp(min_val=0),
'eta_opt': dc_cp(min_val=0, max_val=1),
'lkf_lin': dc_cp(min_val=0), 'lkf_quad': dc_cp(min_val=0),
'Tamb': dc_simple(),
'Q_loss': dc_cp(min_val=0), 'SQ': dc_simple(),
'hydro_group': dc_gcp(), 'energy_group': dc_gcp()
}