Commit Graph

4 Commits

Author SHA1 Message Date
Shawn Anderson a7213aa0d4 Demo updates. 2025-11-24 16:05:47 -08:00
Shawn Anderson cccb6cc20e Fix progressive outflow formula: ensure monotonic increase
Fixed critical bug where outflow would decrease when crossing from
building to capacity zone. The original formula caused a discontinuity.

**Problem:**
Old formula had outflow jumping from (inflow × ratio) in building zone
to (inflow - max) in capacity zone, causing outflow to DROP when
crossing the threshold.

Example (min=100, max=300):
- At inflow=300: outflow = 300 (100% sharing)
- At inflow=301: outflow = 1 (sudden drop!)

**Solution:**
1. Changed capacity threshold from max to 1.5 × max
2. Building zone now uses linear interpolation from 0 to 0.5 × max
3. Capacity zone retains max and shares all excess

New formula guarantees:
✓ Monotonically increasing outflow as inflow increases
✓ Continuous at all zone boundaries
✓ At inflow = min → outflow = 0
✓ At inflow = 1.5 × max → outflow = 0.5 × max
✓ At inflow > 1.5 × max → retain max, share excess

Zones:
- Deficit (inflow < min): outflow = 0
- Building (min ≤ inflow < 1.5×max): progressive linear growth
- Capacity (inflow ≥ 1.5×max): outflow = inflow - max

Changes:
- lib/flow-v2/engine-v2.ts: Updated getFlowZone() and calculateOutflow()

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 11:44:19 -08:00
Shawn Anderson a55cec9958 Implement Flow Funding V2: Continuous flow dynamics with progressive outflow
This commit adds a complete v2 implementation of the flow funding mechanism
with continuous flow dynamics, progressive outflow zones, and real-time
interactive visualization.

## V2 Implementation (New - Today's Work)

### Core Engine (/lib/flow-v2/)
- types.ts: Flow-oriented type system with FlowNode, FlowNetwork, FlowZone
- engine-v2.ts: Steady-state equilibrium solver with progressive outflow
  - Progressive zones: deficit (keep all), building (progressive share), capacity (redirect excess)
  - Iterative convergence algorithm
  - Dual time scale: per-second implementation, per-month UI
- scenarios-v2.ts: 5 preset networks demonstrating various topologies

### Interactive UI (/app/flow-v2/)
- Real-time external inflow sliders (0-$2000/mo per node)
- Dynamic edge width visualization based on flow rate (logarithmic scaling)
- Animated flow particles showing money movement (60 FPS)
- Zone-based node coloring: red (deficit), amber (building), green (capacity)
- Network overflow node (pure sink for unallocatable overflow)
- Comprehensive metrics: per-node and network-level statistics
- Play/pause animation controls
- Click-to-select node highlighting

### Key Features
- Progressive outflow formula implementing the water metaphor:
  * Deficit: outflow = 0
  * Building: outflow = inflow × ((inflow - min) / (max - min))
  * Capacity: outflow = inflow - max
- Steady-state convergence typically in 10-50 iterations
- Fully isolated implementation - no impact on existing routes

## V1 Implementation (Previous Session)

### Core Engine (/lib/flow-funding/)
- Discrete distribution algorithm with phases:
  * Initial distribution (prioritize minimums, fill capacity)
  * Overflow calculation and redistribution
  * Iterative convergence
- Network validation
- 5 preset scenarios

### UI Components
- /app/flowfunding/: Interactive v1 demo with animations
- /app/tbff/: Alternative visualization
- Timeline with time-travel
- Targeted funding mode (click-to-fund)
- Flow particle animations

## Routes
- /flow-v2: V2 continuous flow dynamics demo (NEW)
- /flowfunding: V1 discrete distribution demo
- /tbff: Alternative v1 visualization

All implementations are self-contained and don't affect other parts of the system.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 12:59:52 -08:00
v0 ec0cf6a4ed Initialized repository for chat Post-Appitalism Website
Co-authored-by: Jeff Emmett <46964190+Jeff-Emmett@users.noreply.github.com>
2025-11-02 04:01:46 +00:00