Driveline: Analyze a Drive Cycle

Introduction

This model uses the EPA drive cycle to analyze fuel consumption in a generic car drive line.

Explore the available scenarios by evaluating each cell in order. Evaluation is done by selecting a cell and pressing Shift+Enter.

In order to get the full experience of this example, you need the following:

Wolfram System Modeler; a free trial download is available at www.wolfram.com/system-modeler

The model that came in the same bundle as this notebook

For more information about Wolfram System Modeler, visit www.wolfram.com/system-modeler.

Initialize

Define the model name:

mmodel="IndustryExamples.AutomotiveTransportation.Driveline.DrivelineModel";

Import and Use the EPA Drive Cycle

Import the test data:

rawdata=Import[FileNameJoin[{NotebookDirectory[],"DocumentationFiles/hwycol.txt"}],"Data"][[3;;-1]];

Transform the test data to a form that’s easier to use and convert it from (miles/hour) to (km/hour):

drivedata=Transpose[{rawdata[[All,1]],rawdata[[All,2]] 1.609}];

Adjust the the speeds to change gears to the requested level and click the button to export the settings to the model:

Manipulate[Show[ListPlot[drivedata,Joined->True,ColorFunction->Function[{x,y},Which[y<gear1,color1,gear1≤y<gear2,color2,gear2≤y<gear3,color3,gear3≤y<gear4,color4, True,color5]],ColorFunctionScaling->False,PlotStyle->Thick],Plot[{0,gear1,gear2,gear3,gear4,100},{x,0,765},PlotStyle->Directive[Thick,White,Opacity[.5]],Filling->{1->{{2},Opacity[0.4,color1]},2->{{3},Opacity[0.4,color2]},3->{{4},Opacity[0.4,color3]},4->{{5},Opacity[0.4,color4]},5->{{6},Opacity[0.4,color5]}}],BaseStyle->FontFamily->"Helvetica",AxesLabel->{"Time","KPH"},PlotLabel->"Test Speeds",PlotRange->{{0,800},{0,100}}],Column[{
Row@{Spacer[10],"Gear 1",Control@{{color1,Hue[.6,.7,.8],""},ColorSetter},Control@{{gear1,15 1.609,""},0,100,ImageSize->Small}},
Row@{Spacer[10],"Gear 2",Control@{{color2,Hue[.45,1,.6],""},ColorSetter},Control@{{gear2,25 1.609,""},0,100,ImageSize->Small}},
Row@{Spacer[10],"Gear 3",Control@{{color3,Hue[.25,1,.6],""},ColorSetter},Control@{{gear3,40 1.609,""},0,100,ImageSize->Small}},
Row@{Spacer[10],"Gear 4",Control@{{color4,Hue[.1,1,.8],""},ColorSetter},Control@{{gear4,45 1.609,""},0,100,ImageSize->Small}},
Row@{Spacer[10],"Gear 5",Control@{{color5,Hue[.03,1,.8],""},ColorSetter}},Row@{Spacer[10],Button[Column[{Style[],Style["Export Gear Settings to Model",11]},Alignment->Center],If[(gear1<gear2&&gear2<gear3&&gear3<gear4),modelWithValues=SystemModel[mmodel,<|"ParameterValues"-> {"gearSwitch"-> {gear1,gear2,gear3,gear4}}|>],Print["Error: Make sure that Gear 1 < Gear 2 < Gear 3 < Gear4!"]],ImageSize->{190,85}]}
},Alignment->Left],ControlPlacement->Right,SaveDefinitions->True]

Click the “Export Gear Settings to Model” and simulate the model with the chosen settings:

sim=Quiet[SystemModelSimulate[modelWithValues,{0,760}]];

Plot the gear used over time:

SystemModelPlot[sim,"Selected gear",PlotRange->{1,5},AxesLabel->None]

Analyze Fuel Consumption

Plot the instant fuel consumption in litres per 100 km:

SystemModelPlot[sim,"Fuel consumption (L/100km)",Filling->Axis,PlotLegends->None]

Plot the instant fuel consumption in miles per gallon:

SystemModelPlot[sim,"Fuel consumption (MPG)",Filling->Axis,PlotLegends->None,PlotRange->All]

Compare the instant fuel consumption to the vehicle speed:

SystemModelPlot[sim,"Fuel consumption and vehicle speed",Filling->Axis,ImagePadding->{{50,Automatic},{Automatic,Automatic}},ImageSize->Medium]

Terms and Conditions of Use

This domain example is an informational resource made freely available by Wolfram Research.

Use of This Example

• You may not use this example for any purpose that is unlawful or dangerous.
• You assume total responsibility and risk for your use of this example.
• You may not present this example with any alteration to its trade dress, trademarks, or design.

License

All content in this bundle is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. By accessing the content or using it in any way, you accept and agree to be bound by the terms of this license. If you do not agree to these Terms of Use, you may not use this content. Wolfram Research reserves the right to change, modify, add to, or remove portions of these Terms of Use at any time without notice. Please refer back to www.wolfram.com for the latest Terms of Use.

A summary of the licensing terms can be found at:
http://creativecommons.org/licenses/by-nc-sa/3.0

The full legal code can be found at: 
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode