Python in Chemistry

Learning Python and Exploring Chemical Concepts using Jupyter Notebooks

Blackbody radiation, and all the Python it can teach us

📥  Python Basics

Today we released a notebook which on the surface introduces the np.argmax and np.amax functions, along with a host of other delights:

  • As well as the usual scipy.constants and matplotlib, it introduces using colour in your plots.
  • Using functions is revisited.
  • print() is joined by an example of creating Markdown objects with code, so that units can be presented using LaTeX formatting.

To launch an interactive version of the notebook in your browser, click on the “launch Binder” button below.

We hope that you find this notebook useful and would welcome any feedback.

Launch this notebook using Binder

Download this notebook.


Functions - being able to work mathematically

📥  Uncategorised

Andrew has written an introductory notebook on using and defining functions within python. He has a nice little van't Hoff example at the end as well looking at the effect of temperature on the equilibrium constant. You can check it out here.

I'm sorry if you've been having problems with downloading the notebooks, we had a fancy piece of code which automated the process, but this didn't seem to work for Chrome users, we've changed it to a manual download (save as) there are instructions on most pages - but if you need to ask please do.

Happy coding.


Start working with your first Python Jupyter notebook


📥  Exercises, Python Basics

Today we posted the first of our Jupyter Python notebooks meant as a resource to teach yourself chemistry so that you can learn to code to solve chemistry (and other science) problems.

The first workbook covers the most basic things you can do:

  • how to use the Jupyter notebook environment and markdown cells;
  • how to print a word, which will be useful when you want to print an answer;
  • how to use the assert function to check your work.

The second workbook introduced simple mathematical calculations, that can be used in solving chemical problems:

  • simple calculations;
  • the math module, and mathematical functions;
  • variables.

We have added these resources to our Data Analysis with Jupyter Notebooks page. When you open that page you will see that we've listed a few other tutorials, which will appear in the coming weeks.

Good luck with your coding - we think it will be really useful.


Welcome to the Python in Chemistry Blog


📥  Python Basics

We will be using the Jupyter Notebooks app to use Python notebooks which we use to teach coding alongside chemistry content. The resources here are designed for different experience levels; some notebooks and resources are for absolute beginners, others more advanced, and we will also have PhD students sharing their work too – all of it will be interactive.

The resources shared here are designed to extend what we currently cover in our first and second year computational chemistry labs, for those of you who haven’t done CH10009, CH10193 or CH20023 we will share similar resources designed to help you learn to code.

If you aren’t a chemist the resources contain enough information for you to attempt to work it through, we use chemistry to set in some context for coding in Python, but teaching some coding is one of our primary aims.

If you have no experience of Python welcome, the first thing you need to do is download Anaconda – an application which runs the Jupyter notebooks.

You can download Anaconda for Windows, OSX and Linux here

You need to install this and then open the Jupyter notebook application. This will open a window in your chosen internet browser, and open on a page which is a file navigator. Jupyter notebooks are appended with the file type .ipynb, you can’t open these files by double clicking on them, instead you need to have them downloaded and saved to your computer, and open them from the navigator window in your web browser.

Jupyter's interface with file structure open in a web browser

You can open a file by clicking on the .ipynb files – in this case you can tell I’ve opened the ‘Gas Laws tutorial.ipynb’ file because it is highlighted in green. You can open a new notebook by selecting ‘New’ in the top right hand corner of the screen. It is essential that you download resources to your own computer and open them after opening Anaconda.

a project in Jupyter highlighting an opened file in green

At the moment we haven’t shared any notebooks for you to open, but when we do share them they will look a little bit like this one shared below. In the next post we will share our first resource until then if you have any questions or problems please leave a comment (or just leave a comment to say hello!) we will do our best to answer you.

An example Jupyter Python notebook