How fangq/mcx works
Main Components Overview
The system should be divided into these major components:
a) Core Simulation Engine
• CUDA-based Monte Carlo simulation kernel
• Photon transport physics implementation
• Memory management for GPU operations
b) Input/Output Interfaces
• Multiple file format handlers (JSON, .inp, binary formats)
• Data compression/decompression modules
• Results storage and export systems
c) User Interfaces
• Command-line interface (CLI)
• MATLAB/Octave interface (MCXLAB)
• Python interface (PMCX)
• GUI interface (MCX Studio)
Detailed Component Relationships
[User Interfaces]
• ↓
[Input Processing]
• ↓
[Simulation Core] ←→ [GPU Management]
• ↓
[Output Processing]
• ↓
[Data Storage/Export]
Key Architectural Elements
a) Input Layer:
• JSON parser (cJSON)
• Configuration validator
• Volume data loader
b) Computation Layer:
• CUDA kernel manager
• Multi-GPU scheduler
• Memory allocator
• Random number generators
• Photon physics engine
c) Output Layer:
• Volumetric data formatter
• Detector data processor
• Trajectory recorder
• Format converters (mc2, nii, jnii, bnii)
Integration Points
Interfaces with:
• MATLAB/Octave (MCXLAB)
• Python (PMCX)
• GUI (MCX Studio)
• External visualization tools
Performance-Critical Paths
High-throughput paths:
• GPU memory transfers
• Photon transport calculations
• Output data accumulation
The modular design allowing for different simulation types
• Special symbols
• Component types
This design captures MCX's sophisticated architecture while maintaining clarity about its primary purpose as a GPU-accelerated photon transport simulator.