Skip to content

Commit

Permalink
Merge develop to main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Kumar Rajagopalan authored and Ashwin Kumar Rajagopalan committed Sep 20, 2021
2 parents f761c11 + 90fffa0 commit 8d5ab22
Show file tree
Hide file tree
Showing 36 changed files with 6,003 additions and 0 deletions.
157 changes: 157 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Graphic files
*.eps
*.pdf
*.png
*.tif
*.jpg

# Logs and databases
*.log
*.sql
*.sqlite
#*.bib
*.xlsx
*.txt

# Python related outputs
*.npy
*.npz

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
1 change: 1 addition & 0 deletions auxiliaryFunctions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# __init__.pyfrom .getCommitID import getCommitIDfrom .getCurrentDateTime import getCurrentDateTime
Expand Down
77 changes: 77 additions & 0 deletions auxiliaryFunctions/addInertGasToMaterials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
############################################################################
#
# Imperial College London, United Kingdom
# Multifunctional Nanomaterials Laboratory
#
# Project: ERASE
# Year: 2020
# Python: Python 3.7
# Authors: Ashwin Kumar Rajagopalan (AK)
#
# Purpose:
# Adds an inert gas to the exisitng material property matrix for an n gas
# system. This is done to simulate the sensor array with a full model. The
# inert is used to clean the sensor array
#
# Last modified:
# - 2021-01-20, AK: Initial creation
#
# Input arguments:
#
#
# Output arguments:
#
#
############################################################################

def addInertGasToMaterials(numberOfGases):
import numpy as np
from numpy import load
from numpy import savez
import os
import auxiliaryFunctions

# Get the commit ID of the current repository
gitCommitID = auxiliaryFunctions.getCommitID()

# Get the current date and time for saving purposes
simulationDT = auxiliaryFunctions.getCurrentDateTime()

# For now load a given adsorbent isotherm material file
if numberOfGases == 2:
loadFileName = "isothermParameters_20201020_1756_5f263af.npz" # Two gases
elif numberOfGases == 3:
loadFileName = "isothermParameters_20201022_1056_782efa3.npz" # Three gases
hypoAdsorbentFile = os.path.join('../inputResources',loadFileName);

# Check if the file with the adsorbent properties exist
if os.path.exists(hypoAdsorbentFile):
loadedFileContent = load(hypoAdsorbentFile)
adsorbentIsothermTemp = loadedFileContent['adsIsotherm']
adsorbentDensity = loadedFileContent['adsDensity']
molecularWeightTemp = loadedFileContent['molWeight']
else:
errorString = "Adsorbent property file " + hypoAdsorbentFile + " does not exist."
raise Exception(errorString)

# Create adsorent isotherm matrix with the addition of an intert gas
adsorbentIsotherm = np.zeros([numberOfGases+1,3,adsorbentIsothermTemp.shape[2]])
adsorbentIsotherm[0:numberOfGases,:,:] = adsorbentIsothermTemp

# Add the moleuclar weight of the inert (assumed to be helium)
molecularWeight = np.concatenate((molecularWeightTemp,np.array([4.00])))

# Save the adsorbent isotherm parameters into a native numpy file
# The .npz file is saved in a folder called inputResources (hardcoded)
filePrefix = "isothermParameters"
saveFileName = filePrefix + "_" + simulationDT + "_" + gitCommitID + ".npz";
savePath = os.path.join('../inputResources',saveFileName)

# Check if inputResources directory exists or not. If not, create the folder
if not os.path.exists('../inputResources'):
os.mkdir('../inputResources')

# Save the adsorbent material array
savez (savePath, adsIsotherm = adsorbentIsotherm,
adsDensity = adsorbentDensity,
molWeight = molecularWeight)
36 changes: 36 additions & 0 deletions auxiliaryFunctions/getCommitID.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
############################################################################
#
# Imperial College London, United Kingdom
# Multifunctional Nanomaterials Laboratory
#
# Project: ERASE
# Year: 2020
# Python: Python 3.7
# Authors: Ashwin Kumar Rajagopalan (AK)
#
# Purpose:
# Generates a short SHA key of the git commit id in the current branch and
# repository
#
# Last modified:
# - 2020-10-19, AK: Initial creation
#
# Input arguments:
# - N/A
#
# Output arguments:
# - short_sha: Short git commit ID
#
############################################################################

def getCommitID():
# Use gitpython to get the git information of the current repository
import git
repo = git.Repo(search_parent_directories=True)
# Get the simple hashing algorithm tag (SHA)
sha = repo.head.commit.hexsha
# Parse the first six characters of the sha
short_sha = repo.git.rev_parse(sha, short=7)

# Return the git commit id
return short_sha
33 changes: 33 additions & 0 deletions auxiliaryFunctions/getCurrentDateTime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
############################################################################
#
# Imperial College London, United Kingdom
# Multifunctional Nanomaterials Laboratory
#
# Project: ERASE
# Year: 2020
# Python: Python 3.7
# Authors: Ashwin Kumar Rajagopalan (AK)
#
# Purpose:
# Obtain the current date and time to be used either for saving in file
# name or to enhance traceability of the simulation
#
# Last modified:
# - 2020-10-19, AK: Initial creation
#
# Input arguments:
# - N/A
#
# Output arguments:
# - simulationDT: Current date and time in YYYYmmdd_HHMM format
#
############################################################################

def getCurrentDateTime():
# Get the current date and time for saving purposes
from datetime import datetime
now = datetime.now()
simulationDT = now.strftime("%Y%m%d_%H%M")

# Return the current date and time
return simulationDT
Loading

0 comments on commit 8d5ab22

Please sign in to comment.