1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Organ physics substrate — cardiac and respiratory simulation.
//!
//! `organpool` simulates autonomous organ systems with integer-only physics,
//! wall-clock timing, and chemical modulation by the autonomic nervous system.
//!
//! # Organs
//!
//! **Heart** — 4-zone cardiac conduction (SA → AV → Conduction → Myocardium)
//! with ion channel cycling, escape rhythms, gap junctions, calcium clock,
//! and HRV generation. Modulated by NE (sympathetic), ACh (parasympathetic),
//! and cortisol.
//!
//! **Lungs** — Respiratory cycle (Inspiration → EndInspiratory → Expiration →
//! EndExpiratory) with central pattern generator, CO2/O2 gas exchange, and
//! autonomic modulation. Couples to the heart via respiratory sinus arrhythmia.
//!
//! Each organ runs its own thread with its own chemical environment.
//! External sources inject chemicals; the organ metabolizes them internally.
//! If nothing injects, chemicals decay to resting baselines and the organ
//! operates at its intrinsic rate. Denervated organs still function.
//!
//! # Architecture
//!
//! ```text
//! Brain injects ──→ Heart (thread) ──→ BeatEvent channel
//! ↑ RSA (AtomicU8)
//! Brain injects ──→ Lungs (thread) ──→ BreathEvent channel
//! ```
//!
//! # Usage
//!
//! ```no_run
//! use organpool::CardiacPipeline;
//! use std::time::Duration;
//!
//! // Start the heart — it begins beating immediately at intrinsic rate
//! let heart = CardiacPipeline::start();
//!
//! // Inject NE (sympathetic burst — decays over ~2.5s half-life)
//! heart.inject_ne(200);
//!
//! // Observe beats
//! while let Ok(beat) = heart.beats.recv_timeout(Duration::from_secs(2)) {
//! println!("Beat #{} IBI={}μs", beat.beat_number, beat.ibi_us);
//! }
//!
//! // Stop the heart
//! let snapshot = heart.stop();
//! println!("Final BPM: {}", snapshot.last_bpm);
//! ```
// Re-export cardiac types
pub use ;
pub use ;
pub use ;
// Re-export respiratory types
pub use ;
pub use ;
pub use ;
pub use AutonomicBridge;