├── FML ├── Plotting │ ├── .DS_Store │ ├── example │ │ ├── plot.png │ │ ├── Main.cpp │ │ └── Makefile │ ├── LICENSE │ └── LICENSE.matplotlib ├── Emulator │ ├── EuclidEmulator2.dat │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── COLASolver │ ├── tests │ │ ├── LCDM_COLA_NormalIC_TimesteppingQuinn │ │ │ ├── README │ │ │ └── pofk_TestSim_cb_z0.000.txt │ │ ├── LCDM_noCOLA_NormalIC_TimesteppingQuinn │ │ │ ├── README │ │ │ └── pofk_TestSim_cb_z0.000.txt │ │ ├── LCDM_noCOLA_fixedAmplitudeIC_TimesteppingQuinn │ │ │ ├── README │ │ │ └── pofk_TestSim_cb_z0.000.txt │ │ ├── LCDM_noCOLA_fixedAmplitudeIC_TimesteppingTassev │ │ │ └── README │ │ └── README.md │ ├── examples │ │ ├── example_run_with_neutrinos │ │ │ └── README │ │ ├── example_run_with_dgp │ │ │ ├── README │ │ │ └── output │ │ │ │ ├── snapshot_DGP_z0.000 │ │ │ │ └── pofk_z0.000.txt │ │ │ │ └── snapshot_LCDM_z0.000 │ │ │ │ └── pofk_z0.000.txt │ │ ├── example_run_different_input │ │ │ └── README │ │ └── example_run_with_fofr │ │ │ ├── README │ │ │ └── output │ │ │ ├── snapshot_FOFR_z0.000 │ │ │ └── pofk_z0.000.txt │ │ │ └── snapshot_LCDM_z0.000 │ │ │ └── pofk_z0.000.txt │ ├── CHANGELOG │ ├── input │ │ ├── transfer_infofile_lcdm_nu0.0.txt │ │ ├── transfer_infofile_lcdm_nu0.2.txt │ │ ├── transfer_infofile_lcdm_nu0.4.txt │ │ └── camb_data_lcdm_nu0.2 │ │ │ └── picola_transfer_info_nu0.2.txt │ └── src │ │ ├── Cosmology_LCDM.h │ │ └── Cosmology_DGP.h ├── Cosmology │ ├── EinsteinBoltzmannSolver │ │ └── README │ ├── BackgroundCosmology │ │ └── example │ │ │ ├── Main.cpp │ │ │ └── Makefile │ ├── RecombinationHistory │ │ └── example │ │ │ ├── Main.cpp │ │ │ └── Makefile │ └── LinearPerturbations │ │ └── example │ │ └── Makefile ├── FileUtils │ ├── example │ │ ├── jalla.txt │ │ ├── Main.cpp │ │ └── Makefile │ └── FileUtils.h ├── HaloModel │ ├── PythonWrapper │ │ ├── README │ │ ├── example.py │ │ ├── HaloModelWrapper.py │ │ ├── Makefile │ │ └── InterfaceFile.i │ └── example │ │ └── Makefile ├── RamsesUtils │ ├── ramses2pk │ │ ├── README.md │ │ └── Makefile │ └── example │ │ ├── Makefile │ │ └── Main.cpp ├── LuaFileParser │ └── example │ │ ├── input.lua │ │ ├── Makefile │ │ └── Main.cpp ├── MakePythonWrapper │ ├── test.py │ ├── Main.cpp │ ├── InterfaceFile.i │ └── Makefile ├── ParticleTypes │ ├── SimpleGalaxy.h │ ├── example │ │ ├── Makefile │ │ └── Main.cpp │ └── SimpleParticle.h ├── Timing │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── MemoryLogging │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── Spline │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── KDTree │ ├── LICENSE │ └── example │ │ └── Makefile ├── ParameterMap │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── CAMBUtils │ └── example │ │ ├── Main.cpp │ │ ├── transfer_infofile.txt │ │ └── camb_transfer_data │ │ └── picola_transfer_info_nu0.2.txt ├── RandomGenerator │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── Global │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── ODESolver │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── Units │ └── example │ │ ├── Makefile │ │ └── Main.cpp ├── MPIGrid │ ├── ConvertMPIGridFFTWGrid.h │ └── example │ │ └── Makefile ├── GadgetUtils │ └── example │ │ └── Makefile ├── MPIParticles │ └── example │ │ └── Makefile ├── FriendsOfFriends │ └── example │ │ └── Makefile ├── FFTLog │ └── example │ │ ├── Main.cpp │ │ └── Makefile ├── Smoothing │ └── example │ │ └── Main.cpp ├── Math │ └── example │ │ ├── Makefile │ │ └── Main.cpp ├── SphericalCollapse │ ├── example │ │ ├── Makefile │ │ └── Main.cpp │ └── SphericalCollapseModel.cpp ├── Survey │ └── example │ │ ├── Makefile │ │ └── Main.cpp ├── PairCounting │ └── example │ │ └── Makefile ├── Triangulation │ └── example │ │ └── Makefile ├── FFTWGrid │ ├── FFTWGlobal.h │ └── example │ │ └── Makefile ├── LPT │ └── example │ │ └── Makefile ├── Interpolation │ └── example │ │ └── Makefile ├── ComputePowerSpectra │ └── example │ │ └── Makefile └── PGD │ └── example │ └── Makefile ├── .gitmodules └── doxygen └── run_doxygen.sh /FML/Plotting/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAWinther/FML/HEAD/FML/Plotting/.DS_Store -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "TestData"] 2 | path = TestData 3 | url = https://github.com/HAWinther/TestData 4 | -------------------------------------------------------------------------------- /FML/Plotting/example/plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAWinther/FML/HEAD/FML/Plotting/example/plot.png -------------------------------------------------------------------------------- /FML/Emulator/EuclidEmulator2.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HAWinther/FML/HEAD/FML/Emulator/EuclidEmulator2.dat -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_COLA_NormalIC_TimesteppingQuinn/README: -------------------------------------------------------------------------------- 1 | The same time-stepping enforced by modifying MGPICOLA 2 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_noCOLA_NormalIC_TimesteppingQuinn/README: -------------------------------------------------------------------------------- 1 | The same time-stepping enforced by modifying MGPICOLA 2 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_noCOLA_fixedAmplitudeIC_TimesteppingQuinn/README: -------------------------------------------------------------------------------- 1 | The same time-stepping enforced by modifying MGPICOLA 2 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_noCOLA_fixedAmplitudeIC_TimesteppingTassev/README: -------------------------------------------------------------------------------- 1 | The same time-stepping enforced by modifying MGPICOLA 2 | -------------------------------------------------------------------------------- /FML/Cosmology/EinsteinBoltzmannSolver/README: -------------------------------------------------------------------------------- 1 | A simple Einstein-Boltzmann solver for a flat LCDM 2 | No massive neutrinos or curvature 3 | This is mainly used for teaching ( https://cmb.wintherscoming.no/ ) 4 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_neutrinos/README: -------------------------------------------------------------------------------- 1 | Simulations of LCDM with massive neutrinos for a fixed OmegaM. 2 | Apart from OmegaMNu/OmegaCDM and the initial conditions the simulations are the same. 3 | -------------------------------------------------------------------------------- /doxygen/run_doxygen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Upload the docs to my website 4 | upload=false 5 | 6 | # Run doxygen 7 | doxygen doxyfile 8 | 9 | # Upload to website 10 | if [[ $upload == true ]]; then 11 | rsync -r html/* webpage:fml/doxygen/ 12 | fi 13 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_dgp/README: -------------------------------------------------------------------------------- 1 | Simulations of DGP and LCDM. DGP is set to use the same IC as LCDM (ic_use_gravity_model_GR=true). 2 | For the DGP fifth-force we use an approximate screening model and enforce correct linear evolution on the largest scales. 3 | -------------------------------------------------------------------------------- /FML/FileUtils/example/jalla.txt: -------------------------------------------------------------------------------- 1 | #jallala 2 | #jallala 3 | #jallala 4 | #jallala 5 | 1.0 2.0 3.0 6 | 1.0 2.0 3.0 7 | 2.0 3.0 5.0 8 | 1.0 2.0 3.0 9 | 1.0 2.0 3.0 10 | 1.0 2.0 3.0 11 | 1.0 2.0 3.0 12 | -------------------------------------------------------------------------------- /FML/HaloModel/PythonWrapper/README: -------------------------------------------------------------------------------- 1 | A wrapper around the halomodel which allows you to run it from python 2 | The file containing the C++ functions exposed to pythons are in Wrapper.cpp 3 | The interface for SWIG is in InterfaceFile.i 4 | Use of the resulting python library is in HaloModelWrapper.py (wraps is into a class) 5 | Example on using it is in example.py 6 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_different_input/README: -------------------------------------------------------------------------------- 1 | Example of starting the simulation with different input: 2 | 1) CDM+baryon Power-spectrum P(k,z=0) 3 | 2) CDM+baryon Transfer funcion T(k,z=0) 4 | 3) Transferinfo file (which reads a bunch of T(k,z) files and makes splines - required for doing massive neutrinos) 5 | All of these should give the same result in this case. 6 | -------------------------------------------------------------------------------- /FML/RamsesUtils/ramses2pk/README.md: -------------------------------------------------------------------------------- 1 | ramses2pk 2 | ========= 3 | 4 | A small program for computing power spectra from [RAMSES](https://arxiv.org/abs/astro-ph/0111367) snapshots. 5 | 6 | Build and usage 7 | --------------- 8 | ```sh 9 | make # build 10 | ./ramses2pk --help # show instructions and options 11 | ./ramses2pk path/to/ramses/simulation/output_00001/ # simplest possible usage 12 | ``` 13 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_fofr/README: -------------------------------------------------------------------------------- 1 | Simulations of f(R) and LCDM. f(R) is set to use the same IC as LCDM (ic_use_gravity_model_GR=true). 2 | We use scale-independent COLA for f(R) (simulation_use_scaledependent_cola=false) even though it has scaledependent growth (on small scales so its not super important). 3 | For the f(R) fifth-force we use an approximate screening model and enforce correct linear evolution on the largest scales. 4 | -------------------------------------------------------------------------------- /FML/LuaFileParser/example/input.lua: -------------------------------------------------------------------------------- 1 | 2 | --------------------------- 3 | -- Example parameter file 4 | --------------------------- 5 | 6 | -- An array of strings 7 | AStringArray = {"Hello", "1", "2", "You"} 8 | 9 | -- An array of doubles 10 | ADoubleArray = {1.0, 2.0, 3.0} 11 | 12 | -- A simple string 13 | AString = "Hello" 14 | 15 | -- A simple bool 16 | ABool = true 17 | 18 | -- A simple double 19 | ADouble = 1.2 20 | 21 | -- We can use simple formulas to set a variable 22 | ANewDouble = ADouble * 2^10 * ADoubleArray[2] 23 | 24 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/README.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | This folder contains some tests. This is mainly comparing to L-PICOLA / MG-PICOLA. 4 | We have the option of using the same random number generator and the same time-stepping. 5 | When these things are the same we should get *very* close results (and we do do, the agreement is < 0.1%). 6 | For these tests I also modified the power-spectrum evaluation to do exactly the same in the two codes. 7 | Will add more tests later. 8 | 9 | NB: the k we output is sligtly different (we output the mean of the k-modes in each bin, while the picola results are the raw k-bins thus only the P(k) rows will agree) 10 | -------------------------------------------------------------------------------- /FML/MakePythonWrapper/test.py: -------------------------------------------------------------------------------- 1 | import MyLibrary as mylib 2 | import numpy as np 3 | 4 | # Call the first C++ function we defined in Main.cpp 5 | mylib.test(123) 6 | 7 | # Example of how to pass more complex data from C++ to Python 8 | # We allocate a struct with a double* and an int and provide 9 | # in the InterfaceFile.i how to extract this in python 10 | data = mylib.getData(10) 11 | for i in range(10): 12 | print( data.get_x(i) ) 13 | 14 | # Free up memory we allocated in C++ (if you feel like it) 15 | mylib.freeData(data) 16 | 17 | # Pass numpy arrays to C++ and use them there 18 | x = np.linspace(1,3,3) 19 | y = np.linspace(1,5,5) 20 | mylib.getNumpyArray(x,y) 21 | 22 | -------------------------------------------------------------------------------- /FML/FileUtils/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | 7 | // Read a simple ascii-file 8 | auto data = FML::FILEUTILS::read_regular_ascii("jalla.txt", 3, std::vector{1, 2}, 4, 100); 9 | 10 | // Print the data 11 | std::cout << "Lines " << data.size() << " Extracting col 1 and 2\n"; 12 | for (auto && d : data) { 13 | for (auto && e : d) 14 | std::cout << std::setw(10) << e << " "; 15 | std::cout << "\n"; 16 | } 17 | 18 | auto data2 = FML::FILEUTILS::loadtxt("jalla.txt"); 19 | std::cout << "Full file:\n"; 20 | for(auto && d : data2){ 21 | for (auto && e : d) 22 | std::cout << std::setw(10) << e << " "; 23 | std::cout << "\n"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FML/Cosmology/BackgroundCosmology/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | // Parameter container 5 | FML::UTILS::ParameterMap p; 6 | auto&& param_map = p.get_map(); 7 | 8 | // Add cosmological parameters 9 | param_map["CosmologyLabel"] = std::string("LCDM"); 10 | param_map["PhysicalParameters"] = true; 11 | param_map["OmegaBh2"] = 0.0245; 12 | param_map["OmegaCDMh2"] = 0.10976; 13 | param_map["OmegaKh2"] = 0.0; 14 | param_map["OmegaLambdah2"] = 0.35574; 15 | param_map["TCMB"] = 2.7255 * FML::COSMOLOGY::Constants.K; 16 | param_map["h"] = 0.7; 17 | param_map["Neff"] = 3.046; 18 | p.info(); 19 | 20 | // Set up the cosmology and do all the solving and make splines 21 | FML::COSMOLOGY::BackgroundCosmology lcdm(p); 22 | lcdm.solve(); 23 | } 24 | -------------------------------------------------------------------------------- /FML/MakePythonWrapper/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Data { 4 | int n; 5 | double * x; 6 | }; 7 | 8 | void test(int n) { std::cout << "Hello " << n << "\n"; } 9 | 10 | // Allocate some data and return it to python 11 | Data * getData(int n) { 12 | Data * a = new Data; 13 | a->n = n; 14 | a->x = new double[n]; 15 | for (int i = 0; i < n; i++) 16 | a->x[i] = i; 17 | return a; 18 | } 19 | 20 | // Free up the memory we have allocated 21 | void freeData(Data * f) { 22 | std::cout << "Freeing up memory\n"; 23 | if (f->n > 0) 24 | delete[] f->x; 25 | delete f; 26 | } 27 | 28 | // How to pass (1D) numpy arrays to C++ from python 29 | void getNumpyArray(int nx, double * x, int ny, double * y) { 30 | for (int i = 0; i < nx; i++) 31 | std::cout << "x[" << i << "] = " << x[i] << "\n"; 32 | for (int i = 0; i < ny; i++) 33 | std::cout << "y[" << i << "] = " << y[i] << "\n"; 34 | } 35 | -------------------------------------------------------------------------------- /FML/ParticleTypes/SimpleGalaxy.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLEGALAXY_HEADER 2 | #define SIMPLEGALAXY_HEADER 3 | 4 | /// A minimal class for holding basic info about a galaxy 5 | /// If all galaxies have the same weight then we don't need to include it or its methods below 6 | /// but algorithms will still be able to use it 7 | class SimpleGalaxy { 8 | public: 9 | double RA; 10 | double DEC; 11 | double z; 12 | double weight{1.0}; 13 | 14 | SimpleGalaxy(double _RA, double _DEC, double _z, double _weight = 1.0) 15 | : RA(_RA), DEC(_DEC), z(_z), weight(_weight) {} 16 | 17 | double get_RA() const { return RA; } 18 | double get_DEC() const { return DEC; } 19 | double get_z() const { return z; } 20 | double get_weight() const { return weight; } 21 | void set_RA(double _RA) { return RA = _RA; } 22 | void set_DEC(double _DEC) { return DEC = _DEC; } 23 | void set_z(double _z) { return z = _z; } 24 | void set_weight(double _weight) { return weight = _weight; } 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /FML/Timing/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using Timer = FML::UTILS::Timings; 5 | 6 | int main() { 7 | Timer timer; 8 | timer.StartTiming("Whole Program"); 9 | 10 | //============================================== 11 | // Example of how to do simple benchmarking 12 | // The 'timer' here is a global 13 | //============================================== 14 | 15 | // Add a timing 16 | timer.StartTiming("Label"); 17 | for (int i = 0; i < 10000; i++) 18 | exp(i); 19 | timer.EndTiming("Label"); 20 | 21 | // Add a new timing and print the time right away when we end 22 | timer.StartTiming("Label 1"); 23 | for (int i = 0; i < 10000; i++) 24 | exp(i); 25 | timer.EndTiming("Label 1", true); 26 | 27 | // Add to the same label as above 28 | timer.StartTiming("Label 1"); 29 | for (int i = 0; i < 10000; i++) 30 | exp(i); 31 | timer.EndTiming("Label 1"); 32 | 33 | // Print all the timings we have in the code 34 | timer.EndTiming("Whole Program"); 35 | timer.PrintAllTimings(); 36 | } 37 | -------------------------------------------------------------------------------- /FML/Plotting/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Benno Evers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /FML/MemoryLogging/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Vector using the custom log-allocator 6 | using MyVector = std::vector>; 7 | 8 | int main() { 9 | 10 | auto * mem = FML::MemoryLog::get(); 11 | 12 | //================================================ 13 | // Example of memory logging 14 | //================================================ 15 | 16 | // Allocte some memory 17 | MyVector a(100000); 18 | MyVector b(1000000); 19 | MyVector c; 20 | 21 | if (FML::ThisTask > 0) { 22 | c = MyVector(100000); 23 | mem->add_label(c.data(), "[This is C]"); 24 | } 25 | 26 | // Add a label so its easier to know what we have allocated 27 | // when we print below (not required) 28 | mem->add_label(a.data(), "[This is A]"); 29 | mem->add_label(b.data(), "[This is B]"); 30 | 31 | mem->print(); 32 | 33 | // Free the memory 34 | // a.clear(); a.shrink_to_fit(); 35 | // b.clear(); b.shrink_to_fit(); 36 | // c.clear(); c.shrink_to_fit(); 37 | 38 | // Print the info about the memory and the history 39 | // of allocations 40 | FML::MemoryLog::get()->print(); 41 | } 42 | -------------------------------------------------------------------------------- /FML/Plotting/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace plt = FML::UTILS::Matplotlib; 5 | using DVector = std::vector; 6 | 7 | int main() { 8 | 9 | //======================================================== 10 | // Example of how to use matplotlib to make plots from C++ 11 | // With MPI only call this from the first task 12 | //======================================================== 13 | 14 | const char * filename = "plot.png"; 15 | 16 | // A test function to plot 17 | auto function = [](double x) -> double { return 2.0 + sin(2.0 * M_PI * x); }; 18 | 19 | // Make an x-array 20 | const int npts = 100; 21 | const double xmin = 0.0; 22 | const double xmax = 1.0; 23 | DVector x_array(npts); 24 | for (int i = 0; i < npts; i++) 25 | x_array[i] = xmin + (xmax - xmin) * i / double(npts); 26 | 27 | // Fill the y-array 28 | DVector y_array(npts); 29 | for (int i = 0; i < npts; i++) 30 | y_array[i] = function(x_array[i]); 31 | 32 | // Call matplotlib 33 | plt::xlim(0.0, 1.0); 34 | plt::plot(x_array, y_array); 35 | plt::title("$y = 2 + \\sin(2 \\pi x)$"); 36 | 37 | // Save plot to file 38 | plt::save(filename); 39 | 40 | // Show figure 41 | // plt::show(); 42 | } 43 | -------------------------------------------------------------------------------- /FML/MakePythonWrapper/InterfaceFile.i: -------------------------------------------------------------------------------- 1 | %module MyLibrary 2 | %{ 3 | #define SWIG_FILE_WITH_INIT 4 | 5 | // The functions and data structures you want availiable in Python 6 | struct Data { 7 | int n; 8 | double *x; 9 | }; 10 | extern void test(int n); 11 | extern Data * getData(int n); 12 | extern void freeData(Data *f); 13 | extern void getNumpyArray(int nx, double *x, int ny, double *y); 14 | 15 | %} 16 | 17 | %include "numpy.i" 18 | %init %{ 19 | import_array(); 20 | %} 21 | 22 | // This defines an interface for numpy arrays. The C function getNumpyArray(int nx, double *x, int ny, double *y) 23 | // can with this be called as getNumpyArray(x,y) from python with x,y being 1D numpy arrays 24 | %apply (int DIM1, double* IN_ARRAY1) {(int nx, double *x), (int ny, double *y)}; 25 | 26 | 27 | // The functions and data structures you want availiable in Python (have to be repeated here) 28 | struct Data { 29 | int n; 30 | double *x; 31 | }; 32 | extern void test(int n); 33 | extern Data * getData(int n); 34 | extern void freeData(Data *f); 35 | extern void getNumpyArray(int nx, double *x, int ny, double *y); 36 | 37 | // Here we define how to extract the data from the struct Data in python 38 | %extend Data{ 39 | int get_n(){ 40 | return $self->n; 41 | } 42 | double get_x(int i) { 43 | if($self->n > 0) 44 | return $self->x[i]; 45 | return 0.0; 46 | } 47 | ~Data(){ 48 | freeData($self); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /FML/Spline/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | // using namespace FML::SPLINE; 8 | using Spline = FML::INTERPOLATION::SPLINE::Spline; 9 | using DVector = FML::INTERPOLATION::SPLINE::DVector; 10 | 11 | int main() { 12 | std::mt19937 generator; 13 | auto udist = std::uniform_real_distribution(0.0, 1.0); 14 | 15 | //====================================== 16 | // Make a spline and use it 17 | //====================================== 18 | 19 | // A test function to spline 20 | auto function = [](double x) -> double { return 2.0 + sin(2.0 * M_PI * x); }; 21 | 22 | // Make an x-array 23 | const int npts = 100; 24 | const double xmin = 0.0; 25 | const double xmax = 1.0; 26 | DVector x_array(npts); 27 | for (int i = 0; i < npts; i++) 28 | x_array[i] = xmin + (xmax - xmin) * i / double(npts); 29 | 30 | // Fill the y-array 31 | DVector y_array(npts); 32 | for (int i = 0; i < npts; i++) 33 | y_array[i] = function(x_array[i]); 34 | 35 | // Make a spline 36 | Spline y_spline(x_array, y_array, "Name of spline for better error messages"); 37 | 38 | // Output the error at random points close to the ones we sampled 39 | for (int i = 0; i < npts; i++) { 40 | const double x = x_array[i] + udist(generator) / double(npts); 41 | const double y = y_spline(x); 42 | const double ytrue = function(x); 43 | std::cout << x << " " << y << " " << ytrue << " Error %: " << abs(y - ytrue) / abs(ytrue) * 100. << "\n"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /FML/COLASolver/CHANGELOG: -------------------------------------------------------------------------------- 1 | From now on I will add a little log of changes so people can see what has changed without having to look at the commits. 2 | 3 | ================ 4 | August 9th 2023: 5 | ================ 6 | 7 | * Main update is the JBD solver (code made by Hermann Slettmoen). This now can use several different density parameter definitons and is compatible with the implementation in hi-class. 8 | 9 | * Minor updates to the cosmology class. Added computation of the neutrino pressure (needed for rho-3p terms in some theories like JBD). Added some helper functions (Hermann) for outputting the cosmology. With this its easy to add new columns to the output in child classes (see JBD as an example for how to do this). Extended range for alow/ahigh. 10 | 11 | * The only major change to the code is that I removed OmegaLambda as a free parameter and added OmegaK. It is much more natural to define OmegaK and derive OmegaLambda than the opposite. The main change is that you need to add cosmology_OmegaK to the parameterfile and remove cosmology_OmegaLambda. 12 | 13 | * Minor updates to the GravityModel class. Changed to more general output (easier to add more things). Made stuff that should not be public non-public. Changed the alow/ahigh klow/khigh parameters to cover a wider range. 14 | 15 | * Files changed: 16 | ReadParameters.h (removed the physical parameters for JBD as this is no longer needed) 17 | Cosmology.h (switched OmegaLambda for OmegaK as input parameter; improved output methods; adjusted ranges) 18 | GravityModel.h (adjusted ranges; improved output methods) 19 | COLA.h (cosmetic) 20 | Simulation.h (cosmetic) 21 | -------------------------------------------------------------------------------- /FML/KDTree/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, J. Frederico Carvalho 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /FML/ParameterMap/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using ParameterMap = FML::UTILS::ParameterMap; 4 | 5 | int main() { 6 | 7 | //=========================================================== 8 | // A simple structure for storing parameters of different types 9 | //=========================================================== 10 | 11 | // Add some values to the map 12 | ParameterMap p; 13 | p["AString"] = std::string("Hello"); 14 | p["ADouble"] = 1.0; 15 | p["AnInt"] = 5; 16 | p["Array"] = std::vector{1.0, 2.0, 3.0}; 17 | 18 | // Fetch values from the map 19 | auto AString = p.get("AString"); 20 | auto ADouble = p.get("ADouble"); 21 | auto AnInt = p.get("AnInt"); 22 | auto Array = p.get>("Array"); 23 | 24 | // If not found use a defalt value 25 | auto NonExistentInt = p.get("NonExistentInt", 999); 26 | 27 | // Output 28 | std::cout << "AString: " << AString << "\n"; 29 | std::cout << "ADouble: " << ADouble << "\n"; 30 | std::cout << "AnInt: " << AnInt << "\n"; 31 | std::cout << "NonExistentInt: " << NonExistentInt << "\n"; 32 | for (auto & e : Array) 33 | std::cout << "Array[]: " << e << "\n"; 34 | 35 | //...and if no default value exists throw an error 36 | try { 37 | std::cout << "Trying to fetch a value not in the map:\n"; 38 | [[maybe_unused]] auto NonExistentDouble = p.get("NonExistentDoouble"); 39 | } catch (std::runtime_error & e) { 40 | std::cout << e.what(); 41 | p.info(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FML/Cosmology/RecombinationHistory/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | 6 | // Parameter container 7 | FML::UTILS::ParameterMap p; 8 | auto&& param_map = p.get_map(); 9 | 10 | // Add cosmological parameters 11 | param_map["CosmologyLabel"] = std::string("LCDM"); 12 | param_map["PhysicalParameters"] = true; 13 | param_map["OmegaBh2"] = 0.0245; 14 | param_map["OmegaCDMh2"] = 0.10976; 15 | param_map["OmegaKh2"] = 0.0; 16 | param_map["OmegaLambdah2"] = 0.35574; 17 | param_map["TCMB"] = 2.7255 * FML::COSMOLOGY::Constants.K; 18 | param_map["h"] = 0.7; 19 | param_map["Neff"] = 3.046; 20 | 21 | // Add recombination parameters 22 | param_map["userecfast"] = false; 23 | param_map["RecFudgeFactor"] = 1.14; 24 | param_map["Yp"] = 0.24; 25 | param_map["reionization"] = true; 26 | param_map["helium_reionization"] = true; 27 | param_map["z_reion"] = 11.0; 28 | param_map["delta_z_reion"] = 0.5; 29 | param_map["z_helium_reion"] = 3.5; 30 | param_map["delta_z_helium_reion"] = 0.5; 31 | param_map["pert_x_initial"] = -15.0; 32 | p.info(); 33 | 34 | // Set up the cosmology and do all the solving and make splines 35 | auto lcdm = std::make_shared(p); 36 | lcdm->solve(); 37 | 38 | // Solve the recombination history (Saha+Peebles) 39 | auto rec = std::make_shared(lcdm, p); 40 | rec->solve(); 41 | } 42 | -------------------------------------------------------------------------------- /FML/CAMBUtils/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using Spline = FML::INTERPOLATION::SPLINE::Spline; 4 | 5 | int main() { 6 | 7 | double Omegab = 0.049; 8 | double OmegaCDM = 0.2637; 9 | double OmegaMNu = 0.0; 10 | double kpivot = 0.05; 11 | double As = 2.215e-9; 12 | double ns = 0.966; 13 | double h = 0.671; 14 | std::string fileformat = "CAMB"; 15 | 16 | // Read all the CAMB transfer function data and spline the functions T_i(k,a) and P_i(k,a) 17 | std::string infofile = "transfer_infofile.txt"; 18 | FML::FILEUTILS::LinearTransferData camb(Omegab, OmegaCDM, OmegaMNu, kpivot, As, ns, h, fileformat); 19 | camb.read_transfer(infofile); 20 | 21 | // If we only have a single power-spectrum file: read it and spline it 22 | std::string pofkfile = "camb_transfer_data/lcdm_nu0.2_matterpower_z0.000.dat"; 23 | auto data = camb.read_power_single(pofkfile); 24 | Spline pofk_cb_spline(data.first, data.second); 25 | 26 | // Output the power-spectrum 27 | const double scale_factor = 1.0; 28 | const double kmin = 0.001; 29 | const double kmax = 10.0; 30 | const int npts = 200; 31 | std::cout << "# k (h/Mpc) P(k) (Mpc/h)^3 Pcb(k) (Mpc/h)^3 Pcb(k) (Mpc/h)^3 \n"; 32 | for (int i = 0; i < npts; i++) { 33 | double k = std::exp(std::log(kmin) + std::log(kmax / kmin) * i / double(npts)); 34 | std::cout << std::setw(15) << k << " "; 35 | std::cout << std::setw(15) << camb.get_total_power_spectrum(k, scale_factor) << " "; 36 | std::cout << std::setw(15) << camb.get_cdm_baryon_power_spectrum(k, scale_factor) << " "; 37 | std::cout << std::setw(15) << pofk_cb_spline(k) << "\n"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FML/RandomGenerator/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | 7 | //========================================= 8 | // Simple wrapper around C++ random or GSL 9 | // random number library (or whatever) to 10 | // provide a simple interface for rng in this library 11 | //========================================= 12 | 13 | const int seed = 1234; 14 | FML::RANDOM::RandomGenerator r(seed); 15 | 16 | // Make a clone of the rng 17 | auto rclone = r.clone(); 18 | 19 | // Generate some numbers 20 | std::vector numbers(5); 21 | for(auto & num : numbers){ 22 | num = r.generate_uniform(); 23 | std::cout << num << "\n"; 24 | } 25 | std::cout << "\n"; 26 | 27 | // The clone should give the same results as above 28 | for(auto & num : numbers){ 29 | double num2 = rclone->generate_uniform(); 30 | std::cout << num2 << "\n"; 31 | assert( std::fabs( num - num2 ) < 1e-10 ); 32 | } 33 | std::cout << "\n"; 34 | 35 | #ifdef USE_GSL 36 | // If you want to use GSL 37 | std::shared_ptr r1 = std::make_shared(seed); 38 | 39 | // Make a clone of the rng 40 | auto r1clone = r1->clone(); 41 | 42 | // Generate some numbers 43 | for(auto & num : numbers){ 44 | num = r1->generate_uniform(); 45 | std::cout << num << "\n"; 46 | } 47 | std::cout << "\n"; 48 | 49 | // The clone should give the same results as above 50 | for(auto & num : numbers){ 51 | double num2 = r1clone->generate_uniform(); 52 | std::cout << num2 << "\n"; 53 | assert( std::fabs( num - num2 ) < 1e-10 ); 54 | } 55 | std::cout << "\n"; 56 | 57 | #endif 58 | } 59 | -------------------------------------------------------------------------------- /FML/Global/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | template 6 | using Vector = FML::Vector; 7 | 8 | int main() { 9 | 10 | // If we don't want automatic initialization/finalization of FML/MPI/FFTW (NO_AUTO_FML_SETUP) then we can do it like this 11 | // (or the way you are used to; just remember to set MPIThreadsOK and FFTWThreadsOK and call init_fml last) 12 | // FML::init_mpi(); 13 | // FML::GRID::init_fftw(); 14 | // FML::init_fml(); 15 | // FML::info(); 16 | 17 | // The stuff we store in global 18 | std::cout << "Task " << FML::ThisTask << " Total Tasks: " << FML::NTasks << " xmin: " << FML::xmin_domain 19 | << " xmax: " << FML::xmax_domain << std::endl; 20 | 21 | #ifdef MEMORY_LOGGING 22 | // Print the FML memory log 23 | FML::MemoryLog::get()->print(); 24 | FML::print_system_memory_use(); 25 | 26 | // Allocate some memory with standard container 27 | Vector a(1000000); 28 | Vector b(1000000); 29 | 30 | // Set memory labels 31 | auto * mem = FML::MemoryLog::get(); 32 | mem->add_label(a.data(), "[Vector a]"); 33 | mem->add_label(b.data(), "[Vector b]"); 34 | 35 | // Print the FML memory log 36 | FML::MemoryLog::get()->print(); 37 | FML::print_system_memory_use(); 38 | 39 | // Clear the memory and print again 40 | a.clear(); 41 | b.clear(); 42 | a.shrink_to_fit(); 43 | b.shrink_to_fit(); 44 | 45 | // Print the FML memory log 46 | FML::MemoryLog::get()->print(); 47 | FML::print_system_memory_use(); 48 | #endif 49 | 50 | // If we don't want automatic initialization/finalization of FML/MPI/FFTW (NO_AUTO_FML_SETUP) then we can do it like this 51 | // FML::GRID::finalize_fftw(); 52 | // FML::finalize_mpi(); 53 | } 54 | -------------------------------------------------------------------------------- /FML/ODESolver/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // using namespace FML::ODESOLVER; 5 | using DVector = FML::SOLVERS::ODESOLVER::DVector; 6 | using ODEFunction = FML::SOLVERS::ODESOLVER::ODEFunction; 7 | using ODESolver = FML::SOLVERS::ODESOLVER::ODESolver; 8 | 9 | int main() { 10 | 11 | //========================================= 12 | // Example on how to solve coupled ODEs 13 | //========================================= 14 | 15 | // Make an x-array to store the solution on 16 | const int npts = 10; 17 | const double xmin = 0.0; 18 | const double xmax = 2.0 * M_PI; 19 | DVector x_array(npts); 20 | for (int i = 0; i < npts; i++) 21 | x_array[i] = xmin + (xmax - xmin) * i / double(npts); 22 | 23 | // The RHS of the ODE y'' + y = 0 24 | // We write it as y0' = y1 ; y1' = -y0 25 | ODEFunction deriv = [&](double x, const double * y, double * dydx) { 26 | (void)x; 27 | dydx[0] = y[1]; 28 | dydx[1] = -y[0]; 29 | return GSL_SUCCESS; 30 | }; 31 | 32 | // The initial conditions 33 | DVector y_initial{1.0, 0.0}; 34 | 35 | // The anaytical solution 36 | auto function = [](double x) -> double { return std::cos(x); }; 37 | 38 | // Solve the ODE from xmin = x[0] till xmax = x[npts-1] and store the 39 | // result at every x in x_array 40 | ODESolver ode; 41 | ode.solve(deriv, x_array, y_initial); 42 | 43 | // Fetch solution (y0 = y) 44 | auto y_array = ode.get_data_by_component(0); 45 | 46 | // Output 47 | std::cout << "# x y y_true error\n"; 48 | for (int i = 0; i < npts; i++) { 49 | double x = x_array[i]; 50 | double y = y_array[i]; 51 | double ytrue = function(x); 52 | std::cout << x << " " << y << " " << ytrue << " Error: " << y - ytrue << "\n"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /FML/Emulator/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // The EuclidEmulator2 code was written by Mischa Knabenhans 5 | // and was taken from https://github.com/miknab/EuclidEmulator2 6 | // See headerfile EuclidEmulator2.h for more info 7 | // For use cite the EuclidEmulator2 paper: https://arxiv.org/abs/2010.11288 8 | 9 | using EuclidEmulator2 = FML::EMULATOR::EUCLIDEMULATOR2::EuclidEmulator; 10 | using EuclidEmulator2Cosmology = FML::EMULATOR::EUCLIDEMULATOR2::Cosmology; 11 | 12 | int main() { 13 | 14 | // The euclidemulator needs the EuclidEmulator2.dat file, if this is not 15 | // in the right folder set the path to it here. This path is computed automatically 16 | // at compiletime so as long as the file is in the same folder as EuclidEmulator2.h 17 | // all should be good 18 | // FML::EMULATOR::EUCLIDEMULATOR2::set_path_to_ee2_data("../EuclidEmulator2.dat"); 19 | 20 | // Set cosmological parameters 21 | double h = 0.67, OmegaB = 0.05, OmegaM = 0.3, Sum_m_nu = 0.15, n_s = 1.0, w_0 = -1.0, w_a = 0.0, A_s = 2e-9; 22 | 23 | // Check if cosmology is within bounds and the datafile exists 24 | EuclidEmulator2Cosmology ee2cosmo(OmegaB, OmegaM, Sum_m_nu, n_s, h, w_0, w_a, A_s); 25 | if (not ee2cosmo.is_good_to_use()) { 26 | ee2cosmo.print_errors(); 27 | throw std::runtime_error("Cannot run the EuclidEmulator2 due to errors"); 28 | } 29 | 30 | // Set up the emulator 31 | EuclidEmulator2 ee2(ee2cosmo); 32 | 33 | // Call it for a given redshift to get the boost B = P(k) / P_linear(k) 34 | double redshift = 0.0; 35 | auto result = ee2.compute_boost(redshift); 36 | auto k = result.first; 37 | auto boost = result.second; 38 | for (size_t i = 0; i < k.size(); i++) 39 | std::cout << std::setw(15) << k[i] << " " << std::setw(15) << boost[i] << "\n"; 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /FML/RamsesUtils/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH := $(FML_INCLUDE)/FML/Global/ 58 | OBJS = Main.o Global.o 59 | 60 | TARGETS := ramses 61 | all: $(TARGETS) 62 | .PHONY: all clean 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | ramses: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | -------------------------------------------------------------------------------- /FML/Timing/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH := $(FML_INCLUDE)/FML/Global/ 58 | OBJS = Main.o Global.o 59 | 60 | TARGETS := timing 61 | all: $(TARGETS) 62 | .PHONY: all clean 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | timing: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | 73 | -------------------------------------------------------------------------------- /FML/Units/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH := $(FML_INCLUDE)/FML/Global/ 58 | OBJS = Main.o Global.o 59 | 60 | TARGETS := units 61 | all: $(TARGETS) 62 | .PHONY: all clean 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | units: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | 73 | -------------------------------------------------------------------------------- /FML/ParticleTypes/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH := $(FML_INCLUDE)/FML/Global/ 58 | OBJS = Main.o Global.o 59 | 60 | TARGETS := particle 61 | all: $(TARGETS) 62 | .PHONY: all clean 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | particle: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | 73 | -------------------------------------------------------------------------------- /FML/FileUtils/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (2015) (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | TARGETS := fileutils 54 | all: $(TARGETS) 55 | .PHONY: all clean 56 | 57 | #=================================================== 58 | # Object files to be compiled 59 | #=================================================== 60 | 61 | VPATH := $(FML_INCLUDE)/FML/FileUtils/ 62 | OBJS = Main.o FileUtils.o 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | fileutils: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | 73 | 74 | -------------------------------------------------------------------------------- /FML/ParameterMap/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/ParameterMap/ 58 | OBJS = Main.o ParameterMap.o Global.o 59 | 60 | TARGETS := parametermap 61 | all: $(TARGETS) 62 | .PHONY: all clean 63 | 64 | clean: 65 | rm -rf $(TARGETS) *.o 66 | 67 | parametermap: $(OBJS) 68 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 69 | 70 | %.o: %.cpp 71 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 72 | 73 | -------------------------------------------------------------------------------- /FML/MPIGrid/ConvertMPIGridFFTWGrid.h: -------------------------------------------------------------------------------- 1 | #ifndef CONVERTGRIDS_HEADER 2 | #define CONVERTGRIDS_HEADER 3 | 4 | #include 5 | #include 6 | 7 | //========================================================================= 8 | // Method to convert data in a MPIGrid to a FFTWGrid for the case where T is 9 | // float or double. 10 | // NB: we only copy the main grid and we assume its a real grid 11 | //========================================================================= 12 | 13 | template 14 | void ConvertToFFTWGrid(FML::GRID::MPIGrid & from_grid, FML::GRID::FFTWGrid & to_grid) { 15 | 16 | auto Nmesh = from_grid.get_N(); 17 | auto nleft = from_grid.get_n_extra_slices_left(); 18 | auto nright = from_grid.get_n_extra_slices_right(); 19 | 20 | to_grid = FML::GRID::FFTWGrid(Nmesh, nleft, nright); 21 | 22 | auto Ntot = from_grid.get_NtotLocal(); 23 | #ifdef USE_OMP 24 | #pragma omp parallel for 25 | #endif 26 | for (long long int index = 0; index < Ntot; index++) { 27 | auto coord = from_grid.coord_from_index(index); 28 | auto value = from_grid.get_y(index); 29 | to_grid.set_real(coord, value); 30 | } 31 | } 32 | 33 | template 34 | void ConvertToMPIGrid(FML::GRID::FFTWGrid & from_grid, FML::GRID::MPIGrid & to_grid) { 35 | 36 | auto Nmesh = from_grid.get_nmesh(); 37 | auto Local_nx = from_grid.get_local_nx(); 38 | auto nleft = from_grid.get_n_extra_slices_left(); 39 | auto nright = from_grid.get_n_extra_slices_right(); 40 | 41 | to_grid = FML::GRID::MPIGrid(Nmesh, true, nleft, nright); 42 | 43 | #ifdef USE_OMP 44 | #pragma omp parallel for 45 | #endif 46 | for (int islice = 0; islice < Local_nx; islice++) { 47 | for (auto && real_index : from_grid.get_real_range(islice, islice + 1)) { 48 | auto coord = from_grid.get_coord_from_index(real_index); 49 | auto value = from_grid.get_real_from_index(real_index); 50 | to_grid.set_y(coord, value); 51 | } 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /FML/MPIGrid/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Log allocations in the library 21 | USE_MEMORYLOG = false 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | #=================================================== 33 | # Compile up all library defines from options above 34 | #=================================================== 35 | 36 | INC = -I$(FML_INCLUDE) 37 | LIB = 38 | LINK = 39 | OPTIONS = 40 | 41 | ifeq ($(USE_MPI),true) 42 | CC = $(MPICC) 43 | OPTIONS += -DUSE_MPI 44 | endif 45 | 46 | ifeq ($(USE_OMP),true) 47 | OPTIONS += -DUSE_OMP 48 | CC += -fopenmp 49 | endif 50 | 51 | ifeq ($(USE_SANITIZER),true) 52 | CC += -fsanitize=address 53 | endif 54 | 55 | ifeq ($(USE_MEMORYLOG),true) 56 | OPTIONS += -DMEMORY_LOGGING 57 | endif 58 | 59 | #=================================================== 60 | # Object files to be compiled 61 | #=================================================== 62 | 63 | VPATH = $(FML_INCLUDE)/FML/Global/ 64 | OBJS = Main.o Global.o 65 | 66 | TARGETS := mpigrid 67 | all: $(TARGETS) 68 | .PHONY: all clean 69 | 70 | clean: 71 | rm -rf $(TARGETS) *.o 72 | 73 | mpigrid: $(OBJS) 74 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 75 | 76 | %.o: %.cpp 77 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 78 | 79 | -------------------------------------------------------------------------------- /FML/MemoryLogging/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Log allocations in the library 21 | USE_MEMORYLOG = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | #=================================================== 33 | # Compile up all library defines from options above 34 | #=================================================== 35 | 36 | INC = -I$(FML_INCLUDE) 37 | LIB = 38 | LINK = 39 | OPTIONS = 40 | 41 | ifeq ($(USE_MPI),true) 42 | CC = $(MPICC) 43 | OPTIONS += -DUSE_MPI 44 | endif 45 | 46 | ifeq ($(USE_OMP),true) 47 | OPTIONS += -DUSE_OMP 48 | CC += -fopenmp 49 | endif 50 | 51 | ifeq ($(USE_SANITIZER),true) 52 | CC += -fsanitize=address 53 | endif 54 | 55 | ifeq ($(USE_MEMORYLOG),true) 56 | OPTIONS += -DMEMORY_LOGGING -DMIN_BYTES_TO_LOG=0 57 | endif 58 | 59 | #=================================================== 60 | # Object files to be compiled 61 | #=================================================== 62 | 63 | VPATH := $(FML_INCLUDE)/FML/Global/ 64 | OBJS = Main.o Global.o 65 | 66 | TARGETS := memory 67 | all: $(TARGETS) 68 | .PHONY: all clean 69 | 70 | clean: 71 | rm -rf $(TARGETS) *.o 72 | 73 | memory: $(OBJS) 74 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 75 | 76 | %.o: %.cpp 77 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 78 | 79 | -------------------------------------------------------------------------------- /FML/FileUtils/FileUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEUTILS_HEADER 2 | #define FILEUTILS_HEADER 3 | #include 4 | #include 5 | 6 | namespace FML { 7 | 8 | //================================================================================ 9 | /// This namespace deals with reading and writing files to disc. 10 | /// 11 | //================================================================================ 12 | 13 | namespace FILEUTILS { 14 | 15 | using DVector = std::vector; 16 | using DVector2D = std::vector; 17 | 18 | /// Read a regular ascii files with nskip header lines and containing ncol collums 19 | /// nestimated_lines is the amount we allocate for originally. Reallocated if file is larger 20 | /// Not perfect for realy large files due to all the allocations we have to do 21 | DVector2D read_regular_ascii(std::string filename, 22 | int ncols, 23 | std::vector cols_to_keep, 24 | int nskip, 25 | size_t nestimated_lines = 10000); 26 | 27 | /// As above, but include every line read with probabillity fraction_to_read 28 | DVector2D read_regular_ascii_subsampled(std::string filename, 29 | int ncols, 30 | std::vector cols_to_keep, 31 | int nskip, 32 | size_t nestimated_lines = 10000, 33 | double fraction_to_read = 1.0, 34 | unsigned int randomSeed = 1234); 35 | 36 | /// Similar to pythons loadtxt 37 | DVector2D loadtxt(std::string filename, int nreserve_rows = 1, int nreserve_cols = 1); 38 | 39 | /// Read a regular file and extract two columns (numbering starting with 0) 40 | std::pair read_file_and_extract_two_columns(int col1, int col2); 41 | } // namespace FILEUTILS 42 | } // namespace FML 43 | #endif 44 | -------------------------------------------------------------------------------- /FML/GadgetUtils/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Check for bad memory accesses 21 | USE_SANITIZER = false 22 | 23 | #=================================================== 24 | # Include and library paths 25 | #=================================================== 26 | 27 | # Main library include (path to folder containin FML/) 28 | FML_INCLUDE = $(HOME)/local/FML 29 | 30 | #=================================================== 31 | # Compile up all library defines from options above 32 | #=================================================== 33 | 34 | INC = -I$(FML_INCLUDE) 35 | LIB = 36 | LINK = 37 | OPTIONS = 38 | 39 | ifeq ($(USE_MPI),true) 40 | CC = $(MPICC) 41 | OPTIONS += -DUSE_MPI 42 | endif 43 | 44 | ifeq ($(USE_OMP),true) 45 | OPTIONS += -DUSE_OMP 46 | CC += -fopenmp 47 | endif 48 | 49 | ifeq ($(USE_SANITIZER),true) 50 | CC += -fsanitize=address 51 | endif 52 | 53 | #=================================================== 54 | # Object files to be compiled 55 | #=================================================== 56 | 57 | VPATH = $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/GadgetUtils/:$(FML_INCLUDE)/FML/FileUtils/ 58 | OBJS = Main.o Global.o GadgetUtils.o 59 | OBJS_TEST = Test.o Global.o GadgetUtils.o FileUtils.o 60 | 61 | TARGETS := gadget 62 | all: $(TARGETS) 63 | .PHONY: all clean 64 | 65 | 66 | clean: 67 | rm -rf $(TARGETS) *.o 68 | 69 | gadget: $(OBJS) 70 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 71 | 72 | test: $(OBJS_TEST) 73 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 74 | 75 | %.o: %.cpp 76 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 77 | 78 | -------------------------------------------------------------------------------- /FML/CAMBUtils/example/transfer_infofile.txt: -------------------------------------------------------------------------------- 1 | /Users/hansw/local/FML/FML/CAMBUtils/example/camb_transfer_data 50 2 | lcdm_nu0.2_transfer_z0.000.dat 0.000 3 | lcdm_nu0.2_transfer_z0.084.dat 0.084 4 | lcdm_nu0.2_transfer_z0.174.dat 0.174 5 | lcdm_nu0.2_transfer_z0.272.dat 0.272 6 | lcdm_nu0.2_transfer_z0.378.dat 0.378 7 | lcdm_nu0.2_transfer_z0.494.dat 0.494 8 | lcdm_nu0.2_transfer_z0.618.dat 0.618 9 | lcdm_nu0.2_transfer_z0.754.dat 0.754 10 | lcdm_nu0.2_transfer_z0.900.dat 0.900 11 | lcdm_nu0.2_transfer_z1.059.dat 1.059 12 | lcdm_nu0.2_transfer_z1.231.dat 1.231 13 | lcdm_nu0.2_transfer_z1.417.dat 1.417 14 | lcdm_nu0.2_transfer_z1.619.dat 1.619 15 | lcdm_nu0.2_transfer_z1.838.dat 1.838 16 | lcdm_nu0.2_transfer_z2.075.dat 2.075 17 | lcdm_nu0.2_transfer_z2.332.dat 2.332 18 | lcdm_nu0.2_transfer_z2.611.dat 2.611 19 | lcdm_nu0.2_transfer_z2.912.dat 2.912 20 | lcdm_nu0.2_transfer_z3.239.dat 3.239 21 | lcdm_nu0.2_transfer_z3.593.dat 3.593 22 | lcdm_nu0.2_transfer_z3.977.dat 3.977 23 | lcdm_nu0.2_transfer_z4.393.dat 4.393 24 | lcdm_nu0.2_transfer_z4.843.dat 4.843 25 | lcdm_nu0.2_transfer_z5.332.dat 5.332 26 | lcdm_nu0.2_transfer_z5.861.dat 5.861 27 | lcdm_nu0.2_transfer_z6.434.dat 6.434 28 | lcdm_nu0.2_transfer_z7.055.dat 7.055 29 | lcdm_nu0.2_transfer_z7.728.dat 7.728 30 | lcdm_nu0.2_transfer_z8.457.dat 8.457 31 | lcdm_nu0.2_transfer_z9.247.dat 9.247 32 | lcdm_nu0.2_transfer_z10.103.dat 10.103 33 | lcdm_nu0.2_transfer_z11.031.dat 11.031 34 | lcdm_nu0.2_transfer_z12.036.dat 12.036 35 | lcdm_nu0.2_transfer_z13.125.dat 13.125 36 | lcdm_nu0.2_transfer_z14.305.dat 14.305 37 | lcdm_nu0.2_transfer_z15.584.dat 15.584 38 | lcdm_nu0.2_transfer_z16.970.dat 16.970 39 | lcdm_nu0.2_transfer_z18.471.dat 18.471 40 | lcdm_nu0.2_transfer_z20.098.dat 20.098 41 | lcdm_nu0.2_transfer_z21.861.dat 21.861 42 | lcdm_nu0.2_transfer_z23.771.dat 23.771 43 | lcdm_nu0.2_transfer_z25.840.dat 25.840 44 | lcdm_nu0.2_transfer_z28.082.dat 28.082 45 | lcdm_nu0.2_transfer_z30.512.dat 30.512 46 | lcdm_nu0.2_transfer_z33.145.dat 33.145 47 | lcdm_nu0.2_transfer_z35.998.dat 35.998 48 | lcdm_nu0.2_transfer_z39.089.dat 39.089 49 | lcdm_nu0.2_transfer_z42.438.dat 42.438 50 | lcdm_nu0.2_transfer_z46.068.dat 46.068 51 | lcdm_nu0.2_transfer_z50.000.dat 50.000 52 | -------------------------------------------------------------------------------- /FML/COLASolver/input/transfer_infofile_lcdm_nu0.0.txt: -------------------------------------------------------------------------------- 1 | /Users/hansw/local/FML/FML/COLASolver/input/camb_data_lcdm_nu0.0 50 2 | lcdm_nu0.0_transfer_z0.000.dat 0.000 3 | lcdm_nu0.0_transfer_z0.084.dat 0.084 4 | lcdm_nu0.0_transfer_z0.174.dat 0.174 5 | lcdm_nu0.0_transfer_z0.272.dat 0.272 6 | lcdm_nu0.0_transfer_z0.378.dat 0.378 7 | lcdm_nu0.0_transfer_z0.494.dat 0.494 8 | lcdm_nu0.0_transfer_z0.618.dat 0.618 9 | lcdm_nu0.0_transfer_z0.754.dat 0.754 10 | lcdm_nu0.0_transfer_z0.900.dat 0.900 11 | lcdm_nu0.0_transfer_z1.059.dat 1.059 12 | lcdm_nu0.0_transfer_z1.231.dat 1.231 13 | lcdm_nu0.0_transfer_z1.417.dat 1.417 14 | lcdm_nu0.0_transfer_z1.619.dat 1.619 15 | lcdm_nu0.0_transfer_z1.838.dat 1.838 16 | lcdm_nu0.0_transfer_z2.075.dat 2.075 17 | lcdm_nu0.0_transfer_z2.332.dat 2.332 18 | lcdm_nu0.0_transfer_z2.611.dat 2.611 19 | lcdm_nu0.0_transfer_z2.912.dat 2.912 20 | lcdm_nu0.0_transfer_z3.239.dat 3.239 21 | lcdm_nu0.0_transfer_z3.593.dat 3.593 22 | lcdm_nu0.0_transfer_z3.977.dat 3.977 23 | lcdm_nu0.0_transfer_z4.393.dat 4.393 24 | lcdm_nu0.0_transfer_z4.843.dat 4.843 25 | lcdm_nu0.0_transfer_z5.332.dat 5.332 26 | lcdm_nu0.0_transfer_z5.861.dat 5.861 27 | lcdm_nu0.0_transfer_z6.434.dat 6.434 28 | lcdm_nu0.0_transfer_z7.055.dat 7.055 29 | lcdm_nu0.0_transfer_z7.728.dat 7.728 30 | lcdm_nu0.0_transfer_z8.457.dat 8.457 31 | lcdm_nu0.0_transfer_z9.247.dat 9.247 32 | lcdm_nu0.0_transfer_z10.103.dat 10.103 33 | lcdm_nu0.0_transfer_z11.031.dat 11.031 34 | lcdm_nu0.0_transfer_z12.036.dat 12.036 35 | lcdm_nu0.0_transfer_z13.125.dat 13.125 36 | lcdm_nu0.0_transfer_z14.305.dat 14.305 37 | lcdm_nu0.0_transfer_z15.584.dat 15.584 38 | lcdm_nu0.0_transfer_z16.970.dat 16.970 39 | lcdm_nu0.0_transfer_z18.471.dat 18.471 40 | lcdm_nu0.0_transfer_z20.098.dat 20.098 41 | lcdm_nu0.0_transfer_z21.861.dat 21.861 42 | lcdm_nu0.0_transfer_z23.771.dat 23.771 43 | lcdm_nu0.0_transfer_z25.840.dat 25.840 44 | lcdm_nu0.0_transfer_z28.082.dat 28.082 45 | lcdm_nu0.0_transfer_z30.512.dat 30.512 46 | lcdm_nu0.0_transfer_z33.145.dat 33.145 47 | lcdm_nu0.0_transfer_z35.998.dat 35.998 48 | lcdm_nu0.0_transfer_z39.089.dat 39.089 49 | lcdm_nu0.0_transfer_z42.438.dat 42.438 50 | lcdm_nu0.0_transfer_z46.068.dat 46.068 51 | lcdm_nu0.0_transfer_z50.000.dat 50.000 52 | -------------------------------------------------------------------------------- /FML/COLASolver/input/transfer_infofile_lcdm_nu0.2.txt: -------------------------------------------------------------------------------- 1 | /Users/hansw/local/FML/FML/COLASolver/input/camb_data_lcdm_nu0.2 50 2 | lcdm_nu0.2_transfer_z0.000.dat 0.000 3 | lcdm_nu0.2_transfer_z0.084.dat 0.084 4 | lcdm_nu0.2_transfer_z0.174.dat 0.174 5 | lcdm_nu0.2_transfer_z0.272.dat 0.272 6 | lcdm_nu0.2_transfer_z0.378.dat 0.378 7 | lcdm_nu0.2_transfer_z0.494.dat 0.494 8 | lcdm_nu0.2_transfer_z0.618.dat 0.618 9 | lcdm_nu0.2_transfer_z0.754.dat 0.754 10 | lcdm_nu0.2_transfer_z0.900.dat 0.900 11 | lcdm_nu0.2_transfer_z1.059.dat 1.059 12 | lcdm_nu0.2_transfer_z1.231.dat 1.231 13 | lcdm_nu0.2_transfer_z1.417.dat 1.417 14 | lcdm_nu0.2_transfer_z1.619.dat 1.619 15 | lcdm_nu0.2_transfer_z1.838.dat 1.838 16 | lcdm_nu0.2_transfer_z2.075.dat 2.075 17 | lcdm_nu0.2_transfer_z2.332.dat 2.332 18 | lcdm_nu0.2_transfer_z2.611.dat 2.611 19 | lcdm_nu0.2_transfer_z2.912.dat 2.912 20 | lcdm_nu0.2_transfer_z3.239.dat 3.239 21 | lcdm_nu0.2_transfer_z3.593.dat 3.593 22 | lcdm_nu0.2_transfer_z3.977.dat 3.977 23 | lcdm_nu0.2_transfer_z4.393.dat 4.393 24 | lcdm_nu0.2_transfer_z4.843.dat 4.843 25 | lcdm_nu0.2_transfer_z5.332.dat 5.332 26 | lcdm_nu0.2_transfer_z5.861.dat 5.861 27 | lcdm_nu0.2_transfer_z6.434.dat 6.434 28 | lcdm_nu0.2_transfer_z7.055.dat 7.055 29 | lcdm_nu0.2_transfer_z7.728.dat 7.728 30 | lcdm_nu0.2_transfer_z8.457.dat 8.457 31 | lcdm_nu0.2_transfer_z9.247.dat 9.247 32 | lcdm_nu0.2_transfer_z10.103.dat 10.103 33 | lcdm_nu0.2_transfer_z11.031.dat 11.031 34 | lcdm_nu0.2_transfer_z12.036.dat 12.036 35 | lcdm_nu0.2_transfer_z13.125.dat 13.125 36 | lcdm_nu0.2_transfer_z14.305.dat 14.305 37 | lcdm_nu0.2_transfer_z15.584.dat 15.584 38 | lcdm_nu0.2_transfer_z16.970.dat 16.970 39 | lcdm_nu0.2_transfer_z18.471.dat 18.471 40 | lcdm_nu0.2_transfer_z20.098.dat 20.098 41 | lcdm_nu0.2_transfer_z21.861.dat 21.861 42 | lcdm_nu0.2_transfer_z23.771.dat 23.771 43 | lcdm_nu0.2_transfer_z25.840.dat 25.840 44 | lcdm_nu0.2_transfer_z28.082.dat 28.082 45 | lcdm_nu0.2_transfer_z30.512.dat 30.512 46 | lcdm_nu0.2_transfer_z33.145.dat 33.145 47 | lcdm_nu0.2_transfer_z35.998.dat 35.998 48 | lcdm_nu0.2_transfer_z39.089.dat 39.089 49 | lcdm_nu0.2_transfer_z42.438.dat 42.438 50 | lcdm_nu0.2_transfer_z46.068.dat 46.068 51 | lcdm_nu0.2_transfer_z50.000.dat 50.000 52 | -------------------------------------------------------------------------------- /FML/COLASolver/input/transfer_infofile_lcdm_nu0.4.txt: -------------------------------------------------------------------------------- 1 | /Users/hansw/local/FML/FML/COLASolver/input/camb_data_lcdm_nu0.4 50 2 | lcdm_nu0.4_transfer_z0.000.dat 0.000 3 | lcdm_nu0.4_transfer_z0.084.dat 0.084 4 | lcdm_nu0.4_transfer_z0.174.dat 0.174 5 | lcdm_nu0.4_transfer_z0.272.dat 0.272 6 | lcdm_nu0.4_transfer_z0.378.dat 0.378 7 | lcdm_nu0.4_transfer_z0.494.dat 0.494 8 | lcdm_nu0.4_transfer_z0.618.dat 0.618 9 | lcdm_nu0.4_transfer_z0.754.dat 0.754 10 | lcdm_nu0.4_transfer_z0.900.dat 0.900 11 | lcdm_nu0.4_transfer_z1.059.dat 1.059 12 | lcdm_nu0.4_transfer_z1.231.dat 1.231 13 | lcdm_nu0.4_transfer_z1.417.dat 1.417 14 | lcdm_nu0.4_transfer_z1.619.dat 1.619 15 | lcdm_nu0.4_transfer_z1.838.dat 1.838 16 | lcdm_nu0.4_transfer_z2.075.dat 2.075 17 | lcdm_nu0.4_transfer_z2.332.dat 2.332 18 | lcdm_nu0.4_transfer_z2.611.dat 2.611 19 | lcdm_nu0.4_transfer_z2.912.dat 2.912 20 | lcdm_nu0.4_transfer_z3.239.dat 3.239 21 | lcdm_nu0.4_transfer_z3.593.dat 3.593 22 | lcdm_nu0.4_transfer_z3.977.dat 3.977 23 | lcdm_nu0.4_transfer_z4.393.dat 4.393 24 | lcdm_nu0.4_transfer_z4.843.dat 4.843 25 | lcdm_nu0.4_transfer_z5.332.dat 5.332 26 | lcdm_nu0.4_transfer_z5.861.dat 5.861 27 | lcdm_nu0.4_transfer_z6.434.dat 6.434 28 | lcdm_nu0.4_transfer_z7.055.dat 7.055 29 | lcdm_nu0.4_transfer_z7.728.dat 7.728 30 | lcdm_nu0.4_transfer_z8.457.dat 8.457 31 | lcdm_nu0.4_transfer_z9.247.dat 9.247 32 | lcdm_nu0.4_transfer_z10.103.dat 10.103 33 | lcdm_nu0.4_transfer_z11.031.dat 11.031 34 | lcdm_nu0.4_transfer_z12.036.dat 12.036 35 | lcdm_nu0.4_transfer_z13.125.dat 13.125 36 | lcdm_nu0.4_transfer_z14.305.dat 14.305 37 | lcdm_nu0.4_transfer_z15.584.dat 15.584 38 | lcdm_nu0.4_transfer_z16.970.dat 16.970 39 | lcdm_nu0.4_transfer_z18.471.dat 18.471 40 | lcdm_nu0.4_transfer_z20.098.dat 20.098 41 | lcdm_nu0.4_transfer_z21.861.dat 21.861 42 | lcdm_nu0.4_transfer_z23.771.dat 23.771 43 | lcdm_nu0.4_transfer_z25.840.dat 25.840 44 | lcdm_nu0.4_transfer_z28.082.dat 28.082 45 | lcdm_nu0.4_transfer_z30.512.dat 30.512 46 | lcdm_nu0.4_transfer_z33.145.dat 33.145 47 | lcdm_nu0.4_transfer_z35.998.dat 35.998 48 | lcdm_nu0.4_transfer_z39.089.dat 39.089 49 | lcdm_nu0.4_transfer_z42.438.dat 42.438 50 | lcdm_nu0.4_transfer_z46.068.dat 46.068 51 | lcdm_nu0.4_transfer_z50.000.dat 50.000 52 | -------------------------------------------------------------------------------- /FML/CAMBUtils/example/camb_transfer_data/picola_transfer_info_nu0.2.txt: -------------------------------------------------------------------------------- 1 | /Users/hans/local/MG-PICOLA-PUBLIC/camb_data/example_data_nu0.2 50 2 | lcdm_nu0.2_transfer_z0.000.dat 0.000 3 | lcdm_nu0.2_transfer_z0.084.dat 0.084 4 | lcdm_nu0.2_transfer_z0.174.dat 0.174 5 | lcdm_nu0.2_transfer_z0.272.dat 0.272 6 | lcdm_nu0.2_transfer_z0.378.dat 0.378 7 | lcdm_nu0.2_transfer_z0.494.dat 0.494 8 | lcdm_nu0.2_transfer_z0.618.dat 0.618 9 | lcdm_nu0.2_transfer_z0.754.dat 0.754 10 | lcdm_nu0.2_transfer_z0.900.dat 0.900 11 | lcdm_nu0.2_transfer_z1.059.dat 1.059 12 | lcdm_nu0.2_transfer_z1.231.dat 1.231 13 | lcdm_nu0.2_transfer_z1.417.dat 1.417 14 | lcdm_nu0.2_transfer_z1.619.dat 1.619 15 | lcdm_nu0.2_transfer_z1.838.dat 1.838 16 | lcdm_nu0.2_transfer_z2.075.dat 2.075 17 | lcdm_nu0.2_transfer_z2.332.dat 2.332 18 | lcdm_nu0.2_transfer_z2.611.dat 2.611 19 | lcdm_nu0.2_transfer_z2.912.dat 2.912 20 | lcdm_nu0.2_transfer_z3.239.dat 3.239 21 | lcdm_nu0.2_transfer_z3.593.dat 3.593 22 | lcdm_nu0.2_transfer_z3.977.dat 3.977 23 | lcdm_nu0.2_transfer_z4.393.dat 4.393 24 | lcdm_nu0.2_transfer_z4.843.dat 4.843 25 | lcdm_nu0.2_transfer_z5.332.dat 5.332 26 | lcdm_nu0.2_transfer_z5.861.dat 5.861 27 | lcdm_nu0.2_transfer_z6.434.dat 6.434 28 | lcdm_nu0.2_transfer_z7.055.dat 7.055 29 | lcdm_nu0.2_transfer_z7.728.dat 7.728 30 | lcdm_nu0.2_transfer_z8.457.dat 8.457 31 | lcdm_nu0.2_transfer_z9.247.dat 9.247 32 | lcdm_nu0.2_transfer_z10.103.dat 10.103 33 | lcdm_nu0.2_transfer_z11.031.dat 11.031 34 | lcdm_nu0.2_transfer_z12.036.dat 12.036 35 | lcdm_nu0.2_transfer_z13.125.dat 13.125 36 | lcdm_nu0.2_transfer_z14.305.dat 14.305 37 | lcdm_nu0.2_transfer_z15.584.dat 15.584 38 | lcdm_nu0.2_transfer_z16.970.dat 16.970 39 | lcdm_nu0.2_transfer_z18.471.dat 18.471 40 | lcdm_nu0.2_transfer_z20.098.dat 20.098 41 | lcdm_nu0.2_transfer_z21.861.dat 21.861 42 | lcdm_nu0.2_transfer_z23.771.dat 23.771 43 | lcdm_nu0.2_transfer_z25.840.dat 25.840 44 | lcdm_nu0.2_transfer_z28.082.dat 28.082 45 | lcdm_nu0.2_transfer_z30.512.dat 30.512 46 | lcdm_nu0.2_transfer_z33.145.dat 33.145 47 | lcdm_nu0.2_transfer_z35.998.dat 35.998 48 | lcdm_nu0.2_transfer_z39.089.dat 39.089 49 | lcdm_nu0.2_transfer_z42.438.dat 42.438 50 | lcdm_nu0.2_transfer_z46.068.dat 46.068 51 | lcdm_nu0.2_transfer_z50.000.dat 50.000 -------------------------------------------------------------------------------- /FML/COLASolver/input/camb_data_lcdm_nu0.2/picola_transfer_info_nu0.2.txt: -------------------------------------------------------------------------------- 1 | /Users/hans/local/MG-PICOLA-PUBLIC/camb_data/example_data_nu0.2 50 2 | lcdm_nu0.2_transfer_z0.000.dat 0.000 3 | lcdm_nu0.2_transfer_z0.084.dat 0.084 4 | lcdm_nu0.2_transfer_z0.174.dat 0.174 5 | lcdm_nu0.2_transfer_z0.272.dat 0.272 6 | lcdm_nu0.2_transfer_z0.378.dat 0.378 7 | lcdm_nu0.2_transfer_z0.494.dat 0.494 8 | lcdm_nu0.2_transfer_z0.618.dat 0.618 9 | lcdm_nu0.2_transfer_z0.754.dat 0.754 10 | lcdm_nu0.2_transfer_z0.900.dat 0.900 11 | lcdm_nu0.2_transfer_z1.059.dat 1.059 12 | lcdm_nu0.2_transfer_z1.231.dat 1.231 13 | lcdm_nu0.2_transfer_z1.417.dat 1.417 14 | lcdm_nu0.2_transfer_z1.619.dat 1.619 15 | lcdm_nu0.2_transfer_z1.838.dat 1.838 16 | lcdm_nu0.2_transfer_z2.075.dat 2.075 17 | lcdm_nu0.2_transfer_z2.332.dat 2.332 18 | lcdm_nu0.2_transfer_z2.611.dat 2.611 19 | lcdm_nu0.2_transfer_z2.912.dat 2.912 20 | lcdm_nu0.2_transfer_z3.239.dat 3.239 21 | lcdm_nu0.2_transfer_z3.593.dat 3.593 22 | lcdm_nu0.2_transfer_z3.977.dat 3.977 23 | lcdm_nu0.2_transfer_z4.393.dat 4.393 24 | lcdm_nu0.2_transfer_z4.843.dat 4.843 25 | lcdm_nu0.2_transfer_z5.332.dat 5.332 26 | lcdm_nu0.2_transfer_z5.861.dat 5.861 27 | lcdm_nu0.2_transfer_z6.434.dat 6.434 28 | lcdm_nu0.2_transfer_z7.055.dat 7.055 29 | lcdm_nu0.2_transfer_z7.728.dat 7.728 30 | lcdm_nu0.2_transfer_z8.457.dat 8.457 31 | lcdm_nu0.2_transfer_z9.247.dat 9.247 32 | lcdm_nu0.2_transfer_z10.103.dat 10.103 33 | lcdm_nu0.2_transfer_z11.031.dat 11.031 34 | lcdm_nu0.2_transfer_z12.036.dat 12.036 35 | lcdm_nu0.2_transfer_z13.125.dat 13.125 36 | lcdm_nu0.2_transfer_z14.305.dat 14.305 37 | lcdm_nu0.2_transfer_z15.584.dat 15.584 38 | lcdm_nu0.2_transfer_z16.970.dat 16.970 39 | lcdm_nu0.2_transfer_z18.471.dat 18.471 40 | lcdm_nu0.2_transfer_z20.098.dat 20.098 41 | lcdm_nu0.2_transfer_z21.861.dat 21.861 42 | lcdm_nu0.2_transfer_z23.771.dat 23.771 43 | lcdm_nu0.2_transfer_z25.840.dat 25.840 44 | lcdm_nu0.2_transfer_z28.082.dat 28.082 45 | lcdm_nu0.2_transfer_z30.512.dat 30.512 46 | lcdm_nu0.2_transfer_z33.145.dat 33.145 47 | lcdm_nu0.2_transfer_z35.998.dat 35.998 48 | lcdm_nu0.2_transfer_z39.089.dat 39.089 49 | lcdm_nu0.2_transfer_z42.438.dat 42.438 50 | lcdm_nu0.2_transfer_z46.068.dat 46.068 51 | lcdm_nu0.2_transfer_z50.000.dat 50.000 -------------------------------------------------------------------------------- /FML/MPIParticles/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Log allocations in the library 21 | USE_MEMORYLOG = false 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | # Print more info as the code runs and do some more checks 25 | USE_DEBUG = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | #=================================================== 35 | # Compile up all library defines from options above 36 | #=================================================== 37 | 38 | INC = -I$(FML_INCLUDE) 39 | LIB = 40 | LINK = 41 | OPTIONS = 42 | 43 | ifeq ($(USE_DEBUG),true) 44 | OPTIONS += -DDEBUG_MPIPARTICLES 45 | endif 46 | 47 | ifeq ($(USE_MPI),true) 48 | CC = $(MPICC) 49 | OPTIONS += -DUSE_MPI 50 | endif 51 | 52 | ifeq ($(USE_OMP),true) 53 | OPTIONS += -DUSE_OMP 54 | CC += -fopenmp 55 | endif 56 | 57 | ifeq ($(USE_SANITIZER),true) 58 | CC += -fsanitize=address 59 | endif 60 | 61 | ifeq ($(USE_MEMORYLOG),true) 62 | OPTIONS += -DMEMORY_LOGGING 63 | endif 64 | 65 | #=================================================== 66 | # Object files to be compiled 67 | #=================================================== 68 | 69 | VPATH := $(FML_INCLUDE)/FML/Global/ 70 | OBJS = Main.o Global.o 71 | 72 | TARGETS := mpiparticles 73 | all: $(TARGETS) 74 | .PHONY: all clean 75 | 76 | clean: 77 | rm -rf $(TARGETS) *.o 78 | 79 | mpiparticles: $(OBJS) 80 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 81 | 82 | %.o: %.cpp 83 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 84 | 85 | -------------------------------------------------------------------------------- /FML/FriendsOfFriends/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Log allocations in the library 21 | USE_MEMORYLOG = false 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | # Print more info as the code runs and do some more checks 25 | USE_DEBUG = true 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | #=================================================== 35 | # Compile up all library defines from options above 36 | #=================================================== 37 | 38 | INC = -I$(FML_INCLUDE) 39 | LIB = 40 | LINK = 41 | OPTIONS = 42 | 43 | ifeq ($(USE_DEBUG),true) 44 | OPTIONS += -DDEBUG_FOF 45 | endif 46 | 47 | ifeq ($(USE_MPI),true) 48 | CC = $(MPICC) 49 | OPTIONS += -DUSE_MPI 50 | endif 51 | 52 | ifeq ($(USE_OMP),true) 53 | OPTIONS += -DUSE_OMP 54 | CC += -fopenmp 55 | endif 56 | 57 | ifeq ($(USE_SANITIZER),true) 58 | CC += -fsanitize=address 59 | endif 60 | 61 | ifeq ($(USE_MEMORYLOG),true) 62 | OPTIONS += -DMEMORY_LOGGING 63 | endif 64 | 65 | #=================================================== 66 | # Object files to be compiled 67 | #=================================================== 68 | 69 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FileUtils/ 70 | OBJS = Main.o Global.o FileUtils.o 71 | 72 | TARGETS := fof 73 | all: $(TARGETS) 74 | .PHONY: all clean 75 | 76 | clean: 77 | rm -rf $(TARGETS) *.o 78 | 79 | fof: $(OBJS) 80 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 81 | 82 | %.o: %.cpp 83 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 84 | 85 | -------------------------------------------------------------------------------- /FML/ODESolver/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (2015) (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_DEBUG),true) 47 | OPTIONS += 48 | endif 49 | 50 | ifeq ($(USE_MPI),true) 51 | CC = $(MPICC) 52 | OPTIONS += -DUSE_MPI 53 | endif 54 | 55 | ifeq ($(USE_OMP),true) 56 | OPTIONS += -DUSE_OMP 57 | CC += -fopenmp 58 | endif 59 | 60 | ifeq ($(USE_SANITIZER),true) 61 | CC += -fsanitize=address 62 | endif 63 | 64 | ifeq ($(USE_GSL),true) 65 | OPTIONS += -DUSE_GSL 66 | INC += -I$(GSL_INCLUDE) 67 | LIB += -L$(GSL_LIB) 68 | LINK += $(GSL_LINK) 69 | endif 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/ODESolver/ 72 | OBJS = Main.o ODESolver.o Global.o 73 | 74 | TARGETS := odesolver 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | odesolver: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/Cosmology/BackgroundCosmology/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | 11 | #=================================================== 12 | # Options 13 | #=================================================== 14 | 15 | # Use OpenMP threads 16 | USE_OMP = true 17 | # Use the GSL library (Spline, ODESolver) Required here! 18 | USE_GSL = true 19 | # Check for bad memory accesses 20 | USE_SANITIZER = false 21 | 22 | #=================================================== 23 | # Include and library paths 24 | #=================================================== 25 | 26 | # Main library include (path to folder containin FML/) 27 | FML_INCLUDE = $(HOME)/local/FML 28 | 29 | # GSL 30 | GSL_INCLUDE = $(HOME)/local/include 31 | GSL_LIB = $(HOME)/local/lib 32 | GSL_LINK = -lgsl -lgslcblas 33 | 34 | #=================================================== 35 | # Compile up all library defines from options above 36 | #=================================================== 37 | 38 | INC = -I$(FML_INCLUDE) 39 | LIB = 40 | LINK = 41 | OPTIONS = 42 | 43 | ifeq ($(USE_OMP),true) 44 | OPTIONS += -DUSE_OMP 45 | CC += -fopenmp 46 | endif 47 | 48 | ifeq ($(USE_GSL),true) 49 | OPTIONS += -DUSE_GSL 50 | INC += -I$(GSL_INCLUDE) 51 | LIB += -L$(GSL_LIB) 52 | LINK += $(GSL_LINK) 53 | endif 54 | 55 | ifeq ($(USE_SANITIZER),true) 56 | CC += -fsanitize=address 57 | endif 58 | 59 | TARGETS := cosmo 60 | all: $(TARGETS) 61 | .PHONY: all clean 62 | 63 | #=================================================== 64 | # Object files to be compiled 65 | #=================================================== 66 | 67 | VPATH := ../:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/ParameterMap/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Global/ 68 | OBJS = Main.o BackgroundCosmology.o Spline.o ODESolver.o ParameterMap.o Math.o Global.o 69 | 70 | clean: 71 | rm -rf $(TARGETS) *.o 72 | 73 | cosmo: $(OBJS) 74 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 75 | 76 | %.o: %.cpp 77 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 78 | -------------------------------------------------------------------------------- /FML/LuaFileParser/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use LUA (LuaFileParser) 21 | USE_LUA = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # LUA : only needed if USE_LUA = true 33 | LUA_INCLUDE = $(HOME)/local/include 34 | LUA_LIB = $(HOME)/local/lib 35 | LUA_LINK = -llua -ldl 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_MPI),true) 47 | CC = $(MPICC) 48 | OPTIONS += -DUSE_MPI 49 | endif 50 | 51 | ifeq ($(USE_OMP),true) 52 | OPTIONS += -DUSE_OMP 53 | CC += -fopenmp 54 | endif 55 | 56 | ifeq ($(USE_SANITIZER),true) 57 | CC += -fsanitize=address 58 | endif 59 | 60 | ifeq ($(USE_LUA),true) 61 | OPTIONS += -DUSE_LUA 62 | INC += -I$(LUA_INCLUDE) 63 | LIB += -L$(LUA_LIB) 64 | LINK += $(LUA_LINK) 65 | endif 66 | 67 | #=================================================== 68 | # Object files to be compiled 69 | #=================================================== 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Global/ 72 | OBJS = Main.o Global.o 73 | 74 | TARGETS := lua 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | lua: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/FFTLog/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using DVector = FML::SOLVERS::FFTLog::DVector; 5 | 6 | DVector generate_pofk(DVector & k) { 7 | 8 | //===================================================== 9 | // Generate something that looks like the 10 | // matter power-spectrum with a something to give 11 | // a very sharp BAO peak as a test function to transform 12 | //===================================================== 13 | 14 | // Fitting formula for the transfer function 15 | auto bbks_fit = [&](double k) -> double { 16 | const double keq = 0.01; 17 | const double arg = k / keq; 18 | double T = log(1.0 + 0.171 * arg) / (0.171 * arg) * 19 | pow(1 + 0.284 * arg + pow(1.18 * arg, 2) + pow(0.399 * arg, 3) + pow(0.490 * arg, 4), -0.25); 20 | T *= (1.0 + 0.01 * sin(k * 100.)); 21 | return T; 22 | }; 23 | 24 | // Some thing that looks like the power-spectrum 25 | auto pk_func = [&](double k) -> double { 26 | double T = bbks_fit(k); 27 | const double ns = 0.96; 28 | return 1e6 * k * T * T * pow(k / 0.05, ns - 1); 29 | }; 30 | 31 | // Fill the vector with P(k) 32 | DVector pk(k); 33 | for (auto & x : pk) 34 | x = pk_func(x); 35 | 36 | return pk; 37 | } 38 | 39 | int main() { 40 | 41 | //===================================================== 42 | // Example on how to use FFTLog to compute 43 | // the correlation function from a power-spectrum 44 | // The other way around is completely analogous 45 | //===================================================== 46 | 47 | // Generate a k-array 48 | const double kmin = 1e-5; 49 | const double kmax = 1e3; 50 | const int npts = 4096; 51 | DVector k_array(npts); 52 | for (size_t i = 0; i < npts; i++) 53 | k_array[i] = exp(log(kmin) + (log(kmax / kmin) * i / double(npts))); 54 | 55 | // Generate a power-spectrum array 56 | DVector pk_array = generate_pofk(k_array); 57 | 58 | // Call FFTLog 59 | auto res = FML::SOLVERS::FFTLog::ComputeCorrelationFunction(k_array, pk_array); 60 | 61 | // Output correlation function 62 | auto r = res.first; 63 | auto xi = res.second; 64 | for (size_t i = 0; i < r.size(); i++) 65 | std::cout << r[i] << " " << xi[i] << "\n"; 66 | } 67 | -------------------------------------------------------------------------------- /FML/Smoothing/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | template 5 | using FFTWGrid = FML::GRID::FFTWGrid; 6 | 7 | //================================================ 8 | // Perform a convolution of two grids and check that 9 | // it agrees with the analytical result 10 | //================================================ 11 | 12 | // Dimension of the grid 13 | const int Ndim = 3; 14 | 15 | int main() { 16 | 17 | // Make a grid 18 | const int Nmesh = 128; 19 | FFTWGrid grid(Nmesh); 20 | 21 | // Set the grid equal to Product_i sin(2pi x_i) 22 | for(auto & real_index : grid.get_real_range()){ 23 | auto coord = grid.get_coord_from_index(real_index); 24 | auto pos = grid.get_real_position(coord); 25 | 26 | auto value = 1.0; 27 | for(int idim = 0; idim < Ndim; idim++) 28 | value *= std::sin(2.0*M_PI*pos[idim]); 29 | 30 | grid.set_real_from_index(real_index, value); 31 | } 32 | 33 | // Perform a convolution of the grid with itself 34 | FFTWGrid result(Nmesh); 35 | FML::GRID::convolution_real_space(grid, grid, result); 36 | 37 | // Check that it gives the expected result Product_i -0.5 cos(2pi xi) 38 | double max_error = 0.0; 39 | for(auto & real_index : result.get_real_range()){ 40 | auto coord = result.get_coord_from_index(real_index); 41 | auto pos = result.get_real_position(coord); 42 | 43 | auto expected = 1.0; 44 | for(int idim = 0; idim < Ndim; idim++) 45 | expected *= -0.5* std::cos(2.0*M_PI*pos[idim]); 46 | 47 | auto value = result.get_real_from_index(real_index); 48 | 49 | // Check that error is < 1e-10 (assumes we are using double) 50 | auto error = std::abs(value - expected); 51 | if(error > max_error) max_error = error; 52 | assert(std::fabs(value - expected) < 1e-10); 53 | } 54 | 55 | FML::GRID::whitening_fourier_space(grid); 56 | 57 | // Output maximum error (if the test passed) 58 | FML::MaxOverTasks(&max_error); 59 | if(FML::ThisTask == 0) 60 | std::cout << "Convolution in real space test passed. Maximum error: " << max_error <<"\n"; 61 | 62 | // Create a PDF of the grid 63 | int nbins = 50; 64 | std::vector x, pdf; 65 | FML::GRID::compute_grid_PDF(result, nbins, x, pdf); 66 | for(int i = 0; i < nbins; i++) 67 | std::cout << x[i] << " " << pdf[i] << "\n"; 68 | } 69 | -------------------------------------------------------------------------------- /FML/Spline/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_MPI),true) 47 | CC = $(MPICC) 48 | OPTIONS += -DUSE_MPI 49 | endif 50 | 51 | ifeq ($(USE_OMP),true) 52 | OPTIONS += -DUSE_OMP 53 | CC += -fopenmp 54 | endif 55 | 56 | ifeq ($(USE_SANITIZER),true) 57 | CC += -fsanitize=address 58 | endif 59 | 60 | ifeq ($(USE_GSL),true) 61 | OPTIONS += -DUSE_GSL 62 | INC += -I$(GSL_INCLUDE) 63 | LIB += -L$(GSL_LIB) 64 | LINK += $(GSL_LINK) 65 | endif 66 | 67 | #=================================================== 68 | # Object files to be compiled 69 | #=================================================== 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/Global/ 72 | OBJS = Main.o Spline.o Global.o 73 | 74 | TARGETS := spline 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | spline: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/LuaFileParser/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | 8 | //=============================================================== 9 | // Example of how to read a Lua script 10 | //=============================================================== 11 | 12 | std::string filename = "input.lua"; 13 | FML::FILEUTILS::LuaFileParser lfp(filename); 14 | 15 | //=============================================================== 16 | // Read the parameters in the file. If optional and not found the value is set to the fiducial value 17 | // To throw and error if we don't find it use lfp.required (true) instead of optional (false) 18 | //=============================================================== 19 | auto AString = lfp.read_string("AString", "Fiducial value", lfp.optional); 20 | auto ADouble = lfp.read_double("ADouble", 0.0, lfp.optional); 21 | auto ABool = lfp.read_bool("ABool", false, lfp.optional); 22 | auto ANewDouble = lfp.read_double("ANewDouble", 0.0, lfp.optional); 23 | auto AStringArray = lfp.read_string_array("AStringArray", {}, lfp.optional); 24 | auto ADoubleArray = lfp.read_number_array("ADoubleArray", {}, lfp.optional); 25 | 26 | //=============================================================== 27 | // Output what we have read 28 | //=============================================================== 29 | std::cout << "AString: " << AString << "\n"; 30 | std::cout << "ADouble: " << ADouble << "\n"; 31 | std::cout << "ABool: " << ABool << "\n"; 32 | std::cout << "ANewDouble: " << ANewDouble << "\n"; 33 | std::cout << "ADoubleArray: "; 34 | for (auto & x : ADoubleArray) 35 | std::cout << x << " , "; 36 | std::cout << "\n"; 37 | std::cout << "AStringArray: "; 38 | for (auto & x : AStringArray) 39 | std::cout << x << " , "; 40 | std::cout << "\n"; 41 | 42 | //=============================================================== 43 | // For how errors are handled 44 | //=============================================================== 45 | try { 46 | auto NonExistent = lfp.read_number_array("NonExistent", {}, lfp.required); 47 | } catch (std::runtime_error & e) { 48 | std::cout << "Error in reading: " << e.what(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FML/Cosmology/RecombinationHistory/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | 11 | #=================================================== 12 | # Options 13 | #=================================================== 14 | 15 | # Use OpenMP threads 16 | USE_OMP = true 17 | # Use the GSL library (Spline, ODESolver) Required here! 18 | USE_GSL = true 19 | # Check for bad memory accesses 20 | USE_SANITIZER = false 21 | 22 | #=================================================== 23 | # Include and library paths 24 | #=================================================== 25 | 26 | # Main library include (path to folder containin FML/) 27 | FML_INCLUDE = $(HOME)/local/FML 28 | 29 | # GSL 30 | GSL_INCLUDE = $(HOME)/local/include 31 | GSL_LIB = $(HOME)/local/lib 32 | GSL_LINK = -lgsl -lgslcblas 33 | 34 | #=================================================== 35 | # Compile up all library defines from options above 36 | #=================================================== 37 | 38 | INC = -I$(FML_INCLUDE) 39 | LIB = 40 | LINK = 41 | OPTIONS = 42 | 43 | ifeq ($(USE_OMP),true) 44 | OPTIONS += -DUSE_OMP 45 | CC += -fopenmp 46 | endif 47 | 48 | ifeq ($(USE_GSL),true) 49 | OPTIONS += -DUSE_GSL 50 | INC += -I$(GSL_INCLUDE) 51 | LIB += -L$(GSL_LIB) 52 | LINK += $(GSL_LINK) 53 | endif 54 | 55 | ifeq ($(USE_SANITIZER),true) 56 | CC += -fsanitize=address 57 | endif 58 | 59 | TARGETS := rec 60 | all: $(TARGETS) 61 | .PHONY: all clean 62 | 63 | #=================================================== 64 | # Object files to be compiled 65 | #=================================================== 66 | 67 | VPATH := $(FML_INCLUDE)/FML/Cosmology/RecombinationHistory/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/ParameterMap/:$(FML_INCLUDE)/FML/Cosmology/BackgroundCosmology/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Global/ 68 | OBJS = Main.o BackgroundCosmology.o Spline.o ODESolver.o ParameterMap.o RecombinationHistory.o Math.o Global.o 69 | 70 | clean: 71 | rm -rf $(TARGETS) *.o 72 | 73 | rec: $(OBJS) 74 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 75 | 76 | %.o: %.cpp 77 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 78 | -------------------------------------------------------------------------------- /FML/COLASolver/src/Cosmology_LCDM.h: -------------------------------------------------------------------------------- 1 | #ifndef COSMOLOGY_LCDM_HEADER 2 | #define COSMOLOGY_LCDM_HEADER 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Cosmology.h" 13 | 14 | class CosmologyLCDM final : public Cosmology { 15 | public: 16 | CosmologyLCDM() { name = "LCDM"; } 17 | 18 | double HoverH0_of_a(double a) const override { 19 | return std::sqrt(OmegaLambda + OmegaK / (a * a) + (OmegaCDM + Omegab) / (a * a * a) + OmegaR / (a * a * a * a) + 20 | this->get_rhoNu_exact(a)); 21 | } 22 | 23 | double dlogHdloga_of_a(double a) const override { 24 | double E = HoverH0_of_a(a); 25 | return 1.0 / (2.0 * E * E) * 26 | (-2.0 * OmegaK / (a * a) - 3.0 * (OmegaCDM + Omegab) / (a * a * a) - 4.0 * OmegaR / (a * a * a * a) + 27 | this->get_drhoNudloga_exact(a)); 28 | } 29 | 30 | void info() const override { 31 | Cosmology::info(); 32 | if (FML::ThisTask == 0) { 33 | std::cout << "#=====================================================\n"; 34 | std::cout << "\n"; 35 | } 36 | } 37 | 38 | //======================================================================== 39 | // This method returns an estimate for the non-linear Pnl/Plinea 40 | // The fiducial option is to use the EuclidEmulator2 41 | //======================================================================== 42 | Spline get_nonlinear_matter_power_spectrum_boost(double redshift) const override { 43 | Spline ee2_boost_of_k{"P/Plinear from EuclidEmulator2 uninitialized"}; 44 | try { 45 | FML::EMULATOR::EUCLIDEMULATOR2::Cosmology ee2cosmo(Omegab, OmegaM, Mnu_eV, ns, h, -1.0, 0.0, As); 46 | if (ee2cosmo.is_good_to_use()) { 47 | FML::EMULATOR::EUCLIDEMULATOR2::EuclidEmulator ee2(ee2cosmo); 48 | auto result = ee2.compute_boost(redshift); 49 | ee2_boost_of_k = Spline(result.first, result.second, "P/Plinear from EuclidEmulator2"); 50 | } 51 | } catch(...) { 52 | ee2_boost_of_k = Spline(); 53 | } 54 | return ee2_boost_of_k; 55 | } 56 | 57 | protected: 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /FML/Math/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_MPI),true) 47 | CC = $(MPICC) 48 | OPTIONS += -DUSE_MPI 49 | endif 50 | 51 | ifeq ($(USE_OMP),true) 52 | OPTIONS += -DUSE_OMP 53 | CC += -fopenmp 54 | endif 55 | 56 | ifeq ($(USE_SANITIZER),true) 57 | CC += -fsanitize=address 58 | endif 59 | 60 | ifeq ($(USE_GSL),true) 61 | OPTIONS += -DUSE_GSL 62 | INC += -I$(GSL_INCLUDE) 63 | LIB += -L$(GSL_LIB) 64 | LINK += $(GSL_LINK) 65 | endif 66 | 67 | #=================================================== 68 | # Object files to be compiled 69 | #=================================================== 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/Global/ 72 | OBJS = Main.o Math.o Spline.o ODESolver.o Global.o 73 | 74 | TARGETS := math 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | math: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/SphericalCollapse/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (2015) (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_DEBUG),true) 47 | OPTIONS += 48 | endif 49 | 50 | ifeq ($(USE_MPI),true) 51 | CC = $(MPICC) 52 | OPTIONS += -DUSE_MPI 53 | endif 54 | 55 | ifeq ($(USE_OMP),true) 56 | OPTIONS += -DUSE_OMP 57 | CC += -fopenmp 58 | endif 59 | 60 | ifeq ($(USE_SANITIZER),true) 61 | CC += -fsanitize=address 62 | endif 63 | 64 | ifeq ($(USE_GSL),true) 65 | OPTIONS += -DUSE_GSL 66 | INC += -I$(GSL_INCLUDE) 67 | LIB += -L$(GSL_LIB) 68 | LINK += $(GSL_LINK) 69 | endif 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/SphericalCollapse/ 72 | OBJS = Main.o Global.o Math.o Spline.o ODESolver.o SphericalCollapse.o SphericalCollapseModel.o 73 | 74 | TARGETS := sphericalcollapse 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | sphericalcollapse: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/Cosmology/LinearPerturbations/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | 11 | #=================================================== 12 | # Options 13 | #=================================================== 14 | 15 | # Use OpenMP threads 16 | USE_OMP = true 17 | # Use the GSL library (Spline, ODESolver) Required here! 18 | USE_GSL = true 19 | # Check for bad memory accesses 20 | USE_SANITIZER = false 21 | 22 | #=================================================== 23 | # Include and library paths 24 | #=================================================== 25 | 26 | # Main library include (path to folder containin FML/) 27 | FML_INCLUDE = $(HOME)/local/FML 28 | 29 | # GSL 30 | GSL_INCLUDE = $(HOME)/local/include 31 | GSL_LIB = $(HOME)/local/lib 32 | GSL_LINK = -lgsl -lgslcblas 33 | 34 | #=================================================== 35 | # Compile up all library defines from options above 36 | #=================================================== 37 | 38 | INC = -I$(FML_INCLUDE) 39 | LIB = 40 | LINK = 41 | OPTIONS = 42 | 43 | ifeq ($(USE_OMP),true) 44 | OPTIONS += -DUSE_OMP 45 | CC += -fopenmp 46 | endif 47 | 48 | ifeq ($(USE_GSL),true) 49 | OPTIONS += -DUSE_GSL 50 | INC += -I$(GSL_INCLUDE) 51 | LIB += -L$(GSL_LIB) 52 | LINK += $(GSL_LINK) 53 | endif 54 | 55 | ifeq ($(USE_SANITIZER),true) 56 | CC += -fsanitize=address 57 | endif 58 | 59 | TARGETS := pert 60 | all: $(TARGETS) 61 | .PHONY: all clean 62 | 63 | #=================================================== 64 | # Object files to be compiled 65 | #=================================================== 66 | 67 | VPATH := $(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/ParameterMap/:$(FML_INCLUDE)/FML/Cosmology/BackgroundCosmology/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Cosmology/LinearPerturbations/:$(FML_INCLUDE)/FML/Cosmology/RecombinationHistory/:$(FML_INCLUDE)/FML/Global/ 68 | OBJS = Main.o BackgroundCosmology.o Spline.o ODESolver.o ParameterMap.o RecombinationHistory.o Math.o Perturbations.o Global.o 69 | 70 | clean: 71 | rm -rf $(TARGETS) *.o 72 | 73 | pert: $(OBJS) 74 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 75 | 76 | %.o: %.cpp 77 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 78 | -------------------------------------------------------------------------------- /FML/RandomGenerator/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = 45 | 46 | ifeq ($(USE_MPI),true) 47 | CC = $(MPICC) 48 | OPTIONS += -DUSE_MPI 49 | endif 50 | 51 | ifeq ($(USE_OMP),true) 52 | OPTIONS += -DUSE_OMP 53 | CC += -fopenmp 54 | endif 55 | 56 | ifeq ($(USE_SANITIZER),true) 57 | CC += -fsanitize=address 58 | endif 59 | 60 | ifeq ($(USE_MEMORYLOG),true) 61 | OPTIONS += -DMEMORY_LOGGING 62 | endif 63 | 64 | ifeq ($(USE_GSL),true) 65 | OPTIONS += -DUSE_GSL 66 | INC += -I$(GSL_INCLUDE) 67 | LIB += -L$(GSL_LIB) 68 | LINK += $(GSL_LINK) 69 | endif 70 | 71 | #=================================================== 72 | # Object files to be compiled 73 | #=================================================== 74 | 75 | # Add path to all the directories with .cpp files in FML to be compiled here 76 | VPATH := $(FML_INCLUDE)/FML/Global/ 77 | 78 | OBJS = Main.o 79 | 80 | TARGETS := random 81 | all: $(TARGETS) 82 | .PHONY: all clean 83 | 84 | clean: 85 | rm -rf $(TARGETS) *.o 86 | 87 | random: $(OBJS) 88 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 89 | 90 | %.o: %.cpp 91 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 92 | 93 | -------------------------------------------------------------------------------- /FML/HaloModel/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (2015) (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | 25 | #=================================================== 26 | # Include and library paths 27 | #=================================================== 28 | 29 | # Main library include (path to folder containin FML/) 30 | FML_INCLUDE = $(HOME)/local/FML 31 | 32 | # GSL : only needed if USE_GSL = true 33 | GSL_INCLUDE = $(HOME)/local/include 34 | GSL_LIB = $(HOME)/local/lib 35 | GSL_LINK = -lgsl -lgslcblas 36 | 37 | #=================================================== 38 | # Compile up all library defines from options above 39 | #=================================================== 40 | 41 | INC = -I$(FML_INCLUDE) 42 | LIB = 43 | LINK = 44 | OPTIONS = -DHMCODETESTING 45 | 46 | ifeq ($(USE_DEBUG),true) 47 | OPTIONS += 48 | endif 49 | 50 | ifeq ($(USE_MPI),true) 51 | CC = $(MPICC) 52 | OPTIONS += -DUSE_MPI 53 | endif 54 | 55 | ifeq ($(USE_OMP),true) 56 | OPTIONS += -DUSE_OMP 57 | CC += -fopenmp 58 | endif 59 | 60 | ifeq ($(USE_SANITIZER),true) 61 | CC += -fsanitize=address 62 | endif 63 | 64 | ifeq ($(USE_GSL),true) 65 | OPTIONS += -DUSE_GSL 66 | INC += -I$(GSL_INCLUDE) 67 | LIB += -L$(GSL_LIB) 68 | LINK += $(GSL_LINK) 69 | endif 70 | 71 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/HaloModel/:$(FML_INCLUDE)/FML/SphericalCollapse/: $(FML_INCLUDE)/FML/FileUtils 72 | OBJS = Main.o Global.o Math.o Spline.o ODESolver.o SphericalCollapse.o SphericalCollapseModel.o Halomodel.o FileUtils.o 73 | 74 | TARGETS := halomodel 75 | all: $(TARGETS) 76 | .PHONY: all clean 77 | 78 | clean: 79 | rm -rf $(TARGETS) *.o 80 | 81 | halomodel: $(OBJS) 82 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 83 | 84 | %.o: %.cpp 85 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 86 | 87 | -------------------------------------------------------------------------------- /FML/HaloModel/PythonWrapper/example.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from HaloModelWrapper import HaloModel 3 | import matplotlib.pyplot as plt 4 | import time 5 | import gc 6 | 7 | # Parameters 8 | filename = "pofk_lin.txt" 9 | OmegaM = 0.3 10 | w0 = -1.0 11 | wa = 0.0 12 | mu0 = 0.0 13 | mua = 0.0 14 | deltacfac = 1.0 15 | DeltaVirfac = 1.0 16 | cofmfac = 1.0 17 | sigma8norm = True 18 | hmcode = True 19 | verbose = True 20 | 21 | # Set up halomodel 22 | model = HaloModel( 23 | filename, 24 | OmegaM, 25 | w0, 26 | wa, 27 | mu0, 28 | mua, 29 | verbose, 30 | hmcode, 31 | sigma8norm, 32 | deltacfac, 33 | DeltaVirfac, 34 | cofmfac) 35 | 36 | model2 = HaloModel( 37 | filename, 38 | OmegaM, 39 | w0, 40 | wa, 41 | mu0, 42 | mua, 43 | verbose, 44 | False, 45 | sigma8norm, 46 | deltacfac, 47 | DeltaVirfac, 48 | cofmfac) 49 | 50 | # Arrays to evaluate pofk and massfunction at 51 | k = np.exp(np.linspace(np.log(1e-4),np.log(10.0),100)) 52 | M = np.exp(np.linspace(np.log(1e6),np.log(1e16),100)) 53 | zarr = np.linspace(0.0,4.0,100) 54 | 55 | # Set redshift to compute at 56 | z = 0.0 57 | 58 | # Compute everything at redshift 59 | model.calc_at_redshift(z) 60 | model.info() 61 | 62 | # Fetch P(k,z), Plin(k,z), dndlogM(M) and n(M) at given redshift 63 | # (Since we just computed at z this just fetches the data) 64 | pofk_lin, pofk = model.get_pofk(z, k) 65 | pofk_1h, pofk_2h = model.get_pofk_1h_2h(z, k) 66 | dndlogM, nofM = model.get_nofM(z, M) 67 | deltac = model.get_deltac_of_z(zarr) 68 | 69 | # Model without HMCode 70 | deltac2 = model2.get_deltac_of_z(zarr) 71 | pofk_lin2, pofk2 = model2.get_pofk(z, k) 72 | pofk2_1h, pofk2_2h = model2.get_pofk_1h_2h(z, k) 73 | dndlogM2, nofM2 = model2.get_nofM(z, M) 74 | 75 | # Plot deltac 76 | plt.plot(zarr,deltac) 77 | plt.plot(zarr,deltac2) 78 | plt.show() 79 | 80 | # Make a plot of massfunction 81 | plt.xscale('log') 82 | plt.yscale('log') 83 | plt.plot(M,dndlogM) 84 | plt.plot(M,dndlogM2) 85 | plt.show() 86 | 87 | # Make a plot of power-spectra 88 | plt.xscale('log') 89 | plt.yscale('log') 90 | plt.plot(k,pofk,label="HMCode") 91 | plt.plot(k,pofk_1h,label="HMCode 1h") 92 | plt.plot(k,pofk_2h,label="HMCode 2h") 93 | plt.plot(k,pofk_lin,label="Linear") 94 | plt.plot(k,pofk2,label="Non HMCode",ls="dashed") 95 | plt.plot(k,pofk2_1h,label="Non HMCode 1h",ls="dashed") 96 | plt.plot(k,pofk2_2h,label="Non HMCode 2h",ls="dashed") 97 | plt.legend() 98 | plt.show() 99 | 100 | -------------------------------------------------------------------------------- /FML/HaloModel/PythonWrapper/HaloModelWrapper.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import HaloModelCXX as hm 3 | import matplotlib.pyplot as plt 4 | 5 | """ 6 | Input: linear power-spectrum at z=0 7 | Run the halomodel and get the power-spectra 8 | P1h, P2h and P(k,z), halo-massfunctions etc. 9 | """ 10 | class HaloModel: 11 | def __init__(self, 12 | filename_pofk_lin, 13 | OmegaM, 14 | w0=-1.0, 15 | wa=0.0, 16 | mu0=0.0, 17 | mua=0.0, 18 | verbose=False, 19 | hmcode=True, 20 | sigma8norm=True, 21 | deltacfac=1.0, 22 | DeltaVirfac=1.0, 23 | cofmfac=1.0): 24 | self.filename_pofk_lin = filename_pofk_lin 25 | self.OmegaM = OmegaM 26 | self.w0 = w0 27 | self.wa = wa 28 | self.mu0 = mu0 29 | self.mua = mua 30 | self.verbose = verbose 31 | self.hmcode = bool(hmcode) 32 | self.sigma8norm = bool(sigma8norm) 33 | self.deltacfac = deltacfac 34 | self.DeltaVirfac = DeltaVirfac 35 | self.cofmfac = cofmfac 36 | self.is_init = False 37 | self.init() 38 | 39 | def init(self): 40 | if(self.is_init): 41 | return 42 | self.halomodel = hm.get() 43 | hm.init(self.halomodel, 44 | self.filename_pofk_lin, 45 | self.OmegaM, 46 | self.w0, 47 | self.wa, 48 | self.mu0, 49 | self.mua, 50 | self.verbose, 51 | self.hmcode, 52 | self.sigma8norm, 53 | self.deltacfac, 54 | self.DeltaVirfac, 55 | self.cofmfac) 56 | self.is_init = True 57 | 58 | def info(self): 59 | hm.info(self.halomodel) 60 | 61 | def calc_at_redshift(self,z): 62 | hm.calc(self.halomodel,z) 63 | 64 | def get_pofk(self, z, k): 65 | self.init() 66 | self.calc_at_redshift(z) 67 | pofk_lin = np.zeros_like(k) 68 | pofk = np.zeros_like(k) 69 | hm.get_pofk(self.halomodel, k, pofk_lin, pofk) 70 | return pofk_lin, pofk 71 | 72 | def get_pofk_1h_2h(self, z, k): 73 | self.init() 74 | self.calc_at_redshift(z) 75 | pofk_1h = np.zeros_like(k) 76 | pofk_2h = np.zeros_like(k) 77 | hm.get_pofk_1h_2h(self.halomodel, k, pofk_1h, pofk_2h) 78 | return pofk_1h, pofk_2h 79 | 80 | def get_nofM(self, z, M): 81 | self.init() 82 | self.calc_at_redshift(z) 83 | dndlogM = np.zeros_like(M) 84 | n = np.zeros_like(M) 85 | hm.get_nofM(self.halomodel, M, dndlogM, n) 86 | return dndlogM, n 87 | 88 | def get_deltac_of_z(self, z): 89 | self.init() 90 | deltac = np.zeros_like(z) 91 | hm.get_deltac(self.halomodel, z, deltac) 92 | return deltac 93 | 94 | def __del__(self): 95 | hm.free(self.halomodel) 96 | -------------------------------------------------------------------------------- /FML/Survey/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Use LUA (LuaFileParser) 23 | USE_LUA = false 24 | # Check for bad memory accesses 25 | USE_SANITIZER = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | # GSL : only needed if USE_GSL = true 35 | GSL_INCLUDE = $(HOME)/local/include 36 | GSL_LIB = $(HOME)/local/lib 37 | GSL_LINK = -lgsl -lgslcblas 38 | 39 | #=================================================== 40 | # Compile up all library defines from options above 41 | #=================================================== 42 | 43 | INC = -I$(FML_INCLUDE) 44 | LIB = 45 | LINK = 46 | OPTIONS = 47 | 48 | ifeq ($(USE_MPI),true) 49 | CC = $(MPICC) 50 | OPTIONS += -DUSE_MPI 51 | endif 52 | 53 | ifeq ($(USE_OMP),true) 54 | OPTIONS += -DUSE_OMP 55 | CC += -fopenmp 56 | endif 57 | 58 | ifeq ($(USE_SANITIZER),true) 59 | CC += -fsanitize=address 60 | endif 61 | 62 | ifeq ($(USE_MEMORYLOG),true) 63 | OPTIONS += -DMEMORY_LOGGING 64 | endif 65 | 66 | ifeq ($(USE_GSL),true) 67 | OPTIONS += -DUSE_GSL 68 | INC += -I$(GSL_INCLUDE) 69 | LIB += -L$(GSL_LIB) 70 | LINK += $(GSL_LINK) 71 | endif 72 | 73 | #=================================================== 74 | # Object files to be compiled 75 | #=================================================== 76 | 77 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/FileUtils/ 78 | OBJS = Main.o Spline.o ODESolver.o FileUtils.o Global.o 79 | 80 | TARGETS := galaxiestobox 81 | all: $(TARGETS) 82 | .PHONY: all clean 83 | 84 | clean: 85 | rm -rf $(TARGETS) *.o 86 | 87 | galaxiestobox: $(OBJS) 88 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 89 | 90 | %.o: %.cpp 91 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 92 | -------------------------------------------------------------------------------- /FML/PairCounting/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Log allocations in the library 23 | USE_MEMORYLOG = false 24 | # Check for bad memory accesses 25 | USE_SANITIZER = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | # GSL : only needed if USE_GSL = true 35 | GSL_INCLUDE = $(HOME)/local/include 36 | GSL_LIB = $(HOME)/local/lib 37 | GSL_LINK = -lgsl -lgslcblas 38 | 39 | #=================================================== 40 | # Compile up all library defines from options above 41 | #=================================================== 42 | 43 | INC = -I$(FML_INCLUDE) 44 | LIB = 45 | LINK = 46 | OPTIONS = 47 | 48 | ifeq ($(USE_MPI),true) 49 | CC = $(MPICC) 50 | OPTIONS += -DUSE_MPI 51 | endif 52 | 53 | ifeq ($(USE_OMP),true) 54 | OPTIONS += -DUSE_OMP 55 | CC += -fopenmp 56 | endif 57 | 58 | ifeq ($(USE_SANITIZER),true) 59 | CC += -fsanitize=address 60 | endif 61 | 62 | ifeq ($(USE_MEMORYLOG),true) 63 | OPTIONS += -DMEMORY_LOGGING 64 | endif 65 | 66 | ifeq ($(USE_GSL),true) 67 | OPTIONS += -DUSE_GSL 68 | INC += -I$(GSL_INCLUDE) 69 | LIB += -L$(GSL_LIB) 70 | LINK += $(GSL_LINK) 71 | endif 72 | 73 | #=================================================== 74 | # Object files to be compiled 75 | #=================================================== 76 | 77 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/FileUtils/ 78 | OBJS = Main.o Spline.o ODESolver.o Global.o FileUtils.o 79 | 80 | TARGETS := paircount 81 | all: $(TARGETS) 82 | .PHONY: all clean 83 | 84 | clean: 85 | rm -rf $(TARGETS) *.o 86 | 87 | paircount: $(OBJS) 88 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 89 | 90 | %.o: %.cpp 91 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 92 | 93 | -------------------------------------------------------------------------------- /FML/Math/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | 7 | //============================================== 8 | // Python linspace 9 | //============================================== 10 | auto xarr = FML::MATH::linspace(0.0, 1.0, 11); 11 | for (auto x : xarr) 12 | std::cout << x << " "; 13 | std::cout << std::endl; 14 | 15 | //============================================== 16 | // Find a root of a function 17 | //============================================== 18 | std::function function = [](double x) -> double { return x * x - x - 1; }; 19 | std::pair range = {1.0, 2.0}; 20 | auto root = FML::MATH::find_root_bisection(function, range); 21 | std::cout << "Root " << root << " = " << (1.0 + std::sqrt(5.0)) / 2.0 << "\n"; 22 | 23 | //============================================== 24 | // Sherical bessel function 25 | //============================================== 26 | int ell = 0; 27 | double x = 1.0; 28 | std::cout << "Sph.Bessel " << FML::MATH::j_ell(ell, x) << " = " << sin(x) / x << "\n"; 29 | 30 | //============================================== 31 | // Legendre polyomials 32 | //============================================== 33 | double mu = 1./3.; 34 | auto Pell = FML::MATH::legendre_ell_of_mu_vector(mu, 2); 35 | std::cout << "Legendre P0(" << mu << ") = " << Pell[0] << " = "<< 1.0 << " )\n"; 36 | std::cout << "Legendre P1(" << mu << ") = " << Pell[1] << " = " << mu << " )\n"; 37 | std::cout << "Legendre P2(" << mu << ") = " << Pell[2] << " = " << (3*mu*mu-1)/2. << " )\n"; 38 | 39 | //============================================== 40 | // Airy function 41 | //============================================== 42 | #ifdef USE_GSL 43 | std::cout << "Airy " << FML::MATH::Airy_Ai(0.0) << " = " << 1.0 / std::pow(3., 2. / 3.) / std::tgamma(2. / 3.) 44 | << "\n"; 45 | #endif 46 | 47 | //============================================== 48 | // Evaluate Continued fraction converging to pi 49 | // (b0 + a1/(b1 + a2 /( ... ))) 50 | //============================================== 51 | std::function a = [](int i) -> double { return (2.0 * i - 1) * (2.0 * i - 1); }; 52 | std::function b = [](int i) -> double { 53 | if (i == 0) 54 | return 3.0; 55 | return 6.0; 56 | }; 57 | const double eps = 1e-6; 58 | const int maxsteps = 100; 59 | auto res = FML::MATH::GeneralizedLentzMethod(a, b, eps, maxsteps); 60 | std::cout << "Pi = " << res.first << " Converged? " << res.second << "\n"; 61 | } 62 | -------------------------------------------------------------------------------- /FML/ParticleTypes/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | template 6 | class TestParticle { 7 | double pos[NDIM]; 8 | double vel[NDIM]; 9 | size_t id = 10; 10 | 11 | //double mass = 2.0; 12 | 13 | public: 14 | 15 | constexpr int get_ndim() const { return NDIM; } 16 | double * get_pos() { return pos; } 17 | double * get_vel() { return vel; } 18 | size_t get_id() const { return id; } 19 | void set_id(size_t _id) { id = _id; } 20 | 21 | // If the mass is not set here then the fiducial value 1 is used by algorithms 22 | //double get_mass() { return mass; } 23 | //void set_mass(double _mass) { mass = _mass; } 24 | }; 25 | 26 | int main() { 27 | using Particle = TestParticle<3>; 28 | 29 | Particle p; 30 | 31 | // Show info about the particle 32 | FML::PARTICLE::info(); 33 | 34 | std::cout << "The dimension of the particle is: " << FML::PARTICLE::GetNDIM(p) << "\n"; 35 | std::cout << "The size of the particle is: " << FML::PARTICLE::GetSize(p) << " bytes\n"; 36 | 37 | // Check if we have get_pos in the class 38 | if constexpr (FML::PARTICLE::has_get_pos()) { 39 | auto pos = FML::PARTICLE::GetPos(p); 40 | std::cout << "Particle class has position x = " << pos[0] << "\n"; 41 | } else { 42 | std::cout << "Particle class do not have position\n"; 43 | } 44 | 45 | // Check if we have get_vel in the class 46 | if constexpr (FML::PARTICLE::has_get_vel()) { 47 | auto vel = FML::PARTICLE::GetVel(p); 48 | std::cout << "Particle class has velocity vx = " << vel[0] << "\n"; 49 | } else { 50 | std::cout << "Particle class do not have velocity\n"; 51 | } 52 | 53 | // Check if we have set_id and get_id in the class 54 | if constexpr (FML::PARTICLE::has_get_id() and FML::PARTICLE::has_set_id()) { 55 | auto id = FML::PARTICLE::GetID(p); 56 | std::cout << "Particle class has id = " << id << "\n"; 57 | } else { 58 | std::cout << "Particle class do not have position\n"; 59 | } 60 | 61 | // Check if we have set_mass and get_mass in the class 62 | if constexpr (FML::PARTICLE::has_get_mass() and FML::PARTICLE::has_set_mass()) { 63 | std::cout << "Particle class has mass\n"; 64 | } else { 65 | std::cout << "Particle class do not have mass\n"; 66 | } 67 | 68 | //... but GetMass exist even if we don't define it (fiducial value = 1.0) 69 | auto mass = FML::PARTICLE::GetMass(p); 70 | std::cout << "Mass of particle: " << mass << "\n"; 71 | } 72 | -------------------------------------------------------------------------------- /FML/Triangulation/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the CGAL library (Triangulation) 21 | USE_CGAL = true 22 | # Check for bad memory accesses 23 | USE_SANITIZER = false 24 | # Print more info as the code runs and do some more checks 25 | USE_DEBUG = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | # CGAL : only needed if USE_CGAL = true 35 | CGAL_INCLUDE = /opt/local/include 36 | CGAL_LIB = /opt/local/lib 37 | CGAL_LINK = -lgmp -lm 38 | 39 | # For older version of CGAL when it was a shared library 40 | # instead of just headerfiles 41 | #CGAL_LINK = -lCGAL -lgmp -lm 42 | 43 | #=================================================== 44 | # Compile up all library defines from options above 45 | #=================================================== 46 | 47 | INC = -I$(FML_INCLUDE) 48 | LIB = 49 | LINK = 50 | OPTIONS = 51 | 52 | ifeq ($(USE_DEBUG),true) 53 | OPTIONS += -DDEBUG_TESSELATION 54 | endif 55 | 56 | ifeq ($(USE_MPI),true) 57 | CC = $(MPICC) 58 | OPTIONS += -DUSE_MPI 59 | endif 60 | 61 | ifeq ($(USE_OMP),true) 62 | OPTIONS += -DUSE_OMP 63 | CC += -fopenmp 64 | endif 65 | 66 | ifeq ($(USE_SANITIZER),true) 67 | CC += -fsanitize=address 68 | endif 69 | 70 | ifeq ($(USE_CGAL),true) 71 | OPTIONS += -DUSE_CGAL 72 | INC += -I$(CGAL_INCLUDE) 73 | LIB += -L$(CGAL_LIB) 74 | LINK += $(CGAL_LINK) 75 | endif 76 | 77 | #=================================================== 78 | # Object files to be compiled 79 | #=================================================== 80 | 81 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FileUtils/ 82 | OBJS = Main.o Global.o FileUtils.o 83 | 84 | TARGETS := voronoi 85 | all: $(TARGETS) 86 | .PHONY: all clean 87 | 88 | clean: 89 | rm -rf $(TARGETS) *.o 90 | 91 | voronoi: $(OBJS) 92 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 93 | 94 | %.o: %.cpp 95 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 96 | -------------------------------------------------------------------------------- /FML/Plotting/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Only needeed if you want plotting with matplotlib from C++ 21 | USE_PYTHON = true 22 | # Use LUA (LuaFileParser) 23 | USE_LUA = false 24 | # Check for bad memory accesses 25 | USE_SANITIZER = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | # Python : only needed if USE_PYTHON = true 35 | PYTHON_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/ 36 | PYTHON_LIB = /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/ 37 | NUMPY_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include 38 | PYTHON_LINK = -lpython2.7 -ldl -framework CoreFoundation 39 | 40 | #=================================================== 41 | # Compile up all library defines from options above 42 | #=================================================== 43 | 44 | INC = -I$(FML_INCLUDE) 45 | LIB = 46 | LINK = 47 | OPTIONS = 48 | 49 | ifeq ($(USE_MPI),true) 50 | CC = $(MPICC) 51 | OPTIONS += -DUSE_MPI 52 | endif 53 | 54 | ifeq ($(USE_OMP),true) 55 | OPTIONS += -DUSE_OMP 56 | CC += -fopenmp 57 | endif 58 | 59 | ifeq ($(USE_SANITIZER),true) 60 | CC += -fsanitize=address 61 | endif 62 | 63 | ifeq ($(USE_PYTHON),true) 64 | OPTIONS += -DWITHOUT_NUMPY 65 | INC += -I$(PYTHON_INCLUDE) 66 | INC += -I$(NUMPY_INCLUDE) 67 | LINK += -L$(PYTHON_LIB) $(PYTHON_LINK) 68 | endif 69 | 70 | #=================================================== 71 | # Object files to be compiled 72 | #=================================================== 73 | 74 | VPATH := $(FML_INCLUDE)/FML/Global/ 75 | OBJS = Main.o Global.o 76 | 77 | TARGETS := matplotlib 78 | all: $(TARGETS) 79 | .PHONY: all clean 80 | 81 | 82 | clean: 83 | rm -rf $(TARGETS) *.o 84 | 85 | matplotlib: $(OBJS) 86 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 87 | 88 | %.o: %.cpp 89 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 90 | -------------------------------------------------------------------------------- /FML/SphericalCollapse/SphericalCollapseModel.cpp: -------------------------------------------------------------------------------- 1 | #include "SphericalCollapseModel.h" 2 | 3 | namespace FML { 4 | namespace COSMOLOGY { 5 | namespace SPHERICALCOLLAPSE { 6 | 7 | //================================================ 8 | // Some some general info about the cosmology 9 | //================================================ 10 | void SphericalCollapseModel::info() const { 11 | std::cout << "\n#=====================================================\n"; 12 | std::cout << "# SphericalCollapseModel model info:\n"; 13 | std::cout << "#=====================================================\n"; 14 | std::cout << "OmegaM : " << OmegaM << "\n"; 15 | auto z_array = FML::MATH::linspace(0.0,5.0,10); 16 | for(auto z : z_array){ 17 | const double x = -std::log(1+z); 18 | std::cout << " z: " << std::setw(10) << z; 19 | std::cout << " E(z): " << std::setw(10) << Eofx(x); 20 | std::cout << " mu(z): " << std::setw(10) << muofx(x); 21 | std::cout << " w(z): " << std::setw(10) << wofx(x) << "\n"; 22 | } 23 | std::cout << "#=====================================================\n"; 24 | } 25 | 26 | //================================================ 27 | // Virial condition. Virialization when this quantity is zero 28 | //================================================ 29 | double SphericalCollapseModel::virial_condition( 30 | double delta, 31 | double delta_prime, 32 | double roverR, 33 | double x) const { 34 | const double E = Eofx(x); 35 | const double mu = muofx(x); 36 | const double OmegaMofx = OmegaM * std::exp(-3.0*x) / (E*E); 37 | const double OmegaLambdaofx = 1.0 - OmegaMofx; 38 | const double w = wofx(x); 39 | const double drdx_over_r = 1.0 - delta_prime / 3.0 / (1.0+delta); 40 | double EpoverM = -3.0/10.0 * std::pow(E * roverR, 2) * ( 41 | OmegaLambdaofx * (1.0 + 3.0*w) + 42 | OmegaMofx * (1.0 + (mu - 1.0) * delta / (1.0+delta)) * (1.0+delta) 43 | ); 44 | double EkoverM = 3.0/10.0 * std::pow(E * roverR, 2) * std::pow(drdx_over_r,2); 45 | return 2.0*EkoverM + EpoverM; 46 | } 47 | 48 | //================================================ 49 | // Define non-linear when this quantity is zero 50 | //================================================ 51 | double SphericalCollapseModel::nonlinear_condition( 52 | double delta, 53 | [[maybe_unused]] double delta_prime, 54 | [[maybe_unused]] double roverR, 55 | [[maybe_unused]] double x) const { 56 | return delta-1.0; 57 | } 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FML/FFTLog/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = true 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Check for bad memory accesses 25 | USE_SANITIZER = false 26 | 27 | #=================================================== 28 | # Include and library paths 29 | #=================================================== 30 | 31 | # Main library include (path to folder containin FML/) 32 | FML_INCLUDE = $(HOME)/local/FML 33 | 34 | # FFTW : only needed if USE_FFTW = true 35 | FFTW_INCLUDE = $(HOME)/local/include 36 | FFTW_LIB = $(HOME)/local/lib 37 | FFTW_LINK = -lfftw3 38 | FFTW_MPI_LINK = -lfftw3_mpi 39 | FFTW_OMP_LINK = -lfftw3_threads 40 | 41 | #=================================================== 42 | # Compile up all library defines from options above 43 | #=================================================== 44 | 45 | INC = -I$(FML_INCLUDE) 46 | LIB = 47 | LINK = 48 | OPTIONS = 49 | 50 | ifeq ($(USE_MPI),true) 51 | CC = $(MPICC) 52 | OPTIONS += -DUSE_MPI 53 | endif 54 | 55 | ifeq ($(USE_OMP),true) 56 | OPTIONS += -DUSE_OMP 57 | CC += -fopenmp 58 | endif 59 | 60 | ifeq ($(USE_SANITIZER),true) 61 | CC += -fsanitize=address 62 | endif 63 | 64 | ifeq ($(USE_FFTW),true) 65 | OPTIONS += -DUSE_FFTW 66 | INC += -I$(FFTW_INCLUDE) 67 | LIB += -L$(FFTW_LIB) 68 | ifeq ($(USE_MPI),true) 69 | LINK += $(FFTW_MPI_LINK) 70 | endif 71 | ifeq ($(USE_OMP),true) 72 | ifeq ($(USE_FFTW_THREADS),true) 73 | OPTIONS += -DUSE_FFTW_THREADS 74 | LINK += $(FFTW_OMP_LINK) 75 | endif 76 | endif 77 | LINK += $(FFTW_LINK) 78 | endif 79 | 80 | #=================================================== 81 | # Object files to be compiled 82 | #=================================================== 83 | 84 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FFTLog/ 85 | OBJS = Main.o FFTLog.o Global.o 86 | 87 | TARGETS := fftlog 88 | all: $(TARGETS) 89 | .PHONY: all clean 90 | 91 | clean: 92 | rm -rf $(TARGETS) *.o 93 | 94 | fftlog: $(OBJS) 95 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 96 | 97 | %.o: %.cpp 98 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 99 | 100 | -------------------------------------------------------------------------------- /FML/RamsesUtils/ramses2pk/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++20 compliant compiler. If USE_MPI we use MPICC. 7 | # Want c++20 for the groundbreaking function string.starts_with() ... 8 | #=================================================== 9 | 10 | CC = g++ -std=c++20 -O3 -Wall -Wextra -march=native 11 | MPICC = mpicxx -std=c++20 -O3 -Wall -Wextra -march=native 12 | 13 | #=================================================== 14 | # Options 15 | #=================================================== 16 | 17 | # Use MPI 18 | USE_MPI = true 19 | # Use OpenMP threads 20 | USE_OMP = false 21 | # Check for bad memory accesses 22 | USE_SANITIZER = false 23 | # Use the FFTW library (required) 24 | USE_FFTW = true 25 | # Use threads in FFTW 26 | USE_FFTW_THREADS = true 27 | 28 | #=================================================== 29 | # Include and library paths 30 | #=================================================== 31 | 32 | # Main library include (path to folder containin FML/) 33 | FML_INCLUDE = $(HOME)/local/FML 34 | 35 | # FFTW 36 | FFTW_INCLUDE = $(HOME)/local/include 37 | FFTW_LIB = $(HOME)/local/lib 38 | FFTW_LINK = -lfftw3 39 | FFTW_MPI_LINK = -lfftw3_mpi 40 | FFTW_OMP_LINK = -lfftw3_threads 41 | 42 | #=================================================== 43 | # Compile up all library defines from options above 44 | #=================================================== 45 | 46 | INC = -I$(FML_INCLUDE) 47 | LIB = 48 | LINK = 49 | OPTIONS = 50 | 51 | ifeq ($(USE_MPI),true) 52 | CC = $(MPICC) 53 | OPTIONS += -DUSE_MPI 54 | endif 55 | 56 | ifeq ($(USE_OMP),true) 57 | OPTIONS += -DUSE_OMP 58 | CC += -fopenmp 59 | endif 60 | 61 | ifeq ($(USE_SANITIZER),true) 62 | CC += -fsanitize=address 63 | endif 64 | 65 | ifeq ($(USE_FFTW),true) 66 | OPTIONS += -DUSE_FFTW 67 | INC += -I$(FFTW_INCLUDE) 68 | LIB += -L$(FFTW_LIB) 69 | ifeq ($(USE_MPI),true) 70 | LINK += $(FFTW_MPI_LINK) 71 | endif 72 | ifeq ($(USE_OMP),true) 73 | ifeq ($(USE_FFTW_THREADS),true) 74 | OPTIONS += -DUSE_FFTW_THREADS 75 | LINK += $(FFTW_OMP_LINK) 76 | endif 77 | endif 78 | LINK += $(FFTW_LINK) 79 | endif 80 | 81 | #=================================================== 82 | # Object files to be compiled 83 | #=================================================== 84 | 85 | VPATH := $(FML_INCLUDE)/FML/Global/ 86 | OBJS = Main.o Global.o 87 | 88 | TARGETS := ramses2pk 89 | all: $(TARGETS) 90 | .PHONY: all clean 91 | 92 | clean: 93 | rm -rf $(TARGETS) *.o 94 | 95 | ramses2pk: $(OBJS) 96 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 97 | 98 | %.o: %.cpp 99 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 100 | -------------------------------------------------------------------------------- /FML/Survey/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // RA, DEC is in degrees 6 | struct Galaxy { 7 | double RA; 8 | double DEC; 9 | double z; 10 | double weight; 11 | Galaxy() {} 12 | Galaxy(double _RA, double _DEC, double _z, double _weight) : RA(_RA), DEC(_DEC), z(_z), weight(_weight) {} 13 | double get_RA() const { return RA; } 14 | double get_DEC() const { return DEC; } 15 | double get_z() const { return z; } 16 | double get_weight() const { return weight; } 17 | }; 18 | 19 | // Galaxy in Cartesian coordinates 20 | struct Particle { 21 | double Pos[3]; 22 | double * get_pos() { return Pos; } 23 | constexpr int get_ndim() const { return 3; } 24 | }; 25 | 26 | using namespace FML; 27 | 28 | int main() { 29 | 30 | // Read ascii file with [DEC, RA, z, w] 31 | const std::string filename = "../../../TestData/ExampleSurveyData/Randoms_DEC_RA_z.txt"; 32 | 33 | // Make galaxies 34 | std::vector galaxies; 35 | auto data = FML::FILEUTILS::loadtxt(filename); 36 | for (auto & row : data) { 37 | Galaxy g; 38 | g.DEC = row[0]; 39 | g.RA = row[1]; 40 | g.z = row[2]; 41 | if(row.size() > 3) 42 | g.weight = row[3]; 43 | galaxies.push_back(g); 44 | } 45 | std::cout << "Read: " << galaxies.size() << " galaxies\n"; 46 | 47 | // The Hubble function H/c needed to compute the comoving distance 48 | std::function hubble_over_c_of_z = [&](double z) -> double { 49 | return 1.0 / 2997.92458 * sqrt(0.315 * (1 + z) * (1 + z) * (1 + z) + 0.685); 50 | }; 51 | 52 | // Galaxies to box options (shift/scale the positions to [0,1)) 53 | const bool shiftPositions = true; 54 | const bool scalePositions = true; 55 | const bool verbose = true; 56 | std::vector observer_position; 57 | 58 | // Convert galaxies to cartesian coordinates 59 | std::vector particles; 60 | double boxsize; 61 | FML::SURVEY::GalaxiesToBox(galaxies.data(), 62 | galaxies.size(), 63 | particles, 64 | hubble_over_c_of_z, 65 | boxsize, 66 | observer_position, 67 | shiftPositions, 68 | scalePositions, 69 | verbose); 70 | 71 | // Output positions 72 | // for(size_t i = 0; i < galaxies.size(); i++) 73 | // std::cout << particles[i].Pos[0] << " " << particles[i].Pos[1] << " " << particles[i].Pos[2] << "\n"; 74 | } 75 | -------------------------------------------------------------------------------- /FML/ParticleTypes/SimpleParticle.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLEPARTICLE_HEADER 2 | #define SIMPLEPARTICLE_HEADER 3 | #include 4 | 5 | /// Example of a simple particle with all the methods needed to be used with MPIParticles 6 | /// Some algorithms might require more field like get_vol, id etc. 7 | /// The types used below can be changed (automatically inferred by algorithms) 8 | template 9 | struct SimpleParticle { 10 | 11 | /// Position of particle in [0,1)^NDIM 12 | double Pos[NDIM]; 13 | /// Velocity of particle (in whatever units you want) 14 | double Vel[NDIM]; 15 | 16 | /// Get the dimension of the position 17 | constexpr int get_ndim() const { return NDIM; } 18 | /// Get a pointer to the position of the particle 19 | double * get_pos() { return Pos; } 20 | /// Get a pointer to the velocity of the particle 21 | double * get_vel() { return Vel; } 22 | }; 23 | 24 | /// Example of a particle for COLA N-body simulations 25 | /// that is compatible with the make IC and N-body methods 26 | /// If you only want 1LPT then simply remove all 2LPT stuff below 27 | /// The types used below can be changed (automatically inferred by algorithms) 28 | template 29 | struct COLAParticle { 30 | 31 | /// Position 32 | double Pos[NDIM]; 33 | /// Lagrangian Position 34 | double q[NDIM]; 35 | /// Velocity 36 | double Vel[NDIM]; 37 | /// 1LPT displacement vector 38 | double D_1LPT[NDIM]; 39 | /// 2LPT displacement vector 40 | double D_2LPT[NDIM]; 41 | /// 3LPTa displacement vector 42 | double D_3LPTa[NDIM]; 43 | /// 3LPTb displacement vector 44 | double D_3LPTb[NDIM]; 45 | /// ID of the particle 46 | long long int id; 47 | 48 | /// Get the ID of the particle 49 | long long int get_id() const { return id; } 50 | /// Set the ID of the particle 51 | void set_id(long long int _id) { id = _id; } 52 | /// Get the dimension of the position 53 | constexpr int get_ndim() const { return NDIM; } 54 | /// Get a pointer to the position of the particle 55 | double * get_pos() { return Pos; } 56 | /// Get a pointer to the velocity of the particle 57 | double * get_vel() { return Vel; } 58 | /// Get a pointer to the Lagrangian position of the particle 59 | double * get_q() { return q; } 60 | /// Get a pointer to the initial 1LPT displacement field at the particles initial position 61 | double * get_D_1LPT() { return D_1LPT; } 62 | /// Get a pointer to the initial 2LPT displacement field at the particles initial position 63 | double * get_D_2LPT() { return D_2LPT; } 64 | /// Get a pointer to the initial 3LPTa displacement field at the particles initial position 65 | double * get_D_3LPTa() { return D_3LPTa; } 66 | /// Get a pointer to the initial 3LPTb displacement field at the particles initial position 67 | double * get_D_3LPTb() { return D_3LPTb; } 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /FML/Global/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = false 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = true 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | 29 | #=================================================== 30 | # Include and library paths 31 | #=================================================== 32 | 33 | # Main library include (path to folder containin FML/) 34 | FML_INCLUDE = $(HOME)/local/FML 35 | 36 | # FFTW : only needed if USE_FFTW = true 37 | FFTW_INCLUDE = $(HOME)/local/include 38 | FFTW_LIB = $(HOME)/local/lib 39 | FFTW_LINK = -lfftw3 40 | FFTW_MPI_LINK = -lfftw3_mpi 41 | FFTW_OMP_LINK = -lfftw3_threads 42 | 43 | #=================================================== 44 | # Compile up all library defines from options above 45 | #=================================================== 46 | 47 | INC = -I$(FML_INCLUDE) 48 | LIB = 49 | LINK = 50 | OPTIONS = 51 | 52 | ifeq ($(USE_MPI),true) 53 | CC = $(MPICC) 54 | OPTIONS += -DUSE_MPI 55 | endif 56 | 57 | ifeq ($(USE_OMP),true) 58 | OPTIONS += -DUSE_OMP 59 | CC += -fopenmp 60 | endif 61 | 62 | ifeq ($(USE_SANITIZER),true) 63 | CC += -fsanitize=address 64 | endif 65 | 66 | ifeq ($(USE_FFTW),true) 67 | OPTIONS += -DUSE_FFTW 68 | INC += -I$(FFTW_INCLUDE) 69 | LIB += -L$(FFTW_LIB) 70 | ifeq ($(USE_MPI),true) 71 | LINK += $(FFTW_MPI_LINK) 72 | endif 73 | ifeq ($(USE_OMP),true) 74 | ifeq ($(USE_FFTW_THREADS),true) 75 | OPTIONS += -DUSE_FFTW_THREADS 76 | LINK += $(FFTW_OMP_LINK) 77 | endif 78 | endif 79 | LINK += $(FFTW_LINK) 80 | endif 81 | 82 | ifeq ($(USE_MEMORYLOG),true) 83 | OPTIONS += -DMEMORY_LOGGING 84 | endif 85 | 86 | #=================================================== 87 | # Object files to be compiled 88 | #=================================================== 89 | 90 | VPATH := $(FML_INCLUDE)/FML/Global/ 91 | OBJS = Main.o Global.o 92 | 93 | TARGETS := mpi 94 | all: $(TARGETS) 95 | .PHONY: all clean 96 | 97 | clean: 98 | rm -rf $(TARGETS) *.o 99 | 100 | mpi: $(OBJS) 101 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 102 | 103 | %.o: %.cpp 104 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 105 | -------------------------------------------------------------------------------- /FML/Units/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //================================================ 5 | // A simple units class 6 | //================================================ 7 | 8 | // Constants availiable globally for simplicity 9 | FML::UTILS::ConstantsAndUnits Constants; 10 | 11 | void print() { 12 | std::cout << "In the given units 1 m = " << Constants.m << " Length units\n"; 13 | std::cout << "In the given units 1 s = " << Constants.s << " Time units\n"; 14 | std::cout << "In the given units 1 kg = " << Constants.kg << " Mass units\n"; 15 | std::cout << "In the given units 1 eV = " << Constants.eV << "\n"; 16 | std::cout << "In the given units m_e = " << Constants.m_e << "\n"; 17 | std::cout << "In the given units c = " << Constants.c << "\n"; 18 | } 19 | 20 | int main() { 21 | 22 | //================================================ 23 | // SI units: 24 | //================================================ 25 | 26 | Constants = FML::UTILS::ConstantsAndUnits("SI"); 27 | Constants.info(); 28 | print(); 29 | 30 | // The mass-energy of an electron 31 | double me = Constants.m_e * Constants.c * Constants.c; 32 | std::cout << "m_e c^2 = " << me << " J = " << me / Constants.MeV << " MeV\n"; 33 | 34 | // Compute the Schwarchild radius of a 1 solar-mass black hole in SI units 35 | double r_s = 2 * Constants.G * Constants.Msun / (Constants.c * Constants.c); 36 | std::cout << "Suns Schwarchild radius rs = " << r_s << " m = " << r_s / Constants.km << " km\n"; 37 | 38 | //================================================ 39 | // Planck units c=hbar=G=kb=1: 40 | //================================================ 41 | 42 | Constants = FML::UTILS::ConstantsAndUnits("Planck"); 43 | Constants.info(); 44 | print(); 45 | std::cout << "In Planck Units c = 1. Convert this to SI: c = " << Constants.velocity_to_SI(1.0) << " m/s\n"; 46 | 47 | // The mass-energy of an electron (c=1 so its just m_e) 48 | me = Constants.m_e; 49 | std::cout << "m_e c^2 = " << me << " Planck energy = " << me / Constants.MeV << " MeV\n"; 50 | 51 | // Compute the Schwarchild radius of a 1 solar-mass black hole in Planck units 52 | // (G = c = 1 in these units so we don't need to include it) 53 | r_s = 2 * Constants.Msun; 54 | std::cout << "Suns Schwarchild radius rs = " << r_s << " Planck lengths = " << Constants.length_to_SI(r_s) 55 | << " m = " << r_s / Constants.km << " km\n"; 56 | 57 | //================================================ 58 | // Particle physics units eV and c=hbar=kb=1: 59 | //================================================ 60 | 61 | Constants = FML::UTILS::ConstantsAndUnits("ParticlePhysics"); 62 | Constants.info(); 63 | print(); 64 | 65 | // The mass-energy of an electron (c=1 and fundamental unit is eV) 66 | me = Constants.m_e; 67 | std::cout << "m_e c^2 = " << me << " eV = " << me / Constants.MeV << " MeV\n"; 68 | } 69 | -------------------------------------------------------------------------------- /FML/MakePythonWrapper/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # The name of the library and the interface file 7 | #=================================================== 8 | 9 | PYTHONLIBNAME = _MyLibrary.so 10 | SWIGFILE = InterfaceFile.i 11 | # These are generated 12 | SWIGWRAPPER = InterfaceFile_wrap.cxx 13 | SWIGWRAPPERO = InterfaceFile_wrap.o 14 | 15 | #=================================================== 16 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 17 | #=================================================== 18 | 19 | CC = g++ -std=c++1z -Wall 20 | 21 | #=================================================== 22 | # Options 23 | #=================================================== 24 | 25 | # Required 26 | USE_PYTHON = true 27 | 28 | #=================================================== 29 | # Include and library paths 30 | #=================================================== 31 | 32 | # Main library include (path to folder containin FML/) 33 | FML_INCLUDE = /Users/hansw/local/FML 34 | 35 | # Python and numpy includes 36 | PYTHON_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/ 37 | PYTHON_LIB = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/ 38 | NUMPY_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include 39 | PYTHON_LINK = -lpython3.8 -ldl -framework CoreFoundation 40 | 41 | # For Python 3 42 | #PYTHON_INCLUDE = /astro/local/anaconda3/include/python3.6m 43 | #PYTHON_LIB = /astro/local/anaconda3/lib 44 | #NUMPY_INCLUDE = /astro/local/anaconda3/lib/python3.6/site-packages/numpy/core/include 45 | #PYTHON_LINK = -lpython3.6m -ldl 46 | 47 | #=================================================== 48 | # Compile up all library defines from options above 49 | #=================================================== 50 | 51 | INC = -I$(FML_INCLUDE) 52 | LIB = 53 | LINK = 54 | OPTIONS = 55 | 56 | ifeq ($(USE_PYTHON),true) 57 | INC += -I$(PYTHON_INCLUDE) -I$(NUMPY_INCLUDE) 58 | LIB += -L$(PYTHON_LIB) 59 | LINK += $(PYTHON_LINK) 60 | endif 61 | 62 | #=================================================== 63 | # Object files to be compiled 64 | #=================================================== 65 | 66 | VPATH := 67 | FILE1 = Main.o 68 | OBJS = $(FILE1) 69 | 70 | TARGETS := test 71 | all: $(TARGETS) 72 | .PHONY: all clean 73 | 74 | # Compile all the object files as a shared library 75 | $(FILE1) : Main.cpp 76 | $(CC) $(OPTIONS) -fPIC -c $< -o $@ $(INC) 77 | 78 | # Run swig and generate a library that can be called from python 79 | test: $(OBJS) 80 | swig -c++ -python $(OPTIONS) $(SWIGFILE) 81 | $(CC) -fPIC -c $(SWIGWRAPPER) $(INC) 82 | $(CC) -fPIC -shared $(OPTIONS) $(OBJS) $(SWIGWRAPPERO) -o $(PYTHONLIBNAME) $(INC) $(LIB) $(LINK) 83 | 84 | clean: 85 | rm -rf $(TARGETS) *.o $(SWIGWRAPPER) $(PYTHONLIBNAME) *.pyc 86 | 87 | %.o: %.cpp 88 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 89 | 90 | -------------------------------------------------------------------------------- /FML/Plotting/LICENSE.matplotlib: -------------------------------------------------------------------------------- 1 | This library does not contain any files from the matplotlib project, nor 2 | does it make any changes to it. On the other hand, the code contained herein 3 | is perfectly useless without a separate installation of matplotlib. 4 | I don't know enough about US copyright law to decide whether this implies 5 | that this library "uses" or is "based on" matplotlib. 6 | In any case, matplotlib comes with the following license: 7 | 8 | License agreement for matplotlib 1.4.3 9 | 1. This LICENSE AGREEMENT is between the Matplotlib Development Team (“MDT”), 10 | and the Individual or Organization (“Licensee”) accessing and otherwise 11 | using matplotlib software in source or binary form and its associated documentation. 12 | 13 | 2. Subject to the terms and conditions of this License Agreement, MDT hereby grants 14 | Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, 15 | test, perform and/or display publicly, prepare derivative works, distribute, and 16 | otherwise use matplotlib 1.4.3 alone or in any derivative version, provided, however, 17 | that MDT’s License Agreement and MDT’s notice of copyright, i.e., 18 | “Copyright (c) 2012-2013 Matplotlib Development Team; All Rights Reserved” are retained 19 | in matplotlib 1.4.3 alone or in any derivative version prepared by Licensee. 20 | 21 | 3. In the event Licensee prepares a derivative work that is based on or incorporates 22 | matplotlib 1.4.3 or any part thereof, and wants to make the derivative work available 23 | to others as provided herein, then Licensee hereby agrees to include in any such work a 24 | brief summary of the changes made to matplotlib 1.4.3. 25 | 26 | 4. MDT is making matplotlib 1.4.3 available to Licensee on an “AS IS” basis. MDT MAKES NO 27 | REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, 28 | MDT MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS 29 | FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 1.4.3 WILL NOT INFRINGE ANY 30 | THIRD PARTY RIGHTS. 31 | 32 | 5. MDT SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB 1.4.3 FOR ANY 33 | INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, 34 | DISTRIBUTING, OR OTHERWISE USING MATPLOTLIB 1.4.3, OR ANY DERIVATIVE THEREOF, 35 | EVEN IF ADVISED OF THE POSSIBILITY THEREOF. 36 | 37 | 6. This License Agreement will automatically terminate upon a material breach of 38 | its terms and conditions. 39 | 40 | 7. Nothing in this License Agreement shall be deemed to create any relationship of 41 | agency, partnership, or joint venture between MDT and Licensee. This License 42 | Agreement does not grant permission to use MDT trademarks or trade name in a 43 | trademark sense to endorse or promote products or services of Licensee, or any 44 | third party. 45 | 46 | 8. By copying, installing or otherwise using matplotlib 1.4.3, Licensee agrees to be 47 | bound by the terms and conditions of this License Agreement. 48 | -------------------------------------------------------------------------------- /FML/HaloModel/PythonWrapper/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # The name of the library and the interface file 7 | #=================================================== 8 | 9 | PYTHONLIBNAME = _HaloModelCXX.so 10 | PYWRAPFILE = HaloModelCXX.py 11 | SWIGFILE = InterfaceFile.i 12 | SWIGWRAPPER = InterfaceFile_wrap.cxx 13 | SWIGWRAPPERO = InterfaceFile_wrap.o 14 | 15 | #=================================================== 16 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 17 | #=================================================== 18 | 19 | CC = g++ -std=c++1z -Wall 20 | 21 | #=================================================== 22 | # Options 23 | #=================================================== 24 | 25 | FML_INCLUDE = $(HOME)/local/FML/ 26 | PYTHON_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/ 27 | PYTHON_LIB = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/ 28 | NUMPY_INCLUDE = /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include 29 | PYTHON_LINK = -lpython3.8 -ldl -framework CoreFoundation 30 | 31 | #=================================================== 32 | # Compile up all library defines from options above 33 | #=================================================== 34 | 35 | FML_INCLUDE = $(HOME)/local/FML 36 | GSL_INCLUDE = $(HOME)/local/include 37 | GSL_LIB = $(HOME)/local/lib 38 | GSL_LINK = -lgsl -lgslcblas 39 | 40 | INC = -I$(FML_INCLUDE) 41 | LIB = 42 | LINK = 43 | OPTIONS = -DDONT_SHOW_INIT_INFO 44 | 45 | INC += -I$(PYTHON_INCLUDE) -I$(NUMPY_INCLUDE) 46 | LIB += -L$(PYTHON_LIB) 47 | LINK += $(PYTHON_LINK) 48 | 49 | OPTIONS += -DUSE_OMP 50 | CC += -fopenmp 51 | 52 | OPTIONS += -DUSE_GSL 53 | INC += -I$(GSL_INCLUDE) 54 | LIB += -L$(GSL_LIB) 55 | LINK += $(GSL_LINK) 56 | 57 | #=================================================== 58 | # Object files to be compiled 59 | #=================================================== 60 | 61 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/Math/:$(FML_INCLUDE)/FML/Spline/:$(FML_INCLUDE)/FML/FileUtils/:$(FML_INCLUDE)/FML/SphericalCollapse/:$(FML_INCLUDE)/FML/HaloModel/ 62 | OBJS = Wrapper.o ODESolver.o Global.o Math.o Spline.o FileUtils.o Halomodel.o SphericalCollapse.o SphericalCollapseModel.o 63 | 64 | TARGETS := halomodel 65 | all: $(TARGETS) 66 | .PHONY: all clean 67 | 68 | # Run swig and generate a library that can be called from python 69 | halomodel: $(OBJS) 70 | swig -c++ -python $(OPTIONS) $(SWIGFILE) 71 | $(CC) -fPIC -c $(SWIGWRAPPER) $(INC) 72 | $(CC) -shared $(OPTIONS) $(OBJS) $(SWIGWRAPPERO) -o $(PYTHONLIBNAME) $(INC) $(LIB) $(LINK) 73 | #$(CC) -fPIC -shared $(OPTIONS) $(OBJS) $(SWIGWRAPPERO) -o $(PYTHONLIBNAME) $(INC) $(LIB) $(LINK) 74 | 75 | clean: 76 | rm -rf $(TARGETS) *.o $(SWIGWRAPPER) $(PYTHONLIBNAME) $(PYWRAPFILE) *.pyc __pycache__ 77 | 78 | %.o: %.cpp 79 | ${CC} -fPIC -c -o $@ $< $(OPTIONS) $(INC) 80 | 81 | -------------------------------------------------------------------------------- /FML/HaloModel/PythonWrapper/InterfaceFile.i: -------------------------------------------------------------------------------- 1 | %module HaloModelCXX 2 | %include 3 | %include 4 | %{ 5 | #define SWIG_FILE_WITH_INIT 6 | #include 7 | 8 | using HaloModel = FML::COSMOLOGY::HALOMODEL::HaloModel; 9 | 10 | extern HaloModel **get(); 11 | extern void calc(HaloModel **hm, double z); 12 | extern void free(HaloModel **hm); 13 | extern void info(HaloModel **hm); 14 | extern void init( 15 | HaloModel **hm, 16 | std::string filename_pofk, 17 | double OmegaM, 18 | double w0, 19 | double wa, 20 | double mu0, 21 | double mua, 22 | bool verbose, 23 | bool hmcode, 24 | bool sigma8norm, 25 | double deltac_multiplier, 26 | double DeltaVir_multiplier, 27 | double cofM_multiplier); 28 | extern void get_pofk(HaloModel **hm, int nk, double * k, int npofk_lin, double * pofk_lin, int npofk, double *pofk); 29 | extern void get_nofM(HaloModel **hmp, int nm, double * M, int ndnofm, double *dnofm, int nnofm, double * nofm); 30 | extern void get_DeltaVir(HaloModel **hmp, int nz, double *z, int nDeltaVir, double *DeltaVir); 31 | extern void get_deltac(HaloModel **hmp, int nz, double *z, int ndeltac, double *deltac); 32 | extern void get_pofk_1h_2h(HaloModel **hmp, int nk, double * k, int npofk_1h, double * pofk_1h, int npofk_2h, double *pofk_2h); 33 | %} 34 | 35 | #include 36 | 37 | %include "numpy.i" 38 | %init %{ 39 | import_array(); 40 | %} 41 | 42 | %apply (int DIM1, double* IN_ARRAY1) {(int nk, double *k), (int npofk_lin, double *pofk_lin), (int npofk, double *pofk)}; 43 | %apply (int DIM1, double* IN_ARRAY1) {(int nm, double *M), (int ndnofm, double *dnofm), (int nnofm, double *nofm)}; 44 | %apply (int DIM1, double* IN_ARRAY1) {(int nk, double *k), (int npofk_1h, double *pofk_1h), (int npofk_2h, double *pofk_2h)}; 45 | %apply (int DIM1, double* IN_ARRAY1) {(int nz, double *z), (int nDeltaVir, double *DeltaVir)}; 46 | %apply (int DIM1, double* IN_ARRAY1) {(int nz, double *z), (int ndeltac, double *deltac)}; 47 | 48 | extern HaloModel **get(); 49 | extern void calc(HaloModel **hm, double z); 50 | extern void free(HaloModel **hm); 51 | extern void info(HaloModel **hm); 52 | extern void init( 53 | HaloModel **hm, 54 | std::string filename_pofk, 55 | double OmegaM, 56 | double w0, 57 | double wa, 58 | double mu0, 59 | double mua, 60 | bool verbose, 61 | bool hmcode, 62 | bool sigma8norm, 63 | double deltac_multiplier, 64 | double DeltaVir_multiplier, 65 | double cofM_multiplier); 66 | extern void get_pofk(HaloModel **hm, int nk, double * k, int npofk_lin, double * pofk_lin, int npofk, double *pofk); 67 | extern void get_nofM(HaloModel **hmp, int nm, double * M, int ndnofm, double *dnofm, int nnofm, double * nofm); 68 | extern void get_DeltaVir(HaloModel **hmp, int nz, double *z, int nDeltaVir, double *DeltaVir); 69 | extern void get_deltac(HaloModel **hmp, int nz, double *z, int ndeltac, double *deltac); 70 | extern void get_pofk_1h_2h(HaloModel **hmp, int nk, double * k, int npofk_1h, double * pofk_1h, int npofk_2h, double *pofk_2h); 71 | -------------------------------------------------------------------------------- /FML/FFTWGrid/FFTWGlobal.h: -------------------------------------------------------------------------------- 1 | #ifndef FFTWGLOBAL_HEADER 2 | #define FFTWGLOBAL_HEADER 3 | 4 | #include 5 | 6 | #ifdef USE_FFTW 7 | #include 8 | #endif 9 | 10 | #ifdef USE_MPI 11 | #include 12 | #ifdef USE_FFTW 13 | #include 14 | #endif 15 | #endif 16 | 17 | #ifdef USE_OMP 18 | #include 19 | #endif 20 | 21 | //========================================================================== 22 | // This file contains type definition and macros for avoiding alot of 23 | // ifdefs wrt float/double/long double FFTW transfors 24 | // It also contains a singleton for automatically initializing FFTW 25 | // with MPI and threads 26 | //========================================================================== 27 | 28 | #ifdef SINGLE_PRECISION_FFTW 29 | using FloatType = float; 30 | #else 31 | #ifdef LONG_DOUBLE_PRECISION_FFTW 32 | using FloatType = long double; 33 | #else 34 | using FloatType = double; 35 | #endif 36 | #endif 37 | using ComplexType = std::complex; 38 | 39 | #ifdef USE_FFTW 40 | #ifdef SINGLE_PRECISION_FFTW 41 | using my_fftw_complex = fftwf_complex; 42 | using my_fftw_plan = fftwf_plan; 43 | #define SET_FFTW_NTHREADS fftwf_plan_with_nthreads 44 | #define INIT_FFTW_THREADS fftwf_init_threads 45 | #ifdef USE_MPI 46 | #define INIT_FFTW_MPI fftwf_mpi_init 47 | #define CLEANUP_FFTW_MPI fftwf_mpi_cleanup 48 | #define MAKE_PLAN_R2C fftwf_mpi_plan_dft_r2c 49 | #define MAKE_PLAN_C2R fftwf_mpi_plan_dft_c2r 50 | #define MPI_FFTW_LOCAL_SIZE fftwf_mpi_local_size 51 | #else 52 | #define MAKE_PLAN_R2C fftwf_plan_dft_r2c 53 | #define MAKE_PLAN_C2R fftwf_plan_dft_c2r 54 | #endif 55 | #define EXECUTE_FFT fftwf_execute 56 | #define DESTROY_PLAN fftwf_destroy_plan 57 | #else // Single precision 58 | #ifdef LONG_DOUBLE_PRECISION_FFTW 59 | using my_fftw_complex = fftwl_complex; 60 | using my_fftw_plan = fftwl_plan; 61 | #define SET_FFTW_NTHREADS fftwl_plan_with_nthreads 62 | #define INIT_FFTW_THREADS fftwl_init_threads 63 | #ifdef USE_MPI 64 | #define INIT_FFTW_MPI fftwl_mpi_init 65 | #define CLEANUP_FFTW_MPI fftwl_mpi_cleanup 66 | #define MAKE_PLAN_R2C fftwl_mpi_plan_dft_r2c 67 | #define MAKE_PLAN_C2R fftwl_mpi_plan_dft_c2r 68 | #define MPI_FFTW_LOCAL_SIZE fftwl_mpi_local_size 69 | #else 70 | #define MAKE_PLAN_R2C fftwl_plan_dft_r2c 71 | #define MAKE_PLAN_C2R fftwl_plan_dft_c2r 72 | #endif 73 | #define EXECUTE_FFT fftwl_execute 74 | #define DESTROY_PLAN fftwl_destroy_plan 75 | #else // Long double precision 76 | using my_fftw_complex = fftw_complex; 77 | using my_fftw_plan = fftw_plan; 78 | #define SET_FFTW_NTHREADS fftw_plan_with_nthreads 79 | #define INIT_FFTW_THREADS fftw_init_threads 80 | #ifdef USE_MPI 81 | #define INIT_FFTW_MPI fftw_mpi_init 82 | #define CLEANUP_FFTW_MPI fftw_mpi_cleanup 83 | #define MAKE_PLAN_R2C fftw_mpi_plan_dft_r2c 84 | #define MAKE_PLAN_C2R fftw_mpi_plan_dft_c2r 85 | #define MPI_FFTW_LOCAL_SIZE fftw_mpi_local_size 86 | #else 87 | #define MAKE_PLAN_R2C fftw_plan_dft_r2c 88 | #define MAKE_PLAN_C2R fftw_plan_dft_c2r 89 | #endif 90 | #define EXECUTE_FFT fftw_execute 91 | #define DESTROY_PLAN fftw_destroy_plan 92 | #endif // Double precision 93 | #endif 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /FML/SphericalCollapse/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using SphericalCollapseModel = FML::COSMOLOGY::SPHERICALCOLLAPSE::SphericalCollapseModel; 5 | using SphericalCollapse = FML::COSMOLOGY::SPHERICALCOLLAPSE::SphericalCollapse; 6 | using Spline = FML::INTERPOLATION::SPLINE::Spline; 7 | using Func1 = FML::COSMOLOGY::SPHERICALCOLLAPSE::Func1; 8 | 9 | int main(){ 10 | const bool verbose = true; 11 | 12 | //=================================================== 13 | // Define cosmological parameters and functions 14 | // Cosmology functions E = H(x)/H0, x = log(a) 15 | //=================================================== 16 | const double w0 = -1.0; 17 | const double wa = 0.0; 18 | const double mu0 = 0.0; 19 | const double mua = 0.0; 20 | const double OmegaM = 0.3; 21 | const double OmegaLambda = 1-OmegaM; 22 | 23 | const Func1 Eofx = [OmegaM,OmegaLambda,w0,wa](double x) -> double { 24 | const double a = std::exp(x); 25 | return std::sqrt( 26 | OmegaM * std::exp(-3.0*x) + 27 | OmegaLambda * std::exp(3.0 * wa * (a - 1) - 3 * (1 + w0 + wa) * x) 28 | ); 29 | }; 30 | const Func1 OmegaMofx = [OmegaM,Eofx](double x) -> double { 31 | return OmegaM*std::exp(-3.0*x)/std::pow(Eofx(x),2); 32 | }; 33 | const Func1 logEprimeofx = [OmegaM,OmegaLambda,w0,wa,Eofx](double x) -> double { 34 | const double E = Eofx(x); 35 | const double a = std::exp(x); 36 | return 1.0 / (2.0 * E * E) * (-3.0 * OmegaM / (a * a * a) + 37 | OmegaLambda * std::exp(3.0 * wa * (a - 1) - 3 * (1 + w0 + wa) * x) * 38 | (3.0 * wa * a - 3.0 * (1 + w0 + wa))); 39 | }; 40 | const Func1 muofx = [mu0,mua,Eofx](double x) -> double { 41 | const double E = Eofx(x); 42 | const double a = std::exp(x); 43 | return 1.0 + (mu0 + mua*(1.0-a)) / (E*E); 44 | }; 45 | const Func1 wofx = [w0,wa](double x) -> double { 46 | const double a = std::exp(x); 47 | return w0 + wa*(1-a); 48 | }; 49 | 50 | //=================================================== 51 | // Set up the spherical collapse model 52 | //=================================================== 53 | SphericalCollapseModel scm( 54 | Eofx, 55 | OmegaMofx, 56 | logEprimeofx, 57 | muofx, 58 | wofx); 59 | scm.info(); 60 | 61 | //=================================================== 62 | // Run spherical collapse for this model 63 | //=================================================== 64 | SphericalCollapse sc( 65 | scm, 66 | verbose); 67 | Spline deltac_of_x_spline, 68 | DeltaVir_of_x_spline, 69 | xta_of_x_spline, 70 | xvir_of_x_spline, 71 | xnl_of_x_spline, 72 | delta_ini_of_x_spline, 73 | growthfactor_of_x_spline, 74 | growthrate_of_x_spline; 75 | sc.run_at_all_redshifts( 76 | deltac_of_x_spline, 77 | DeltaVir_of_x_spline, 78 | xta_of_x_spline, 79 | xnl_of_x_spline, 80 | xvir_of_x_spline, 81 | delta_ini_of_x_spline, 82 | growthfactor_of_x_spline, 83 | growthrate_of_x_spline); 84 | } 85 | -------------------------------------------------------------------------------- /FML/LPT/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = true 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = true 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Print more info as the code runs and do some more checks 29 | USE_DEBUG = false 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # FFTW : only needed if USE_FFTW = true 39 | FFTW_INCLUDE = $(HOME)/local/include 40 | FFTW_LIB = $(HOME)/local/lib 41 | FFTW_LINK = -lfftw3 42 | FFTW_MPI_LINK = -lfftw3_mpi 43 | FFTW_OMP_LINK = -lfftw3_threads 44 | 45 | #=================================================== 46 | # Compile up all library defines from options above 47 | #=================================================== 48 | 49 | INC = -I$(FML_INCLUDE) 50 | LIB = 51 | LINK = 52 | OPTIONS = 53 | 54 | ifeq ($(USE_DEBUG),true) 55 | OPTIONS += -DBOUNDSCHECK_FFTWGRID -DDEBUG_LPT -DMIN_BYTES_TO_LOG=0 56 | endif 57 | 58 | ifeq ($(USE_MPI),true) 59 | CC = $(MPICC) 60 | OPTIONS += -DUSE_MPI 61 | endif 62 | 63 | ifeq ($(USE_OMP),true) 64 | OPTIONS += -DUSE_OMP 65 | CC += -fopenmp 66 | endif 67 | 68 | ifeq ($(USE_SANITIZER),true) 69 | CC += -fsanitize=address 70 | endif 71 | 72 | ifeq ($(USE_FFTW),true) 73 | OPTIONS += -DUSE_FFTW 74 | INC += -I$(FFTW_INCLUDE) 75 | LIB += -L$(FFTW_LIB) 76 | ifeq ($(USE_MPI),true) 77 | LINK += $(FFTW_MPI_LINK) 78 | endif 79 | ifeq ($(USE_OMP),true) 80 | ifeq ($(USE_FFTW_THREADS),true) 81 | OPTIONS += -DUSE_FFTW_THREADS 82 | LINK += $(FFTW_OMP_LINK) 83 | endif 84 | endif 85 | LINK += $(FFTW_LINK) 86 | endif 87 | 88 | ifeq ($(USE_MEMORYLOG),true) 89 | OPTIONS += -DMEMORY_LOGGING -DMIN_BYTES_TO_LOG=0 90 | endif 91 | 92 | #=================================================== 93 | # Object files to be compiled 94 | #=================================================== 95 | 96 | VPATH := $(FML_INCLUDE)/FML/Global/ 97 | OBJS = Main.o Global.o 98 | 99 | TARGETS := lpt 100 | all: $(TARGETS) 101 | .PHONY: all clean 102 | 103 | clean: 104 | rm -rf $(TARGETS) *.o 105 | 106 | lpt: $(OBJS) 107 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 108 | 109 | %.o: %.cpp 110 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 111 | 112 | -------------------------------------------------------------------------------- /FML/Interpolation/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = false 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = false 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Print more info as the code runs and do some more checks 29 | USE_DEBUG = false 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # FFTW : only needed if USE_FFTW = true 39 | FFTW_INCLUDE = $(HOME)/local/include 40 | FFTW_LIB = $(HOME)/local/lib 41 | FFTW_LINK = -lfftw3 42 | FFTW_MPI_LINK = -lfftw3_mpi 43 | FFTW_OMP_LINK = -lfftw3_threads 44 | 45 | #=================================================== 46 | # Compile up all library defines from options above 47 | #=================================================== 48 | 49 | INC = -I$(FML_INCLUDE) 50 | LIB = 51 | LINK = 52 | OPTIONS = 53 | 54 | ifeq ($(USE_DEBUG),true) 55 | OPTIONS += -DDEBUG_FFTWGRID -DDEBUG_MPIPARTICLES -DDEBUG_INTERPOL 56 | endif 57 | 58 | ifeq ($(USE_MPI),true) 59 | CC = $(MPICC) 60 | OPTIONS += -DUSE_MPI 61 | endif 62 | 63 | ifeq ($(USE_OMP),true) 64 | OPTIONS += -DUSE_OMP 65 | CC += -fopenmp 66 | endif 67 | 68 | ifeq ($(USE_SANITIZER),true) 69 | CC += -fsanitize=address 70 | endif 71 | 72 | ifeq ($(USE_FFTW),true) 73 | OPTIONS += -DUSE_FFTW 74 | INC += -I$(FFTW_INCLUDE) 75 | LIB += -L$(FFTW_LIB) 76 | ifeq ($(USE_MPI),true) 77 | LINK += $(FFTW_MPI_LINK) 78 | endif 79 | ifeq ($(USE_OMP),true) 80 | ifeq ($(USE_FFTW_THREADS),true) 81 | OPTIONS += -DUSE_FFTW_THREADS 82 | LINK += $(FFTW_OMP_LINK) 83 | endif 84 | endif 85 | LINK += $(FFTW_LINK) 86 | endif 87 | 88 | ifeq ($(USE_MEMORYLOG),true) 89 | OPTIONS += -DMEMORY_LOGGING 90 | endif 91 | 92 | #=================================================== 93 | # Object files to be compiled 94 | #=================================================== 95 | 96 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FileUtils:/ 97 | OBJS = Main.o Global.o FileUtils.o 98 | 99 | TARGETS := interpol 100 | all: $(TARGETS) 101 | .PHONY: all clean 102 | 103 | clean: 104 | rm -rf $(TARGETS) *.o 105 | 106 | interpol: $(OBJS) 107 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 108 | 109 | %.o: %.cpp 110 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 111 | -------------------------------------------------------------------------------- /FML/ComputePowerSpectra/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -O3 -std=c++1z -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = true 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = false 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Print more info as the code runs and do some more checks 29 | USE_DEBUG = false 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # FFTW : only needed if USE_FFTW = true 39 | FFTW_INCLUDE = $(HOME)/local/include 40 | FFTW_LIB = $(HOME)/local/lib 41 | FFTW_LINK = -lfftw3 42 | FFTW_MPI_LINK = -lfftw3_mpi 43 | FFTW_OMP_LINK = -lfftw3_threads 44 | 45 | #=================================================== 46 | # Compile up all library defines from options above 47 | #=================================================== 48 | 49 | INC = -I$(FML_INCLUDE) 50 | LIB = 51 | LINK = 52 | OPTIONS = 53 | 54 | ifeq ($(USE_DEBUG),true) 55 | OPTIONS += -DDEBUG_FFTWGRID -DDEBUG_MPIPARTICLES -DDEBUG_INTERPOL 56 | endif 57 | 58 | ifeq ($(USE_MPI),true) 59 | CC = $(MPICC) 60 | OPTIONS += -DUSE_MPI 61 | endif 62 | 63 | ifeq ($(USE_OMP),true) 64 | OPTIONS += -DUSE_OMP 65 | CC += -fopenmp 66 | endif 67 | 68 | ifeq ($(USE_SANITIZER),true) 69 | CC += -fsanitize=address 70 | endif 71 | 72 | ifeq ($(USE_FFTW),true) 73 | OPTIONS += -DUSE_FFTW 74 | INC += -I$(FFTW_INCLUDE) 75 | LIB += -L$(FFTW_LIB) 76 | ifeq ($(USE_MPI),true) 77 | LINK += $(FFTW_MPI_LINK) 78 | endif 79 | ifeq ($(USE_OMP),true) 80 | ifeq ($(USE_FFTW_THREADS),true) 81 | OPTIONS += -DUSE_FFTW_THREADS 82 | LINK += $(FFTW_OMP_LINK) 83 | endif 84 | endif 85 | LINK += $(FFTW_LINK) 86 | endif 87 | 88 | ifeq ($(USE_MEMORYLOG),true) 89 | OPTIONS += -DMEMORY_LOGGING 90 | endif 91 | 92 | #=================================================== 93 | # Object files to be compiled 94 | #=================================================== 95 | 96 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FileUtils/ 97 | OBJS = Main.o Global.o FileUtils.o 98 | 99 | TARGETS := powspec 100 | all: $(TARGETS) 101 | .PHONY: all clean 102 | 103 | clean: 104 | rm -rf $(TARGETS) *.o 105 | 106 | powspec: $(OBJS) 107 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 108 | 109 | %.o: %.cpp 110 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 111 | 112 | -------------------------------------------------------------------------------- /FML/KDTree/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the FFTW library 21 | USE_FFTW = false 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = false 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Print more info as the code runs and do some more checks 29 | USE_DEBUG = false 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # FFTW : only needed if USE_FFTW = true 39 | FFTW_INCLUDE = $(HOME)/local/include 40 | FFTW_LIB = $(HOME)/local/lib 41 | FFTW_LINK = -lfftw3 42 | FFTW_MPI_LINK = -lfftw3_mpi 43 | FFTW_OMP_LINK = -lfftw3_threads 44 | 45 | #=================================================== 46 | # Compile up all library defines from options above 47 | #=================================================== 48 | 49 | INC = -I$(FML_INCLUDE) 50 | LIB = 51 | LINK = 52 | OPTIONS = 53 | 54 | ifeq ($(USE_DEBUG),true) 55 | OPTIONS += 56 | endif 57 | 58 | ifeq ($(USE_MPI),true) 59 | CC = $(MPICC) 60 | OPTIONS += -DUSE_MPI 61 | endif 62 | 63 | ifeq ($(USE_OMP),true) 64 | OPTIONS += -DUSE_OMP 65 | CC += -fopenmp 66 | endif 67 | 68 | ifeq ($(USE_SANITIZER),true) 69 | CC += -fsanitize=address 70 | endif 71 | 72 | ifeq ($(USE_FFTW),true) 73 | OPTIONS += -DUSE_FFTW 74 | INC += -I$(FFTW_INCLUDE) 75 | LIB += -L$(FFTW_LIB) 76 | ifeq ($(USE_MPI),true) 77 | LINK += $(FFTW_MPI_LINK) 78 | endif 79 | ifeq ($(USE_OMP),true) 80 | ifeq ($(USE_FFTW_THREADS),true) 81 | OPTIONS += -DUSE_FFTW_THREADS 82 | LINK += $(FFTW_OMP_LINK) 83 | endif 84 | endif 85 | LINK += $(FFTW_LINK) 86 | endif 87 | 88 | ifeq ($(USE_MEMORYLOG),true) 89 | OPTIONS += -DMEMORY_LOGGING 90 | endif 91 | 92 | #=================================================== 93 | # Object files to be compiled 94 | #=================================================== 95 | 96 | VPATH := $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/FileUtils/ 97 | 98 | TARGETS := kdtree test 99 | all: $(TARGETS) 100 | .PHONY: all clean 101 | 102 | clean: 103 | rm -rf $(TARGETS) *.o 104 | 105 | test: Test.o Global.o 106 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 107 | 108 | kdtree: Main.o Global.o FileUtils.o 109 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 110 | 111 | 112 | %.o: %.cpp 113 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 114 | -------------------------------------------------------------------------------- /FML/FFTWGrid/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the FFTW library 21 | USE_FFTW = true 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = false 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Print more info as the code runs and do some more checks 29 | USE_DEBUG = false 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # FFTW : only needed if USE_FFTW = true 39 | FFTW_INCLUDE = $(HOME)/local/include 40 | FFTW_LIB = $(HOME)/local/lib 41 | FFTW_LINK = -lfftw3 42 | FFTW_MPI_LINK = -lfftw3_mpi 43 | FFTW_OMP_LINK = -lfftw3_threads 44 | 45 | #=================================================== 46 | # Compile up all library defines from options above 47 | #=================================================== 48 | 49 | INC = -I$(FML_INCLUDE) 50 | LIB = 51 | LINK = 52 | OPTIONS = 53 | 54 | ifeq ($(USE_DEBUG),true) 55 | OPTIONS += -DDEBUG_FFTWGRID -DBOUNDSCHECK_FFTWGRID 56 | endif 57 | 58 | ifeq ($(USE_MPI),true) 59 | CC = $(MPICC) 60 | OPTIONS += -DUSE_MPI 61 | endif 62 | 63 | ifeq ($(USE_OMP),true) 64 | OPTIONS += -DUSE_OMP 65 | CC += -fopenmp 66 | endif 67 | 68 | ifeq ($(USE_SANITIZER),true) 69 | CC += -fsanitize=address 70 | endif 71 | 72 | ifeq ($(USE_FFTW),true) 73 | OPTIONS += -DUSE_FFTW 74 | INC += -I$(FFTW_INCLUDE) 75 | LIB += -L$(FFTW_LIB) 76 | ifeq ($(USE_MPI),true) 77 | LINK += $(FFTW_MPI_LINK) 78 | endif 79 | ifeq ($(USE_OMP),true) 80 | ifeq ($(USE_FFTW_THREADS),true) 81 | OPTIONS += -DUSE_FFTW_THREADS 82 | LINK += $(FFTW_OMP_LINK) 83 | endif 84 | endif 85 | LINK += $(FFTW_LINK) 86 | endif 87 | 88 | ifeq ($(USE_MEMORYLOG),true) 89 | OPTIONS += -DMEMORY_LOGGING 90 | endif 91 | 92 | TARGETS := fftwgrid 93 | all: $(TARGETS) 94 | .PHONY: all clean 95 | 96 | #=================================================== 97 | # Object files to be compiled 98 | #=================================================== 99 | 100 | VPATH := $(FML_INCLUDE)/FML/Global/ 101 | OBJS = Main.o Global.o 102 | OBJS_TEST = Test.o Global.o 103 | 104 | clean: 105 | rm -rf $(TARGETS) *.o 106 | 107 | fftwgrid: $(OBJS) 108 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 109 | 110 | test: $(OBJS_TEST) 111 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 112 | 113 | %.o: %.cpp 114 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 115 | 116 | -------------------------------------------------------------------------------- /FML/RamsesUtils/example/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //==================================================== 4 | // Simple particle type to store the data in 5 | // If you want to save memory and only want to read positions say 6 | // then you can remove the v[] etc. from the class 7 | // and just leave the related set_* methods blank (or 8 | // retuning a nullptr for *get_vel) 9 | //==================================================== 10 | 11 | template 12 | class RamsesParticle { 13 | private: 14 | double x[NDIM]; 15 | double v[NDIM]; 16 | double mass; 17 | int id; 18 | 19 | public: 20 | RamsesParticle() = default; 21 | ~RamsesParticle() = default; 22 | 23 | int get_ndim() { return NDIM; } 24 | 25 | // If any of these methods are not present then we will ignore it when 26 | // reading the file. So if you only have say get_pos then we will only 27 | // store the positions 28 | double * get_pos() { return x; } 29 | double * get_vel() { return v; } 30 | double get_mass() { return mass; }; 31 | void set_mass(double m) { mass = m; }; 32 | int get_id() { return id; }; 33 | void set_id(int i) { id = i; }; 34 | //int get_level() { return 0; }; 35 | //void set_level(int l) { (void)l; }; 36 | //char get_family() { return 1; }; 37 | //void set_family(char f) { (void)f; }; 38 | //char get_tag() { return 0;; }; 39 | //void set_tag(char t) { (void)t; }; 40 | }; 41 | 42 | //==================================================== 43 | // Examples on how to use the RamsesReader class 44 | //==================================================== 45 | 46 | int main() { 47 | const int NDIM = 3; 48 | using Particle = RamsesParticle; 49 | using RamsesReader = FML::FILEUTILS::RAMSES::RamsesReader; 50 | 51 | // Set up the Ramses reader 52 | // keep_only_particles_in_domain means each task only keeps particles in its own domain 53 | // so after we are done the particles are distributed among tasks 54 | // buffer_factor (1.0): If keep_only_particles_in_domain then we allocate this number times the 55 | // particles we need (only needed if we want extra capacity in the vector we store the particles in) 56 | std::string snapdir = "../../../TestData/ExampleRamsesSnapshot/output_00008"; 57 | const bool keep_only_particles_in_domain = true; 58 | const double buffer_factor = 1.0; 59 | const bool verbose = true; 60 | RamsesReader reader(snapdir, buffer_factor, keep_only_particles_in_domain, verbose); 61 | 62 | // The reader tries to automatically detect the particle file format from the header file 63 | // The default file format is POS,VEL,MASS,ID,LEVEL,FAMILY,TAG, 64 | // If it is not detected, it can be overridden like this: 65 | std::vector fileformat{"POS", "VEL", "MASS", "ID"}; 66 | reader.set_file_format(fileformat); 67 | 68 | // Read all particles and store it in p 69 | std::vector part; 70 | reader.read_ramses(part); 71 | 72 | std::cout << FML::ThisTask << " has " << part.size() << " local particles. Capacity of local storage: " << part.capacity() << "\n"; 73 | 74 | // Read a single file and store it in q 75 | // std::vector q; 76 | // reader.read_ramses_single(1, q); 77 | } 78 | -------------------------------------------------------------------------------- /FML/PGD/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -g -Wall -Wextra -march=native 10 | MPICC = mpicxx-mpich-gcc11 -std=c++1z -O3 -g -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = true 18 | # Use OpenMP threads 19 | USE_OMP = true 20 | # Use the FFTW library (required) 21 | USE_FFTW = true 22 | # Use threads in FFTW 23 | USE_FFTW_THREADS = false 24 | # Log allocations in the library 25 | USE_MEMORYLOG = true 26 | # Check for bad memory accesses 27 | USE_SANITIZER = false 28 | # Use GSL (required) 29 | USE_GSL = true 30 | 31 | #=================================================== 32 | # Include and library paths 33 | #=================================================== 34 | 35 | # Main library include (path to folder containin FML/) 36 | FML_INCLUDE = $(HOME)/local/FML 37 | 38 | # GSL : only needed if USE_GSL = true 39 | GSL_INCLUDE = $(HOME)/local/include 40 | GSL_LIB = $(HOME)/local/lib 41 | GSL_LINK = -lgsl -lgslcblas 42 | 43 | # FFTW 44 | FFTW_INCLUDE = $(HOME)/local/include 45 | FFTW_LIB = $(HOME)/local/lib 46 | FFTW_LINK = -lfftw3 47 | FFTW_MPI_LINK = -lfftw3_mpi 48 | FFTW_OMP_LINK = -lfftw3_threads 49 | 50 | #=================================================== 51 | # Compile up all library defines from options above 52 | #=================================================== 53 | 54 | INC = -I$(FML_INCLUDE) 55 | LIB = 56 | LINK = 57 | OPTIONS = 58 | 59 | ifeq ($(USE_MPI),true) 60 | CC = $(MPICC) 61 | OPTIONS += -DUSE_MPI 62 | endif 63 | 64 | ifeq ($(USE_OMP),true) 65 | OPTIONS += -DUSE_OMP 66 | CC += -fopenmp 67 | endif 68 | 69 | ifeq ($(USE_SANITIZER),true) 70 | CC += -fsanitize=address 71 | endif 72 | 73 | ifeq ($(USE_GSL),true) 74 | OPTIONS += -DUSE_GSL 75 | INC += -I$(GSL_INCLUDE) 76 | LIB += -L$(GSL_LIB) 77 | LINK += $(GSL_LINK) 78 | endif 79 | 80 | ifeq ($(USE_FFTW),true) 81 | OPTIONS += -DUSE_FFTW 82 | INC += -I$(FFTW_INCLUDE) 83 | LIB += -L$(FFTW_LIB) 84 | ifeq ($(USE_MPI),true) 85 | LINK += $(FFTW_MPI_LINK) 86 | endif 87 | ifeq ($(USE_OMP),true) 88 | ifeq ($(USE_FFTW_THREADS),true) 89 | OPTIONS += -DUSE_FFTW_THREADS 90 | LINK += $(FFTW_OMP_LINK) 91 | endif 92 | endif 93 | LINK += $(FFTW_LINK) 94 | endif 95 | 96 | ifeq ($(USE_MEMORYLOG),true) 97 | OPTIONS += -DMEMORY_LOGGING 98 | endif 99 | 100 | #=================================================== 101 | # Object files to be compiled 102 | #=================================================== 103 | 104 | VPATH = $(FML_INCLUDE)/FML/Global/:$(FML_INCLUDE)/FML/GadgetUtils/:$(FML_INCLUDE)/FML/FileUtils/:$(FML_INCLUDE)/FML/ODESolver/:$(FML_INCLUDE)/FML/Spline/ 105 | OBJS = Main.o Global.o GadgetUtils.o ODESolver.o Spline.o 106 | 107 | TARGETS := pgd 108 | all: $(TARGETS) 109 | .PHONY: all clean 110 | 111 | 112 | clean: 113 | rm -rf $(TARGETS) *.o 114 | 115 | pgd: $(OBJS) 116 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 117 | 118 | %.o: %.cpp 119 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 120 | 121 | -------------------------------------------------------------------------------- /FML/COLASolver/src/Cosmology_DGP.h: -------------------------------------------------------------------------------- 1 | #ifndef COSMOLOGY_DGP_HEADER 2 | #define COSMOLOGY_DGP_HEADER 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Cosmology.h" 12 | 13 | class CosmologyDGP final : public Cosmology { 14 | public: 15 | CosmologyDGP() { name = "DGP"; } 16 | 17 | //======================================================================== 18 | // Read the parameters we need 19 | //======================================================================== 20 | void read_parameters(ParameterMap & param) override { 21 | Cosmology::read_parameters(param); 22 | OmegaRC = param.get("cosmology_dgp_OmegaRC"); 23 | } 24 | 25 | //======================================================================== 26 | // Initialize the cosmology 27 | //======================================================================== 28 | void init() override { 29 | Cosmology::init(); 30 | 31 | // Set OmegaK from closure-condition 32 | double tmp = std::sqrt(OmegaRC) + std::sqrt(OmegaRC + OmegaCDM + Omegab + OmegaR + this->get_rhoNu_exact(1.0)); 33 | this->OmegaK = 1.0 - tmp * tmp; 34 | this->OmegaLambda = 0.0; 35 | } 36 | 37 | //======================================================================== 38 | // Print some info 39 | //======================================================================== 40 | void info() const override { 41 | Cosmology::info(); 42 | if (FML::ThisTask == 0) { 43 | std::cout << "# OmegaRC : " << OmegaRC << "\n"; 44 | std::cout << "# rcH0 : " << std::sqrt(0.25 / OmegaRC) << "\n"; 45 | std::cout << "#=====================================================\n"; 46 | std::cout << "\n"; 47 | } 48 | } 49 | 50 | //======================================================================== 51 | // Hubble function 52 | //======================================================================== 53 | double HoverH0_of_a(double a) const override { 54 | double tmp = std::sqrt(OmegaRC) + std::sqrt(OmegaRC + (OmegaCDM + Omegab) / (a * a * a) + 55 | OmegaR / (a * a * a * a) + this->get_rhoNu_exact(a)); 56 | return std::sqrt(OmegaK / (a * a) + tmp * tmp); 57 | } 58 | 59 | double dlogHdloga_of_a(double a) const override { 60 | double tmp1 = std::sqrt(OmegaRC + (OmegaCDM + Omegab) / (a * a * a) + OmegaR / (a * a * a * a) + 61 | this->get_rhoNu_exact(a)); 62 | double tmp2 = std::sqrt(OmegaRC) + tmp1; 63 | double H2 = OmegaK / (a * a) + tmp2 * tmp2; 64 | return -OmegaK / (a * a * H2) + tmp2 * 1.0 / (2.0 * tmp1) * 65 | (-3.0 * (OmegaCDM + Omegab) / (a * a * a * H2) - 66 | 4.0 * OmegaR / (a * a * a * a * H2) + this->get_drhoNudloga_exact(a) / H2); 67 | } 68 | 69 | protected: 70 | //======================================================================== 71 | // Parameters specific to the DGP model 72 | //======================================================================== 73 | double OmegaRC; 74 | }; 75 | #endif 76 | -------------------------------------------------------------------------------- /FML/Emulator/example/Makefile: -------------------------------------------------------------------------------- 1 | # Hans A. Winther (hans.a.winther@gmail.com) 2 | 3 | SHELL := /bin/bash 4 | 5 | #=================================================== 6 | # Set c++11 compliant compiler. If USE_MPI we use MPICC 7 | #=================================================== 8 | 9 | CC = g++ -std=c++1z -O3 -Wall -Wextra -march=native 10 | MPICC = mpicxx -std=c++1z -O3 -Wall -Wextra -march=native 11 | 12 | #=================================================== 13 | # Options 14 | #=================================================== 15 | 16 | # Use MPI 17 | USE_MPI = false 18 | # Use OpenMP threads 19 | USE_OMP = false 20 | # Use the GSL library (Spline, ODESolver) 21 | USE_GSL = true 22 | # Use the FFTW library 23 | USE_FFTW = false 24 | # Use threads in FFTW 25 | USE_FFTW_THREADS = false 26 | # Log allocations in the library 27 | USE_MEMORYLOG = false 28 | # Check for bad memory accesses 29 | USE_SANITIZER = false 30 | # Print more info as the code runs and do some more checks 31 | USE_DEBUG = false 32 | 33 | #=================================================== 34 | # Include and library paths 35 | #=================================================== 36 | 37 | # Main library include (path to folder containin FML/) 38 | FML_INCLUDE = $(HOME)/local/FML 39 | 40 | # GSL : only needed if USE_GSL = true 41 | GSL_INCLUDE = $(HOME)/local/include 42 | GSL_LIB = $(HOME)/local/lib 43 | GSL_LINK = -lgsl -lgslcblas 44 | 45 | # FFTW : only needed if USE_FFTW = true 46 | FFTW_INCLUDE = $(HOME)/local/include 47 | FFTW_LIB = $(HOME)/local/lib 48 | FFTW_LINK = -lfftw3 49 | FFTW_MPI_LINK = -lfftw3_mpi 50 | FFTW_OMP_LINK = -lfftw3_threads 51 | 52 | #=================================================== 53 | # Compile up all library defines from options above 54 | #=================================================== 55 | 56 | INC = -I$(FML_INCLUDE) 57 | LIB = 58 | LINK = 59 | OPTIONS = 60 | 61 | ifeq ($(USE_DEBUG),true) 62 | OPTIONS += 63 | endif 64 | 65 | ifeq ($(USE_GSL),true) 66 | OPTIONS += -DUSE_GSL 67 | INC += -I$(GSL_INCLUDE) 68 | LIB += -L$(GSL_LIB) 69 | LINK += $(GSL_LINK) 70 | endif 71 | 72 | ifeq ($(USE_MPI),true) 73 | CC = $(MPICC) 74 | OPTIONS += -DUSE_MPI 75 | endif 76 | 77 | ifeq ($(USE_OMP),true) 78 | OPTIONS += -DUSE_OMP 79 | CC += -fopenmp 80 | endif 81 | 82 | ifeq ($(USE_SANITIZER),true) 83 | CC += -fsanitize=address 84 | endif 85 | 86 | ifeq ($(USE_FFTW),true) 87 | OPTIONS += -DUSE_FFTW 88 | INC += -I$(FFTW_INCLUDE) 89 | LIB += -L$(FFTW_LIB) 90 | ifeq ($(USE_MPI),true) 91 | LINK += $(FFTW_MPI_LINK) 92 | endif 93 | ifeq ($(USE_OMP),true) 94 | ifeq ($(USE_FFTW_THREADS),true) 95 | OPTIONS += -DUSE_FFTW_THREADS 96 | LINK += $(FFTW_OMP_LINK) 97 | endif 98 | endif 99 | LINK += $(FFTW_LINK) 100 | endif 101 | 102 | ifeq ($(USE_MEMORYLOG),true) 103 | OPTIONS += -DMEMORY_LOGGING 104 | endif 105 | 106 | TARGETS := ee2 107 | all: $(TARGETS) 108 | .PHONY: all clean 109 | 110 | #=================================================== 111 | # Object files to be compiled 112 | #=================================================== 113 | 114 | VPATH := 115 | OBJS = Main.o 116 | 117 | clean: 118 | rm -rf $(TARGETS) *.o 119 | 120 | ee2: $(OBJS) 121 | ${CC} -o $@ $^ $(OPTIONS) $(LIB) $(LINK) 122 | 123 | %.o: %.cpp 124 | ${CC} -c -o $@ $< $(OPTIONS) $(INC) 125 | 126 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_COLA_NormalIC_TimesteppingQuinn/pofk_TestSim_cb_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) Pcb(k) (Mpc/h)^3 Pcb_linear(k) (Mpc/h)^3 2 | 0.0125664 38483.5 23293.7 3 | 0.0251327 19692.2 19792.1 4 | 0.0376991 12481.9 14768.9 5 | 0.0502655 9101.61 11660.7 6 | 0.0628319 8621.08 9940.15 7 | 0.0753982 8218.18 8324.29 8 | 0.0879646 5863.07 6600.31 9 | 0.100531 5292.71 5230.97 10 | 0.113097 4040.43 4439.98 11 | 0.125664 3961 4017.03 12 | 0.13823 3183.27 3552.44 13 | 0.150796 3003.42 2987.72 14 | 0.163363 2627.11 2500.08 15 | 0.175929 2243.59 2222.42 16 | 0.188496 2104.34 2059.96 17 | 0.201062 1862.6 1876.42 18 | 0.213628 1718.32 1643.95 19 | 0.226195 1542.51 1437.68 20 | 0.238761 1422.91 1303.89 21 | 0.251327 1309.38 1212.75 22 | 0.263894 1217.94 1120.28 23 | 0.27646 1127.12 1016.9 24 | 0.289027 1040.58 920.493 25 | 0.301593 987.609 845.297 26 | 0.314159 940.654 787.214 27 | 0.326726 870.396 734.49 28 | 0.339292 819.346 680.424 29 | 0.351858 759.131 628.175 30 | 0.364425 724.306 583.11 31 | 0.376991 694.35 546.333 32 | 0.389557 648.768 513.589 33 | 0.402124 625.783 481.886 34 | 0.41469 600.437 451.175 35 | 0.427257 580.15 422.854 36 | 0.439823 556.648 398.321 37 | 0.452389 509.687 376.428 38 | 0.464956 497.37 355.714 39 | 0.477522 468.471 335.983 40 | 0.490088 459.751 317.82 41 | 0.502655 440.719 301.214 42 | 0.515221 429.312 285.885 43 | 0.527788 412.774 271.657 44 | 0.540354 399.681 258.307 45 | 0.55292 373.011 245.757 46 | 0.565487 367.891 234.034 47 | 0.578053 351.86 223.216 48 | 0.590619 343.045 213.24 49 | 0.603186 338.004 203.748 50 | 0.615752 326.35 194.702 51 | 0.628319 316.478 186.187 52 | 0.640885 307.405 178.302 53 | 0.653451 303.115 170.895 54 | 0.666018 299.184 163.852 55 | 0.678584 288.014 157.239 56 | 0.69115 283.91 151.015 57 | 0.703717 280.82 145.148 58 | 0.716283 276.731 139.515 59 | 0.728849 272.064 134.201 60 | 0.741416 268.304 129.213 61 | 0.753982 267.86 124.447 62 | 0.766549 266.438 119.911 63 | 0.779115 266.782 115.613 64 | 0.791681 265.904 111.566 65 | 0.804248 264.884 107.722 66 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_noCOLA_NormalIC_TimesteppingQuinn/pofk_TestSim_cb_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) Pcb(k) (Mpc/h)^3 Pcb_linear(k) (Mpc/h)^3 2 | 0.0125664 35684.1 23293.7 3 | 0.0251327 18299.5 19792.1 4 | 0.0376991 11602.4 14768.9 5 | 0.0502655 8467.11 11660.7 6 | 0.0628319 8008.97 9940.15 7 | 0.0753982 7631.78 8324.29 8 | 0.0879646 5448.75 6600.31 9 | 0.100531 4887.29 5230.97 10 | 0.113097 3731.18 4439.98 11 | 0.125664 3656.81 4017.03 12 | 0.13823 2937.39 3552.44 13 | 0.150796 2758.33 2987.72 14 | 0.163363 2408.93 2500.08 15 | 0.175929 2052.54 2222.42 16 | 0.188496 1923.72 2059.96 17 | 0.201062 1690.97 1876.42 18 | 0.213628 1561.22 1643.95 19 | 0.226195 1394.95 1437.68 20 | 0.238761 1284.52 1303.89 21 | 0.251327 1181.77 1212.75 22 | 0.263894 1094.95 1120.28 23 | 0.27646 1011.39 1016.9 24 | 0.289027 931.885 920.493 25 | 0.301593 882.733 845.297 26 | 0.314159 838.59 787.214 27 | 0.326726 773.409 734.49 28 | 0.339292 725.555 680.424 29 | 0.351858 671.519 628.175 30 | 0.364425 639.888 583.11 31 | 0.376991 610.864 546.333 32 | 0.389557 569.683 513.589 33 | 0.402124 548.891 481.886 34 | 0.41469 525.468 451.175 35 | 0.427257 508.092 422.854 36 | 0.439823 484.642 398.321 37 | 0.452389 442.979 376.428 38 | 0.464956 432.346 355.714 39 | 0.477522 406.501 335.983 40 | 0.490088 398.451 317.82 41 | 0.502655 381.334 301.214 42 | 0.515221 369.728 285.885 43 | 0.527788 355.197 271.657 44 | 0.540354 343.617 258.307 45 | 0.55292 320.728 245.757 46 | 0.565487 315.599 234.034 47 | 0.578053 301.484 223.216 48 | 0.590619 294.538 213.24 49 | 0.603186 288.883 203.748 50 | 0.615752 278.453 194.702 51 | 0.628319 271.05 186.187 52 | 0.640885 262.028 178.302 53 | 0.653451 258.213 170.895 54 | 0.666018 254.464 163.852 55 | 0.678584 244.919 157.239 56 | 0.69115 241.053 151.015 57 | 0.703717 237.994 145.148 58 | 0.716283 234.206 139.515 59 | 0.728849 230.352 134.201 60 | 0.741416 227.231 129.213 61 | 0.753982 226.013 124.447 62 | 0.766549 225.053 119.911 63 | 0.779115 225.211 115.613 64 | 0.791681 225.078 111.566 65 | 0.804248 223.455 107.722 66 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_dgp/output/snapshot_DGP_z0.000/pofk_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) P(k) (Mpc/h)^3 P_linear(k) (Mpc/h)^3 2 | 0.00801824 23378.5 23705.7 3 | 0.0140165 28761.1 29071 4 | 0.0196925 29024.3 29140.9 5 | 0.0255134 25984.7 26628.5 6 | 0.0320291 21733.5 22790.9 7 | 0.0384652 18599.2 19283.8 8 | 0.0444331 16047.3 16790.9 9 | 0.0504231 13719.6 15049.4 10 | 0.0569093 12600.8 13789.2 11 | 0.0634184 11237.9 12825.4 12 | 0.0694999 10180 11934 13 | 0.0755813 9419.91 10922.7 14 | 0.0819627 7831.28 9745.41 15 | 0.0883023 7448.87 8574.56 16 | 0.0943521 6368.83 7574.09 17 | 0.10056 5732.83 6749.31 18 | 0.107014 4975.48 6138.13 19 | 0.113427 4501.29 5737.63 20 | 0.119609 4175.15 5463.87 21 | 0.12578 3943.86 5220.42 22 | 0.132149 3688.99 4940.34 23 | 0.138456 3321.28 4608.54 24 | 0.14465 3029.98 4242.65 25 | 0.150853 2743.33 3871.04 26 | 0.157173 2557.16 3525.42 27 | 0.163542 2272.49 3239.69 28 | 0.169825 2074.73 3029.61 29 | 0.176101 1978.33 2879.63 30 | 0.1824 1824.29 2765.05 31 | 0.188651 1703.68 2662.64 32 | 0.194908 1601.84 2552.49 33 | 0.201142 1507.72 2425.24 34 | 0.207395 1339.89 2281.99 35 | 0.213739 1278.14 2131.91 36 | 0.220033 1191.91 1991.34 37 | 0.226293 1108.36 1869.59 38 | 0.232598 1024.29 1769.54 39 | 0.238889 981.083 1690.7 40 | 0.245122 921.516 1627.49 41 | 0.251374 865.293 1571.4 42 | 0.257707 823.518 1514.77 43 | 0.26402 755.575 1453.77 44 | 0.27029 715.364 1388.44 45 | 0.276561 678.987 1321.05 46 | 0.28287 646.167 1254.96 47 | 0.289148 610.26 1194.26 48 | 0.295352 584.101 1141.53 49 | 0.301607 543.577 1096.11 50 | 0.307938 522.591 1056.57 51 | 0.314276 488.184 1021.07 52 | 0.320546 463.653 987.623 53 | 0.326813 442.888 954.05 54 | 0.333124 422.923 919.387 55 | 0.339404 404.519 884.206 56 | 0.345639 380.364 849.731 57 | 0.351881 364.374 816.807 58 | 0.358203 348.014 785.967 59 | 0.364512 333.408 758.068 60 | 0.370764 319.142 733.103 61 | 0.377054 305.237 710.113 62 | 0.383359 293.292 688.407 63 | 0.389651 279.157 667.445 64 | 0.395877 270.863 646.91 65 | 0.402094 256.184 626.546 66 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_dgp/output/snapshot_LCDM_z0.000/pofk_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) P(k) (Mpc/h)^3 P_linear(k) (Mpc/h)^3 2 | 0.00801824 20493.2 20772.9 3 | 0.0140165 25211.9 25474.4 4 | 0.0196925 25436.4 25535.7 5 | 0.0255134 22799.1 23334.1 6 | 0.0320291 19091.9 19971.2 7 | 0.0384652 16328.9 16898.1 8 | 0.0444331 14085.5 14713.6 9 | 0.0504231 12070.2 13187.5 10 | 0.0569093 11081.4 12083.2 11 | 0.0634184 9894.07 11238.6 12 | 0.0694999 8972.56 10457.5 13 | 0.0755813 8291.59 9571.38 14 | 0.0819627 6908.03 8539.74 15 | 0.0883023 6540.04 7513.74 16 | 0.0943521 5590.29 6637.04 17 | 0.10056 5019.1 5914.3 18 | 0.107014 4355.71 5378.74 19 | 0.113427 3933.69 5027.78 20 | 0.119609 3657.63 4787.89 21 | 0.12578 3453.07 4574.57 22 | 0.132149 3223.51 4329.13 23 | 0.138456 2903.33 4038.38 24 | 0.14465 2640.92 3717.76 25 | 0.150853 2386.63 3392.12 26 | 0.157173 2213.64 3089.27 27 | 0.163542 1969 2838.89 28 | 0.169825 1790.09 2654.8 29 | 0.176101 1707.36 2523.37 30 | 0.1824 1572.55 2422.96 31 | 0.188651 1465.04 2333.23 32 | 0.194908 1374.34 2236.71 33 | 0.201142 1292.17 2125.2 34 | 0.207395 1144.28 1999.67 35 | 0.213739 1088.58 1868.16 36 | 0.220033 1012.04 1744.98 37 | 0.226293 941.201 1638.29 38 | 0.232598 867.668 1550.61 39 | 0.238889 830.467 1481.53 40 | 0.245122 775.994 1426.14 41 | 0.251374 728.517 1376.99 42 | 0.257707 689.365 1327.37 43 | 0.26402 632.456 1273.91 44 | 0.27029 597.463 1216.66 45 | 0.276561 565.298 1157.61 46 | 0.28287 537.339 1099.7 47 | 0.289148 506.325 1046.51 48 | 0.295352 483.05 1000.31 49 | 0.301607 447.9 960.499 50 | 0.307938 429.641 925.852 51 | 0.314276 401.47 894.743 52 | 0.320546 379.801 865.437 53 | 0.326813 361.975 836.018 54 | 0.333124 344.326 805.643 55 | 0.339404 329.137 774.815 56 | 0.345639 307.646 744.605 57 | 0.351881 295.561 715.754 58 | 0.358203 280.893 688.73 59 | 0.364512 268.428 664.282 60 | 0.370764 257.017 642.406 61 | 0.377054 244.839 622.26 62 | 0.383359 234.62 603.239 63 | 0.389651 222.725 584.871 64 | 0.395877 215.702 566.876 65 | 0.402094 203.576 549.031 66 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_fofr/output/snapshot_FOFR_z0.000/pofk_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) P(k) (Mpc/h)^3 P_linear(k) (Mpc/h)^3 2 | 0.00801824 20503.2 20785.2 3 | 0.0140165 25253.3 25520.2 4 | 0.0196925 25516.2 25625.5 5 | 0.0255134 22915.4 23470.3 6 | 0.0320291 19239.7 20152.2 7 | 0.0384652 16497.3 17114.9 8 | 0.0444331 14265.7 14960.7 9 | 0.0504231 12253.3 13466.6 10 | 0.0569093 11276.5 12400.7 11 | 0.0634184 10089.1 11595.3 12 | 0.0694999 9165.96 10845.2 13 | 0.0755813 8477.72 9979.11 14 | 0.0819627 7074.73 8954.27 15 | 0.0883023 6706.89 7923.59 16 | 0.0943521 5738.16 7037.5 17 | 0.10056 5157.72 6306.46 18 | 0.107014 4480.92 5768.76 19 | 0.113427 4052.22 5423.23 20 | 0.119609 3771.74 5192.6 21 | 0.12578 3564.05 4987.8 22 | 0.132149 3328.41 4745.81 23 | 0.138456 3000.17 4450.39 24 | 0.14465 2733.41 4117.8 25 | 0.150853 2471.51 3775.76 26 | 0.157173 2295.81 3455.63 27 | 0.163542 2044 3190.97 28 | 0.169825 1862.52 2997.99 29 | 0.176101 1776.25 2862.53 30 | 0.1824 1638.02 2760.86 31 | 0.188651 1527.08 2670.05 32 | 0.194908 1434.29 2570.34 33 | 0.201142 1349.3 2452.16 34 | 0.207395 1196.15 2316.52 35 | 0.213739 1138.92 2172.7 36 | 0.220033 1060.18 2037.17 37 | 0.226293 987.063 1919.69 38 | 0.232598 909.97 1823.55 39 | 0.238889 872.034 1748.46 40 | 0.245122 814.998 1688.83 41 | 0.251374 766.033 1636.09 42 | 0.257707 725.985 1582.34 43 | 0.26402 665.73 1523.5 44 | 0.27029 629.622 1459.57 45 | 0.276561 596.213 1392.97 46 | 0.28287 567.109 1327.25 47 | 0.289148 534.704 1266.74 48 | 0.295352 510.586 1214.23 49 | 0.301607 473.598 1169.15 50 | 0.307938 454.73 1130.08 51 | 0.314276 425.075 1095.06 52 | 0.320546 402.17 1061.96 53 | 0.326813 383.644 1028.49 54 | 0.333124 365.277 993.627 55 | 0.339404 349.267 957.96 56 | 0.345639 326.656 922.818 57 | 0.351881 314.136 889.151 58 | 0.358203 298.571 857.582 59 | 0.364512 285.643 829.036 60 | 0.370764 273.68 803.52 61 | 0.377054 260.92 780.035 62 | 0.383359 250.167 757.83 63 | 0.389651 237.587 736.314 64 | 0.395877 230.171 715.134 65 | 0.402094 217.379 694.026 66 | -------------------------------------------------------------------------------- /FML/COLASolver/examples/example_run_with_fofr/output/snapshot_LCDM_z0.000/pofk_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) P(k) (Mpc/h)^3 P_linear(k) (Mpc/h)^3 2 | 0.00801824 20493.2 20772.9 3 | 0.0140165 25211.9 25474.4 4 | 0.0196925 25436.4 25535.7 5 | 0.0255134 22799.1 23334.1 6 | 0.0320291 19091.9 19971.2 7 | 0.0384652 16328.9 16898.1 8 | 0.0444331 14085.5 14713.6 9 | 0.0504231 12070.2 13187.5 10 | 0.0569093 11081.4 12083.2 11 | 0.0634184 9894.07 11238.6 12 | 0.0694999 8972.56 10457.5 13 | 0.0755813 8291.59 9571.38 14 | 0.0819627 6908.03 8539.74 15 | 0.0883023 6540.04 7513.74 16 | 0.0943521 5590.29 6637.04 17 | 0.10056 5019.1 5914.3 18 | 0.107014 4355.71 5378.74 19 | 0.113427 3933.69 5027.78 20 | 0.119609 3657.63 4787.89 21 | 0.12578 3453.07 4574.57 22 | 0.132149 3223.51 4329.13 23 | 0.138456 2903.33 4038.38 24 | 0.14465 2640.92 3717.76 25 | 0.150853 2386.63 3392.12 26 | 0.157173 2213.64 3089.27 27 | 0.163542 1969 2838.89 28 | 0.169825 1790.09 2654.8 29 | 0.176101 1707.36 2523.37 30 | 0.1824 1572.55 2422.96 31 | 0.188651 1465.04 2333.23 32 | 0.194908 1374.34 2236.71 33 | 0.201142 1292.17 2125.2 34 | 0.207395 1144.28 1999.67 35 | 0.213739 1088.58 1868.16 36 | 0.220033 1012.04 1744.98 37 | 0.226293 941.201 1638.29 38 | 0.232598 867.668 1550.61 39 | 0.238889 830.467 1481.53 40 | 0.245122 775.994 1426.14 41 | 0.251374 728.517 1376.99 42 | 0.257707 689.365 1327.37 43 | 0.26402 632.456 1273.91 44 | 0.27029 597.463 1216.66 45 | 0.276561 565.298 1157.61 46 | 0.28287 537.339 1099.7 47 | 0.289148 506.325 1046.51 48 | 0.295352 483.05 1000.31 49 | 0.301607 447.9 960.499 50 | 0.307938 429.641 925.852 51 | 0.314276 401.47 894.743 52 | 0.320546 379.801 865.437 53 | 0.326813 361.975 836.018 54 | 0.333124 344.326 805.643 55 | 0.339404 329.137 774.815 56 | 0.345639 307.646 744.605 57 | 0.351881 295.561 715.754 58 | 0.358203 280.893 688.73 59 | 0.364512 268.428 664.282 60 | 0.370764 257.017 642.406 61 | 0.377054 244.839 622.26 62 | 0.383359 234.62 603.239 63 | 0.389651 222.725 584.871 64 | 0.395877 215.702 566.876 65 | 0.402094 203.576 549.031 66 | -------------------------------------------------------------------------------- /FML/COLASolver/tests/LCDM_noCOLA_fixedAmplitudeIC_TimesteppingQuinn/pofk_TestSim_cb_z0.000.txt: -------------------------------------------------------------------------------- 1 | # k (h/Mpc) Pcb(k) (Mpc/h)^3 Pcb_linear(k) (Mpc/h)^3 2 | 0.0125664 21021.1 23293.7 3 | 0.0251327 18204.2 19792.1 4 | 0.0376991 13243.1 14768.9 5 | 0.0502655 10306.6 11660.7 6 | 0.0628319 8948.22 9940.15 7 | 0.0753982 7151.9 8324.29 8 | 0.0879646 5959.57 6600.31 9 | 0.100531 4505.73 5230.97 10 | 0.113097 3889.4 4439.98 11 | 0.125664 3474.92 4017.03 12 | 0.13823 3169.86 3552.44 13 | 0.150796 2642.03 2987.72 14 | 0.163363 2235.77 2500.08 15 | 0.175929 2141.95 2222.42 16 | 0.188496 1886.48 2059.96 17 | 0.201062 1676.46 1876.42 18 | 0.213628 1542.1 1643.95 19 | 0.226195 1330.18 1437.68 20 | 0.238761 1286.9 1303.89 21 | 0.251327 1214.44 1212.75 22 | 0.263894 1103.95 1120.28 23 | 0.27646 1024.74 1016.9 24 | 0.289027 936.597 920.493 25 | 0.301593 887.166 845.297 26 | 0.314159 826.096 787.214 27 | 0.326726 774.352 734.49 28 | 0.339292 723.078 680.424 29 | 0.351858 663.425 628.175 30 | 0.364425 644.301 583.11 31 | 0.376991 617.697 546.333 32 | 0.389557 585.879 513.589 33 | 0.402124 543.065 481.886 34 | 0.41469 510.909 451.175 35 | 0.427257 510.467 422.854 36 | 0.439823 471.596 398.321 37 | 0.452389 453.02 376.428 38 | 0.464956 428.165 355.714 39 | 0.477522 415.488 335.983 40 | 0.490088 401.917 317.82 41 | 0.502655 383.526 301.214 42 | 0.515221 371.746 285.885 43 | 0.527788 353.891 271.657 44 | 0.540354 345.523 258.307 45 | 0.55292 335.851 245.757 46 | 0.565487 320.875 234.034 47 | 0.578053 311.454 223.216 48 | 0.590619 300.134 213.24 49 | 0.603186 293.276 203.748 50 | 0.615752 282.516 194.702 51 | 0.628319 275.239 186.187 52 | 0.640885 267.759 178.302 53 | 0.653451 264.103 170.895 54 | 0.666018 255.419 163.852 55 | 0.678584 252.071 157.239 56 | 0.69115 247.781 151.015 57 | 0.703717 240.643 145.148 58 | 0.716283 239.863 139.515 59 | 0.728849 236.468 134.201 60 | 0.741416 233.862 129.213 61 | 0.753982 234.156 124.447 62 | 0.766549 232.936 119.911 63 | 0.779115 236.508 115.613 64 | 0.791681 232.816 111.566 65 | 0.804248 235.178 107.722 66 | --------------------------------------------------------------------------------