04-14-2012 05:23 AM
Hi, I have an input table “composition” consisting of hydrocarbon components. I’m also using an array as a look up table, table B.1 in this case. There are 21 gas components, and 21 molar masses that correspond to each of the components. However, and here is my dilemma, as you can see Im indexing all values of molar mass. However, I only want to index the molar mass values that have a corresponding non zero value from my composition table, or probably more realistically, replace the molar masses that have a mole fraction of 0, to a 0 value for molar mass.
E.g.
Methane > 0.9 >16.043
Nitrogen > 0.01 > 28.0135
Carbon dioxide > 0.01 >44.01
Ethane > 0 > 0 (replaced expected 30.07 with 0)
Any ideas?
Thanks
Solved! Go to Solution.
04-14-2012 06:27 AM - edited 04-14-2012 06:27 AM
Hi labnoob,
you should actually use your "components" table for getting the desired results - right now it's wire ends at the loop input!
- You don't need a for loop to get 21 consecutive elements of an array - you only need one ArraySubset function.
- "ConvertStringToNum" works with arrays too.
- Analyze your components "Mole Fract" column by comparing with ">0", convert the resulting boolean array to 0/1 and multply with your mole mass array - you're done with some simple (polymorphic array) math...
04-14-2012 06:40 AM
I like the sound of that. Ok, i will take some time to digest your advice and try and implement this.
Thanks mate
04-14-2012 06:57 AM
Ok, done it 🙂 works a treat and i can see this is a much better solution than the direction i was heading...
Thanks again