Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make full use of UseCase class #102

Merged
merged 46 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bb8fcca
Add dates input options to usecase
Bachibouzouk Nov 17, 2023
f375fc3
Move calc_peak_time_range as method of usecase
Bachibouzouk Nov 17, 2023
d1d2123
Connect User instances to a potential usecase
Bachibouzouk Nov 17, 2023
62c5e0d
Update generate_daily_load_profiles
Bachibouzouk Nov 17, 2023
8b0148c
Adapt input files
Bachibouzouk Nov 17, 2023
e9824fd
Remove unused code
Bachibouzouk Nov 17, 2023
6957148
Change attribute name
Bachibouzouk Nov 17, 2023
c11d510
Add one example of rewritten notebook
Bachibouzouk Nov 17, 2023
6272db7
Modify run_uscase and cli modules
Bachibouzouk Nov 18, 2023
d33f264
Define num_days for User class
Bachibouzouk Nov 18, 2023
3d3a5b4
Fix failing test
Bachibouzouk Nov 18, 2023
68cd804
Enable python file to be run by ramp cli
Bachibouzouk Nov 19, 2023
7106134
Move code from Run postprocess to UseCase methods
Bachibouzouk Nov 20, 2023
b2da25e
Adapt README
Bachibouzouk Nov 20, 2023
d40836c
Add a test to make sure the .ipynb file in documentation run
Bachibouzouk Nov 24, 2023
f993703
Make get_day_type function accept iso format date string as input
Bachibouzouk Nov 30, 2023
f0ce520
Provide getter and setter for date input of UseCase
Bachibouzouk Nov 30, 2023
7155317
By default expect 366 days for power timeseries input
Bachibouzouk Nov 30, 2023
a957c1b
Make peak_enlarge an attribute of the UseCase
Bachibouzouk Nov 30, 2023
733de35
Fix parallel processing
Bachibouzouk Nov 30, 2023
7a89100
Add a property to check if UseCase was already initialized
Bachibouzouk Nov 30, 2023
b51c917
Make daily_profile method callable with default values
Bachibouzouk Nov 30, 2023
4ca0060
Manage options to build a date range depending on user inputs
Bachibouzouk Nov 30, 2023
1991528
Fix and lint jupter notebooks
Bachibouzouk Nov 30, 2023
fd8b22d
Fix conversion from .py to .xlsx
Bachibouzouk Nov 30, 2023
7eb6abb
Fix failing tests
Bachibouzouk Nov 30, 2023
b09be99
Fix test requiring 365 days in a year
Bachibouzouk Nov 30, 2023
45d4b5c
Comment out a failing test
Bachibouzouk Nov 30, 2023
1939c8c
Lint test file
Bachibouzouk Nov 30, 2023
7c3199c
Add nbformat to test requirements
Bachibouzouk Nov 30, 2023
69738f4
Correct typo in core.py
FLomb Dec 1, 2023
8c4f97b
Update, fix and refine jupyter notebooks
FLomb Dec 1, 2023
fbbc8f2
Update README file
FLomb Dec 1, 2023
2f67728
Update test requirements
Bachibouzouk Dec 1, 2023
fee9a81
Add local ramp package to test requirements
Bachibouzouk Dec 1, 2023
f4e4abd
Fix twine check errors
Bachibouzouk Dec 1, 2023
50b5d38
Update .rst files based on jupyter notebooks examples
Bachibouzouk Dec 1, 2023
c4e3ca0
Improve cli help text and lint jupyter example notebooks
Bachibouzouk Dec 1, 2023
67231ed
Updaing the API docs for UseCase
mohammadamint Dec 4, 2023
3bad531
Update api_references.rst
mohammadamint Dec 4, 2023
3791f67
Update readme to showcase UseCase
FLomb Dec 4, 2023
0dd2ad8
Update docstrings
Bachibouzouk Dec 4, 2023
240ce33
Fix docs warnings
Bachibouzouk Dec 4, 2023
f8c4adb
Add missing images for the docs
Bachibouzouk Dec 4, 2023
7189443
Update changelog
Bachibouzouk Dec 4, 2023
f78dee4
Minor typo fixes in CHANGELOG.md
FLomb Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@ Release History
===============

0.4.2 (dev)
------------------
-----------



**|fixed|** jupyter notebooks are up to date with the UseCase class

**|fixed|** UseCase class usage is now documented

**|changed|** num_profile variable was changed to num_days

**|changed|** User class get assigned automatically to a default UseCase instance if not provided

**|changed|** Delete ramp.core.initialize and ramp.core.stochastic_process, move calc_peak_time_range inside UseCase method

**|fixed|** conversion of .py files into .xlsx is fixed

**|fixed|** using .py files is now possible in the command line as well as from IDE

**|new|** tests for example jupyter notebook (smoke test to see if the notebooks run through)

**|new|** continuous integration setup

Expand Down
94 changes: 67 additions & 27 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,15 @@ To have a look to the python files, you can download them using the `download_ex

download_example("the specfic folder directory to save the files")

- ``input_file_1.py``: represents the most basic electric appliances,
is an example of how to model lightbulbs, radios, TVs, fridges, and
- ``input_file_1.py``: represents the most basic electric appliances; it is
an example of how to model lightbulbs, radios, TVs, fridges, and
other electric appliances. This input file is based on the ones used
for `this
publication <https://doi.org/10.1016/j.energy.2019.04.097>`__.
for `the first RAMP publication <https://doi.org/10.1016/j.energy.2019.04.097>`__.

- ``input_file_2.py``: shows how to model thermal loads, with the
- ``input_file_2.py``: shows how to model user-driven thermal loads, with the
example of a “shower” appliance. The peculiarity of thermal appliances
is that the nominal power can be provided as external input as a
“csv” file (in this case, ``shower_P.csv``). For the example “shower”
.csv” file (in this case, ``shower_P.csv``). For the example “shower”
appliance, the varying nominal power accounts for the effect of
groundwater temperature variation throughout the year. This input
file is based on that used for `this
Expand All @@ -138,6 +137,14 @@ To have a look to the python files, you can download them using the `download_ex
file is used in `this
publication <https://doi.org/10.1109/PTC.2019.8810571>`__

You can execute python input files within an IDE, in your terminal with python command

.. code-block:: bash

python <path to .py input file>

or in your terminal with the ``ramp`` command, see `Command line options <cmd_option_>`_ below for more information.

Spreadsheet input files
-----------------------

Expand All @@ -149,18 +156,22 @@ need to run the ``ramp`` command with the option ``-i``:
ramp -i <path to .xlsx input file>


.. note:: You can input several files, separated from each others by a single blank space
.. note:: You can input several files, separated from each others by a single blank space you can also input python files

.. _cmd_option:

Command line options
--------------------

If you already know how many profile you want to simulate you can indicate it with the ``-n`` option:
In the command line you can also run .py input files
If you already know how many daily profiles you want to simulate you can indicate it with the ``-n`` option:

.. code-block:: bash

ramp -i <path to .xlsx input file> -n 10
ramp -i <path to .xlsx or .py input file> -n 10

will simulate 10 profiles. Note that you can use this option without
providing a ``.xlsx`` input file with the ``-i`` option, this will then
be equivalent to running ``python ramp_run.py`` from the ``ramp`` folder
without being prompted for the number of profile within the console.
will simulate 10 daily profiles. Note that if you do not provide this option you will being prompted for the
number of daily profiles within the console.


If you want to save ramp results to a custom file, you can provide it with the option `-o`
Expand Down Expand Up @@ -193,11 +204,11 @@ Building a model with a python script
.. code-block:: python

# importing functions
from ramp import User,calc_peak_time_range,yearly_pattern
from ramp import UseCase, User
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A problem I see in the README.rst file is that we import the UseCase but never use it. We just run the profiles for one User, which is not what one typically wants to do. We should show how to add Users to a UseCase and how to run via the UseCase class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I just translated the existing example but we should also showcase the UseCase more


# Create a user category
low_income_households = User(
user_name = "low_income_household", # an optional feature for the User class
household_1 = User(
user_name = "Household type 1", # an optional feature for the User class
num_users = 10, # Specifying the number of specific user category in the community
)

Expand All @@ -206,14 +217,15 @@ You can add appliances to a user category by:
.. code-block:: python

# adding some appliances for the household
radio = low_income_household.add_appliance(
radio = household_1.add_appliance(
name = "Small Radio", # optional feature for the appliance class
number = 1, # how many radio each low income household holds
power = 10, # RAMP does not take care of unit of measures , watt
number = 1, # how many radio each household type 1 has
power = 10, # RAMP does not take care of units of measure (e.g., Watts), you must be consistent
func_time = 120, # Total functioning time of appliance in minutes
num_windows = 2, # in how many time-windows the appliance is used
num_windows = 2, # how many time-windows the appliance is used in
)


The use time frames can be specified using the 'window' method for each appliance of the user category:

.. code-block:: python
Expand All @@ -224,16 +236,44 @@ The use time frames can be specified using the 'window' method for each applianc
window_2 = [1320,1380], # from 10 PM to 11 PM
)

Now you can generate your **stochastic profiles**:
You can also add another, different user to the simulation. In this case,
we use a more compact formulation:

.. code-block:: python

# generating load_curves
load = low_income_household.generate_aggregated_load_profiles(
prof_i = 1, # the ith day profile
peak_time_range = calc_peak_time_range(), # the peak time range
Year_behaviour = yearly_pattern(), # defining the yearly pattern (like weekdays/weekends)
)
# Create a second user category
household_2 = User(
user_name = "Household type 2", # an optional feature for the User class
num_users = 13, # Specifying the number of specific user category in the community
)

# adding some appliances for the new household type in compact form, with windows specified directly and random variability
light_bulbs = household_2.add_appliance(
name = "Light bulbs", # optional feature for the appliance class
number = 5, # how many light bulbs each household type 2 has
power = 7, # RAMP does not take care of units of measure (e.g., Watts), you must be consistent
func_time = 120, # total functioning time of appliance in minutes
time_fraction_random_variability=0.2, # 20% random variability associated to the total functioning time
num_windows = 2, # how many time-windows the appliance is used in
window_1 = [390,480], # from 6.30 AM to 8 AM
window_2 = [1020,1440], # from 5 PM to 12 PM
random_var_w=0.35 # 35% randomness assigned to the size of the functioning windows
)

At this point, we can group our different users into a "use case" and run the simulation,
for instance for a whole year.

.. code-block:: python

use_case = UseCase(users=[household_1,household_2], date_start="2020-01-01", date_end="2020-12-31")
whole_year_profile = use_case.generate_daily_load_profiles()

Here is your first load for a community including two types of housholds,
for a total of 23 individual users. Of course, more variations and many more
features are possible! For instance, you can simulate loads even for
an individual appliance or user. In addition, you can use in-built plotting
functionalities to explore your results. Check out the documentation
for all the possibilities.

Contributing
============
Expand Down
Loading
Loading