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

Clover hpc #26

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open

Conversation

sheridanfew
Copy link

No description provided.

…oblems with some compilers.

Clean up anomylous naming and spacing. This is in order to allow automatic editing of scripts matching given patterns in later changes.

Used the following commands to achieve this in shell terminal in CLOVER directory:

# Clean up inconsistency in type of inverted commas. This has caused problems with some compilers.

SRC="‘"
DST="'"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py
SRC="’"
DST="'"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

# Clean up anomylous naming and spacing. This is in order to allow automatic editing of scripts matching given patterns in later changes.

sed -i "" -e "s/location_input_data/location_inputs/g" Scripts/*/*py
sed -i "" -e "s/_inputs =  pd.read_csv/_inputs = pd.read_csv/g" Scripts/*/*py
sed -i "" -e "s/_inputs  = pd.read_csv/_inputs = pd.read_csv/g" Scripts/*/*py
Reconfigure to take '.' as filepath - necessary for HPC where CLOVER is copied to the node before processing. (May wish to amend if CLOVER dir gets very big)

Commands used:

SRC="\/\*\*\*YOUR LOCAL FILE PATH\*\*\*\/CLOVER 4.0"
DST="."
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

SRC="\/\*\*\*YOUR LOCAL FILE PATH\*\*\*\/CLOVER"
DST="."
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

# Reconfigure to take kwargs for location
sed -i "" -e 's/__init__(self)/__init__(self,**kwargs)/g' Scripts/*/*py

SRC="self.location = 'Bahraich'"
DST="self.location = kwargs.get('location')"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

SRC="self.location = ‘Bahraich’" # This is required too as there is some inconsistency in type of inverted commas used in original CLOVER scripts.
DST="self.location = kwargs.get('location')"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py
# Reconfigure to take '.' as filepath - necessary for HPC where CLOVER is copied to the node before processing. (May wish to amend if CLOVER dir gets very big)

Bash commands:

SRC="\/\*\*\*YOUR LOCAL FILE PATH\*\*\*\/CLOVER 4.0"
DST="."
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

SRC="\/\*\*\*YOUR LOCAL FILE PATH\*\*\*\/CLOVER"
DST="."
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py
# Reconfigure to take kwargs for location
sed -i "" -e 's/__init__(self)/__init__(self,**kwargs)/g' Scripts/*/*py

SRC="self.location = 'Bahraich'"
DST="self.location = kwargs.get('location')"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

SRC="self.location = ‘Bahraich’" # This was required too as there was some inconsistency in type of inverted commas used in original CLOVER scripts - may have been fixed by earlier commands
DST="self.location = kwargs.get('location')"
sed -i "" -e "s/$SRC/$DST/g" Scripts/*/*py

# Set up dependencies in taking kwargs for location

sed -i "" -e "s/Diesel()\./Diesel(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/Grid()\./Grid(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/Solar()\./Solar(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/Finance()\./Finance(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/GHGs()\./GHGs(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/Load()\./Load(kwargs)./g" Scripts/*/*py
sed -i "" -e "s/Energy_System()\./Energy_System(kwargs)./g" Scripts/*/*py
Replace spaces with underscores in filenames because spaces cause problems in file handling

This stops github from recognising that files are the same, which is a pity! This will need to be resolved to merge hpc CLOVER with new features in main branch

Bash commands:

rename -s ' scripts' '_scripts' Scripts/*/

for file in Scripts/*/*py;
do
   sed "s| scripts|_scripts|" $file > temp; mv temp $file;
done
…s those specified in location)

# Set up scripts to allow specification of inputs with kwargs (overrides those specified in location)

bash commands used:

for name in grid location finance GHG device optimisation energy_system scenario diesel
do
	cat > ${name}_line.py << EOF
        # Replace input values with keywords if specified
        if kwargs.get('${name}_inputs'):
            for i in kwargs.get('${name}_inputs'):
                if not i[0] in self.${name}_inputs.index:
                    print("Couldn't find entry",i[0],"in ${name}_inputs. Perhaps it's misspelt in kwargs? Printing list of possible variables and exiting.")
                    print(self.${name}_inputs.index)
                    exit(1)
            self.${name}_inputs[i[0]] = i[1]
EOF

	for file in Scripts/*/*py
	do
		sed "/        self.${name}_inputs = pd.read_csv/r ${name}_line.py" $file > tmp
		mv tmp $file
	done

rm ${name}_line.py

done
Relating to specific projects - I think unlikely to be harmful, but may not be useful
Accomodate revised file structuring (keep Jobs in separate dir and repository from main CLOVER files
Reduced number of devices for example run
New hpc users don't seem to have a work directory of the same format
Directory structure changed in 2018
Changed file format to remove \r newlines which were causing problems
- Moved launch file & added it's new home to the path in .bash_profile (readme instructions, could also add to setup file)
- Corrected time between renewables ninja requests in Load_Solar_Bhinjpur.py
Hoping this will encourage these necessary folders to be recognised in upload & download of repo
@@ -18,15 +18,23 @@
import numpy as np

class Diesel():
def __init__(self):
def __init__(self,**kwargs):
Copy link
Collaborator

@BenWinchester BenWinchester Mar 11, 2021

Choose a reason for hiding this comment

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

def __init__(self, *, location, diesel_inputs=None):
   self.location = location

Copy link
Collaborator

Choose a reason for hiding this comment

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

:)

self.location_filepath = self.CLOVER_filepath + '/Locations/' + self.location
self.generation_filepath = self.location_filepath + '/Generation/'
self.diesel_filepath = self.generation_filepath + 'Diesel/Diesel inputs.csv'
self.diesel_inputs = pd.read_csv(self.diesel_filepath,header=None,index_col=0).round(decimals=3)

# Replace input values with keywords if specified
if kwargs.get('diesel_inputs'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

if diesel_input is not None

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the kwarg is specified as above, then this would default to None if the kwarg was not specified.

self.location = 'Bahraich'
self.CLOVER_filepath = '/***YOUR LOCAL FILE PATH***/CLOVER 4.0'
self.location = kwargs.get('location')
self.CLOVER_filepath = '.'
Copy link
Collaborator

Choose a reason for hiding this comment

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

os.getcwd()

Copy link
Collaborator

Choose a reason for hiding this comment

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

Python's os module contains built-in functionality for getting the working directory.

Added indication of which kwargs can/must be specified per script (some way towards Ben's suggested safer way of specifying arguments)

Removed some of my obsolete options (quick battery recharge, efficient diesel - introduced in the earlier "miscellaneous" commit):

Left a few other additions in (which were also introduced in the earlier "miscellaneous" commit) :
- In Optimisation.py: Additional metrics around storage performance reported: LCSE, Cumulative storage cost
- In Load.py: optional arguments for different approaches to load generation
- In Optimisation.py: optional argument to dump spare battery capacity at the end of a simulation period
@BenWinchester BenWinchester added duplicate This issue or pull request already exists enhancement New feature or request and removed duplicate This issue or pull request already exists labels Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants