Developing Hydrogen Systems from Tank to Fuel Cell
Overview
In this presentation you will learn how Simulink and Simscape can be used to model, simulate, and analyze multidomain dynamical systems. Latest features facilitate the precise modeling and simulation of thermodynamics and behavior of complex gas mixture. Three typical industrial applications related to the hydrogen gas distribution network from tank to fuel cell are presented, highlighting key workflows such as parameter estimation or component sizing optimization.
Highlights
- Introduction in modeling gas systems with Simscape
- Valve control for hydrogen charging station tank-to-tank
- Parameter estimation from measurements and datasheets
- Multi-species fuel cell model including nitrogen diffusion and purging
About the Presenters
Vasco Lenzi is senior application engineer at MathWorks Switzerland. He specializes in design automation with emphasis on multidomain modelling, control design, verification, and deployment. Prior to joining MathWorks in 2016, Vasco worked as a development engineer on the modelling and simulation of engines and hydraulic systems at Liebherr Machines Bulle. Vasco also worked as a control software developer at the Institute of Dynamic Systems and Control, ETH, with active participation in Formula Student competitions. He holds a B.S. in mechanical engineering and an M.S. in Energy Sciences from ETH Zurich.
Gernot Schraberger is Principal Application Engineer in the Munich office of The MathWorks with 14 years of experience in that position. His main application focus is on Electrification, Physical System Modelling and Control Design. Prior to joining MathWorks, Gernot worked as Development Engineer for motor control and embedded SW engineering in the semiconductor manufacturing industry. Gernot holds a master degree in automation engineering from the Technical University of Munich.
Recorded: 6 Apr 2022
Hi, everybody, and welcome to this webinar titled developing hydrogen systems from tank to fuel cell. I am Vasco Lenzi. I'm an application engineer in the Swiss office based in Berne. And my background is in control design, physical modeling, and simulation on real time systems. With me today there is Gernot Schraberger.
Go ahead, Gernot.
Well, I'm going to try, but I'm also application engineer in the Munich office at MathWorks. And I have an electrical background. And I focus here on electrification topics, physical modeling, and control design.
Thank you, Gernot. Today we are in the second installment of our three-part series around hydrogen production and fuel cell application with MATLAB and Simulink. I hope all of you already had the pleasure to attend to the first one. And we invite you to take the third one as well.
In this part of the series, we are going to focus more on the thermodynamics aspect of hydrogen, how to model the gas system, the infrastructure around hydrogen transportation, tank, heat exchangers, and so on. And we will then in the second part of today's webinar focus on a very high fidelity model of a fuel cell, as well can be applied the same concept for an electrolyzer, which includes nitrogen diffusion and purging. So let's get started.
Introduction in modeling gas system with Simscape, this is something that happens mostly in a library product called Simscape, has been used in the industry since a while. We have here an example from RAG Austria, one of the largest energy storage and gas transportation companies of Europe. They presented at our MATLAB Energy Conference in 2021. And this is an excerpt of what Christian Burgstaller, the technical advisor who gave the presentation, said. I particularly like it how they wanted to create a digital twin of the entire gas hydration facility built.
They use the MathWorks platforms from Simulink to Stateflow to Simscape to model this water vapor extraction in the gas processing facility and operational logic. And they had a very positive comment, like a power solver. There is an extensive library. You can customize it, and it's really a valuable tool for planning and optimization. They even compared measurement with a data point.
This is one slide I took of his presentation. And he says that they expected, they measured minus 23.4 degrees of dew point for the water in the hydrogen gas, and in reality, in the model, they got to minus 24. So they really find very good agreement between what they modeled and the data they got from the measured facility, which is always nice to see. But as an introduction to how we deal with such system, we are going to take a look at a hydrogen refueling station.
Here we have a low pressure supply of hydrogen, which has been done, thanks to the compressor, go up to 950 bar. And in these test cases we are going to run in the model, we are going to do this in one hour. Then there is a chiller. Then, when the time is right and the dispenser is activated, it's always keeping a very low temperature of the gas flowing into the vehicle. This is necessary to avoid a big temperature jump in the vehicle tank.
The idea here is that after one hour, when we reach the right pressure, the vehicle, which is empty, has only 30 bar in the tank, is going to be refueled to 700 bar. We are going to put 6 kilos, this is the requirement we have of hydrogen, in our vehicle tank, and t should last less than five minutes. So let's see it in action.
I'm using the newly released release 22a. And what we can see here is already open up our project. Project is a nice way to interact with our files. It directly integrates with version controls, and it allows you as well to share your project, packaging everything that is going to be needed for this to other people, reference other projects, create what is going to be run, the startup and shutdown. So if you have never used Project before, my suggestion is that you start using it. It's a very convenient way to work with it.
There are shortcuts as well. I did one shortcut to the model I want to discuss today. And this is the model we're going to look together. It's a nitrogen gas refueling station. We have the low pressure supply, like in my architecture. We have a compressor inside a subsystem.
You see this pink line. We're going to discuss about it later on. But this is the flow of hydrogen, which is physically connected between the different components. The heat exchanger, before going the high pressure buffer storage, you have the chiller, we have the high pressure valve. We have a small pipe that goes to the dispenser which is kind of the things attached to the vehicle, delivering the hydrogen gas. And then we have the vehicle tank.
And then we do some calculation, such as integrating from the initial mass. We integrate the vehicle tank, so that we can have the total kilos. And back in the days when we didn't have a physical modeling platform such as Simscape, you could do physical modeling using this kind of approach, where you would have a velocity going into an integrator and then having the position out of it. And you could build up your differential equation with a lot, basically rewriting system level equation. And while this was OK for certain systems, it surely cannot scale to much more complex and multi-domain systems.
And that's why we introduced the Simscape platform already 15 years ago, where connection are no longer signal driven and flows in one direction and you solve the equation, but you have component out of a library, the Simscape library, that you connect together as they were physical connections. Just to take a look at example on the compressor, let's go in it. We can see that we have two possibilities. These are called variant subsystems.
I have an ideal compressor and a real compressor. And if I look in my ideal compressor, this is simply mass flow, simply a mass flow. I can give any mass flow and it's going to keep this mass flow from port A to port B. And so there is real hydrogen flowing in. The same can be seen in the heat exchanger where we actually have modeled the pipe, which is exchanging heat with the rest of the environment.
And this is the real cool thing about Simscape. You get, so to speak, more color. And each color is associated with a new physical domain. And so you have the heat flow, taking heat out of the pipe and putting it into the ambient temperature. In this case, we are using an ideal heat exchanger. We are just giving power to take away the heat from the pipe.
And we can then size and dimension the necessary heat exchange that we need to make this storage work, this refueling station work. So I ran the simulation now for 40,000 seconds. You can see down below that now, what happens is that I defined, each component brings its own equation to the entire system. There is a compilation part in which the entire state space basically is calculated, based on all the components attached to the physical network.
And this is then inserted in our powerful solver and simulation engine. And then it is simulated. And then we are going to see that this model is actually exceptionally fast, of course. It's not very complex. And to repeat what we achieve, we want to do, is we want to bring the first hour to fill up the compressor and then start the vehicle tanking process. So we can see here that it starts the simulation down below.
It goes from 0 is already after one hour, and then there is a bit of more slowness when we are charging the tank. There is a lot of physical things happening there during the tanking process. The simulation slows down a bit and then it stops. And we get the result back.
Vasco, just a short question. Can you say a few words, what benefits this simulation brings in that case? So what's the real use case?
Yes, that's a very good question, Gernot. Thanks. Such a simulation like I did right now can be used with-- can be quickly put together using ideal components, such as ideal compressor. This is not physics at all. It's just we control the mass flow going into the system. We control the heat taken out of the system.
And so it can be used to start sizing up our system, seeing if everything is all right without really going into the details of our physical domain. It can already be coupled with part of the software to see if our logic and whatever we achieve and we want to do, such as opening up the valve that flows into the chiller, then after two seconds opening up the dispenser to start the tank charging for refueling process, and then once the vehicle pressure is more than 700 bar, we can close it off. So you can really start combining softer logic and a very high level physical model, but nevertheless, with time, you can increase the complexity of your model.
I will do that when I switch to the real compressor, so that we can compare the two simulation runs. If I open up the data inspector, very quickly, just to take a look, we can look at a couple of key performance. We wanted to see if the vehicle tank flow, we see that after 3,700, we go up to around 20 gram per second, which compares to more or less 1.5 kilograms per minute, which is what expected on today's hydrogen refueling station.
I can measure if I meet my requirement of 300 seconds. I see that, thanks to this cursor, I am at 303. So I'm almost there. It fulfilled the requirement, we can say. And we can fill up the tank.
But how much did we fill up? We can plot the total mass that's flowing into our tank and we see we start from 300 grams of hydrogen and in the end we have 6 kilograms. So actually we reach six kilo around after 250 second, 260 seconds.
So this is fully complying with our requirement, high level requirement, or how we want to operate. And so we can really use this simulation to get all this how much of this KPI right, how much should flow from the dispenser to the vehicle tank, and so on. We can as well clear this plot, and plot something like the high pressure pressure. So the compressor works, we see that we start from 30 bar and we bring it up to 950. After more or less 3,500 seconds, we are there.
And down below we can see maybe the temperature, very quickly, the high pressure storage temperature. The gas, of course, heat up while it's being compressed, but we have a heat exchanger that can keep the temperature in check around 60 degrees. And then we can take a quick look at the total power needed, for instance, to keep the gas after the chiller at minus 40 degrees.
This is very often done in this kind of refueling station. We have a chiller after the high pressure storage. We need to keep the gas at around minus 35, minus 40 degrees, so that we don't have a big spike in temperature when we are bringing it into the tank. And we can see that here as well in the tank temperature.
There is a big spike. It comes to around 60 degrees. But this is not dangerous. This is fully acceptable. So I did my thinking process in a safe way.
Let me just quickly do one last simulation to showcase the difference with a real compressor. We can go inside the compressor to take a look at this new block that we are bringing in air, 22a. It's a positive displacement compressor and can easily be parameterized using your data sheet of your machine. We tried really to take a look at our compressor producer, our parameterizing their machines, and so you can refound the same things here.
You can put kilograms per hour as a mass flow, what would be the nominal shaft speed, and what would be the nominal pressure ratio, and the volumetric efficiency. And these things can always be checked. This is a kind of a trick for you in the audience. There is very often a fluid, in the right click there is very often a fluid field, where you can plot key characteristics of component. In this case, it's the volumetric efficiency versus the pressure of the compressor, pressure ratio.
So let's simulate with this block. Quickly compare it, and then we go back to the presentation. As we can see here, already, this is one of the many blocks that combines two domains together. We have the pink one for the gas. And then we have the green one for the mechanical part.
And so there are a lot of these multi-domain blocks within Simscape that allows you to build up truly this multi-domain simulation. I cancel all the subplots. Let's put just one. And the nice things about the data inspector is that I can always see my past simulation. So I have the mass flow of the compressor, in this case, the ideal one, we can see is just like I give a constant.
And then we can take the real compressor mass flow. Let's put it in green. And we can see how this respect truly reacts to the different pressure differential that you have from port A and port B. This works around the nominal mass flow, and so we already have more precision in our system.
But we see we can use the mass flow to size it up and then we can put a real component to see how it all fits together in a more dynamic way. Very well. Let's go back to the presentation. We respected our requirement, and what we saw was Simscape in action. It's an add-on to Simulink. It requires MATLAB and Simulink.
It comes with foundation libraries in many domains. It is a custom diagnostic and a simulation engine. It's a dedicated solver and we have add-on libraries as well, such as electrical, driveline, multi-body, and fluids. And today we saw fluid in action with the compressor block and other components of the fluids library. These additional libraries provide you with a transit block to make your system even more accurate.
That Simscape language that we didn't show, but Gernot is going to show you in the second part of the webinar, is a powerful way to customize your system. We try to put together for you the relevant Simscape domain for hydrogen system modeling. They go from thermal exchange, like we saw the temperature, to mechanical, like we saw with the compressor, electrical, this, for the fuel cells, is going to be very important, thermal liquid for the electrolyzer with the water coming into the system, gas, two-phase fluid, and moist air.
These all come off the shelf as a shipping library. But that's not all. We can build custom domain, and we actually, this is quite new, in our 22a release we bring an example of custom domain. It's not a proper library yet, but an example of a custom domain, within a fuel cell example of a multi-species mixed gas domain, which comprises of nitrogen, hydrogen, water vapor, and oxygen. And Gernot is going to talk about it by showing this fuel cell example in the second half.
We saw very quickly that we can implement software. Let's take a very quick look on this in the model. We used in this case Stateflow, which is our software for supervisory logic. We see here that the logic can be very clearly expressed through transition between states, using things such as times, which makes it very readable, or other kind of transition criteria, such as logical and Boolean. But this is just a very simple machine.
It reads very well. You can even, while you simulate, see how the system goes through the different states. But this is widely used, widely adopted by our customer writing supervisory logic for industrial automation systems. It's a very, very powerful tool that can do much more than simply these four states. It can create events. It can really be used for complex logic.
And this is very necessary as well for modeling physical systems, as we see in the example of RAG Austria, again from Christian, that presented in our energy conference series. It really clearly says that you need a way to express the valve logic when you're building a facility, a digital twin of your facility, and use Stateflow. And you can see already, if we zoom in into the Stateflow that he shows in his presentation, how you can very elegantly do parallel states for different adsorber and create this kind of logic and switching sequence.
And the best part is you can use this software to generate code, so that you can directly reuse the logic on a real time controller. With the automatic code generation you reduce coding time and error. You can get source code, which is hardware independent and everything is captured in one model. You can generate both structural, text, and C code.
You bring it into the proper IDEs and you can then deploy it in many different PLCs, direct by a pre-prepared control unit, for which we have a partnership. We have partners and third party partnership you can look up in our connection website. Or you can even build, if you have your own custom hardware that you just built, you can generate code for that as well, with our consulting services. We do support all the relevant PLCs worldwide, and that we structure the text very often in both with C code.
So don't hesitate. This can be quite a complex implementation. So don't hesitate to reach out to your MathWorks representative and discuss with people like me, application engineering, your application in more details. This is true as well for training. We put together a curriculum for you, for people who want to work hydrogen system. This is our suggestion.
You saw a Simscape. You saw Stateflow. So we really think, if you're serious and start using our platform, it's really critical that you take the time to get your team properly ramped up from Simulink to Stateflow. If you're using code generation, it's critical to take the right code, because there are tons of parameters and things that you can change. So this is a slide that you can use as a reference when you discuss with the MathWorks representative about your training path.
The same is true for consulting. Work with us to speed up your project. Many don't know that we have a very successful consulting engineering branch, where we did work with many customers in energy domain, and others like LV or Genentech, it's building bioreactors. So we have really hands-on experience, and you don't need to stay alone for your project. Reach out to us.
We have reached now the third part of our webinar about parameter estimation from measurement and data sheet. And we are going to compare our experiment with our compressor data from real life compressor, to our model, and try to fit the parameters to that. To be more concrete, what I did is I performed a ramp from 1,000 rpm to 2,000 rpm on my compressor, and then I recorded the mass flow using a mass flow meter.
And I kind of tried to parameterize my model, my compressor block model. But it wasn't that good in putting the parameters, because the result of the model is way off from my measurement. So what can we do about it to make it much better?
We can switch to the model. I prepared the same harness that I used in my experimental setup, I replicated in the model using Simscape. And we can see here the same compressor we discussed before. Some of these numbers we have here, they can be parameterized directly from data sheet, because they match very well with what the supplier are giving you. Some orders, such as the volumetric efficiency, pressure ratio, the polytropic exponent, mechanical efficiency, they are used for formula and equation within the block.
And we may not know them exactly, or the supplier may not provide them exactly. They are used, for instance, for this kind of equation for the fluid power, or to calculate the volumetric efficiency. You can find all the equations in the documentation page of this block. So what we can do is go to Apps and open up the parameter estimator App.
And in this case, we can create a new experiment. It is picking up all the signals that are locked in the model. We are just interested in the one from the mass flow from my model. And we want to compare it with the time series I saved in my MATLAB workspace called mass flow measured. If I plot and simulate, it's going to retrieve this information from the MATLAB workspace, simulate once, and compare it to my measurement.
Here it is. What we need to do now is to pick the right parameter. We can select them, again, from the MATLAB work-space that picked it up from the GUI automatically, the mechanical efficiency, pressure ratio, volumetric efficient, polytropic, exponential, they come here. And then the best things to help the optimization problem is to bound them to some value.
We know the efficiency is always between 0 and 1. This is always defined. We know that our pressure ratio for this kind of system can go from 1 to kind of 30, on a scale of 30 from pressure in to pressure out. And then the polytropic exponent of hydrogen is kind of always between 1.28 and 1.33. Once we have done this, we should actually activate fast restart for a slightly faster simulation, and then click the estimate button.
What is happening here is that we can see the experiment changing. It's starting with a certain data set from the beginning, which causes a certain error. And then it changes this kind of parameter to try and reduce the error. We can see already that we went from 20 to sum of the squared error between the two signal to 5. And we can see how the curve is approximating approaching the others.
Vasco, I've got one question. You've just got four signals here at the moment. What if you have more? How can you make sure that it's fast enough?
Yeah, that's a very good question. While it's optimized, I can give you some tips and tricks. You saw me before activating fast restart. What does it mean? It means that the steady state equation of the system is compiled once, at the first simulation.
And then it just changes parameter without ever recompiling the model each time. This makes it a bit faster. The second thing that you can do is to activate an option like parallel core, so that you can perform the optimization of multiple cores, and lastly you can perform sensitivity analysis so that you can find only the parameters that are really impactful for this optimization problem.
Maybe instead of 30, you can perform sensitivity analysis, find the three most impactful parameters and concentrate your parameter estimation on those parameters. We see now our estimated parameter, our estimation is finished. We matched now the measurement. Some parameters change, some more of the others. Here maybe there is a scale problem.
Some, since the scale is different, some parameters seem that they didn't change. But in reality they changed a bit. And here are our final results, with our new parameter we can fit to the compressor so that we can cover this kind of operating region. What do we see now? We have used Simulink design optimization, which comes with three apps such as parameter estimator, response optimizer, or sensitivity analyzer, to help you through these kind of workflows.
And this closes my part. The word is now to Gernot, and the fourth part, the most complex part, around the new fuel cell model we ship in 22a. So take it away, Gernot.
Thank you, Vasco. Well, I want to talk now about the multi-species fuel cell modeling, including nitrogen diffusion and purging. And you already see here an overview image of such a system. What's the main task here? In principle the main task of a fuel cell is to convert hydrogen and oxygen to energy and water.
And how you can build up such a model in Simscape I will show you now. So but let's go one step back first. The question is what are fuel cell system models used for? So there are different things our customers do with them. One is the selection sizing of components. So they do that for trade-off studies, just to figure out, well, is one setup better than the other one? And it's also used for the optimization of parameters and for finding right operating strategies.
Another point is the design and validation of control algorithms. We will see just in a few minutes that such a fuel cell system not only consists of the fuel cell stack, but you have a lot of other components around, like pumps, like heat exchanges, and also things that have to be controlled. And that's for example, thermal management, humidity management. So that's a kind of control that we have to take care here. Pressure control is another one.
Now and then fuel cells can be part of a bigger system, for example in vehicles, in ships, and airplanes, whatever. Then we want to analyze, for example, the energy flows between a fuel cell system, the electricity produced there, the battery system. We want to see the range, for example, of a vehicle, how far that we can go with a full tank, and so on. So these are the typical use cases people are interested in.
So what's the benefit of a simulation here? It will shorten the development time. You can test a wider range of conditions, and that even without risking your real system. And then you can reduce the costs of testing with prototypes. Because we can test here virtually in a simulation, not everything has to be built up and tested in a real setup. So before we come to the modeling of a fuel cell, we have to think about which kind of fuel cell we want to focus on.
And here's a list from a web page from Energy.gov, where you can see different fuel cell types, like polymer, electrolyte, membrane, or alkaline, and so on. And we also see information here about the typical operating range, like temperatures here, like the power and the efficiency. And we'll see, especially for vehicles, and that's I think one of our main customers are coming from this area.
You can see here the polymer electrolyte membrane fuel cells are the most interesting ones. And that's where we want to focus on today. So how does a fuel cell work? Now let's have a look at this diagram here. We have hydrogen here on the top, coming in at the anode. It's oxidized here in the anode.
That means it will lose the electrons. They are passing over the wire here, over the load. The hydrogen protons will pass the membrane. And on the cathode side, we have oxygen here coming in. It will be reduced here.
So that means it will take electrons coming over the wire and, together with hydrogen protons, it will be converted to water vapor here, which is exhausted here. In such a model, of course, we have to focus on anode/cathode, on this process here in the membrane. But we also have to think about the temperature and the heat flows in the system, because heat is playing an important role here as well.
Well, let's have a look at how such a whole system looks like. And that's a fuel cell system, including the balance of plant. These are all these additional components around the fuel cell stack. So here is the stack. And then we have, for example, hydrogen tank here. We have valves to reduce the pressure.
We will have heat exchangers. We have a pump here for the airflow, so especially for the oxygen path, we have to have humidifiers, because the membrane has to be operated with about 100% relative humidity. It should never get dry, because that will cause trouble. And that's all-important to model as well here, in such a system.
Then we also have to consider the load. This can be a power converter for driving an electric motor here. And you also see here, for example a battery system, which can be a backup for the fuel cell. So before I directly jump into the demo, I have a screenshot here of the demo. And I want to start on the top level here.
And here we see different colors. The colors are representing different physical domains. And we have got this dark blue color for the custom fuel cell domain. This is a mult-species gas domain covering nitrogen, oxygen, hydrogen, and water vapor. So these are the four species that are of interest here in a fuel cell operation.
And we used that on the hydrogen side, on the anode side, but as well as on the oxygen side or on the air side. So in real life we are considering air, not only oxygen, because we will take the air from the environment. The membrane, well, is, of course, also connected to the fuel cell domain. But it also has electrical characteristics.
So here we have Faraday's law in Nernst equation and so on. On the top you'll see the electric connection to the electric load. And here in orange color, we have the thermal connections, from the anode, cathode, and the membrane. The reason is that we have to operate a fuel cell at around 80 centigrade, and that's very important.
So we have to use thermal management. And that can be done with heaters or with cooling. That's the reason why we have to consider here these thermal connections. We also have a cooling system, for example, with liquid cooling, because it's one of the most efficient ones. And that's also part of the model.
But now let's go to the model itself. Well, you can see the model that I've just shown before. If we go through the single components now, well, we start here with the hydrogen. We have got the hydrogen source, which is mainly a tank. And the tank in the model will be a so-called constant volume chamber.
We have a parameter list here and you will see here if you go into detail that all the four species that we are focusing on have to be covered here. So that means we use typically tables here for the parameterization, if they are depending on, for example, one other entity, like the temperature. Or we might use even more tables, so like in 3D tables, if we also have to make it depending on the pressure.
So indeed we have four species here. We have a thermal connection port here to the environment. In this case, it's isolated. We have a port here, where this tank is connected to the next unit, which is a pressure-reducing valve. And there are also some inputs here where we can apply an external mass flow for this four species from outside with a specific temperature.
And we've got also some measurement connections here, measurement outputs for the mole fraction, for temperature, for the pressure here, for example. I explained it in that detail because you will see this concept all over the model, independently if it's a tank or any other volume chamber or a pipe element and so on. So what's done here in this block is that we have to reduce this high pressure of the tank of about 700 bars to a pressure of about 1.6 bar for real operation.
So we have got this pressure reducing valve here with some controller. And we have got a pipe element. Once again as mentioned before, the same connection, inputs here for the mass flow per species and the temperature. If you continue here, the next partial system is here, a recirculation system, because we come in here with hydrogen, but typically not all the hydrogen is used on the anode side.
Some part will be passing the anode and it can be reused. So we have this recirculation to increase the efficiency. And what you see in here is another volume chamber, in this case with three port connections. And then we model here an ejector, in case of a controlled mass flow. And this mass flow is then controlled by the amount of current that is used on the electrical side. So another controller in here.
Then, as I mentioned before, the hydrogen has to be wet, so we need 100% relative humidity here, so to be able to apply the hydrogen to the anode or to the membrane. So that's the task of the next controller here, where we have one that's 100% relative humidity. We measure the humidity here and we apply additional water here. And that's interesting.
Well, you cannot see directly here what's going on. But you have to know that every location here in this vector has a standing for a specific species. The first one is nitrogen and we have oxygen, then hydrogen. The last one is water. So you see here, just the last element is set here in the game block.
That means the output here is applied to water flow that is getting in here to the pipe. And that means that we increase the humidity here in the system. At the same time, we have to apply a temperature here of the stack so that we can tell the system in which temperature the water or water steam is coming in here.
Well, next part is the anode itself. Anode is, once again, a constant volume chamber with several connections here. We come in here at port C. We get out at port B. And we have a connection here to the membrane. This one is just used for getting temperature and pressure.
There is no flow going over the membrane here. The flow is controlled from the equations in the membrane by these external mass flows inputs here, as I mentioned, just before in the other block where we increase the humidity. We have got also thermal connection here, so an exchange of heat with the environment. And we have an output here in use for the mass fraction of every single species.
If we come back here with the hydrogen on this path in the recirculation, well, we might also take some nitrogen from the membrane, because we do not have ideal conditions in the membrane and real membrane will also pass some water and nitrogen. And that we will find then here in this path. And now the point is if the nitrogen level is too high, we cannot use this here in the supply of hydrogen.
We have to get rid of that. And that's the reason why we need an anode exhaust here. The anode exhaust, the concept is that we measure the molar fraction of the nitrogen. That's the first component here of the four species. And we have a relay switch. And if we reach more than 50% of molar fraction, we have to purge, that means we have to get rid of the gas combination.
And we have to restart the process. And the purging will happen as long as we are in the range between 0.5 and 0.1. So I have started a simulation already before. That means I can use now a specific representation of outputs. And that's within the Simscape Result Explorer. We see already some concentrations here.
But if we look, for example, specifically here to the anode exhaust, where we have been in here. Let's go in here again. And we say, well, we are interested, if the purging works correctly, then we can check, well, we have got this connection port A here of the anode exhaust. So we are up here, port A, and you see here we can measure the molar fraction and the mass fraction.
So if we click on here on the molar fraction, what can we see? We see the first species which is nitrogen. Nitrogen level is increasing here, until we reach this level of 0.05. Then we start the purging. We are going down to the level of 0.1. And these are exactly the values that we have specified here.
So that's a way of checking if the behavior is correct. What else can we see here? We can see that in this path here, we can see which species can be found there. So we can find here as seen here, the nitrogen in orange, we have oxygen, that's 0. That means we have no oxygen on that side. That's the other side.
You can see in yellow, hydrogen. You see the level is going down here, till we do the purging. Then it's going up again. And we have to keep the level over a certain threshold. And the last one is the water steam that is here in violet color.
So if we continue here, next thing is the membrane. The membrane is a custom component here. I will just show later on how you can use Simscape language to build such custom components. You've got the chance here to look to the source code by clicking on here. And I would say let's have a look a little bit later on that part.
Now if we look to the right side, that's the oxygen path. And it is built up very similarly like the hydrogen path. The only big difference here is that oxygen is coming here from the environment. It has the ambient pressure, which is about 1 bar. So we need a compressor here to increase the pressure, not a valve to reduce the pressure.
But you also have got controllers here, in a similar way, driven by the current demand from the electrical side. We have humidifiers here, built up in the same way, cathode built up in the same way as on the anode side, and then a cathode exhaust. Well, there is no recirculation here in that case, because the air is available. We don't have to take care on the consumption, amount of consumption of air.
So Gernot, quick question. This is a great example. They are shipping with 22a. And in the audience there are a lot of people working on electrolyzer, not fuel cell. Does the same concept in principle could be applied for an electrolyzer model?
It's a good question, Vasco. Yes, it's very similar. And we even have got an electrolyzer model. Let me just open that up. Here we are. Well, and you can see a similar structure. We have anode side, cathode side, and we are coming in here with water. That's the big difference.
And because of that, we use here thermal liquid domain. It's a different color here. This thick wire is a bus system in Simscape, covering gas. That's oxygen and water. And on the other side, we use the gas domain. So there is no need to use this multi-species gas domain. The custom domain, that's a little bit different. But the overall structure is quite similar. And, yes, we can also simulate these processes within a electrolyzer system.
So if we're coming back here what else can I show you here in the model? One thing is the thermal connections here, from the anode, cathode, and membrane. Especially interesting cooling system, possibly, cooling system has got a pump here, a cooling cycle with a heat exchanger, modeled as a simple pipe on one side, and then a radiator on the other side to get rid of the heat. And we have got a thermal controller here where we want to control the temperature at 80 centigrade.
Well, I already mentioned before that the membrane is modeled with Simscape language, because it's a custom component. And now I want to give you a short insight how such custom components are built up in the Simscape language. Well, the Simscape language is based on MATLAB language, but it's object-orientated and it will generate Simscape blocks at the end of the day, which look exactly the same as a shipping block coming from the MathWorks.
So you can add the mask, for example, a parameterization mask. You can add, well, images here for better recognition of the block. And I use here the local restrictions example, which is a part of this custom domain for the fuel cell modeling multi-species gas. So if we look to the source code here, a Simscape language file typically starts with the expression component to describe a component.
There's also another keyword here, domain, if you want to author your own domain, like the fuel cell domain. But for the component we'll have component name here next to the keyword component local restriction, then some text that you will find in the parameterization mask, the input with the name AR, that's here, which is specifying, well, the size of the local restriction here in square meters. Then we have the connection ports A and B, that are coming from the fuel cell domain.
That's the domain where we have the four gases per definition. Next thing is then the parameters. If we double click here on the block, you'll see a parameter mask. And you will find the prompt for the parameters here, as a command here in the parameter section of the Simscape language file. We have variable names for the internal use in the file, and initial value and initial units that you can find here.
In this case, it's already overwritten. It's not using the initial value any longer, as you can see here. But you see the single expressions here from the commands here as prompts here in the mask.
The most important part here of Simscape language files are the equations. The equations are expressing the behavior of the component. And equations, for example, are equations concerning the pressure, concerning mass balance, energy balance for example, in such a block, and a few other things.
Well, we started now with the most detailed way of modeling fuel cell systems with a balance of plant that you can find here. Of course, that's also system that will not run so fast, because we focus on all the details. We can use that one for all the control design, for controller tuning, for figuring out concentrations of the gases, for example, in every specific branch.
But for some other reasons, you might need sometimes simpler systems. And, well, we also have got fuel cell blocks, pre-defined blocks in Simscape electrical, like the simple fuel cell block here on the very right. There's another parameterization variant where we can set it to detailed, so it's a first principles model but without the gas dynamics. But we can apply at least the pressure and the mass flow rate for the fuel and the air.
And there's something in between here as well. That's a lookup table based modeling approach with no dynamics. We use statistical modeling methods here. And the big difference to the model that I've shown on first in detail is that it's just purely based on data. So you have to do a lot of measurements, and you build up a multidimensional lookup table reference.
So last step I want to focus on here is now if you have modeled such a system in Simscape, as shown before, how can you protect your property, if you have to share your model with partners, with other departments. And there are several ways to do that. One thing you can do is use Simscape language files and create protected components.
There is a command to do that. And this one is SSC_protect, before you even can combine all the Simscape blocks to a single Simscape block, so that you are not protecting single blocks but the entire system. And that's possible as long as you don't have Simulink parts in there. The concept of protection here is by encryption.
So we are encrypting the Simscape language files, the source code. And it will be decrypted whenever it is integrated in the bigger system. Another concept is the use of protected models or FMUs. And that's now running on the level of subsystems. These subsystems can also contain Simscape components, but also Simulink blocks, without any problem.
And how that is done, this concept is using code generation. So we have a model with the fuel cells in there, for example, including the controllers in Simulink. We can use here protected reference models. And this, the protection process, will create a file called MDLP or SLXP into the new variant, P for protected. And it's a similar workflow with FMUs, so there is a specific safe option to save a model as an FMU. In both cases, code generation technology is used to do the protection.
So Gernot, to save as an FMU, do I need a specific tool, because this is something which is having a large interest in the industry?
Yeah, for creating standalone FMUs, you will need the MATLAB compiler and Simulink compiler, too. So we are nearly at the end now. Let's have a look to the conclusion. Simscape offers components for fuel cell modeling on various fidelity levels. We have seen complete fuel cell models in the overview, just as a single block.
But we also have all the single components for a fuel cell system, like the tanks, like valves, heat exchangers, and so on. Then we have shown here the different domains used for fuel cell modeling. It was on one side the multi-species gas domain for nitrogen, oxygen, hydrogen, and water, which was a custom domain that was created with the Simscape language. We had electrical domain, where we did not have a big focus on today because it's, well, not too complicated.
And we have also had a look to the thermal and thermal liquid domain for the temperature management. And the last point is that fuel cell models can be used for control design and algorithm development, for integration studies, for example, and for system and control parameter optimization. So you can fine tune your system here on the algorithmic side, but also on the physical side, by using such Simscape models.
Well, as a last slide I want to pinpoint here, once again, that we have our next webinar on the 26th of April. The topic there will be fuel cell integration for electrified propulsion. And, well, we are looking forward to seeing you in this webinar once again as participants. Additionally, I want to mention that you can register for the webinar here with this link down here or with the QR code. Thank you for coming to the webinar. And we are open now for your questions coming over the chat.