From ce8a09caa3d843e234bf0211c1bad816fd491032 Mon Sep 17 00:00:00 2001 From: Andrea Contu Date: Mon, 24 Feb 2020 17:32:58 +0100 Subject: [PATCH 01/21] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ba5f411..5e78ee8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![DOI](https://zenodo.org/badge/164617844.svg)](https://zenodo.org/badge/latestdoi/164617844) + ## What is it? From b8c60cfa0990dd9ce1efd9185b345557597afe61 Mon Sep 17 00:00:00 2001 From: Andrea Contu Date: Wed, 17 Jun 2020 15:06:11 +0200 Subject: [PATCH 02/21] Update Evolve.h Avoid dot product bug in Hydra --- include/simulation/Evolve.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/simulation/Evolve.h b/include/simulation/Evolve.h index 1db18a2..aa2930c 100644 --- a/include/simulation/Evolve.h +++ b/include/simulation/Evolve.h @@ -241,7 +241,7 @@ namespace evolve{ auto Vdrift = k1 +ref; //calculate current with Ramo's theorem - hydra::get<5>(p)=hydra::get<_tc_charge>(p)*HCHARGE*(Vdrift.dot(wfvec)); + hydra::get<5>(p)=hydra::get<_tc_charge>(p)*HCHARGE*(Vdrift.get(0)*wfvec.get(0)+Vdrift.get(1)*wfvec.get(1)+Vdrift.get(2)*wfvec.get(2)); } size_t _fN; @@ -373,7 +373,7 @@ namespace evolve{ auto Vdrift = k1 +ref; //calculate current with Ramo's theorem - hydra::get<5>(p)=hydra::get<_tc_charge>(p)*HCHARGE*(Vdrift.dot(wfvec)); + hydra::get<5>(p)=hydra::get<_tc_charge>(p)*HCHARGE*(Vdrift.get(0)*wfvec.get(0)+Vdrift.get(1)*wfvec.get(1)+Vdrift.get(2)*wfvec.get(2)); } From 808618e664380b18fe53db7e9b39d609d5072208 Mon Sep 17 00:00:00 2001 From: acontu Date: Wed, 17 Jun 2020 15:36:20 +0200 Subject: [PATCH 03/21] Bump up copyright --- INSTALL.md | 2 +- include/analysis.h | 2 +- include/deposits/E_deposit.cpp | 2 +- include/deposits/E_deposit.h | 2 +- include/deposits/deposit.h | 2 +- include/details/constants.h | 2 +- include/details/datatypes.h | 2 +- include/details/defaults.h | 2 +- include/details/utils.h | 2 +- include/loadfiles.h | 2 +- include/main.inl | 2 +- include/main_maps.inl | 2 +- include/maps/preparemaps.h | 2 +- include/plotstyle.C | 2 +- include/simulation/Evolve.h | 2 +- include/simulation/HydraSim.h | 2 +- include/simulation/simulation.h | 2 +- src/loadmaps.cpp | 2 +- src/loadmaps.cu | 2 +- src/simulation.cpp | 17 ++++++++--------- src/simulation.cu | 16 ++++++++-------- 21 files changed, 35 insertions(+), 36 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 6f17741..eedf5ef 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,7 +1,7 @@ Build application ------------------------------- Make sure that you have the following packages available in your system: -- [Hydra >= v2.3.1](https://github.com/MultithreadCorner/Hydra/releases/tag/v2.3.1) +- [Hydra = v2.3.1](https://github.com/MultithreadCorner/Hydra/releases/tag/v2.3.1) - [libconfig >= v1.5](https://github.com/hyperrealm/libconfig) - [TCLAP >= v1.2.1](http://tclap.sourceforge.net/) - [ROOT >= v6.14](https://root.cern.ch/) diff --git a/include/analysis.h b/include/analysis.h index 7145c93..3c515b3 100644 --- a/include/analysis.h +++ b/include/analysis.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/deposits/E_deposit.cpp b/include/deposits/E_deposit.cpp index e750557..81ecf8a 100644 --- a/include/deposits/E_deposit.cpp +++ b/include/deposits/E_deposit.cpp @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/deposits/E_deposit.h b/include/deposits/E_deposit.h index 8ec14ff..455a300 100644 --- a/include/deposits/E_deposit.h +++ b/include/deposits/E_deposit.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/deposits/deposit.h b/include/deposits/deposit.h index ab29dd8..605769b 100644 --- a/include/deposits/deposit.h +++ b/include/deposits/deposit.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/details/constants.h b/include/details/constants.h index 4f054a2..ddbc349 100644 --- a/include/details/constants.h +++ b/include/details/constants.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/details/datatypes.h b/include/details/datatypes.h index 786143b..fa5643b 100644 --- a/include/details/datatypes.h +++ b/include/details/datatypes.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/details/defaults.h b/include/details/defaults.h index a5f53de..e073c69 100644 --- a/include/details/defaults.h +++ b/include/details/defaults.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/details/utils.h b/include/details/utils.h index 1885dbd..c12db34 100644 --- a/include/details/utils.h +++ b/include/details/utils.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/loadfiles.h b/include/loadfiles.h index 604cd88..da8bd67 100644 --- a/include/loadfiles.h +++ b/include/loadfiles.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/main.inl b/include/main.inl index dfb3c8f..9760572 100644 --- a/include/main.inl +++ b/include/main.inl @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/main_maps.inl b/include/main_maps.inl index 0b74bd8..b698fad 100644 --- a/include/main_maps.inl +++ b/include/main_maps.inl @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/maps/preparemaps.h b/include/maps/preparemaps.h index af020cf..0adc605 100644 --- a/include/maps/preparemaps.h +++ b/include/maps/preparemaps.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/plotstyle.C b/include/plotstyle.C index ea2d851..26ea04c 100644 --- a/include/plotstyle.C +++ b/include/plotstyle.C @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/simulation/Evolve.h b/include/simulation/Evolve.h index aa2930c..2dca0ed 100644 --- a/include/simulation/Evolve.h +++ b/include/simulation/Evolve.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/simulation/HydraSim.h b/include/simulation/HydraSim.h index 85d3a96..096431c 100644 --- a/include/simulation/HydraSim.h +++ b/include/simulation/HydraSim.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/include/simulation/simulation.h b/include/simulation/simulation.h index d92e995..0ccf015 100644 --- a/include/simulation/simulation.h +++ b/include/simulation/simulation.h @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018-2019 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/src/loadmaps.cpp b/src/loadmaps.cpp index 8463d05..27b27c7 100644 --- a/src/loadmaps.cpp +++ b/src/loadmaps.cpp @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/src/loadmaps.cu b/src/loadmaps.cu index 77eefb0..323d088 100644 --- a/src/loadmaps.cu +++ b/src/loadmaps.cu @@ -1,6 +1,6 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2018 Andrea Contu e Angelo Loi + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * * This file is part of TCode software. * diff --git a/src/simulation.cpp b/src/simulation.cpp index 117646c..4a935b5 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -1,31 +1,30 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2016 Antonio Augusto Alves Junior e Andrea Contu + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * - * This file is part of MassMeasurement software. + * This file is part of TCode software. * - * MassMeasurement is free software: you can redistribute it and/or modify + * TCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * MassMeasurement is distributed in the hope that it will be useful, + * TCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Hydra. If not, see . + * along with TCode. If not, see . * *---------------------------------------------------------------------------*/ /* - * analysis.cpp + * simulations.cpp * - * Created on: 30/01/2018 - * Author: Antonio Augusto Alves Junior + * Created on: 27/12/2018 + * Author: Andrea Contu */ - #include diff --git a/src/simulation.cu b/src/simulation.cu index bfec629..b86ec1b 100644 --- a/src/simulation.cu +++ b/src/simulation.cu @@ -1,28 +1,28 @@ /*---------------------------------------------------------------------------- * - * Copyright (C) 2016 Antonio Augusto Alves Junior e Andrea Contu + * Copyright (C) 2018-2020 Andrea Contu e Angelo Loi * - * This file is part of MassMeasurement software. + * This file is part of TCode software. * - * MassMeasurement is free software: you can redistribute it and/or modify + * TCode is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * MassMeasurement is distributed in the hope that it will be useful, + * TCode is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Hydra. If not, see . + * along with TCode. If not, see . * *---------------------------------------------------------------------------*/ /* - * analysis.cu + * simulation.cu * - * Created on: 30/01/2018 - * Author: Antonio Augusto Alves Junior + * Created on: 27/12/2018 + * Author: Andrea Contu */ From f9c24a30383ba313646b56d4df531ff8e383736c Mon Sep 17 00:00:00 2001 From: Andrea Contu Date: Wed, 21 Oct 2020 11:20:58 +0200 Subject: [PATCH 04/21] Update HydraSim.h Fix bug when reusing cached deposit --- include/simulation/HydraSim.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/simulation/HydraSim.h b/include/simulation/HydraSim.h index 096431c..1a2cb19 100644 --- a/include/simulation/HydraSim.h +++ b/include/simulation/HydraSim.h @@ -61,6 +61,8 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ double simulationtime=0; std::string tmpfile=std::get(configlist[0].get("path")); + size_t tmpparticles=std::get(configlist[0].get("nparticles")); + size_t tmpgroup=std::get(configlist[0].get("group")); RunningStateHost_t data_dinit; if(tmpfile==DEFAULT_PATH) data_dinit = loaddata::getDummy( std::get(configlist[0].get("nparticles")), @@ -90,7 +92,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ auto length = std::get(cf.get("length")); auto start = std::chrono::high_resolution_clock::now(); - if(path!=tmpfile){ + if(path!=tmpfile || nparticles!=tmpparticles || group!=tmpgroup){ tmpfile=path; if(tmpfile==DEFAULT_PATH) data_dinit=loaddata::getDummy(nparticles,length,group); else data_dinit=loaddata::loadfile(tmpfile,group); @@ -269,6 +271,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ } } + //information about process time auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration elapsed = end - start; std::cout << std::endl; @@ -289,12 +292,14 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ settings["x shift"]=Form("%g #mu m",xshift); settings["y shift"]=Form("%g #mu m",yshift); settings["z shift"]=Form("%g #mu m",zshift); + if(!(extrainfo || plot)) analysis::AnalyseSim(tp_currs,timestep,settings); else{ analysis::AnalyseSim(tp_currs,timestep,settings); analysis::ExtraPlots(states_host, tp_currs, h3, timestep, settings, extrainfo, plot); } + } sim++; } From 4cbffe047d1face334b81ac4bf5142b1d6e70749 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:14:49 +0100 Subject: [PATCH 05/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e78ee8..8aa8e75 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ TCode uses external 3D maps of electric fields, carrier mobilities and weighting TCode depends on [ROOT >= v.6.14](https://github.com/root-project/root), [libconfig >= v1.5](https://hyperrealm.github.io/libconfig/), [TCLAP >= v1.2.1](http://tclap.sourceforge.net/) and optionally [CUDA >= 10.0](https://developer.nvidia.com/cuda-toolkit) (needed for nVidia GPUs). ## Manual -IN PREPARATION +### Parameter file ## Authors TCode was created by [Andrea Contu](https://github.com/acontu) and [Angelo Loi](https://github.com/angeloloi19). From 8c3465997d8726f6f126c96a876699710675536b Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:26:52 +0100 Subject: [PATCH 06/21] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 8aa8e75..175ebcb 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ TCode depends on [ROOT >= v.6.14](https://github.com/root-project/root), [libcon ## Manual ### Parameter file +Every simulation is set by defining its parameters on the configuration file. Each configuration file has 3 main sections: +1. OutputDirectory: This output sets the folder where all the results of the simulations will be stored + `OutputDirectory = "/path/to/output"` +3. PhysicsMaps: This section contains the paths where the physics maps are stored. It is possibile to call a single physics file which contains all needed physics or 4 different files which contains the electric field (efield), wheighting field (wfield), electron mobility (emob) and hole mobility (hmob). + `PhysicsMaps:{ + efield = "path/to/efield_map" + wfield = "path/to/wfield_map" + emob = "path/to/emob_map" + hmob = "path/to/hmob_map" + }` +5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. ## Authors TCode was created by [Andrea Contu](https://github.com/acontu) and [Angelo Loi](https://github.com/angeloloi19). From 64a297079721c5b35c0b9d221101e82d3e01c825 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:32:33 +0100 Subject: [PATCH 07/21] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 175ebcb..9225af2 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,13 @@ Every simulation is set by defining its parameters on the configuration file. Ea 1. OutputDirectory: This output sets the folder where all the results of the simulations will be stored `OutputDirectory = "/path/to/output"` 3. PhysicsMaps: This section contains the paths where the physics maps are stored. It is possibile to call a single physics file which contains all needed physics or 4 different files which contains the electric field (efield), wheighting field (wfield), electron mobility (emob) and hole mobility (hmob). - `PhysicsMaps:{ + ```PhysicsMaps:{ efield = "path/to/efield_map" wfield = "path/to/wfield_map" emob = "path/to/emob_map" hmob = "path/to/hmob_map" - }` + }``` + 5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. ## Authors From b8c85983e424126f169dacdea77e3b5a4716027a Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:33:12 +0100 Subject: [PATCH 08/21] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9225af2..22addf4 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,14 @@ Every simulation is set by defining its parameters on the configuration file. Ea 1. OutputDirectory: This output sets the folder where all the results of the simulations will be stored `OutputDirectory = "/path/to/output"` 3. PhysicsMaps: This section contains the paths where the physics maps are stored. It is possibile to call a single physics file which contains all needed physics or 4 different files which contains the electric field (efield), wheighting field (wfield), electron mobility (emob) and hole mobility (hmob). - ```PhysicsMaps:{ + ``` + PhysicsMaps:{ efield = "path/to/efield_map" wfield = "path/to/wfield_map" emob = "path/to/emob_map" hmob = "path/to/hmob_map" - }``` + } + ``` 5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. From 0dc5331ebb1fa764cfc8bb6936fb2c2cc8dd08ad Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:34:25 +0100 Subject: [PATCH 09/21] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 22addf4..48be1c6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,12 @@ Every simulation is set by defining its parameters on the configuration file. Ea hmob = "path/to/hmob_map" } ``` - +The alternative with the all-physics maps is called with the keyword `map`: + ``` + PhysicsMaps:{ + map = "path/to/physics_map" + } + ``` 5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. ## Authors From 45e9c267586198cece88cd4a9a1007ab6327a89c Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:45:56 +0100 Subject: [PATCH 10/21] Update README.md --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 48be1c6..505fe34 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,38 @@ Every simulation is set by defining its parameters on the configuration file. Ea hmob = "path/to/hmob_map" } ``` -The alternative with the all-physics maps is called with the keyword `map`: + The alternative with the all-physics maps is called with the keyword `map`: ``` PhysicsMaps:{ map = "path/to/physics_map" } ``` -5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. +5. InputData: This section sets the name of every single simulation, its parameters like the timestep and the number of time steps. Furthermore InputData defines the energy deposit and how it is build. + ``` + InputData: + { + SimulationName: + { + name = "SimulationName"; + steps = 100; + timestep = 1e-12; + plot = false; + process = true; + extrainfo = false; + T = 300.; + path = "path/to/energyDeposit.dat" + customdeposit = "NO"; + particles = 0; + Aexpl = 0.; + Sexpl = 5e-12; + Xshift = 2.; + Yshift = 2.; + Zshift = 0.; + Length = 100.; + BunchSize = 600; + } + } + ``` ## Authors TCode was created by [Andrea Contu](https://github.com/acontu) and [Angelo Loi](https://github.com/angeloloi19). From edd60e56f43c16e7fb4c63e6b57e5bbbd4680e11 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:54:44 +0100 Subject: [PATCH 11/21] Update README.md some info about parameter file --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 505fe34..3324393 100644 --- a/README.md +++ b/README.md @@ -45,11 +45,10 @@ Every simulation is set by defining its parameters on the configuration file. Ea process = true; extrainfo = false; T = 300.; + group = 1; path = "path/to/energyDeposit.dat" customdeposit = "NO"; particles = 0; - Aexpl = 0.; - Sexpl = 5e-12; Xshift = 2.; Yshift = 2.; Zshift = 0.; @@ -58,7 +57,17 @@ Every simulation is set by defining its parameters on the configuration file. Ea } } ``` - +### The parameters +1. `name`(string): is the nickname for the simulation +2. `path`(string): indicates the path where the specifications of the energy deposit are located +3. `plot`(bool): if `true` generates a gif containing charge drift and signal plotting (timeconsuming!) +4. `extrainfo`(bool): generates snapshots for all simulation steps (timeconsuming!) +5. `steps`: Indicates the number of timesteps required to run the transient simulation +6. `timestep`: Is the minimum advancement in time requested for the transient simulation +7. `particles`: Is the number of particles requested for the dummy deposit (if path is activated, particles does not work). +8. `X/Y/Zshift`: Allows to shift (in micrometres) the energy deposit (imported or dummy). +9. `Length`: Lenght of the dummy deposit (does not work if path activated). +10. `group`: Allows group a large number of electron hole pairs. ## Authors TCode was created by [Andrea Contu](https://github.com/acontu) and [Angelo Loi](https://github.com/angeloloi19). From b0e3822794861b9ef0949f612d182dd25d357463 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:20:42 +0100 Subject: [PATCH 12/21] Update analysis.h --- include/analysis.h | 94 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/include/analysis.h b/include/analysis.h index 3c515b3..2ee8461 100644 --- a/include/analysis.h +++ b/include/analysis.h @@ -138,6 +138,90 @@ namespace analysis{ void AnalyseSim(std::vector &tp_currs, double timestep, std::map settings){ + INFO_LINE("Writing .dat file") + + std::ofstream myfile; + myfile.open(Form("%s/%s.dat",settings["outputdir"].c_str(),settings["name"].c_str())); + + double t_ec=0, t_hc=0, t_tc=0, t_time=0, t_einduced=0, t_hinduced=0, t_tinduced=0, t_elost=0, t_hlost=0, t_tlost=0; + double t_ec_sec=0, t_hc_sec=0, t_tc_sec=0, t_einduced_sec=0, t_hinduced_sec=0, t_tinduced_sec=0, t_elost_sec=0, t_hlost_sec=0, t_tlost_sec=0; + + double currmax=-999999; + double chargemax=-999999; + double currmin=-0; + double chargemin=-0; + unsigned pl=0; + + for(auto& curr:tp_currs){ + + double ce=hydra::get<1>(curr); + double ch=hydra::get<0>(curr); + double ct=ce+ch; + double ce_sec=hydra::get<3>(curr); + double ch_sec=hydra::get<2>(curr); + double ct_sec=ce_sec+ch_sec; + + t_ec=ce; + t_hc=ch; + t_tc=ct; + t_ec_sec=ce_sec; + t_hc_sec=ch_sec; + t_tc_sec=ct_sec; + + t_elost=hydra::get<5>(curr); + t_hlost=hydra::get<4>(curr); + t_tlost=t_elost+t_hlost; + t_elost_sec=hydra::get<7>(curr); + t_hlost_sec=hydra::get<6>(curr); + t_tlost_sec=t_elost_sec+t_hlost_sec; + + + myfile<currmax) currmax=ct; + if(ctchargemax) chargemax=t_tinduced; + if(t_tinduced &tp_currs, TH3D* hdraw, double timestep, std::map settings, bool storeextra=true, bool drawgif=false){ if(drawgif){ @@ -412,7 +502,7 @@ namespace analysis{ std::remove(Form("%s/%s.gif",settings["outputdir"].c_str(),settings["name"].c_str())); } - TFile *outf=new TFile(Form("%s/%s.root",settings["outputdir"].c_str(),settings["name"].c_str()),"UPDATE"); + TFile *outf=new TFile(Form("%s/%s.dat",settings["outputdir"].c_str(),settings["name"].c_str()),"UPDATE"); double t_ec=0, t_hc=0, t_tc=0, t_einduced=0, t_hinduced=0, t_tinduced=0; double t_ec_sec=0, t_hc_sec=0, t_tc_sec=0, t_einduced_sec=0, t_hinduced_sec=0, t_tinduced_sec=0; From 9a82026ccc4422da086dee1e003e0498a620d1c0 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:21:21 +0100 Subject: [PATCH 13/21] Update loadfiles.h --- include/loadfiles.h | 194 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 161 insertions(+), 33 deletions(-) diff --git a/include/loadfiles.h b/include/loadfiles.h index da8bd67..6832784 100644 --- a/include/loadfiles.h +++ b/include/loadfiles.h @@ -28,13 +28,24 @@ //Functions to load files +#include +#include using namespace hydra::placeholders; +// using namespace hydra::arguments; +// +// declarg(xvar, double); namespace loaddata{ - RunningStateHost_t getDummy(size_t nparticles, double length, size_t group=DEFAULT_GROUP){ - INFO_LINE("Generating deposit") - hydra::Random<> Generator( std::chrono::system_clock::now().time_since_epoch().count()); + + RunningStateHost_t getDummy(size_t nparticles=MAXPARTICLES, double length=DEFAULT_LENGTH, size_t group=DEFAULT_GROUP){ + INFO_LINE("Generating dummy deposit ... ") + + auto A = hydra::Parameter::Create().Name("A").Value(0.0); + auto B = hydra::Parameter::Create().Name("B").Value(length); + hydra_thrust::default_random_engine engine; + auto uniform = hydra::UniformShape(A,B); + size_t np=(nparticles<=0) ? MAXPARTICLES : nparticles; if(np==0) ERROR_LINE("Number of particles is zero! Check your configuration.") @@ -43,8 +54,8 @@ namespace loaddata{ auto data_d1=RunningStateHost_t(np,RunningTuple_t(std::copysign(1.,length)*group,0.,0.,0., 1.,0.,0.,0.,0.,0.,0.,0.)); return data_d1; } - size_t halfsize=np/2; - if(group>1) halfsize/=group; + size_t halfsize=np; + if(group>1) halfsize=halfsize/(group*2); RunningStateHost_t data_d(halfsize*2); auto data_de=RunningStateHost_t(halfsize,RunningTuple_t(-1.*group,0.,0.,0., 1.,0.,0.,0.,0.,0.,0.,0.)); auto data_dh=RunningStateHost_t(halfsize,RunningTuple_t(1.*group,0.,0.,0., 1.,0.,0.,0.,0.,0.,0.,0.)); @@ -53,26 +64,25 @@ namespace loaddata{ //distribute them randomly in a line along Z if(length>0.){ int seed=0; - Generator.SetSeed(seed); // IMPORTANT, otherwise the seed stays the same - Generator.Uniform(0., length, data_de.begin(_tc_z), data_de.end(_tc_z)); - Generator.SetSeed(seed); - Generator.Uniform(0., length, data_dh.begin(_tc_z), data_dh.end(_tc_z)); + hydra::fill_random(data_de.begin(_tc_z), data_de.end(_tc_z) , uniform,std::chrono::system_clock::now().time_since_epoch().count()); + hydra::fill_random(data_dh.begin(_tc_z), data_dh.end(_tc_z) , uniform,std::chrono::system_clock::now().time_since_epoch().count()); } hydra::copy(data_de,hydra::make_range(data_d.begin(),data_d.begin()+halfsize)); hydra::copy(data_dh,hydra::make_range(data_d.begin()+halfsize,data_d.end())); - + INFO_LINE("Generating dummy deposit ... done") return data_d; } + + + + RunningStateHost_t loadfile(std::string path, size_t group=DEFAULT_GROUP, std::string custom=DEFAULT_DEPOSIT_BUILD){ +// RunningStateHost_t loadfile(std::string path, size_t group=DEFAULT_GROUP){ - RunningStateHost_t loadfile(std::string path, size_t group=DEFAULT_GROUP){ std::ifstream infile; - + std::string strc ("YES"); RunningStateHost_t data_d; -// if(path=="dummy"){ -// return getDummy(MAXPARTICLES); -// } - + infile.open(path.c_str());// file containing numbers in 3 columns @@ -80,7 +90,7 @@ namespace loaddata{ ERROR_LINE("Error loading file " << path << ". Please check!") exit(1); } - + double pix=0; double piy=0; double piz=0; @@ -91,20 +101,57 @@ namespace loaddata{ std::string line; + double sigm_f=0; //initialising dispersion + double sigm_i=0; //initialising dispersion + char dispersion[20]; //initialising dispersion TYPE + double absorption = 0; //initialising absorption + double deposit=0; + int ct=0; - double deposit=0; - int ct=0; while(std::getline(infile,line)){ typ=0; std::stringstream lineStream; lineStream << line; - lineStream >> pix >> piy >> piz >> pfx >> pfy >> pfz >> deposit >> typ; - // std::cout << line << std::endl; +// lineStream >> pix >> piy >> piz >> pfx >> pfy >> pfz >> deposit >> typ; + // lineStream >> pix >> piy >> piz >> pfx >> pfy >> pfz >> deposit >> typ >> sigm_i >> sigm_f >> dispersion >> absorption ; //<<----prende tutte le righe + // std::cout << line << std::endl; //old code + //-------------------- + if(strc.compare(custom) == 0){ + INFO_LINE("Custom deposit generation start ...") + lineStream >> pix >> piy >> piz >> pfx >> pfy >> pfz >> deposit >> typ >> sigm_i >> sigm_f >> dispersion >> absorption ; //<<----deposito custom + } + else{ + INFO_LINE("Standard G4 deposit generation start ...") + lineStream >> pix >> piy >> piz >> pfx >> pfy >> pfz >> deposit >> typ ; //<<----srtandard geant4 conv + } + //-------------------- + + if(deposit<1) continue; unsigned int idep=deposit/group; + + /*************************************************************************** + ***NEW FEATURE START-code*** + **************************************************************************/ + int save_group = group; + //need the float in order to compute the lost charge in the calculus + double idep_f = deposit/group; + //lost charge will be divided by number of cycles and multiplied by group. total charge is conv + double rest_charge = ((idep_f - idep)/idep)*group; + //if division is less than 1, correct in order to not loose the charge! + if(idep_f<1){ + idep=1; + rest_charge = idep_f*group; + group=0; + } + + /*************************************************************************** + ***NEW FEATURE END-code*** + **************************************************************************/ + + if(idep<1) continue; - // std::cout << pix << "\t" << piy << "\t" << piz << "\t" << pfx << "\t" << pfy << "\t" << pfz << "\t" << deposit << std::endl; double d=sqrt((pfx-pix)*(pfx-pix)+(pfy-piy)*(pfy-piy)+(pfz-piz)*(pfz-piz)); if(d==0){ @@ -114,22 +161,103 @@ namespace loaddata{ } } else{ - double a=(pfx-pix)/d; - double b=(pfy-piy)/d; - double c=(pfz-piz)/d; - - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_real_distribution dist(0.,d); - for(unsigned int i=0;i dist(0.,d); //uniform real number distribution + vec=dist(mt); //Random position along line for point generation + } + else if(absorption != 0){ //If light is used, absorption becomes important. + std::exponential_distribution dist(absorption); //exponential distribution uses lambert-beer-like equation + vec=dist(mt); //to redistribute points along tracks + while( vec>d){ //if exponential is larger than module, a while loop tries again + vec=dist(mt); //until vec Radius_distribution(0,sigma_a*vec+sigm_i); //Introduces UNIFORM Distribution for radial dispersion of carriers + disp_radius = Radius_distribution(mt); + } + else if(str2.compare(dispersion) == 0){ + std::normal_distribution Radius_distribution(0,sigma_a*vec+sigm_i); //Introduces Gaussian Distribution for radial dispersion of carriers + disp_radius = Radius_distribution(mt); + } + else{ //If you set an unexisting dispersion shape + ERROR_LINE("Dispersion shape does not exist! Set Dispersion at 0!"); + disp_radius = 0; + } + //RANDOM DISTRIBUTION ARROUND TRACK + //############################################################################################################################### + + std::uniform_real_distribution angle(0.,2*PI); + phi = acos(((pfz-piz)/d)); //determines angulation of track in space + if(pfy == piy && pfx == pix){ //in spherical coordinates + theta = 0; //if theta is undetermined, set by default to 0 ... + } + else{ + theta = atan(abs(pfy-piy)/(pfx-pix)); //... or direct computed + } + + double x_Y = disp_radius*sin(theta + PI/2)*cos(phi); //defines perpendicular dispersion vector to line + double y_Y = disp_radius*sin(theta + PI/2)*sin(phi); + double z_Y = disp_radius*cos(theta + PI/2); + + gamma = angle(ang_d); // Random rotation arround track + //final point obtained by rotating the dispersion vector arround the track by gamma + double dispX = (((pfx - pix)*(pfx - pix)*(1/(d*d)) + (1-(pfx - pix)*(pfx - pix)*(1/(d*d)))*cos(gamma))*x_Y + ((pfx - pix)*(pfy - piy)*(1/(d*d))*(1-cos(gamma)) - (pfz - piz)*(1/(d))*sin(gamma))*y_Y + ((pfx - pix)*(pfz - piz)*(1/(d*d))*(1 - cos(gamma)) + (pfy - piy)*(1/(d))*sin(gamma))*z_Y); + + double dispY = ((pfx - pix)*(1/(d*d))*(pfy - piy)*(1 - cos(gamma))*x_Y + (pfz - piz)*(1/(d))*sin(gamma)*x_Y + (pfy - piy)*(1/(d*d))*(pfy - piy)*y_Y + (1-(pfy - piy)*(1/(d*d))*(pfy - piy))*cos(gamma)*y_Y + (pfy - piy)*(1/(d*d))*(pfz - piz)*(1 - cos(gamma))*z_Y - (pfx - pix)*(1/(d))*sin(gamma)*z_Y); + + double dispZ = ((pfx - pix)*(pfz - piz)*(1/(d*d))*(1-cos(gamma))*x_Y - (pfy - piy)*(1/(d))*sin(gamma)*x_Y + (pfy - piy)*(1/(d*d))*(pfz - piz)*(1-cos(gamma))*y_Y + (pfx - pix)*(1/(d*d))*sin(gamma)*y_Y + (pfz - piz)*(pfz - piz)*(1/(d*d))*z_Y + (1-(pfz - piz)*(1/(d*d))*(pfz - piz))*cos(gamma)*z_Y); + + //adds poins + data_d.push_back(RunningTuple_t(-1.*(group+rest_charge),a*vec+pix+dispX, b*vec+piy+dispY, c*vec+piz+dispZ, 1.,0.,0.,0.,0.,0.,0.,typ)); + data_d.push_back(RunningTuple_t(1.*(group+rest_charge) ,a*vec+pix+dispX, b*vec+piy+dispY, c*vec+piz+dispZ, 1.,0.,0.,0.,0.,0.,0.,typ)); + + } + } + else{ + INFO_LINE("G4 deposit generation ongoing ...") + double a=(pfx-pix)/d; + double b=(pfy-piy)/d; + double c=(pfz-piz)/d; + + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_real_distribution dist(0.,d); + for(unsigned int i=0;i Date: Mon, 15 Jan 2024 10:22:46 +0100 Subject: [PATCH 14/21] Update main.inl --- include/main.inl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/include/main.inl b/include/main.inl index 9760572..1c986cc 100644 --- a/include/main.inl +++ b/include/main.inl @@ -23,6 +23,8 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #ifndef MAIN_INL_ @@ -47,7 +49,7 @@ int main(int argv, char** argc){ cfg::Config Cfg; std::string cfg_file_name = "settings.cfg"; - std::string EFfile=DEFAULT_FILE_NAME,WFfile=DEFAULT_FILE_NAME,EMOBfile=DEFAULT_FILE_NAME,HMOBfile=DEFAULT_FILE_NAME,PHYSMAPfile=DEFAULT_FILE_NAME; + std::string EFfile=DEFAULT_FILE_NAME,WFfile=DEFAULT_FILE_NAME,EMOBfile=DEFAULT_FILE_NAME,HMOBfile=DEFAULT_FILE_NAME,PHYSMAPfile=DEFAULT_FILE_NAME; //, custom=DEFAULT_DEPOSIT_BUILD; int icfg=-1; std::string outputdir="output"; bool isconfig=false; @@ -66,6 +68,7 @@ int main(int argv, char** argc){ double zshift = DEFAULT_Z; double length = DEFAULT_LENGTH; std::string file_single=DEFAULT_PATH; + std::string custom=DEFAULT_DEPOSIT_BUILD; //<-- nuovo std::string file_single_name="InlineSim"; //------------------------- // command line arguments @@ -84,6 +87,11 @@ int main(int argv, char** argc){ cmd.add(PMap_Arg); TCLAP::ValueArg EFfile_Arg("", "efield","Electric field map", false, EFfile.c_str(), "string"); cmd.add(EFfile_Arg); + + TCLAP::ValueArg Custom_Arg("", "customdeposit","Energy deposit build algorithm", false, custom.c_str(), "string"); //<-- nuovo + cmd.add(Custom_Arg); + + TCLAP::ValueArg EMOBfile_Arg("", "emob","Electron mobility map", false, EMOBfile.c_str(), "string"); cmd.add(EMOBfile_Arg); TCLAP::ValueArg HMOBfile_Arg("", "hmob","Hole mobility map", false, HMOBfile.c_str(), "string"); @@ -156,8 +164,11 @@ int main(int argv, char** argc){ outputdir = Odir_Arg.getValue(); PHYSMAPfile = PMap_Arg.getValue(); + custom = Custom_Arg.getValue(); //<-- new + EFfile = EFfile_Arg.getValue(); - WFfile = WFfile_Arg.getValue(); + + WFfile = WFfile_Arg.getValue(); EMOBfile = EMOBfile_Arg.getValue(); HMOBfile = HMOBfile_Arg.getValue(); @@ -223,6 +234,9 @@ int main(int argv, char** argc){ cfg::Setting & root_line_maps = root["PhysicsMaps"]; if(PHYSMAPfile!="none") root_line_maps.add("map",cfg::Setting::TypeString) = PHYSMAPfile; if(EFfile!="none") root_line_maps.add("efield", cfg::Setting::TypeString) = EFfile; + + if(custom!="none") root_line_maps.add("customdeposit", cfg::Setting::TypeString) = custom; //<-- new + if(WFfile!="none") root_line_maps.add("wfield", cfg::Setting::TypeString) = WFfile; if(EMOBfile!="none") root_line_maps.add("emob", cfg::Setting::TypeString) = EMOBfile; if(HMOBfile!="none") root_line_maps.add("hmob", cfg::Setting::TypeString) = HMOBfile; From 82fb079ae11076518fcba84b2c813940839f4709 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:23:59 +0100 Subject: [PATCH 15/21] Update HydraSim.h --- include/simulation/HydraSim.h | 127 ++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/include/simulation/HydraSim.h b/include/simulation/HydraSim.h index 1a2cb19..5094e8b 100644 --- a/include/simulation/HydraSim.h +++ b/include/simulation/HydraSim.h @@ -23,10 +23,14 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #include #include +#include + void signal_simulation(cfg::Setting const& root, int icfg=-1){ //configuration list @@ -56,18 +60,10 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ #endif //_ROOT_AVAILABLE_ - INFO_LINE("Starting signal simulation...") + INFO_LINE("Starting signal simulation now...") std::cout << MIDDLEROW << std::endl; double simulationtime=0; - std::string tmpfile=std::get(configlist[0].get("path")); - size_t tmpparticles=std::get(configlist[0].get("nparticles")); - size_t tmpgroup=std::get(configlist[0].get("group")); - - RunningStateHost_t data_dinit; - if(tmpfile==DEFAULT_PATH) data_dinit = loaddata::getDummy( std::get(configlist[0].get("nparticles")), - std::get(configlist[0].get("length")),std::get(configlist[0].get("group"))); - else data_dinit=loaddata::loadfile(tmpfile); size_t sim=0; for(auto cf:configlist){ @@ -80,6 +76,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ auto group = std::get(cf.get("group")); auto path = std::get(cf.get("path")); auto nickname = std::get(cf.get("nickname")); + auto custom = std::get(cf.get("customdeposit"));//<------aggiuntoi auto plot = std::get(cf.get("plot")); auto extrainfo = std::get(cf.get("extrainfo")); auto temperature = std::get(cf.get("temperature")); @@ -90,30 +87,34 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ auto sig = std::get(cf.get("sig")); auto amp = std::get(cf.get("amp")); auto length = std::get(cf.get("length")); - + auto start = std::chrono::high_resolution_clock::now(); - if(path!=tmpfile || nparticles!=tmpparticles || group!=tmpgroup){ - tmpfile=path; - if(tmpfile==DEFAULT_PATH) data_dinit=loaddata::getDummy(nparticles,length,group); - else data_dinit=loaddata::loadfile(tmpfile,group); - } - //create running state - - if(nparticles==0 || nparticles>data_dinit.size()) nparticles=data_dinit.size(); - - //create running state - RunningState_t data_d(nparticles,RunningTuple_init); // running state - data_d.reserve(nparticles); + //selects which deposit kind will be generated + RunningStateHost_t data_dinit; + if(path==DEFAULT_PATH){ + data_dinit = loaddata::getDummy(std::get(cf.get("nparticles")),std::get(cf.get("length")),std::get(cf.get("group"))); + } + else{ + data_dinit = loaddata::loadfile(path,group,custom); + } + nparticles=(data_dinit.size()); + //sets number of total particles + + + + RunningState_t data_d((nparticles)/group,RunningTuple_init); // running state + data_d.reserve((nparticles)/group); //create reduced vector for plotting ReducedDataDev_t currents(nsteps); currents.reserve(nsteps); CurrentVec_t tp_currs; - - + //fill running state with initial particles - hydra::copy(hydra::make_range(data_dinit.begin(),data_dinit.begin()+nparticles),data_d); // with ranges + hydra::copy(hydra::make_range(data_dinit.begin(),data_dinit.begin()+((nparticles)/group)),data_d); // with ranges +// hydra::copy(hydra::make_range(data_dinit.begin(),data_dinit.begin()+((nparticles*2)/group)),data_d); // with ranges + hydra::for_each(data_d, loaddata::Translate(xshift,yshift,zshift,std::get<0>(_maps.Boundaries()),std::get<1>(_maps.Boundaries()), std::get<2>(_maps.Boundaries()),std::get<3>(_maps.Boundaries()), std::get<4>(_maps.Boundaries()),std::get<5>(_maps.Boundaries()))); @@ -121,18 +122,21 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ //creating large host vector to copy bunches of dev vectors size_t stp=1; if(extrainfo || plot) stp=nsteps; - UniverseHost_t states_host(stp, StateHost_t(nparticles,StateTuple_init)); + UniverseHost_t states_host(stp, StateHost_t((nparticles*2)/group,StateTuple_init)); states_host.reserve(stp); for(auto& st:states_host){ - st.reserve(nparticles); + st.reserve((nparticles*2)/group); } size_t nbunches = nsteps/bunchsize; size_t rest = nsteps%bunchsize; INFO_LINE("Simulation "<1) INFO_LINE("Particles are grouped in "<< nparticles <<" bunches of "<1) INFO_LINE("Particles are grouped in "<< (nparticles*2)/group <<" bunches of "<1) INFO_LINE("Particles are grouped in "<< (nparticles)/group <<" bunches of "< Generator( std::chrono::system_clock::now().time_since_epoch().count()); + + auto A = hydra::Parameter::Create().Name("A").Value(0.0); + auto B = hydra::Parameter::Create().Name("B").Value(PI); + auto C = hydra::Parameter::Create().Name("C").Value(2*PI); + + auto uniform_theta = hydra::UniformShape(A,B); + auto uniform_phi = hydra::UniformShape(A,C); + + auto mean = hydra::Parameter::Create("mean" ).Value(0.0); + auto sigma = hydra::Parameter::Create("sigma").Value(1.0); + + auto gauss = hydra::Gaussian(mean, sigma); + +// hydra::Random<> Generator( std::chrono::system_clock::now().time_since_epoch().count()); size_t niter=0; //creating running vectors of states and reserving memory for them and their elements size_t bnc=1; +// if((extrainfo || plot)) bnc=bunchsize; +// UniverseDev_t states(bnc, StateDev_t((nparticles*2)/group,StateTuple_init)); +// states.reserve(bnc); +// for(auto& final_state:states){ +// final_state.reserve((nparticles*2)/group); +// } if((extrainfo || plot)) bnc=bunchsize; - UniverseDev_t states(bnc, StateDev_t(nparticles,StateTuple_init)); + UniverseDev_t states(bnc, StateDev_t((nparticles)/group,StateTuple_init)); states.reserve(bnc); for(auto& final_state:states){ - final_state.reserve(nparticles); + final_state.reserve((nparticles)/group); } - size_t cb=0; //count bunches { @@ -161,15 +182,11 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ //for loop on all states in the universe if(_maps.ismulti()){ for(size_t id=0; id<=nsteps; id++){ - double temperature_nmob = (((KB*temperature))/HCHARGE)*(1 + amp*exp(-0.5*pow((timestep*niter - sig)/sig,2))); - - Generator.SetSeed(std::rand()); - Generator.Gauss(0.0, 1.0, data_d.begin(_tc_gauss_x), data_d.end(_tc_gauss_x)); + double temperature_nmob = (((KB*temperature))/(HCHARGE*group))*(1 + amp*exp(-0.5*pow((timestep*niter - sig)/sig,2))); - Generator.SetSeed(std::rand()); - Generator.Uniform(0.0, 2*PI, data_d.begin(_tc_angle_1), data_d.end(_tc_angle_1)); - Generator.SetSeed(std::rand()); - Generator.Uniform(0.0, PI, data_d.begin(_tc_angle_2), data_d.end(_tc_angle_2)); + hydra::fill_random(data_d.begin(_tc_gauss_x), data_d.end(_tc_gauss_x) , gauss,std::rand()); + hydra::fill_random(data_d.begin(_tc_angle_1), data_d.end(_tc_angle_1) , uniform_phi,std::rand()); + hydra::fill_random(data_d.begin(_tc_angle_2), data_d.end(_tc_angle_2) , uniform_theta,std::rand()); hydra::for_each(data_d, evolve::make_RamoCurrent(niter, @@ -184,9 +201,9 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ // auto int_curr = hydra::reduce ( hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)) | (analysis::_SelectChargeAndSec), ReducedTuple_init,analysis::_SumTuples); // auto int_curr = hydra::reduce ( hydra::transform (hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)), analysis::SelectChargeAndSec()), ReducedTuple_init,analysis::SumTuples()); - auto int_curr=HYDRA_EXTERNAL_NS::thrust::transform_reduce(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec),analysis::SelectChargeAndSec(), ReducedTuple_init,analysis::SumTuples()); + auto int_curr=hydra_thrust::transform_reduce(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec),analysis::SelectChargeAndSec(), ReducedTuple_init,analysis::SumTuples()); tp_currs.push_back(int_curr); - +// INFO_LINE(_maps.VecXEField()<<" "<< _maps.VecYEField()<<" "<< _maps.VecZEField()<<" "<< _maps.EField()<<" "<<_maps.VecXEMob()<<" "<< _maps.VecYEMob()<<" "<< _maps.VecZEMob()<<" "<< _maps.EMob()<<" "<<_maps.VecXHMob()<<" "<< _maps.VecYHMob()<<" "<< _maps.VecZHMob()<<" "<< _maps.HMob()<<" "<<_maps.VecXWField()<<" "<< _maps.VecYWField()<<" "<< _maps.VecZWField()<<" "<< _maps.WField()) // auto int_curr=hydra::reduce(hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)),ReducedTuple_init, analysis::SumCarriers()); // if(extrainfo || plot){ @@ -218,16 +235,11 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ } else{ for(size_t id=0; id<=nsteps; id++){ - double temperature_nmob = (((KB*temperature))/HCHARGE)*(1 + amp*exp(-0.5*pow((timestep*niter - sig)/sig,2))); - - Generator.SetSeed(std::rand()); - Generator.Gauss(0.0, 1.0, data_d.begin(_tc_gauss_x), data_d.end(_tc_gauss_x)); - - Generator.SetSeed(std::rand()); - Generator.Uniform(0.0, 2*PI, data_d.begin(_tc_angle_1), data_d.end(_tc_angle_1)); - Generator.SetSeed(std::rand()); - Generator.Uniform(0.0, PI, data_d.begin(_tc_angle_2), data_d.end(_tc_angle_2)); + double temperature_nmob = (((KB*temperature))/(HCHARGE*group))*(1 + amp*exp(-0.5*pow((timestep*niter - sig)/sig,2))); + hydra::fill_random(data_d.begin(_tc_gauss_x), data_d.end(_tc_gauss_x) , gauss,std::rand()); + hydra::fill_random(data_d.begin(_tc_angle_1), data_d.end(_tc_angle_1) , uniform_phi,std::rand()); + hydra::fill_random(data_d.begin(_tc_angle_2), data_d.end(_tc_angle_2) , uniform_theta,std::rand()); hydra::for_each(data_d, evolve::make_RamoCurrent(niter, timestep, @@ -238,7 +250,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ // auto int_curr = hydra::reduce ( hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)) | (analysis::_SelectChargeAndSec), ReducedTuple_init,analysis::_SumTuples); // // auto int_curr = hydra::reduce ( hydra::transform(hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)),analysis::SelectChargeAndSec()), ReducedTuple_init,analysis::SumTuples()); // // auto r = reduce ( transform (data, functorT), init, functorR) - auto int_curr=HYDRA_EXTERNAL_NS::thrust::transform_reduce(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec),analysis::SelectChargeAndSec(), ReducedTuple_init,analysis::SumTuples()); + auto int_curr=hydra_thrust::transform_reduce(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec),analysis::SelectChargeAndSec(), ReducedTuple_init,analysis::SumTuples()); // auto int_curr=hydra::reduce(hydra::make_range(data_d.begin(_tc_charge,_tc_isin,_tc_curr,_tc_issec),data_d.end(_tc_charge,_tc_isin,_tc_curr,_tc_issec)),ReducedTuple_init,analysis::SumCarriers()); @@ -251,7 +263,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ cb++; } } - + INFO_LINE(int_curr); printProgress((double)(niter+1)/(double)nsteps,"Simulation progress:"); @@ -271,7 +283,6 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ } } - //information about process time auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration elapsed = end - start; std::cout << std::endl; @@ -283,7 +294,7 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ std::map settings; settings["name"]=nickname; settings["outputdir"]=outputdir; - settings["pairs"]=Form("%i",(int)nparticles/2); + settings["pairs"]=Form("%i",(int)(nparticles)/(group)); settings["timestep"]=Form("%g s",timestep); settings["nstep"]=Form("%i s",(int)nsteps); settings["T"]=Form("%0.0f K",temperature); @@ -292,14 +303,12 @@ void signal_simulation(cfg::Setting const& root, int icfg=-1){ settings["x shift"]=Form("%g #mu m",xshift); settings["y shift"]=Form("%g #mu m",yshift); settings["z shift"]=Form("%g #mu m",zshift); - if(!(extrainfo || plot)) analysis::AnalyseSim(tp_currs,timestep,settings); else{ analysis::AnalyseSim(tp_currs,timestep,settings); analysis::ExtraPlots(states_host, tp_currs, h3, timestep, settings, extrainfo, plot); } - } sim++; } From f045c932118962297a9b4b96033bb19e17e39e82 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:24:42 +0100 Subject: [PATCH 16/21] Update simulation.h --- include/simulation/simulation.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/simulation/simulation.h b/include/simulation/simulation.h index 0ccf015..ae67d27 100644 --- a/include/simulation/simulation.h +++ b/include/simulation/simulation.h @@ -23,6 +23,8 @@ * * Created on: 13/01/2019 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #ifndef __SIMULATION_H__ @@ -41,6 +43,7 @@ namespace sim{ size_t _nparticles; size_t _nsteps; std::string _path; + std::string _custom; std::string _nickname; bool _plot; bool _extrainfo; @@ -65,6 +68,7 @@ namespace sim{ _nparticles = std::get(cf.get("nparticles")); _nsteps = std::get(cf.get("nsteps")); _path = std::get(cf.get("path")); + _custom = std::get(cf.get("customdeposit")); //<-- extra _nickname = std::get(cf.get("nickname")); _plot = std::get(cf.get("plot")); _extrainfo = std::get(cf.get("extrainfo")); From 480800d2c9bc92673bf2a76421669d61330d056d Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:26:01 +0100 Subject: [PATCH 17/21] Update defaults.h --- include/details/defaults.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/details/defaults.h b/include/details/defaults.h index e073c69..964f756 100644 --- a/include/details/defaults.h +++ b/include/details/defaults.h @@ -23,6 +23,8 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #ifndef __DEFAULTS_H__ @@ -57,13 +59,14 @@ #define DEFAULT_BUNCHSIZE 600 //bunch size (if gif animation or extra info requested). Timesteps are processed in bunches to avoid excessive memory usage #define DEFAULT_AMP 0. //not used #define DEFAULT_SIGMA 1. //not used -#define DEFAULT_LENGTH 1. //default deposit lenght for dummy deposit +#define DEFAULT_LENGTH 10. //default deposit lenght for dummy deposit #define DEFAULT_PATH "dummy" //default deposit path (DO NOT CHANGE) #define DEFAULT_DRAW false //plot gif animation? #define DEFAULT_EXTRAINFO false //request full info dumping? #define DEFAULT_X 0. //default deposit shift in x direction #define DEFAULT_Y 0. //default deposit shift in y direction #define DEFAULT_Z 0. //default deposit shift in z direction -#define DEFAULT_GROUP 1 //default carrier grouping factor +#define DEFAULT_GROUP 1 //default carrier grouping factor +#define DEFAULT_DEPOSIT_BUILD "NO" //default deposit build up #endif From 494f87c97277a8342e6d9109f2006aa536388f71 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:27:44 +0100 Subject: [PATCH 18/21] Update utils.h --- include/details/utils.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/details/utils.h b/include/details/utils.h index c12db34..41ad4e6 100644 --- a/include/details/utils.h +++ b/include/details/utils.h @@ -23,6 +23,8 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #ifndef UTILS_H_ @@ -65,7 +67,7 @@ if(flag){\ #include #include #include -#include +// #include #include #include #include @@ -228,12 +230,16 @@ class singleconf{ std::vector FillOneConfig(cfg::Setting const& root, int icfg){ std::vector sets; - std::string file_single_config, file_single_name_config; + std::string file_single_config, file_single_name_config, custom; bool draw_config=false, extrainfo_config=false; int bunchsize_config; std::vector nsteps_config, nparticles_config, group_config; std::vector temperature_config, timestep_config, ampexp_config, sigmaexp_config, xshift_config, yshift_config, zshift_config, length_config; - if(root["InputData"][icfg].exists("path")) root["InputData"][icfg].lookupValue("path",file_single_config); + + if(root["InputData"][icfg].exists("customdeposit")) root["InputData"][icfg].lookupValue("customdeposit",custom); //<<----nuovo + else custom=DEFAULT_DEPOSIT_BUILD; + + if(root["InputData"][icfg].exists("path")) root["InputData"][icfg].lookupValue("path",file_single_config); else file_single_config=DEFAULT_PATH; if(root["InputData"][icfg].exists("name")) root["InputData"][icfg].lookupValue("name",file_single_name_config); @@ -314,6 +320,7 @@ std::vector FillOneConfig(cfg::Setting const& root, int icfg){ for(auto gr:group_config){ singleconf tmpconf; tmpconf.set("path",file_single_config); + tmpconf.set("customdeposit",custom); tmpconf.set("nickname",file_single_name_config+"_"+std::to_string(count)); tmpconf.set("plot",draw_config); tmpconf.set("extrainfo",extrainfo_config); From b0e532bbed7075fdb5239bf45126f2a4f852ea9a Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:30:08 +0100 Subject: [PATCH 19/21] Update loadfiles.h New deposit construction, including also customised deposits --- include/loadfiles.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/loadfiles.h b/include/loadfiles.h index 6832784..86787d2 100644 --- a/include/loadfiles.h +++ b/include/loadfiles.h @@ -23,6 +23,8 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo loi */ From daf5d54beb0d6dba089271945774be69793f1614 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:31:03 +0100 Subject: [PATCH 20/21] Update analysis.h capable of writinng in DAT format --- include/analysis.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/analysis.h b/include/analysis.h index 2ee8461..4470d56 100644 --- a/include/analysis.h +++ b/include/analysis.h @@ -23,6 +23,8 @@ * * Created on: 12/11/2018 * Author: Andrea Contu + * Updated on: 15/01/2024 + * Author: Angelo Loi */ #ifndef __ANALYSIS_H__ From 9142ab7369c220b9b78b2ccef392fa379f14fe77 Mon Sep 17 00:00:00 2001 From: Angelo Loi <46484436+Angeloloi19@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:52:59 +0100 Subject: [PATCH 21/21] Update README.md merging with install --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 3324393..7e0ba00 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,19 @@ TCode uses external 3D maps of electric fields, carrier mobilities and weighting ## Dependencies TCode depends on [ROOT >= v.6.14](https://github.com/root-project/root), [libconfig >= v1.5](https://hyperrealm.github.io/libconfig/), [TCLAP >= v1.2.1](http://tclap.sourceforge.net/) and optionally [CUDA >= 10.0](https://developer.nvidia.com/cuda-toolkit) (needed for nVidia GPUs). +## Build application +To generate executables to run on nVidia GPUs you also need an installation of [CUDA >= 10.0](https://developer.nvidia.com/cuda-toolkit) and to use a [compatible GCC version](https://docs.nvidia.com/cuda/). + +Build TCode following the instructions below: +1. clone the git repository: `git clone https://github.com/MultithreadCorner/TCode.git` +2. go to TCode directory: `cd TCode` +3. create a build directory: `mkdir build` +4. go to build directory cd `build` +5. run cmake specifying the path to Hydra: `cmake -DHYDRA_INCLUDE_DIR='path-to-hydra'../` +6. compile (all backends): `make -j8` + +Several executables, separate for each available backend (CPP, TBB, OMP and CUDA) will be generated in the build directory. + ## Manual ### Parameter file Every simulation is set by defining its parameters on the configuration file. Each configuration file has 3 main sections: