### Build and Install DICE Source: https://context7.com/vperret/dice/llms.txt Instructions for cloning the DICE repository, configuring the build with CMake, and compiling the code. It includes options for enabling OpenMP threading and specifying a custom installation path. ```bash # Clone the repository git clone https://bitbucket.org/vperret/dice # Create build directory and configure cd dice mkdir build && cd build cmake .. # Build with optional OpenMP threading support cmake -DENABLE_THREADS=ON .. make # Install to ~/local by default make install # Custom installation path cmake -DCMAKE_INSTALL_PREFIX=/path/to/install .. make && make install ``` -------------------------------- ### DICE Galaxy Parameter File Example Source: https://context7.com/vperret/dice/llms.txt An example of a galaxy parameter file (`galaxy.params`) used by DICE to define a multi-component galaxy model. It includes global parameters like virial velocity and halo spin, as well as settings for potential grid refinement, density fluctuations, and MCMC algorithm. ```bash # galaxy.params - Full multi-component galaxy model ################### # Global parameters ################### # Virial velocity [km/s] or mass [1e10 Msol] v200 200.0 m200 0. # Halo spin parameter lambda 0.04 # Potential grid refinement (2^level cells per side) level_coarse 7 level_grid_mid_dens 7 level_grid_turb 7 level_grid_dens_fluct 7 # Potential grid size [kpc] (nested boxes) boxsize1 100.0 boxsize2 14.0 boxsize3 5.0 # Density fluctuation parameters dens_fluct_sigma 0.50 dens_fluct_scale_inj 2.00 dens_fluct_scale_diss 0.25 dens_fluct_seed 1212 # Random seed seed 1246 # MCMC ntry algorithm (>1 for multi-try) mcmc_ntry 1 # Hydrostatic equilibrium iterations hydro_eq_niter 3 ####################### ``` -------------------------------- ### DICE Configuration File Example Source: https://context7.com/vperret/dice/llms.txt An example of a DICE configuration file (`dice_isolated.config`) used to define simulation parameters. It specifies galaxy properties, parallel execution settings, output format, and cosmological parameters. ```bash # dice_isolated.config - Configuration for an isolated disk galaxy # Galaxy definition with position and orientation # x[kpc] y[kpc] z[kpc] vx[km/s] vy[km/s] vz[km/s] spin[deg] incl[deg] Galaxy params_files/galaxy1.params 0. 0. 0. 0. 0. 0. 45. 45. # Parallel execution settings Nthreads 16 # Output configuration MaxCompNumber 64 OutputRz 1 Filename dice_iso ICformat Gadget2 # Cosmological parameters (Planck cosmology) Redshift 0.0 H0 71.0 OmegaL 0.70 OmegaM 0.30 OmegaK 0.00 # Normalize mass fractions to unity NormMassFact 0 # GSL integration settings GslWorkspaceSize 10000 GslIntegrationScheme 3 ``` -------------------------------- ### Installation Prefix and RPATH Configuration (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Configures the installation prefix, defaulting to '$ENV{HOME}/local' if not specified. It also sets up RPATH settings for runtime library linking, especially for non-system directories. ```cmake # ---------------------------------------------------------- # # Install SETUP # # ---------------------------------------------------------- mark_as_advanced(CMAKE_INSTALL_PREFIX) IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # no -DCMAKE_INSTALL_PREFIX=INSTALL_PATH from the command line set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/local" CACHE PATH "" FORCE) # default location /home/${USER}/local ENDIF() MESSAGE( STATUS "CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX}) # Set the default installation directories set (LIB_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/lib) set (INCLUDE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/include) set (BIN_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/bin) # use, i.e. don't skip the full RPATH for the build tree SET(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already # (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # the RPATH to be used when installing, but only if it's not a system directory LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") ENDIF("${isSystemDir}" STREQUAL "-1") if (OSX) set(CMAKE_MACOSX_RPATH ON) endif() ``` -------------------------------- ### Configure Installation Rules Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Sets up installation rules for the DICE executable and its libraries. It defines the runtime destination for the executable and the library destination. It also configures the RPATH for executables on macOS. ```cmake get_filename_component(exe ${BIN} NAME_WE) if (OSX) set_target_properties(${exe} PROPERTIES INSTALL_RPATH "@loader_path/../lib") endif() install (TARGETS ${exe} RUNTIME DESTINATION bin) install (FILES ${PROJECT_BINARY_DIR}/lib/lib${LIB}.${LIBEXT} DESTINATION lib) ``` -------------------------------- ### Run DICE with Configuration Source: https://context7.com/vperret/dice/llms.txt Demonstrates how to execute the DICE code using a configuration file. It shows the command-line invocation and provides an example of the expected output, including version information and simulation status. ```bash # Run DICE with a configuration file dice dice_iso.config # Example output: # ///// _____ __ ______ ______ # ///// /\ __-. /\ \ /\ __\ /\ __\ # ///// \ \ \/\ \ \ \ \ \ \ \____ \ \ __ # ///// \ \____- \ \_\ \ \_____\ \ \_____ # ///// \/____/ \/_/ \/_____/ \/_____/ # ///// DICE 4.8 # ///// Written by Valentin Perret [University of Zurich] # ///// # ///// -------------------------------------------------- # ///// Reading configuration file [dice_iso.config] # ///// 1 galaxy to generate # ///// -------------------------------------------------- # ///// ICs successfully created [45 seconds] ``` -------------------------------- ### Target and Output Directory Setup (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Defines the names for the library ('dicetools') and executable ('dice'). It also sets the output paths for libraries and executables. ```cmake # Set the targets set (LIB dicetools) set (BIN dice) # Set the output directories set (LIBRARY_OUTPUT_PATH lib) set (EXECUTABLE_OUTPUT_PATH bin) ``` -------------------------------- ### Build Options Definition and Setup (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Defines build options for shared libraries and OpenMP threading using the 'option' command. It then sets corresponding variables based on user choices. ```cmake # ----- Define all build options ----- # # Shared library option option (ENABLE_SHARED "Build shared libraries") # OpenMP threading option (ENABLE_THREADS "Enable parallel execution" OFF) mark_as_advanced(ENABLE_THREADS) # ----- Setup all build options ----- # # Shared library if (${ENABLE_SHARED} MATCHES "ON") set (BUILD_SHARED_LIBS ON) MESSAGE(STATUS "Shared libraries will be built") endif (${ENABLE_SHARED} MATCHES "ON") # OpenMP threading, default to no set (USE_THREADS 0) if (${ENABLE_THREADS} MATCHES "ON") MESSAGE (STATUS "Parallel execution enabled") set (USE_THREADS 1) endif (${ENABLE_THREADS} MATCHES "ON") ``` -------------------------------- ### Build Flags and Paths Configuration (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Configures build flags, module paths, and messages build-related information. It includes setup from external CMake modules and prints various build environment variables. ```cmake # Set the master build flag. This flag is used to signal if the build should be # performed or if it should be aborted. set (MASTER_BUILD_FLAG true) # extra path for DICE SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} ) MESSAGE( STATUS "CMAKE_MODULE_PATH = " ${CMAKE_MODULE_PATH} ) # Set up compilation flags through cmake macros include(SetupFlags) # contains the full path to the top level directory of your build tree MESSAGE( STATUS "PROJECT_BINARY_DIR = " ${PROJECT_BINARY_DIR} ) # contains the full path to the root of your project source directory, # i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command MESSAGE( STATUS "PROJECT_SOURCE_DIR = " ${PROJECT_SOURCE_DIR} ) MESSAGE( STATUS "CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE} ) MESSAGE( STATUS "CMAKE_C_FLAGS = " ${CMAKE_C_FLAGS} ) MESSAGE( STATUS "LIBRARY TYPE = " ${LIBTYPE} ) MESSAGE( STATUS "core OPT = " ${OPT} ) MESSAGE( STATUS "OSX detected = " ${OSX} ) MESSAGE( STATUS "BUILD_TYPE = " ${RELEASE} ) MESSAGE( STATUS "C COMPILER = " ${CMAKE_C_COMPILER}) MESSAGE( STATUS "CXX COMPILER = " ${CMAKE_CXX_COMPILER}) ``` -------------------------------- ### Clone DICE Repository Source: https://github.com/vperret/dice/blob/master/README.md This command clones the DICE source code from its Bitbucket repository. Ensure you have Git installed to use this command. ```bash git clone https://bitbucket.org/vperperret/dice ``` -------------------------------- ### DICE Configuration for Gas Disk Properties Source: https://context7.com/vperret/dice/llms.txt Sets parameters for a gas disk component in DICE simulations. Includes mass fraction, particle mass, model type, particle type, flatness, hydrodynamical equilibrium, and polytropic index. ```plaintext mass_frac3 0.0066 part_mass3 1e3 model3 2 type3 0 flatz3 0.2 hydro_eq3 1 gamma_poly3 1.1 ``` -------------------------------- ### DICE Velocity Computation Methods Configuration Source: https://context7.com/vperret/dice/llms.txt Configures methods for computing streaming velocities and velocity dispersions in DICE. Includes options for streaming velocity methods (e.g., Bullock 2001, Springel 1999) and Jeans equation dimensions (spherical, 2D, 3D). ```bash # Streaming velocity methods (stream_method): # 0 = User-defined fixed fraction (uses stream_fraction) # 1 = Bullock 2001 - follows cumulative mass profile # 2 = Springel 1999 - fixed fraction of rotation curve # 3 = Solid body rotation # Jeans equation dimensions (jeans_dim): # 0 = Do not use Jeans equations (use sigmar_model/sigmaz_model) # 1 = Spherically symmetric Jeans equation # 2 = Jeans equations with 2 integrals of motion # 3 = Jeans equations with 3 integrals (2D r-z grid) # Example: Disk with epicycle approximation stream_fraction2 1.00 stream_method2 0 epicycle2 1 # Enable epicycle approximation Q_lim2 1.25 # Minimum Toomre Q parameter Q_fixed2 0.0 # Fixed Q (0 = use Q_lim) Q_boost2 0.0 # Additional Q term jeans_dim2 2 # 2D Jeans equations ``` -------------------------------- ### GADGET Particle Type Configuration in DICE Source: https://context7.com/vperret/dice/llms.txt Defines particle types for GADGET simulations using DICE. Specifies how to set gas, dark matter, disk, bulge, and star particles via the 'type' parameter. Also details output formats for GADGET. ```bash # Particle types (set via type parameter): # type1 = 0 # Gas particles (SPH) # type1 = 1 # Dark matter halo particles # type1 = 2 # Disk particles # type1 = 3 # Bulge particles # type1 = 4 # Star particles # Output formats: # ICformat = Gadget1 # Outputs .g1 file # ICformat = Gadget2 # Outputs .g2 file (recommended) # Example usage with GADGET2: dice dice_iso.config # Creates: dice_iso.g2 # Run with GADGET2: mpirun -np 8 Gadget2 param.txt ``` -------------------------------- ### Build DICE Executable Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Defines the main executable target named 'BIN' and specifies its source file, 'src/dice.c'. This command initiates the compilation of the DICE program. ```cmake add_executable(${BIN} src/dice.c) ``` -------------------------------- ### Project Configuration and Versioning (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Sets the minimum required CMake version and the project name. It also defines and formats the project's version number. ```cmake cmake_minimum_required (VERSION 2.6) project (DICE) # Set the version number set (DICE_VERSION_MAJOR 4) set (DICE_VERSION_MINOR 8) set (DICE_VERSION "${DICE_VERSION_MAJOR}.${DICE_VERSION_MINOR}") # Say hello MESSAGE(STATUS "Configuring CMake build system for DICE ${DICE_VERSION}") ``` -------------------------------- ### Dependency Finding and OpenMP Configuration (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Searches for required external libraries like GSL and FFTW3. It conditionally checks for OpenMP support based on the ENABLE_THREADS option and configures C flags accordingly. ```cmake # Looking for required libraries FIND_PACKAGE(GSL REQUIRED) FIND_PACKAGE(FFTW3 REQUIRED) if (${ENABLE_THREADS} MATCHES "ON") FIND_PACKAGE(OpenMP) if(OPENMP_FOUND) SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") else() message(SEND_ERROR "OpenMP not found - skipping building tests") endif(OPENMP_FOUND) endif (${ENABLE_THREADS} MATCHES "ON") ``` -------------------------------- ### Library Source and Header Discovery (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Uses FILE(GLOB) to find all C source files and header files in the 'src' directory. These files will be used to build the library. ```cmake # Set the C files for the library FILE(GLOB LIB_C_SRC ${PROJECT_SOURCE_DIR}/src/[a-z]*.c) # Grab the headers FILE(GLOB LIB_HEADERS src/[a-z]*.h) # Add the library add_library (${LIB} ${LIB_C_SRC}) ``` -------------------------------- ### Configuration File Generation (CMake) Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Generates a configuration header file (dice_config.h) from a template (dice_config.h.in). This file will contain build-time configuration variables. ```cmake CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/src/dice_config.h.in ${CMAKE_SOURCE_DIR}/src/dice_config.h ) # Instruct CMake to create shared libraries #set (BUILD_SHARED_LIBS ON) # Add the binary directory to the search path so that the DICE # configuration file will be found include_directories ("${PROJECT_BINARY_DIR}/src") # Add the DICE source directory to the build configuration, include files # first and then the source files include_directories ("${PROJECT_SOURCE_DIR}/src") #add_subdirectory (src) # Setup a header file to hold configuration variables for Starscream configure_file ( "${PROJECT_SOURCE_DIR}/src/dice_config.h.in" "${PROJECT_SOURCE_DIR}/src/dice_config.h") ``` -------------------------------- ### Define Library and Include Directories Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Specifies the directories where libraries and header files can be found. This is crucial for the build system to locate dependencies like GSL and FFTW3. ```cmake link_directories(${PROJECT_BINARY_DIR}/lib ${GSL_PATH}/lib ${FFTW3_PATH}/lib) include_directories(${PROJECT_SOURCE_DIR}/src ${GSL_PATH}/include ${FFTW3_PATH}/include) ``` -------------------------------- ### Link Libraries to DICE Executable Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Links the necessary libraries to the DICE executable. It conditionally includes 'fftw3_threads' if threading is enabled ('ENABLE_THREADS' is ON), otherwise it links the standard FFTW3 library. ```cmake if(${ENABLE_THREADS} MATCHES "ON") target_link_libraries(${BIN} ${LIB} gsl gslcblas fftw3 fftw3_threads m ) else() target_link_libraries(${BIN} ${LIB} gsl gslcblas fftw3 m) endif() ``` -------------------------------- ### Set Darwin Linker Flags Source: https://github.com/vperret/dice/blob/master/CMakeLists.txt Configures linker flags for Darwin (macOS) to prevent 'Undefined symbols' errors by suppressing undefined symbols and using a flat namespace. This is applied conditionally if the OS is detected as OSX. ```cmake if(OSX) set_target_properties(${LIB} PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace") endif(OSX) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.