Difference between revisions of "Python"

From Chemical Engineering @ UP wiki
Jump to: navigation, search
(Python)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Python ==
 
== Python ==
Python is a popular scripting language. It is on the top 10 of the [http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html TIOBE index], and is often used in scientific programming outside of the major commercial platforms like Matlab or Mathematica.
+
Python is a popular scripting language. It is on the top 5 of the [http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html TIOBE index], and is very popular in scientific computing, in some fields more popular than commercial platforms like Matlab or Mathematica.
 
+
* Check out the [http://www.python.org Python website] for more information
+
  
 
=== Installation ===
 
=== Installation ===
  
* Windows: [ftp://ftp.ee.up.ac.za/pub/windows/maths/Python(x,y)-2.7.2.2.exe Python(x,y)] supplies a full scientific programming environment.
+
* The MPR module uses [https://www.continuum.io/downloads Anaconda]. This is a distribution which supplies a full scientific programming environment. There is a local mirror of that [http://ftp.ee.up.ac.za/pub/windows/python/ here]. Use Anaconda3.
* Linux: Install python along with Matplotlib and Numpy/Scipy
+
* For "serious" programming in Python, we recommend [https://www.jetbrains.com/pycharm/download/ PyCharm] as an IDE. You can get an academic license with your UP e-mail address.
* Mac: Use the [Enthought Python Distribution]
+
 
 +
==== Python 2 vs Python 3 ====
 +
 
 +
Python 3 came out in 2008. Python 2 will have no support past 2020. Use the new one (Python 3), not the old one.
  
 
=== Scientific computing ===
 
=== Scientific computing ===
Line 15: Line 16:
 
is a handy starting point for someone used to Matlab/Octave to get into
 
is a handy starting point for someone used to Matlab/Octave to get into
 
NumpPy/Scipy.
 
NumpPy/Scipy.
 +
 +
* [http://mathesaurus.sourceforge.net/matlab-numpy.html Numpy/SciPy for Matlab/Octave users]. Like a Rosetta stone.
 +
* [http://www.scipy-lectures.org/ More detailed SciPy lectures]
  
 
Plotting is done using the [http://matplotlib.sourceforge.net/ matplotlib] library. The website contains
 
Plotting is done using the [http://matplotlib.sourceforge.net/ matplotlib] library. The website contains
Line 25: Line 29:
 
* [http://www.scipy.org/Cookbook/FittingData Fitting data]
 
* [http://www.scipy.org/Cookbook/FittingData Fitting data]
 
* [http://www.scipy.org/Cookbook/LoktaVolterraTutorial Numerical integration of ODEs]
 
* [http://www.scipy.org/Cookbook/LoktaVolterraTutorial Numerical integration of ODEs]
 +
 +
The department also maintains a small [https://github.com/alchemyst/chemengcookbook cookbook notebook].
 +
 +
=== Symbolic computing ===
 +
 +
The [http://www.sympy.org sympy module] is a very capable symbolic module for Python. It plays well with the [http://ipython.org/notebook.html IPython notebook]
 +
 +
=== Extra modules useful to chemical engineers ===
 +
 +
* [http://coolprop.org CoolProp] is a properties database. It is a thermo-physical property database with properties of many common pure substances. It has a python package as well as an Excel add-in.
 +
* [https://github.com/CalebBell/thermo#thermo Thermo] facilitates the retrieval of constants of chemicals, the calculation of temperature and pressure dependent chemical properties (both thermodynamic and transport), the calculation of the same for chemical mixtures (including phase equilibria), and assorted information of a regulatory or legal nature about chemicals.
 +
* [https://github.com/CalebBell/fluids#fluids Fluids] is open-source software for engineers and technicians working in the fields of chemical, mechanical, or civil engineering. It includes modules for piping, fittings, pumps, tanks, compressible flow, open-channel flow, and more.
 +
 +
=== In teaching ===
 +
Basic Chem Eng Notebooks by Jeff Kantor by Notre Dame: [http://jckantor.github.io/CBE20255/ Here]

Latest revision as of 06:44, 17 March 2019

Python

Python is a popular scripting language. It is on the top 5 of the TIOBE index, and is very popular in scientific computing, in some fields more popular than commercial platforms like Matlab or Mathematica.

Installation

  • The MPR module uses Anaconda. This is a distribution which supplies a full scientific programming environment. There is a local mirror of that here. Use Anaconda3.
  • For "serious" programming in Python, we recommend PyCharm as an IDE. You can get an academic license with your UP e-mail address.

Python 2 vs Python 3

Python 3 came out in 2008. Python 2 will have no support past 2020. Use the new one (Python 3), not the old one.

Scientific computing

Numeric calculations are done using the NumPy or SciPy modules. Here is a handy starting point for someone used to Matlab/Octave to get into NumpPy/Scipy.

Plotting is done using the matplotlib library. The website contains documentation as well as a large gallery of examples.

The SciPy website also has a lot of examples in their Cookbook. Topical ones include

The department also maintains a small cookbook notebook.

Symbolic computing

The sympy module is a very capable symbolic module for Python. It plays well with the IPython notebook

Extra modules useful to chemical engineers

  • CoolProp is a properties database. It is a thermo-physical property database with properties of many common pure substances. It has a python package as well as an Excel add-in.
  • Thermo facilitates the retrieval of constants of chemicals, the calculation of temperature and pressure dependent chemical properties (both thermodynamic and transport), the calculation of the same for chemical mixtures (including phase equilibria), and assorted information of a regulatory or legal nature about chemicals.
  • Fluids is open-source software for engineers and technicians working in the fields of chemical, mechanical, or civil engineering. It includes modules for piping, fittings, pumps, tanks, compressible flow, open-channel flow, and more.

In teaching

Basic Chem Eng Notebooks by Jeff Kantor by Notre Dame: Here