Hello all,
I work on modeling / simulation of some thermal energy system in Mathcad 15. The existing model works on the equation oriented approach, at the end all the mass and energy balance equations are gathered in the given-find block. Now I want to "modularize" the program - the components of the system are to be black-boxes, which have inputs and outputs (more precisely input and output streams, which are vectors of parameters). I was thinking about defining modules as functions, but the problem is I can not use boolean equal sign inside a function, that I need, since the whole system of equations / functions can only be solved numerically, in case of Mathcad in Given-Find block. So, every black-box would be expressed as
Function(X,U) = Y
where
X - vector of input streams (if particular black-box has more than one input stream this vector will often contain nested vectors)
U - vector of internal parameters
Y - vector of output streams (if particular black-box has more than one output stream this vector will often contain nested vectors)
As each module is connected to some other by stream(s), output stream of one module can be at the same time inlet stream of the subsequent module. For example, output stream of the superheater is simultaneously input stream of the turbine.
I would be very grateful to any ideas how to resolve the above described problem. Thanks in advance for help.
Piotr
Solved! Go to Solution.
This is much more clear to me now, I think I start to catch it. Indeed I had some misunderstanding of how it works before. Huge step foreward.
There is still a problem with equation for specific enthalpy of outlet water, I admit that you are right that it is no needed, since this enthalpy is known. It must be probably replaced by flue gas outlet enthalpy. Anyway I consider extension of the parameters list of temperature.
Piotr
I think this is the approach temperature equation you need. I can't test it because I don't have the function.
This should allow you to remove the spec on water flow rate.
Yes you can. Look at my post from 2015-03-28 12:21. There is a link to the website where you can download steam tables. Just put dlls to USER EFI folder.
I was thinking about this solution, but in that case i will have 5 equations, but I need 6.
Now I am gonna organize 2 left functions to be able to simulate HRSG.
Piotr
I see what you mean. You need to replace the water out enthalpy spec with a gas out enthalpy spec. That will allow you to keep your water outlet approach equation. I think you mentioned that as a possibility earlier.
I have Prode Properties for my physical properties program so I'm not going to load the steam tables. I've attached my changes. You will need to re-enable the water enthalpy equation and eliminate my replacement equation.
Harvey, if you want you can use many physical properties libraries independently, it will not interrupt your "main" properties library.
Piotr
Norton Security didn't trust Xsteam dll and removed it. Try the attached.
Hello Harvey. My development and testing continues. I have added temperature to the params list, now it is m, p, T, h. The current version of ECO function works fine and looks like this (F_I - flue gas inlet, F_O - flue gas outlet, W_I - water inlet, W_O - water outlet):
Note that inlet mass flow rate of flue gas and outlet mass flow rate of water are loaded as known. Outlet flue gas enthalpy is calculated from enegry balance equation.
Then I have created EVA function. As evaporator is responsible for steam generation, inlet water and outlet steam mass flow rates (which are equal) are to be calculated, not loaded as known, but I am not sure about that. The problem is that the function does not work properly (it shows 0 as water in and steam out flow rates), and I can not figure out why. Probably I made some logical mistake. Can you please take a look on this? Maybe you will know...
Note that water inlet mass flow rate is calculated from energy balance.
I also have not yet crystallized concept of how to calculate HRSG when having 3 needed functions. Only a few parameters will be known:
- gas turbine flue gas mass flow rate, temperature, and enthalpy
- flue gas pressure after economiser = atmospheric pressure
- feed water temperature before economiser
- steam pressure after superheater
- design params of ECO, EVA, and SH (flue gas / water(steam) pressure drops, pinch/approach points, heat exchange efficiency)
If you have any (new) tips for me, I will listen attentively.
I attach worksheet for your information.
Piotr
I took a quick look at the file. You may have an over specified problem because you have set T and H for the flue gas inlet in the EVA block.
I have to start dinner now, but I will look at it again later. If you find the error, please post.
I am aware that in consequence of adding T to the params list I have not got independent params list. But I have also specified T and h for flue gas inlet in the ECO block, and it works. I think the problem lies elsewhere.
EDIT: Error found. Specified flue gas mass flow rate value was defined as m.2 instead of m[2. Gosh, I spent all day tracing this.
Piotr
Piotr,
Are you sure your enthalpy balances are correct? The enthalpy of a stream out should have some connection to that same stream inlet enthalpy. I don't see this connection in either ECO or EVA.
Harvey, I guess the connections are proper. For example, T and h of water going out from ECO are specs for EVA water inlet. This is kinda tricky because we need to know p to obtain T (T is equal to saturation T at pressure p minus approach point), and then use p and T to obtain h. So T and h of water out from ECO are input data for water going in for EVA, but p is loaded from EVA water inlet to ECO water outlet.
Now please look at flue gas side. Parameters of gas going out from EVA are specs for gas going in to ECO (will be loaded as specs) - exept p, which is always calculated backwards. This is because the fixed values of pressure are always on the end, for flue gas side it is atmospheric pressure, and for water/steam side it is pressure after superheater.
I already have all 3 functions and currently I try to connect them by streams properly to form HRSG, without results for now, but this is just a beginning. All in all probably I will not handle this without your help, but I will try to play with this for some hours. Like I said, the concept is not yet crystallized in my head, but I feel it may work.
We will see if this concept is correct, if not it can always be changed.
Piotr
I see my problem. I keep thinking of the fourth element in the stream vector as total enthalpy, not specific enthalpy. Now, by multiplying the specific enthalpy by the flow rate, I do see the connections between inlet and outlet.
I forgot to be precise and start writing just enthaply instaed of specific enthalpy. I am not operating on total enthalpy at all, or rather I operate on total enthalpy implicitly, by multiplication of mass flow rate and specific enthalpy, as you see.
In addition to the case of pressure loading backwards, another example is steam turbine. Pressure of steam incoming to the turbine will be loaded forewards. However, as pressure after steam turbine is determined only by condenser (conditions of cooling), its value will have to be transferred from condenser unit to steam turbine unit. But specific enthalpy after turbine / before condenser is not only a function of steam pressure, so the units will have to communicate bidirectional.
Piotr
I think this is going to work. You will be able to set your individual specs to results of other units in a new, grand solve block. Good luck!