How lolle2001/ampt-fhmpf works
The AMPT-FHMPF project is a specialized framework developed in C++ (with integrated Fortran components) to run the AMPT (A Multi-Phase Transport) simulation model in a multi-core, file-handling accelerated environment. In essence, it provides a wrapper around different versions of the AMPT code (original, animation-enabled, and hijing-only) by using a combination of C++ (for orchestration, file management, and multi-threading/processing) and legacy Fortran (for the simulation engines). Additionally, there is a Python utility for generating input files based on centrality tables and simulation parameters.
• User Interface / Execution Layer:
• Command-line executable (ampt-mp) that is the main entry point.
• Shell scripts (like compile-ampt-mp.sh and those in the server folder) used for compilation, simulation execution, and file synchronization.
• Core Processing/Manager Module:
• The C++ library files (found in the lib folder) contain key classes such as InstanceManager, Manager, Messenger, Timer, and Utilities. These pieces are responsible for managing simulation instances, messaging between threads/processes, tracking progress, and providing utility functions.
• Simulation Engines:
• The Fortran codes are organized within the src directory into multiple subdirectories (original, animation, and hijing-only), each representing a different compiled variant of the AMPT simulation. They interact with the C++ orchestrator via file input/output.
• File and Data Handling:
• The “input” directory holds parameter files for configuration.
• The “data” directory is designated for storing simulation outputs from various runs.
• Build and Deployment:
• Makefiles (in the make folder and within src subdirectories) outline the compilation steps for both the C++ wrapper and Fortran simulation codes.
• The server folder includes scripts for handling remote file operations (upload/download), which can be conceptualized as a deployment or data management module.
• Input Generation Utility:
• A Python script in the “utils” folder (ampt-input-gen.py) alongside a collection of centrality tables (subfolder centrality_tables) is used to generate and possibly batch-create simulation input files.
Relationships and Data Flow
• The command-line interface (CLI) receives user commands to compile or run simulations.
• The orchestration layer (C++ in lib) uses its manager classes to launch simulation processes (Fortran executables compiled from src).
• Data flows from input files (in “input”) to simulation execution and is subsequently written to the “data” directory.
• For build/deployment, Makefiles coordinate with the compilation scripts (e.g. compile-ampt-mp.sh) to connect the different code bases.
• The Python input generator (from utils) provides dynamically created parameter files that are then used by the simulation processes.
• The external server scripts connect the local file management system with remote servers for data transfer, thus interacting with the file handling subsystem.
Architectural Patterns/Technologies
• The separation of concerns is clear: the project is divided into a CLI controller, a core orchestration module managing simulation instances, legacy simulation engines, and auxiliary utilities (Python and shell scripts).
• Use of modern C++ (C++17 standard) with external libraries such as fmt (for formatting), argparse (for command-line parsing), and OpenMP (for multiprocessing), showcasing an approach that combines legacy simulation code (Fortran) with modern orchestration.