### Start Jupyter Notebook Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/run_model.md Launch the Jupyter Notebook server to access and run the time-series generation notebook. Requires Jupyter to be installed. ```bash $ jupyter notebook ``` -------------------------------- ### Install emobpy Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/README.rst Install the package using pip. ```console pip install emobpy ``` -------------------------------- ### Install emobpy Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/installation.md Installs the emobpy package and its dependencies from PyPI. ```bash $ pip install emobpy ``` -------------------------------- ### Launch Jupyter Notebook Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/README.rst Start the Jupyter notebook server for interactive exploration. ```console jupyter notebook ``` -------------------------------- ### Get First Availability Data Name Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Retrieves the name of the first loaded availability dataset. ```python aname = list(DBa.db.keys())[0] aname ``` -------------------------------- ### Create a new emobpy project Source: https://context7.com/diw-evu/emobpy/llms.txt Initialize a project directory with necessary configuration templates and scripts. ```bash # Create a new project from the base template emobpy create -n my_ev_project # Navigate to the project folder cd my_ev_project # The project contains: # - config_files/DepartureDestinationTrip.csv # - config_files/DistanceDurationTrip.csv # - config_files/TripsPerDay.csv # - config_files/rules.yml # - config_files/seed.txt # - Step1Mobility.py through Step4GridDemand.py # - Time-series_generation.ipynb ``` -------------------------------- ### Create a project folder Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/README.rst Initialize a new project directory named my_evs. ```console emobpy create -n my_evs ``` -------------------------------- ### Create a project from a template Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/examples.md Use this command to initialize a new project directory based on a specific template. ```bash $ dieterpy create_project -n myproject -t eg1 ``` ```bash dieterpy create_project -n myproject ``` -------------------------------- ### Initialize emobpy and load modules Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Visualize_and_Export.ipynb Import necessary classes from emobpy. ```python from emobpy import DataBase, Export from emobpy.plot import NBplot ``` -------------------------------- ### Executing Complete Pipeline Source: https://context7.com/diw-evu/emobpy/llms.txt Demonstrates the full workflow from mobility simulation to consumption, availability, and charging profile generation. ```python from emobpy import ( Mobility, Consumption, Availability, Charging, DataBase, BEVspecs, HeatInsulation ) from emobpy.tools import set_seed # Set reproducible seed set_seed(seed=123) # Step 1: Create mobility profile mobility = Mobility(config_folder='config_files') mobility.set_params( name_prefix='demo', total_hours=168, time_step_in_hrs=0.25, # 15-minute resolution reference_date='01/01/2020' ) mobility.set_stats('TripsPerDay.csv', 'DepartureDestinationTrip.csv', 'DistanceDurationTrip.csv') mobility.set_rules(rule_key='user_defined', rules_path='rules.yml') mobility.run() mobility.save_profile(folder='output') print(f"Step 1 complete: {mobility.name}") # Step 2: Create consumption profile DB = DataBase(folder='output') DB.loadfiles() vehicles = BEVspecs() ev = vehicles.model(('Volkswagen', 'ID.3', 2020)) ev.add({ 'transmission_eff': 0.95, 'battery_charging_eff': 0.95, 'battery_discharging_eff': 0.95, 'hvac_cop_heating': 2.0, 'hvac_cop_cooling': 2.5, 'auxiliary_power': 0.3, 'cabin_volume': 2.5 }) insulation = HeatInsulation(default=True) consumption = Consumption(inpt=mobility.name, ev_model=ev) consumption.load_setting_mobility(DB) consumption.run( heat_insulation=insulation, weather_country='DE', weather_year=2016, driving_cycle_type='WLTC' ) consumption.save_profile(folder='output') print(f"Step 2 complete: {consumption.name}") # Step 3: Create availability profile DB.loadfiles() charging_scenario = { 'prob_charging_point': { 'home': {'home': 0.9, 'none': 0.1}, 'workplace': {'workplace': 0.5, 'none': 0.5}, 'shopping': {'none': 1.0}, 'leisure': {'none': 1.0}, 'errands': {'none': 1.0}, 'escort': {'none': 1.0}, 'driving': {'none': 1.0} }, 'capacity_charging_point': {'home': 11, 'workplace': 22, 'none': 0} } availability = Availability(inpt=consumption.name, db=DB) availability.set_scenario(charging_scenario) availability.run() availability.save_profile(folder='output') print(f"Step 3 complete: {availability.name}") # Step 4: Create charging profile DB.loadfiles() charging = Charging(inpt=availability.name) charging.load_scenario(DB) charging.set_sub_scenario('balanced') charging.run() charging.save_profile(folder='output') print(f"Step 4 complete: {charging.name}") # Final summary print(f"\n=== Final Time Series ===") print(charging.timeseries[['hh', 'state', 'charge_grid', 'actual_soc']].head(20)) print(f"\nTotal grid consumption: {charging.timeseries['charge_grid'].sum() * 0.25:.2f} kWh") ``` -------------------------------- ### BEVspecs: Get Maximum Parameter Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Returns the maximum value of a specified parameter from the vehicle data. ```python bev_specs.maximum(parameter='power') ``` -------------------------------- ### Initialize and Run Availability Class Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Instantiate the Availability class with a consumption profile name and a DataBase instance. Then, set the scenario with charging data, run the simulation, and save the resulting profile. ```python GA = Availability('ev1_abc_tesla3_def', DB) GA.set_scenario(charging_data) GA.run() GA.save_profile('path to folder') ``` -------------------------------- ### Get First Charging Data Name Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Retrieves the name of the first loaded charging dataset. ```python dname = list(DBd.db.keys())[0] dname ``` -------------------------------- ### Initialize emobpy Project with Template Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/eg1.md Use this command to create a new emobpy project, specifying a name and a template. Ensure you have a dedicated emobpy environment activated before running. ```bash $ emobpy create -n -t eg1 ``` -------------------------------- ### Get First Consumption Data Name Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Retrieves the name of the first loaded consumption dataset. ```python cname = list(DBc.db.keys())[0] cname ``` -------------------------------- ### Initialize emobpy project Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/basecase.md Creates a new project folder and file structure without using a specific template. ```bash $ emobpy create -n ``` -------------------------------- ### Project Initialization Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Utilities for creating project folders and managing user data directories. ```APIDOC ## emobpy.init.create_project ### Description Creates a project based on a selected template and copies necessary files. ### Parameters - **project_name** (str) - Required - Chosen project name. - **template** (str) - Required - Chosen template. ### Errors - Raises Exception if template arguments are not valid or the folder does not exist. ``` -------------------------------- ### BEVspecs: Get Average Parameter Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Calculates and returns the average value of a specified parameter from the vehicle data. ```python bev_specs.average(parameter='power') ``` -------------------------------- ### Get First Driving Mobility Name Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Retrieves the name of the first loaded driving mobility dataset. ```python mname = list(DBm.db.keys())[0] mname ``` -------------------------------- ### Navigate to project folder Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/README.rst Change the current directory to the newly created project folder. ```console cd my_evs ``` -------------------------------- ### BEVspecs: Get Fallback Parameter Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Retrieves a fallback data value for a given parameter if the primary data is missing. ```python bev_specs.get_fallback_parameter(parameter='charging_time_full') ``` -------------------------------- ### Configure Consumption Simulation Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg1/eg1.ipynb Sets up the database, heat insulation, and vehicle specification instances required for consumption calculations. ```python DB = DataBase('db') # Instance of profiles' database whose input is the pickle files' folder DB.loadfiles_batch(kind="driving") # loading mobility pickle files to the database mname = list(DB.db.keys())[0] # getting the id of the first mobility profile HI = HeatInsulation(True) # Creating the heat insulation configuration by copying the default configuration BEVS = BEVspecs() # Database that contains BEV models ``` -------------------------------- ### BEVspecs: Get Vehicle Parameter Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Retrieves a specific parameter for a given vehicle model and year. Returns None if the information is not found. ```python bev_specs.get(brand='Volkswagen', model='ID.3', year=2020, parameter='acc_0_100_kmh') ``` -------------------------------- ### Initialize User Data Directory Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg1/eg1.ipynb Optional utility to copy default configuration files to the user's data directory. ```python # # Read the docstrings of function copy_to_user_data_dir # from emobpy.init import copy_to_user_data_dir; copy_to_user_data_dir() ``` -------------------------------- ### Get DataBase Keys Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Retrieves a list of keys (names) of all loaded mobility profiles within the DataBase. This can be used to identify available profiles. ```python DB.db.keys() ``` -------------------------------- ### Get Mobility Profile Name for Consumption Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Retrieves the name of the mobility profile to be used for consumption calculations. It defaults to the name of the last created mobility profile 'm'. ```python # mname = list(DB.db.keys())[0] # getting the id of the first mobility profile mname = m.name ``` -------------------------------- ### Import Charging Module and Define Strategies Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Initializes the Charging class and defines various charging strategies. ```python from emobpy import Charging ``` ```python DB.update() aname = ga.name # getting the id of the availability profile strategies = [ "immediate", # When battery has SOC < 100% then it charges immediatelly at a maximun power rating of the current charging station "balanced", # When battery has SOC < 100% then it charges immediatelly but at lower rating power to ensure 100% SOC at the end (before moving to another place). "from_0_to_24_at_home", # Customized: starting time of charging (this case 0 hrs), final time of charging (this case 24 hrs), at could be one 'location' (this case 'home') or 'any'. "from_23_to_8_at_any" ] ``` -------------------------------- ### Configure and Run Consumption Simulation for Renault Zoe Q90 Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Initializes a Renault Zoe Q90 model, sets up a consumption object with mobility data, and runs a detailed simulation. The simulation results are saved. ```python ZOE = BEVS.model(('Renault', 'Zoe Q90', 2019)) c = Consumption(mname, ZOE) c.load_setting_mobility(DB) c.run( heat_insulation=HI, weather_country='DE', weather_year=2016, passenger_mass=75, # kg passenger_sensible_heat=70, # W passenger_nr=1.5, air_cabin_heat_transfer_coef=20, # W/(m2K) air_flow=0.02, # m3/s driving_cycle_type='WLTC', road_type=0, road_slope=0 ) c.save_profile('db') ``` -------------------------------- ### Execute emobpy Simulation Scripts Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Instructions.rst Run the Python scripts in the specified order to perform the mobility, consumption, grid availability, and grid demand modeling. Results are saved as pickle files. ```bash cd python Step1Mobility.py python Step2DrivingConsumption.py python Step3GridAvailability.py python Step4GridDemand.py ``` -------------------------------- ### Create a New emobpy Project Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/create_project.md Use this command to create a new project directory. The project name must not contain spaces. The `--name` or `-n` flag is required. ```bash $ emobpy create -n my_evs ``` ```bash $ emobpy create --name my_evs ``` -------------------------------- ### Initialize Emobpy Environment Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg1/eg1.ipynb Imports necessary modules and sets the random seed for reproducibility. ```python from emobpy import Mobility, Consumption, HeatInsulation, BEVspecs, DataBase, Export from emobpy.plot import NBplot # Initialize seed from emobpy.tools import set_seed set_seed() ``` -------------------------------- ### Create Availability Profile Source: https://context7.com/diw-evu/emobpy/llms.txt Initializes and runs an availability profile based on consumption data. ```python # Create availability profile availability = Availability(inpt=consumption_profile, db=DB) availability.set_scenario(charging_data) availability.run() # Check results print(f"Profile name: {availability.name}") print(f"Success: {availability.success}") print(f"SOC init: {availability.soc_init} -> SOC end: {availability.soc_end}") print(availability.timeseries.head(20)) # Output columns: hh, state, distance, consumption, charging_point, charging_cap, soc # Save profile availability.save_profile(folder='profiles', description='Home and workplace charging') ``` -------------------------------- ### Initialize and Load Data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg3/Visualize_and_Export.ipynb Import necessary modules and load mobility time-series data into the database. ```python from emobpy import DataBase, Export from emobpy.plot import NBplot ``` ```python DBm = DataBase('db') DBm.loadfiles_batch(kind="driving") # load files in parallel that only contains Mobility time-series ``` ```python mname = list(DBm.db.keys())[0] mname ``` -------------------------------- ### Project file structure Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/basecase.md The directory layout generated after initializing the base case. ```text ├── my_evs │   └── config_files │   ├── DepartureDestinationTrip.csv │   ├── DistanceDurationTrip.csv │   ├── TripsPerDay.csv │   ├── rules.yml │   ├── Time-series_generation.ipynb │   ├── Step1Mobility.py │   ├── Step2DrivingConsumption.py │   ├── Step3GridAvailability.py │   ├── Step4GridDemand.py │   ├── Visualize_and_Export.ipynb ``` -------------------------------- ### Initialize Heat Insulation and BEV Specs Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Creates instances for heat insulation configuration and a database of Battery Electric Vehicle (BEV) specifications. These are used in the consumption simulation. ```python HI = HeatInsulation(True) BEVS = BEVspecs() ``` -------------------------------- ### Import Availability Module Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Initializes the Availability class from the emobpy library. ```python from emobpy import Availability ``` -------------------------------- ### emobpy Project File Structure Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/eg1.md This illustrates the typical directory and file structure created by the 'emobpy create' command when using the 'eg1' template. All simulation and visualization tasks are performed within the 'eg1.ipynb' Jupyter notebook. ```bash ├── my_evs │ └── config_files │ ├── DepartureDestinationTrip_Worker.csv │ ├── DistanceDurationTrip.csv │ ├── rules.yml │ ├── TripsPerDay.csv │ ├── eg1.ipynb ``` -------------------------------- ### Configure and Run Consumption Simulation for Volkswagen ID.3 Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Initializes a Volkswagen ID.3 model, sets up a consumption object with mobility data, and runs a detailed simulation including environmental and passenger parameters. The results are then saved. ```python VW_ID3 = BEVS.model(('Volkswagen', 'ID.3', 2020)) c = Consumption(mname, VW_ID3) c.load_setting_mobility(DB) c.run( heat_insulation=HI, weather_country='DE', weather_year=2016, passenger_mass=75, # kg passenger_sensible_heat=70, # W passenger_nr=1.5, air_cabin_heat_transfer_coef=20, # W/(m2K) air_flow=0.02, # m3/s driving_cycle_type='WLTC', road_type=0, road_slope=0 ) c.save_profile('db') ``` -------------------------------- ### Initialize Emobpy User Data Directory Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md This function creates the necessary user data directory for emobpy if it does not exist. It is typically run when a project is created from the command line. If the directory is missing, errors may occur when using the Consumption class. ```python from emobpy.init import copy_to_user_data_dir copy_to_user_data_dir() ``` -------------------------------- ### Initialize Heat Insulation Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates a HeatInsulation object, optionally copying default configurations. This is used in consumption calculations to model thermal properties. ```python HI = HeatInsulation(True) # Creating the heat insulation by copying the default configuration ``` -------------------------------- ### Initialize DataBase Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates a DataBase object to manage mobility profiles stored in a specified folder. This is used for loading, managing, and querying saved profiles. ```python from emobpy import DataBase DB = DataBase('db') ``` -------------------------------- ### emobpy Project File Structure Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg1/Instructions.rst This is the typical file and folder structure created after initializing an emobpy project using the 'eg1' template. The main analysis and visualization occur within the 'eg1.ipynb' notebook. ```bash ├── my_evs │   └── config_files │   ├── DepartureDestinationTrip_Worker.csv │   ├── DistanceDurationTrip.csv │   ├── rules.yml │   ├── TripsPerDay.csv │   ├── eg1.ipynb ``` -------------------------------- ### Initialize Mobility Class Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Instantiate the Mobility class. The config_folder parameter specifies the location of configuration files. ```python mobility = Mobility(config_folder='config_files') ``` -------------------------------- ### Initialize MathJax Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Configures MathJax settings for rendering mathematical equations in the environment. ```javascript init_mathjax = function() { if (window.MathJax) { // MathJax loaded MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true }, displayAlign: 'center', CommonHTML: { linebreaks: { automatic: true } }, "HTML-CSS": { linebreaks: { automatic: true } } }); MathJax.Hub.Queue(["Typeset", MathJax.Hub]); } } init_mathjax(); ``` -------------------------------- ### Initialize Overview Plotting Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Creates an NBplot object for generating an overview plot. ```python viz = NBplot(DB) ``` -------------------------------- ### emobpy Project Structure Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/create_project.md This illustrates the default folder and file structure created for a new emobpy project. It includes configuration files, Python scripts for simulation steps, and Jupyter notebooks for analysis. ```bash ├── my_evs │ └── config_files │ ├── DepartureDestinationTrip.csv │ ├── DistanceDurationTrip.csv │ ├── TripsPerDay.csv │ ├── rules.yml │ ├── Time-series_generation.ipynb │ ├── Step1Mobility.py │ ├── Step2DrivingConsumption.py │ ├── Step3GridAvailability.py │ ├── Step4GridDemand.py │ ├── Visualize_and_Export.ipynb ``` -------------------------------- ### Navigate to Project Directory Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/run_model.md Change to the project directory before running the model. Ensure a conda environment is activated. ```bash $ cd my_evs ``` -------------------------------- ### Initialize Mobility Profile Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates a Mobility object, specifying the configuration folder. This is the first step in generating vehicle mobility time series. ```python from emobpy import Mobility m = Mobility(config_folder='config_files') ``` -------------------------------- ### Create Emobpy Project Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Use this function to create a new project based on a selected template. It copies the necessary files for the project. Ensure the chosen template and project directory are valid. ```python from emobpy.init import create_project # Example usage: create_project(project_name='my_new_project', template='default_template') ``` -------------------------------- ### Verify Conda environments Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/installation.md Lists all available Conda environments to confirm the new environment was created successfully. ```bash conda info --envs ``` -------------------------------- ### Initialize Database and Load Mobility Data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Instantiates a DataBase object and loads mobility pickle files. This is a prerequisite for accessing vehicle and driving data. ```python DB = DataBase('db') DB.loadfiles_batch(kind="driving") mname = list(DB.db.keys())[0] ``` -------------------------------- ### Availability Class Initialization Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Initializes the Availability object with a driving consumption profile and a database instance. ```APIDOC ## Availability(inpt, db) ### Description Initializes an instance that represents a grid availability time series. ### Parameters - **inpt** (str) - Required - Driving consumption profile name. - **db** (DataBase) - Required - Class instance that contains the profiles. ``` -------------------------------- ### Configure Plotly and MathJax Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Sets up Plotly and MathJax configurations for the notebook environment. ```javascript window.PlotlyConfig = {MathJaxConfig: 'local'}; if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});} if (typeof require !== 'undefined') { require.undef("plotly"); requirejs.config({ paths: { 'plotly': ['https://cdn.plot.ly/plotly-2.4.2.min'] } }); require(['plotly'], function(Plotly) { window._Plotly = Plotly; }); } ``` -------------------------------- ### Generate Availability Time Series Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Sets up and runs the availability profile generation process. ```python ga = Availability(cname, DB) ``` ```python ga.set_scenario(station_distribution) ``` ```python ga.run() ``` ```python ga.save_profile('db') ``` -------------------------------- ### Load DataBase Files Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Loads all mobility profile files found in the DataBase folder. This operation should be performed after initializing the DataBase object. ```python DB.loadfiles() ``` -------------------------------- ### emobpy.consumption Module Functions Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Functions for loading settings, running simulations, and saving profiles. ```APIDOC ## Module Functions: emobpy.consumption ### Description Functions for loading settings, running simulations, and saving profiles. ### Functions #### load_setting_mobility(DataBase) ##### Description Load certain attributes of the object with data from the transferred database. ##### Parameters - **DataBase** (DataBase()) – Database from which the data is to be loaded. ##### Raises - **ValueError** – A driving profile can not be found in the database. #### run(heat_insulation, weather_country='DE', weather_year=2016, passenger_mass=75, passenger_sensible_heat=70, passenger_nr=1.5, air_cabin_heat_transfer_coef=10, air_flow=0.01, driving_cycle_type='WLTC', road_type=0, wind_speed=0, road_slope=0) ##### Description Runs the mobility simulation with specified parameters. ##### Parameters - **heat_insulation** (object) – [description] - **weather_country** (str, optional) – [description]. Defaults to “DE”. - **weather_year** (int, optional) – [description]. Defaults to 2016. - **passenger_mass** (int, optional) – Passenger mass in kg. Defaults to 75. - **passenger_sensible_heat** (int, optional) – Passenger sensible heat in W. Defaults to 70. - **air_cabin_heat_transfer_coef** (int, optional) – Coefficient in W/(m2K). Defaults to 10. - **air_flow** (float, optional) – Ranges from 0.02 (high ventilation) to 0.001 (minimum ventilation) in me/s. Defaults to 0.01. - **driving_cycle_type** (str, optional) – [desc]. Defaults to “WLTC”. - **road_type** (int, optional) – See function rolling_resistance_coef(method=’M1’) if an integer then all trips have the same value, if list must fit the length of the profile. Defaults to 0. - **wind_speed** (int, optional) – m/s if an integer then all trips have the same value, if list must fit the length of the profile. Defaults to 0. - **road_slope** (int, optional) – Radians if an integer then all trips have the same value, if list must fit the length of the profile. Defaults to 0. ##### Raises - **Exception** – [description] #### save_profile(folder, description=' ') ##### Description Saves object profile as a pickle file. ##### Parameters - **folder** (str) – Where the files will be stored. Folder is created in case it does not exist. - **description** (str, optional) – Description which can be saved in object attribute. Defaults to “ “. ``` -------------------------------- ### Define HeatInsulation Properties Source: https://context7.com/diw-evu/emobpy/llms.txt Configures thermal insulation parameters for HVAC energy calculations. Use default=True for standard values or instantiate without arguments for custom configurations. ```python from emobpy import HeatInsulation # Use default insulation values insulation = HeatInsulation(default=True) # Or define custom insulation properties insulation = HeatInsulation() # View current settings insulation.show() # Shows: zone_layers, zone_surface, layer_conductivity, layer_thickness # Access arrays for calculations print(f"Zone layers: {insulation.zone_layers_}") print(f"Zone surface areas: {insulation.zone_surface_}") print(f"Layer conductivity: {insulation.layer_conductivity_}") print(f"Layer thickness: {insulation.layer_thickness_}") ``` -------------------------------- ### Generate database overview plot Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Visualize_and_Export.ipynb Create an overview plot for the database. ```python viz = NBplot(DB) ``` ```python fig = viz.overview(dname) fig.show() ``` -------------------------------- ### Load Charging Data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Initializes a DataBase object and loads charging data. ```python DBd = DataBase('db') DBd.loadfiles_batch(kind="charging") ``` -------------------------------- ### Create Charging Profiles Source: https://context7.com/diw-evu/emobpy/llms.txt Generates grid electricity demand time series using different charging strategies like immediate, balanced, or time-windowed charging. ```python from emobpy import Charging, DataBase # Load all profiles DB = DataBase(folder='profiles') DB.loadfiles() # Get an availability profile name availability_profile = [k for k in DB.db.keys() if DB.db[k]['kind'] == 'availability'][0] # Create charging profile with immediate charging strategy charging_immediate = Charging(inpt=availability_profile) charging_immediate.load_scenario(DB) charging_immediate.set_sub_scenario('immediate') # Charge at max power immediately charging_immediate.run() print(f"Immediate charging profile: {charging_immediate.name}") print(f"Success: {charging_immediate.success}") print(charging_immediate.timeseries.head(20)) # Output: hh, state, distance, consumption, charging_point, charging_cap, # actual_soc, charge_battery, charge_grid charging_immediate.save_profile(folder='profiles') # Create balanced charging profile charging_balanced = Charging(inpt=availability_profile) charging_balanced.load_scenario(DB) charging_balanced.set_sub_scenario('balanced') # Spread charging over connection time charging_balanced.run() print(f"Balanced charging profile: {charging_balanced.name}") charging_balanced.save_profile(folder='profiles') # Create time-window charging (charge only from 22:00 to 6:00 at home) charging_night = Charging(inpt=availability_profile) charging_night.load_scenario(DB) charging_night.set_sub_scenario('from_22_to_6_at_home') charging_night.run() print(f"Night charging profile: {charging_night.name}") charging_night.save_profile(folder='profiles') ``` -------------------------------- ### Load Availability Data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Initializes a DataBase object and loads availability data. ```python DBa = DataBase('db') DBa.loadfiles_batch(kind="availability") ``` -------------------------------- ### Initialize Plotting Utility Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates an NBplot object, which is used for generating various plots from the DataBase. It requires a DataBase instance as input. ```python from emobpy.plot import NBplot PLT = NBplot(DB) ``` -------------------------------- ### Initialize Charging Data Plotting Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Creates an NBplot object for visualizing charging data. ```python vizd = NBplot(DBd) ``` -------------------------------- ### run Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Executes the availability time series generation process. ```APIDOC ## run() ### Description Runs the allocation process to generate the charging availability time series. Once finished, attributes like 'timeseries' and 'success' become available. ``` -------------------------------- ### Initialize Consumption Calculation Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates a Consumption object to calculate driving energy consumption. It requires the mobility profile name and a vehicle model instance. ```python from emobpy import Consumption, HeatInsulation, BEVspecs c = Consumption(mname, VW_ID3) ``` -------------------------------- ### Initialize BEV Specifications Database Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Creates a BEVspecs object, which acts as a database for various electric vehicle models and their parameters. ```python BEVS = BEVspecs() # Database that contains BEV models ``` -------------------------------- ### Initialize Availability Data Plotting Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Creates an NBplot object for visualizing availability data. ```python viza = NBplot(DBa) ``` -------------------------------- ### Configure and Run Consumption Simulation for Tesla Model S Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html Initializes a Tesla Model S 60D model, sets up a consumption object with mobility data, and runs a detailed simulation. The results are saved to the database. ```python MODEL_3 = BEVS.model(('Tesla', 'Model S 60D', 2017)) c = Consumption(mname, MODEL_3) c.load_setting_mobility(DB) c.run( heat_insulation=HI, weather_country='DE', weather_year=2016, passenger_mass=75, # kg passenger_sensible_heat=70, # W passenger_nr=1.5, air_cabin_heat_transfer_coef=20, # W/(m2K) air_flow=0.02, # m3/s driving_cycle_type='WLTC', road_type=0, road_slope=0 ) c.save_profile('db') ``` -------------------------------- ### Load and visualize availability data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Visualize_and_Export.ipynb Load availability data and generate a plot. ```python DBa = DataBase('db') DBa.loadfiles_batch(kind="availability") ``` ```python aname = list(DBa.db.keys())[0] aname ``` ```python viza = NBplot(DBa) ``` ```python figg = viza.sgplot_ga(aname, rng=None, to_html=False, path=None) ``` ```python figg.show() ``` -------------------------------- ### Mobility Class Initialization Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Initializes the Mobility class. The config_folder parameter specifies the location of configuration files. ```APIDOC ## class emobpy.mobility.Mobility(config_folder='config_files') ### Description Initializes the Mobility class. The config_folder parameter specifies the location of configuration files. ### Parameters - **config_folder** (string) - Folder name where the configuration files are hosted. Configuration files names are specified when setting stats and rules. ``` -------------------------------- ### Set Mobility Statistics Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Configure the statistical distributions for trip generation, including number of trips per day, destination probabilities, and distance traveled. ```python mobility.set_stats(stat_ntrip, stat_dest, stat_km) ``` -------------------------------- ### Set Mobility Parameters Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Configures the parameters for the mobility profile, including total hours, time step, category, and reference date. Ensure 'total_hours' and 'time_step_in_hrs' are set appropriately for your simulation. ```python m.set_params( name_prefix="BEV1", total_hours=168, # one week time_step_in_hrs=0.25, # 15 minutes category="user_defined", reference_date="01/01/2020" ) ``` -------------------------------- ### emobpy.tools Module Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/modules.md Utility functions for unit conversion, message handling, progress bars, and parallel processing. ```APIDOC ## emobpy.tools Utility Functions ### Description Collection of helper functions for unit management, message logging, and task parallelization. ### Key Functions - **Unit.convert_to()**: Converts units. - **Unit.convert_to_default_value()**: Converts to default unit value. - **Unit.info()**: Displays unit information. - **parallelize()**: Executes functions in parallel. - **consumption_progress_bar()**: Displays a progress bar for consumption tasks. - **set_seed()**: Sets the random seed for reproducibility. ``` -------------------------------- ### Execute modeling scripts Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/basecase.md Runs the four sequential Python scripts required for the modeling workflow. ```bash $ cd $ python Step1Mobility.py $ python Step2DrivingConsumption.py $ python Step3GridAvailability.py $ python Step4GridDemand.py ``` -------------------------------- ### List Available Data Keys Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Retrieves a list of all keys (dataset names) available in the database. ```python list(DB.db.keys()) ``` -------------------------------- ### emobpy.consumption.DrivingCycle Class Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Provides methods for creating, loading, and managing driving cycle data. ```APIDOC ## Class: DrivingCycle ### Description Provides methods for creating, loading, and managing driving cycle data. ### Methods #### create_data() ##### Description Create self.data from self.dc_df. #### driving_cycle(trip, model, full_driving_cycle=False) ##### Description Calculates driving cycle from Trip and ModelSpecs object. ##### Parameters - **trip** (Trip) - Trip for the driving cycle. - **model** (ModelSpecs) - Vehicle Model for the driving cycle. - **full_driving_cycle** (bool, optional) - [description]. Defaults to False. #### get_csv(csv_path='/workspace/input/emobpy/data/driving_cycles.csv') ##### Description Load csv as dataframe into self.dc_df ##### Parameters - **csv_path** (str, optional) - Path of file. Defaults to os.path.join(MODULE_DATA_PATH, "driving_cycles.csv"). #### load_data() ##### Description Load data from self.datafile to self.data. #### save_data() ##### Description Save self.tmpdata to file. ``` -------------------------------- ### Manage Profiles with DataBase Source: https://context7.com/diw-evu/emobpy/llms.txt Provides methods to load, inspect, batch process, and persist profile data. ```python from emobpy import DataBase, DataManager # Initialize database with profiles folder DB = DataBase(folder='profiles') # Load all profiles from folder DB.loadfiles() # Access the database dictionary print(f"Loaded {len(DB.db)} profiles") # List profiles by type for name, profile in DB.db.items(): print(f"{profile['kind']}: {name}") # Access specific profile data for name in DB.db: if DB.db[name]['kind'] == 'charging': profile = DB.db[name] print(f"\nCharging profile: {name}") print(f" Battery capacity: {profile.get('battery_capacity', 'N/A')} kWh") print(f" Charging efficiency: {profile.get('charging_eff', 'N/A')}") print(f" Time series shape: {profile['timeseries'].shape}") # Load profiles in batches (for large datasets) DB.loadfiles_batch( loaddir='profiles', batch=10, nr_workers=4, kind='charging', add_variables=['timeseries', 'name'] ) # Remove a profile # DB.remove('profile_name') # Save/load database state manager = DataManager() manager.savedb(DB, dbdir='database') # loaded_db = manager.loaddb('database/db_file.pickle', 'profiles') ``` -------------------------------- ### Run Time-Series Generation Scripts Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/gettingstarted/run_model.md Execute the Python scripts in sequence to generate mobility, driving consumption, grid availability, and grid demand data. Ensure all scripts are run in the correct order. ```bash $ python Step1Mobility.py ``` ```bash $ python Step2DrivingConsumption.py ``` ```bash $ python Step3GridAvailability.py ``` ```bash $ python Step4GridDemand.py ``` -------------------------------- ### Download Weather Data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Download weather data for multiple European countries and years. This data can be used for creating driving consumption time-series. ```python # from emobpy import Weather ``` ```python # WD = Weather() ``` ```python # WD.download_weather_data() ``` -------------------------------- ### Access Consumption Input Parameters Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Shows the input parameters used for the consumption calculation. This is useful for verifying the settings applied during the run. ```python c.input ``` -------------------------------- ### Plotly Notebook Initialization Script Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/_static/0/example1/example1.html JavaScript code to initialize Plotly charts and set up MutationObservers to handle chart cleanup when DOM elements are removed. ```javascript { "responsive": true } ).then(function(){ var gd = document.getElementById('f8a1f2db-1f31-4426-9589-300d405e997b'); var x = new MutationObserver(function (mutations, observer) {{ var display = window.getComputedStyle(gd).display; if (!display || display === 'none') {{ console.log([gd, 'removed!']); Plotly.purge(gd); observer.disconnect(); }} }}); // Listen for the removal of the full notebook cells var notebookContainer = gd.closest('#notebook-container'); if (notebookContainer) {{ x.observe(notebookContainer, {childList: true}); }} // Listen for the clearing of the current output cell var outputEl = gd.closest('.output'); if (outputEl) {{ x.observe(outputEl, {childList: true}); }} }) }; }); ``` -------------------------------- ### Load and visualize charging data Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Visualize_and_Export.ipynb Load charging data and generate a plot. ```python DBd = DataBase('db') DBd.loadfiles_batch(kind="charging") ``` ```python dname = list(DBd.db.keys())[0] dname ``` ```python vizd = NBplot(DBd) ``` ```python figd = vizd.sgplot_ged(dname, rng=None, to_html=False, path=None) ``` ```python figd.show() ``` -------------------------------- ### Run Mobility Profile Generation Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/base/Time-series_generation.ipynb Executes the mobility profile generation based on the configured parameters and statistics. ```python m.run() ``` -------------------------------- ### Charging Class Methods Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Methods for initializing, configuring, and executing charging scenario calculations. ```APIDOC ## POST /charging/load_scenario ### Description Loads scenario data from a specified database into the Charging object. ### Parameters #### Request Body - **database** (DataBase) - Required - An instance of the DataBase class containing the profiles. ### Response #### Success Response (200) - **status** (string) - Success message indicating the scenario was loaded. --- ## POST /charging/set_sub_scenario ### Description Sets the charging sub-scenario option for the calculation. ### Parameters #### Request Body - **option** (string) - Required - The charging strategy to use. Options: 'immediate', 'balanced', or 'from_22_to_6_at_home'. --- ## POST /charging/run ### Description Executes the charging profile calculation based on the loaded scenario and selected sub-scenario. ### Response #### Success Response (200) - **attributes** (object) - Returns calculated attributes including 'timeseries', 'profile', and 'success' status. --- ## POST /charging/save_profile ### Description Saves the generated charging profile as a pickle file. ### Parameters #### Request Body - **folder** (string) - Required - The directory path where the file will be stored. - **description** (string) - Optional - A description to be saved within the object attribute. ``` -------------------------------- ### Run Mobility Simulation Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Execute the mobility simulation to generate a driving profile. This method does not take any input and returns nothing. After execution, various attributes like 'profile' and 'timeseries' become available. ```python mobility.run() ``` -------------------------------- ### Show Overview Plot Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Generates and displays an overview plot for the specified data. ```python fig = viz.overview(dname) fig.show() ``` -------------------------------- ### emobpy.functions.qhvac Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/src/emobpy.md Calculates HVAC system performance. ```APIDOC ## emobpy.functions.qhvac ### Description Calculates HVAC energy consumption and heat transfer components. ### Parameters - **D** (method) - Required - **T_out** (float) - Required - **T_targ** (int) - Required - **cabin_volume** (float) - Required - **flow_air** (float) - Required - **zone_layer** (ndarray) - Required - **zone_area** (ndarray) - Required - **layer_conductivity** (ndarray) - Required - **layer_thickness** (ndarray) - Required - **vehicle_speed** (ndarray) - Required - **Q_sensible** (int) - Optional - Defaults to 70 - **persons** (int) - Optional - Defaults to 1 - **P_out** (float) - Optional - Defaults to 1013.25 - **h_out** (int) - Optional - Defaults to 60 - **air_cabin_heat_transfer_coef** (int) - Optional - Defaults to 10 ``` -------------------------------- ### Initialize Consumption Data Plotting Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/emobpy/data/eg4/Visualize_and_Export.ipynb Creates an NBplot object for visualizing consumption data. ```python vizc = NBplot(DBc) ``` -------------------------------- ### Read pickle results Source: https://gitlab.com/diw-evu/emobpy/emobpy/-/blob/master/docs/examples/basecase.md Opens and loads a generated pickle file containing modeling results. ```python pickle_in = open("data.pickle","rb") data = pickle.load(pickle_in) ```