A python package to read, write, and calculate batteries in the BatPaC tool.
Project description
batpy
batpy
is a Python wrapper for Argonne National Laboratory's Microsoft Excel-based software modeling tool BatPaC.
Installation
batpy
is available from PyPI, and currently requires Python 3.9 or newer. It can be installed with:
$ pip install batpy
Documentation
Documentation for batpy
is available at GitHub Pages, including an example and documentation on all the modules and functions.
Usage
batpy
is able to read, write, and calculate batteries in the BatPaC tool.
from batpy.batpac_battery import BatpacBattery
from batpy.batpac_tool import BatpacTool
# Constants
BATPY_BATPAC_EXCEL = "./BatPaC 5.0 2022-07-22.xlsm"
BATPY_BATPAC_BATTERY_CONFIG = "./batpy_batteries_config.toml"
BATPY_BATPAC_USER_INPUT_CONFIG = "./batpy_batpac_user_input_cells.toml"
BATPY_BATPAC_TOOL_CONFIG = "./batpy_batpac_config.toml"
BATPY_BATPAC_TOOL_CALCULATION_VALIDATION_CONFIG = (
"./batpy_batpac_calculation_and_validation_results.toml"
)
# Create batteries
bat1 = BatpacBattery("Battery 1")
bat2 = BatpacBattery("Battery 2")
bat3 = BatpacBattery("Battery 3")
bat4 = BatpacBattery("Battery 4")
bat5 = BatpacBattery("Battery 5")
bat6 = BatpacBattery("Battery 6")
bat7 = BatpacBattery("Battery 7")
# Change battery properties
# a) Write individual properties for created batteries
bat1.set_new_property("Dashboard", "Number of modules in parallel", 10)
# b) Load individiual battery configuration from file
bat2.load_battery_file(
"./battery_config.toml", "Battery"
)
# Create BatPaC instance
battery_calculation = BatpacTool(
BATPY_BATPAC_EXCEL,
BATPY_BATPAC_USER_INPUT_CONFIG,
BATPY_BATPAC_TOOL_CALCULATION_VALIDATION_CONFIG,
excel_visible=True
)
# Add batteries to BatPaC instance
# a) Add individual batteries, which were created before
battery_calculation.add_battery(
[
bat1,
bat2,
bat3,
bat4,
bat5,
bat6,
bat7,
]
)
# b) Create new batteries from configuration file (will overwrite all batteries)
battery_calculation.load_batteries_file(
BATPY_BATPAC_BATTERY_CONFIG,
[
bat1,
bat2,
bat3,
bat4,
bat5,
bat6,
bat7,
],
)
# Load configuration file for BatPaC instance
battery_calculation.load_batpac_file(BATPY_BATPAC_TOOL_CONFIG)
# Write configuration in Excel file and calculate batteries
battery_calculation.calculate()
battery_calculation.read_calculation_and_validation_results()
# Save configuration from Excel:
battery_calculation.save_config(
batpac_path="./saved_batpac_config.toml",
battery_path="./saved_batteries_config.toml",
)
# Save Excel file
battery_calculation.save("./saved_BatPaC.xlsm")
# Close Excel file
battery_calculation.close()
Contributing
Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
License
batpy
was created by Raphael Ginster. It is licensed under the terms of the MIT license.
Credits
batpy
was created with cookiecutter
and the py-pkgs-cookiecutter
template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.