Contributing¶
Contributing to Elementa¶
Thank you for your interest in contributing! This document explains how to set up a development environment, run tests, and submit changes.
Development Setup¶
# 1. Fork and clone
git clone https://github.com/<your-username>/elementa.git
cd elementa
# 2. Create a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install in editable mode with dev extras
pip install -e ".[dev]"
Code Style¶
Elementa uses Ruff for linting and formatting.
Please run these before submitting a pull request.
Running Tests¶
Adding a New Physics Module¶
- Create
elementa/physics/<name>.py. - Import and subclass
PhysicsDescriptorfromelementa.physics.registry. - Define all required class attributes (
name,abbreviation,icon,bc_types,result_fields,default_config, …). - Implement
assemble_and_solve(cls, state: PhysicsState) -> PhysicsState. - Call
register_physics(YourDescriptor)at the bottom of the file. - Add the import to
elementa/physics/__init__.py. - Add an icon file (PNG, 350×350) to
elementa/assets/.
See docs/guides/adding-physics.md for a detailed walkthrough.
Adding a New Geometry Primitive¶
- Subclass
ShapeDefinelementa/core/geometry_registry.py. - Set
kind,dim, andparams. - Implement
build(cls, cad, name, params) -> intusing theElementaCADAPI. - Add the class to
SHAPE_REGISTRY. - Add a corresponding
add_<shape>method toElementaCADinelementa/cad/cad.pyif required.
Pull Request Guidelines¶
- Target the
mainbranch. - Include a clear description of the change and the motivation.
- Add or update tests where appropriate.
- Keep commits focused; squash fixup commits before requesting review.
- Reference related issues with
Fixes #<issue>in the PR description.
Reporting Bugs¶
Open an issue at https://github.com/soheilgreen/elementa/issues with:
- A minimal reproducible example.
- Python version, OS, and package versions (
pip show elementa-fem). - Full traceback if applicable.
Code of Conduct¶
Be respectful and constructive in all interactions. We follow the Contributor Covenant.