示例#1
0
	def _find_three_phase_nodes(self, S0, V0):
		try:
			# set the random number seed
			randomSeed = 25000
			np.random.seed(randomSeed)

			DNet=OpenDSSData.data['DNet']
			myconfig=OpenDSSData.config['myconfig']
			defaultConfig=myconfig['DERParameters']['default']

			#### default settings
			if 'pref' not in defaultConfig:
				myconfig['DERParameters']['default']['pref']=10
			if 'qref' not in defaultConfig:
				myconfig['DERParameters']['default']['qref']=0
			if 'sbase' not in defaultConfig:
				myconfig['DERParameters']['default']['sbase']=10

			if myconfig['DERSetting'] == 'PVPlacement':
				PVPlacement = True
				nSolar=len(myconfig['DERParameters']['PVPlacement']) #Number of solarpv DERs
			elif myconfig['DERSetting'] == 'default':
				PVPlacement = False
				feeder_load=0 # rating will be in kVA as Default
				for entry in S0['P']: #Sum all the loads in the feeder
					if myconfig['DERParameters']['default']['solarPenetrationUnit']=='kva':
						feeder_load+=abs(S0['P'][entry]+S0['Q'][entry]*1j)
					elif myconfig['DERParameters']['default']['solarPenetrationUnit']=='kw':
						feeder_load+=S0['P'][entry]
				# number of 50 kVA solar installtions required
				if self.der_solver_type.replace('_','').replace('-','').lower()=='fastder':
					nSolar=int(np.ceil((feeder_load/defaultConfig['pref'])*\
					defaultConfig['solarPenetration']))
				else:
					nSolar=int(np.ceil((feeder_load/myconfig['DERParameters']['default']['powerRating'])*\
					myconfig['DERParameters']['default']['solarPenetration']))
			else:
				raise ValueError('{} is not a valid DER setting in config file'.format(
				myconfig['DERSetting']))

			# find all three phase nodes
			threePhaseNode=[]
			for node in V0:
				count=len(V0[node])
				if count==3 and node not in myconfig['DERParameters']['avoidNodes']: # three phase node
					threePhaseNode.append(node)

			if PVPlacement:
				invalid_nodes = set(myconfig['DERParameters']['PVPlacement'].keys()).difference(
				threePhaseNode)
				if not invalid_nodes:
					threePhaseNode=list(myconfig['DERParameters']['PVPlacement']) #Get list of D nodes
				else:
					raise ValueError('Config file contains following invalid nodes:{}'.format(
					invalid_nodes))
			OpenDSSData.log(level=10,msg="{} DERs will be created...".format(nSolar))
			return threePhaseNode,PVPlacement,nSolar
		except:
			OpenDSSData.log()