diff --git a/MAIN_Unbalanced_OPF_RUN.py b/MAIN_Unbalanced_OPF_RUN.py index f30e189..e8ced2a 100644 --- a/MAIN_Unbalanced_OPF_RUN.py +++ b/MAIN_Unbalanced_OPF_RUN.py @@ -216,15 +216,15 @@ def range1(start, end, step): # like range but inlcuding the ending value #### Choose a NLP solver - make sure its installed - some solvers won't be able to find a feasible or optimal solution - NOTE: with IPOPT as default, I've disabled "PV operational limits" constraint... you need another solver when including that # IPOPT -optimizer = pyo.SolverFactory('ipopt') -optimizer.options["max_iter"] = 100000 -optimizer.options["linear_solver"] = 'mumps' +#optimizer = pyo.SolverFactory('ipopt') +#optimizer.options["max_iter"] = 100000 +#optimizer.options["linear_solver"] = 'mumps' # KNITRO -#optimizer = pyo.SolverFactory('knitroampl') -#optimizer.options["par_numthreads"] = 5 -#optimizer.options["algorithm"] = 0 # Indicates which algorithm to use to solve the problem - 0 is auto [0-5] -#optimizer.options["presolve"] = 1 # Determine whether or not to use the Knitro presolver to try to simplify the model by removing variables or constraints. +optimizer = pyo.SolverFactory('knitroampl') +optimizer.options["par_numthreads"] = 1 +optimizer.options["algorithm"] = 0 # Indicates which algorithm to use to solve the problem - 0 is auto [0-5] +optimizer.options["presolve"] = 1 # Determine whether or not to use the Knitro presolver to try to simplify the model by removing variables or constraints. print('Solving OPF model...') Problem = optimizer.solve(instance,tee=True) diff --git a/Main_packages/OPF_model_creator_v01.py b/Main_packages/OPF_model_creator_v01.py index 00e2b46..bac8ced 100644 --- a/Main_packages/OPF_model_creator_v01.py +++ b/Main_packages/OPF_model_creator_v01.py @@ -166,7 +166,7 @@ def Q_flow_receiving_rule(model, l, s, t): # Q receiving flow return -1.0 *(model.Vim[model.Lines_i[l],s,t] * model.Iflow_re[l,s,t] - model.Vre[model.Lines_i[l],s,t] * model.Iflow_im[l,s,t]) model.Q_flow_receiving = pyo.Expression(model.Lines,model.Phases_abc,model.time, rule=Q_flow_receiving_rule) # Losses - if 1==1: + if 1==0: # Only model the variables that you are using in the optimization problem (in objective function or constraints) # Losses for this time step per line and phase def P_losses_rule(model, l, s, t): # Active power losses Watts! return model.P_flow_sending[l,s,t] + model.P_flow_receiving[l,s,t] @@ -233,7 +233,7 @@ def Transformer_limit_rule(model, t): model.Transformer_limit_con = pyo.Constraint(model.time, rule=Transformer_limit_rule) # PV operational limits - if 1==0: # I recommend using a different NLP solver than IPOPT if incorporating this constraint (e.g. knitro or modifiying IPOPT options) - otherwise, relax the constraint + if 1==1: # I recommend using a different NLP solver than IPOPT if incorporating this constraint (e.g. knitro or modifiying IPOPT options) - otherwise, relax the constraint def PV_inverter_limit_rule(model, pv, t): max_P = PV_Gen_data[pv,'Profile'].loc[t] max_S = (max_P**2+ (max_P*math.tan(math.acos(min_Cosphi)))**2)**0.5