diff --git a/ramp/core/core.py b/ramp/core/core.py index 2e1308f8..5780ad0d 100644 --- a/ramp/core/core.py +++ b/ramp/core/core.py @@ -128,6 +128,19 @@ def add_appliance(self, *args, **kwargs): # I would add the appliance explicitely here, unless the appliance works only if a windows is defined return Appliance(self, *args, **kwargs) + @property + def windows_curve(self): + windows_curve = np.zeros(1440) + for App in self.App_list: + # Calculate windows curve, i.e. the theoretical maximum curve that can be obtained, for each app, by switching-on always all the 'n' apps altogether in any time-step of the functioning windows + single_wcurve = ( + App.single_wcurve + ) # this computes the curve for the specific App + windows_curve = np.vstack( + [windows_curve, single_wcurve] + ) # this stacks the specific App curve in an overall curve comprising all the Apps within a User class + return np.transpose(np.sum(windows_curve, axis=0)) * self.num_users + def save(self, filename=None): answer = pd.concat([app.save() for app in self.App_list], ignore_index=True) if filename is not None: @@ -328,6 +341,10 @@ def windows(self, window_1 = np.array([0,0]), window_2 = np.array([0,0]),random_ self.random_var_2 = int(random_var_w*np.diff(window_2)) #same as above self.random_var_3 = int(random_var_w*np.diff(window_3)) #same as above self.user.App_list.append(self) #automatically appends the appliance to the user's appliance list + @property + def single_wcurve(self): + return self.daily_use * np.mean(self.power) * self.number + if self.fixed_cycle == 1: self.cw11 = self.window_1 diff --git a/ramp/core/stochastic_process.py b/ramp/core/stochastic_process.py index ffb18c56..713ac6f5 100644 --- a/ramp/core/stochastic_process.py +++ b/ramp/core/stochastic_process.py @@ -24,14 +24,6 @@ def Stochastic_Process(j=None, fname=None, num_profiles=None): windows_curve = np.zeros(1440) #creates an empty daily profile Tot_curve = np.zeros(1440) #creates another empty daily profile for Us in User_list: - App_count = 0 - for App in Us.App_list: - #Calculate windows curve, i.e. the theoretical maximum curve that can be obtained, for each app, by switching-on always all the 'n' apps altogether in any time-step of the functioning windows - single_wcurve = Us.App_list[App_count].daily_use*np.mean(Us.App_list[App_count].power)*Us.App_list[App_count].number #this computes the curve for the specific App - windows_curve = np.vstack([windows_curve, single_wcurve]) #this stacks the specific App curve in an overall curve comprising all the Apps within a User class - App_count += 1 - Us.windows_curve = windows_curve #after having iterated for all the Apps within a User class, saves the overall User class theoretical maximum curve - Us.windows_curve = np.transpose(np.sum(Us.windows_curve, axis = 0))*Us.num_users Tot_curve = Tot_curve + Us.windows_curve #adds the User's theoretical max profile to the total theoretical max comprising all classes peak_window = np.transpose(np.argwhere(Tot_curve == np.amax(Tot_curve))) #Find the peak window within the theoretical max profile peak_time = round(random.normalvariate(round(np.average(peak_window)),1/3*(peak_window[0,-1]-peak_window[0,0]))) #Within the peak_window, randomly calculate the peak_time using a gaussian distribution