Techno-Economic Analysis and Optimization of Microgrids with EV Charging - MATLAB
Video Player is loading.
Current Time 0:00
Duration 51:36
Loaded: 0.32%
Stream Type LIVE
Remaining Time 51:36
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 51:36

    Techno-Economic Analysis and Optimization of Microgrids with EV Charging

    Overview

    In this webinar, we will show how to architect a techno-economic analysis and optimization framework in MATLAB. We will use a microgrid example with a utility grid, renewable energy, energy storage and EV charging. The system will be optimized in terms of power rating and energy rating, such that levelized-cost-of-energy (LCOE) is minimized over a 20-year period.

    About the Presenters

    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.

    Chris LeeSenior Product Manager, MathWorks

    Chris Lee is a senior product manager for optimization at MathWorks. He works with customers, field engineers, and the software development team to define new optimization capabilities and applications to serve the diverse industries where optimization is used, including aerospace and defense, automotive, energy, and manufacturing. Prior to MathWorks, Chris worked at Dassault Systèmes as a product manager for aerodynamic design optimization. He holds a master's degree in aerospace engineering from the University of Toronto.

    Recorded: 31 Jan 2025

    Hello, everyone, and welcome to this webinar on Techno-Economic Analysis and Optimization of Microgrids with EV Charging. My name is Graham Dudgeon. I am a Consultant Product Manager for Electrical Technology at MathWorks.

    Hi, everyone, my name is Chris Lee, and I'm the Senior Product Manager for Optimization Technology here at MathWorks.

    Thank you, everyone, for joining us online today. Here is our agenda. We'll start with some key takeaways of what we will be discussing. And I'll give a high level view of how MathWorks supports all stages of electrical technology development. And as part of that, we'll set some of the context for the area we're looking at today, which is our case study, which is our microgrid with EV charging. Chris will be talking a lot more about that as we go on. And then we'll end with a summary.

    So the key takeaways are, every energy system is unique, and therefore requires a flexible computational environment to answer unique engineering questions. So as we're developing those engineered systems, no two are the same. And so we have to bear that in mind as we're designing those systems. And so flexibility in your computational tools is very important.

    Focus of today will be on the Optimization Toolbox, which Chris will talk about in more detail. But we will see that it supports efficient and scalable problem formulation and execution. And the final point I'll be making is the extended MathWorks ecosystem provides additional analysis and design capability that supports overall energy system technology development. So we're not just constrained to Optimization Toolbox overall, but it is the focus of today's webinar.

    So at the highest level, MathWorks' vision is to support all stages of electrical technology development and the way that we do this is we map our software, our computational tools, to each stage of analytical technology development cycle, starting from early stage feasibility all the way through to in-service operation. And so our objective is to give engineers engineering tools to allow them to answer the engineering questions that they have.

    In today's webinar, we're focusing very much on early stage design and early stage feasibility, in particular techno-economic analysis and optimization. But we can cover the full development cycle. If you're interested in learning more, please visit MathWorks.com and you'll see some more information on that.

    So here's a system we're looking at today, a new renewable energy microgrid with EV charging. So this is just a basic structure of what we're looking at. We're looking in particular at energy balance, power balance formulation. So we have a grid connection, a utility grid. We have solar and wind. We have grid-level energy storage, some industrial load, and also what you might call an EV fleet. And we're going to be looking at two scenarios for how we can optimize this system over a 20-year period, Chris, if I remember correctly.

    That's right.

    But we can also look at 8760, just one-year periods at one-hour time steps as well. But our focus will be on 20 years. So we're looking at two scenarios today. The first scenario is where our load, our industrial load, is supplied from the utility grid, the renewable energy, and energy storage. But the EV fleet, we're going to constrain our optimization so that it's supplied only from when renewable energy is available.

    Now, we can't differentiate electrons, but what we can do is we can measure power levels coming from the different assets and build that into the constraints as we go. And you'll see that when Chris is showing this in more detail. So, supply of our industrial load comes from any of the sources. But when it comes to the EV fleet, the constraints we're going to be looking at in particular is the energy storage will be charged only from renewable energy. So when renewable energy is available, that's when we'll be able to store.

    And the EV charging will be supplied only from renewable energy and energy storage. So that's scenario one. Scenario two is where we unconstrain the supply for our loads. And so both the industrial load and the EV fleet can be supplied from the utility grid, renewable energy, and energy storage. We're showing this for two reasons, these two scenarios for two reasons. One is there is an increasing emphasis on being able to select renewable sources for loads considerations and supplying loads. Secondly, we want to show you how easy this is done in the Optimization Toolbox.

    And so our objectives are, we're going to determine the power rating for wind, solar, and storage. We'll determine the energy rating for the storage system at the grid level. We will meet the EV charging demand from appropriate sources, as per our scenarios. And we're also going to look at minimize overall cost over a 20-year period at one-hour time steps. And I believe we're looking at levelized cost of energy, Chris.

    That's correct. Yes.

    Excellent. So with that, I am going to pass it over to Chris, who's going to show us the workflow in more detail.

    Great. Thanks a lot, Graham. OK, so for the next part of the webinar, we're going to spend a significant amount of time getting our hands dirty in MATLAB. So this is going to be exciting. We're going to be in the tool. I'm going to go through in detail how to set up an optimization study to assess the techno-economic feasibility of this microgrid that we're considering.

    And we're going to go through it in detail. But again, even if you don't follow all the specifics of how to set this up, the key takeaways that we want you to come away with are the flexibility that our tools provide to orchestrate a study like this, how easy it is to set up an optimization study with the Optimization Toolbox, so the ease of use as well as the efficiency of the solvers that we provide.

    And then third, we're going to show some examples of how the broader capabilities within the MATLAB platform augment just the pure optimization study. So, in particular, what we're going to do is extend the optimization study to consider not just a single scenario, but multiple scenarios through sensitivity analysis. And we'll also leverage parallel computing to help scale up efficiently.

    So, Graham already covered the description of the problem that we're going to look at. And then just as a quick preview of results, once we run the optimization, we're going to be able to look at details of the power profiles and what resources are being used when. We'll look at that in more detail once we actually produce the results. And then once we run the sensitivity analysis, we'll be able to look at things like this. So it's the distribution of levelized--

    Cost of energy.

    Cost of energy. Yeah, thanks.

    [LAUGHTER]

    Levelized cost of energy, yeah, I'm blanking here, for different discount rates. So we'll get into that in a short little bit. But let's start at the beginning. So we're going to start with data. What data do we have? What data are we assuming we know leading into this optimization study? So we're going to assume we know a few things. We're going to assume that we know the power requirements for the load. So you can think of it as a building within-- or maybe a set of buildings within the microgrid system.

    We have the price of electricity from the grid. We also have solar and wind profiles. These are going to be normalized profiles that provide us with how much energy over time can be harnessed from the environment to produce electricity. And then we have this aggregate EV charging power from this EV fleet. So we're going to need to figure out what are the sizes of the solar, wind, and storage as well to satisfy our load and aggregate EV charging power.

    And I think, at this point, it's worthwhile saying that we synthesized all of this data. But when you're doing this properly, you'll obviously be using data that's available from various sources, whatever those sources might be. But for the purposes of demonstration, we've synthesized the data to be as reasonable as we could make it, so you can at least see similar types of profiles that you would expect to see with real data.

    Right. Yes. And so some of the values that you might see might not be 100% realistic in all cases. But I think that the emphasis today is not on the specific results that you're going to see, but more about the overall workflow. And then what we hope you're able to do is then adopt that workflow and use your real data for this problem.

    Exactly.

    So what I'm going to do is first start by loading the data. I'll do that in a moment. And we actually have data for the full 20-year period that we're considering, so hourly data over 20 years. But for the purposes of what I'm going to show right now, just to make things quicker, we're just going to consider three years of data. I'm going to go back later and then we'll scale up to 20 years. But let's just take a look at three years for now.

    So we're going to load the data and then assign the different parts of our data into a structure. That's just going to make it easier to pass the data into different parts of our workflow. And then I've created a few different visualizations for the data that we have. So for each data set, we have a heatmap that looks at the details of the data in the first year to see some trends over the course of the day over the first year, as well as some line plots where we'll see the trends, if there are any trends, over the full, in this case, three years, but later on, we'll see 20-year period. So some of these look pretty cool to me.

    Yeah. And just, if you're wondering why the bars are pretty consistent, it's because when I created this, I had a base profile, which I then randomized to some degree. So you're seeing some effect of the randomization with the different colorings. But overall, it's following a specific pattern. That can all be changed as you need, of course, or as per your own data. But yeah, it definitely lets you focus in on where you're seeing the primary loading points, time of day, that type of stuff. So it's an effective visualization.

    So it looks like over this year, most of the load requirements come in the evening, the later part of the day. And then this is just a really condensed line plot showing that there's not really much change over the course of the three years. But for some of the other plots, we'll see some more differences. So here, we're looking at the grid price. And so again, it's pretty randomized. Not a whole lot of concentration of higher grid prices at certain times of the day. And here's over the full three-year period.

    This one's more interesting. So here, we're looking at the normalized solar profile. And as you would expect in the middle of the year, so in the summer months, we have more solar energy available. And then, of course, in the middle of the day, also. So we have this nice eye pattern.

    Yep. Yep. This was one where I did try my best to put in this periodic nature of solar. And I think we see the effects here. It's quite a cool plot, that one.

    Yes. And then if you look over the three-year period then, as you would expect, you see the cyclical nature of the solar profile. Wind is a little more randomized, right?

    Yeah, exactly. I didn't put any particular kind of underlying pattern to this. I just randomized between certain levels. And so that's why we're not seeing any distinct pattern showing up.

    Sure.

    But actually, I think with the purely randomized data, Chris, I may be wrong. You can correct me if I am. But the optimization will have to work a little bit harder when it's purely random, as opposed to when there's trends occurring. But I could be totally wrong with that one. But anyway, randomized data is a good test for our optimization tool.

    That's right. That's right. And here, we see the randomized wind profile over the three years. Finally, we have EV charging power. So again, we set up a particular kind of scenario where the EVs are plugged into the system and require charging in the evening, so from 5:00 to 11:00 PM. The rest of the day, there's no EV charging load.

    Yeah. We should talk a little bit about this. So yeah, again, synthesized EV charging profiles. But the way we've set it up is you can choose a sort of period of the day in which you would expect your fleet or vehicles to be plugging in. We chose evening for this particular study. But you can change that.

    I should also add that we're not actually optimizing the charging profiles themselves. We're consuming that data from another source. And then we're sizing our microgrid system based on that. But it's probably worthwhile saying that you can extend optimizations into the realm of optimizing charging patterns as well.

    That's right.

    But in this particular case, the focus is on the microgrid system itself. But you're not limited in the type of optimization study you can conduct.

    Absolutely. Yes. Yes. And then the last thing I'll show for the EV charging power is you can see, each year, we're getting an increase in the expected charging load requirements. And that's just to synthesize a situation where, over time, we're having more and more vehicles added to the EV fleet.

    All right. So that's just a quick overview of the data that we're working with. Our objective function is going to be to minimize the LCOE, the levelized cost of energy. And we'll show the equation for that later. But a key component of that equation is a discount rate. And that's to factor in the time value of money that's included in the LCOE calculation. We don't know exactly what the discount rate is going to be in the future. So we have to make an assumption.

    Right now, we're going to assume that it's 5%. And then we'll run the optimization to see what results we get at 5%. But later on, what we're going to do is consider the fact, the reality that we don't actually know what it's going to be. And so let's do a sensitivity analysis to see how our optimization results are affected by changes in the discount rate. So we'll start with 5%. And then at this point, we are ready to jump in and actually start setting up the optimization problem.

    So we're going to jump into this function that we've set up that takes care of the whole optimization problem formulation. And we'll go through this in detail so you can see how this works. We're going to be using a framework called the problem-based optimization workflow that's provided in the Optimization Toolbox. And it provides a really convenient and intuitive way to define even complicated optimization problems.

    If you're not familiar with optimization modeling, there are really three main components to any optimization problem. There are the variables, the constraints, and then an objective. The variables are the things that we are trying to decide on specific values for. The constraints are quantities that either bound certain variables or place restrictions on other kinds of metrics that we're looking at over the course of the optimization. And then the objective function is the quantity that we're either trying to minimize or maximize in this case.

    So we'll take a look at how this works for our specific problem. But before I do that, I just want to open up a simple example that shows how the problem-based optimization workflow works on a smaller problem, just so that you have familiarity with the framework. And then we'll see how it applies to this larger problem.

    So this is one of our documentation examples in the Optimization Toolbox. And our objective function is this nonlinear function of two variables, x1 and x2. Doesn't really matter what the details of what it is, but it's just some mathematical expression. We have this objective function. We have two variables, x1 and x2. And then we also have a constraint that the values of x1 and x2 have to satisfy this expression.

    So x1 squared plus x2 squared has to be less than or equal to 1. So that's a constraint that's restricting the choices of combination of x1 and x2. So that's a mathematical or a verbal description of what the optimization problem is. Let's see how you define that in MATLAB code. So the first thing that we're going to do is set up an optimization variable. So we're using this optimvar function to define a variable x that has, that's a 1 by 2 variable for x1 and x2.

    Then given this variable x, we define a mathematical expression of x that defines our objective function. So it's the same equation that we saw earlier. And then we create an optimization problem object. So we're saying that this optimization problem has this objective that we just created. So we have our variable, we have our objective. The last thing that we need is our constraint, which was, again, x1 squared plus x2 squared has to be less than or equal to 1. You see that's exactly what we've written out here. And then we define that as a constraint inside of the optimization problem.

    And that's it. So just as simple as that. We've set up this optimization problem with just a few lines of code, maps really easily to the equation that you would write down on paper if you were to describe what this problem is. And then, given the problem, then we pick an initial point in this case, and then just call a function called solve. And so you'll notice we didn't even need to specify a particular optimization solver or algorithm. The solve function will look at the problem that you defined and figure out, based on the problem formulation, which solver is the most appropriate one to use and solve the problem.

    So in this case, it's using a nonlinear solver that we offer for the problem that we're going to step back to in a moment, we're going to be using a different solver. But the point is, it's really easy to set up. It maps conceptually to the problem that you would describe verbally or write down on a piece of paper.

    OK, so let's get back to the real problem, the interesting problem that we're all here to take a look at. So the first thing that we're going to do is set up or define our optimization problem. We're going to be minimizing our objective function. So we could do this later, but here I'm just doing it now, saying that the optimization is going to be a minimization problem. Right now, it's just an empty problem. But over the course of the next few lines of code, we're going to be filling up the problem object with the problem description.

    So, in this next section, what we're going to do is set up the different optimization variables. The first variable that we're looking at is the grid power. So, at each hour time step, over the course of 3 years, 20 years, whatever we're looking at, the optimization needs to figure out how much grid power to either purchase from the grid. And we're also, in fact, actually allowing our micro grid to supply power back to the main grid. So this can change depending on what your system actually is set up to do or what you're planning to do with it.

    But we're considering a scenario where you can both purchase power from the grid, supply power back to the grid to make some money back. So in this case, we have these specific ranges. And we're using that function that we saw earlier, optimvar. So grid power is an optimization variable. It's a time series variable, so number of time steps by one with lower and upper bounds as we've defined here. And of course, again, user configurable as you see fit.

    Is this a good point to talk a little bit more about buy and sell and how we've addressed it here in this particular problem?

    Sure.

    So the buy and sell price is the same--

    That's correct.

    --in this particular problem. And because of that, we're going to be using continuous variables and linear programming. If we wanted a different price for sell, we would make that an integer problem. So buy, sell, it can be one or the other.

    Right.

    But we're not showing that today, but we do have other examples of doing that in other resources, which we'd be happy to provide anyone who asks us. One other point about this, if I may, the scripts that we're showing today, in the workflow we're showing, we can make this available on demand. So anyone asks us about this, just get in touch and ask us. We can provide this to you so you can run it yourself.

    Yes, we've built this and carefully tried to document what we've done. Not just for fun, but so that we can actually share it with you all. So if you're interested in this, please let us know and we're happy to share it with you.

    Yes, thanks for adding that. So that defines our grid power variable. Next, we have a variable to size our solar elements, so the power rating for our solar unit. So we're going to assume some maximum solar rating that we can allow. And then this is just a scalar variable, so scalar optimization variable that can go from 0 to whatever we've defined as the maximum.

    Again, here, we're explicitly saying that this is going to be of type continuous, so a continuous variable. But this is another place where we could introduce integer constraints if we wanted to. For example, if we wanted to say, you can only choose solar ratings of 100, 200, 300, that type of thing, we would be able to use integer constraints to keep the variables at those discrete levels.

    Next, we have the wind power rating. So this is formulated basically the same way with an optimization variable from 0 to some max wind rating. And then the next part of the system is the storage unit. And this requires a little more thought to set up. But it is pretty interesting. So let's take a look at this. So this storage unit, we want to figure out how much power rating it should have, how much energy rating, as well as, over time at each hour, how much power it's either supplying to other parts of the system or how much power is being supplied to it so that it gets charged up.

    So these, we have one optimization variable, which is a time series variable for the power. So at each time step, we need to figure out how much we-- really, the optimization algorithm is going to figure out how much power is either going in or out of the units. And similarly, we've defined an optimization variable for the storage energy to keep track of how much energy is inside of the storage unit at a given point in time.

    And then we have the optimization variables for the energy rating, the power rating. These are scalars between 0 and whatever maximum you set. And then to make things a little more interesting, we've also included degradation into the model. So we're just considering a simple linear degradation model of 5% over the course of whatever time horizon we're considering. So, in this case, three years, the energy and power capacity of the storage is going to decrease linearly by 5% over those three years.

    So now we're going to start actually introducing some constraints. So far, we've just created variables. But we need to relate the storage power to the storage energy. And so this is where the energy balance constraint comes in. We're going to assume that at the beginning, the storage unit doesn't have any energy in it. But then at the first time step, the storage energy is equal to whatever power is supplied to it times a one-hour time step. And then for every time step after that, the storage energy is equal to the storage energy at the previous time step, plus whatever power you supply or minus whatever power you draw out of the unit.

    So just on this point, Chris, so we're using kilowatts and kilowatt hours.

    Yes.

    So power and energy are basically the same, which is where the ones are coming from. But that number would be changing, of course, if you had a different time step. So that's where you would do it in this formulation. That 1 would change depending on what time. But kilowatts and kilowatt hours actually makes it pretty easy.

    Yeah. Yeah, I probably should have parameterized this more carefully, so that you could change the time step.

    This, for me, is one of the most important constructs in these types of problems, the energy. Because, as you can see, it's a few lines of code. But this has been optimized, this code construct, there are different ways of doing it. But this is the way you should be doing it.

    Right. Yes. And then we have-- you don't really need this, but we've said we're also going to add a constraint that at the end of the time horizon that the storage energy is equal to 0. So I mentioned the linear degradation on the storage energy earlier. So this is where that's coming into play. We're saying that the storage energy at each time step has to be less than or equal to the storage energy rating. So that's another variable that we need to figure out, times this linear degradation factor, which uses that the 5%, yeah, the 5% linear degradation that we talked about earlier.

    Next, we have a constraint to set up this scenario, one that you were mentioning, Graham, right?

    The green charging.

    Yes. I'm not actually sure if that's a real-- I threw that in. I'm not sure if that's a real term or not.

    I think it's appropriate for this, charging only from renewable source.

    Exactly.

    Or storage charged from renewable sources.

    Right, yeah. So we want the EVs to only be supplied by green energy. So there are actually two constraints involved in this, the other one comes later. But this one is constraining the storage power to only be supplied by solar and wind. And the signs are based on the fact that positive storage power means that the storage is supplying energy to the rest of the system, and the negative storage power is that it's being charged up.

    And then we have the constraints on the storage power. So storage power has to be-- these are the lower and upper bound constraints on the storage power. So they have to be constrained by the storage power rating in both directions with the linear degradation that we talked about.

    And then this is where things start to all come together. So we have the power balance across the whole system. So we have the load power plus the charging power has to be equal to all the energy that's provided by-- or all the power that's provided by the grid plus the storage plus solar plus wind. And this is an equality constraint.

    And just to reemphasize, this is just power balance. No losses, nothing like that, taken into account other than that degradation. But this could all be modified appropriately depending on the types of effects you really do want to see. But this is basic power balance.

    Right. So that defines the power balance expression. And then we're saying this expression gets assigned to a constraint in our optimization problem. And then finally, we have another constraint to enforce the green charging scenario. So here, we're saying that the charging power has to come from only the storage power, solar power, and wind power. And again, remember we have a separate constraint on the storage power to only be charged up by solar and wind. So, if you do all the accounting, everything that's going into to the EVs is effectively coming from green energy.

    So we've taken care of the variables and the constraint, several constraints. And then finally, we have the objective function. So our objective function, again, is levelized cost of energy. And so we're going to show how we're going to build up that expression. We have some data that's describing different costs for our cost model. But of course, you can choose values that are appropriate for you.

    This is the general equation for levelized cost of-- sorry, levelized--

    Cost of energy.

    Yes, levelized cost of energy. [LAUGHS] I'm struggling today. So you can see, it takes into account. So it's the sum of costs over the lifetime to produce all the energy in the system divided by the sum of electrical energy produced over lifetime. And so what's implicit in over lifetime is that we're considering, over a long time period, the impact of the time value of money. And specifically, what that means is we're including a discount rate. That's what this r value is.

    So, in general, the different cost components can include investment expenditures, operational and maintenance expenditures, and fuel expenditures, and the energy-- the different energy that's produced in the system. In our specific case, on the expenditure side, we're focusing primarily on the investment in the renewable energy equipment, plus the operational expenses of purchasing power from the grid.

    So the 1 over 1 plus r to the power of t factors, that's a well-known factor that's used to apply a discount rate to calculate a present value of some quantity. And so, because we're considering multiple years, I'm going to what I'm doing here is just building a vector of these factors that will apply to both the energy as well as the cost in the final calculation.

    So our grid power is calculated at each hourly time step. But to calculate the present value of the grid power, we're just going to do that on an annual basis. So what we're doing here is calculating first the grid cash flows at each hourly time step, but then using the reshape function to calculate the sum of those cash flows for each year.

    So, to calculate the cost, the total cost expression for our objective function, we have the annual grid cash flows corrected by the present value factors that we showed earlier. And then we have the costs of the different components in our system. So we have the costs associated with the storage, costs for solar, and cost of wind. And these are based on the energy and power ratings that the optimization will figure out. So this takes care of the numerator in the LCOE equation.

    And then for the energy, we're doing something very similar. So we have from our data set the charging power and the load power at each hourly time step. We're calculating what that sums up to on an annual basis, and then correcting it for net present value, and then bringing that all together. So here the LCOE finally comes together as the cost plus present value of energy used to charge the EVs, plus energy used to supply the load. And then finally, I want to represent that as dollars per megawatt hour. So, just multiplying it here. And finally, we take this expression and assign it to our objective.

    So, we've set up our variables, we've set up our constraints, and finally, our objective function. We're finally ready to actually run and solve our optimization problem. So, in this case, what we've actually set up is an optimization model that is a linear programming model. What that means is that our objective function and all of our constraints are linear expressions of our optimization variables. And, of course, we have a solver for that in the Optimization Toolbox. So that's what we're going to use.

    There's a specific algorithm in the Toolbox that we're using that's efficient for problems of this scale and of this type. And then we call the solve function on our problem, and it'll iterate until it finds a solution. So I think I'm still actually in debug mode. Let me just continue and let this thing run. And I think for this three-year scenario, it takes maybe 15 to 20 seconds. So we'll go back up here.

    So we've got a few seconds. Maybe the interior point algorithm, you mentioned it's suitable for problems of this type. Are there any specific pointers for people who are picking up the tools and thinking about the solver choice?

    Actually, our default solver is a dual simplex base solver. And earlier this year, actually, we have an update to the algorithm. So we're now using a HiGHS algorithm, an algorithm provided by the HiGHS Organization. And we found it to provide a significant speed up to situations where the simplex solver is the right choice. That's actually our default solver.

    But, for certain cases, we've seen that if you have a larger set of variables or constraints, the interior point solver can be more efficient. But usually, we tell people to start with the HiGHS solver. And then, if that's not giving the efficiency that's needed, then try the interior point solver.

    Easily changed, right, is the point.

    Yeah. All right. So, that was for three years, it was less than 30 seconds because I still had to resume it. So let's look at some of the results here. So, in this case, the optimize LCOE is $427 per megawatt hour. That's pretty high. But I think part of why that's so high is because we're actually only considering a three--

    You're on three. It's not kind of scaled it to the 20.

    Yeah. So I wouldn't worry much about that.

    Right.

    The next thing that we'll look at, though, are some of the sizes that-- the ratings that the solver came up with. So we have these different ratings for solar and wind as well as the storage. You can see that all the ratings are within the bounds that we had set. But for this particular scenario that we're looking at, based on the data that we have, the system is favoring solar resources over wind.

    Now, I think now is actually probably a good time to switch over to the scenario number two. And I could just show how--

    Oh, yeah, absolutely.

    --that would work.

    Scenario number two, just to remind everybody, that's when we're removing the constraints on supplying the EVs. So we're basically saying all energy sources are fair game for both our industrial load and for our EVs.

    That's right. Yes. So all I'm going to do is just comment out two constraints. So there's this one constraint that had storage power being supplied by solar and wind. So I'm going to take that out. And then I'm also going to take out this other constraint that says that the charging power has to come from either the combination of storage, solar, and wind.

    And just with those two lines commented out, let's run this again. And then we'll see how the results change. And again, this is still just on the three-year period. So take the results with a grain of salt. But we just want to show how easy it is to make this change and to demonstrate the flexibility of the problem setup. All right. So solved in 9 seconds.

    Let's take a look at our LCOE. So as you would expect then, it's actually lower, right?

    That's the main point, right? Regardless of the scaling, we have with the three-year, it's taken advantage of that grid.

    Yes.

    A lot more.

    Oh yes. And actually, so you can see here that the optimized ratings for the renewable assets is nothing. So it's just going grid.

    Decided the grid is all it needs.

    Yeah. Offline, I did experiment a bit, as you start increasing the time horizon, then the value of renewables still comes into play, so you start actually using some of these resources. But the three-year example, it doesn't want to it doesn't want to do anything but use the grid.

    Just want to make clear at this point, we're not advocating that when you're doing systems of this type, and you don't require a green charge, that it's grid all the way, and that will always be the answer. It's not true. It's just this particular case has came out this way. The main thing is the optimization workflow being able to set it up and run it for your specific needs and your specific data.

    Yes. Important clarification. Thank you. So I've reset the script to be in the 20-year scenario state now. And I've preloaded the data from having run this ahead of time. Not that the 20-year actually takes all that long, but we don't want to be sitting here waiting for it still. So, the one thing I'll show on the data side that's different is now if you look at the 20-year time horizon, you can see that, over time, we really are seeing a big increase of EV charging demand.

    So, I've run this already. It takes about three minutes to consider 20-year periods. So it's still really, really fast. And so let's look-- well, I've already-- so the optimize LCOE in this case is 160. Here are the ratings. So now we have-- still, it's favoring solar over wind, but it is using wind as well. Now let's look at some of these plots. So I'm just going to rerun it there so I can open this up.

    So there's going to be a lot here because we're plotting a lot on the same line chart. But I'm just going to randomly zoom in to see if we can pick out any interesting observations from the results. So there's a lot here, but a few things kind of stand out to me. So if you look first at the PV power, the blue curve here, we saw this earlier over the course of the day, it goes up and down.

    One observation that I'm seeing, Graham, is that, basically, when PV power is available and high, then if you look at the cyan curve, which is the storage power, it's charging up the storage unit. So that's what-- you would expect that. And then at least for this time period, the EV charging power, so when the EVs require charge, it's kind of offset from when solar is available. So we're storing the solar energy, but then using the storage power to supply the EVs.

    Yep. And we're selling back to the grid quite a bit as well. But that's just the cost model, right? It's a simple function of that. And so it's favoring selling back to the grid because it's getting more money out of that. It's offsetting that cost. But again, it's dependent on the data you're using what you will see.

    Yes. Yeah. Yeah, and then you can see how the grid-- we're selling back to the grid. And then sometimes, we're using grid power to supply the load when there's not enough renewable resource for that. So, of course, with your data, with your problem, this will look different. But this is more just to demonstrate the types of analysis that you can do after you run an optimization study of this sort. Here, we're plotting grid power and grid power price over time. So let's quickly peek at this and see what it looks like.

    Zoom in a bit more. Now, this one's pretty all over the place. Of course, we're seeing times when we're purchasing power from the grid, times when we're selling power back to the grid. In general, you'd probably expect that we sell back to the grid when the price is high. And we do see some of that. But it's not always the case. And I think that's actually showing part of the value of using optimization for a situation.

    Absolutely. You can't work this stuff out by hand. So you need to use optimization to figure this stuff out. Exactly. Yeah.

    All right. So that was a little bit of analysis that you could do based on results from a single optimization. Now, of course, let's go back to the discount rate. So we don't actually know whether a discount rate of 5% is appropriate for this 20-year time period. And so we could perform sensitivity analysis to see how varying the discount rate is going to affect our LCOE, as well as the sizes of the assets that we're considering. So our nominal discount rate is 5%

    But there's different ways we can do this sensitivity analysis. We could just do a uniform distribution between some range. But to make things a little more interesting, I thought I'd take something from the-- do some more statistical stuff, so take advantage of functions from the Statistics and Machine Learning Toolbox to give us a normal distribution of discount rates.

    So I'm going to say, let's look at 200 different discount rates with a mean discount rate of 5%, with a standard deviation of 1%. And so we get this distribution of discount rates that we're going to consider for our sensitivity analysis.

    Then we're just, again, setting up the data for this problem. And then here, we're actually running the optimization-- well, not the optimization, the 200 separate optimization instances. And what I want to call out here is that we're leveraging another part of the MATLAB ecosystem, which is the parallel computing tools. With parallel computing, of course, then we can distribute multiple optimizations to run on parallel workers at the same time. And so the more cores that we have, the more we can scale this up and improve the efficiency and turnaround time of this study.

    In my particular case, I only had four cores on this machine. But if you have even more resource, then you could take advantage of that. And the beauty is that all it takes to use parallel computing for this scenario is changing the for loop to use parfor instead. It's as simple as that. And then under the hood, Parallel Computing Toolbox takes care of all the work of figuring out how to distribute the resources.

    Yeah. And no code change required, which is very nice.

    Yeah. So it's pretty typical that people will first test things out in serial. And then once they're ready to scale it, then you just change the for to parfor and there you go. So 200 optimization instances running on four workers took, in this case, five to six hours. Again, this is the 20-year period. But again, if you have more resources then you can get the results faster if you just parallelize on more workers.

    So then given all those results, then you are given-- once you run all those optimizations, then you can tabulate the results. Of course, you see for the different discount rates, you're starting to see different values for the ratings. fval is the LCOE coming from each of the optimizations. Oops, sorry. And then we can see how the optimal LCOE values change with respect to discount rate. And in this case, you're seeing that as we increase the discount rate, the optimal LCOE also increases.

    To look at how discount rate affects other aspects of the results, so the ratings of the different components in the system, I'm using something called the Create Plot Live Editor Task. If you're not familiar with Live Editor Tasks, there are these convenient GUI-based tools that are offered in the MATLAB Live Editor environment. And there's really a wide range of tools available. But the advantage of using these is that they allow you to do specific tasks that are pretty common for things like preprocessing data, working with tables, as well as some more specific things like even running an optimization.

    And it's a point and click workflow. So it allows you to do things in MATLAB without even needing to learn all the syntax to accomplish the task. So here, for something like this, where you're able to create different kinds of plots with the data, I'm just keeping it simple here and using create plot to create different scatter charts. But you can see how the solar power rating changes depending on the discount rate. We could flip and see what does it look like for the wind power rating.

    So, interestingly, as far as discount rate increases, it's better to have more solar than wind. And then we can look at the storage as well. So again, just an example of the type of analysis that you could do once you've performed a set of optimizations and explore the sensitivities with respect to other types of uncertain variables.

    And then the last thing I'll do for the sensitivity analysis is look at the distribution of LCOE values that we got from the optimization. And we could pull things like different statistical measures from this distribution, the mean, standard deviation. And then we can use that distribution function to calculate the cumulative-- we can use this probability distribution to calculate the distribution function for LCOE. And it looks like this.

    So what this plot is showing is, given the uncertainty in our discount rate, what is the probability of getting an LCOE value below a point that we pick on this curve? So, as an example scenario, let's say we require that LCOE has to be below 150 megawatt hours-- $150 per megawatt hour for us to consider this project to be feasible. Well, we can use this curve or just use the CDF function to see what the probability is of actually having an LCOE below 150. And in this case, you can see both from the plot as well as from running this function that it's 18%.

    This is just a helper function for the heatmap. So we need to cover that. But that covers the demo. So we went through a lot. But if you didn't follow all the specific details, that's completely OK. Because again, we are more than happy to share the example code with you. So if you're interested in that, we're happy to share it with you so that you can look through the details and figure out how to adapt the methodology for your needs. But with that, I'll pass it back to you, Graham, to wrap things up.

    Thanks, Chris. I don't think I'm going to read the summary line by line. Everybody who's watching online can go through this. But I think we'll just go through the main points of what we've went through today. So the focus on early-stage feasibility of the development of an engineered system, so that necessarily brings in techno-economic analysis and optimization. So you showed Optimization Toolbox primarily as part of that and how we can create those problems using problem-based formulation.

    But, to the point, we made earlier about the extended ecosystem of MathWorks software, you also brought Statistics and Machine Learning Toolbox in for the sensitivity analysis, and also Parallel Computing Toolbox to basically improve the performance of that large number of runs. Anything else that we should just raise here as our summary before we finish up?

    Well, I think we've hit upon this a few times, but the fact that every system is going to be unique. So, with MATLAB and the tools that we provide, they provide the flexibility to model your system, to model your study in the specific way that best represents what you're trying to accomplish. So I think that's a clear advantage of using these tools to do these kinds of analysis in MATLAB, is that flexibility.

    Yeah, exactly. It's a great point, I think, to end on. So Chris, thank you. It's always a pleasure. Definitely appreciate you jumping in.

    Pleasure is mine, Graham. Thank you.

    Thank you, everyone online, for showing up today. We greatly appreciate it. And thank you for attending.

    Thank you very much.

    Related Products