How to write and run Finesse code

Finesse is a Python package and can be used inside any Python code. Usually, that will be as a stand-alone Jupyter Notebook, Python script, or inside a broader project.

Jupyter notebooks

A Jupyter Notebook combines blocks of text, code and output (including plotting) to create a single document (a.k.a. literate programming). This approach to writing code is especially useful in a scientific context where the live kernel and block-level execution allows fast code iterations, and the literate programming allows documented calculation that can be easily shared.

This is a common way to write and run Finesse code and probably where you should start. Most examples in the documentation are written as Jupyter Notebooks.

Jupyter

For stand-alone notebooks and small projects you can use Jupyter Lab to easily create, edit and execute notebooks in your browser. Jupyter Lab can be installed in your conda environment with:

conda install jupyterlab

Then you can start a notebook server in your project directory with:

jupyter lab

This will open a browser window with the Jupyter Lab interface where you can create, browse, edit, and run notebooks.

Integrated Development Environments

More complex projects may benefit from using a modern Integrated Development Environment (IDE) such as VS Code with the Jupyter extension or PyCharm that support notebooks directly.

This allows you to use the full power of an IDE for editing, managing, debugging and running your code and notebooks.

Scripts

You can write Python scripts that use the Finesse Python API and functionalities. These scripts can be executed from the command line by calling the Python interpreter with the script as argument:

python my_script.py

This can be a versatile way to execute some calculation especially if you need to run them on a cluster, a remote server, or via other scripting tools.

kat3

Finesse include a KatScript interpreter called kat3. It exists mostly for historical reason and it is not recommended to use it for new projects. Instead, using the Python scripts or notebooks.