-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Chameleon-company/Haroldpsunny-patch-3
Harold Parappillil Sunny: Time required to stop at EV charger.
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
personal-work/harold-parappillil-sunny/cleaned_charging_station (1).csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ID,Power (kW),Connection Type,Location,Operator | ||
node/11885672552,50,AC,"City Center, XYZ",ChargePoint | ||
node/1189771948,250,DC,"Highway 101, ABC",Tesla Supercharger | ||
node/1253852373,22,AC,"Shopping Mall, DEF",Blink Charging | ||
node/1278067243,150,DC,"Airport, GHI",Electrify America | ||
node/1638722815,7.2,AC,"Office Park, JKL",ChargePoint |
6 changes: 6 additions & 0 deletions
6
personal-work/harold-parappillil-sunny/filtered_charging_stations_data (1).csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Model,Battery: kWh,Energy Consumption (kWh/100km),AC Charge Rate (kW),DC Charge Rate (kW) | ||
Audi e-tron,95,22,11,150 | ||
Tesla Model S,100,20,16,250 | ||
Nissan Leaf,40,15,6.6,50 | ||
BMW i3,42.2,16,7.4,50 | ||
Hyundai Kona Electric,64,14,11,100 |
149 changes: 149 additions & 0 deletions
149
personal-work/harold-parappillil-sunny/timerequired.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"import pandas as pd\n", | ||
"import os\n", | ||
"\n", | ||
"# Check if the files exist at the specified locations\n", | ||
"ev_data_path = \"/filtered_charging_stations_data (1).csv\"\n", | ||
"charger_data_path = \"/cleaned_charging_station (1).csv\"\n", | ||
"\n", | ||
"if not os.path.exists(ev_data_path):\n", | ||
" raise FileNotFoundError(f\"The file {ev_data_path} does not exist. Please check the file path.\")\n", | ||
"if not os.path.exists(charger_data_path):\n", | ||
" raise FileNotFoundError(f\"The file {charger_data_path} does not exist. Please check the file path.\")\n", | ||
"\n", | ||
"# Load the datasets\n", | ||
"ev_data = pd.read_csv(ev_data_path)\n", | ||
"charger_data = pd.read_csv(charger_data_path)\n", | ||
"\n", | ||
"# Convert the ID column to strings (if necessary)\n", | ||
"charger_data['ID'] = charger_data['ID'].astype(str)\n", | ||
"\n", | ||
"# Function to calculate charging time\n", | ||
"def calculate_charging_time(vehicle_model, current_charge, desired_charge, charger_id, temperature=None):\n", | ||
" # Filter the vehicle data based on the model\n", | ||
" vehicle_info = ev_data[ev_data['Model'].str.contains(vehicle_model, case=False, na=False)]\n", | ||
"\n", | ||
" if vehicle_info.empty:\n", | ||
" return f\"Vehicle model '{vehicle_model}' not found in the dataset.\"\n", | ||
"\n", | ||
" # Get relevant vehicle details\n", | ||
" battery_capacity_kwh = vehicle_info['Battery: kWh'].values[0]\n", | ||
" ac_charge_rate = vehicle_info['AC Charge Rate (kW)'].values[0]\n", | ||
" dc_charge_rate = vehicle_info['DC Charge Rate (kW)'].values[0]\n", | ||
"\n", | ||
" # Ensure that charger_id is in the correct format (string)\n", | ||
" charger_id = str(charger_id)\n", | ||
"\n", | ||
" # Find the charger information based on charger_id\n", | ||
" charger_info = charger_data[charger_data['ID'] == charger_id]\n", | ||
"\n", | ||
" if charger_info.empty:\n", | ||
" return f\"Charger ID '{charger_id}' not found in the dataset.\"\n", | ||
"\n", | ||
" charger_power_output = charger_info['Power (kW)'].values[0]\n", | ||
" charger_type = charger_info['Connection Type'].values[0]\n", | ||
"\n", | ||
" # Use the AC rate or DC rate depending on the charger type\n", | ||
" if charger_type == 'AC':\n", | ||
" effective_charger_power = min(charger_power_output, ac_charge_rate)\n", | ||
" else:\n", | ||
" effective_charger_power = min(charger_power_output, dc_charge_rate)\n", | ||
"\n", | ||
" # Optional: Adjust efficiency based on environmental conditions\n", | ||
" charging_efficiency = 0.90 # Default value as decimal\n", | ||
"\n", | ||
" if charger_type == 'AC':\n", | ||
" charging_efficiency = min(charging_efficiency, 0.95) # Limit max efficiency for AC chargers\n", | ||
" elif charger_type == 'DC':\n", | ||
" charging_efficiency = max(charging_efficiency, 0.90) # Set base efficiency for DC chargers\n", | ||
"\n", | ||
" if temperature is not None:\n", | ||
" if temperature < 0:\n", | ||
" charging_efficiency -= 0.1 # Decrease efficiency in cold\n", | ||
" elif temperature > 35:\n", | ||
" charging_efficiency -= 0.05 # Decrease efficiency in heat\n", | ||
"\n", | ||
" # Validate that the desired charge does not exceed battery capacity\n", | ||
" if desired_charge > 100:\n", | ||
" raise ValueError(\"Desired charge cannot exceed 100% of the battery capacity.\")\n", | ||
" # Additional Validation\n", | ||
" if battery_capacity_kwh <= 0 or current_charge < 0 or ac_charge_rate <= 0:\n", | ||
" raise ValueError(\"Battery capacity, current battery level, and charge rate must be positive values.\")\n", | ||
"\n", | ||
" # Calculate the percentage of battery needed to be charged\n", | ||
" charge_needed_percentage = desired_charge - current_charge\n", | ||
" if charge_needed_percentage <= 0:\n", | ||
" return f\"Current charge is already above or equal to the desired charge level.\"\n", | ||
"\n", | ||
" # Calculate the amount of energy (kWh) required to charge the battery to the desired level\n", | ||
" charge_needed_kwh = (charge_needed_percentage / 100) * battery_capacity_kwh\n", | ||
"\n", | ||
" # Adjust the energy required based on the charging efficiency\n", | ||
" effective_energy_needed_kwh = charge_needed_kwh / charging_efficiency\n", | ||
"\n", | ||
" # Calculate the time required to charge (in hours)\n", | ||
" charging_time_hours = effective_energy_needed_kwh / effective_charger_power\n", | ||
"\n", | ||
" # Convert charging time to minutes\n", | ||
" charging_time_minutes = charging_time_hours * 60\n", | ||
"\n", | ||
" return {\n", | ||
" 'Vehicle Model': vehicle_model,\n", | ||
" 'Current Charge (%)': current_charge,\n", | ||
" 'Desired Charge (%)': desired_charge,\n", | ||
" 'Charger Power Output (kW)': charger_power_output,\n", | ||
" 'Effective Charger Power (kW)': effective_charger_power, # Capped by max charge rate\n", | ||
" 'Charger Type': charger_type,\n", | ||
" 'Charging Efficiency': round(charging_efficiency, 2),\n", | ||
" 'Estimated Charging Time (minutes)': round(charging_time_minutes, 2)\n", | ||
" }\n", | ||
"\n", | ||
"# Get user inputs\n", | ||
"vehicle_model = input(\"Enter the vehicle model: \")\n", | ||
"current_charge = float(input(\"Enter the current charge percentage: \"))\n", | ||
"desired_charge = float(input(\"Enter the desired charge percentage: \"))\n", | ||
"charger_id = input(\"Enter the charger ID: \")\n", | ||
"temperature = float(input(\"Enter the temperature (optional, leave blank for default): \") or \"25\") # Default to 25 if left blank\n", | ||
"\n", | ||
"# Calculate and display the charging time\n", | ||
"result = calculate_charging_time(vehicle_model, current_charge, desired_charge, charger_id, temperature)\n", | ||
"print(result)\n" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "qycmjtLPxutd", | ||
"outputId": "089d321c-130c-4be8-df9f-81d9780c24da" | ||
}, | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Enter the vehicle model: Tesla Model S\n" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |