예제 #1
0
    def Vgrms_calc(self):
        """Grid side terminal voltage -  RMS"""

        return utility_functions.Urms_calc(self.vag, self.vbg, self.vcg)
 def Vtrms_calc(self):
     """Inverter terminal voltage -  RMS"""
     
     return utility_functions.Urms_calc(self.vta,self.vtb,self.vtc)
 def Vrms_calc(self):
     """PCC LV side voltage - RMS"""
     
     return utility_functions.Urms_calc(self.va,self.vb,self.vc)
 def Irms_calc(self):
     """Inverter current - RMS"""
     
     return utility_functions.Urms_calc(self.ia,self.ib,self.ic)
예제 #5
0
    def setup(self, nodeid, V0):
        try:
            VpuInitial = 1.0
            SinglePhase = False

            if 'myconfig' in OpenDSSData.config and 'DERParameters' in OpenDSSData.config[
                    'myconfig']:
                #pvderConfig = copy.deepcopy(OpenDSSData.config['myconfig']['DERParameters'])

                DERFilePath = OpenDSSData.config['myconfig']['DERFilePath']
                DERModelType = OpenDSSData.config['myconfig']['DERModelType']
                DERSetting = OpenDSSData.config['myconfig']['DERSetting']

                DERParameters = OpenDSSData.config['myconfig']['DERParameters']

                if DERSetting == 'default':
                    pvderConfig = self.get_derconfig(DERParameters['default'])
                    DERArguments = self.get_derarguments(
                        DERParameters['default'])

                elif DERSetting == 'PVPlacement':  # for manual feeder config based on PVPlacement
                    if nodeid in DERParameters['PVPlacement']:
                        pvderConfig = self.get_derconfig(
                            DERParameters['PVPlacement'][nodeid])
                        DERArguments = self.get_derarguments(
                            DERParameters['PVPlacement'][nodeid])
                    else:
                        raise ValueError(
                            'Distribution node {} not found in config file!'.
                            format(nodeid))
                else:
                    raise ValueError(
                        '{} is not a valid DER setting in config file!'.format(
                            DERSetting))

                if 'nodenumber' in OpenDSSData.config['myconfig']:
                    DERLocation = str(os.getpid()) + '-' + 'bus_' + str(
                        OpenDSSData.config['myconfig']
                        ['nodenumber']) + '-' + 'node_' + nodeid
                else:
                    DERLocation = str(os.getpid()) + '-' + 'node_' + nodeid

            else:
                print(
                    'DERParameters not found in `OpenDSSData` object - using default ratings and parameters!'
                )
                DERArguments = {}
                pvderConfig = {}
                SteadyState = True
                if SinglePhase:
                    powerRating = 10.0e3
                else:
                    powerRating = 50.0e3
                DERLocation = 'node_' + nodeid

                DERArguments.update({'pvderConfig': pvderConfig})
                DERArguments.update({'powerRating': powerRating})
                DERArguments.update({'SteadyState': SteadyState})

            #Va = cmath.rect(DERArguments['VrmsRating']*math.sqrt(2),0.0)
            #Vb = utility_functions.Ub_calc(Va)
            #Vc = utility_functions.Uc_calc(Va)
            a = utility_functions.Urms_calc(
                V0['a'], V0['b'], V0['c']) / DERArguments['VrmsRating']
            Va = (V0['a'] / a)  #Convert node voltage at HV side to LV
            Vb = (V0['b'] / a)
            Vc = (V0['c'] / a)

            DERArguments.update({'identifier': DERLocation})
            DERArguments.update({'derConfig': pvderConfig})
            DERArguments.update({'standAlone': False})

            DERArguments.update({'gridFrequency': 2 * math.pi * 60.0})
            DERArguments.update({'gridVoltagePhaseA': Va})
            DERArguments.update({'gridVoltagePhaseB': Vb})
            DERArguments.update({'gridVoltagePhaseC': Vc})

            logging.debug(
                'Creating DER instance of {} model for {} node.'.format(
                    DERModelType, DERLocation))
            print('Creating DER instance of {} model for {} node.'.format(
                DERModelType, DERLocation))
            events = SimulationEvents()

            PVDER_model = DERModel(modelType=DERModelType,
                                   events=events,
                                   configFile=DERFilePath,
                                   **DERArguments)
            self.PV_model = PVDER_model.DER_model

            self.PV_model.LVRT_ENABLE = True  #Disconnects PV-DER based on ride through settings in case of voltage anomaly
            self.sim = DynamicSimulation(PV_model=self.PV_model,
                                         events=events,
                                         LOOP_MODE=True,
                                         COLLECT_SOLUTION=True)
            if DERModelType in self.sim.jac_list:
                self.sim.jacFlag = True  #Provide analytical Jacobian to ODE solver
            else:
                self.sim.jacFlag = False
            self.sim.DEBUG_SOLVER = False  #Check whether solver is failing to converge at any step
            self.results = SimulationResults(simulation=self.sim,
                                             PER_UNIT=True)

            self.lastSol = copy.deepcopy(self.sim.y0)  # mutable,make copy
            self.lastT = 0
        except Exception as e:
            OpenDSSData.log("Failed Setup PVDER at node:{}!".format(nodeid))