Skip to content

Commit

Permalink
Fix calculation of cargo mass. Moved to set_all().
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Jun 16, 2023
1 parent c765cf8 commit b9ffcc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion carculator_truck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)

# library version
__version__ = (0, 3, 9)
__version__ = (0, 4, 0)

from pathlib import Path

Expand Down
12 changes: 6 additions & 6 deletions carculator_truck/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def set_all(self, electric_utility_factor: float = None):
"available payload"
].sum()

self["cargo mass"] = np.clip(self["cargo mass"], 0, self["available payload"])

self["capacity utilization"] = np.clip(
(self["cargo mass"] / self["available payload"]), 0, 1
)

self.adjust_cost()

self.set_electric_utility_factor(electric_utility_factor)
Expand Down Expand Up @@ -520,12 +526,6 @@ def set_vehicle_masses(self):
- (self["average passengers"] * self["average passenger mass"])
)

self["cargo mass"] = np.clip(self["cargo mass"], 0, self["available payload"])

self["capacity utilization"] = np.clip(
(self["cargo mass"] / self["available payload"]), 0, 1
)

def set_component_masses(self):
self["combustion engine mass"] = (
self["combustion power"] * self["engine mass per power"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def package_files(directory):

setup(
name="carculator_truck",
version="0.3.9",
version="0.4.0",
packages=packages,
author="Romain Sacchi <[email protected]>",
license=open("LICENSE").read(),
Expand Down

0 comments on commit b9ffcc8

Please sign in to comment.