### Compile Example Programs Source: https://github.com/arguelles/nusquids/blob/master/README.md Compile the example programs. Executables are placed in subdirectories of examples/. ```bash make examples ``` -------------------------------- ### Run Python single_energy example Source: https://github.com/arguelles/nusquids/blob/master/examples/README.md Command to run the Python Single_energy example after installing nuSQuIDS with `pip install .`. ```bash python examples/Single_energy/main.py ``` -------------------------------- ### Install the C++ Library Source: https://github.com/arguelles/nusquids/blob/master/README.md Install the library to the default location /usr/local. ```bash make install ``` -------------------------------- ### Install Julia bindings with Pkg.develop Source: https://github.com/arguelles/nusquids/blob/master/README.md Install the Julia bindings by developing the local package path. Run from Julia. ```julia using Pkg Pkg.develop(path="/path/to/nuSQuIDS/resources/julia/nuSQuIDS") ``` -------------------------------- ### Run Full Benchmark Source: https://github.com/arguelles/nusquids/blob/master/README.md Run the full benchmark suite with more iterations. ```bash make benchmark ``` -------------------------------- ### Run C++ single_energy example Source: https://github.com/arguelles/nusquids/blob/master/examples/README.md Command to run the C++ Single_energy example after building nuSQuIDS with `make examples`. ```bash ./examples/Single_energy/single_energy ``` -------------------------------- ### Run Quick Benchmark Source: https://github.com/arguelles/nusquids/blob/master/README.md Run the quick benchmark suite with fewer iterations. ```bash make benchmark-quick ``` -------------------------------- ### Build and install Python bindings Source: https://github.com/arguelles/nusquids/blob/master/README.md Build and install the Python bindings after configuration. Alternatively, add the bindings to PYTHONPATH for development. ```bash make python make python-install ``` ```bash export PYTHONPATH=$(PATH_TO_nuSQUIDS)/resources/python/bindings/:$PYTHONPATH ``` -------------------------------- ### Write and evolve state in HDF5 write example Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Saves the system state to HDF5 before and after evolution. Used in write.cpp to serialize the full system for later reading. ```latex nus.WriteStateHDF5("./initial_state.hdf5"); nus.EvolveState(); nus.WriteStateHDF5("./final_state.hdf5"); ``` -------------------------------- ### Install nuSQuIDS from PyPI Source: https://github.com/arguelles/nusquids/blob/master/README.md Install the Python package with pre-built wheels from PyPI. No need to install GSL, HDF5, or SQuIDS separately. ```bash pip install nusquids ``` -------------------------------- ### Run Unit Tests Source: https://github.com/arguelles/nusquids/blob/master/README.md Run unit tests to verify correct behavior. ```bash make test ``` -------------------------------- ### Change Installation Prefix Source: https://github.com/arguelles/nusquids/blob/master/README.md Set a custom installation prefix, e.g., $HOME. ```bash ./configure --prefix=$HOME ``` -------------------------------- ### Get Linker Flags with nusquids-config Source: https://github.com/arguelles/nusquids/blob/master/README.md Retrieve linker flags for linking programs against nuSQuIDS. ```bash nusquids-config --libs ``` -------------------------------- ### Compile the C++ Library Source: https://github.com/arguelles/nusquids/blob/master/README.md Compile the library after configuration is complete. ```bash make ``` -------------------------------- ### Install Python helpers and __init__.py Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Installs pure-Python helper files and __init__.py from the bindings directory into the nuSQuIDS package. ```cmake install( DIRECTORY ${CMAKE_SOURCE_DIR}/resources/python/bindings/ DESTINATION nuSQuIDS FILES_MATCHING PATTERN "*.py" # nuSQUIDSTools.py, __init__.py, etc. ) ``` -------------------------------- ### Output of flavor composition query Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Example output showing the flavor probabilities after evolution. ```Python [0.004675502573140013, 0.9022064087866011, 0.09311808864025879] ``` -------------------------------- ### Python Example: Loading WCG24 Cross Sections Source: https://github.com/arguelles/nusquids/blob/master/data/xsections/README.md Python equivalent for loading WCG24 cross sections for specific elements (oxygen, iron) and setting the library on a nuSQUIDS instance. ```python import nuSQuIDS as nsq # Load WCG24 cross sections for specific elements xsdir = nsq.getResourcePath() + "/xsections/" lib = nsq.CrossSectionLibrary() lib.addTarget(nsq.oxygen, nsq.NeutrinoDISCrossSectionsFromTables(xsdir + "wcg24_oxygen.h5")) lib.addTarget(nsq.iron, nsq.NeutrinoDISCrossSectionsFromTables(xsdir + "wcg24_iron.h5")) # ... etc nus = nsq.nuSQUIDS(...) nus.Set_CrossSectionLibrary(lib) ``` -------------------------------- ### Use Julia bindings to evolve neutrino state Source: https://github.com/arguelles/nusquids/blob/master/README.md Example usage of the Julia bindings: create a nuSQUIDS object, set vacuum body and track, set energy and initial state, evolve, and print flavor probabilities. ```julia using nuSQuIDS units = Const() nus = nuSQUIDS(3, neutrino) Set_Body_Vacuum(nus, make_Vacuum()) Set_Track_Vacuum(nus, make_VacuumTrack(1000.0 * km(units))) Set_E(nus, 1.0 * GeV(units)) Set_initial_state(nus, [0.0, 1.0, 0.0], flavor) EvolveState(nus) for i in 0:2 println("P(nu_mu -> flavor $i) = ", EvalFlavor(nus, i)) end ``` -------------------------------- ### Get Compiler Flags with nusquids-config Source: https://github.com/arguelles/nusquids/blob/master/README.md Retrieve compiler flags for compiling programs against nuSQuIDS. ```bash nusquids-config --cflags ``` -------------------------------- ### Build nuSQuIDS from Source Source: https://github.com/arguelles/nusquids/blob/master/README.md Build the Python package from source. Requires GSL, HDF5, and SQuIDS installed on the system. ```bash pip install . ``` -------------------------------- ### Compile and Link a Program with nusquids-config Source: https://github.com/arguelles/nusquids/blob/master/README.md Compile and link a custom program using the flags from nusquids-config. ```bash g++ $(nusquids-config --cflags) -c myprogram.cpp g++ myprogram.o $(nusquids-config --libs) -o myprogram ``` -------------------------------- ### Verify nuSQuIDS Import Source: https://github.com/arguelles/nusquids/blob/master/README.md After installation, verify the package imports correctly. ```python import nuSQuIDS as nsq print("nuSQuIDS imported successfully!") ``` -------------------------------- ### Build nuSQuIDS C++ library and Python bindings Source: https://github.com/arguelles/nusquids/blob/master/RELEASE_NOTES_v1.13.0.md Use these commands to build and install the C++ library and Python bindings. Run the commands in order from the source directory. ```bash # C++ library ./configure make make test make install # Python bindings pip install . ``` -------------------------------- ### Build Julia bindings Source: https://github.com/arguelles/nusquids/blob/master/README.md Build the Julia bindings from the resources/julia directory. Requires Julia 1.9+, CxxWrap.jl, and the nuSQuIDS C++ library installed. ```bash cd resources/julia ./build.sh ``` -------------------------------- ### Example Benchmark Output Source: https://github.com/arguelles/nusquids/blob/master/benchmarks/README.md Sample output from the benchmark suite showing system info, per-test timing, and summary with pass/fail status. The version shown is 1.13.0. ```text ================================================================================ nuSQuIDS Performance Benchmark Version: 1.13.0 ================================================================================ System Info: Platform: macOS (arm64) Date: Sat Jan 3 12:00:00 2026 -------------------------------------------------------------------------------- Single Energy Mode (isoscalar) -------------------------------------------------------------------------------- Test: Propagate nu_mu through Earth (cos_zen = -1), E = 100 GeV Iterations: 100 Time per iteration: 4.52 ms Total time: 452 ms Status: PASS ... ================================================================================ Summary ================================================================================ Single Energy (isoscalar) 4.52 ms [PASS] Multi-E isoscalar (no int.) 85.3 ms [PASS] Multi-E isoscalar (with int.) 1.25 s [PASS] ... Total benchmark time: 45.2 s Tests passed: 8/8 ================================================================================ ``` -------------------------------- ### Configure GSL Include and Library Paths Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify custom GSL include and library directories during configuration. ```bash ./configure --with-gsl-incdir=GSL_include_path --with-gsl-libdir=GSL_library_path ``` -------------------------------- ### Configure with Python bindings Source: https://github.com/arguelles/nusquids/blob/master/README.md Configure the build to include Python bindings using pybind11 (default) or Boost.Python. Additional options allow specifying pybind11 headers, Boost location, Python executable, python-config, and module installation directory. ```bash ./configure --with-python-bindings ``` ```bash ./configure --with-boost-python-bindings ``` ```bash # Specify pybind11 headers location ./configure --with-pybind-incdir=location_of_pybind11 ``` ```bash # Specify Boost location (for Boost.Python) ./configure --with-boost=boost_prefix ``` ```bash # Specify Python executable ./configure --python-bin=PYTHON_EXECUTABLE ``` ```bash # Specify python-config for compilation flags ./configure --python-config=PYTHON_CONFIG_EXECUTABLE ``` ```bash # Specify installation directory for Python module ./configure --python-module-dir=PYTHON_MODULE_INSTALLATION ``` -------------------------------- ### Configure GSL with Common Prefix Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify GSL prefix assuming standard 'include' and 'lib' subdirectories. ```bash ./configure --with-gsl=GSL_prefix ``` -------------------------------- ### Configure HDF5 Include and Library Paths Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify custom HDF5 include and library directories during configuration. ```bash ./configure --with-hdf5-incdir=HDF5_include_path --with-hdf5-libdir=HDF5_library_path ``` -------------------------------- ### Set initial state, tolerances, and evolve Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets the initial state in flavor basis, sets relative and absolute errors to 1e-17, and evolves the state. This completes the multiple-energy propagation setup. ```Python nuSQ.Set_initial_state(Einitial,nsq.Basis.flavor) nuSQ.Set_rel_error(1.0e-17) nuSQ.Set_abs_error(1.0e-17) nuSQ.EvolveState() ``` -------------------------------- ### Configure HDF5 with Common Prefix Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify HDF5 prefix assuming standard 'include' and 'lib' subdirectories. ```bash ./configure --with-hdf5=HDF5_prefix ``` -------------------------------- ### Install C++ headers and libraries Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Installs C++ headers and compiled libraries from the build prefix into the system or wheel prefix. Also installs libSQuIDS when SQuIDS is not found. ```cmake install(DIRECTORY ${NUSQUIDS_INSTALL_PREFIX}/include/ DESTINATION include) ``` ```cmake install(DIRECTORY ${NUSQUIDS_INSTALL_PREFIX}/lib/ DESTINATION lib) ``` ```cmake if(NOT SQuIDS_FOUND) install(DIRECTORY ${SQuIDS_PREFIX}/lib/ DESTINATION lib FILES_MATCHING PATTERN "libSQuIDS*") endif() ``` -------------------------------- ### Install nusquids-config script Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Installs the nusquids-config script to the bin directory. ```cmake install(PROGRAMS ${NUSQUIDS_INSTALL_PREFIX}/bin/nusquids-config DESTINATION bin) ``` -------------------------------- ### Basic vacuum oscillation example Source: https://github.com/arguelles/nusquids/blob/master/resources/julia/README.md Sets up a single-energy nuSQUIDS object for vacuum propagation, configures mixing parameters, evolves the state, and prints oscillation probabilities. ```julia using nuSQuIDS # Physical constants units = Const() # Create single-energy nuSQUIDS (3 flavors, neutrino) nus = nuSQUIDS(3, neutrino) # Set up vacuum propagation Set_Body(nus, Vacuum()) Set_Track(nus, VacuumTrack(1000.0 * km(units))) # 1000 km baseline # Set neutrino energy Set_E(nus, 1.0 * GeV(units)) # Set mixing parameters Set_MixingAngle(nus, 0, 1, 0.5836) # θ₁₂ Set_MixingAngle(nus, 0, 2, 0.1496) # θ₁₃ Set_MixingAngle(nus, 1, 2, 0.8587) # θ₂₃ Set_SquareMassDifference(nus, 1, 7.5e-5 * eV(units)^2) # Δm²₂₁ Set_SquareMassDifference(nus, 2, 2.5e-3 * eV(units)^2) # Δm²₃₁ # Set initial state: pure νμ Set_initial_state(nus, [0.0, 1.0, 0.0], flavor) # Evolve the state EvolveState(nus) # Get oscillation probabilities P_e = EvalFlavor(nus, 0) # P(νμ → νe) P_mu = EvalFlavor(nus, 1) # P(νμ → νμ) P_tau = EvalFlavor(nus, 2) # P(νμ → ντ) println("P(νμ → νe) = $P_e") println("P(νμ → νμ) = $P_mu") println("P(νμ → ντ) = $P_tau") ``` -------------------------------- ### Set initial state with power-law spectrum Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Gets energy nodes and sets initial state: E^-2 power-law for muon flavor, zero for others. Array rank 2 with dimensions energy and flavor. ```latex marray E_range = nus.GetERange(); marray inistate{E_range.size(),numneu}; double N0 = 1.0e18; for ( int i = 0 ; i < inistate.extent(0); i++){ for ( int k = 0; k < inistate.extent(1); k ++){ inistate[i][k] = (k == 1) ? N0*pow(E_range[i],-2) : 0.0; } } nus.Set_initial_state(inistate,flavor); ``` -------------------------------- ### Construct nuSQuIDS object with simplified mode Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Creates a nuSQuIDS object for three neutrino flavors, specifying neutrino (not antineutrino) mode. This is the first step in the Single_energy example. ```latex nuSQUIDS nus(3,neutrino); ``` -------------------------------- ### Example nuSQUIDSExt class definition in C++ Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Shows a user-defined class derived from nuSQUIDS with two constructors and a function of interest to expose to Python. ```C class nuSQUIDSExt : public nuSQUIDS { ... public: nuSQUIDSExt(); // default constructor nuSQUIDSExt(double x); // constructor double FunctionExtension(double x); // function of interest ... } ``` -------------------------------- ### Compile C++ program with nusquids-config Source: https://github.com/arguelles/nusquids/blob/master/examples/README.md Use nusquids-config to obtain compiler and linker flags for compiling a C++ program that uses nuSQuIDS. ```bash # Compile a C++ program g++ $(nusquids-config --cflags) myprogram.cpp $(nusquids-config --libs) -o myprogram ``` -------------------------------- ### Vacuum::Vacuum() Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a Vacuum environment. ```APIDOC ## Vacuum::Vacuum() ### Description Initializes a Vacuum environment. ### Method Vacuum ### Parameters None ### Returns Vacuum object ``` -------------------------------- ### Set initial state and print it Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets the initial flavor state and prints the initial probabilities over the energy range. ```latex marray ini_state({3},{0,1,0}); nus.Set_initial_state(ini_state,flavor); std::cout << "In state" << std::endl; for (double EE : nus.GetERange()){ std::cout << EE/units.GeV << " "; for(int i = 0; i < 3; i++){ std::cout << nus.EvalFlavor(i) << " "; } std::cout << std::endl; } ``` -------------------------------- ### Run Full and Quick Benchmarks with Make Source: https://github.com/arguelles/nusquids/blob/master/benchmarks/README.md Commands to run the full benchmark suite (more iterations, more accurate) or the quick benchmark (fewer iterations, faster) from the project root. ```bash # Full benchmark (more iterations, more accurate) make benchmark # Quick benchmark (fewer iterations, faster) make benchmark-quick ``` -------------------------------- ### Sun() Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a Sun environment as defined by the Standard Solar Model. ```APIDOC ## Sun() ### Description Initializes a Sun environment as defined by the Standard Solar Model. ### Method Constructor ### Signature `Sun();` ### Parameters None ### Returns A Sun object initialized with the Standard Solar Model. ``` -------------------------------- ### Set up nuSQUIDS object with oscillation parameters Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Constructs a nuSQUIDS object for three neutrinos, sets mixing angles, mass differences, CP phase, and energy. ```latex nuSQUIDS nus(3,neutrino); nus.Set_MixingAngle(0,1,0.563942); nus.Set_MixingAngle(0,2,0.154085); nus.Set_MixingAngle(1,2,0.785398); nus.Set_SquareMassDifference(1,7.65e-05); nus.Set_SquareMassDifference(2,0.00247); nus.Set_CPPhase(0,2,0.0); squids::Const units; nus.Set_E(10.0*units.GeV); ``` -------------------------------- ### Import nuSQuIDS in Python Source: https://github.com/arguelles/nusquids/blob/master/examples/README.md After installation, import nuSQuIDS in Python with the standard import statement. ```python import nuSQuIDS as nsq ``` -------------------------------- ### Set Boost library and include paths Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Configuration flags to set Boost include and library directories. The --with-boost flag sets both to DIR/lib and DIR/include. ```latex --with-boost=DIR --with-boost-incdir=DIR --with-boost-libdir=DIR ``` -------------------------------- ### Earth() Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes an Earth environment as defined by the PREM model. ```APIDOC ## Earth() ### Description Initializes an Earth environment as defined by the PREM model. ### Method Constructor ### Signature ```cpp Earth(); ``` ``` -------------------------------- ### Cite SQuIDS papers Source: https://github.com/arguelles/nusquids/blob/master/README.md BibTeX entries for citing the SQuIDS library papers. ```bibtex @article{Arguelles:2020hss, author = {Arg{"u}elles, Carlos A. and Salvado, Jordi and Weaver, Christopher N.}, title = "{A Simple Quantum Integro-Differential Solver (SQuIDS)}", doi = "10.1016/j.cpc.2020.107405", journal = "Comput. Phys. Commun.", volume = "255", pages = "107405", year = "2020" } ``` ```bibtex @article{Delgado:2014lyt, author = "Arguelles, Carlos and Salvado, Jordi and Weaver, Christopher N.", title = "{A Simple Quantum Integro-Differential Solver (SQuIDS)}", eprint = "1412.3832", archivePrefix = "arXiv", primaryClass = "hep-ph", doi = "10.1016/j.cpc.2015.06.022", journal = "Comput. Phys. Commun.", volume = "196", pages = "569--591", year = "2015" } ``` -------------------------------- ### Compile and run earth_osc with make Source: https://github.com/arguelles/nusquids/blob/master/resources/build_template/README.md Run make to compile the program, then execute it with an energy argument (e.g., 10 GeV). The output shows the flavor probabilities after propagation. ```bash $ make pkg-config nusquids squids --cflags > .nusquids_cxxflags /usr/local/bin/clang++ -c -std=c++11 $(cat .nusquids_cxxflags) earth_osc.cpp -o earth_osc.o pkg-config nusquids squids --libs > .nusquids_ldflags /usr/local/bin/clang++ earth_osc.o $(cat .nusquids_ldflags) -o earth_osc $ ./earth_osc 10 0.0835682 0.507911 0.408521 ``` -------------------------------- ### Quick Mode Command Line Options Source: https://github.com/arguelles/nusquids/blob/master/benchmarks/README.md Run the benchmark in quick mode with fewer iterations using either the --quick flag or the -q shorthand. ```bash # Quick mode (fewer iterations) ./benchmark --quick ./benchmark -q ``` -------------------------------- ### Configure SQuIDS with Common Prefix Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify SQuIDS prefix assuming standard 'include' and 'lib' subdirectories. ```bash ./configure --with-squids=SQuIDS_prefix ``` -------------------------------- ### Configure SQuIDS Include and Library Paths Source: https://github.com/arguelles/nusquids/blob/master/README.md Specify custom SQuIDS include and library directories during configuration. ```bash ./configure --with-squids-incdir=SQuIDS_include_path --with-squids-libdir=SQuIDS_library_path ``` -------------------------------- ### Sun(std::string sunmodel) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a Sun object from a text file in the Standard Solar Model format. ```APIDOC ## Sun(std::string sunmodel) ### Description Initializes a Sun object from a text file that should have the same format as the Standard Solar Model. The file must have columns: second column from zero to one (radial position), fourth column density in g/cm³, seventh column hydrogen fraction. Internally assumes solar radius 695980.0 km. ### Method Constructor ### Signature `Sun(std::string sunmodel);` ### Parameters - **sunmodel** (std::string) - Required - Path to the text file containing the solar model data. ### Returns A Sun object initialized from the file. ``` -------------------------------- ### EarthAtm() Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes an Earth environment as defined by the PREM model. ```APIDOC ## EarthAtm() ### Description Initializes an Earth environment as defined by the PREM model. ### Method Constructor ### Signature ```cpp EarthAtm(); ``` ``` -------------------------------- ### Configure with Python bindings Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Run this command to generate a Makefile for compiling the Python bindings. Requires Boost.Python (>=1.54) and Python.numpy (>=1.7). ```bash ./configure --with-python-bindings ``` -------------------------------- ### SunASnu() Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a SunASnu environment as defined by the Standard Solar Model. ```APIDOC ## SunASnu() ### Description Initializes a SunASnu environment as defined by the Standard Solar Model. ### Method Constructor ### Signature `SunASnu();` ### Parameters None ### Returns A SunASnu object initialized with the Standard Solar Model. ``` -------------------------------- ### Track::GetInitialX() const Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Returns the initial value of the evolution parameter x. ```APIDOC ## Track::GetInitialX() const ### Description Returns the initial value of the evolution parameter x. ### Method GetInitialX ### Parameters None ### Returns double - Initial value of x. ``` -------------------------------- ### SunASnu(std::string sunmodel) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a SunASnu object from a text file in the Standard Solar Model format. ```APIDOC ## SunASnu(std::string sunmodel) ### Description Initializes a SunASnu object from a text file that should have the same format as the Standard Solar Model. The file must have columns: second column from zero to one (radial position), fourth column density in g/cm³, seventh column hydrogen fraction. Internally assumes solar radius 695980.0 km. ### Method Constructor ### Signature `SunASnu(std::string sunmodel);` ### Parameters - **sunmodel** (std::string) - Required - Path to the text file containing the solar model data. ### Returns A SunASnu object initialized from the file. ``` -------------------------------- ### EarthAtm(std::string earthmodel) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes an EarthAtm environment as defined by a table given in the file specified by filepath. The table should have three columns: relative radius (dimensionless, where 0 is the center and 1 the is surface), density (g/cm^3), and electron fraction y_e (dimensionless). ```APIDOC ## EarthAtm(std::string earthmodel) ### Description Initializes an EarthAtm environment as defined by a table given in the file specified by filepath. The table should have three columns: relative radius (dimensionless, where 0 is the center and 1 the is surface), density (g/cm^3), and electron fraction y_e (dimensionless). ### Method Constructor ### Parameters - **earthmodel** (std::string) - Required - File path to the table file. ### Signature ```cpp EarthAtm(std::string earthmodel); ``` ``` -------------------------------- ### Install data manager module Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Installs the nuSQuIDS_data.py module to the top-level so the nusquids-fetch-data CLI works. ```cmake install(FILES ${CMAKE_SOURCE_DIR}/resources/python/nuSQuIDS_data.py DESTINATION .) ``` -------------------------------- ### macOS install script to fix library paths for Python extension Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt When building on Apple platforms, this CMake install(CODE) script runs after installation to adjust dynamic library references so the Python extension can find libnuSQuIDS and libSQuIDS in the same directory. It uses otool and install_name_tool to replace absolute or non-absolute library references with @loader_path-relative paths, and sets proper install name IDs for the dylibs. ```cmake if(APPLE) # Create a script that will be run after installation to fix paths install(CODE " set(NUSQUIDS_DIR \"\${CMAKE_INSTALL_PREFIX}/nuSQuIDS\") # Helper macro to fix library references in a binary macro(fix_lib_refs BINARY) if(EXISTS \${BINARY}) execute_process( COMMAND otool -L \${BINARY} OUTPUT_VARIABLE OTOOL_OUTPUT ) # Fix references to libSQuIDS (may be absolute paths from build) string(REGEX MATCHALL \"[^\n]*libSQuIDS[^\n]*\" SQUIDS_REFS \"\${OTOOL_OUTPUT}\") foreach(REF \${SQUIDS_REFS}) if(REF MATCHES \"(/[^ ]+libSQuIDS[^ ]*\\.dylib)\") set(OLD_PATH \${CMAKE_MATCH_1}) get_filename_component(LIB_NAME \${OLD_PATH} NAME) execute_process( COMMAND install_name_tool -change \${OLD_PATH} @loader_path/\${LIB_NAME} \${BINARY} ERROR_QUIET ) endif() endforeach() # Also fix non-absolute libSQuIDS references execute_process( COMMAND install_name_tool -change libSQuIDS.1.dylib @loader_path/libSQuIDS.1.dylib \${BINARY} ERROR_QUIET ) # Fix references to libnuSQuIDS (may be absolute paths from build) string(REGEX MATCHALL \"[^\n]*libnuSQuIDS[^\n]*\" NUSQUIDS_REFS \"\${OTOOL_OUTPUT}\") foreach(REF \${NUSQUIDS_REFS}) if(REF MATCHES \"(/[^ ]+libnuSQuIDS[^ ]*\\.dylib)\") set(OLD_PATH \${CMAKE_MATCH_1}) get_filename_component(LIB_NAME \${OLD_PATH} NAME) execute_process( COMMAND install_name_tool -change \${OLD_PATH} @loader_path/\${LIB_NAME} \${BINARY} ERROR_QUIET ) endif() endforeach() # Also fix non-absolute libnuSQuIDS references execute_process( COMMAND install_name_tool -change libnuSQuIDS.1.dylib @loader_path/libnuSQuIDS.1.dylib \${BINARY} ERROR_QUIET ) endif() endmacro() # Fix the Python extension nuSQuIDS.so set(NUSQUIDS_SO \"\${NUSQUIDS_DIR}/nuSQuIDS.so\") if(EXISTS \${NUSQUIDS_SO}) message(STATUS \"Fixing library paths in nuSQuIDS.so\") fix_lib_refs(\${NUSQUIDS_SO}) # Fix lib/nuSQuIDS.so reference (incorrect id path) execute_process( COMMAND install_name_tool -change lib/nuSQuIDS.so @loader_path/nuSQuIDS.so \${NUSQUIDS_SO} ERROR_QUIET ) # Set the install name id properly execute_process( COMMAND install_name_tool -id @loader_path/nuSQuIDS.so \${NUSQUIDS_SO} ERROR_QUIET ) endif() # Fix all libnuSQuIDS dylibs file(GLOB NUSQUIDS_DYLIBS \"\${NUSQUIDS_DIR}/libnuSQuIDS*.dylib\") foreach(DYLIB \${NUSQUIDS_DYLIBS}) message(STATUS \"Fixing library paths in \${DYLIB}\") fix_lib_refs(\${DYLIB}) get_filename_component(DYLIB_NAME \${DYLIB} NAME) execute_process( COMMAND install_name_tool -id @loader_path/\${DYLIB_NAME} \${DYLIB} ERROR_QUIET ) endforeach() # Fix all libSQuIDS dylibs (when bundled) file(GLOB SQUIDS_DYLIBS \"\${NUSQUIDS_DIR}/libSQuIDS*.dylib\") foreach(DYLIB \${SQUIDS_DYLIBS}) message(STATUS \"Fixing library paths in \${DYLIB}\") fix_lib_refs(\${DYLIB}) get_filename_component(DYLIB_NAME \${DYLIB} NAME) execute_process( COMMAND install_name_tool -id @loader_path/\${DYLIB_NAME} \${DYLIB} ERROR_QUIET ) endforeach() ") endif() ``` -------------------------------- ### ConstantDensity::ConstantDensity(double density, double ye) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes a ConstantDensity environment with constant density and electron fraction. ```APIDOC ## ConstantDensity::ConstantDensity(double density, double ye) ### Description Initializes a ConstantDensity environment with constant density (density in g/cm^3) and electron fraction (ye). ### Method ConstantDensity ### Parameters - **density** (double) - Required - Constant density in g/cm^3. - **ye** (double) - Required - Electron fraction. ### Returns ConstantDensity object ``` -------------------------------- ### nuSQUIDSAtm Constructor (HDF5 file) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes nuSQUIDS from a previously generated νSQuIDS-HDF5 file. The resulting nuSQUIDS object will be given in single or multiple energy mode depending on the HDF5 file configuration. ```APIDOC ## Constructor: nuSQUIDSAtm(hdf5_filename) ### Description Initializes nuSQUIDS from a previously generated νSQuIDS-HDF5 file. The resulting nuSQUIDS object will be given in single or multiple energy mode depending on the HDF5 file configuration. ### Parameters - **hdf5_filename** (std::string) - Required - Full path of the HDF5 file. ### Return Value A nuSQUIDSAtm object. ``` -------------------------------- ### Earth(std::string earthmodel) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initializes an Earth environment as defined by a table given in the file specified by filepath. The table should have three columns: radius (where 0 is center and 1 is surface), density (g/cm^3), and y_e (dimensionless). ```APIDOC ## Earth(std::string earthmodel) ### Description Initializes an Earth environment as defined by a table given in the file specified by filepath. The table should have three columns: radius (where 0 is center and 1 is surface), density (g/cm^3), and y_e (dimensionless). ### Method Constructor ### Parameters - **earthmodel** (std::string) - Required - File path to the table file. ### Signature ```cpp Earth(std::string earthmodel); ``` ``` -------------------------------- ### Install compiled Python extension Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Installs compiled extension files (.so, .dylib, .pyd) from the build prefix into the nuSQuIDS package directory. ```cmake install(DIRECTORY ${NUSQUIDS_INSTALL_PREFIX}/lib/ DESTINATION ${PROJECT_NAME} # "nuSQuIDS" FILES_MATCHING PATTERN "*.so" PATTERN "*.dylib" PATTERN "*.pyd") ``` -------------------------------- ### Extract include paths and set install prefix Source: https://github.com/arguelles/nusquids/blob/master/CMakeLists.txt Extracts the first include directory from GSL and HDF5, derives their prefixes, and sets the install prefix for the core library. The SQuIDS include extraction is commented out. ```cmake # Extract single include path from GSL (first element of the list) list(GET GSL_INCLUDE_DIRS 0 GSL_INCLUDE_DIR) get_filename_component(GSL_PREFIX "${GSL_INCLUDE_DIR}" DIRECTORY) # Extract single include path from HDF5 list(GET HDF5_INCLUDE_DIRS 0 HDF5_INCLUDE_DIR) get_filename_component(HDF5_PREFIX "${HDF5_INCLUDE_DIR}" DIRECTORY) # Extract single include path from SQuIDS (via pkg-config) #list(GET SQuIDS_INCLUDE_DIRS 0 SQuIDS_INCLUDE_DIR) #get_filename_component(SQuIDS_PREFIX "${SQuIDS_INCLUDE_DIR}" DIRECTORY) # Directory where Autotools “make install” will land set(NUSQUIDS_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/_deps/nusquids_core-install) ``` -------------------------------- ### Implement nuSQUIDSNSI constructor Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Constructs the NSI operator from a complex matrix, rotates it to the mass basis, and initializes the time-evolved operator vector. Only three-neutrino scenarios are supported; other settings are rejected via assert. ```latex nuSQUIDSNSI(double epsilon_mutau, marray Erange, int numneu, NeutrinoType NT, bool iinteraction, double th01, double th02, double th12) : nuSQUIDS(Erange,numneu,NT,iinteraction), epsilon_mutau(epsilon_mutau) { assert(numneu == 3); // define the flavor structure as a complex matrix gsl_matrix_complex* M = gsl_matrix_complex_calloc(3,3); gsl_complex c {{ epsilon_mutau , 0.0 }}; gsl_matrix_complex_set(M,2,1,c); gsl_matrix_complex_set(M,1,2,gsl_complex_conjugate(c)); NSI = squids::SU_vector(M); gsl_matrix_complex_free(M); Set_MixingAngle(0,1,th01); Set_MixingAngle(0,2,th02); Set_MixingAngle(1,2,th12); // rotate to mass representation NSI.RotateToB1(params); NSI_evol.resize(ne); for(int ei = 0; ei < ne; ei++) NSI_evol[ei] = squids::SU_vector(nsun); } ``` -------------------------------- ### SunASnu::Track(double b_impact_) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets a trajectory starting at the Sun center with impact factor b_impact_. ```APIDOC ## SunASnu::Track(double b_impact_) ### Description Sets a trajectory starting at the Sun center with impact factor b_impact_. ### Method Constructor ### Signature `Track(double b_impact_);` ### Parameters - **b_impact_** (double) - Required - Impact parameter in eV⁻¹. ### Returns A Track object representing the trajectory. ``` -------------------------------- ### Earth(std::vector x, std::vector rho, std::vector ye) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Initialize an earth whose radial density is specified by the values in the vector rho in g/cm^3, the electron fraction in the vector ye, and the radial positions in the vector x in centimeters. ```APIDOC ## Earth(std::vector x, std::vector rho, std::vector ye) ### Description Initialize an earth whose radial density is specified by the values in the vector rho in g/cm^3, the electron fraction in the vector ye, and the radial positions in the vector x in centimeters. ### Method Constructor ### Parameters - **x** (std::vector) - Required - Radial positions in centimeters. - **rho** (std::vector) - Required - Density values in g/cm^3. - **ye** (std::vector) - Required - Electron fraction values. ### Signature ```cpp Earth(std::vector x, std::vector rho, std::vector ye); ``` ``` -------------------------------- ### Sun::Track(double xend) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets a trajectory starting at the Sun center and ending at a distance xend from it. ```APIDOC ## Sun::Track(double xend) ### Description Sets a trajectory starting at the Sun center and ending at a distance xend from it. ### Method Constructor ### Signature `Sun::Track(double xend);` ### Parameters - **xend** (double) - Required - Distance from the Sun center to the end of the trajectory. ### Returns A Track object representing the trajectory. ``` -------------------------------- ### Set integration parameters Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Configures maximum step size, GSL stepper algorithm (rk4), and relative/absolute error tolerances for the evolution. ```latex nus.Set_h_max( 500.0*units.km ); nus.Set_GSL_step(gsl_odeiv2_step_rk4); nus.Set_rel_error(1.0e-5); nus.Set_abs_error(1.0e-5); ``` -------------------------------- ### Set PROGRAM variable in Makefile Source: https://github.com/arguelles/nusquids/blob/master/resources/build_template/README.md Edit the copied Makefile to set PROGRAM to the name of the program, which is earth_osc for this example. ```makefile PROGRAM:=earth_osc ``` -------------------------------- ### Install CxxWrap.jl in Julia Source: https://github.com/arguelles/nusquids/blob/master/resources/julia/README.md Adds the CxxWrap.jl package to the Julia environment, a prerequisite for the nuSQuIDS bindings. ```julia using Pkg Pkg.add("CxxWrap") ``` -------------------------------- ### Set initial neutrino flux (power-law spectrum) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Configures the initial neutrino flux as a two-dimensional array indexed by flavor and energy, using a power-law spectrum (E^-2) for the muon neutrino flavor (k==1) and zero for others. ```latex marray inistate{energies.size(), numneu}; double N0 = 1.0e18; for(int i = 0 ; i < inistate.extent(0); i++){ for(int k = 0; k < inistate.extent(1); k ++){ inistate[i][k] = (k == 1) ? N0*pow(energies[i],-2) : 0.0; } } nus.Set_initial_state(inistate,flavor); ``` -------------------------------- ### Default constructor for NeutrinoDISCrossSectionsFromTables Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Default constructor that loads the default 'csms.h5' file. Use this when the standard cross section tables are sufficient. ```latex NeutrinoDISCrossSectionsFromTables(); ``` -------------------------------- ### Set ConstantDensity body and track Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Constructs a ConstantDensity body with density 100 g/cm^3 and electron fraction 0.3, and a track with baseline 500 km, then sets them on the nuSQUIDS object. ```latex double density = 100.0; double ye = 0.3; std::shared_ptr constdens = std::make_shared(density,ye); double baseline_3 = 500.0*units.km; std::shared_ptr track_constdens = std::make_shared(0.0,baseline_3); nus.Set_Body(constdens); nus.Set_Track(track_constdens); ``` -------------------------------- ### Get energy range of nuSQUIDS object Source: https://github.com/arguelles/nusquids/blob/master/resources/python/example/nuSQUIDS-DEMO.ipynb Retrieves the energy nodes of the nuSQUIDS object, returned in eV. ```python nuSQ.GetERange() ``` -------------------------------- ### NewBody.cpp implementation file Source: https://github.com/arguelles/nusquids/blob/master/resources/build_template/README.md Implements the NewBody constructor and other functions. Includes the corresponding header file. ```cpp /* NewBody.cpp */ #include "NewBody.h" NewBody::NewBody(double density){ /* implementation. . . */ } // Implementations of other functions. . . ``` -------------------------------- ### Import nuSQuIDS Python modules Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Import the required modules for using the nuSQuIDS Python interface. The shorthand nsq is used for the nuSQUIDSpy bindings throughout the example. ```Python import numpy as np import matplotlib.pyplot as plt import nuSQUIDSpy as nsq import nuSQUIDSTools ``` -------------------------------- ### Copy template Makefile to project directory Source: https://github.com/arguelles/nusquids/blob/master/resources/build_template/README.md Copy the template Makefile from the nuSQuIDS source path into the directory containing earth_osc.cpp. Assumes NUSQUIDS_SOURCE_PATH is set to the nuSQuIDS source location. ```bash # In the directory containing earth_osc.cpp: cp ${NUSQUIDS_SOURCE_PATH}/resources/build_template/Makefile ./ ``` -------------------------------- ### SunASnu::Track(double xini, double b_impact) Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets a trajectory starting at distance xini with impact factor b_impact, with current position equal to xini. ```APIDOC ## SunASnu::Track(double xini, double b_impact) ### Description Sets a trajectory starting at distance xini with impact factor b_impact, with current position equal to xini. ### Method Constructor ### Signature `Track(double xini, double b_impact);` ### Parameters - **xini** (double) - Required - Initial position along the trajectory. - **b_impact** (double) - Required - Impact parameter in eV⁻¹. ### Returns A Track object representing the trajectory. ``` -------------------------------- ### Configure Earth body and initial state Source: https://github.com/arguelles/nusquids/blob/master/resources/paper/nusquids.tex Sets the mixing parameters to default, uses the Earth atmosphere as the body, sets a vertical track (cosine -1), and assigns the initial state in flavor basis. ```Python nuSQ.Set_MixingParametersToDefault() earth = nsq.EarthAtm() nuSQ.Set_Body(earth) nuSQ.Set_Track(earth.MakeTrackWithCosine(-1)) nuSQ.Set_initial_state(InitialFlux,nsq.Basis.flavor) ``` -------------------------------- ### Atmospheric neutrino example Source: https://github.com/arguelles/nusquids/blob/master/resources/julia/README.md Sets up an atmospheric nuSQUIDS object with zenith and energy arrays, evolves, and evaluates flux at a specific zenith and energy. ```julia using nuSQuIDS units = Const() # Zenith angle and energy arrays costh_nodes = linspace(-1.0, 0.0, 20) # upgoing E_nodes = logspace(1e9, 1e15, 100) # Create atmospheric nuSQUIDS atm = nuSQUIDSAtm_new(costh_nodes, E_nodes, 3, both, true) # Set mixing parameters, initial flux... # Evolve EvolveState(atm) # Evaluate at specific zenith and energy flux = EvalFlavor(atm, 1, -0.5, 1e11, 0) # νμ at cos(θ)=-0.5, 100 GeV ``` -------------------------------- ### Loading WCG24 Nuclear Cross Sections in C++ Source: https://github.com/arguelles/nusquids/blob/master/data/xsections/README.md Creates a CrossSectionLibrary with per-nucleus targets (oxygen, iron, silicon) and an electron target for Glashow resonance. Requires including nuSQuIDS/nuSQuIDS.h and nuSQuIDS/resources.h. Sets the library on a nuSQUIDS instance. ```cpp #include #include // Create cross section library with nuclear targets CrossSectionLibrary lib; std::string xsdir = getResourcePath() + "/xsections/"; // Add per-nucleus cross sections lib.addTarget(oxygen, NeutrinoDISCrossSectionsFromTables(xsdir + "wcg24_oxygen.h5")); lib.addTarget(iron, NeutrinoDISCrossSectionsFromTables(xsdir + "wcg24_iron.h5")); lib.addTarget(silicon, NeutrinoDISCrossSectionsFromTables(xsdir + "wcg24_silicon.h5")); // ... add other elements as needed // Add electron target for Glashow resonance lib.addTarget(electron, GlashowResonanceCrossSection()); // Create nuSQuIDS with custom cross sections nuSQUIDS nus(...); nus.Set_CrossSectionLibrary(std::make_shared(lib)); ```