Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
- Code of Conduct
- Development Setup
- Code Style
- Pull Request Process
- Adding New Features
- Testing
- Documentation
- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
- Rust 1.70 or later
- Platform-specific dependencies (see GETTING_STARTED.md)
# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/Atoms.git
cd Atoms/Atoms_Rust
# Build the project
cargo build
# Run tests
cargo test
# Run a binary to verify setup
cargo run --bin realtime# Install rustfmt and clippy
rustup component add rustfmt clippy
# Run formatting check
cargo fmt --check
# Run linter
cargo clippy --all-targets --all-featuresWe use rustfmt with default settings. Before committing:
cargo fmtWe use clippy for additional linting. Address all warnings:
cargo clippy --all-targets --all-features -- -D warnings| Item | Convention | Example |
|---|---|---|
| Types | PascalCase | OrbitCamera, Sampler |
| Functions | snake_case | sample_phi, calculate_probability_flow |
| Constants | SCREAMING_SNAKE_CASE | ELECTRON_R, A0 |
| Modules | snake_case | physics, render |
All public items must have documentation comments:
/// Calculate probability current at a position.
///
/// For states with m ≠ 0, returns the velocity of probability flow.
/// This gives the circulating motion visible in orbitals like 2p±1.
///
/// # Arguments
///
/// * `pos` - Position in Cartesian coordinates
/// * `n` - Principal quantum number
/// * `l` - Angular momentum quantum number
/// * `m` - Magnetic quantum number
///
/// # Returns
///
/// Velocity vector representing probability current flow.
///
/// # Example
///
/// ```
/// use atoms_rust::calculate_probability_flow;
/// use macroquad::prelude::Vec3;
///
/// let vel = calculate_probability_flow(Vec3::new(5.0, 0.0, 5.0), 2, 1, 1);
/// ```
pub fn calculate_probability_flow(pos: Vec3, n: i32, l: i32, m: i32) -> Vec3 {
// Implementation...
}Use Result for fallible operations. Use thiserror for custom error types:
use thiserror::Error;
#[derive(Error, Debug)]
pub enum PhysicsError {
#[error("Invalid quantum numbers: n={n}, l={l}, m={m}")]
InvalidQuantumNumbers { n: i32, l: i32, m: i32 },
#[error("CDF table not built for n={n}, l={l}")]
CdfNotBuilt { n: i32, l: i32 },
}- Create an issue describing the bug or feature
- Fork the repository and create a feature branch
- Make your changes following code style guidelines
- Add tests for new functionality
- Update documentation as needed
- Run all checks:
cargo fmt --check cargo clippy --all-targets --all-features -- -D warnings cargo test cargo doc --no-deps
Use conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentation onlyrefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
Examples:
feat: add 4f orbital presetsfix: correct Laguerre polynomial recurrencedocs: add installation guide for Windows
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactoring
## Testing
Describe how you tested these changes
## Checklist
- [ ] Code follows style guidelines
- [ ] Documentation updated
- [ ] Tests added/updated
- [ ] All checks pass- PRs require at least one approval
- Address all review comments
- Squash commits before merge (if requested)
- Add preset definition in appropriate binary
- Update documentation with new preset
- Add example to user guide
- Create new binary in
src/bin/ - Import library functions:
use atoms_rust::{ inferno, sample_phi, spherical_to_cartesian, OrbitCamera, Sampler, };
- Add to
Cargo.toml:[[bin]] name = "your_visualizer" path = "src/bin/your_visualizer.rs"
- Add documentation in user guide
- Add function to appropriate module in
src/physics/ - Export from
mod.rs - Add to
lib.rsre-exports - Write unit tests
- Document with rustdoc and LaTeX formulas
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_laguerre_base_cases() {
assert!((laguerre(1, 0, 1.0) - 1.0).abs() < 1e-10);
assert!((laguerre(2, 0, 1.0) - 1.0).abs() < 1e-10);
}
#[test]
fn test_spherical_to_cartesian() {
let pos = spherical_to_cartesian(1.0, std::f32::consts::FRAC_PI_2, 0.0);
assert!((pos.x - 1.0).abs() < 1e-6);
assert!(pos.y.abs() < 1e-6);
assert!(pos.z.abs() < 1e-6);
}
}# Run all tests
cargo test
# Run specific test
cargo test test_laguerre
# Run with output
cargo test -- --nocapture# Run benchmarks
cargo benchcargo doc --openWhen adding features, update relevant docs:
| Change | Update |
|---|---|
| New binary | README.md, USER_GUIDE.md |
| New physics | PHYSICS.md, API_REFERENCE.md |
| Architecture change | ARCHITECTURE.md |
| Performance change | PERFORMANCE.md |
- Open an issue for questions
- Check existing issues before opening new ones
- Join discussions on existing issues
Thank you for contributing! 🎉