Jump to content



Featured Articles

Check out the latest featured articles.

File Library

Check out the latest downloads available in the File Library.

New Article

Product Viscosity vs. Shear

Featured File

Vertical Tank Selection

New Blog Entry

Low Flow in Pipes- posted in Ankur's blog

Calculation Of Water


This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic
Share this topic:
| More

#1 Zac00

Zac00

    Brand New Member

  • Members
  • 5 posts

Posted 31 March 2014 - 08:08 AM

Hello

 

I have this new spreadsheet for calculating Evaporation.I have learnt how the steps are generated to give each result except for the result in cell D21.The formula uses User Defined Formulas stored in a module.Could someone please explain how the formula works in cell D21 and how the enthalpySatVapPW & enthalpySatLiqPW work in the formula.I would presume 101.3 is 1 Bar Pressure (kPa) and 1.013 is 1 Bar....

 

Any help appreciated

 

Thanks

 

Zac00

Attached Files



#2 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 31 March 2014 - 02:45 PM

You will find the functions by opening the visual basic editor.

 

Bobby



#3 Zac00

Zac00

    Brand New Member

  • Members
  • 5 posts

Posted 31 March 2014 - 06:32 PM

Thank you

 

I have been through the functions but need help understanding the functions in the formula D21.I am trying to workout how the result was achieved.What are these 2 functions performing - enthalpySatVapPW & enthalpySatLiqPW in the formula.I see they are in the VBE/Module but what is there role in the final result?

 

Thanks again



#4 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 31 March 2014 - 07:55 PM

The functions are defined in the VBA code. The functions each return a value that is used in the cell formula.

 

Bobby



#5 Zac00

Zac00

    Brand New Member

  • Members
  • 5 posts

Posted 31 March 2014 - 09:23 PM

Hi Bobby

Thanks

 

I have been through the UDF originally but i do not understand how the UDF returns the values.I worked out that 101.3 would be 1 Bar in kPa and 1.013 is 1 Bar.What i casnnot workout is how the UDF return a value.I looked at these UDF before i posted but unfortunately am unable to see how they return a vale

 

Thanks



#6 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 31 March 2014 - 10:44 PM

Set up a calculation using any of the functions. You need to pass the paramaters as defined by the function. This will answer your query.

=funx(p1, p2, ....pn)

Bobby


Edited by Bobby Strain, 31 March 2014 - 10:45 PM.


#7 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 01 April 2014 - 10:49 AM

I'm not sure if this is what you are asking. VBA functions are designed to return values through the function name. You will notice in the code for each of the UDF's that there is a statement (or multiple statements depending on the code) assigning a value to the function name (as if it were a variable). For example from one of the thermal conductivity functions:

Public Function thconSatVapPW(Pressure)
'
' thermal conductivity of saturated steam as a function of pressure
' thconSatVapPW in W /(m K)
' pressure in bar
'
' thconSatVapPW = -1: pressure outside range
'
    If Pressure >= pSatW(273.15) And Pressure <= pSatW(623.15) Then
'  region 2
        Temperature = tSatW(Pressure)
        density = 1 / volreg2(Temperature, Pressure)
        delta = density / 317.763
        tau = 647.226 / Temperature
        Pressure = Pressure - 0.0001 * Pressure
        thconSatVapPW = 0.4945 * lambthcon(Temperature, Pressure, tau, delta) <--- value assigned to function name
    ElseIf Pressure > pSatW(623.15) And Pressure <= pc_water Then
'  region 3
        Temperature = tSatW(Pressure)
        Pressure = Pressure - 0.00001
        density = densreg3(Temperature, Pressure)
        delta = density / 317.763
        tau = 647.226 / Temperature
        thconSatVapPW = 0.4945 * lambthcon(Temperature, Pressure, tau, delta) <--- value assigned to function name
    Else
'  outside range
        thconSatVapPW = -1# <--- value assigned to function name
    End If
'
End Function

The assignment statements highlighted in red (well, I wanted them to be highlighted in red) are assigning a value to the function name. When the function gets to the end and returns to Excel, the value stored in the function name is the value that Excel sees.

 

Is that what you are looking for?


Edited by MrShorty, 01 April 2014 - 10:51 AM.


#8 Zac00

Zac00

    Brand New Member

  • Members
  • 5 posts

Posted 01 April 2014 - 11:22 AM

Thanks MrShorty

 

The result in D21 on the spreadsheet is 2207.....i tried but cannot seem to workout how this was achieved....if you were to breakdown the formula into steps how is the result 2207.....are you able to show the calculations for each step for the formula in D21

This may be the best way for me to understand and then try some of the other UDF myself..

 

From the example above if the Pressure >= pSatW(273.15) And Pressure <= pSatW(623.15) Then it will look at region2 to calculate the value...is this correct?

 

Thanks for the help



#9 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 01 April 2014 - 12:04 PM

From the example above if the Pressure >= pSatW(273.15) And Pressure <= pSatW(623.15) Then it will look at region2 to calculate the value...is this correct?

Correct. If you follow the link at the top of the code module to B. Spang's page here, he describes the 5 regions defined by the IAPWS for calculating the properties of water. Each function in the module will need these kind of If...Then statements to determine which region it should use to calculate whatever property is requested.
 

Just pulling the equation out of the spreadsheet and putting it into a more algebraic format, it looks like this is the equation:

 

meFD=metotal / [Hvap(FD)/Hvap(sys) + 1] where:

 

meFD=mass evaporated in FD

metotal=total mass evaporated

Hvap(FD)=enthalpy of vaporization at FD vacuum

Hvap(sys)=enthalpy of vaporization at system vacuum

 

The 101.3 and 1.013 values are there to convert the given kPa(gauge) pressures to the bar(absolute) values required by the functions to calculate the thermodynamic properties of water.

 

P(bara)=P(kPa)/101.325*1.01325 + 1.01325

 

There's the basic equation being used. Rather than go through the entire calculation step by step, are there specific quantities/steps that you are having trouble following or understanding?


Edited by MrShorty, 01 April 2014 - 12:05 PM.


#10 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 01 April 2014 - 12:34 PM

Another skill that may be useful for this kind of thing. On the Formulas group, there is the "evaluate formula" tool. Select D21 and call this utility. Excel will bring up a window and you will be able to evaluate the function one step at a time. This will allow you to see what values are being returned for each step of the calculation in D21.

 

In this spreadsheet, I did the same thing, only separating each step of the calculation into separate cells.

Attached Files



#11 Zac00

Zac00

    Brand New Member

  • Members
  • 5 posts

Posted 01 April 2014 - 05:44 PM

Hi MrShorty

 

Thank you kindly for your excellent help

 

Very much appreciated

 

Thanks again






Similar Topics