JRCSTU / CO2MPAS-TA

EU's Type-Approving vehicle simulator predicting NEDC CO2 emissions from WLTP
https://co2mpas.readthedocs.io/
European Union Public License 1.1
23 stars 13 forks source link

Interfacing MATLAB and CO2MPAS #23

Open GokulMaharaj opened 6 years ago

GokulMaharaj commented 6 years ago

I am new to CO2MPAS and I have a task in hand to optimize an hybrid vehicle for its fuel economy. I want to run the optimization using NSGA II with minimizing fuel economy and acceleration time and maximizing the vehicle speed as the objectives. The design parameters would be engine power, motor power and battery energy capacity. I want to find the values of the objective functions using CO2MPAS for each generation of solutions obtained from NSGA. Is it possible to do that? I can also run the NSGA in MATLAB but in that case I would like to know how to interface MATLAB and CO2MPAS. Please guide me.

dimitriskomnos commented 6 years ago

Dear @GokulMaharaj,

The present CO2MPAS Release doesn't support hybrids. So, you first need to consider if CO2MPAS is the right tool for you. If it is, then, in order to try and solve your problem, here are some notes for you:

  1. Matlab/ Python API: First you need a way to invoke Python from Matlab. MathWorks suggested way of doing this should be fine: http://www.mathworks.com/help/matlab/matlab_external/call-python-from-matlab.html Of course you have to properly install CO2MPAS in the python-environment that Matlab would be calling out.

  2. CO2MPAS DataStructures for Input You need to plug into CO2MPAS's internal data-structures. We have an IPython script, (simVehicle.ipynb) that did exactly this for previous versions: http://co2mpas.io/usage.html#launch-co2mpas-from-jupyter-aka-ipython It is a nice starting-point and a good guideline on how you could handle the data communication. This requires some good knowledge of python and the respective packages but if you are an experienced matlab user it shouldn't take very much time to orientate yourself.

  3. Read Output into MATLAB Handling the output is much more complex if you don't have experience with python. We suggest that you try to use the out-template function, define an excel template that fits your requirements and use that one for detailed time series comparison. For comparing simple CO2 values, the summary file produced after any batch run should work fine and it is fairly easy to read also with Matlab.

We hope this helps.

GokulMaharaj commented 6 years ago

Thanks a lot for the information. Is there any version coming soon which could possibly simulate hybrid vehicles?

dimitriskomnos commented 6 years ago

It is hard to estimate, but not earlier than September 2018.