Setting up your computing environment
Contents
Setting up your computing environment#
You have a few options for running these examples and solving other problems using the approaches shown:
Install and use Python and a text editor or integrated development environment (IDE), like Spyder, on your computer
Install and use Jupyter Notebooks on your computer
Use a (free) cloud Jupyter Notebook environment like Google Colab, Microsoft Azure Notebooks, or Binder
Using Python and Jupyter Notebooks on your computer require essentially the same setup, which is slightly different for different operating systems. The steps following this assume you are planning to use Jupyter Notebook.
Installing Jupyter#
I recommend you install Anaconda to manage your Python environment—it makes installing and managing packages very easy, and works on macOS, Linux, and Windows.
Create and activate an environment (for example, called
thermo
) for Jupyter with Python 3.7. From the command line for Linux and macOS, or the Anaconda Prompt on Windows, run:
$ conda create -vv --name thermo --channel cantera --channel conda-forge python=3.7 cantera pint coolprop jupyter ipython numpy scipy matplotlib
$ conda activate thermo
Before the second command, you may need to tell your shell (e.g., bash, zsh) about conda, by doing conda init zsh
for example. If you get an error with the conda activate
command, your terminal should tell you to do this.
You should activate this environment whenever you want to use these packages.
Run Jupyter Notebook:
$ jupyter notebook
and create a new Python 3 notebook with “New” then “Python 3” under “Notebook:”.
Cloud Jupyter Notebook Environments#
If you cannot or prefer not to install Anaconda/Python/Jupyter on your computer, you can use one of a number of cloud Jupyter Notebook environments to run these examples and do your work. Major options include:
Google Colab#
Google Colab (Colaboratory) is a nice, newer service connected to your Google account that offers free computation time.
In a new notebook, you need to first install Cantera:
!apt-get -qq update -y
!apt-get -qq install -y python3-software-properties
!apt-add-repository -y ppa:speth/cantera > /dev/null 2>&1
!apt-get -qq install -y cantera-python3
and then additional packages like Pint and CoolProp:
!pip install -q pint coolprop
Or, click this link to open a notebook that includes these commands:
(Other common packages like NumPy and SciPy should already be available.)
Binder#
Binder is a service that runs Jupyter Notebooks online, and can automatically create an environment based on a configuration file:
Visit https://mybinder.org
Enter the URL for this textbook: https://github.com/kyleniemeyer/computational-thermo
Click the “launch” button.
Microsoft Azure Notebooks#
With Microsoft Azure Notebooks, after signing in with your Microsoft or Outlook account, you can create a “project” which contains one or more notebooks, text files, data, etc.
In a new Python 3 notebook, you can install Cantera, Pint, and CoolProp in the first cell using:
!conda install -y --channel cantera cantera
!pip install pint coolprop
(This may take some time.)
DataLore#
DataLore is a new and slightly different service that is still under development. Rather than support Jupyter Notebooks directly, they have developed their own implementation of a Python-based notebook.
Although DataLore workbooks come with many common packages installed (e.g., NumPy, SciPy, Matplotlib), it is a bit more challenging to install other packages:
Go to “Tools” → “Library Manager”
In “All Libraries”, search for the package you want to install. For example, you can install
pint
andcoolprop
.In the search results, choose the correct package, then from the dropdown next to the “Install” button choose the latest version available (this should already be selected).
Click the “Install” button. After a few moments, the package should be accessible in your workbook.
Repeat for other packages as needed.
To solve thermodynamics problems, you’ll need to install CoolProp at minimum.
Unfortunately, it is not clear how to install Cantera at the moment, so DataLore may be limited. The behavior is also a bit different than expected with Jupyter notebooks regarding work between different cells, since DataLore is more strict about executing cells in order and tracking dependency—it automatically updates any cells that depend on variables that change in the current cell.
This information will be updated as DataLore evolves and more documentation is available.