Skip to content

Commit

Permalink
Merge pull request #3 from iSOLveIT/master
Browse files Browse the repository at this point in the history
Updated documentation and doctsrings in package files
  • Loading branch information
romainsacchi authored Jun 19, 2023
2 parents b9ffcc8 + 20aa74a commit 099374e
Show file tree
Hide file tree
Showing 68 changed files with 1,237 additions and 1,423 deletions.
2 changes: 1 addition & 1 deletion carculator_truck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

_all_ = (
__all__ = (
"TruckInputParameters",
"fill_xarray_from_input_parameters",
"TruckModel",
Expand Down
14 changes: 14 additions & 0 deletions carculator_truck/driving_cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@


def get_driving_cycle(size: list, name: str) -> np.ndarray:
"""
Get driving cycle.
:param size: List of vehicle sizes.
:param name: The name of the driving cycle.
:return: :meth:`ndarray` object
"""
return get_standard_driving_cycle_and_gradient(
vehicle_type="truck",
vehicle_sizes=size,
Expand All @@ -11,6 +18,13 @@ def get_driving_cycle(size: list, name: str) -> np.ndarray:


def get_road_gradient(size: list, name: str) -> np.ndarray:
"""
Get road gradient data.
:param size: List of vehicle sizes.
:param name: The name of the driving cycle.
:return: :meth:`ndarray` object
"""
return get_standard_driving_cycle_and_gradient(
vehicle_type="truck",
vehicle_sizes=size,
Expand Down
2 changes: 1 addition & 1 deletion carculator_truck/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def fill_in_A_matrix(self):
Fill-in the A matrix. Does not return anything. Modifies in place.
Shape of the A matrix (values, products, activities).
:param array: :attr:`array` from :class:`CarModel` class
:attr:`array` from :class:`CarModel` class
"""

# Glider/Frame
Expand Down
53 changes: 20 additions & 33 deletions carculator_truck/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TruckModel(VehicleModel):
This class represents the entirety of the vehicles considered, with useful attributes, such as an array that stores
all the vehicles parameters.
:ivar array: multi-dimensional numpy-like array that contains parameters' value(s)
:ivar array: multidimensional numpy-like array that contains parameters' value(s)
:vartype array: xarray.DataArray
:ivar mappings: Dictionary with names correspondence
:vartype mappings: dict
Expand All @@ -44,18 +44,16 @@ def set_all(self, electric_utility_factor: float = None):
efficiency of the vehicle, costs, etc.
:meth:`set_component_masses()`, :meth:`set_vehicle_masses()` and :meth:`set_power_parameters()` and
:meth:`set_energy_stored_properties` relate to one another.
:meth:`set_energy_stored_properties` relate to one another.
`powertrain_mass` depends on `power`, `curb_mass` is affected by changes in `powertrain_mass`,
`combustion engine mass`, `electric engine mass`. `energy battery mass` is influenced
by the `curb mass` but also
`combustion engine mass`, `electric engine mass`. `energy battery mass` is influencedby the `curb mass` but also
by the `target range` the truck has. `power` is also varying with `curb_mass`.
The current solution is to loop through the methods until the change in payload between
two iterations is
inferior to 0.1%. It is then assumed that the trucks are correctly sized.
:returns: Does not return anything. Modifies ``self.array`` in place.
two iterations is inferior to 0.1%. It is then assumed that the trucks are correctly sized.
:param electric_utility_factor: the share of km driven in battery-depleting mode over the required range autonomy
:return: Does not return anything. Modifies ``self.array`` in place.
"""

diff = 1.0
Expand Down Expand Up @@ -173,7 +171,6 @@ def adjust_cost(self):
"""
This method adjusts costs of energy storage over time, to correct for the overly optimistic linear
interpolation between years.
"""

n_iterations = self.array.shape[-1]
Expand Down Expand Up @@ -279,7 +276,6 @@ def set_battery_chemistry(self):
def override_range(self):
"""
Set storage size or range for each powertrain.
:return:
"""

target_ranges = {
Expand Down Expand Up @@ -322,7 +318,6 @@ def calculate_ttw_energy(self):
auxiliary services as well as to move the vehicle.
The sum is stored under the parameter label "TtW energy"
in :attr:`self.array`.
"""

self.energy = self.ecm.motive_energy_per_km(
Expand Down Expand Up @@ -405,7 +400,7 @@ def calculate_ttw_energy(self):

def set_battery_fuel_cell_replacements(self):
"""
This methods calculates the number of replacement batteries needed
These methods calculates the number of replacement batteries needed
to match the vehicle lifetime. Given the chemistry used,
the cycle life is known. Given the lifetime kilometers and
the kilometers per charge, the number of charge cycles can be inferred.
Expand All @@ -415,7 +410,6 @@ def set_battery_fuel_cell_replacements(self):
Also, the number of replacement is rounded up.
This means that the entirety of the battery replacement is allocated
to the vehicle (and not to its potential second life).
"""
# Number of replacement of battery is rounded *up*

Expand Down Expand Up @@ -464,13 +458,11 @@ def set_vehicle_masses(self):
"""
Define ``curb mass``, ``driving mass``, and ``cargo mass``.
* `curb mass <https://en.wikipedia.org/wiki/Curb_weight>`__ is the mass of the vehicle and fuel, without people or cargo.
* ``cargo mass`` is the mass of the cargo and passengers.
* ``driving mass`` is the ``curb mass`` plus ``cargo mass``.
.. note::
driving mass = cargo mass + driving mass
* `curb mass <https://en.wikipedia.org/wiki/Curb_weight>`__ is the mass of the vehicle and fuel, without people or cargo.
* ``cargo mass`` is the mass of the cargo and passengers.
* ``driving mass`` is the ``curb mass`` plus ``cargo mass``.
.. note:: driving mass = cargo mass + driving mass
"""

# Base components, common to all powertrains
Expand Down Expand Up @@ -546,11 +538,8 @@ def set_component_masses(self):

def set_electric_utility_factor(self, uf: float = None) -> None:
"""
The electric utility factor
is the share of km driven in battery-depleting mode
over the required range autonomy.
Scania's PHEV tractor can drive 60 km in electric mode
:return:
The electric utility factor is the share of km driven in battery-depleting mode
over the required range autonomy. Scania's PHEV tractor can drive 60 km in electric mode
"""
if "PHEV-e" in self.array.coords["powertrain"].values:
range = (
Expand Down Expand Up @@ -581,9 +570,7 @@ def set_electric_utility_factor(self, uf: float = None) -> None:
def set_energy_stored_properties(self):
"""
First, fuel mass is defined. It is dependent on the range required.
Then batteries are sized, depending on the range
required and the energy consumption.
:return:
Then batteries are sized, depending on the range required and the energy consumption.
"""

_ = lambda x: np.where(x == 0, 1, x)
Expand Down Expand Up @@ -848,13 +835,13 @@ def set_costs(self):

def calculate_cost_impacts(self, sensitivity=False, scope=None):
"""
This method returns an array with cost values per vehicle-km, sub-divided into the following groups:
This method returns an array with cost values per vehicle-km, subdivided into the following groups:
* Purchase
* Maintentance
* Component replacement
* Energy
* Total cost of ownership
* Purchase
* Maintenance
* Component replacement
* Energy
* Total cost of ownership
:return: A xarray array with cost information per vehicle-km
:rtype: xarray.core.dataarray.DataArray
Expand Down
Binary file modified docs/_static/img/energy_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/img/hybrid_efficiency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added docs/_static/img/image11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added docs/_static/img/image15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/_static/img/image20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/_static/img/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added docs/_static/img/image8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/img/image9.png
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file modified docs/_static/img/vecto_validation.png
Binary file modified docs/_static/resources/examples.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions docs/annexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ used to calibrate ``carculator_truck`` are shown in the table below.
+------------------+--------+---------+------------+----------------------------+-------------------------------+-------------------+-------------------------+-------------------------+--------------------------------------+
| Class 8 Aero | DayCab | PHEV-d | 40 | 510 | 280 | 510 | 55% | | |
+------------------+--------+---------+------------+----------------------------+-------------------------------+-------------------+-------------------------+-------------------------+--------------------------------------+


14 changes: 7 additions & 7 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Truck Input Parameter
Array
-----

.. automodule:: carculator_truck.array
.. automodule:: carculator_utils.array
:members:

Driving cycle
Expand All @@ -24,25 +24,25 @@ Driving cycle
Energy consumption
------------------

.. automodule:: carculator_truck.energy_consumption
.. automodule:: carculator_utils.energy_consumption
:members:

Car Model
---------
Truck Model
-----------

.. automodule:: carculator_truck.model
:members:

Noise Model
-----------

.. automodule:: carculator_truck.noise_emissions
.. automodule:: carculator_utils.noise_emissions
:members:

Hot pollutants emissions
------------------------

.. automodule:: carculator_truck.hot_emissions
.. automodule:: carculator_utils.hot_emissions
:members:

Inventory calculation
Expand All @@ -54,7 +54,7 @@ Inventory calculation
Inventory export
----------------

.. automodule:: carculator_truck.export
.. automodule:: carculator_utils.export
:members:

Background systems
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys

# sys.path.insert(0, os.path.abspath('C:\Users\sacchi_r\Documents\GitHub\coarse\coarse'))
sys.path.insert(0, os.path.abspath(".."))
sys.path.append(os.path.abspath(".."))


# -- Project information -----------------------------------------------------
Expand All @@ -24,7 +24,7 @@
author = "Romain Sacchi"

# The full version, including alpha/beta/rc tags
release = "0.3.8"
release = "0.3.9"


# -- General configuration ---------------------------------------------------
Expand All @@ -36,7 +36,6 @@
"sphinx.ext.autodoc",
"sphinxcontrib.bibtex",
"sphinx_copybutton",
"sphinx_design",
"sphinx_immaterial",
]

Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

.. _intro:

Welcome to Carculator truck’s documentation
===========================================
Carculator Truck
================

``carculator_truck`` is a parameterized model that allows to generate and characterize life cycle inventories for different
truck configurations, according to selected:
Expand Down
Binary file removed docs/media/image70.png
Diff not rendered.
Binary file removed docs/media/image71.png
Diff not rendered.
Binary file removed docs/media/image76.png
Diff not rendered.
Binary file removed docs/media/image77.png
Diff not rendered.
Binary file removed docs/media/image78.png
Diff not rendered.
Binary file removed docs/media/image80.png
Diff not rendered.
Binary file removed docs/media/image81.png
Diff not rendered.
Binary file removed docs/media/image82.png
Diff not rendered.
Binary file removed docs/media/image84.png
Diff not rendered.
Binary file removed docs/media/image85.png
Diff not rendered.
Binary file removed docs/media/image86.png
Diff not rendered.
Binary file removed docs/media/image87.png
Diff not rendered.
Binary file removed docs/media/image88.png
Diff not rendered.
Binary file removed docs/media/image89.png
Diff not rendered.
Binary file removed docs/media/image90.png
Diff not rendered.
Binary file removed docs/media/image91.png
Diff not rendered.
Binary file removed docs/media/image92.png
Diff not rendered.
Loading

0 comments on commit 099374e

Please sign in to comment.