Closed ellieLitwack closed 2 years ago
Hi, I really don't like the style of the code with so much ifs clause, but you're right it's faster, so I'm merging your contribution. I have also corrected a typo in your contribution and applied the changes to the deriv_H function used for IAPWS95 and IAPWS97 region3. Thank you very much for your contribution and I am glad that you use and like this software. Best regards, Juan José Gómez
Thanks Juan! I started using your software at my company and it's really sped up our simulations. Very grateful for your work. I believe the "correct" way to do it would be with the new match/case syntax in Python 3.10, but that would cause a versioning issue for this project unfortunately.
This edit reduces the time to call deriv_G from 2.8 to 1.7 microseconds on my computer (based on cProfile of instantiating one IAPWS97 object at 300K/0.101 megapascals).
About 40% of deriv_G execution time was being spent on instantiating the dictionaries containing the different partial derivatives of G - this method uses if statements, which is much faster.
This lead to a pretty significant code speedup for a program I was writing that called IAPWS97 a large number of times - I hope it can be helpful to others as well.