Skip to content

Commit

Permalink
Define windows_curve as property of User class
Browse files Browse the repository at this point in the history
  • Loading branch information
Bachibouzouk committed May 18, 2022
1 parent a402e17 commit eb47df5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
17 changes: 17 additions & 0 deletions ramp/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions ramp/core/stochastic_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb47df5

Please sign in to comment.