[iapws] 01/02: IAPWS 1.1 upstream
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jun 16 11:28:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to tag debian_1.1-1
in repository iapws.
commit 498a9ac063ca2cd08b4f6c3fbc5e2f9adcdf5c51
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Fri May 1 12:08:55 2015 +0100
IAPWS 1.1 upstream
---
LICENSE | 674 ++++++++
MANIFEST.in | 2 +
PKG-INFO | 350 ++++
README.rst | 329 ++++
iapws.egg-info/PKG-INFO | 350 ++++
iapws.egg-info/SOURCES.txt | 14 +
iapws.egg-info/dependency_links.txt | 1 +
iapws.egg-info/requires.txt | 1 +
iapws.egg-info/top_level.txt | 1 +
iapws/__init__.py | 938 +++++++++++
iapws/_iapws.py | 413 +++++
iapws/iapws08.py | 214 +++
iapws/iapws95.py | 1317 +++++++++++++++
iapws/iapws97.py | 3086 +++++++++++++++++++++++++++++++++++
setup.cfg | 5 +
setup.py | 34 +
16 files changed, 7729 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..70566f2
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
\ No newline at end of file
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..b1eaf85
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include README.rst
+include LICENSE
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..4f2d9d7
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,350 @@
+Metadata-Version: 1.1
+Name: iapws
+Version: 1.1
+Summary: Python implementation of standard from The International Association for the Properties of Water and Steam
+Home-page: https://github.com/jjgomera/iapws
+Author: jjgomera
+Author-email: jjgomera at gmail.com
+License: gpl v3
+Description: iapws
+ =====
+
+ Python implementation of standard from IAPWS (http://www.iapws.org/release.html). The available standard are::
+
+ IAPWS-IF97
+ IAPWS-95
+ IAPWS-06 for Ice
+ IAPWS-08 for seawater
+ IAPWS-05 for Heavy water
+
+ dependences
+ --------------------
+
+ * python 2x, 3x, compatible with both versions
+ * Numpy-scipy: library with mathematic and scientific tools
+
+
+ install
+ --------------------
+
+ In debian you can find in official repositories in testing and sid. In stable you can install using pip::
+
+ pip install iapws
+
+ In ubuntu it's in official repositories from ubuntu saucy (13.10)
+
+ In other SO you can download from its webpage in `pypi <http://pypi.python.org/pypi/iapws>`_ and unzipped in python folder dist-packages. This is the recommended options to have the latest version.
+
+
+ TODO
+ --------------------
+
+ Improve convergence in two phase region for IAPWS95 and D2O class
+
+
+ IAPWS-IF97
+ --------------------
+
+ Class to model a state for liquid water or steam with the Industrial Formulation IAPWS-IF97
+
+ Incoming properties:
+
+ * T, Temperature, K
+ * P, Pressure, MPa
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * x, Quality, [-]
+
+ Definitions options:
+
+ * T, P (Not valid for two-phases region)
+ * P, h
+ * P, s
+ * h, s
+ * T, x (Only for two-phases region)
+ * P, x (Only for two-phases region)
+
+ Properties:
+
+ * P, Pressure, MPa
+ * T, Temperature, K
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * x, quality, [-]
+ * h, Specific enthalpy, kJ/kg
+ * u, Specific internal energy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * cv, Specific isochoric heat capacity, kJ/kg·K
+ * Z, Compression factor. [-]
+ * gamma, Isoentropic exponent, [-]
+ * alfav, Isobaric cubic expansion coefficient, 1/K
+ * kt, Isothermal compressibility, 1/MPa
+ * alfap, Relative pressure coefficient, 1/K
+ * betap, Isothermal stress coefficient, kg/m³
+ * joule, Joule-Thomson coefficient, K/MPa
+ * deltat, Isothermal throttling coefficient, kJ/kg·MPa
+ * region, Region
+
+ * v0, Ideal specific volume, m³/kg
+ * u0, Ideal specific internal energy, kJ/kg
+ * h0, Ideal specific enthalpy, kJ/kg
+ * s0, Ideal specific entropy, kJ/kg·K
+ * a0, Ideal specific Helmholtz free energy, kJ/kg
+ * g0, Ideal specific Gibbs free energy, kJ/kg
+ * cp0, Ideal specific isobaric heat capacity, kJ/kg·K
+ * cv0, Ideal specific isochoric heat capacity, kJ/kg·K
+ * w0, Ideal speed of sound, m/s
+ * gamma0, Ideal isoentropic exponent [-]
+
+ * w, Speed of sound, m/s
+ * mu, Dynamic viscosity, Pa·s
+ * nu, Kinematic viscosity, m²/s
+ * k, Thermal conductivity, W/m·K
+ * alfa, Thermal diffusivity, m²/s
+ * sigma, Surface tension, N/m
+ * epsilon, Dielectric constant, [-]
+ * n, Refractive index, [-]
+ * Prandt, Prandtl number, [-]
+ * Tr, Reduced temperature, [-]
+ * Pr, Reduced pressure, [-]
+
+
+ Usage::
+
+ from iapws import IAPWS97
+ sat_steam=IAPWS97(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS97(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS97(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+ IAPWS-95
+ --------------------------------
+
+ Class to model a state for liquid water or steam with the general and scientific formulation IAPWS-95
+
+ Incoming properties:
+
+ * T, Temperature, K
+ * P, Pressure, MPa
+ * rho, Density, kg/m3
+ * v, Specific volume, m3/kg
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * x, Quality, [-]
+ * l, Optional parameter to light wavelength for Refractive index, mm
+
+ rho and v are equivalent, only one can be defined
+ Definitions options:
+
+ * T, P (Not valid for two-phases region)
+ * T, rho
+ * T, h
+ * T, s
+ * T, u
+ * P, rho
+ * P, h
+ * P, s
+ * P, u
+ * rho, h
+ * rho, s
+ * rho, u
+ * h, s
+ * h, u
+ * s, u
+ * T, x (Only for two-phases region)
+ * P, x (Only for two-phases region) Very slow
+
+ Properties:
+
+ * P, Pressure, MPa
+ * Pr, Reduced pressure, [-]
+ * T, Temperature, K
+ * Tr, Reduced temperature, [-]
+ * x, Quality, [-]
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * u, Specific internal energy, kJ/kg
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * cv, Specific isochoric heat capacity, kJ/kg·K
+ * cp_cv, Heat capacity ratio, [-]
+ * w, Speed of sound, m/s
+ * Z, Compression factor, [-]
+ * fi, Fugacity coefficient, [-]
+ * f, Fugacity, MPa
+ * gamma, Isoentropic exponent, [-]
+
+ * alfav, Thermal expansion coefficient (Volume expansivity), 1/K
+ * kappa, Isothermal compressibility, 1/MPa
+ * alfap, Relative pressure coefficient, 1/K
+ * betap, Isothermal stress coefficient, kg/m³
+ * betas, Isoentropic temperature-pressure coefficient, [-]
+ * joule, Joule-Thomson coefficient, K/MPa
+ * Gruneisen, Gruneisen parameter, [-]
+ * virialB, Second virial coefficient, m³/kg
+ * virialC, Third virial coefficient, m⁶/kg²
+ * dpdT_rho, Derivatives, dp/dT at constant rho, MPa/K
+ * dpdrho_T, Derivatives, dp/drho at constant T, MPa·m³/kg
+ * drhodT_P, Derivatives, drho/dT at constant P, kg/m³·K
+ * drhodP_T, Derivatives, drho/dP at constant T, kg/m³·MPa
+ * dhdT_rho, Derivatives, dh/dT at constant rho, kJ/kg·K
+ * dhdP_T, Isothermal throttling coefficient, kJ/kg·MPa
+ * dhdT_P, Derivatives, dh/dT at constant P, kJ/kg·K
+ * dhdrho_T, Derivatives, dh/drho at constant T, kJ·m³/kg²
+ * dhdrho_P, Derivatives, dh/drho at constant P, kJ·m³/kg²
+ * dhdP_rho, Derivatives, dh/dP at constant rho, kJ/kg·MPa
+ * kt, Isothermal Expansion Coefficient, [-]
+ * ks, Adiabatic Compressibility, 1/MPa
+ * Ks, Adiabatic bulk modulus, MPa
+ * Kt, Isothermal bulk modulus, MPa
+
+ * Hvap, Vaporization heat, kJ/kg
+ * Z_rho, (Z-1) over the density, m³/kg
+ * IntP, Internal pressure, MPa
+ * invT, Negative reciprocal temperature, 1/K
+ * hInput, Specific heat input, kJ/kg
+
+ * mu, Dynamic viscosity, Pa·s
+ * nu, Kinematic viscosity, m²/s
+ * k, Thermal conductivity, W/m·K
+ * sigma, Surface tension, N/m
+ * alfa, Thermal diffusivity, m²/s
+ * Pramdt, Prandtl number, [-]
+ * epsilon, Dielectric constant, [-]
+ * n, Refractive index, [-]
+
+ * v0, Ideal gas Specific volume, m³/kg
+ * rho0, Ideal gas Density, kg/m³
+ * h0, Ideal gas Specific enthalpy, kJ/kg
+ * u0, Ideal gas Specific internal energy, kJ/kg
+ * s0, Ideal gas Specific entropy, kJ/kg·K
+ * a0, Ideal gas Specific Helmholtz free energy, kJ/kg
+ * g0, Ideal gas Specific Gibbs free energy, kJ/kg
+ * cp0, Ideal gas Specific isobaric heat capacity, kJ/kg·K
+ * cv0, Ideal gas Specific isochoric heat capacity, kJ/kg·K
+ * cp0_cv, Ideal gas Heat capacity ratio, [-]
+ * gamma0, Ideal gas Isoentropic exponent, [-]
+
+
+ Usage::
+
+ from iapws import IAPWS95
+ sat_steam=IAPWS95(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS95(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS95(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+ IAPWS-06 for Ice Ih
+ --------------------------------------------
+
+ There is too implemented a function to calculate properties of ice Ih from 2009 revision, in this case only let temperature and pressure as input for calculate properties, the function return a dict with properties available:
+
+ * P, Pressure, MPa
+ * T, Temperature, K
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * h, Specific enthalpy, kJ/kg
+ * u, Specific internal energy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * alfa, Cubic expansion coefficient, 1/K
+ * beta, Pressure coefficient, MPa/K
+ * kt, Isothermal compressibility, MPa
+ * ks, Isentropic compressibility, MPa
+
+
+ Usage::
+
+ from iapws import _Ice
+ ice=_Ice(273.15, 0.101325) #Ice at normal melting point
+ print(ice["rho"]) #Calculated density
+
+
+ IAPWS-05 for Heavy water
+ --------------------------------------------
+
+ Same properties as for IAPWS-95
+ Reference state set at liquid at normal boiling point (1 atm)
+
+ Usage::
+
+ from iapws import D2O
+ sat_liquid=D2O(T=370, x=0) #saturated liquid with known T
+ print(sat_liquid.h) #calculated enthalpy
+
+
+ IAPWS-08 for seawater
+ --------------------------------------------
+
+ Incoming properties:
+
+ * T: Temperature, K
+ * P: Pressure, MPa
+ * S: Salinity, kg/kg
+
+ S is the Reference-Composition Salinity as defined in Millero, F.J., R. Feistel, D.G. Wright and T.J. McDougall, "The composition of Standard Seawater and the definition of the Reference-Composition Salinity Scale", Deep-Sea Res. I 55, 50 (2008).
+
+ Calculated properties:
+
+ * T: Temperature, K
+ * P: Pressure, MPa
+ * rho: Density, kg/m³
+ * v: Specific volume, m³/kg
+ * h: Specific enthalpy, kJ/kg
+ * s: Specific entropy, kJ/kg·K
+ * u: Specific internal energy, kJ/kg
+ * g: Specific Gibbs free energy, kJ/kg
+ * a: Specific Helmholtz free energy, kJ/kg
+ * cp: Specific isobaric heat capacity, kJ/kg·K
+
+ * gt: Derivative Gibbs energy with temperature, kJ/kg·K
+ * gp: Derivative Gibbs energy with pressure, m³/kg
+ * gtt: Derivative Gibbs energy with temperature square, kJ/kg·K²
+ * gtp: Derivative Gibbs energy with pressure and temperature, m³/kg·K
+ * gpp: Derivative Gibbs energy with temperature square, m³/kg·MPa
+ * gs: Derivative Gibbs energy with salinity, kJ/kg
+ * gsp: Derivative Gibbs energy with salinity and pressure, m³/kg
+
+ * alfa: Thermal expansion coefficient, 1/K
+ * betas: Isentropic temperature-pressure coefficient, K/MPa
+ * kt: Isothermal compressibility, 1/MPa
+ * ks: Isentropic compressibility, 1/MPa
+ * w: Sound Speed, m/s
+
+ * mu: Relative chemical potential, kJ/kg
+ * muw: Chemical potential of H2O, kJ/kg
+ * mus: Chemical potential of sea salt, kJ/kg
+ * osm: Osmotic coefficient, [-]
+ * haline: Haline contraction coefficient, kg/kg
+
+
+ Usage::
+
+ from iapws import SeaWater
+ state = SeaWater(T=300, P=0.101325, S=0.001) #Seawater with 0.1% Salinity
+ print(state.cp) # Get cp
+
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Education
+Classifier: Intended Audience :: Science/Research
+Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Scientific/Engineering
+Classifier: Topic :: Scientific/Engineering :: Chemistry
+Classifier: Topic :: Scientific/Engineering :: Physics
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..e97406b
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,329 @@
+iapws
+=====
+
+Python implementation of standard from IAPWS (http://www.iapws.org/release.html). The available standard are::
+
+ IAPWS-IF97
+ IAPWS-95
+ IAPWS-06 for Ice
+ IAPWS-08 for seawater
+ IAPWS-05 for Heavy water
+
+dependences
+--------------------
+
+* python 2x, 3x, compatible with both versions
+* Numpy-scipy: library with mathematic and scientific tools
+
+
+install
+--------------------
+
+In debian you can find in official repositories in testing and sid. In stable you can install using pip::
+
+ pip install iapws
+
+In ubuntu it's in official repositories from ubuntu saucy (13.10)
+
+In other SO you can download from its webpage in `pypi <http://pypi.python.org/pypi/iapws>`_ and unzipped in python folder dist-packages. This is the recommended options to have the latest version.
+
+
+TODO
+--------------------
+
+Improve convergence in two phase region for IAPWS95 and D2O class
+
+
+IAPWS-IF97
+--------------------
+
+Class to model a state for liquid water or steam with the Industrial Formulation IAPWS-IF97
+
+Incoming properties:
+
+* T, Temperature, K
+* P, Pressure, MPa
+* h, Specific enthalpy, kJ/kg
+* s, Specific entropy, kJ/kg·K
+* x, Quality, [-]
+
+Definitions options:
+
+* T, P (Not valid for two-phases region)
+* P, h
+* P, s
+* h, s
+* T, x (Only for two-phases region)
+* P, x (Only for two-phases region)
+
+Properties:
+
+* P, Pressure, MPa
+* T, Temperature, K
+* g, Specific Gibbs free energy, kJ/kg
+* a, Specific Helmholtz free energy, kJ/kg
+* v, Specific volume, m³/kg
+* rho, Density, kg/m³
+* x, quality, [-]
+* h, Specific enthalpy, kJ/kg
+* u, Specific internal energy, kJ/kg
+* s, Specific entropy, kJ/kg·K
+* cp, Specific isobaric heat capacity, kJ/kg·K
+* cv, Specific isochoric heat capacity, kJ/kg·K
+* Z, Compression factor. [-]
+* gamma, Isoentropic exponent, [-]
+* alfav, Isobaric cubic expansion coefficient, 1/K
+* kt, Isothermal compressibility, 1/MPa
+* alfap, Relative pressure coefficient, 1/K
+* betap, Isothermal stress coefficient, kg/m³
+* joule, Joule-Thomson coefficient, K/MPa
+* deltat, Isothermal throttling coefficient, kJ/kg·MPa
+* region, Region
+
+* v0, Ideal specific volume, m³/kg
+* u0, Ideal specific internal energy, kJ/kg
+* h0, Ideal specific enthalpy, kJ/kg
+* s0, Ideal specific entropy, kJ/kg·K
+* a0, Ideal specific Helmholtz free energy, kJ/kg
+* g0, Ideal specific Gibbs free energy, kJ/kg
+* cp0, Ideal specific isobaric heat capacity, kJ/kg·K
+* cv0, Ideal specific isochoric heat capacity, kJ/kg·K
+* w0, Ideal speed of sound, m/s
+* gamma0, Ideal isoentropic exponent [-]
+
+* w, Speed of sound, m/s
+* mu, Dynamic viscosity, Pa·s
+* nu, Kinematic viscosity, m²/s
+* k, Thermal conductivity, W/m·K
+* alfa, Thermal diffusivity, m²/s
+* sigma, Surface tension, N/m
+* epsilon, Dielectric constant, [-]
+* n, Refractive index, [-]
+* Prandt, Prandtl number, [-]
+* Tr, Reduced temperature, [-]
+* Pr, Reduced pressure, [-]
+
+
+Usage::
+
+ from iapws import IAPWS97
+ sat_steam=IAPWS97(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS97(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS97(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+IAPWS-95
+--------------------------------
+
+Class to model a state for liquid water or steam with the general and scientific formulation IAPWS-95
+
+Incoming properties:
+
+* T, Temperature, K
+* P, Pressure, MPa
+* rho, Density, kg/m3
+* v, Specific volume, m3/kg
+* h, Specific enthalpy, kJ/kg
+* s, Specific entropy, kJ/kg·K
+* x, Quality, [-]
+* l, Optional parameter to light wavelength for Refractive index, mm
+
+rho and v are equivalent, only one can be defined
+Definitions options:
+
+* T, P (Not valid for two-phases region)
+* T, rho
+* T, h
+* T, s
+* T, u
+* P, rho
+* P, h
+* P, s
+* P, u
+* rho, h
+* rho, s
+* rho, u
+* h, s
+* h, u
+* s, u
+* T, x (Only for two-phases region)
+* P, x (Only for two-phases region) Very slow
+
+Properties:
+
+* P, Pressure, MPa
+* Pr, Reduced pressure, [-]
+* T, Temperature, K
+* Tr, Reduced temperature, [-]
+* x, Quality, [-]
+* v, Specific volume, m³/kg
+* rho, Density, kg/m³
+* h, Specific enthalpy, kJ/kg
+* s, Specific entropy, kJ/kg·K
+* u, Specific internal energy, kJ/kg
+* g, Specific Gibbs free energy, kJ/kg
+* a, Specific Helmholtz free energy, kJ/kg
+* cp, Specific isobaric heat capacity, kJ/kg·K
+* cv, Specific isochoric heat capacity, kJ/kg·K
+* cp_cv, Heat capacity ratio, [-]
+* w, Speed of sound, m/s
+* Z, Compression factor, [-]
+* fi, Fugacity coefficient, [-]
+* f, Fugacity, MPa
+* gamma, Isoentropic exponent, [-]
+
+* alfav, Thermal expansion coefficient (Volume expansivity), 1/K
+* kappa, Isothermal compressibility, 1/MPa
+* alfap, Relative pressure coefficient, 1/K
+* betap, Isothermal stress coefficient, kg/m³
+* betas, Isoentropic temperature-pressure coefficient, [-]
+* joule, Joule-Thomson coefficient, K/MPa
+* Gruneisen, Gruneisen parameter, [-]
+* virialB, Second virial coefficient, m³/kg
+* virialC, Third virial coefficient, m⁶/kg²
+* dpdT_rho, Derivatives, dp/dT at constant rho, MPa/K
+* dpdrho_T, Derivatives, dp/drho at constant T, MPa·m³/kg
+* drhodT_P, Derivatives, drho/dT at constant P, kg/m³·K
+* drhodP_T, Derivatives, drho/dP at constant T, kg/m³·MPa
+* dhdT_rho, Derivatives, dh/dT at constant rho, kJ/kg·K
+* dhdP_T, Isothermal throttling coefficient, kJ/kg·MPa
+* dhdT_P, Derivatives, dh/dT at constant P, kJ/kg·K
+* dhdrho_T, Derivatives, dh/drho at constant T, kJ·m³/kg²
+* dhdrho_P, Derivatives, dh/drho at constant P, kJ·m³/kg²
+* dhdP_rho, Derivatives, dh/dP at constant rho, kJ/kg·MPa
+* kt, Isothermal Expansion Coefficient, [-]
+* ks, Adiabatic Compressibility, 1/MPa
+* Ks, Adiabatic bulk modulus, MPa
+* Kt, Isothermal bulk modulus, MPa
+
+* Hvap, Vaporization heat, kJ/kg
+* Z_rho, (Z-1) over the density, m³/kg
+* IntP, Internal pressure, MPa
+* invT, Negative reciprocal temperature, 1/K
+* hInput, Specific heat input, kJ/kg
+
+* mu, Dynamic viscosity, Pa·s
+* nu, Kinematic viscosity, m²/s
+* k, Thermal conductivity, W/m·K
+* sigma, Surface tension, N/m
+* alfa, Thermal diffusivity, m²/s
+* Pramdt, Prandtl number, [-]
+* epsilon, Dielectric constant, [-]
+* n, Refractive index, [-]
+
+* v0, Ideal gas Specific volume, m³/kg
+* rho0, Ideal gas Density, kg/m³
+* h0, Ideal gas Specific enthalpy, kJ/kg
+* u0, Ideal gas Specific internal energy, kJ/kg
+* s0, Ideal gas Specific entropy, kJ/kg·K
+* a0, Ideal gas Specific Helmholtz free energy, kJ/kg
+* g0, Ideal gas Specific Gibbs free energy, kJ/kg
+* cp0, Ideal gas Specific isobaric heat capacity, kJ/kg·K
+* cv0, Ideal gas Specific isochoric heat capacity, kJ/kg·K
+* cp0_cv, Ideal gas Heat capacity ratio, [-]
+* gamma0, Ideal gas Isoentropic exponent, [-]
+
+
+Usage::
+
+ from iapws import IAPWS95
+ sat_steam=IAPWS95(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS95(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS95(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+IAPWS-06 for Ice Ih
+--------------------------------------------
+
+There is too implemented a function to calculate properties of ice Ih from 2009 revision, in this case only let temperature and pressure as input for calculate properties, the function return a dict with properties available:
+
+* P, Pressure, MPa
+* T, Temperature, K
+* v, Specific volume, m³/kg
+* rho, Density, kg/m³
+* g, Specific Gibbs free energy, kJ/kg
+* a, Specific Helmholtz free energy, kJ/kg
+* h, Specific enthalpy, kJ/kg
+* u, Specific internal energy, kJ/kg
+* s, Specific entropy, kJ/kg·K
+* cp, Specific isobaric heat capacity, kJ/kg·K
+* alfa, Cubic expansion coefficient, 1/K
+* beta, Pressure coefficient, MPa/K
+* kt, Isothermal compressibility, MPa
+* ks, Isentropic compressibility, MPa
+
+
+Usage::
+
+ from iapws import _Ice
+ ice=_Ice(273.15, 0.101325) #Ice at normal melting point
+ print(ice["rho"]) #Calculated density
+
+
+IAPWS-05 for Heavy water
+--------------------------------------------
+
+Same properties as for IAPWS-95
+Reference state set at liquid at normal boiling point (1 atm)
+
+Usage::
+
+ from iapws import D2O
+ sat_liquid=D2O(T=370, x=0) #saturated liquid with known T
+ print(sat_liquid.h) #calculated enthalpy
+
+
+IAPWS-08 for seawater
+--------------------------------------------
+
+Incoming properties:
+
+* T: Temperature, K
+* P: Pressure, MPa
+* S: Salinity, kg/kg
+
+S is the Reference-Composition Salinity as defined in Millero, F.J., R. Feistel, D.G. Wright and T.J. McDougall, "The composition of Standard Seawater and the definition of the Reference-Composition Salinity Scale", Deep-Sea Res. I 55, 50 (2008).
+
+Calculated properties:
+
+* T: Temperature, K
+* P: Pressure, MPa
+* rho: Density, kg/m³
+* v: Specific volume, m³/kg
+* h: Specific enthalpy, kJ/kg
+* s: Specific entropy, kJ/kg·K
+* u: Specific internal energy, kJ/kg
+* g: Specific Gibbs free energy, kJ/kg
+* a: Specific Helmholtz free energy, kJ/kg
+* cp: Specific isobaric heat capacity, kJ/kg·K
+
+* gt: Derivative Gibbs energy with temperature, kJ/kg·K
+* gp: Derivative Gibbs energy with pressure, m³/kg
+* gtt: Derivative Gibbs energy with temperature square, kJ/kg·K²
+* gtp: Derivative Gibbs energy with pressure and temperature, m³/kg·K
+* gpp: Derivative Gibbs energy with temperature square, m³/kg·MPa
+* gs: Derivative Gibbs energy with salinity, kJ/kg
+* gsp: Derivative Gibbs energy with salinity and pressure, m³/kg
+
+* alfa: Thermal expansion coefficient, 1/K
+* betas: Isentropic temperature-pressure coefficient, K/MPa
+* kt: Isothermal compressibility, 1/MPa
+* ks: Isentropic compressibility, 1/MPa
+* w: Sound Speed, m/s
+
+* mu: Relative chemical potential, kJ/kg
+* muw: Chemical potential of H2O, kJ/kg
+* mus: Chemical potential of sea salt, kJ/kg
+* osm: Osmotic coefficient, [-]
+* haline: Haline contraction coefficient, kg/kg
+
+
+Usage::
+
+ from iapws import SeaWater
+ state = SeaWater(T=300, P=0.101325, S=0.001) #Seawater with 0.1% Salinity
+ print(state.cp) # Get cp
diff --git a/iapws.egg-info/PKG-INFO b/iapws.egg-info/PKG-INFO
new file mode 100644
index 0000000..4f2d9d7
--- /dev/null
+++ b/iapws.egg-info/PKG-INFO
@@ -0,0 +1,350 @@
+Metadata-Version: 1.1
+Name: iapws
+Version: 1.1
+Summary: Python implementation of standard from The International Association for the Properties of Water and Steam
+Home-page: https://github.com/jjgomera/iapws
+Author: jjgomera
+Author-email: jjgomera at gmail.com
+License: gpl v3
+Description: iapws
+ =====
+
+ Python implementation of standard from IAPWS (http://www.iapws.org/release.html). The available standard are::
+
+ IAPWS-IF97
+ IAPWS-95
+ IAPWS-06 for Ice
+ IAPWS-08 for seawater
+ IAPWS-05 for Heavy water
+
+ dependences
+ --------------------
+
+ * python 2x, 3x, compatible with both versions
+ * Numpy-scipy: library with mathematic and scientific tools
+
+
+ install
+ --------------------
+
+ In debian you can find in official repositories in testing and sid. In stable you can install using pip::
+
+ pip install iapws
+
+ In ubuntu it's in official repositories from ubuntu saucy (13.10)
+
+ In other SO you can download from its webpage in `pypi <http://pypi.python.org/pypi/iapws>`_ and unzipped in python folder dist-packages. This is the recommended options to have the latest version.
+
+
+ TODO
+ --------------------
+
+ Improve convergence in two phase region for IAPWS95 and D2O class
+
+
+ IAPWS-IF97
+ --------------------
+
+ Class to model a state for liquid water or steam with the Industrial Formulation IAPWS-IF97
+
+ Incoming properties:
+
+ * T, Temperature, K
+ * P, Pressure, MPa
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * x, Quality, [-]
+
+ Definitions options:
+
+ * T, P (Not valid for two-phases region)
+ * P, h
+ * P, s
+ * h, s
+ * T, x (Only for two-phases region)
+ * P, x (Only for two-phases region)
+
+ Properties:
+
+ * P, Pressure, MPa
+ * T, Temperature, K
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * x, quality, [-]
+ * h, Specific enthalpy, kJ/kg
+ * u, Specific internal energy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * cv, Specific isochoric heat capacity, kJ/kg·K
+ * Z, Compression factor. [-]
+ * gamma, Isoentropic exponent, [-]
+ * alfav, Isobaric cubic expansion coefficient, 1/K
+ * kt, Isothermal compressibility, 1/MPa
+ * alfap, Relative pressure coefficient, 1/K
+ * betap, Isothermal stress coefficient, kg/m³
+ * joule, Joule-Thomson coefficient, K/MPa
+ * deltat, Isothermal throttling coefficient, kJ/kg·MPa
+ * region, Region
+
+ * v0, Ideal specific volume, m³/kg
+ * u0, Ideal specific internal energy, kJ/kg
+ * h0, Ideal specific enthalpy, kJ/kg
+ * s0, Ideal specific entropy, kJ/kg·K
+ * a0, Ideal specific Helmholtz free energy, kJ/kg
+ * g0, Ideal specific Gibbs free energy, kJ/kg
+ * cp0, Ideal specific isobaric heat capacity, kJ/kg·K
+ * cv0, Ideal specific isochoric heat capacity, kJ/kg·K
+ * w0, Ideal speed of sound, m/s
+ * gamma0, Ideal isoentropic exponent [-]
+
+ * w, Speed of sound, m/s
+ * mu, Dynamic viscosity, Pa·s
+ * nu, Kinematic viscosity, m²/s
+ * k, Thermal conductivity, W/m·K
+ * alfa, Thermal diffusivity, m²/s
+ * sigma, Surface tension, N/m
+ * epsilon, Dielectric constant, [-]
+ * n, Refractive index, [-]
+ * Prandt, Prandtl number, [-]
+ * Tr, Reduced temperature, [-]
+ * Pr, Reduced pressure, [-]
+
+
+ Usage::
+
+ from iapws import IAPWS97
+ sat_steam=IAPWS97(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS97(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS97(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+ IAPWS-95
+ --------------------------------
+
+ Class to model a state for liquid water or steam with the general and scientific formulation IAPWS-95
+
+ Incoming properties:
+
+ * T, Temperature, K
+ * P, Pressure, MPa
+ * rho, Density, kg/m3
+ * v, Specific volume, m3/kg
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * x, Quality, [-]
+ * l, Optional parameter to light wavelength for Refractive index, mm
+
+ rho and v are equivalent, only one can be defined
+ Definitions options:
+
+ * T, P (Not valid for two-phases region)
+ * T, rho
+ * T, h
+ * T, s
+ * T, u
+ * P, rho
+ * P, h
+ * P, s
+ * P, u
+ * rho, h
+ * rho, s
+ * rho, u
+ * h, s
+ * h, u
+ * s, u
+ * T, x (Only for two-phases region)
+ * P, x (Only for two-phases region) Very slow
+
+ Properties:
+
+ * P, Pressure, MPa
+ * Pr, Reduced pressure, [-]
+ * T, Temperature, K
+ * Tr, Reduced temperature, [-]
+ * x, Quality, [-]
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * h, Specific enthalpy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * u, Specific internal energy, kJ/kg
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * cv, Specific isochoric heat capacity, kJ/kg·K
+ * cp_cv, Heat capacity ratio, [-]
+ * w, Speed of sound, m/s
+ * Z, Compression factor, [-]
+ * fi, Fugacity coefficient, [-]
+ * f, Fugacity, MPa
+ * gamma, Isoentropic exponent, [-]
+
+ * alfav, Thermal expansion coefficient (Volume expansivity), 1/K
+ * kappa, Isothermal compressibility, 1/MPa
+ * alfap, Relative pressure coefficient, 1/K
+ * betap, Isothermal stress coefficient, kg/m³
+ * betas, Isoentropic temperature-pressure coefficient, [-]
+ * joule, Joule-Thomson coefficient, K/MPa
+ * Gruneisen, Gruneisen parameter, [-]
+ * virialB, Second virial coefficient, m³/kg
+ * virialC, Third virial coefficient, m⁶/kg²
+ * dpdT_rho, Derivatives, dp/dT at constant rho, MPa/K
+ * dpdrho_T, Derivatives, dp/drho at constant T, MPa·m³/kg
+ * drhodT_P, Derivatives, drho/dT at constant P, kg/m³·K
+ * drhodP_T, Derivatives, drho/dP at constant T, kg/m³·MPa
+ * dhdT_rho, Derivatives, dh/dT at constant rho, kJ/kg·K
+ * dhdP_T, Isothermal throttling coefficient, kJ/kg·MPa
+ * dhdT_P, Derivatives, dh/dT at constant P, kJ/kg·K
+ * dhdrho_T, Derivatives, dh/drho at constant T, kJ·m³/kg²
+ * dhdrho_P, Derivatives, dh/drho at constant P, kJ·m³/kg²
+ * dhdP_rho, Derivatives, dh/dP at constant rho, kJ/kg·MPa
+ * kt, Isothermal Expansion Coefficient, [-]
+ * ks, Adiabatic Compressibility, 1/MPa
+ * Ks, Adiabatic bulk modulus, MPa
+ * Kt, Isothermal bulk modulus, MPa
+
+ * Hvap, Vaporization heat, kJ/kg
+ * Z_rho, (Z-1) over the density, m³/kg
+ * IntP, Internal pressure, MPa
+ * invT, Negative reciprocal temperature, 1/K
+ * hInput, Specific heat input, kJ/kg
+
+ * mu, Dynamic viscosity, Pa·s
+ * nu, Kinematic viscosity, m²/s
+ * k, Thermal conductivity, W/m·K
+ * sigma, Surface tension, N/m
+ * alfa, Thermal diffusivity, m²/s
+ * Pramdt, Prandtl number, [-]
+ * epsilon, Dielectric constant, [-]
+ * n, Refractive index, [-]
+
+ * v0, Ideal gas Specific volume, m³/kg
+ * rho0, Ideal gas Density, kg/m³
+ * h0, Ideal gas Specific enthalpy, kJ/kg
+ * u0, Ideal gas Specific internal energy, kJ/kg
+ * s0, Ideal gas Specific entropy, kJ/kg·K
+ * a0, Ideal gas Specific Helmholtz free energy, kJ/kg
+ * g0, Ideal gas Specific Gibbs free energy, kJ/kg
+ * cp0, Ideal gas Specific isobaric heat capacity, kJ/kg·K
+ * cv0, Ideal gas Specific isochoric heat capacity, kJ/kg·K
+ * cp0_cv, Ideal gas Heat capacity ratio, [-]
+ * gamma0, Ideal gas Isoentropic exponent, [-]
+
+
+ Usage::
+
+ from iapws import IAPWS95
+ sat_steam=IAPWS95(P=1,x=1) #saturated steam with known P
+ sat_liquid=IAPWS95(T=370, x=0) #saturated liquid with known T
+ steam=IAPWS95(P=2.5, T=500) #steam with known P and T
+ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies
+
+
+
+ IAPWS-06 for Ice Ih
+ --------------------------------------------
+
+ There is too implemented a function to calculate properties of ice Ih from 2009 revision, in this case only let temperature and pressure as input for calculate properties, the function return a dict with properties available:
+
+ * P, Pressure, MPa
+ * T, Temperature, K
+ * v, Specific volume, m³/kg
+ * rho, Density, kg/m³
+ * g, Specific Gibbs free energy, kJ/kg
+ * a, Specific Helmholtz free energy, kJ/kg
+ * h, Specific enthalpy, kJ/kg
+ * u, Specific internal energy, kJ/kg
+ * s, Specific entropy, kJ/kg·K
+ * cp, Specific isobaric heat capacity, kJ/kg·K
+ * alfa, Cubic expansion coefficient, 1/K
+ * beta, Pressure coefficient, MPa/K
+ * kt, Isothermal compressibility, MPa
+ * ks, Isentropic compressibility, MPa
+
+
+ Usage::
+
+ from iapws import _Ice
+ ice=_Ice(273.15, 0.101325) #Ice at normal melting point
+ print(ice["rho"]) #Calculated density
+
+
+ IAPWS-05 for Heavy water
+ --------------------------------------------
+
+ Same properties as for IAPWS-95
+ Reference state set at liquid at normal boiling point (1 atm)
+
+ Usage::
+
+ from iapws import D2O
+ sat_liquid=D2O(T=370, x=0) #saturated liquid with known T
+ print(sat_liquid.h) #calculated enthalpy
+
+
+ IAPWS-08 for seawater
+ --------------------------------------------
+
+ Incoming properties:
+
+ * T: Temperature, K
+ * P: Pressure, MPa
+ * S: Salinity, kg/kg
+
+ S is the Reference-Composition Salinity as defined in Millero, F.J., R. Feistel, D.G. Wright and T.J. McDougall, "The composition of Standard Seawater and the definition of the Reference-Composition Salinity Scale", Deep-Sea Res. I 55, 50 (2008).
+
+ Calculated properties:
+
+ * T: Temperature, K
+ * P: Pressure, MPa
+ * rho: Density, kg/m³
+ * v: Specific volume, m³/kg
+ * h: Specific enthalpy, kJ/kg
+ * s: Specific entropy, kJ/kg·K
+ * u: Specific internal energy, kJ/kg
+ * g: Specific Gibbs free energy, kJ/kg
+ * a: Specific Helmholtz free energy, kJ/kg
+ * cp: Specific isobaric heat capacity, kJ/kg·K
+
+ * gt: Derivative Gibbs energy with temperature, kJ/kg·K
+ * gp: Derivative Gibbs energy with pressure, m³/kg
+ * gtt: Derivative Gibbs energy with temperature square, kJ/kg·K²
+ * gtp: Derivative Gibbs energy with pressure and temperature, m³/kg·K
+ * gpp: Derivative Gibbs energy with temperature square, m³/kg·MPa
+ * gs: Derivative Gibbs energy with salinity, kJ/kg
+ * gsp: Derivative Gibbs energy with salinity and pressure, m³/kg
+
+ * alfa: Thermal expansion coefficient, 1/K
+ * betas: Isentropic temperature-pressure coefficient, K/MPa
+ * kt: Isothermal compressibility, 1/MPa
+ * ks: Isentropic compressibility, 1/MPa
+ * w: Sound Speed, m/s
+
+ * mu: Relative chemical potential, kJ/kg
+ * muw: Chemical potential of H2O, kJ/kg
+ * mus: Chemical potential of sea salt, kJ/kg
+ * osm: Osmotic coefficient, [-]
+ * haline: Haline contraction coefficient, kg/kg
+
+
+ Usage::
+
+ from iapws import SeaWater
+ state = SeaWater(T=300, P=0.101325, S=0.001) #Seawater with 0.1% Salinity
+ print(state.cp) # Get cp
+
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Education
+Classifier: Intended Audience :: Science/Research
+Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Scientific/Engineering
+Classifier: Topic :: Scientific/Engineering :: Chemistry
+Classifier: Topic :: Scientific/Engineering :: Physics
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/iapws.egg-info/SOURCES.txt b/iapws.egg-info/SOURCES.txt
new file mode 100644
index 0000000..9b35027
--- /dev/null
+++ b/iapws.egg-info/SOURCES.txt
@@ -0,0 +1,14 @@
+LICENSE
+MANIFEST.in
+README.rst
+setup.py
+iapws/__init__.py
+iapws/_iapws.py
+iapws/iapws08.py
+iapws/iapws95.py
+iapws/iapws97.py
+iapws.egg-info/PKG-INFO
+iapws.egg-info/SOURCES.txt
+iapws.egg-info/dependency_links.txt
+iapws.egg-info/requires.txt
+iapws.egg-info/top_level.txt
\ No newline at end of file
diff --git a/iapws.egg-info/dependency_links.txt b/iapws.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/iapws.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/iapws.egg-info/requires.txt b/iapws.egg-info/requires.txt
new file mode 100644
index 0000000..9c61c73
--- /dev/null
+++ b/iapws.egg-info/requires.txt
@@ -0,0 +1 @@
+scipy
\ No newline at end of file
diff --git a/iapws.egg-info/top_level.txt b/iapws.egg-info/top_level.txt
new file mode 100644
index 0000000..c0f6e5b
--- /dev/null
+++ b/iapws.egg-info/top_level.txt
@@ -0,0 +1 @@
+iapws
diff --git a/iapws/__init__.py b/iapws/__init__.py
new file mode 100644
index 0000000..7047f7a
--- /dev/null
+++ b/iapws/__init__.py
@@ -0,0 +1,938 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+__version__ = "1.1"
+
+import unittest
+
+from iapws97 import IAPWS97
+from iapws97 import (_Region1, _Region2, _Region3, _Region5,
+ _Backward1_T_Ph, _Backward1_T_Ps, _Backward1_P_hs,
+ _Backward2_T_Ph, _Backward2_T_Ps, _Backward2_P_hs,
+ _h_3ab, _Backward3_T_Ph, _Backward3_v_Ph, _Backward3_T_Ps,
+ _Backward3_v_Ps, _PSat_h, _PSat_s, _Backward3_P_hs, _h1_s,
+ _h3a_s, _h2ab_s, _h2c3b_s, _PSat_T, _TSat_P, _h13_s,
+ _t_hs, _Backward4_T_hs, _tab_P, _top_P, _twx_P, _tef_P,
+ _txx_P, _Backward3_v_PT)
+from iapws95 import IAPWS95, D2O
+from iapws08 import SeaWater
+from _iapws import (_Ice, _Sublimation_Pressure, _Melting_Pressure,
+ _Viscosity, _ThCond)
+
+
+# Test
+class Test(unittest.TestCase):
+ """
+ Global unittest for module
+ Run for python2 and python3 before to release distribution
+ """
+ def test_Helmholtz(self):
+ """Table 6 from IAPWS95, pag 14"""
+ T = 500
+ rho = 838.025
+ fluid = IAPWS95()
+ delta = rho/fluid.rhoc
+ tau = fluid.Tc/T
+
+ fio, fiot, fiott, fiod, fiodd, fiodt = fluid._phi0(tau, delta)
+ self.assertEqual(round(fio, 8), 2.04797733)
+ self.assertEqual(round(fiod, 9), 0.384236747)
+ self.assertEqual(round(fiodd, 9), -0.147637878)
+ self.assertEqual(round(fiot, 8), 9.04611106)
+ self.assertEqual(round(fiott, 8), -1.93249185)
+ self.assertEqual(round(fiodt, 8), 0.0)
+
+ fir, firt, firtt, fird, firdd, firdt, firdtt, B, C = fluid._phir(tau, delta)
+ self.assertEqual(round(fir, 8), -3.42693206)
+ self.assertEqual(round(fird, 9), -0.364366650)
+ self.assertEqual(round(firdd, 9), 0.856063701)
+ self.assertEqual(round(firt, 8), -5.81403435)
+ self.assertEqual(round(firtt, 8), -2.23440737)
+ self.assertEqual(round(firdt, 8), -1.12176915)
+
+ def test_phase(self):
+ """Table 7 from IAPWS95, pag 14"""
+ fluid = IAPWS95()
+
+ state = fluid._Helmholtz(996.556, 300)
+ # See footnote for imprecise P value in last significant figures
+ self.assertEqual(round(state["P"], 7), 99.241835)
+ self.assertEqual(round(state["cv"], 8), 4.13018112)
+ self.assertEqual(round(state["w"], 5), 1501.51914)
+ self.assertEqual(round(state["s"], 9), 0.393062643)
+
+ state = fluid._Helmholtz(1005.308, 300)
+ self.assertEqual(round(state["P"], 4), 20002.2515)
+ self.assertEqual(round(state["cv"], 8), 4.06798347)
+ self.assertEqual(round(state["w"], 5), 1534.92501)
+ self.assertEqual(round(state["s"], 9), 0.387405401)
+
+ state = fluid._Helmholtz(1188.202, 300)
+ self.assertEqual(round(state["P"], 3), 700004.704)
+ self.assertEqual(round(state["cv"], 8), 3.46135580)
+ self.assertEqual(round(state["w"], 5), 2443.57992)
+ self.assertEqual(round(state["s"], 9), 0.132609616)
+
+ state = fluid._Helmholtz(0.435, 500)
+ self.assertEqual(round(state["P"], 7), 99.9679423)
+ self.assertEqual(round(state["cv"], 8), 1.50817541)
+ self.assertEqual(round(state["w"], 6), 548.314253)
+ self.assertEqual(round(state["s"], 8), 7.94488271)
+
+ state = fluid._Helmholtz(4.532, 500)
+ self.assertEqual(round(state["P"], 6), 999.938125)
+ self.assertEqual(round(state["cv"], 8), 1.66991025)
+ self.assertEqual(round(state["w"], 6), 535.739001)
+ self.assertEqual(round(state["s"], 8), 6.82502725)
+
+ state = fluid._Helmholtz(838.025, 500)
+ self.assertEqual(round(state["P"], 4), 10000.3858)
+ self.assertEqual(round(state["cv"], 8), 3.22106219)
+ self.assertEqual(round(state["w"], 5), 1271.28441)
+ self.assertEqual(round(state["s"], 8), 2.56690919)
+
+ state = fluid._Helmholtz(1084.564, 500)
+ self.assertEqual(round(state["P"], 3), 700000.405)
+ self.assertEqual(round(state["cv"], 8), 3.07437693)
+ self.assertEqual(round(state["w"], 5), 2412.00877)
+ self.assertEqual(round(state["s"], 8), 2.03237509)
+
+ state = fluid._Helmholtz(358., 647)
+ self.assertEqual(round(state["P"], 4), 22038.4756)
+ self.assertEqual(round(state["cv"], 8), 6.18315728)
+ self.assertEqual(round(state["w"], 6), 252.145078)
+ self.assertEqual(round(state["s"], 8), 4.32092307)
+
+ state = fluid._Helmholtz(0.241, 900)
+ self.assertEqual(round(state["P"], 6), 100.062559)
+ self.assertEqual(round(state["cv"], 8), 1.75890657)
+ self.assertEqual(round(state["w"], 6), 724.027147)
+ self.assertEqual(round(state["s"], 8), 9.16653194)
+
+ state = fluid._Helmholtz(52.615, 900)
+ self.assertEqual(round(state["P"], 3), 20000.069)
+ self.assertEqual(round(state["cv"], 8), 1.93510526)
+ self.assertEqual(round(state["w"], 6), 698.445674)
+ self.assertEqual(round(state["s"], 8), 6.59070225)
+
+ state = fluid._Helmholtz(870.769, 900)
+ self.assertEqual(round(state["P"], 3), 700000.006)
+ self.assertEqual(round(state["cv"], 8), 2.66422350)
+ self.assertEqual(round(state["w"], 5), 2019.33608)
+ self.assertEqual(round(state["s"], 8), 4.17223802)
+
+ def test_saturation(self):
+ """Table 8 from IAPWS95, pag 14"""
+ fluid = IAPWS95()
+
+ rhol, rhov, Ps = fluid._saturation(275)
+ liquid = fluid._Helmholtz(rhol, 275)
+ vapor = fluid._Helmholtz(rhov, 275)
+ self.assertEqual(round(Ps, 9), 0.698451167)
+ self.assertEqual(round(rhol, 6), 999.887406)
+ self.assertEqual(round(rhov, 11), 0.00550664919)
+ self.assertEqual(round(liquid["h"], 8), 7.75972202)
+ self.assertEqual(round(vapor["h"], 5), 2504.28995)
+ self.assertEqual(round(liquid["s"], 10), 0.0283094670)
+ self.assertEqual(round(vapor["s"], 8), 9.10660121)
+
+ rhol, rhov, Ps = fluid._saturation(450)
+ liquid = fluid._Helmholtz(rhol, 450)
+ vapor = fluid._Helmholtz(rhov, 450)
+ self.assertEqual(round(Ps, 6), 932.203564)
+ self.assertEqual(round(rhol, 6), 890.341250)
+ self.assertEqual(round(rhov, 8), 4.81200360)
+ self.assertEqual(round(liquid["h"], 6), 749.161585)
+ self.assertEqual(round(vapor["h"], 5), 2774.41078)
+ self.assertEqual(round(liquid["s"], 8), 2.10865845)
+ self.assertEqual(round(vapor["s"], 8), 6.60921221)
+
+ rhol, rhov, Ps = fluid._saturation(625)
+ liquid = fluid._Helmholtz(rhol, 625)
+ vapor = fluid._Helmholtz(rhov, 625)
+ self.assertEqual(round(Ps, 4), 16908.2693)
+ self.assertEqual(round(rhol, 6), 567.090385)
+ self.assertEqual(round(rhov, 6), 118.290280)
+ self.assertEqual(round(liquid["h"], 5), 1686.26976)
+ self.assertEqual(round(vapor["h"], 5), 2550.71625)
+ self.assertEqual(round(liquid["s"], 8), 3.80194683)
+ self.assertEqual(round(vapor["s"], 8), 5.18506121)
+
+ def test_Melting(self):
+ """Table 3, pag 7"""
+ self.assertEqual(round(_Sublimation_Pressure(230), 11), 8.94735e-6)
+ self.assertEqual(round(_Melting_Pressure(260, 200), 3), 138.268)
+ self.assertEqual(round(_Melting_Pressure(254, 350), 3), 268.685)
+ self.assertEqual(round(_Melting_Pressure(265, 500), 3), 479.640)
+ self.assertEqual(round(_Melting_Pressure(320, 1200), 2), 1356.76)
+ self.assertEqual(round(_Melting_Pressure(550, 3000), 2), 6308.71)
+
+ def test_Viscosity_1(self):
+ """Table 4, pag 8"""
+ self.assertEqual(round(_Viscosity(998, 298.15)*1e6, 6), 889.735100)
+ self.assertEqual(round(_Viscosity(1200, 298.15)*1e6, 6), 1437.649467)
+ self.assertEqual(round(_Viscosity(1000, 373.15)*1e6, 6), 307.883622)
+ self.assertEqual(round(_Viscosity(1, 433.15)*1e6, 6), 14.538324)
+ self.assertEqual(round(_Viscosity(1000, 433.15)*1e6, 6), 217.685358)
+ self.assertEqual(round(_Viscosity(1, 873.15)*1e6, 6), 32.619287)
+ self.assertEqual(round(_Viscosity(100, 873.15)*1e6, 6), 35.802262)
+ self.assertEqual(round(_Viscosity(600, 873.15)*1e6, 6), 77.430195)
+ self.assertEqual(round(_Viscosity(1, 1173.15)*1e6, 6), 44.217245)
+ self.assertEqual(round(_Viscosity(100, 1173.15)*1e6, 6), 47.640433)
+ self.assertEqual(round(_Viscosity(400, 1173.15)*1e6, 6), 64.154608)
+
+ def test_Viscosity_2(self):
+ """Table 5, pag 9"""
+ fluid = IAPWS95(rho=122, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 25.520677)
+ fluid = IAPWS95(rho=222, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 31.337589)
+ fluid = IAPWS95(rho=272, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 36.228143)
+ fluid = IAPWS95(rho=322, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 42.961579)
+ fluid = IAPWS95(rho=372, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 45.688204)
+ fluid = IAPWS95(rho=422, T=647.35)
+ self.assertEqual(round(fluid.mu*1e6, 6), 49.436256)
+
+ def test_ThCond_1(self):
+ """Table 4, pag 10"""
+ self.assertEqual(round(_ThCond(0, 298.15)*1000, 7), 18.4341883)
+ self.assertEqual(round(_ThCond(998, 298.15)*1000, 6), 607.712868)
+ self.assertEqual(round(_ThCond(1200, 298.15)*1000, 6), 799.038144)
+ self.assertEqual(round(_ThCond(0, 873.15)*1000, 7), 79.1034659)
+
+ def test_ThCond_2(self):
+ """Table 5, pag 10"""
+ fluid = IAPWS95(rho=1, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 7), 51.9298924)
+ fluid = IAPWS95(rho=122, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 130.922885)
+ fluid = IAPWS95(rho=222, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 367.787459)
+ fluid = IAPWS95(rho=272, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 757.959776)
+ fluid = IAPWS95(rho=322, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 5), 1443.75556)
+ fluid = IAPWS95(rho=372, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 650.319402)
+ fluid = IAPWS95(rho=422, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 448.883487)
+ fluid = IAPWS95(rho=750, T=647.35)
+ self.assertEqual(round(fluid.k*1000, 6), 600.961346)
+
+ def test_Tension(self):
+ """Selected values from table 1"""
+ fluid = IAPWS95()
+ self.assertEqual(round(fluid._Tension(273.16)*1000, 2), 75.65)
+ self.assertEqual(round(fluid._Tension(283.15)*1000, 2), 74.22)
+ self.assertEqual(round(fluid._Tension(293.15)*1000, 2), 72.74)
+ self.assertEqual(round(fluid._Tension(303.15)*1000, 2), 71.19)
+ self.assertEqual(round(fluid._Tension(313.15)*1000, 2), 69.60)
+ self.assertEqual(round(fluid._Tension(323.15)*1000, 2), 67.94)
+ self.assertEqual(round(fluid._Tension(333.15)*1000, 2), 66.24)
+ self.assertEqual(round(fluid._Tension(343.15)*1000, 2), 64.48)
+ self.assertEqual(round(fluid._Tension(353.15)*1000, 2), 62.67)
+ self.assertEqual(round(fluid._Tension(363.15)*1000, 2), 60.82)
+ self.assertEqual(round(fluid._Tension(373.15)*1000, 2), 58.91)
+ self.assertEqual(round(fluid._Tension(393.15)*1000, 2), 54.97)
+ self.assertEqual(round(fluid._Tension(413.15)*1000, 2), 50.86)
+ self.assertEqual(round(fluid._Tension(433.15)*1000, 2), 46.59)
+ self.assertEqual(round(fluid._Tension(453.15)*1000, 2), 42.19)
+ self.assertEqual(round(fluid._Tension(473.15)*1000, 2), 37.67)
+ self.assertEqual(round(fluid._Tension(523.15)*1000, 2), 26.04)
+ self.assertEqual(round(fluid._Tension(573.15)*1000, 2), 14.36)
+ self.assertEqual(round(fluid._Tension(623.15)*1000, 2), 3.67)
+ self.assertEqual(round(fluid._Tension(643.15)*1000, 2), 0.39)
+
+ def test_Dielect(self):
+ """Table 4, pag 8"""
+ fluid = IAPWS95(P=0.101325, T=240)
+ self.assertEqual(round(fluid.epsilon, 5), 104.34982)
+ fluid = IAPWS95(P=0.101325, T=300)
+ self.assertEqual(round(fluid.epsilon, 5), 77.74735)
+ fluid = IAPWS95(P=10, T=300)
+ self.assertEqual(round(fluid.epsilon, 5), 78.11269)
+ fluid = IAPWS95(P=1000, T=300)
+ self.assertEqual(round(fluid.epsilon, 5), 103.69632)
+ fluid = IAPWS95(P=10, T=650)
+ self.assertEqual(round(fluid.epsilon, 5), 1.26715)
+ fluid = IAPWS95(P=100, T=650)
+ self.assertEqual(round(fluid.epsilon, 5), 17.71733)
+ fluid = IAPWS95(P=500, T=650)
+ self.assertEqual(round(fluid.epsilon, 5), 26.62132)
+ fluid = IAPWS95(P=10, T=870)
+ self.assertEqual(round(fluid.epsilon, 5), 1.12721)
+ fluid = IAPWS95(P=100, T=870)
+ self.assertEqual(round(fluid.epsilon, 5), 4.98281)
+ fluid = IAPWS95(P=500, T=870)
+ self.assertEqual(round(fluid.epsilon, 5), 15.09746)
+
+ def test_Refractive(self):
+ """Selected values from table 3, pag 6"""
+ fluid = IAPWS95(P=0.1, T=273.15, l=0.2265)
+ self.assertEqual(round(fluid.n, 6), 1.394527)
+ fluid = IAPWS95(P=10., T=273.15, l=0.2265)
+ self.assertEqual(round(fluid.n, 6), 1.396526)
+ fluid = IAPWS95(P=1., T=373.15, l=0.2265)
+ self.assertEqual(round(fluid.n, 6), 1.375622)
+ fluid = IAPWS95(P=100., T=373.15, l=0.2265)
+ self.assertEqual(round(fluid.n, 6), 1.391983)
+ fluid = IAPWS95(P=0.1, T=473.15, l=0.589)
+ self.assertEqual(round(fluid.n, 7), 1.0001456)
+ fluid = IAPWS95(P=1., T=773.15, l=0.589)
+ self.assertEqual(round(fluid.n, 7), 1.0008773)
+ fluid = IAPWS95(P=10., T=273.15, l=1.01398)
+ self.assertEqual(round(fluid.n, 6), 1.327710)
+ fluid = IAPWS95(P=100., T=473.15, l=1.01398)
+ self.assertEqual(round(fluid.n, 6), 1.298369)
+
+ def test_IAPWS97_1(self):
+ """Table 5, pag 9"""
+ fluid = _Region1(300, 3)
+ self.assertEqual(round(fluid["v"], 11), 0.00100215168)
+ self.assertEqual(round(fluid["h"], 6), 115.331273)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 6), 112.324818)
+ self.assertEqual(round(fluid["s"], 9), 0.392294792)
+ self.assertEqual(round(fluid["cp"], 8), 4.17301218)
+ self.assertEqual(round(fluid["w"], 5), 1507.73921)
+
+ fluid = _Region1(300, 80)
+ self.assertEqual(round(fluid["v"], 12), 0.000971180894)
+ self.assertEqual(round(fluid["h"], 6), 184.142828)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 6), 106.448356)
+ self.assertEqual(round(fluid["s"], 9), 0.368563852)
+ self.assertEqual(round(fluid["cp"], 8), 4.01008987)
+ self.assertEqual(round(fluid["w"], 5), 1634.69054)
+
+ fluid = _Region1(500, 3)
+ self.assertEqual(round(fluid["v"], 10), 0.0012024180)
+ self.assertEqual(round(fluid["h"], 6), 975.542239)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 6), 971.934985)
+ self.assertEqual(round(fluid["s"], 9), 2.58041912)
+ self.assertEqual(round(fluid["cp"], 8), 4.65580682)
+ self.assertEqual(round(fluid["w"], 5), 1240.71337)
+
+ # _Backward1_T_Ph Table 7 pag 11
+ self.assertEqual(round(_Backward1_T_Ph(3, 500), 6), 391.798509)
+ self.assertEqual(round(_Backward1_T_Ph(80, 500), 6), 378.108626)
+ self.assertEqual(round(_Backward1_T_Ph(80, 1500), 6), 611.041229)
+
+ # _Backward1_T_Ps Table 9 pag 12
+ self.assertEqual(round(_Backward1_T_Ps(3, 0.5), 6), 307.842258)
+ self.assertEqual(round(_Backward1_T_Ps(80, 0.5), 6), 309.979785)
+ self.assertEqual(round(_Backward1_T_Ps(80, 3), 6), 565.899909)
+
+ # _Backward1_P_hs Table 3 pag 6 for supplementary p(h,s)
+ self.assertEqual(round(_Backward1_P_hs(0.001, 0), 13), 0.0009800980612)
+ self.assertEqual(round(_Backward1_P_hs(90, 0), 8), 91.92954727)
+ self.assertEqual(round(_Backward1_P_hs(1500, 3.4), 8), 58.68294423)
+
+ def test_IAPWS97_2(self):
+ """Table 15, pag 17"""
+ fluid = _Region2(300, 0.0035)
+ self.assertEqual(round(fluid["v"], 7), 39.4913866)
+ self.assertEqual(round(fluid["h"], 5), 2549.91145)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 2411.69160)
+ self.assertEqual(round(fluid["s"], 8), 8.52238967)
+ self.assertEqual(round(fluid["cp"], 8), 1.91300162)
+ self.assertEqual(round(fluid["w"], 6), 427.920172)
+
+ fluid = _Region2(700, 0.0035)
+ self.assertEqual(round(fluid["v"], 7), 92.3015898)
+ self.assertEqual(round(fluid["h"], 5), 3335.68375)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 3012.62819)
+ self.assertEqual(round(fluid["s"], 7), 10.1749996)
+ self.assertEqual(round(fluid["cp"], 8), 2.08141274)
+ self.assertEqual(round(fluid["w"], 6), 644.289068)
+
+ fluid = _Region2(700, 30)
+ self.assertEqual(round(fluid["v"], 11), 0.00542946619)
+ self.assertEqual(round(fluid["h"], 5), 2631.49474)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 2468.61076)
+ self.assertEqual(round(fluid["s"], 8), 5.17540298)
+ self.assertEqual(round(fluid["cp"], 7), 10.3505092)
+ self.assertEqual(round(fluid["w"], 6), 480.386523)
+
+ # Backward2_T_Ph Table 24 pag 25
+ self.assertEqual(round(_Backward2_T_Ph(0.001, 3000), 6), 534.433241)
+ self.assertEqual(round(_Backward2_T_Ph(3, 3000), 6), 575.373370)
+ self.assertEqual(round(_Backward2_T_Ph(3, 4000), 5), 1010.77577)
+ self.assertEqual(round(_Backward2_T_Ph(5, 3500), 6), 801.299102)
+ self.assertEqual(round(_Backward2_T_Ph(5, 4000), 5), 1015.31583)
+ self.assertEqual(round(_Backward2_T_Ph(25, 3500), 6), 875.279054)
+ self.assertEqual(round(_Backward2_T_Ph(40, 2700), 6), 743.056411)
+ self.assertEqual(round(_Backward2_T_Ph(60, 2700), 6), 791.137067)
+ self.assertEqual(round(_Backward2_T_Ph(60, 3200), 6), 882.756860)
+
+ # _Backward2_T_Ps Table 9 pag 12
+ self.assertEqual(round(_Backward2_T_Ps(0.1, 7.5), 6), 399.517097)
+ self.assertEqual(round(_Backward2_T_Ps(0.1, 8), 6), 514.127081)
+ self.assertEqual(round(_Backward2_T_Ps(2.5, 8), 5), 1039.84917)
+ self.assertEqual(round(_Backward2_T_Ps(8, 6), 6), 600.484040)
+ self.assertEqual(round(_Backward2_T_Ps(8, 7.5), 5), 1064.95556)
+ self.assertEqual(round(_Backward2_T_Ps(90, 6), 5), 1038.01126)
+ self.assertEqual(round(_Backward2_T_Ps(20, 5.75), 6), 697.992849)
+ self.assertEqual(round(_Backward2_T_Ps(80, 5.25), 6), 854.011484)
+ self.assertEqual(round(_Backward2_T_Ps(80, 5.75), 6), 949.017998)
+
+ # _Backward2_P_hs Table 9 pag 10 for supplementary p(h,s)
+ self.assertEqual(round(_Backward2_P_hs(2800, 6.5), 9), 1.371012767)
+ self.assertEqual(round(_Backward2_P_hs(2800, 9.5), 12), 0.001879743844)
+ self.assertEqual(round(_Backward2_P_hs(4100, 9.5), 10), 0.1024788997)
+ self.assertEqual(round(_Backward2_P_hs(2800, 6), 9), 4.793911442)
+ self.assertEqual(round(_Backward2_P_hs(3600, 6), 8), 83.95519209)
+ self.assertEqual(round(_Backward2_P_hs(3600, 7), 9), 7.527161441)
+ self.assertEqual(round(_Backward2_P_hs(2800, 5.1), 8), 94.39202060)
+ self.assertEqual(round(_Backward2_P_hs(2800, 5.8), 9), 8.414574124)
+ self.assertEqual(round(_Backward2_P_hs(3400, 5.8), 8), 83.76903879)
+
+ def test_IAPWS97_3(self):
+ """Table 33, pag 49"""
+ fluid = _Region3(500, 650)
+ self.assertEqual(round(fluid["P"], 7), 25.5837018)
+ self.assertEqual(round(fluid["h"], 5), 1863.43019)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 1812.26279)
+ self.assertEqual(round(fluid["s"], 8), 4.05427273)
+ self.assertEqual(round(fluid["cp"], 7), 13.8935717)
+ self.assertEqual(round(fluid["w"], 6), 502.005554)
+
+ fluid = _Region3(200, 650)
+ self.assertEqual(round(fluid["P"], 7), 22.2930643)
+ self.assertEqual(round(fluid["h"], 5), 2375.12401)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 2263.65868)
+ self.assertEqual(round(fluid["s"], 8), 4.85438792)
+ self.assertEqual(round(fluid["cp"], 7), 44.6579342)
+ self.assertEqual(round(fluid["w"], 6), 383.444594)
+
+ fluid = _Region3(500, 750)
+ self.assertEqual(round(fluid["P"], 7), 78.3095639)
+ self.assertEqual(round(fluid["h"], 5), 2258.68845)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 2102.06932)
+ self.assertEqual(round(fluid["s"], 8), 4.46971906)
+ self.assertEqual(round(fluid["cp"], 8), 6.34165359)
+ self.assertEqual(round(fluid["w"], 6), 760.696041)
+
+ # _h_3ab pag 7
+ self.assertEqual(round(_h_3ab(25), 6), 2095.936454)
+
+ def test_IAPWS97_3_Sup03(self):
+ """Test for supplementary 03 for region 3"""
+ # _Backward3_T_Ph Table 5 pag 8
+ self.assertEqual(round(_Backward3_T_Ph(20, 1700), 7), 629.3083892)
+ self.assertEqual(round(_Backward3_T_Ph(50, 2000), 7), 690.5718338)
+ self.assertEqual(round(_Backward3_T_Ph(100, 2100), 7), 733.6163014)
+ self.assertEqual(round(_Backward3_T_Ph(20, 2500), 7), 641.8418053)
+ self.assertEqual(round(_Backward3_T_Ph(50, 2400), 7), 735.1848618)
+ self.assertEqual(round(_Backward3_T_Ph(100, 2700), 7), 842.0460876)
+
+ # _Backward3_v_Ph Table 8 pag 10
+ self.assertEqual(round(_Backward3_v_Ph(20, 1700), 12), 1.749903962e-3)
+ self.assertEqual(round(_Backward3_v_Ph(50, 2000), 12), 1.908139035e-3)
+ self.assertEqual(round(_Backward3_v_Ph(100, 2100), 12), 1.676229776e-3)
+ self.assertEqual(round(_Backward3_v_Ph(20, 2500), 12), 6.670547043e-3)
+ self.assertEqual(round(_Backward3_v_Ph(50, 2400), 12), 2.801244590e-3)
+ self.assertEqual(round(_Backward3_v_Ph(100, 2700), 12), 2.404234998e-3)
+
+ # _Backward3_T_Ps Table 12 pag 13
+ self.assertEqual(round(_Backward3_T_Ps(20, 3.8), 7), 628.2959869)
+ self.assertEqual(round(_Backward3_T_Ps(50, 3.6), 7), 629.7158726)
+ self.assertEqual(round(_Backward3_T_Ps(100, 4.0), 7), 705.6880237)
+ self.assertEqual(round(_Backward3_T_Ps(20, 5.0), 7), 640.1176443)
+ self.assertEqual(round(_Backward3_T_Ps(50, 4.5), 7), 716.3687517)
+ self.assertEqual(round(_Backward3_T_Ps(100, 5.0), 7), 847.4332825)
+
+ # _Backward3_v_Ps Table 15 pag 15
+ self.assertEqual(round(_Backward3_v_Ps(20, 3.8), 12), 1.733791463e-3)
+ self.assertEqual(round(_Backward3_v_Ps(50, 3.6), 12), 1.469680170e-3)
+ self.assertEqual(round(_Backward3_v_Ps(100, 4.0), 12), 1.555893131e-3)
+ self.assertEqual(round(_Backward3_v_Ps(20, 5.0), 12), 6.262101987e-3)
+ self.assertEqual(round(_Backward3_v_Ps(50, 4.5), 12), 2.332634294e-3)
+ self.assertEqual(round(_Backward3_v_Ps(100, 5.0), 12), 2.449610757e-3)
+
+ # _PSat_h Table 18 pag 18
+ self.assertEqual(round(_PSat_h(1700), 8), 17.24175718)
+ self.assertEqual(round(_PSat_h(2000), 8), 21.93442957)
+ self.assertEqual(round(_PSat_h(2400), 8), 20.18090839)
+
+ # _PSat_s Table 20 pag 19
+ self.assertEqual(round(_PSat_s(3.8), 8), 16.87755057)
+ self.assertEqual(round(_PSat_s(4.2), 8), 21.64451789)
+ self.assertEqual(round(_PSat_s(5.2), 8), 16.68968482)
+
+ def test_IAPWS97_3_Sup04(self):
+ """Test for supplementary 04 for region 3"""
+ # _Backward3_P_hs Table 5 pag 10
+ self.assertEqual(round(_Backward3_P_hs(1700, 3.8), 8), 25.55703246)
+ self.assertEqual(round(_Backward3_P_hs(2000, 4.2), 8), 45.40873468)
+ self.assertEqual(round(_Backward3_P_hs(2100, 4.3), 8), 60.78123340)
+ self.assertEqual(round(_Backward3_P_hs(2600, 5.1), 8), 34.34999263)
+ self.assertEqual(round(_Backward3_P_hs(2400, 4.7), 8), 63.63924887)
+ self.assertEqual(round(_Backward3_P_hs(2700, 5.0), 8), 88.39043281)
+
+ # _h1_s _h3a_s Table 11 pag 17
+ self.assertEqual(round(_h1_s(1), 7), 308.5509647)
+ self.assertEqual(round(_h1_s(2), 7), 700.6304472)
+ self.assertEqual(round(_h1_s(3), 6), 1198.359754)
+ self.assertEqual(round(_h3a_s(3.8), 6), 1685.025565)
+ self.assertEqual(round(_h3a_s(4), 6), 1816.891476)
+ self.assertEqual(round(_h3a_s(4.2), 6), 1949.352563)
+
+ # _h2ab_s _h2c3b_s Table 18 pag 21
+ self.assertEqual(round(_h2ab_s(7), 6), 2723.729985)
+ self.assertEqual(round(_h2ab_s(8), 6), 2599.047210)
+ self.assertEqual(round(_h2ab_s(9), 6), 2511.861477)
+ self.assertEqual(round(_h2c3b_s(5.5), 6), 2687.693850)
+ self.assertEqual(round(_h2c3b_s(5.0), 6), 2451.623609)
+ self.assertEqual(round(_h2c3b_s(4.5), 6), 2144.360448)
+
+ # _h13_s Table 18 pag 21
+ self.assertEqual(round(_h13_s(3.7), 6), 1632.525047)
+ self.assertEqual(round(_h13_s(3.6), 6), 1593.027214)
+ self.assertEqual(round(_h13_s(3.5), 6), 1566.104611)
+
+ # _t_hs Table 26 pag 26
+ self.assertEqual(round(_t_hs(2600, 5.1), 7), 713.5259364)
+ self.assertEqual(round(_t_hs(2700, 5.15), 7), 768.5345532)
+ self.assertEqual(round(_t_hs(2800, 5.2), 7), 817.6202120)
+
+ # _Backward4_T_hs Table 29 pag 31
+ self.assertEqual(round(_Backward4_T_hs(1800, 5.3), 7), 346.8475498)
+ self.assertEqual(round(_Backward4_T_hs(2400, 6.0), 7), 425.1373305)
+ self.assertEqual(round(_Backward4_T_hs(2500, 5.5), 7), 522.5579013)
+
+ def test_IAPWS97_3_Sup05(self):
+ """Test for supplementary 05 for region 3 v=f(T,P)"""
+ # T=f(P) limit Table 3 pag 11
+ self.assertEqual(round(_tab_P(40), 7), 693.0341408)
+ self.assertEqual(round(_txx_P(25, "cd"), 7), 649.3659208)
+ self.assertEqual(round(_tef_P(40), 7), 713.9593992)
+ self.assertEqual(round(_txx_P(23, "gh"), 7), 649.8873759)
+ self.assertEqual(round(_txx_P(23, "ij"), 7), 651.5778091)
+ self.assertEqual(round(_txx_P(23, "jk"), 7), 655.8338344)
+ self.assertEqual(round(_txx_P(22.8, "mn"), 7), 649.6054133)
+ self.assertEqual(round(_top_P(22.8), 7), 650.0106943)
+ self.assertEqual(round(_txx_P(22, "qu"), 7), 645.6355027)
+ self.assertEqual(round(_txx_P(22, "rx"), 7), 648.2622754)
+
+ # _Backward3_v_PT Table 5 pag 13
+ self.assertEqual(round(_Backward3_v_PT(50, 630), 12), 1.470853100e-3)
+ self.assertEqual(round(_Backward3_v_PT(80, 670), 12), 1.503831359e-3)
+ self.assertEqual(round(_Backward3_v_PT(50, 710), 12), 2.204728587e-3)
+ self.assertEqual(round(_Backward3_v_PT(80, 750), 12), 1.973692940e-3)
+ self.assertEqual(round(_Backward3_v_PT(20, 630), 12), 1.761696406e-3)
+ self.assertEqual(round(_Backward3_v_PT(30, 650), 12), 1.819560617e-3)
+ self.assertEqual(round(_Backward3_v_PT(26, 656), 12), 2.245587720e-3)
+ self.assertEqual(round(_Backward3_v_PT(30, 670), 12), 2.506897702e-3)
+ self.assertEqual(round(_Backward3_v_PT(26, 661), 12), 2.970225962e-3)
+ self.assertEqual(round(_Backward3_v_PT(30, 675), 12), 3.004627086e-3)
+ self.assertEqual(round(_Backward3_v_PT(26, 671), 12), 5.019029401e-3)
+ self.assertEqual(round(_Backward3_v_PT(30, 690), 12), 4.656470142e-3)
+ self.assertEqual(round(_Backward3_v_PT(23.6, 649), 12), 2.163198378e-3)
+ self.assertEqual(round(_Backward3_v_PT(24, 650), 12), 2.166044161e-3)
+ self.assertEqual(round(_Backward3_v_PT(23.6, 652), 12), 2.651081407e-3)
+ self.assertEqual(round(_Backward3_v_PT(24, 654), 12), 2.967802335e-3)
+ self.assertEqual(round(_Backward3_v_PT(23.6, 653), 12), 3.273916816e-3)
+ self.assertEqual(round(_Backward3_v_PT(24, 655), 12), 3.550329864e-3)
+ self.assertEqual(round(_Backward3_v_PT(23.5, 655), 12), 4.545001142e-3)
+ self.assertEqual(round(_Backward3_v_PT(24, 660), 12), 5.100267704e-3)
+ self.assertEqual(round(_Backward3_v_PT(23, 660), 12), 6.109525997e-3)
+ self.assertEqual(round(_Backward3_v_PT(24, 670), 12), 6.427325645e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.6, 646), 12), 2.117860851e-3)
+ self.assertEqual(round(_Backward3_v_PT(23, 646), 12), 2.062374674e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.6, 648.6), 12), 2.533063780e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.8, 649.3), 12), 2.572971781e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.6, 649.0), 12), 2.923432711e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.8, 649.7), 12), 2.913311494e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.6, 649.1), 12), 3.131208996e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.8, 649.9), 12), 3.221160278e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.6, 649.4), 12), 3.715596186e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.8, 650.2), 12), 3.664754790e-3)
+ self.assertEqual(round(_Backward3_v_PT(21.1, 640), 12), 1.970999272e-3)
+ self.assertEqual(round(_Backward3_v_PT(21.8, 643), 12), 2.043919161e-3)
+ self.assertEqual(round(_Backward3_v_PT(21.1, 644), 12), 5.251009921e-3)
+ self.assertEqual(round(_Backward3_v_PT(21.8, 648), 12), 5.256844741e-3)
+ self.assertEqual(round(_Backward3_v_PT(19.1, 635), 12), 1.932829079e-3)
+ self.assertEqual(round(_Backward3_v_PT(20, 638), 12), 1.985387227e-3)
+ self.assertEqual(round(_Backward3_v_PT(17, 626), 12), 8.483262001e-3)
+ self.assertEqual(round(_Backward3_v_PT(20, 640), 12), 6.227528101e-3)
+
+ # T=f(P) limit Table 11 pag 19
+ self.assertEqual(round(_txx_P(22.3, "uv"), 7), 647.7996121)
+ self.assertEqual(round(_twx_P(22.3), 7), 648.2049480)
+
+ # _Backward3_v_PT Table 13 pag 20
+ self.assertEqual(round(_Backward3_v_PT(21.5, 644.6), 12), 2.268366647e-3)
+ self.assertEqual(round(_Backward3_v_PT(22, 646.1), 12), 2.296350553e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.5, 648.6), 12), 2.832373260e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.3, 647.9), 12), 2.811424405e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.15, 647.5), 12), 3.694032281e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.3, 648.1), 12), 3.622226305e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.11, 648), 12), 4.528072649e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.3, 649), 12), 4.556905799e-3)
+ self.assertEqual(round(_Backward3_v_PT(22, 646.84), 12), 2.698354719e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.064, 647.05), 12), 2.717655648e-3)
+ self.assertEqual(round(_Backward3_v_PT(22, 646.89), 12), 3.798732962e-3)
+ self.assertEqual(round(_Backward3_v_PT(22.064, 647.15), 11), 3.701940010e-3)
+
+ def test_IAPWS97_4(self):
+ """Saturation line"""
+ # _PSat_T Table 35 pag 34
+ self.assertEqual(round(_PSat_T(300), 11), 0.00353658941)
+ self.assertEqual(round(_PSat_T(500), 8), 2.63889776)
+ self.assertEqual(round(_PSat_T(600), 7), 12.3443146)
+
+ # _TSat_P Table 36 pag 36
+ self.assertEqual(round(_TSat_P(0.1), 6), 372.755919)
+ self.assertEqual(round(_TSat_P(1), 6), 453.035632)
+ self.assertEqual(round(_TSat_P(10), 6), 584.149488)
+
+ def test_IAPWS97_5(self):
+ """Table 42, pag 40"""
+ fluid = _Region5(1500, 0.5)
+ self.assertEqual(round(fluid["v"], 8), 1.38455090)
+ self.assertEqual(round(fluid["h"], 5), 5219.76855)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 4527.49310)
+ self.assertEqual(round(fluid["s"], 8), 9.65408875)
+ self.assertEqual(round(fluid["cp"], 8), 2.61609445)
+ self.assertEqual(round(fluid["w"], 6), 917.068690)
+
+ fluid = _Region5(1500, 30)
+ self.assertEqual(round(fluid["v"], 10), 0.0230761299)
+ self.assertEqual(round(fluid["h"], 5), 5167.23514)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 4474.95124)
+ self.assertEqual(round(fluid["s"], 8), 7.72970133)
+ self.assertEqual(round(fluid["cp"], 8), 2.72724317)
+ self.assertEqual(round(fluid["w"], 6), 928.548002)
+
+ fluid = _Region5(2000, 30)
+ self.assertEqual(round(fluid["v"], 10), 0.0311385219)
+ self.assertEqual(round(fluid["h"], 5), 6571.22604)
+ self.assertEqual(round(fluid["h"]-fluid["P"]*1000*fluid["v"], 5), 5637.07038)
+ self.assertEqual(round(fluid["s"], 8), 8.53640523)
+ self.assertEqual(round(fluid["cp"], 8), 2.88569882)
+ self.assertEqual(round(fluid["w"], 5), 1067.36948)
+
+ def test_D2O(self):
+ """Table 5 pag 11"""
+ fluid = D2O()
+ Tr = 643.847
+ rhor = 358
+ ar = 21.671*1000/358
+ sr = 21.671*1000/358./643.847
+ pr = 21.671*1000
+
+ state = fluid._Helmholtz(0.0002*rhor, 0.5*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -2.644979)
+ self.assertEqual(round(state["P"]/pr, 7), 0.0004402)
+ self.assertEqual(round(state["cv"]/sr, 4), 14.2768)
+
+ state = fluid._Helmholtz(3.18*rhor, 0.5*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -0.217388)
+ self.assertEqual(round(state["P"]/pr, 7), 4.3549719)
+ self.assertEqual(round(state["cv"]/sr, 4), 41.4463)
+
+ state = fluid._Helmholtz(0.0295*rhor, 0.75*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -7.272543)
+ self.assertEqual(round(state["P"]/pr, 7), 0.0870308)
+ self.assertEqual(round(state["cv"]/sr, 4), 20.1586)
+
+ state = fluid._Helmholtz(2.83*rhor, 0.75*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -4.292707)
+ self.assertEqual(round(state["P"]/pr, 7), 4.4752958)
+ self.assertEqual(round(state["cv"]/sr, 4), 33.4367)
+
+ state = fluid._Helmholtz(0.3*rhor, Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -15.163326)
+ self.assertEqual(round(state["P"]/pr, 7), 0.8014044)
+ self.assertEqual(round(state["cv"]/sr, 4), 30.8587)
+
+ state = fluid._Helmholtz(1.55*rhor, Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -12.643811)
+ self.assertEqual(round(state["P"]/pr, 7), 1.0976283)
+ self.assertEqual(round(state["cv"]/sr, 4), 33.0103)
+
+ state = fluid._Helmholtz(0.4*rhor, 1.2*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -25.471535)
+ self.assertEqual(round(state["P"]/pr, 7), 1.4990994)
+ self.assertEqual(round(state["cv"]/sr, 4), 23.6594)
+
+ state = fluid._Helmholtz(1.61*rhor, 1.2*Tr)
+ self.assertEqual(round((state["h"]-state["P"]*1000*state["v"]-state["T"]*state["s"])/ar, 6), -21.278164)
+ self.assertEqual(round(state["P"]/pr, 7), 4.5643798)
+ self.assertEqual(round(state["cv"]/sr, 4), 25.4800)
+
+ def test_D2O_Viscosity(self):
+ """Table A5 pag 10"""
+ mur = 55.2651e-6
+ Tr = 643.847
+ rhor = 358
+ self.assertEqual(round(D2O._visco(3.09*rhor, 0.431*Tr)/mur, 10), 36.9123166244)
+ self.assertEqual(round(D2O._visco(3.23*rhor, 0.431*Tr)/mur, 10), 34.1531546602)
+ self.assertEqual(round(D2O._visco(0.0002*rhor, 0.5*Tr)/mur, 10), 0.1972984225)
+ self.assertEqual(round(D2O._visco(3.07*rhor, 0.5*Tr)/mur, 10), 12.0604912273)
+ self.assertEqual(round(D2O._visco(3.18*rhor, 0.5*Tr)/mur, 10), 12.4679405772)
+ self.assertEqual(round(D2O._visco(0.0027*rhor, 0.6*Tr)/mur, 10), 0.2365829037)
+ self.assertEqual(round(D2O._visco(2.95*rhor, 0.6*Tr)/mur, 10), 5.2437249935)
+ self.assertEqual(round(D2O._visco(3.07*rhor, 0.6*Tr)/mur, 10), 5.7578399754)
+ self.assertEqual(round(D2O._visco(0.0295*rhor, 0.75*Tr)/mur, 10), 0.2951479769)
+ self.assertEqual(round(D2O._visco(2.65*rhor, 0.75*Tr)/mur, 10), 2.6275043948)
+ self.assertEqual(round(D2O._visco(2.83*rhor, 0.75*Tr)/mur, 10), 3.0417583586)
+ self.assertEqual(round(D2O._visco(0.08*rhor, 0.9*Tr)/mur, 10), 0.3685472578)
+ self.assertEqual(round(D2O._visco(0.163*rhor, 0.9*Tr)/mur, 10), 0.3619649145)
+ self.assertEqual(round(D2O._visco(2.16*rhor, 0.9*Tr)/mur, 10), 1.6561616211)
+ self.assertEqual(round(D2O._visco(2.52*rhor, 0.9*Tr)/mur, 10), 2.1041364724)
+ self.assertEqual(round(D2O._visco(0.3*rhor, Tr)/mur, 10), 0.4424816849)
+ self.assertEqual(round(D2O._visco(0.7*rhor, Tr)/mur, 10), 0.5528693914)
+ self.assertEqual(round(D2O._visco(1.55*rhor, Tr)/mur, 10), 1.1038442411)
+ self.assertEqual(round(D2O._visco(2.26*rhor, Tr)/mur, 10), 1.7569585722)
+ self.assertEqual(round(D2O._visco(0.49*rhor, 1.1*Tr)/mur, 10), 0.5633038063)
+ self.assertEqual(round(D2O._visco(0.98*rhor, 1.1*Tr)/mur, 10), 0.7816387903)
+ self.assertEqual(round(D2O._visco(1.47*rhor, 1.1*Tr)/mur, 10), 1.1169456968)
+ self.assertEqual(round(D2O._visco(1.96*rhor, 1.1*Tr)/mur, 10), 1.5001420619)
+ self.assertEqual(round(D2O._visco(0.4*rhor, 1.2*Tr)/mur, 10), 0.6094539064)
+ self.assertEqual(round(D2O._visco(0.8*rhor, 1.2*Tr)/mur, 10), 0.7651099154)
+ self.assertEqual(round(D2O._visco(1.2*rhor, 1.2*Tr)/mur, 10), 0.9937870139)
+ self.assertEqual(round(D2O._visco(1.61*rhor, 1.2*Tr)/mur, 10), 1.2711900131)
+
+ def test_D2O_ThCond(self):
+ """Table B4 pag 17"""
+ lr = 0.742128e-3
+ Tr = 643.847
+ rhor = 358
+ self.assertEqual(round(D2O._thermo(3.09*rhor, 0.431*Tr)/lr, 9), 762.915707396)
+ self.assertEqual(round(D2O._thermo(3.23*rhor, 0.431*Tr)/lr, 9), 833.912049618)
+ self.assertEqual(round(D2O._thermo(0.0002*rhor, 0.5*Tr)/lr, 9), 27.006536978)
+ self.assertEqual(round(D2O._thermo(3.07*rhor, 0.5*Tr)/lr, 9), 835.786416818)
+ self.assertEqual(round(D2O._thermo(3.18*rhor, 0.5*Tr)/lr, 9), 891.181752526)
+ self.assertEqual(round(D2O._thermo(0.0027*rhor, 0.6*Tr)/lr, 9), 35.339949553)
+ self.assertEqual(round(D2O._thermo(2.95*rhor, 0.6*Tr)/lr, 9), 861.240794445)
+ self.assertEqual(round(D2O._thermo(3.07*rhor, 0.6*Tr)/lr, 9), 919.859094854)
+ self.assertEqual(round(D2O._thermo(0.0295*rhor, 0.75*Tr)/lr, 9), 55.216750017)
+ self.assertEqual(round(D2O._thermo(2.65*rhor, 0.75*Tr)/lr, 9), 790.442563472)
+ self.assertEqual(round(D2O._thermo(2.83*rhor, 0.75*Tr)/lr, 9), 869.672292625)
+ self.assertEqual(round(D2O._thermo(0.08*rhor, 0.9*Tr)/lr, 9), 74.522283066)
+ self.assertEqual(round(D2O._thermo(0.163*rhor, 0.9*Tr)/lr, 9), 106.301972320)
+ self.assertEqual(round(D2O._thermo(2.16*rhor, 0.9*Tr)/lr, 9), 627.777590127)
+ self.assertEqual(round(D2O._thermo(2.52*rhor, 0.9*Tr)/lr, 9), 761.055043002)
+ self.assertEqual(round(D2O._thermo(0.3*rhor, Tr)/lr, 9), 143.422002971)
+ self.assertEqual(round(D2O._thermo(0.7*rhor, Tr)/lr, 9), 469.015122112)
+ self.assertEqual(round(D2O._thermo(1.55*rhor, Tr)/lr, 9), 502.846952426)
+ self.assertEqual(round(D2O._thermo(2.26*rhor, Tr)/lr, 9), 668.743524402)
+ self.assertEqual(round(D2O._thermo(0.49*rhor, 1.1*Tr)/lr, 9), 184.813462109)
+ self.assertEqual(round(D2O._thermo(0.98*rhor, 1.1*Tr)/lr, 9), 326.652382218)
+ self.assertEqual(round(D2O._thermo(1.47*rhor, 1.1*Tr)/lr, 9), 438.370305052)
+ self.assertEqual(round(D2O._thermo(1.96*rhor, 1.1*Tr)/lr, 9), 572.014411428)
+ self.assertEqual(round(D2O._thermo(0.4*rhor, 1.2*Tr)/lr, 9), 160.059403824)
+ self.assertEqual(round(D2O._thermo(0.8*rhor, 1.2*Tr)/lr, 9), 259.605241187)
+ self.assertEqual(round(D2O._thermo(1.2*rhor, 1.2*Tr)/lr, 9), 362.179570932)
+ self.assertEqual(round(D2O._thermo(1.61*rhor, 1.2*Tr)/lr, 9), 471.747729424)
+ self.assertEqual(round(D2O._thermo(0.3*rhor, 1.27*Tr)/lr, 9), 145.249914694)
+ self.assertEqual(round(D2O._thermo(0.6*rhor, 1.27*Tr)/lr, 9), 211.996299238)
+ self.assertEqual(round(D2O._thermo(0.95*rhor, 1.27*Tr)/lr, 9), 299.251471210)
+ self.assertEqual(round(D2O._thermo(1.37*rhor, 1.27*Tr)/lr, 9), 409.359675394)
+
+ def test_D2O_Tension(self):
+ """Selected values from table 1"""
+ fluid = D2O()
+ self.assertEqual(round(fluid._Tension(273.15+3.8)*1000, 2), 74.93)
+ self.assertEqual(round(fluid._Tension(283.15)*1000, 2), 74.06)
+ self.assertEqual(round(fluid._Tension(293.15)*1000, 2), 72.61)
+ self.assertEqual(round(fluid._Tension(303.15)*1000, 2), 71.09)
+ self.assertEqual(round(fluid._Tension(313.15)*1000, 2), 69.52)
+ self.assertEqual(round(fluid._Tension(323.15)*1000, 2), 67.89)
+ self.assertEqual(round(fluid._Tension(333.15)*1000, 2), 66.21)
+ self.assertEqual(round(fluid._Tension(343.15)*1000, 2), 64.47)
+ self.assertEqual(round(fluid._Tension(353.15)*1000, 2), 62.67)
+ self.assertEqual(round(fluid._Tension(363.15)*1000, 2), 60.82)
+ self.assertEqual(round(fluid._Tension(373.15)*1000, 2), 58.93)
+ self.assertEqual(round(fluid._Tension(393.15)*1000, 2), 54.99)
+ self.assertEqual(round(fluid._Tension(413.15)*1000, 2), 50.87)
+ self.assertEqual(round(fluid._Tension(433.15)*1000, 2), 46.59)
+ self.assertEqual(round(fluid._Tension(453.15)*1000, 2), 42.16)
+ self.assertEqual(round(fluid._Tension(473.15)*1000, 2), 37.61)
+ self.assertEqual(round(fluid._Tension(523.15)*1000, 2), 25.84)
+ self.assertEqual(round(fluid._Tension(573.15)*1000, 2), 13.99)
+ self.assertEqual(round(fluid._Tension(623.15)*1000, 2), 3.17)
+ self.assertEqual(round(fluid._Tension(643.15)*1000, 2), 0.05)
+
+ def test_Ice(self):
+ """Table, pag 12"""
+ ice = _Ice(273.16, 0.000611657)
+ self.assertEqual(round(ice["g"], 12), 0.000611784135)
+ self.assertEqual(round(ice["gp"], 11), 1.09085812737)
+ self.assertEqual(round(ice["gt"], 11), 1.22069433940)
+ self.assertEqual(round(ice["gpp"], 15), -0.000128495941571)
+ self.assertEqual(round(ice["gtp"], 15), 0.000174387964700)
+ self.assertEqual(round(ice["gtt"], 14), -0.00767602985875)
+ self.assertEqual(round(ice["h"], 9), -333.444253966)
+ self.assertEqual(round(ice["a"], 12), -0.000055446875)
+ self.assertEqual(round(ice["u"], 9), -333.444921197)
+ self.assertEqual(round(ice["s"], 11), -1.22069433940)
+ self.assertEqual(round(ice["cp"], 11), 2.09678431622)
+ self.assertEqual(round(ice["rho"], 9), 916.709492200)
+ self.assertEqual(round(ice["alfav"], 15), 0.000159863102566)
+ self.assertEqual(round(ice["beta"], 11), 1.35714764659)
+ self.assertEqual(round(ice["kt"], 15), 0.000117793449348)
+ self.assertEqual(round(ice["ks"], 15), 0.000114161597779)
+
+ ice = _Ice(273.152519, 0.101325)
+ self.assertEqual(round(ice["g"], 11), 0.10134274069)
+ self.assertEqual(round(ice["gp"], 11), 1.09084388214)
+ self.assertEqual(round(ice["gt"], 11), 1.22076932550)
+ self.assertEqual(round(ice["gpp"], 15), -0.000128485364928)
+ self.assertEqual(round(ice["gtp"], 15), 0.000174362219972)
+ self.assertEqual(round(ice["gtt"], 14), -0.00767598233365)
+ self.assertEqual(round(ice["h"], 9), -333.354873637)
+ self.assertEqual(round(ice["a"], 11), -0.00918701567)
+ self.assertEqual(round(ice["u"], 9), -333.465403393)
+ self.assertEqual(round(ice["s"], 11), -1.22076932550)
+ self.assertEqual(round(ice["cp"], 11), 2.09671391024)
+ self.assertEqual(round(ice["rho"], 9), 916.721463419)
+ self.assertEqual(round(ice["alfav"], 15), 0.000159841589458)
+ self.assertEqual(round(ice["beta"], 11), 1.35705899321)
+ self.assertEqual(round(ice["kt"], 15), 0.000117785291765)
+ self.assertEqual(round(ice["ks"], 15), 0.000114154442556)
+
+ ice = _Ice(100, 100.)
+ self.assertEqual(round(ice["g"], 9), -222.296513088)
+ self.assertEqual(round(ice["gp"], 11), 1.06193389260)
+ self.assertEqual(round(ice["gt"], 11), 2.61195122589)
+ self.assertEqual(round(ice["gpp"], 16), -0.0000941807981761)
+ self.assertEqual(round(ice["gtp"], 16), 0.0000274505162488)
+ self.assertEqual(round(ice["gtt"], 14), -0.00866333195517)
+ self.assertEqual(round(ice["h"], 9), -483.491635676)
+ self.assertEqual(round(ice["a"], 9), -328.489902347)
+ self.assertEqual(round(ice["u"], 9), -589.685024936)
+ self.assertEqual(round(ice["s"], 11), -2.61195122589)
+ self.assertEqual(round(ice["cp"], 12), 0.866333195517)
+ self.assertEqual(round(ice["rho"], 9), 941.678203297)
+ self.assertEqual(round(ice["alfav"], 16), 0.0000258495528207)
+ self.assertEqual(round(ice["beta"], 12), 0.291466166994)
+ self.assertEqual(round(ice["kt"], 16), 0.0000886880048115)
+ self.assertEqual(round(ice["ks"], 16), 0.0000886060982687)
+
+ def test_SeaWater(self):
+ """Table 8, pag 17-19"""
+
+ # Part a, pag 17
+ fluid = SeaWater(T=273.15, P=0.101325, S=0.03516504)
+ state = fluid._water(273.15, 0.101325)
+ self.assertEqual(round(state["g"], 9), 0.101342742)
+ self.assertEqual(round(state["gs"], 9), 0.0)
+ self.assertEqual(round(state["gt"], 12), 0.000147643376)
+ self.assertEqual(round(state["gp"], 11), 0.00100015694)
+ self.assertEqual(round(state["gsp"], 9), 0.0)
+ self.assertEqual(round(state["gtt"], 10), -0.0154473542)
+ self.assertEqual(round(state["gtp"], 16), -0.677700318e-7)
+ self.assertEqual(round(state["gpp"], 15), -0.508928895e-6)
+
+ state = fluid._saline(273.15, 0.101325, 0.03516504)
+ self.assertEqual(round(state["g"], 9), -0.101342742)
+ self.assertEqual(round(state["gs"], 7), 63.9974067)
+ self.assertEqual(round(state["gt"], 12), -0.000147643376)
+ self.assertEqual(round(state["gp"], 13), -0.0000274957224)
+ self.assertEqual(round(state["gsp"], 12), -0.000759615412)
+ self.assertEqual(round(state["gtt"], 12), 0.000852861151)
+ self.assertEqual(round(state["gtp"], 15), 0.119286787e-6)
+ self.assertEqual(round(state["gpp"], 16), 0.581535172e-7)
+
+ self.assertEqual(round(fluid.g, 5), 0.0)
+ self.assertEqual(round(fluid.gs, 7), 63.9974067)
+ self.assertEqual(round(fluid.gt, 5), 0.0)
+ self.assertEqual(round(fluid.gp, 12), 0.000972661217)
+ self.assertEqual(round(fluid.gsp, 12), -0.000759615412)
+ self.assertEqual(round(fluid.gtt, 10), -0.0145944931)
+ self.assertEqual(round(fluid.gtp, 16), 0.515167556e-7)
+ self.assertEqual(round(fluid.gpp, 15), -0.450775377e-6)
+ self.assertEqual(round(fluid.h, 6), 0.0)
+ self.assertEqual(round(fluid.a, 10), -0.0985548978)
+ self.assertEqual(round(fluid.u, 10), -0.0985548978)
+ self.assertEqual(round(fluid.s, 6), 0.0)
+ self.assertEqual(round(fluid.rho, 5), 1028.10720)
+ self.assertEqual(round(fluid.cp, 8), 3.98648579)
+ self.assertEqual(round(fluid.w, 5), 1449.00246)
+ self.assertEqual(round(fluid.muw, 8), -2.25047137)
+
+ # Part b, pag 18
+ fluid = SeaWater(T=353, P=0.101325, S=0.1)
+ state = fluid._water(353, 0.101325)
+ self.assertEqual(round(state["g"], 9), -44.6114969)
+ self.assertEqual(round(state["gs"], 9), 0.0)
+ self.assertEqual(round(state["gt"], 8), -1.07375993)
+ self.assertEqual(round(state["gp"], 11), 0.00102892956)
+ self.assertEqual(round(state["gsp"], 9), 0.0)
+ self.assertEqual(round(state["gtt"], 10), -0.0118885000)
+ self.assertEqual(round(state["gtp"], 15), 0.659051552e-6)
+ self.assertEqual(round(state["gpp"], 15), -0.474672819e-6)
+
+ state = fluid._saline(353, 0.101325, 0.1)
+ self.assertEqual(round(state["g"], 7), 15.0871740)
+ self.assertEqual(round(state["gs"], 6), 251.957276)
+ self.assertEqual(round(state["gt"], 9), 0.156230907)
+ self.assertEqual(round(state["gp"], 13), -0.0000579227286)
+ self.assertEqual(round(state["gsp"], 12), -0.000305957802)
+ self.assertEqual(round(state["gtt"], 11), 0.00127922649)
+ self.assertEqual(round(state["gtp"], 15), 0.803061596e-6)
+ self.assertEqual(round(state["gpp"], 15), 0.213086154e-6)
+
+ self.assertEqual(round(fluid.g, 7), -29.5243229)
+ self.assertEqual(round(fluid.gs, 6), 251.957276)
+ self.assertEqual(round(fluid.gt, 9), -0.917529024)
+ self.assertEqual(round(fluid.gp, 12), 0.000971006828)
+ self.assertEqual(round(fluid.gsp, 12), -0.000305957802)
+ self.assertEqual(round(fluid.gtt, 10), -0.0106092735)
+ self.assertEqual(round(fluid.gtp, 14), 0.146211315e-5)
+ self.assertEqual(round(fluid.gpp, 15), -0.261586665e-6)
+ self.assertEqual(round(fluid.h, 6), 294.363423)
+ self.assertEqual(round(fluid.a, 7), -29.6227102)
+ self.assertEqual(round(fluid.u, 6), 294.265035)
+ self.assertEqual(round(fluid.s, 9), 0.917529024)
+ self.assertEqual(round(fluid.rho, 5), 1029.85888)
+ self.assertEqual(round(fluid.cp, 8), 3.74507355)
+ self.assertEqual(round(fluid.w, 5), 3961.27835)
+ self.assertEqual(round(fluid.muw, 7), -54.7200505)
+
+ # Part c, pag 19
+ fluid = SeaWater(T=273.15, P=100, S=0.03516504)
+ state = fluid._water(273.15, 100)
+ self.assertEqual(round(state["g"], 7), 97.7303862)
+ self.assertEqual(round(state["gs"], 9), 0.0)
+ self.assertEqual(round(state["gt"], 11), 0.00851466502)
+ self.assertEqual(round(state["gp"], 12), 0.000956683329)
+ self.assertEqual(round(state["gsp"], 9), 0.0)
+ self.assertEqual(round(state["gtt"], 10), -0.0142969873)
+ self.assertEqual(round(state["gtp"], 15), 0.199079571e-6)
+ self.assertEqual(round(state["gpp"], 15), -0.371530889e-6)
+
+ state = fluid._saline(273.15, 100, 0.03516504)
+ self.assertEqual(round(state["g"], 8), -2.60093051)
+ self.assertEqual(round(state["gs"], 8), -5.45861581)
+ self.assertEqual(round(state["gt"], 11), 0.00754045685)
+ self.assertEqual(round(state["gp"], 13), -0.0000229123842)
+ self.assertEqual(round(state["gsp"], 12), -0.000640757619)
+ self.assertEqual(round(state["gtt"], 12), 0.000488076974)
+ self.assertEqual(round(state["gtp"], 16), 0.466284412e-7)
+ self.assertEqual(round(state["gpp"], 16), 0.357345736e-7)
+
+ self.assertEqual(round(fluid.g, 7), 95.1294557)
+ self.assertEqual(round(fluid.gs, 8), -5.45861581)
+ self.assertEqual(round(fluid.gt, 10), 0.0160551219)
+ self.assertEqual(round(fluid.gp, 12), 0.000933770945)
+ self.assertEqual(round(fluid.gsp, 12), -0.000640757619)
+ self.assertEqual(round(fluid.gtt, 10), -0.0138089104)
+ self.assertEqual(round(fluid.gtp, 15), 0.245708012e-6)
+ self.assertEqual(round(fluid.gpp, 15), -0.335796316e-6)
+ self.assertEqual(round(fluid.h, 7), 90.7439992)
+ self.assertEqual(round(fluid.a, 8), 1.75236121)
+ self.assertEqual(round(fluid.u, 8), -2.63309532)
+ self.assertEqual(round(fluid.s, 10), -0.0160551219)
+ self.assertEqual(round(fluid.rho, 5), 1070.92645)
+ self.assertEqual(round(fluid.cp, 8), 3.77190387)
+ self.assertEqual(round(fluid.w, 5), 1621.98998)
+ self.assertEqual(round(fluid.muw, 7), 95.3214082)
+
+
+if __name__ == "__main__":
+ unittest.main(verbosity=2)
diff --git a/iapws/_iapws.py b/iapws/_iapws.py
new file mode 100644
index 0000000..d01e99a
--- /dev/null
+++ b/iapws/_iapws.py
@@ -0,0 +1,413 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+###############################################################################
+# Several IAPWS standards
+###############################################################################
+
+from __future__ import division
+
+from math import log, exp, tan, atan, acos, sin, pi
+from cmath import log as log_c
+
+
+# Constants
+Rm = 8.31451 # kJ/kmol·K
+M = 18.015257 # kg/kmol
+R = 0.461526 # kJ/kg·K
+Tc = 647.096 # K
+Pc = 22.064 # MPa
+rhoc = 322. # kg/m³
+Tt = 273.16 # K
+Pt = 611.657e-6 # MPa
+Tb = 373.1243 # K
+Dipole = 1.855 # Debye
+f_acent = 0.3443
+
+
+# IAPWS-06 for Ice
+def _Ice(T, P):
+ """Basic equation for Ice Ih
+
+ >>> "%.9f" % _Ice(100,100)["rho"]
+ '941.678203297'
+ >>> "%.9f" % _Ice(100,100)["h"]
+ '-483.491635676'
+ >>> "%.11f" % _Ice(100,100)["s"]
+ '-2.61195122589'
+ >>> "%.11f" % _Ice(273.152519,0.101325)["a"]
+ '-0.00918701567'
+ >>> "%.9f" % _Ice(273.152519,0.101325)["u"]
+ '-333.465403393'
+ >>> "%.11f" % _Ice(273.152519,0.101325)["cp"]
+ '2.09671391024'
+ >>> "%.15f" % _Ice(273.16,611.657e-6)["alfav"]
+ '0.000159863102566'
+ >>> "%.11f" % _Ice(273.16,611.657e-6)["beta"]
+ '1.35714764659'
+ >>> "%.11e" % _Ice(273.16,611.657e-6)["kt"]
+ '1.17793449348e-04'
+ >>> "%.11e" % _Ice(273.16,611.657e-6)["ks"]
+ '1.14161597779e-04'
+ """
+ # Check input in range of validity
+ if P < Pt:
+ Psub = _Sublimation_Pressure(T)
+ if Psub > P:
+ # Zone Gas
+ raise NotImplementedError("Incoming out of bound")
+ elif P > 208.566:
+ # Ice Ih limit upper pressure
+ raise NotImplementedError("Incoming out of bound")
+ else:
+ Pmel = _Melting_Pressure(T, P)
+ if Pmel < P:
+ # Zone Liquid
+ raise NotImplementedError("Incoming out of bound")
+
+ Tr = T/Tt
+ Pr = P/Pt
+ P0 = 101325e-6/Pt
+ s0 = -0.332733756492168e4*1e-3 # Express in kJ/kgK
+
+ gok = [-0.632020233335886e6, 0.655022213658955, -0.189369929326131e-7,
+ 0.339746123271053e-14, -0.556464869058991e-21]
+ r2k = [complex(-0.725974574329220e2, -0.781008427112870e2)*1e-3,
+ complex(-0.557107698030123e-4, 0.464578634580806e-4)*1e-3,
+ complex(0.234801409215913e-10, -0.285651142904972e-10)*1e-3]
+ t1 = complex(0.368017112855051e-1, 0.510878114959572e-1)
+ t2 = complex(0.337315741065416, 0.335449415919309)
+ r1 = complex(0.447050716285388e2, 0.656876847463481e2)*1e-3
+
+ go = gop = gopp = 0
+ for k in range(5):
+ go += gok[k]*1e-3*(Pr-P0)**k
+ for k in range(1, 5):
+ gop += gok[k]*1e-3*k/Pt*(Pr-P0)**(k-1)
+ for k in range(2, 5):
+ gopp += gok[k]*1e-3*k*(k-1)/Pt**2*(Pr-P0)**(k-2)
+ r2 = r2p = 0
+ for k in range(3):
+ r2 += r2k[k]*(Pr-P0)**k
+ for k in range(1, 3):
+ r2p += r2k[k]*k/Pt*(Pr-P0)**(k-1)
+ r2pp = r2k[2]*2/Pt**2
+
+ c = r1*((t1-Tr)*log_c(t1-Tr)+(t1+Tr)*log_c(t1+Tr)-2*t1*log_c(t1)-Tr**2/t1) + \
+ r2*((t2-Tr)*log_c(t2-Tr)+(t2+Tr)*log_c(t2+Tr)-2*t2*log_c(t2)-Tr**2/t2)
+ ct = r1*(-log_c(t1-Tr)+log_c(t1+Tr)-2*Tr/t1) + \
+ r2*(-log_c(t2-Tr)+log_c(t2+Tr)-2*Tr/t2)
+ ctt = r1*(1/(t1-Tr)+1/(t1+Tr)-2/t1) + r2*(1/(t2-Tr)+1/(t2+Tr)-2/t2)
+ cp = r2p*((t2-Tr)*log_c(t2-Tr)+(t2+Tr)*log_c(t2+Tr)-2*t2*log_c(t2)-Tr**2/t2)
+ ctp = r2p*(-log_c(t2-Tr)+log_c(t2+Tr)-2*Tr/t2)
+ cpp = r2pp*((t2-Tr)*log_c(t2-Tr)+(t2+Tr)*log_c(t2+Tr)-2*t2*log_c(t2)-Tr**2/t2)
+
+ g = go-s0*Tt*Tr+Tt*c.real
+ gt = -s0+ct.real
+ gp = gop+Tt*cp.real
+ gtt = ctt.real/Tt
+ gtp = ctp.real
+ gpp = gopp+Tt*cpp.real
+
+ propiedades = {}
+ propiedades["gt"] = gt
+ propiedades["gp"] = gp
+ propiedades["gtt"] = gtt
+ propiedades["gpp"] = gpp
+ propiedades["gtp"] = gtp
+ propiedades["T"] = T
+ propiedades["P"] = P
+ propiedades["v"] = gp/1000
+ propiedades["rho"] = 1000./gp
+ propiedades["h"] = g-T*gt
+ propiedades["s"] = -gt
+ propiedades["cp"] = -T*gtt
+ propiedades["u"] = g-T*gt-P*gp
+ propiedades["g"] = g
+ propiedades["a"] = g-P*gp
+ propiedades["alfav"] = gtp/gp
+ propiedades["beta"] = -gtp/gpp
+ propiedades["kt"] = -gpp/gp
+ propiedades["ks"] = (gtp**2-gtt*gpp)/gp/gtt
+ return propiedades
+
+
+def _Sublimation_Pressure(T):
+ """Sublimation Pressure correlation"""
+ Tita = T/Tt
+ suma = 0
+ a = [-0.212144006e2, 0.273203819e2, -0.61059813e1]
+ expo = [0.333333333e-2, 1.20666667, 1.70333333]
+ for ai, expi in zip(a, expo):
+ suma += ai*Tita**expi
+ return exp(suma/Tita)*Pt
+
+
+def _Melting_Pressure(T, P):
+ """Melting Pressure correlation"""
+ if P < 208.566 and 251.165 <= T <= 273.16:
+ # Ice Ih
+ Tref = Tt
+ Pref = Pt
+ Tita = T/Tref
+ a = [0.119539337e7, 0.808183159e5, 0.33382686e4]
+ expo = [3., 0.2575e2, 0.10375e3]
+ suma = 1
+ for ai, expi in zip(a, expo):
+ suma += ai*(1-Tita**expi)
+ P = suma*Pref
+ elif 208.566 < P < 350.1 and 251.165 < T <= 256.164:
+ # Ice III
+ Tref = 251.165
+ Pref = 208.566
+ Tita = T/Tref
+ P = Pref*(1-0.299948*(1-Tita**60.))
+ elif 350.1 < P < 632.4 and 256.164 < T <= 273.31:
+ # Ice V
+ Tref = 256.164
+ Pref = 350.100
+ Tita = T/Tref
+ P = Pref*(1-1.18721*(1-Tita**8.))
+ elif 632.4 < P < 2216 and 273.31 < T <= 355:
+ # Ice VI
+ Tref = 273.31
+ Pref = 632.400
+ Tita = T/Tref
+ P = Pref*(1-1.07476*(1-Tita**4.6))
+ elif 2216 < P and 355. < T <= 715:
+ # Ice VII
+ Tref = 355
+ Pref = 2216.000
+ Tita = T/Tref
+ P = Pref*exp(1.73683*(1-1./Tita)-0.544606e-1*(1-Tita**5) +
+ 0.806106e-7*(1-Tita**22))
+
+ return P
+
+
+# Transport properties
+def _Viscosity(rho, T, fase=None, drho=None):
+ """Equation for the Viscosity
+
+ >>> "%.12f" % _Viscosity(997.047435,298.15)
+ '0.000890022551'
+ >>> "%.13f" % _Viscosity(54.9921814,873.15)
+ '0.0000339743835'
+ """
+ Tr = T/Tc
+ Dr = rho/rhoc
+
+ no = [1.67752, 2.20462, 0.6366564, -0.241605]
+ suma = 0
+ for i in range(4):
+ suma += no[i]/Tr**i
+ fi0 = 100*Tr**0.5/suma
+
+ I = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6]
+ J = [0, 1, 2, 3, 0, 1, 2, 3, 5, 0, 1, 2, 3, 4, 0, 1, 0, 3, 4, 3, 5]
+ nr = [0.520094, 0.850895e-1, -0.108374e1, -0.289555, 0.222531, 0.999115,
+ 0.188797e1, 0.126613e1, 0.120573, -0.281378, -0.906851, -0.772479,
+ -0.489837, -0.257040, 0.161913, 0.257399, -0.325372e-1, 0.698452e-1,
+ 0.872102e-2, -0.435673e-2, -0.593264e-3]
+ suma = 0
+ for i in range(21):
+ suma += nr[i]*(Dr-1)**I[i]*(1/Tr-1)**J[i]
+ fi1 = exp(Dr*suma)
+ if fase and drho:
+ qc = 1/1.9
+ qd = 1/1.1
+
+ DeltaX = Pc*Dr**2*(fase.drhodP_T/rho-drho/rho*1.5/Tr)
+ if DeltaX < 0:
+ DeltaX = 0
+ X = 0.13*(DeltaX/0.06)**(0.63/1.239)
+ if X <= 0.3817016416:
+ Y = qc/5*X*(qd*X)**5*(1-qc*X+(qc*X)**2-765./504*(qd*X)**2)
+ else:
+ Fid = acos((1+qd**2*X**2)**-0.5)
+ w = abs((qc*X-1)/(qc*X+1))**0.5*tan(Fid/2)
+ if qc*X > 1:
+ Lw = log((1+w)/(1-w))
+ else:
+ Lw = 2*atan(abs(w))
+ Y = sin(3*Fid)/12-sin(2*Fid)/4/qc/X+(1-5/4*(qc*X)**2)/(qc*X)**2*sin(
+ Fid)-((1-3/2*(qc*X)**2)*Fid-abs((qc*X)**2-1)**1.5*Lw)/(qc*X)**3
+ fi2 = exp(0.068*Y)
+ else:
+ fi2 = 1
+ return fi0*fi1*fi2*1e-6
+
+
+def _ThCond(rho, T, fase=None, drho=None):
+ """Equation for the thermal conductivity
+
+ >>> "%.9f" % _ThCond(997.047435,298.15)
+ '0.606515826'
+ >>> "%.10f" % _ThCond(26.0569558,873.15)
+ '0.0870480934'
+ """
+ d = rho/322.
+ Tr = T/647.096
+
+ no = [2.443221e-3, 1.323095e-2, 6.770357e-3, -3.454586e-3, 4.096266e-4]
+ suma = 0
+ for i in range(5):
+ suma += no[i]/Tr**i
+ L0 = Tr**0.5/suma
+
+ nij = [
+ [1.60397357, -0.646013523, 0.111443906, 0.102997357, -0.0504123634, 0.00609859258],
+ [2.33771842, -2.78843778, 1.53616167, -0.463045512, 0.0832827019, -0.00719201245],
+ [2.19650529, -4.54580785, 3.55777244, -1.40944978, 0.275418278, -0.0205938816],
+ [-1.21051378, 1.60812989, -0.621178141, 0.0716373224, 0, 0],
+ [-2.7203370, 4.57586331, -3.18369245, 1.1168348, -0.19268305, 0.012913842]]
+ suma = 0
+ for i in range(len(nij)):
+ suma2 = 0
+ for j in range(len(nij[i])):
+ suma2 += nij[i][j]*(d-1)**j
+ suma += (1/Tr-1)**i*suma2
+ L1 = exp(d*suma)
+
+ L2 = 0
+ if fase and drho:
+ R = 0.46151805
+
+ DeltaX = Pc*d**2*(fase.drhodP_T/rho-drho/rho*1.5/Tr)
+ if DeltaX < 0:
+ DeltaX = 0
+ X = 0.13*(DeltaX/0.06)**(0.63/1.239)
+ y = X/0.4
+ if y < 1.2e-7:
+ Z = 0
+ else:
+ Z = 2/pi/y*(((1-1/fase.cp_cv)*atan(y)+y/fase.cp_cv)-(1-exp(-1/(1/y+y**2/3/d**2))))
+ L2 = 177.8514*d*fase.cp/R*Tr/fase.mu*1e-6*Z
+ return 1e-3*(L0*L1+L2)
+
+
+def _Tension(T):
+ """Equation for the surface tension
+
+ >>> "%.10f" % _Tension(300)
+ '0.0716859625'
+ >>> "%.10f" % _Tension(450)
+ '0.0428914992'
+ """
+ Tr = T/Tc
+ if 273.15 <= T < Tc:
+ return 1e-3*(235.8*(1-Tr)**1.256*(1-0.625*(1-Tr)))
+ else:
+ return 0
+
+
+def _Dielectric(rho, T):
+ """Equation for the Dielectric constant
+
+ >>> "%.7f" % _Dielectric(999.242866, 298.15)
+ '78.5907250'
+ >>> "%.8f" % _Dielectric(26.0569558, 873.15)
+ '1.12620970'
+ """
+ k = 1.380658e-23
+ Na = 6.0221367e23
+ alfa = 1.636e-40
+ epsilon0 = 8.854187817e-12
+ mu = 6.138e-30
+ M = 0.018015268
+
+ d = rho/rhoc
+ Tr = Tc/T
+ I = [1, 1, 1, 2, 3, 3, 4, 5, 6, 7, 10, None]
+ J = [0.25, 1, 2.5, 1.5, 1.5, 2.5, 2, 2, 5, 0.5, 10, None]
+ n = [0.978224486826, -0.957771379375, 0.237511794148, 0.714692244396,
+ -0.298217036956, -0.108863472196, .949327488264e-1, -.980469816509e-2,
+ .165167634970e-4, .937359795772e-4, -.12317921872e-9, .196096504426e-2]
+
+ g = 1+n[11]*d/(Tc/228/Tr-1)**1.2
+ for i in range(11):
+ g += n[i]*d**I[i]*Tr**J[i]
+ A = Na*mu**2*rho*g/M/epsilon0/k/T
+ B = Na*alfa*rho/3/M/epsilon0
+ e = (1+A+5*B+(9+2*A+18*B+A**2+10*A*B+9*B**2)**0.5)/4/(1-B)
+ return e
+
+
+def _Refractive(rho, T, l=0.5893):
+ """Equation for the refractive index
+
+ >>> "%.8f" % _Refractive(997.047435, 298.15, 0.2265)
+ '1.39277824'
+ >>> "%.8f" % _Refractive(30.4758534, 773.15, 0.5893)
+ '1.00949307'
+ """
+ Lir = 5.432937
+ Luv = 0.229202
+ d = rho/1000.
+ Tr = T/273.15
+ L = l/0.589
+ a = [0.244257733, 0.974634476e-2, -0.373234996e-2, 0.268678472e-3,
+ 0.158920570e-2, 0.245934259e-2, 0.900704920, -0.166626219e-1]
+ A = d*(a[0]+a[1]*d+a[2]*Tr+a[3]*L**2*Tr+a[4]/L**2+a[5]/(L**2-Luv**2)+a[6]/(
+ L**2-Lir**2)+a[7]*d**2)
+ return ((2*A+1)/(1-A))**0.5
+
+
+class _fase(object):
+ """Class to implement a null phase"""
+ v = None
+ rho = None
+
+ h = None
+ s = None
+ u = None
+ a = None
+ g = None
+
+ cp = None
+ cv = None
+ cp_cv = None
+ w = None
+ Z = None
+ fi = None
+ f = None
+
+ mu = None
+ k = None
+ nu = None
+ Prandt = None
+ epsilon = None
+ alfa = None
+ n = None
+
+ alfap = None
+ betap = None
+ joule = None
+ Gruneisen = None
+ alfav = None
+ kappa = None
+ betas = None
+ gamma = None
+ Kt = None
+ kt = None
+ Ks = None
+ ks = None
+ dpdT_rho = None
+ dpdrho_T = None
+ drhodT_P = None
+ drhodP_T = None
+ dhdT_rho = None
+ dhdT_P = None
+ dhdrho_T = None
+ dhdrho_P = None
+ dhdP_T = None
+ dhdP_rho = None
+
+ Z_rho = None
+ IntP = None
+ hInput = None
+
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
diff --git a/iapws/iapws08.py b/iapws/iapws08.py
new file mode 100644
index 0000000..65b36e7
--- /dev/null
+++ b/iapws/iapws08.py
@@ -0,0 +1,214 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+###############################################################################
+# IAPWS for seawater
+###############################################################################
+
+from __future__ import division
+from math import log
+
+from iapws95 import IAPWS95
+
+
+# Constants
+Rm = 8.314472
+Sn = 0.03516504
+S_ = Sn*40/35
+Ms = 31.4038218
+T_ = 40
+P_ = 100
+Po = 0.101325
+To = 273.15
+
+
+class SeaWater(object):
+ """
+ Class to model seawater with standard IAPWS-08
+ Incoming properties:
+ T - Temperature, K
+ P - Pressure, MPa
+ S - Salinity, kg/kg
+
+ Calculated properties:
+ T: Temperature, K
+ P: Pressure, MPa
+ rho: Density, kg/m³
+ v: Specific volume, m³/kg
+ h: Specific enthalpy, kJ/kg
+ s: Specific entropy, kJ/kg·K
+ u: Specific internal energy, kJ/kg
+ g: Specific Gibbs free energy, kJ/kg
+ a: Specific Helmholtz free energy, kJ/kg
+ cp: Specific isobaric heat capacity, kJ/kg·K
+
+ gt: Derivative Gibbs energy with temperature, kJ/kg·K
+ gp: Derivative Gibbs energy with pressure, m³/kg
+ gtt: Derivative Gibbs energy with temperature square, kJ/kg·K²
+ gtp: Derivative Gibbs energy with pressure and temperature, m³/kg·K
+ gpp: Derivative Gibbs energy with temperature square, m³/kg·MPa
+ gs: Derivative Gibbs energy with salinity, kJ/kg
+ gsp: Derivative Gibbs energy with salinity and pressure, m³/kg
+
+ alfa: Thermal expansion coefficient, 1/K
+ betas: Isentropic temperature-pressure coefficient, K/MPa
+ kt: Isothermal compressibility, 1/MPa
+ ks: Isentropic compressibility, 1/MPa
+ w: Sound Speed, m/s
+
+ mu: Relative chemical potential, kJ/kg
+ muw: Chemical potential of H2O, kJ/kg
+ mus: Chemical potential of sea salt, kJ/kg
+ osm: Osmotic coefficient, [-]
+ haline: Haline contraction coefficient, kg/kg
+ """
+ kwargs = {"T": 0.0,
+ "P": 0.0,
+ "S": None}
+ status = 0
+ msg = "Undefined"
+
+ def __init__(self, **kwargs):
+ """Constructor, initinialice kwargs"""
+ self.kwargs = SeaWater.kwargs.copy()
+ self.__call__(**kwargs)
+
+ def __call__(self, **kwargs):
+ """Make instance callable to can add input parameter one to one"""
+ self.kwargs.update(kwargs)
+
+ if self.kwargs["T"] and self.kwargs["P"] and \
+ self.kwargs["S"] is not None:
+ self.status = 1
+ self.calculo()
+ self.msg = ""
+
+ def calculo(self):
+ """Calculate procedure"""
+ T = self.kwargs["T"]
+ P = self.kwargs["P"]
+ S = self.kwargs["S"]
+
+ m = S/(1-S)/Ms
+ pw = self._water(T, P)
+ ps = self._saline(T, P, S)
+
+ prop = {}
+ for key in pw:
+ prop[key] = pw[key]+ps[key]
+ self.__setattr__(key, prop[key])
+
+ self.T = T
+ self.P = P
+ self.rho = 1./prop["gp"]
+ self.v = prop["gp"]
+ self.s = -prop["gt"]
+ self.cp = -T*prop["gtt"]
+ self.h = prop["g"]-T*prop["gt"]
+ self.u = prop["g"]-T*prop["gt"]-P*1000*prop["gp"]
+ self.a = prop["g"]-P*1000*prop["gp"]
+ self.alfa = prop["gtp"]/prop["gp"]
+ self.betas = -prop["gtp"]/prop["gtt"]
+ self.kt = -prop["gpp"]/prop["gp"]
+ self.ks = (prop["gtp"]**2-prop["gt"]*prop["gpp"])/prop["gp"]/prop["gtt"]
+ self.w = prop["gp"]*(prop["gtt"]*1000/(prop["gtp"]**2 -
+ prop["gtt"]*1000*prop["gpp"]*1e-6))**0.5
+
+ self.mu = prop["gs"]
+ self.muw = prop["g"]-S*prop["gs"]
+ self.mus = prop["g"]+(1-S)*prop["gs"]
+ self.osm = -(ps["g"]-S*prop["gs"])/m/Rm/T
+ self.haline = -prop["gsp"]/prop["gp"]
+
+ @classmethod
+ def _water(cls, T, P):
+ """Get properties of pure water, Table4 pag 8"""
+ water = IAPWS95(P=P, T=T)
+ prop = {}
+ prop["g"] = water.h-T*water.s
+ prop["gt"] = -water.s
+ prop["gp"] = 1./water.rho
+ prop["gtt"] = -water.cp/T
+ prop["gtp"] = water.betas*water.cp/T
+ prop["gpp"] = -1e6/(water.rho*water.w)**2-water.betas**2*1e3*water.cp/T
+ prop["gs"] = 0
+ prop["gsp"] = 0
+ return prop
+
+ @classmethod
+ def _saline(cls, T, P, S):
+ """Eq 4"""
+ S_ = 0.03516504*40/35
+ X = (S/S_)**0.5
+ tau = (T-273.15)/40
+ pi = (P-0.101325)/100
+
+ I = [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 2, 3, 4, 2, 3, 4, 2, 3, 4,
+ 2, 4, 2, 2, 3, 4, 5, 2, 3, 4, 2, 3, 2, 3, 2, 3, 2, 3, 4, 2, 3, 2,
+ 3, 2, 2, 2, 3, 4, 2, 3, 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2]
+ J = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4,
+ 5, 5, 6, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 0, 0, 0, 1, 1, 2,
+ 2, 3, 4, 0, 0, 0, 1, 1, 2, 2, 3, 4, 0, 0, 1, 2, 3, 0, 1, 2]
+ K = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5]
+ G = [0.581281456626732e4, 0.141627648484197e4, -0.243214662381794e4,
+ 0.202580115603697e4, -0.109166841042967e4, 0.374601237877840e3,
+ -0.485891069025409e2, 0.851226734946706e3, 0.168072408311545e3,
+ -0.493407510141682e3, 0.543835333000098e3, -0.196028306689776e3,
+ 0.367571622995805e2, 0.880031352997204e3, -0.430664675978042e2,
+ -0.685572509204491e2, -0.225267649263401e3, -0.100227370861875e2,
+ 0.493667694856254e2, 0.914260447751259e2, 0.875600661808945,
+ -0.171397577419788e2, -0.216603240875311e2, 0.249697009569508e1,
+ 0.213016970847183e1, -0.331049154044839e4, 0.199459603073901e3,
+ -0.547919133532887e2, 0.360284195611086e2, 0.729116529735046e3,
+ -0.175292041186547e3, -0.226683558512829e2, -0.860764303783977e3,
+ 0.383058066002476e3, 0.694244814133268e3, -0.460319931801257e3,
+ -0.297728741987187e3, 0.234565187611355e3, 0.384794152978599e3,
+ -0.522940909281335e2, -0.408193978912261e1, -0.343956902961561e3,
+ 0.831923927801819e2, 0.337409530269367e3, -0.541917262517112e2,
+ -0.204889641964903e3, 0.747261411387560e2, -0.965324320107458e2,
+ 0.680444942726459e2, -0.301755111971161e2, 0.124687671116248e3,
+ -0.294830643494290e2, -0.178314556207638e3, 0.256398487389914e2,
+ 0.113561697840594e3, -0.364872919001588e2, 0.158408172766824e2,
+ -0.341251932441282e1, -0.316569643860730e2, 0.442040358308000e2,
+ -0.111282734326413e2, -0.262480156590992e1, 0.704658803315449e1,
+ -0.792001547211682e1]
+
+ g, gt, gp, gtt, gtp, gpp, gs, gsp = 0, 0, 0, 0, 0, 0, 0, 0
+ for i, j, k, gi in zip(I, J, K, G):
+ if i == 1:
+ g += gi*X**2*log(X)*tau**j*pi**k
+ gs += gi*(2*log(X)+1)*tau**j*pi**k
+ else:
+ g += gi*X**i*tau**j*pi**k
+ gs += i*gi*X**(i-2)*tau**j*pi**k
+ if j >= 1:
+ if i == 1:
+ gt += gi*X**2*log(X)*j*tau**(j-1)*pi**k
+ else:
+ gt += gi*X**i*j*tau**(j-1)*pi**k
+ if k >= 1:
+ gp += k*gi*X**i*tau**j*pi**(k-1)
+ gsp += i*k*gi*X**(i-2)*tau**j*pi**(k-1)
+ if j >= 2:
+ gtt += j*(j-1)*gi*X**i*tau**(j-2)*pi**k
+ if j >= 1 and k >= 1:
+ gtp += j*k*gi*X**i*tau**(j-1)*pi**(k-1)
+ if k >= 2:
+ gpp += k*(k-1)*gi*X**i*tau**j*pi**(k-2)
+
+ prop = {}
+ prop["g"] = g*1e-3
+ prop["gt"] = gt/40*1e-3
+ prop["gp"] = gp/100*1e-6
+ prop["gtt"] = gtt/40**2*1e-3
+ prop["gtp"] = gtp/40/100*1e-6
+ prop["gpp"] = gpp/100**2*1e-6
+ prop["gs"] = gs/S_/2*1e-3
+ prop["gsp"] = gsp/S_/2/100*1e-6
+ return prop
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
diff --git a/iapws/iapws95.py b/iapws/iapws95.py
new file mode 100644
index 0000000..b100104
--- /dev/null
+++ b/iapws/iapws95.py
@@ -0,0 +1,1317 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+
+###############################################################################
+# Implemented multiparameter equation of state
+# o IAPWS-95 implementation
+# o Heavy water formulation 2005
+###############################################################################
+
+
+from scipy import exp, log
+from scipy.optimize import fsolve
+
+from _iapws import _fase
+from _iapws import _Viscosity, _ThCond, _Dielectric, _Refractive
+from iapws97 import _TSat_P
+
+
+class MEoS(_fase):
+ """
+ General implementation of multiparameter equation of state
+ From this derived all child class specified per individual compounds
+
+ Incoming properties:
+ T - Temperature, K
+ P - Pressure, MPa
+ rho - Density, kg/m3
+ v - Specific volume, m3/kg
+ h - Specific enthalpy, kJ/kg
+ s - Specific entropy, kJ/kg·K
+ u - Specific internal energy, kJ/kg·K
+ x - Quality
+ l - Opcional parameter to light wavelength for Refractive index
+
+ It needs two incoming properties
+
+ Calculated properties:
+ P - Pressure, MPa
+ Pr - Reduce pressure
+ T - Temperature, K
+ Tr - Reduced temperature
+ x - Quality
+ v - Specific volume, m³/kg
+ rho - Density, kg/m³
+ h - Specific enthalpy, kJ/kg
+ s - Specific entropy, kJ/kg·K
+ u - Specific internal energy, kJ/kg
+ g - Specific Gibbs free energy, kJ/kg
+ a - Specific Helmholtz free energy, kJ/kg
+ cp - Specific isobaric heat capacity, kJ/kg·K
+ cv - Specific isochoric heat capacity, kJ/kg·K
+ cp_cv - Heat capacity ratio
+ w - Speed of sound, m/s
+ Z - Compression factor
+ fi - Fugacity coefficient
+ f - Fugacity, MPa
+ gamma - Isoentropic exponent
+ Hvap - Vaporization heat, kJ/kg
+ alfav - Thermal expansion coefficient (Volume expansivity), 1/K
+ kappa - Isothermal compressibility, 1/MPa
+ alfap - Relative pressure coefficient, 1/K
+ betap - Isothermal stress coefficient, kg/m³
+ betas - Isoentropic temperature-pressure coefficient
+ joule - Joule-Thomson coefficient, K/MPa
+ Gruneisen - Gruneisen parameter
+ virialB - Second virial coefficient, m³/kg
+ virialC - Third virial coefficient, m⁶/kg²
+ dpdT_rho - Derivatives, dp/dT at constant rho, MPa/K
+ dpdrho_T - Derivatives, dp/drho at constant T, MPa·m³/kg
+ drhodT_P - Derivatives, drho/dT at constant P, kg/m³·K
+ drhodP_T - Derivatives, drho/dP at constant T, kg/m³·MPa
+ dhdT_rho - Derivatives, dh/dT at constant rho, kJ/kg·K
+ dhdP_T - Isothermal throttling coefficient, kJ/kg·MPa
+ dhdT_P - Derivatives, dh/dT at constant P, kJ/kg·K
+ dhdrho_T - Derivatives, dh/drho at constant T, kJ·m³/kg²
+ dhdrho_P - Derivatives, dh/drho at constant P, kJ·m³/kg²
+ dhdP_rho - Derivatives, dh/dP at constant rho, kJ/kg·MPa
+ kt - Isothermal Expansion Coefficient
+ ks - Adiabatic Compressibility, 1/MPa
+ Ks - Adiabatic bulk modulus, MPa
+ Kt - Isothermal bulk modulus, MPa
+
+ Z_rho - (Z-1) over the density, m³/kg
+ IntP - Internal pressure
+ invT - Negative reciprocal temperature
+ hInput - Specific heat input, kJ/kg
+ mu - Dynamic viscosity, Pa·s
+ nu - Kinematic viscosity, m²/s
+ k - Thermal conductivity, W/m·K
+ sigma - Surface tension, N/m
+ alfa - Thermal diffusivity, m²/s
+ Pramdt - Prandtl number
+ epsilon - Dielectric constant
+ n - Refractive index
+
+ v0 - Ideal gas Specific volume, m³/kg
+ rho0 - Ideal gas Density, kg/m³
+ h0 - Ideal gas Specific enthalpy, kJ/kg
+ u0 - Ideal gas Specific internal energy, kJ/kg
+ s0 - Ideal gas Specific entropy, kJ/kg·K
+ a0 - Ideal gas Specific Helmholtz free energy, kJ/kg
+ g0 - Ideal gas Specific Gibbs free energy, kJ/kg
+ cp0 - Ideal gas Specific isobaric heat capacity, kJ/kg·K
+ cv0 - Ideal gas Specific isochoric heat capacity, kJ/kg·K
+ cp0_cv - Ideal gas Heat capacity ratio
+ gamma0 - Ideal gas Isoentropic exponent
+
+ """
+
+ CP = None
+ _surface = None
+ _vapor_Pressure = None
+ _liquid_Density = None
+ _vapor_Density = None
+
+ kwargs = {"T": 0.0,
+ "P": 0.0,
+ "rho": 0.0,
+ "v": 0.0,
+ "h": None,
+ "s": None,
+ "u": None,
+ "x": None,
+ "l": 0.5893}
+ status = 0
+ msg = "Undefined"
+
+ def __init__(self, **kwargs):
+ """Constructor, define common constant and initinialice kwargs"""
+ self.R = self._constants["R"]/self.M
+ self.Zc = self.Pc/self.rhoc/self.R/self.Tc
+ self.kwargs = MEoS.kwargs.copy()
+ self.__call__(**kwargs)
+
+ def __call__(self, **kwargs):
+ """Make instance callable to can add input parameter one to one"""
+ if kwargs.get("v", 0):
+ kwargs["rho"] = kwargs["v"]
+ del kwargs["v"]
+ self.kwargs.update(kwargs)
+
+ if self.calculable:
+ self.status = 1
+ self.calculo()
+ self.msg = ""
+
+ @property
+ def calculable(self):
+ """Check if inputs are enough to define state"""
+ self._mode = ""
+ if self.kwargs["T"] and self.kwargs["P"]:
+ self._mode = "TP"
+ elif self.kwargs["T"] and self.kwargs["rho"]:
+ self._mode = "Trho"
+ elif self.kwargs["T"] and self.kwargs["h"] is not None:
+ self._mode = "Th"
+ elif self.kwargs["T"] and self.kwargs["s"] is not None:
+ self._mode = "Ts"
+ elif self.kwargs["T"] and self.kwargs["u"] is not None:
+ self._mode = "Tu"
+ elif self.kwargs["P"] and self.kwargs["rho"]:
+ self._mode = "Prho"
+ elif self.kwargs["P"] and self.kwargs["h"] is not None:
+ self._mode = "Ph"
+ elif self.kwargs["P"] and self.kwargs["s"] is not None:
+ self._mode = "Ps"
+ elif self.kwargs["P"] and self.kwargs["u"] is not None:
+ self._mode = "Pu"
+ elif self.kwargs["rho"] and self.kwargs["h"] is not None:
+ self._mode = "rhoh"
+ elif self.kwargs["rho"] and self.kwargs["s"] is not None:
+ self._mode = "rhos"
+ elif self.kwargs["rho"] and self.kwargs["u"] is not None:
+ self._mode = "rhou"
+ elif self.kwargs["h"] is not None and self.kwargs["s"] is not None:
+ self._mode = "hs"
+ elif self.kwargs["h"] is not None and self.kwargs["u"] is not None:
+ self._mode = "hu"
+ elif self.kwargs["s"] is not None and self.kwargs["u"] is not None:
+ self._mode = "su"
+
+ elif self.kwargs["T"] and self.kwargs["x"] is not None:
+ self._mode = "Tx"
+ elif self.kwargs["P"] and self.kwargs["x"] is not None:
+ self._mode = "Px"
+ return bool(self._mode)
+
+ def calculo(self):
+ """Calculate procedure"""
+ T = self.kwargs["T"]
+ rho = self.kwargs["rho"]
+ P = self.kwargs["P"]
+ v = self.kwargs["v"]
+ s = self.kwargs["s"]
+ h = self.kwargs["h"]
+ u = self.kwargs["u"]
+ x = self.kwargs["x"]
+
+ self.R = self._constants["R"]/self.M
+
+ propiedades = None
+ if v and not rho:
+ rho = 1./v
+
+ if x is None:
+ # Method with iteration necessary to get x
+ if self._mode == "TP":
+ if T < self.Tc and P < self.Pc and \
+ self._Vapor_Pressure(T) < P:
+ rhoo = self._Liquid_Density(T)
+ elif T < self.Tc and P < self.Pc:
+ rhoo = self._Vapor_Density(T)
+ else:
+ rhoo = self.rhoc*3
+ rho = fsolve(lambda rho: self._Helmholtz(rho, T)["P"]-P*1000, rhoo)
+
+ elif self._mode == "Th":
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ hv = self._Helmholtz(rhov, T)["h"]
+ if h > hv:
+ rhoo = rhov
+ else:
+ rhoo = 1000
+ rho = fsolve(lambda rho: self._Helmholtz(rho, T)["h"]-h, rhoo)
+
+ elif self._mode == "Ts":
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ sv = self._Helmholtz(rhov, T)["s"]
+ if s > sv:
+ rhoo = rhov
+ else:
+ rhoo = 1000
+ rho = fsolve(lambda rho: self._Helmholtz(rho, T)["s"]-s, rhoo)
+
+ elif self._mode == "Tu":
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ Ps = self._Vapor_Pressure(T)
+ vapor = self._Helmholtz(rhov, T)
+ uv = vapor["h"]-Ps*vapor["v"]
+ if u > uv:
+ rhoo = rhov
+ else:
+ rhoo = 1000
+
+ def funcion(rho):
+ par = self._Helmholtz(rho, T)
+ return par["h"]-par["P"]*par["v"]-u
+ rho = fsolve(funcion, rhoo)
+
+ elif self._mode == "Prho":
+ T = fsolve(lambda T: self._Helmholtz(rho, T)["P"]-P*1000, 600)
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T[0] == 600 or rhov <= rho <= rhol:
+ def funcion(T):
+ rhol, rhov, Ps = self._saturation(T)
+ return Ps-P*1000
+ T = fsolve(funcion, 600)
+
+ elif self._mode == "Ph":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["P"]-P*1000, par["h"]-h
+ rho, T = fsolve(funcion, [1000, 300])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if rho == 1000 or rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return Ps-P*1000, vapor["h"]*x+liquido["h"]*(1-x)-h
+ rho, T = fsolve(funcion, [2., 500.])
+
+ elif self._mode == "Ps":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["P"]-P*1000, par["s"]-s
+ rho, T = fsolve(funcion, [2., 400])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if rho == 2. or rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return Ps-P*1000, vapor["s"]*x+liquido["s"]*(1-x)-s
+ rho, T = fsolve(funcion, [2., 500.])
+
+ elif self._mode == "Pu":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["h"]-par["P"]*par["v"]-u, par["P"]-P*1000
+ rho, T = fsolve(funcion, [1000, 600])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if rho == 1000 or rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ vu = vapor["h"]-Ps/rhov
+ lu = liquido["h"]-Ps/rhol
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return Ps-P*1000, vu*x+lu*(1-x)-u
+ rho, T = fsolve(funcion, [2., 500.])
+
+ elif self._mode == "rhoh":
+ f = lambda T: self._Helmholtz(rho, T)["h"]-h
+ T = fsolve(f, 600)
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T[0] == 600 or rhov <= rho <= rhol:
+ def funcion(T):
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vapor["h"]*x+liquido["h"]*(1-x)-h
+ T = fsolve(funcion, 500.)
+
+ elif self._mode == "rhos":
+ f = lambda T: self._Helmholtz(rho, T)["s"]-s
+ T = fsolve(f, 600)
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T[0] == 600 or rhov <= rho <= rhol:
+ def funcion(T):
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vapor["s"]*x+liquido["s"]*(1-x)-s
+ T = fsolve(funcion, 500.)
+
+ elif self._mode == "rhou":
+ def funcion(T):
+ par = self._Helmholtz(rho, T)
+ return par["h"]-par["P"]/1000*par["v"]-u
+ T = fsolve(funcion, 600)
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T[0] == 600 or rhov <= rho <= rhol:
+ def funcion(T):
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ vu = vapor["h"]-Ps/rhov
+ lu = liquido["h"]-Ps/rhol
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vu*x+lu*(1-x)-u
+ T = fsolve(funcion, 500.)
+
+ elif self._mode == "hs":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["h"]-h, par["s"]-s
+ rho, T = fsolve(funcion, [1000, 300])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vapor["h"]*x+liquido["h"]*(1-x)-h, vapor["s"]*x+liquido["s"]*(1-x)-s
+ rho, T = fsolve(funcion, [0.5, 400.])
+
+ elif self._mode == "hu":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["h"]-par["P"]/1000*par["v"]-u, par["h"]-h
+ rho, T = fsolve(funcion, [1000, 600])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T == 600 or rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ vu = vapor["h"]-Ps/rhov
+ lu = liquido["h"]-Ps/rhol
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vapor["h"]*x+liquido["h"]*(1-x)-h, vu*x+lu*(1-x)-u
+ rho, T = fsolve(funcion, [2., 500.])
+
+ elif self._mode == "su":
+ def funcion(parr):
+ par = self._Helmholtz(parr[0], parr[1])
+ return par["h"]-par["P"]/1000*par["v"]-u, par["s"]-s
+ rho, T = fsolve(funcion, [1000, 600])
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if T == 600 or rhov <= rho <= rhol:
+ def funcion(parr):
+ rho, T = parr
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ vu = vapor["h"]-Ps/rhov
+ lu = liquido["h"]-Ps/rhol
+ x = (1./rho-1/rhol)/(1/rhov-1/rhol)
+ return vapor["s"]*x+liquido["s"]*(1-x)-s, vu*x+lu*(1-x)-u
+ rho, T = fsolve(funcion, [2., 500.])
+
+ rho = float(rho)
+ T = float(T)
+ propiedades = self._Helmholtz(rho, T)
+ if T <= self.Tc:
+ rhol = self._Liquid_Density(T)
+ rhov = self._Vapor_Density(T)
+ if rhol > rho > rhov:
+ rhol, rhov, Ps = self._saturation(T)
+ x = (1/rho-1/rhol)/(1/rhov-1/rhol)
+ if x < 0:
+ x = 0
+ elif x > 1:
+ x = 1
+ P = Ps/1000
+ elif rho <= rhov:
+ x = 1
+ elif rho >= rhol:
+ x = 0
+
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+
+ elif T > self.Tc:
+ x = 1
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ if not P:
+ P = propiedades["P"]/1000.
+
+ elif self._mode == "Tx":
+ # Check input T in saturation range
+ if self.Tt > T or self.Tc < T:
+ raise ValueError("Wrong input values")
+
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ if x == 0:
+ propiedades = liquido
+ elif x == 1:
+ propiedades = vapor
+ P = Ps/1000.
+
+ elif self._mode == "Px":
+ # Iterate over saturation routine to get T
+ # FIXME: Too slow, it need find any other algorithm
+ def funcion(T):
+ rhol, rhov, Ps = self._saturation(T)
+ return Ps/1000-P
+ To = _TSat_P(P)
+ T = fsolve(funcion, To)[0]
+ rhol, rhov, Ps = self._saturation(T)
+ vapor = self._Helmholtz(rhov, T)
+ liquido = self._Helmholtz(rhol, T)
+ if x == 0:
+ propiedades = liquido
+ elif x == 1:
+ propiedades = vapor
+
+ self.T = T
+ self.Tr = T/self.Tc
+ self.P = P
+ self.Pr = self.P/self.Pc
+ self.x = x
+
+ self.Liquid = _fase()
+ self.Gas = _fase()
+ if x == 0:
+ # liquid phase
+ self.fill(self.Liquid, propiedades)
+ self.fill(self, propiedades)
+ elif x == 1:
+ # vapor phase
+ self.fill(self.Gas, propiedades)
+ self.fill(self, propiedades)
+ else:
+ self.fill(self.Liquid, liquido)
+ self.fill(self.Gas, vapor)
+
+ self.v = x*self.Gas.v+(1-x)*self.Liquid.v
+ self.rho = 1./self.v
+
+ self.h = x*self.Gas.h+(1-x)*self.Liquid.h
+ self.s = x*self.Gas.s+(1-x)*self.Liquid.s
+ self.u = x*self.Gas.u+(1-x)*self.Liquid.u
+ self.a = x*self.Gas.a+(1-x)*self.Liquid.a
+ self.g = x*self.Gas.g+(1-x)*self.Liquid.g
+
+ self.Z = x*self.Gas.Z+(1-x)*self.Liquid.Z
+ self.f = x*self.Gas.f+(1-x)*self.Liquid.f
+
+ self.Z_rho = x*self.Gas.Z_rho+(1-x)*self.Liquid.Z_rho
+ self.IntP = x*self.Gas.IntP+(1-x)*self.Liquid.IntP
+
+ # Calculate special properties useful only for one phase
+ if x < 1 and self.Tt <= T <= self.Tc:
+ self.sigma = self._Tension(T)
+ else:
+ self.sigma = None
+
+ if 0 < x < 1:
+ self.virialB = vapor["B"]/self.rhoc
+ self.virialC = vapor["C"]/self.rhoc**2
+ else:
+ self.virialB = propiedades["B"]/self.rhoc
+ self.virialC = propiedades["C"]/self.rhoc**2
+
+ if self.Tt <= T <= self.Tc:
+ self.Hvap = vapor["h"]-liquido["h"]
+ else:
+ self.Hvap = None
+ self.invT = -1/self.T
+
+ # Ideal properties
+ cp0 = self._prop0(self.rho, self.T)
+ self.v0 = cp0.v
+ self.rho0 = 1./self.v0
+ self.h0 = cp0.h
+ self.u0 = self.h0-self.P*self.v0
+ self.s0 = cp0.s
+ self.a0 = self.u0-self.T*self.s0
+ self.g0 = self.h0-self.T*self.s0
+ self.cp0 = cp0.cp
+ self.cv0 = cp0.cv
+ self.cp0_cv = self.cp0/self.cv0
+ self.gamma0 = -self.v0/self.P/1000*self.derivative("P", "v", "s", cp0)
+
+ def fill(self, fase, estado):
+ """Fill phase properties"""
+ fase.v = estado["v"]
+ fase.rho = 1/fase.v
+
+ fase.h = estado["h"]
+ fase.s = estado["s"]
+ fase.u = fase.h-self.P*1000*fase.v
+ fase.a = fase.u-self.T*fase.s
+ fase.g = fase.h-self.T*fase.s
+
+ fase.Z = self.P*fase.v/self.T/self.R*1e3
+ fase.fi = estado["fugacity"]
+ fase.f = fase.fi*self.P
+ fase.cp = estado["cp"]
+ fase.cv = estado["cv"]
+ fase.cp_cv = fase.cp/fase.cv
+ fase.w = estado["w"]
+
+ fase.alfap = estado["alfap"]
+ fase.betap = estado["betap"]
+
+ fase.joule = self.derivative("T", "P", "h", fase)*1e3
+ fase.Gruneisen = fase.v/fase.cv*self.derivative("P", "T", "v", fase)
+ fase.alfav = self.derivative("v", "T", "P", fase)/fase.v
+ fase.kappa = -self.derivative("v", "P", "T", fase)/fase.v*1e3
+ fase.betas = self.derivative("T", "P", "s", fase)
+
+ fase.gamma = -fase.v/self.P*self.derivative("P", "v", "s", fase)*1e-3
+ fase.kt = -fase.v/self.P*self.derivative("P", "v", "T", fase)*1e-3
+ fase.ks = -self.derivative("v", "P", "s", fase)/fase.v*1e3
+ fase.Kt = -fase.v*self.derivative("P", "v", "s", fase)*1e-3
+ fase.Ks = -fase.v*self.derivative("P", "v", "T", fase)*1e-3
+ fase.dhdT_rho = self.derivative("h", "T", "rho", fase)
+ fase.dhdT_P = self.derivative("h", "T", "P", fase)
+ fase.dhdP_T = self.derivative("h", "P", "T", fase)*1e3
+ fase.dhdP_rho = self.derivative("h", "P", "rho", fase)*1e3
+ fase.dhdrho_T = estado["dhdrho"]
+ fase.dhdrho_P = estado["dhdrho"]+fase.dhdT_rho/estado["drhodt"]
+ fase.dpdT_rho = self.derivative("P", "T", "rho", fase)*1e-3
+ fase.dpdrho_T = estado["dpdrho"]*1e-3
+ fase.drhodP_T = 1/estado["dpdrho"]*1e3
+ fase.drhodT_P = estado["drhodt"]
+
+ fase.Z_rho = (fase.Z-1)/fase.rho
+ fase.IntP = self.T*self.derivative("P", "T", "rho", fase)*1e-3-self.P
+ fase.hInput = fase.v*self.derivative("h", "v", "P", fase)
+
+ fase.mu = self._visco(fase.rho, self.T, fase)
+ fase.k = self._thermo(fase.rho, self.T, fase)
+ fase.nu = fase.mu/fase.rho
+ fase.alfa = fase.k/1000/fase.rho/fase.cp
+ fase.Prandt = fase.mu*fase.cp*1000/fase.k
+ if self.name == "water":
+ fase.epsilon = _Dielectric(fase.rho, self.T)
+ fase.n = _Refractive(fase.rho, self.T, self.kwargs["l"])
+ else:
+ fase.epsilon = None
+ fase.n = None
+
+ def _saturation(self, T):
+ """Akasaka (2008) "A Reliable and Useful Method to Determine the
+ Saturation State from Helmholtz Energy Equations of State", Journal of
+ Thermal Science and Technology, 3, 442-451
+ http://dx.doi.org/10.1299/jtst.3.442"""
+
+ rhoL = self._Liquid_Density(T)
+ rhoG = self._Vapor_Density(T)
+ g = 500.
+ erroro = 1e6
+ rholo = rhoL
+ rhogo = rhoG
+ contador = 0
+ while True:
+ contador += 1
+ deltaL = rhoL/self.rhoc
+ deltaG = rhoG/self.rhoc
+ liquido = self._Helmholtz(rhoL, T)
+ vapor = self._Helmholtz(rhoG, T)
+ Jl = deltaL*(1+deltaL*liquido["fird"])
+ Jv = deltaG*(1+deltaG*vapor["fird"])
+ Kl = deltaL*liquido["fird"]+liquido["fir"]+log(deltaL)
+ Kv = deltaG*vapor["fird"]+vapor["fir"]+log(deltaG)
+ Jdl = 1+2*deltaL*liquido["fird"]+deltaL**2*liquido["firdd"]
+ Jdv = 1+2*deltaG*vapor["fird"]+deltaG**2*vapor["firdd"]
+ Kdl = 2*liquido["fird"]+deltaL*liquido["firdd"]+1/deltaL
+ Kdv = 2*vapor["fird"]+deltaG*vapor["firdd"]+1/deltaG
+ Delta = Jdv*Kdl-Jdl*Kdv
+ error = abs(Kv-Kl)+abs(Jv-Jl)
+ if error < 1e-12 or contador > 100:
+ break
+ elif error > erroro:
+ rhoL = rholo
+ rhoG = rhogo
+ g = g*0.5
+ else:
+ erroro = error
+ rholo = rhoL
+ rhogo = rhoG
+ rhoL = rhoL+g/Delta*((Kv-Kl)*Jdv-(Jv-Jl)*Kdv)
+ rhoG = rhoG+g/Delta*((Kv-Kl)*Jdl-(Jv-Jl)*Kdl)
+ if error > 1e-3:
+ print("Iteration don´t converge, residual error %g" % error)
+
+ Ps = self.R*T*rhoL*rhoG/(rhoL-rhoG)*(liquido["fir"]-vapor["fir"]+log(deltaL/deltaG))
+ return rhoL, rhoG, Ps
+
+ def _Helmholtz(self, rho, T):
+ """Calculated properties, table 3 pag 10"""
+ rhoc = self._constants.get("rhoref", self.rhoc)
+ Tc = self._constants.get("Tref", self.Tc)
+ delta = rho/rhoc
+ tau = Tc/T
+ fio, fiot, fiott, fiod, fiodd, fiodt = self._phi0(tau, delta)
+ fir, firt, firtt, fird, firdd, firdt, firdtt, B, C = self._phir(tau, delta)
+
+ propiedades = {}
+ propiedades["fir"] = fir
+ propiedades["fird"] = fird
+ propiedades["firdd"] = firdd
+
+ propiedades["T"] = T
+ propiedades["P"] = (1+delta*fird)*self.R*T*rho
+ propiedades["v"] = 1./rho
+ propiedades["h"] = self.R*T*(1+tau*(fiot+firt)+delta*fird)
+ propiedades["s"] = self.R*(tau*(fiot+firt)-fio-fir)
+ propiedades["cv"] = -self.R*tau**2*(fiott+firtt)
+ propiedades["cp"] = self.R*(-tau**2*(fiott+firtt) +
+ (1+delta*fird-delta*tau*firdt)**2/(1+2*delta*fird+delta**2*firdd))
+ propiedades["w"] = (self.R*1000*T*(1+2*delta*fird+delta**2*firdd -
+ (1+delta*fird-delta*tau*firdt)**2/tau**2/(fiott+firtt)))**0.5
+ propiedades["alfap"] = (1-delta*tau*firdt/(1+delta*fird))/T
+ propiedades["betap"] = rho*(1+(delta*fird+delta**2*firdd)/(1+delta*fird))
+ propiedades["fugacity"] = exp(fir+delta*fird-log(1+delta*fird))
+ propiedades["B"] = B
+ propiedades["C"] = C
+ propiedades["dpdrho"] = self.R*T*(1+2*delta*fird+delta**2*firdd)
+ propiedades["drhodt"] = -rho*(1+delta*fird-delta*tau*firdt) / \
+ (T*(1+2*delta*fird+delta**2*firdd))
+ propiedades["dhdrho"] = self.R*T/rho * \
+ (tau*delta*(fiodt+firdt)+delta*fird+delta**2*firdd)
+# dbt=-phi11/rho/t
+# propiedades["cps"] = propiedades["cv"] Add cps from Argon pag.27
+
+ return propiedades
+
+ def _prop0(self, rho, T):
+ """Ideal gas properties"""
+ rhoc = self._constants.get("rhoref", self.rhoc)
+ Tc = self._constants.get("Tref", self.Tc)
+ delta = rho/rhoc
+ tau = Tc/T
+ fio, fiot, fiott, fiod, fiodd, fiodt = self._phi0(tau, delta)
+
+ propiedades = _fase()
+ propiedades.v = self.R*T/self.P/1000
+ propiedades.h = self.R*T*(1+tau*fiot)
+ propiedades.s = self.R*(tau*fiot-fio)
+ propiedades.cv = -self.R*tau**2*fiott
+ propiedades.cp = self.R*(-tau**2*fiott+1)
+ propiedades.alfap = 1/T
+ propiedades.betap = rho
+ return propiedades
+
+ def _phi0(self, tau, delta):
+ Fi0 = self.Fi0
+
+ fio = Fi0["ao_log"][0]*log(delta)+Fi0["ao_log"][1]*log(tau)
+ fiot = +Fi0["ao_log"][1]/tau
+ fiott = -Fi0["ao_log"][1]/tau**2
+
+ fiod = 1/delta
+ fiodd = -1/delta**2
+ fiodt = 0
+
+ for n, t in zip(Fi0["ao_pow"], Fi0["pow"]):
+ fio += n*tau**t
+ if t != 0:
+ fiot += t*n*tau**(t-1)
+ if t not in [0, 1]:
+ fiott += n*t*(t-1)*tau**(t-2)
+
+ for n, t in zip(Fi0["ao_exp"], Fi0["titao"]):
+ fio += n*log(1-exp(-tau*t))
+ fiot += n*t*((1-exp(-t*tau))**-1-1)
+ fiott -= n*t**2*exp(-t*tau)*(1-exp(-t*tau))**-2
+
+ return fio, fiot, fiott, fiod, fiodd, fiodt
+
+ def _phir(self, tau, delta):
+ delta_0 = 1e-200
+
+ fir = fird = firdd = firt = firtt = firdt = firdtt = B = C = 0
+
+ # Polinomial terms
+ nr1 = self._constants.get("nr1", [])
+ d1 = self._constants.get("d1", [])
+ t1 = self._constants.get("t1", [])
+ for n, d, t in zip(nr1, d1, t1):
+ fir += n*delta**d*tau**t
+ fird += n*d*delta**(d-1)*tau**t
+ firdd += n*d*(d-1)*delta**(d-2)*tau**t
+ firt += n*t*delta**d*tau**(t-1)
+ firtt += n*t*(t-1)*delta**d*tau**(t-2)
+ firdt += n*t*d*delta**(d-1)*tau**(t-1)
+ firdtt += n*t*d*(t-1)*delta**(d-1)*tau**(t-2)
+ B += n*d*delta_0**(d-1)*tau**t
+ C += n*d*(d-1)*delta_0**(d-2)*tau**t
+
+ # Exponential terms
+ nr2 = self._constants.get("nr2", [])
+ d2 = self._constants.get("d2", [])
+ g2 = self._constants.get("gamma2", [])
+ t2 = self._constants.get("t2", [])
+ c2 = self._constants.get("c2", [])
+ for n, d, g, t, c in zip(nr2, d2, g2, t2, c2):
+ fir += n*delta**d*tau**t*exp(-g*delta**c)
+ fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c)
+ firdd += n*exp(-g*delta**c)*delta**(d-2)*tau**t * \
+ ((d-g*c*delta**c)*(d-1-g*c*delta**c)-g**2*c**2*delta**c)
+ firt += n*t*delta**d*tau**(t-1)*exp(-g*delta**c)
+ firtt += n*t*(t-1)*delta**d*tau**(t-2)*exp(-g*delta**c)
+ firdt += n*t*delta**(d-1)*tau**(t-1)*(d-g*c*delta**c)*exp(-g*delta**c)
+ firdtt += n*t*(t-1)*delta**(d-1)*tau**(t-2)*(d-g*c*delta**c) * \
+ exp(-g*delta**c)
+ B += n*exp(-g*delta_0**c)*delta_0**(d-1)*tau**t*(d-g*c*delta_0**c)
+ C += n*exp(-g*delta_0**c)*(delta_0**(d-2)*tau**t *
+ ((d-g*c*delta_0**c)*(d-1-g*c*delta_0**c)-g**2*c**2*delta_0**c))
+
+ # Gaussian terms
+ nr3 = self._constants.get("nr3", [])
+ d3 = self._constants.get("d3", [])
+ t3 = self._constants.get("t3", [])
+ a3 = self._constants.get("alfa3", [])
+ e3 = self._constants.get("epsilon3", [])
+ b3 = self._constants.get("beta3", [])
+ g3 = self._constants.get("gamma3", [])
+ for i in range(len(nr3)):
+ exp1 = self._constants.get("exp1", [2]*len(nr3))
+ exp2 = self._constants.get("exp2", [2]*len(nr3))
+ fir += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i])
+ fird += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ (d3[i]/delta-2*a3[i]*(delta-e3[i]))
+ firdd += nr3[i]*tau**t3[i]*exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i] *
+ (tau-g3[i])**exp2[i])*(-2*a3[i]*delta**d3[i]+4*a3[i]**2 *
+ delta**d3[i]*(delta-e3[i])**exp1[i]-4*d3[i]*a3[i]*delta**2 *
+ (delta-e3[i])+d3[i]*2*delta)
+ firt += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ (t3[i]/tau-2*b3[i]*(tau-g3[i]))
+ firtt += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ ((t3[i]/tau-2*b3[i]*(tau-g3[i]))**exp2[i]-t3[i]/tau**2-2*b3[i])
+ firdt += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ (t3[i]/tau-2*b3[i]*(tau-g3[i]))*(d3[i]/delta-2*a3[i]*(delta-e3[i]))
+ firdtt += nr3[i]*delta**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ ((t3[i]/tau-2*b3[i]*(tau-g3[i]))**exp2[i]-t3[i]/tau**2-2*b3[i]) * \
+ (d3[i]/delta-2*a3[i]*(delta-e3[i]))
+ B += nr3[i]*delta_0**d3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta_0-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ (d3[i]/delta_0-2*a3[i]*(delta_0-e3[i]))
+ C += nr3[i]*tau**t3[i] * \
+ exp(-a3[i]*(delta_0-e3[i])**exp1[i]-b3[i]*(tau-g3[i])**exp2[i]) * \
+ (-2*a3[i]*delta_0**d3[i]+4*a3[i]**2*delta_0**d3[i] *
+ (delta_0-e3[i])**exp1[i]-4*d3[i]*a3[i]*delta_0**2*(delta_0-e3[i]) +
+ d3[i]*2*delta_0)
+
+ # Non analitic terms
+ nr4 = self._constants.get("nr4", [])
+ a4 = self._constants.get("a4", [])
+ b = self._constants.get("b4", [])
+ A = self._constants.get("A", [])
+ Bi = self._constants.get("B", [])
+ Ci = self._constants.get("C", [])
+ D = self._constants.get("D", [])
+ bt = self._constants.get("beta4", [])
+ for i in range(len(nr4)):
+ Tita = (1-tau)+A[i]*((delta-1)**2)**(0.5/bt[i])
+ F = exp(-Ci[i]*(delta-1)**2-D[i]*(tau-1)**2)
+ Fd = -2*Ci[i]*F*(delta-1)
+ Fdd = 2*Ci[i]*F*(2*Ci[i]*(delta-1)**2-1)
+ Ft = -2*D[i]*F*(tau-1)
+ Ftt = 2*D[i]*F*(2*D[i]*(tau-1)**2-1)
+ Fdt = 4*Ci[i]*D[i]*F*(delta-1)*(tau-1)
+ Fdtt = 4*Ci[i]*D[i]*F*(delta-1)*(2*D[i]*(tau-1)**2-1)
+
+ Delta = Tita**2+Bi[i]*((delta-1)**2)**a4[i]
+ Deltad = (delta-1)*(A[i]*Tita*2/bt[i]*((delta-1)**2)**(0.5/bt[i]-1) \
+ + 2*Bi[i]*a4[i]*((delta-1)**2)**(a4[i]-1))
+ if delta == 1:
+ Deltadd = 0
+ else:
+ Deltadd = Deltad/(delta-1)+(delta-1)**2 * \
+ (4*Bi[i]*a4[i]*(a4[i]-1)*((delta-1)**2)**(a4[i]-2) +
+ 2*A[i]**2/bt[i]**2*(((delta-1)**2)**(0.5/bt[i]-1))**2 +
+ A[i]*Tita*4/bt[i]*(0.5/bt[i]-1)*((delta-1)**2)**(0.5/bt[i]-2))
+
+ DeltaBd = b[i]*Delta**(b[i]-1)*Deltad
+ DeltaBdd = b[i]*(Delta**(b[i]-1)*Deltadd+(b[i]-1)*Delta**(b[i]-2)*Deltad**2)
+ DeltaBt = -2*Tita*b[i]*Delta**(b[i]-1)
+ DeltaBtt = 2*b[i]*Delta**(b[i]-1)+4*Tita**2*b[i]*(b[i]-1)*Delta**(b[i]-2)
+ DeltaBdt = -A[i]*b[i]*2/bt[i]*Delta**(b[i]-1)*(delta-1)*((delta-1)**2) ** \
+ (0.5/bt[i]-1)-2*Tita*b[i]*(b[i]-1)*Delta**(b[i]-2)*Deltad
+ DeltaBdtt = 2*b[i]*(b[i]-1)*Delta**(b[i]-2) * \
+ (Deltad*(1+2*Tita**2*(b[i]-2)/Delta)+4*Tita*A[i] *
+ (delta-1)/bt[i]*((delta-1)**2)**(0.5/bt[i]-1))
+
+ fir += nr4[i]*Delta**b[i]*delta*F
+ fird += nr4[i]*(Delta**b[i]*(F+delta*Fd)+DeltaBd*delta*F)
+ firdd += nr4[i]*(Delta**b[i]*(2*Fd+delta*Fdd)+2*DeltaBd *
+ (F+delta*Fd)+DeltaBdd*delta*F)
+ firt += nr4[i]*delta*(DeltaBt*F+Delta**b[i]*Ft)
+ firtt += nr4[i]*delta*(DeltaBtt*F+2*DeltaBt*Ft+Delta**b[i]*Ftt)
+ firdt += nr4[i]*(Delta**b[i]*(Ft+delta*Fdt)+delta*DeltaBd*Ft +
+ DeltaBt*(F+delta*Fd)+DeltaBdt*delta*F)
+ firdtt += nr4[i]*((DeltaBtt*F+2*DeltaBt*Ft+Delta**b[i]*Ftt) +
+ delta*(DeltaBdtt*F+DeltaBtt*Fd+2*DeltaBdt*Ft+2*DeltaBt*Fdt +
+ DeltaBt*Ftt+Delta**b[i]*Fdtt))
+
+ Tita_ = (1-tau)+A[i]*((delta_0-1)**2)**(0.5/bt[i])
+ Delta_ = Tita_**2+Bi[i]*((delta_0-1)**2)**a4[i]
+ Deltad_ = (delta_0-1)*(A[i]*Tita_*2/bt[i]*((delta_0-1)**2) **
+ (0.5/bt[i]-1)+2*Bi[i]*a4[i]*((delta_0-1)**2)**(a4[i]-1))
+ Deltadd_ = Deltad_/(delta_0-1)+(delta_0-1)**2 * \
+ (4*Bi[i]*a4[i]*(a4[i]-1)*((delta_0-1)**2)**(a4[i]-2)+2*A[i]**2 /
+ bt[i]**2*(((delta_0-1)**2)**(0.5/bt[i]-1))**2+A[i]*Tita_ *
+ 4/bt[i]*(0.5/bt[i]-1)*((delta_0-1)**2)**(0.5/bt[i]-2))
+ DeltaBd_ = b[i]*Delta_**(b[i]-1)*Deltad_
+ DeltaBdd_ = b[i]*(Delta_**(b[i]-1)*Deltadd_ +
+ (b[i]-1)*Delta_**(b[i]-2)*Deltad_**2)
+ F_ = exp(-Ci[i]*(delta_0-1)**2-D[i]*(tau-1)**2)
+ Fd_ = -2*Ci[i]*F_*(delta_0-1)
+ Fdd_ = 2*Ci[i]*F_*(2*Ci[i]*(delta_0-1)**2-1)
+
+ B += nr4[i]*(Delta_**b[i]*(F_+delta_0*Fd_) +
+ DeltaBd_*delta_0*F_)
+ C += nr4[i]*(Delta_**b[i]*(2*Fd_+delta_0*Fdd_) +
+ 2*DeltaBd_*(F_+delta_0*Fd_) +
+ DeltaBdd_*delta_0*F_)
+
+ return fir, firt, firtt, fird, firdd, firdt, firdtt, B, C
+
+ def derivative(self, z, x, y, fase):
+ """Calculate generic partial derivative: (δz/δx)y
+ where x, y, z can be: P, T, v, u, h, s, g, a"""
+ dT = {"P": self.P*1000*fase.alfap,
+ "T": 1,
+ "v": 0,
+ "rho": 0,
+ "u": fase.cv,
+ "h": fase.cv+self.P*1000*fase.v*fase.alfap,
+ "s": fase.cv/self.T,
+ "g": self.P*1000*fase.v*fase.alfap-fase.s,
+ "a": -fase.s}
+ dv = {"P": -self.P*1000*fase.betap,
+ "T": 0,
+ "v": 1,
+ "rho": -1,
+ "u": self.P*1000*(self.T*fase.alfap-1),
+ "h": self.P*1000*(self.T*fase.alfap-fase.v*fase.betap),
+ "s": self.P*1000*fase.alfap,
+ "g": -self.P*1000*fase.v*fase.betap,
+ "a": -self.P*1000}
+ return (dv[z]*dT[y]-dT[z]*dv[y])/(dv[x]*dT[y]-dT[x]*dv[y])
+
+ def _Vapor_Pressure(self, T):
+ eq = self._vapor_Pressure["eq"]
+ Tita = 1-T/self.Tc
+ if eq in [2, 4, 6]:
+ Tita = Tita**0.5
+ suma = sum([n*Tita**x for n, x in zip(
+ self._vapor_Pressure["ao"], self._vapor_Pressure["exp"])])
+ if eq in [1, 2]:
+ Pr = suma+1
+ elif eq in [3, 4]:
+ Pr = exp(suma)
+ else:
+ Pr = exp(self.Tc/T*suma)
+ Pv = Pr*self.Pc
+ return Pv
+
+ def _Liquid_Density(self, T=None):
+ if not T:
+ T = self.T
+ eq = self._liquid_Density["eq"]
+ Tita = 1-T/self.Tc
+ if eq in [2, 4, 6]:
+ Tita = Tita**(1./3)
+ suma = sum([n*Tita**x for n, x in zip(
+ self._liquid_Density["ao"], self._liquid_Density["exp"])])
+ if eq in [1, 2]:
+ Pr = suma+1
+ elif eq in [3, 4]:
+ Pr = exp(suma)
+ else:
+ Pr = exp(self.Tc/T*suma)
+ rho = Pr*self.rhoc
+ return rho
+
+ def _Vapor_Density(self, T=None):
+ eq = self._vapor_Density["eq"]
+ Tita = 1-T/self.Tc
+ if eq in [2, 4, 6]:
+ Tita = Tita**(1./3)
+ suma = sum([n*Tita**x for n, x in zip(
+ self._vapor_Density["ao"], self._vapor_Density["exp"])])
+ if eq in [1, 2]:
+ Pr = suma+1
+ elif eq in [3, 4]:
+ Pr = exp(suma)
+ else:
+ Pr = exp(self.Tc/T*suma)
+ rho = Pr*self.rhoc
+ return rho
+
+ def _Tension(self, T):
+ """Equation for the surface tension"""
+ tau = 1-T/self.Tc
+ tension = 0
+ for sigma, n in zip(self._surface["sigma"],
+ self._surface["exp"]):
+ tension += sigma*tau**n
+ return tension
+
+
+class IAPWS95(MEoS):
+ """Multiparameter equation of state for water (including IAPWS95)
+
+ >>> water=IAPWS95(T=300, rho=996.5560)
+ >>> print("%0.10f %0.8f %0.5f %0.9f" % (water.P, water.cv, water.w, water.s))
+ 0.0992418350 4.13018112 1501.51914 0.393062643
+
+ >>> water=IAPWS95(T=500, rho=0.435)
+ >>> print("%0.10f %0.8f %0.5f %0.9f" % (water.P, water.cv, water.w, water.s))
+ 0.0999679423 1.50817541 548.31425 7.944882714
+
+ >>> water=IAPWS95(T=900., P=700)
+ >>> print("%0.4f %0.8f %0.5f %0.8f" % (water.rho, water.cv, water.w, water.s))
+ 870.7690 2.66422350 2019.33608 4.17223802
+
+ >>> water=IAPWS95(T=300., P=0.1)
+ >>> print("%0.2f %0.5f %0.2f %0.2f %0.5f %0.4f %0.1f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.cp, water.w, water.virialB))
+ 300.00 0.10000 996.56 112.65 0.39306 4.1806 1501.5 -0.066682
+
+ >>> water=IAPWS95(T=500., P=0.1)
+ >>> print("%0.2f %0.5f %0.5f %0.1f %0.4f %0.4f %0.2f %0.7f" % (water.T, water.P, water.rho, water.h, water.s, water.cp, water.w, water.virialB))
+ 500.00 0.10000 0.43514 2928.6 7.9447 1.9813 548.31 -0.0094137
+
+ >>> water=IAPWS95(T=450., x=0.5)
+ >>> print("%0.2f %0.5f %0.4f %0.1f %0.4f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.virialB))
+ 450.00 0.93220 9.5723 1761.8 4.3589 -0.013028
+
+ >>> water=IAPWS95(P=1.5, rho=1000.)
+ >>> print("%0.2f %0.4f %0.1f %0.3f %0.5f %0.4f %0.1f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.cp, water.w, water.virialB))
+ 286.44 1.5000 1000.0 57.253 0.19931 4.1855 1462.1 -0.085566
+
+ >>> water=IAPWS95(h=3000, s=8.)
+ >>> print("%0.2f %0.5f %0.5f %0.1f %0.4f %0.4f %0.2f %0.7f" % (water.T, water.P, water.rho, water.h, water.s, water.cp, water.w, water.virialB))
+ 536.24 0.11970 0.48547 3000.0 8.0000 1.9984 567.04 -0.0076606
+
+ >>> water=IAPWS95(h=150, s=0.4)
+ >>> print("%0.2f %0.5f %0.2f %0.2f %0.5f %0.4f %0.1f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.cp, water.w, water.virialB))
+ 301.27 35.50549 1011.48 150.00 0.40000 4.0932 1564.1 -0.065238
+
+ >>> water=IAPWS95(T=450., rho=300)
+ >>> print("%0.2f %0.5f %0.2f %0.2f %0.4f %0.6f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.x, water.virialB))
+ 450.00 0.93220 300.00 770.82 2.1568 0.010693 -0.013028
+
+ >>> water=IAPWS95(rho=300., P=0.1)
+ >>> print("%0.2f %0.5f %0.2f %0.2f %0.4f %0.7f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.x, water.virialB))
+ 372.76 0.10000 300.00 420.56 1.3110 0.0013528 -0.025144
+
+ >>> water=IAPWS95(h=1500., P=0.1)
+ >>> print("%0.2f %0.5f %0.4f %0.1f %0.4f %0.5f %0.6f" % (water.T, water.P, water.rho, water.h, water.s, water.x, water.virialB))
+ 372.76 0.10000 1.2303 1500.0 4.2068 0.47952 -0.025144
+
+ >>> water=IAPWS95(s=5., P=3.5)
+ >>> print("%0.2f %0.4f %0.3f %0.1f %0.4f %0.5f %0.7f" % (water.T, water.P, water.rho, water.h, water.s, water.x, water.virialB))
+ 515.71 3.5000 25.912 2222.8 5.0000 0.66921 -0.0085877
+
+ >>> water=IAPWS95(T=500., u=900)
+ >>> print("%0.2f %0.2f %0.2f %0.2f %0.1f %0.4f %0.4f %0.1f %0.7f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.cp, water.w, water.virialB))
+ 500.00 108.21 903.62 900.00 1019.8 2.4271 4.1751 1576.0 -0.0094137
+
+ >>> water=IAPWS95(P=0.3, u=1550.)
+ >>> print("%0.2f %0.5f %0.4f %0.1f %0.1f %0.4f %0.5f %0.6f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 406.67 0.30000 3.3029 1550.0 1640.8 4.3260 0.49893 -0.018263
+
+ >>> water=IAPWS95(rho=300, h=1000.)
+ >>> print("%0.2f %0.4f %0.2f %0.2f %0.1f %0.4f %0.6f %0.7f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 494.92 2.3991 300.00 992.00 1000.0 2.6315 0.026071 -0.0097064
+
+ >>> water=IAPWS95(rho=30, s=8.)
+ >>> print("%0.2f %0.3f %0.3f %0.1f %0.1f %0.4f %0.4f %0.2f %0.9f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.cp, water.w, water.virialB))
+ 1562.42 21.671 30.000 4628.5 5350.9 8.0000 2.7190 943.53 0.000047165
+
+ >>> water=IAPWS95(rho=30, s=4.)
+ >>> print("%0.2f %0.4f %0.3f %0.1f %0.1f %0.4f %0.5f %0.7f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 495.00 2.4029 30.000 1597.3 1677.4 4.0000 0.39218 -0.0097015
+
+ >>> water=IAPWS95(rho=300, u=1000.)
+ >>> print("%0.2f %0.4f %0.3f %0.1f %0.1f %0.4f %0.5f %0.7f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 496.44 2.4691 300.000 1000.0 1008.2 2.6476 0.02680 -0.0096173
+
+ >>> water=IAPWS95(s=3., h=1000.)
+ >>> print("%0.2f %0.6f %0.5f %0.2f %0.1f %0.4f %0.5f %0.6f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 345.73 0.034850 0.73526 952.60 1000.0 3.0000 0.29920 -0.034124
+
+ >>> water=IAPWS95(u=995., h=1000.)
+ >>> print("%0.2f %0.4f %0.2f %0.2f %0.1f %0.4f %0.5f %0.6f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 501.89 2.7329 546.58 995.00 1000.0 2.6298 0.00866 -0.009308
+
+ >>> water=IAPWS95(u=1000., s=3.)
+ >>> print("%0.2f %0.6f %0.5f %0.2f %0.1f %0.4f %0.5f %0.6f" % (water.T, water.P, water.rho, water.u, water.h, water.s, water.x, water.virialB))
+ 371.24 0.094712 1.99072 1000.00 1047.6 3.0000 0.28144 -0.025543
+
+ """
+ name = "water"
+ CASNumber = "7732-18-5"
+ formula = "H2O"
+ synonym = "R-718"
+ Tc = 647.096
+ rhoc = 322.
+ Pc = 22.064
+ M = 18.015268 # g/mol
+ Tt = 273.16
+ Tb = 373.1243
+ f_acent = 0.3443
+ momentoDipolar = 1.855
+
+ Fi0 = {"ao_log": [1, 3.00632],
+ "pow": [0, 1],
+ "ao_pow": [-8.3204464837497, 6.6832105275932],
+ "ao_exp": [0.012436, 0.97315, 1.2795, 0.96956, 0.24873],
+ "titao": [1.28728967, 3.53734222, 7.74073708, 9.24437796, 27.5075105]}
+
+ _constants = {
+ "R": 8.314371357587,
+
+ "nr1": [0.12533547935523e-1, 0.78957634722828e1, -0.87803203303561e1,
+ 0.31802509345418, -0.26145533859358, -0.78199751687981e-2,
+ 0.88089493102134e-2],
+ "d1": [1, 1, 1, 2, 2, 3, 4],
+ "t1": [-0.5, 0.875, 1, 0.5, 0.75, 0.375, 1],
+
+ "nr2": [-0.66856572307965, 0.20433810950965, -0.66212605039687e-4,
+ -0.19232721156002, -0.25709043003438, 0.16074868486251,
+ -0.4009282892587e-1, 0.39343422603254e-6, -0.75941377088144e-5,
+ 0.56250979351888e-3, -0.15608652257135e-4, 0.11537996422951e-8,
+ 0.36582165144204e-6, -0.13251180074668e-11, -0.62639586912454e-9,
+ -0.10793600908932, 0.17611491008752e-1, 0.22132295167546,
+ -0.40247669763528, 0.58083399985759, 0.49969146990806e-2,
+ -0.31358700712549e-1, -0.74315929710341, 0.47807329915480,
+ 0.20527940895948e-1, -0.13636435110343, 0.14180634400617e-1,
+ 0.83326504880713e-2, -0.29052336009585e-1, 0.38615085574206e-1,
+ -0.20393486513704e-1, -0.16554050063734e-2, 0.19955571979541e-2,
+ 0.15870308324157e-3, -0.16388568342530e-4, 0.43613615723811e-1,
+ 0.34994005463765e-1, -0.76788197844621e-1, 0.22446277332006e-1,
+ -0.62689710414685e-4, -0.55711118565645e-9, -0.19905718354408,
+ 0.31777497330738, -0.11841182425981],
+ "c2": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 6, 6,
+ 6, 6],
+ "d2": [1, 1, 1, 2, 2, 3, 4, 4, 5, 7, 9, 10, 11, 13, 15, 1, 2, 2, 2, 3,
+ 4, 4, 4, 5, 6, 6, 7, 9, 9, 9, 9, 9, 10, 10, 12, 3, 4, 4, 5, 14,
+ 3, 6, 6, 6],
+ "t2": [4, 6, 12, 1, 5, 4, 2, 13, 9, 3, 4, 11, 4, 13, 1, 7, 1, 9, 10,
+ 10, 3, 7, 10, 10, 6, 10, 10, 1, 2, 3, 4, 8, 6, 9, 8, 16, 22, 23,
+ 23, 10, 50, 44, 46, 50],
+ "gamma2": [1]*44,
+
+ "nr3": [-0.31306260323435e2, 0.31546140237781e2, -0.25213154341695e4],
+ "d3": [3]*3,
+ "t3": [0, 1, 4],
+ "alfa3": [20]*3,
+ "beta3": [150, 150, 250],
+ "gamma3": [1.21, 1.21, 1.25],
+ "epsilon3": [1.]*3,
+
+ "nr4": [-0.14874640856724, 0.31806110878444],
+ "a4": [3.5, 3.5],
+ "b4": [0.85, 0.95],
+ "B": [0.2, 0.2],
+ "C": [28, 32],
+ "D": [700, 800],
+ "A": [0.32, .32],
+ "beta4": [0.3, 0.3]}
+
+ _surface = {"sigma": [0.2358, -0.147375], "exp": [1.256, 2.256]}
+ _vapor_Pressure = {
+ "eq": 6,
+ "ao": [-7.85951783, 1.84408259, -11.7866497, 22.6807411, -15.9618719,
+ 1.80122502],
+ "exp": [2, 3, 6, 7, 8, 15]}
+ _liquid_Density = {
+ "eq": 2,
+ "ao": [1.99274064, 1.09965342, -0.510839303, -1.75493479, -45.5170352,
+ -6.74694450e5],
+ "exp": [1, 2, 5, 16, 43, 110]}
+ _vapor_Density = {
+ "eq": 4,
+ "ao": [-2.0315024, -2.6830294, -5.38626492, -17.2991605, -44.7586581,
+ -63.9201063],
+ "exp": [1, 2, 4, 9, 18.5, 35.5]}
+
+ def _visco(self, rho, T, fase):
+ ref = IAPWS95()
+ estado = ref._Helmholtz(rho, 1.5*647.096)
+ drho = 1/estado["dpdrho"]*1e3
+ return _Viscosity(rho, T, fase, drho)
+
+ def _thermo(self, rho, T, fase):
+ ref = IAPWS95()
+ estado = ref._Helmholtz(rho, 1.5*647.096)
+ drho = 1/estado["dpdrho"]*1e3
+ return _ThCond(rho, T, fase, drho)
+
+
+class IAPWS95_PT(IAPWS95):
+ """Derivated class for direct P and T input"""
+ def __init__(self, P, T):
+ IAPWS95.__init__(self, T=T, P=P)
+
+
+class IAPWS95_Ph(IAPWS95):
+ """Derivated class for direct P and h input"""
+ def __init__(self, P, h):
+ IAPWS95.__init__(self, P=P, h=h)
+
+
+class IAPWS95_Ps(IAPWS95):
+ """Derivated class for direct P and s input"""
+ def __init__(self, P, s):
+ IAPWS95.__init__(self, P=P, s=s)
+
+
+class IAPWS95_Pv(IAPWS95):
+ """Derivated class for direct P and v input"""
+ def __init__(self, P, v):
+ IAPWS95.__init__(self, P=P, v=v)
+
+
+class IAPWS95_Tx(IAPWS95):
+ """Derivated class for direct T and x input"""
+ def __init__(self, T, x):
+ IAPWS95.__init__(self, T=T, x=x)
+
+
+class D2O(MEoS):
+ """Multiparameter equation of state for heavy water
+
+ >>> water=D2O(T=300, rho=996.5560)
+ >>> print("%0.10f %0.8f %0.5f" % (water.P, water.Liquid.cv, water.Liquid.w))
+ 0.0030675947 4.21191157 5332.04871
+ """
+ name = "heavy water"
+ CASNumber = "7789-20-0"
+ formula = "D2O"
+ synonym = "deuterium oxide"
+ Tc = 643.847
+ rhoc = 356.0
+ Pc = 21.671
+ M = 20.027508 # g/mol
+ Tt = 276.97
+ Tb = 374.563
+ f_acent = 0.364
+ momentoDipolar = 1.9
+
+ Fi0 = {'ao_log': [1, 2.9176485],
+ 'ao_pow': [-5.60420745, 5.4495718, 0.100195196505025,
+ -0.2844660508898171, 0.06437609920676933, -0.005436994367359454],
+ 'pow': [0, 1, -1.0, -2.0, -3.0, -4.0],
+ 'ao_exp': [], 'titao': []}
+
+ _constants = {
+ "R": 8.3143565,
+ "rhoref": 358.,
+
+ "nr1": [-0.384820628204e3, 0.108213047259e4, -0.110768260635e4,
+ 0.164668954246e4, -0.137959852228e4, 0.598964185629e3,
+ -0.100451752702e3, 0.419192736351e3, -0.107279987867e4,
+ 0.653852283544e3, -0.984305985655e3, 0.845444459339e3,
+ -0.376799930490e3, 0.644512590492e2, -0.214911115714e3,
+ 0.531113962967e3, -0.135454224420e3, 0.202814416558e3,
+ -0.178293865031e3, 0.818739394970e2, -0.143312594493e2,
+ 0.651202383207e2, -0.171227351208e3, 0.100859921516e2,
+ -0.144684680657e2, 0.128871134847e2, -0.610605957134e1,
+ 0.109663804408e1, -0.115734899702e2, 0.374970075409e2,
+ 0.897967147669, -0.527005883203e1, 0.438084681795e-1,
+ 0.406772082680, -0.965258571044e-2, -0.119044600379e-1],
+ "d1": [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],
+ "t1": [0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6,
+ 0, 1, 2, 3, 4, 5, 6, 0, 1, 0, 1, 0, 1, 0, 1],
+
+ "nr2": [0.382589102341e3, -0.106406466204e4, 0.105544952919e4,
+ -0.157579942855e4, 0.132703387531e4, -0.579348879870e3,
+ 0.974163902526e2, 0.286799294226e3, -0.127543020847e4,
+ 0.275802674911e4, -0.381284331492e4, 0.293755152012e4,
+ -0.117858249946e4, 0.186261198012e3],
+ "c2": [1]*14,
+ "d2": [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2],
+ "t2": [0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6],
+ "gamma2": [1.5394]*14}
+
+ _surface = {"sigma": [0.238, -0.152082], "exp": [1.25, 2.25]}
+ _vapor_Pressure = {
+ "eq": 5,
+ "ao": [-0.80236e1, 0.23957e1, -0.42639e2, 0.99569e2, -0.62135e2],
+ "exp": [1.0, 1.5, 2.75, 3.0, 3.2]}
+ _liquid_Density = {
+ "eq": 1,
+ "ao": [0.26406e1, 0.97090e1, -0.18058e2, 0.87202e1, -0.74487e1],
+ "exp": [0.3678, 1.9, 2.2, 2.63, 7.3]}
+ _vapor_Density = {
+ "eq": 3,
+ "ao": [-0.37651e1, -0.38673e2, 0.73024e2, -0.13251e3, 0.75235e2, -0.70412e2],
+ "exp": [0.409, 1.766, 2.24, 3.04, 3.42, 6.9]}
+
+ @classmethod
+ def _visco(cls, rho, T, fase=None):
+ Tr = T/643.847
+ rhor = rho/358.0
+
+ no = [1.0, 0.940695, 0.578377, -0.202044]
+ fi0 = Tr**0.5/sum([n/Tr**i for i, n in enumerate(no)])
+
+ Li = [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 0, 1, 2, 5, 0, 1, 2, 3, 0, 1, 3,
+ 5, 0, 1, 5, 3]
+ Lj = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,
+ 4, 5, 5, 5, 6]
+ Lij = [0.4864192, -0.2448372, -0.8702035, 0.8716056, -1.051126,
+ 0.3458395, 0.3509007, 1.315436, 1.297752, 1.353448, -0.2847572,
+ -1.037026, -1.287846, -0.02148229, 0.07013759, 0.4660127,
+ 0.2292075, -0.4857462, 0.01641220, -0.02884911, 0.1607171,
+ -0.009603846, -0.01163815, -0.008239587, 0.004559914, -0.003886659]
+
+ array = [lij*(1./Tr-1)**i*(rhor-1)**j for i, j, lij in zip(Li, Lj, Lij)]
+ fi1 = exp(rhor*sum(array))
+
+ return 55.2651e-6*fi0*fi1
+
+ @classmethod
+ def _thermo(cls, rho, T, fase=None):
+ rhor = rho/358
+ Tr = T/643.847
+ tau = Tr/(abs(Tr-1.1)+1.1)
+
+ no = [1.0, 37.3223, 22.5485, 13.0465, 0.0, -2.60735]
+ Lo = sum([Li*Tr**i for i, Li in enumerate(no)])
+
+ nr = [483.656, -191.039, 73.0358, -7.57467]
+ Lr = -167.31*(1-exp(-2.506*rhor))+sum([Li*rhor**(i+1) for i, Li in enumerate(nr)])
+
+ f1 = exp(0.144847*Tr-5.64493*Tr**2)
+ f2 = exp(-2.8*(rhor-1)**2)-0.080738543*exp(-17.943*(rhor-0.125698)**2)
+ f3 = 1+exp(60*(tau-1)+20)
+ f4 = 1+exp(100*(tau-1)+15)
+ Lc = 35429.6*f1*f2*(1+f2**2*(5e9*f1**4/f3+3.5*f2/f4))
+
+ Ll = -741.112*f1**1.2*(1-exp(-(rhor/2.5)**10))
+
+ return 0.742128e-3*(Lo+Lr+Lc+Ll)
+
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
diff --git a/iapws/iapws97.py b/iapws/iapws97.py
new file mode 100644
index 0000000..36c03df
--- /dev/null
+++ b/iapws/iapws97.py
@@ -0,0 +1,3086 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"IAPWS-IF97 Steam Tables implementation"
+
+from __future__ import division
+from math import sqrt, log, exp
+
+from scipy.optimize import fsolve
+
+from _iapws import M, R, Tc, Pc, rhoc, Tt, Pt, Tb, Dipole, f_acent, _fase
+from _iapws import _Viscosity, _ThCond, _Tension, _Dielectric, _Refractive
+
+
+sc = 4.41202148223476 # Critic entropy
+# Pmin = _PSat_T(273.15) # Minimum pressure
+Pmin = 0.000611212677444
+# Ps_623 = _PSat_T(623.15) # P Saturation at 623.15 K, boundary region 1-3
+Ps_623 = 16.5291642526
+
+
+# Boundary Region1-Region2
+def _h13_s(s):
+ """Define the boundary between Region 1 and 3, h=f(s)
+
+ >>> "%.6f" % _h13_s(3.7)
+ '1632.525047'
+ >>> "%.6f" % _h13_s(3.5)
+ '1566.104611'
+ """
+ sigma = s/3.8
+ I = [0, 1, 1, 3, 5, 6]
+ J = [0, -2, 2, -12, -4, -3]
+ n = [0.913965547600543, -0.430944856041991e-4, 0.603235694765419e2,
+ 0.117518273082168e-17, 0.220000904781292, -0.690815545851641e2]
+
+ suma = 0
+ for i in range(6):
+ suma += n[i] * (sigma-0.884)**I[i] * (sigma-0.864)**J[i]
+ return 1700 * suma
+
+
+# Boundary Region2-Region3
+def _P23_T(T):
+ """Define the boundary between Region 2 and 3, P=f(T)
+
+ >>> "%.8f" % _P23_T(623.15)
+ '16.52916425'
+ """
+ n = [0.34805185628969e3, -0.11671859879975e1, 0.10192970039326e-2]
+ return n[0]+n[1]*T+n[2]*T**2
+
+
+def _t_P(P):
+ """Define the boundary between Region 2 and 3, T=f(P)
+
+ >>> "%.2f" % _t_P(16.52916425)
+ '623.15'
+ """
+ n = [0.10192970039326e-2, 0.57254459862746e3, 0.1391883977870e2]
+ return n[1]+((P-n[2])/n[0])**0.5
+
+
+def _t_hs(h, s):
+ """Define the boundary between Region 2 and 3, T=f(h,s)
+
+ >>> "%.7f" % _t_hs(2600, 5.1)
+ '713.5259364'
+ >>> "%.7f" % _t_hs(2800, 5.2)
+ '817.6202120'
+ """
+ nu = h/3000
+ sigma = s/5.3
+ I = [-12, -10, -8, -4, -3, -2, -2, -2, -2, 0, 1, 1, 1, 3, 3, 5, 6, 6, 8, 8,
+ 8, 12, 12, 14, 14]
+ J = [10, 8, 3, 4, 3, -6, 2, 3, 4, 0, -3, -2, 10, -2, -1, -5, -6, -3, -8,
+ -2, -1, -12, -1, -12, 1]
+ n = [0.629096260829810e-3, -0.823453502583165e-3, 0.515446951519474e-7,
+ -0.117565945784945e1, 0.348519684726192e1, -0.507837382408313e-11,
+ -0.284637670005479e1, -0.236092263939673e1, 0.601492324973779e1,
+ 0.148039650824546e1, 0.360075182221907e-3, -0.126700045009952e-1,
+ -0.122184332521413e7, 0.149276502463272, 0.698733471798484,
+ -0.252207040114321e-1, 0.147151930985213e-1, -0.108618917681849e1,
+ -0.936875039816322e-3, 0.819877897570217e2, -0.182041861521835e3,
+ 0.261907376402688e-5, -0.291626417025961e5, 0.140660774926165e-4,
+ 0.783237062349385e7]
+
+ suma = 0
+ for i in range(25):
+ suma += n[i]*(nu-0.727)**I[i]*(sigma-0.864)**J[i]
+ return 900*suma
+
+
+# Saturated line
+def _PSat_T(T):
+ """Define the saturated line, P=f(T)
+
+ >>> "%.8f" % _PSat_T(500)
+ '2.63889776'
+ """
+ if T < 273.15:
+ T = 273.15
+ elif T > Tc:
+ T = Tc
+ n = [0, 0.11670521452767E+04, -0.72421316703206E+06, -0.17073846940092E+02,
+ 0.12020824702470E+05, -0.32325550322333E+07, 0.14915108613530E+02,
+ -0.48232657361591E+04, 0.40511340542057E+06, -0.23855557567849E+00,
+ 0.65017534844798E+03]
+ tita = T+n[9]/(T-n[10])
+ A = tita**2+n[1]*tita+n[2]
+ B = n[3]*tita**2+n[4]*tita+n[5]
+ C = n[6]*tita**2+n[7]*tita+n[8]
+ return (2*C/(-B+(B**2-4*A*C)**0.5))**4
+
+
+def _TSat_P(P):
+ """Define the saturated line, T=f(P)
+
+ >>> "%.6f" % _TSat_P(10)
+ '584.149488'
+ """
+ if P < 611.212677/1e6:
+ P = 611.212677/1e6
+ elif P > 22.064:
+ P = 22.064
+ n = [0, 0.11670521452767E+04, -0.72421316703206E+06, -0.17073846940092E+02,
+ 0.12020824702470E+05, -0.32325550322333E+07, 0.14915108613530E+02,
+ -0.48232657361591E+04, 0.40511340542057E+06, -0.23855557567849E+00,
+ 0.65017534844798E+03]
+ beta = P**0.25
+ E = beta**2+n[3]*beta+n[6]
+ F = n[1]*beta**2+n[4]*beta+n[7]
+ G = n[2]*beta**2+n[5]*beta+n[8]
+ D = 2*G/(-F-(F**2-4*E*G)**0.5)
+ return (n[10]+D-((n[10]+D)**2-4*(n[9]+n[10]*D))**0.5)/2
+
+
+def _PSat_h(h):
+ """Define the saturated line, P=f(h) for region 3
+
+ >>> "%.8f" % _PSat_h(1700)
+ '17.24175718'
+ >>> "%.8f" % _PSat_h(2400)
+ '20.18090839'
+ """
+ hmin_Ps3 = _Region1(623.15, _PSat_T(623.15))["h"]
+ hmax_Ps3 = _Region2(623.15, _PSat_T(623.15))["h"]
+ if h < hmin_Ps3:
+ h = hmin_Ps3
+ if h > hmax_Ps3:
+ h = hmax_Ps3
+ nu = h/2600
+ I = [0, 1, 1, 1, 1, 5, 7, 8, 14, 20, 22, 24, 28, 36]
+ J = [0, 1, 3, 4, 36, 3, 0, 24, 16, 16, 3, 18, 8, 24]
+ n = [0.600073641753024, -0.936203654849857e1, 0.246590798594147e2,
+ -0.107014222858224e3, -0.915821315805768e14, -0.862332011700662e4,
+ -0.235837344740032e2, 0.252304969384128e18, -0.389718771997719e19,
+ -0.333775713645296e23, 0.356499469636328e11, -0.148547544720641e27,
+ 0.330611514838798e19, 0.813641294467829e38]
+
+ suma = 0
+ for i in range(14):
+ suma += n[i]*(nu-1.02)**I[i]*(nu-0.608)**J[i]
+ return 22*suma
+
+
+def _PSat_s(s):
+ """Define the saturated line, P=f(s) for region 3
+
+ >>> "%.8f" % _PSat_s(3.8)
+ '16.87755057'
+ >>> "%.8f" % _PSat_s(5.2)
+ '16.68968482'
+ """
+ sigma = s/5.2
+ I = [0, 1, 1, 4, 12, 12, 16, 24, 28, 32]
+ J = [0, 1, 32, 7, 4, 14, 36, 10, 0, 18]
+ n = [0.639767553612785, -0.129727445396014e2, -0.224595125848403e16,
+ 0.177466741801846e7, 0.717079349571538e10, -0.378829107169011e18,
+ -0.955586736431328e35, 0.187269814676188e24, 0.119254746466473e12,
+ 0.110649277244882e37]
+
+ suma = 0
+ for i in range(10):
+ suma += n[i]*(sigma-1.03)**I[i]*(sigma-0.699)**J[i]
+ return 22*suma
+
+
+def _h1_s(s):
+ """Define the saturated line boundary between Region 1 and 4, h=f(s)
+
+ >>> "%.7f" % _h1_s(1)
+ '308.5509647'
+ >>> "%.6f" % _h1_s(3)
+ '1198.359754'
+ """
+ sigma = s/3.8
+ I = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 7, 8, 12, 12, 14, 14, 16, 20,
+ 20, 22, 24, 28, 32, 32]
+ J = [14, 36, 3, 16, 0, 5, 4, 36, 4, 16, 24, 18, 24, 1, 4, 2, 4, 1, 22, 10,
+ 12, 28, 8, 3, 0, 6, 8]
+ n = [0.332171191705237, 0.611217706323496e-3, -0.882092478906822e1,
+ -0.455628192543250, -0.263483840850452e-4, -0.223949661148062e2,
+ -0.428398660164013e1, -0.616679338856916, -0.146823031104040e2,
+ 0.284523138727299e3, -0.113398503195444e3, 0.115671380760859e4,
+ 0.395551267359325e3, -0.154891257229285e1, 0.194486637751291e2,
+ -0.357915139457043e1, -0.335369414148819e1, -0.664426796332460,
+ 0.323321885383934e5, 0.331766744667084e4, -0.223501257931087e5,
+ 0.573953875852936e7, 0.173226193407919e3, -0.363968822121321e-1,
+ 0.834596332878346e-6, 0.503611916682674e1, 0.655444787064505e2]
+
+ suma = 0
+ for i in range(27):
+ suma += n[i]*(sigma-1.09)**I[i]*(sigma+0.366e-4)**J[i]
+ return 1700*suma
+
+
+def _h3a_s(s):
+ """Define the saturated line boundary between Region 4 and 3a, h=f(s)
+
+ >>> "%.6f" % _h3a_s(3.8)
+ '1685.025565'
+ >>> "%.6f" % _h3a_s(4.2)
+ '1949.352563'
+ """
+ sigma = s/3.8
+ I = [0, 0, 0, 0, 2, 3, 4, 4, 5, 5, 6, 7, 7, 7, 10, 10, 10, 32, 32]
+ J = [1, 4, 10, 16, 1, 36, 3, 16, 20, 36, 4, 2, 28, 32, 14, 32, 36, 0, 6]
+ n = [0.822673364673336, 0.181977213534479, -0.112000260313624e-1,
+ -0.746778287048033e-3, -0.179046263257381, 0.424220110836657e-1,
+ -0.341355823438768, -0.209881740853565e1, -0.822477343323596e1,
+ -0.499684082076008e1, 0.191413958471069, 0.581062241093136e-1,
+ -0.165505498701029e4, 0.158870443421201e4, -0.850623535172818e2,
+ -0.317714386511207e5, -0.945890406632871e5, -0.139273847088690e-5,
+ 0.631052532240980]
+
+ suma = 0
+ for i in range(19):
+ suma += n[i]*(sigma-1.09)**I[i]*(sigma+0.366e-4)**J[i]
+ return 1700*suma
+
+
+def _h2ab_s(s):
+ """Define the saturated line boundary between Region 4 and 2a-2b, h=f(s)
+
+ >>> "%.6f" % _h2ab_s(7)
+ '2723.729985'
+ >>> "%.6f" % _h2ab_s(9)
+ '2511.861477'
+ """
+ sigma1 = s/5.21
+ sigma2 = s/9.2
+ I = [1, 1, 2, 2, 4, 4, 7, 8, 8, 10, 12, 12, 18, 20, 24, 28, 28, 28, 28, 28,
+ 32, 32, 32, 32, 32, 36, 36, 36, 36, 36]
+ J = [8, 24, 4, 32, 1, 2, 7, 5, 12, 1, 0, 7, 10, 12, 32, 8, 12, 20, 22, 24,
+ 2, 7, 12, 14, 24, 10, 12, 20, 22, 28]
+ n = [-0.524581170928788e3, -0.926947218142218e7, -0.237385107491666e3,
+ 0.210770155812776e11, -0.239494562010986e2, 0.221802480294197e3,
+ -0.510472533393438e7, 0.124981396109147e7, 0.200008436996201e10,
+ -0.815158509791035e3, -0.157612685637523e3, -0.114200422332791e11,
+ 0.662364680776872e16, -0.227622818296144e19, -0.171048081348406e32,
+ 0.660788766938091e16, 0.166320055886021e23, -0.218003784381501e30,
+ -0.787276140295618e30, 0.151062329700346e32, 0.795732170300541e7,
+ 0.131957647355347e16, -0.325097068299140e24, -0.418600611419248e26,
+ 0.297478906557467e35, -0.953588761745473e20, 0.166957699620939e25,
+ -0.175407764869978e33, 0.347581490626396e35, -0.710971318427851e39]
+
+ suma = 0
+ for i in range(30):
+ suma += n[i]*(1/sigma1-0.513)**I[i]*(sigma2-0.524)**J[i]
+ return 2800*exp(suma)
+
+
+def _h2c3b_s(s):
+ """Define the saturated line boundary between Region 4 and 2c-3b, h=f(s)
+
+ >>> "%.6f" % _h2c3b_s(5.5)
+ '2687.693850'
+ >>> "%.6f" % _h2c3b_s(4.5)
+ '2144.360448'
+ """
+ sigma = s/5.9
+ I = [0, 0, 0, 1, 1, 5, 6, 7, 8, 8, 12, 16, 22, 22, 24, 36]
+ J = [0, 3, 4, 0, 12, 36, 12, 16, 2, 20, 32, 36, 2, 32, 7, 20]
+ n = [0.104351280732769e1, -0.227807912708513e1, 0.180535256723202e1,
+ 0.420440834792042, -0.105721244834660e6, 0.436911607493884e25,
+ -0.328032702839753e12, -0.678686760804270e16, 0.743957464645363e4,
+ -0.356896445355761e20, 0.167590585186801e32, -0.355028625419105e38,
+ 0.396611982166538e12, -0.414716268484468e41, 0.359080103867382e19,
+ -0.116994334851995e41]
+
+ suma = 0
+ for i in range(16):
+ suma += n[i]*(sigma-1.02)**I[i]*(sigma-0.726)**J[i]
+ return 2800*suma**4
+
+
+# Region 1
+def _Region1(T, P):
+ """Basic equation for region 1
+
+ >>> "%.11f" % _Region1(300,3)["v"]
+ '0.00100215168'
+ >>> "%.6f" % _Region1(300,3)["h"]
+ '115.331273'
+ >>> "%.6f" % (_Region1(300,3)["h"]-3000*_Region1(300,3)["v"], )
+ '112.324818'
+ >>> "%.9f" % _Region1(300,80)["s"]
+ '0.368563852'
+ >>> "%.8f" % _Region1(300,80)["cp"]
+ '4.01008987'
+ >>> "%.8f" % _Region1(300,80)["cv"]
+ '3.91736606'
+ >>> "%.5f" % _Region1(500,3)["w"]
+ '1240.71337'
+ >>> "%.11f" % _Region1(500,3)["alfav"]
+ '0.00164118128'
+ >>> "%.11f" % _Region1(500,3)["kt"]
+ '0.00112892188'
+ """
+ I = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4,
+ 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32]
+ J = [-2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0,
+ 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41]
+ n = [0.14632971213167, -0.84548187169114, -0.37563603672040e1,
+ 0.33855169168385e1, -0.95791963387872, 0.15772038513228,
+ -0.16616417199501e-1, 0.81214629983568e-3, 0.28319080123804e-3,
+ -0.60706301565874e-3, -0.18990068218419e-1, -0.32529748770505e-1,
+ -0.21841717175414e-1, -0.52838357969930e-4, -0.47184321073267e-3,
+ -0.30001780793026e-3, 0.47661393906987e-4, -0.44141845330846e-5,
+ -0.72694996297594e-15, -0.31679644845054e-4, -0.28270797985312e-5,
+ -0.85205128120103e-9, -0.22425281908000e-5, -0.65171222895601e-6,
+ -0.14341729937924e-12, -0.40516996860117e-6, -0.12734301741641e-8,
+ -0.17424871230634e-9, -0.68762131295531e-18, 0.14478307828521e-19,
+ 0.26335781662795e-22, -0.11947622640071e-22, 0.18228094581404e-23,
+ -0.93537087292458e-25]
+ Tr = 1386/T
+ Pr = P/16.53
+ g = gp = gpp = gt = gtt = gpt = 0
+ for i in range(34):
+ g += n[i]*(7.1-Pr)**I[i]*(Tr-1.222)**J[i]
+ gp -= n[i]*I[i]*(7.1-Pr)**(I[i]-1)*(Tr-1.222)**J[i]
+ gpp += n[i]*I[i]*(I[i]-1)*(7.1-Pr)**(I[i]-2)*(Tr-1.222)**J[i]
+ gt += n[i] * (7.1-Pr)**I[i] * J[i] * (Tr-1.222)**(J[i]-1)
+ gtt += n[i]*(7.1-Pr)**I[i]*J[i]*(J[i]-1)*(Tr-1.222)**(J[i]-2)
+ gpt -= n[i]*I[i]*(7.1-Pr)**(I[i]-1)*J[i]*(Tr-1.222)**(J[i]-1)
+
+ propiedades = {}
+ propiedades["T"] = T
+ propiedades["P"] = P
+ propiedades["v"] = Pr*gp*R*T/P/1000
+ propiedades["h"] = Tr*gt*R*T
+ propiedades["s"] = R*(Tr*gt-g)
+ propiedades["cp"] = -R*Tr**2*gtt
+ propiedades["cv"] = R*(-Tr**2*gtt+(gp-Tr*gpt)**2/gpp)
+ propiedades["w"] = sqrt(R*T*1000*gp**2/((gp-Tr*gpt)**2/(Tr**2*gtt)-gpp))
+ propiedades["alfav"] = (1-Tr*gpt/gp)/T
+ propiedades["kt"] = -Pr*gpp/gp/P
+ propiedades["region"] = 1
+ propiedades["x"] = 0
+ return propiedades
+
+
+def _Backward1_T_Ph(P, h):
+ """Backward equation for region 1, T=f(P,h)
+
+ >>> "%.6f" % _Backward1_T_Ph(3,500)
+ '391.798509'
+ >>> "%.6f" % _Backward1_T_Ph(80,1500)
+ '611.041229'
+ """
+ I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6]
+ J = [0, 1, 2, 6, 22, 32, 0, 1, 2, 3, 4, 10, 32, 10, 32, 10, 32, 32, 32, 32]
+ n = [-0.23872489924521e3, 0.40421188637945e3, 0.11349746881718e3,
+ -0.58457616048039e1, -0.15285482413140e-3, -0.10866707695377e-5,
+ -0.13391744872602e2, 0.43211039183559e2, -0.54010067170506e2,
+ 0.30535892203916e2, -0.65964749423638e1, 0.93965400878363e-2,
+ 0.11573647505340e-6, -0.25858641282073e-4, -0.40644363084799e-8,
+ 0.66456186191635e-7, 0.80670734103027e-10, -0.93477771213947e-12,
+ 0.58265442020601e-14, -0.15020185953503e-16]
+
+ Pr = P/1
+ nu = h/2500
+ T = 0
+ for i in range(20):
+ T += n[i]*Pr**I[i]*(nu+1)**J[i]
+ return T
+
+
+def _Backward1_T_Ps(P, s):
+ """Backward equation for region 1, T=f(P,s)
+
+ >>> "%.6f" % _Backward1_T_Ps(3,0.5)
+ '307.842258'
+ >>> "%.6f" % _Backward1_T_Ps(80,3)
+ '565.899909'
+ """
+ I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 4]
+ J = [0, 1, 2, 3, 11, 31, 0, 1, 2, 3, 12, 31, 0, 1, 2, 9, 31, 10, 32, 32]
+ n = [0.17478268058307e3, 0.34806930892873e2, 0.65292584978455e1,
+ 0.33039981775489, -0.19281382923196e-6, -0.24909197244573e-22,
+ -0.26107636489332, 0.22592965981586, -0.64256463395226e-1,
+ 0.78876289270526e-2, 0.35672110607366e-9, 0.17332496994895e-23,
+ 0.56608900654837e-3, -0.32635483139717e-3, 0.44778286690632e-4,
+ -0.51322156908507e-9, -0.42522657042207e-25, 0.26400441360689e-12,
+ 0.78124600459723e-28, -0.30732199903668e-30]
+
+ Pr = P/1
+ sigma = s/1
+ T = 0
+ for i in range(20):
+ T += n[i]*Pr**I[i]*(sigma+2)**J[i]
+ return T
+
+
+def _Backward1_P_hs(h, s):
+ """Backward equation for region 1, P=f(h,s)
+
+ >>> "%.13f" % _Backward1_P_hs(0.001,0)
+ '0.0009800980612'
+ >>> "%.8f" % _Backward1_P_hs(90,0)
+ '91.92954727'
+ >>> "%.8f" % _Backward1_P_hs(1500,3.4)
+ '58.68294423'
+ """
+ I = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 5]
+ J = [0, 1, 2, 4, 5, 6, 8, 14, 0, 1, 4, 6, 0, 1, 10, 4, 1, 4, 0]
+ n = [-0.691997014660582, -0.183612548787560e2, -0.928332409297335e1,
+ 0.659639569909906e2, -0.162060388912024e2, 0.450620017338667e3,
+ 0.854680678224170e3, 0.607523214001162e4, 0.326487682621856e2,
+ -0.269408844582931e2, -0.319947848334300e3, -0.928354307043320e3,
+ 0.303634537455249e2, -0.650540422444146e2, -0.430991316516130e4,
+ -0.747512324096068e3, 0.730000345529245e3, 0.114284032569021e4,
+ -0.436407041874559e3]
+
+ nu = h/3400
+ sigma = s/7.6
+ P = 0
+ for i in range(19):
+ P += n[i]*(nu+0.05)**I[i]*(sigma+0.05)**J[i]
+ return 100*P
+
+
+# Region 2
+def _Region2(T, P):
+ """Basic equation for region 2
+
+ >>> "%.11f" % _Region2(700,30)["v"]
+ '0.00542946619'
+ >>> "%.5f" % _Region2(700,30)["h"]
+ '2631.49474'
+ >>> "%.5f" % (_Region2(700,30)["h"]-30000*_Region2(700,30)["v"], )
+ '2468.61076'
+ >>> "%.7f" % _Region2(700,0.0035)["s"]
+ '10.1749996'
+ >>> "%.8f" % _Region2(700,0.0035)["cp"]
+ '2.08141274'
+ >>> "%.8f" % _Region2(700,0.0035)["cv"]
+ '1.61978333'
+ >>> "%.6f" % _Region2(300,0.0035)["w"]
+ '427.920172'
+ >>> "%.11f" % _Region2(300,0.0035)["alfav"]
+ '0.00337578289'
+ >>> "%.6f" % _Region2(300,0.0035)["kt"]
+ '286.239651'
+ """
+ Tr = 540/T
+ Pr = P/1
+
+ go, gop, gopp, got, gott, gopt = Region2_cp0(Tr, Pr)
+
+ Ir = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 6, 6, 6, 7, 7,
+ 7, 8, 8, 9, 10, 10, 10, 16, 16, 18, 20, 20, 20, 21, 22, 23, 24, 24, 24]
+ Jr = [0, 1, 2, 3, 6, 1, 2, 4, 7, 36, 0, 1, 3, 6, 35, 1, 2, 3, 7, 3, 16, 35,
+ 0, 11, 25, 8, 36, 13, 4, 10, 14, 29, 50, 57, 20, 35, 48, 21, 53, 39,
+ 26, 40, 58]
+ nr = [-0.0017731742473212999, -0.017834862292357999, -0.045996013696365003,
+ -0.057581259083432, -0.050325278727930002, -3.3032641670203e-05,
+ -0.00018948987516315, -0.0039392777243355001, -0.043797295650572998,
+ -2.6674547914087001e-05, 2.0481737692308999e-08, 4.3870667284435001e-07,
+ -3.2277677238570002e-05, -0.0015033924542148, -0.040668253562648998,
+ -7.8847309559367001e-10, 1.2790717852285001e-08, 4.8225372718507002e-07,
+ 2.2922076337661001e-06, -1.6714766451061001e-11, -0.0021171472321354998,
+ -23.895741934103999, -5.9059564324270004e-18, -1.2621808899101e-06,
+ -0.038946842435739003, 1.1256211360459e-11, -8.2311340897998004,
+ 1.9809712802088e-08, 1.0406965210174e-19, -1.0234747095929e-13,
+ -1.0018179379511e-09, -8.0882908646984998e-11, 0.10693031879409,
+ -0.33662250574170999, 8.9185845355420999e-25, 3.0629316876231997e-13,
+ -4.2002467698208001e-06, -5.9056029685639003e-26, 3.7826947613457002e-06,
+ -1.2768608934681e-15, 7.3087610595061e-29, 5.5414715350778001e-17,
+ -9.4369707241209998e-07]
+
+ gr = grp = grpp = grt = grtt = grpt = 0
+ for i in range(43):
+ gr += nr[i]*Pr**Ir[i]*(Tr-0.5)**Jr[i]
+ grp += nr[i]*Ir[i]*Pr**(Ir[i]-1)*(Tr-0.5)**Jr[i]
+ grpp += nr[i]*Ir[i]*(Ir[i]-1)*Pr**(Ir[i]-2)*(Tr-0.5)**Jr[i]
+ grt += nr[i]*Pr**Ir[i]*Jr[i]*(Tr-0.5)**(Jr[i]-1)
+ grtt += nr[i]*Pr**Ir[i]*Jr[i]*(Jr[i]-1)*(Tr-0.5)**(Jr[i]-2)
+ grpt += nr[i]*Ir[i]*Pr**(Ir[i]-1)*Jr[i]*(Tr-0.5)**(Jr[i]-1)
+
+ propiedades = {}
+ propiedades["T"] = T
+ propiedades["P"] = P
+ propiedades["v"] = Pr*(gop+grp)*R*T/P/1000
+ propiedades["h"] = Tr*(got+grt)*R*T
+ propiedades["s"] = R*(Tr*(got+grt)-(go+gr))
+ propiedades["cp"] = -R*Tr**2*(gott+grtt)
+ propiedades["cv"] = R*(-Tr**2*(gott+grtt)-(1+Pr*grp-Tr*Pr*grpt)**2/(1-Pr**2*grpp))
+ propiedades["w"] = (R*T*1000*(1+2*Pr*grp+Pr**2*grp**2)/(1-Pr**2*grpp+(
+ 1+Pr*grp-Tr*Pr*grpt)**2/Tr**2/(gott+grtt)))**0.5
+ propiedades["alfav"] = (1+Pr*grp-Tr*Pr*grpt)/(1+Pr*grp)/T
+ propiedades["kt"] = (1-Pr**2*grpp)/(1+Pr*grp)/P
+ propiedades["region"] = 2
+ propiedades["x"] = 1
+ return propiedades
+
+
+def Region2_cp0(Tr, Pr):
+ """Ideal properties for Region 2"""
+ Jo = [0, 1, -5, -4, -3, -2, -1, 2, 3]
+ no = [-0.96927686500217E+01, 0.10086655968018E+02, -0.56087911283020E-02,
+ 0.71452738081455E-01, -0.40710498223928E+00, 0.14240819171444E+01,
+ -0.43839511319450E+01, -0.28408632460772E+00, 0.21268463753307E-01]
+ go = log(Pr)
+ gop = Pr**-1
+ gopp = -Pr**-2
+ got = gott = gopt = 0
+ for i in range(9):
+ go += no[i]*Tr**Jo[i]
+ got += no[i]*Jo[i]*Tr**(Jo[i]-1)
+ gott += no[i]*Jo[i]*(Jo[i]-1)*Tr**(Jo[i]-2)
+ return go, gop, gopp, got, gott, gopt
+
+
+def _P_2bc(h):
+ """Define the boundary between Region 2b and 2c, P=f(h)
+
+ >>> "%.3f" % _P_2bc(3516.004323)
+ '100.000'
+ """
+ return 905.84278514723-0.67955786399241*h+1.2809002730136e-4*h**2
+
+
+def _hbc_P(P):
+ """Define the boundary between Region 2b and 2c, h=f(P)
+
+ >>> "%.6f" % _hbc_P(100)
+ '3516.004323'
+ """
+ return 0.26526571908428e4+((P-0.45257578905948e1)/1.2809002730136e-4)**0.5
+
+
+def _hab_s(s):
+ """Define the boundary between Region 2a and 2b, h=f(s)
+
+ >>> "%.6f" % _hab_s(7)
+ '3376.437884'
+ """
+ smin = _Region2(_TSat_P(4), 4)["s"]
+ smax = _Region2(1073.15, 4)["s"]
+ if s < smin:
+ h = 0
+ elif s > smax:
+ h = 5000
+ else:
+ h = -0.349898083432139e4 + 0.257560716905876e4*s - \
+ 0.421073558227969e3*s**2+0.276349063799944e2*s**3
+ return h
+
+
+def _Backward2a_T_Ph(P, h):
+ """Backward equation for region 2a, T=f(P,h)
+
+ >>> "%.6f" % _Backward2a_T_Ph(0.001,3000)
+ '534.433241'
+ >>> "%.5f" % _Backward2a_T_Ph(3,4000)
+ '1010.77577'
+ """
+ I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7]
+ J = [0, 1, 2, 3, 7, 20, 0, 1, 2, 3, 7, 9, 11, 18, 44, 0, 2, 7, 36, 38, 40,
+ 42, 44, 24, 44, 12, 32, 44, 32, 36, 42, 34, 44, 28]
+ n = [0.10898952318288e4, 0.84951654495535e3, -0.10781748091826e3,
+ 0.33153654801263e2, -0.74232016790248e1, 0.11765048724356e2,
+ 0.18445749355790e1, -0.41792700549624e1, 0.62478196935812e1,
+ -0.17344563108114e2, -0.20058176862096e3, 0.27196065473796e3,
+ -0.45511318285818e3, 0.30919688604755e4, 0.25226640357872e6,
+ -0.61707422868339e-2, -0.31078046629583, 0.11670873077107e2,
+ 0.12812798404046e9, -0.98554909623276e9, 0.28224546973002e10,
+ -0.35948971410703e10, 0.17227349913197e10, -0.13551334240775e5,
+ 0.12848734664650e8, 0.13865724283226e1, 0.23598832556514e6,
+ -0.13105236545054e8, 0.73999835474766e4, -0.55196697030060e6,
+ 0.37154085996233e7, 0.19127729239660e5, -0.41535164835634e6,
+ -0.62459855192507e2]
+
+ Pr = P/1
+ nu = h/2000
+ T = 0
+ for i in range(34):
+ T += n[i]*Pr**I[i]*(nu-2.1)**J[i]
+ return T
+
+
+def _Backward2b_T_Ph(P, h):
+ """Backward equation for region 2b, T=f(P,h)
+
+ >>> "%.5f" % _Backward2b_T_Ph(5,4000)
+ '1015.31583'
+ >>> "%.6f" % _Backward2b_T_Ph(25,3500)
+ '875.279054'
+ """
+ I = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3,
+ 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 6, 7, 7, 9, 9]
+ J = [0, 1, 2, 12, 18, 24, 28, 40, 0, 2, 6, 12, 18, 24, 28, 40, 2, 8, 18,
+ 40, 1, 2, 12, 24, 2, 12, 18, 24, 28, 40, 18, 24, 40, 28, 2, 28, 1, 40]
+ n = [0.14895041079516e4, 0.74307798314034e3, -0.97708318797837e2,
+ 0.24742464705674e1, -0.63281320016026, 0.11385952129658e1,
+ -0.47811863648625, 0.85208123431544e-2, 0.93747147377932,
+ 0.33593118604916e1, 0.33809355601454e1, 0.16844539671904,
+ 0.73875745236695, -0.47128737436186, 0.15020273139707,
+ -0.21764114219750e-2, -0.21810755324761e-1, -0.10829784403677,
+ -0.46333324635812e-1, 0.71280351959551e-4, 0.11032831789999e-3,
+ 0.18955248387902e-3, 0.30891541160537e-2, 0.13555504554949e-2,
+ 0.28640237477456e-6, -0.10779857357512e-4, -0.76462712454814e-4,
+ 0.14052392818316e-4, -0.31083814331434e-4, -0.10302738212103e-5,
+ 0.28217281635040e-6, 0.12704902271945e-5, 0.73803353468292e-7,
+ -0.11030139238909e-7, -0.81456365207833e-13, -0.25180545682962e-10,
+ -0.17565233969407e-17, 0.86934156344163e-14]
+
+ Pr = P/1
+ nu = h/2000
+ T = 0
+ for i in range(38):
+ T += n[i]*(Pr-2)**I[i]*(nu-2.6)**J[i]
+ return T
+
+
+def _Backward2c_T_Ph(P, h):
+ """Backward equation for region 2c, T=f(P,h)
+
+ >>> "%.6f" % _Backward2c_T_Ph(40,2700)
+ '743.056411'
+ >>> "%.6f" % _Backward2c_T_Ph(60,3200)
+ '882.756860'
+ """
+ I = [-7, -7, -6, -6, -5, -5, -2, -2, -1, -1, 0, 0, 1, 1, 2, 6, 6, 6, 6, 6,
+ 6, 6, 6]
+ J = [0, 4, 0, 2, 0, 2, 0, 1, 0, 2, 0, 1, 4, 8, 4, 0, 1, 4, 10, 12, 16, 20, 22]
+ n = [-0.32368398555242e13, 0.73263350902181e13, 0.35825089945447e12,
+ -0.58340131851590e12, -0.10783068217470e11, 0.20825544563171e11,
+ 0.61074783564516e6, 0.85977722535580e6, -0.25745723604170e5,
+ 0.31081088422714e5, 0.12082315865936e4, 0.48219755109255e3,
+ 0.37966001272486e1, -0.10842984880077e2, -0.45364172676660e-1,
+ 0.14559115658698e-12, 0.11261597407230e-11, -0.17804982240686e-10,
+ 0.12324579690832e-6, -0.11606921130984e-5, 0.27846367088554e-4,
+ -0.59270038474176e-3, 0.12918582991878e-2]
+
+ Pr = P/1
+ nu = h/2000
+ T = 0
+ for i in range(23):
+ T += n[i]*(Pr+25)**I[i]*(nu-1.8)**J[i]
+ return T
+
+
+def _Backward2_T_Ph(P, h):
+ """Backward equation for region 2, T=f(P,h)"""
+ Tsat = _TSat_P(P)
+ if P <= 4:
+ T = _Backward2a_T_Ph(P, h)
+ elif 4 < P <= 6.546699678:
+ T = _Backward2b_T_Ph(P, h)
+ else:
+ hf = _hbc_P(P)
+ if h >= hf:
+ T = _Backward2b_T_Ph(P, h)
+ else:
+ T = _Backward2c_T_Ph(P, h)
+ return max(Tsat, T)
+
+
+def _Backward2a_T_Ps(P, s):
+ """Backward equation for region 2a, T=f(P,s)
+
+ >>> "%.6f" % _Backward2a_T_Ps(0.1,7.5)
+ '399.517097'
+ >>> "%.5f" % _Backward2a_T_Ps(2.5,8)
+ '1039.84917'
+ """
+ I = [-1.5, -1.5, -1.5, -1.5, -1.5, -1.5, -1.25, -1.25, -1.25, -1.0, -1.0,
+ -1.0, -1.0, -1.0, -1.0, -0.75, -0.75, -0.5, -0.5, -0.5, -0.5, -0.25,
+ -0.25, -0.25, -0.25, 0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.5, 0.5, 0.5,
+ 0.5, 0.5, 0.75, 0.75, 0.75, 0.75, 1.0, 1.0, 1.25, 1.25, 1.5, 1.5]
+ J = [-24, -23, -19, -13, -11, -10, -19, -15, -6, -26, -21, -17, -16, -9,
+ -8, -15, -14, -26, -13, -9, -7, -27, -25, -11, -6, 1, 4, 8, 11, 0, 1,
+ 5, 6, 10, 14, 16, 0, 4, 9, 17, 7, 18, 3, 15, 5, 18]
+ n = [-0.39235983861984e6, 0.51526573827270e6, 0.40482443161048e5,
+ -0.32193790923902e3, 0.96961424218694e2, -0.22867846371773e2,
+ -0.44942914124357e6, -0.50118336020166e4, 0.35684463560015,
+ 0.44235335848190e5, -0.13673388811708e5, 0.42163260207864e6,
+ 0.22516925837475e5, 0.47442144865646e3, -0.14931130797647e3,
+ -0.19781126320452e6, -0.23554399470760e5, -0.19070616302076e5,
+ 0.55375669883164e5, 0.38293691437363e4, -0.60391860580567e3,
+ 0.19363102620331e4, 0.42660643698610e4, -0.59780638872718e4,
+ -0.70401463926862e3, 0.33836784107553e3, 0.20862786635187e2,
+ 0.33834172656196e-1, -0.43124428414893e-4, 0.16653791356412e3,
+ -0.13986292055898e3, -0.78849547999872, 0.72132411753872e-1,
+ -0.59754839398283e-2, -0.12141358953904e-4, 0.23227096733871e-6,
+ -0.10538463566194e2, 0.20718925496502e1, -0.72193155260427e-1,
+ 0.20749887081120e-6, -0.18340657911379e-1, 0.29036272348696e-6,
+ 0.21037527893619, 0.25681239729999e-3, -0.12799002933781e-1,
+ -0.82198102652018e-5]
+
+ Pr = P/1
+ sigma = s/2
+ T = 0
+ for i in range(46):
+ T += n[i]*Pr**I[i]*(sigma-2)**J[i]
+ return T
+
+
+def _Backward2b_T_Ps(P, s):
+ """Backward equation for region 2b, T=f(P,s)
+
+ >>> "%.6f" % _Backward2b_T_Ps(8,6)
+ '600.484040'
+ >>> "%.5f" % _Backward2b_T_Ps(90,6)
+ '1038.01126'
+ """
+ I = [-6, -6, -5, -5, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, -1, -1,
+ -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3,
+ 4, 4, 5, 5, 5]
+ J = [0, 11, 0, 11, 0, 1, 11, 0, 1, 11, 12, 0, 1, 6, 10, 0, 1, 5, 8, 9, 0,
+ 1, 2, 4, 5, 6, 9, 0, 1, 2, 3, 7, 8, 0, 1, 5, 0, 1, 3, 0, 1, 0, 1, 2]
+ n = [0.31687665083497e6, 0.20864175881858e2, -0.39859399803599e6,
+ -0.21816058518877e2, 0.22369785194242e6, -0.27841703445817e4,
+ 0.99207436071480e1, -0.75197512299157e5, 0.29708605951158e4,
+ -0.34406878548526e1, 0.38815564249115, 0.17511295085750e5,
+ -0.14237112854449e4, 0.10943803364167e1, 0.89971619308495,
+ -0.33759740098958e4, 0.47162885818355e3, -0.19188241993679e1,
+ 0.41078580492196, -0.33465378172097, 0.13870034777505e4,
+ -0.40663326195838e3, 0.41727347159610e2, 0.21932549434532e1,
+ -0.10320050009077e1, 0.35882943516703, 0.52511453726066e-2,
+ 0.12838916450705e2, -0.28642437219381e1, 0.56912683664855,
+ -0.99962954584931e-1, -0.32632037778459e-2, 0.23320922576723e-3,
+ -0.15334809857450, 0.29072288239902e-1, 0.37534702741167e-3,
+ 0.17296691702411e-2, -0.38556050844504e-3, -0.35017712292608e-4,
+ -0.14566393631492e-4, 0.56420857267269e-5, 0.41286150074605e-7,
+ -0.20684671118824e-7, 0.16409393674725e-8]
+
+ Pr = P/1
+ sigma = s/0.7853
+ T = 0
+ for i in range(44):
+ T += n[i]*Pr**I[i]*(10-sigma)**J[i]
+ return T
+
+
+def _Backward2c_T_Ps(P, s):
+ """Backward equation for region 2c, T=f(P,s)
+
+ >>> "%.6f" % _Backward2c_T_Ps(20,5.75)
+ '697.992849'
+ >>> "%.6f" % _Backward2c_T_Ps(80,5.75)
+ '949.017998'
+ """
+ I = [-2, -2, -1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5,
+ 5, 6, 6, 7, 7, 7, 7, 7]
+ J = [0, 1, 0, 0, 1, 2, 3, 0, 1, 3, 4, 0, 1, 2, 0, 1, 5, 0, 1, 4, 0, 1, 2,
+ 0, 1, 0, 1, 3, 4, 5]
+ n = [0.90968501005365e3, 0.24045667088420e4, -0.59162326387130e3,
+ 0.54145404128074e3, -0.27098308411192e3, 0.97976525097926e3,
+ -0.46966772959435e3, 0.14399274604723e2, -0.19104204230429e2,
+ 0.53299167111971e1, -0.21252975375934e2, -0.31147334413760,
+ 0.60334840894623, -0.42764839702509e-1, 0.58185597255259e-2,
+ -0.14597008284753e-1, 0.56631175631027e-2, -0.76155864584577e-4,
+ 0.22440342919332e-3, -0.12561095013413e-4, 0.63323132660934e-6,
+ -0.20541989675375e-5, 0.36405370390082e-7, -0.29759897789215e-8,
+ 0.10136618529763e-7, 0.59925719692351e-11, -0.20677870105164e-10,
+ -0.20874278181886e-10, 0.10162166825089e-9, -0.16429828281347e-9]
+
+ Pr = P/1
+ sigma = s/2.9251
+ T = 0
+ for i in range(30):
+ T += n[i]*Pr**I[i]*(2-sigma)**J[i]
+ return T
+
+
+def _Backward2_T_Ps(P, s):
+ """Backward equation for region 2, T=f(P,s)"""
+ sf = 5.85
+ Tsat = _TSat_P(P)
+ if P <= 4:
+ T = _Backward2a_T_Ps(P, s)
+ elif s >= sf:
+ T = _Backward2b_T_Ps(P, s)
+ else:
+ T = _Backward2c_T_Ps(P, s)
+ return max(Tsat, T)
+
+
+def _Backward2a_P_hs(h, s):
+ """Backward equation for region 2a, P=f(h,s)
+
+ >>> "%.9f" % _Backward2a_P_hs(2800,6.5)
+ '1.371012767'
+ >>> "%.12f" % _Backward2a_P_hs(2800,9.5)
+ '0.001879743844'
+ >>> "%.10f" % _Backward2a_P_hs(4100,9.5)
+ '0.1024788997'
+ """
+ I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3,
+ 3, 4, 5, 5, 6, 7]
+ J = [1, 3, 6, 16, 20, 22, 0, 1, 2, 3, 5, 6, 10, 16, 20, 22, 3, 16, 20, 0,
+ 2, 3, 6, 16, 16, 3, 16, 3, 1]
+ n = [-0.182575361923032e-1, -0.125229548799536, 0.592290437320145,
+ 0.604769706185122e1, 0.238624965444474e3, -0.298639090222922e3,
+ 0.512250813040750e-1, -0.437266515606486, 0.413336902999504,
+ -0.516468254574773e1, -0.557014838445711e1, 0.128555037824478e2,
+ 0.114144108953290e2, -0.119504225652714e3, -0.284777985961560e4,
+ 0.431757846408006e4, 0.112894040802650e1, 0.197409186206319e4,
+ 0.151612444706087e4, 0.141324451421235e-1, 0.585501282219601,
+ -0.297258075863012e1, 0.594567314847319e1, -0.623656565798905e4,
+ 0.965986235133332e4, 0.681500934948134e1, -0.633207286824489e4,
+ -0.558919224465760e1, 0.400645798472063e-1]
+
+ nu = h/4200
+ sigma = s/12
+ suma = 0
+ for i in range(29):
+ suma += n[i]*(nu-0.5)**I[i]*(sigma-1.2)**J[i]
+ return 4*suma**4
+
+
+def _Backward2b_P_hs(h, s):
+ """Backward equation for region 2b, P=f(h,s)
+
+ >>> "%.9f" % _Backward2b_P_hs(2800,6)
+ '4.793911442'
+ >>> "%.8f" % _Backward2b_P_hs(3600,6)
+ '83.95519209'
+ >>> "%.9f" % _Backward2b_P_hs(3600,7)
+ '7.527161441'
+ """
+ I = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6,
+ 6, 6, 7, 7, 8, 8, 8, 8, 12, 14]
+ J = [0, 1, 2, 4, 8, 0, 1, 2, 3, 5, 12, 1, 6, 18, 0, 1, 7, 12, 1, 16, 1,
+ 12, 1, 8, 18, 1, 16, 1, 3, 14, 18, 10, 16]
+ n = [0.801496989929495e-1, -0.543862807146111, 0.337455597421283,
+ 0.890555451157450e1, 0.313840736431485e3, 0.797367065977789,
+ -0.121616973556240e1, 0.872803386937477e1, -0.169769781757602e2,
+ -0.186552827328416e3, 0.951159274344237e5, -0.189168510120494e2,
+ -0.433407037194840e4, 0.543212633012715e9, 0.144793408386013,
+ 0.128024559637516e3, -0.672309534071268e5, 0.336972380095287e8,
+ -0.586634196762720e3, -0.221403224769889e11, 0.171606668708389e4,
+ -0.570817595806302e9, -0.312109693178482e4, -0.207841384633010e7,
+ 0.305605946157786e13, 0.322157004314333e4, 0.326810259797295e12,
+ -0.144104158934487e4, 0.410694867802691e3, 0.109077066873024e12,
+ -0.247964654258893e14, 0.188801906865134e10, -0.123651009018773e15]
+
+ nu = h/4100
+ sigma = s/7.9
+ suma = 0
+ for i in range(33):
+ suma += n[i]*(nu-0.6)**I[i]*(sigma-1.01)**J[i]
+ return 100*suma**4
+
+
+def _Backward2c_P_hs(h, s):
+ """Backward equation for region 2c, P=f(h,s)
+
+ >>> "%.8f" % _Backward2c_P_hs(2800,5.1)
+ '94.39202060'
+ >>> "%.9f" % _Backward2c_P_hs(2800,5.8)
+ '8.414574124'
+ >>> "%.8f" % _Backward2c_P_hs(3400,5.8)
+ '83.76903879'
+ """
+ I = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 5,
+ 5, 5, 5, 6, 6, 10, 12, 16]
+ J = [0, 1, 2, 3, 4, 8, 0, 2, 5, 8, 14, 2, 3, 7, 10, 18, 0, 5, 8, 16, 18,
+ 18, 1, 4, 6, 14, 8, 18, 7, 7, 10]
+ n = [0.112225607199012, -0.339005953606712e1, -0.320503911730094e2,
+ -0.197597305104900e3, -0.407693861553446e3, 0.132943775222331e5,
+ 0.170846839774007e1, 0.373694198142245e2, 0.358144365815434e4,
+ 0.423014446424664e6, -0.751071025760063e9, 0.523446127607898e2,
+ -0.228351290812417e3, -0.960652417056937e6, -0.807059292526074e8,
+ 0.162698017225669e13, 0.772465073604171, 0.463929973837746e5,
+ -0.137317885134128e8, 0.170470392630512e13, -0.251104628187308e14,
+ 0.317748830835520e14, 0.538685623675312e2, -0.553089094625169e5,
+ -0.102861522421405e7, 0.204249418756234e13, 0.273918446626977e9,
+ -0.263963146312685e16, -0.107890854108088e10, -0.296492620980124e11,
+ -0.111754907323424e16]
+
+ nu = h/3500
+ sigma = s/5.9
+ suma = 0
+ for i in range(31):
+ suma += n[i]*(nu-0.7)**I[i]*(sigma-1.1)**J[i]
+ return 100*suma**4
+
+
+def _Backward2_P_hs(h, s):
+ """Backward equation for region 2, P=f(h,s)"""
+ sfbc = 5.85
+ hamin = _hab_s(s)
+ if h <= hamin:
+ P = _Backward2a_P_hs(h, s)
+ elif s >= sfbc:
+ P = _Backward2b_P_hs(h, s)
+ else:
+ P = _Backward2c_P_hs(h, s)
+ return P
+
+
+# Region 3
+def _Region3(rho, T):
+ """Basic equation for region 3
+
+ >>> "%.7f" % _Region3(500,650)["P"]
+ '25.5837018'
+ >>> "%.5f" % _Region3(500,650)["h"]
+ '1863.43019'
+ >>> p = _Region3(500, 650)
+ >>> "%.5f" % (p["h"]-p["P"]*1000*p["v"], )
+ '1812.26279'
+ >>> "%.8f" % _Region3(200,650)["s"]
+ '4.85438792'
+ >>> "%.7f" % _Region3(200,650)["cp"]
+ '44.6579342'
+ >>> "%.8f" % _Region3(200,650)["cv"]
+ '4.04118076'
+ >>> "%.6f" % _Region3(200,650)["w"]
+ '383.444594'
+ >>> "%.11f" % _Region3(500,750)["alfav"]
+ '0.00441515098'
+ >>> "%.11f" % _Region3(500,750)["kt"]
+ '0.00806710817'
+ >>> "%.11f" % _Region3(500,750)["alfap"]
+ '0.00698896514'
+ >>> "%.6f" % _Region3(500,750)["betap"]
+ '791.475213'
+ """
+
+ I = [None, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
+ 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, 10, 10, 11]
+ J = [None, 0, 1, 2, 7, 10, 12, 23, 2, 6, 15, 17, 0, 2, 6, 7, 22, 26, 0, 2,
+ 4, 16, 26, 0, 2, 4, 26, 1, 3, 26, 0, 2, 26, 2, 26, 2, 26, 0, 1, 26]
+ n = [0.10658070028513e1, -0.15732845290239e2, 0.20944396974307e2,
+ -0.76867707878716e1, 0.26185947787954e1, -0.28080781148620e1,
+ 0.12053369696517e1, -0.84566812812502e-2, -0.12654315477714e1,
+ -0.11524407806681e1, 0.88521043984318, -0.64207765181607,
+ 0.38493460186671, -0.85214708824206, 0.48972281541877e1,
+ -0.30502617256965e1, 0.39420536879154e-1, 0.12558408424308,
+ -0.27999329698710, 0.13899799569460e1, -0.20189915023570e1,
+ -0.82147637173963e-2, -0.47596035734923, 0.43984074473500e-1,
+ -0.44476435428739, 0.90572070719733, .70522450087967, .10770512626332,
+ -0.32913623258954, -0.50871062041158, -0.22175400873096e-1,
+ 0.94260751665092e-1, 0.16436278447961, -0.13503372241348e-1,
+ -0.14834345352472e-1, 0.57922953628084e-3, 0.32308904703711e-2,
+ 0.80964802996215e-4, -0.16557679795037e-3, -0.44923899061815e-4]
+
+ d = rho/rhoc
+ Tr = Tc/T
+ g = n[0]*log(d)
+ gd = n[0]*d**-1
+ gdd = -n[0]*d**-2
+ gt = gtt = gdt = 0
+ for i in range(1, 40):
+ g += n[i]*d**I[i]*Tr**J[i]
+ gd += n[i]*I[i]*d**(I[i]-1)*Tr**J[i]
+ gdd += n[i]*I[i]*(I[i]-1)*d**(I[i]-2)*Tr**J[i]
+ gt += n[i] * d**I[i] * J[i] * Tr**(J[i]-1)
+ gtt += n[i]*d**I[i]*J[i]*(J[i]-1)*Tr**(J[i]-2)
+ gdt += n[i]*I[i]*d**(I[i]-1)*J[i]*Tr**(J[i]-1)
+
+ propiedades = {}
+ propiedades["T"] = T
+ propiedades["P"] = d*gd*R*T*rho/1000
+ propiedades["v"] = 1/rho
+ propiedades["h"] = R*T*(Tr*gt+d*gd)
+ propiedades["s"] = R*(Tr*gt-g)
+ propiedades["cp"] = R*(-Tr**2*gtt+(d*gd-d*Tr*gdt)**2/(2*d*gd+d**2*gdd))
+ propiedades["cv"] = -R*Tr**2*gtt
+ propiedades["w"] = sqrt(R*T*1000*(2*d*gd+d**2*gdd-(d*gd-d*Tr*gdt)**2/Tr**2/gtt))
+ propiedades["alfav"] = (gd-Tr*gdt)/(2*gd+d*gdd)/T
+ propiedades["kt"] = 1/(2*d*gd+d**2*gdd)/rho/R/T*1000
+ propiedades["alfap"] = (1-Tr*gdt/gd)/T
+ propiedades["betap"] = rho*(2+d*gdd/gd)
+ propiedades["region"] = 3
+ propiedades["x"] = 1
+ return propiedades
+
+
+def _h_3ab(P):
+ """Define the boundary between Region 3a-3b, h=f(P)
+
+ >>> "%.6f" % _h_3ab(25)
+ '2095.936454'
+ """
+ return 0.201464004206875e4 + 3.74696550136983*P - \
+ 0.0219921901054187*P**2+0.875131686009950e-4*P**3
+
+
+def _tab_P(P):
+ """Define the boundary between Region 3a-3b, T=f(P)
+
+ >>> "%.7f" % _tab_P(40)
+ '693.0341408'
+ """
+ I = [0, 1, 2, -1, -2]
+ n = [0.154793642129415e4, -0.187661219490113e3, 0.213144632222113e2,
+ -0.191887498864292e4, 0.918419702359447e3]
+
+ Pr = P/1
+ T = 0
+ for i in range(5):
+ T += n[i]*log(Pr)**I[i]
+ return T
+
+
+def _top_P(P):
+ """Define the boundary between Region 3o-3p, T=f(P)
+
+ >>> "%.7f" % _top_P(22.8)
+ '650.0106943'
+ """
+ I = [0, 1, 2, -1, -2]
+ n = [0.969461372400213e3, -0.332500170441278e3, 0.642859598466067e2,
+ 0.773845935768222e3, -0.152313732937084e4]
+
+ Pr = P/1
+ T = 0
+ for i in range(5):
+ T += n[i]*log(Pr)**I[i]
+ return T
+
+
+def _twx_P(P):
+ """Define the boundary between Region 3w-3x, T=f(P)
+
+ >>> "%.7f" % _twx_P(22.3)
+ '648.2049480'
+ """
+ I = [0, 1, 2, -1, -2]
+ n = [0.728052609145380e1, 0.973505869861952e2, 0.147370491183191e2,
+ 0.329196213998375e3, 0.873371668682417e3]
+
+ Pr = P/1
+ T = 0
+ for i in range(5):
+ T += n[i]*log(Pr)**I[i]
+ return T
+
+
+def _tef_P(P):
+ """Define the boundary between Region 3e-3f, T=f(P)
+
+ >>> "%.7f" % _tef_P(40)
+ '713.9593992'
+ """
+ return 3.727888004*(P-22.064)+647.096
+
+
+def _txx_P(P, xx):
+ """Define the boundary between 3x-3y, T=f(P)
+ where xx represent the subregions options: cd, gh, ij, jk, mn, qu, rx, uv
+
+ >>> "%.7f" % _txx_P(25,"cd")
+ '649.3659208'
+ >>> "%.7f" % _txx_P(23,"gh")
+ '649.8873759'
+ >>> "%.7f" % _txx_P(23,"ij")
+ '651.5778091'
+ >>> "%.7f" % _txx_P(23,"jk")
+ '655.8338344'
+ >>> "%.7f" % _txx_P(22.8,"mn")
+ '649.6054133'
+ >>> "%.7f" % _txx_P(22,"qu")
+ '645.6355027'
+ >>> "%.7f" % _txx_P(22,"rx")
+ '648.2622754'
+ >>> "%.7f" % _txx_P(22.3,"uv")
+ '647.7996121'
+ """
+ ng = {
+ "cd": [0.585276966696349e3, 0.278233532206915e1, -0.127283549295878e-1,
+ 0.159090746562729e-3],
+ "gh": [-0.249284240900418e5, 0.428143584791546e4, -0.269029173140130e3,
+ 0.751608051114157e1, -0.787105249910383e-1],
+ "ij": [0.584814781649163e3, -0.616179320924617, 0.260763050899562,
+ -0.587071076864459e-2, 0.515308185433082e-4],
+ "jk": [0.617229772068439e3, -0.770600270141675e1, 0.697072596851896,
+ -0.157391839848015e-1, 0.137897492684194e-3],
+ "mn": [0.535339483742384e3, 0.761978122720128e1, -0.158365725441648,
+ 0.192871054508108e-2],
+ "qu": [0.565603648239126e3, 0.529062258221222e1, -0.102020639611016,
+ 0.122240301070145e-2],
+ "rx": [0.584561202520006e3, -0.102961025163669e1, 0.243293362700452,
+ -0.294905044740799e-2],
+ "uv": [0.528199646263062e3, 0.890579602135307e1, -0.222814134903755,
+ 0.286791682263697e-2]}
+
+ n = ng[xx]
+ Pr = P/1
+ T = 0
+ for i in range(len(n)):
+ T += n[i]*Pr**i
+ return T
+
+
+def _Backward3a_v_Ph(P, h):
+ """Backward equation for region 3a, v=f(P,h)
+
+ >>> "%.12f" % _Backward3a_v_Ph(20,1700)
+ '0.001749903962'
+ >>> "%.12f" % _Backward3a_v_Ph(100,2100)
+ '0.001676229776'
+ """
+ I = [-12, -12, -12, -12, -10, -10, -10, -8, -8, -6, -6, -6, -4, -4, -3, -2,
+ -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 8]
+ J = [6, 8, 12, 18, 4, 7, 10, 5, 12, 3, 4, 22, 2, 3, 7, 3, 16, 0, 1, 2, 3,
+ 0, 1, 0, 1, 2, 0, 2, 0, 2, 2, 2]
+ n = [0.529944062966028e-2, -0.170099690234461, 0.111323814312927e2,
+ -0.217898123145125e4, -0.506061827980875e-3, 0.556495239685324,
+ -0.943672726094016e1, -0.297856807561527, 0.939353943717186e2,
+ 0.192944939465981e-1, 0.421740664704763, -0.368914126282330e7,
+ -0.737566847600639e-2, -0.354753242424366, -0.199768169338727e1,
+ 0.115456297059049e1, 0.568366875815960e4, 0.808169540124668e-2,
+ 0.172416341519307, 0.104270175292927e1, -0.297691372792847,
+ 0.560394465163593, 0.275234661176914, -0.148347894866012,
+ -0.651142513478515e-1, -0.292468715386302e1, 0.664876096952665e-1,
+ 0.352335014263844e1, -0.146340792313332e-1, -0.224503486668184e1,
+ 0.110533464706142e1, -0.408757344495612e-1]
+
+ Pr = P/100
+ nu = h/2100
+ suma = 0
+ for i in range(32):
+ suma += n[i]*(Pr+0.128)**I[i]*(nu-0.727)**J[i]
+ return 0.0028*suma
+
+
+def _Backward3b_v_Ph(P, h):
+ """Backward equation for region 3b, v=f(P,h)
+
+ >>> "%.12f" % _Backward3b_v_Ph(20,2500)
+ '0.006670547043'
+ >>> "%.12f" % _Backward3b_v_Ph(100,2700)
+ '0.002404234998'
+ """
+ I = [-12, -12, -8, -8, -8, -8, -8, -8, -6, -6, -6, -6, -6, -6, -4, -4, -4,
+ -3, -3, -2, -2, -1, -1, -1, -1, 0, 1, 1, 2, 2]
+ J = [0, 1, 0, 1, 3, 6, 7, 8, 0, 1, 2, 5, 6, 10, 3, 6, 10, 0, 2, 1, 2, 0,
+ 1, 4, 5, 0, 0, 1, 2, 6]
+ n = [-0.225196934336318e-8, 0.140674363313486e-7, 0.233784085280560e-5,
+ -0.331833715229001e-4, 0.107956778514318e-2, -0.271382067378863,
+ 0.107202262490333e1, -0.853821329075382, -0.215214194340526e-4,
+ 0.769656088222730e-3, -0.431136580433864e-2, 0.453342167309331,
+ -0.507749535873652, -0.100475154528389e3, -0.219201924648793,
+ -0.321087965668917e1, 0.607567815637771e3, 0.557686450685932e-3,
+ 0.187499040029550, 0.905368030448107e-2, 0.285417173048685,
+ 0.329924030996098e-1, 0.239897419685483, 0.482754995951394e1,
+ -0.118035753702231e2, 0.169490044091791, -0.179967222507787e-1,
+ 0.371810116332674e-1, -0.536288335065096e-1, 0.160697101092520e1]
+
+ Pr = P/100
+ nu = h/2800
+ suma = 0
+ for i in range(30):
+ suma += n[i]*(Pr+0.0661)**I[i]*(nu-0.72)**J[i]
+ return 0.0088*suma
+
+
+def _Backward3_v_Ph(P, h):
+ """Backward equation for region 3, v=f(P,h)"""
+ hf = _h_3ab(P)
+ if h <= hf:
+ return _Backward3a_v_Ph(P, h)
+ else:
+ return _Backward3b_v_Ph(P, h)
+
+
+def _Backward3a_T_Ph(P, h):
+ """Backward equation for region 3a, T=f(P,h)
+
+ >>> "%.7f" % _Backward3a_T_Ph(20,1700)
+ '629.3083892'
+ >>> "%.7f" % _Backward3a_T_Ph(100,2100)
+ '733.6163014'
+ """
+ I = [-12, -12, -12, -12, -12, -12, -12, -12, -10, -10, -10, -8, -8, -8, -8,
+ -5, -3, -2, -2, -2, -1, -1, 0, 0, 1, 3, 3, 4, 4, 10, 12]
+ J = [0, 1, 2, 6, 14, 16, 20, 22, 1, 5, 12, 0, 2, 4, 10, 2, 0, 1, 3, 4, 0,
+ 2, 0, 1, 1, 0, 1, 0, 3, 4, 5]
+ n = [-0.133645667811215e-6, 0.455912656802978e-5, -0.146294640700979e-4,
+ 0.639341312970080e-2, 0.372783927268847e3, -0.718654377460447e4,
+ 0.573494752103400e6, -0.267569329111439e7, -0.334066283302614e-4,
+ -0.245479214069597e-1, 0.478087847764996e2, 0.764664131818904e-5,
+ 0.128350627676972e-2, 0.171219081377331e-1, -0.851007304583213e1,
+ -0.136513461629781e-1, -0.384460997596657e-5, 0.337423807911655e-2,
+ -0.551624873066791, 0.729202277107470, -0.992522757376041e-2,
+ -.119308831407288, .793929190615421, .454270731799386, .20999859125991,
+ -0.642109823904738e-2, -0.235155868604540e-1, 0.252233108341612e-2,
+ -0.764885133368119e-2, 0.136176427574291e-1, -0.133027883575669e-1]
+
+ Pr = P/100.
+ nu = h/2300.
+ suma = 0
+ for i, j, n in zip(I, J, n):
+ suma += n*(Pr+0.240)**i*(nu-0.615)**j
+ return 760*suma
+
+
+def _Backward3b_T_Ph(P, h):
+ """Backward equation for region 3b, T=f(P,h)
+
+ >>> "%.7f" % _Backward3b_T_Ph(20,2500)
+ '641.8418053'
+ >>> "%.7f" % _Backward3b_T_Ph(100,2700)
+ '842.0460876'
+ """
+ I = [-12, -12, -10, -10, -10, -10, -10, -8, -8, -8, -8, -8, -6, -6, -6, -4,
+ -4, -3, -2, -2, -1, -1, -1, -1, -1, -1, 0, 0, 1, 3, 5, 6, 8]
+ J = [0, 1, 0, 1, 5, 10, 12, 0, 1, 2, 4, 10, 0, 1, 2, 0, 1, 5, 0, 4, 2, 4,
+ 6, 10, 14, 16, 0, 2, 1, 1, 1, 1, 1]
+ n = [0.323254573644920e-4, -0.127575556587181e-3, -0.475851877356068e-3,
+ 0.156183014181602e-2, 0.105724860113781, -0.858514221132534e2,
+ 0.724140095480911e3, 0.296475810273257e-2, -0.592721983365988e-2,
+ -0.126305422818666e-1, -0.115716196364853, 0.849000969739595e2,
+ -0.108602260086615e-1, 0.154304475328851e-1, 0.750455441524466e-1,
+ 0.252520973612982e-1, -0.602507901232996e-1, -0.307622221350501e1,
+ -0.574011959864879e-1, 0.503471360939849e1, -0.925081888584834,
+ 0.391733882917546e1, -0.773146007130190e2, 0.949308762098587e4,
+ -0.141043719679409e7, 0.849166230819026e7, 0.861095729446704,
+ 0.323346442811720, 0.873281936020439, -0.436653048526683,
+ 0.286596714529479, -0.131778331276228, 0.676682064330275e-2]
+
+ Pr = P/100.
+ nu = h/2800.
+ suma = 0
+ for i, j, n in zip(I, J, n):
+ suma += n*(Pr+0.298)**i*(nu-0.72)**j
+ return 860*suma
+
+
+def _Backward3_T_Ph(P, h):
+ """Backward equation for region 3, T=f(P,h)"""
+ hf = _h_3ab(P)
+ if h <= hf:
+ T = _Backward3a_T_Ph(P, h)
+ else:
+ T = _Backward3b_T_Ph(P, h)
+ return T
+
+
+def _Backward3a_v_Ps(P, s):
+ """Backward equation for region 3a, v=f(P,s)
+
+ >>> "%.12f" % _Backward3a_v_Ps(20,3.8)
+ '0.001733791463'
+ >>> "%.12f" % _Backward3a_v_Ps(100,4)
+ '0.001555893131'
+ """
+ I = [-12, -12, -12, -10, -10, -10, -10, -8, -8, -8, -8, -6, -5, -4, -3, -3,
+ -2, -2, -1, -1, 0, 0, 0, 1, 2, 4, 5, 6]
+ J = [10, 12, 14, 4, 8, 10, 20, 5, 6, 14, 16, 28, 1, 5, 2, 4, 3, 8, 1, 2, 0,
+ 1, 3, 0, 0, 2, 2, 0]
+ n = [0.795544074093975e2, -0.238261242984590e4, 0.176813100617787e5,
+ -0.110524727080379e-2, -0.153213833655326e2, 0.297544599376982e3,
+ -0.350315206871242e8, 0.277513761062119, -0.523964271036888,
+ -0.148011182995403e6, 0.160014899374266e7, 0.170802322663427e13,
+ 0.246866996006494e-3, 0.165326084797980e1, -0.118008384666987,
+ 0.253798642355900e1, 0.965127704669424, -0.282172420532826e2,
+ 0.203224612353823, 0.110648186063513e1, 0.526127948451280,
+ 0.277000018736321, 0.108153340501132e1, -0.744127885357893e-1,
+ 0.164094443541384e-1, -0.680468275301065e-1, 0.257988576101640e-1,
+ -0.145749861944416e-3]
+
+ Pr = P/100
+ sigma = s/4.4
+ suma = 0
+ for i in range(28):
+ suma += n[i]*(Pr+0.187)**I[i]*(sigma-0.755)**J[i]
+ return 0.0028*suma
+
+
+def _Backward3b_v_Ps(P, s):
+ """Backward equation for region 3b, v=f(P,s)
+
+ >>> "%.12f" % _Backward3b_v_Ps(20,5)
+ '0.006262101987'
+ >>> "%.12f" % _Backward3b_v_Ps(100,5)
+ '0.002449610757'
+ """
+ I = [-12, -12, -12, -12, -12, -12, -10, -10, -10, -10, -8, -5, -5, -5, -4,
+ -4, -4, -4, -3, -2, -2, -2, -2, -2, -2, 0, 0, 0, 1, 1, 2]
+ J = [0, 1, 2, 3, 5, 6, 0, 1, 2, 4, 0, 1, 2, 3, 0, 1, 2, 3, 1, 0, 1, 2, 3,
+ 4, 12, 0, 1, 2, 0, 2, 2]
+ n = [0.591599780322238e-4, -0.185465997137856e-2, 0.104190510480013e-1,
+ 0.598647302038590e-2, -0.771391189901699, 0.172549765557036e1,
+ -0.467076079846526e-3, 0.134533823384439e-1, -0.808094336805495e-1,
+ 0.508139374365767, 0.128584643361683e-2, -0.163899353915435e1,
+ 0.586938199318063e1, -0.292466667918613e1, -0.614076301499537e-2,
+ 0.576199014049172e1, -0.121613320606788e2, 0.167637540957944e1,
+ -0.744135838773463e1, 0.378168091437659e-1, 0.401432203027688e1,
+ 0.160279837479185e2, 0.317848779347728e1, -0.358362310304853e1,
+ -0.115995260446827e7, 0.199256573577909, -0.122270624794624,
+ -0.191449143716586e2, -0.150448002905284e-1, 0.146407900162154e2,
+ -0.327477787188230e1]
+
+ Pr = P/100
+ sigma = s/5.3
+ suma = 0
+ for i in range(31):
+ suma += n[i]*(Pr+0.298)**I[i]*(sigma-0.816)**J[i]
+ return 0.0088*suma
+
+
+def _Backward3_v_Ps(P, s):
+ """Backward equation for region 3, v=f(P,s)"""
+ if s <= sc:
+ return _Backward3a_v_Ps(P, s)
+ else:
+ return _Backward3b_v_Ps(P, s)
+
+
+def _Backward3a_T_Ps(P, s):
+ """Backward equation for region 3a, T=f(P,s)
+
+ >>> "%.7f" % _Backward3a_T_Ps(20,3.8)
+ '628.2959869'
+ >>> "%.7f" % _Backward3a_T_Ps(100,4)
+ '705.6880237'
+ """
+ I = [-12, -12, -10, -10, -10, -10, -8, -8, -8, -8, -6, -6, -6, -5, -5, -5,
+ -4, -4, -4, -2, -2, -1, -1, 0, 0, 0, 1, 2, 2, 3, 8, 8, 10]
+ J = [28, 32, 4, 10, 12, 14, 5, 7, 8, 28, 2, 6, 32, 0, 14, 32, 6, 10, 36, 1,
+ 4, 1, 6, 0, 1, 4, 0, 0, 3, 2, 0, 1, 2]
+ n = [0.150042008263875e10, -0.159397258480424e12, 0.502181140217975e-3,
+ -0.672057767855466e2, 0.145058545404456e4, -0.823889534888890e4,
+ -0.154852214233853, 0.112305046746695e2, -0.297000213482822e2,
+ 0.438565132635495e11, 0.137837838635464e-2, -0.297478527157462e1,
+ 0.971777947349413e13, -0.571527767052398e-4, 0.288307949778420e5,
+ -0.744428289262703e14, 0.128017324848921e2, -0.368275545889071e3,
+ 0.664768904779177e16, 0.449359251958880e-1, -0.422897836099655e1,
+ -0.240614376434179, -0.474341365254924e1, 0.724093999126110,
+ 0.923874349695897, 0.399043655281015e1, 0.384066651868009e-1,
+ -0.359344365571848e-2, -0.735196448821653, 0.188367048396131,
+ 0.141064266818704e-3, -0.257418501496337e-2, 0.123220024851555e-2]
+
+ Pr = P/100
+ sigma = s/4.4
+ suma = 0
+ for i in range(33):
+ suma += n[i]*(Pr+0.240)**I[i]*(sigma-0.703)**J[i]
+ return 760*suma
+
+
+def _Backward3b_T_Ps(P, s):
+ """Backward equation for region 3b, T=f(P,s)
+
+ >>> "%.7f" % _Backward3b_T_Ps(20,5)
+ '640.1176443'
+ >>> "%.7f" % _Backward3b_T_Ps(100,5)
+ '847.4332825'
+ """
+ I = [-12, -12, -12, -12, -8, -8, -8, -6, -6, -6, -5, -5, -5, -5, -5, -4,
+ -3, -3, -2, 0, 2, 3, 4, 5, 6, 8, 12, 14]
+ J = [1, 3, 4, 7, 0, 1, 3, 0, 2, 4, 0, 1, 2, 4, 6, 12, 1, 6, 2, 0, 1, 1, 0,
+ 24, 0, 3, 1, 2]
+ n = [0.527111701601660, -0.401317830052742e2, 0.153020073134484e3,
+ -0.224799398218827e4, -0.193993484669048, -0.140467557893768e1,
+ 0.426799878114024e2, 0.752810643416743, 0.226657238616417e2,
+ -0.622873556909932e3, -0.660823667935396, 0.841267087271658,
+ -0.253717501764397e2, 0.485708963532948e3, 0.880531517490555e3,
+ 0.265015592794626e7, -0.359287150025783, -0.656991567673753e3,
+ 0.241768149185367e1, 0.856873461222588, 0.655143675313458,
+ -0.213535213206406, 0.562974957606348e-2, -0.316955725450471e15,
+ -0.699997000152457e-3, 0.119845803210767e-1, 0.193848122022095e-4,
+ -0.215095749182309e-4]
+
+ Pr = P/100
+ sigma = s/5.3
+ suma = 0
+ for i in range(28):
+ suma += n[i]*(Pr+0.760)**I[i]*(sigma-0.818)**J[i]
+ return 860*suma
+
+
+def _Backward3_T_Ps(P, s):
+ """Backward equation for region 3, T=f(P,s)"""
+ sc = 4.41202148223476
+ if s <= sc:
+ T = _Backward3a_T_Ps(P, s)
+ else:
+ T = _Backward3b_T_Ps(P, s)
+ return T
+
+
+def _Backward3a_P_hs(h, s):
+ """Backward equation for region 3a, P=f(h,s)
+
+ >>> "%.8f" % _Backward3a_P_hs(1700,3.8)
+ '25.55703246'
+ >>> "%.8f" % _Backward3a_P_hs(2000,4.2)
+ '45.40873468'
+ >>> "%.8f" % _Backward3a_P_hs(2100,4.3)
+ '60.78123340'
+ """
+ I = [0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 6, 7, 8, 10, 10,
+ 14, 18, 20, 22, 22, 24, 28, 28, 32, 32]
+ J = [0, 1, 5, 0, 3, 4, 8, 14, 6, 16, 0, 2, 3, 0, 1, 4, 5, 28, 28, 24, 1,
+ 32, 36, 22, 28, 36, 16, 28, 36, 16, 36, 10, 28]
+ n = [0.770889828326934e1, -0.260835009128688e2, 0.267416218930389e3,
+ 0.172221089496844e2, -0.293542332145970e3, 0.614135601882478e3,
+ -0.610562757725674e5, -0.651272251118219e8, 0.735919313521937e5,
+ -0.116646505914191e11, 0.355267086434461e2, -0.596144543825955e3,
+ -0.475842430145708e3, 0.696781965359503e2, 0.335674250377312e3,
+ 0.250526809130882e5, 0.146997380630766e6, 0.538069315091534e20,
+ 0.143619827291346e22, 0.364985866165994e20, -0.254741561156775e4,
+ 0.240120197096563e28, -0.393847464679496e30, 0.147073407024852e25,
+ -0.426391250432059e32, 0.194509340621077e39, 0.666212132114896e24,
+ 0.706777016552858e34, 0.175563621975576e42, 0.108408607429124e29,
+ 0.730872705175151e44, 0.159145847398870e25, 0.377121605943324e41]
+
+ nu = h/2300
+ sigma = s/4.4
+ suma = 0
+ for i in range(33):
+ suma += n[i]*(nu-1.01)**I[i]*(sigma-0.75)**J[i]
+ return 99*suma
+
+
+def _Backward3b_P_hs(h, s):
+ """Backward equation for region 3b, P=f(h,s)
+
+ >>> "%.8f" % _Backward3b_P_hs(2400,4.7)
+ '63.63924887'
+ >>> "%.8f" % _Backward3b_P_hs(2600,5.1)
+ '34.34999263'
+ >>> "%.8f" % _Backward3b_P_hs(2700,5.0)
+ '88.39043281'
+ """
+ I = [-12, -12, -12, -12, -12, -10, -10, -10, -10, -8, -8, -6, -6, -6, -6, -5,
+ -4, -4, -4, -3, -3, -3, -3, -2, -2, -1, 0, 2, 2, 5, 6, 8, 10, 14, 14]
+ J = [2, 10, 12, 14, 20, 2, 10, 14, 18, 2, 8, 2, 6, 7, 8, 10, 4, 5, 8, 1, 3,
+ 5, 6, 0, 1, 0, 3, 0, 1, 0, 1, 1, 1, 3, 7]
+ n = [0.125244360717979e-12, -0.126599322553713e-1, 0.506878030140626e1,
+ 0.317847171154202e2, -0.391041161399932e6, -0.975733406392044e-10,
+ -0.186312419488279e2, 0.510973543414101e3, 0.373847005822362e6,
+ 0.299804024666572e-7, 0.200544393820342e2, -0.498030487662829e-5,
+ -0.102301806360030e2, 0.552819126990325e2, -0.206211367510878e3,
+ -0.794012232324823e4, 0.782248472028153e1, -0.586544326902468e2,
+ 0.355073647696481e4, -0.115303107290162e-3, -0.175092403171802e1,
+ 0.257981687748160e3, -0.727048374179467e3, 0.121644822609198e-3,
+ 0.393137871762692e-1, 0.704181005909296e-2, -0.829108200698110e2,
+ -0.265178818131250, 0.137531682453991e2, -0.522394090753046e2,
+ 0.240556298941048e4, -0.227361631268929e5, 0.890746343932567e5,
+ -0.239234565822486e8, 0.568795808129714e10]
+
+ nu = h/2800
+ sigma = s/5.3
+ suma = 0
+ for i in range(35):
+ suma += n[i]*(nu-0.681)**I[i]*(sigma-0.792)**J[i]
+ return 16.6/suma
+
+
+def _Backward3_P_hs(h, s):
+ """Backward equation for region 3, P=f(h,s)"""
+ sc = 4.41202148223476
+ if s <= sc:
+ return _Backward3a_P_hs(h, s)
+ else:
+ return _Backward3b_P_hs(h, s)
+
+
+def _Backward3_v_PT(P, T):
+ """Backward equation for region 3, v=f(P,T)"""
+ if P > 40:
+ if T <= _tab_P(P):
+ region = "a"
+ else:
+ region = "b"
+ elif 25 < P <= 40:
+ tcd = _txx_P(P, "cd")
+ tab = _tab_P(P)
+ tef = _tef_P(P)
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= tab:
+ region = "d"
+ elif tab < T <= tef:
+ region = "e"
+ else:
+ region = "f"
+ elif 23.5 < P <= 25:
+ tcd = _txx_P(P, "cd")
+ tgh = _txx_P(P, "gh")
+ tef = _tef_P(P)
+ tij = _txx_P(P, "ij")
+ tjk = _txx_P(P, "jk")
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= tgh:
+ region = "g"
+ elif tgh < T <= tef:
+ region = "h"
+ elif tef < T <= tij:
+ region = "i"
+ elif tij < T <= tjk:
+ region = "j"
+ else:
+ region = "k"
+ elif 23 < P <= 23.5:
+ tcd = _txx_P(P, "cd")
+ tgh = _txx_P(P, "gh")
+ tef = _tef_P(P)
+ tij = _txx_P(P, "ij")
+ tjk = _txx_P(P, "jk")
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= tgh:
+ region = "l"
+ elif tgh < T <= tef:
+ region = "h"
+ elif tef < T <= tij:
+ region = "i"
+ elif tij < T <= tjk:
+ region = "j"
+ else:
+ region = "k"
+ elif 22.5 < P <= 23:
+ tcd = _txx_P(P, "cd")
+ tgh = _txx_P(P, "gh")
+ tmn = _txx_P(P, "mn")
+ tef = _tef_P(P)
+ top = _top_P(P)
+ tij = _txx_P(P, "ij")
+ tjk = _txx_P(P, "jk")
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= tgh:
+ region = "l"
+ elif tgh < T <= tmn:
+ region = "m"
+ elif tmn < T <= tef:
+ region = "n"
+ elif tef < T <= top:
+ region = "o"
+ elif top < T <= tij:
+ region = "p"
+ elif tij < T <= tjk:
+ region = "j"
+ else:
+ region = "k"
+ elif _PSat_T(643.15) < P <= 22.5:
+ tcd = _txx_P(P, "cd")
+ tqu = _txx_P(P, "qu")
+ trx = _txx_P(P, "rx")
+ tjk = _txx_P(P, "jk")
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= tqu:
+ region = "q"
+ elif tqu < T <= trx:
+ tef = _tef_P(P)
+ twx = _twx_P(P)
+ tuv = _txx_P(P, "uv")
+ if 22.11 < P <= 22.5:
+ if T <= tuv:
+ region = "u"
+ elif tuv <= T <= tef:
+ region = "v"
+ elif tef <= T <= twx:
+ region = "w"
+ else:
+ region = "x"
+ elif 22.064 < P <= 22.11:
+ if T <= tuv:
+ region = "u"
+ elif tuv <= T <= tef:
+ region = "y"
+ elif tef <= T <= twx:
+ region = "z"
+ else:
+ region = "x"
+ elif T > _TSat_P(P):
+ if _PSat_T(643.15) < P <= 21.90096265:
+ region = "x"
+ elif 21.90096265 < P <= 22.064:
+ if T <= twx:
+ region = "z"
+ else:
+ region = "x"
+ elif T <= _TSat_P(P):
+ if _PSat_T(643.15) < P <= 21.93161551:
+ region = "u"
+ elif 21.93161551 < P <= 22.064:
+ if T <= tuv:
+ region = "u"
+ else:
+ region = "y"
+ elif trx < T <= tjk:
+ region = "r"
+ else:
+ region = "k"
+ elif 20.5 < P <= _PSat_T(643.15):
+ tcd = _txx_P(P, "cd")
+ Ts = _TSat_P(P)
+ tjk = _txx_P(P, "jk")
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= Ts:
+ region = "s"
+ elif Ts < T <= tjk:
+ region = "r"
+ else:
+ region = "k"
+ elif 19.00881189 < P <= 20.5:
+ tcd = _txx_P(P, "cd")
+ Ts = _TSat_P(P)
+ if T <= tcd:
+ region = "c"
+ elif tcd < T <= Ts:
+ region = "s"
+ else:
+ region = "t"
+ elif _PSat_T(623.15) < P <= 19.00881189:
+ Ts = _TSat_P(P)
+ if T <= Ts:
+ region = "c"
+ else:
+ region = "t"
+
+ return _Backward3x_v_PT(T, P, region)
+
+
+def _Backward3x_v_PT(T, P, x):
+ """Backward equation for region 3x, v=f(P,T)
+
+ >>> "%.12f" % _Backward3x_v_PT(630,50,"a")
+ '0.001470853100'
+ >>> "%.12f" % _Backward3x_v_PT(670,80,"a")
+ '0.001503831359'
+ >>> "%.12f" % _Backward3x_v_PT(710,50,"b")
+ '0.002204728587'
+ >>> "%.12f" % _Backward3x_v_PT(750,80,"b")
+ '0.001973692940'
+ >>> "%.12f" % _Backward3x_v_PT(630,20,"c")
+ '0.001761696406'
+ >>> "%.12f" % _Backward3x_v_PT(650,30,"c")
+ '0.001819560617'
+ >>> "%.12f" % _Backward3x_v_PT(656,26,"d")
+ '0.002245587720'
+ >>> "%.12f" % _Backward3x_v_PT(670,30,"d")
+ '0.002506897702'
+ >>> "%.12f" % _Backward3x_v_PT(661,26,"e")
+ '0.002970225962'
+ >>> "%.12f" % _Backward3x_v_PT(675,30,"e")
+ '0.003004627086'
+ >>> "%.12f" % _Backward3x_v_PT(671,26,"f")
+ '0.005019029401'
+ >>> "%.12f" % _Backward3x_v_PT(690,30,"f")
+ '0.004656470142'
+ >>> "%.12f" % _Backward3x_v_PT(649,23.6,"g")
+ '0.002163198378'
+ >>> "%.12f" % _Backward3x_v_PT(650,24,"g")
+ '0.002166044161'
+ >>> "%.12f" % _Backward3x_v_PT(652,23.6,"h")
+ '0.002651081407'
+ >>> "%.12f" % _Backward3x_v_PT(654,24,"h")
+ '0.002967802335'
+ >>> "%.12f" % _Backward3x_v_PT(653,23.6,"i")
+ '0.003273916816'
+ >>> "%.12f" % _Backward3x_v_PT(655,24,"i")
+ '0.003550329864'
+ >>> "%.12f" % _Backward3x_v_PT(655,23.5,"j")
+ '0.004545001142'
+ >>> "%.12f" % _Backward3x_v_PT(660,24,"j")
+ '0.005100267704'
+ >>> "%.12f" % _Backward3x_v_PT(660,23,"k")
+ '0.006109525997'
+ >>> "%.12f" % _Backward3x_v_PT(670,24,"k")
+ '0.006427325645'
+ >>> "%.12f" % _Backward3x_v_PT(646,22.6,"l")
+ '0.002117860851'
+ >>> "%.12f" % _Backward3x_v_PT(646,23,"l")
+ '0.002062374674'
+ >>> "%.12f" % _Backward3x_v_PT(648.6,22.6,"m")
+ '0.002533063780'
+ >>> "%.12f" % _Backward3x_v_PT(649.3,22.8,"m")
+ '0.002572971781'
+ >>> "%.12f" % _Backward3x_v_PT(649,22.6,"n")
+ '0.002923432711'
+ >>> "%.12f" % _Backward3x_v_PT(649.7,22.8,"n")
+ '0.002913311494'
+ >>> "%.12f" % _Backward3x_v_PT(649.1,22.6,"o")
+ '0.003131208996'
+ >>> "%.12f" % _Backward3x_v_PT(649.9,22.8,"o")
+ '0.003221160278'
+ >>> "%.12f" % _Backward3x_v_PT(649.4,22.6,"p")
+ '0.003715596186'
+ >>> "%.12f" % _Backward3x_v_PT(650.2,22.8,"p")
+ '0.003664754790'
+ >>> "%.12f" % _Backward3x_v_PT(640,21.1,"q")
+ '0.001970999272'
+ >>> "%.12f" % _Backward3x_v_PT(643,21.8,"q")
+ '0.002043919161'
+ >>> "%.12f" % _Backward3x_v_PT(644,21.1,"r")
+ '0.005251009921'
+ >>> "%.12f" % _Backward3x_v_PT(648,21.8,"r")
+ '0.005256844741'
+ >>> "%.12f" % _Backward3x_v_PT(635,19.1,"s")
+ '0.001932829079'
+ >>> "%.12f" % _Backward3x_v_PT(638,20,"s")
+ '0.001985387227'
+ >>> "%.12f" % _Backward3x_v_PT(626,17,"t")
+ '0.008483262001'
+ >>> "%.12f" % _Backward3x_v_PT(640,20,"t")
+ '0.006227528101'
+ >>> "%.12f" % _Backward3x_v_PT(644.6,21.5,"u")
+ '0.002268366647'
+ >>> "%.12f" % _Backward3x_v_PT(646.1,22,"u")
+ '0.002296350553'
+ >>> "%.12f" % _Backward3x_v_PT(648.6,22.5,"v")
+ '0.002832373260'
+ >>> "%.12f" % _Backward3x_v_PT(647.9,22.3,"v")
+ '0.002811424405'
+ >>> "%.12f" % _Backward3x_v_PT(647.5,22.15,"w")
+ '0.003694032281'
+ >>> "%.12f" % _Backward3x_v_PT(648.1,22.3,"w")
+ '0.003622226305'
+ >>> "%.12f" % _Backward3x_v_PT(648,22.11,"x")
+ '0.004528072649'
+ >>> "%.12f" % _Backward3x_v_PT(649,22.3,"x")
+ '0.004556905799'
+ >>> "%.12f" % _Backward3x_v_PT(646.84,22,"y")
+ '0.002698354719'
+ >>> "%.12f" % _Backward3x_v_PT(647.05,22.064,"y")
+ '0.002717655648'
+ >>> "%.12f" % _Backward3x_v_PT(646.89,22,"z")
+ '0.003798732962'
+ >>> "%.12f" % _Backward3x_v_PT(647.15,22.064,"z")
+ '0.003701940009'
+ """
+ par = {
+ "a": [0.0024, 100, 760, 30, 0.085, 0.817, 1, 1, 1],
+ "b": [0.0041, 100, 860, 32, 0.280, 0.779, 1, 1, 1],
+ "c": [0.0022, 40, 690, 35, 0.259, 0.903, 1, 1, 1],
+ "d": [0.0029, 40, 690, 38, 0.559, 0.939, 1, 1, 4],
+ "e": [0.0032, 40, 710, 29, 0.587, 0.918, 1, 1, 1],
+ "f": [0.0064, 40, 730, 42, 0.587, 0.891, 0.5, 1, 4],
+ "g": [0.0027, 25, 660, 38, 0.872, 0.971, 1, 1, 4],
+ "h": [0.0032, 25, 660, 29, 0.898, 0.983, 1, 1, 4],
+ "i": [0.0041, 25, 660, 42, 0.910, 0.984, 0.5, 1, 4],
+ "j": [0.0054, 25, 670, 29, 0.875, 0.964, 0.5, 1, 4],
+ "k": [0.0077, 25, 680, 34, 0.802, 0.935, 1, 1, 1],
+ "l": [0.0026, 24, 650, 43, 0.908, 0.989, 1, 1, 4],
+ "m": [0.0028, 23, 650, 40, 1.000, 0.997, 1, 0.25, 1],
+ "n": [0.0031, 23, 650, 39, 0.976, 0.997, None, None, None],
+ "o": [0.0034, 23, 650, 24, 0.974, 0.996, 0.5, 1, 1],
+ "p": [0.0041, 23, 650, 27, 0.972, 0.997, 0.5, 1, 1],
+ "q": [0.0022, 23, 650, 24, 0.848, 0.983, 1, 1, 4],
+ "r": [0.0054, 23, 650, 27, 0.874, 0.982, 1, 1, 1],
+ "s": [0.0022, 21, 640, 29, 0.886, 0.990, 1, 1, 4],
+ "t": [0.0088, 20, 650, 33, 0.803, 1.020, 1, 1, 1],
+ "u": [0.0026, 23, 650, 38, 0.902, 0.988, 1, 1, 1],
+ "v": [0.0031, 23, 650, 39, 0.960, 0.995, 1, 1, 1],
+ "w": [0.0039, 23, 650, 35, 0.959, 0.995, 1, 1, 4],
+ "x": [0.0049, 23, 650, 36, 0.910, 0.988, 1, 1, 1],
+ "y": [0.0031, 22, 650, 20, 0.996, 0.994, 1, 1, 4],
+ "z": [0.0038, 22, 650, 23, 0.993, 0.994, 1, 1, 4],
+ }
+
+ I = {
+ "a": [-12, -12, -12, -10, -10, -10, -8, -8, -8, -6, -5, -5, -5, -4, -3,
+ -3, -3, -3, -2, -2, -2, -1, -1, -1, 0, 0, 1, 1, 2, 2],
+ "b": [-12, -12, -10, -10, -8, -6, -6, -6, -5, -5, -5, -4, -4, -4, -3,
+ -3, -3, -3, -3, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 3, 4, 4],
+ "c": [-12, -12, -12, -10, -10, -10, -8, -8, -8, -6, -5, -5, -5, -4, -4,
+ -3, -3, -2, -2, -2, -1, -1, -1, 0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 8],
+ "d": [-12, -12, -12, -12, -12, -12, -10, -10, -10, -10, -10, -10, -10,
+ -8, -8, -8, -8, -6, -6, -5, -5, -5, -5, -4, -4, -4, -3, -3, -2,
+ -2, -1, -1, -1, 0, 0, 1, 1, 3],
+ "e": [-12, -12, -10, -10, -10, -10, -10, -8, -8, -8, -6, -5, -4, -4,
+ -3, -3, -3, -2, -2, -2, -2, -1, 0, 0, 1, 1, 1, 2, 2],
+ "f": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7,
+ 10, 12, 12, 12, 14, 14, 14, 14, 14, 16, 16, 18, 18, 20, 20, 20,
+ 22, 24, 24, 28, 32],
+ "g": [-12, -12, -12, -12, -12, -12, -10, -10, -10, -8, -8, -8, -8, -6,
+ -6, -5, -5, -4, -3, -2, -2, -2, -2, -1, -1, -1, 0, 0, 0, 1, 1, 1,
+ 3, 5, 6, 8, 10, 10],
+ "h": [-12, -12, -10, -10, -10, -10, -10, -10, -8, -8, -8, -8, -8, -6,
+ -6, -6, -5, -5, -5, -4, -4, -3, -3, -2, -1, -1, 0, 1, 1],
+ "i": [0, 0, 0, 1, 1, 1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 7, 7, 8, 8, 10,
+ 12, 12, 12, 14, 14, 14, 14, 18, 18, 18, 18, 18, 20, 20, 22, 24,
+ 24, 32, 32, 36, 36],
+ "j": [0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 10, 12, 12, 14, 14,
+ 14, 16, 18, 20, 20, 24, 24, 28, 28],
+ "k": [-2, -2, -1, -1, 0, -0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2,
+ 2, 2, 2, 2, 5, 5, 5, 6, 6, 6, 6, 8, 10, 12],
+ "l": [-12, -12, -12, -12, -12, -10, -10, -8, -8, -8, -8, -8, -8, -8,
+ -6, -5, -5, -4, -4, -3, -3, -3, -3, -2, -2, -2, -1, -1, -1, 0, 0,
+ 0, 0, 1, 1, 2, 4, 5, 5, 6, 10, 10, 14],
+ "m": [0, 3, 8, 20, 1, 3, 4, 5, 1, 6, 2, 4, 14, 2, 5, 3, 0, 1, 1, 1, 28,
+ 2, 16, 0, 5, 0, 3, 4, 12, 16, 1, 8, 14, 0, 2, 3, 4, 8, 14, 24],
+ "n": [0, 3, 4, 6, 7, 10, 12, 14, 18, 0, 3, 5, 6, 8, 12, 0, 3, 7, 12,
+ 2, 3, 4, 2, 4, 7, 4, 3, 5, 6, 0, 0, 3, 1, 0, 1, 0, 1, 0, 1],
+ "o": [0, 0, 0, 2, 3, 4, 4, 4, 4, 4, 5, 5, 6, 7, 8, 8, 8, 10, 10, 14,
+ 14, 20, 20, 24],
+ "p": [0, 0, 0, 0, 1, 2, 3, 3, 4, 6, 7, 7, 8, 10, 12, 12, 12, 14, 14,
+ 14, 16, 18, 20, 22, 24, 24, 36],
+ "q": [-12, -12, -10, -10, -10, -10, -8, -6, -5, -5, -4, -4, -3, -2,
+ -2, -2, -2, -1, -1, -1, 0, 1, 1, 1],
+ "r": [-8, -8, -3, -3, -3, -3, -3, 0, 0, 0, 0, 3, 3, 8, 8, 8, 8, 10,
+ 10, 10, 10, 10, 10, 10, 10, 12, 14],
+ "s": [-12, -12, -10, -8, -6, -5, -5, -4, -4, -3, -3, -2, -1, -1, -1, 0,
+ 0, 0, 0, 1, 1, 3, 3, 3, 4, 4, 4, 5, 14],
+ "t": [0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 7, 7, 7, 7, 7, 10, 10, 10,
+ 10, 10, 18, 20, 22, 22, 24, 28, 32, 32, 32, 36],
+ "u": [-12, -10, -10, -10, -8, -8, -8, -6, -6, -5, -5, -5, -3, -1, -1,
+ -1, -1, 0, 0, 1, 2, 2, 3, 5, 5, 5, 6, 6, 8, 8, 10, 12, 12, 12,
+ 14, 14, 14, 14],
+ "v": [-10, -8, -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5, -4, -4,
+ -4, -4, -3, -3, -3, -2, -2, -1, -1, 0, 0, 0, 1, 1, 3, 4, 4, 4, 5,
+ 8, 10, 12, 14],
+ "w": [-12, -12, -10, -10, -8, -8, -8, -6, -6, -6, -6, -5, -4, -4, -3, -3,
+ -2, -2, -1, -1, -1, 0, 0, 1, 2, 2, 3, 3, 5, 5, 5, 8, 8, 10, 10],
+ "x": [-8, -6, -5, -4, -4, -4, -3, -3, -1, 0, 0, 0, 1, 1, 2, 3, 3, 3, 4,
+ 5, 5, 5, 6, 8, 8, 8, 8, 10, 12, 12, 12, 12, 14, 14, 14, 14],
+ "y": [0, 0, 0, 0, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 8, 8, 10, 12],
+ "z": [-8, -6, -5, -5, -4, -4, -4, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 6,
+ 6, 6, 6, 8, 8]}
+
+ J = {
+ "a": [5, 10, 12, 5, 10, 12, 5, 8, 10, 1, 1, 5, 10, 8, 0, 1, 3, 6, 0,
+ 2, 3, 0, 1, 2, 0, 1, 0, 2, 0, 2],
+ "b": [10, 12, 8, 14, 8, 5, 6, 8, 5, 8, 10, 2, 4, 5, 0, 1, 2, 3, 5, 0,
+ 2, 5, 0, 2, 0, 1, 0, 2, 0, 2, 0, 1],
+ "c": [6, 8, 10, 6, 8, 10, 5, 6, 7, 8, 1, 4, 7, 2, 8, 0, 3, 0, 4, 5, 0,
+ 1, 2, 0, 1, 2, 0, 2, 0, 1, 3, 7, 0, 7, 1],
+ "d": [4, 6, 7, 10, 12, 16, 0, 2, 4, 6, 8, 10, 14, 3, 7, 8, 10, 6, 8, 1,
+ 2, 5, 7, 0, 1, 7, 2, 4, 0, 1, 0, 1, 5, 0, 2, 0, 6, 0],
+ "e": [14, 16, 3, 6, 10, 14, 16, 7, 8, 10, 6, 6, 2, 4, 2, 6, 7, 0, 1,
+ 3, 4, 0, 0, 1, 0, 4, 6, 0, 2],
+ "f": [-3, -2, -1, 0, 1, 2, -1, 1, 2, 3, 0, 1, -5, -2, 0, -3, -8, 1, -6,
+ -4, 1, -6, -10, -8, -4, -12, -10, -8, -6, -4, -10, -8, -12, -10,
+ -12, -10, -6, -12, -12, -4, -12, -12],
+ "g": [7, 12, 14, 18, 22, 24, 14, 20, 24, 7, 8, 10, 12, 8, 22, 7, 20, 22,
+ 7, 3, 5, 14, 24, 2, 8, 18, 0, 1, 2, 0, 1, 3, 24, 22, 12, 3, 0, 6],
+ "h": [8, 12, 4, 6, 8, 10, 14, 16, 0, 1, 6, 7, 8, 4, 6, 8, 2, 3, 4, 2,
+ 4, 1, 2, 0, 0, 2, 0, 0, 2],
+ "i": [0, 1, 10, -4, -2, -1, 0, 0, -5, 0, -3, -2, -1, -6, -1, 12, -4,
+ -3, -6, 10, -8, -12, -6, -4, -10, -8, -4, 5, -12, -10, -8, -6,
+ 2, -12, -10, -12, -12, -8, -10, -5, -10, -8],
+ "j": [-1, 0, 1, -2, -1, 1, -1, 1, -2, -2, 2, -3, -2, 0, 3, -6, -8, -3,
+ -10, -8, -5, -10, -12, -12, -10, -12, -6, -12, -5],
+ "k": [10, 12, -5, 6, -12, -6, -2, -1, 0, 1, 2, 3, 14, -3, -2, 0, 1, 2,
+ -8, -6, -3, -2, 0, 4, -12, -6, -3, -12, -10, -8, -5, -12, -12, -10],
+ "l": [14, 16, 18, 20, 22, 14, 24, 6, 10, 12, 14, 18, 24, 36, 8, 4, 5,
+ 7, 16, 1, 3, 18, 20, 2, 3, 10, 0, 1, 3, 0, 1, 2, 12, 0, 16, 1, 0,
+ 0, 1, 14, 4, 12, 10],
+ "m": [0, 0, 0, 2, 5, 5, 5, 5, 6, 6, 7, 8, 8, 10, 10, 12, 14, 14, 18,
+ 20, 20, 22, 22, 24, 24, 28, 28, 28, 28, 28, 32, 32, 32, 36, 36,
+ 36, 36, 36, 36, 36],
+ "n": [-12, -12, -12, -12, -12, -12, -12, -12, -12, -10, -10, -10, -10,
+ -10, -10, -8, -8, -8, -8, -6, -6, -6, -5, -5, -5, -4, -3, -3,
+ -3, -2, -1, -1, 0, 1, 1, 2, 4, 5, 6],
+ "o": [-12, -4, -1, -1, -10, -12, -8, -5, -4, -1, -4, -3, -8, -12, -10,
+ -8, -4, -12, -8, -12, -8, -12, -10, -12],
+ "p": [-1, 0, 1, 2, 1, -1, -3, 0, -2, -2, -5, -4, -2, -3, -12, -6, -5,
+ -10, -8, -3, -8, -8, -10, -10, -12, -8, -12],
+ "q": [10, 12, 6, 7, 8, 10, 8, 6, 2, 5, 3, 4, 3, 0, 1, 2, 4, 0, 1, 2,
+ 0, 0, 1, 3],
+ "r": [6, 14, -3, 3, 4, 5, 8, -1, 0, 1, 5, -6, -2, -12, -10, -8, -5,
+ -12, -10, -8, -6, -5, -4, -3, -2, -12, -12],
+ "s": [20, 24, 22, 14, 36, 8, 16, 6, 32, 3, 8, 4, 1, 2, 3, 0, 1, 4, 28,
+ 0, 32, 0, 1, 2, 3, 18, 24, 4, 24],
+ "t": [0, 1, 4, 12, 0, 10, 0, 6, 14, 3, 8, 0, 10, 3, 4, 7, 20, 36, 10,
+ 12, 14, 16, 22, 18, 32, 22, 36, 24, 28, 22, 32, 36, 36],
+ "u": [14, 10, 12, 14, 10, 12, 14, 8, 12, 4, 8, 12, 2, -1, 1, 12, 14,
+ -3, 1, -2, 5, 10, -5, -4, 2, 3, -5, 2, -8, 8, -4, -12, -4, 4,
+ -12, -10, -6, 6],
+ "v": [-8, -12, -12, -3, 5, 6, 8, 10, 1, 2, 6, 8, 10, 14, -12, -10, -6,
+ 10, -3, 10, 12, 2, 4, -2, 0, -2, 6, 10, -12, -10, 3, -6, 3, 10,
+ 2, -12, -2, -3, 1],
+ "w": [8, 14, -1, 8, 6, 8, 14, -4, -3, 2, 8, -10, -1, 3, -10, 3, 1, 2, -8,
+ -4, 1, -12, 1, -1, -1, 2, -12, -5, -10, -8, -6, -12, -10, -12, -8],
+ "x": [14, 10, 10, 1, 2, 14, -2, 12, 5, 0, 4, 10, -10, -1, 6, -12, 0, 8,
+ 3, -6, -2, 1, 1, -6, -3, 1, 8, -8, -10, -8, -5, -4, -12, -10, -8, -6],
+ "y": [-3, 1, 5, 8, 8, -4, -1, 4, 5, -8, 4, 8, -6, 6, -2, 1, -8, -2, -5, -8],
+ "z": [3, 6, 6, 8, 5, 6, 8, -2, 5, 6, 2, -6, 3, 1, 6, -6, -2, -6, -5,
+ -4, -1, -8, -4]}
+
+ n = {
+ "a": [0.110879558823853e-2, 0.572616740810616e3, -0.767051948380852e5,
+ -0.253321069529674e-1, 0.628008049345689e4, 0.234105654131876e6,
+ 0.216867826045856, -0.156237904341963e3, -0.269893956176613e5,
+ -0.180407100085505e-3, 0.116732227668261e-2, 0.266987040856040e2,
+ 0.282776617243286e5, -0.242431520029523e4, 0.435217323022733e-3,
+ -0.122494831387441e-1, 0.179357604019989e1, 0.442729521058314e2,
+ -0.593223489018342e-2, 0.453186261685774, 0.135825703129140e1,
+ 0.408748415856745e-1, 0.474686397863312, 0.118646814997915e1,
+ 0.546987265727549, 0.195266770452643, -0.502268790869663e-1,
+ -0.369645308193377, 0.633828037528420e-2, 0.797441793901017e-1],
+ "b": [-0.827670470003621e-1, 0.416887126010565e2, 0.483651982197059e-1,
+ -0.291032084950276e5, -0.111422582236948e3, -.202300083904014e-1,
+ 0.294002509338515e3, 0.140244997609658e3, -0.344384158811459e3,
+ 0.361182452612149e3, -0.140699677420738e4, -0.202023902676481e-2,
+ 0.171346792457471e3, -0.425597804058632e1, 0.691346085000334e-5,
+ 0.151140509678925e-2, -0.416375290166236e-1, -.413754957011042e2,
+ -0.506673295721637e2, -0.572212965569023e-3, 0.608817368401785e1,
+ 0.239600660256161e2, 0.122261479925384e-1, 0.216356057692938e1,
+ 0.398198903368642, -0.116892827834085, -0.102845919373532,
+ -0.492676637589284, 0.655540456406790e-1, -0.240462535078530,
+ -0.269798180310075e-1, 0.128369435967012],
+ "c": [0.311967788763030e1, 0.276713458847564e5, 0.322583103403269e8,
+ -0.342416065095363e3, -0.899732529907377e6, -0.793892049821251e8,
+ 0.953193003217388e2, 0.229784742345072e4, 0.175336675322499e6,
+ 0.791214365222792e7, 0.319933345844209e-4, -0.659508863555767e2,
+ -0.833426563212851e6, 0.645734680583292e-1, -0.382031020570813e7,
+ 0.406398848470079e-4, 0.310327498492008e2, -0.892996718483724e-3,
+ 0.234604891591616e3, 0.377515668966951e4, 0.158646812591361e-1,
+ 0.707906336241843, 0.126016225146570e2, 0.736143655772152,
+ 0.676544268999101, -0.178100588189137e2, -0.156531975531713,
+ 0.117707430048158e2, 0.840143653860447e-1, -0.186442467471949,
+ -0.440170203949645e2, 0.123290423502494e7, -0.240650039730845e-1,
+ -0.107077716660869e7, 0.438319858566475e-1],
+ "d": [-0.452484847171645e-9, .315210389538801e-4, -.214991352047545e-2,
+ 0.508058874808345e3, -0.127123036845932e8, 0.115371133120497e13,
+ -.197805728776273e-15, .241554806033972e-10, -.156481703640525e-5,
+ 0.277211346836625e-2, -0.203578994462286e2, 0.144369489909053e7,
+ -0.411254217946539e11, 0.623449786243773e-5, -.221774281146038e2,
+ -0.689315087933158e5, -0.195419525060713e8, 0.316373510564015e4,
+ 0.224040754426988e7, -0.436701347922356e-5, -.404213852833996e-3,
+ -0.348153203414663e3, -0.385294213555289e6, 0.135203700099403e-6,
+ 0.134648383271089e-3, 0.125031835351736e6, 0.968123678455841e-1,
+ 0.225660517512438e3, -0.190102435341872e-3, -.299628410819229e-1,
+ 0.500833915372121e-2, 0.387842482998411, -0.138535367777182e4,
+ 0.870745245971773, 0.171946252068742e1, -0.326650121426383e-1,
+ 0.498044171727877e4, 0.551478022765087e-2],
+ "e": [0.715815808404721e9, -0.114328360753449e12, .376531002015720e-11,
+ -0.903983668691157e-4, 0.665695908836252e6, 0.535364174960127e10,
+ 0.794977402335603e11, 0.922230563421437e2, -0.142586073991215e6,
+ -0.111796381424162e7, 0.896121629640760e4, -0.669989239070491e4,
+ 0.451242538486834e-2, -0.339731325977713e2, -0.120523111552278e1,
+ 0.475992667717124e5, -0.266627750390341e6, -0.153314954386524e-3,
+ 0.305638404828265, 0.123654999499486e3, -0.104390794213011e4,
+ -0.157496516174308e-1, 0.685331118940253, 0.178373462873903e1,
+ -0.544674124878910, 0.204529931318843e4, -0.228342359328752e5,
+ 0.413197481515899, -0.341931835910405e2],
+ "f": [-0.251756547792325e-7, .601307193668763e-5, -.100615977450049e-2,
+ 0.999969140252192, 0.214107759236486e1, -0.165175571959086e2,
+ -0.141987303638727e-2, 0.269251915156554e1, 0.349741815858722e2,
+ -0.300208695771783e2, -0.131546288252539e1, -0.839091277286169e1,
+ 0.181545608337015e-9, -0.591099206478909e-3, 0.152115067087106e1,
+ 0.252956470663225e-4, 0.100726265203786e-14, -0.14977453386065e1,
+ -0.793940970562969e-9, -0.150290891264717e-3, .151205531275133e1,
+ 0.470942606221652e-5, .195049710391712e-12, -.911627886266077e-8,
+ .604374640201265e-3, -.225132933900136e-15, .610916973582981e-11,
+ -.303063908043404e-6, -.137796070798409e-4, -.919296736666106e-3,
+ .639288223132545e-9, .753259479898699e-6, -0.400321478682929e-12,
+ .756140294351614e-8, -.912082054034891e-11, -.237612381140539e-7,
+ 0.269586010591874e-4, -.732828135157839e-10, .241995578306660e-9,
+ -.405735532730322e-3, .189424143498011e-9, -.486632965074563e-9],
+ "g": [0.412209020652996e-4, -0.114987238280587e7, 0.948180885032080e10,
+ -0.195788865718971e18, 0.4962507048713e25, -0.105549884548496e29,
+ -0.758642165988278e12, -.922172769596101e23, .725379072059348e30,
+ -0.617718249205859e2, 0.107555033344858e5, -0.379545802336487e8,
+ 0.228646846221831e12, -0.499741093010619e7, -.280214310054101e31,
+ 0.104915406769586e7, 0.613754229168619e28, 0.802056715528378e32,
+ -0.298617819828065e8, -0.910782540134681e2, 0.135033227281565e6,
+ -0.712949383408211e19, -0.104578785289542e37, .304331584444093e2,
+ 0.593250797959445e10, -0.364174062110798e28, 0.921791403532461,
+ -0.337693609657471, -0.724644143758508e2, -0.110480239272601,
+ 0.536516031875059e1, -0.291441872156205e4, 0.616338176535305e40,
+ -0.120889175861180e39, 0.818396024524612e23, 0.940781944835829e9,
+ -0.367279669545448e5, -0.837513931798655e16],
+ "h": [0.561379678887577e-1, 0.774135421587083e10, 0.111482975877938e-8,
+ -0.143987128208183e-2, 0.193696558764920e4, -0.605971823585005e9,
+ 0.171951568124337e14, -.185461154985145e17, 0.38785116807801e-16,
+ -.395464327846105e-13, -0.170875935679023e3, -0.21201062070122e4,
+ 0.177683337348191e8, 0.110177443629575e2, -0.234396091693313e6,
+ -0.656174421999594e7, 0.156362212977396e-4, -0.212946257021400e1,
+ 0.135249306374858e2, 0.177189164145813, 0.139499167345464e4,
+ -0.703670932036388e-2, -0.152011044389648, 0.981916922991113e-4,
+ 0.147199658618076e-2, 0.202618487025578e2, 0.899345518944240,
+ -0.211346402240858, 0.249971752957491e2],
+ "i": [0.106905684359136e1, -0.148620857922333e1, 0.259862256980408e15,
+ -.446352055678749e-11, -.566620757170032e-6, -.235302885736849e-2,
+ -0.269226321968839, 0.922024992944392e1, 0.357633505503772e-11,
+ -0.173942565562222e2, 0.700681785556229e-5, -.267050351075768e-3,
+ -0.231779669675624e1, -0.753533046979752e-12, .481337131452891e1,
+ -0.223286270422356e22, -.118746004987383e-4, .646412934136496e-2,
+ -0.410588536330937e-9, .422739537057241e20, .313698180473812e-12,
+ 0.16439533434504e-23, -.339823323754373e-5, -.135268639905021e-1,
+ -.723252514211625e-14, .184386437538366e-8, -.463959533752385e-1,
+ -.99226310037675e14, .688169154439335e-16, -.222620998452197e-10,
+ -0.540843018624083e-7, 0.345570606200257e-2, .422275800304086e11,
+ -.126974478770487e-14, .927237985153679e-9, .612670812016489e-13,
+ -.722693924063497e-11, -.383669502636822e-3, .374684572410204e-3,
+ -0.931976897511086e5, -0.247690616026922e-1, .658110546759474e2],
+ "j": [-0.111371317395540e-3, 0.100342892423685e1, 0.530615581928979e1,
+ 0.179058760078792e-5, -0.728541958464774e-3, -.187576133371704e2,
+ 0.199060874071849e-2, 0.243574755377290e2, -0.177040785499444e-3,
+ -0.25968038522713e-2, -0.198704578406823e3, 0.738627790224287e-4,
+ -0.236264692844138e-2, -0.161023121314333e1, 0.622322971786473e4,
+ -.960754116701669e-8, -.510572269720488e-10, .767373781404211e-2,
+ .663855469485254e-14, -.717590735526745e-9, 0.146564542926508e-4,
+ .309029474277013e-11, -.464216300971708e-15, -.390499637961161e-13,
+ -.236716126781431e-9, .454652854268717e-11, -.422271787482497e-2,
+ 0.283911742354706e-10, 0.270929002720228e1],
+ "k": [-0.401215699576099e9, 0.484501478318406e11, .394721471363678e-14,
+ .372629967374147e5, -.369794374168666e-29, -.380436407012452e-14,
+ 0.475361629970233e-6, -0.879148916140706e-3, 0.844317863844331,
+ 0.122433162656600e2, -0.104529634830279e3, 0.589702771277429e3,
+ -.291026851164444e14, .170343072841850e-5, -0.277617606975748e-3,
+ -0.344709605486686e1, 0.221333862447095e2, -0.194646110037079e3,
+ .808354639772825e-15, -.18084520914547e-10, -.696664158132412e-5,
+ -0.181057560300994e-2, 0.255830298579027e1, 0.328913873658481e4,
+ -.173270241249904e-18, -.661876792558034e-6, -.39568892342125e-2,
+ .604203299819132e-17, -.400879935920517e-13, .160751107464958e-8,
+ .383719409025556e-4, -.649565446702457e-14, -.149095328506e-11,
+ 0.541449377329581e-8],
+ "l": [0.260702058647537e10, -.188277213604704e15, 0.554923870289667e19,
+ -.758966946387758e23, .413865186848908e27, -.81503800073806e12,
+ -.381458260489955e33, -.123239564600519e-1, 0.226095631437174e8,
+ -.49501780950672e12, 0.529482996422863e16, -0.444359478746295e23,
+ .521635864527315e35, -0.487095672740742e55, -0.714430209937547e6,
+ 0.127868634615495, -0.100752127917598e2, 0.777451437960990e7,
+ -.108105480796471e25, -.357578581169659e-5, -0.212857169423484e1,
+ 0.270706111085238e30, -0.695953622348829e33, 0.110609027472280,
+ 0.721559163361354e2, -0.306367307532219e15, 0.265839618885530e-4,
+ 0.253392392889754e-1, -0.214443041836579e3, 0.937846601489667,
+ 0.223184043101700e1, 0.338401222509191e2, 0.494237237179718e21,
+ -0.198068404154428, -0.141415349881140e31, -0.993862421613651e2,
+ 0.125070534142731e3, -0.996473529004439e3, 0.473137909872765e5,
+ 0.116662121219322e33, -0.315874976271533e16,
+ -0.445703369196945e33, 0.642794932373694e33],
+ "m": [0.811384363481847, -0.568199310990094e4, -0.178657198172556e11,
+ 0.795537657613427e32, -0.814568209346872e5, -0.659774567602874e8,
+ -.152861148659302e11, -0.560165667510446e12, 0.458384828593949e6,
+ -0.385754000383848e14, 0.453735800004273e8, 0.939454935735563e12,
+ .266572856432938e28, -0.547578313899097e10, 0.200725701112386e15,
+ 0.185007245563239e13, 0.185135446828337e9, -0.170451090076385e12,
+ 0.157890366037614e15, -0.202530509748774e16, 0.36819392618357e60,
+ 0.170215539458936e18, 0.639234909918741e42, -.821698160721956e15,
+ -.795260241872306e24, 0.23341586947851e18, -0.600079934586803e23,
+ 0.594584382273384e25, 0.189461279349492e40, -.810093428842645e46,
+ 0.188813911076809e22, 0.111052244098768e36, 0.291133958602503e46,
+ -.329421923951460e22, -.137570282536696e26, 0.181508996303902e28,
+ -.346865122768353e30, -.21196114877426e38, -0.128617899887675e49,
+ 0.479817895699239e65],
+ "n": [.280967799943151e-38, .614869006573609e-30, .582238667048942e-27,
+ .390628369238462e-22, .821445758255119e-20, .402137961842776e-14,
+ .651718171878301e-12, -.211773355803058e-7, 0.264953354380072e-2,
+ -.135031446451331e-31, -.607246643970893e-23, -.402352115234494e-18,
+ -.744938506925544e-16, .189917206526237e-12, .364975183508473e-5,
+ .177274872361946e-25, -.334952758812999e-18, -.421537726098389e-8,
+ -.391048167929649e-1, .541276911564176e-13, .705412100773699e-11,
+ .258585887897486e-8, -.493111362030162e-10, -.158649699894543e-5,
+ -0.525037427886100, 0.220019901729615e-2, -0.643064132636925e-2,
+ 0.629154149015048e2, 0.135147318617061e3, 0.240560808321713e-6,
+ -.890763306701305e-3, -0.440209599407714e4, -0.302807107747776e3,
+ 0.159158748314599e4, 0.232534272709876e6, -0.792681207132600e6,
+ -.869871364662769e11, .354542769185671e12, 0.400849240129329e15],
+ "o": [.128746023979718e-34, -.735234770382342e-11, .28907869214915e-2,
+ 0.244482731907223, 0.141733492030985e-23, -0.354533853059476e-28,
+ -.594539202901431e-17, -.585188401782779e-8, .201377325411803e-5,
+ 0.138647388209306e1, -0.173959365084772e-4, 0.137680878349369e-2,
+ .814897605805513e-14, .425596631351839e-25, -.387449113787755e-17,
+ .13981474793024e-12, -.171849638951521e-2, 0.641890529513296e-21,
+ .118960578072018e-10, -.155282762571611e-17, .233907907347507e-7,
+ -.174093247766213e-12, .377682649089149e-8, -.516720236575302e-10],
+ "p": [-0.982825342010366e-4, 0.105145700850612e1, 0.116033094095084e3,
+ 0.324664750281543e4, -0.123592348610137e4, -0.561403450013495e-1,
+ 0.856677401640869e-7, 0.236313425393924e3, 0.972503292350109e-2,
+ -.103001994531927e1, -0.149653706199162e-8, -.215743778861592e-4,
+ -0.834452198291445e1, 0.586602660564988, 0.343480022104968e-25,
+ .816256095947021e-5, .294985697916798e-2, 0.711730466276584e-16,
+ 0.400954763806941e-9, 0.107766027032853e2, -0.409449599138182e-6,
+ -.729121307758902e-5, 0.677107970938909e-8, 0.602745973022975e-7,
+ -.382323011855257e-10, .179946628317437e-2, -.345042834640005e-3],
+ "q": [-0.820433843259950e5, 0.473271518461586e11, -.805950021005413e-1,
+ 0.328600025435980e2, -0.35661702998249e4, -0.172985781433335e10,
+ 0.351769232729192e8, -0.775489259985144e6, 0.710346691966018e-4,
+ 0.993499883820274e5, -0.642094171904570, -0.612842816820083e4,
+ .232808472983776e3, -0.142808220416837e-4, -0.643596060678456e-2,
+ -0.428577227475614e1, 0.225689939161918e4, 0.100355651721510e-2,
+ 0.333491455143516, 0.109697576888873e1, 0.961917379376452,
+ -0.838165632204598e-1, 0.247795908411492e1, -.319114969006533e4],
+ "r": [.144165955660863e-2, -.701438599628258e13, -.830946716459219e-16,
+ 0.261975135368109, 0.393097214706245e3, -0.104334030654021e5,
+ 0.490112654154211e9, -0.147104222772069e-3, 0.103602748043408e1,
+ 0.305308890065089e1, -0.399745276971264e7, 0.569233719593750e-11,
+ -.464923504407778e-1, -.535400396512906e-17, .399988795693162e-12,
+ -.536479560201811e-6, .159536722411202e-1, .270303248860217e-14,
+ .244247453858506e-7, -0.983430636716454e-5, 0.663513144224454e-1,
+ -0.993456957845006e1, 0.546491323528491e3, -0.143365406393758e5,
+ 0.150764974125511e6, -.337209709340105e-9, 0.377501980025469e-8],
+ "s": [-0.532466612140254e23, .100415480000824e32, -.191540001821367e30,
+ 0.105618377808847e17, 0.202281884477061e59, 0.884585472596134e8,
+ 0.166540181638363e23, -0.313563197669111e6, -.185662327545324e54,
+ -.624942093918942e-1, -0.50416072413259e10, 0.187514491833092e5,
+ 0.121399979993217e-2, 0.188317043049455e1, -0.167073503962060e4,
+ 0.965961650599775, 0.294885696802488e1, -0.653915627346115e5,
+ 0.604012200163444e50, -0.198339358557937, -0.175984090163501e58,
+ 0.356314881403987e1, -0.575991255144384e3, 0.456213415338071e5,
+ -.109174044987829e8, 0.437796099975134e34, -0.616552611135792e46,
+ 0.193568768917797e10, 0.950898170425042e54],
+ "t": [0.155287249586268e1, 0.664235115009031e1, -0.289366236727210e4,
+ -0.385923202309848e13, -.291002915783761e1, -.829088246858083e12,
+ 0.176814899675218e1, -0.534686695713469e9, 0.160464608687834e18,
+ 0.196435366560186e6, 0.156637427541729e13, -0.178154560260006e1,
+ -0.229746237623692e16, 0.385659001648006e8, 0.110554446790543e10,
+ -.677073830687349e14, -.327910592086523e31, -.341552040860644e51,
+ -.527251339709047e21, .245375640937055e24, -0.168776617209269e27,
+ .358958955867578e29, -0.656475280339411e36, 0.355286045512301e39,
+ .569021454413270e58, -.700584546433113e48, -0.705772623326374e65,
+ 0.166861176200148e53, -.300475129680486e61, -.668481295196808e51,
+ .428432338620678e69, -.444227367758304e72, -.281396013562745e77],
+ "u": [0.122088349258355e18, 0.104216468608488e10, -.882666931564652e16,
+ .259929510849499e20, 0.222612779142211e15, -0.878473585050085e18,
+ -0.314432577551552e22, -.216934916996285e13, .159079648196849e21,
+ -.339567617303423e3, 0.884387651337836e13, -0.843405926846418e21,
+ 0.114178193518022e2, -0.122708229235641e-3, -0.106201671767107e3,
+ .903443213959313e25, -0.693996270370852e28, 0.648916718965575e-8,
+ 0.718957567127851e4, 0.105581745346187e-2, -0.651903203602581e15,
+ -0.160116813274676e25, -0.510254294237837e-8, -0.152355388953402,
+ 0.677143292290144e12, 0.276378438378930e15, 0.116862983141686e-1,
+ -.301426947980171e14, 0.169719813884840e-7, 0.104674840020929e27,
+ -0.10801690456014e5, -0.990623601934295e-12, 0.536116483602738e7,
+ .226145963747881e22, -0.488731565776210e-9, 0.151001548880670e-4,
+ -0.227700464643920e5, -0.781754507698846e28],
+ "v": [-.415652812061591e-54, .177441742924043e-60, -.357078668203377e-54,
+ 0.359252213604114e-25, -0.259123736380269e2, 0.594619766193460e5,
+ -0.624184007103158e11, 0.313080299915944e17, .105006446192036e-8,
+ -0.192824336984852e-5, 0.654144373749937e6, 0.513117462865044e13,
+ -.697595750347391e19, -.103977184454767e29, .119563135540666e-47,
+ -.436677034051655e-41, .926990036530639e-29, .587793105620748e21,
+ .280375725094731e-17, -0.192359972440634e23, .742705723302738e27,
+ -0.517429682450605e2, 0.820612048645469e7, -0.188214882341448e-8,
+ .184587261114837e-1, -0.135830407782663e-5, -.723681885626348e17,
+ -.223449194054124e27, -.111526741826431e-34, .276032601145151e-28,
+ 0.134856491567853e15, 0.652440293345860e-9, 0.510655119774360e17,
+ -.468138358908732e32, -.760667491183279e16, -.417247986986821e-18,
+ 0.312545677756104e14, -.100375333864186e15, .247761392329058e27],
+ "w": [-.586219133817016e-7, -.894460355005526e11, .531168037519774e-30,
+ 0.109892402329239, -0.575368389425212e-1, 0.228276853990249e5,
+ -.158548609655002e19, .329865748576503e-27, -.634987981190669e-24,
+ 0.615762068640611e-8, -.961109240985747e8, -.406274286652625e-44,
+ -0.471103725498077e-12, 0.725937724828145, 0.187768525763682e-38,
+ -0.103308436323771e4, -0.662552816342168e-1, 0.579514041765710e3,
+ .237416732616644e-26, .271700235739893e-14, -0.9078862134836e2,
+ -0.171242509570207e-36, 0.156792067854621e3, 0.923261357901470,
+ -0.597865988422577e1, 0.321988767636389e7, -.399441390042203e-29,
+ .493429086046981e-7, .812036983370565e-19, -.207610284654137e-11,
+ -.340821291419719e-6, .542000573372233e-17, -.856711586510214e-12,
+ 0.266170454405981e-13, 0.858133791857099e-5],
+ "x": [.377373741298151e19, -.507100883722913e13, -0.10336322559886e16,
+ .184790814320773e-5, -.924729378390945e-3, -0.425999562292738e24,
+ -.462307771873973e-12, .107319065855767e22, 0.648662492280682e11,
+ 0.244200600688281e1, -0.851535733484258e10, 0.169894481433592e22,
+ 0.215780222509020e-26, -0.320850551367334, -0.382642448458610e17,
+ -.275386077674421e-28, -.563199253391666e6, -.326068646279314e21,
+ 0.397949001553184e14, 0.100824008584757e-6, 0.162234569738433e5,
+ -0.432355225319745e11, -.59287424559861e12, 0.133061647281106e1,
+ 0.157338197797544e7, 0.258189614270853e14, 0.262413209706358e25,
+ -.920011937431142e-1, 0.220213765905426e-2, -0.110433759109547e2,
+ 0.847004870612087e7, -0.592910695762536e9, -0.183027173269660e-4,
+ 0.181339603516302, -0.119228759669889e4, 0.430867658061468e7],
+ "y": [-0.525597995024633e-9, 0.583441305228407e4, -.134778968457925e17,
+ .118973500934212e26, -0.159096490904708e27, -.315839902302021e-6,
+ 0.496212197158239e3, 0.327777227273171e19, -0.527114657850696e22,
+ .210017506281863e-16, 0.705106224399834e21, -.266713136106469e31,
+ -0.145370512554562e-7, 0.149333917053130e28, -.149795620287641e8,
+ -.3818819062711e16, 0.724660165585797e-4, -0.937808169550193e14,
+ 0.514411468376383e10, -0.828198594040141e5],
+ "z": [0.24400789229065e-10, -0.463057430331242e7, 0.728803274777712e10,
+ .327776302858856e16, -.110598170118409e10, -0.323899915729957e13,
+ .923814007023245e16, 0.842250080413712e-12, 0.663221436245506e12,
+ -.167170186672139e15, .253749358701391e4, -0.819731559610523e-20,
+ 0.328380587890663e12, -0.625004791171543e8, 0.803197957462023e21,
+ -.204397011338353e-10, -.378391047055938e4, 0.97287654593862e-2,
+ 0.154355721681459e2, -0.373962862928643e4, -0.682859011374572e11,
+ -0.248488015614543e-3, 0.394536049497068e7]}
+
+ I = I[x]
+ J = J[x]
+ n = n[x]
+ v_, P_, T_, N, a, b, c, d, e = par[x]
+
+ Pr = P/P_
+ Tr = T/T_
+ suma = 0
+ if x == "n":
+ for i in range(N):
+ suma += n[i]*(Pr-a)**I[i]*(Tr-b)**J[i]
+ return v_*exp(suma)
+ else:
+ for i in range(N):
+ suma += n[i]*(Pr-a)**(c*I[i])*(Tr-b)**(J[i]*d)
+ return v_*suma**e
+
+
+# Region 4
+def _Region4(P, x):
+ """Basic equation for region 4"""
+ T = _TSat_P(P)
+ P1 = _Region1(T, P)
+ P2 = _Region2(T, P)
+
+ propiedades = {}
+ propiedades["T"] = T
+ propiedades["P"] = P
+ propiedades["v"] = P1["v"]+x*(P2["v"]-P1["v"])
+ propiedades["h"] = P1["h"]+x*(P2["h"]-P1["h"])
+ propiedades["s"] = P1["s"]+x*(P2["s"]-P1["s"])
+ propiedades["cp"] = None
+ propiedades["cv"] = None
+ propiedades["w"] = None
+ propiedades["alfav"] = None
+ propiedades["kt"] = None
+ propiedades["alfap"] = None
+ propiedades["betap"] = None
+ propiedades["region"] = 4
+ propiedades["x"] = x
+ return propiedades
+
+
+def _Backward4_T_hs(h, s):
+ """Backward equation for region 4, T=f(h,s)
+
+ >>> "%.7f" % _Backward4_T_hs(1800,5.3)
+ '346.8475498'
+ >>> "%.7f" % _Backward4_T_hs(2400,6.0)
+ '425.1373305'
+ >>> "%.7f" % _Backward4_T_hs(2500,5.5)
+ '522.5579013'
+ """
+ I = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6,
+ 8, 10, 10, 12, 14, 14, 16, 16, 18, 18, 18, 20, 28]
+ J = [0, 3, 12, 0, 1, 2, 5, 0, 5, 8, 0, 2, 3, 4, 0, 1, 1, 2, 4, 16, 6, 8,
+ 22, 1, 20, 36, 24, 1, 28, 12, 32, 14, 22, 36, 24, 36]
+ n = [0.179882673606601, -0.267507455199603, 0.116276722612600e1,
+ 0.147545428713616, -0.512871635973248, 0.421333567697984,
+ 0.563749522189870, 0.429274443819153, -0.335704552142140e1,
+ 0.108890916499278e2, -0.248483390456012, 0.304153221906390,
+ -0.494819763939905, 0.107551674933261e1, 0.733888415457688e-1,
+ 0.140170545411085e-1, -0.106110975998808, 0.168324361811875e-1,
+ 0.125028363714877e1, 0.101316840309509e4, -0.151791558000712e1,
+ 0.524277865990866e2, 0.230495545563912e5, 0.249459806365456e-1,
+ 0.210796467412137e7, 0.366836848613065e9, -0.144814105365163e9,
+ -0.179276373003590e-2, 0.489955602100459e10, 0.471262212070518e3,
+ -0.829294390198652e11, -0.171545662263191e4, 0.355777682973575e7,
+ 0.586062760258436e12, -0.129887635078195e8, 0.317247449371057e11]
+
+ nu = h/2800
+ sigma = s/9.2
+ suma = 0
+ for i in range(36):
+ suma += n[i]*(nu-0.119)**I[i]*(sigma-1.07)**J[i]
+ return 550*suma
+
+
+# Region 5
+def _Region5(T, P):
+ """Basic equation for region 5
+
+ >>> "%.8f" % _Region5(1500,0.5)["v"]
+ '1.38455090'
+ >>> "%.5f" % _Region5(1500,0.5)["h"]
+ '5219.76855'
+ >>> "%.5f" % (_Region5(1500,0.5)["h"]-500*_Region5(1500,0.5)["v"], )
+ '4527.49310'
+ >>> "%.8f" % _Region5(1500,30)["s"]
+ '7.72970133'
+ >>> "%.8f" % _Region5(1500,30)["cp"]
+ '2.72724317'
+ >>> "%.8f" % _Region5(1500,30)["cv"]
+ '2.19274829'
+ >>> "%.5f" % _Region5(2000,30)["w"]
+ '1067.36948'
+ >>> "%.12f" % _Region5(2000,30)["alfav"]
+ '0.000508830641'
+ >>> "%.10f" % _Region5(2000,30)["kt"]
+ '0.0329193892'
+ """
+ Tr = 1000/T
+ Pr = P/1
+
+ go, gop, gopp, got, gott, gopt = Region5_cp0(Tr, Pr)
+
+ Ir = [1, 1, 1, 2, 2, 3]
+ Jr = [1, 2, 3, 3, 9, 7]
+ nr = [0.15736404855259e-2, 0.90153761673944e-3, -0.50270077677648e-2,
+ 0.22440037409485e-5, -0.41163275453471e-5, 0.37919454822955e-7]
+ gr = grp = grpp = grt = grtt = grpt = 0
+ for i in range(6):
+ gr += nr[i]*Pr**Ir[i]*Tr**Jr[i]
+ grp += nr[i]*Ir[i]*Pr**(Ir[i]-1)*Tr**Jr[i]
+ grpp += nr[i]*Ir[i]*(Ir[i]-1)*Pr**(Ir[i]-2)*Tr**Jr[i]
+ grt += nr[i]*Pr**Ir[i]*Jr[i]*Tr**(Jr[i]-1)
+ grtt += nr[i]*Pr**Ir[i]*Jr[i]*(Jr[i]-1)*Tr**(Jr[i]-2)
+ grpt += nr[i]*Ir[i]*Pr**(Ir[i]-1)*Jr[i]*Tr**(Jr[i]-1)
+
+ propiedades = {}
+ propiedades["T"] = T
+ propiedades["P"] = P
+ propiedades["v"] = Pr*(gop+grp)*R*T/P/1000
+ propiedades["h"] = Tr*(got+grt)*R*T
+ propiedades["s"] = R*(Tr*(got+grt)-(go+gr))
+ propiedades["cp"] = -R*Tr**2*(gott+grtt)
+ propiedades["cv"] = R*(-Tr**2*(gott+grtt)+((gop+grp)-Tr*(gopt+grpt))**2/(gopp+grpp))
+ propiedades["w"] = (R*T*1000*(1+2*Pr*grp+Pr**2*grp**2)/(1-Pr**2*grpp+(
+ 1+Pr*grp-Tr*Pr*grpt)**2/Tr**2/(gott+grtt)))**0.5
+ propiedades["alfav"] = (1+Pr*grp-Tr*Pr*grpt)/(1+Pr*grp)/T
+ propiedades["kt"] = (1-Pr**2*grpp)/(1+Pr*grp)/P
+ propiedades["region"] = 5
+ propiedades["x"] = 1
+ return propiedades
+
+
+def Region5_cp0(Tr, Pr):
+ """Ideal properties for Region 5"""
+ Jo = [0, 1, -3, -2, -1, 2]
+ no = [-0.13179983674201e2, 0.68540841634434e1, -0.24805148933466e-1,
+ 0.36901534980333, -0.31161318213925e1, -0.32961626538917]
+ go = log(Pr)
+ gop = Pr**-1
+ gopp = -Pr**-2
+ got = gott = gopt = 0
+ for i in range(6):
+ go += no[i]*Tr**Jo[i]
+ got += no[i]*Jo[i]*Tr**(Jo[i]-1)
+ gott += no[i]*Jo[i]*(Jo[i]-1)*Tr**(Jo[i]-2)
+
+ return go, gop, gopp, got, gott, gopt
+
+
+# Region definitions
+def _Bound_TP(T, P):
+ """Region definition for input T and P"""
+ region = None
+ if 1073.15 < T <= 2273.15 and Pmin <= P <= 50:
+ region = 5
+ elif Pmin <= P <= Ps_623:
+ Tsat = _TSat_P(P)
+ if 273.15 <= T <= Tsat:
+ region = 1
+ elif Tsat < T <= 1073.15:
+ region = 2
+ elif Ps_623 < P <= 100:
+ T_b23 = _t_P(P)
+ if 273.15 <= T <= 623.15:
+ region = 1
+ elif T_b23 <= T <= 1073.15:
+ region = 2
+ elif 623.15 < T < T_b23:
+ region = 3
+ return region
+
+
+def _Bound_Ph(P, h):
+ """Region definition for input P y h"""
+ region = None
+ if Pmin <= P <= Ps_623:
+ h14 = _Region1(_TSat_P(P), P)["h"]
+ h24 = _Region2(_TSat_P(P), P)["h"]
+ h25 = _Region2(1073.15, P)["h"]
+ hmin = _Region1(273.15, P)["h"]
+ hmax = _Region5(2273.15, P)["h"]
+ if hmin <= h <= h14:
+ region = 1
+ elif h14 < h < h24:
+ region = 4
+ elif h24 <= h <= h25:
+ region = 2
+ elif h25 < h <= hmax:
+ region = 5
+ elif Ps_623 < P < Pc:
+ hmin = _Region1(273.15, P)["h"]
+ h13 = _Region1(623.15, P)["h"]
+ h32 = _Region2(_t_P(P), P)["h"]
+ h25 = _Region2(1073.15, P)["h"]
+ hmax = _Region5(2273.15, P)["h"]
+ if hmin <= h <= h13:
+ region = 1
+ elif h13 < h < h32:
+ p34 = _PSat_h(h)
+ if P < p34:
+ region = 4
+ else:
+ region = 3
+ elif h32 <= h <= h25:
+ region = 2
+ elif h25 < h <= hmax:
+ region = 5
+ elif Pc <= P <= 100:
+ hmin = _Region1(273.15, P)["h"]
+ h13 = _Region1(623.15, P)["h"]
+ h32 = _Region2(_t_P(P), P)["h"]
+ h25 = _Region2(1073.15, P)["h"]
+ hmax = _Region5(2273.15, P)["h"]
+ if hmin <= h <= h13:
+ region = 1
+ elif h13 < h < h32:
+ region = 3
+ elif h32 <= h <= h25:
+ region = 2
+ elif P <= 50 and h25 <= h <= hmax:
+ region = 5
+ return region
+
+
+def _Bound_Ps(P, s):
+ """Region definition for input P and s"""
+ region = None
+ if Pmin <= P <= Ps_623:
+ smin = _Region1(273.15, P)["s"]
+ s14 = _Region1(_TSat_P(P), P)["s"]
+ s24 = _Region2(_TSat_P(P), P)["s"]
+ s25 = _Region2(1073.15, P)["s"]
+ smax = _Region5(2273.15, P)["s"]
+ if smin <= s <= s14:
+ region = 1
+ elif s14 < s < s24:
+ region = 4
+ elif s24 <= s <= s25:
+ region = 2
+ elif s25 < s <= smax:
+ region = 5
+ elif Ps_623 < P < Pc:
+ smin = _Region1(273.15, P)["s"]
+ s13 = _Region1(623.15, P)["s"]
+ s32 = _Region2(_t_P(P), P)["s"]
+ s25 = _Region2(1073.15, P)["s"]
+ smax = _Region5(2273.15, P)["s"]
+ if smin <= s <= s13:
+ region = 1
+ elif s13 < s < s32:
+ p34 = _PSat_s(s)
+ if P < p34:
+ region = 4
+ else:
+ region = 3
+ elif s32 <= s <= s25:
+ region = 2
+ elif s25 < s <= smax:
+ region = 5
+ elif Pc <= P <= 100:
+ smin = _Region1(273.15, P)["s"]
+ s13 = _Region1(623.15, P)["s"]
+ s32 = _Region2(_t_P(P), P)["s"]
+ s25 = _Region2(1073.15, P)["s"]
+ smax = _Region5(2273.15, P)["s"]
+ if smin <= s <= s13:
+ region = 1
+ elif s13 < s < s32:
+ region = 3
+ elif s32 <= s <= s25:
+ region = 2
+ elif P <= 50 and s25 <= s <= smax:
+ region = 5
+ return region
+
+
+def _Bound_hs(h, s):
+ """Region definition for input h and s"""
+ region = None
+ smin = _Region1(273.15, 100)["s"]
+ hmin = _Region1(273.15, 100)["h"]
+ s13 = _Region1(623.15, 100)["s"]
+ s13s = _Region1(623.15, _PSat_T(623.15))["s"]
+ smax = _Region2(1073.15, _PSat_T(273.15))["s"]
+ hmax = _Region2(1073.15, _PSat_T(273.15))["h"]
+
+ s4l = _Region1(273.15, Pmin)["s"]
+ h4l = _Region1(273.15, Pmin)["h"]
+ s4v = _Region2(273.15, Pmin)["s"]
+ h4v = _Region2(273.15, Pmin)["h"]
+
+ h23max = _Region2(863.15, 100)["h"]
+ h23min = _Region2(623.15, Ps_623)["h"]
+
+ if h <= hmax:
+ if smin <= s <= s13:
+ P = _Backward1_P_hs(h, s)
+ T = _Backward1_T_Ph(P, h)
+ if T-0.0218 >= 273.15 and Pt <= P <= 100:
+ hs = _h1_s(s)
+ if h >= hs:
+ region = 1
+ elif hmin <= h < hs:
+ region = 4
+ elif s13 < s <= s13s:
+ hs = _h1_s(s)
+ h13 = _h13_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ if h > h13 and _Backward3_P_hs(h, s) <= 100:
+ region = 3
+ elif hs <= h <= h13:
+ region = 1
+ elif hmin4 <= h < hs:
+ region = 4
+ elif s13s < s <= sc:
+ hs = _h3a_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ if h >= hs and _Backward3_P_hs(h, s) <= 100:
+ region = 3
+ elif hmin4 <= h < hs:
+ region = 4
+ elif sc < s < 5.049096828:
+ hs = _h2c3b_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ if h >= hs and _Backward3_P_hs(h, s) <= 100:
+ region = 3
+ elif hmin4 <= h < hs:
+ region = 4
+ elif 5.049096828 <= s < 5.260578707:
+ hs = _h2c3b_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ if h23max <= h and _Backward2_P_hs(h, s) <= 100:
+ region = 2
+ elif h23min <= h < h23max:
+ if _Backward2c_P_hs(h, s) <= _P23_T(_t_hs(h, s)):
+ region = 2
+ else:
+ region = 3
+ elif hs <= h < h23min:
+ region = 3
+ elif hmin4 <= h < hs:
+ region = 4
+ elif 5.260578707 <= s < 5.85:
+ hs = _h2c3b_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ if hs <= h and _Backward2_P_hs(h, s) <= 100:
+ region = 2
+ elif hmin4 <= h < hs:
+ region = 4
+ elif 5.85 <= s < s4v:
+ hs = _h2ab_s(s)
+ hmin4 = h4l+(s-s4l)/(s4v-s4l)*(h4v-h4l)
+ P = _Backward2_P_hs(h, s)
+ if P <= 100:
+ T = _Backward2_T_Ph(P, h)
+ h2max = _Region2(1073.15, P)["h"]
+ if hs <= h <= h2max and Pmin <= P <= 100 and T <= 1073.15:
+ region = 2
+ elif hmin4 <= h < hs:
+ region = 4
+ elif s4v <= s <= smax:
+ P = _Backward2a_P_hs(h, s)
+ T = _Backward2a_T_Ph(P, h)
+ if P >= Pmin and T <= 1073.15:
+ region = 2
+
+ if not region and \
+ _Region5(1073.15, 50)["s"] < s <= _Region5(2273.15, Pmin)["s"] and \
+ _Region5(1073.15, 50)["h"] < h <= _Region5(2273.15, Pmin)["h"]:
+ funcion = lambda par: (_Region5(par[0], par[1])["h"]-h,
+ _Region5(par[0], par[1])["s"]-s)
+ T, P = fsolve(funcion, [1400, 0.001])
+ if 1073.15 < T <= 2273.15 and Pmin <= P <= 50:
+ region = 5
+
+ return region
+
+
+def prop0(T, P):
+ """Ideal gas properties"""
+ if T <= 1073.15:
+ Tr = 540/T
+ Pr = P/1.
+ go, gop, gopp, got, gott, gopt = Region2_cp0(Tr, Pr)
+ else:
+ Tr = 1000/T
+ Pr = P/1.
+ go, gop, gopp, got, gott, gopt = Region5_cp0(Tr, Pr)
+
+ prop0 = _fase()
+ prop0.v = Pr*gop*R*T/P/1000
+ prop0.h = Tr*got*R*T
+ prop0.s = R*(Tr*got-go)
+ prop0.cp = -R*Tr**2*gott
+ prop0.cv = R*(-Tr**2*gott+(gop-Tr*gopt)**2/gopp)
+
+ prop0.w = (R*T*1000/(1+1/Tr**2/gott))**0.5
+ prop0.alfav = 1/T
+ prop0.xkappa = 1/P
+ # FIXME: Ideal Isentropic exponent dont work
+ prop0.gamma = 0
+ # prop0.gamma = -prop0.v/P/1000*prop0.derivative("P", "v", "s", prop0)
+ return prop0
+
+
+class IAPWS97(object):
+ """Class to model a state for liquid water or steam with the IAPWS-IF97
+
+ Incoming properties::
+ T - Temperature, K
+ P - Pressure, MPa
+ h - Specific enthalpy, kJ/kg
+ s - Specific entropy, kJ/kg·K
+ x - Quality
+
+ Optional:
+ l - Wavelength of light, for refractive index
+
+ Definitions options:
+ T, P Not valid for two-phases region
+ P, h
+ P, s
+ h, s
+ T, x Only for two-phases region
+ P, x Only for two-phases region
+
+
+ Properties:
+ P - Pressure, MPa
+ T - Temperature, K
+ g - Specific Gibbs free energy, kJ/kg
+ a - Specific Helmholtz free energy, kJ/kg
+ v - Specific volume, m³/kg
+ r - Density, kg/m³
+ h - Specific enthalpy, kJ/kg
+ u - Specific internal energy, kJ/kg
+ s - Specific entropy, kJ/kg·K
+ c - Specific isobaric heat capacity, kJ/kg·K
+ c - Specific isochoric heat capacity, kJ/kg·K
+ Z - Compression factor
+ f - Fugacity, MPa
+ gamma - Isoentropic exponent
+ alfav - Isobaric cubic expansion coefficient, 1/K
+ xkappa - Isothermal compressibility, 1/MPa
+ alfap - Relative pressure coefficient, 1/K
+ betap - Isothermal stress coefficient, kg/m³
+ joule - Joule-Thomson coefficient, K/MPa
+ deltat - Isothermal throttling coefficient, kJ/kg·MPa
+ region - Region
+
+ v0 - Ideal specific volume, m³/kg
+ u0 - Ideal specific internal energy, kJ/kg
+ h0 - Ideal specific enthalpy, kJ/kg
+ s0 - Ideal specific entropy, kJ/kg·K
+ a0 - Ideal specific Helmholtz free energy, kJ/kg
+ g0 - Ideal specific Gibbs free energy, kJ/kg
+ cp0 - Ideal specific isobaric heat capacity, kJ/kg·K
+ cv0 - Ideal specific isochoric heat capacity, kJ/kg·K
+ w0 - Ideal speed of sound, m/s
+ gamma0 - Ideal isoentropic exponent
+
+ w - Speed of sound, m/s
+ mu - Dynamic viscosity, Pa·s
+ nu - Kinematic viscosity, m²/s
+ k - Thermal conductivity, W/m·K
+ alfa - Thermal diffusivity, m²/s
+ sigma - Surface tension, N/m
+ epsilon - Dielectric constant
+ n - Refractive index
+ Prandt - Prandtl number
+ Pr - Reduced Pressure
+ Tr - Reduced Temperature
+
+ Usage:
+ >>> water=IAPWS97(T=170+273.15,x=0.5)
+ >>> "%0.4f %0.4f %0.1f %0.2f" %(water.Liquid.cp, water.Vapor.cp, water.Liquid.w, water.Vapor.w)
+ '4.3695 2.5985 1418.3 498.78'
+ >>> water=IAPWS97(T=325+273.15,x=0.5)
+ >>> "%0.4f %0.8f %0.7f %0.2f %0.2f" %(water.P, water.Liquid.v, water.Vapor.v, water.Liquid.h, water.Vapor.h)
+ '12.0505 0.00152830 0.0141887 1493.37 2684.48'
+ >>> water=IAPWS97(T=50+273.15,P=0.0006112127)
+ >>> "%0.4f %0.4f %0.2f %0.3f %0.2f" %(water.cp0, water.cv0, water.h0, water.s0, water.w0)
+ '1.8714 1.4098 2594.66 9.471 444.93'
+ """
+ kwargs = {"T": 0.0,
+ "P": 0.0,
+ "x": None,
+ "h": None,
+ "s": None,
+ "v": 0.0,
+ "l": 0.5893}
+ status = 0
+ msg = "Unknown variables"
+
+ def __init__(self, **kwargs):
+ self.kwargs = IAPWS97.kwargs.copy()
+ self.__call__(**kwargs)
+
+ def __call__(self, **kwargs):
+ self.kwargs.update(kwargs)
+
+ if self.calculable:
+ self.status = 1
+ self.calculo()
+ self.msg = "Solved"
+
+ @property
+ def calculable(self):
+ """Check if class is calculable by its kwargs"""
+ self._thermo = ""
+ if self.kwargs["T"] and self.kwargs["P"]:
+ self._thermo = "TP"
+ elif self.kwargs["P"] and self.kwargs["h"] is not None:
+ self._thermo = "Ph"
+ elif self.kwargs["P"] and self.kwargs["s"] is not None:
+ self._thermo = "Ps"
+ # TODO: Add other pairs definitions options
+ # elif self.kwargs["P"] and self.kwargs["v"]:
+ # self._thermo = "Pv"
+ # elif self.kwargs["T"] and self.kwargs["s"] is not None:
+ # self._thermo = "Ts"
+ elif self.kwargs["h"] is not None and self.kwargs["s"] is not None:
+ self._thermo = "hs"
+ elif self.kwargs["T"] and self.kwargs["x"] is not None:
+ self._thermo = "Tx"
+ elif self.kwargs["P"] and self.kwargs["x"] is not None:
+ self._thermo = "Px"
+ return self._thermo
+
+ def calculo(self):
+ propiedades = None
+ args = (self.kwargs[self._thermo[0]], self.kwargs[self._thermo[1]])
+ if self._thermo == "TP":
+ T, P = args
+ region = _Bound_TP(T, P)
+ if region == 1:
+ propiedades = _Region1(T, P)
+ elif region == 2:
+ propiedades = _Region2(T, P)
+ elif region == 3:
+ vo = _Backward3_v_PT(P, T)
+ funcion = lambda rho: _Region3(rho, self.kwargs["T"])["P"]-P
+ rho = fsolve(funcion, 1/vo)
+ propiedades = _Region3(rho, T)
+ elif region == 5:
+ propiedades = _Region5(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ elif self._thermo == "Ph":
+ P, h = args
+ region = _Bound_Ph(P, h)
+ if region == 1:
+ To = _Backward1_T_Ph(P, h)
+ funcion = lambda T: _Region1(T, P)["h"]-h
+ T = fsolve(funcion, To)
+ propiedades = _Region1(T, P)
+ elif region == 2:
+ To = _Backward2_T_Ph(P, h)
+ funcion = lambda T: _Region2(T, P)["h"]-h
+ T = fsolve(funcion, To)
+ propiedades = _Region2(T, P)
+ elif region == 3:
+ vo = _Backward3_v_Ph(P, h)
+ To = _Backward3_T_Ph(P, h)
+ funcion = lambda par: (_Region3(par[0], par[1])["h"]-h,
+ _Region3(par[0], par[1])["P"]-P)
+# print 1/vo, To, type(vo), type(To)
+ rho, T = fsolve(funcion, [1/vo, To])
+ propiedades = _Region3(rho, T)
+ elif region == 4:
+ # FIXME: Bad region interpretation
+ T = _TSat_P(P)
+ if T <= 623.15:
+ h1 = _Region1(T, P)["h"]
+ h2 = _Region2(T, P)["h"]
+ x = (h-h1)/(h2-h1)
+ propiedades = _Region4(P, x)
+ else:
+ vo = _Backward3_v_Ph(P, h)
+ To = _Backward3_T_Ph(P, h)
+ funcion = lambda par: (_Region3(par[0], par[1])["h"]-h,
+ _Region3(par[0], par[1])["P"]-P)
+ rho, T = fsolve(funcion, [1/vo, To])
+ propiedades = _Region3(rho, T)
+ elif region == 5:
+ funcion = lambda T: _Region5(T, P)["h"]-h
+ T = fsolve(funcion, 1500)
+ propiedades = _Region5(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ elif self._thermo == "Ps":
+ P, s = args
+ region = _Bound_Ps(P, s)
+ if region == 1:
+ To = _Backward1_T_Ps(P, s)
+ funcion = lambda T: _Region1(T, P)["s"]-s
+ T = fsolve(funcion, To)
+ propiedades = _Region1(T, P)
+ elif region == 2:
+ To = _Backward2_T_Ps(P, s)
+ funcion = lambda T: _Region2(T, P)["s"]-s
+ T = fsolve(funcion, To)
+ propiedades = _Region2(T, P)
+ elif region == 3:
+ vo = _Backward3_v_Ps(P, s)
+ To = _Backward3_T_Ps(P, s)
+ funcion = lambda par: (_Region3(par[0], par[1])["s"]-s,
+ _Region3(par[0], par[1])["P"]-P)
+ rho, T = fsolve(funcion, [1/vo, To])
+ propiedades = _Region3(rho, T)
+ elif region == 4:
+ T = _TSat_P(P)
+ if T <= 623.15:
+ s1 = _Region1(T, P)["s"]
+ s2 = _Region2(T, P)["s"]
+ x = (s-s1)/(s2-s1)
+ propiedades = _Region4(P, x)
+ else:
+ vo = _Backward3_v_Ps(P, s)
+ To = _Backward3_T_Ps(P, s)
+ funcion = lambda par: (_Region3(par[0], par[1])["s"]-s,
+ _Region3(par[0], par[1])["P"]-P)
+ rho, T = fsolve(funcion, [1/vo, To])
+ propiedades = _Region3(rho, T)
+ elif region == 5:
+ funcion = lambda T: _Region5(T, P)["s"]-s
+ T = fsolve(funcion, 1500)
+ propiedades = _Region5(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ elif self._thermo == "hs":
+ h, s = args
+ region = _Bound_hs(h, s)
+ if region == 1:
+ Po = _Backward1_P_hs(h, s)
+ To = _Backward1_T_Ph(Po, h)
+ funcion = lambda par: (_Region1(par[0], par[1])["h"]-h,
+ _Region1(par[0], par[1])["s"]-s)
+ T, P = fsolve(funcion, [To, Po])
+ propiedades = _Region1(T, P)
+ elif region == 2:
+ Po = _Backward2_P_hs(h, s)
+ To = _Backward2_T_Ph(Po, h)
+ funcion = lambda par: (_Region2(par[0], par[1])["h"]-h,
+ _Region2(par[0], par[1])["s"]-s)
+ T, P = fsolve(funcion, [To, Po])
+ propiedades = _Region2(T, P)
+ elif region == 3:
+ P = _Backward3_P_hs(h, s)
+ vo = _Backward3_v_Ps(P, s)
+ To = _Backward3_T_Ps(P, s)
+ funcion = lambda par: (_Region3(par[0], par[1])["h"]-h,
+ _Region3(par[0], par[1])["s"]-s)
+ rho, T = fsolve(funcion, [1/vo, T])
+ propiedades = _Region3(rho, T)
+ elif region == 4:
+ T = _Backward4_T_hs(h, s)
+ P = _PSat_T(T)
+ h1 = _Region1(T, P)["h"]
+ h2 = _Region2(T, P)["h"]
+ x = (h-h1)/(h2-h1)
+ propiedades = _Region4(P, x)
+ elif region == 5:
+ funcion = lambda par: (_Region5(par[0], par[1])["h"]-h,
+ _Region5(par[0], par[1])["s"]-s)
+ T, P = fsolve(funcion, [1400, 1])
+ propiedades = _Region5(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ elif self._thermo == "Px":
+ P, x = args
+ if Pt <= P <= Pc and 0 < x < 1:
+ propiedades = _Region4(P, x)
+ elif P > 16.529:
+ T = _TSat_P(P)
+ rho = 1./_Backward3_v_PT(P, T)
+ propiedades = _Region3(rho, T)
+ elif x == 0:
+ T = _TSat_P(P)
+ propiedades = _Region1(T, P)
+ elif x == 1:
+ T = _TSat_P(P)
+ propiedades = _Region2(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ elif self._thermo == "Tx":
+ T, x = args
+ P = _PSat_T(T)
+ if Tt <= T <= Tc and 0 < x < 1:
+ propiedades = _Region4(P, x)
+ elif P > 16.529:
+ rho = 1./_Backward3_v_PT(P, T)
+ propiedades = _Region3(rho, T)
+ elif x == 0:
+ T = _TSat_P(P)
+ propiedades = _Region1(T, P)
+ elif x == 1:
+ T = _TSat_P(P)
+ propiedades = _Region2(T, P)
+ else:
+ raise NotImplementedError("Incoming out of bound")
+
+ else:
+ raise NotImplementedError("Bad incoming variables")
+
+ self.M = M
+ self.Pc = Pc
+ self.Tc = Tc
+ self.rhoc = rhoc
+ self.Tt = Tt
+ self.Tb = Tb
+ self.f_accent = f_acent
+ self.dipole = Dipole
+
+ self.x = propiedades["x"]
+ self.region = propiedades["region"]
+ self.phase = self.getphase(propiedades)
+ self.name = "water"
+ self.synonim = "R-718"
+ self.CAS = "7732-18-5"
+
+ self.T = propiedades["T"]
+ self.P = propiedades["P"]
+ self.v = propiedades["v"]
+ self.rho = 1/self.v
+ self.Tr = self.T/self.Tc
+ self.Pr = self.P/self.Pc
+
+ self.Liquid = _fase()
+ self.Vapor = _fase()
+ if self.x == 0:
+ # only lilquid phase
+ self.fill(self, propiedades)
+ self.fill(self.Liquid, propiedades)
+ elif self.x == 1:
+ # only vapor phase
+ self.fill(self, propiedades)
+ self.fill(self.Vapor, propiedades)
+ else:
+ # two phases
+ liquido = _Region1(self.T, self.P)
+ self.fill(self.Liquid, liquido)
+ vapor = _Region2(self.T, self.P)
+ self.fill(self.Vapor, vapor)
+
+ self.h = propiedades["h"]
+ self.u = self.h-self.P*1000*self.v
+ self.s = propiedades["s"]
+ self.a = self.u-self.T*self.s
+ self.g = self.h-self.T*self.s
+ self.sigma = _Tension(self.T)
+
+ def fill(self, fase, estado):
+ fase.v = estado["v"]
+ fase.rho = 1/fase.v
+
+ fase.h = estado["h"]
+ fase.s = estado["s"]
+ fase.u = fase.h-self.P*1000*fase.v
+ fase.a = fase.u-self.T*fase.s
+ fase.g = fase.h-self.T*fase.s
+
+ fase.cv = estado["cv"]
+ fase.cp = estado["cp"]
+ fase.cp_cv = fase.cp/fase.cv
+ fase.w = estado["w"]
+
+ fase.Z = self.P*fase.v/R*self.M/self.T
+ fase.alfav = estado["alfav"]
+ fase.xkappa = estado["kt"]
+
+ fase.mu = _Viscosity(fase.rho, self.T)
+ fase.k = _ThCond(fase.rho, self.T)
+ fase.nu = fase.mu/fase.rho
+ fase.epsilon = _Dielectric(fase.rho, self.T)
+ fase.Prandt = fase.mu*fase.cp*1000/fase.k
+ fase.n = _Refractive(fase.rho, self.T, self.kwargs["l"])
+
+ fase.alfa = fase.k/1000/fase.rho/fase.cp
+ fase.joule = self.derivative("T", "P", "h", fase)
+ fase.deltat = self.derivative("h", "P", "T", fase)
+ fase.gamma = -self.v/self.P/1000*self.derivative("P", "v", "s", fase)
+
+ if self.region == 3:
+ fase.alfap = estado["alfap"]
+ fase.betap = estado["betap"]
+ else:
+ fase.alfap = fase.alfav/self.P/fase.xkappa
+ fase.betap = -1/self.P/1000*self.derivative("P", "v", "T", fase)
+
+ cp0 = prop0(self.T, self.P)
+ fase.v0 = cp0.v
+ fase.h0 = cp0.h
+ fase.u0 = fase.h0-self.P*1000*fase.v0
+ fase.s0 = cp0.s
+ fase.a0 = fase.u0-self.T*fase.s0
+ fase.g0 = fase.h0-self.T*fase.s0
+
+ fase.cp0 = cp0.cp
+ fase.cv0 = cp0.cv
+ fase.cp0_cv = fase.cp0/fase.cv0
+ fase.w0 = cp0.w
+ fase.gamma0 = cp0.gamma
+ fase.f = self.P*exp((fase.g-fase.g0)/R/self.T)
+
+ def getphase(self, fld):
+ """Return fluid phase"""
+ # check if fld above critical pressure
+ if fld["P"] > self.Pc:
+ # check if fld above critical pressure
+ if fld["T"] > self.Tc:
+ return "Supercritical fluid"
+ else:
+ return "Compressible liquid"
+ # check if fld above critical pressure
+ elif fld["T"] > self.Tc:
+ return "Gas"
+ # check quality
+ if fld["x"] >= 1.:
+ if self.kwargs["x"] == 1.:
+ return "Saturated vapor"
+ else:
+ return "Vapor"
+ elif 0 < fld["x"] < 1:
+ return "Two phases"
+ elif fld["x"] <= 0.:
+ if self.kwargs["x"] == 0.:
+ return "Saturated liquid"
+ else:
+ return "Liquid"
+
+ def derivative(self, z, x, y, fase):
+ """Calculate generic partial derivative: (δz/δx)y
+ where x, y, z can be: P, T, v, u, h, s, g, a"""
+ dT = {"P": 0,
+ "T": 1,
+ "v": fase.v*fase.alfav,
+ "u": fase.cp-self.P*1000*fase.v*fase.alfav,
+ "h": fase.cp,
+ "s": fase.cp/self.T,
+ "g": -fase.s,
+ "a": -self.P*1000*fase.v*fase.alfav-fase.s}
+ dP = {"P": 1,
+ "T": 0,
+ "v": -fase.v*fase.xkappa,
+ "u": fase.v*(self.P*1000*fase.xkappa-self.T*fase.alfav),
+ "h": fase.v*(1-self.T*fase.alfav),
+ "s": -fase.v*fase.alfav,
+ "g": fase.v,
+ "a": self.P*1000*fase.v*fase.xkappa}
+ return (dP[z]*dT[y]-dT[z]*dP[y])/(dP[x]*dT[y]-dT[x]*dP[y])
+
+
+class IAPWS97_PT(IAPWS97):
+ """Derivated class for direct P and T input"""
+ def __init__(self, P, T):
+ IAPWS97.__init__(self, T=T, P=P)
+
+
+class IAPWS97_Ph(IAPWS97):
+ """Derivated class for direct P and h input"""
+ def __init__(self, P, h):
+ IAPWS97.__init__(self, P=P, h=h)
+
+
+class IAPWS97_Ps(IAPWS97):
+ """Derivated class for direct P and s input"""
+ def __init__(self, P, s):
+ IAPWS97.__init__(self, P=P, s=s)
+
+
+class IAPWS97_Pv(IAPWS97):
+ """Derivated class for direct P and v input"""
+ def __init__(self, P, v):
+ IAPWS97.__init__(self, P=P, v=v)
+
+
+class IAPWS97_Tx(IAPWS97):
+ """Derivated class for direct T and x input"""
+ def __init__(self, T, x):
+ IAPWS97.__init__(self, T=T, x=x)
+
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod()
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..861a9f5
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..24fc14e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,34 @@
+from setuptools import setup
+
+from iapws import __version__
+
+
+with open('README.rst') as file:
+ long_description = file.read()
+
+setup(
+ name='iapws',
+ version=__version__,
+ packages=['iapws'],
+ package_data={'': ['LICENSE']},
+ author='jjgomera',
+ author_email='jjgomera at gmail.com',
+ url='https://github.com/jjgomera/iapws',
+ description='Python implementation of standard from The International Association for the Properties of Water and Steam',
+ long_description=long_description,
+ license="gpl v3",
+ install_requires=["scipy"],
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Education",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
+ "Natural Language :: English",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Topic :: Scientific/Engineering",
+ "Topic :: Scientific/Engineering :: Chemistry",
+ "Topic :: Scientific/Engineering :: Physics",
+ "Topic :: Software Development :: Libraries :: Python Modules"
+ ]
+ )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/iapws.git
More information about the debian-science-commits
mailing list