Assessing the Impact of EV Smart Charging on Grid Response
Overview
In this webinar, we consider a scenario where a number of electric vehicle battery units can be commanded to both store and supply electricity while connected to the grid. Techno-economic analysis and optimization is applied to an energy balance representation of the charging profiles to minimize electricity cost while accounting for system requirements and constraints, such as limits on state of charge, grid supply, and charge/discharge rate. The optimization provides a fast and automated approach for leveraging all of the units connected to the grid for overall system benefit. Charging profiles are then integrated into a grid-level simulation to assess the impact on voltage and power flow levels at different connection points.
About the Presenter
Graham Dudgeon, Consultant Product Manager for Electrical Technology, MathWorks
Graham Dudgeon is Consultant Product Manager for Electrical Technology at MathWorks. Over the last two decades Graham has supported several industries in the Electrical Technology area, including Aerospace, Marine, Automotive, Industrial Automation, Medical Devices and Power & Utilities. Graham's technical experience covers - Transmission & Distribution, Grid Integration, Renewable Energy, Power Conversion, Motors & Drives, Microgrids, Electric Aircraft, Electric Ship and Electric Vehicle, with an emphasis on system modeling and simulation, control design, real-time simulation, and data analytics. Prior to joining MathWorks, Graham was Senior Research Fellow at the Rolls-Royce University Technology Centre in Electrical Power Systems at the University of Strathclyde in Scotland, UK.
Recorded: 25 Feb 2025
Hello, everyone, and welcome to this webinar on assessing the impact of EV smart charging on grid response. My name is Graham Dudgeon. I am a consultant product manager for electrical technology at MathWorks.
Here's our agenda for today. We'll start with the problem statement that we will be looking at specifically. As part of that, we'll be talking about techno-economic analysis and optimization, using Optimization Toolbox, and then grid simulation using Simscape Electrical. And we will end with a summary.
So there are two parts to our problem statement. First part-- for a given number of connected assets, or EVs, we want to optimize individual battery charging profiles to achieve some system-level benefit such as minimizing the cost of electricity and/or minimizing peak grid power.
The second part then is taking those profiles that we have obtained from optimization, assess the impact on, say, substation power and grid voltage level for some power grid. In this case, we're going to be using the IEEE European Test Feeder, which is a 906-bus distribution system.
So for the first part of our webinar today, the optimization of the connected assets-- so we are wanting to optimize the profiles to achieve some system-level benefit. So you can see here I've got a basic graphic on our right where I've got four connected assets, four storage units connected to the grid.
Now, over a 24-hour period, as that's the period we're looking at today, at some point, an EV will connect to a charging point. And at some point, it will disconnect. So there's this period of time where it's charging.
So if we're just assuming that we've just got a constant charge profile over that time, then you might get profiles that you see here. So you can see the actual rates of charging is changing based on connect and disconnect time. But that can be modified as per your own needs. But in this case, we're just looking at that constant charge rate.
So for each of those assets, they come in and they will have a certain charge. So the initial charge when they connect will be different for each vehicle. But the constraints we want to place on our optimization problem are that each asset, when it's at the end of its charge period, must be fully charged.
And in this case, we're going to place a number-- say, 70 kilowatt-hours-- as our maximum charge. But that can be changed as well. So the energy profiles look like what you're seeing at the bottom here.
Now, when you take those four profiles and then you take the powers and add them together, you get the power profile at the top. And so that's the power on the grid. So it's quite variable. And you can see it has quite a high peak at a certain period of time.
So what we want to consider is if we are able to control the charging patterns of each asset at a system level to make sure that we stay within minimum and maximum energy, but each asset must be fully charged at the end of its charging period, then we might see charging profiles like this that you see in green. So this example was to minimize grid power. And you can see that our constraints are met.
Each asset ends with full power. But it can vary. The charging can vary. So you charge and discharge during that connection time. And with this optimization, you can see that we've been able to reduce the grid power overall.
So this is a problem in shifting energy intake. And that's the problem we're going to look at at a larger scale as we go through this webinar. I'll be considering specifically 100 connected assets.
The next part of the problem statement is then to look at the charging profiles we obtain from the optimization and then apply them to a grid simulation. And so looking specifically today at the IEEE European Test Feeder, a 906-bus system three-phase, I'm going to consider just balanced charging in the case today, although you have the flexibility to change the unbalanced.
What I'm just showing here is I'm randomly selecting 100 locations on the grid and changing that. So visually, what you're actually seeing here is locations changing every time those red dots appear. So I'm going to set up an automated process to simulate, say, for this example 100 scenarios-- so 100 different location placements-- and show how you set that up using scripting in MATLAB to then execute multiple scenarios using Simscape Electrical and Parallel Computing Toolbox.
So when we look at the larger problem, and I'll show this in more detail in just a second-- but what you can see here is the load profile with, say, the constant charging. So that's the blue line. We've minimized grid power with some smart charging with the green line.
And if you look at the right, you can see the difference between the units in terms of their constant charging and their smart charging. And we'll see more of that as I go through the specific code structures that enable you to do this.
So let's, at this point, move across to the software. So the first thing I'm going to bring up is a MATLAB live script that I prepared that sets up this smart charging problem using Optimization Toolbox, and specifically using problem-based formulation.
So it's not my intent to go through every line of code. But I'm going to give the high-level observations about why this code looks the way it does, what it's looking to do. I might add that anyone who is interested in the code you see, and then perhaps the models later on, as well, just contact us. We can provide everything I'm showing here. We can provide it to you so you can take a look yourself.
So first thing we do is we set up a basic cost model. So our problem is over a 24-hour period, 10-minute intervals. So there's 144 time periods that we're considering.
So I've got a basic price of electricity over a 24-hour period that I've defined. We'll see that later in the figures when I run this. But I want the option of selling energy as well as buying it. And so in this case, you might see there in line 7, very simple-- I've just said the sale price is 95% of the buy price. You can change these numbers, of course, to your own profiles.
But because we're doing this because we're wanting to have the opportunity to sell energy when we're looking at minimizing total cost, this makes it an integer problem. And so we can't buy and sell at the same time period. It's a either buy or either sell. So that's an integer problem. And we'll see that coming out as we go further down.
I've also set up some basic load-- aggregate load profile that we need to meet over the 24-hour period as well. So it's separate from the EVs. So there's going to be a base load, and then also the EVs.
Next part-- we define the number of units, which is 100. And what I'm doing is I'm randomizing the connection times. So I'm saying each vehicle is going to connect and disconnect somewhere between 2:00 AM and 11:00 PM. But that's random.
So this function, connection times the script-- it does this randomly. Again, we'll see these charging patterns or connection times later on in a figure. So you'll see that's randomly done. The constraint I put on this was the connection time has to be at least two hours. So we'll see that as we go through.
We then set the-- some of the constraints or settings of these units. There's initial charge, when it first comes in. I've just randomized that as well. But we have a final state of charge, which in this case is 70 kilowatt-hours. And that can all be changed.
If you're doing a more rigorous study with specific asset types, you could change these numbers. But for the purposes of this, I'm keeping it. Every asset has to have a final charge of 70 kilowatt-hours. And no unit, when it is going through charging profile, can go below 18 kilowatt-hours. And these numbers, again, can be changed per your specific needs.
We then get into setting the problem up using Optimization Toolbox and problem-based formulation. So we're basically setting up a number of optimization variables and then a number of constraints, as well, as part of the optimization.
So the first thing we do is we set up a storage power optimization variable. I'm also looking at the difference of storage power. So charging rate-- I can put constraints on that. Optimization variables for buying and selling into the grid-- and total grid power is grid power buy minus grid power sell.
Maximum grid power-- I've got that as a optimization variable when I want to minimize power from the grid. I have then entered integer constraints for buying and selling. And you see line 67 here, buy or sell. Here's the constraint that we either buy or sell. We're constrained. We can't do both at the same time. And that, of course, is important.
Then have some constraint expressions on the limits that we are constraining our system to be within. We specify that every unit must end its charge at the 70 kilowatt-hour level. And then we have our power balance.
So this implementation-- there's no grid simulation, detailed grid simulation, going on here. It's simply energy balance, or power balance. So we've got some of the storage as our EV units plus that base load is equal to grid power buy minus grid power sell. And then we have an expression for the total cost associated with buying and selling.
We then set up our optimization problem using the optimproblem function. So we create that prob object. And then we set our constraints appropriately. And here, the objective-- you can see I've got a combination of cost, suitably scaled, and also grid power max. And I'm just going to change between the two as I show you these examples running.
So the first optimization problem I'm going to run is to minimize the cost. So I've set grid power max. I've set that weight to be 0 on the objective. So its only concern, the only concern of the optimization problem in this case, is to minimize the cost of electricity. So let's run that. And I'll just scroll down here.
So a couple of things I want to point out-- we're using intlinprog as our solver, integer linear programming. We recently introduced the HIGHS algorithm into intlinprog. And I'm using that.
It's very effective. The performance is excellent for problems of this type. So I've optimized 100 assets over 144 time points. And it took, in this case, just over three seconds. Let's look at some of the figures now.
So here's the timing for the plugin for the vehicles. You can see it's randomized. And you can see that connect/disconnect times vary. This was purely randomized for the purpose of demonstration. You could change this for the specific charging profiles you would expect on your own system.
Then we're looking at the power when we have a constant charging profile in each of our 100 assets plus the base load. And so that's the purple, the thick purple line here. That's our overall loading when we're just doing constant charging.
Now, with optimized, you can see it's quite different from the constant profile. And you can also see in this period here, we are selling electricity back to the grid. And we'll take a look at price later to show why that's happening.
But we've minimized cost. And part of the way we've minimized is to sell back to the grid. This figure here is just showing the base load profile and then total load with constant in blue and then total load with smart charging in green.
Now, this figure here-- let me just pop this out and expand it. So you can see in red that's my grid price. Now, the selling price we just made 95%. So it's got the same profile in this case.
But you can see the grid price is quite high in the period where we're actually selling. So that means the sale price is quite high. So the optimization solution has taken advantage of that to earn some money by selling some energy back to the grid. And we don't need to do that. But we've implemented it here to show you the way that you would structure these types of problems using integer programming.
Let me just close that down and then scroll down a little bit. And the final figure is the charging units and their charging profiles-- so looking at the state of charge. Blue is constant. Green is smart, or optimized. And we can take a look. I'm just going to go to unit 19, which I happen to know is quite variable.
It starts off charging. Then it discharges quite quickly as per the rates that I've put in-- can't go below that minimum value of 18 kilowatt-hours. And then it charges up to full power. So all the constraints are being met on every unit. And we can visually confirm that by stepping through these plots.
Now, I've used 100 units here for the purposes of the demonstration. You can scale this up. You can scale to more units. And you can actually go to more granular time steps, as well, if you want. The Optimization Toolbox-- the problem formulation scales quite well. And so we can go to larger problems than you're seeing here today.
So that was minimizing costs. Let's go back to our objective and change it to minimize grid power. So I'm just going to set the cost objective to 0. And we're now just concentrating fully on the maximum grid power.
So let's run that and take a look at the difference. I'll just take a few seconds to run through this. There we go. It's done-- about six seconds for this particular one. And you can see now that for the optimized charging profile, we have minimized that grid power. And so we can see it a little bit more clearly here.
Let me just pop this figure out-- taking a little bit of time to do that. If it doesn't pop out, that's OK. You can see it relatively well here. Give it one more go. There we go. It's popped out now.
So you can see there that we've minimized grid power. And you can clearly see the temporal shifting, as well, of the energy as a consequence of that, the periods where we're at higher power where our constant charging was lower. So we're shifting energy around to bring that peak down.
My final run on this optimization-- I'm actually going to take out that base load profile. The reason I'm taking the base best load profile out is I'm moving next to the simulation environment to do grid simulation. I could have split that aggregate load around the buses on the system. But for the purpose of demonstration, I'm just going to take that load profile out and focus only on the charging units.
So let's just get up to where I defined the load. I'm just going to multiply it by 0 here to take it out. I'll just rerun this. This will be our final run before we move into the simulation environment.
There you see is about six seconds this time. And I've got charging profiles. My base load is 0. So now I'm just going to focus on the connected assets, the 100 assets that we have. And you can see that it's just running through the profiles.
The good thing about a MATLAB live script-- well, there's several good things about MATLAB live scripts and-- to document and architect your scripts. But one thing is if you are running through multiple figures, it runs-- when it runs through, it then gives you a playback option, which is just a really nice feature so that I can go through these assets and just check them all again at my leisure.
Anyway, we are now ready to move into the simulation environment. So let me bring up our simulation model. Just orienting myself here.
So what I've got here-- this is the IEEE 906-bus European Test Feeder. I've modeled it in four segments. Modeling using segments is valuable, like for other types of studies that I do with models of this type. But it's the complete model-- four segments, suitably connected.
I've set it up in what is called frequency and time mode in Simscape, which is phasor simulation. So I'm going to be running this as a quasi-static model to run those profiles through randomly selected connection points. And so let me just show you a little bit about-- here's the loading.
It's active and reactive power loading that I'm using in this particular example. I'm just setting the active power P and those references as per the smart charging profiles that we have.
So without further ado, let me just run this. I should have started running it before, actually. But let me just run this. It's quasi-static, meaning it's moving from one operating point to the next as quickly as it can. And once it starts running, I'll bring up a plot so you can see it advancing.
And we're doing a-- 144 step changes, basically. So let me bring up the Data Inspector. And we'll start taking a look at some of these results. You can see it started to simulate.
Now, one thing to note is the-- it's a 24-hour profile with 10-minute intervals. My time step on this model is not 10 minutes. I've actually got a 0.01-second time step. And I'm moving through 10 time steps before I change operating point.
Here's the result coming up now. Let me explain. When you're doing quasi-statics-- so basically, moving from an operating point to a next operating point in as few time steps as you can-- you're excluding as much dynamic effect as you can.
It means you can have your time step to whatever you want it to be. So I can have a quasi-static simulation, phase or simulation, with a 0.01-second time step. Then I just condense or compress the time scale over which I'm exploring these loading profiles.
So you can see here we're looking at substation power. And there's 144 steps. You can see it's going to run up, in this case, to about 14.4 seconds-- so 144 steps at 0.1-second snapshots, although we are running 10 time steps every operational change here.
So as this is running, what I actually want to do is bring up our optimization script again and do a comparison. So here's my-- there's our optimized profile here with the energy balance. Let me bring up the grid simulation result.
So you can see with the energy balance-- notice how we've got perfectly flat response. And it's just below 200 kilowatts. But on a grid simulation, it's just above 200 kilowatts. And it's quite variable.
This is loss. It's power loss caused by the cables and the location of our charging. And so that's what you're seeing here. But you can see the profile is very similar. But we are now seeing the impact of loss on the system.
The other thing I should show is voltage because voltage is the-- another response that we get to see in simulation that we do not see in our energy balance optimization. So there's nothing too dramatic about this. But it's incredibly valuable to be able to move from these charging profiles that you've obtained using Optimization Toolbox with simple energy balance, but then evaluating their effect on a more detailed grid simulation. And so I'll just bring up the power, as well, so you can see voltage because the scale now looks pretty flat. And there's substation power.
So everything's looking good. We have a mechanism for moving from the Optimization Toolbox straight into the simulation environment. We use MATLAB scripts to automate picking up these profiles, putting them in the right place at the grid. But the next thing I do want to show you is the-- is using parallel computing to run multiple scenarios.
So let me just bring up a script. I want to show you how straightforward it is to set these problems up for use with parallel computing and parallel simulation. So I have my model, my IEEE model that I am simulating.
The first thing I do is I set up what are called simulation input objects-- so this in1 object that I'm creating. I loop through each of my scenarios. I've just done 100 scenarios here. And I ran it previously. But you're not limited to 100. You could do thousands, tens of thousands.
So we set up the simulation and input. And then we set variables. So I'm setting my active power reference, Pref, and my reactive power reference, Qref. And I'm also storing the locations where each of those powers are being, basically, input in the grid model.
The defineProfiles script is randomizing the location around that grid. So I've got these 100 scenarios defined in a single object, in one. And then I just call the parsing command with in1. And that's it. That's what you do to set up your problem to run multiple operational scenarios using parallel computing.
And then I've got a simple analysis set up. I won't dwell too much on this. But I just want to show you what it looks like. Basically, I saved all my scenarios to outData.mat.
I can then pick up the values from my out multi-function. So basically, out multi-stores all your runs. And I can pick up the relevant values. The fifth value is active power. The seventh value is voltage. Here, colon, comma, 1 means I'm just picking up phase A voltage. And then I can just run some basic statistics.
And so what we see here just over a period of time-- I can look at substation active power. Let me just expand that. So substation active power is just a histogram. I haven't done anything fancy here in terms of all the capabilities that you have at your disposal with the Statistics Toolbox. But I'm just showing simple histograms here.
And then as part of an overall study where you're looking at thousands of operational patterns, then it makes sense to look at histograms as part of that. But I'm not doing a specific study. I'm not looking for a specific outcome in my example. I just wanted to show how you set the problem up.
So in summary, we can reduce risk and build confidence in power grid operational readiness with techno-economic analysis. We can model and solve large-scale optimization studies using problem-based modeling in Optimization Toolbox. And we also used the HIGHS algorithm for integer linear programming in the case that we showed today.
We can then take those optimized profiles and assess grid impact by performing grid simulations. And by running thousands of scenarios, potentially, using parallel computing, we can enhance our understanding of grid response with statistical analysis and visualization. Thank you for listening.