def to_grg_dcline(self, lookup, base_mva, omit_subtype=False): '''Returns: a grg data dc line name and data as a dictionary''' if self.pmin >= 0 and self.pmax >= 0: active_1_min = self.pmin active_1_max = self.pmax active_2_min = self.loss0 - active_1_max * (1 - self.loss1) active_2_max = self.loss0 - active_1_min * (1 - self.loss1) if self.pmin >= 0 and self.pmax < 0: active_1_min = self.pmin active_2_min = self.pmax active_1_max = (-active_2_min + self.loss0) / (1 - self.loss1) active_2_max = self.loss0 - active_1_min * (1 - self.loss1) if self.pmin < 0 and self.pmax >= 0: active_2_max = -self.pmin active_1_max = self.pmax active_1_min = (-active_2_max + self.loss0) / (1 - self.loss1) active_2_min = self.loss0 - active_1_max * (1 - self.loss1) if self.pmin < 0 and self.pmax < 0: active_2_max = -self.pmin active_2_min = self.pmax active_1_max = (-active_2_min + self.loss0) / (1 - self.loss1) active_1_min = (-active_2_max + self.loss0) / (1 - self.loss1) data = { 'type': 'dc_line', 'id': lookup['dcline'][self.index], 'source_id': str(self.index), 'link_1': lookup['voltage'][self.f_bus], 'link_2': lookup['voltage'][self.t_bus], 'resistance': 0.0, 'losses_1': { 'min': active_1_min / base_mva, 'max': active_1_max / base_mva, 'c_0': 0.0, 'c_1': 0.0, }, 'losses_2': { 'min': active_2_min / base_mva, 'max': active_2_max / base_mva, 'c_0': self.loss0, 'c_1': self.loss1, }, 'output_1': { 'reactive': grg_common.build_range_variable(self.qminf / base_mva, self.qmaxf / base_mva) }, 'output_2': { 'reactive': grg_common.build_range_variable(self.qmint / base_mva, self.qmaxt / base_mva) }, } return data
def to_grg_generator(self, lookup, base_mva, omit_subtype=False): '''Returns: a grg data gen name and data as a dictionary''' data = { 'id': lookup['gen'][self.index], 'link': lookup['voltage'][self.gen_bus], 'source_id': str(self.index), 'mbase': self.mbase, 'vg': self.vg, } if self.apf != 0.0: data['apf'] = self.apf if self.is_synchronous_condenser(): # TODO throw warning that this gen is becoming a synchronous_condenser data.update({ 'type': 'synchronous_condenser', 'output': { 'reactive': grg_common.build_range_variable(self.qmin / base_mva, self.qmax / base_mva), } }) else: data.update({ 'type': 'generator', 'output': { 'active': grg_common.build_range_variable(self.pmin / base_mva, self.pmax / base_mva), 'reactive': grg_common.build_range_variable(self.qmin / base_mva, self.qmax / base_mva), } }) return data
def to_grg_bus(self, lookup, omit_subtype=False): '''Returns: a grg data bus name and data as a dictionary''' if omit_subtype: warnings.warn( 'attempted to omit subtype on bus \'%s\', but this is not allowed.' % str(self.bus_i), MP2GRGWarning) data = { 'source_id': str(self.bus_i), 'id': lookup['bus'][self.bus_i], 'type': 'bus', 'link': lookup['voltage'][self.bus_i], 'voltage': { 'magnitude': grg_common.build_range_variable(self.vmin, self.vmax), 'angle': grg_common.build_range_variable('-Inf', 'Inf'), } } if self.bus_type == 3: data['reference'] = True return data
def _grg_tap_changer(self): tap_value = self.tap if tap_value == 0.0: assert (self.shift != 0.0) tap_value = 1.0 return { 'position': grg_common.build_range_variable(0, 0), 'impedance': { 'resistance': grg_common.build_range_variable(self.br_r, self.br_r), 'reactance': grg_common.build_range_variable(self.br_x, self.br_x) }, 'shunt': { 'conductance': grg_common.build_range_variable(0, 0), 'susceptance': grg_common.build_range_variable(self.br_b, self.br_b), }, 'transform': { 'tap_ratio': grg_common.build_range_variable(tap_value, tap_value), 'angle_shift': grg_common.build_range_variable(math.radians(self.shift), math.radians(self.shift)), }, 'steps': [{ 'position': 0, 'impedance': { 'resistance': self.br_r, 'reactance': self.br_x }, 'shunt': { 'conductance': 0.0, 'susceptance': self.br_b }, 'transform': { 'tap_ratio': tap_value, 'angle_shift': math.radians(self.shift) } }] }
def get_grg_operations(self, lookup): key = lookup['branch'][self.index] + '/angle_difference' value = grg_common.build_range_variable(math.radians(self.angmin), math.radians(self.angmax)) return key, value