How to setup a PyCharm project
In this tutorial we explain how to setup a Python development environment to be able to create, modify and run BornAgain simulations using Python scripts. The tutorial is oriented towards Windows users who are making their first steps in scientfic computing with Python.
At this point we assume that the user has already installed
Anaconda Python distribution as explained in installation section. As the next step, we suggest you to install PyCharm - a free, lightweighted, multi-platform Python IDE - to be able to work with Python code in a convenient manner. Download PyCharm community edition from here.
The rest of the tutorial explains how to setup Anaconda + BornAgain + PyCharm project for the first time.
1. Start PyCharm and create new project
Our project Untitled1 will be created in the default projects directory and will use Python interpreter from Anaconda Python distribution
As soon as you push create button, you will be presented with the initial project view. The tree view on the left notifies that your project so far consists from two parts: '
untitled' directory for your python scripts (empty for the moment) and 'External Libraries' directory you shouldn't worry about.
2. Add BornAgain libraries to your project
At this point it might be necessary to help PyCharm find the BornAgain libraries. The easiest way to do this, is to add BornAgain library directory to your project. Go to the "File/Settings" menu
Select in the settings tree from the left "Settings > Project> Project Structure" and then push the button "+Add Content Root" on the right
A new window will appear, select C:\BornAgain-1.4.0\bin directory and click the OK button
As a result, the directory
C:\BornAgain-1.4.0\bin will be aded to your project. The directory contains BornAgain core libraries and PyCharm will always be able to load them if other project files require this.
3. Add BornAgain example directory to your project
Optionally, you might want to add the BornAgain examples directory to you project to be able to see, modify and run examples at any time. As was explained in the previous section, go to the project settings and add new directory C:\BornAgain-1.4.0\Examples as new content. The final project settings window should look like below
Close settings window. The final project will look like shown below. Try to run examples one by one, or start creating you own first BornAgain script.