# CometsFactory
> **Part of the [Celestial](https://celestial4498-prog.github.io/Celestial/) project.**
Procedural comet generator for the **Celestial Bodies** ecosystem.
Build, classify, and catalogue comets of every dynamical family — from Jupiter-family short-period comets to interstellar visitors.
---
## Architecture
| **config** | `parameters.rs` | Physical constants, orbital helpers, sublimation constants |
| **types** | `short_period.rs`, `long_period.rs`, `halley_type.rs`, `sungrazer.rs`, `interstellar.rs`, `main_belt_comet.rs`, `centaur_transition.rs`, `extinct.rs` | 8 comet types with builder pattern |
| **physics** | `gravity.rs`, `sublimation.rs` | Binding energy, tides, Roche limit, sublimation rates, gas production, non-grav acceleration |
| **engine** | `orbits.rs`, `evolution.rs`, `coma.rs` | Keplerian propagation, mantle growth, spin-up, coma/tail modelling |
| **observables** | `photometry.rs`, `tail.rs` | Total/nuclear magnitudes, Afρ, dust/ion tail orientation, disconnection events |
| **utils** | `helpers.rs`, `io.rs` | Angle conversions, summary lines for all 8 types |
---
## Comet Types
| 1 | **ShortPeriod** | Jupiter-family comets, P < 20 yr, 2 < T_J < 3 |
| 2 | **LongPeriod** | Oort Cloud origin, P > 200 yr, dynamically new flag |
| 3 | **HalleyType** | 20 < P < 200 yr, T_J < 2, retrograde detection |
| 4 | **Sungrazer** | Kreutz/Marsden/Kracht/Meyer groups, tidal disruption |
| 5 | **Interstellar** | Hyperbolic orbits (e > 1), excess velocity |
| 6 | **MainBeltComet** | Asteroid-like orbits (T_J > 3), sublimation-driven activity |
| 7 | **CentaurTransition** | CO-driven outbursts, giant-planet region, dynamical lifetime |
| 8 | **Extinct** | Dormant/extinct states, mantle thickness, reactivation potential |
All types expose a **builder pattern**: `new()` → `with_*()` chainable methods.
---
## Usage
```rust
use cometsfactory::types::*;
let jfc = ShortPeriod::new(500.0, 3.5, 0.6)
.with_density(600.0)
.with_inclination(10.0)
.with_active_fraction(0.03);
assert!(jfc.is_jupiter_family());
assert!(jfc.perihelion() < jfc.semi_major_axis);
```
```rust
use cometsfactory::physics::sublimation;
let q = sublimation::gas_production_rate(1000.0, 0.05, 1.0, 0.04);
assert!(q > 1.0e20);
```
---
## Tests
73 tests across 3 test suites:
- **types_tests** — 38 tests (builders, orbital properties, classifications)
- **physics_tests** — 14 tests (gravity, sublimation, thermal)
- **engine_tests** — 21 tests (orbits, evolution, coma)
```bash
cargo test --all-targets
```
## Examples
| `generation` | Creates all 8 comet types, exercises enum dispatch |
| `physics` | Gravity + sublimation computations on a Jupiter-family comet |
| `observables` | Photometry, Afρ, dust/ion tails, disconnection events |
```bash
cargo run --example generation
cargo run --example physics
cargo run --example observables
```
---
## License
MIT — Copyright (c) 2026 Rayan Morel