Package: clover-energy
CLOVERCLOVER minigrid simulation and optimisation for supporting rural electrification in developing countries.The quick start guide below provides step-by-step introductions for downloading, setting up, and using CLOVER. For full documentation containing further information about CLOVER and more detailed descriptions of its functionality, pleasevisit the Wiki.Table Of ContentsQuick start guide⏬Downloading CLOVERStable installationUpgradingDownloading as a developer🐍Setting up your Python environmentAnaconda methodPip install⛅Setting up a new locationUpdating an existing location🌦️Renewables ninja:memo:Completing input filesSimulation and optimisation filesOptimisation only files🍀Running CLOVERProfile generationRunning a simulationRunning an optimisationAnalysis🎓Running CLOVER on Imperial College London's high-performance computers🚤 Quick start guideThis guide provides a very brief introduction to get your CLOVER installation up and running as quickly as possible following the initial download. The file structure has two main branches:a python branch,src, which contains CLOVER's source code which is used to perform simulations and generate outputs,and a data branch,locations, which contains informaiton describing the locations being modelled and contains parameters to outline the simulations and optimisations that should be run.An example location, "Bahraich," in India, is included in the initial download for reference.Downloading CLOVERCLOVER can be downloaded from Github or installed via the Python package manager. If you intend to use CLOVER, but not develop or edit any of its code, then it is recommended that you install CLOVER from the Python package manager as this will guarantee that you install a stable version. If you intend to develop or edit any of the code contained within CLOVER as part of your research, then it is recommended that you download CLOVER directly from Github.Stable installationFor a stable version of CLOVER, it is recommended that you directly install the latest version of CLOVER via theclover-energypackage. This can be installed using the python package manage,pip, in the usual way:python-mpipinstallclover-energyThis will download and install the latest version of CLOVER into the current virtual environment that you have running. If you are using Anaconda, please note that this will install CLOVER only for the virtual environment that you are currently in, not for your system as a whole. CLOVER can now be run by callingcloverfrom a terminal anywhere on your system, though you will need to set up a location in order for it to run successfully. See 'Setting up a new location' below.This should install all of the relevant dependencies for CLOVER as well as providing four installable executable files:new-clover-location,update-api-token,clover-hpcandclover, which are described in more detail below.Note, installing CLOVER in this way will install the package to your conda environment or local computer and will not provide you with easy access to the source code files. To develop CLOVER and have access to the source code, ensure that you download the code from GitHub.UpgradingTo update the version of CLOVER that you have installed, from anywhere on your system, run:python-mpipinstallclover-energy--upragdeThis will fetch the latest stable version of CLOVER and install it into your current virtual environment.Downloading as a developerTo download the CLOVER source, with a view to editing and helping to develop the code, simply click the greenCodebutton near the top of this page, copy the URL, and, in your local terminal, rungit clone <URL>to get your local copy of CLOVER. From there, check out a new branch for any of your edits:git checkout -b <new_branch_name>⚠️ One-time download from GithubTo download the CLOVER source code directly from Github, simply click the greenCodebutton near the top of this page, and selectDownload ZIP. Once downloaded, unpack the zip file into a directory of your choice. You will now be able to run CLOVER from a terminal in this directory. Use thecdcommand to change the directory of your terminal to the extracted folder in order to run CLOVER.Note:this is not recommended, as the version you will download will not be easily updatable from Github. It is recommended that you eitherinstall as a developerorinstall with the Python package manage.Setting up your Python environmentCLOVER is a scientific package and, as such, uses Python packages that may not have come installed by default on your system. These packages can be easily installed, provided that you are connected to the internet, either usingpip, the python package manager, orconda, a virtual-environment-based system. Instructions forcondaare provided below.Note:If you have installed CLOVER following the instructions in theStable Installationsection, then you do not need to install any dependencies, and you can skip straight toSetting up a new location.Anaconda methodTo install usingconda, from the root of the repository, run:condainstall--filerequirements.txtNote, on some systems, Anaconda is unable to find the requirements.txt file. In these cases, it is necessary to use the full and absolute path to the file. E.G.,condainstall--fileC:\\Users\<User>\...\requirements.txtPip installWhether you are in an anaconda environment, or are using your native Python, you can use Python's native package manager to install any dependencies. From the root of the repository, run:python-mpipinstall-rrequirements.txtSetting up a new locationNew locations can be set up in one of two ways:By creating a new location from scratch and inputting all necessary information. To do this, call thenew_locationhelper script with just the name of your new location.
If you have installed CLOVER via agit clonecommand:python-msrc.clover.scripts.new_location<new_location_name>if you are on a Linux machine, you can use the launch scripts provided:./bin/new_location.sh<new_location_name>or, if you have installed theclover-energypackage, eithernew-clover-location<new_location_name>orpython-mnew-clover-location<new_location_name>By basing the location on an existing location. To do this, call thenew_locationhelper script with the--from-existingflag.
If you have installed CLOVER via agit clonecommand:python-msrc.clover.scripts.new_location<new_location_name>--from-existing<existing_location>if you are on a Linux machine, you can use the launch scripts provided with the additionalfrom-existingflag:./bin/new_location.sh<new_location_name>--from-existing<existing_location>or, if you have installed theclover-energypackage, eithernew-clover-location<new_location_name>--from-existing<existing_location>orpython-mnew-clover-location<new_location_name>--from-existing<existing_location>Updating an existing locationAs part of the ongoing development of CLOVER, new features will be introduced. In order to incorporate these into existing CLOVER locations on your system, you can use thenew_locationscript provided to update these locations:python -m src.clover.scripts.new_location <location_name> --updateor, if you have installed theclover-energypackage, eithernew-clover-location <location_name> --updateorpython-mnew-clover-location<location_name>--updateCLOVER will search through your location and attempt to replace missing files and include new files that have been brought in by an update. Note, CLOVER will not correct missing or invalid fields within files, these must be corrected manually and the User Guide should be consulted for more information.Renewables ninjaGo tohttps://www.renewables.ninja/registerto register a free account to gain your API token. This will be needed in order for CLOVER to correctly fetch and utilise solar profiles.Once you have created a new location, you can input your API token using a CLOVER helper script.
If you have downloaded CLOVER using thegit clonecommand:python-msrc.clover.scripts.update_api_token--location<location_name>--token<renewables_ninja_api_token>or, if you have installed theclover-energypackage, eitherupdate-api-token--location<location_name>--token<renewables_ninja_api_token>orpython-mupdate-api-token--location<location_name>--token<renewables_ninja_api_token>Completing input filesWithin your location folder you will find a subfolder namedinputs. This contains the various input files which are used by CLOVER. These need to be completed in order for CLOVER to run. Some files are needed only for optimisations while some are needed for both optimisations and simulations.Simulation and optimisation filesEnsure thatinputs/generation/generation_inputs.yamlcontains your renewables.ninja API token and that the other parameters within the file are set correctly;Completeinputs/location_data/location_inputs.yamlwith the details of your location;Complete theinputs/generation/grid/grid_times.csvtemplate with the details of your location:Grid profiles are a 1x24 matrix of hourly probabilities (0-1) that the grid is available,Input all grid profiles at the same time;Completeinputs/generation/diesel/diesel_inputs.yamlwith information about your diesel generator;Completeinputs/load/devices.yamlwith the devices that your location needs and the parameters as appropriate.NOTE:CLOVER considers kerosene as a mitigated source. The best practice for leaving kerosene out of your location is to set theinitial_ownershipandfinal_ownershipof the kerosene device included by default to0.In theinputs/load/device_utilisationfolder, complete the utilisation profiles for each device e.g.light_times.csv:Utilisation profiles are a 12x24 (monthly x hourly) matrix of probabilities that the specified device is in use in that hour,Each device in  “Devices.csv” must have a corresponding utilisation profile;In theinputs/simulationfolder, complete theenergy_system.yamlfile with the details of your location's energy system;In theinputs/simulationfolder, complete thesimulations.yamlfile with the details of the simulation bounds that you wish to run.Optimisation-only filesComplete theinputs/impact/finance_inputs.yamlwith the financial details of your location;Complete theinputs/impact/ghg_inputs.yamlwith the GHG-emission details of your location;Complete theinputs/optimisation/optimisation_inputs.yamlwith the various parameters used to define the scope of the optimisations;See the user guide, available within the repository, for more information on these input files.Running CLOVERThe operation of CLOVER can be broken down into two steps:Fetching and generating profilesCarrying out simulations and optimisations as appropriate.When running a CLOVER simulation or optimisation, profiles will be generated if they are not present. However, these can also be generated on their own, without running a simultaion.Profile generationTo generate the profiles on their own, run CLOVER with the name of the location only. If you have downloaded CLOVER from GitHub using thegit clonecommand:python-msrc.clover--location<location_name>or, if you are on a Linux machine,./bin/clover.sh--location<location_name>If you have installed theclover-energypackage, run eitherclover--location<location_name>orpython-mclover--location<location_name>Running a simulationWhen running a CLOVER simulation, the size of the PV and storage systems needs to be specified on the comand-line:python-msrc.clover--location<location_name>--simulation--pv-system-size<float>--storage-size<float>or, if you are on a Linux machine,./bin/clover.sh--location<location_name>--simulation--pv-system-size<float>--storage-size<float>If you have installed theclover-energypackage, eitherclover--location<location_name>--simulation--pv-system-size<float>--storage-size<float>orpython-mclover--location<location_name>--simulation--pv-system-size<float>--storage-size<float>where<float>indicates that a floating point object, i.e., a number, is an acceptable input. The number should not have quotation marks around it.Running an optimisationWhen running a CLOVER optimisation, the size of the PV and storage systems are optimised based on the information inputted in theoptimisation_inputs.yamlfile. To run an optimisation, simply call CLOVER from the command line:python-msrc.clover--location<location_name>--optimisationor, if you are on a Linux machine:./bin/clover.sh--location<location_name>--optimisationIf you have installed theclover-energypackage, eitherclover--location<location_name>--optimisationorpython-mclover--location<location_name>--optimisationAnalysisWhen running CLOVER simulations, in-built graph plotting can be carried out by CLOVER. To activate this functionality, simply use the--analyseflag when initialising a CLOVER simulation from the command-line interface. You can run the analysiswithoutany plots by including the--skip-analysisflag.Running CLOVER on Imperial College London's high-performance computersThe operation of CLOVER can be broken down into the same steps as per running CLOVER on a local machine. These are described inRunning CLOVER. On Imperial's high-performance computers (HPCs), this functionality is wrapped up in such a way that a single entry point is provided for launching runs and a single additional input file is required in addition to those described inCompleting input files. Consult the user guide or wiki pages for more information on what is required of the input jobs file.Launching jobsOnce you have completed your input runs file, jobs are launched to the HPC by calling CLOVER's launch script from the command-line:python-msrc.clover.scripts.clover_hpc--runs<jobs_file>or, if you have installed theclover-energypackage, eitherclover-hpc--runs<jobs_file>orpython-mclover-hpc--runs<jobs_file>For more information, contact Phil Sandwell (philip.sandwell@gmail.com) or Ben Winchester (benedict.winchester@gmail.com).