Skip to content

ComFiT documentation

ComFiT (Github) is a versatile Python library for simulating field theories, including plotting and animation in an object-oriented manner. If you use ComFiT in your research, please cite the following paper:

Skogvoll, V., & Rønning, J. (2024). ComFiT: A Python library for computational field theory with topological defects. Journal of Open Source Software, 9(98), 6599.


The best way to get to know ComFiT is by using it in one of the following tutorials.

Base System

Quantum Mechanics

Bose-Einstein Condensates

Nematic Liquid Crystal

Phase-field crystal

For the time being, ComFiT is limited to periodic boundary conditions, but this may change in the future.


Comfit can be installed from the Python Package Index (PyPI), a repository of software for the Python programming language, by executing the command

pip install comfit

pip install comfit in your terminal or command prompt.

Virtual environnement

Using a virtual environnement when using ComFiT is highly encouraged for because even though we try to write robust code, it is still a library under development, so previously written simulations may break. By keeping your simulations together with the specific version of ComFiT, you make sure that your simulations will not break due to coming updates.

To create a virtual environnement, run the following command in your terminal after having navigated to the root folder of your exploration project

Python -m venv myvenv

This will create the folder myvenv which will contain the local installation of Python and associated packages. To activate the virtual environnement, simply run


from the terminal. Afterwards, you may install ComFiT using PyPi. If your folder is part of a github repository, it is recommended to remove the virtual environment from the git project by adding venv/ to your .gitignore file.


We welcome contributions. Whether you're fixing a bug, adding a new feature, or improving our documentation, your support helps us make the package more robust and versatile. Contributions can take many forms, from fixing minor bugs to implementing complex new features. Below are the ways you can contribute:

Bug Fixes

Did you identify a bug? Here's how to proceed:

  1. Fork the repository: Start by forking the ComFiT GitHub repository.
  2. Create a branch: Make a new branch on your fork dedicated to the bug fix.
  3. Fix the bug: Make the necessary changes to resolve the bug.
  4. Run tests: Ensure all existing tests pass with your changes. Add new tests if necessary to cover the bug fix.
  5. Submit a Pull Request (PR): Create a PR against the main ComFiT repository. Clearly describe the bug and how your changes fix it.

Reporting Issues

Encountered an issue or have a suggestion? Please follow these steps:

  1. Check existing issues: Before creating a new issue, please check existing issues to avoid duplicates.
  2. Create a new issue: If your issue is unique, open a new issue on GitHub. Provide a detailed description, including steps to reproduce the issue if applicable.

Feature Requests

Got an idea for a new feature or enhancement? We'd love to hear it! Please raise a discussion, or an issue as outlined above, detailing your idea and its potential benefits to ComFiT.

Adding Your Own Model

If you're interested in adding your own model to ComFiT, we welcome your contribution! Your model should adhere to the following guidelines:

  1. Well-documented: Include detailed documentation explaining your model's theory, implementation, and usage.
  2. Thoroughly tested: Write comprehensive tests covering the functionality of your model.
  3. Follow ComFiT structure: Ensure your model integrates seamlessly with the existing ComFiT framework.
  4. Tutorial: Consider adding a tutorial in the form of a Jupyter notebook, demonstrating how to use your model. Link to the tutorial in your contribution.

For detailed instructions on implementing your own PDE model with ComFiT, refer to our tutorial for creating your own model.

Documentation Improvements

Good documentation is key to a project's usability and its community's growth. If you see areas for improvement or want to add documentation for undocumented features, your contributions are greatly appreciated.