Skip to main content

A Python module for thermodynamic calculations for teaching thermodynamics at the University of California, Berkeley.

Project description

me40

ME40 — Thermodynamics

Department of Mechanical Engineering University of California, Berkeley

pyCalor

The software package contains classes state and process. The following is the description of their use. You can also get the built-in information by typing the following statements in the Python command line:

import thermo as th

print(th.state.__doc__)

print(th.process.__doc__)

Class state

A call

import thermo as th

st = th.state(substance, property1=value1, property2=value2, name="A")

creates an object of class state. Each such object contains the following fields:

| :----------- | :--------------: | -------------------------: | | st.p | pressure | (in units of kPa) | | st.t | temperature | (in units of K) | | st.v | specific volume | (in units of m3/kg) | | st.u | specific energy | (in units of kJ/kg) | | st.h | specific enthalpy | (in units of kJ/kg) | | st.s | specific entropy | (in units of kJ/kg K) | | st.x | quality | (fraction) | | st.molW | molecular weight | (in units of kg/kmol) | | st.R | gas constant | (in units of kJ/kg K) | | st.substance | 'water', 'air', 'nitrogen', ... | () |

The property values are in the “base units”; they can be viewed by issuing a command:

state.units

Examples:

import thermo as th

th.state.units

st1 = th.state('water', p=(1,'bar'), v=0.1, name="1")

st1.plot("pv") # supported plots are: "pv","Ts","ph"

st2 = th.state('R134a', x=1, t=300, name="B")

st2.plot("Ts", isoProp="v")

st3 = th.state('air', p=(1,'Mpa'), t=(10,'c'))

st3.name = "2a"

This information can also be viewed in the programming environment;

th.state.__doc__

Class process

A call

import thermo as th pr = th.process([(state1,state2),(state2,state3),...])

creates an object of class process. An object of this class represent a simple process, from st1 to st2,

pr = th.process(st1,st2)

a simple cyclic process,

pr = th.process([(st1,st2),(st2,st3),(st3,st4),(st4,st1)]),

which can also be created as

pr = th.process(st1,st2,st3,st4,st1),

or any complex process, but for a single working fluid.

You can access process object properties by the following calls

| :----------- | :--------------: | | pr.StateList | returns a list of state objects| | pr.isoProp(st1,st2) | returns a dictionary of {isoProperty: value,...} for process st1st2 |

Once you created process object pr, you can display its states on a thermodynamic diagram via

pr.plot('ts')

to display process pr on a T-s diagram; you may likewise to make such plot in other coordinates, like 'pv', 'ph', etc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycalor-1.0.2.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycalor-1.0.2-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file pycalor-1.0.2.tar.gz.

File metadata

  • Download URL: pycalor-1.0.2.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.12

File hashes

Hashes for pycalor-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4212a1aed953ae521e01f322607daf2ae0df75e895d84c3b59671b33a62fd26a
MD5 b89ec50a9af99467797a020ae26a4866
BLAKE2b-256 d81534370216981673ae1632589025c3b5004ea2c9b9558178806c5a1cc7046e

See more details on using hashes here.

File details

Details for the file pycalor-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pycalor-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for pycalor-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 043ad28eb1b0797f18b6e964b9ea6b41b833a0a1df9b8ebb69a888e939f2724e
MD5 6e785ca5049ccc0a351588d8012be06f
BLAKE2b-256 b33349de303ed094687204080638af6a910f2b39edc21f10a4f63f0b344bb569

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page