Metadata-Version: 2.1
Name: batpy
Version: 0.0.5
Summary: A python package to read, write, and calculate batteries in the BatPaC tool.
Home-page: https://github.com/rginster/batpy
License: MIT
Author: Raphael Ginster
Author-email: r.ginster@tu-braunschweig.de
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: pathlib (>=1.0.1,<2.0.0)
Requires-Dist: prettytable (>=3.7.0,<4.0.0)
Requires-Dist: semantic-version (>=2.10.0,<3.0.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Requires-Dist: tqdm (>=4.65.0,<5.0.0)
Requires-Dist: xlwings (>=0.30.4,<0.31.0)
Project-URL: Documentation, https://rginster.github.io/batpy/
Project-URL: Repository, https://github.com/rginster/batpy
Description-Content-Type: text/markdown

[![ci-cd](https://github.com/rginster/batpy/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/rginster/batpy/actions/workflows/ci-cd.yaml)
[![PyPI version](https://badge.fury.io/py/batpy.svg)](https://badge.fury.io/py/batpy)


# batpy

`batpy` is a Python wrapper for [Argonne National Laboratory's](https://www.anl.gov) Microsoft Excel-based [software modeling tool BatPaC](https://www.anl.gov/partnerships/batpac-battery-manufacturing-cost-estimation).

## Installation

`batpy` is available from [PyPI](https://pypi.org/project/batpy/), and currently requires Python 3.9 or newer. It can be installed with:
```bash
$ pip install batpy
```

## Documentation

Documentation for `batpy` is available at [GitHub Pages](https://rginster.github.io/batpy/), 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](https://www.anl.gov/partnerships/batpac-battery-manufacturing-cost-estimation).



```python
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](https://www.tu-braunschweig.de/en/aip/pl/team/ginster). It is licensed under the terms of the MIT license.

## Credits

`batpy` was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).

