diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index 679ace3c..17a9b4e4 100644 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -45,21 +45,22 @@ def set_line_volume_limit(n, lv): n.lines['capital_cost'] = 0. n.links['capital_cost'] = 0. - lines_s_nom = n.lines.s_nom.where( - n.lines.type == '', - np.sqrt(3) * n.lines.num_parallel * - n.lines.type.map(n.line_types.i_nom) * - n.lines.bus0.map(n.buses.v_nom) - ) + if lv > 1.0: + lines_s_nom = n.lines.s_nom.where( + n.lines.type == '', + np.sqrt(3) * n.lines.num_parallel * + n.lines.type.map(n.line_types.i_nom) * + n.lines.bus0.map(n.buses.v_nom) + ) - n.lines['s_nom_min'] = lines_s_nom - n.links['p_nom_min'] = n.links['p_nom'] + n.lines['s_nom_min'] = lines_s_nom + n.links['p_nom_min'] = n.links['p_nom'] - n.lines['s_nom_extendable'] = True - n.links['p_nom_extendable'] = True + n.lines['s_nom_extendable'] = True + n.links['p_nom_extendable'] = True - n.line_volume_limit = lv * ((lines_s_nom * n.lines['length']).sum() + - n.links.loc[n.links.carrier=='DC'].eval('p_nom * length').sum()) + n.line_volume_limit = lv * ((lines_s_nom * n.lines['length']).sum() + + n.links.loc[n.links.carrier=='DC'].eval('p_nom * length').sum()) return n diff --git a/scripts/solve_network.py b/scripts/solve_network.py index df95f3a8..64fd9baf 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -181,7 +181,7 @@ def add_opts_constraints(n, opts=None): n.model.safe_peakdemand = pypsa.opt.Constraint(expr=sum(n.model.generator_p_nom[gen] for gen in ext_gens_i) >= peakdemand - exist_conv_caps) def add_lv_constraint(n): - line_volume = getattr(n, 'line_volume_limit') + line_volume = getattr(n, 'line_volume_limit', None) if line_volume is not None and not np.isinf(line_volume): n.model.line_volume_constraint = pypsa.opt.Constraint( expr=((sum(n.model.passive_branch_s_nom["Line",line]*n.lines.at[line,"length"]