Skip to content

Commit

Permalink
do not allow 0 sizing of battery, use ceil instead of round for num_s…
Browse files Browse the repository at this point in the history
…trings
  • Loading branch information
dguittet committed Sep 3, 2020
1 parent b2b365a commit f2d7c17
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions files/BatteryTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ def check_keys(keys):

def size_from_strings(capacity):
num_series = math.ceil(desired_voltage / batt_Vnom_default)
num_strings = round(capacity * 1000 / (batt_Qfull * batt_Vnom_default * num_series))
if num_strings < 1:
raise ValueError("Calculated number of strings less than 1; increase desired capacity.")
num_strings = math.ceil(capacity * 1000 / (batt_Qfull * batt_Vnom_default * num_series))
computed_voltage = batt_Vnom_default * num_series
computed_capacity = batt_Qfull * computed_voltage * num_strings * 0.001
max_rate = desired_power / desired_capacity
Expand Down

0 comments on commit f2d7c17

Please sign in to comment.