Coder Social home page Coder Social logo

jrcstu / gearshift_calculation_tool Goto Github PK

View Code? Open in Web Editor NEW
6.0 7.0 3.0 15.63 MB

The Joint Research Centre (JRC) developed ‘JRC Python Gearshift Calculation Tool’ (JR-Shift), a simulation tool developed in Python programming language, that calculates the required gears for manual transmission vehicles as required by the Worldwide harmonized Light-duty vehicles Test Procedure (WLTP) and UN GTR 15 and (EU) 2017/1151 regulations.

Home Page: https://gearshift-calculation-tool.readthedocs.io/

License: European Union Public License 1.2

Python 4.89% Jupyter Notebook 56.62% Shell 0.01% HTML 38.49%
python wltc gear gearshift emissions simulator jrc wltp regulation

gearshift_calculation_tool's Introduction

--(( Project has moved to https://code.europa.eu/jrc-ldv/jrshift since version 1.1.3 ))--=========================================================================================

versions

release date

documentation

https://gearshift-calculation-tool.readthedocs.io/en/latest/ GitHub page documentation

sources

https://github.com/JRCSTU/gearshift_calculation_tool Code Style

keywords

automotive, car, cars, driving, engine, emissions, fuel-consumption, gears, gearshifts, rpm, simulation, simulator, standard, vehicle, vehicles, WLTP

short name

JR-Shift

live-demo

JupyterLab for Gerashift Calculation Tool (stable)

Copyright and License

© Copyright (c) 2021 European Union.

Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission – subsequent versions of the EUPL (the "Licence"); You may not use this work except in compliance with the Licence. You may obtain a copy of the Licence at:

Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence.

A python-3.6+ package to generate the gear-shifts of Light-duty vehicles

Table of Contents

Introduction

The aim of the JR-Shift is obtain the Required Engine Speeds, the Available Powers, the Required Vehicle Speeds and the Gears for the whole WLTC based on the vehicle characteristics. The model should allow accurate calculation of final trace and the operating conditions of the engine.

Overview

The calculator accepts as input an excel file that contains the vehicle's technical data, along with parameters for modifying the execution WLTC cycle, and it then spits-out the gear-shifts of the vehicle and the others parameters used during the obtaining of these. It does not calculate any CO2 emissions.

Installation

Prerequisites

Python-3.6+ is required and Python-3.7 recommended. It requires numpy/scipy and pandas libraries with native backends.

Tip

On Windows, it is preferable to use the Anaconda distribution. To avoid possible incompatibilities with other projects

Download

Download the sources,

  • either with git, by giving this command to the terminal:

    git clone https://github.com/JRCSTU/gearshift_calculation_tool --depth=1

Install

From within the project directory, run one of these commands to install it:

  • for standard python, installing with pip is enough (but might):

    pip install -e .[path_to_gearshift_calculation_tool_folder]

Project files and folders

The files and folders of the project are listed below:

+--gearshift/                                       # main folder that contains the whole gearshift project
|   +--cli/                                         # folder that contains all cli scripts
|   +--core/                                        # folder that contains core packages
|       +--load/                                    # (package) python-code of the load
|           +--speed_phases/                        # folder that contains speed phases in ftr format
|           +--excel.py                             # (script) load from the excel file parameters
|       +--model/                                   # (package) python-code of the model
|           +--calculateShiftpointsNdvFullPC/       # (package) python-code of the calculate shift points, Ndv and  FullPC
|           +--scaleTrace/                          # (package) python-code of the calculate scale trace
|       +--write/                                   # (package) python-code of the write
|           +--excel.py                             # (script) write to the excel file output parameters
|   +--demos/                                       # folder that contains demo files
|   +--docs/                                        # folder that contains documentation
+-- AUTHORS.rst
+--setup.py                                         # (script) The entry point for `setuptools`, installing, testing, etc
+--README.rst
+--LICENSE.txt

Quick-Start

Cmd-line usage

The command-line usage below requires the Python environment to be installed, and provides for executing an experiment directly from the OS's shell (i.e. cmd in windows or bash in POSIX), and in a single command. To have precise control over the inputs and outputs

$ gearshift --help                                                  ## to get generic help for cmd-line syntax
$ gearshift demo                                                    ## to get demo input file
$ gearshift run "path_input_file" -O "path_to_save_output_file"     ## to run gearshift tool

Usage

In this example we will use gearshift model in order to predict the gears.

Setup

Import dispatcher(dsp) from gearshift tool that contains functions and simulation model to process vehicle data and Import also schedula for selecting and executing functions. for more information on how to use schedula

from gearshift.core import dsp
import schedula as sh

Load data

  • Load vehicle data for a specific vehicle from excel template

    vehData = 'gs_input_demo.xlsx'
  • Define the input dictionary for the dispacher.

    input = dict(input_file_name=vehData)

Dispatcher

  • Dispatcher will select and execute the proper functions for the given inputs and the requested outputs

    core = dsp(input, outputs=['sol'], shrink=True)
  • Plot workflow of the core model from the dispatcher

    core.plot()

    This will automatically open an internet browser and show the work flow of the core model as below. You can click all the rectangular boxes to see in detail sub models like load, model, write and plot.

    The load module

  • Load outputs of dispatcher Select the chosen dictionary key (sol) from the given dictionary.

    solution = sh.selector(['sol'], sh.selector(['sol'], core))
  • Select each output case

    # Select first case
    solution['sol'][0]
    
    # Select second case case
    solution['sol'][1]
    
    # Select gears output for different cases
    gears = {}
    for sol in solution['sol']:
        gears[f'gears_{sol["Case"]}'] = sol['GearsOutput']

gearshift_calculation_tool's People

Contributors

andreslaverdemarin avatar vinci1it2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gearshift_calculation_tool's Issues

name 'Environment' is not defined / name 'HtmlFormatter' is not defined

Hi,

I tried running the script as proposed here in the docs but I only receive error messages.
First I got:

D:\Git\gearshift_calculation_tool>gearshift run "inputs/gs_input_demo.xlsx" -O "outputs/2022-05-25_demo"
  0%|                                                                                                                                                                                                                        | 0/1 [00:00<?, ?it/s]: Processing D:\Git\gearshift_calculation_tool\inputs\gs_input_demo.xlsx
2022-05-25 18:04:59,621:ERROR:schedula.utils.sol:Failed DISPATCHING 'load_inputs/parse_excel_file' due to:
  ValueError('Unknown engine: openpyxl')
Traceback (most recent call last):
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\sol.py", line 632, in _evaluate_node
    **kw)
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\sol.py", line 606, in _evaluate_function
    verbose=self.verbose
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\asy\__init__.py", line 202, in async_process
    exe_id, funcs, executor, *args, **kw
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\asy\__init__.py", line 159, in _process_funcs
    r['res'] = e.process(sid, fn, *args, **kw) if e else fn(*args, **kw)
  File "d:\git\gearshift_calculation_tool\gearshift\core\load\excel.py", line 148, in parse_excel_file
    input_data = pd.ExcelFile(input_file, engine="openpyxl")
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\pandas\io\excel.py", line 369, in __init__
    raise ValueError("Unknown engine: {engine}".format(engine=engine))
ValueError: Unknown engine: openpyxl

...which I could fix by downgrading some of the required packages (I think I changed "pandas>=0.21.0" to "pandas==0.21.0" in the setup.py) and created a virtual environment with this in PyCharm.
However, I still have multiple error messages left:

Executing gearshift model: 100%|██████████| 1/1 [00:02<00:00,  2.53s/it]
name 'Environment' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'Environment' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
Traceback (most recent call last):
  File "D:/Git/gearshift_calculation_tool/run_this_script.py", line 7, in <module>
    core.plot()
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\schedula\utils\base.py", line 282, in plot
    executor=executor
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\schedula\utils\drw\__init__.py", line 1669, in render
    self._view(fpath, format=osp.splitext(fpath)[1][1:], quiet=True)
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\graphviz\files.py", line 300, in _view
    view_method(filepath, quiet)
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\graphviz\backend.py", line 376, in view_windows
    os.startfile(filepath)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden: 'C:\\Users\\my_username\\AppData\\Local\\Temp\\tmpoumbf9no\\core.html'

Process finished with exit code 1

I think it has something to do with the Pygments package? I don't know where exactly I can add the "not defined" names...? I also tried downgrading Pygments using "Pygments==2.8.1".

My script looks like this (as the example in the docs):

from gearshift.core import dsp
import schedula as sh

vehData = 'inputs/gs_input_demo2.xlsx'
my_input = dict(input_file_name=vehData)
core = dsp(my_input, outputs=['sol'], shrink=True)
core.plot()  # script stops during execution of this line
solution = sh.selector(['sol'], sh.selector(['sol'], core))

# Select gears output for different cases
gears = {}
for sol in solution['sol']:
    gears[f'gears_{sol["Case"]}'] = sol['GearsOutput']

Any clue on how I can make the script running? Thank you!

Best regards,
Matthias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.