Browse Source

Some fine tuning

master
Maximilian Stiefel 3 years ago
parent
commit
a85ab2beac
  1. 8
      README.md
  2. 16
      ecar.py
  3. 3
      example_0.json
  4. BIN
      pictures/plot_ex_0.png

8
README.md

@ -33,17 +33,17 @@ Important milestones the script allows to calculate depending on personal drivin
The plot below can be generated with The plot below can be generated with
``` ```
python3 ecar.py --settings ecar.json -b -c -d -e -f --plot 3 python3 ecar.py --settings example_0.json -b -c -d -e -f --plot 3
``` ```
This will also lead to the following output This will lead to the following output.
``` ```
Break even after 0.0 years and 3.0 months. Break even after 0.0 years and 3.0 months.
Savings per month based on yearly spending: 279.83. Savings per month based on yearly spending: 279.83.
Savings per year: 3358.0. Savings per year: 3358.0.
Costs driving 100 km in the Nissan Leaf 2013: 3.5. Costs driving 100 km in the Suzuki Grand Vitara 2008: 14. Costs driving 100 km in the Nissan Leaf 2013: 3.5. Costs driving 100 km in the Suzuki Grand Vitara 2008: 14.
The electric vehicle will be amortized by savings after 2.0 years, 4.0 months or exactely at 45265.04 kilometres. The electric vehicle will be amortized by savings after 2.0 years, 7.0 months or exactely at 50666.67 kilometres.
``` ```
![Example 0](https://git.stiefel.tech/m3x1m0m/EconomicsOfAnElectricVehicle/raw/branch/master/pictures/plot_ex_0.png) ![Example 0](https://git.stiefel.tech/m3x1m0m/EconomicsOfAnElectricVehicle/raw/branch/master/pictures/plot_ex_0.png)

16
ecar.py

@ -9,7 +9,7 @@ class c_settings_extractor:
def __init__(self, fname): def __init__(self, fname):
with open(fname, "r") as rf: with open(fname, "r") as rf:
settings = json.load(rf) settings = json.load(rf)
kilometer_price_ccar = settings["ccar"]["litres_per_kilometer"] * settings["petrol_litre_price"] kilometer_price_ccar = settings["ccar"]["litres_per_kilometer"] * settings["juice_litre_price"]
self.labels = [settings["ecar"]["label"], settings["ccar"]["label"]] self.labels = [settings["ecar"]["label"], settings["ccar"]["label"]]
self.purchase = np.array([settings["ecar"]["price"], settings["ccar"]["price"]]) self.purchase = np.array([settings["ecar"]["price"], settings["ccar"]["price"]])
self.taxes = np.array([settings["ecar"]["taxes"], settings["ccar"]["taxes"]]) self.taxes = np.array([settings["ecar"]["taxes"], settings["ccar"]["taxes"]])
@ -138,22 +138,26 @@ def main():
current_y = current_y + maintenance current_y = current_y + maintenance
y += 1 y += 1
labels = ["Purchase", "Taxes", "Insurance", "Driving", "Maintenance"] labels = ["Purchase", "Taxes", "Insurance", "Driving", "Maintenance"]
lnspace_start = -0.2
lnspace_stop = 1.2
lnspace_n = 10
x_text = 0.2
if args.break_even: if args.break_even:
months_a_year = 12.0 months_a_year = 12.0
be_money = (be_years + be_months/months_a_year) * comparator.calculate_costs_a_year() be_money = (be_years + be_months/months_a_year) * comparator.calculate_costs_a_year()
be_money = be_money[1] + extractor.get_purchase() be_money = be_money[1] + extractor.get_purchase()
ax.plot(np.linspace(-0.2, 1.2, 10), [be_money[1]]*10, "--", color = plt_colors[2], label = "Break even") ax.plot(np.linspace(lnspace_start, lnspace_stop, lnspace_n), [be_money[1]]*lnspace_n, "--", color = plt_colors[2], label = "Break even")
ax.text(0.3, be_money[1] + 100, "Break even: {} years, {} months, {} kilometers".format(be_years, be_months, be_kilometers)) ax.text(x_text, be_money[1] + 100, "Break even: {} years, {} months, {} kilometers".format(be_years, be_months, be_kilometers))
labels = ["Break even"] + labels labels = ["Break even"] + labels
if args.amortization: if args.amortization:
months_a_year = 12.0 months_a_year = 12.0
am_money = (am_years + am_months/months_a_year) * comparator.calculate_costs_a_year() am_money = (am_years + am_months/months_a_year) * comparator.calculate_costs_a_year()
am_money = am_money[1] + extractor.get_purchase() am_money = am_money[1] + extractor.get_purchase()
ax.plot(np.linspace(-0.2, 1.2, 10), [am_money[1]]*10, "--", color = plt_colors[2], label = "Amortization") ax.plot(np.linspace(lnspace_start, lnspace_stop, lnspace_n), [am_money[1]]*lnspace_n, "--", color = plt_colors[2], label = "Amortization")
ax.text(0.3, am_money[1] + 100, "Amortization: {} years, {} months, {} kilometers".format(am_years, am_months, am_kilometers)) ax.text(x_text, am_money[1] + 100, "Amortization: {} years, {} months, {} kilometers".format(am_years, am_months, am_kilometers))
labels = ["Amortization"] + labels labels = ["Amortization"] + labels
ax.set_ylabel(extractor.get_currency()) ax.set_ylabel(extractor.get_currency())
ax.set_title("Comparision of economics electric vs. combustion car") ax.set_title("Comparision of economics: Electric vs. combustion car")
ax.legend(labels) ax.legend(labels)
ax.grid(axis = "y") ax.grid(axis = "y")
plt.show() plt.show()

3
ecar.json → example_0.json

@ -2,9 +2,8 @@
"currency": "CHF", "currency": "CHF",
"kwh_price_home": 0.2, "kwh_price_home": 0.2,
"kwh_price_commercial": 0.5, "kwh_price_commercial": 0.5,
"petrol_litre_price": 1.75, "juice_litre_price": 1.75,
"kilometers_per_year": 20000.0, "kilometers_per_year": 20000.0,
"years": 6,
"ecar": { "ecar": {
"label": "Nissan Leaf 2013", "label": "Nissan Leaf 2013",
"price": 7600, "price": 7600,

BIN
pictures/plot_ex_0.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Loading…
Cancel
Save