Custom K factor calculation for pipe fittings.

Custom K factor calculation for pipe fittings.

js1900
Contributor Contributor
7,073 Views
16 Replies
Message 1 of 17

Custom K factor calculation for pipe fittings.

js1900
Contributor
Contributor

 

We have a requirment to use our own numbers for the K factor calculation for pipe fittings.

 

This could be done through the API with a IPipeFittingAndAccessoryPressureDropServer, but it seems like it could be simpler to just add an entry to the PipeKFactors.xml in C:\Program Files\Autodesk\Revit 201x\PipeKFactors.xml.

 

It looks to be a simple enough for elbows, we can just create a new table in the xml with the diameters and coefficients we need, and Revit will use it to get our value.

 

However for Tees the table is more complex and Revit seems to be doing more behind the scenes. For example we can put our coefficients in but Revit seems to output a number 4 times larger than expected every time. It gets even more complex for the table “Converging/Diverging Tee/Wye” which seems to have no numbers in the xml and instead references equations defined elsewhere.

 

Has anyone have some insight into the algorithm used on these tables so we can be sure we can get the right values? Or have an idea why our edits to the Tee coofeicients ("Custom Welded Tee" in attached xml) result in in Revit giving a factor 4 times greater when we inspect it through the pressure loss reports?

 

 

Many thanks

 

 

Accepted solutions (1)
7,074 Views
16 Replies
Replies (16)
Message 2 of 17

jeremytammik
Autodesk
Autodesk

Dear js1900,

 

Thank you for your very valid query.

 

I am checking with the development team and will let you know as soon as I hear back from them.

 

I wish you a wonderful weekend.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear js1900,

 

The development team already replied rapidly with a number of helpful hints.

 

The Revit UI provides a lot of detail on these calculations if you navigate to

 

Manage > MEP Settings > Mechanical Settings > Pipe Settings > Calculation

 

Additional information is provided in the help:

 

http://help.autodesk.com/view/RVT/2017/ENU/?guid=GUID-7D4BF4BC-89DF-4EB2-93EB-52900B8583B5

 

In general, the loss on a fitting is the velocity pressure multiplied by the loss coefficient. This can be confirmed in the pressure loss report:

 

pressure_loss_report.png

 

For the “4x greater” case of the custom tee, we tried to reproduce and were unable to do so.

 

I had a different problem with it altogether, namely, no friction factor was found in the table at all (see image below).

 

What would be helpful in this case is to get a sample model demonstrating this issue. In some cases, the family and/or its instance parameters are defined in such a way that factors are applied multiple times, so it may not necessarily be the XML at issue.

 

Can you provide details of where you are getting your data from for your ‘Custom Welded Tee’? E.g., do you have table(s) of data you can provide for the various conditions through the tee?

 

It looks like you are trying to input the “Custom Welded Tee” data in a format similar to the “Converging/Diverging/Side Tee” in the default .xml file. Can you confirm that? Any details of what exactly was changed would probably be helpful as well.

 

no_friction_factor.png

 

Converging/Diverging Tee/Wye is implemented in code, as it is not based on simple tabular data. It is based on the method in the Crane Technical Paper 410.

 

In order for us to explore this in any greater depth, we need a complete and minimal reproducible case:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

I hope this helps.

 

Once again, I wish you a wonderful weekend.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 17

Anonymous
Not applicable

Hi Jeremy thanks for your reply, I have been working with js1900 on this.

 

We had looked through those calculations in Revit help which are well explained for pipes. However for fittings it simply says you can choose a K Coefficient from table, without really saying how it gets the number.

 

You are right, “Custom Tee” in our xml is simply the “Converging/Diverging/Side Tee” table copied. Then we modified XAxis values, which appear to be diameter ratios, to be 2 numbers far apart. This was to cover all diameter values. We repeated data for these X values to avoid Revit interpolating between them (We only want this to cover equal tees so perhaps we could have just had a single X value of 1.0?)

Then we just put the K coefficients we wanted in the data element, mapped to the flow ratio.

 

This was all based on guesswork and some testing, and it does appear the logic makes sense apart from the factor of 4!

 

I have attached the data we are trying to get Revit to use for Tee coefficients, a basic test model and test PipeKFactors.xml.

The XML includes a Tee table with the data we want to use/4, along with some test tables containing only values of 1. Replacing the default PipeKFactors.xml and running a pressure loss report gives this.

 

Loss Report.PNG

 

We have just been using guesswork and experimentation to get this far in modifying the xml, but it does seem like we can get useful results so appreciate any insight!

 

Thanks

Jared

Message 5 of 17

jeremytammik
Autodesk
Autodesk

Dear Jared,

 

Thank you very much for your research, new results and patience.

 

Do you have anything further to add from the last two months?

 

I have passed this on to the development team again to hopefully provide explanations of the missing bits and pieces.

Best regards,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 17

jeremytammik
Autodesk
Autodesk

Dear js1900 and Jared,

 

I heard back from the development team again. They say:

 

I’d like to elevate this discussion to ‘what’ and ‘why’ before we endeavour into the ‘how’...

 

Who is the inquirer?  What company, what use case?

 

It is pretty clear what they want to accomplish (get loss coefficients based on the PDF), regardless of how... however, in the PDF (within the ZIP), it is not clear what ‘configuration A’ or ‘configuration B’ is... thus, it isn’t clear if what we have in the PipeKFactors for A vs B is the same as what they expect for A vs B. 

 

What is the source of the data in the PDF?  We’re using CIBSE Guide C 2001 table 4.47, has something superseded that that is generally applicable (the last data I have from CIBSE was from 2007?  Why is the data we have not sufficient?

 

One gap I noticed during reviewing this is that we don’t have the ‘screwed’ data for sub-table (f), and I noticed their data is all ‘threaded’ vs. ‘welded’ (for Configuration A), so I suspect that they’ll need two separate tables to deal with those cases.

 

Some more inline comments on the previous reply:

 

> We had looked through those calculations in Revit help which are well explained for pipes.

However, for fittings, it simply says you can choose a K Coefficient from table, without really saying how it gets the number.

You are right; 'Custom Tee' in our xml is simply the 'Converging/Diverging/Side Tee' table copied. Then we modified X-axis values, which appear to be diameter ratios, to be 2 numbers far apart. This was to cover all diameter values. We repeated data for these X values to avoid Revit interpolating between them (We only want this to cover equal tees, so perhaps we could have just had a single X value of 1.0?)

 

Answer: based on what I see in the tabular data, it seems that having a single row of x data for 1.0 would be sufficient if the tee is always equal size is a good starting assumption.

 

> Then we just put the K coefficients we wanted in the data element, mapped to the flow ratio.

This was all based on guesswork and some testing, and it does appear the logic makes sense, apart from the factor of 4!

 

Answer: Are you saying that the resulting coefficient is 4x bigger than expected?  Do you have this same problem if you use the PipeKFactors.xml table unmodified?  Does this actually affect the expected pressure drop, or is this just an issue with the reported K value?

 

Looking forward to your renewed response and also to hearing how you are doing with this issue.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 7 of 17

Anonymous
Not applicable

Hi Jeremy, Thanks for getting back to us. We are Hoare Lea, an MEP engineer. The pressure loss calculations would be used by mechanical engineers to size pipes. This is normally done using dedicated spreadsheets based on CIBSE Guide C (2007) but we would like to do it using Revit. 

 

We have had another in depth look at this since the original post and decided on using creating a custom calculation server using the API, which was able to meet our requirements. This basically checks which type tee configuration is being calculated and selects the appropriate lookup table, derived from CIBSE C 2007 (Configuration B is the configuration when the branch pipe has the greatest flow, so branch in for diverging and out for converging BTW). This server also calculates K factor for elbows and transitions.

We did this as there’s some resistance to using Revit for these calcs from users in HL. It seems there is a feeling, rightly or wrongly, the numbers are coming from a black box which the engineers don’t feel they can trust. Using an API calculation server suits us better than editing PipeKFactors.xml because there are too many unknowns about how Revit uses it and of course it could change at any time. We have more control with our code.

 

One thing we noticed is that IPipeFittingAndAccessoryPressureDropUIServer just doesn’t seem to work. We created our own, it is loaded as a service but no option to show a UI is ever presented. Also tried the https://github.com/jeremytammik/UserMepCalculation which again all works except the UI servers. I'm guessing the Edit button below should be active? That sample is superseded but there is no UI server in the new sample…

 

Capture.PNG

 

Thanks again

Message 8 of 17

jeremytammik
Autodesk
Autodesk

Dear Jared,

 

Thank you very much for your new input and interesting research and experiences!

 

The loss method settings edit button that you show looks as if it comes from the Revit element property panel.

 

In most cases, these properties represent element parameter values.

 

The Revit API only provides access to very simple parameter data types.

 

Everything more complex cannot currently be handled by the API and remains inaccessible.

 

I have passed this on to the Revit MEP development team asking for their response.

 

Please give us a shout if you don't hear anything back from them within a week or two, please.

 

Thank you!

Best regards,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 17

Hugh_Compton
Advisor
Advisor

 

The attached Dynamo code can change those values.  If the Loss Method is NOT 'Specific Coefficient' on the element then the first run will fail but the second run will work. 

 

 

Message 10 of 17

jeremytammik
Autodesk
Autodesk

Dear Hugh,

 

Thank you for sharing this!

 

I extracted the following code from your Dynamo script, for those interested in reading it online (questions added by me):

 

def getServerById(serverGUID, serviceId):
  service = ExternalServiceRegistry.GetService(serviceId)
  if service != "null" and serverGUID != "null":
    server = service.GetServer(serverGUID)
    if server != "null":
      return server
  return null

def getLossMethods(serviceId):
  service = ExternalServiceRegistry.GetService(serviceId)
  serverIds = service.GetRegisteredServerIds()
  list=List[ElementId]()
  for serverId in serverIds:
    server = getServerById(serverId, serviceId)
    
    id=serverId
    name=server.GetName()
    lc.append(id)
    lc.append(name)
    lc.append(server)
    
  return lc

# Set Coefficient?

  TransactionManager.Instance.EnsureInTransaction(doc)
  param = fitting.get_Parameter(BuiltInParameter.RBS_PIPE_FITTING_LOSS_METHOD_SERVER_PARAM)
  lc = getLossMethods(ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService)
  schema = lc[8].GetDataSchema()
  field = schema.GetField("Coefficient")
  entity=fitting.GetEntity(schema)
    
  param.Set(lc[6].ToString()) 
  TransactionManager.Instance.TransactionTaskDone()

# Set K Factor?

  fitting = doc.GetElement(eleId)
  param = fitting.get_Parameter(BuiltInParameter.RBS_PIPE_FITTING_LOSS_METHOD_SERVER_PARAM)
  lc = getLossMethods(ExternalServices.BuiltInExternalServices.PipeFittingAndAccessoryPressureDropService)
  schema = lc[8].GetDataSchema()
  field = schema.GetField("KFactor")
  entity=fitting.GetEntity(schema)
     
  oldval = entity.Get[field.ValueType](field) # obtaining values
  
  TransactionManager.Instance.EnsureInTransaction(doc)
  entity.Set[field.ValueType](field, SetNew) # installation of a new coefficient value of certain
  fitting.SetEntity(entity)
  TransactionManager.Instance.TransactionTaskDone()

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 11 of 17

jeremytammik
Autodesk
Autodesk

Dear Jared,

 

Thank you for your patience.

 

The development team responded:

 

"It appears that they’ve gone from modifying the PipeKFactors.xml to creating their own calculation servers.  Would be good if they were to summarize their current status/issues, and setup a meeting, vs. handling this through a forum.  Who specifically at HL shall we connect with?  I’m happy to reach out to my contact at HL (Ben Roberts), unless you have a more specific contact to reach out to."

 

Sorry to hear about the issue with IPipeFittingAndAccessoryPressureDropUIServer.

 

I logged the issue REVIT-123389 [IPipeFittingAndAccessoryPressureDropUIServer -- 11843886] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

Can you please provide a full minimal reproducible case for them to analyse demonstrating the issue?

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

As it stands now, they have very little to look at and can do nothing at all about it.

 

Thank you!

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team, and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 12 of 17

jeremytammik
Autodesk
Autodesk

Dear Jared,

 

The development team are working on the issue REVIT-123389 [IPipeFittingAndAccessoryPressureDropUIServer -- 11843886] that I logged for this on your behalf and ask:

 

Is it possible to get the code implementing IPipeFittingAndAccessoryPressureDropUIServer from the developer?

 

I don't see it in the forum thread, or anywhere else either.

 

The best would obviously be if you can provide a complete reproducible case for the issue with exact steps to reproduce:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 13 of 17

Anonymous
Not applicable

Hi Jeremy,

 

I have attached an example of an app which tries to use an IPipeFittingAndAccessoryPressureDropUIServer. Basically i don't know how 

 

bool ShowSettings(PipeFittingAndAccessoryPressureDropUIData data);

 

in IPipeFittingAndAccessoryPressureDropUIServer is ever run.

 

To try this example open or create any model with a pipe fitting in it.

 

It adds some commands to the external commands drop down,

1 to register/unregister a PipeFittingPressureDropServer named "Example Test Server"

1 to register/unregister the corresponding IPipeFittingAndAccessoryPressureDropUIServer named "Test Pipe Fittings UI server"

A command to very simply show all registered services and their servers. This is to confirm the UIserver is actually active.

 

The pressure drop server is correctly registered and available to select in the "Loss Method" on pipe fittings. The UI server should open a simple window on show settings but we just don't know this is executed.

 

Thanks for having a look

Message 14 of 17

jeremytammik
Autodesk
Autodesk

Thank you. I passed it on to the development team for you.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 15 of 17

jeremytammik
Autodesk
Autodesk

Dear Jared,

 

The development team analysed the issue REVIT-123389 [IPipeFittingAndAccessoryPressureDropUIServer -- 11843886] that I logged for this on your behalf and explain:

 

Thank you for providing the sample.

 

The root cause is: the user needs to define one data schema in the DB Server.

 

Currently, the user just returns null, so the UI server button will be disabled.

DataSchema.png

 

I attached a sample file PipeFittingPressureDropServer.cs with updated code.

 

I mainly added one utility class PipeSchemaBuildingUtility to show how to create a data schema.

 

You can replace with your own code, of course.

 

Then you can invoke the user defined dialogue.

 

TestUIServer.png

 

 

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 16 of 17

Anonymous
Not applicable

Aha we have got the UI server working now!

 

Thanks for you assistance

Message 17 of 17

Iev60047
Advocate
Advocate

Wow This is a great thread! Lot's of helpful info. I am also working to convince my department that we can use Revit for these calculations.

 

Is there a tutorial floating around somewhere, where someone walks through how to modify the PipeKFactors.xml file to include custom k coefficients for general pipe fittings and/or all the different types of tees?