Detailed Running

Code Structure

The Partial Pressures Module is designed to calculate partial pressures from hadronic susceptibilities. The module is implemented within a Docker container to ensure portability and consistency. The workflow involves parsing input parameters, performing core computations, and generating output files for further analysis. Below is a detailed explanation of the code structure and its components.

—

  1. Input Files: - `config.yaml`: This file specifies the ranges for \(T\), \(\mu_B\), \(\mu_Q\), and \(\mu_S\), as well as user-defined options for:

    • Thermodynamics: Thermodynamic data to be stored in the output.

    • File structure: Input directory, file extensions, and output format.

  2. Configuration Validation: - The OpenAPI_Specifications_validator.py script validates the config.yaml file against the OpenAPI specifications defined in OpenAPI_Specifications-PartPress.yaml. This ensures that all required parameters are provided and conform to the expected structure.

  3. Core Computation: - The main script, MUSES_Wrapper.py, orchestrates the execution of the module. It validates inputs, processes susceptibility data, and calls the PartialPressure function from src/Partial_Pressure_Equations.py to compute the partial pressures.

  4. Output Files: - The results of the computation are saved in the output/ directory. The following files are generated:

    • `Partial_Pressures.csv` or `Partial_Pressures.tsv`: Contains the calculated partial pressures and their associated errors for each temperature point.

    • `Partial_Pressures-metadata.yaml`: Describes the structure and units of the output data.

    • `status.yaml`: Provides the status of the module’s execution, including success or error messages.

—

Core function (in src/Partial_Pressure_Equations.py)

The Partial_Pressure_Equations.py script contains the core functions for reading susceptibility data, combining data from multiple files, and calculating partial pressures. Below is an overview of the key functions:

  1. `generate_formula(coefficients, variables)`: - Computes a linear combination of variables using the provided coefficients. - Used to calculate partial pressures based on susceptibility data.

  2. `generate_error(coefficients, variables)`: - Computes the error associated with a linear combination using the square root of the sum of squared terms. - Used to calculate the errors for the partial pressures.

  3. `ReadDataOfOneFileIntoArray(filename, allow_warnings=True)`: - Reads susceptibility data from a single file and organizes it into arrays for temperatures and chi values. - Handles errors such as missing or malformed data.

  4. `combine_data_from_files(input_folder, file_extension=”.hrg”)`: - Combines susceptibility data from multiple files in the specified input folder. - Handles issues such as missing files, mismatched data lengths, and files with no error data. - Returns averaged temperature values, combined chi values, and associated error points.

  5. `PartialPressure(input_dir, output_dir, output_format=”csv”, file_extension=”.hrg”)`: - The main function for calculating partial pressures. - Reads susceptibility data from the input directory, either from a single file (dat.txt) or by combining multiple files. - Computes partial pressures and their errors for each temperature point using predefined equations and coefficients. - Writes the results to an output file in the specified format (csv or tsv).

—

Workflow Overview

The module’s workflow can be summarized as follows:

  1. Input Validation: - The config.yaml file is validated against the OpenAPI specifications. - Missing or invalid parameters are flagged, and execution is halted if necessary.

  2. Data Processing: - Susceptibility data is read from the input directory. - If multiple files are provided, their data is combined and averaged.

  3. Partial Pressure Calculation: - Partial pressures and their errors are calculated for each temperature point using the PartialPressure function. - The calculations are based on predefined equations and coefficients for each partial pressure.

  4. Output Generation: - The results are written to an output file in the specified format. - Metadata describing the output structure is saved in a separate YAML file. - A status file is generated to indicate the success or failure of the module’s execution.

—

Code Organization

The module’s code is organized into the following directories:

  • `api/`: - Contains the OpenAPI specifications and the input validation script. - Key file: OpenAPI_Specifications_validator.py.

  • `src/`: - Contains the core computation script for calculating partial pressures. - Key file: Partial_Pressure_Equations.py.

  • `input/`: - Contains the config.yaml file and susceptibility data files.

  • `output/`: - Stores the generated output files, including results, metadata, and status.

  • `test/`: - Contains reference files and test cases for validating the module’s functionality.