diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c83d5488bb8ccdb2ad14b619b74bf39328d88ab9..e88e0d23c0425f735a7dd0782f2e60ced6f37d18 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,8 @@ -image: ubuntu:bionic +image: corsika/devel:u-18.04 variables: GIT_SSL_NO_VERIFY: "1" -before_script: - - apt-get update --yes - - apt-get install --yes cmake libboost-dev libeigen3-dev python3 gfortran - - apt-get install --yes doxygen graphviz - build: stage: build tags: @@ -16,7 +11,7 @@ build: - mkdir build - cd build - cmake .. - - cmake --build . + - cmake --build . -- -j 4 - ctest -j4 -V >& test.log after_script: - cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 216bb098c81608a19999f7f975b8a99cb16a4aa5..d8a697d2c66eea9a74919cc676af90ea5021c3bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.4.3) +cmake_minimum_required (VERSION 3.9) project ( corsika @@ -40,7 +40,8 @@ endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) # enable warnings and disallow non-standard language set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") # -O2 would not trade speed for size, neither O2/3 use fast-math +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g") # -O2 would not trade speed for size, neither O2/3 use fast-math +set(CMAKE_Fortran_FLAGS "-std=legacy") # clang produces a lot of unecessary warnings without this: add_compile_options("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-nonportable-include-path>") @@ -72,6 +73,8 @@ if (Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) endif (Boost_FOUND) +find_package (Pythia8) # optional + find_package (Eigen3 REQUIRED) #find_package (HDF5) # not yet needed diff --git a/CMakeModules/CorsikaUtilities.cmake b/CMakeModules/CorsikaUtilities.cmake index 85105468ad429e013f499fd221b2d657e60fd612..9b00787289f634872b707c208cc899136418d597 100644 --- a/CMakeModules/CorsikaUtilities.cmake +++ b/CMakeModules/CorsikaUtilities.cmake @@ -1,4 +1,14 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# +################################################# # # takes a list of input files and prepends a path # @@ -12,6 +22,7 @@ function (CORSIKA_PREPEND_PATH return prefix) endfunction (CORSIKA_PREPEND_PATH) +################################################# # # use: CORSIKA_COPY_HEADERS_TO_NAMESPACE theLib theNamesapce header1.h header2.h ... # @@ -58,6 +69,7 @@ endfunction (CORSIKA_COPY_HEADERS_TO_NAMESPACE) +################################################# # # use: CORSIKA_ADD_FILES_ABSOLUTE varname # @@ -81,6 +93,7 @@ endmacro(CORSIKA_ADD_FILES_ABSOLUTE) +################################################# # # central macro to activate unit tests in cmake # diff --git a/CMakeModules/FindPythia8.cmake b/CMakeModules/FindPythia8.cmake new file mode 100644 index 0000000000000000000000000000000000000000..57aea3d0bb86f4a90a17e36cb0e18da5561ba309 --- /dev/null +++ b/CMakeModules/FindPythia8.cmake @@ -0,0 +1,73 @@ +# +# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# +# See file AUTHORS for a list of contributors. +# +# This software is distributed under the terms of the GNU General Public +# Licence version 3 (GPL Version 3). See file LICENSE for a full version of +# the license. +# + +################################################# +# +# run pythia8-config and interpret result +# + +function (_PYTHIA8_CONFIG_ option variable type doc) + execute_process(COMMAND ${PYTHIA8_CONFIG} ${option} + OUTPUT_VARIABLE _local_out_ + RESULT_VARIABLE _local_res_) + string(REGEX REPLACE "\n$" "" _local_out_ "${_local_out_}") + if (NOT ${_local_res_} EQUAL 0) + message ("Error in running ${PYTHIA8_CONFIG} ${option}") + else () + set(${variable} "${_local_out_}" CACHE ${type} ${doc}) + endif () +endfunction (_PYTHIA8_CONFIG_) + + + +################################################# +# +# Searched PYTHIA8 on system. Expect pythia8-config in PATH, or typical installation location +# +# This module defines +# HAVE_PYTHIA8 +# PYTHIA8_INCLUDE_DIR where to locate Pythia.h file +# PYTHIA8_LIBRARY where to find the libpythia8 library +# PYTHIA8_LIBRARIES (not cached) the libraries to link against to use Pythia8 +# PYTHIA8_VERSION version of Pythia8 if found +# + +set(_SEARCH_PYTHIA8_ + ${PROJECT_BINARY_DIR}/ThirdParty/pythia8-install + ${PYTHIA8} + $ENV{PYTHIA8} + ${PYTHIA8DIR} + $ENV{PYTHIA8DIR} + ${PYTHIA8_DIR} + $ENV{PYTHIA8_DIR} + ${PYTHIA8_ROOT} + $ENV{PYTHIA8_ROOT} + /opt/pythia8) + +find_program(PYTHIA8_CONFIG + NAME pythia8-config + PATHS ${_SEARCH_PYTHIA8_} + PATH_SUFFIXES "/bin" + DOC "The location of the pythia8-config script") + +if (PYTHIA8_CONFIG) + set(HAVE_PYTHIA8 1 CACHE BOOL "presence of pythia8, found via pythia8-config") + + _PYTHIA8_CONFIG_("--prefix" PYTHIA8_PREFIX PATH "location of pythia8 installation") + _PYTHIA8_CONFIG_("--includedir" PYTHIA8_INCLUDE_DIR PATH "pythia8 include directory") + _PYTHIA8_CONFIG_("--libs" PYTHIA8_LIBRARY STRING "the pythia8 libs") + _PYTHIA8_CONFIG_("--datadir" PYTHIA8_DATA_DIR PATH "the pythia8 data dir") + _PYTHIA8_CONFIG_("--cxxflags" PYTHIA8_CXXFLAGS STRING "the pythia8 cxxflags") +endif () + +# standard cmake infrastructure: +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Pythia8 DEFAULT_MSG PYTHIA8_PREFIX PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARY) +mark_as_advanced(PYTHIA8_DATA_DIR PYTHIA8_CXXFLAGS PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARY) diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 925cdac6ef4a98b4dc63b2c01696c1d82aad9bc2..6529b5153565a74ddc39fc16b3e7c90f882f7aac 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -18,19 +18,24 @@ CORSIKA_ADD_TEST (logger_example) add_executable (stack_example stack_example.cc) target_compile_options(stack_example PRIVATE -g) # do not skip asserts -target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging) +target_link_libraries (stack_example SuperStupidStack CORSIKAunits + CORSIKAlogging) CORSIKA_ADD_TEST (stack_example) add_executable (cascade_example cascade_example.cc) target_compile_options(cascade_example PRIVATE -g) # do not skip asserts -target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging - CORSIKArandom - ProcessSibyll +target_link_libraries (cascade_example SuperStupidStack CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + ProcessPythia CORSIKAcascade + ProcessEnergyLoss ProcessStackInspector ProcessTrackWriter ProcessTrackingLine CORSIKAprocesses + CORSIKAcascade CORSIKAparticles CORSIKAgeometry CORSIKAenvironment @@ -53,9 +58,32 @@ target_link_libraries (boundary_example SuperStupidStack CORSIKAunits CORSIKAlog CORSIKAenvironment CORSIKAprocesssequence ) + install (TARGETS boundary_example DESTINATION share/examples) CORSIKA_ADD_TEST (boundary_example) +add_executable (cascade_proton_example cascade_proton_example.cc) +target_compile_options(cascade_proton_example PRIVATE -g) # do not skip asserts +target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + ProcessPythia + CORSIKAcascade + ProcessStackInspector + ProcessTrackWriter + ProcessTrackingLine + ProcessHadronicElasticModel + CORSIKAprocesses + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) + +install (TARGETS cascade_proton_example DESTINATION share/examples) +CORSIKA_ADD_TEST (cascade_proton_example) + add_executable (staticsequence_example staticsequence_example.cc) target_compile_options(staticsequence_example PRIVATE -g) # do not skip asserts target_link_libraries (staticsequence_example diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 67ff9c8fa14173764044fc5b60749e6dfd9e6606..0807cc640c1583422e940dae5bd109ff549a8382 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -11,6 +11,7 @@ #include <corsika/cascade/Cascade.h> #include <corsika/process/ProcessSequence.h> +#include <corsika/process/energy_loss/EnergyLoss.h> #include <corsika/process/tracking_line/TrackingLine.h> #include <corsika/setup/SetupEnvironment.h> @@ -27,6 +28,8 @@ #include <corsika/process/sibyll/Interaction.h> #include <corsika/process/sibyll/NuclearInteraction.h> +#include <corsika/process/pythia/Decay.h> + #include <corsika/process/track_writer/TrackWriter.h> #include <corsika/units/PhysicalUnits.h> @@ -251,15 +254,22 @@ int main() { universe.AddChild(std::move(outerMedium)); // setup processes, decays and interactions - tracking_line::TrackingLine tracking; + tracking_line::TrackingLine<setup::Stack, setup::Trajectory> tracking(env); + stack_inspector::StackInspector<setup::Stack> stackInspect(true); + + const std::vector<particles::Code> trackedHadrons = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, + particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; random::RNGManager::GetInstance().RegisterRandomStream("s_rndm"); - process::sibyll::Interaction sibyll; - process::sibyll::NuclearInteraction sibyllNuc(sibyll); - process::sibyll::Decay decay; + random::RNGManager::GetInstance().RegisterRandomStream("pythia"); + process::sibyll::Interaction sibyll(env); + process::sibyll::NuclearInteraction sibyllNuc(env, sibyll); + process::sibyll::Decay decay(trackedHadrons); ProcessCut cut(20_GeV); process::TrackWriter::TrackWriter trackWriter("tracks.dat"); + process::EnergyLoss::EnergyLoss eLoss; // assemble all processes into an ordered process list auto sequence = sibyll << sibyllNuc << decay << cut << trackWriter; @@ -270,8 +280,8 @@ int main() { const Code beamCode = Code::Nucleus; const int nuclA = 4; const int nuclZ = int(nuclA / 2.15 + 0.7); - const HEPMassType mass = nuclA * particles::GetMass(Code::Proton); - const HEPEnergyType E0 = nuclA * 25_TeV; + const HEPMassType mass = GetNucleusMass(nuclA, nuclZ); + const HEPEnergyType E0 = nuclA * 10_TeV; double theta = 0.; double phi = 0.; @@ -302,10 +312,13 @@ int main() { EAS.Init(); EAS.Run(); - cout << "Result: E0=" << E0 / 1_GeV << endl; + eLoss.PrintProfile(); // print longitudinal profile + cut.ShowResults(); const HEPEnergyType Efinal = cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy(); - cout << "total energy (GeV): " << Efinal / 1_GeV << endl - << "relative difference (%): " << (Efinal / E0 - 1.) * 100 << endl; + cout << "total cut energy (GeV): " << Efinal / 1_GeV << endl + << "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl; + cout << "total dEdX energy (GeV): " << eLoss.GetTotal() / 1_GeV << endl + << "relative difference (%): " << eLoss.GetTotal() / E0 * 100 << endl; } diff --git a/Documentation/Examples/cascade_proton_example.cc b/Documentation/Examples/cascade_proton_example.cc new file mode 100644 index 0000000000000000000000000000000000000000..b8851ffe622e1583a2ce55e60e7dd4a112065959 --- /dev/null +++ b/Documentation/Examples/cascade_proton_example.cc @@ -0,0 +1,325 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/cascade/Cascade.h> +#include <corsika/process/ProcessSequence.h> +#include <corsika/process/hadronic_elastic_model/HadronicElasticModel.h> +#include <corsika/process/stack_inspector/StackInspector.h> +#include <corsika/process/tracking_line/TrackingLine.h> + +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +#include <corsika/environment/Environment.h> +#include <corsika/environment/HomogeneousMedium.h> +#include <corsika/environment/NuclearComposition.h> + +#include <corsika/geometry/Sphere.h> + +#include <corsika/process/sibyll/Decay.h> +#include <corsika/process/sibyll/Interaction.h> +#include <corsika/process/sibyll/NuclearInteraction.h> + +#include <corsika/process/pythia/Decay.h> +#include <corsika/process/pythia/Interaction.h> + +#include <corsika/process/track_writer/TrackWriter.h> + +#include <corsika/units/PhysicalUnits.h> + +#include <corsika/random/RNGManager.h> + +#include <corsika/utl/CorsikaFenv.h> + +#include <boost/type_index.hpp> +using boost::typeindex::type_id_with_cvr; + +#include <iostream> +#include <limits> +#include <typeinfo> + +using namespace corsika; +using namespace corsika::process; +using namespace corsika::units; +using namespace corsika::particles; +using namespace corsika::random; +using namespace corsika::setup; +using namespace corsika::geometry; +using namespace corsika::environment; + +using namespace std; +using namespace corsika::units::si; + +class ProcessCut : public process::ContinuousProcess<ProcessCut> { + + HEPEnergyType fECut; + + HEPEnergyType fEnergy = 0_GeV; + HEPEnergyType fEmEnergy = 0_GeV; + int fEmCount = 0; + HEPEnergyType fInvEnergy = 0_GeV; + int fInvCount = 0; + +public: + ProcessCut(const HEPEnergyType cut) + : fECut(cut) {} + + template <typename Particle> + bool isBelowEnergyCut(Particle& p) const { + // nuclei + if (p.GetPID() == particles::Code::Nucleus) { + auto const ElabNuc = p.GetEnergy() / p.GetNuclearA(); + auto const EcmNN = sqrt(2. * ElabNuc * 0.93827_GeV); + if (ElabNuc < fECut || EcmNN < 10_GeV) + return true; + else + return false; + } else { + // TODO: center-of-mass energy hard coded + const HEPEnergyType Ecm = sqrt(2. * p.GetEnergy() * 0.93827_GeV); + if (p.GetEnergy() < fECut || Ecm < 10_GeV) + return true; + else + return false; + } + } + + bool isEmParticle(Code pCode) const { + bool is_em = false; + // FOR NOW: switch + switch (pCode) { + case Code::Electron: + is_em = true; + break; + case Code::Positron: + is_em = true; + break; + case Code::Gamma: + is_em = true; + break; + default: + break; + } + return is_em; + } + + void defineEmParticles() const { + // create bool array identifying em particles + } + + bool isInvisible(Code pCode) const { + bool is_inv = false; + // FOR NOW: switch + switch (pCode) { + case Code::NuE: + is_inv = true; + break; + case Code::NuEBar: + is_inv = true; + break; + case Code::NuMu: + is_inv = true; + break; + case Code::NuMuBar: + is_inv = true; + break; + case Code::MuPlus: + is_inv = true; + break; + case Code::MuMinus: + is_inv = true; + break; + + case Code::Neutron: + is_inv = true; + break; + + case Code::AntiNeutron: + is_inv = true; + break; + + default: + break; + } + return is_inv; + } + + template <typename Particle> + LengthType MaxStepLength(Particle& p, setup::Trajectory&) const { + cout << "ProcessCut: MinStep: pid: " << p.GetPID() << endl; + cout << "ProcessCut: MinStep: energy (GeV): " << p.GetEnergy() / 1_GeV << endl; + const Code pid = p.GetPID(); + if (isEmParticle(pid) || isInvisible(pid) || isBelowEnergyCut(p)) { + cout << "ProcessCut: MinStep: next cut: " << 0. << endl; + return 0_m; + } else { + LengthType next_step = 1_m * std::numeric_limits<double>::infinity(); + cout << "ProcessCut: MinStep: next cut: " << next_step << endl; + return next_step; + } + } + + template <typename Particle, typename Stack> + EProcessReturn DoContinuous(Particle& p, setup::Trajectory&, Stack&) { + const Code pid = p.GetPID(); + HEPEnergyType energy = p.GetEnergy(); + cout << "ProcessCut: DoContinuous: " << pid << " E= " << energy + << ", EcutTot=" << (fEmEnergy + fInvEnergy + fEnergy) / 1_GeV << " GeV" << endl; + EProcessReturn ret = EProcessReturn::eOk; + if (isEmParticle(pid)) { + cout << "removing em. particle..." << endl; + fEmEnergy += energy; + fEmCount += 1; + // p.Delete(); + ret = EProcessReturn::eParticleAbsorbed; + } else if (isInvisible(pid)) { + cout << "removing inv. particle..." << endl; + fInvEnergy += energy; + fInvCount += 1; + // p.Delete(); + ret = EProcessReturn::eParticleAbsorbed; + } else if (isBelowEnergyCut(p)) { + cout << "removing low en. particle..." << endl; + fEnergy += energy; + // p.Delete(); + ret = EProcessReturn::eParticleAbsorbed; + } + return ret; + } + + void Init() { + fEmEnergy = 0. * 1_GeV; + fEmCount = 0; + fInvEnergy = 0. * 1_GeV; + fInvCount = 0; + fEnergy = 0. * 1_GeV; + // defineEmParticles(); + } + + void ShowResults() { + cout << " ******************************" << endl + << " ParticleCut: " << endl + << " energy in em. component (GeV): " << fEmEnergy / 1_GeV << endl + << " no. of em. particles injected: " << fEmCount << endl + << " energy in inv. component (GeV): " << fInvEnergy / 1_GeV << endl + << " no. of inv. particles injected: " << fInvCount << endl + << " energy below particle cut (GeV): " << fEnergy / 1_GeV << endl + << " ******************************" << endl; + } + + HEPEnergyType GetInvEnergy() const { return fInvEnergy; } + HEPEnergyType GetCutEnergy() const { return fEnergy; } + HEPEnergyType GetEmEnergy() const { return fEmEnergy; } +}; + +// +// The example main program for a particle cascade +// +int main() { + feenableexcept(FE_INVALID); + // initialize random number sequence(s) + random::RNGManager::GetInstance().RegisterRandomStream("cascade"); + + // setup environment, geometry + environment::Environment env; + auto& universe = *(env.GetUniverse()); + + auto theMedium = environment::Environment::CreateNode<Sphere>( + Point{env.GetCoordinateSystem(), 0_m, 0_m, 0_m}, + 1_km * std::numeric_limits<double>::infinity()); + + using MyHomogeneousModel = environment::HomogeneousMedium<environment::IMediumModel>; + theMedium->SetModelProperties<MyHomogeneousModel>( + 1_kg / (1_m * 1_m * 1_m), + environment::NuclearComposition( + std::vector<particles::Code>{particles::Code::Hydrogen}, + std::vector<float>{(float)1.})); + + universe.AddChild(std::move(theMedium)); + + const CoordinateSystem& rootCS = env.GetCoordinateSystem(); + + // setup processes, decays and interactions + tracking_line::TrackingLine<setup::Stack, setup::Trajectory> tracking(env); + stack_inspector::StackInspector<setup::Stack> p0(true); + + const std::vector<particles::Code> trackedHadrons = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, + particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; + + + random::RNGManager::GetInstance().RegisterRandomStream("s_rndm"); + random::RNGManager::GetInstance().RegisterRandomStream("pythia"); + // process::sibyll::Interaction sibyll(env); + process::pythia::Interaction pythia(env); + // process::sibyll::NuclearInteraction sibyllNuc(env, sibyll); + // process::sibyll::Decay decay(trackedHadrons); + process::pythia::Decay decay(trackedHadrons); + ProcessCut cut(20_GeV); + + // random::RNGManager::GetInstance().RegisterRandomStream("HadronicElasticModel"); + // process::HadronicElasticModel::HadronicElasticInteraction + // hadronicElastic(env); + + process::TrackWriter::TrackWriter trackWriter("tracks.dat"); + + // assemble all processes into an ordered process list + // auto sequence = p0 << sibyll << decay << hadronicElastic << cut << trackWriter; + // auto sequence = p0 << sibyll << sibyllNuc << decay << cut << trackWriter; + + auto sequence = p0 << pythia << decay << cut << trackWriter; + + // cout << "decltype(sequence)=" << type_id_with_cvr<decltype(sequence)>().pretty_name() + // << "\n"; + + // setup particle stack, and add primary particle + setup::Stack stack; + stack.Clear(); + const Code beamCode = Code::Proton; + const HEPMassType mass = particles::Proton::GetMass(); + const HEPEnergyType E0 = 100_GeV; + double theta = 0.; + double phi = 0.; + + { + auto elab2plab = [](HEPEnergyType Elab, HEPMassType m) { + return sqrt(Elab * Elab - m * m); + }; + HEPMomentumType P0 = elab2plab(E0, mass); + auto momentumComponents = [](double theta, double phi, HEPMomentumType ptot) { + return std::make_tuple(ptot * sin(theta) * cos(phi), ptot * sin(theta) * sin(phi), + -ptot * cos(theta)); + }; + auto const [px, py, pz] = + momentumComponents(theta / 180. * M_PI, phi / 180. * M_PI, P0); + auto plab = corsika::stack::MomentumVector(rootCS, {px, py, pz}); + cout << "input particle: " << beamCode << endl; + cout << "input angles: theta=" << theta << " phi=" << phi << endl; + cout << "input momentum: " << plab.GetComponents() / 1_GeV << endl; + Point pos(rootCS, 0_m, 0_m, 0_m); + stack.AddParticle(std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, + units::si::TimeType>{ + beamCode, E0, plab, pos, 0_ns}); + } + + // define air shower object, run simulation + cascade::Cascade EAS(env, tracking, sequence, stack); + EAS.Init(); + EAS.Run(); + + cout << "Result: E0=" << E0 / 1_GeV << endl; + cut.ShowResults(); + const HEPEnergyType Efinal = + cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy(); + cout << "total energy (GeV): " << Efinal / 1_GeV << endl + << "relative difference (%): " << (Efinal / E0 - 1.) * 100 << endl; +} diff --git a/Environment/CMakeLists.txt b/Environment/CMakeLists.txt index b0e4a43f9b22be2a199559aa32d6f132d7262839..0a94c410aeebbf353d225e9e7ea2822d814b1728 100644 --- a/Environment/CMakeLists.txt +++ b/Environment/CMakeLists.txt @@ -10,6 +10,7 @@ set ( DensityFunction.h Environment.h NameModel.h + FlatExponential.h ) set ( diff --git a/Environment/FlatExponential.h b/Environment/FlatExponential.h new file mode 100644 index 0000000000000000000000000000000000000000..19e42c725c4b5204dc9c6fc166f9be00f44bdb7a --- /dev/null +++ b/Environment/FlatExponential.h @@ -0,0 +1,92 @@ +/* + * (c) Copyright 2019 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_Environment_FlatExponential_h_ +#define _include_Environment_FlatExponential_h_ + +#include <corsika/environment/NuclearComposition.h> +#include <corsika/geometry/Line.h> +#include <corsika/geometry/Point.h> +#include <corsika/geometry/Trajectory.h> +#include <corsika/particles/ParticleProperties.h> +#include <corsika/random/RNGManager.h> +#include <corsika/units/PhysicalUnits.h> + +#include <cassert> +#include <limits> + +/** + * + */ + +namespace corsika::environment { + + template <class T> + class FlatExponential : public T { + corsika::units::si::MassDensityType const fRho0; + units::si::LengthType const fLambda; + units::si::InverseLengthType const fInvLambda; + NuclearComposition const fNuclComp; + geometry::Vector<units::si::dimensionless_d> const fAxis; + geometry::Point const fP0; + + public: + FlatExponential(geometry::Point const& p0, + geometry::Vector<units::si::dimensionless_d> const& axis, + units::si::MassDensityType rho, units::si::LengthType lambda, + NuclearComposition pNuclComp) + : fRho0(rho) + , fLambda(lambda) + , fInvLambda(1 / lambda) + , fNuclComp(pNuclComp) + , fAxis(axis) + , fP0(p0) {} + + corsika::units::si::MassDensityType GetMassDensity( + corsika::geometry::Point const& p) const override { + return fRho0 * exp(fInvLambda * (p - fP0).dot(fAxis)); + } + NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; } + + corsika::units::si::GrammageType IntegratedGrammage( + corsika::geometry::Trajectory<corsika::geometry::Line> const& line, + corsika::units::si::LengthType pTo) const override { + auto const vDotA = line.NormalizedDirection().dot(fAxis).magnitude(); + + if (vDotA == 0) { + return pTo * GetMassDensity(line.GetR0()); + } else { + return GetMassDensity(line.GetR0()) * (fLambda / vDotA) * + (exp(vDotA * pTo / fLambda) - 1); + } + } + + corsika::units::si::LengthType ArclengthFromGrammage( + corsika::geometry::Trajectory<corsika::geometry::Line> const& line, + corsika::units::si::GrammageType pGrammage) const override { + auto const vDotA = line.NormalizedDirection().dot(fAxis).magnitude(); + + if (vDotA == 0) { + return pGrammage / GetMassDensity(line.GetR0()); + } else { + auto const logArg = pGrammage * vDotA / (fRho0 * fLambda) + 1; + if (logArg > 0) { + return fLambda / vDotA * log(pGrammage * vDotA / (fRho0 * fLambda) + 1); + } else { + return std::numeric_limits<typename decltype( + pGrammage)::value_type>::infinity() * + corsika::units::si::meter; + } + } + } + }; + +} // namespace corsika::environment +#endif diff --git a/Environment/NuclearComposition.h b/Environment/NuclearComposition.h index 5f89bd2cadb50e48f01931abafbc4ee94305cf8b..dee18a4463c340698bbff372cc504d4744748375 100644 --- a/Environment/NuclearComposition.h +++ b/Environment/NuclearComposition.h @@ -35,15 +35,15 @@ namespace corsika::environment { public: using value_type = double; using iterator_category = std::input_iterator_tag; - using pointer = double*; - using reference = double&; + using pointer = value_type*; + using reference = value_type&; using difference_type = ptrdiff_t; WeightProviderIterator(AConstIterator a, BConstIterator b) : fAIter(a) , fBIter(b) {} - double operator*() const { return ((*fAIter) * (*fBIter)).magnitude(); } + value_type operator*() const { return ((*fAIter) * (*fBIter)).magnitude(); } WeightProviderIterator& operator++() { // prefix ++ ++fAIter; diff --git a/Environment/VolumeTreeNode.h b/Environment/VolumeTreeNode.h index 54bc0cc76d05a473fcdcd2a8cfa3d390f32f865b..f08762fe44947101ff95aa457af11a1b6aed943f 100644 --- a/Environment/VolumeTreeNode.h +++ b/Environment/VolumeTreeNode.h @@ -1,4 +1,3 @@ - /* * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu * @@ -69,6 +68,24 @@ namespace corsika::environment { } } + /** + * Traverses the VolumeTree pre- or post-order and calls the functor \p func for each + * node. \p func takes a reference to VolumeTreeNode as argument. The return value \p + * func is ignored. + */ + template <typename TCallable, bool preorder = true> + void walk(TCallable func) { + if constexpr (preorder) { + func(*this); + std::for_each(fChildNodes.begin(), fChildNodes.end(), + [&](auto& v) { v->walk(func); }); + } else { + std::for_each(fChildNodes.begin(), fChildNodes.end(), + [&](auto& v) { v->walk(func); }); + func(*this); + } + } + void AddChild(VTNUPtr pChild) { pChild->fParentNode = this; fChildNodes.push_back(std::move(pChild)); diff --git a/Environment/testEnvironment.cc b/Environment/testEnvironment.cc index 5bb18bfe09e48d4865f5aafcd8ad4aa01f4afeb8..206849e7eb17b6d33a23fffddb4abefbb16900e8 100644 --- a/Environment/testEnvironment.cc +++ b/Environment/testEnvironment.cc @@ -13,6 +13,7 @@ // cpp file #include <corsika/environment/DensityFunction.h> +#include <corsika/environment/FlatExponential.h> #include <corsika/environment/HomogeneousMedium.h> #include <corsika/environment/IMediumModel.h> #include <corsika/environment/InhomogeneousMedium.h> @@ -30,6 +31,12 @@ using namespace corsika::geometry; using namespace corsika::environment; using namespace corsika::particles; using namespace corsika::units::si; +using namespace corsika; + +CoordinateSystem const& gCS = + RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + +Point const gOrigin(gCS, {0_m, 0_m, 0_m}); TEST_CASE("HomogeneousMedium") { NuclearComposition const protonComposition(std::vector<Code>{Code::Proton}, @@ -37,6 +44,62 @@ TEST_CASE("HomogeneousMedium") { HomogeneousMedium<IMediumModel> const medium(19.2_g / cube(1_cm), protonComposition); } +TEST_CASE("FlatExponential") { + NuclearComposition const protonComposition(std::vector<Code>{Code::Proton}, + std::vector<float>{1.f}); + + Vector const axis(gCS, QuantityVector<dimensionless_d>(0, 0, 1)); + LengthType const lambda = 3_m; + auto const rho0 = 1_g / units::si::detail::static_pow<3>(1_cm); + FlatExponential<IMediumModel> const medium(gOrigin, axis, rho0, lambda, + protonComposition); + auto const tEnd = 5_s; + + SECTION("horizontal") { + Line const line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {20_cm / second, 0_m / second, 0_m / second})); + Trajectory<Line> const trajectory(line, tEnd); + + REQUIRE((medium.IntegratedGrammage(trajectory, 2_m) / (rho0 * 2_m)) == Approx(1)); + REQUIRE((medium.ArclengthFromGrammage(trajectory, rho0 * 5_m) / 5_m) == Approx(1)); + } + + SECTION("vertical") { + Line const line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {0_m / second, 0_m / second, 5_m / second})); + Trajectory<Line> const trajectory(line, tEnd); + LengthType const length = 2 * lambda; + GrammageType const exact = rho0 * lambda * (exp(length / lambda) - 1); + + REQUIRE((medium.IntegratedGrammage(trajectory, length) / exact) == Approx(1)); + REQUIRE((medium.ArclengthFromGrammage(trajectory, exact) / length) == Approx(1)); + } + + SECTION("escape grammage") { + Line const line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {0_m / second, 0_m / second, -5_m / second})); + Trajectory<Line> const trajectory(line, tEnd); + + GrammageType const escapeGrammage = rho0 * lambda; + + REQUIRE(trajectory.NormalizedDirection().dot(axis).magnitude() < 0); + REQUIRE(medium.ArclengthFromGrammage(trajectory, 1.2 * escapeGrammage) == + std::numeric_limits<typename GrammageType::value_type>::infinity() * 1_m); + } + + SECTION("inclined") { + Line const line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {0_m / second, 5_m / second, 5_m / second})); + Trajectory<Line> const trajectory(line, tEnd); + double const cosTheta = M_SQRT1_2; + LengthType const length = 2 * lambda; + GrammageType const exact = + rho0 * lambda * (exp(cosTheta * length / lambda) - 1) / cosTheta; + REQUIRE((medium.IntegratedGrammage(trajectory, length) / exact) == Approx(1)); + REQUIRE((medium.ArclengthFromGrammage(trajectory, exact) / length) == Approx(1)); + } +} + auto constexpr rho0 = 1_kg / 1_m / 1_m / 1_m; struct Exponential { @@ -60,15 +123,10 @@ struct Exponential { }; TEST_CASE("InhomogeneousMedium") { - CoordinateSystem const& cs = - RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); - - Point const origin(cs, {0_m, 0_m, 0_m}); - - Vector direction(cs, QuantityVector<dimensionless_d>(1, 0, 0)); + Vector direction(gCS, QuantityVector<dimensionless_d>(1, 0, 0)); - Line line(origin, Vector<SpeedType::dimension_type>( - cs, {20_m / second, 0_m / second, 0_m / second})); + Line line(gOrigin, Vector<SpeedType::dimension_type>( + gCS, {20_m / second, 0_m / second, 0_m / second})); auto const tEnd = 5_s; Trajectory<Line> const trajectory(line, tEnd); @@ -77,9 +135,9 @@ TEST_CASE("InhomogeneousMedium") { DensityFunction<decltype(e), LinearApproximationIntegrator> const rho(e); SECTION("DensityFunction") { - REQUIRE(e.Derivative<1>(origin, direction) / (1_kg / 1_m / 1_m / 1_m / 1_m) == + REQUIRE(e.Derivative<1>(gOrigin, direction) / (1_kg / 1_m / 1_m / 1_m / 1_m) == Approx(1)); - REQUIRE(rho.EvaluateAt(origin) == e(origin)); + REQUIRE(rho.EvaluateAt(gOrigin) == e(gOrigin)); } auto const exactGrammage = [](auto l) { return 1_m * rho0 * (exp(l / 1_m) - 1); }; diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h index 4da4609aea684ec8dbefc4ca35230a527aec44a1..c7a187447a5d3f6034600a05bffe09e3543cd7f0 100644 --- a/Framework/Cascade/Cascade.h +++ b/Framework/Cascade/Cascade.h @@ -23,6 +23,7 @@ #include <cassert> #include <cmath> #include <iostream> +#include <limits> #include <type_traits> /** diff --git a/Framework/Geometry/CMakeLists.txt b/Framework/Geometry/CMakeLists.txt index bb96c2ea6bf5cf6e228b23fb7471c73c1b282923..f827de1f4cfcf4f8ef0ee5d4f986cea0eeff96b2 100644 --- a/Framework/Geometry/CMakeLists.txt +++ b/Framework/Geometry/CMakeLists.txt @@ -44,8 +44,14 @@ target_link_libraries ( target_include_directories ( CORSIKAgeometry + SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR} INTERFACE ${EIGEN3_INCLUDE_DIR} + ) + +target_include_directories ( + CORSIKAgeometry + INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> $<INSTALL_INTERFACE:include/include> ) diff --git a/Framework/Geometry/Trajectory.h b/Framework/Geometry/Trajectory.h index 1718fa2c492c896901ea85311d2e2314bd61cc17..559dbd562694a6a38cc150fab71bee52059b9062 100644 --- a/Framework/Geometry/Trajectory.h +++ b/Framework/Geometry/Trajectory.h @@ -37,11 +37,12 @@ namespace corsika::geometry { Point GetPosition(double u) const { return T::GetPosition(fTimeLength * u); } corsika::units::si::TimeType GetDuration() const { return fTimeLength; } + corsika::units::si::LengthType GetLength() const { return GetDistance(fTimeLength); } corsika::units::si::LengthType GetDistance(corsika::units::si::TimeType t) const { - assert(t > fTimeLength); + assert(t <= fTimeLength); assert(t >= 0 * corsika::units::si::second); - return T::ArcLength(0, t); + return T::ArcLength(0 * corsika::units::si::second, t); } void LimitEndTo(corsika::units::si::LengthType limit) { diff --git a/Framework/Geometry/Vector.h b/Framework/Geometry/Vector.h index 5ac1f118b789b500ad26a23f840bda954b2c9800..ca97abb50feec457527751d79cd9e76b760cb4f2 100644 --- a/Framework/Geometry/Vector.h +++ b/Framework/Geometry/Vector.h @@ -75,12 +75,14 @@ namespace corsika::geometry { * think about whether squaredNorm() might be cheaper for your computation. */ auto norm() const { return BaseVector<dim>::qVector.norm(); } + auto GetNorm() const { return BaseVector<dim>::qVector.norm(); } /*! * returns the squared norm of the Vector. Before using this method, * think about whether norm() might be cheaper for your computation. */ auto squaredNorm() const { return BaseVector<dim>::qVector.squaredNorm(); } + auto GetSquaredNorm() const { return BaseVector<dim>::qVector.squaredNorm(); } /*! * returns a Vector \f$ \vec{v}_{\parallel} \f$ which is the parallel projection @@ -123,17 +125,9 @@ namespace corsika::geometry { template <typename ScalarDim> auto operator*(phys::units::quantity<ScalarDim, double> const p) const { - using ProdQuantity = phys::units::detail::Product<dim, ScalarDim, double, double>; + using ProdDim = phys::units::detail::product_d<dim, ScalarDim>; - if constexpr (std::is_same<ProdQuantity, double>::value) // result dimensionless, - // not a "Quantity" anymore - { - return Vector<phys::units::dimensionless_d>(*BaseVector<dim>::cs, - BaseVector<dim>::qVector * p); - } else { - return Vector<typename ProdQuantity::dimension_type>( - *BaseVector<dim>::cs, BaseVector<dim>::qVector * p); - } + return Vector<ProdDim>(*BaseVector<dim>::cs, BaseVector<dim>::qVector * p); } template <typename ScalarDim> @@ -171,16 +165,8 @@ namespace corsika::geometry { auto const c2 = pV.GetComponents(*BaseVector<dim>::cs).eVector; auto const bareResult = c1.cross(c2); - using ProdQuantity = phys::units::detail::Product<dim, dim2, double, double>; - - if constexpr (std::is_same<ProdQuantity, double>::value) // result dimensionless, - // not a "Quantity" anymore - { - return Vector<phys::units::dimensionless_d>(*BaseVector<dim>::cs, bareResult); - } else { - return Vector<typename ProdQuantity::dimension_type>(*BaseVector<dim>::cs, - bareResult); - } + using ProdDim = phys::units::detail::product_d<dim, dim2>; + return Vector<ProdDim>(*BaseVector<dim>::cs, bareResult); } template <typename dim2> @@ -189,9 +175,10 @@ namespace corsika::geometry { auto const c2 = pV.GetComponents(*BaseVector<dim>::cs).eVector; auto const bareResult = c1.dot(c2); - using ProdQuantity = phys::units::detail::Product<dim, dim2, double, double>; + using ProdDim = phys::units::detail::product_d<dim, dim2>; - return ProdQuantity(phys::units::detail::magnitude_tag, bareResult); + return phys::units::quantity<ProdDim, double>(phys::units::detail::magnitude_tag, + bareResult); } }; diff --git a/Framework/Particles/ParticleProperties.h b/Framework/Particles/ParticleProperties.h index dcbbe6398e84a0ad3f148eabf36ad01f380deb12..472baf40dfff9707fb52302043adcd10a4449c3b 100644 --- a/Framework/Particles/ParticleProperties.h +++ b/Framework/Particles/ParticleProperties.h @@ -44,8 +44,8 @@ namespace corsika::particles { using PDGCodeType = std::underlying_type<PDGCode>::type; // forward declarations to be used in GeneratedParticleProperties - int16_t constexpr GetElectricChargeNumber(Code const); - corsika::units::si::ElectricChargeType constexpr GetElectricCharge(Code const); + int16_t constexpr GetChargeNumber(Code const); + corsika::units::si::ElectricChargeType constexpr GetCharge(Code const); corsika::units::si::HEPMassType constexpr GetMass(Code const); PDGCode constexpr GetPDG(Code const); constexpr std::string const& GetName(Code const); @@ -61,6 +61,8 @@ namespace corsika::particles { * returns mass of particle in natural units */ corsika::units::si::HEPMassType constexpr GetMass(Code const p) { + if (p == Code::Nucleus) + throw std::runtime_error("Cannot GetMass() of particle::Nucleus -> unspecified"); return detail::masses[static_cast<CodeIntType>(p)]; } @@ -72,17 +74,23 @@ namespace corsika::particles { } /*! - * returns electric charge of particle / (e/3), e.g. return 3 for a proton. + * returns electric charge number of particle return 1 for a proton. */ - int16_t constexpr GetElectricChargeNumber(Code const p) { - return detail::electric_charges[static_cast<CodeIntType>(p)]; + int16_t constexpr GetChargeNumber(Code const p) { + if (p == Code::Nucleus) + throw std::runtime_error( + "Cannot GetChargeNumber() of particle::Nucleus -> unspecified"); + // electric_charges stores charges in units of (e/3), e.g. 3 for a proton + return detail::electric_charges[static_cast<CodeIntType>(p)] / 3; } /*! * returns electric charge of particle, e.g. return 1.602e-19_C for a proton. */ - corsika::units::si::ElectricChargeType constexpr GetElectricCharge(Code const p) { - return GetElectricChargeNumber(p) * (corsika::units::constants::e * (1. / 3.)); + corsika::units::si::ElectricChargeType constexpr GetCharge(Code const p) { + if (p == Code::Nucleus) + throw std::runtime_error("Cannot GetCharge() of particle::Nucleus -> unspecified"); + return GetChargeNumber(p) * (corsika::units::constants::e); } constexpr std::string const& GetName(Code const p) { @@ -112,6 +120,14 @@ namespace corsika::particles { std::ostream& operator<<(std::ostream& stream, corsika::particles::Code const p); Code ConvertFromPDG(PDGCode); + + /** + * Get mass of nucleus + **/ + corsika::units::si::HEPMassType constexpr GetNucleusMass(const int vA, const int vZ) { + return Proton::GetMass() * vZ + (vA - vZ) * Neutron::GetMass(); + } + } // namespace corsika::particles #endif diff --git a/Framework/Particles/pdxml_reader.py b/Framework/Particles/pdxml_reader.py index 946940f7dcf54551e2888e438c6eeeae0e1659e1..84ef0ee981a77d1ac68768ac548d02ec06ac19f3 100755 --- a/Framework/Particles/pdxml_reader.py +++ b/Framework/Particles/pdxml_reader.py @@ -418,8 +418,8 @@ def gen_classes(particle_db): string += " public:\n" string += " static constexpr Code GetCode() { return Type; }\n" string += " static constexpr corsika::units::si::HEPMassType GetMass() { return corsika::particles::GetMass(Type); }\n" - string += " static constexpr corsika::units::si::ElectricChargeType GetCharge() { return corsika::particles::GetElectricCharge(Type); }\n" - string += " static constexpr int16_t GetChargeNumber() { return corsika::particles::GetElectricChargeNumber(Type); }\n" + string += " static constexpr corsika::units::si::ElectricChargeType GetCharge() { return corsika::particles::GetCharge(Type); }\n" + string += " static constexpr int16_t GetChargeNumber() { return corsika::particles::GetChargeNumber(Type); }\n" string += " static std::string const& GetName() { return corsika::particles::GetName(Type); }\n" string += " static constexpr Code GetAntiParticle() { return AntiType; }\n" string += " static constexpr bool IsNucleus() { return corsika::particles::IsNucleus(Type); }\n" diff --git a/Framework/Particles/testParticles.cc b/Framework/Particles/testParticles.cc index 8bb73e7ac252fafe334d12c93a22dc05e195c4a5..3fd99ea2c0e24f52ebd61cd978db97ce54fe3ac7 100644 --- a/Framework/Particles/testParticles.cc +++ b/Framework/Particles/testParticles.cc @@ -43,7 +43,7 @@ TEST_CASE("ParticleProperties", "[Particles]") { SECTION("Charges") { REQUIRE(Electron::GetCharge() / constants::e == Approx(-1)); REQUIRE(Positron::GetCharge() / constants::e == Approx(+1)); - REQUIRE(GetElectricCharge(Positron::GetAntiParticle()) / constants::e == Approx(-1)); + REQUIRE(GetCharge(Positron::GetAntiParticle()) / constants::e == Approx(-1)); } SECTION("Names") { diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h index 786044aef3055b1472e0150dd451fa5050628f4b..b1f1eb7420f3e5e19b9a5694c66e604323786a78 100644 --- a/Framework/Units/PhysicalUnits.h +++ b/Framework/Units/PhysicalUnits.h @@ -45,9 +45,11 @@ namespace corsika::units::si { using hepmomentum_d = phys::units::hepenergy_d; using hepmass_d = phys::units::hepenergy_d; - /// defining cross section + /// defining cross section as area using sigma_d = phys::units::area_d; + // constexpr quantity<area_d> barn{Rep(1e-28L) * square(meter)}; + /// add the unit-types using LengthType = phys::units::quantity<phys::units::length_d, double>; using TimeType = phys::units::quantity<phys::units::time_interval_d, double>; @@ -156,7 +158,7 @@ namespace phys { QUANTITY_DEFINE_SCALING_LITERALS(eV, hepenergy_d, 1) - QUANTITY_DEFINE_SCALING_LITERALS(barn, corsika::units::si::sigma_d, + QUANTITY_DEFINE_SCALING_LITERALS(b, corsika::units::si::sigma_d, magnitude(corsika::units::constants::barn)) } // namespace literals diff --git a/Framework/Units/testUnits.cc b/Framework/Units/testUnits.cc index e8f389a05818615475dd988cce1181f6bf66ba42..8788fd6f19d872c65445300baa25efa272c09425 100644 --- a/Framework/Units/testUnits.cc +++ b/Framework/Units/testUnits.cc @@ -59,7 +59,7 @@ TEST_CASE("PhysicalUnits", "[Units]") { REQUIRE(1_mol / 1_amol == Approx(1e18)); REQUIRE(1_K / 1_zK == Approx(1e21)); REQUIRE(1_K / 1_yK == Approx(1e24)); - REQUIRE(1_barn / 1_mbarn == Approx(1e3)); + REQUIRE(1_b / 1_mb == Approx(1e3)); REQUIRE(1_A / 1_hA == Approx(1e-2)); REQUIRE(1_m / 1_km == Approx(1e-3)); diff --git a/Processes/CMakeLists.txt b/Processes/CMakeLists.txt index 26a44fe6e1ea2ddf806a4f9fd1e2b0552153a64d..d6162179ca3440e788a40a9a6ab0c18edb7d44f6 100644 --- a/Processes/CMakeLists.txt +++ b/Processes/CMakeLists.txt @@ -1,14 +1,22 @@ add_subdirectory (NullModel) add_subdirectory (Sibyll) +if (PYTHIA8_FOUND) + add_subdirectory (Pythia) +endif (PYTHIA8_FOUND) add_subdirectory (StackInspector) add_subdirectory (TrackWriter) add_subdirectory (TrackingLine) add_subdirectory (HadronicElasticModel) +add_subdirectory (EnergyLoss) #add_custom_target(CORSIKAprocesses) add_library (CORSIKAprocesses INTERFACE) add_dependencies(CORSIKAprocesses ProcessNullModel) add_dependencies(CORSIKAprocesses ProcessSibyll) +if (PYTHIA8_FOUND) + add_dependencies(CORSIKAprocesses ProcessPythia) +endif (PYTHIA8_FOUND) add_dependencies(CORSIKAprocesses ProcessStackInspector) add_dependencies(CORSIKAprocesses ProcessTrackingLine) +add_dependencies(CORSIKAprocesses ProcessEnergyLoss) diff --git a/Processes/EnergyLoss/CMakeLists.txt b/Processes/EnergyLoss/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..41eb2ececa1ba9baba44836c58151d8dfd5f6623 --- /dev/null +++ b/Processes/EnergyLoss/CMakeLists.txt @@ -0,0 +1,65 @@ + +set ( + MODEL_SOURCES + EnergyLoss.cc + ) + +set ( + MODEL_HEADERS + EnergyLoss.h + ) + +set ( + MODEL_NAMESPACE + corsika/process/energy_loss + ) + +add_library (ProcessEnergyLoss STATIC ${MODEL_SOURCES}) +CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessEnergyLoss ${MODEL_NAMESPACE} ${MODEL_HEADERS}) + +set_target_properties ( + ProcessEnergyLoss + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 1 +# PUBLIC_HEADER "${MODEL_HEADERS}" + ) + +# target dependencies on other libraries (also the header onlys) +target_link_libraries ( + ProcessEnergyLoss + CORSIKAunits + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAsetup + ) + +target_include_directories ( + ProcessEnergyLoss + INTERFACE + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include/include> + ) + +install ( + TARGETS ProcessEnergyLoss + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +# PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE} + ) + + +# -------------------- +# code unit testing +#add_executable (testNullModel testNullModel.cc) + +#target_link_libraries ( +# testNullModel ProcessNullModel +# CORSIKAsetup +# CORSIKAgeometry +# CORSIKAunits +# CORSIKAthirdparty # for catch2 +# ) +# CORSIKA_ADD_TEST(testNullModel) + diff --git a/Processes/EnergyLoss/EnergyLoss.cc b/Processes/EnergyLoss/EnergyLoss.cc new file mode 100644 index 0000000000000000000000000000000000000000..a20158bb96623895c1af1454eae79d33740b6da5 --- /dev/null +++ b/Processes/EnergyLoss/EnergyLoss.cc @@ -0,0 +1,222 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/process/energy_loss/EnergyLoss.h> + +#include <corsika/particles/ParticleProperties.h> + +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +#include <cmath> +#include <iostream> +#include <limits> + +using namespace std; + +using namespace corsika; +using namespace corsika::units::si; +using namespace corsika::setup; +using Particle = Stack::ParticleType; +using Track = Trajectory; + +namespace corsika::process::EnergyLoss { + + auto elab2plab = [](HEPEnergyType Elab, HEPMassType m) { + return sqrt((Elab - m) * (Elab + m)); + }; + + EnergyLoss::EnergyLoss() + : fEnergyLossTot(0_GeV) + , fdX(10_g / square(1_cm)) // profile binning + {} + + /** + * PDG2018, passage of particles through matter + * + * Note, that \f$I_{\mathrm{eff}}\f$ of composite media a determined from \f$ \ln I = + * \sum_i a_i \ln(I_i) \f$ where \f$ a_i \f$ is the fraction of the electron population + * (\f$\sim Z_i\f$) of the \f$i\f$-th element. This can also be used for shell + * corrections or density effects. + * + * The \f$I_{\mathrm{eff}}\f$ of compounds is not better than a few percent, if not + * measured explicitly. + * + * For shell correction, see Sec 6 of https://www.nap.edu/read/20066/chapter/8#115 + * + */ + HEPEnergyType EnergyLoss::BetheBloch(Particle& p, GrammageType const dX) { + + // all these are material constants and have to come through Environment + // right now: values for nitrogen_D + // 7 nitrogen_gas 82.0 0.49976 D E 0.0011653 0.0 1.7378 4.1323 0.15349 3.2125 10.54 + auto Ieff = 82.0_eV; + [[maybe_unused]] auto Zmat = 7; + auto ZoverA = 0.49976_mol / 1_g; + const double x0 = 1.7378; + const double x1 = 4.1323; + const double Cbar = 10.54; + const double delta0 = 0.0; + const double aa = 0.15349; + const double sk = 3.2125; + // end of material constants + + // this is the Bethe-Bloch coefficiet 4pi N_A r_e^2 m_e c^2 + auto const K = 0.307075_MeV / 1_mol * square(1_cm); + HEPEnergyType const E = p.GetEnergy(); + HEPMassType const m = p.GetMass(); + double const gamma = E / m; + double const Z = p.GetChargeNumber(); + double const Z2 = pow(Z, 2); + HEPMassType const me = particles::Electron::GetMass(); + auto const m2 = m * m; + auto const me2 = me * me; + double const gamma2 = pow(gamma, 2); + + double const beta2 = (gamma2 - 1) / gamma2; // 1-1/gamma2 (1-1/gamma)*(1+1/gamma); + // (gamma_2-1)/gamma_2 = (1-1/gamma2); + double const c2 = 1; // HEP convention here c=c2=1 + cout << "BetheBloch beta2=" << beta2 << " gamma2=" << gamma2 << endl; + [[maybe_unused]] double const eta2 = beta2 / (1 - beta2); + HEPMassType const Wmax = + 2 * me * c2 * beta2 * gamma2 / (1 + 2 * gamma * me / m + me2 / m2); + // approx, but <<1% HEPMassType const Wmax = 2*me*c2*beta2*gamma2; for HEAVY + // PARTICLES Wmax ~ 2me v2 for non-relativistic particles + cout << "BetheBloch Wmax=" << Wmax << endl; + + // Sternheimer parameterization, density corrections towards high energies + // NOTE/TODO: when Cbar is 0 it needs to be approximated from parameterization -> + // MISSING + cout << "BetheBloch p.GetMomentum().GetNorm()/m=" << p.GetMomentum().GetNorm() / m + << endl; + double const x = log10(p.GetMomentum().GetNorm() / m); + double delta = 0; + if (x >= x1) { + delta = 2 * (log(10)) * x - Cbar; + } else if (x < x1 && x >= x0) { + delta = 2 * (log(10)) * x - Cbar + aa * pow((x1 - x), sk); + } else if (x < x0) { // and IF conductor (otherwise, this is 0) + delta = delta0 * pow(100, 2 * (x - x0)); + } + cout << "BetheBloch delta=" << delta << endl; + + // with further low energies correction, accurary ~1% down to beta~0.05 (1MeV for p) + + // shell correction, <~100MeV + // need more clarity about formulas and units + const double Cadj = 0; + /* + // https://www.nap.edu/read/20066/chapter/8#104 + HEPEnergyType Iadj = 12_eV * Z + 7_eV; // Iadj<163eV + if (Iadj>=163_eV) + Iadj = 9.76_eV * Z + 58.8_eV * pow(Z, -0.19); // Iadj>=163eV + double const Cadj = (0.422377/eta2 + 0.0304043/(eta2*eta2) - + 0.00038106/(eta2*eta2*eta2)) * 1e-6 * Iadj*Iadj + (3.858019/eta2 - + 0.1667989/(eta2*eta2) + 0.00157955/(eta2*eta2*eta2)) * 1e-9 * Iadj*Iadj*Iadj; + */ + + // Barkas correction O(Z3) higher-order Born approximation + // see Appl. Phys. 85 (1999) 1249 + double A = 1; + if (p.GetPID() == particles::Code::Nucleus) A = p.GetNuclearA(); + // double const Erel = (p.GetEnergy()-p.GetMass()) / A / 1_keV; + // double const Llow = 0.01 * Erel; + // double const Lhigh = 1.5/pow(Erel, 0.4) + 45000./Zmat * pow(Erel, 1.6); + // double const barkas = Z * Llow*Lhigh/(Llow+Lhigh); // RU, I think the Z was + // missing... + double const barkas = 1; // does not work yet + + // Bloch correction for O(Z4) higher-order Born approximation + // see Appl. Phys. 85 (1999) 1249 + const double alpha = 1. / 137.035999173; + double const y2 = Z * Z * alpha * alpha / beta2; + double const bloch = -y2 * (1.202 - y2 * (1.042 - 0.855 * y2 + 0.343 * y2 * y2)); + + // cout << "BetheBloch Erel=" << Erel << " barkas=" << barkas << " bloch=" << bloch << + // endl; + + double const aux = 2 * me * c2 * beta2 * gamma2 * Wmax / (Ieff * Ieff); + return -K * Z2 * ZoverA / beta2 * + (0.5 * log(aux) - beta2 - Cadj / Z - delta / 2 + barkas + bloch) * dX; + } + + process::EProcessReturn EnergyLoss::DoContinuous(Particle& p, Track& t, Stack&) { + if (p.GetChargeNumber() == 0) return process::EProcessReturn::eOk; + GrammageType const dX = + p.GetNode()->GetModelProperties().IntegratedGrammage(t, t.GetLength()); + cout << "EnergyLoss " << p.GetPID() << ", z=" << p.GetChargeNumber() + << ", dX=" << dX / 1_g * square(1_cm) << "g/cm2" << endl; + HEPEnergyType dE = BetheBloch(p, dX); + auto E = p.GetEnergy(); + const auto Ekin = E - p.GetMass(); + auto Enew = E + dE; + cout << "EnergyLoss dE=" << dE / 1_MeV << "MeV, " + << " E=" << E / 1_GeV << "GeV, Ekin=" << Ekin / 1_GeV + << ", Enew=" << Enew / 1_GeV << "GeV" << endl; + auto status = process::EProcessReturn::eOk; + if (-dE > Ekin) { + dE = -Ekin; + Enew = p.GetMass(); + status = process::EProcessReturn::eParticleAbsorbed; + } + p.SetEnergy(Enew); + MomentumUpdate(p, Enew); + fEnergyLossTot += dE; + GetXbin(p, dE); + return status; + } + + units::si::LengthType EnergyLoss::MaxStepLength(Particle&, Track&) { + return units::si::meter * std::numeric_limits<double>::infinity(); + } + + void EnergyLoss::MomentumUpdate(corsika::setup::Stack::ParticleType& p, + corsika::units::si::HEPEnergyType Enew) { + HEPMomentumType Pnew = elab2plab(Enew, p.GetMass()); + auto pnew = p.GetMomentum(); + p.SetMomentum(pnew * Pnew / pnew.GetNorm()); + } + +#include <corsika/geometry/CoordinateSystem.h> + + int EnergyLoss::GetXbin(corsika::setup::Stack::ParticleType& p, + const HEPEnergyType dE) { + + using namespace corsika::geometry; + + CoordinateSystem const& rootCS = + RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + Point pos1(rootCS, 0_m, 0_m, 0_m); + Point pos2(rootCS, 0_m, 0_m, p.GetPosition().GetCoordinates()[2]); + Vector delta = (pos2 - pos1) / 1_s; + Trajectory t(Line(pos1, delta), 1_s); + + GrammageType const grammage = + p.GetNode()->GetModelProperties().IntegratedGrammage(t, t.GetLength()); + + const int bin = grammage / fdX; + + // fill longitudinal profile + if (!fProfile.count(bin)) { cout << "EnergyLoss new x bin " << bin << endl; } + fProfile[bin] += -dE / 1_GeV; + return bin; + } + + void EnergyLoss::PrintProfile() const { + + cout << "EnergyLoss PrintProfile X-bin [g/cm2] dE/dX [GeV/g/cm2] " << endl; + double const deltaX = fdX / 1_g * square(1_cm); + for (auto v : fProfile) { + cout << v.first * deltaX << " " << v.second / deltaX << endl; + } + } + +} // namespace corsika::process::EnergyLoss diff --git a/Processes/EnergyLoss/EnergyLoss.h b/Processes/EnergyLoss/EnergyLoss.h new file mode 100644 index 0000000000000000000000000000000000000000..5eb2a6b6782b12bb7b336e67d43e2882d666b80a --- /dev/null +++ b/Processes/EnergyLoss/EnergyLoss.h @@ -0,0 +1,61 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _Processes_EnergyLoss_h_ +#define _Processes_EnergyLoss_h_ + +#include <corsika/process/ContinuousProcess.h> +#include <corsika/units/PhysicalUnits.h> + +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +#include <map> + +namespace corsika::process::EnergyLoss { + + class EnergyLoss : public corsika::process::ContinuousProcess<EnergyLoss> { + + using MeVgcm2 = decltype(1e6 * units::si::electronvolt / units::si::gram * + corsika::units::si::square(1e-2 * units::si::meter)); + + void MomentumUpdate(corsika::setup::Stack::ParticleType&, + corsika::units::si::HEPEnergyType Enew); + + public: + EnergyLoss(); + void Init() {} + + corsika::process::EProcessReturn DoContinuous(corsika::setup::Stack::ParticleType&, + corsika::setup::Trajectory&, + corsika::setup::Stack&); + corsika::units::si::LengthType MaxStepLength(corsika::setup::Stack::ParticleType&, + corsika::setup::Trajectory&); + + corsika::units::si::HEPEnergyType GetTotal() const { return fEnergyLossTot; } + void PrintProfile() const; + + private: + corsika::units::si::HEPEnergyType BetheBloch( + corsika::setup::Stack::ParticleType& p, + const corsika::units::si::GrammageType dX); + + int GetXbin(corsika::setup::Stack::ParticleType& p, + const corsika::units::si::HEPEnergyType dE); + + corsika::units::si::HEPEnergyType fEnergyLossTot; + corsika::units::si::GrammageType fdX; // profile binning + std::map<int, double> fProfile; // longitudinal profile + }; + +} // namespace corsika::process::EnergyLoss + +#endif diff --git a/Processes/EnergyLoss/Properties8.dat b/Processes/EnergyLoss/Properties8.dat new file mode 100644 index 0000000000000000000000000000000000000000..377c3df7748acf71795e02277fbf6cb8c1905943 --- /dev/null +++ b/Processes/EnergyLoss/Properties8.dat @@ -0,0 +1,2907 @@ +# RU Mo 18. Feb 14:07:40 CET 2019 +# Data table obtained from: http://pdg.lbl.gov/2018/AtomicNuclearProperties/properties8.dat +# see also: http://pdg.lbl.gov/2018/AtomicNuclearProperties/expert.html + 1 Hydro 3 1.0080000000 7 0.99212 8.3748E-05 8.3755E-05 D 1 1 4 E +H hydrogen_gas +hydrogen gas (H%2#) + 19.2 9.5835 1.8639 3.2718 0.14092 5.7273 0.00 + 1 1.000000 1.000000 +Boiling point -252.87 20.267 K +Melting point -259.34 13.82 K +Index of ref (n-1)*E6 132.0 http://www.kayelaby.npl.co.uk/ +Note: The mass of atomic <SUP>1</SUP>H is 1.007 276 522 6 (13) u (mass of the proton less binding energy of 13.61 eV = 1.461E-09 u). +---------------------------------------------------------------------------- + 2 Heliu 6 4.0026020000 2 0.49967 1.6632E-04 1.6632E-04 G 1 1 2 E +He helium_gas_He +helium gas (He) + 41.8 11.1393 2.2017 3.6122 0.13443 5.8347 0.00 + 2 1.000000 1.000000 +Boiling point -268.93 +Index of ref (n-1)*E6 35.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 3 Lithi 2 6.9400000000 2 0.43221 5.3400E-01 5.3400E-01 S 1 1 2 E +Li lithium_Li +lithium (Li) + 40.0 3.1221 0.1304 1.6397 0.95136 2.4993 0.14 + 3 1.000000 1.000000 +melting point 180.5 +boiling point 1342. +---------------------------------------------------------------------------- + 4 Beryl 7 9.0121831000 5 0.44384 1.8480E+00 1.8480E+00 S 1 1 2 E +Be beryllium_Be +beryllium (Be) + 63.7 2.7847 0.0592 1.6922 0.80392 2.4339 0.14 + 4 1.000000 1.000000 +melting point 1287. +boiling point 2471. +---------------------------------------------------------------------------- + 5 Boron 2 10.8100000000 7 0.46249 2.3700E+00 2.3700E+00 S 1 1 0 E +B boron_B +boron (B) + 76.0 2.8477 0.0305 1.9688 0.56224 2.4512 0.14 + 5 1.000000 1.000000 +---------------------------------------------------------------------------- + 6 Carbo 4 12.0107000000 8 0.49955 2.0000E+00 2.0000E+00 S 1 1 0 E +C carbon_amorphous_C +carbon (amorphous) (C) + 78.0 2.9925 -0.0351 2.4860 0.20240 3.0036 0.10 + 6 1.000000 1.000000 +---------------------------------------------------------------------------- + 7 Nitro 3 14.0070000000 2 0.49976 1.1653E-03 1.1653E-03 D 1 1 3 E +N nitrogen_gas +nitrogen gas (N%2#) + 82.0 10.5400 1.7378 4.1323 0.15349 3.2125 0.00 + 7 1.000000 1.000000 +Melting point (C) -210.00 +Boiling point (C) -195.86 +Index of ref (n-1)*E6 298.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 8 Oxyge 3 15.9990000000 3 0.50002 1.3315E-03 1.3315E-03 D 1 1 3 E +O oxygen_gas +oxygen gas (O%2#) + 95.0 10.7004 1.7541 4.3213 0.11778 3.2913 0.00 + 8 1.000000 1.000000 +Melting point (C) -218.79 +Boiling point (C) -182.95 +Index of ref (n-1)*E6 271.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 9 Fluor 9 18.9984031630 6 0.47372 1.5803E-03 1.5803E-03 D 1 1 3 E +F fluorine_gas +fluorine gas (F%2#) + 115.0 10.9653 1.8433 4.4096 0.11083 3.2962 0.00 + 9 1.000000 1.000000 +Melting point -219.62 +Boiling point -188.12 +Index ref (n-1) 195. +---------------------------------------------------------------------------- + 10 Neon 4 20.1797000000 6 0.49555 8.3851E-04 8.3851E-04 G 1 1 3 E +Ne neon_gas_Ne +neon gas (Ne) + 137.0 11.9041 2.0735 4.6421 0.08064 3.5771 0.00 + 10 1.000000 1.000000 +Boiling point -246.08 +Melting point -248.59 +Index ref 67.1 +---------------------------------------------------------------------------- + 11 Sodiu 8 22.9897692800 2 0.47847 9.7100E-01 9.7100E-01 S 1 1 0 E +Na sodium_Na +sodium (Na) + 149.0 5.0526 0.2880 3.1962 0.07772 3.6452 0.08 + 11 1.000000 1.000000 +---------------------------------------------------------------------------- + 12 Magne 3 24.3050000000 6 0.49373 1.7400E+00 1.7400E+00 S 1 1 0 E +Mg magnesium_Mg +magnesium (Mg) + 156.0 4.5297 0.1499 3.0668 0.08163 3.6166 0.08 + 12 1.000000 1.000000 +---------------------------------------------------------------------------- + 13 Alumi 7 26.9815385000 7 0.48181 2.6989E+00 2.6989E+00 S 1 1 2 E +Al aluminum_Al +aluminum (Al) + 166.0 4.2395 0.1708 3.0127 0.08024 3.6345 0.12 + 13 1.000000 1.000000 +melti 660.32 Aluminum +boili 2519. Aluminum +---------------------------------------------------------------------------- + 14 Silic 4 28.0855000000 3 0.49848 2.3300E+00 2.3290E+00 S 1 1 3 E +Si silicon_Si +silicon (Si) + 173.0 4.4351 0.2014 2.8715 0.14921 3.2546 0.14 + 14 1.000000 1.000000 +Index of ref 3.95 +Melting point 1414. +Boiling point 3265. +---------------------------------------------------------------------------- + 15 Phosp 9 30.9737619980 5 0.48428 2.2000E+00 2.2000E+00 S 1 1 0 E +P phosphorus_P +phosphorus (P) + 173.0 4.5214 0.1696 2.7815 0.23610 2.9158 0.14 + 15 1.000000 1.000000 +---------------------------------------------------------------------------- + 16 Sulfu 3 32.0650000000 5 0.49899 2.0000E+00 2.0000E+00 S 1 1 0 E +S sulfur_S +sulfur (S) + 180.0 4.6659 0.1580 2.7159 0.33992 2.6456 0.14 + 16 1.000000 1.000000 +---------------------------------------------------------------------------- + 17 Chlor 3 35.4530000000 2 0.47951 2.9947E-03 2.9800E-03 D 1 1 3 E +Cl chlorine_gas +chlorine gas (Cl%2#) + 174.0 11.1421 1.5555 4.2994 0.19849 2.9702 0.00 + 17 1.000000 1.000000 +Melting point -101.5 +Boiling point -34.04 +Index of ref (n-1)*E6 773.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 18 Argon 3 39.9480000000 1 0.45059 1.6620E-03 1.6620E-03 G 1 1 3 E +Ar argon_gas_Ar +argon gas (Ar) + 188.0 11.9480 1.7635 4.4855 0.19714 2.9618 0.00 + 18 1.000000 1.000000 +Boiling point -185.89 +Melting point -189.3442 +Index of ref (n-1)*E6 281.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 19 Potas 4 39.0983000000 1 0.48595 8.6200E-01 8.6200E-01 S 1 1 0 E +K potassium_K +potassium (K) + 190.0 5.6423 0.3851 3.1724 0.19827 2.9233 0.10 + 19 1.000000 1.000000 +---------------------------------------------------------------------------- + 20 Calci 3 40.0780000000 4 0.49903 1.5500E+00 1.5500E+00 S 1 1 0 E +Ca calcium_Ca +calcium (Ca) + 191.0 5.0396 0.3228 3.1191 0.15643 3.0745 0.14 + 20 1.000000 1.000000 +---------------------------------------------------------------------------- + 21 Scand 6 44.9559080000 5 0.46712 2.9890E+00 2.9890E+00 S 1 1 0 E +Sc scandium_Sc +scandium (Sc) + 216.0 4.6949 0.1640 3.0593 0.15754 3.0517 0.10 + 21 1.000000 1.000000 +---------------------------------------------------------------------------- + 22 Titan 3 47.8670000000 1 0.45961 4.5400E+00 4.5400E+00 S 1 1 2 E +Ti titanium_Ti +titanium (Ti) + 233.0 4.4450 0.0957 3.0386 0.15662 3.0302 0.12 + 22 1.000000 1.000000 +melti 1668. Titanium +boili 3287. Titanium +---------------------------------------------------------------------------- + 23 Vanad 4 50.9415000000 1 0.45150 6.1100E+00 6.1100E+00 S 1 1 0 E +V vanadium_V +vanadium (V) + 245.0 4.2659 0.0691 3.0322 0.15436 3.0163 0.14 + 23 1.000000 1.000000 +---------------------------------------------------------------------------- + 24 Chrom 4 51.9961000000 6 0.46157 7.1800E+00 7.1800E+00 S 1 1 0 E +Cr chromium_Cr +chromium (Cr) + 257.0 4.1781 0.0340 3.0451 0.15419 2.9896 0.14 + 24 1.000000 1.000000 +---------------------------------------------------------------------------- + 25 Manga 6 54.9380440000 3 0.45506 7.4400E+00 7.4400E+00 S 1 1 0 E +Mn manganese_Mn +manganese (Mn) + 272.0 4.2702 0.0447 3.1074 0.14973 2.9796 0.14 + 25 1.000000 1.000000 +---------------------------------------------------------------------------- + 26 Iron 3 55.8450000000 2 0.46557 7.8740E+00 7.8740E+00 S 1 1 2 E +Fe iron_Fe +iron (Fe) + 286.0 4.2911 -0.0012 3.1531 0.14680 2.9632 0.12 + 26 1.000000 1.000000 +Melting point C 1538. +Boiling point C 2861. +---------------------------------------------------------------------------- + 27 Cobal 6 58.9331940000 4 0.45815 8.9000E+00 8.9000E+00 S 1 1 0 E +Co cobalt_Co +cobalt (Co) + 297.0 4.2601 -0.0187 3.1790 0.14474 2.9502 0.12 + 27 1.000000 1.000000 +---------------------------------------------------------------------------- + 28 Nicke 4 58.6934000000 4 0.47706 8.9020E+00 8.9020E+00 S 1 1 0 E +Ni nickel_Ni +nickel (Ni) + 311.0 4.3115 -0.0566 3.1851 0.16496 2.8430 0.10 + 28 1.000000 1.000000 +---------------------------------------------------------------------------- + 29 Coppe 3 63.5460000000 3 0.45636 8.9600E+00 8.9600E+00 S 1 1 2 E +Cu copper_Cu +copper (Cu) + 322.0 4.4190 -0.0254 3.2792 0.14339 2.9044 0.08 + 29 1.000000 1.000000 +melti 1084.62 Copper +boili 2562. Copper +---------------------------------------------------------------------------- + 30 Zinc 2 65.3800000000 2 0.45886 7.1330E+00 7.1330E+00 S 1 1 0 E +Zn zinc_Zn +zinc (Zn) + 330.0 4.6906 0.0049 3.3668 0.14714 2.8652 0.08 + 30 1.000000 1.000000 +---------------------------------------------------------------------------- + 31 Galli 3 69.7230000000 1 0.44462 5.9040E+00 5.9040E+00 S 1 1 0 E +Ga gallium_Ga +gallium (Ga) + 334.0 4.9353 0.2267 3.5434 0.09440 3.1314 0.14 + 31 1.000000 1.000000 +---------------------------------------------------------------------------- + 32 Germa 3 72.6300000000 1 0.44053 5.3230E+00 5.3230E+00 S 1 1 2 E +Ge germanium_Ge +germanium (Ge) + 350.0 5.1411 0.3376 3.6096 0.07188 3.3306 0.14 + 32 1.000000 1.000000 +melti 938.25 Germanium +boili 2833. Germanium +---------------------------------------------------------------------------- + 33 Arsen 6 74.9215950000 6 0.44046 5.7300E+00 5.7300E+00 S 1 1 0 E +As arsenic_As +arsenic (As) + 347.0 5.0510 0.1767 3.5702 0.06633 3.4176 0.08 + 33 1.000000 1.000000 +---------------------------------------------------------------------------- + 34 Selen 3 78.9710000000 8 0.43060 4.5000E+00 4.5000E+00 S 1 1 0 E +Se selenium_Se +selenium (Se) + 348.0 5.3210 0.2258 3.6264 0.06568 3.4317 0.10 + 34 1.000000 1.000000 +---------------------------------------------------------------------------- + 35 Bromi 3 79.9040000000 1 0.43803 7.0722E-03 7.0722E-03 D 1 1 2 E +Br bromine_gas +bromine gas (Br%2#) + 343.0 11.7307 1.5262 4.9899 0.06335 3.4670 0.00 + 35 1.000000 1.000000 +melting point -7.2 +boiling point 58.78 +---------------------------------------------------------------------------- + 36 Krypt 3 83.7980000000 2 0.42960 3.4783E-03 3.4856E-03 G 1 1 2 E +Kr krypton_gas_Kr +krypton gas (Kr) + 352.0 12.5115 1.7158 5.0748 0.07446 3.4051 0.00 + 36 1.000000 1.000000 +melting point -157.36 +boiling point -153.22 +---------------------------------------------------------------------------- + 37 Rubid 4 85.4678000000 3 0.43291 1.5320E+00 1.5320E+00 S 1 1 0 E +Rb rubidium_Rb +rubidium (Rb) + 363.0 6.4776 0.5737 3.7995 0.07261 3.4177 0.14 + 37 1.000000 1.000000 +---------------------------------------------------------------------------- + 38 Stron 2 87.6200000000 1 0.43369 2.5400E+00 2.5400E+00 S 1 1 0 E +Sr strontium_Sr +strontium (Sr) + 366.0 5.9867 0.4585 3.6778 0.07165 3.4435 0.14 + 38 1.000000 1.000000 +---------------------------------------------------------------------------- + 39 Yttri 5 88.9058400000 2 0.43867 4.4690E+00 4.4690E+00 S 1 1 0 E +Y yttrium_Y +yttrium (Y) + 379.0 5.4801 0.3608 3.5542 0.07138 3.4585 0.14 + 39 1.000000 1.000000 +---------------------------------------------------------------------------- + 40 Zirco 3 91.2240000000 2 0.43848 6.5060E+00 6.5060E+00 S 1 1 0 E +Zr zirconium_Zr +zirconium (Zr) + 393.0 5.1774 0.2957 3.4890 0.07177 3.4533 0.14 + 40 1.000000 1.000000 +---------------------------------------------------------------------------- + 41 Niobi 5 92.9063700000 2 0.44130 8.5700E+00 8.5700E+00 S 1 1 0 E +Nb niobium_Nb +niobium (Nb) + 417.0 5.0141 0.1785 3.2201 0.13883 3.0930 0.14 + 41 1.000000 1.000000 +---------------------------------------------------------------------------- + 42 Molyb 2 95.9500000000 1 0.43768 1.0220E+01 1.0220E+01 S 1 1 0 E +Mo molybdenum_Mo +molybdenum (Mo) + 424.0 4.8793 0.2267 3.2784 0.10525 3.2549 0.14 + 42 1.000000 1.000000 +---------------------------------------------------------------------------- + 43 Techn 5 97.9072200000 3 0.43919 1.1500E+01 1.1500E+01 S 1 1 3 R +Tc technetium_Tc +technetium (Tc) + 428.0 4.7769 0.0949 3.1253 0.16572 2.9738 0.14 + 43 1.000000 1.000000 +melting 2157. +boiling 4265. +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 44 Ruthe 2 101.0700000000 2 0.43534 1.2410E+01 1.2410E+01 S 1 1 0 E +Ru ruthenium_Ru +ruthenium (Ru) + 441.0 4.7694 0.0599 3.0834 0.19342 2.8707 0.14 + 44 1.000000 1.000000 +---------------------------------------------------------------------------- + 45 Rhodi 5 102.9055000000 2 0.43729 1.2410E+01 1.2410E+01 S 1 1 0 E +Rh rhodium_Rh +rhodium (Rh) + 449.0 4.8008 0.0576 3.1069 0.19205 2.8633 0.14 + 45 1.000000 1.000000 +---------------------------------------------------------------------------- + 46 Palla 2 106.4200000000 1 0.43225 1.2020E+01 1.2020E+01 S 1 1 0 E +Pd palladium_Pd +palladium (Pd) + 470.0 4.9358 0.0563 3.0555 0.24178 2.7239 0.14 + 46 1.000000 1.000000 +---------------------------------------------------------------------------- + 47 Silve 4 107.8682000000 2 0.43572 1.0500E+01 1.0500E+01 S 1 1 0 E +Ag silver_Ag +silver (Ag) + 470.0 5.0630 0.0657 3.1074 0.24585 2.6899 0.14 + 47 1.000000 1.000000 +---------------------------------------------------------------------------- + 48 Cadmi 3 112.4140000000 4 0.42700 8.6500E+00 8.6500E+00 S 1 1 0 E +Cd cadmium_Cd +cadmium (Cd) + 469.0 5.2727 0.1281 3.1667 0.24609 2.6772 0.14 + 48 1.000000 1.000000 +---------------------------------------------------------------------------- + 49 Indiu 3 114.8180000000 3 0.42676 7.3100E+00 7.3100E+00 S 1 1 0 E +In indium_In +indium (In) + 488.0 5.5211 0.2406 3.2032 0.23879 2.7144 0.14 + 49 1.000000 1.000000 +---------------------------------------------------------------------------- + 50 Tin 3 118.7100000000 7 0.42119 7.3100E+00 7.3100E+00 S 1 1 2 E +Sn tin_Sn +tin (Sn) + 488.0 5.5340 0.2879 3.2959 0.18689 2.8576 0.14 + 50 1.000000 1.000000 +melti 231.93 Tin +boili 2602. Tin +---------------------------------------------------------------------------- + 51 Antim 3 121.7600000000 1 0.41886 6.6910E+00 6.6910E+00 S 1 1 0 E +Sb antimony_Sb +antimony (Sb) + 487.0 5.6241 0.3189 3.3489 0.16652 2.9319 0.14 + 51 1.000000 1.000000 +---------------------------------------------------------------------------- + 52 Tellu 2 127.6000000000 3 0.40752 6.2400E+00 6.2400E+00 S 1 1 0 E +Te tellurium_Te +tellurium (Te) + 485.0 5.7131 0.3296 3.4418 0.13815 3.0354 0.14 + 52 1.000000 1.000000 +---------------------------------------------------------------------------- + 53 Iodin 5 126.9044700000 3 0.41764 4.9300E+00 4.9300E+00 S 1 1 2 E +I iodine_I +iodine (I) + 491.0 5.9488 0.0549 3.2596 0.23766 2.7276 0.00 + 53 1.000000 1.000000 +melting point 113.7 +boiling point 184.4 +---------------------------------------------------------------------------- + 54 Xenon 3 131.2930000000 6 0.41129 5.4854E-03 5.4830E-03 G 1 1 3 E +Xe xenon_gas_Xe +xenon gas (Xe) + 482.0 12.7281 1.5630 4.7371 0.23314 2.7414 0.00 + 54 1.000000 1.000000 +Index ref 701. +Melting point -111.75 +Boiling point -108.0 +---------------------------------------------------------------------------- + 55 Caesi 8 132.9054519600 6 0.41383 1.8730E+00 1.8730E+00 S 1 1 0 E +Cs caesium_Cs +caesium (Cs) + 488.0 6.9135 0.5473 3.5914 0.18233 2.8866 0.14 + 55 1.000000 1.000000 +---------------------------------------------------------------------------- + 56 Bariu 3 137.3270000000 7 0.40779 3.5000E+00 3.5000E+00 S 1 1 0 E +Ba barium_Ba +barium (Ba) + 491.0 6.3153 0.4190 3.4547 0.18268 2.8906 0.14 + 56 1.000000 1.000000 +---------------------------------------------------------------------------- + 57 Lanth 5 138.9054700000 7 0.41035 6.1540E+00 6.1450E+00 S 1 1 0 E +La lanthanum_La +lanthanum (La) + 501.0 5.7850 0.3161 3.3293 0.18591 2.8828 0.14 + 57 1.000000 1.000000 +---------------------------------------------------------------------------- + 58 Ceriu 3 140.1160000000 1 0.41394 6.6570E+00 6.7700E+00 S 1 1 0 E +Ce cerium_Ce +cerium (Ce) + 523.0 5.7837 0.2713 3.3432 0.18885 2.8592 0.14 + 58 1.000000 1.000000 +---------------------------------------------------------------------------- + 59 Prase 5 140.9076600000 2 0.41871 6.7100E+00 6.7730E+00 S 1 1 0 E +Pr praseodymium_Pr +praseodymium (Pr) + 535.0 5.8096 0.2333 3.2773 0.23265 2.7331 0.14 + 59 1.000000 1.000000 +---------------------------------------------------------------------------- + 60 Neody 3 144.2420000000 3 0.41597 6.9000E+00 7.0080E+00 S 1 1 0 E +Nd neodymium_Nd +neodymium (Nd) + 546.0 5.8290 0.1984 3.3063 0.23530 2.7050 0.14 + 60 1.000000 1.000000 +---------------------------------------------------------------------------- + 61 Prome 5 144.9127500000 3 0.42094 7.2200E+00 7.2640E+00 S 1 1 1 R +Pm promethium_Pm +promethium (Pm) + 560.0 5.8224 0.1627 3.3199 0.24280 2.6674 0.14 + 61 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 62 Samar 2 150.3600000000 2 0.41234 7.4600E+00 7.5200E+00 S 1 1 0 E +Sm samarium_Sm +samarium (Sm) + 574.0 5.8597 0.1520 3.3460 0.24698 2.6403 0.14 + 62 1.000000 1.000000 +---------------------------------------------------------------------------- + 63 Europ 3 151.9640000000 1 0.41457 5.2430E+00 5.2440E+00 S 1 1 0 E +Eu europium_Eu +europium (Eu) + 580.0 6.2278 0.1888 3.4633 0.24448 2.6245 0.14 + 63 1.000000 1.000000 +---------------------------------------------------------------------------- + 64 Gadol 2 157.2500000000 3 0.40700 7.9004E+00 7.9010E+00 S 1 1 0 E +Gd gadolinium_Gd +gadolinium (Gd) + 591.0 5.8738 0.1058 3.3932 0.25109 2.5977 0.14 + 64 1.000000 1.000000 +---------------------------------------------------------------------------- + 65 Terbi 5 158.9253500000 2 0.40900 8.2290E+00 8.2300E+00 S 1 1 0 E +Tb terbium_Tb +terbium (Tb) + 614.0 5.9045 0.0947 3.4224 0.24453 2.6056 0.14 + 65 1.000000 1.000000 +---------------------------------------------------------------------------- + 66 Dyspr 3 162.5000000000 1 0.40615 8.5500E+00 8.5510E+00 S 1 1 0 E +Dy dysprosium_Dy +dysprosium (Dy) + 628.0 5.9183 0.0822 3.4474 0.24665 2.5849 0.14 + 66 1.000000 1.000000 +---------------------------------------------------------------------------- + 67 Holmi 5 164.9303300000 2 0.40623 8.7950E+00 8.7950E+00 S 1 1 0 E +Ho holmium_Ho +holmium (Ho) + 650.0 5.9587 0.0761 3.4782 0.24638 2.5726 0.14 + 67 1.000000 1.000000 +---------------------------------------------------------------------------- + 68 Erbiu 3 167.2590000000 3 0.40656 9.0660E+00 9.0260E+00 S 1 1 0 E +Er erbium_Er +erbium (Er) + 658.0 5.9521 0.0648 3.4922 0.24823 2.5573 0.14 + 68 1.000000 1.000000 +---------------------------------------------------------------------------- + 69 Thuli 5 168.9342200000 2 0.40844 9.3210E+00 9.3210E+00 S 1 1 0 E +Tm thulium_Tm +thulium (Tm) + 674.0 5.9677 0.0812 3.5085 0.24889 2.5469 0.14 + 69 1.000000 1.000000 +---------------------------------------------------------------------------- + 70 Ytter 3 173.0540000000 5 0.40450 6.7300E+00 6.9030E+00 S 1 1 0 E +Yb ytterbium_Yb +ytterbium (Yb) + 684.0 6.3325 0.1199 3.6246 0.25295 2.5141 0.14 + 70 1.000000 1.000000 +---------------------------------------------------------------------------- + 71 Lutet 4 174.9668000000 1 0.40579 9.8400E+00 9.8410E+00 S 1 1 0 E +Lu lutetium_Lu +lutetium (Lu) + 694.0 5.9785 0.1560 3.5218 0.24033 2.5643 0.14 + 71 1.000000 1.000000 +---------------------------------------------------------------------------- + 72 Hafni 2 178.4900000000 2 0.40338 1.3310E+01 1.3310E+01 S 1 1 0 E +Hf hafnium_Hf +hafnium (Hf) + 705.0 5.7139 0.1965 3.4337 0.22918 2.6155 0.14 + 72 1.000000 1.000000 +---------------------------------------------------------------------------- + 73 Tanta 5 180.9478800000 2 0.40343 1.6654E+01 1.6654E+01 S 1 1 0 E +Ta tantalum_Ta +tantalum (Ta) + 718.0 5.5262 0.2117 3.4805 0.17798 2.7623 0.14 + 73 1.000000 1.000000 +---------------------------------------------------------------------------- + 74 Tungs 2 183.8400000000 1 0.40252 1.9300E+01 1.9300E+01 S 1 1 2 E +W tungsten_W +tungsten (W) + 727.0 5.4059 0.2167 3.4960 0.15509 2.8447 0.14 + 74 1.000000 1.000000 +melti 3422. Tungsten +boili 5555. Tungsten +---------------------------------------------------------------------------- + 75 Rheni 3 186.2070000000 1 0.40278 2.1020E+01 2.1020E+01 S 1 1 0 E +Re rhenium_Re +rhenium (Re) + 736.0 5.3445 0.0559 3.4845 0.15184 2.8627 0.08 + 75 1.000000 1.000000 +---------------------------------------------------------------------------- + 76 Osmiu 2 190.2300000000 3 0.39952 2.2570E+01 2.2570E+01 S 1 1 0 E +Os osmium_Os +osmium (Os) + 746.0 5.3083 0.0891 3.5414 0.12751 2.9608 0.10 + 76 1.000000 1.000000 +---------------------------------------------------------------------------- + 77 Iridi 3 192.2170000000 3 0.40059 2.2420E+01 2.2420E+01 S 1 1 0 E +Ir iridium_Ir +iridium (Ir) + 757.0 5.3418 0.0819 3.5480 0.12690 2.9658 0.10 + 77 1.000000 1.000000 +---------------------------------------------------------------------------- + 78 Plati 3 195.0840000000 9 0.39983 2.1450E+01 2.1450E+01 S 1 1 2 E +Pt platinum_Pt +platinum (Pt) + 790.0 5.4732 0.1484 3.6212 0.11128 3.0417 0.12 + 78 1.000000 1.000000 +melti 1768.4 Platinum +boili 3825. Platinum +---------------------------------------------------------------------------- + 79 Gold 6 196.9665690000 5 0.40108 1.9320E+01 1.9320E+01 S 1 1 2 E +Au gold_Au +gold (Au) + 790.0 5.5747 0.2021 3.6979 0.09756 3.1101 0.14 + 79 1.000000 1.000000 +melti 1064.18 Gold +boili 2856. Gold +---------------------------------------------------------------------------- + 80 Mercu 3 200.5920000000 2 0.39882 1.3546E+01 1.3546E+01 L 1 1 0 E +Hg mercury_Hg +mercury (Hg) + 800.0 5.9605 0.2756 3.7275 0.11014 3.0519 0.14 + 80 1.000000 1.000000 +---------------------------------------------------------------------------- + 81 Thall 2 204.3800000000 2 0.39631 1.1720E+01 1.1720E+01 S 1 1 0 E +Tl thallium_Tl +thallium (Tl) + 810.0 6.1365 0.3491 3.8044 0.09455 3.1450 0.14 + 81 1.000000 1.000000 +---------------------------------------------------------------------------- + 82 Lead 1 207.2000000000 1 0.39575 1.1350E+01 1.1350E+01 S 1 1 2 E +Pb lead_Pb +lead (Pb) + 823.0 6.2018 0.3776 3.8073 0.09359 3.1608 0.14 + 82 1.000000 1.000000 +melti 327.46 Lead +boili 1749. Lead +---------------------------------------------------------------------------- + 83 Bismu 5 208.9804000000 1 0.39717 9.7470E+00 9.7470E+00 S 1 1 0 E +Bi bismuth_Bi +bismuth (Bi) + 823.0 6.3505 0.4152 3.8248 0.09410 3.1671 0.14 + 83 1.000000 1.000000 +---------------------------------------------------------------------------- + 84 Polon 5 208.9824300000 2 0.40195 9.3200E+00 9.3200E+00 S 1 1 1 R +Po polonium_Po +polonium (Po) + 830.0 6.4003 0.4267 3.8293 0.09282 3.1830 0.14 + 84 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 85 H-liq 3 1.0080000000 7 0.99212 6.0000E-02 7.0800E-02 L 1 1 3 E +H liquid_hydrogen +liquid hydrogen (H%2#) + 21.8 3.2632 0.4759 1.9215 0.13483 5.6249 0.00 + 1 1.000000 1.000000 +Melting point -259.34 Rubber Bible +Boiling point -252.87 Rubber Bible +Index of ref 1.112 +---------------------------------------------------------------------------- + 86 Radon 5 222.0175800000 2 0.38736 9.0662E-03 9.0662E-03 G 1 1 3 R +Rn radon_Rn +radon (Rn) + 794.0 13.2839 1.5368 4.9889 0.20798 2.7409 0.00 + 86 1.000000 1.000000 +Melting point -71. +Boiling point -61.7 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 87 C (gr 4 12.0107000000 8 0.49955 1.7000E+00 2.2100E+00 S 1 1 2 E +C carbon_graphite_C +carbon (graphite) (C) + 78.0 3.1550 0.0480 2.5387 0.20762 2.9532 0.14 + 6 1.000000 1.000000 +Sublimation point 3825.0 +Note: Density may vary 2.09 to 2.23 +---------------------------------------------------------------------------- + 88 Radiu 5 226.0254100000 2 0.38934 5.0000E+00 5.0000E+00 S 1 1 1 R +Ra radium_Ra +radium (Ra) + 826.0 7.0452 0.5991 3.9428 0.08804 3.2454 0.14 + 88 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 89 Actin 5 227.0277500000 2 0.39202 1.0070E+01 1.0070E+01 S 1 1 1 R +Ac actinium_Ac +actinium (Ac) + 841.0 6.3742 0.4559 3.7966 0.08567 3.2683 0.14 + 89 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 90 Thori 4 232.0377000000 4 0.38787 1.1720E+01 1.1720E+01 S 1 1 3 R +Th thorium_Th +thorium (Th) + 847.0 6.2473 0.4202 3.7681 0.08655 3.2610 0.14 + 90 1.000000 1.000000 +melting 1135. +boiling 4131. +Note: There is a well-defined terrestrial aboundance for thorium even though it is radioactive. +---------------------------------------------------------------------------- + 91 Prota 5 231.0358800000 2 0.39388 1.5370E+01 1.5370E+01 S 1 1 2 R +Pa protactinium_Pa +protactinium (Pa) + 878.0 6.0327 0.3144 3.5079 0.14770 2.9845 0.14 + 91 1.000000 1.000000 +melting 1572. +Note: There is a well-defined terrestrial aboundance for protactinium even though it is radioactive. +---------------------------------------------------------------------------- + 92 Urani 5 238.0289100000 3 0.38651 1.8950E+01 1.8950E+01 S 1 1 3 R +U uranium_U +uranium (U) + 890.0 5.8694 0.2260 3.3721 0.19677 2.8171 0.14 + 92 1.000000 1.000000 +melti 1135. Uranium +boili 4131. Uranium +Note: There is a well-defined terrestrial aboundance for uranium even though it is radioactive. +---------------------------------------------------------------------------- + 93 Neptu 5 237.0481700000 2 0.39233 2.0250E+01 2.0250E+01 S 1 1 1 R +Np neptunium_Np +neptunium (Np) + 902.0 5.8149 0.1869 3.3690 0.19741 2.8082 0.14 + 93 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 94 Pluto 5 244.0642000000 4 0.38514 1.9840E+01 1.9840E+01 S 1 1 1 R +Pu plutonium_Pu +plutonium (Pu) + 921.0 5.8748 0.1557 3.3981 0.20419 2.7679 0.14 + 94 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 95 Ameri 5 243.0613800000 2 0.39085 1.3670E+01 1.3670E+01 S 1 1 1 R +Am americium_Am +americium (Am) + 934.0 6.2813 0.2274 3.5021 0.20308 2.7615 0.14 + 95 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 96 Curiu 5 247.0703500000 3 0.38855 1.3510E+01 1.3510E+01 S 1 1 2 R +Cm curium_Cm +curium (Cm) + 939.0 6.3097 0.2484 3.5160 0.20257 2.7579 0.14 + 96 1.000000 1.000000 +Melting 1345. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 97 Berke 5 247.0703100000 4 0.39260 0.9860E+00 0.9860E+01 S 1 1 2 R +Bk berkelium_Bk +berkelium (Bk) + 952.0 6.2912 0.5509 3.0000 0.25556 3.0000 0.00 + 97 1.000000 1.000000 +Melting point 986. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 98 Carbo 4 12.0107000000 8 0.49955 2.2650E+00 2.2650E+00 S 1 1 0 R +C carbon_compact_C +carbon (compact) (C) + 78.0 2.8680 -0.0178 2.3415 0.26142 2.8697 0.12 + 6 1.000000 1.000000 +---------------------------------------------------------------------------- + 99 A-150 5 -1.0000000000 0.54903 1.1270E+00 1.1270E+00 S 6 1 0 B + a-150_tissue-equivalent_plastic +A-150 tissue-equivalent plastic + 65.1 3.1100 0.1329 2.6234 0.10783 3.4442 0.00 + 1 1.000000 0.101327 + 6 0.642279 0.775501 + 7 0.024897 0.035057 + 8 0.032527 0.052316 + 9 0.009122 0.017422 + 20 0.004561 0.018378 +---------------------------------------------------------------------------- + 100 Aceto 5 -1.0000000000 0.55097 7.8990E-01 7.8990E-01 L 3 6 1 O + acetone +acetone (CH%3#COCH%3#) + 64.2 3.4341 0.2197 2.6928 0.11100 3.4047 0.00 + 1 6.000000 0.104122 + 6 3.000201 0.620405 + 8 1.000043 0.275473 +Index of ref 1.36 +---------------------------------------------------------------------------- + 101 Acety 5 -1.0000000000 0.53768 1.0967E-03 1.0967E-03 G 2 2 0 O + acetylene_CHCH +acetylene (CHCH) + 58.2 9.8419 1.6017 4.0074 0.12167 3.4277 0.00 + 1 2.000000 0.077418 + 6 2.000135 0.922582 +---------------------------------------------------------------------------- + 102 Adeni 5 -1.0000000000 0.51903 1.3500E+00 1.3500E+00 S 3 5 0 O + adenine +adenine (C%5#H%5#N%5#) + 71.4 3.1724 0.1295 2.4219 0.20908 3.0271 0.00 + 1 5.000000 0.037294 + 6 5.000354 0.444430 + 7 5.000218 0.518275 +---------------------------------------------------------------------------- + 103 Adip- 5 -1.0000000000 0.55947 9.2000E-01 9.2000E-01 S 13 1 0 B + adipose_tissue_ICRP +adipose tissue (ICRP) + 63.2 3.2367 0.1827 2.6530 0.10278 3.4817 0.00 + 1 1.000000 0.119477 + 6 0.447595 0.637240 + 7 0.004800 0.007970 + 8 0.122506 0.232333 + 11 0.000183 0.000500 + 12 0.000007 0.000020 + 15 0.000044 0.000160 + 16 0.000192 0.000730 + 17 0.000283 0.001190 + 19 0.000069 0.000320 + 20 0.000004 0.000020 + 26 0.000003 0.000020 + 30 0.000003 0.000020 +---------------------------------------------------------------------------- + 104 Air 5 -1.0000000000 0.49919 1.2048E-03 1.2048E-03 G 4 0 2 M + air_dry_1_atm +air (dry, 1 atm) + 85.7 10.5961 1.7418 4.2759 0.10914 3.3994 0.00 + 6 0.000124 0.000124 + 7 0.755267 0.755267 + 8 0.231871 0.231781 + 18 0.012827 0.012827 +Boiling point -194.35 +Index of ref 288.6 http://emtoolbox.nist.gov/ +---------------------------------------------------------------------------- + 105 Alani 5 -1.0000000000 0.53976 1.4200E+00 1.4200E+00 S 4 7 0 O + alanine +alanine (C%3#H%7#NO%2#) + 71.9 3.0965 0.1354 2.6336 0.11484 3.3526 0.00 + 1 7.000000 0.079190 + 6 3.000178 0.404439 + 7 1.000032 0.157213 + 8 2.000071 0.359159 +---------------------------------------------------------------------------- + 106 Al2O3 5 -1.0000000000 0.49038 3.9700E+00 3.9700E+00 S 2 3 3 I + aluminum_oxide_sapphire +aluminum oxide (sapphire, Al%2#O%3#) + 145.2 3.5682 0.0402 2.8665 0.08500 3.5458 0.00 + 8 3.000000 0.470749 + 13 2.000002 0.529251 +Index of refraction 1.77 +Melting point 2054. +Boiling point 3000. approximate +---------------------------------------------------------------------------- + 107 Amber 5 -1.0000000000 0.55179 1.1000E+00 1.1000E+00 S 3 16 0 O + amber +amber (C%10#H%16#O) + 63.2 3.0701 0.1335 2.5610 0.11934 3.4098 0.00 + 1 16.000000 0.105930 + 6 10.000679 0.788973 + 8 1.000042 0.105096 +---------------------------------------------------------------------------- + 108 Ammon 5 -1.0000000000 0.59719 8.2602E-04 8.2602E-04 G 2 3 1 I + ammonia +ammonia (NH%3#) + 53.7 9.8763 1.6822 4.1158 0.08315 3.6464 0.00 + 1 3.000000 0.177547 + 7 1.000038 0.822453 +Index of ref (n-1)*E6 376.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 109 Anili 5 -1.0000000000 0.53699 1.0235E+00 1.0235E+00 L 3 7 0 O + aniline +aniline (C%6#H%5#NH%2#) + 66.2 3.2622 0.1618 2.5805 0.13134 3.3434 0.00 + 1 7.000000 0.075759 + 6 6.000400 0.773838 + 7 1.000041 0.150403 +---------------------------------------------------------------------------- + 110 Anthr 5 -1.0000000000 0.52740 1.2830E+00 1.2830E+00 S 2 10 0 O + anthracene +anthracene (C%14#H%10#) + 69.5 3.1514 0.1146 2.5213 0.14677 3.2831 0.00 + 1 10.000000 0.056550 + 6 14.000793 0.943450 +---------------------------------------------------------------------------- + 111 B-100 5 -1.0000000000 0.52740 1.4500E+00 1.4500E+00 S 6 1 0 B + b-100_Bone-equivalent_plastic +b-100 Bone-equivalent plastic + 85.9 3.4528 0.1252 3.0420 0.05268 3.7365 0.00 + 1 1.000000 0.065471 + 6 0.688251 0.536945 + 7 0.023631 0.021500 + 8 0.030873 0.032085 + 9 0.135660 0.167411 + 20 0.067833 0.176589 +---------------------------------------------------------------------------- + 112 Bakel 5 -1.0000000000 0.52792 1.2500E+00 1.2500E+00 S 3 38 0 P + bakelite +bakelite [(C%43#H%38#O%7#)%n#] + 72.4 3.2582 0.1471 2.6055 0.12713 3.3470 0.00 + 1 38.000000 0.057441 + 6 43.003166 0.774591 + 8 7.000340 0.167968 +---------------------------------------------------------------------------- + 113 Ba-F2 5 -1.0000000000 0.42207 4.8900E+00 4.8930E+00 S 2 2 3 I + barium_fluoride +barium fluoride (BaF%2#) + 375.9 5.4122 -0.0098 3.3871 0.15991 2.8867 0.00 + 9 2.000000 0.216720 + 56 1.000021 0.783280 +Melting point (C) 1368. +Boiling point (C) 2260. +Index of ref 1.4744 CRC2006 10-246 +---------------------------------------------------------------------------- + 114 Ba-SO 5 -1.0000000000 0.44561 4.5000E+00 4.5000E+00 S 3 4 0 I + barium_sulfate +barium sulfate BaSO%4# + 285.7 4.8923 -0.0128 3.4069 0.11747 3.0427 0.00 + 8 4.000000 0.274212 + 16 0.999811 0.137368 + 56 1.000020 0.588420 +---------------------------------------------------------------------------- + 115 Benze 5 -1.0000000000 0.53769 8.7865E-01 8.7865E-01 L 2 6 0 O + benzene +benzene C%6#H%6# + 63.4 3.3269 0.1710 2.5091 0.16519 3.2174 0.00 + 1 6.000000 0.077418 + 6 6.000406 0.922582 +---------------------------------------------------------------------------- + 116 Be-O 5 -1.0000000000 0.47979 3.0100E+00 3.0100E+00 S 2 1 0 I + beryllium_oxide_BeO +beryllium oxide (BeO) + 93.2 2.9801 0.0241 2.5846 0.10755 3.4927 0.00 + 4 1.000000 0.360320 + 8 1.000002 0.639680 +---------------------------------------------------------------------------- + 117 BGO 5 -1.0000000000 0.42065 7.1300E+00 7.1300E+00 S 3 12 3 I + bismuth_germanate_BGO +bismuth germanate (BGO) [(Bi%2#O%3#)%2#(GeO%2#)%3#] + 534.1 5.7409 0.0456 3.7816 0.09569 3.0781 0.00 + 8 12.000000 0.154126 + 32 2.999188 0.174820 + 83 4.000009 0.671054 +Melting point 1044. CRC2006 +Index of refraction 2.15 +Note: Evalite structure; less common is Bi{12}GeO{20} +---------------------------------------------------------------------------- + 118 Blood 5 -1.0000000000 0.54995 1.0600E+00 1.0600E+00 L 14 1 0 B + blood_ICRP +blood (ICRP) + 75.2 3.4581 0.2239 2.8017 0.08492 3.5406 0.00 + 1 1.000000 0.101866 + 6 0.082399 0.100020 + 7 0.020939 0.029640 + 8 0.469656 0.759414 + 11 0.000796 0.001850 + 12 0.000016 0.000040 + 14 0.000011 0.000030 + 15 0.000112 0.000350 + 16 0.000571 0.001850 + 17 0.000776 0.002780 + 19 0.000413 0.001630 + 20 0.000015 0.000060 + 26 0.000082 0.000460 + 30 0.000002 0.000010 +---------------------------------------------------------------------------- + 119 Bonec 5 -1.0000000000 0.53010 1.8500E+00 1.8500E+00 S 8 1 0 B + compact_bone_ICRU +compact bone (ICRU) + 91.9 3.3390 0.0944 3.0201 0.05822 3.6419 0.00 + 1 1.000000 0.063984 + 6 0.364619 0.278000 + 7 0.030366 0.027000 + 8 0.403702 0.410016 + 12 0.001296 0.002000 + 15 0.035601 0.070000 + 16 0.000983 0.002000 + 20 0.057780 0.147000 +---------------------------------------------------------------------------- + 120 Bonec 5 -1.0000000000 0.52130 1.8500E+00 1.8500E+00 S 9 1 0 B + cortical_bone_ICRP +cortical bone (ICRP) + 106.4 3.6488 0.1161 3.0919 0.06198 3.5919 0.00 + 1 1.000000 0.047234 + 6 0.256430 0.144330 + 7 0.063972 0.041990 + 8 0.594983 0.446096 + 12 0.001932 0.002200 + 15 0.072319 0.104970 + 16 0.002096 0.003150 + 20 0.111776 0.209930 + 30 0.000033 0.000100 +---------------------------------------------------------------------------- + 121 B4-C 5 -1.0000000000 0.47059 2.5200E+00 2.5200E+00 S 2 4 0 I + boron_carbide +boron carbide (B%4#C) + 84.7 2.9859 0.0093 2.1006 0.37087 2.8076 0.00 + 5 4.000000 0.782610 + 6 1.000119 0.217390 +---------------------------------------------------------------------------- + 122 B2-O3 5 -1.0000000000 0.49839 1.8120E+00 1.8120E+00 S 2 2 0 I + boron_oxide +boron oxide (B%2#O%3#) + 99.6 3.6027 0.1843 2.7379 0.11548 3.3832 0.00 + 5 2.000000 0.310551 + 8 3.000277 0.689449 +---------------------------------------------------------------------------- + 123 Brain 5 -1.0000000000 0.55423 1.0300E+00 1.0300E+00 S 13 1 0 B + brain_ICRP +brain (ICRP) + 73.3 3.4279 0.2206 2.8021 0.08255 3.5585 0.00 + 1 1.000000 0.110667 + 6 0.095108 0.125420 + 7 0.008635 0.013280 + 8 0.419958 0.737723 + 11 0.000729 0.001840 + 12 0.000056 0.000150 + 15 0.001041 0.003540 + 16 0.000503 0.001770 + 17 0.000606 0.002360 + 19 0.000722 0.003100 + 20 0.000020 0.000090 + 26 0.000008 0.000050 + 30 0.000001 0.000010 +---------------------------------------------------------------------------- + 124 Butan 5 -1.0000000000 0.59497 2.4934E-03 2.4890E-03 G 2 10 2 O + butane +butane (C%4#H%10#) + 48.3 8.5633 1.3788 3.7524 0.10852 3.4884 0.00 + 1 10.000000 0.173408 + 6 4.000262 0.826592 +Boiling point -0.5 +Melting point -138.2 +---------------------------------------------------------------------------- + 125 Butyl 5 -1.0000000000 0.56663 8.0980E-01 8.0980E-01 L 3 10 0 O + n-butyl_alcohol +n-butyl alcohol (C%4#H%9#OH) + 59.9 3.2425 0.1937 2.6439 0.10081 3.5139 0.00 + 1 10.000000 0.135978 + 6 4.000252 0.648171 + 8 1.000038 0.215851 +---------------------------------------------------------------------------- + 126 C-552 5 -1.0000000000 0.49969 1.7600E+00 1.7600E+00 S 5 1 0 B + C-552_air-equivalent_plastic +C-552 air-equivalent plastic + 86.8 3.3338 0.1510 2.7083 0.10492 3.4344 0.00 + 1 1.000000 0.024680 + 6 1.705640 0.501610 + 8 0.011556 0.004527 + 9 1.000047 0.465209 + 14 0.005777 0.003973 +---------------------------------------------------------------------------- + 127 Cd-Te 5 -1.0000000000 0.41665 6.2000E+00 6.2000E+00 S 2 1 0 I + cadmium_telluride_CdTe +cadmium telluride (CdTe) + 539.3 5.9096 0.0438 3.2836 0.24840 2.6665 0.00 + 48 1.000000 0.468355 + 52 1.000011 0.531645 +---------------------------------------------------------------------------- + 128 Cd-W- 5 -1.0000000000 0.42747 7.9000E+00 7.9000E+00 S 3 4 0 I + cadmium_tungstate +cadmium tungstate (CdWO%4#) + 468.3 5.3594 0.0123 3.5941 0.12861 2.9150 0.00 + 8 4.000000 0.177644 + 48 0.999992 0.312027 + 74 1.000054 0.510329 +---------------------------------------------------------------------------- + 129 Ca-C- 5 -1.0000000000 0.49955 2.8000E+00 2.8000E+00 S 3 1 0 I + calcium_carbonate +calcium carbonate (CaCO%3#) + 136.4 3.7738 0.0492 3.0549 0.08301 3.4120 0.00 + 6 1.000000 0.120003 + 8 2.999923 0.479554 + 20 1.000025 0.400443 +---------------------------------------------------------------------------- + 130 Ca-F2 5 -1.0000000000 0.49670 3.1800E+00 3.1800E+00 S 2 2 1 I + calcium_fluoride +calcium fluoride (CaF%2#) + 166.0 4.0653 0.0676 3.1683 0.06942 3.5263 0.00 + 9 2.000000 0.486659 + 20 1.000051 0.513341 +Index of ref 1.434 +---------------------------------------------------------------------------- + 131 Ca-O 5 -1.0000000000 0.49929 3.3000E+00 3.3000E+00 S 2 1 0 I + calcium_oxide_CaO +calcium oxide (CaO) + 176.1 4.1209 -0.0172 3.0171 0.12128 3.1936 0.00 + 8 1.000000 0.285299 + 20 1.000050 0.714701 +---------------------------------------------------------------------------- + 132 Ca-S- 5 -1.0000000000 0.49950 2.9600E+00 2.9600E+00 S 3 4 0 I + calcium_sulfate +calcium sulfate (CaSO%4#) + 152.3 3.9388 0.0587 3.1229 0.07708 3.4495 0.00 + 8 4.000000 0.470095 + 16 0.999813 0.235497 + 20 1.000050 0.294408 +---------------------------------------------------------------------------- + 133 Ca-W- 5 -1.0000000000 0.43761 6.0620E+00 6.0620E+00 S 3 4 0 I + calcium_tungstate +calcium tungstate (CaWO%4#) + 395.0 5.2603 0.0323 3.8932 0.06210 3.2649 0.00 + 8 4.000000 0.222270 + 20 1.000051 0.139202 + 74 1.000054 0.638529 +---------------------------------------------------------------------------- + 134 C-O2 5 -1.0000000000 0.49989 1.8421E-03 1.8421E-03 G 2 2 2 I + carbon_dioxide_gas +carbon dioxide gas (CO%2#) + 85.0 10.1537 1.6294 4.1825 0.11768 3.3227 0.00 + 6 2.000000 0.272916 + 8 3.999910 0.727084 +Index of ref (n-1)*E6 449.0 http://www.kayelaby.npl.co.uk/ +Sublimation point -78.4 194.7 K +---------------------------------------------------------------------------- + 135 C-Cl4 5 -1.0000000000 0.49107 1.5940E+00 1.5940E+00 L 2 1 0 O + carbon_tetrachloride +carbon tetrachloride (CCl%4#) + 166.3 4.7712 0.1773 2.9165 0.19018 3.0116 0.00 + 6 1.000000 0.078083 + 17 3.999948 0.921917 +---------------------------------------------------------------------------- + 136 Cello 5 -1.0000000000 0.53040 1.4200E+00 1.4200E+00 S 3 10 0 P + cellulose +cellulose [(C%6#H%10#O%5#)%n#] + 77.6 3.2647 0.1580 2.6778 0.11151 3.3810 0.00 + 1 10.000000 0.062162 + 6 6.000342 0.444462 + 8 5.000161 0.493376 +---------------------------------------------------------------------------- + 137 Cella 5 -1.0000000000 0.53279 1.2000E+00 1.2000E+00 S 3 22 0 P + cellulose_acetate_butyrate +cellulose acetate butyrate [(C%15#H%22#O%8#)%n#] + 74.6 3.3497 0.1794 2.6809 0.11444 3.3738 0.00 + 1 22.000000 0.067125 + 6 15.001071 0.545403 + 8 8.000363 0.387472 +---------------------------------------------------------------------------- + 138 Celln 5 -1.0000000000 0.51424 1.4900E+00 1.4900E+00 S 4 7 0 P + cellulose_nitrate +cellulose nitrate [(C%12#H%14#O%4#(ONO%2#)%6#)%n#] + 87.0 3.4762 0.1897 2.7253 0.11813 3.3237 0.00 + 1 7.000000 0.029216 + 6 5.454903 0.271296 + 7 2.090979 0.121276 + 8 8.727611 0.578212 +---------------------------------------------------------------------------- + 139 Cersu 5 -1.0000000000 0.55279 1.0300E+00 1.0300E+00 L 5 1 0 B + ceric_sulfate_dosimeter_solution +ceric sulfate dosimeter solution + 76.7 3.5212 0.2363 2.8769 0.07666 3.5607 0.00 + 1 1.000000 0.107596 + 7 0.000535 0.000800 + 8 0.512308 0.874976 + 16 0.004273 0.014627 + 58 0.000134 0.002001 +---------------------------------------------------------------------------- + 140 Cs-F 5 -1.0000000000 0.42132 4.1150E+00 4.1150E+00 S 2 1 0 I + cesium_fluoride_CsF +cesium fluoride (CsF) + 440.7 5.9046 0.0084 3.3374 0.22052 2.7280 0.00 + 9 1.000000 0.125069 + 55 0.999996 0.874931 +---------------------------------------------------------------------------- + 141 Cs-I 5 -1.0000000000 0.41569 4.5100E+00 4.5100E+00 S 2 1 3 I + cesium_iodide_CsI +cesium iodide (CsI) + 553.1 6.2807 0.0395 3.3353 0.25381 2.6657 0.00 + 53 1.000000 0.488451 + 55 1.000001 0.511549 +melti 621. Caesium iodide +boili 1280. Caesium iodide +Index 1.7873 CRC2006 10-147 +---------------------------------------------------------------------------- + 142 Chlor 5 -1.0000000000 0.51529 1.1058E+00 1.1058E+00 L 3 5 0 O + chlorobenzene +chlorobenzene C%6#H%5#Cl + 89.1 3.8201 0.1714 2.9272 0.09856 3.3797 0.00 + 1 5.000000 0.044772 + 6 6.000428 0.640254 + 17 1.000054 0.314974 +---------------------------------------------------------------------------- + 143 Chlor 5 -1.0000000000 0.48585 1.4832E+00 1.4832E+00 L 3 1 0 O + chloroform +chloroform (CHCl%3#) + 156.0 4.7055 0.1786 2.9581 0.16959 3.0627 0.00 + 1 1.000000 0.008443 + 6 1.000054 0.100613 + 17 3.000123 0.890944 +---------------------------------------------------------------------------- + 144 Concr 5 -1.0000000000 0.50274 2.3000E+00 2.3000E+00 S 10 1 2 M + shielding_concrete +shielding concrete + 135.2 3.9464 0.1301 3.0466 0.07515 3.5467 0.00 + 1 1.000000 0.010000 + 6 0.008392 0.001000 + 8 3.333301 0.529107 + 11 0.070149 0.016000 + 12 0.008294 0.002000 + 13 0.126534 0.033872 + 14 1.209510 0.337021 + 19 0.033514 0.013000 + 20 0.110658 0.044000 + 26 0.025268 0.014000 +Note: Standard shielding blocks, typical composition O%2# 0.52, Si 0.325, Ca 0.06, Na 0.015, Fe 0.02, Al 0.04 + plus reinforcing iron bars, from CERN-LRL-RHEL Shielding exp., UCRA-17841. +---------------------------------------------------------------------------- + 145 Cyclo 5 -1.0000000000 0.57034 7.7900E-01 7.7900E-01 L 2 12 0 O + cyclohexane +cyclohexane (C%6#H%12#) + 56.4 3.1544 0.1728 2.5549 0.12035 3.4278 0.00 + 1 12.000000 0.143711 + 6 6.000369 0.856289 +---------------------------------------------------------------------------- + 146 Dichl 5 -1.0000000000 0.50339 1.3048E+00 1.3048E+00 L 3 4 0 O + 12-dichlorobenzene +1,2-dichlorobenzene (C%6#H%4#Cl%2#) + 106.5 4.0348 0.1587 2.8276 0.16010 3.0836 0.00 + 1 4.000000 0.027425 + 6 6.000428 0.490233 + 17 2.000110 0.482342 +---------------------------------------------------------------------------- + 147 Dichl 5 -1.0000000000 0.51744 1.2199E+00 1.2199E+00 L 4 8 0 O + dichlorodiethyl_ether +dichlorodiethyl ether C%4#Cl%2#H%8#O + 103.3 4.0135 0.1773 3.1586 0.06799 3.5250 0.00 + 1 8.000000 0.056381 + 6 4.000257 0.335942 + 8 1.000040 0.111874 + 17 2.000096 0.495802 +---------------------------------------------------------------------------- + 148 Dichl 5 -1.0000000000 0.50526 1.2351E+00 1.2351E+00 L 3 4 0 O + 12-dichloroethane +1,2-dichloroethane C%2#H%4#C%12# + 111.9 4.1849 0.1375 2.9529 0.13383 3.1675 0.00 + 1 4.000000 0.040740 + 6 2.000126 0.242746 + 17 2.000090 0.716515 +---------------------------------------------------------------------------- + 149 Dieth 5 -1.0000000000 0.56663 7.1378E-01 7.1378E-01 L 3 10 0 O + diethyl_ether +diethyl ether [(CH%3#CH%2#)%2#O] + 60.0 3.3721 0.2231 2.6745 0.10550 3.4586 0.00 + 1 10.000000 0.135978 + 6 4.000252 0.648171 + 8 1.000038 0.215851 +---------------------------------------------------------------------------- + 150 Dimet 5 -1.0000000000 0.54724 9.4870E-01 9.4870E-01 S 4 7 0 O + mn-dimethyl_formamide +mn-dimethyl formamide (C%3#H%6#NOH) + 66.6 3.3311 0.1977 2.6686 0.11470 3.3710 0.00 + 1 7.000000 0.096523 + 6 3.000196 0.492965 + 7 1.000039 0.191625 + 8 1.000042 0.218887 +---------------------------------------------------------------------------- + 151 Dimet 5 -1.0000000000 0.53757 1.1014E+00 1.1014E+00 S 4 6 0 O + dimethyl_sulfoxide +dimethyl sulfoxide (CH%3#)%2#SO + 98.6 3.9844 0.2021 3.1263 0.06619 3.5708 0.00 + 1 6.000000 0.077403 + 6 2.000130 0.307467 + 8 1.000037 0.204782 + 16 0.999852 0.410348 +---------------------------------------------------------------------------- + 152 Ethan 5 -1.0000000000 0.59861 1.2532E-03 1.2630E-03 G 2 6 4 O + ethane +ethane (C%2#H%6#) + 45.4 9.1043 1.5107 3.8743 0.09627 3.6095 0.00 + 1 6.000000 0.201115 + 6 2.000126 0.798885 +Boiling point -88.6 +Triple point -89.88 +Melting point -182.79 +Note: Density of liquid at - 88.6 C is 0.5645 +---------------------------------------------------------------------------- + 153 Ethan 5 -1.0000000000 0.56437 7.8930E-01 7.8930E-01 L 3 6 3 O + ethanol +ethanol (C%2#H%5#OH) + 62.9 3.3699 0.2218 2.7052 0.09878 3.4834 0.00 + 1 6.000000 0.131269 + 6 2.000130 0.521438 + 8 1.000040 0.347294 +Index of refraction 1.36 +Melting point -114.14 +Boiling point 78.29 +---------------------------------------------------------------------------- + 154 Ethyl 5 -1.0000000000 0.54405 1.1300E+00 1.1300E+00 S 3 22 0 P + ethyl_cellulose +ethyl cellulose ([C%12#H%22#O5)%n#] + 69.3 3.2415 0.1683 2.6527 0.11077 3.4098 0.00 + 1 22.000000 0.090027 + 6 12.000718 0.585182 + 8 5.000172 0.324791 +---------------------------------------------------------------------------- + 155 Ethyl 5 -1.0000000000 0.57034 1.1750E-03 1.1750E-03 G 2 4 0 O + ethylene +ethylene (C%2#H%4#) + 50.7 9.4380 1.5528 3.9327 0.10636 3.5387 0.00 + 1 4.000000 0.143711 + 6 2.000123 0.856289 +---------------------------------------------------------------------------- + 156 Eye-l 5 -1.0000000000 0.54977 1.1000E+00 1.1000E+00 S 4 1 0 B + eye_lens_ICRP +eye lens (ICRP) + 73.3 3.3720 0.2070 2.7446 0.09690 3.4550 0.00 + 1 1.000000 0.099269 + 6 0.163759 0.193710 + 7 0.038616 0.053270 + 8 0.414887 0.653751 +---------------------------------------------------------------------------- + 157 Fe2-O 5 -1.0000000000 0.47592 5.2000E+00 5.2000E+00 S 2 3 0 I + ferric_oxide +ferric oxide (Fe%2#O%3#) + 227.3 4.2245 -0.0074 3.2573 0.10478 3.1313 0.00 + 8 3.000000 0.300567 + 26 2.000071 0.699433 +---------------------------------------------------------------------------- + 158 Fe-B 5 -1.0000000000 0.46507 7.1500E+00 7.1500E+00 S 2 1 0 I + ferroboride_FeB +ferroboride (FeB) + 261.0 4.2057 -0.0988 3.1749 0.12911 3.0240 0.00 + 5 1.000000 0.162174 + 26 1.000125 0.837826 +---------------------------------------------------------------------------- + 159 Fe-O 5 -1.0000000000 0.47323 5.7000E+00 5.7000E+00 S 2 1 0 I + ferrous_oxide_FeO +ferrous oxide (FeO) + 248.6 4.3175 -0.0279 3.2002 0.12959 3.0168 0.00 + 8 1.000000 0.222689 + 26 1.000036 0.777311 +---------------------------------------------------------------------------- + 160 Fe-su 5 -1.0000000000 0.55329 1.0240E+00 1.0240E+00 L 7 1 0 B + ferrous_sulfate_dosimeter_solution +ferrous sulfate dosimeter solution + 76.4 3.5183 0.2378 2.8254 0.08759 3.4923 0.00 + 1 1.000000 0.108259 + 7 0.000018 0.000027 + 8 0.511300 0.878636 + 11 0.000009 0.000022 + 16 0.003765 0.012968 + 17 0.000009 0.000034 + 26 0.000009 0.000054 +---------------------------------------------------------------------------- + 161 Freon 5 -1.0000000000 0.47969 1.1200E+00 1.1200E+00 G 3 1 0 O + Freon-12 +Freon-12 (CF%2#Cl%2#) + 143.0 4.8251 0.3035 3.2659 0.07978 3.4626 0.00 + 6 1.000000 0.099335 + 9 1.999954 0.314247 + 17 1.999972 0.586418 +---------------------------------------------------------------------------- + 162 Freon 5 -1.0000000000 0.44901 1.8000E+00 1.8000E+00 G 3 1 0 O + Freon-12B2 +Freon-12B2 (CF%2#Br%2#) + 284.9 5.7976 0.3406 3.7956 0.05144 3.5565 0.00 + 6 1.000000 0.057245 + 9 1.999966 0.181096 + 35 1.999967 0.761659 +---------------------------------------------------------------------------- + 163 Freon 5 -1.0000000000 0.47966 9.5000E-01 9.5000E-01 G 3 1 0 O + Freon-13 +Freon-13 (CF%3#Cl) + 126.6 4.7483 0.3659 3.2337 0.07238 3.5551 0.00 + 6 1.000000 0.114983 + 9 2.999918 0.545622 + 17 0.999982 0.339396 +---------------------------------------------------------------------------- + 164 Freon 5 -1.0000000000 0.45665 1.5000E+00 1.5000E+00 G 3 1 0 O + Freon-13b1 +Freon-13b1 (CF%3#Br) + 210.5 5.3555 0.3522 3.7554 0.03925 3.7194 0.00 + 6 1.000000 0.080659 + 9 2.999939 0.382749 + 35 0.999980 0.536592 +---------------------------------------------------------------------------- + 165 Freon 5 -1.0000000000 0.43997 1.8000E+00 1.8000E+00 G 3 1 0 O + Freon-13i1 +Freon-13i1 (CF%3#I) + 293.5 5.8774 0.2847 3.7280 0.09112 3.1658 0.00 + 6 1.000000 0.061309 + 9 2.999898 0.290924 + 53 0.999968 0.647767 +---------------------------------------------------------------------------- + 166 Gd2-O 5 -1.0000000000 0.42266 7.4400E+00 7.4400E+00 S 3 2 0 I + gadolinium_oxysulfide +gadolinium oxysulfide (Gd%2#O%2#S) + 493.3 5.5347 -0.1774 3.4045 0.22161 2.6300 0.00 + 8 2.000000 0.084528 + 16 0.999817 0.084690 + 64 1.999998 0.830782 +---------------------------------------------------------------------------- + 167 Ga-As 5 -1.0000000000 0.44247 5.3100E+00 5.3100E+00 S 2 1 0 I + gallium_arsenide_GaAs +gallium arsenide (GaAs) + 384.9 5.3299 0.1764 3.6420 0.07152 3.3356 0.00 + 31 1.000000 0.482019 + 33 1.000043 0.517981 +---------------------------------------------------------------------------- + 168 Photo 5 -1.0000000000 0.53973 1.2914E+00 1.2914E+00 S 5 1 0 M + gel_in_photographic_emulsion +gel in photographic emulsion + 74.8 3.2687 0.1709 2.7058 0.10102 3.4418 0.00 + 1 1.000000 0.081180 + 6 0.430104 0.416060 + 7 0.098607 0.111240 + 8 0.295390 0.380640 + 16 0.004213 0.010880 +---------------------------------------------------------------------------- + 169 Pyrex 5 -1.0000000000 0.49707 2.2300E+00 2.2300E+00 S 6 1 0 M + borosilicate_glass_Pyrex_Corning_7740 +borosilicate glass (Pyrex Corning 7740) + 134.0 3.9708 0.1479 2.9933 0.08270 3.5224 0.00 + 5 1.000000 0.040061 + 8 9.100880 0.539564 + 11 0.330918 0.028191 + 13 0.116461 0.011644 + 14 3.624571 0.377220 + 19 0.022922 0.003321 +---------------------------------------------------------------------------- + 170 Lead 5 -1.0000000000 0.42101 6.2200E+00 6.2200E+00 S 5 1 0 M + lead_glass +lead glass + 526.4 5.8476 0.0614 3.8146 0.09544 3.0740 0.00 + 8 1.000000 0.156453 + 14 0.294445 0.080866 + 22 0.017288 0.008092 + 33 0.003618 0.002651 + 82 0.371118 0.751938 +---------------------------------------------------------------------------- + 171 Glass 5 -1.0000000000 0.49731 2.4000E+00 2.4000E+00 S 4 1 0 M + plate_glass +plate glass + 145.4 4.0602 0.1237 3.0649 0.07678 3.5381 0.00 + 8 1.000000 0.459800 + 11 0.145969 0.096441 + 14 0.416971 0.336553 + 20 0.093077 0.107205 +---------------------------------------------------------------------------- + 172 Gluco 5 -1.0000000000 0.53499 1.5400E+00 1.5400E+00 S 3 14 0 O + glucose_dextrose_monohydrate +glucose (dextrose monohydrate) (C%6#H%12#O%6#.H%2#O)) + 77.2 3.1649 0.1411 2.6700 0.10783 3.3946 0.00 + 1 14.000000 0.071204 + 6 6.000342 0.363652 + 8 7.000253 0.565144 +---------------------------------------------------------------------------- + 173 Gluta 5 -1.0000000000 0.53371 1.4600E+00 1.4600E+00 S 4 10 0 O + glutamine +glutamine (C%5#H%10#N%2#O%3#) + 73.3 3.1167 0.1347 2.6301 0.11931 3.3254 0.00 + 1 10.000000 0.068965 + 6 5.000360 0.410926 + 7 2.000082 0.191681 + 8 3.000137 0.328427 +---------------------------------------------------------------------------- + 174 Glyce 5 -1.0000000000 0.54292 1.2613E+00 1.2613E+00 L 3 8 0 O + glycerol +glycerol (C%3#H%5#(OH)%3#) + 72.6 3.2267 0.1653 2.6862 0.10168 3.4481 0.00 + 1 8.000000 0.087554 + 6 3.000185 0.391262 + 8 3.000108 0.521185 +---------------------------------------------------------------------------- + 175 Guani 5 -1.0000000000 0.51612 1.5800E+00 1.5800E+00 S 4 5 0 O + guanine +guanine (C%5#H%5#N%5#O) + 75.0 3.1171 0.1163 2.4296 0.20530 3.0186 0.00 + 1 5.000000 0.033346 + 6 5.000329 0.397380 + 7 5.000189 0.463407 + 8 1.000041 0.105867 +---------------------------------------------------------------------------- + 176 Gypsu 5 -1.0000000000 0.51113 2.3200E+00 2.3200E+00 S 4 4 0 I + gypsum_plaster_of_Paris +gypsum (plaster of Paris, CaSO%4#$\cdot$H%2#O) + 129.7 3.8382 0.0995 3.1206 0.06949 3.5134 0.00 + 1 4.000000 0.023416 + 8 6.000387 0.557572 + 16 0.999889 0.186215 + 20 1.000123 0.232797 +---------------------------------------------------------------------------- + 177 Hepta 5 -1.0000000000 0.57992 6.8376E-01 6.8376E-01 L 2 16 0 O + n-heptane +n-heptane (C%7#H%16#) + 54.4 3.1978 0.1928 2.5706 0.11255 3.4885 0.00 + 1 16.000000 0.160937 + 6 7.000435 0.839063 +---------------------------------------------------------------------------- + 178 Hexan 5 -1.0000000000 0.59020 6.6030E-01 6.6030E-01 L 2 14 0 O + n-hexane +n-hexane C%6#H%14# + 54.0 3.2156 0.1984 2.5757 0.11085 3.5027 0.00 + 1 14.000000 0.163741 + 6 6.000366 0.836259 +---------------------------------------------------------------------------- + 179 Kapto 5 -1.0000000000 0.51264 1.4200E+00 1.4200E+00 S 4 10 0 P + polyimide_film +polyimide film [(C%22#H%10#N%2#O%5#)%n#] + 79.6 3.3497 0.1509 2.5631 0.15972 3.1921 0.00 + 1 10.000000 0.026362 + 6 22.001366 0.691133 + 7 2.000071 0.073270 + 8 5.000195 0.209235 +---------------------------------------------------------------------------- + 180 La-O- 5 -1.0000000000 0.42599 6.2800E+00 6.2800E+00 S 3 1 0 I + lanthanum_oxybromide_LaOBr +lanthanum oxybromide (LaOBr) + 439.7 5.4666 -0.0350 3.3288 0.17830 2.8457 0.00 + 8 1.000000 0.068138 + 35 1.000000 0.340294 + 57 0.999999 0.591568 +---------------------------------------------------------------------------- + 181 La2-O 5 -1.0000000000 0.42706 5.8600E+00 5.8600E+00 S 3 2 0 I + lanthanum_oxysulfide +lanthanum oxysulfide La%2#O%2#S + 421.2 5.4470 -0.0906 3.2664 0.21501 2.7298 0.00 + 8 2.000000 0.093600 + 16 0.999802 0.093778 + 57 1.999986 0.812622 +---------------------------------------------------------------------------- + 182 Pb-O 5 -1.0000000000 0.40323 9.5300E+00 9.5300E+00 S 2 1 0 I + lead_oxide_PbO +lead oxide (PbO) + 766.7 6.2162 0.0356 3.5456 0.19645 2.7299 0.00 + 8 1.000000 0.071682 + 82 1.000001 0.928318 +---------------------------------------------------------------------------- + 183 Li-N- 5 -1.0000000000 0.52257 1.1780E+00 1.1780E+00 S 3 2 0 I + lithium_amide +lithium amide (LiNH%2#) + 55.5 2.7961 0.0198 2.5152 0.08740 3.7534 0.00 + 1 2.000000 0.087783 + 3 1.000036 0.302262 + 7 1.000035 0.609955 +---------------------------------------------------------------------------- + 184 LI2-C 5 -1.0000000000 0.49720 2.1100E+00 2.1100E+00 S 3 2 0 I + lithium_carbonate +lithium carbonate (Li%2#C-O%3#) + 87.9 3.2029 0.0551 2.6598 0.09936 3.5417 0.00 + 3 2.000000 0.187871 + 6 1.000025 0.162550 + 8 2.999995 0.649579 +---------------------------------------------------------------------------- + 185 Li-F 5 -1.0000000000 0.46262 2.6350E+00 2.6350E+00 S 2 1 3 I + lithium_fluoride_LiF +lithium fluoride (LiF) + 94.0 3.1667 0.0171 2.7049 0.07593 3.7478 0.00 + 3 1.000000 0.267585 + 9 1.000001 0.732415 +melti 848.2 Lithium flouride +boili 1673. Lithium flouride +Index of ref 1.392 old RPP value +---------------------------------------------------------------------------- + 186 Li-H 5 -1.0000000000 0.50321 8.2000E-01 8.2000E-01 S 2 1 1 I + lithium_hydride_LiH +lithium hydride (LiH) + 36.5 2.3580 -0.0988 1.4515 0.90567 2.5849 0.00 + 1 1.000000 0.126797 + 3 1.000043 0.873203 +Melting point 692 +---------------------------------------------------------------------------- + 187 Li-I 5 -1.0000000000 0.41939 3.4940E+00 3.4940E+00 S 2 1 0 I + lithium_iodide_LiI +lithium iodide (LiI) + 485.1 6.2671 0.0892 3.3702 0.23274 2.7146 0.00 + 3 1.000000 0.051858 + 53 1.000006 0.948142 +---------------------------------------------------------------------------- + 188 Li2-O 5 -1.0000000000 0.46952 2.0130E+00 2.0130E+00 S 2 2 0 I + lithium_oxide +lithium oxide Li%2#O + 73.6 2.9340 -0.0511 2.5874 0.08035 3.7878 0.00 + 3 2.000000 0.464570 + 8 1.000000 0.535430 +---------------------------------------------------------------------------- + 189 Li2-B 5 -1.0000000000 0.48487 2.4400E+00 2.4400E+00 S 3 2 0 I + lithium_tetraborate +lithium tetraborate Li%2#B%4#O%7# + 94.6 3.2093 0.0737 2.6502 0.11075 3.4389 0.00 + 3 2.000000 0.082085 + 5 3.999624 0.255680 + 8 6.999978 0.662235 +---------------------------------------------------------------------------- + 190 Lung 5 -1.0000000000 0.54965 1.0500E+00 1.0500E+00 S 13 1 0 B + lung_ICRP +lung (ICRP) + 75.3 3.4708 0.2261 2.8001 0.08588 3.5353 0.00 + 1 1.000000 0.101278 + 6 0.084775 0.102310 + 7 0.020357 0.028650 + 8 0.470926 0.757072 + 11 0.000797 0.001840 + 12 0.000299 0.000730 + 15 0.000257 0.000800 + 16 0.000698 0.002250 + 17 0.000747 0.002660 + 19 0.000494 0.001940 + 20 0.000022 0.000090 + 26 0.000066 0.000370 + 30 0.000002 0.000010 +---------------------------------------------------------------------------- + 191 M3-wa 5 -1.0000000000 0.55512 1.0500E+00 1.0500E+00 S 5 1 0 B + M3_WAX +M3 WAX + 67.9 3.2540 0.1523 2.7529 0.07864 3.6412 0.00 + 1 1.000000 0.114318 + 6 0.481436 0.655823 + 8 0.050800 0.092183 + 12 0.048898 0.134792 + 20 0.000634 0.002883 +---------------------------------------------------------------------------- + 192 Mg-C- 5 -1.0000000000 0.49814 2.9580E+00 2.9580E+00 S 3 1 0 I + magnesium_carbonate +magnesium carbonate MgCO%3# + 118.0 3.4319 0.0860 2.7997 0.09219 3.5003 0.00 + 6 1.000000 0.142455 + 8 2.999932 0.569278 + 12 0.999977 0.288267 +---------------------------------------------------------------------------- + 193 Mg-F2 5 -1.0000000000 0.48153 3.0000E+00 3.0000E+00 S 2 2 0 I + magnesium_fluoride +magnesium fluoride MgF%2# + 134.3 3.7105 0.1369 2.8630 0.07934 3.6485 0.00 + 9 2.000000 0.609883 + 12 1.000000 0.390117 +---------------------------------------------------------------------------- + 194 Mg-O 5 -1.0000000000 0.49622 3.5800E+00 3.5800E+00 S 2 1 0 I + magnesium_oxide_MgO +magnesium oxide MgO + 143.8 3.6404 0.0575 2.8580 0.08313 3.5968 0.00 + 8 1.000000 0.396964 + 12 1.000000 0.603036 +---------------------------------------------------------------------------- + 195 Mg-B4 5 -1.0000000000 0.49014 2.5300E+00 2.5300E+00 S 3 4 0 I + magnesium_tetraborate +magnesium tetraborate MgB%4#O%7# + 108.3 3.4328 0.1147 2.7635 0.09703 3.4893 0.00 + 5 4.000000 0.240837 + 8 7.000634 0.623790 + 12 1.000090 0.135373 +---------------------------------------------------------------------------- + 196 Hg-I2 5 -1.0000000000 0.40933 6.3600E+00 6.3600E+00 S 2 2 0 I + mercuric_iodide +mercuric iodide HgI%2# + 684.5 6.3787 0.1040 3.4728 0.21513 2.7264 0.00 + 53 2.000000 0.558560 + 80 0.999999 0.441440 +---------------------------------------------------------------------------- + 197 Metha 5 -1.0000000000 0.62334 6.6715E-04 6.6715E-04 G 2 4 3 O + methane +methane (CH%4#) + 41.7 9.5243 1.6263 3.9716 0.09253 3.6257 0.00 + 1 4.000000 0.251306 + 6 1.000064 0.748694 +Boiling point -161.48 +Melting point -182.47 +Index of ref (n-1)*E6 444.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 198 Metha 5 -1.0000000000 0.56176 7.9140E-01 7.9140E-01 L 3 4 0 O + methanol +methanol (CH%3#OH) + 67.6 3.5160 0.2529 2.7639 0.08970 3.5477 0.00 + 1 4.000000 0.125822 + 6 1.000068 0.374852 + 8 1.000043 0.499326 +---------------------------------------------------------------------------- + 199 mix-D 5 -1.0000000000 0.56479 9.9000E-01 9.9000E-01 S 5 1 0 B + mix_D_wax +mix D wax + 60.9 3.0780 0.1371 2.7145 0.07490 3.6823 0.00 + 1 1.000000 0.134040 + 6 0.487068 0.777960 + 8 0.016459 0.035020 + 12 0.011941 0.038594 + 22 0.002260 0.014386 +---------------------------------------------------------------------------- + 200 MS20 5 -1.0000000000 0.53886 1.0000E+00 1.0000E+00 S 6 1 0 B + ms20_tissue_substitute +ms20 tissue substitute + 75.1 3.5341 0.1997 2.8033 0.08294 3.6061 0.00 + 1 1.000000 0.081192 + 6 0.603046 0.583442 + 7 0.015774 0.017798 + 8 0.144617 0.186381 + 12 0.066547 0.130287 + 17 0.000315 0.000900 +---------------------------------------------------------------------------- + 201 Skelm 5 -1.0000000000 0.54938 1.0400E+00 1.0400E+00 S 13 1 0 B + skeletal_muscle_ICRP +skeletal muscle (ICRP) + 75.3 3.4809 0.2282 2.7999 0.08636 3.5330 0.00 + 1 1.000000 0.100637 + 6 0.089918 0.107830 + 7 0.019793 0.027680 + 8 0.472487 0.754773 + 11 0.000327 0.000750 + 12 0.000078 0.000190 + 15 0.000582 0.001800 + 16 0.000753 0.002410 + 17 0.000223 0.000790 + 19 0.000774 0.003020 + 20 0.000007 0.000030 + 26 0.000007 0.000040 + 30 0.000008 0.000050 +---------------------------------------------------------------------------- + 202 Strim 5 -1.0000000000 0.55005 1.0400E+00 1.0400E+00 S 9 1 0 B + striated_muscle_ICRU +striated muscle (ICRU) + 74.7 3.4636 0.2249 2.8032 0.08507 3.5383 0.00 + 1 1.000000 0.101997 + 6 0.101201 0.123000 + 7 0.024693 0.035000 + 8 0.450270 0.729003 + 11 0.000344 0.000800 + 12 0.000081 0.000200 + 15 0.000638 0.002000 + 16 0.001541 0.005000 + 19 0.001264 0.005000 +---------------------------------------------------------------------------- + 203 Eqvmu 5 -1.0000000000 0.54828 1.1100E+00 1.1100E+00 L 4 1 0 B + muscle-equivalent_liquid_with_sucrose +muscle-equivalent liquid with sucrose + 74.3 3.3910 0.2098 2.7550 0.09481 3.4699 0.00 + 1 1.000000 0.098234 + 6 0.133452 0.156214 + 7 0.025970 0.035451 + 8 0.455395 0.710100 +---------------------------------------------------------------------------- + 204 Eqvmu 5 -1.0000000000 0.55014 1.0700E+00 1.0700E+00 L 4 1 0 B + muscle-equivalent_liquid_without_sucrose +muscle-equivalent liquid without sucrose + 74.2 3.4216 0.2187 2.7680 0.09143 3.4982 0.00 + 1 1.000000 0.101969 + 6 0.098807 0.120058 + 7 0.025018 0.035451 + 8 0.458746 0.742522 +---------------------------------------------------------------------------- + 205 Napht 5 -1.0000000000 0.53053 1.1450E+00 1.1450E+00 S 2 8 0 O + naphtalene +naphtalene (C%10#H%8#) + 68.4 3.2274 0.1374 2.5429 0.14766 3.2654 0.00 + 1 8.000000 0.062909 + 6 10.000584 0.937091 +---------------------------------------------------------------------------- + 206 Nitro 5 -1.0000000000 0.51986 1.1987E+00 1.1987E+00 L 4 5 0 O + nitrobenzene +nitrobenzene (C%6#H%5#NO%2#) + 75.8 3.4073 0.1777 2.6630 0.12727 3.3091 0.00 + 1 5.000000 0.040935 + 6 6.000329 0.585374 + 7 1.000028 0.113773 + 8 2.000058 0.259918 +---------------------------------------------------------------------------- + 207 N2-O 5 -1.0000000000 0.49985 1.8309E-03 1.8309E-03 G 2 2 0 I + nitrous_oxide +nitrous oxide (N%2#O) + 84.9 10.1575 1.6477 4.1565 0.11992 3.3318 0.00 + 7 2.000000 0.636483 + 8 1.000003 0.363517 +---------------------------------------------------------------------------- + 208 Elvam 5 -1.0000000000 0.55063 1.0800E+00 1.0800E+00 S 4 1 0 P + Nylon_du_Pont_Elvamide_8062M +Nylon du Pont Elvamide 8062M + 64.3 3.1250 0.1503 2.6004 0.11513 3.4044 0.00 + 1 1.000000 0.103509 + 6 0.525704 0.648415 + 7 0.069199 0.099536 + 8 0.090405 0.148539 +---------------------------------------------------------------------------- + 209 Nylon 5 -1.0000000000 0.54790 1.1400E+00 1.1800E+00 S 4 11 0 P + Nylon_type_6_6-6 +Nylon (type 6, 6/6) [(CH(CH%2#)%5#NO)%n#] + 63.9 3.0634 0.1336 2.5834 0.11818 3.3826 0.00 + 1 11.000000 0.097976 + 6 6.000405 0.636856 + 7 1.000040 0.123779 + 8 1.000045 0.141389 +---------------------------------------------------------------------------- + 210 Nylon 5 -1.0000000000 0.55236 1.1400E+00 1.1400E+00 S 4 15 0 P + Nylon_type_6-10 +Nylon type 6/10 [(CH(CH%2#)%7#NO)%n#] + 63.2 3.0333 0.1304 2.5681 0.11852 3.3912 0.00 + 1 15.000000 0.107062 + 6 8.000514 0.680449 + 7 1.000039 0.099189 + 8 1.000039 0.113300 +---------------------------------------------------------------------------- + 211 Rilsa 5 -1.0000000000 0.55649 1.4250E+00 1.4250E+00 S 4 21 0 P + Nylon_type_11_Rilsan +Nylon type 11 Rilsan ([C%11#H%21#ON)%n#], [(CH(CH%2#)%10#NO)%n#]) + 61.6 2.7514 0.0678 2.4281 0.14868 3.2576 0.00 + 1 21.000000 0.115476 + 6 11.000696 0.720819 + 7 1.000035 0.076417 + 8 1.000042 0.087289 +---------------------------------------------------------------------------- + 212 Octan 5 -1.0000000000 0.57778 7.0260E-01 7.0260E-01 L 2 18 2 O + octane +octane (C%8#H%18#) + 54.7 3.1834 0.1882 2.5664 0.11387 3.4776 0.00 + 1 18.000000 0.158821 + 6 8.000541 0.841179 +Boiling point 125.6 +Melting point -58.7 +---------------------------------------------------------------------------- + 213 Paraf 5 -1.0000000000 0.57275 9.3000E-01 9.3000E-01 S 2 52 0 O + paraffin +paraffin (CH%3#(CH%2#)%n\approx23#CH%3#) + 55.9 2.9551 0.1289 2.5084 0.12087 3.4288 0.00 + 1 52.000000 0.148605 + 6 25.001575 0.851395 +---------------------------------------------------------------------------- + 214 Penta 5 -1.0000000000 0.58212 6.2620E-01 6.2620E-01 L 2 12 1 O + n-pentane +n-pentane (C%5#H%12#) + 53.6 3.2504 0.2086 2.5855 0.10809 3.5265 0.00 + 1 12.000000 0.167635 + 6 5.000308 0.832365 +Index of ref (n-1)*E6 1711.0 http://www.kayelaby.npl.co.uk/ +---------------------------------------------------------------------------- + 215 Photo 5 -1.0000000000 0.45453 3.8150E+00 3.8150E+00 S 8 1 0 M + photographic_emulsion +photographic emulsion + 331.0 5.3319 0.1009 3.4866 0.12399 3.0094 0.00 + 1 1.000000 0.014100 + 6 0.430082 0.072261 + 7 0.098602 0.019320 + 8 0.295338 0.066101 + 16 0.004213 0.001890 + 35 0.312321 0.349103 + 47 0.314193 0.474105 + 53 0.001757 0.003120 +---------------------------------------------------------------------------- + 216 Plast 5 -1.0000000000 0.54141 1.0320E+00 1.0320E+00 S 2 10 1 P + polyvinyltoluene +polyvinyltoluene [(2-CH%3#C%6#H%4#CHCH%2#)%n#] + 64.7 3.1997 0.1464 2.4855 0.16101 3.2393 0.00 + 1 10.000000 0.085000 + 6 9.033760 0.915000 +Index of refraction 1.58 +---------------------------------------------------------------------------- + 217 Pu-O2 5 -1.0000000000 0.40583 1.1460E+01 1.1460E+01 S 2 2 0 I + plutonium_dioxide +plutonium dioxide (PuO%2#) + 746.5 5.9719 -0.2311 3.5554 0.20594 2.6522 0.00 + 8 2.000000 0.118055 + 94 0.979460 0.881945 +---------------------------------------------------------------------------- + 218 Pacry 5 -1.0000000000 0.52767 1.1700E+00 1.1700E+00 S 3 3 0 P + polyacrylonitrile +polyacrylonitrile [(C%3#H%3#N)%n#] + 69.6 3.2459 0.1504 2.5159 0.16275 3.1975 0.00 + 1 3.000000 0.056983 + 6 3.000184 0.679056 + 7 1.000034 0.263962 +---------------------------------------------------------------------------- + 219 Lexan 5 -1.0000000000 0.52697 1.2000E+00 1.2000E+00 S 3 14 0 P + polycarbonate_Lexan +polycarbonate (Lexan, [OC%6#H%4#C(CH%3#)%2#C%6#H%4#OCO)%n#]) + 73.1 3.3201 0.1606 2.6225 0.12860 3.3288 0.00 + 1 14.000000 0.055491 + 6 16.001127 0.755751 + 8 3.000142 0.188758 +---------------------------------------------------------------------------- + 220 Pchlo 5 -1.0000000000 0.52518 1.3000E+00 1.3000E+00 S 3 18 0 P + polychlorostyrene +polychlorostyrene [(C%17#H%18#C%l2#)%n#] + 81.7 3.4659 0.1238 2.9241 0.07530 3.5441 0.00 + 1 18.000000 0.061869 + 6 17.001129 0.696325 + 17 2.000101 0.241806 +---------------------------------------------------------------------------- + 221 Polye 5 -1.0000000000 0.57034 9.4000E-01 8.9000E-01 S 2 2 0 P + polyethylene +polyethylene [(CH%2#CH%2#)%n#] + 57.4 3.0016 0.1370 2.5177 0.12108 3.4292 0.00 + 1 2.000000 0.143711 + 6 1.000062 0.856289 +---------------------------------------------------------------------------- + 222 Poly 5 -1.0000000000 0.52037 1.4000E+00 1.4000E+00 S 3 4 0 P + polyethylene_terephthalate_Mylar +polyethylene terephthalate (Mylar) [(C%10#H%8#O%4#)%n#] + 78.7 3.3262 0.1562 2.6507 0.12679 3.3076 0.00 + 1 4.000000 0.041959 + 6 5.000266 0.625017 + 8 2.000059 0.333025 +---------------------------------------------------------------------------- + 223 Acryl 5 -1.0000000000 0.53937 1.1900E+00 1.1900E+00 S 3 8 1 P + polymethylmethacrylate_acrylic +polymethylmethacrylate (acrylic, [(CH%2#C(CH%3#)(COOCH%3#))%n#] + 74.0 3.3297 0.1824 2.6681 0.11433 3.3836 0.00 + 1 8.000000 0.080538 + 6 5.000308 0.599848 + 8 2.000073 0.319614 +Index of refraction 1.49 +---------------------------------------------------------------------------- + 224 Polyo 5 -1.0000000000 0.53287 1.4250E+00 1.4250E+00 S 3 2 0 P + polyoxymethylene +polyoxymethylene [(CH%2#O)%n#] + 77.4 3.2514 0.1584 2.6838 0.10808 3.4002 0.00 + 1 2.000000 0.067135 + 6 1.000059 0.400017 + 8 1.000035 0.532848 +---------------------------------------------------------------------------- + 225 Polyp 5 -1.0000000000 0.55998 9.4000E-01 9.0500E-01 S 2 3 2 P + polypropylene +polypropylene [(CH(CH%3#)CH%2#)%n#] + 57.4 3.0016 0.1370 2.5177 0.12108 3.4292 0.00 + 1 2.000000 0.143711 + 6 1.000062 0.856289 +Note: Chem formula wrong in Sternheimer. <i>I</i> and density effect constants + for polyethylene, scaled with density, were used for these calculations. +---------------------------------------------------------------------------- + 226 Polys 5 -1.0000000000 0.53768 1.0600E+00 1.0600E+00 S 2 8 1 P + polystyrene +polystyrene [(C%6#H%5#CHCH%2#)%n#] + 68.7 3.2999 0.1647 2.5031 0.16454 3.2224 0.00 + 1 8.000000 0.077418 + 6 8.000541 0.922582 +Index of ref 1.59 +---------------------------------------------------------------------------- + 227 Teflo 5 -1.0000000000 0.47992 2.2000E+00 2.2000E+00 S 2 1 0 P + polytetrafluoroethylene_Teflon +polytetrafluoroethylene (Teflon, [(CF%2#CF%2#)%n#]) + 99.1 3.4161 0.1648 2.7404 0.10606 3.4046 0.00 + 6 1.000000 0.240183 + 9 1.999945 0.759817 +---------------------------------------------------------------------------- + 228 KEL-F 5 -1.0000000000 0.48081 2.1000E+00 2.1000E+00 S 3 2 0 P + polytrifluorochloroethylene +polytrifluorochloroethylene [(C%2#F%3#Cl)%n#] + 120.7 3.8551 0.1714 3.0265 0.07727 3.5085 0.00 + 6 2.000000 0.206250 + 9 2.999925 0.489354 + 17 0.999983 0.304395 +---------------------------------------------------------------------------- + 229 Pviny 5 -1.0000000000 0.53432 1.1900E+00 1.1900E+00 S 3 6 0 P + polyvinylacetate +polyvinylacetate [(CH%2#CHOCOCH%3#)%n#] + 73.7 3.3309 0.1769 2.6747 0.11442 3.3762 0.00 + 1 6.000000 0.070245 + 6 4.000256 0.558066 + 8 2.000076 0.371689 +---------------------------------------------------------------------------- + 230 Pviny 5 -1.0000000000 0.54480 1.3000E+00 1.3000E+00 S 3 4 0 P + polyvinyl_alcohol +polyvinyl alcohol [(C%2#H3-O-H)%n#] + 69.7 3.1115 0.1401 2.6315 0.11178 3.3893 0.00 + 1 4.000000 0.091517 + 6 2.000131 0.545298 + 8 1.000039 0.363185 +---------------------------------------------------------------------------- + 231 Pviny 5 -1.0000000000 0.54537 1.1200E+00 1.1200E+00 S 3 13 0 P + polyvinyl_butyral +polyvinyl butyral [(C%8#H%13#0%2#)%n#] + 67.2 3.1865 0.1555 2.6186 0.11544 3.3983 0.00 + 1 13.000000 0.092802 + 6 8.000543 0.680561 + 8 2.000082 0.226637 +---------------------------------------------------------------------------- + 232 PVC 5 -1.0000000000 0.51201 1.3000E+00 1.3000E+00 S 3 3 0 P + polyvinylchloride_PVC +polyvinylchloride (PVC) [(CH%2#CHCl)%n#] + 108.2 4.0532 0.1559 2.9415 0.12438 3.2104 0.00 + 1 3.000000 0.048380 + 6 2.000138 0.384360 + 17 1.000053 0.567260 +---------------------------------------------------------------------------- + 233 Saran 5 -1.0000000000 0.49513 1.7000E+00 1.7000E+00 S 3 2 0 P + polyvinylidene_chloride_Saran +polyvinylidene chloride (Saran) [(C%2#H%2#Cl%2#)%n#] + 134.3 4.2506 0.1314 2.9009 0.15466 3.1020 0.00 + 1 2.000000 0.020793 + 6 2.000176 0.247793 + 17 2.000142 0.731413 +---------------------------------------------------------------------------- + 234 Pvnyd 5 -1.0000000000 0.49973 1.7600E+00 1.7600E+00 S 3 2 0 P + polyvinylidene_fluoride +polyvinylidene fluoride [(CH%2#CHF%2#)%n#] + 88.8 3.3793 0.1717 2.7375 0.10316 3.4200 0.00 + 1 2.000000 0.031480 + 6 2.000121 0.375141 + 9 2.000069 0.593379 +---------------------------------------------------------------------------- + 235 Pvnyl 5 -1.0000000000 0.53984 1.2500E+00 1.2500E+00 S 4 9 0 P + polyvinyl_pyrrolidone +polyvinyl pyrrolidone [(C%6#H%9#NO)%n#] + 67.7 3.1017 0.1324 2.5867 0.12504 3.3326 0.00 + 1 9.000000 0.081616 + 6 6.000414 0.648407 + 7 1.000042 0.126024 + 8 1.000044 0.143953 +---------------------------------------------------------------------------- + 236 K-I 5 -1.0000000000 0.43373 3.1300E+00 3.1300E+00 S 2 1 0 I + potassium_iodide_KI +potassium iodide (KI) + 431.9 6.1088 0.1044 3.3442 0.22053 2.7558 0.00 + 19 1.000000 0.235528 + 53 1.000000 0.764472 +---------------------------------------------------------------------------- + 237 K2-O 5 -1.0000000000 0.48834 2.3200E+00 2.3200E+00 S 2 1 0 I + potassium_oxide +potassium oxide (K%2#O) + 189.9 4.6463 0.0480 3.0110 0.16789 3.0121 0.00 + 8 1.000000 0.169852 + 19 2.000003 0.830148 +---------------------------------------------------------------------------- + 238 Propa 5 -1.0000000000 0.58962 1.8794E-03 1.8680E-03 G 2 8 2 O + propane +propane (C%3#H%8#) + 47.1 8.7878 1.4326 3.7998 0.09916 3.5920 0.00 + 1 8.000000 0.182855 + 6 3.000189 0.817145 +Boiling point -42.1 +Melting point -187.63 +---------------------------------------------------------------------------- + 239 Propa 5 -1.0000000000 0.58962 4.3000E-01 4.9300E-01 L 2 8 2 O + liquid_propane +liquid propane (C%3#H%8#) + 52.0 3.5529 0.2861 2.6568 0.10329 3.5620 0.00 + 1 8.000000 0.182855 + 6 3.000189 0.817145 +Boiling point -42.1 +Melting point -187.63 +---------------------------------------------------------------------------- + 240 n-pro 5 -1.0000000000 0.56577 8.0350E-01 8.0350E-01 L 3 8 0 O + n-propyl_alcohol +n-propyl alcohol (C%3#H%7#OH) + 61.1 3.2915 0.2046 2.6681 0.09644 3.5415 0.00 + 1 8.000000 0.134173 + 6 3.000193 0.599595 + 8 1.000037 0.266232 +---------------------------------------------------------------------------- + 241 Pyrid 5 -1.0000000000 0.53096 9.8190E-01 9.8190E-01 L 3 5 0 O + pyridine +pyridine (C%5#H%5#N) + 66.2 3.3148 0.1670 2.5245 0.16399 3.1977 0.00 + 1 5.000000 0.063710 + 6 5.000285 0.759217 + 7 1.000028 0.177073 +---------------------------------------------------------------------------- + 242 Rubbe 5 -1.0000000000 0.57034 9.2000E-01 9.2000E-01 S 2 8 0 O + rubber_butyl +rubber butyl ([C%4#H8)%n#] + 56.5 2.9915 0.1347 2.5154 0.12108 3.4296 0.00 + 1 8.000000 0.143711 + 6 4.000246 0.856289 +---------------------------------------------------------------------------- + 243 Rubbe 5 -1.0000000000 0.55785 9.2000E-01 9.2000E-01 S 2 8 0 O + rubber_natural +rubber natural [(C%5#H8)%n#] + 59.8 3.1272 0.1512 2.4815 0.15058 3.2879 0.00 + 1 8.000000 0.118371 + 6 5.000309 0.881629 +---------------------------------------------------------------------------- + 244 Rubbe 5 -1.0000000000 0.51956 1.2300E+00 1.2300E+00 S 3 5 0 O + rubber_neoprene +rubber neoprene [(C%4#H%5#Cl)%n#] + 93.0 3.7911 0.1501 2.9461 0.09763 3.3632 0.00 + 1 5.000000 0.056920 + 6 4.000259 0.542646 + 17 1.000049 0.400434 +---------------------------------------------------------------------------- + 245 Si-O2 5 -1.0000000000 0.49930 2.3200E+00 2.2000E+00 S 2 2 3 I + silicon_dioxide_fused_quartz +silicon dioxide (fused quartz) (SiO%2#) + 139.2 4.0029 0.1385 3.0025 0.08408 3.5064 0.00 + 8 2.000000 0.532565 + 14 1.000000 0.467435 +Melting point 1713. +Boiling point 2950. +Index of refraction 1.458 +---------------------------------------------------------------------------- + 246 Ag-Br 5 -1.0000000000 0.43670 6.4730E+00 6.4730E+00 S 2 1 0 I + silver_bromide_AgBr +silver bromide (AgBr) + 486.6 5.6139 0.0352 3.2109 0.24582 2.6820 0.00 + 35 1.000000 0.425537 + 47 1.000000 0.574463 +---------------------------------------------------------------------------- + 247 Ag-Cl 5 -1.0000000000 0.44655 5.5600E+00 5.5600E+00 S 2 1 0 I + silver_chloride_AgCl +silver chloride (AgCl) + 398.4 5.3437 -0.0139 3.2022 0.22968 2.7041 0.00 + 17 1.000000 0.247368 + 47 0.999989 0.752632 +---------------------------------------------------------------------------- + 248 Ag-ha 5 -1.0000000000 0.43663 6.4700E+00 6.4700E+00 S 3 1 0 M + ag_halides_in_phot_emulsion +ag halides in phot emulsion + 487.1 5.6166 0.0353 3.2117 0.24593 2.6814 0.00 + 35 1.000000 0.422895 + 47 1.004995 0.573748 + 53 0.004998 0.003357 +---------------------------------------------------------------------------- + 249 Ag-I 5 -1.0000000000 0.42594 6.0100E+00 6.0100E+00 S 2 1 0 I + silver_iodide_AgI +silver iodide (AgI) + 543.5 5.9342 0.0148 3.2908 0.25059 2.6572 0.00 + 47 1.000000 0.459458 + 53 1.000000 0.540542 +---------------------------------------------------------------------------- + 250 Skin 5 -1.0000000000 0.54932 1.1000E+00 1.1000E+00 S 13 1 0 B + skin_ICRP +skin (ICRP) + 72.7 3.3546 0.2019 2.7526 0.09459 3.4643 0.00 + 1 1.000000 0.100588 + 6 0.190428 0.228250 + 7 0.033209 0.046420 + 8 0.387683 0.619002 + 11 0.000031 0.000070 + 12 0.000025 0.000060 + 15 0.000107 0.000330 + 16 0.000497 0.001590 + 17 0.000755 0.002670 + 19 0.000218 0.000850 + 20 0.000038 0.000150 + 26 0.000002 0.000010 + 30 0.000002 0.000010 +---------------------------------------------------------------------------- + 251 Na2-C 5 -1.0000000000 0.49062 2.5320E+00 2.5320E+00 S 3 1 0 I + sodium_carbonate +sodium carbonate (Na%2#CO%3#) + 125.0 3.7178 0.1287 2.8591 0.08715 3.5638 0.00 + 6 1.000000 0.113323 + 8 2.999933 0.452861 + 11 1.999955 0.433815 +---------------------------------------------------------------------------- + 252 Na-I 5 -1.0000000000 0.42697 3.6670E+00 3.6670E+00 S 2 1 3 I + sodium_iodide_NaI +sodium iodide (NaI) + 452.0 6.0572 0.1203 3.5920 0.12516 3.0398 0.00 + 11 1.000000 0.153373 + 53 1.000002 0.846627 +Melting point 660. +Boiling point 1304. +Index of ref 1.775 +---------------------------------------------------------------------------- + 253 Na2-O 5 -1.0000000000 0.48404 2.2700E+00 2.2700E+00 S 2 1 0 I + sodium_monoxide +sodium monoxide (Na%2#O) + 148.8 4.1892 0.1652 2.9793 0.07501 3.6943 0.00 + 8 1.000000 0.258143 + 11 1.999995 0.741857 +---------------------------------------------------------------------------- + 254 Na-N- 5 -1.0000000000 0.49415 2.2610E+00 2.2610E+00 S 3 1 0 I + sodium_nitrate +sodium nitrate (NaNO%3#) + 114.6 3.6502 0.1534 2.8221 0.09391 3.5097 0.00 + 7 1.000000 0.164795 + 8 3.000009 0.564720 + 11 1.000004 0.270485 +---------------------------------------------------------------------------- + 255 Stilb 5 -1.0000000000 0.53260 9.7070E-01 9.7070E-01 S 2 12 0 O + stilbene +stilbene (C%6#H%5#)CHCH(C%6#H%5#) + 67.7 3.3680 0.1734 2.5142 0.16659 3.2168 0.00 + 1 12.000000 0.067101 + 6 14.000813 0.932899 +---------------------------------------------------------------------------- + 256 Sucro 5 -1.0000000000 0.53170 1.5805E+00 1.5805E+00 S 3 22 0 O + sucrose +sucrose (C%12#H%22#O%11#) + 77.5 3.1526 0.1341 2.6558 0.11301 3.3630 0.00 + 1 22.000000 0.064779 + 6 12.000771 0.421070 + 8 11.000442 0.514151 +---------------------------------------------------------------------------- + 257 Terph 5 -1.0000000000 0.52148 1.2340E+00 1.2340E+00 S 2 10 0 O + terphenyl +terphenyl (C%18#H%10#) + 71.7 3.2639 0.1322 2.5429 0.14964 3.2685 0.00 + 1 10.000000 0.044543 + 6 18.001057 0.955457 +---------------------------------------------------------------------------- + 258 Teste 5 -1.0000000000 0.55108 1.0400E+00 1.0400E+00 S 13 1 0 B + testes_ICRP +testes (ICRP) + 75.0 3.4698 0.2274 2.7988 0.08533 3.5428 0.00 + 1 1.000000 0.104166 + 6 0.074336 0.092270 + 7 0.013775 0.019940 + 8 0.468038 0.773884 + 11 0.000951 0.002260 + 12 0.000044 0.000110 + 15 0.000391 0.001250 + 16 0.000441 0.001460 + 17 0.000666 0.002440 + 19 0.000515 0.002080 + 20 0.000024 0.000100 + 26 0.000003 0.000020 + 30 0.000003 0.000020 +---------------------------------------------------------------------------- + 259 C2-Cl 5 -1.0000000000 0.48241 1.6250E+00 1.6250E+00 L 2 2 0 O + tetrachloroethylene +tetrachloroethylene (C%2#C%l4#) + 159.2 4.6619 0.1713 2.9083 0.18595 3.0156 0.00 + 6 2.000000 0.144856 + 17 3.999924 0.855144 +---------------------------------------------------------------------------- + 260 Tl-Cl 5 -1.0000000000 0.40861 7.0040E+00 7.0040E+00 S 2 1 0 I + thallium_chloride_TlCl +thallium chloride (TlCl) + 690.3 6.3009 0.0705 3.5716 0.18599 2.7690 0.00 + 17 1.000000 0.147822 + 81 0.999999 0.852187 +---------------------------------------------------------------------------- + 261 Soft 5 -1.0000000000 0.55121 1.0000E+00 1.0000E+00 S 13 1 0 B + soft_tissue_ICRP +soft tissue (ICRP) + 72.3 3.4354 0.2211 2.7799 0.08926 3.5110 0.00 + 1 1.000000 0.104472 + 6 0.186513 0.232190 + 7 0.017138 0.024880 + 8 0.380046 0.630238 + 11 0.000474 0.001130 + 12 0.000052 0.000130 + 15 0.000414 0.001330 + 16 0.000599 0.001990 + 17 0.000365 0.001340 + 19 0.000491 0.001990 + 20 0.000055 0.000230 + 26 0.000009 0.000050 + 30 0.000004 0.000030 +---------------------------------------------------------------------------- + 262 Tissu 5 -1.0000000000 0.54975 1.0000E+00 1.0000E+00 S 4 1 0 B + soft_tissue_ICRU_four-component +soft tissue (ICRU four-component) + 74.9 3.5087 0.2377 2.7908 0.09629 3.4371 0.00 + 1 1.000000 0.101172 + 6 0.092072 0.111000 + 7 0.018493 0.026000 + 8 0.474381 0.761828 +---------------------------------------------------------------------------- + 263 TE-ga 5 -1.0000000000 0.54993 1.0641E-03 1.0641E-03 G 4 1 0 B + tissue-equivalent_gas_Methane_based +tissue-equivalent gas (Methane based) + 61.2 9.9500 1.6442 4.1399 0.09946 3.4708 0.00 + 1 1.000000 0.101869 + 6 0.375802 0.456179 + 7 0.024846 0.035172 + 8 0.251564 0.406780 +---------------------------------------------------------------------------- + 264 TE-ga 5 -1.0000000000 0.55027 1.8263E-03 1.8263E-03 G 4 1 0 B + tissue-equivalent_gas_Propane_based +tissue-equivalent gas (Propane based) + 59.5 9.3529 1.5139 3.9916 0.09802 3.5159 0.00 + 1 1.000000 0.102672 + 6 0.465030 0.568940 + 7 0.024546 0.035022 + 8 0.180007 0.293366 +---------------------------------------------------------------------------- + 265 Ti-O2 5 -1.0000000000 0.47572 4.2600E+00 4.2600E+00 S 2 2 0 I + titanium_dioxide +titanium dioxide (TiO%2#) + 179.5 3.9522 -0.0119 3.1647 0.08569 3.3267 0.00 + 8 2.000000 0.400592 + 22 1.000271 0.599408 +---------------------------------------------------------------------------- + 266 Tolue 5 -1.0000000000 0.54265 8.6690E-01 8.6690E-01 L 2 8 0 O + toluene +toluene (C%6#H%5#CH%3#) + 62.5 3.3026 0.1722 2.5728 0.13284 3.3558 0.00 + 1 8.000000 0.087510 + 6 7.000463 0.912490 +---------------------------------------------------------------------------- + 267 C2-H- 5 -1.0000000000 0.48710 1.4600E+00 1.4600E+00 L 3 1 0 O + trichloroethylene +trichloroethylene (C%2#HCl%3#) + 148.1 4.6148 0.1803 2.9140 0.18272 3.0137 0.00 + 1 1.000000 0.007671 + 6 2.000158 0.182831 + 17 3.000193 0.809498 +---------------------------------------------------------------------------- + 268 Triet 5 -1.0000000000 0.53800 1.0700E+00 1.0700E+00 S 4 15 0 O + triethyl_phosphate +triethyl phosphate C%6#H%15#PO%4# + 81.2 3.6242 0.2054 2.9428 0.06922 3.6302 0.00 + 1 15.000000 0.082998 + 6 6.000356 0.395628 + 8 4.000136 0.351334 + 15 1.000036 0.170040 +---------------------------------------------------------------------------- + 269 W-F6 5 -1.0000000000 0.42976 2.4000E+00 2.4000E+00 S 2 6 0 I + tungsten_hexafluoride +tungsten hexafluoride (WF%6#) + 354.4 5.9881 0.3020 4.2602 0.03658 3.5134 0.00 + 9 6.000000 0.382723 + 74 1.000055 0.617277 +---------------------------------------------------------------------------- + 270 U-C2 5 -1.0000000000 0.39687 1.1280E+01 1.1280E+01 S 2 2 0 I + uranium_dicarbide +uranium dicarbide (UC%2#) + 752.0 6.0247 -0.2191 3.5208 0.21120 2.6577 0.00 + 6 2.000000 0.091669 + 92 0.999978 0.908331 +---------------------------------------------------------------------------- + 271 U-C 5 -1.0000000000 0.39194 1.3630E+01 1.3630E+01 S 2 1 0 I + uranium_monocarbide_UC +uranium monocarbide (UC) + 862.0 6.1210 -0.2524 3.4941 0.22972 2.6169 0.00 + 6 1.000000 0.048036 + 92 0.999982 0.951964 +---------------------------------------------------------------------------- + 272 U-O2 5 -1.0000000000 0.39996 1.0960E+01 1.0960E+01 S 2 2 0 I + uranium_oxide +uranium oxide (UO%2#) + 720.6 5.9605 -0.1938 3.5292 0.20463 2.6711 0.00 + 8 2.000000 0.118502 + 92 0.999999 0.881498 +---------------------------------------------------------------------------- + 273 Urea 5 -1.0000000000 0.53284 1.3230E+00 1.3230E+00 S 4 4 0 O + urea +urea (CO(NH%2#)%2#) + 72.8 3.2032 0.1603 2.6525 0.11609 3.3461 0.00 + 1 4.000000 0.067131 + 6 1.000072 0.199999 + 7 2.000083 0.466459 + 8 1.000046 0.266411 +---------------------------------------------------------------------------- + 274 Valin 5 -1.0000000000 0.54632 1.2300E+00 1.2300E+00 S 4 11 0 O + valine +valine (C%5#H%11#NOi%2#) + 67.7 3.1059 0.1441 2.6227 0.11386 3.3774 0.00 + 1 11.000000 0.094641 + 6 5.000305 0.512645 + 7 1.000035 0.119565 + 8 2.000072 0.273150 +---------------------------------------------------------------------------- + 275 Viton 5 -1.0000000000 0.48585 1.8000E+00 1.8000E+00 S 3 2 0 P + viton_fluoroelastomer +viton fluoroelastomer [(C%5#H%2#F8)%n#] + 98.6 3.5943 0.2106 2.7874 0.09965 3.4556 0.00 + 1 2.000000 0.009417 + 6 5.000366 0.280555 + 9 8.000378 0.710028 +---------------------------------------------------------------------------- + 276 Water 5 -1.0000000000 0.55509 1.0000E+00 1.0000E+00 L 2 2 3 I + water_liquid +water (liquid) (H%2#O) + 79.7 3.5017 0.2400 2.8004 0.09116 3.4773 0.00 + 1 2.000000 0.111894 + 8 1.000044 0.888106 +Index of refraction 1.333 +Melting point 0.0 +Boiling point 99.964 CRC2006 4-98 +---------------------------------------------------------------------------- + 277 Water 5 -1.0000000000 0.55509 7.5618E-04 7.5618E-04 G 2 2 0 I + water_vapor +water (vapor) (H%2#O) + 71.6 10.5962 1.7952 4.3437 0.08101 3.5901 0.00 + 1 2.000000 0.111894 + 8 1.000044 0.888106 +---------------------------------------------------------------------------- + 278 Xylen 5 -1.0000000000 0.54631 8.7000E-01 8.7000E-01 L 2 10 0 O + xylene +xylene (C%8#H%10#) + 61.8 3.2698 0.1695 2.5675 0.13216 3.3564 0.00 + 1 10.000000 0.094935 + 6 8.000548 0.905065 +---------------------------------------------------------------------------- + 279 Heavy 5 -1.0000000000 0.40594 1.9300E+01 1.9300E+01 S 3 1 1 M + heavymet_in_ATLAS_calorimeter +heavymet in ATLAS calorimeter + 727.0 5.4059 0.2167 3.4960 0.15509 2.8447 0.14 + 28 1.000000 0.035000 + 29 0.395844 0.015000 + 74 8.665723 0.950000 +Note: Tungsten properties except for average Z/A used in calculations +---------------------------------------------------------------------------- + 280 Heavy 5 -1.0000000000 0.40915 1.9300E+01 1.9300E+01 S 3 1 1 M + heavymet_in_Rochester_gamma_stop +heavymet as Rochester gamma stop + 727.0 5.4059 0.2167 3.4960 0.15509 2.8447 0.14 + 28 1.000000 0.060000 + 29 0.615758 0.040000 + 74 4.788952 0.900000 +Note: Tungsten properties except for average Z/A used in calculations +---------------------------------------------------------------------------- + 281 Std-R 0 11.0000000000 9 0.50000 2.6500E+00 2.6500E+00 S 2 1 1 M + standard_rock +standard rock + 136.4 3.7738 0.0492 3.0549 0.08301 3.4120 0.00 + 11 1.000000 1.000000 + 12 0.000000 0.000000 +Note: <A HREF="../standardrock.html">Explanation of "Standard Rock." +---------------------------------------------------------------------------- + 282 Hydro 3 1.0080000000 7 0.99212 6.0000E-02 7.0800E-02 L 1 1 1 E +H nonsense + Liquid hydrogen (H%2#) + 21.8 2.8438 0.2000 2.0000 0.32969 3.0000 0.00 + 1 1.000000 1.000000 +Note: This looks like nonsense. ind = 85 is correct! +---------------------------------------------------------------------------- + 283 Heliu 6 4.0026020000 2 0.49967 1.2490E-01 1.2490E-01 L 1 1 2 E +He liquid_helium +liquid helium (He) + 41.8 4.5180 0.4729 2.0000 0.65713 3.0000 0.00 + 2 1.000000 1.000000 +Boiling point -268.93 +Index of ref 1.024 +---------------------------------------------------------------------------- + 284 Nitro 3 14.0070000000 2 0.49976 8.0700E-01 8.0700E-01 L 1 1 4 E +N liquid_nitrogen +liquid nitrogen (N%2#) + 82.0 3.9996 0.3039 2.0000 0.53289 3.0000 0.00 + 7 1.000000 1.000000 +Melting point -210.00 +Boiling point -195.86 +Index of ref 1.19876 CRC2006 4-148 +Note: Index of refraction at boiling point, 1 atm. +---------------------------------------------------------------------------- + 285 Oxyge 3 15.9990000000 3 0.50002 1.1410E+00 1.1410E+00 L 1 1 4 E +O liquid_oxygen +liquid oxygen (O%2#) + 95.0 3.9471 0.2868 2.0000 0.52231 3.0000 0.00 + 8 1.000000 1.000000 +Melting point (C) -218.79 +Boiling point (C) -182.95 +Index of ref 1.2243 +Note: Index of refraction at boiling point, 1 atm. +---------------------------------------------------------------------------- + 286 Fluor 9 18.9984031630 6 0.47372 1.5070E+00 1.5070E+00 L 1 1 2 E +F liquid_fluorine +liquid fluorine (F%2#) + 115.0 4.1050 0.2000 3.0000 0.14504 3.0000 0.00 + 9 1.000000 1.000000 +Melting point -219.62 +Boiling point -188.12 +---------------------------------------------------------------------------- + 287 Neon 4 20.1797000000 6 0.49555 1.2040E+00 1.2040E+00 L 1 1 3 E +Ne liquid_neon +liquid neon (Ne) + 137.0 4.6345 0.2000 3.0000 0.16916 3.0000 0.00 + 10 1.000000 1.000000 +Boiling point -246.08 +Melting point -248.59 +Index of ref 1.092 +---------------------------------------------------------------------------- + 288 Chlor 3 35.4530000000 2 0.47951 1.5740E+00 1.5740E+00 L 1 1 2 E +Cl liquid_chlorine +liquid chlorine (Cl%2#) + 174.0 4.8776 0.2000 3.0000 0.18024 3.0000 0.00 + 17 1.000000 1.000000 +Melting point -101.5 +Boiling point -34.04 +---------------------------------------------------------------------------- + 289 Argon 3 39.9480000000 1 0.45059 1.3960E+00 1.3960E+00 L 1 1 3 E +Ar liquid_argon +liquid argon (Ar) + 188.0 5.2146 0.2000 3.0000 0.19559 3.0000 0.00 + 18 1.000000 1.000000 +Boiling point -185.85 +Melting point -189.36 +Index of ref 1.233 +---------------------------------------------------------------------------- + 290 Bromi 3 79.9040000000 1 0.43803 3.1028E+00 3.1028E+00 L 1 1 2 E +Br liquid_bromine +bromine liquid (Br%2#) + 357.0 0.0000 0.0000 0.0000 0.0000 0.0000 0.00 + 35 1.000000 1.000000 +melting point -7.2 +boiling point 58.78 +---------------------------------------------------------------------------- + 291 Krypt 3 83.7980000000 2 0.42960 2.4180E+00 2.4180E+00 L 1 1 4 E +Kr liquid_krypton_Kr +liquid krypton (Kr) + 352.0 5.9674 0.4454 3.0000 0.23491 3.0000 0.00 + 36 1.000000 1.000000 +melting point -157.36 +boiling point -153.22 +Index refraction 1.3032 CRC2006 4-148 +Note: Index of refraction at boiling point, 1 atm. +---------------------------------------------------------------------------- + 292 Xenon 3 131.2930000000 6 0.41129 2.9530E+00 2.9530E+00 L 1 1 4 E +Xe liquid_xenon_Xe +liquid xenon (Xe) + 482.0 6.4396 0.5993 3.0000 0.26595 3.0000 0.00 + 54 1.000000 1.000000 +Melting point -111.75 +Boiling point -108.0 +Index refraction 1.3918 CRC2006 4-148 +Note: Index of refraction at boiling point, 1 atm. +---------------------------------------------------------------------------- + 293 C-O2 5 -1.0000000000 0.49989 1.5630E+00 1.5630E+00 S 2 2 1 I + solid_carbon_dioxide_dry_ice +solid carbon dioxide (dry ice, CO%2#) + 85.0 3.4513 0.2000 2.0000 0.43387 3.0000 0.00 + 6 2.000000 0.272916 + 8 4.000010 0.727084 +Note: Sublimation point 194.7 K = -78.4 C +---------------------------------------------------------------------------- + 294 Hydro 5 1.0079400000 7 0.99212 6.0000E-02 6.0000E-02 L 1 1 0 E +H bubble_chamber_H_liquid +Hydrogen BC liquid DEG calc to check code + 21.8 3.0093 0.2000 2.0000 0.35807 3.0000 0.00 + 1 1.000000 1.000000 +---------------------------------------------------------------------------- + 295 Water 5 -1.0000000000 0.55509 1.0000E+00 1.0000E+00 L 2 2 0 I + water_as_calc_from_steam_to_check_code +water as calc from steam to check code + 71.6 3.5017 0.2000 2.0000 0.44251 3.0000 0.00 + 1 2.000000 0.111894 + 8 1.000044 0.888106 +---------------------------------------------------------------------------- + 296 Aerog 5 -1.0000000000 0.50093 2.0000E-01 2.0000E-01 S 3 2 1 M + silica_aerogel +silica aerogel for rho = 0.2 (0.03 H%2#O, 0.97 SiO%2#) + 139.2 6.4507 0.6029 3.0000 0.26675 3.0000 0.00 + 8 2.000000 0.543192 + 14 1.000000 0.453451 + 1 2.000000 0.003357 +Note: See A. R. Buzykaev et al, NIM A433 396 (1999) +---------------------------------------------------------------------------- + 297 Carbo 4 12.0107000000 8 0.49955 2.2650E+00 3.5200E+00 S 1 1 2 E +C carbon_gem_diamond +carbon (gem diamond) + 78.0 2.8680 -0.0178 2.3415 0.26142 2.8697 0.12 + 6 1.000000 1.000000 +Note: variety of melting points found, e.g. 4400 C, 3675 C +Index of ref (n-1)*E6 2.419 +---------------------------------------------------------------------------- + 298 Deute 9 2.014101764 13 0.49650 1.8000E-04 1.6770E-04 D 1 1 3 E +D deuterium_gas +deuterium gas (D%2#) + 19.2 9.5835 1.8639 3.2718 0.14092 5.7273 0.00 + 1 1.000000 1.000000 +Boiling point (C) -249.5 (mass from Phys. Rev. A 47, 3433 - 3436 (1993)) +Triple point -254.461 CRC2006 +Index of ref (n-1)*E6 138.0 +---------------------------------------------------------------------------- + 299 D-liq 9 2.014101764 13 0.49650 1.4320E-01 1.6380E-01 L 1 1 3 E +D liquid_deuterium +liquid deuterium (D%2#) + 21.8 3.2632 0.4759 1.9215 0.13483 5.6249 0.00 + 1 1.000000 1.000000 +Boiling point -249.5 +Triple point -254.461 CRC2006 +Index of ref 1.112 +---------------------------------------------------------------------------- + 300 Salt 5 -1.0000000000 0.47910 2.1650E+00 2.1700E+00 S 2 2 3 I + sodium_chloride_NaCl +sodium chloride (NaCl) + 175.3 4.4250 0.2000 3.0000 0.15962 3.0000 0.00 + 11 1.000000 0.393375 + 17 1.000000 0.606626 +Melting point (C) 802.018 CRC2008 15-11 +Boiling point (C) 1465. +Index of refraction 1.544 +---------------------------------------------------------------------------- + 301 PbWO4 5 -1.0000000000 0.41315 8.3900E+00 8.3000E+00 S 3 1 2 I + lead_tungstate +lead tungstate (PbWO%4#) + 600.7 5.8420 0.4045 3.0000 0.22758 3.0000 0.00 + 82 1.000000 0.455347 + 74 1.000000 0.404011 + 8 4.000000 0.140462 +Melting point 1123. +Index of refraction 2.20 +---------------------------------------------------------------------------- + 302 Calif 5 251.0795900000 3 0.39031 1.5100E+00 1.5100E+01 S 1 1 3 R +Cf californium_Cf +californium (Cf) + 966.0 6.3262 0.5623 3.0000 0.25796 3.0000 0.00 + 98 1.000000 1.000000 +melting 900. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: I<SUB><I>eff</I></SUB> = 966 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 303 Einst 4 252.0830000000 4 0.39273 0.0000E+00 1.4000E+01 S 1 1 3 R +Es einsteinium_Es +einsteinium (Es) + 980.0 6.3488 0.5697 3.0000 0.25952 3.0000 0.00 + 99 1.000000 1.000000 +melting 860. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 980 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 304 Fermi 5 257.0951000000 5 0.38896 0.0000E+00 1.4000E+01 S 1 1 3 R +Fm fermium_Fm +fermium (Fm) + 994.0 6.3868 0.5821 3.0000 0.26219 3.0000 0.00 + 100 1.000000 1.000000 +Melting: 1527. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 994 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 305 Mende 5 258.0984300000 3 0.39132 0.0000E+00 1.4000E+01 S 1 1 3 R +Md mendelevium_Md +mendelevium (Md) + 1007.0 6.4068 0.5886 3.0000 0.26360 3.0000 0.00 + 101 1.000000 1.000000 +Melting 827. +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1007 eV assumed in calculating critical energies and <I><I>dE/dx</I></I>. +---------------------------------------------------------------------------- + 306 Nobel 4 259.1010000000 7 0.39367 0.0000E+00 1.4000E+01 S 1 1 2 R +No nobelium_No +nobelium (No) + 1020.0 6.4264 0.5950 3.0000 0.26500 3.0000 0.00 + 102 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1020 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 307 Lawre 5 262.1096100000 2 0.39296 0.0000E+00 1.4000E+01 S 1 1 2 R +Lr lawrencium_Lr +lawrencium (Lr) + 1034.0 6.4555 0.6045 3.0000 0.26710 3.0000 0.00 + 103 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = Z*10.0 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 308 Ruthe 5 267.1217900000 4 0.38934 0.0000E+00 1.4000E+01 S 1 1 2 R +Rf rutherfordium_Rf +rutherfordium (Rf) + 1047.0 6.4898 0.6157 3.0000 0.26960 3.0000 0.00 + 104 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1047 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 309 Dubni 5 268.1256700000 4 0.39161 0.0000E+00 1.4000E+01 S 1 1 2 R +Db dubnium_Db +dubnium (Db) + 1061.0 6.5105 0.6224 3.0000 0.27114 3.0000 0.00 + 105 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1061 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 310 Seabo 5 269.1286300000 5 0.39095 0.0000E+00 1.4000E+01 S 1 1 2 R +Sg seaborgium_Sg +seaborgium (Sg) + 1074.0 6.5365 0.6309 3.0000 0.27308 3.0000 0.00 + 106 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1074 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 311 Bohri 5 270.1333600000 4 0.39610 0.0000E+00 1.4000E+01 S 1 1 2 R +Bh bohrium_Bh +bohrium (Bh) + 1087.0 6.5549 0.6369 3.0000 0.27447 3.0000 0.00 + 107 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1087 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 312 Hassi 5 269.1337500000 13 0.40129 0.0000E+00 1.4000E+01 S 1 1 2 R +Hs hassium_Hs +hassium (Hs) + 1102.0 6.5913 0.6488 3.0000 0.27724 3.0000 0.00 + 108 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1102 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 313 Meitn 4 278.1563000000 7 0.39471 0.0000E+00 1.4000E+01 S 1 1 2 R +Mt meitnerium_Mt +meitnerium (Mt) + 1115.0 6.6019 0.6522 3.0000 0.27805 3.0000 0.00 + 109 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1115 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 314 Darms 4 281.1645000000 6 0.39123 0.0000E+00 1.4000E+01 S 1 1 2 R +Ds darmstadtium_Ds +darmstadtium (Ds) + 1129.0 6.6357 0.6632 3.0000 0.28068 3.0000 0.00 + 110 1.000000 1.000000 +Note: Since there is no stable isotope, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1129 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 315 Roent 4 282.1691200000 7 0.39620 0.0000E+00 1.4000E+01 S 1 1 2 R +Rg roentgenium_Rg +roentgenium (Rg) + 1143.0 6.6477 0.6672 3.0000 0.28162 3.0000 0.00 + 111 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1143 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 316 Coper 5 285.17712 5 0.39274 0.0000E+00 1.4000E+01 S 1 1 2 R +Cn copernicium_Cn +copernicium (Cn) + 1156.0 6.6791 0.6774 3.0000 0.28410 3.0000 0.00 + 112 1.000000 1.000000 +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = Z*10.0 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 317 nihon 5 286.1822100000 6 0.39764 0.0000E+00 1.4000E+01 S 1 1 1 R +Nh nihonium_Nh +nihonium (Nh) + 1171.0 6.6925 0.6818 3.0000 0.28517 3.0000 0.00 + 113 1.000000 1.000000 +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1171 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 318 flero 5 289.1904200000 5 0.39421 0.0000E+00 1.4000E+01 S 1 1 1 R +Fl flerovium_Fl +flerovium (Fl) + 1185.0 6.7249 0.6923 3.0000 0.28779 3.0000 0.00 + 114 1.000000 1.000000 +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1185 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 319 mosco 5 289.1936300000 6 0.39904 0.0000E+00 1.4000E+01 S 1 1 1 R +Mc moscovium_Mc +moscovium (Mc) + 1199.0 6.7363 0.6960 3.0000 0.28871 3.0000 0.00 + 115 1.000000 1.000000 +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1199 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 320 liver 4 293.2045000000 6 0.39563 0.0000E+00 1.4000E+01 S 1 1 1 R +Lv livermorium_Lv +livermorium (Lv) + 1213.0 6.7571 0.7028 3.0000 0.29041 3.0000 0.00 + 116 1.000000 1.000000 +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1213 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 321 tenne 4 294.2105100000 7 0.39796 0.0000E+00 1.4000E+01 S 1 1 1 R +Ts tennessine_Ts +tennessine (Ts) + 1227.0 6.7800 0.7103 3.0000 0.29231 3.0000 0.00 + 117 1.000000 1.000000 +Note: Density 14.0 g/cm<SUP>3</SUP> and I<SUB><I>eff</I></SUB> = 1227 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 322 ogane 5 294.2139220000 8 0.40107 1.2000E-02 1.2000E-02 G 1 1 2 R +Og oganesson_Og +oganesson (Og) + 1242.0 13.8662 2.0204 -1.9972 -0.07035 3.0000 0.00 + 118 1.000000 1.000000 +Note: Density is that of an ideal monatomic gas. +Note: I<SUB><I>eff</I></SUB> = 1242 eV assumed in calculating critical energies and <I>dE/dx</I>. +---------------------------------------------------------------------------- + 323 Astat 5 209.9871500000 6 0.40479 0.0000E+00 5.0000E+00 S 1 1 3 R +At astatine_At +astatine (At) + 825.0 7.0039 0.7833 3.0000 0.31184 3.0000 0.00 + 85 1.000000 1.000000 +Melting : 302. +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope (8.1 hr). +Note: Density 5.0 g/cm<SUP>3</SUP> assumed. +---------------------------------------------------------------------------- + 324 Franc 5 223.0197400000 2 0.39010 1.8700E+00 1.8700E+00 S 1 1 4 R +Fr francium_Fr +francium (Fr) + 827.0 8.0292 1.1175 3.0000 0.43214 3.0000 0.00 + 87 1.000000 1.000000 +Melting 27. +Boiling 677. +Note: Francium is less stable than any other element lighter than nobelium, element 102. +Note: Since there are no stable isotopes, [atomic mass] is that of the longest-lived isotope known as of Jun 2017. +---------------------------------------------------------------------------- + 325 Ice 5 -1.0000000000 0.55509 1.0000E+00 0.9180E+00 L 2 2 3 I + water_ice +water (ice) (H%2#O) + 79.7 3.5017 0.2400 2.8004 0.09116 3.4773 0.00 + 1 2.000000 0.111894 + 8 1.000044 0.888106 +Index of refraction 1.309 +Melting point 0.0 +Boiling point 99.964 CRC2006 4-98 +---------------------------------------------------------------------------- + 326 CF4 5 -1.0000000000 0.47721 3.78E-3 3.78E-3 G 2 1 4 O + carbon_tetrafluoride +carbon tetrafluoride (CF%4#) + 115.0 0.0 0. .0000 0. .0000 0.00 + 6 1.000000 0.136548 + 9 4.000000 0.86345 +Melting : -183.6 +boiling -127.8 +Note: Physical properties such as gas density are not well vetted +Note: Ieff supplied by Hans Bichsel +---------------------------------------------------------------------------- + 327 LaBr3 5 -1.0000000000 0.42787 5.2900e+00 5.2900e+00 S 2 1 1 I + lanthanum_bromide +lanthanum bromide (LaBr%3#) + 454.5 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 57 1.000000 0.366875 + 35 3.000000 0.633124 +Note: Ieff calculated using the ICRU37 algorithm given in Table 5.1 +---------------------------------------------------------------------------- + 328 YBr3 5 -1.0000000000 0.43820 5.2900e+00 5.2900e+00 S 2 1 1 I + yttrium_bromide +yttrium bromide (YBr%3#) + 410.0 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 39 1.000000 0.270545 + 35 3.000000 0.729455 +Note: Ieff calculated using the ICRU37 algorithm given in Table 5.1 +---------------------------------------------------------------------------- + 329 BSO 5 -1.0000000000 0.42260 9.2000e+00 7.1200e+00 S 3 12 3 I + bismuth_silicate_BSO +bismuth silicate (BSO) [(Bi%2#O%3#)%2#(SiO%2#)%3#] + 519.2 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 8 12.000000 0.172629 + 14 3.000000 0.075759 + 83 4.000000 0.751613 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +Note: Evalite structure; less common is Bi{12}SiO{20} +Note: Check density. Probably wrong +---------------------------------------------------------------------------- + 330 PbF2 5 -1.0000000000 0.40784 7.7700e+00 7.7700e+00 S 2 1 1 I + lead_fluoride +lead fluoride (PbF%2#) + 635.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 82 1.000000 0.845035 + 9 2.000000 0.154965 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 331 LaF3 5 -1.0000000000 0.42879 5.9000e+00 5.9000e+00 S 2 1 1 I + lanthanum_fluoride +lanthanum fluoride (LaF%3#) + 336.3 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 57 1.000000 0.709061 + 9 3.000000 0.290939 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 332 CeF3 5 -1.0000000000 0.43123 6.1600e+00 6.1600e+00 S 2 1 1 I + cerium_fluoride +cerium fluoride (CeF%3#) + 348.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 58 1.000000 0.710847 + 9 3.000000 0.289153 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 333 LuF3 5 -1.0000000000 0.42248 8.3000e+00 8.3000e+00 S 2 1 1 I + lutetium_fluoride +lutetium fluoride (LuF%3#) + 458.7 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 71 1.000000 0.754291 + 9 3.000000 0.245709 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 334 LaCl3 5 -1.0000000000 0.44034 3.8600e+00 3.8600e+00 S 2 1 1 I + lanthanum_chloride +lanthanum chloride (LaCl%3#) + 329.5 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 57 1.000000 0.566350 + 17 3.000000 0.433650 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 335 LuAlO 5 -1.0000000000 0.43209 8.3000e+00 8.3000e+00 S 3 1 1 I + lutetium_aluminum_oxide_1 +lutetium aluminum oxide (1) (LuAlO%3#) + 423.2 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 71 1.000000 0.700017 + 13 1.000000 0.107949 + 8 3.000000 0.192034 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 336 LuAlO 5 -1.0000000000 0.43907 6.7300e+00 6.7300e+00 S 3 3 1 I + lutetium_aluminum_oxide_2 +lutetium aluminum oxide (2) (Lu%3#Al%5#O%12#) + 365.9 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 71 3.000000 0.616224 + 13 5.000000 0.158379 + 8 12.000000 0.225396 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 337 LuSiO 5 -1.0000000000 0.42793 7.4000e+00 7.4000e+00 S 3 2 1 I + lutetium_silicon_oxide +lutetium silicon oxide (Lu%2#SiO%5#) + 472.0 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 71 2.000000 0.764020 + 14 1.000000 0.061320 + 8 5.000000 0.174660 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 338 YAlO-1 5 -1.0000000000 0.46374 5.5000e+00 5.5000e+00 S 3 1 1 I + yttrium_aluminum_oxide_1 +yttrium aluminum oxide (1) (YAlO%3#) + 239.3 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 39 1.000000 0.542487 + 13 1.000000 0.164636 + 8 3.000000 0.292876 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 339 YAlO-2 5 -1.0000000000 0.46831 4.5600e+00 4.5600e+00 S 3 3 1 I + yttrium_aluminum_oxide_2 +yttrium aluminum oxide (2) (Y%3#Al%5#O%12#) + 218.0 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 39 3.000000 0.449308 + 13 5.000000 0.227263 + 8 12.000000 0.323428 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 340 YSiO 5 -1.0000000000 0.46171 4.5400e+00 4.5400e+00 S 3 2 1 I + yttrium_silicon_oxide +yttrium silicon oxide (Y%2#SiO%5#) + 258.1 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 39 2.000000 0.621949 + 14 1.000000 0.098237 + 8 5.000000 0.279813 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 341 GdSiO 5 -1.0000000000 0.43069 6.7100e+00 6.7100e+00 S 3 2 1 I + gadolinium_silicate +gadolinium silicate (Gd%2#SiO%5#) + 405.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 64 2.000000 0.744233 + 14 1.000000 0.066462 + 8 5.000000 0.189305 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +---------------------------------------------------------------------------- + 342 baksa 5 -1.0000000000 0.49228 2.7400e+00 2.7400e+00 S 2 0 1 I + baksan_rock +baksan rock + 175.6 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 11 0.100000 0.095103 + 12 0.900000 0.904897 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 343 bakst 5 -1.0000000000 0.49228 2.7400e+00 2.6500e+00 S 2 0 1 I + baksan_rock_st +baksan rock, std rock density + 175.6 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 11 0.100000 0.095103 + 12 0.900000 0.904897 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 344 MtBla 5 -1.0000000000 0.48003 2.6000e+00 2.6000e+00 S 2 0 1 I + MtBlanc_rock +Mt Blanc rock + 159.2 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 6 0.132000 0.073601 + 11 0.868000 0.926399 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 345 MtBst 5 -1.0000000000 0.48003 2.6000e+00 2.6500e+00 S 2 0 1 I + MtBlanc_rock_sd +Mt Blanc rock, std rock density + 159.2 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 6 0.132000 0.073601 + 11 0.868000 0.926399 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 346 KGFst 5 -1.0000000000 0.48605 3.0200e+00 2.6500e+00 S 2 0 1 I + KGF_rock_st +Kolar Gold Fields rock, std rock density + 183.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 12 0.380000 0.355713 + 13 0.620000 0.644287 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 347 KGF 5 -1.0000000000 0.48605 3.0200e+00 3.0200e+00 S 2 0 1 I + KGF_rock +Kolar Gold Fields rock + 183.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 12 0.380000 0.355713 + 13 0.620000 0.644287 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 348 UD 5 -1.0000000000 0.49602 2.7000e+00 2.7000e+00 S 11 0 1 I + UD_rock +UD rock for doug + 145.4 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 14 0.245239 0.334025 + 22 0.001368 0.003176 + 13 0.056485 0.073911 + 26 0.009477 0.025666 + 25 0.000148 0.000394 + 12 0.004120 0.004856 + 20 0.009895 0.019232 + 11 0.041643 0.046428 + 19 0.001606 0.003045 + 15 0.000592 0.000889 + 8 0.629426 0.488377 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 349 LMP 5 -1.0000000000 0.49641 2.7000e+00 2.7000e+00 S 11 0 1 I + LMP_rock +LMP rock for Doug + 145.9 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 14 0.248086 0.335584 + 22 0.001242 0.002863 + 13 0.066504 0.086423 + 26 0.008725 0.023467 + 25 0.000146 0.000386 + 12 0.010053 0.011768 + 20 0.007152 0.013805 + 11 0.002935 0.003250 + 19 0.015537 0.029258 + 15 0.000437 0.000652 + 8 0.639181 0.492543 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- + 350 UM 5 -1.0000000000 0.49407 2.7000e+00 2.7000e+00 S 11 0 1 I + UM_rock +UM rock for Doug + 152.7 0.0000 0.0000 0.0000 0.00000 0.0000 0.00 + 14 0.184026 0.238952 + 22 0.002244 0.004966 + 13 0.069046 0.086130 + 26 0.030831 0.079602 + 25 0.000822 0.002088 + 12 0.042435 0.047684 + 20 0.031499 0.058365 + 11 0.025503 0.027107 + 19 0.000642 0.001160 + 15 0.000791 0.001133 + 8 0.612161 0.452813 +Note: Ieff calculated using the ICRU37 Table 5.1 algorithm for liquids and solids +--------------------------------------------------------------------------- diff --git a/Processes/EnergyLoss/ReadData.py b/Processes/EnergyLoss/ReadData.py new file mode 100644 index 0000000000000000000000000000000000000000..377f3992d7a8ff7888b7a01ef5b202e019533016 --- /dev/null +++ b/Processes/EnergyLoss/ReadData.py @@ -0,0 +1,73 @@ +#!/usr/bin/python + +import os +import sys +import string + + +data = open("Properties8.dat", "r") + +nEl = 0 +nOpt = 0 +count = 0 # the data comes with flexible row-blocks, need to count +for line in data.readlines(): + line = line.rstrip() + if line == "" or line[0] == "#": + continue + +# print str(count) + " " + line + + if count == 0: + index = int(line[0:4].strip()) # sternheimers index + name = line[5:11].strip() # tag + sig = int(line[11:14].strip()) # significant figures of atomic mass if element + weight = float(line[16:27].strip()) # atomic weight, if element + weight_error = int((line[31:32].strip() or "0"))# error in last place + ZoverA = float(line[34:42].strip()) # Z/A + rho = float(line[42:52].strip()) # Sternheimers density + rho_corr = float(line[52:63].strip())# Corrected density + state = line[64].strip() # Solid Liquid Gas Diatomicgas + nEl = int(line[66:69].strip()) # number of elements + nAtom = int(line[70:72].strip()) # atoms of el. 1 + nOpt = int(line[73:74].strip()) # number of optional lines + type = line[75] # type: Element, Radiactive element, Inorganic compound, Organic compound, Polymer, Mixture, Biological + + elif count == 1: + short = line[0:4].strip() # if element + long = line[4:100].strip() + + elif count == 2: + desc = line # description and formula + + elif count == 3: + Ieff = float(line[0:10].strip()) # ieff + Cbar = float(line[11:19].strip()) # cbar + x0 = float(line[21:28].strip()) # x0 + x1 = float(line[30:37].strip()) # x1 + aa = float(line[39:46].strip()) # a / aa + sk = float(line[48:55].strip()) # k / sk + delta0 = float(line[59:].strip()) # delta0 / dlt0 + + elif count == 4 and count < 4+nEl: + elZ = int(line[0:11].strip()) # Z + # num frac. + # weigh frac. + pass + + elif count>=4+nEl and count<=4+nEl+nOpt: + # print "opt : " + str(count) + " " + str(4+nEl+nOpt) + " " + line + # property A25 + # value F20 + # if 1:5 is "Note:" following lines are extra comments + if (count == 4+nEl+nOpt): + count = -1 + + print str(elZ) + " " + long + " " + str(Ieff) + " " + str(ZoverA) + " " + state + " " + type + " " + str(rho_corr) + " " + str(delta0) + " " + str(x0) + " " + str(x1) + " " + str(aa) + " " + str(sk) + " " + str(Cbar) + + + count += 1 + + +if (count != 0): + print ("Error " + str(count)) + diff --git a/Processes/EnergyLoss/SummaryPropTable.dat b/Processes/EnergyLoss/SummaryPropTable.dat new file mode 100644 index 0000000000000000000000000000000000000000..2ebc9d2e630ce5b3bd1e32e30cd00e5f3eb6f166 --- /dev/null +++ b/Processes/EnergyLoss/SummaryPropTable.dat @@ -0,0 +1,138 @@ +# RU Mo 18. Feb 14:07:40 CET 2019 +# Data table obtained from http://pdg.lbl.gov/2018/AtomicNuclearProperties/summary_prop_table.dat +# see also http://pdg.lbl.gov/2018/AtomicNuclearProperties/expert.html +# Z A density dEmin Xo lam_I lam_pi_I E_c (elec) E_c (pstrn) state + 1 1.00794 0.00 4.103 63.04 52.01 80.26 344.80 338.33 D + 1 1.00794 0.07 4.034 63.04 52.01 80.26 278.02 271.50 L + 1 2.01410 0.00 2.053 125.98 71.78 110.12 345.50 339.03 D + 1 2.01410 0.17 2.019 125.98 71.78 110.12 278.02 271.50 L + 2 4.00260 0.00 1.937 94.32 71.00 103.61 257.13 252.23 G + 2 4.00260 0.12 1.936 94.32 71.00 103.61 208.25 203.34 L + 3 6.94100 0.53 1.639 82.78 71.34 103.26 149.06 145.33 S + 4 9.01218 1.85 1.595 65.19 77.80 109.90 113.70 110.68 S + 5 10.81100 2.37 1.623 52.69 83.32 115.54 93.95 91.41 S + 6 12.01070 2.00 1.749 42.70 85.81 117.79 82.08 79.85 S + 6 12.01070 2.21 1.742 42.70 85.81 117.79 81.74 79.51 S + 6 12.01070 2.27 1.745 42.70 85.81 117.79 81.67 79.44 S + 6 12.01070 3.52 1.725 42.70 85.81 117.79 80.17 77.94 S + 7 14.00670 0.00 1.825 37.99 89.68 121.69 91.73 89.71 D + 7 14.00670 0.81 1.813 37.99 89.68 121.69 75.47 73.49 L + 8 15.99940 0.00 1.801 34.24 90.17 121.91 81.45 79.62 D + 8 15.99940 1.14 1.788 34.24 90.17 121.91 66.82 65.04 L + 9 18.99840 0.00 1.676 32.93 97.42 127.24 73.15 71.48 D + 9 18.99840 1.51 1.634 32.93 97.42 127.24 59.81 58.17 L + 10 20.17970 0.00 1.724 28.93 98.99 128.66 67.02 65.47 G + 10 20.17970 1.20 1.695 28.93 98.99 128.66 55.10 53.59 L + 11 22.98977 0.97 1.639 27.74 102.55 132.22 51.38 49.99 S + 12 24.30500 1.74 1.674 25.03 104.12 133.65 46.55 45.25 S + 13 26.98154 2.70 1.615 24.01 107.16 136.67 42.70 41.48 S + 14 28.08550 2.33 1.664 21.82 108.35 137.74 40.19 39.05 S + 15 30.97376 2.20 1.613 21.21 111.36 140.72 37.92 36.84 S + 16 32.06500 2.00 1.652 19.50 112.44 141.70 35.85 34.83 S + 17 35.45300 0.00 1.630 19.28 115.70 144.94 40.05 39.04 D + 17 35.45300 1.57 1.608 19.28 115.70 144.94 34.32 33.35 L + 18 39.94800 0.00 1.519 19.55 119.73 148.99 38.03 37.06 G + 18 39.94800 1.40 1.508 19.55 119.73 148.99 32.84 31.91 L + 19 39.09830 0.86 1.623 17.32 118.98 148.08 31.62 30.72 S + 20 40.07800 1.55 1.655 16.14 119.83 148.83 29.56 28.71 S + 21 44.95591 2.99 1.522 16.55 123.90 152.91 27.61 26.79 S + 22 47.86700 4.54 1.477 16.16 126.20 155.17 26.01 25.23 S + 23 50.94150 6.11 1.436 15.84 128.54 157.46 24.67 23.91 S + 24 51.99610 7.18 1.456 14.94 129.31 158.16 23.52 22.79 S + 25 54.93804 7.44 1.428 14.64 131.44 160.24 22.59 21.89 S + 26 55.84500 7.87 1.451 13.84 132.08 160.80 21.68 21.00 S + 27 58.93319 8.90 1.419 13.62 134.23 162.90 20.82 20.16 S + 28 58.69340 8.90 1.468 12.68 134.06 162.64 20.05 19.41 S + 29 63.54600 8.96 1.403 12.86 137.30 165.87 19.42 18.79 S + 30 65.38000 7.13 1.411 12.43 138.49 166.99 18.93 18.33 S + 31 69.72300 5.90 1.379 12.47 141.22 169.69 18.57 17.98 S + 32 72.64000 5.32 1.370 12.25 143.00 171.42 18.16 17.58 S + 33 74.92159 5.73 1.370 11.94 144.36 172.73 17.65 17.09 S + 34 78.97100 4.50 1.343 11.91 146.71 175.04 17.34 16.79 S + 35 79.90400 0.01 1.388 11.42 147.24 175.51 19.16 18.60 D + 35 79.90400 3.10 1.380 11.42 147.24 175.51 17.28 16.75 L + 36 83.79800 0.00 1.357 11.37 149.42 177.65 18.61 18.06 G + 36 83.79800 2.42 1.357 11.37 149.42 177.65 17.03 16.51 L + 37 85.46780 1.53 1.356 11.03 150.34 178.51 16.61 16.10 S + 38 87.62000 2.54 1.353 10.76 151.50 179.62 15.97 15.47 S + 39 88.90584 4.47 1.359 10.41 152.18 180.26 15.30 14.81 S + 40 91.22400 6.51 1.349 10.20 153.41 181.44 14.74 14.27 S + 41 92.90637 8.57 1.343 9.92 154.28 182.26 14.23 13.77 S + 42 95.95000 10.22 1.329 9.80 155.84 183.78 13.85 13.39 S + 43 97.90722 11.50 1.325 9.58 156.83 184.72 13.46 13.01 S + 44 101.07000 12.41 1.307 9.48 158.40 186.25 13.12 12.68 S + 45 102.90550 12.41 1.310 9.27 159.30 187.11 12.84 12.41 S + 46 106.42000 12.02 1.289 9.20 161.00 188.76 12.57 12.15 S + 47 107.86820 10.50 1.299 8.97 161.68 189.41 12.36 11.94 S + 48 112.41400 8.65 1.277 9.00 163.81 191.49 12.21 11.80 S + 49 114.81800 7.31 1.278 8.85 164.91 192.55 12.06 11.65 S + 50 118.71000 7.31 1.263 8.82 166.67 194.27 11.86 11.46 S + 51 121.76000 6.69 1.259 8.73 168.02 195.58 11.70 11.31 S + 52 127.60000 6.24 1.227 8.83 170.56 198.08 11.54 11.16 S + 53 126.90447 4.93 1.263 8.48 170.25 197.74 11.42 11.04 S + 54 131.29300 0.01 1.255 8.48 172.12 199.56 12.30 11.91 G + 54 131.29300 2.95 1.255 8.48 172.12 199.56 11.66 11.28 L + 55 132.90545 1.87 1.254 8.31 172.79 200.20 11.34 10.97 S + 56 137.32700 3.50 1.231 8.31 174.62 201.98 10.98 10.62 S + 57 138.90547 6.14 1.231 8.14 175.26 202.59 10.63 10.27 S + 58 140.11600 6.77 1.234 7.96 175.75 203.04 10.40 10.04 S + 59 140.90766 6.77 1.243 7.76 176.07 203.32 10.21 9.86 S + 60 144.24200 7.01 1.231 7.71 177.40 204.62 10.02 9.68 S + 61 144.91275 7.26 1.240 7.51 177.66 204.85 9.83 9.49 S + 62 150.36000 7.52 1.210 7.57 179.79 206.95 9.66 9.32 S + 63 151.96400 5.24 1.219 7.44 180.41 207.53 9.59 9.26 S + 64 157.25000 7.90 1.188 7.48 182.42 209.50 9.34 9.01 S + 65 158.92535 8.23 1.188 7.36 183.05 210.10 9.17 8.85 S + 66 162.50000 8.55 1.175 7.32 184.38 211.39 9.02 8.70 S + 67 164.93033 8.80 1.170 7.23 185.27 212.25 8.86 8.55 S + 68 167.25900 9.03 1.168 7.14 186.12 213.07 8.73 8.42 S + 69 168.93422 9.32 1.170 7.03 186.72 213.64 8.59 8.28 S + 70 173.05400 6.90 1.159 7.02 188.19 215.08 8.52 8.22 S + 71 174.96680 9.84 1.160 6.92 188.87 215.72 8.36 8.06 S + 72 178.49000 13.31 1.152 6.89 190.10 216.93 8.22 7.93 S + 73 180.94788 16.65 1.149 6.82 190.96 217.75 8.09 7.79 S + 74 183.84000 19.30 1.145 6.76 191.95 218.71 7.97 7.68 S + 75 186.20700 21.02 1.143 6.69 192.75 219.49 7.85 7.57 S + 76 190.23000 22.57 1.132 6.68 194.11 220.81 7.75 7.47 S + 77 192.21700 22.42 1.134 6.59 194.77 221.45 7.67 7.39 S + 78 195.08400 21.45 1.128 6.54 195.72 222.37 7.59 7.31 S + 79 196.96657 19.32 1.134 6.46 196.34 222.96 7.53 7.26 S + 80 200.59000 13.55 1.130 6.44 197.52 224.11 7.53 7.26 L + 81 204.38330 11.72 1.125 6.42 198.75 225.30 7.50 7.23 S + 82 207.20000 11.35 1.122 6.37 199.64 226.17 7.43 7.16 S + 83 208.98040 9.75 1.128 6.29 200.21 226.71 7.39 7.13 S + 84 208.98243 9.32 1.141 6.16 200.21 226.69 7.33 7.06 S + 85 209.98715 5.00 1.160 6.07 200.52 226.98 7.60 7.33 S + 86 222.01758 0.01 1.116 6.28 204.25 230.66 7.71 7.43 G + 87 223.01974 1.87 1.118 6.19 204.56 230.94 7.59 7.32 S + 88 226.02541 5.00 1.111 6.15 205.47 231.83 7.19 6.94 S + 89 227.02775 10.07 1.112 6.06 205.77 232.11 7.00 6.75 S + 90 232.03770 11.72 1.098 6.07 207.26 233.57 6.91 6.66 S + 91 231.03588 15.37 1.107 5.93 206.96 233.25 6.77 6.52 S + 92 238.02891 18.95 1.081 6.00 209.02 235.28 6.65 6.41 S + 93 237.04817 20.25 1.095 5.87 208.73 234.97 6.57 6.33 S + 94 244.06420 19.84 1.071 5.93 210.77 236.98 6.49 6.25 S + 95 243.06138 13.67 1.089 5.80 210.48 236.67 6.50 6.25 S + 96 247.07035 13.51 1.082 5.79 211.63 237.79 6.44 6.20 S + 97 247.07031 14.00 1.106 5.69 211.63 237.77 6.59 6.35 S + 98 251.07959 14.00 1.097 5.68 212.77 238.88 6.53 6.29 S + 99 252.08300 14.00 1.102 5.61 213.05 239.15 6.47 6.24 S + 100 257.09510 14.00 1.090 5.62 214.45 240.52 6.42 6.19 S + 101 258.09843 14.00 1.095 5.55 214.73 240.78 6.37 6.13 S + 102 259.10100 14.00 1.099 5.48 215.00 241.04 6.31 6.08 S + 103 262.11000 14.00 1.096 5.45 215.83 241.84 6.26 6.03 S + 104 267.12200 14.00 1.084 5.47 217.20 243.19 6.21 5.98 S + 105 268.12500 14.00 1.088 5.40 217.48 243.44 6.16 5.93 S + 106 271.13300 14.00 1.085 5.38 218.29 244.23 6.11 5.89 S + 107 270.13400 14.00 1.097 5.27 218.02 243.95 6.06 5.84 S + 108 269.13410 14.00 1.110 5.17 217.75 243.66 6.01 5.79 S + 109 276.15100 14.00 1.090 5.23 219.63 245.51 5.97 5.75 S + 110 281.16200 14.00 1.079 5.24 220.96 246.82 5.92 5.71 S + 111 280.16400 14.00 1.091 5.14 220.69 246.54 5.88 5.66 S + 112 285.00000 14.00 1.080 5.16 221.96 247.78 5.83 5.61 S + 113 284.17800 14.00 1.091 5.07 221.75 247.55 5.79 5.57 S + 114 289.18700 14.00 1.080 5.08 223.05 248.83 5.75 5.53 S + 115 288.19200 14.00 1.092 4.99 222.79 248.56 5.71 5.49 S + 116 293.20000 14.00 1.081 5.00 224.08 249.83 5.67 5.45 S + 117 294.00000 14.00 1.086 4.95 224.29 250.01 5.62 5.41 S + 118 294.21500 0.01 1.092 4.88 224.34 250.05 5.67 5.45 G diff --git a/Processes/HadronicElasticModel/HadronicElasticModel.cc b/Processes/HadronicElasticModel/HadronicElasticModel.cc index 42a42e0abd257c2b01f69e44c5ae8dcf3d6dba47..95388ce557cb726d50fcebede52085bdc89910af 100644 --- a/Processes/HadronicElasticModel/HadronicElasticModel.cc +++ b/Processes/HadronicElasticModel/HadronicElasticModel.cc @@ -53,7 +53,7 @@ namespace corsika::process::HadronicElasticModel { auto const projectileEnergy = p.GetEnergy(); auto const avgCrossSection = [&]() { - CrossSectionType avgCrossSection = 0_barn; + CrossSectionType avgCrossSection = 0_b; for (size_t i = 0; i < fractions.size(); ++i) { auto const targetMass = particles::GetMass(components[i]); @@ -62,7 +62,7 @@ namespace corsika::process::HadronicElasticModel { avgCrossSection += CrossSection(s) * fractions[i]; } - std::cout << "avgCrossSection: " << avgCrossSection / 1_mbarn << " mb" + std::cout << "avgCrossSection: " << avgCrossSection / 1_mb << " mb" << std::endl; return avgCrossSection; @@ -196,8 +196,8 @@ namespace corsika::process::HadronicElasticModel { units::si::detail::static_pow<2>(sigmaTotal) / (16 * M_PI * ConvertHEPToSI<CrossSectionType::dimension_type>(B(s))); - std::cout << "HEM sigmaTot = " << sigmaTotal / 1_mbarn << " mb" << std::endl; - std::cout << "HEM sigmaElastic = " << sigmaElastic / 1_mbarn << " mb" << std::endl; + std::cout << "HEM sigmaTot = " << sigmaTotal / 1_mb << " mb" << std::endl; + std::cout << "HEM sigmaElastic = " << sigmaElastic / 1_mb << " mb" << std::endl; return sigmaElastic; } diff --git a/Processes/HadronicElasticModel/HadronicElasticModel.h b/Processes/HadronicElasticModel/HadronicElasticModel.h index acf7d96b8786bcc63d1e066e5357cf043de17b0e..fae8c97242bac32426eca9089ac8a8ff611b631e 100644 --- a/Processes/HadronicElasticModel/HadronicElasticModel.h +++ b/Processes/HadronicElasticModel/HadronicElasticModel.h @@ -40,8 +40,8 @@ namespace corsika::process::HadronicElasticModel { using SquaredHEPEnergyType = decltype(corsika::units::si::HEPEnergyType() * corsika::units::si::HEPEnergyType()); - using eV2 = decltype(units::si::detail::static_pow<2>(units::si::electronvolt)); - using inveV2 = decltype(units::si::detail::static_pow<-2>(units::si::electronvolt)); + using eV2 = decltype(units::si::square(units::si::electronvolt)); + using inveV2 = decltype(1 / units::si::square(units::si::electronvolt)); corsika::random::RNG& fRNG = corsika::random::RNGManager::GetInstance().GetRandomStream( diff --git a/Processes/Pythia/CMakeLists.txt b/Processes/Pythia/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..adc953090c31505acf4fd4c6c85dd85435ca136c --- /dev/null +++ b/Processes/Pythia/CMakeLists.txt @@ -0,0 +1,88 @@ +set(Python_ADDITIONAL_VERSIONS 3) +find_package(PythonInterp 3 REQUIRED) + +set ( + MODEL_SOURCES + Decay.cc + Random.cc + Interaction.cc + ) + +set ( + MODEL_HEADERS + Decay.h + Random.h + Interaction.h + ) + +set ( + MODEL_NAMESPACE + corsika/process/pythia + ) + +add_library (ProcessPythia STATIC ${MODEL_SOURCES}) +CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessPythia ${MODEL_NAMESPACE} ${MODEL_HEADERS}) + + +set_target_properties ( + ProcessPythia + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 1 +# PUBLIC_HEADER "${MODEL_HEADERS}" + ) + +# target dependencies on other libraries (also the header onlys) +target_link_libraries ( + ProcessPythia + CORSIKAparticles + CORSIKAutilities + CORSIKAunits + CORSIKAthirdparty + CORSIKAgeometry + CORSIKAenvironment + ${PYTHIA8_LIBRARY} + ) + +target_include_directories ( + ProcessPythia + INTERFACE + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include/include> + ) + +target_include_directories ( + ProcessPythia + SYSTEM + PUBLIC ${PYTHIA8_INCLUDE_DIR} + INTERFACE ${PYTHIA8_INCLUDE_DIR} + ) + +install ( + TARGETS ProcessPythia + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +# PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE} + ) + + +# -------------------- +# code unit testing +add_executable (testPythia + testPythia.cc + ${MODEL_HEADERS} + ) + + +target_link_libraries ( + testPythia + ProcessPythia + CORSIKAsetup + CORSIKArandom + CORSIKAgeometry + CORSIKAunits + CORSIKAthirdparty # for catch2 + ${PYTHIA8_LIBRARY} + ) + +CORSIKA_ADD_TEST(testPythia) diff --git a/Processes/Pythia/Decay.cc b/Processes/Pythia/Decay.cc new file mode 100644 index 0000000000000000000000000000000000000000..77241b106dff5d6f674f60ec9a2acfe763ca09be --- /dev/null +++ b/Processes/Pythia/Decay.cc @@ -0,0 +1,155 @@ +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <Pythia8/Pythia.h> +#include <corsika/process/pythia/Decay.h> +#include <corsika/process/pythia/Random.h> + +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +using std::cout; +using std::endl; +using std::tuple; +using std::vector; + +using namespace corsika; +using namespace corsika::setup; +using Particle = Stack::StackIterator; // ParticleType; +using Track = Trajectory; + +namespace corsika::process::pythia { + + Decay::Decay(vector<particles::Code> pParticles) + : fTrackedParticles(pParticles) {} + + Decay::~Decay() { cout << "Pythia::Decay n=" << fCount << endl; } + + void Decay::Init() { + + Decay::SetParticleListStable(fTrackedParticles); + + // set random number generator in pythia + Pythia8::RndmEngine* rndm = new corsika::process::pythia::Random(); + fPythia.setRndmEnginePtr(rndm); + + fPythia.readString("Next:numberShowInfo = 0"); + fPythia.readString("Next:numberShowProcess = 0"); + fPythia.readString("Next:numberShowEvent = 0"); + + fPythia.readString("Print:quiet = on"); + + fPythia.readString("ProcessLevel:all = off"); + fPythia.readString("ProcessLevel:resonanceDecays = off"); + + fPythia.particleData.readString("59:m0 = 101.00"); + + fPythia.init(); + } + + void Decay::SetParticleListStable(const vector<particles::Code> particleList) { + for (auto p : particleList) Decay::SetStable(p); + } + + void Decay::SetUnstable(const particles::Code pCode) { + cout << "Pythia::Decay: setting " << pCode << " unstable.." << endl; + fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(pCode)), true); + } + + void Decay::SetStable(const particles::Code pCode) { + cout << "Pythia::Decay: setting " << pCode << " stable.." << endl; + fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(pCode)), false); + } + + template <> + units::si::TimeType Decay::GetLifetime(Particle const& p) { + using namespace units::si; + + HEPEnergyType E = p.GetEnergy(); + HEPMassType m = particles::GetMass(p.GetPID()); + + const double gamma = E / m; + + const TimeType t0 = particles::GetLifetime(p.GetPID()); + auto const lifetime = gamma * t0; + + return lifetime; + } + + template <> + void Decay::DoDecay(Particle& p, Stack&) { + using geometry::Point; + using namespace units; + using namespace units::si; + + auto const decayPoint = p.GetPosition(); + auto const t0 = p.GetTime(); + + // coordinate system, get global frame of reference + geometry::CoordinateSystem& rootCS = + geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + + fCount++; + + // pythia stack + Pythia8::Event& event = fPythia.event; + event.reset(); + + // set particle unstable + Decay::SetUnstable(p.GetPID()); + + // input particle PDG + auto const pdgCode = static_cast<int>(particles::GetPDG(p.GetPID())); + + auto const pcomp = p.GetMomentum().GetComponents(); + double px = pcomp[0] / 1_GeV; + double py = pcomp[1] / 1_GeV; + double pz = pcomp[2] / 1_GeV; + double en = p.GetEnergy() / 1_GeV; + double m = particles::GetMass(p.GetPID()) / 1_GeV; + + // add particle to pythia stack + event.append(pdgCode, 1, 0, 0, px, py, pz, en, m); + + if (!fPythia.next()) + cout << "Pythia::Decay: decay failed!" << endl; + else + cout << "Pythia::Decay: particles after decay: " << event.size() << endl; + + // list final state + event.list(); + + // loop over final state + for (int i = 0; i < event.size(); ++i) + if (event[i].isFinal()) { + auto const pyId = + particles::ConvertFromPDG(static_cast<particles::PDGCode>(event[i].id())); + HEPEnergyType pyEn = event[i].e() * 1_GeV; + MomentumVector pyP(rootCS, {event[i].px() * 1_GeV, event[i].py() * 1_GeV, + event[i].pz() * 1_GeV}); + + cout << "particle: id=" << pyId << " momentum=" << pyP.GetComponents() / 1_GeV + << " energy=" << pyEn << endl; + + p.AddSecondary( + tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ + pyId, pyEn, pyP, decayPoint, t0}); + } + + // set particle stable + Decay::SetStable(p.GetPID()); + + // remove original particle from corsika stack + p.Delete(); + // if (fCount>10) throw std::runtime_error("stop here"); + } + +} // namespace corsika::process::pythia diff --git a/Processes/Pythia/Decay.h b/Processes/Pythia/Decay.h new file mode 100644 index 0000000000000000000000000000000000000000..fc76137160177afabe0d6624b2bc1b708f545ab4 --- /dev/null +++ b/Processes/Pythia/Decay.h @@ -0,0 +1,51 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_corsika_process_pythia_decay_h_ +#define _include_corsika_process_pythia_decay_h_ + +#include <Pythia8/Pythia.h> +#include <corsika/particles/ParticleProperties.h> +#include <corsika/process/DecayProcess.h> + +namespace corsika::process { + + namespace pythia { + + typedef corsika::geometry::Vector<corsika::units::si::hepmomentum_d> MomentumVector; + + class Decay : public corsika::process::DecayProcess<Decay> { + const std::vector<particles::Code> fTrackedParticles; + int fCount = 0; + + public: + Decay(std::vector<corsika::particles::Code>); + ~Decay(); + void Init(); + + void SetParticleListStable(const std::vector<particles::Code>); + void SetUnstable(const corsika::particles::Code); + void SetStable(const corsika::particles::Code); + + template <typename Particle> + corsika::units::si::TimeType GetLifetime(Particle const& p); + + template <typename Particle, typename Stack> + void DoDecay(Particle& p, Stack&); + + private: + Pythia8::Pythia fPythia; + }; + + } // namespace pythia +} // namespace corsika::process + +#endif diff --git a/Processes/Pythia/Interaction.cc b/Processes/Pythia/Interaction.cc new file mode 100644 index 0000000000000000000000000000000000000000..a57d967c04f065054e4f656652aca03feec15c60 --- /dev/null +++ b/Processes/Pythia/Interaction.cc @@ -0,0 +1,424 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/process/pythia/Interaction.h> + +#include <corsika/environment/Environment.h> +#include <corsika/environment/NuclearComposition.h> +#include <corsika/geometry/FourVector.h> +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> +#include <corsika/utl/COMBoost.h> + +#include <tuple> + +using std::cout; +using std::endl; +using std::tuple; + +using namespace corsika; +using namespace corsika::setup; +using Particle = Stack::StackIterator; // ParticleType; +using Track = Trajectory; + +namespace corsika::process::pythia { + + typedef corsika::geometry::Vector<corsika::units::si::hepmomentum_d> MomentumVector; + + Interaction::Interaction(environment::Environment const& env) + : fEnvironment(env) {} + + Interaction::~Interaction() { + cout << "Pythia::Interaction n=" << fCount << endl; + } + + void Interaction::Init() { + + using random::RNGManager; + + // initialize Pythia + if (!fInitialized) { + + fPythia.readString("Print:quiet = on"); + // TODO: proper process initialization for MinBias needed + fPythia.readString("HardQCD:all = on"); + fPythia.readString("ProcessLevel:resonanceDecays = off"); + + fPythia.init(); + + // any decays in pythia? if yes need to define which particles + if(fInternalDecays){ + // define which particles are passed to corsika, i.e. which particles make it into history + // even very shortlived particles like charm or pi0 are of interest here + const std::vector<particles::Code> HadronsWeWantTrackedByCorsika = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::Pi0, + particles::Code::KMinus, particles::Code::KPlus, + particles::Code::K0Long, particles::Code::K0Short, + particles::Code::SigmaPlus, particles::Code::SigmaMinus, + particles::Code::Lambda0, + particles::Code::Xi0, particles::Code::XiMinus, + particles::Code::OmegaMinus, + particles::Code::DPlus, particles::Code::DMinus, particles::Code::D0, particles::Code::D0Bar}; + + Interaction::SetParticleListStable(HadronsWeWantTrackedByCorsika); + } + + // basic initialization of cross section routines + fSigma.init( &fPythia.info, fPythia.settings, &fPythia.particleData, &fPythia.rndm ); + + fInitialized = true; + } + } + + void Interaction::SetParticleListStable(const std::vector<particles::Code> particleList) { + for (auto p : particleList) + Interaction::SetStable( p ); + } + + void Interaction::SetUnstable(const particles::Code pCode) { + cout << "Pythia::Interaction: setting " << pCode << " unstable.." << endl; + fPythia.particleData.mayDecay( static_cast<int>( particles::GetPDG(pCode) ) , true); + } + + void Interaction::SetStable(const particles::Code pCode) { + cout << "Pythia::Interaction: setting " << pCode << " stable.." << endl; + fPythia.particleData.mayDecay( static_cast<int>( particles::GetPDG(pCode) ) , false); + } + + + void Interaction::ConfigureLabFrameCollision( const particles::Code BeamId, const particles::Code TargetId, + const units::si::HEPEnergyType BeamEnergy ) + { + using namespace units::si; + // Pythia configuration of the current event + // very clumsy. I am sure this can be done better.. + + // set beam + // beam id for pythia + auto const pdgBeam = static_cast<int>(particles::GetPDG(BeamId)); + std::stringstream stBeam; + stBeam << "Beams:idA = " << pdgBeam; + fPythia.readString(stBeam.str()); + // set target + auto pdgTarget = static_cast<int>(particles::GetPDG(TargetId)); + // replace hydrogen with proton, otherwise pythia goes into heavy ion mode! + if(TargetId == particles::Code::Hydrogen) + pdgTarget = static_cast<int>( particles::GetPDG(particles::Code::Proton)); + std::stringstream stTarget; + stTarget << "Beams:idB = " << pdgTarget; + fPythia.readString(stTarget.str()); + // set frame to lab. frame + fPythia.readString("Beams:frameType = 2"); + // set beam energy + const double Elab = BeamEnergy / 1_GeV; + std::stringstream stEnergy; + stEnergy << "Beams:eA = " << Elab; + fPythia.readString(stEnergy.str()); + // target at rest + fPythia.readString("Beams:eB = 0."); + // initialize this config + fPythia.init(); + } + + + bool Interaction::CanInteract(const corsika::particles::Code pCode) + { + return pCode == corsika::particles::Code::Proton || pCode == corsika::particles::Code::Neutron + || pCode == corsika::particles::Code::AntiProton || pCode == corsika::particles::Code::AntiNeutron + || pCode == corsika::particles::Code::PiMinus || pCode == corsika::particles::Code::PiPlus; + } + + tuple<units::si::CrossSectionType, units::si::CrossSectionType> + Interaction::GetCrossSection(const particles::Code BeamId, + const particles::Code TargetId, + const units::si::HEPEnergyType CoMenergy) { + using namespace units::si; + + // interaction possible in pythia? + if( TargetId == particles::Code::Proton || TargetId == particles::Code::Hydrogen ){ + if( CanInteract(BeamId) && ValidCoMEnergy(CoMenergy) ){ + // input particle PDG + auto const pdgCodeBeam = static_cast<int>( particles::GetPDG( BeamId )); + auto const pdgCodeTarget = static_cast<int>( particles::GetPDG( TargetId )); + const double ecm = CoMenergy / 1_GeV; + + // calculate cross section + fSigma.calc( pdgCodeBeam, pdgCodeTarget, ecm); + if(fSigma.hasSigmaTot()){ + const double sigEla = fSigma.sigmaEl(); + const double sigProd = fSigma.sigmaTot() - sigEla; + + return std::make_tuple(sigProd * 1_mb, sigEla * 1_mb); + + } else + throw std::runtime_error("pythia cross section init failed"); + + } else { + return std::make_tuple(std::numeric_limits<double>::infinity() * 1_mb, + std::numeric_limits<double>::infinity() * 1_mb); + } + } else { + throw std::runtime_error("invalid target for pythia"); + } + } + + template <> + units::si::GrammageType Interaction::GetInteractionLength(Particle& p, Track&) { + + using namespace units; + using namespace units::si; + using namespace geometry; + + // coordinate system, get global frame of reference + CoordinateSystem& rootCS = + RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + + const particles::Code corsikaBeamId = p.GetPID(); + + // beam particles for pythia : 1, 2, 3 for p, pi, k + // read from cross section code table + const bool kInteraction = CanInteract(corsikaBeamId); + + // FOR NOW: assume target is at rest + process::pythia::MomentumVector pTarget(rootCS, {0_GeV, 0_GeV, 0_GeV}); + + // total momentum and energy + HEPEnergyType Elab = p.GetEnergy() + constants::nucleonMass; + process::pythia::MomentumVector pTotLab(rootCS, {0_GeV, 0_GeV, 0_GeV}); + pTotLab += p.GetMomentum(); + pTotLab += pTarget; + auto const pTotLabNorm = pTotLab.norm(); + // calculate cm. energy + const HEPEnergyType ECoM = sqrt( + (Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy + + cout << "Interaction: LambdaInt: \n" + << " input energy: " << p.GetEnergy() / 1_GeV << endl + << " beam can interact:" << kInteraction << endl + << " beam pid:" << p.GetPID() << endl; + + // TODO: move limits into variables + if (kInteraction && Elab >= 8.5_GeV && ValidCoMEnergy(ECoM) ) { + + // get target from environment + /* + the target should be defined by the Environment, + ideally as full particle object so that the four momenta + and the boosts can be defined.. + */ + const auto currentNode = + fEnvironment.GetUniverse()->GetContainingNode(p.GetPosition()); + const auto mediumComposition = + currentNode->GetModelProperties().GetNuclearComposition(); + // determine average interaction length + // weighted sum + int i = -1; + si::CrossSectionType weightedProdCrossSection = 0_mb; + // get weights of components from environment/medium + const auto w = mediumComposition.GetFractions(); + // loop over components in medium + for (auto const targetId : mediumComposition.GetComponents()) { + i++; + cout << "Interaction: get interaction length for target: " << targetId << endl; + + auto const [productionCrossSection, elaCrossSection] = + GetCrossSection(corsikaBeamId, targetId, ECoM); + [[maybe_unused]] auto elaCrossSectionCopy = + elaCrossSection; // ONLY TO AVOID COMPILER WARNING + + cout << "Interaction: IntLength: pythia return (mb): " + << productionCrossSection / 1_mb << endl + << "Interaction: IntLength: weight : " << w[i] << endl; + + weightedProdCrossSection += w[i] * productionCrossSection; + } + cout << "Interaction: IntLength: weighted CrossSection (mb): " + << weightedProdCrossSection / 1_mb << endl + << "Interaction: IntLength: average mass number: " + << mediumComposition.GetAverageMassNumber() << endl; + + // calculate interaction length in medium + GrammageType const int_length = + mediumComposition.GetAverageMassNumber() * units::constants::u / weightedProdCrossSection; + cout << "Interaction: " + << "interaction length (g/cm2): " << int_length / (0.001_kg) * 1_cm * 1_cm + << endl; + + return int_length; + } + + return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm); + } + + /** + In this function PYTHIA is called to produce one event. The + event is copied (and boosted) into the shower lab frame. + */ + + template <> + process::EProcessReturn Interaction::DoInteraction(Particle& p, Stack&) { + + using namespace units; + using namespace utl; + using namespace units::si; + using namespace geometry; + + + const auto corsikaBeamId = p.GetPID(); + cout << "Pythia::Interaction: " + << "DoInteraction: " << corsikaBeamId << " interaction? " + << process::pythia::Interaction::CanInteract(corsikaBeamId) << endl; + + if (particles::IsNucleus(corsikaBeamId)) { + // nuclei handled by different process, this should not happen + throw std::runtime_error("Nuclear projectile are not handled by PYTHIA!"); + } + + if (process::pythia::Interaction::CanInteract(corsikaBeamId)) { + + const CoordinateSystem& rootCS = + RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + + // position and time of interaction, not used in Sibyll + Point pOrig = p.GetPosition(); + TimeType tOrig = p.GetTime(); + + // define target + // FOR NOW: target is always at rest + const auto eTargetLab = 0_GeV + constants::nucleonMass; + const auto pTargetLab = MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); + const FourVector PtargLab(eTargetLab, pTargetLab); + + // define projectile + HEPEnergyType const eProjectileLab = p.GetEnergy(); + auto const pProjectileLab = p.GetMomentum(); + + cout << "Interaction: ebeam lab: " << eProjectileLab / 1_GeV << endl + << "Interaction: pbeam lab: " << pProjectileLab.GetComponents() / 1_GeV + << endl; + cout << "Interaction: etarget lab: " << eTargetLab / 1_GeV << endl + << "Interaction: ptarget lab: " << pTargetLab.GetComponents() / 1_GeV << endl; + + const FourVector PprojLab(eProjectileLab, pProjectileLab); + + // define target kinematics in lab frame + // define boost to and from CoM frame + // CoM frame definition in Pythia projectile: +z + COMBoost const boost(PprojLab, constants::nucleonMass); + + // just for show: + // boost projecticle + auto const PprojCoM = boost.toCoM(PprojLab); + + // boost target + auto const PtargCoM = boost.toCoM(PtargLab); + + cout << "Interaction: ebeam CoM: " << PprojCoM.GetTimeLikeComponent() / 1_GeV + << endl + << "Interaction: pbeam CoM: " + << PprojCoM.GetSpaceLikeComponents().GetComponents() / 1_GeV << endl; + cout << "Interaction: etarget CoM: " << PtargCoM.GetTimeLikeComponent() / 1_GeV + << endl + << "Interaction: ptarget CoM: " + << PtargCoM.GetSpaceLikeComponents().GetComponents() / 1_GeV << endl; + + cout << "Interaction: position of interaction: " << pOrig.GetCoordinates() << endl; + cout << "Interaction: time: " << tOrig << endl; + + HEPEnergyType Etot = eProjectileLab + eTargetLab; + MomentumVector Ptot = p.GetMomentum(); + // invariant mass, i.e. cm. energy + HEPEnergyType Ecm = sqrt(Etot * Etot - Ptot.squaredNorm()); + + // sample target mass number + const auto currentNode = fEnvironment.GetUniverse()->GetContainingNode(pOrig); + const auto& mediumComposition = + currentNode->GetModelProperties().GetNuclearComposition(); + // get cross sections for target materials + /* + Here we read the cross section from the interaction model again, + should be passed from GetInteractionLength if possible + */ + //#warning reading interaction cross section again, should not be necessary + auto const& compVec = mediumComposition.GetComponents(); + std::vector<si::CrossSectionType> cross_section_of_components(compVec.size()); + + for (size_t i = 0; i < compVec.size(); ++i) { + auto const targetId = compVec[i]; + const auto [sigProd, sigEla] = + GetCrossSection(corsikaBeamId, targetId, Ecm); + cross_section_of_components[i] = sigProd; + [[maybe_unused]] auto sigElaCopy = + sigEla; // to avoid not used warning in array binding + } + + const auto corsikaTargetId = + mediumComposition.SampleTarget(cross_section_of_components, fRNG); + cout << "Interaction: target selected: " << corsikaTargetId << endl; + + if (corsikaTargetId != particles::Code::Hydrogen && corsikaTargetId != particles::Code::Neutron + && corsikaTargetId != particles::Code::Proton ) + throw std::runtime_error("DoInteraction: wrong target for PYTHIA"); + + cout << "Interaction: " + << " DoInteraction: E(GeV):" << eProjectileLab / 1_GeV + << " Ecm(GeV): " << Ecm / 1_GeV << endl; + + if (eProjectileLab < 8.5_GeV || !ValidCoMEnergy(Ecm)) { + cout << "Interaction: " + << " DoInteraction: should have dropped particle.. " + << "THIS IS AN ERROR" << endl; + throw std::runtime_error("energy too low for PYTHIA"); + + } else { + fCount++; + + ConfigureLabFrameCollision( corsikaBeamId, corsikaTargetId, eProjectileLab ); + + // create event in pytia + if(!fPythia.next()) + throw std::runtime_error("Pythia::DoInteraction: failed!"); + + // link to pythia stack + Pythia8::Event& event = fPythia.event; + // print final state + event.list(); + + MomentumVector Plab_final(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV}); + HEPEnergyType Elab_final = 0_GeV; + for (int i = 0; i < event.size(); ++i){ + Pythia8::Particle &pp = event[i]; + // skip particles that have decayed in pythia + if (!pp.isFinal()) continue; + + auto const pyId = particles::ConvertFromPDG(static_cast<particles::PDGCode>(pp.id())); + + const MomentumVector pyPlab(rootCS, {pp.px()*1_GeV, pp.py()*1_GeV, pp.pz()*1_GeV}); + HEPEnergyType const pyEn = pp.e() * 1_GeV; + + // add to corsika stack + auto pnew = p.AddSecondary( + tuple<particles::Code, units::si::HEPEnergyType, stack::MomentumVector, + geometry::Point, units::si::TimeType>{pyId, pyEn, pyPlab, pOrig, tOrig}); + + Plab_final += pnew.GetMomentum(); + Elab_final += pnew.GetEnergy(); + } + cout << "conservation (all GeV): " << "Elab_final=" << Elab_final / 1_GeV + << ", Plab_final=" << (Plab_final / 1_GeV).GetComponents() << endl; + } + // delete current particle + p.Delete(); + } + return process::EProcessReturn::eOk; + } + +} // namespace corsika::process::pythia diff --git a/Processes/Pythia/Interaction.h b/Processes/Pythia/Interaction.h new file mode 100644 index 0000000000000000000000000000000000000000..f384da655322cac969588308c85094358c11cd80 --- /dev/null +++ b/Processes/Pythia/Interaction.h @@ -0,0 +1,79 @@ +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _corsika_process_pythia_interaction_h_ +#define _corsika_process_pythia_interaction_h_ + +#include <Pythia8/Pythia.h> + +#include <corsika/particles/ParticleProperties.h> +#include <corsika/process/InteractionProcess.h> +#include <corsika/random/RNGManager.h> +#include <corsika/units/PhysicalUnits.h> +#include <tuple> + +namespace corsika::environment { + class Environment; +} + +namespace corsika::process::pythia { + + class Interaction : public corsika::process::InteractionProcess<Interaction> { + + int fCount = 0; + bool fInitialized = false; + + public: + Interaction(corsika::environment::Environment const& env); + ~Interaction(); + + void Init(); + + void SetParticleListStable(const std::vector<particles::Code>); + void SetUnstable(const corsika::particles::Code ); + void SetStable(const corsika::particles::Code ); + + bool WasInitialized() { return fInitialized; } + bool ValidCoMEnergy(corsika::units::si::HEPEnergyType ecm) { + using namespace corsika::units::si; + return (10_GeV < ecm) && (ecm < 1_PeV); + } + + bool CanInteract(const corsika::particles::Code); + void ConfigureLabFrameCollision(const corsika::particles::Code, const corsika::particles::Code, + const corsika::units::si::HEPEnergyType); + std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType> + GetCrossSection(const corsika::particles::Code BeamId, + const corsika::particles::Code TargetId, + const corsika::units::si::HEPEnergyType CoMenergy); + + template <typename Particle, typename Track> + corsika::units::si::GrammageType GetInteractionLength(Particle&, Track&); + + /** + In this function PYTHIA is called to produce one event. The + event is copied (and boosted) into the shower lab frame. + */ + + template <typename Particle, typename Stack> + corsika::process::EProcessReturn DoInteraction(Particle&, Stack&); + + private: + corsika::environment::Environment const& fEnvironment; + corsika::random::RNG& fRNG = + corsika::random::RNGManager::GetInstance().GetRandomStream("pythia"); + Pythia8::Pythia fPythia; + Pythia8::SigmaTotal fSigma; + const bool fInternalDecays = true; + }; + +} // namespace corsika::process::pythia + +#endif diff --git a/Processes/Pythia/Random.cc b/Processes/Pythia/Random.cc new file mode 100644 index 0000000000000000000000000000000000000000..8fcbcf4ee7274ba36252f7969306073f3cffddd5 --- /dev/null +++ b/Processes/Pythia/Random.cc @@ -0,0 +1,20 @@ +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/process/pythia/Random.h> + +namespace corsika::process::pythia { + + double Random::flat() { + std::uniform_real_distribution<double> dist; + return dist(fRNG); + } + +} // namespace corsika::process::pythia diff --git a/Processes/Pythia/Random.h b/Processes/Pythia/Random.h new file mode 100644 index 0000000000000000000000000000000000000000..276fc532ca53ac84b708e8ad12cb16fbaed01c9a --- /dev/null +++ b/Processes/Pythia/Random.h @@ -0,0 +1,33 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_corsika_process_pythia_random_h_ +#define _include_corsika_process_pythia_random_h_ + +#include <Pythia8/Pythia.h> +#include <corsika/random/RNGManager.h> + +namespace corsika::process { + + namespace pythia { + + class Random : public Pythia8::RndmEngine { + double flat(); + + private: + corsika::random::RNG& fRNG = + corsika::random::RNGManager::GetInstance().GetRandomStream("pythia"); + }; + + } // namespace pythia +} // namespace corsika::process + +#endif diff --git a/Processes/Pythia/testPythia.cc b/Processes/Pythia/testPythia.cc new file mode 100644 index 0000000000000000000000000000000000000000..418ff6973b6c51cc0c8a9cc6fa96c06e9c8988a3 --- /dev/null +++ b/Processes/Pythia/testPythia.cc @@ -0,0 +1,177 @@ + +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/process/pythia/Decay.h> +#include <corsika/process/pythia/Interaction.h> +#include <Pythia8/Pythia.h> +#include <corsika/process/pythia/Decay.h> + +#include <corsika/random/RNGManager.h> + +#include <corsika/particles/ParticleProperties.h> + +#include <corsika/geometry/Point.h> +#include <corsika/units/PhysicalUnits.h> + +#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one + // cpp file +#include <catch2/catch.hpp> + +TEST_CASE("Pythia", "[processes]") { + + SECTION("linking pythia") { + using namespace Pythia8; + using std::cout; + using std::endl; + + // Generator. Process selection. LHC initialization. Histogram. + Pythia pythia; + + pythia.readString("Next:numberShowInfo = 0"); + pythia.readString("Next:numberShowProcess = 0"); + pythia.readString("Next:numberShowEvent = 0"); + + pythia.readString("ProcessLevel:all = off"); + + pythia.init(); + + Event& event = pythia.event; + event.reset(); + + pythia.particleData.mayDecay(321, true); + double pz = 100.; + double m = 0.49368; + event.append(321, 1, 0, 0, 0., 0., 100., sqrt(pz * pz + m * m), m); + + if (!pythia.next()) + cout << "decay failed!" << endl; + else + cout << "particles after decay: " << event.size() << endl; + event.list(); + + // loop over final state + for (int i = 0; i < pythia.event.size(); ++i) + if (pythia.event[i].isFinal()) { + cout << "particle: id=" << pythia.event[i].id() << endl; + } + } + + SECTION("pythia interface") { + using namespace corsika; + + const std::vector<particles::Code> particleList = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, + particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; + + random::RNGManager::GetInstance().RegisterRandomStream("pythia"); + + process::pythia::Decay model(particleList); + + model.Init(); + } +} + +#include <corsika/geometry/Point.h> +#include <corsika/geometry/RootCoordinateSystem.h> +#include <corsika/geometry/Vector.h> + +#include <corsika/units/PhysicalUnits.h> + +#include <corsika/particles/ParticleProperties.h> +#include <corsika/setup/SetupStack.h> +#include <corsika/setup/SetupTrajectory.h> + +#include <corsika/environment/Environment.h> +#include <corsika/environment/HomogeneousMedium.h> +#include <corsika/environment/NuclearComposition.h> + +using namespace corsika; +using namespace corsika::units::si; + +TEST_CASE("pythia process"){ + + // setup environment, geometry + environment::Environment env; + auto& universe = *(env.GetUniverse()); + + auto theMedium = environment::Environment::CreateNode<geometry::Sphere>( + geometry::Point{env.GetCoordinateSystem(), 0_m, 0_m, 0_m}, + 1_km * std::numeric_limits<double>::infinity()); + + using MyHomogeneousModel = environment::HomogeneousMedium<environment::IMediumModel>; + theMedium->SetModelProperties<MyHomogeneousModel>( + 1_kg / (1_m * 1_m * 1_m), + environment::NuclearComposition( + std::vector<particles::Code>{particles::Code::Hydrogen}, std::vector<float>{1.})); + + universe.AddChild(std::move(theMedium)); + + const geometry::CoordinateSystem& cs = env.GetCoordinateSystem(); + + geometry::Point const origin(cs, {0_m, 0_m, 0_m}); + geometry::Vector<units::si::SpeedType::dimension_type> v(cs, 0_m / second, 0_m / second, + 1_m / second); + geometry::Line line(origin, v); + geometry::Trajectory<geometry::Line> track(line, 10_s); + + random::RNGManager::GetInstance().RegisterRandomStream("s_rndm"); + + SECTION("pythia decay") { + + setup::Stack stack; + const HEPEnergyType E0 = 10_GeV; + HEPMomentumType P0 = + sqrt(E0 * E0 - particles::PiPlus::GetMass() * particles::PiPlus::GetMass()); + auto plab = corsika::stack::MomentumVector(cs, {0_GeV, 0_GeV, -P0}); + geometry::Point pos(cs, 0_m, 0_m, 0_m); + auto particle = stack.AddParticle( + std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ + particles::Code::PiPlus, E0, plab, pos, 0_ns}); + + const std::vector<particles::Code> particleList = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, + particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; + + random::RNGManager::GetInstance().RegisterRandomStream("pythia"); + + process::pythia::Decay model(particleList); + + model.Init(); + /*[[maybe_unused]] const process::EProcessReturn ret =*/model.DoDecay(particle, + stack); + [[maybe_unused]] const TimeType time = model.GetLifetime(particle); + } + + SECTION("pythia interaction") { + + setup::Stack stack; + const HEPEnergyType E0 = 100_GeV; + HEPMomentumType P0 = + sqrt(E0 * E0 - particles::PiPlus::GetMass() * particles::PiPlus::GetMass()); + auto plab = corsika::stack::MomentumVector(cs, {0_GeV, 0_GeV, -P0}); + geometry::Point pos(cs, 0_m, 0_m, 0_m); + auto particle = stack.AddParticle( + std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ + particles::Code::PiPlus, E0, plab, pos, 0_ns}); + + + process::pythia::Interaction model(env); + + model.Init(); + /*[[maybe_unused]] const process::EProcessReturn ret =*/model.DoInteraction(particle, + stack); + [[maybe_unused]] const GrammageType length = + model.GetInteractionLength(particle, track); + } + +} diff --git a/Processes/Sibyll/Decay.cc b/Processes/Sibyll/Decay.cc index eec1f27f2239f6ba01bc4b77588313a62c6d518a..3cd009c580d10845ea2219b59322dc1855a88295 100644 --- a/Processes/Sibyll/Decay.cc +++ b/Processes/Sibyll/Decay.cc @@ -29,44 +29,36 @@ using Track = Trajectory; namespace corsika::process::sibyll { - Decay::Decay() {} + Decay::Decay(vector<particles::Code> pParticles) + : fTrackedParticles(pParticles) {} Decay::~Decay() { cout << "Sibyll::Decay n=" << fCount << endl; } void Decay::Init() { - setHadronsUnstable(); - setTrackedParticlesStable(); + SetHadronsUnstable(); + SetParticleListStable(fTrackedParticles); } - void Decay::setTrackedParticlesStable() { + void Decay::SetParticleListStable(const vector<particles::Code> particleList) { /* Sibyll is hadronic generator only hadrons decay */ // set particles unstable - setHadronsUnstable(); - // make tracked particles stable + SetHadronsUnstable(); cout << "Interaction: setting tracked hadrons stable.." << endl; - const vector<particles::Code> particleList = { - particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, - particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; - - for (auto p : particleList) { - // set particle stable by setting table value negative - const int sibid = process::sibyll::ConvertToSibyllRaw(p); - s_csydec_.idb[sibid - 1] = (-1) * abs(s_csydec_.idb[sibid - 1]); - } + for (auto p : particleList) Decay::SetStable(p); } - void Decay::setUnstable(const particles::Code pCode) { + void Decay::SetUnstable(const particles::Code pCode) { int s_id = process::sibyll::ConvertToSibyllRaw(pCode); s_csydec_.idb[s_id - 1] = abs(s_csydec_.idb[s_id - 1]); } - void Decay::setStable(const particles::Code pCode) { + void Decay::SetStable(const particles::Code pCode) { int s_id = process::sibyll::ConvertToSibyllRaw(pCode); s_csydec_.idb[s_id - 1] = (-1) * abs(s_csydec_.idb[s_id - 1]); } - void Decay::setAllStable() { + void Decay::SetAllStable() { // name? also makes EM particles stable cout << "Decay: setting all particles stable.." << endl; @@ -83,7 +75,7 @@ namespace corsika::process::sibyll { } } - void Decay::setHadronsUnstable() { + void Decay::SetHadronsUnstable() { // name? also makes EM particles stable @@ -115,7 +107,7 @@ namespace corsika::process::sibyll { using namespace units::si; HEPEnergyType E = p.GetEnergy(); - HEPMassType m = particles::GetMass(p.GetPID()); + HEPMassType m = p.GetMass(); const double gamma = E / m; @@ -159,12 +151,12 @@ namespace corsika::process::sibyll { TimeType const t0 = p.GetTime(); // set all particles/hadrons unstable // setHadronsUnstable(); - setUnstable(pCode); + SetUnstable(pCode); // call sibyll decay cout << "Decay: calling Sibyll decay routine.." << endl; decsib_(); // reset to stable - setStable(pCode); + SetStable(pCode); // print output int print_unit = 6; sib_list_(print_unit); diff --git a/Processes/Sibyll/Decay.h b/Processes/Sibyll/Decay.h index c078af7b8763c4d6df9015177ed764f6a663b460..7e7a202e7c3172577c6a5662d09eb67bbb9433f2 100644 --- a/Processes/Sibyll/Decay.h +++ b/Processes/Sibyll/Decay.h @@ -15,23 +15,26 @@ #include <corsika/particles/ParticleProperties.h> #include <corsika/process/DecayProcess.h> +#include <vector> + namespace corsika::process { namespace sibyll { class Decay : public corsika::process::DecayProcess<Decay> { + std::vector<particles::Code> fTrackedParticles; int fCount = 0; public: - Decay(); + Decay(std::vector<particles::Code>); ~Decay(); void Init(); - void setTrackedParticlesStable(); - void setUnstable(const corsika::particles::Code pCode); - void setStable(const corsika::particles::Code pCode); - void setAllStable(); - void setHadronsUnstable(); + void SetParticleListStable(const std::vector<particles::Code>); + void SetUnstable(const corsika::particles::Code); + void SetStable(const corsika::particles::Code); + void SetAllStable(); + void SetHadronsUnstable(); template <typename Particle> corsika::units::si::TimeType GetLifetime(Particle const& p); diff --git a/Processes/Sibyll/Interaction.cc b/Processes/Sibyll/Interaction.cc index 290c72b2ad4abe36b79a074430aa4c53dd0d01ba..645667f812f972ce76fb97baecdd549a84d88699 100644 --- a/Processes/Sibyll/Interaction.cc +++ b/Processes/Sibyll/Interaction.cc @@ -48,11 +48,46 @@ namespace corsika::process::sibyll { if (!fInitialized) { sibyll_ini_(); + // any decays in sibyll? if yes need to define which particles + if (fInternalDecays) { + // define which particles are passed to corsika, i.e. which particles make it into + // history even very shortlived particles like charm or pi0 are of interest here + const std::vector<particles::Code> HadronsWeWantTrackedByCorsika = { + particles::Code::PiPlus, particles::Code::PiMinus, + particles::Code::Pi0, particles::Code::KMinus, + particles::Code::KPlus, particles::Code::K0Long, + particles::Code::K0Short, particles::Code::SigmaPlus, + particles::Code::SigmaMinus, particles::Code::Lambda0, + particles::Code::Xi0, particles::Code::XiMinus, + particles::Code::OmegaMinus, particles::Code::DPlus, + particles::Code::DMinus, particles::Code::D0, + particles::Code::D0Bar}; + + Interaction::SetParticleListStable(HadronsWeWantTrackedByCorsika); + } + fInitialized = true; } } - tuple<units::si::CrossSectionType, units::si::CrossSectionType, int> + void Interaction::SetParticleListStable( + const std::vector<particles::Code> particleList) { + for (auto p : particleList) Interaction::SetStable(p); + } + + void Interaction::SetUnstable(const particles::Code pCode) { + cout << "Sibyll::Interaction: setting " << pCode << " unstable.." << endl; + int s_id = process::sibyll::ConvertToSibyllRaw(pCode); + s_csydec_.idb[s_id - 1] = abs(s_csydec_.idb[s_id - 1]); + } + + void Interaction::SetStable(const particles::Code pCode) { + cout << "Sibyll::Interaction: setting " << pCode << " stable.." << endl; + int s_id = process::sibyll::ConvertToSibyllRaw(pCode); + s_csydec_.idb[s_id - 1] = (-1) * abs(s_csydec_.idb[s_id - 1]); + } + + tuple<units::si::CrossSectionType, units::si::CrossSectionType> Interaction::GetCrossSection(const particles::Code BeamId, const particles::Code TargetId, const units::si::HEPEnergyType CoMenergy) { @@ -60,23 +95,25 @@ namespace corsika::process::sibyll { double sigProd, sigEla, dummy, dum1, dum3, dum4; double dumdif[3]; const int iBeam = process::sibyll::GetSibyllXSCode(BeamId); + if (!IsValidCoMEnergy(CoMenergy)) { + throw std::runtime_error( + "Interaction: GetCrossSection: CoM energy outside range for Sibyll!"); + } const double dEcm = CoMenergy / 1_GeV; - int iTarget = -1; if (particles::IsNucleus(TargetId)) { - iTarget = particles::GetNucleusA(TargetId); - if (iTarget > 18 || iTarget == 0) + const int iTarget = particles::GetNucleusA(TargetId); + if (iTarget > fMaxTargetMassNumber || iTarget == 0) throw std::runtime_error( "Sibyll target outside range. Only nuclei with A<18 are allowed."); sib_sigma_hnuc_(iBeam, iTarget, dEcm, sigProd, dummy, sigEla); } else if (TargetId == particles::Proton::GetCode()) { sib_sigma_hp_(iBeam, dEcm, dum1, sigEla, sigProd, dumdif, dum3, dum4); - iTarget = 1; } else { // no interaction in sibyll possible, return infinite cross section? or throw? sigProd = std::numeric_limits<double>::infinity(); sigEla = std::numeric_limits<double>::infinity(); } - return std::make_tuple(sigProd * 1_mbarn, sigEla * 1_mbarn, iTarget); + return std::make_tuple(sigProd * 1_mb, sigEla * 1_mb); } template <> @@ -96,14 +133,11 @@ namespace corsika::process::sibyll { // read from cross section code table const bool kInteraction = process::sibyll::CanInteract(corsikaBeamId); - const HEPMassType nucleon_mass = - 0.5 * (particles::Proton::GetMass() + particles::Neutron::GetMass()); - // FOR NOW: assume target is at rest MomentumVector pTarget(rootCS, {0_GeV, 0_GeV, 0_GeV}); // total momentum and energy - HEPEnergyType Elab = p.GetEnergy() + nucleon_mass; + HEPEnergyType Elab = p.GetEnergy() + constants::nucleonMass; MomentumVector pTotLab(rootCS, {0_GeV, 0_GeV, 0_GeV}); pTotLab += p.GetMomentum(); pTotLab += pTarget; @@ -118,7 +152,8 @@ namespace corsika::process::sibyll { << " beam pid:" << p.GetPID() << endl; // TODO: move limits into variables - if (kInteraction && Elab >= 8.5_GeV && ECoM >= 10_GeV) { + // FR: removed && Elab >= 8.5_GeV + if (kInteraction && IsValidCoMEnergy(ECoM)) { // get target from environment /* @@ -132,34 +167,30 @@ namespace corsika::process::sibyll { // determine average interaction length // weighted sum int i = -1; - double avgTargetMassNumber = 0.; - si::CrossSectionType weightedProdCrossSection = 0_mbarn; + si::CrossSectionType weightedProdCrossSection = 0_mb; // get weights of components from environment/medium - const auto w = mediumComposition.GetFractions(); + const auto& w = mediumComposition.GetFractions(); // loop over components in medium for (auto const targetId : mediumComposition.GetComponents()) { i++; cout << "Interaction: get interaction length for target: " << targetId << endl; - auto const [productionCrossSection, elaCrossSection, numberOfNucleons] = + [[maybe_unused]] auto const [productionCrossSection, elaCrossSection] = GetCrossSection(corsikaBeamId, targetId, ECoM); - [[maybe_unused]] auto elaCrossSectionCopy = - elaCrossSection; // ONLY TO AVOID COMPILER WARNING cout << "Interaction: " - << " IntLength: sibyll return (mb): " << productionCrossSection / 1_mbarn + << " IntLength: sibyll return (mb): " << productionCrossSection / 1_mb << endl; weightedProdCrossSection += w[i] * productionCrossSection; - avgTargetMassNumber += w[i] * numberOfNucleons; } cout << "Interaction: " - << "IntLength: weighted CrossSection (mb): " - << weightedProdCrossSection / 1_mbarn << endl; + << "IntLength: weighted CrossSection (mb): " << weightedProdCrossSection / 1_mb + << endl; // calculate interaction length in medium //#warning check interaction length units - GrammageType const int_length = - avgTargetMassNumber * units::constants::u / weightedProdCrossSection; + GrammageType const int_length = mediumComposition.GetAverageMassNumber() * + units::constants::u / weightedProdCrossSection; cout << "Interaction: " << "interaction length (g/cm2): " << int_length / (0.001_kg) * 1_cm * 1_cm << endl; @@ -203,10 +234,8 @@ namespace corsika::process::sibyll { // define target // for Sibyll is always a single nucleon - auto constexpr nucleon_mass = - 0.5 * (particles::Proton::GetMass() + particles::Neutron::GetMass()); // FOR NOW: target is always at rest - const auto eTargetLab = 0_GeV + nucleon_mass; + const auto eTargetLab = 0_GeV + constants::nucleonMass; const auto pTargetLab = MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); const FourVector PtargLab(eTargetLab, pTargetLab); @@ -225,7 +254,7 @@ namespace corsika::process::sibyll { // define target kinematics in lab frame // define boost to and from CoM frame // CoM frame definition in Sibyll projectile: +z - COMBoost const boost(PprojLab, nucleon_mass); + COMBoost const boost(PprojLab, constants::nucleonMass); // just for show: // boost projecticle @@ -266,7 +295,7 @@ namespace corsika::process::sibyll { for (size_t i = 0; i < compVec.size(); ++i) { auto const targetId = compVec[i]; - [[maybe_unsused]] const auto [sigProd, sigEla, nNuc] = + [[maybe_unsused]] const auto [sigProd, sigEla] = GetCrossSection(corsikaBeamId, targetId, Ecm); cross_section_of_components[i] = sigProd; } @@ -283,7 +312,7 @@ namespace corsika::process::sibyll { if (IsNucleus(targetCode)) targetSibCode = GetNucleusA(targetCode); if (targetCode == particles::Proton::GetCode()) targetSibCode = 1; cout << "Interaction: sibyll code: " << targetSibCode << endl; - if (targetSibCode > 18 || targetSibCode < 1) + if (targetSibCode > fMaxTargetMassNumber || targetSibCode < 1) throw std::runtime_error( "Sibyll target outside range. Only nuclei with A<18 or protons are " "allowed."); @@ -294,7 +323,10 @@ namespace corsika::process::sibyll { cout << "Interaction: " << " DoInteraction: E(GeV):" << eProjectileLab / 1_GeV << " Ecm(GeV): " << Ecm / 1_GeV << endl; - if (eProjectileLab < 8.5_GeV || Ecm < 10_GeV) { + if (Ecm > GetMaxEnergyCoM()) + throw std::runtime_error("Interaction::DoInteraction: CoM energy too high!"); + // FR: removed eProjectileLab < 8.5_GeV || + if (Ecm < GetMinEnergyCoM()) { cout << "Interaction: " << " DoInteraction: should have dropped particle.. " << "THIS IS AN ERROR" << endl; @@ -307,8 +339,7 @@ namespace corsika::process::sibyll { // running sibyll, filling stack sibyll_(kBeam, targetSibCode, sqs); // running decays - // setTrackedParticlesStable(); - decsib_(); + if (fInternalDecays) decsib_(); // print final state int print_unit = 6; sib_list_(print_unit); diff --git a/Processes/Sibyll/Interaction.h b/Processes/Sibyll/Interaction.h index 4157738ffadfd0ee0809277f482e938c94b62d07..33fe9001a65c20294d7b04077befdee12165080c 100644 --- a/Processes/Sibyll/Interaction.h +++ b/Processes/Sibyll/Interaction.h @@ -32,14 +32,23 @@ namespace corsika::process::sibyll { void Init(); + void SetParticleListStable(const std::vector<particles::Code>); + void SetUnstable(const corsika::particles::Code); + void SetStable(const corsika::particles::Code); + bool WasInitialized() { return fInitialized; } - bool ValidCoMEnergy(corsika::units::si::HEPEnergyType ecm) { - using namespace corsika::units::si; - return (10_GeV < ecm) && (ecm < 1_PeV); + bool IsValidCoMEnergy(corsika::units::si::HEPEnergyType ecm) { + return (fMinEnergyCoM <= ecm) && (ecm <= fMaxEnergyCoM); + } + int GetMaxTargetMassNumber() { return fMaxTargetMassNumber; } + corsika::units::si::HEPEnergyType GetMinEnergyCoM() { return fMinEnergyCoM; } + corsika::units::si::HEPEnergyType GetMaxEnergyCoM() { return fMaxEnergyCoM; } + bool IsValidTarget(corsika::particles::Code TargetId) { + return (corsika::particles::GetNucleusA(TargetId) < fMaxTargetMassNumber) && + corsika::particles::IsNucleus(TargetId); } - std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType, - int> + std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType> GetCrossSection(const corsika::particles::Code BeamId, const corsika::particles::Code TargetId, const corsika::units::si::HEPEnergyType CoMenergy); @@ -58,6 +67,13 @@ namespace corsika::process::sibyll { private: corsika::random::RNG& fRNG = corsika::random::RNGManager::GetInstance().GetRandomStream("s_rndm"); + + const bool fInternalDecays = true; + const corsika::units::si::HEPEnergyType fMinEnergyCoM = + 10. * 1e9 * corsika::units::si::electronvolt; + const corsika::units::si::HEPEnergyType fMaxEnergyCoM = + 1.e6 * 1e9 * corsika::units::si::electronvolt; + const int fMaxTargetMassNumber = 18; }; } // namespace corsika::process::sibyll diff --git a/Processes/Sibyll/NuclearInteraction.cc b/Processes/Sibyll/NuclearInteraction.cc index 23ec7510df721c468b044e502a996d3fbc0ecc98..c657a2cbf6e6d4df42002496b72023eee79b76f0 100644 --- a/Processes/Sibyll/NuclearInteraction.cc +++ b/Processes/Sibyll/NuclearInteraction.cc @@ -22,6 +22,8 @@ #include <corsika/setup/SetupStack.h> #include <corsika/setup/SetupTrajectory.h> +#include <set> + using std::cout; using std::endl; using std::tuple; @@ -39,6 +41,7 @@ namespace corsika::process::sibyll { NuclearInteraction::~NuclearInteraction() { cout << "Nuclib::NuclearInteraction n=" << fCount << " Nnuc=" << fNucCount << endl; + fTargetComponentsIndex.clear(); } void NuclearInteraction::Init() { @@ -49,25 +52,134 @@ namespace corsika::process::sibyll { // TODO: safe to run multiple initializations? if (!fHadronicInteraction.WasInitialized()) fHadronicInteraction.Init(); + // check compatibility of energy ranges, someone could try to use low-energy model.. + if (!fHadronicInteraction.IsValidCoMEnergy(GetMinEnergyPerNucleonCoM()) || + !fHadronicInteraction.IsValidCoMEnergy(GetMaxEnergyPerNucleonCoM())) + throw std::runtime_error( + "NuclearInteraction: hadronic interaction model incompatible!"); + // initialize nuclib // TODO: make sure this does not overlap with sibyll nuc_nuc_ini_(); + + // initialize cross sections + InitializeNuclearCrossSections(); + } + + void NuclearInteraction::InitializeNuclearCrossSections() { + using namespace corsika::particles; + using namespace units::si; + + auto& universe = *(fEnvironment.GetUniverse()); + + auto const allElementsInUniverse = std::invoke([&]() { + std::set<particles::Code> allElementsInUniverse; + auto collectElements = [&](auto& vtn) { + if (auto const mp = vtn.GetModelPropertiesPtr(); + mp != nullptr) { // do not query Universe it self, it has no ModelProperties + auto const& comp = mp->GetNuclearComposition().GetComponents(); + for (auto const c : comp) allElementsInUniverse.insert(c); + } + }; + universe.walk(collectElements); + return allElementsInUniverse; + }); + + cout << "NuclearInteraction: initializing nuclear cross sections..." << endl; + + // loop over target components, at most 4!! + int k = -1; + for (auto& ptarg : allElementsInUniverse) { + ++k; + cout << "NuclearInteraction: init target component: " << ptarg << endl; + const int ib = GetNucleusA(ptarg); + if (!fHadronicInteraction.IsValidTarget(ptarg)) { + cout << "NuclearInteraction::InitializeNuclearCrossSections: target nucleus? id=" + << ptarg << endl; + throw std::runtime_error( + " target can not be handled by hadronic interaction model! "); + } + fTargetComponentsIndex.insert(std::pair<Code, int>(ptarg, k)); + // loop over energies, fNEnBins log. energy bins + for (int i = 0; i < GetNEnergyBins(); ++i) { + // hard coded energy grid, has to be aligned to definition in signuc2!!, no + // comment.. + const units::si::HEPEnergyType Ecm = pow(10., 1. + 1. * i) * 1_GeV; + // get p-p cross sections + auto const protonId = Code::Proton; + auto const [siginel, sigela] = + fHadronicInteraction.GetCrossSection(protonId, protonId, Ecm); + const double dsig = siginel / 1_mb; + const double dsigela = sigela / 1_mb; + // loop over projectiles, mass numbers from 2 to fMaxNucleusAProjectile + for (int j = 1; j < fMaxNucleusAProjectile; ++j) { + const int jj = j + 1; + double sig_out, dsig_out, sigqe_out, dsigqe_out; + sigma_mc_(jj, ib, dsig, dsigela, fNSample, sig_out, dsig_out, sigqe_out, + dsigqe_out); + // write to table + cnucsignuc_.sigma[j][k][i] = sig_out; + cnucsignuc_.sigqe[j][k][i] = sigqe_out; + } + } + } + cout << "NuclearInteraction: cross sections for " << fTargetComponentsIndex.size() + << " components initialized!" << endl; + for (auto& ptarg : allElementsInUniverse) { + cout << "cross section table: " << ptarg << endl; + PrintCrossSectionTable(ptarg); + } + } + + void NuclearInteraction::PrintCrossSectionTable(corsika::particles::Code pCode) { + using namespace corsika::particles; + const int k = fTargetComponentsIndex.at(pCode); + Code pNuclei[] = {Code::Helium, Code::Lithium7, Code::Oxygen, + Code::Neon, Code::Argon, Code::Iron}; + cout << "en/A "; + for (auto& j : pNuclei) cout << std::setw(9) << j; + cout << endl; + + // loop over energy bins + for (int i = 0; i < GetNEnergyBins(); ++i) { + cout << " " << i << " "; + for (auto& n : pNuclei) { + auto const j = GetNucleusA(n); + cout << " " << std::setprecision(5) << std::setw(8) + << cnucsignuc_.sigma[j - 1][k][i]; + } + cout << endl; + } + } + + units::si::CrossSectionType NuclearInteraction::ReadCrossSectionTable( + const int ia, particles::Code pTarget, units::si::HEPEnergyType elabnuc) { + using namespace corsika::particles; + using namespace units::si; + const int ib = fTargetComponentsIndex.at(pTarget) + 1; // table index in fortran + auto const ECoMNuc = sqrt(2. * corsika::units::constants::nucleonMass * elabnuc); + if (ECoMNuc < GetMinEnergyPerNucleonCoM() || ECoMNuc > GetMaxEnergyPerNucleonCoM()) + throw std::runtime_error("NuclearInteraction: energy outside tabulated range!"); + const double e0 = elabnuc / 1_GeV; + double sig; + cout << "ReadCrossSectionTable: " << ia << " " << ib << " " << e0 << endl; + signuc2_(ia, ib, e0, sig); + cout << "ReadCrossSectionTable: sig=" << sig << endl; + return sig * 1_mb; } - // TODO: remove number of nucleons, avg target mass is available in environment + // TODO: remove elastic cross section? template <> tuple<units::si::CrossSectionType, units::si::CrossSectionType> NuclearInteraction::GetCrossSection(Particle& p, const particles::Code TargetId) { using namespace units::si; - double sigProd; - auto const pCode = p.GetPID(); - if (pCode != particles::Code::Nucleus) + if (p.GetPID() != particles::Code::Nucleus) throw std::runtime_error( "NuclearInteraction: GetCrossSection: particle not a nucleus!"); - auto const iBeam = p.GetNuclearA(); - HEPEnergyType LabEnergyPerNuc = p.GetEnergy() / iBeam; - cout << "NuclearInteraction: GetCrossSection: called with: beamNuclA= " << iBeam + auto const iBeamA = p.GetNuclearA(); + HEPEnergyType LabEnergyPerNuc = p.GetEnergy() / iBeamA; + cout << "NuclearInteraction: GetCrossSection: called with: beamNuclA= " << iBeamA << " TargetId= " << TargetId << " LabEnergyPerNuc= " << LabEnergyPerNuc / 1_GeV << endl; @@ -75,41 +187,23 @@ namespace corsika::process::sibyll { // TODO: for now assumes air with hard coded composition // extend to arbitrary mixtures, requires smarter initialization // get nuclib projectile code: nucleon number - if (iBeam > 56 || iBeam < 2) { + if (iBeamA > GetMaxNucleusAProjectile() || iBeamA < 2) { cout << "NuclearInteraction: beam nucleus outside allowed range for NUCLIB!" << endl - << "A=" << iBeam << endl; + << "A=" << iBeamA << endl; throw std::runtime_error( "NuclearInteraction: GetCrossSection: beam nucleus outside allowed range for " "NUCLIB!"); } - const double dElabNuc = LabEnergyPerNuc / 1_GeV; - // TODO: these limitations are still sibyll specific. - // available target nuclei depends on the hadronic interaction model and the - // initialization - if (dElabNuc < 10.) - throw std::runtime_error("NuclearInteraction: GetCrossSection: energy too low!"); - - // TODO: these limitations are still sibyll specific. - // available target nuclei depends on the hadronic interaction model and the - // initialization - if (particles::IsNucleus(TargetId)) { - const int iTarget = particles::GetNucleusA(TargetId); - if (iTarget > 18 || iTarget == 0) - throw std::runtime_error( - "Sibyll target outside range. Only nuclei with A<18 are allowed."); - cout << "NuclearInteraction: calling signuc.." << endl; - cout << "WARNING: using hard coded cross section for Nucleus-Air with " - "SIBYLL! (fix me!)" - << endl; - // TODO: target id is not used because cross section is still hard coded and fixed - // to air. - signuc_(iBeam, dElabNuc, sigProd); - cout << "cross section: " << sigProd << endl; - return std::make_tuple(sigProd * 1_mbarn, 0_mbarn); + if (fHadronicInteraction.IsValidTarget(TargetId)) { + auto const sigProd = ReadCrossSectionTable(iBeamA, TargetId, LabEnergyPerNuc); + cout << "cross section (mb): " << sigProd / 1_mb << endl; + return std::make_tuple(sigProd, 0_mb); + } else { + throw std::runtime_error("target outside range."); } - return std::make_tuple(std::numeric_limits<double>::infinity() * 1_mbarn, - std::numeric_limits<double>::infinity() * 1_mbarn); + return std::make_tuple(std::numeric_limits<double>::infinity() * 1_mb, + std::numeric_limits<double>::infinity() * 1_mb); } template <> @@ -135,14 +229,12 @@ namespace corsika::process::sibyll { "projectiles should use NuclearStackExtension!"); // read from cross section code table - const HEPMassType nucleon_mass = - 0.5 * (particles::Proton::GetMass() + particles::Neutron::GetMass()); // FOR NOW: assume target is at rest corsika::stack::MomentumVector pTarget(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV}); // total momentum and energy - HEPEnergyType Elab = p.GetEnergy() + nucleon_mass; + HEPEnergyType Elab = p.GetEnergy() + constants::nucleonMass; int const nuclA = p.GetNuclearA(); auto const ElabNuc = p.GetEnergy() / nuclA; @@ -153,7 +245,7 @@ namespace corsika::process::sibyll { // calculate cm. energy const HEPEnergyType ECoM = sqrt( (Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy - auto const ECoMNN = sqrt(2. * ElabNuc * nucleon_mass); + auto const ECoMNN = sqrt(2. * ElabNuc * constants::nucleonMass); cout << "NuclearInteraction: LambdaInt: \n" << " input energy: " << Elab / 1_GeV << endl << " input energy CoM: " << ECoM / 1_GeV << endl @@ -165,7 +257,8 @@ namespace corsika::process::sibyll { // energy limits // TODO: values depend on hadronic interaction model !! this is sibyll specific - if (ElabNuc >= 8.5_GeV && ECoMNN >= 10_GeV) { + if (ElabNuc >= 8.5_GeV && ECoMNN >= fMinEnergyPerNucleonCoM && + ECoMNN < fMaxEnergyPerNucleonCoM) { // get target from environment /* @@ -179,7 +272,7 @@ namespace corsika::process::sibyll { // determine average interaction length // weighted sum int i = -1; - si::CrossSectionType weightedProdCrossSection = 0_mbarn; + si::CrossSectionType weightedProdCrossSection = 0_mb; // get weights of components from environment/medium const auto w = mediumComposition.GetFractions(); // loop over components in medium @@ -192,13 +285,13 @@ namespace corsika::process::sibyll { [[maybe_unused]] auto elaCrossSectionCopy = elaCrossSection; cout << "NuclearInteraction: " - << "IntLength: nuclib return (mb): " << productionCrossSection / 1_mbarn + << "IntLength: nuclib return (mb): " << productionCrossSection / 1_mb << endl; weightedProdCrossSection += w[i] * productionCrossSection; } cout << "NuclearInteraction: " << "IntLength: weighted CrossSection (mb): " - << weightedProdCrossSection / 1_mbarn << endl; + << weightedProdCrossSection / 1_mb << endl; // calculate interaction length in medium GrammageType const int_length = mediumComposition.GetAverageMassNumber() * @@ -261,7 +354,8 @@ namespace corsika::process::sibyll { // projectile nucleon number const int kAProj = p.GetNuclearA(); // GetNucleusA(ProjId); - if (kAProj > 56) throw std::runtime_error("Projectile nucleus too large for NUCLIB!"); + if (kAProj > GetMaxNucleusAProjectile()) + throw std::runtime_error("Projectile nucleus too large for NUCLIB!"); // kinematics // define projectile nucleus @@ -284,10 +378,8 @@ namespace corsika::process::sibyll { // define target // always a nucleon - auto constexpr nucleon_mass = - 0.5 * (particles::Proton::GetMass() + particles::Neutron::GetMass()); // target is always at rest - const auto eTargetNucLab = 0_GeV + nucleon_mass; + const auto eTargetNucLab = 0_GeV + constants::nucleonMass; const auto pTargetNucLab = corsika::stack::MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); const FourVector PtargNucLab(eTargetNucLab, pTargetNucLab); @@ -301,7 +393,7 @@ namespace corsika::process::sibyll { HEPEnergyType EcmNN = PtotNN4.GetNorm(); cout << "NuclearInteraction: nuc-nuc cm energy: " << EcmNN / 1_GeV << endl; - if (!fHadronicInteraction.ValidCoMEnergy(EcmNN)) { + if (!fHadronicInteraction.IsValidCoMEnergy(EcmNN)) { cout << "NuclearInteraction: nuc-nuc. CoM energy too low for hadronic " "interaction model!" << endl; @@ -309,7 +401,7 @@ namespace corsika::process::sibyll { } // define boost to NUCLEON-NUCLEON frame - COMBoost const boost(PprojNucLab, nucleon_mass); + COMBoost const boost(PprojNucLab, constants::nucleonMass); // boost projecticle auto const PprojNucCoM = boost.toCoM(PprojNucLab); @@ -346,11 +438,10 @@ namespace corsika::process::sibyll { auto const targetId = compVec[i]; cout << "target component: " << targetId << endl; cout << "beam id: " << beamId << endl; - const auto [sigProd, sigEla, nNuc] = + const auto [sigProd, sigEla] = fHadronicInteraction.GetCrossSection(beamId, targetId, EcmNN); cross_section_of_components[i] = sigProd; [[maybe_unused]] auto sigElaCopy = sigEla; // ONLY TO AVOID COMPILER WARNINGS - [[maybe_unused]] auto sigNucCopy = nNuc; // ONLY TO AVOID COMPILER WARNINGS } const auto targetCode = @@ -365,10 +456,8 @@ namespace corsika::process::sibyll { if (IsNucleus(targetCode)) kATarget = GetNucleusA(targetCode); if (targetCode == particles::Proton::GetCode()) kATarget = 1; cout << "NuclearInteraction: nuclib target code: " << kATarget << endl; - if (kATarget > 18 || kATarget < 1) - throw std::runtime_error( - "Sibyll target outside range. Only nuclei with A<18 or protons are " - "allowed."); + if (!fHadronicInteraction.IsValidTarget(targetCode)) + throw std::runtime_error("target outside range. "); // end of target sampling // superposition @@ -376,11 +465,10 @@ namespace corsika::process::sibyll { // get nucleon-nucleon cross section // (needed to determine number of nucleon-nucleon scatterings) const auto protonId = particles::Proton::GetCode(); - const auto [prodCrossSection, elaCrossSection, dum] = + const auto [prodCrossSection, elaCrossSection] = fHadronicInteraction.GetCrossSection(protonId, protonId, EcmNN); - [[maybe_unused]] auto dumCopy = dum; // ONLY TO AVOID COMPILER WARNING - const double sigProd = prodCrossSection / 1_mbarn; - const double sigEla = elaCrossSection / 1_mbarn; + const double sigProd = prodCrossSection / 1_mb; + const double sigEla = elaCrossSection / 1_mb; // sample number of interactions (only input variables, output in common cnucms) // nuclear multiple scattering according to glauber (r.i.p.) int_nuc_(kATarget, kAProj, sigProd, sigEla); @@ -412,7 +500,7 @@ namespace corsika::process::sibyll { fragm_(kATarget, kAProj, nIntProj, impactPar, nFragments, AFragments); // this should not occur but well :) - if (nFragments > 60) + if (nFragments > GetMaxNFragments()) throw std::runtime_error("Number of nuclear fragments in NUCLIB exceeded!"); cout << "number of fragments: " << nFragments << endl; diff --git a/Processes/Sibyll/NuclearInteraction.h b/Processes/Sibyll/NuclearInteraction.h index 920904edaf85a89b6a4fde91ac5ef7ec3f24fb7b..1a6449d2c4d924fcfe3a9363c4c553a433ea34c5 100644 --- a/Processes/Sibyll/NuclearInteraction.h +++ b/Processes/Sibyll/NuclearInteraction.h @@ -35,7 +35,19 @@ namespace corsika::process::sibyll { NuclearInteraction(corsika::process::sibyll::Interaction& hadint); ~NuclearInteraction(); void Init(); - + void InitializeNuclearCrossSections(); + void PrintCrossSectionTable(corsika::particles::Code); + corsika::units::si::CrossSectionType ReadCrossSectionTable( + const int, corsika::particles::Code, corsika::units::si::HEPEnergyType); + corsika::units::si::HEPEnergyType GetMinEnergyPerNucleonCoM() { + return fMinEnergyPerNucleonCoM; + } + corsika::units::si::HEPEnergyType GetMaxEnergyPerNucleonCoM() { + return fMaxEnergyPerNucleonCoM; + } + int GetMaxNucleusAProjectile() { return fMaxNucleusAProjectile; } + int GetMaxNFragments() { return fMaxNFragments; } + int GetNEnergyBins() { return fNEnBins; } template <typename Particle> std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType> GetCrossSection(Particle& p, const corsika::particles::Code TargetId); @@ -48,8 +60,19 @@ namespace corsika::process::sibyll { private: corsika::process::sibyll::Interaction& fHadronicInteraction; + std::map<corsika::particles::Code, int> fTargetComponentsIndex; corsika::random::RNG& fRNG = corsika::random::RNGManager::GetInstance().GetRandomStream("s_rndm"); + const int fNSample = 500; // number of samples in MC estimation of cross section + const int fMaxNucleusAProjectile = 56; + const int fNEnBins = 6; + const int fMaxNFragments = 60; + // energy limits defined by table used for cross section in signuc.f + // 10**1 GeV to 10**6 GeV + const corsika::units::si::HEPEnergyType fMinEnergyPerNucleonCoM = + 10. * 1e9 * corsika::units::si::electronvolt; + const corsika::units::si::HEPEnergyType fMaxEnergyPerNucleonCoM = + 1.e6 * 1e9 * corsika::units::si::electronvolt; }; } // namespace corsika::process::sibyll diff --git a/Processes/Sibyll/ParticleConversion.h b/Processes/Sibyll/ParticleConversion.h index 90e0b612c49fa312dfa1aabe95eb580ebb0df67e..0d67fc830eb3975ed6cc47aaff3972ca846124d4 100644 --- a/Processes/Sibyll/ParticleConversion.h +++ b/Processes/Sibyll/ParticleConversion.h @@ -14,8 +14,6 @@ #include <corsika/particles/ParticleProperties.h> -#include <bitset2/bitset2.hpp> - #include <map> namespace corsika::process::sibyll { @@ -25,14 +23,6 @@ namespace corsika::process::sibyll { #include <corsika/process/sibyll/Generated.inc> - bool constexpr KnownBySibyll(corsika::particles::Code pCode) { - return isKnown[static_cast<corsika::particles::CodeIntType>(pCode)]; - } - - bool constexpr CanInteract(corsika::particles::Code pCode) { - return canInteract[static_cast<corsika::particles::CodeIntType>(pCode)]; - } - SibyllCode constexpr ConvertToSibyll(corsika::particles::Code pCode) { return static_cast<SibyllCode>( corsika2sibyll[static_cast<corsika::particles::CodeIntType>(pCode)]); @@ -50,6 +40,10 @@ namespace corsika::process::sibyll { return corsika2sibyllXStype[static_cast<corsika::particles::CodeIntType>(pCode)]; } + bool constexpr CanInteract(corsika::particles::Code pCode) { + return GetSibyllXSCode(pCode) != 0; + } + } // namespace corsika::process::sibyll #endif diff --git a/Processes/Sibyll/code_generator.py b/Processes/Sibyll/code_generator.py index e1cfcbfaf84e4d04aff4ed35b324daacf1fc66c1..cb7d0cb2471c004b84345a544698defbd3e9c9f0 100755 --- a/Processes/Sibyll/code_generator.py +++ b/Processes/Sibyll/code_generator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu +# (c) Copyright 2018-2019 CORSIKA Project, corsika-project@lists.kit.edu # # See file AUTHORS for a list of contributors. # @@ -31,7 +31,6 @@ def read_sibyll_codes(filename, particle_db): identifier, sib_code, canInteractFlag, xsType = line.split() try: particle_db[identifier]["sibyll_code"] = int(sib_code) - particle_db[identifier]["sibyll_canInteract"] = int(canInteractFlag) particle_db[identifier]["sibyll_xsType"] = int(xsType) except KeyError as e: raise Exception("Identifier '{:s}' not found in particle_db".format(identifier)) @@ -101,54 +100,6 @@ def generate_sibyll2corsika(particle_db) : string += "};\n" return string - - -# generates the bitset for the flag whether Sibyll knows the particle -def generate_known_particle(particle_db): - num_particles = len(particle_db) - num_bytes = num_particles // 32 + 1 - string = "Bitset2::bitset2<{:d}> constexpr isKnown{{ std::array<uint32_t, {:d}>{{{{\n".format(num_particles, num_bytes) - - numeric = 0 - for identifier, pData in reversed(particle_db.items()): - handledBySibyll = int("sibyll_code" in pData) & 0x1 - numeric = (numeric << 1) | handledBySibyll - - while numeric != 0: - low = numeric & 0xFFFFFFFF - numeric = numeric >> 32 - string += " 0x{:0x},\n".format(low) - - string += "}}};\n" - return string - - - -# generates the bitset for the flag whether Sibyll can use particle as projectile -def generate_interacting_particle(particle_db): - num_particles = len(particle_db) - num_bytes = num_particles // 32 + 1 - string = "Bitset2::bitset2<{:d}> constexpr canInteract{{ std::array<uint32_t, {:d}>{{{{\n".format(num_particles, num_bytes) - #string = "std::array<bool, {:d}> constexpr corsika2sibyll = {{\n".format(num_particles) - - numeric = 0 - for identifier, pData in reversed(particle_db.items()): - can = 0 - if 'sibyll_canInteract' in pData: - if pData['sibyll_canInteract'] > 0: - can = 0x1 - numeric = (numeric << 1) | can - - while numeric != 0: - low = numeric & 0xFFFFFFFF - numeric = numeric >> 32 - string += " 0x{:0x},\n".format(low) - - string += "}}};\n" - return string - - - if __name__ == "__main__": if len(sys.argv) != 3: print("usage: {:s} <particle_db.pkl> <sibyll_codes.dat>".format(sys.argv[0]), file=sys.stderr) @@ -163,7 +114,5 @@ if __name__ == "__main__": print("// this file is automatically generated\n// edit at your own risk!\n", file=f) print(generate_sibyll_enum(particle_db), file=f) print(generate_corsika2sibyll(particle_db), file=f) - print(generate_known_particle(particle_db), file=f) print(generate_sibyll2corsika(particle_db), file=f) - print(generate_interacting_particle(particle_db), file=f) print(generate_corsika2sibyll_xsType(particle_db), file=f) diff --git a/Processes/Sibyll/nuclib.h b/Processes/Sibyll/nuclib.h index e4b89b52bed8bab3f1898183b2398c5ef3c2d3b3..44e86f50ef825bc8bfd7d98763d86be1ab903fa4 100644 --- a/Processes/Sibyll/nuclib.h +++ b/Processes/Sibyll/nuclib.h @@ -34,6 +34,12 @@ extern struct { */ extern struct { double ppp[60][3]; } fragments_; +// COMMON /cnucsignuc/SIGMA(6,4,56), SIGQE(6,4,56) +extern struct { + double sigma[56][4][6]; + double sigqe[56][4][6]; +} cnucsignuc_; + // NUCLIB // subroutine to initiate nuclib @@ -46,5 +52,10 @@ void int_nuc_(const int&, const int&, const double&, const double&); void fragm_(const int&, const int&, const int&, const double&, int&, int*); void signuc_(const int&, const double&, double&); + +void signuc2_(const int&, const int&, const double&, double&); + +void sigma_mc_(const int&, const int&, const double&, const double&, const int&, double&, + double&, double&, double&); } #endif diff --git a/Processes/Sibyll/sibyll_codes.dat b/Processes/Sibyll/sibyll_codes.dat index fc8515886b07c5f5a8f7a9307a7f06b88a65366c..08209d0f9f27249932c850199dc7cb5c12c92ef9 100644 --- a/Processes/Sibyll/sibyll_codes.dat +++ b/Processes/Sibyll/sibyll_codes.dat @@ -30,16 +30,16 @@ KPlus 9 1 3 KMinus 10 1 3 KStarPlus 28 0 0 KStarMinus 29 0 0 -DPlus 59 1 0 -DMinus 60 1 0 +DPlus 59 1 3 +DMinus 60 1 3 DStarPlus 78 0 0 DStarMinus 79 0 0 -D0 71 1 0 -D0Bar 72 1 0 +D0 71 1 3 +D0Bar 72 1 3 DStar0 80 0 0 DStar0Bar 81 0 0 -DsPlus 74 1 0 -DsMinus 75 1 0 +DsPlus 74 1 3 +DsMinus 75 1 3 DStarSPlus 76 0 0 DStarSMinus 77 0 0 EtaC 73 0 0 diff --git a/Processes/Sibyll/signuc.f b/Processes/Sibyll/signuc.f index b21bce8cbb4893c90b1bfca4f5c1a0ca617fcb4f..b88f2ae0bd37f76bcb693692ac0fea0911b053bf 100644 --- a/Processes/Sibyll/signuc.f +++ b/Processes/Sibyll/signuc.f @@ -274,3 +274,46 @@ C ADD INELASTIC AND QUASI-ELASTIC CROSS-SECTIONS RETURN END + + + SUBROUTINE SIGNUC2(IA,IB,E0,SSIGNUC) + +C----------------------------------------------------------------------- +C SIG(MA) NUC(LEUS) 2 +C INPUT: IA : projectile mass number +C IB : position in cross section table for target nucleus +C specified when tables are filled +C E0 : Energy per nucleon in GeV in the lab. +C OUTPUT: inelastic cross section +C----------------------------------------------------------------------- + IMPLICIT NONE + DOUBLE PRECISION SIGMA,SIGQE + COMMON /cnucsignuc/SIGMA(6,4,56), SIGQE(6,4,56) + DIMENSION AA(6) + DOUBLE PRECISION AA,DA,AMIN,ABEAM,S1,S2,ASQS + DOUBLE PRECISION E0,SSIGNUC + INTEGER IA,IB,J,JE,NE + DOUBLE PRECISION QUAD_INT + EXTERNAL QUAD_INT + SAVE + DATA NE /6/, AMIN /1.D0/, DA /1.D0/ + DATA AA /1.D0,2.D0,3.D0,4.D0,5.D0,6.D0/ + +C ENERGY E0 IN GEV + ASQS = 0.5D0*LOG10(1.876D0*E0) + JE = MIN( INT( (ASQS-AMIN)/DA )+1, NE-2 ) + ABEAM = DBLE(IA) +C INELASTIC CROSS-SECTION + S1 = QUAD_INT( ASQS, AA(JE),AA(JE+1),AA(JE+2), + + SIGMA(JE,IB,IA),SIGMA(JE+1,IB,IA), + + SIGMA(JE+2,IB,IA) ) +C QUASI ELASTIC CROSS-SECTION + S2 = QUAD_INT( ASQS, AA(JE),AA(JE+1),AA(JE+2), + + SIGQE(JE,IB,IA),SIGQE(JE+1,IB,IA), + + SIGQE(JE+2,IB,IA) ) +C ADD INELASTIC AND QUASI-ELASTIC CROSS-SECTIONS + SSIGNUC = S1 + S2 + + RETURN + END + diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc index 8f9bf45120562a7e31a12683e26e8f3a56931450..7a02fa2888fc7d85bc55f81df1aad2abd3557bc9 100644 --- a/Processes/Sibyll/testSibyll.cc +++ b/Processes/Sibyll/testSibyll.cc @@ -41,12 +41,6 @@ TEST_CASE("Sibyll", "[processes]") { REQUIRE(process::sibyll::ConvertToSibyllRaw(particles::Proton::GetCode()) == 13); } - SECTION("KnownBySibyll") { - REQUIRE(process::sibyll::KnownBySibyll(particles::Electron::GetCode())); - - REQUIRE_FALSE(process::sibyll::KnownBySibyll(particles::XiPrimeC0::GetCode())); - } - SECTION("canInteractInSibyll") { REQUIRE(process::sibyll::CanInteract(particles::Proton::GetCode())); @@ -174,7 +168,11 @@ TEST_CASE("SibyllInterface", "[processes]") { corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ particles::Code::Proton, E0, plab, pos, 0_ns}); - Decay model; + const std::vector<particles::Code> particleList = { + particles::Code::PiPlus, particles::Code::PiMinus, particles::Code::KPlus, + particles::Code::KMinus, particles::Code::K0Long, particles::Code::K0Short}; + + Decay model(particleList); model.Init(); /*[[maybe_unused]] const process::EProcessReturn ret =*/model.DoDecay(particle, diff --git a/Stack/NuclearStackExtension/NuclearStackExtension.h b/Stack/NuclearStackExtension/NuclearStackExtension.h index 11923aba8497123b6ac9175b73ab6b1b27aa9725..6c1fd2b801120bbe0c22c6c76d22ccadc652f4af 100644 --- a/Stack/NuclearStackExtension/NuclearStackExtension.h +++ b/Stack/NuclearStackExtension/NuclearStackExtension.h @@ -159,7 +159,24 @@ namespace corsika::stack { int GetNuclearZ() const { return GetStackData().GetNuclearZ(GetIndex()); } /// @} - // int GetNucleusRef() const { return GetStackData().GetNucleusRef(GetIndex()); } + /** + * Overwrite normal GetParticleMass function with nuclear version + */ + corsika::units::si::HEPMassType GetMass() const { + if (InnerParticleInterface<StackIteratorInterface>::GetPID() == + corsika::particles::Code::Nucleus) + return corsika::particles::GetNucleusMass(GetNuclearA(), GetNuclearZ()); + return InnerParticleInterface<StackIteratorInterface>::GetMass(); + } + /** + * Overwirte normal GetChargeNumber function with nuclear version + **/ + int16_t GetChargeNumber() const { + if (InnerParticleInterface<StackIteratorInterface>::GetPID() == + corsika::particles::Code::Nucleus) + return GetNuclearZ(); + return InnerParticleInterface<StackIteratorInterface>::GetChargeNumber(); + } protected: void SetNucleusRef(const int vR) { GetStackData().SetNucleusRef(GetIndex(), vR); } diff --git a/Stack/SuperStupidStack/SuperStupidStack.h b/Stack/SuperStupidStack/SuperStupidStack.h index 365a45aa963c235b34b5e762cd79192af40b56c2..1610aede7ec0cad53a8e5e92d14ffba5ce1ab973 100644 --- a/Stack/SuperStupidStack/SuperStupidStack.h +++ b/Stack/SuperStupidStack/SuperStupidStack.h @@ -117,10 +117,22 @@ namespace corsika::stack { corsika::units::si::TimeType GetTime() const { return GetStackData().GetTime(GetIndex()); } + /** + * @name derived quantities + * + * @{ + */ corsika::geometry::Vector<corsika::units::si::dimensionless_d> GetDirection() const { return GetMomentum() / GetEnergy(); } + corsika::units::si::HEPMassType GetMass() const { + return corsika::particles::GetMass(GetPID()); + } + int16_t GetChargeNumber() const { + return corsika::particles::GetChargeNumber(GetPID()); + } + ///@} }; /** diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index fb6c08fce7c2fcc869b9c51853db0b0388ca5613..c7f90c5b9bdb6ad21d4f918e22a8f973abd838eb 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -9,4 +9,3 @@ target_include_directories (CORSIKAthirdparty SYSTEM install (DIRECTORY phys DESTINATION include/ThirdParty/) install (DIRECTORY catch2 DESTINATION include/ThirdParty/) -install (DIRECTORY bitset2 DESTINATION include/ThirdParty/) diff --git a/ThirdParty/bitset2/LICENSE.txt b/ThirdParty/bitset2/LICENSE.txt deleted file mode 100644 index 36b7cd93cdfbac762f5be4c6ce276df2ea6305c2..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/LICENSE.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/ThirdParty/bitset2/README.md b/ThirdParty/bitset2/README.md deleted file mode 100644 index 5e7f2f9e83cf2034030d0f7ff4761c13fbaff86f..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/README.md +++ /dev/null @@ -1,232 +0,0 @@ -# bitset2: bitset improved - -|Note| -|----| -|This version of bitset2 is for C++17. For C++14 checkout the corresponding [branch](https://github.com/ClaasBontus/bitset2/tree/cpp14).| - -Bitset2::bitset2 is a header only library. It provides the same functionality as [std::bitset](http://en.cppreference.com/w/cpp/utility/bitset) with the -following extentions/changes. - - -Focus was set on having as many functions -implemented as [constexpr](http://en.cppreference.com/w/cpp/language/constexpr) -as possible. Moreover a second template parameter (with appropriate default) -allows control of the underlying data structure (see below). -* Copy and move constructors are specified constexpr. -* Additional constexpr constructor `bitset2( std::array<T,N> const & )`, where `T` needs not necessarily be equal to `base_t`. `T` has to be an unsigned integral type. -* Conversion from and to `std::bitset`. -* Operators implemented as constexpr are `~`, `==`, `!=`, `|`, `&`, `^`, `<<` (shift left), `>>` (shift right), `[]` (bit access). -* Non-const operators implemented as constexpr are `<<=`, `>>=`, `|=`, `&=`, `^=` -* Functions implemented as constexpr are `test`, `none`, `any`, `all`, `count`, `to_ulong`, `to_ullong`. -* Non-const functions implemented as constexpr are `set`, `reset`, `flip`. -* Additional constexpr operator `+` for adding two bitset2 objects. -* Additional constexpr operators `++`, `--`, `+=`. -* Additional constexpr operators `<`, `>`, `<=`, `>=`. -* Additional constexpr functions `rotate_left` and `rotate_right` for binary rotations. -* Additional constexpr member functions `rotate_left` and `rotate_right`. -* Additional member function `to_hex_string()` (see below). -* Additional constexpr member function `test_set( size_t bit, bool value= true )`, which sets or clears the specified bit and returns its previous state. Throws `out_of_range` if bit >= N. -* Additional constexpr function `difference`, which computes the set difference (`bs1 & ~bs2`) of two bitset2 objects. -* Additional constexpr member function `difference`. -* Additional constexpr member functions `find_first()` and `find_next(size_t)` returning the index of the first (next) bit set. Returning npos if all (remaining) bits are false. -* Additional constexpr function `complement2(bs)` computing the [two's complement](https://en.wikipedia.org/wiki/Two%27s_complement) (~bs +1). -* Additional constexpr member function `complement2`. -* Additional constexpr function `reverse`, which returns argument with bits reversed. -* Additional constexpr member function `reverse`. -* Additional constexpr function `convert_to<n>` for converting an *m*-bit bitset2 into an *n*-bit bitset2. -* Additional constexpr function `convert_to<n,T>` for converting an *m*-bit bitset2 into an *n*-bit bitset2 with `base_t=T`. -* Constexpr member function `data()` gives read access to the underlying `array<base_t,N>`. Here element with index zero is the least significant word. -* Additional constexpr functions `zip_fold_and` and `zip_fold_or`. See below for details. - -## Examples -```.cpp -#include <iostream> -#include <array> -#include <cassert> -#include "bitset2.hpp" - -template<size_t n_bits> -using BS2= Bitset2::bitset2<n_bits>; - -int main() -{ - using bs_128= BS2<128>; - using base_t_128= bs_128::base_t; - constexpr std::array<base_t_128,2> - ar1{{ ~(base_t_128(0)), base_t_128(0xFEDCBA) }}; - constexpr bs_128 b1{ ar1 }; - constexpr auto b1_add= b1 + b1; - constexpr auto b1_shft= b1 << 1; // binary shift - static_assert( b1_add == b1_shft, "" ); - - std::cout << b1.to_hex_string() // 0000000000fedcbaffffffffffffffff - << "\n" - << b1_add.to_hex_string() // 0000000001fdb975fffffffffffffffe - << "\n"; - - BS2<12> b2; - for( size_t c= 0; c < 12; c += 2 ) b2[c]= true; - auto b3= ~b2; - std::cout << b2 << "\n"; // 010101010101 - std::cout << b2.flip() << "\n"; // 101010101010 - assert( b2 == b3 ); - - BS2<7> const b4{ "1110000" }; - auto const b5= Bitset2::rotate_left( b4, 3 ); - std::cout << b4 << "\n" // 1110000 - << b5 << "\n"; // 0000111 - - BS2<7> b6{ "1010010" }; - b6.reverse(); - std::cout << b6 << "\n"; // 0100101 -} -``` - -The following example illustrates how -[non-const constexpr](https://stackoverflow.com/q/43592862/3876684) -operators and functions are useful for writing constexpr functions. -It converts between [gray](https://en.wikipedia.org/wiki/Gray_code) -and binary coding. - -```.cpp -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -binary_to_gray( Bitset2::bitset2<N,T> const &bs ) -{ return bs ^ (bs >> 1); } - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -gray_to_binary( Bitset2::bitset2<N,T> bs ) -{ - Bitset2::bitset2<N,T> mask= bs >> 1; - for( ; !mask.none(); mask >>= 1 ) bs ^= mask; - return bs; -} // gray_to_binary - -int main() -{ - using ULLONG= unsigned long long; - constexpr std::array<ULLONG,2> arr_01a{{ 0xFEFDFCFBFAF9F8F7ull, 1ull }}; - constexpr Bitset2::bitset2<129> bs_01a{ arr_01a }; - constexpr auto gray_01a= binary_to_gray( bs_01a ); - constexpr auto bin_01a= gray_to_binary( gray_01a ); - - static_assert( bs_01a == bin_01a, "" ); -} -``` - -## Template parameters and underlying data type -`bitset2` is declared as -```.cpp -template< size_t N, class T > -class bitset2; -``` -`N` is the number of bits and `T` has to be an unsigned -[integral type](http://en.cppreference.com/w/cpp/types/is_integral). Data -represented by `bitset2` objects are stored in elements of type -`std::array<T,n_array>`. - -`T` defaults -to `uint8_t`, `uint16_t`, or `uint32_t` if `N` bits fit into these integers -(and the type is supported by the system). -`T` defaults to `unsigned long long` otherwise. The following aliases and -constants are public within `bitset2`: -* `using base_t= T;` -* `size_t n_array;` Number of words in underlying array -* `using array_t= std::array<T,n_array>;` Underlying data type - -## to_hex_string -Function `to_hex_string` takes - as an optional argument - an element of type -`hex_params`, which is defined as -```.cpp -template< class CharT = char, - class Traits = std::char_traits<CharT>, - class Allocator = std::allocator<CharT> > -struct hex_params -{ - using str_t= std::basic_string<CharT,Traits,Allocator>; - - CharT zeroCh= CharT( '0' ); - CharT aCh= CharT( 'a' ); - bool leadingZeroes= true; - bool nonEmpty= true; - str_t prefix; -}; -``` -It allows fine tuning the outcome of the function. In the following -examples the output is shown in the comments. -```.cpp -bitset2<16> b16_a( "0000101000011111" ); -bitset2<16> b16_b; -std::cout - << b16_a.to_hex_string() << '\n' // 0a1f - << b16_a.to_hex_string( hex_params<>{'0', 'A', false, true, "0x"}) // 0xA1F - << '\n' - << b16_b.to_hex_string() << '\n' // 0000 - << b16_b.to_hex_string( hex_params<>{'0', 'a', false, false, "0X"}) // 0X - << '\n'; -``` - -## zip\_fold\_* -Functions `zip_fold_and(bs1,bs2,f)` and `zip_fold_or(bs1,bs2,f)` expect two -variables of type `bitset2` and a functional object `f`. -The latter must accept two variables of type `base_t` and return a `bool`. -`zip_fold_*` are mapped over the underlying -`std::array<base_t,n>`s. They will -[short-circuit](http://en.cppreference.com/w/cpp/language/operator_logical) -if possible, which can result in performance advantages. -`zip_fold_and` returns `true` if `f` -returns `true` for each pair of `base_t`s, while `zip_fold_or` returns `true` -if `f` returns `true` for at least one pair of `base_t`s. -In other words `zip_fold_and` and `zip_fold_or` are similar to -[`std::inner_product(...,BinOp1 op1,BinOp2 op2)`](http://en.cppreference.com/w/cpp/algorithm/inner_product) -with `op1` set to `&&` and `||`, resp. - -For instance `is_subset_of` as proposed in [p0125r0](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0125r0.html) -can be implemented as follows. -```.cpp -template<size_t N,class T> -constexpr -bool -is_subset_of( Bitset2::bitset2<N,T> const &bs1, - Bitset2::bitset2<N,T> const &bs2 ) noexcept -{ - using base_t= T; - return Bitset2::zip_fold_and( bs1, bs2, - []( base_t v1, base_t v2 ) noexcept - // Any bit unset in v2 must not be set in v1 - { return (v1 & ~v2) == 0; } ); -} - -constexpr Bitset2::bitset2<7> b7_a( 0b1000101ull ); -constexpr Bitset2::bitset2<7> b7_b( 0b1010101ull ); -static_assert( is_subset_of( b7_a, b7_b), "" ); -``` - -Similarly an `unequal` function can be defined as -```.cpp -template<size_t N,class T> -bool -unequal( Bitset2::bitset2<N,T> const &bs1, Bitset2::bitset2<N,T> const &bs2 ) -{ - using base_t= T; - return Bitset2::zip_fold_or( bs1, bs2, - []( base_t v1, base_t v2 ) noexcept - { return v1 != v2; } ); -} -``` - -## Trivia -The following code shows a counter based on a 128-bit integer. If the -counter gets incremented once at each nanosecond, you have to wait for -overflow for *only* [1.078 * 10<sup>22</sup> years](http://www.wolframalpha.com/input/?i=2%5E128+nanoseconds). -```.cpp -Bitset2::bitset2<128> c; -for( ;; ++c ) {} -``` - -## Caveats -* bitset2 requires a C++17 compliant compiler. -* Tested with gcc 7 and clang 5. diff --git a/ThirdParty/bitset2/bitset2.hpp b/ThirdParty/bitset2/bitset2.hpp deleted file mode 100644 index 0b9c95aadfa809715104fd79c248a8382d694a30..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/bitset2.hpp +++ /dev/null @@ -1,646 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#ifndef BITSET2_CB_HPP -#define BITSET2_CB_HPP - - -#include "detail/hex_params.hpp" -#include "detail/select_base_t.hpp" -#include "detail/hash.hpp" -#include "detail/array_access.hpp" -#include "detail/array_funcs.hpp" -#include "detail/array_add.hpp" -#include "detail/array_ops.hpp" -#include "detail/array_complement2.hpp" -#include "detail/array2array.hpp" -#include "detail/bitset2_impl.hpp" - -#include <bitset> -#include <climits> -#include <cstdint> -#include <array> -#include <stdexcept> -#include <utility> -#include <string> -#include <functional> -#include <type_traits> - - - -namespace Bitset2 -{ - - - -template<size_t N, - class T= Bitset2::detail::select_base_t<N>, - class Enabled=void> class bitset2; - -template<size_t N,class T> -class bitset2<N,T, - typename std::enable_if< std::is_integral<T>::value - && std::is_unsigned<T>::value>::type> -: public detail::bitset2_impl<N,T> -{ - enum : size_t { base_t_n_bits= detail::bitset2_impl<N,T>::base_t_n_bits }; -public: - using array_t= typename detail::bitset2_impl<N,T>::array_t; - using ULLONG_t= typename detail::bitset2_impl<N,T>::ULLONG_t; - using base_t= T; - using detail::bitset2_impl<N,T>::n_array; - - enum : size_t { npos= detail::h_types<T>::npos }; - - class reference - { - friend class bitset2; - reference() noexcept {} - reference( bitset2<N,T> *ptr, size_t bit ) noexcept - : m_ptr( ptr ) - , m_bit( bit ) - {} - bitset2<N,T> *m_ptr= nullptr; - size_t m_bit; - public: - ~reference() noexcept {} - reference& operator=( bool x ) noexcept - { - m_ptr->set_noexcept( m_bit, x ); - return *this; - } - reference& operator=( reference const & r ) noexcept - { - m_ptr->set_noexcept( m_bit, bool( r ) ); - return *this; - } - reference& flip() noexcept - { - m_ptr->flip_noexcept( m_bit ); - return *this; - } - operator bool() const noexcept - { return m_ptr->test_noexcept(m_bit); } - bool operator~() const noexcept - { return !bool(*this); } - }; // class reference - - - /* ------------------------------------------------------------- */ - constexpr - bitset2() noexcept - : detail::bitset2_impl<N,T>() - {} - - constexpr - bitset2( bitset2 const & ) noexcept= default; - - constexpr - bitset2( bitset2 && ) noexcept= default; - - constexpr - bitset2 & - operator=( bitset2 const & ) noexcept= default; - - constexpr - bitset2 & - operator=( bitset2 && ) noexcept= default; - - explicit - bitset2( const std::bitset<N> &bs ) noexcept - : detail::bitset2_impl<N,T>( bs ) - {} - - explicit - constexpr - bitset2( ULLONG_t v ) noexcept - : detail::bitset2_impl<N,T>( v ) - {} - - template<size_t n,class Tsrc> - explicit - constexpr - bitset2( std::array<Tsrc,n> const & value ) noexcept - : detail::bitset2_impl<N,T>( value ) - {} - - template< class CharT, class Traits, class Alloc > - explicit - bitset2( std::basic_string<CharT,Traits,Alloc> const - & str, - typename std::basic_string<CharT,Traits,Alloc>::size_type - pos = 0, - typename std::basic_string<CharT,Traits,Alloc>::size_type - n = std::basic_string<CharT,Traits,Alloc>::npos, - CharT zero= CharT('0'), - CharT one= CharT('1') ) - : detail::bitset2_impl<N,T>( str, pos, n, zero, one ) - {} - - - template< class CharT > - explicit - bitset2( const CharT *str, - typename std::basic_string<CharT>::size_type - n= std::basic_string<CharT>::npos, - CharT zero= CharT('0'), - CharT one= CharT('1') ) - : detail::bitset2_impl<N,T>( n == std::basic_string<CharT>::npos - ? std::basic_string<CharT>( str ) - : std::basic_string<CharT>( str, n ), - 0, n, zero, one ) - {} - /* ------------------------------------------------------------- */ - - - //**************************************************** - - /// Bitwise NOT - constexpr - bitset2 - operator~() const noexcept - { return bitset2(detail::array_ops<N,T>( 0 ).flip(this->data())); } - - constexpr - bool - operator[]( size_t bit ) const noexcept - { return detail::bitset2_impl<N,T>::operator[]( bit ); } - - reference - operator[]( size_t bit ) noexcept - { return reference( this, bit ); } - - constexpr - bitset2 & - operator<<=( size_t n_shift ) noexcept - { - detail::array_ops<N,T>( n_shift ).shift_left_assgn( this->get_data() ); - return *this; - } - - constexpr - bitset2 & - operator>>=( size_t n_shift ) noexcept - { - detail::array_ops<N,T>( n_shift ).shift_right_assgn( this->get_data() ); - return *this; - } - - constexpr - bitset2 & - rotate_left( size_t n_rot ) noexcept - { - this->get_data()= detail::array_ops<N,T>(n_rot).rotate_left( this->data() ); - return *this; - } - - constexpr - bitset2 & - rotate_right( size_t n_rot ) noexcept - { - this->get_data()= detail::array_ops<N,T>( N - ( n_rot % N ) ) - .rotate_left( this->data() ); - return *this; - } - - constexpr - bitset2 & - reverse() noexcept - { - this->get_data()= detail::array_ops<N,T>( 0 ).reverse( this->data() ); - return *this; - } - - /// Computes two's complement - constexpr - bitset2 & - complement2() noexcept - { - detail::array_complement2<N,T>().comp2_assgn( this->get_data() ); - return *this; - } - - constexpr - bitset2 & - operator+=( bitset2 const &bs2 ) noexcept - { - detail::array_add<N,T>().add_assgn(this->get_data(), bs2.data()); - return *this; - } - - constexpr - bitset2 & - operator++() noexcept - { - detail::array_ops<N,T>(0).increment( this->get_data() ); - return *this; - } - - constexpr - bitset2 - operator++(int) noexcept - { - bitset2 tmp( *this ); - operator++(); - return tmp; - } - - constexpr - bitset2 & - operator--() noexcept - { - detail::array_ops<N,T>(0).decrement( this->get_data() ); - return *this; - } - - constexpr - bitset2 - operator--(int) noexcept - { - bitset2 tmp( *this ); - operator--(); - return tmp; - } - - constexpr - bitset2 & - operator|=( bitset2 const & v2 ) noexcept - { - detail::array_funcs<bitset2::n_array,T>() - .bitwise_or_assgn(this->get_data(), v2.data() ); - return *this; - } - - constexpr - bitset2 & - operator&=( bitset2 const & v2 ) noexcept - { - detail::array_funcs<bitset2::n_array,T>() - .bitwise_and_assgn( this->get_data(), v2.data() ); - return *this; - } - - constexpr - bitset2 & - operator^=( bitset2 const & v2 ) noexcept - { - detail::array_funcs<bitset2::n_array,T>() - .bitwise_xor_assgn( this->get_data(), v2.data() ); - return *this; - } - - /// Computes the set difference, i.e. *this &= ~v2 - constexpr - bitset2 & - difference( bitset2 const & v2 ) noexcept - { - detail::array_funcs<bitset2::n_array,T>() - .bitwise_setdiff_assgn( this->get_data(), v2.data() ); - return *this; - } - - constexpr - bitset2 & - set() noexcept - { detail::bitset2_impl<N,T>::set(); return *this; } - - constexpr - bitset2 & - set( size_t bit, bool value= true ) - { detail::bitset2_impl<N,T>::set( bit, value ); return *this; } - - constexpr - bitset2 & - reset() noexcept - { detail::bitset2_impl<N,T>::reset(); return *this; } - - constexpr - bitset2 & - reset( size_t bit ) - { - if( bit >= N ) throw std::out_of_range( "bitset2: reset out of range" ); - return set( bit, false ); - } - - /// \brief Sets the specified bit if value==true, - /// clears it otherwise. Returns the previous state of the bit. - constexpr - bool - test_set( size_t bit, bool value= true ) - { return detail::bitset2_impl<N,T>::test_set( bit, value ); } - - constexpr - bitset2 & - flip() noexcept - { detail::bitset2_impl<N,T>::flip(); return *this; } - - constexpr - bitset2 & - flip( size_t bit ) - { detail::bitset2_impl<N,T>::flip( bit ); return *this; } - - constexpr std::size_t size() const noexcept { return N; } - - template<class CharT = char, - class Traits = std::char_traits<CharT>, - class Allocator = std::allocator<CharT> > - std::basic_string<CharT,Traits,Allocator> - to_string( CharT zero = CharT('0'), CharT one = CharT('1') ) const - { - std::basic_string<CharT,Traits,Allocator> ret_val; - ret_val.reserve( N ); - for( size_t ct= N; ct > 0; ) - { - --ct; - ret_val += this->operator[]( ct ) ? one : zero; - } - return ret_val; - } // to_string - - template<class CharT = char, - class Traits = std::char_traits<CharT>, - class Allocator = std::allocator<CharT>, - typename std::enable_if<base_t_n_bits % 4 == 0>::type* = nullptr > - std::basic_string<CharT,Traits,Allocator> - to_hex_string( hex_params<CharT,Traits,Allocator> const ¶ms= - hex_params<CharT,Traits,Allocator>{} ) const - { - using arr_acc= detail::array_access<N,T>; - arr_acc a_a; - constexpr auto div_four= arr_acc::div_four; - constexpr auto mod_four= arr_acc::mod_four; - constexpr auto n_char= div_four + ( mod_four > 0 ); - - auto const zeroCh= params.zeroCh; - auto const aCh= params.aCh; - - std::basic_string<CharT,Traits,Allocator> ret_val; - ret_val.reserve( n_char + params.prefix.size() ); - ret_val= params.prefix; - size_t ct= n_char; - if( !params.leadingZeroes ) - { - for( ; ct > 0; --ct ) - { - auto const val= a_a.get_four_bits( this->data(), 4 * ct - 1 ); - if( val != 0 ) break; - } - } - if( ct == 0 && params.nonEmpty ) ret_val += zeroCh; - for( ; ct > 0; --ct ) - { - auto const val= a_a.get_four_bits( this->data(), 4 * ct - 1 ); - CharT const c= - ( val < 10 ) ? ( zeroCh + val ) : ( aCh + ( val - 10 ) ); - ret_val += c; - } - return ret_val; - } // to_hex_string - -}; // class bitset2 - - -template<size_t N, class T> -constexpr -bitset2<N,T> -rotate_left( bitset2<N,T> const & bs, size_t n_rot ) noexcept -{ - return - bitset2<N,T>( detail::array_ops<N,T>( n_rot ).rotate_left( bs.data() ) ); -} - - -template<size_t N, class T> -constexpr -bitset2<N,T> -rotate_right( bitset2<N,T> const & bs, size_t n_rot ) noexcept -{ - return - bitset2<N,T>( detail::array_ops<N,T>( N - ( n_rot % N ) ). - rotate_left( bs.data() ) ); -} - - -/// Computes the set difference, i.e. bs1 & ~bs2 -template<size_t N, class T> -constexpr -bitset2<N,T> -difference( bitset2<N,T> const & bs1, bitset2<N,T> const & bs2 ) noexcept -{ - return - bitset2<N,T>( detail::array_funcs<bitset2<N,T>::n_array,T>() - .bitwise_setdiff( bs1.data(), bs2.data() ) ); -} - - -/// Returns bs with bits reversed -template<size_t N, class T> -constexpr -bitset2<N,T> -reverse( bitset2<N,T> const & bs ) noexcept -{ return bitset2<N,T>( detail::array_ops<N,T>( 0 ).reverse( bs.data() ) ); } - - -/// Computes the two's complement -template<size_t N, class T> -constexpr -bitset2<N,T> -complement2( bitset2<N,T> const & bs ) noexcept -{ return bitset2<N,T>( detail::array_complement2<N,T>().comp2(bs.data()) ); } - - -/// Converts an M-bit bitset2 to an N-bit bitset2. -template<size_t N,class T1,size_t M, class T2> -constexpr -bitset2<N,T1> -convert_to( bitset2<M,T2> const & bs ) noexcept -{ - using a2a= - detail::array2array<bitset2<N,T1>::n_array,bitset2<M,T2>::n_array,T1,T2>; - return - bitset2<N,T1>(a2a()(detail::bit_chars<N,T1>::hgh_bit_pattern, bs.data())); -} - - -/// Converts an M-bit bitset2 to an N-bit bitset2. -template<size_t N,size_t M, class T> -constexpr -bitset2<N,T> -convert_to( bitset2<M,T> const & bs ) noexcept -{ return bitset2<N,T>( bs.data() ); } - - -/// \brief Returns true if f returns true for each pair -/// of base_t=T values in bs1 and bs2. f should be a binary function -/// taking two base_t values and returning bool. -/// zip_fold_and does short circuit if possible. -template<size_t N, class F, class T> -constexpr -bool -zip_fold_and( bitset2<N,T> const & bs1, bitset2<N,T> const & bs2, - F f ) noexcept(noexcept( f( T(0), T(0) ) )) -{ - return - detail::array_funcs<bitset2<N,T>::n_array,T>().zip_fold_and(bs1.data(), - bs2.data(), f); -} - - -/// \brief Returns true if f returns true for at least one pair -/// of base_t=T values in bs1 and bs2. f should be a binary function -/// taking two base_t values and returning bool. -/// zip_fold_or does short circuit if possible. -template<size_t N, class F,class T> -constexpr -bool -zip_fold_or( bitset2<N,T> const & bs1, bitset2<N,T> const & bs2, - F f ) noexcept(noexcept( f( T(0), T(0) ) )) -{ - return - detail::array_funcs<bitset2<N,T>::n_array,T>().zip_fold_or( bs1.data(), - bs2.data(), f ); -} - - -} // namespace Bitset2 - - - - -/// Stream output -template <class CharT, class Traits, size_t N,class T> -std::basic_ostream<CharT, Traits>& -operator<<( std::basic_ostream<CharT, Traits> & os, - Bitset2::bitset2<N,T> const & x ) -{ - for( size_t ct= N; ct > 0; ) - { - --ct; - os << ( x[ct] ? "1" : "0" ); - } - return os; -} - -/// Stream input -template <class CharT, class Traits, size_t N,class T> -std::basic_istream<CharT, Traits>& -operator>>( std::basic_istream<CharT, Traits> & is, - Bitset2::bitset2<N,T> & x ) -{ - std::bitset<N> bs; - is >> bs; - x= Bitset2::bitset2<N,T>( bs ); - return is; -} - - - -/// Shift left -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator<<( Bitset2::bitset2<N,T> const & bs, size_t n_shift ) noexcept -{ - return - Bitset2::bitset2<N,T>( Bitset2::detail::array_ops<N,T>( n_shift ) - .shift_left( bs.data() ) ); -} - - -/// Shift right -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator>>( Bitset2::bitset2<N,T> const & bs, size_t n_shift ) noexcept -{ - return - Bitset2::bitset2<N,T>( Bitset2::detail::array_ops<N,T>( n_shift ) - .shift_right( bs.data() ) ); -} - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator|( Bitset2::bitset2<N,T> const & bs1, - Bitset2::bitset2<N,T> const & bs2 ) noexcept -{ - return - Bitset2::bitset2<N,T>( - Bitset2::detail::array_funcs<Bitset2::bitset2<N,T>::n_array,T>() - .bitwise_or( bs1.data(), bs2.data() ) ); -} - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator&( Bitset2::bitset2<N,T> const & bs1, - Bitset2::bitset2<N,T> const & bs2 ) noexcept -{ - return - Bitset2::bitset2<N,T>( - Bitset2::detail::array_funcs<Bitset2::bitset2<N,T>::n_array,T>() - .bitwise_and( bs1.data(), bs2.data() ) ); -} - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator^( Bitset2::bitset2<N,T> const & bs1, - Bitset2::bitset2<N,T> const & bs2 ) noexcept -{ - return - Bitset2::bitset2<N,T>( - Bitset2::detail::array_funcs<Bitset2::bitset2<N,T>::n_array,T>() - .bitwise_xor( bs1.data(), bs2.data() ) ); -} - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -operator+( Bitset2::bitset2<N,T> const & bs1, - Bitset2::bitset2<N,T> const & bs2 ) noexcept -{ - return - Bitset2::bitset2<N,T>( - Bitset2::detail::array_add<N,T>().add( bs1.data(), bs2.data() ) ); -} - - -namespace std -{ - template<size_t N,class T> - struct hash<Bitset2::bitset2<N,T> > - { - private: - enum : size_t - { n_array= Bitset2::detail::bitset2_impl<N,T>::n_array }; - - Bitset2::detail::hash_impl<n_array,T> m_func; - - public: - using argument_type= Bitset2::bitset2<N,T>; - using result_type= - typename Bitset2::detail::hash_impl<n_array,T>::result_type; - - result_type operator()( argument_type const& bs ) const - { return m_func( bs.data() ); } - }; // struct hash - -} // namespace std - - -#endif // BITSET2_CB_HPP diff --git a/ThirdParty/bitset2/detail/array2array.hpp b/ThirdParty/bitset2/detail/array2array.hpp deleted file mode 100644 index 618af64eeef50fd5bda55b94867f14d572fd8afa..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array2array.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY2ARRAY_CB_HPP -#define BITSET2_ARRAY2ARRAY_CB_HPP - - -#include "h_types.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - -/// \brief Convert std::array<Tsrc,src_n> to std::array<Ttrgt,trgt_n> -template<size_t trgt_n, size_t src_n, class Ttrgt, class Tsrc> -struct array2array -{ - using h_t_trgt= h_types<Ttrgt>; - using h_t_src= h_types<Tsrc>; - using trgt_array_t= typename h_t_trgt::template array_t<trgt_n>; - using src_array_t= typename h_t_src:: template array_t<src_n>; - - enum : size_t - { trgt_base_n_bits= h_t_trgt::base_t_n_bits - , src_base_n_bits= h_t_src:: base_t_n_bits - }; - - enum : bool - { small_to_large= ( src_base_n_bits < trgt_base_n_bits ) }; - - enum : size_t - { ts_div= small_to_large ? trgt_base_n_bits / src_base_n_bits - : src_base_n_bits / trgt_base_n_bits }; - - enum : Tsrc - { h_all_set= Tsrc( Ttrgt(~Ttrgt(0)) ) }; - - /// Applies pttrn to most significant entry in result - constexpr - trgt_array_t - operator()( Ttrgt pttrn, src_array_t const &src ) const noexcept - { - static_assert( ( small_to_large && trgt_base_n_bits % src_base_n_bits == 0) - || (!small_to_large && src_base_n_bits % trgt_base_n_bits == 0), - "Conversion between arrays of these types not supported" ); - return small_to_large - ? conv_small_to_large( pttrn, src, std::make_index_sequence<trgt_n-1>() ) - : conv_large_to_small( pttrn, src, std::make_index_sequence<trgt_n-1>() ); - } - - - template<size_t ... S1> - constexpr - trgt_array_t - conv_small_to_large( Ttrgt pttrn, - src_array_t const &src, - std::index_sequence<S1...> ) const noexcept - { - return {{ get_from_smaller( S1, src, S1 * ts_div )..., - Ttrgt( get_from_smaller( trgt_n-1, src, (trgt_n-1) * ts_div ) - & pttrn ) }}; - } - - template<size_t ... S1> - constexpr - trgt_array_t - conv_large_to_small( Ttrgt pttrn, - src_array_t const &src, - std::index_sequence<S1...> ) const noexcept - { - return - {{ get_from_larger( S1 / ts_div, S1 % ts_div, src )..., - Ttrgt( get_from_larger((trgt_n-1) / ts_div, (trgt_n-1) % ts_div, src) - & pttrn ) }}; - } - - constexpr - Ttrgt - get_from_smaller( size_t trgt_idx, - src_array_t const &src, - size_t src_idx, - size_t src_ct= 0, - Ttrgt so_far= Ttrgt(0) ) const noexcept - { - return ( src_ct >= ts_div || src_idx >= src_n ) - ? so_far - : get_from_smaller( trgt_idx, src, src_idx + 1, src_ct + 1, - so_far | Ttrgt( Ttrgt(src[src_idx]) - << (src_base_n_bits * src_ct) ) ); - } - - constexpr - Ttrgt - get_from_larger( size_t div_val, - size_t mod_val, - src_array_t const &src ) const noexcept - { - return ( div_val >= src_n ) ? Ttrgt(0) - : Ttrgt(Tsrc( src[div_val] >> (mod_val*trgt_base_n_bits) ) & h_all_set ); - } -}; // struct array2array - - - -} // namespace detail -} // namespace Bitset2 - - - -#endif // BITSET2_ARRAY2ARRAY_CB_HPP diff --git a/ThirdParty/bitset2/detail/array2u_long_t.hpp b/ThirdParty/bitset2/detail/array2u_long_t.hpp deleted file mode 100644 index ec2ddc4ca8d736efea1b44abe733964640649b79..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array2u_long_t.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#ifndef BITSET2_ARRAY2U_LONG_T_CB_HPP -#define BITSET2_ARRAY2U_LONG_T_CB_HPP - -#include "bit_chars.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - /// \brief Takes a std::array 'arr' and returns a variable 'x' of type Tlong. - /// Bits in 'x' are set if corresponding bits in 'arr' are set. - template<size_t N, class T, class Tlong> - struct array2u_long_t - { - using base_t= T; - using b_c= bit_chars<N,T>; - - enum : size_t - { n_bits= N - , base_t_n_bits= b_c::base_t_n_bits - , long_t_n_bits= sizeof( Tlong ) * CHAR_BIT - , n_array= b_c::n_array - , div_val= long_t_n_bits / base_t_n_bits - , mod_val= long_t_n_bits % base_t_n_bits - , use_vals= ce_min( div_val + (mod_val!=0), n_array ) - , bit_diff= mod_val == 0 ? 0 : ( base_t_n_bits - mod_val ) - }; - - enum : base_t - { allset= base_t( ~base_t(0) ) - , h_pttrn= use_vals < n_array ? allset : ce_right_shift( allset, bit_diff ) - , i_pttrn= base_t( ~h_pttrn ) - }; - - using array_t= typename h_types<T>::template array_t<n_array>; - - constexpr - Tlong - operator()( array_t const & arr ) const noexcept - { - return - base_t_n_bits >= long_t_n_bits ? Tlong( arr[0] ) - : combine( Tlong(0), arr, 0 ); - } - - /// \brief Returns true if arr cannot be converted to Tlong. - constexpr - bool - check_overflow( array_t const & arr ) const noexcept - { return N <= long_t_n_bits ? false : check_impl( arr, use_vals - 1 ); } - - - - constexpr - Tlong - combine( Tlong v, array_t const & arr, size_t idx ) const noexcept - { - return ( idx >= use_vals ) ? v - : idx + 1 == use_vals - ? Tlong( v + take_v( arr, idx, h_pttrn ) ) - : combine( Tlong( v + take_v( arr, idx ) ), arr, idx + 1 ); - } - - constexpr - Tlong - take_v( array_t const & arr, size_t idx, base_t pttrn= allset ) const noexcept - { return ce_left_shift( Tlong( arr[idx] & pttrn ), idx * base_t_n_bits ); } - - constexpr - bool - check_impl( array_t const & arr, size_t idx ) const noexcept - { - return idx >= n_array ? false - : ( ( take_check( arr, idx ) != base_t(0) ) - || check_impl( arr, idx + 1 ) ); - } - - constexpr - base_t - take_check( array_t const & arr, size_t idx ) const noexcept - { return arr[idx] & ( idx + 1 == use_vals ? i_pttrn : allset ); } - - }; // struct array2u_long_t - - -} // namespace detail -} // namespace Bitset2 - - - - - - - -#endif // BITSET2_ARRAY2U_LONG_T_CB_HPP diff --git a/ThirdParty/bitset2/detail/array_access.hpp b/ThirdParty/bitset2/detail/array_access.hpp deleted file mode 100644 index a4e42b492eb3c246078fc088f5fe720c036511f6..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array_access.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY_ACCESS_CB_HPP -#define BITSET2_ARRAY_ACCESS_CB_HPP - -#include "bit_chars.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - /// \brief array_access is used for getting bunches of 4 bits, which is - /// needed when creating hex-strings - template<size_t N,class T> - struct array_access - { - using base_t= T; - using b_chars= bit_chars<N,T>; - enum : size_t { base_t_n_bits= b_chars::base_t_n_bits - , n_array= b_chars::n_array - }; - enum : size_t { div_four= N / 4 - , mod_four= N % 4 - }; - using array_t= typename h_types<T>::template array_t<n_array>; - - constexpr - base_t - get_four_bits( array_t const &arr, size_t offset ) const noexcept - { - return - get_four_bits_impl( arr, - offset / base_t_n_bits, offset % base_t_n_bits ); - } - - constexpr - base_t - get_four_bits_impl( array_t const &arr, - size_t idx, size_t bit_idx ) const noexcept - { - return ( bit_idx >= 3 ) - ? h1_get_four_bits( arr[idx], bit_idx ) - : h2_get_four_bits( arr, idx, bit_idx ); - } - - constexpr - base_t - h1_get_four_bits( base_t v, size_t bit_idx ) const noexcept - { return ( v >> ( bit_idx - 3 ) ) & base_t(0xF); } - - constexpr - base_t - h2_get_four_bits( array_t const &arr, - size_t idx, size_t bit_idx ) const noexcept - { - return - (( arr[idx] & ( ( base_t(1) << (bit_idx+1) ) - 1 ) ) << ( 3 - bit_idx )) - + ( ( idx == 0 ) ? base_t(0) - : ( arr[idx-1] >> (base_t_n_bits - (3 - bit_idx)) ) ); - } - }; // struct array_access - - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_ARRAY_ACCESS_CB_HPP diff --git a/ThirdParty/bitset2/detail/array_add.hpp b/ThirdParty/bitset2/detail/array_add.hpp deleted file mode 100644 index 55dc6f7a1ade67a4a4c0f04de0499f4cd0816088..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array_add.hpp +++ /dev/null @@ -1,153 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY_ADD_CB_HPP -#define BITSET2_ARRAY_ADD_CB_HPP - - -#include "bit_chars.hpp" -#include "array_funcs.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - template<size_t N,size_t it_n,class T> - struct array_add_base - { - using base_t= T; - using b_chars= bit_chars<N,T>; - enum : size_t { n_array= b_chars::n_array }; - enum : base_t - { hgh_bit_pattern= b_chars::hgh_bit_pattern - , all_one= b_chars::all_one - }; - using array_t= typename h_types<T>::template array_t<n_array>; - using zero_array_t= typename h_types<T>::template array_t<0>; - - /// Used to submit the curent result of the addition and the carry over - template<size_t n> - using array_pair_t= std::pair<base_t, - typename h_types<T>::template array_t<n> >; - - - constexpr - array_pair_t<it_n+1> - add_h1( base_t a, base_t b, base_t sm1, base_t sum, - typename - h_types<T>::template array_t<it_n> const &so_far ) const noexcept - { - return - std::make_pair( ( sum < a || sm1 < b ) ? base_t(1) : base_t(0) - , array_funcs<it_n,T>() - .append( so_far - , ( it_n + 1 < n_array ) - ? sum - : base_t(sum & hgh_bit_pattern) ) ); - } - - constexpr - array_pair_t<it_n+1> - add_h2( base_t a, base_t b, array_pair_t<it_n> const &a_p ) const noexcept - { return add_h1( a, b, b + a_p.first, a + b + a_p.first, a_p.second ); } - }; //struct array_add_base - - - /// \brief This struct is introduced for beeing able to partially - /// specialize function add_h3. - template<size_t N,size_t it_n,class T> - struct array_add_h : public array_add_base<N,it_n,T> - { - using array_t= typename array_add_base<N,it_n,T>::array_t; - - template<size_t n> - using array_pair_t= - typename array_add_base<N,it_n,T>::template array_pair_t<n>; - - constexpr - array_pair_t<it_n+1> - add_h3( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return - this->add_h2( arr1[it_n], arr2[it_n] - , array_add_h<N,it_n-1,T>().add_h3( arr1, arr2 ) ); - } - }; // struct array_add_h - - - template<size_t N,class T> - struct array_add_h<N,0,T> : public array_add_base<N,0,T> - { - using array_t= typename array_add_base<N,0,T>::array_t; - using zero_array_t= typename array_add_base<N,0,T>::zero_array_t; - - template<size_t n> - using array_pair_t=typename array_add_base<N,0,T>::template array_pair_t<n>; - - constexpr - array_pair_t<1> - add_h3( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return - this->add_h2( arr1[0], arr2[0] - , std::make_pair( T(0), zero_array_t{} ) ); - } - }; // struct array_add_h - - - /// Allows to add two std::array's in a constexpr - template<size_t N,class T> - struct array_add - { - using base_t= T; - using b_chars= bit_chars<N,T>; - enum : base_t - { hgh_bit_pattern= b_chars::hgh_bit_pattern - , all_one= b_chars::all_one - }; - enum : size_t { n_array= b_chars::n_array }; - using array_t= typename h_types<T>::template array_t<n_array>; - - constexpr - array_t - add( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return - ( N == 0 ) ? array_t{} - : array_add_h<N,n_array-1,T>().add_h3( arr1, arr2 ).second; - } - - constexpr - void - add_assgn( array_t &arr1, array_t const &arr2 ) const noexcept - { - base_t carry= base_t(0); - for( size_t c= 0; c < n_array; ++c ) - { - auto const sm1= base_t( arr2[c] + carry ); - auto const sm= base_t( arr1[c] + sm1 ); - carry= sm < arr1[c] || sm1 < arr2[c]; - arr1[c]= sm; - } - arr1[n_array-1] &= hgh_bit_pattern; - } // add_assgn - }; // struct array_add - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_ARRAY_ADD_CB_HPP diff --git a/ThirdParty/bitset2/detail/array_complement2.hpp b/ThirdParty/bitset2/detail/array_complement2.hpp deleted file mode 100644 index eaab57be63332ddd91e73d2b12e614137d9d2cf0..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array_complement2.hpp +++ /dev/null @@ -1,149 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY_COMPLEMENT2_CB_HPP -#define BITSET2_ARRAY_COMPLEMENT2_CB_HPP - - -#include "bit_chars.hpp" -#include "array_funcs.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - template<size_t N,size_t it_n,class T> - struct array_complement2_base - { - using base_t= T; - using b_chars= bit_chars<N,T>; - enum : base_t { hgh_bit_pattern= b_chars::hgh_bit_pattern }; - enum : size_t { n_array= b_chars::n_array }; - using array_t= typename h_types<T>::template array_t<n_array>; - - template<size_t n> - using arr_t= typename h_types<T>::template array_t<n>; - - constexpr - arr_t<it_n+1> - comp2_h1( arr_t<it_n> const &so_far, base_t sum ) const noexcept - { - return - array_funcs<it_n,T>().append( so_far - , ( it_n + 1 < n_array ) - ? sum - : base_t(sum & hgh_bit_pattern) ); - } - - constexpr - arr_t<it_n+1> - comp2_h2( array_t const &arr, - arr_t<it_n> const &so_far, - base_t carry ) const noexcept - { return comp2_h1( so_far, base_t( base_t(~arr[it_n]) + carry ) ); } - - constexpr - arr_t<it_n+1> - comp2_h3( array_t const &arr, - arr_t<it_n> const &so_far ) const noexcept - { - return comp2_h2( arr, so_far, - it_n == 0 - ? base_t(1) - : base_t(so_far[it_n-1] == 0 && arr[it_n-1] == 0) ); - } - - }; // struct array_complement2_base - - - template<size_t N,size_t it_n,class T> - struct array_complement2_h : array_complement2_base<N,it_n,T> - { - using array_t= typename array_complement2_base<N,it_n,T>::array_t; - - template<size_t n> - using arr_t= typename array_complement2_base<N,it_n,T>::template arr_t<n>; - - constexpr - arr_t<it_n+1> - comp2_h4( array_t const &arr ) const noexcept - { - return - this->comp2_h3( arr, - array_complement2_h<N,it_n-1,T>().comp2_h4( arr ) ); - } - - }; // struct array_complement2_h - - - template<size_t N,class T> - struct array_complement2_h<N,0,T> : array_complement2_base<N,0,T> - { - using array_t= typename array_complement2_base<N,0,T>::array_t; - - template<size_t n> - using arr_t= typename array_complement2_base<N,0,T>::template arr_t<n>; - - constexpr - arr_t<1> - comp2_h4( array_t const &arr ) const noexcept - { return this->comp2_h3( arr, arr_t<0>{} ); } - - }; // struct array_complement2_h<N,0,T> - - - - /// Computes the two's complement of the number encoded in the array - template<size_t N,class T> - struct array_complement2 - { - using base_t= T; - using b_chars= bit_chars<N,T>; - enum : base_t { hgh_bit_pattern= b_chars::hgh_bit_pattern }; - enum : size_t { n_array= b_chars::n_array }; - using array_t= typename h_types<T>::template array_t<n_array>; - - - constexpr - array_t - comp2( array_t const &arr ) const noexcept - { - return - ( N == 0 ) ? array_t{} - : array_complement2_h<N,n_array-1,T>().comp2_h4( arr ); - } - - constexpr - void - comp2_assgn( array_t &arr ) const noexcept - { - base_t carry= base_t(1); - for( size_t c= 0; c < n_array; ++c ) - { - auto const sm= base_t( base_t(~arr[c]) + carry ); - carry= base_t( (carry == base_t(1)) && ( sm == 0 ) ); - arr[c]= sm; - } // for c - arr[n_array-1] &= hgh_bit_pattern; - } // comp2_assgn - - }; // struct array_complement2 - - -} // namespace detail -} // namespace Bitset2 - - - -#endif // BITSET2_ARRAY_COMPLEMENT2_CB_HPP diff --git a/ThirdParty/bitset2/detail/array_funcs.hpp b/ThirdParty/bitset2/detail/array_funcs.hpp deleted file mode 100644 index f75afb02d2d342c6330451b4c70717db0d02f8bd..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array_funcs.hpp +++ /dev/null @@ -1,346 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY_FUNCS_CB_HPP -#define BITSET2_ARRAY_FUNCS_CB_HPP - - -#include "h_types.hpp" -#include "count_bits.hpp" -#include "index_lsb_set.hpp" -#include <utility> - - -namespace Bitset2 -{ -namespace detail -{ - - template<size_t n_array,class T> - struct array_funcs - { - using base_t= T; - using array_t= typename h_types<T>::template array_t<n_array>; - using array_p1_t= typename h_types<T>::template array_t<n_array+1>; - - enum : size_t { base_t_n_bits= h_types<T>::base_t_n_bits - , npos= h_types<T>::npos }; - - /// Binary operator type - enum class op_type { or_op, and_op, xor_op, sdiff_op }; - - constexpr - array_t - bitwise_or( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return bitwise_op_impl( op_type::or_op, arr1, arr2, - std::make_index_sequence<n_array>() ); - } - - /// Used for |= operator. Separate implementation for better performance. - constexpr - void - bitwise_or_assgn( array_t &arr1, array_t const &arr2 ) const noexcept - { return bitwise_op_assgn_impl( op_type::or_op, arr1, arr2 ); } - - constexpr - array_t - bitwise_and( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return bitwise_op_impl( op_type::and_op, arr1, arr2, - std::make_index_sequence<n_array>() ); - } - - /// Used for &= operator. Separate implementation for better performance. - constexpr - void - bitwise_and_assgn( array_t &arr1, array_t const &arr2 ) const noexcept - { return bitwise_op_assgn_impl( op_type::and_op, arr1, arr2 ); } - - constexpr - array_t - bitwise_xor( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return bitwise_op_impl( op_type::xor_op, arr1, arr2, - std::make_index_sequence<n_array>() ); - } - - /// Used for ^= operator. Separate implementation for better performance. - constexpr - void - bitwise_xor_assgn( array_t &arr1, array_t const &arr2 ) const noexcept - { return bitwise_op_assgn_impl( op_type::xor_op, arr1, arr2 ); } - - /// Computes the set difference, i.e. arr1 & ~arr2 - constexpr - array_t - bitwise_setdiff( array_t const &arr1, array_t const &arr2 ) const noexcept - { - return bitwise_op_impl( op_type::sdiff_op, arr1, arr2, - std::make_index_sequence<n_array>() ); - } - - /// \brief Computes the set difference, i.e. arr1 & ~arr2. - /// Separate implementation for better performance. - constexpr - void - bitwise_setdiff_assgn( array_t &arr1, array_t const &arr2 ) const noexcept - { return bitwise_op_assgn_impl( op_type::sdiff_op, arr1, arr2 ); } - - - constexpr - bool - none( array_t const &arr ) const noexcept - { return none_impl( n_array - 1, arr ); } - - - constexpr - size_t - count( array_t const &arr ) const noexcept - { - return - sum_impl( count_impl( arr, std::make_index_sequence<n_array>() ) ); - } - - - constexpr - bool - equal( array_t const &arr1, array_t const &arr2 ) const noexcept - { return equal_impl( arr1, arr2, 0 ); } - - - constexpr - bool - less_than( array_t const &arr1, array_t const &arr2 ) const noexcept - { return less_than_impl( arr1, arr2, n_array - 1 ); } - - - /// \brief Returns true if f returns true for each pair - /// of elements in arr1 and arr2 - template<class F> - constexpr - bool - zip_fold_and( array_t const &arr1, array_t const &arr2, - F &f ) const noexcept(noexcept( f( base_t(0), base_t(0) ) )) - { return zip_fold_and_impl( arr1, arr2, f, 0 ); } - - - /// \brief Returns true if f returns true for at least one pair - /// of elements in arr1 and arr2 - template<class F> - constexpr - bool - zip_fold_or( array_t const &arr1, array_t const &arr2, - F &f ) const noexcept(noexcept( f( base_t(0), base_t(0) ) )) - { return zip_fold_or_impl( arr1, arr2, f, 0 ); } - - - /// Prepend v1 in front of arr - constexpr - array_p1_t - prepend( base_t const v1, array_t const &arr ) const noexcept - { return prepend_impl( v1, arr, std::make_index_sequence<n_array>()); } - - - /// Append v1 to arr - constexpr - array_p1_t - append( array_t const &arr, base_t const v1 ) const noexcept - { return append_impl( arr, v1, std::make_index_sequence<n_array>()); } - - - /// Copy each element in arr but apply pttrn to most significant entry - template<size_t n> - constexpr - array_t - copy_and_map( base_t const pttrn, - typename - h_types<T>::template array_t<n> const &arr ) const noexcept - { - return - n_array == 0 ? array_t{} - : copy_and_map_impl( - pttrn, - arr, - gen_empty_array<n_array,T>(), - n >= n_array, - std::make_index_sequence<ce_min( n_array-1, n )>(), - std::make_index_sequence<n_array-1-ce_min(n_array-1, n)>() ); - } // copy_and_map - - - //** _impl functions - - template<size_t n,size_t ... S1,size_t ... S2> - constexpr - array_t - copy_and_map_impl( base_t const pttrn, - typename - h_types<T>::template array_t<n> const &arr, - array_t const &zeroes, - bool const take_all, - std::index_sequence<S1...>, - std::index_sequence<S2...> ) const noexcept - { - return {{ arr[S1]..., zeroes[S2]..., - base_t(( take_all ? arr[n_array-1] : base_t(0) ) & pttrn) }}; - } - - - - constexpr - bool - none_impl( size_t idx, array_t const &arr ) const noexcept - { - return ( arr[idx] == base_t(0) ) - && ( ( idx == 0 ) ? true : none_impl( idx - 1, arr ) ); - } - - - template<size_t ... S> - constexpr - array_p1_t - append_impl( array_t const &arr, base_t const v1, - std::index_sequence<S...> ) const noexcept - { return {{ arr[S]..., v1 }}; } - - - template<size_t ... S> - constexpr - array_p1_t - prepend_impl( base_t const v1, array_t const &arr, - std::index_sequence<S...> ) const noexcept - { return {{ v1, arr[S]... }}; } - - - constexpr - bool - equal_impl( array_t const &arr1, array_t const &arr2, - size_t ct ) const noexcept - { - return ( ct == n_array ) ? true - : ( arr1[ct] == arr2[ct] ) && equal_impl( arr1, arr2, ct + 1 ); - } - - - constexpr - bool - less_than_impl( array_t const &arr1, array_t const &arr2, - size_t ct ) const noexcept - { - return - ( arr1[ct] < arr2[ct] ) - || ( arr1[ct] == arr2[ct] - && ( ct == 0 ? false : less_than_impl( arr1, arr2, ct-1 ) ) ); - } - - - template<class F> - constexpr - bool - zip_fold_and_impl( array_t const &arr1, array_t const &arr2, - F &f, - size_t ct ) - const noexcept(noexcept( f(base_t(0), base_t(0)))) - { - return ( ct == n_array ) ? true - : ( f( arr1[ct], arr2[ct] ) - && zip_fold_and_impl( arr1, arr2, f, ct + 1 ) ); - } - - - template<class F> - constexpr - bool - zip_fold_or_impl( array_t const &arr1, array_t const &arr2, - F &f, - size_t ct ) - const noexcept(noexcept( f(base_t(0), base_t(0)))) - { - return ( ct == n_array ) ? false - : ( f( arr1[ct], arr2[ct] ) - || zip_fold_or_impl( arr1, arr2, f, ct + 1 ) ); - } - - - constexpr - void - bitwise_op_assgn_impl( op_type opt, - array_t &arr1, array_t const &arr2 ) const noexcept - { - for( size_t c= 0; c < n_array; ++c ) - { - if( opt == op_type::or_op ) arr1[c] |= arr2[c]; - else if( opt == op_type::and_op ) arr1[c] &= arr2[c]; - else if( opt == op_type::xor_op ) arr1[c] ^= arr2[c]; - else arr1[c] &= ~arr2[c]; - } - } // bitwise_op_assgn_impl - - - template<size_t ... S> - constexpr - array_t - bitwise_op_impl( op_type opt, - array_t const &arr1, array_t const &arr2, - std::index_sequence<S...> ) const noexcept - { return {{ h_bitwise_op( S, opt, arr1, arr2 )... }}; } - - constexpr - base_t - h_bitwise_op( size_t idx, op_type opt, - array_t const &arr1, array_t const &arr2 ) const noexcept - { - return ( opt == op_type::or_op ) ? ( arr1[idx] | arr2[idx] ) - : ( ( opt == op_type::and_op ) ? ( arr1[idx] & arr2[idx] ) - : ( opt == op_type::xor_op ) ? ( arr1[idx] ^ arr2[idx] ) - : ( arr1[idx] & ~arr2[idx] ) ); - } - - /// Count bits in each element of arr - template<size_t ... S> - constexpr - std::array<size_t, n_array> - count_impl( array_t const &arr, std::index_sequence<S...> ) const noexcept - { return {{ count_bits( arr[S] )... }}; } - - - /// Sum over all elements in vals - template<class T1> - constexpr - T1 - sum_impl( std::array<T1, n_array> const &vals, - size_t ct= n_array - 1 ) const noexcept - { return vals[ct] + ( ( ct == 0 ) ? T1(0) : sum_impl( vals, ct - 1 ) ); } - - - constexpr - size_t - idx_lsb_set( array_t const &arr, base_t v, size_t idx ) const noexcept - { - return - v == base_t(0) - ? ( idx + 1 == n_array ? npos - : idx_lsb_set( arr, arr[idx+1], idx + 1 ) ) - : idx * base_t_n_bits + index_lsb_set<base_t>()( v ); - } - - }; // struct array_funcs - -} // namespace detail - -} // namespace Bitset2 - - - - -#endif // BITSET2_ARRAY_FUNCS_CB_HPP diff --git a/ThirdParty/bitset2/detail/array_ops.hpp b/ThirdParty/bitset2/detail/array_ops.hpp deleted file mode 100644 index eecbc6d03a7d7f324dd251c1abf2c379f877b657..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/array_ops.hpp +++ /dev/null @@ -1,336 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_ARRAY_OPS_CB_HPP -#define BITSET2_ARRAY_OPS_CB_HPP - -#include "bit_chars.hpp" -#include "reverse_bits.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - template<size_t N,class T> - struct array_ops - { - using base_t= T; - using this_t= array_ops<N,T>; - using b_chars= bit_chars<N,T>; - enum : size_t { base_t_n_bits= b_chars::base_t_n_bits - , n_words= b_chars::n_words - , n_array= b_chars::n_array - , mod_val= b_chars::mod_val - , n_m_mod= mod_val == 0 ? 0 : base_t_n_bits-mod_val - }; - enum : base_t - { hgh_bit_pattern= b_chars::hgh_bit_pattern - , all_one= b_chars::all_one }; - using array_t= typename h_types<T>::template array_t<n_array>; - using zero_array_t= typename h_types<T>::template array_t<0>; - - constexpr - array_ops( size_t n_shift ) noexcept - : m_n_shift_mod( n_shift % N ) - , m_shft_div( n_shift / base_t_n_bits ) - , m_shft_mod( n_shift % base_t_n_bits ) - , m_shft_leftright_shift( base_t_n_bits-(n_shift % base_t_n_bits) ) - , m_shft_left_pattern( ce_left_shift( T(~T(0)), - base_t_n_bits - - (n_shift % base_t_n_bits) )) - , m_shft_right_pattern( ce_right_shift( T(~T(0)), - base_t_n_bits - - (n_shift % base_t_n_bits) )) - {} - - constexpr - array_t - shift_left( array_t const &arr ) const noexcept - { return shift_left_impl( arr, std::make_index_sequence<n_array>() ); } - - constexpr - array_t - shift_right( array_t const &arr ) const noexcept - { return shift_right_impl( arr, std::make_index_sequence<n_array>() ); } - - /// Used for <<= operator. Separate implementation for better performance. - constexpr - void - shift_left_assgn( array_t &arr ) const noexcept - { - for( size_t c= n_words; c > 0; ) - { - --c; - if( c >= m_shft_div ) - { - auto const c2= c - m_shft_div; - base_t const v1= arr[c2] << m_shft_mod; - base_t const v2= - c2 == 0 ? base_t(0) - : ce_right_shift( base_t(arr[c2-1] & m_shft_left_pattern), - m_shft_leftright_shift ); - arr[c]= base_t( v1 | v2 ); - } - else arr[c]= base_t(0); - } // for c - arr[n_array-1] &= hgh_bit_pattern; - } // shift_left_assgn - - /// Used for >>= operator. Separate implementation for better performance. - constexpr - void - shift_right_assgn( array_t &arr ) const noexcept - { - for( size_t c= 0; c < n_words; ++c ) - { - auto const c2= c + m_shft_div; - if( c2 < n_words ) - { - base_t const v1= arr[c2] >> m_shft_mod; - base_t const v2= - ( c2 + 1 >= n_words ) ? base_t(0) - : ce_left_shift( base_t( arr[c2+1] & m_shft_right_pattern ), - m_shft_leftright_shift ); - arr[c]= v1 | v2; - } - else arr[c]= base_t(0); - } // for c - arr[n_array-1] &= hgh_bit_pattern; - } // shift_right_assgn - - - constexpr - array_t - rotate_left( array_t const &arr ) const noexcept - { - return - ( n_array == 1 ) - ? array_t{{ base_t(( base_t( arr[0] << m_n_shift_mod ) - | ( ce_right_shift( arr[0], N - m_n_shift_mod ) ) - ) & hgh_bit_pattern ) }} - : rotate_left_impl( arr, - array_ops<N,T>( m_n_shift_mod ), - array_ops<N,T>( N - m_n_shift_mod ), - std::make_index_sequence<n_array>() ); - } // rotate_left - - constexpr - array_t - flip( array_t const &arr ) const noexcept - { return flip_impl( arr, std::make_index_sequence<n_array>() ); } - - constexpr - bool - all( array_t const &arr ) const noexcept - { return ( N > 0 ) && all_impl( n_words - 1, arr ); } - - - /// Used for ++ operator. - constexpr - void - increment( array_t &arr ) const noexcept - { - if( N == 0 ) return; - - size_t c= 0; - for( ; c + 1 < n_words; ++c ) - { - if( ( ++arr[c] ) != base_t(0) ) return; - } - ++arr[c]; - arr[c] &= hgh_bit_pattern; - } // increment - - - /// Used for -- operator. - constexpr - void - decrement( array_t &arr ) const noexcept - { - if( N == 0 ) return; - - size_t c= 0; - for( ; c + 1 < n_words; ++c ) - { - if( ( arr[c]-- ) != base_t(0) ) return; - } - --arr[c]; - arr[c] &= hgh_bit_pattern; - } // decrement - - /// Reverse bits - constexpr - array_t - reverse( array_t const &arr ) const noexcept - { - return n_array == 1 - ? array_t{{ base_t( reverse_bits<base_t>()(arr[0]) >> n_m_mod ) }} - : reverse_impl( arr, std::make_index_sequence<n_array>() ); - } // reverse - - - //**************************************************** - - - constexpr - bool - all_impl( size_t idx, array_t const &arr ) const noexcept - { - return h_all( idx, arr ) - && ( ( idx == 0 ) ? true : all_impl( idx - 1, arr ) ); - } - - constexpr - bool - h_all( size_t idx, array_t const &arr ) const noexcept - { - return ( idx + 1 == n_words ) ? ( arr[idx] == hgh_bit_pattern ) - : ( arr[idx] == all_one ); - } - - - template<size_t ... S> - constexpr - array_t - shift_left_impl( array_t const &arr, - std::index_sequence<S...> ) const noexcept - { return {{ h_shift_left( S, arr )... }}; } - - constexpr - base_t - h_shift_left( size_t idx, array_t const &arr ) const noexcept - { - return h_shift_left1( idx, arr ) - & ( ( idx+1 == n_words ) ? hgh_bit_pattern : all_one ); - } - - constexpr - base_t - h_shift_left1( size_t idx, array_t const &arr ) const noexcept - { - return ( idx >= n_words || idx < m_shft_div ) ? base_t(0) - : base_t( ( arr[idx-m_shft_div] << m_shft_mod ) - | h_shift_left_rem( idx - m_shft_div, arr ) ); - } - - constexpr - base_t - h_shift_left_rem( size_t idx, array_t const &arr ) const noexcept - { - return ( idx == 0 ) ? base_t(0) - : ce_right_shift( base_t( arr[idx-1] & m_shft_left_pattern ), - m_shft_leftright_shift ); - } - - - template<size_t ... S> - constexpr - array_t - shift_right_impl( array_t const &arr, - std::index_sequence<S...> ) const noexcept - { return {{ h_shift_right( S, arr )... }}; } - - constexpr - base_t - h_shift_right( size_t idx, array_t const &arr ) const noexcept - { - return ( idx + m_shft_div >= n_words ) ? base_t(0) - : base_t( ( arr[idx+m_shft_div] >> m_shft_mod ) - | h_shift_right_rem( idx + m_shft_div, arr ) ); - } - - constexpr - base_t - h_shift_right_rem( size_t idx, array_t const &arr ) const noexcept - { - return ( idx + 1 >= n_words ) ? base_t(0) - : ce_left_shift( base_t( arr[idx+1] & m_shft_right_pattern ), - m_shft_leftright_shift ); - } - - - template<size_t ... S> - constexpr - array_t - rotate_left_impl( array_t const &arr, - this_t lft, - this_t rgt, - std::index_sequence<S...> ) const noexcept - { - return - {{ ( S > lft.m_shft_div ? lft.h_shift_left( S, arr ) - : S == lft.m_shft_div - ? base_t( lft.h_shift_left( lft.m_shft_div, arr ) - | rgt.h_shift_right( lft.m_shft_div, arr ) ) - : rgt.h_shift_right( S, arr ) )... }}; - } // rotate_left_impl - - - template<size_t ... S> - constexpr - array_t - flip_impl( array_t const &arr, std::index_sequence<S...> ) const noexcept - { return {{ h_flip( S, arr )... }}; } - - constexpr - base_t - h_flip( size_t idx, array_t const &arr ) const noexcept - { - return ( idx >= n_words ) ? base_t(0) - : ( ~arr[idx] ) - & ( (idx+1 == n_words) ? hgh_bit_pattern : all_one ); - } - - - template<size_t ... S> - constexpr - array_t - reverse_impl( array_t const &arr, std::index_sequence<S...> ) const noexcept - { return {{ h_reverse( S, arr )... }}; } - - constexpr - base_t - h_reverse( size_t idx, array_t const &arr ) const noexcept - { - return idx + 1 == n_words - ? base_t( reverse_bits<base_t>()( arr[0] ) >> n_m_mod ) - : reverse_bits<base_t>()( h2_reverse( idx, arr ) ); - } - - constexpr - base_t - h2_reverse( size_t idx, array_t const &arr ) const noexcept - { - return mod_val == 0 ? arr[n_words-idx-1] - : base_t( ( arr[n_words-idx-1] << n_m_mod ) - | ( arr[n_words-idx-2] >> mod_val ) ); - } - - - size_t const m_n_shift_mod; - size_t const m_shft_div; - size_t const m_shft_mod; - size_t const m_shft_leftright_shift; - base_t const m_shft_left_pattern; - base_t const m_shft_right_pattern; - - }; // struct array_ops - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_ARRAY_OPS_CB_HPP diff --git a/ThirdParty/bitset2/detail/bit_chars.hpp b/ThirdParty/bitset2/detail/bit_chars.hpp deleted file mode 100644 index 5823d384de22c5fbba8ab20df92d5cd31e0171c5..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/bit_chars.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_BIT_CHARS_CB_HPP -#define BITSET2_BIT_CHARS_CB_HPP - -#include "h_types.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - template<size_t N,class T> - struct bit_chars - { - using h_t= h_types<T>; - using ULONG_t= typename h_t::ULONG_t; - using ULLONG_t= typename h_t::ULLONG_t; - using base_t= T; - // - enum : size_t - { n_bits= N - , ulong_n_bits= h_t::ulong_n_bits ///< #bits in ULONG_t - , ullong_n_bits= h_t::ullong_n_bits ///< #bits in ULLONG_t - , base_t_n_bits= h_t::base_t_n_bits ///< #bits in T - , div_val= n_bits / base_t_n_bits - , mod_val= n_bits % base_t_n_bits - , n_words= mod_val ? div_val + 1 : div_val ///< #words required - , n_array= ( n_words == 0 ) ? 1 : n_words ///< #words used - }; - enum : ULONG_t - { ulong_max= ULONG_MAX }; - enum : base_t - { all_one= base_t(~base_t(0)) - , low_bit_pattern= ///< Mask for idx==0 - n_bits == 0 ? base_t(0) - : ( div_val > 0 || mod_val == 0 ) - ? all_one - : ce_right_shift( all_one, base_t_n_bits - mod_val ) - , hgh_bit_pattern= ///< Mask for idx+1==n_words - n_bits == 0 ? base_t(0) - : mod_val == 0 - ? all_one - : ce_right_shift( all_one, base_t_n_bits - mod_val ) - }; - }; // struct bit_chars - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_BIT_CHARS_CB_HPP diff --git a/ThirdParty/bitset2/detail/bitset2_impl.hpp b/ThirdParty/bitset2/detail/bitset2_impl.hpp deleted file mode 100644 index 835d76b96ca93392b89416c07d41019547799a60..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/bitset2_impl.hpp +++ /dev/null @@ -1,400 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_IMPL_CB_HPP -#define BITSET2_IMPL_CB_HPP - -#include "bit_chars.hpp" -#include "array_add.hpp" -#include "ullong2array.hpp" -#include "array2u_long_t.hpp" -#include <bitset> - - -namespace Bitset2 -{ -namespace detail -{ - -template<size_t N,class T> -class bitset2_impl -{ - using b_chars= bit_chars<N,T>; - using h_t= h_types<T>; - -public: - enum : size_t { n_array= b_chars::n_array - , npos= h_t::npos }; - using base_t= T; - using ULONG_t= typename b_chars::ULONG_t; - using ULLONG_t= typename b_chars::ULLONG_t; - using array_t= typename h_types<T>::template array_t<n_array>; - -protected: - enum : size_t - { n_words= b_chars::n_words - , ulong_n_bits= b_chars::ulong_n_bits - , ullong_n_bits= b_chars::ullong_n_bits - , base_t_n_bits= b_chars::base_t_n_bits - }; - enum : ULONG_t - { ulong_max= b_chars::ulong_max }; - enum : base_t - { low_bit_pattern= b_chars::low_bit_pattern - , hgh_bit_pattern= b_chars::hgh_bit_pattern - , all_one= b_chars::all_one - }; - - template<size_t n_arr_src, class Tsrc> - using a2a= detail::array2array<n_array, n_arr_src,T,Tsrc>; - - - /* ----------------------------------------------------------------------- */ - constexpr - bitset2_impl() noexcept - {} - - constexpr - bitset2_impl( bitset2_impl const & ) noexcept= default; - - constexpr - bitset2_impl( bitset2_impl && ) noexcept= default; - - constexpr - bitset2_impl & - operator=( bitset2_impl const & ) noexcept= default; - - constexpr - bitset2_impl & - operator=( bitset2_impl && ) noexcept= default; - - explicit - constexpr - bitset2_impl( ULLONG_t v ) noexcept - : m_value( ullong2array<N,T>()( v ) ) - {} - - template<size_t n,class Tsrc> - explicit - constexpr - bitset2_impl( std::array<Tsrc,n> const & value ) noexcept - : m_value( a2a<n,Tsrc>()( hgh_bit_pattern, value ) ) - {} - - explicit - bitset2_impl( const std::bitset<N> &bs ) noexcept - { - if( N == 0 ) return; - if( ullong_n_bits <= base_t_n_bits && n_words == 1 ) - { - m_value[0]= bs.to_ullong(); - return; - } - - size_t offset= 0; - for( size_t ct= 0; ct < n_words; ++ct ) - { - base_t val= base_t(0); - auto const bit_limit= - ( ct < n_words - 1 ) ? base_t_n_bits : N - offset; - for( size_t bit_ct= 0; bit_ct < bit_limit; ++bit_ct ) - { - auto const test_bit= offset + bit_limit - bit_ct - 1; - val <<= 1; - if( bs.test( test_bit ) ) val |= base_t(1); - } // for bit_ct - m_value[ct]= val; - offset += base_t_n_bits; - } // for ct - } // bitset2_impl( const std::bitset<N> &bs ) - - - template< class CharT, class Traits, class Alloc > - explicit - bitset2_impl( std::basic_string<CharT,Traits,Alloc> const &str, - typename - std::basic_string<CharT,Traits,Alloc>::size_type pos, - typename - std::basic_string<CharT,Traits,Alloc>::size_type n, - CharT zero, - CharT one ) - { - auto const str_sz= str.size(); - if( pos > str_sz ) - throw std::out_of_range( "bitset2: String submitted to " - "constructor smaller than pos" ); - auto const n_bits= std::min( N, std::min( n, str_sz - pos ) ); - - for( size_t bit_ct= 0; bit_ct < n_bits; ++bit_ct ) - { - auto const chr= str[bit_ct+pos]; - if( Traits::eq( one, chr ) ) set( n_bits - bit_ct - 1 ); - else if( !Traits::eq( zero, chr ) ) - throw std::invalid_argument( "bitset2: Invalid argument in " - "string submitted to constructor" ); - } // for bit_ct - } - /* ----------------------------------------------------------------------- */ - - - //********************************************************** - - - constexpr - array_t & - get_data() noexcept - { return m_value; } - - constexpr - bool - operator[]( size_t bit ) const noexcept - { return test_noexcept( bit ); } - - constexpr - bool - test_noexcept( size_t bit ) const noexcept - { return m_value[bit / base_t_n_bits] & ( T(1) << ( bit % base_t_n_bits ) ); } - - constexpr - bitset2_impl & - set( size_t bit, bool value= true ) - { - if( bit >= N ) - throw std::out_of_range( "bitset2: Setting of bit out of range" ); - set_noexcept( bit, value ); - return *this; - } // set - - constexpr - bitset2_impl & - set() noexcept - { - if( N > 0 ) - { - size_t c= 0; - for( ; c < n_words - 1; ++c ) m_value[c]= ~base_t(0); - m_value[c]= hgh_bit_pattern; - } - return *this; - } // set - - constexpr - bitset2_impl & - reset() noexcept - { - for( size_t c= 0; c < n_array; ++c ) m_value[c]= base_t(0); - return *this; - } - - constexpr - bool - test_set( size_t bit, bool value= true ) - { - if( bit >= N ) - throw std::out_of_range( "bitset2: test_set out of range" ); - return test_set_noexcept( bit, value ); - } // test_set - - constexpr - bitset2_impl & - flip_noexcept( size_t bit ) noexcept - { - m_value[bit / base_t_n_bits] ^= ( base_t(1) << ( bit % base_t_n_bits ) ); - return *this; - } - - constexpr - bitset2_impl & - flip( size_t bit ) - { - if( bit >= N ) - throw std::out_of_range( "bitset2: Flipping of bit out of range" ); - return flip_noexcept( bit ); - } // flip - - constexpr - bitset2_impl & - flip() noexcept - { - if( N > 0 ) - { - size_t c= 0; - for( ; c < n_words - 1; ++c ) m_value[c] ^= ~base_t(0); - m_value[c] ^= hgh_bit_pattern; - } - return *this; - } // flip - -public: - constexpr - array_t const & - data() const noexcept - { return m_value; } - - constexpr - ULONG_t - to_ulong() const - { - using a2l= array2u_long_t<N,T,ULONG_t>; - return ( N == 0 ) ? 0ul - : a2l().check_overflow( m_value ) - ? throw std::overflow_error( "Cannot convert bitset2 " - "to unsigned long" ) - : a2l()( m_value ); - } // to_ulong - - constexpr - ULLONG_t - to_ullong() const - { - using a2l= array2u_long_t<N,T,ULLONG_t>; - return ( N == 0 ) ? 0ull - : a2l().check_overflow( m_value ) - ? throw std::overflow_error( "Cannot convert bitset2 " - "to unsigned long long" ) - : a2l()( m_value ); - } // to_ullong - - constexpr - bool - test( size_t bit ) const - { - return ( bit >= N ) - ? throw std::out_of_range( "bitset2: Testing of bit out of range" ) - : operator[]( bit ); - } - - constexpr - void - set_noexcept( size_t bit, bool value= true ) noexcept - { - if( value ) m_value[bit / base_t_n_bits] - |= base_t( base_t(1) << ( bit % base_t_n_bits ) ); - else m_value[bit / base_t_n_bits] - &= base_t(~( base_t(1) << ( bit % base_t_n_bits ) )); - } - - constexpr - bool - test_set_noexcept( size_t bit, bool value= true ) noexcept - { - auto const dv= bit / base_t_n_bits; - auto const md= bit % base_t_n_bits; - auto const pttrn= ( base_t(1) << md ); - auto const ret_val= bool( m_value[dv] & pttrn ); - - if( value ) m_value[dv] |= pttrn; - else m_value[dv] &= ~pttrn; - - return ret_val; - } // test_set_noexcept - - constexpr - bool - none() const noexcept - { return detail::array_funcs<n_array,T>().none( m_value ); } - - constexpr - bool - any() const noexcept - { return ( N > 0 ) && !none(); } - - constexpr - bool - all() const noexcept - { return ( N > 0 ) && detail::array_ops<N,T>( 0 ).all( m_value ); } - - constexpr - size_t - count() const noexcept - { return detail::array_funcs<n_array,T>().count( m_value ); } - - /// \brief Returns index of first (least significant) bit set. - /// Returns npos if all bits are zero. - constexpr - size_t - find_first() const noexcept - { - return detail::array_funcs<n_array,T>().idx_lsb_set(m_value, m_value[0], 0); - } - - /// \brief Returns index of next (> idx) bit set. - /// Returns npos if no more bits set. - /// Throws out_of_range if idx >= N. - constexpr - size_t - find_next( size_t idx ) const - { - return idx >= N - ? throw std::out_of_range( "bitset2: find_next index out of range" ) - : idx + 1 == N - ? npos - : detail::array_funcs<n_array,T>() - .idx_lsb_set( m_value, - base_t( m_value[(idx+1) / base_t_n_bits] - & ce_left_shift(T(~T(0)),(idx+1) % base_t_n_bits) ), - (idx+1) / base_t_n_bits ); - } - - constexpr - bool - operator==( bitset2_impl const &v2 ) const noexcept - { return detail::array_funcs<n_array,T>().equal( m_value, v2.m_value ); } - - constexpr - bool - operator!=( bitset2_impl const &v2 ) const noexcept - { return !( *this == v2 ); } - - constexpr - bool - operator<( bitset2_impl const &v2 ) const noexcept - { return detail::array_funcs<n_array,T>().less_than( m_value, v2.m_value ); } - - constexpr - bool - operator<=( bitset2_impl const &v2 ) const noexcept - { return ! ( *this > v2 ); } - - constexpr - bool - operator>( bitset2_impl const &v2 ) const noexcept - { return detail::array_funcs<n_array,T>().less_than(v2.m_value, m_value); } - - constexpr - bool - operator>=( bitset2_impl const &v2 ) const noexcept - { return ! ( *this < v2 ); } - - explicit - operator std::bitset<N>() const - { - using b_t= std::bitset<N>; - if( N == 0 ) return b_t{}; - if( n_words == 1 ) return b_t( to_ullong() ); - - b_t ret_val; - for( size_t ct= 0; ct < N; ++ct ) ret_val[ct]= operator[](ct); - - return ret_val; - } -private: - array_t m_value= (detail::gen_empty_array<n_array,T>)(); -}; // class bitset2_impl - - -} // namespace detail -} // namespace Bitset2 - - - -#endif // BITSET2_IMPL_CB_HPP diff --git a/ThirdParty/bitset2/detail/count_bits.hpp b/ThirdParty/bitset2/detail/count_bits.hpp deleted file mode 100644 index 221e7b05bdf21dd837992c43cd0284b3416c98cb..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/count_bits.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_COUNT_BITS_CB_HPP -#define BITSET2_COUNT_BITS_CB_HPP - - -#include "h_types.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - /// Returns the number of bits set in val - template<class T> - constexpr - inline - size_t - count_bits( T val, size_t count= 0 ) noexcept - { - return - ( val == T(0) ) - ? count - : count_bits( T(val & T( val - T(1) )), // clears lowest set bit - count + 1 ); - } - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_COUNT_BITS_CB_HPP diff --git a/ThirdParty/bitset2/detail/h_types.hpp b/ThirdParty/bitset2/detail/h_types.hpp deleted file mode 100644 index 94b9d9eed1279ecdd32ab2b1132c85ed441db838..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/h_types.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_H_TYPES_CB_HPP -#define BITSET2_H_TYPES_CB_HPP - -#include <array> -#include <utility> -#include <climits> -#include <type_traits> - - -namespace Bitset2 -{ -namespace detail -{ - - template<class T,class Enabled=void> struct h_types; - - template<class T> - struct h_types<T, - typename std::enable_if< std::is_integral<T>::value - && std::is_unsigned<T>::value>::type> - { - using ULONG_t= unsigned long; - using ULLONG_t= unsigned long long; - using base_t= T; - - template<size_t n_array> - using array_t= std::array<base_t,n_array>; - - enum : size_t - { ulong_n_bits= sizeof(ULONG_t) * CHAR_BIT ///< #bits in ULONG_t - , ullong_n_bits= sizeof(ULLONG_t) * CHAR_BIT ///< #bits in ULLONG_t - , base_t_n_bits= sizeof(base_t) * CHAR_BIT ///< #bits in base_t - , npos= ~size_t(0) - }; - }; // struct h_types - - - template<class T> - constexpr - T - ce_min( T v1, T v2 ) noexcept - { return ( v1 < v2 ) ? v1 : v2; } - - - - /// http://stackoverflow.com/q/29136207/3876684 - template<class T> - constexpr - T - ce_left_shift( T v1, size_t n_shift ) noexcept - { - return ( n_shift == 0 ) ? v1 - : ( ( n_shift >= h_types<T>::base_t_n_bits ) ? T(0) - : T( v1 << n_shift ) ); - } - - template<class T> - constexpr - T - ce_right_shift( T v1, size_t n_shift ) noexcept - { - return ( n_shift == 0 ) ? v1 - : ( ( n_shift >= h_types<T>::base_t_n_bits ) ? T(0) - : T( v1 >> n_shift ) ); - } - - - - template<size_t n_array,class T,size_t ... S> - inline constexpr - typename h_types<T>::template array_t<n_array> - gen_empty_array_impl( std::index_sequence<S...> ) noexcept - { - return - typename h_types<T>::template array_t<n_array>{{ ( T(S) & T(0) ) ... }}; - } - - - - template<size_t n_array,class T> - inline constexpr - typename h_types<T>::template array_t<n_array> - gen_empty_array() noexcept - { - return - gen_empty_array_impl<n_array,T>( std::make_index_sequence<n_array>() ); - } // gen_empty_array - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_H_TYPES_CB_HPP diff --git a/ThirdParty/bitset2/detail/hash.hpp b/ThirdParty/bitset2/detail/hash.hpp deleted file mode 100644 index 6248737c8e54f0def420e2eb6a145de34ea2eba3..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/hash.hpp +++ /dev/null @@ -1,126 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_HASH_CB_HPP -#define BITSET2_HASH_CB_HPP - -#include "h_types.hpp" - -#include <functional> -#include <array> -#include <climits> -#include <algorithm> - - -namespace Bitset2 -{ -namespace detail -{ - - -template<size_t n_words,class T> -struct hash_impl -{ - using base_t= T; - using result_type= std::size_t; - using array_t= typename h_types<T>::template array_t<n_words>; - - enum : size_t - { size_t_bits= sizeof(result_type) * CHAR_BIT ///< #bits in result_type - , base_t_n_bits= h_types<T>::base_t_n_bits ///< #bits in T - , bits_mod= base_t_n_bits % size_t_bits - , bits_div= base_t_n_bits / size_t_bits + ( bits_mod > 0 ) - , size_t_mod= size_t_bits % base_t_n_bits - , size_t_div= size_t_bits / base_t_n_bits - }; - - enum : bool - { easy_bits= ( size_t_bits >= base_t_n_bits ) - , easy_ratio= ( size_t_mod == 0 ) - }; - - result_type - operator()( array_t const & arr ) const noexcept - { - if( n_words == 0 ) return 0; - if( n_words == 1 ) - { - if( easy_bits ) return arr[0]; - return to_result_t( arr[0] ); - } // if n_words == 1 - - return cmpsd_hash( arr ); - } - - result_type - to_result_t( base_t a ) const noexcept - { - result_type ret_val= 0; - size_t shft= 0; - for( size_t c= 0; c < bits_div; ++c, shft += size_t_bits ) - { - auto const crrnt= result_type( a >> shft ); - do_combine( ret_val, crrnt, c ); - } - return ret_val; - } // to_result_t - - result_type - cmpsd_hash( array_t const & arr ) const noexcept - { - result_type ret_val= 0; - - if( easy_ratio ) - { - for( size_t c= 0; c < n_words; c += size_t_div ) - { - result_type r= 0; - auto const uppr= std::min( n_words, c + size_t_div ); - for( size_t w= c; w < uppr; ++w ) - r |= ( result_type(arr[w]) << ((w-c)*base_t_n_bits) ); - do_combine( ret_val, r, c / size_t_div ); - } - } - else - { - for( size_t c= 0; c < n_words; ++c ) - { - auto const crrnt= easy_bits - ? result_type(arr[c]) : to_result_t(arr[c]); - do_combine( ret_val, crrnt, c ); - } - } - - return ret_val; - } // cmpsd_hash - - void - do_combine( result_type &r, result_type crrnt, size_t cnt ) const noexcept - { - crrnt += cnt; - auto const n_rot= cnt % size_t_bits; - if( n_rot > 0 ) - crrnt= ( crrnt << n_rot ) | ( crrnt >> (size_t_bits-n_rot) ); - - r ^= crrnt; - } // do_combine -}; // struct hash_impl - - - - -} } // namespace Bitset2::detail - - - - -#endif // BITSET2_HASH_CB_HPP diff --git a/ThirdParty/bitset2/detail/hex_params.hpp b/ThirdParty/bitset2/detail/hex_params.hpp deleted file mode 100644 index 66e21f6646324ed08d067adb93aa6b6ca9a08b60..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/hex_params.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_HEX_PARAMS_CB_HPP -#define BITSET2_HEX_PARAMS_CB_HPP - -#include <string> - - -namespace Bitset2 -{ - - -template< class CharT = char, - class Traits = std::char_traits<CharT>, - class Allocator = std::allocator<CharT> > -struct hex_params -{ - using str_t= std::basic_string<CharT,Traits,Allocator>; - - hex_params( CharT zero_ch= CharT('0'), - CharT a_ch= CharT('a'), - bool leading_zeroes= true, - bool non_empty= true, - str_t const & prfx= str_t{} ) - : zeroCh{ zero_ch } - , aCh{ a_ch } - , leadingZeroes{ leading_zeroes } - , nonEmpty{ non_empty } - , prefix{ prfx } - {} - - CharT zeroCh= CharT( '0' ); - CharT aCh= CharT( 'a' ); - bool leadingZeroes= true; - bool nonEmpty= true; - str_t prefix; -}; // struct hex_params - - - -} // namespace Bitset2 - - -#endif // BITSET2_HEX_PARAMS_CB_HPP diff --git a/ThirdParty/bitset2/detail/index_lsb_set.hpp b/ThirdParty/bitset2/detail/index_lsb_set.hpp deleted file mode 100644 index 5c986ca64e654d3a7e9a0f53fa07e1720c8e6e32..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/index_lsb_set.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#ifndef BITSET2_INDEX_LSB_SET_CB_HPP -#define BITSET2_INDEX_LSB_SET_CB_HPP - - -#include <limits> -#include <climits> -#include <cstddef> - - - -namespace Bitset2 -{ -namespace detail -{ - - -/// https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightBinSearch -template<class T> -struct index_lsb_set -{ - enum : size_t { npos= std::numeric_limits<size_t>::max() - , n_bits= sizeof(T) * CHAR_BIT }; - - constexpr - index_lsb_set() noexcept - { - static_assert( ( n_bits & ( n_bits - 1 ) ) == 0, - "Number of bits in data type is not a power of 2" ); - } - - /// \brief Returns index of first (least significant) bit set in val. - /// Returns npos if all bits are zero. - constexpr - size_t - operator()( T val ) const noexcept - { - return ( T(0) == val ) ? npos - : find_idx( val, T( T(~T(0)) >> (n_bits >> 1) ), n_bits >> 1, 1 ); - } - -private: - constexpr - size_t - find_idx( T val, T pttrn, size_t sh_rght, size_t ct ) const noexcept - { - return ( sh_rght == 1 ) ? ( ct - size_t( T(val & T(0x1)) ) ) - : T( val & pttrn ) == T(0) - ? find_idx( T(val >> sh_rght), T( pttrn >> ( sh_rght >> 1 )), - sh_rght >> 1, ct + sh_rght ) - : find_idx( val, T(pttrn >> ( sh_rght >> 1 )), sh_rght >> 1, ct ); - } -}; // struct index_lsb_set - - - -} // namespace detail -} // namespace Bitset2 - - -#endif // BITSET2_INDEX_LSB_SET_CB_HPP diff --git a/ThirdParty/bitset2/detail/reverse_bits.hpp b/ThirdParty/bitset2/detail/reverse_bits.hpp deleted file mode 100644 index f4e8db66d9744d9bfca5a80ff9e27a6ceb140039..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/reverse_bits.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_REVERSE_BITS_CB_HPP -#define BITSET2_REVERSE_BITS_CB_HPP - -#include <limits> -#include <climits> -#include <cstddef> - - - -namespace Bitset2 -{ -namespace detail -{ - - -/// https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel -template<class T> -struct reverse_bits -{ - enum : size_t { n_bits= sizeof(T) * CHAR_BIT - , n_bits_h= n_bits >> 1 }; - - constexpr - reverse_bits() noexcept - { - static_assert( ( n_bits & ( n_bits - 1 ) ) == 0, - "Number of bits in data type is not a power of 2" ); - } - - /// \brief Reverses bits in val. - constexpr - T - operator()( T val ) const noexcept { return rvrs( val ); } - -private: - constexpr - T - rvrs( T val, - T mask= T( ~T(0) ) >> n_bits_h, - size_t s= n_bits_h ) const noexcept - { - return s == 0 ? val - : rvrs( ( (val >> s) & mask ) | ( (val << s) & ~mask ), - mask ^ ( mask << ( s >> 1 ) ), - s >> 1 ); - } -}; // struct reverse_bits - - -} // namespace detail -} // namespace Bitset2 - - -#endif // BITSET2_REVERSE_BITS_CB_HPP diff --git a/ThirdParty/bitset2/detail/select_base_t.hpp b/ThirdParty/bitset2/detail/select_base_t.hpp deleted file mode 100644 index abfe92744e1f72dc5fec9a06816bc210ec6dcab5..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/select_base_t.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#ifndef BITSET2_SELECT_BASE_T_CB_HPP -#define BITSET2_SELECT_BASE_T_CB_HPP - -#include <cstdint> -#include <cstddef> - -namespace Bitset2 -{ -namespace detail -{ - - -template<bool b,class T1, class T2> -struct if_else { using type= T1; }; - -template<class T1, class T2> -struct if_else<false,T1,T2> { using type= T2; }; - -template<bool b,class T1, class T2> -using if_else_t= typename if_else<b,T1,T2>::type ; - - -/// \brief Select any of uint8_t, uint16_t, uint32_t or -/// unsigned long long. Result depends on N and on provision -/// of these types by compiler. -template<size_t N> -struct select_base -{ -#ifdef INT8_MIN - enum : bool { has_int8= true }; - using UI8= uint8_t; -#else - enum : bool { has_int8= false }; - using UI8= void; -#endif -#ifdef INT16_MIN - enum : bool { has_int16= true }; - using UI16= uint16_t; -#else - enum : bool { has_int16= false }; - using UI16= void; -#endif -#ifdef INT32_MIN - enum : bool { has_int32= true }; - using UI32= uint32_t; -#else - enum : bool { has_int32= false }; - using UI32= void; -#endif - - using type= - if_else_t< has_int8 && (N<=8), UI8, - if_else_t< has_int16 && (N<=16), UI16, - if_else_t< has_int32 && (N<=32), UI32, - unsigned long long > > >; -}; // struct select_base - - -template<size_t N> -using select_base_t= typename select_base<N>::type; - - -} // namespace detail -} // namespace Bitset2 - - - - - -#endif // BITSET2_SELECT_BASE_T_CB_HPP diff --git a/ThirdParty/bitset2/detail/ullong2array.hpp b/ThirdParty/bitset2/detail/ullong2array.hpp deleted file mode 100644 index 41559858d2ff049d2e5211c0d5ddb5729647c320..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/detail/ullong2array.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#ifndef BITSET2_ULLONG2ARRAY_CB_HPP -#define BITSET2_ULLONG2ARRAY_CB_HPP - -#include "bit_chars.hpp" - - -namespace Bitset2 -{ -namespace detail -{ - - /// \brief Takes a variable 'v' of type unsigned long long - /// and returns a std::array 'a' equivalent to v. 'a' represents - /// an N bit bitset2 with base_t == T. - template<size_t N,class T> - struct ullong2array - { - using base_t= T; - using b_c= bit_chars<N,T>; - using ULLONG_t= typename b_c::ULLONG_t; - - enum : size_t - { n_bits= N - , base_t_n_bits= b_c::base_t_n_bits - , ullong_n_bits= b_c::ullong_n_bits - , n_array= b_c::n_array - , centrl_i= ce_min( (ullong_n_bits-1) / base_t_n_bits, n_array - 1 ) - , n_empty_vals= n_array - centrl_i - 1 - }; - - enum : base_t - { hgh_bit_pattern= b_c::hgh_bit_pattern - , use_pattern= (n_empty_vals==0) ? hgh_bit_pattern : base_t(~base_t(0)) - }; - - using array_t= typename h_types<T>::template array_t<n_array>; - - constexpr - array_t - operator()( ULLONG_t v ) const noexcept - { - return fill( gen_empty_array<n_array,T>(), v, - std::make_index_sequence<n_empty_vals>(), - std::make_index_sequence<centrl_i>() ); - } - - template<size_t ... S1,size_t ... S2> - constexpr - array_t - fill( array_t const & empty, ULLONG_t v, - std::index_sequence<S1...>, - std::index_sequence<S2...> ) const noexcept - { - return {{ base_t(ce_right_shift(v, S2 * base_t_n_bits))..., - base_t(ce_right_shift(v, centrl_i * base_t_n_bits)&use_pattern), - empty[S1]... }}; - } - }; // struct ullong2array - - -} // namespace detail -} // namespace Bitset2 - - - - -#endif // BITSET2_ULLONG2ARRAY_CB_HPP diff --git a/ThirdParty/bitset2/tests/bench01.cpp b/ThirdParty/bitset2/tests/bench01.cpp deleted file mode 100644 index 5e5e0071657af83a9032a53fb4a462f2e4c00817..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/bench01.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "../bitset2.hpp" -#include "gen_randoms.hpp" -#include <iostream> -#include <cassert> -#include <chrono> - - - -using ULLONG= unsigned long long; - -template<size_t N> -using t1= Bitset2::bitset2<N>; - -template<size_t N> -using vec_t= std::vector<t1<N> >; - - -constexpr size_t n_loops= 1000000; - -template<size_t N> -vec_t<N> -gen_bs_vec( size_t n ) -{ - std::vector<t1<N> > ret_val; - gen_random_bitset2<N,ULLONG> gen_rand; - ret_val.reserve( n ); - for( size_t c= 0; c < n; ++c ) ret_val.push_back( gen_rand() ); - - return ret_val; -} // gen_bs_vec - - -template<size_t N> -void -apply_or_equal( vec_t<N> & v1, vec_t<N> const & v2 ) -{ - auto it2= v2.begin(); - for( auto & bs: v1 ) bs |= *(it2++); -} // apply_or_equal - - -template<size_t n> -std::array<ULLONG,n> & -rm_const( std::array<ULLONG,n> const & a ) -{ return const_cast<std::array<ULLONG,n> &>(a); } - - -template<size_t N> -void -array_or_equal( vec_t<N> & v1, vec_t<N> const & v2 ) -{ - auto const n_array= v1[0].data().size(); - auto it2= v2.begin(); - for( auto & bs: v1 ) - { - auto & a1= rm_const( bs.data() ); - auto & a2= it2->data(); - for( size_t c= 0; c < n_array; ++c ) a1[c] |= a2[c]; - - ++it2; - } -} - - -int main() -{ - auto const vec1= gen_bs_vec<2048>( 128 ); - auto const vec2= gen_bs_vec<2048>( 128 ); - - std::cout << "Running computations\n"; - - auto const t1 = std::chrono::high_resolution_clock::now(); - - auto v1= vec1; - for( size_t c= 0; c < n_loops; ++c ) - { - v1= vec1; - apply_or_equal( v1, vec2 ); - } - - auto const t2 = std::chrono::high_resolution_clock::now(); - - auto v1a= vec1; - for( size_t c= 0; c < n_loops; ++c ) - { - v1a= vec1; - array_or_equal( v1a, vec2 ); - } - - auto const t3 = std::chrono::high_resolution_clock::now(); - - assert( v1 == v1a ); - - for( size_t c= 0; c < n_loops; ++c ) - { - v1a= vec1; - array_or_equal( v1a, vec2 ); - } - - auto const t4 = std::chrono::high_resolution_clock::now(); - - for( size_t c= 0; c < n_loops; ++c ) - { - v1= vec1; - apply_or_equal( v1, vec2 ); - } - - auto const t5 = std::chrono::high_resolution_clock::now(); - const std::chrono::duration<double> dt21 = t2 -t1; - const std::chrono::duration<double> dt32 = t3 -t2; - const std::chrono::duration<double> dt43 = t4 -t3; - const std::chrono::duration<double> dt54 = t5 -t4; - - std::cout << "dt21= " << dt21.count() * 1.0e3 << "ms\n"; - std::cout << "dt32= " << dt32.count() * 1.0e3 << "ms\n"; - std::cout << "dt43= " << dt43.count() * 1.0e3 << "ms\n"; - std::cout << "dt54= " << dt54.count() * 1.0e3 << "ms\n"; -} // main diff --git a/ThirdParty/bitset2/tests/counter128.cpp b/ThirdParty/bitset2/tests/counter128.cpp deleted file mode 100644 index 8adbb698322f764fa3974909b2c8f2c0caac656f..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/counter128.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - - -#include <iostream> -#include "bitset2.hpp" - - -int main() -{ - Bitset2::bitset2<128> c; - constexpr Bitset2::bitset2<128> tst{ 0xFFFFFFFFull }; - - for( ;; ++c ) - { - if( ( c & tst) == tst ) - std::cout << c.to_hex_string() << "\n"; - } -} // main diff --git a/ThirdParty/bitset2/tests/example01.cpp b/ThirdParty/bitset2/tests/example01.cpp deleted file mode 100644 index af1aa2b3e26854c116fa6d0b702cd6fb216f5f61..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/example01.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - -#include <iostream> -#include <array> -#include <cassert> -#include "bitset2.hpp" - -template<size_t n_bits> -using BS2= Bitset2::bitset2<n_bits>; - -int main() -{ - using bs_128= BS2<128>; - using base_t_128= bs_128::base_t; - constexpr std::array<base_t_128,2> - ar1{{ ~(base_t_128(0)), base_t_128(0xFEDCBA) }}; - constexpr bs_128 b1{ ar1 }; - constexpr auto b1_add= b1 + b1; - constexpr auto b1_shft= b1 << 1; // binary shift - static_assert( b1_add == b1_shft, "" ); - - std::cout << b1.to_hex_string() // 0000000000fedcbaffffffffffffffff - << "\n" - << b1_add.to_hex_string() // 0000000001fdb975fffffffffffffffe - << "\n"; - - BS2<12> b2; - for( size_t c= 0; c < 12; c += 2 ) b2[c]= true; - auto b3= ~b2; - std::cout << b2 << "\n"; // 010101010101 - std::cout << b2.flip() << "\n"; // 101010101010 - assert( b2 == b3 ); - - BS2<7> const b4{ "1110000" }; - auto const b5= Bitset2::rotate_left( b4, 3 ); - std::cout << b4 << "\n" // 1110000 - << b5 << "\n"; // 0000111 - - BS2<7> b6{ "1010010" }; - b6.reverse(); - std::cout << b6 << "\n"; // 0100101 -} // main diff --git a/ThirdParty/bitset2/tests/gen_randoms.hpp b/ThirdParty/bitset2/tests/gen_randoms.hpp deleted file mode 100644 index 9a95e27d2d0d2ef2760195cdc3e2d029fca4b134..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/gen_randoms.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#ifndef BITSET2_GEN_RANDOMS_CB_HPP -#define BITSET2_GEN_RANDOMS_CB_HPP - -#include "../bitset2.hpp" -#include <random> -#include <climits> -#include <array> -#include <vector> - - - -template<class T> -class gen_randoms -{ -public: - gen_randoms( T max_val, T min_val= 0 ) - : m_generator( std::random_device{}() ) - , m_distri( min_val, max_val ) - {} - // - T - operator()() - { return m_distri( m_generator ); } - // -private: - std::mt19937 m_generator; - std::uniform_int_distribution<T> m_distri; -}; // class gen_randoms - - - - -/// Generate N-bit sized bitset2 randomly -template<size_t N,class T> -class gen_random_bitset2 -{ - // - enum : size_t - { base_t_n_bits= sizeof(T) * CHAR_BIT - , div_val= N / base_t_n_bits - , mod_val= N % base_t_n_bits - , n_words= mod_val ? div_val + 1 : div_val - }; - enum : T - { max_ullong= T(~T(0)) - , hgh_bit_pattern= - N == 0 ? T(0) - : mod_val == 0 - ? max_ullong - : max_ullong >> T(base_t_n_bits-mod_val) - }; - // - using arr_t= std::array<T,n_words>; - // -public: - using b_t= Bitset2::bitset2<N,T>; - // - gen_random_bitset2() - : m_gen{ gen_generators() } - {} - // - b_t - operator()() - { - arr_t a; - for( size_t c= 0; c < n_words; ++c ) a[c]= m_gen[c](); - return b_t( a ); - } - // -private: - using gen_rand_t= gen_randoms<T>; - - std::vector<gen_rand_t> m_gen; - // - std::vector<gen_rand_t> - gen_generators() - { - std::vector<gen_rand_t> ret_val; - - if( n_words > 0 ) - { - ret_val.reserve( n_words ); - for( size_t c= 0; c < n_words - 1; ++c ) - ret_val.push_back( gen_rand_t{ max_ullong } ); - ret_val.push_back( gen_rand_t{ hgh_bit_pattern } ); - } - - return ret_val; - } -}; // gen_random_bitset2 - - - - -#endif // BITSET2_GEN_RANDOMS_CB_HPP diff --git a/ThirdParty/bitset2/tests/gray_code.cpp b/ThirdParty/bitset2/tests/gray_code.cpp deleted file mode 100644 index 72765bb92ccc69251a86fff3a712a6912ad01af3..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/gray_code.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "../bitset2.hpp" -#include <cassert> -#include <iostream> - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -binary_to_gray( Bitset2::bitset2<N,T> const &bs ) -{ return bs ^ (bs >> 1); } - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -gray_to_binary( Bitset2::bitset2<N,T> bs ) -{ - Bitset2::bitset2<N,T> mask= bs >> 1; - for( ; !mask.none(); mask >>= 1 ) bs ^= mask; - return bs; -} // gray_to_binary - - -int main() -{ - using ULLONG= unsigned long long; - constexpr std::array<ULLONG,2> arr_01a{{ 0xFEFDFCFBFAF9F8F7ull, 1ull }}; - constexpr Bitset2::bitset2<129> bs_01a{ arr_01a }; - constexpr auto gray_01a= binary_to_gray( bs_01a ); - constexpr auto bin_01a= gray_to_binary( gray_01a ); - - static_assert( bs_01a == bin_01a ); - - std::cout << bs_01a << '\n' << gray_01a << '\n'; - - return 0; -} // main diff --git a/ThirdParty/bitset2/tests/mk.sh b/ThirdParty/bitset2/tests/mk.sh deleted file mode 100755 index 45d30d119a2aada0a3fe3e3e541689c4ae869e5d..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/mk.sh +++ /dev/null @@ -1,43 +0,0 @@ -cc=g++-7 -#cc=clang++ - - -p=gray_code -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -I../detail -fdiagnostics-color=auto $p.cpp -o $p - -p=test_nonconst_constexpr01 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -I../detail -fdiagnostics-color=auto $p.cpp -o $p - -p=test_array2array -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -I../detail -fdiagnostics-color=auto $p.cpp -o $p - -p=tests01 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -fdiagnostics-color=auto $p.cpp -o $p - -p=test_bitset2_01 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -Wno-unused-but-set-variable -std=c++1z -I.. -fdiagnostics-color=auto $p.cpp -o $p - -p=test_bitset2_02 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -fdiagnostics-color=auto $p.cpp -o $p - -p=counter128 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -fdiagnostics-color=auto $p.cpp -o $p - -p=bench01 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -fdiagnostics-color=auto -D_GLIBCXX_USE_NANOSLEEP $p.cpp -o $p - -p=example01 -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -fdiagnostics-color=auto $p.cpp -o $p - -p=test_ullong2array -echo "Compiling $p" -$cc -O2 -Wall -Wextra -std=c++1z -I.. -I../detail -fdiagnostics-color=auto $p.cpp -o $p diff --git a/ThirdParty/bitset2/tests/test_array2array.cpp b/ThirdParty/bitset2/tests/test_array2array.cpp deleted file mode 100644 index 70bb3e5ab4d7705679a0496f7d73a5a00d88c690..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/test_array2array.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "array2array.hpp" -#include "gen_randoms.hpp" -#include <iostream> -#include <cstdint> -#include <cassert> - - - -constexpr size_t n_loops= 100000; - - - -template<class T1,class T2> -void -fwd_bckwd() -{ - constexpr size_t bits_T1= sizeof(T1) * CHAR_BIT; - constexpr size_t bits_T2= sizeof(T2) * CHAR_BIT; - - constexpr size_t t_n1= 8, s_n1= 1; - constexpr size_t t_n2= 24, s_n2= 3; - - using a2a_t1a= Bitset2::detail::array2array<t_n1,s_n1,T2,T1>; - using a2a_t1b= Bitset2::detail::array2array<s_n1,t_n1,T1,T2>; - using a2a_t2a= Bitset2::detail::array2array<t_n1,s_n1,T1,T2>; - using a2a_t2b= Bitset2::detail::array2array<s_n1,t_n1,T2,T1>; - - using a2a_t3a= Bitset2::detail::array2array<t_n2,s_n2,T2,T1>; - using a2a_t3b= Bitset2::detail::array2array<s_n2,t_n2,T1,T2>; - using a2a_t4a= Bitset2::detail::array2array<t_n2,s_n2,T1,T2>; - using a2a_t4b= Bitset2::detail::array2array<s_n2,t_n2,T2,T1>; - - gen_random_bitset2<s_n1*bits_T1,T1> gen_rand1a; - gen_random_bitset2<s_n1*bits_T2,T2> gen_rand1b; - - gen_random_bitset2<s_n2*bits_T1-bits_T1/2,T1> gen_rand2a; - gen_random_bitset2<s_n2*bits_T2-bits_T2/2,T2> gen_rand2b; - - for( size_t ct= 0; ct < n_loops; ++ct ) - { - // if( (ct+1) % 1000 == 0 ) std::cout << (ct+1) << '\n'; - - auto const bs1= gen_rand1a(); - auto const a1a= a2a_t1a()( ~T2(0), bs1.data() ); - auto const a1b= a2a_t1b()( ~T1(0), a1a ); - assert( bs1.data() == a1b ); - - auto const bs2= gen_rand1b(); - auto const a2a= a2a_t2a()( ~T1(0), bs2.data() ); - auto const a2b= a2a_t2b()( ~T2(0), a2a ); - assert( bs2.data() == a2b ); - - auto const bs3= gen_rand2a(); - auto const a3a= a2a_t3a()( ~T2(0), bs3.data() ); - auto const a3b= a2a_t3b()( T1(T1(~T1(0)) >> (bits_T1/2)), a3a ); - assert( bs3.data() == a3b ); - - auto const bs4= gen_rand2b(); - auto const a4a= a2a_t4a()( ~T1(0), bs4.data() ); - auto const a4b= a2a_t4b()( T2(T2(~T2(0)) >> (bits_T2/2)), a4a ); - assert( bs4.data() == a4b ); - } // for ct -} // fwd_bckwd - - -int main() -{ - - constexpr size_t t_n1= 2, s_n1= 2; - - std::cout << Bitset2::detail::array2array<t_n1,s_n1,uint16_t,uint8_t>::h_all_set - << " " - // << Bitset2::detail::array2array<t_n1,s_n1,uint8_t,uint16_t>::h_all_set - // << " " - << Bitset2::detail::array2array<t_n1,s_n1,uint8_t,uint32_t>::h_all_set - << " " - << Bitset2::detail::array2array<t_n1,s_n1,uint16_t,uint32_t>::h_all_set - << " " - << Bitset2::detail::array2array<t_n1,s_n1,uint16_t,uint64_t>::h_all_set - << " " - << Bitset2::detail::array2array<t_n1,s_n1,uint32_t,uint64_t>::h_all_set - << '\n'; - - std::cout << " 8 <-> 64\n"; - fwd_bckwd<uint8_t,uint64_t>(); - std::cout << "16 <-> 64\n"; - fwd_bckwd<uint16_t,uint64_t>(); - std::cout << "32 <-> 64\n"; - fwd_bckwd<uint32_t,uint64_t>(); - - std::cout << "\n 8 <-> 32\n"; - fwd_bckwd<uint8_t,uint32_t>(); - std::cout << "16 <-> 32\n"; - fwd_bckwd<uint16_t,uint32_t>(); - - std::cout << "\n 8 <-> 16\n"; - fwd_bckwd<uint8_t,uint16_t>(); -} // main diff --git a/ThirdParty/bitset2/tests/test_bitset2_01.cpp b/ThirdParty/bitset2/tests/test_bitset2_01.cpp deleted file mode 100644 index 2113e96f53a4c4193e87825188f9a0de7a773c78..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/test_bitset2_01.cpp +++ /dev/null @@ -1,420 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include <iostream> -#include <sstream> -#include <cassert> -#include "bitset2.hpp" - - -template<size_t N,class T> -constexpr -bool -is_subset_of( Bitset2::bitset2<N,T> const &bs1, - Bitset2::bitset2<N,T> const &bs2 ) noexcept -{ - using base_t= T; - return Bitset2::zip_fold_and( bs1, bs2, - []( base_t v1, base_t v2 ) noexcept - { return (v1 & ~v2) == 0; } ); -} // is_subset_of - - -template<size_t N,class T> -constexpr -bool -unequal( Bitset2::bitset2<N,T> const &bs1, - Bitset2::bitset2<N,T> const &bs2 ) noexcept -{ - using base_t= T; - return Bitset2::zip_fold_or( bs1, bs2, - []( base_t v1, base_t v2 ) noexcept - { return v1 != v2; } ); -} // unequal - - - -int main() -{ - using namespace Bitset2; - using ULLONG= unsigned long long; - - constexpr bitset2<32> b1; - constexpr auto v1= b1.to_ullong(); - constexpr auto b1_n= ~b1; - constexpr bool b1_n_none= b1_n.none(); - constexpr bool b1_n_all= b1_n.all(); - constexpr bool b1_n_any= b1_n.any(); - - bitset2<63> b_63; - bitset2<64> b_64; - bitset2<65> b_65; - auto b1a= b1; - b1a.set(); - b_63.set(); - b_64.set(); - b_65.set(); - - std::bitset<65> sb1; - auto sb2= std::bitset<32>( b1 ); - sb1[64]= 1; - - bitset2<65> b2( sb1 ); - - std::cout << v1 << "\n" - << b2 << "\n" - << sb2 << "\n" - << b1_n << "\n" - << "b1.none()= " << b1.none() << " " - << "b1.any()= " << b1.any() << " " - << "b1.all()= " << b1.all() << "\n" - << "b1a.none()= " << b1a.none() << " " - << "b1a.any()= " << b1a.any() << " " - << "b1a.all()= " << b1a.all() << "\n" - << "b2.none()= " << b2.none() << " " - << "b2.any()= " << b2.any() << " " - << "b2.all()= " << b2.all() << "\n" - << "b1_n.none()= " << b1_n_none << " " - << "b1_n.any()= " << b1_n_any << " " - << "b1_n.all()= " << b1_n_all << "\n" - << "b_63.all()= " << b_63.all() << " " - << "b_64.all()= " << b_64.all() << " " - << "b_65.all()= " << b_65.all() << "\n"; - std::cout << "b_63.flip()= " << b_63.flip() << "\n" - << "b_64.flip()= " << b_64.flip() << "\n" - << "b_65.flip()= " << b_65.flip() << "\n"; - std::cout << "b_63.flip()= " << b_63.flip() << "\n" - << "b_64.flip()= " << b_64.flip() << "\n" - << "b_65.flip()= " << b_65.flip() << "\n"; - std::cout << "b_63.reset()= " << b_63.reset() << "\n" - << "b_64.reset()= " << b_64.reset() << "\n" - << "b_65.reset()= " << b_65.reset() << "\n"; - - detail::bit_chars<4,ULLONG> bc1; - detail::bit_chars<64,ULLONG> bc2; - detail::bit_chars<65,ULLONG> bc3; - detail::bit_chars<63,ULLONG> bc4; - - bitset2<64> lbp1( bc1.low_bit_pattern ); - bitset2<64> lbp2( bc2.low_bit_pattern ); - bitset2<64> lbp3( bc3.low_bit_pattern ); - bitset2<64> lbp4( bc4.low_bit_pattern ); - - std::cout << bc1.low_bit_pattern << " " << bc1.mod_val << "\n" - << " " << lbp1 << "\n" - << bc2.low_bit_pattern << " " << bc2.mod_val << "\n" - << " " << lbp2 << "\n" - << bc3.low_bit_pattern << " " << bc3.mod_val << "\n" - << " " << lbp3 << "\n" - << bc4.low_bit_pattern << " " << bc4.mod_val << "\n" - << " " << lbp4 << "\n"; - - constexpr - std::array<unsigned long long,2> ar1{{ ~(0ull), 1 }}; - - constexpr - auto s_ar1= detail::array_ops<128,ULLONG>( 63 ).shift_left( ar1 ); - - std::cout << "\n" << ar1[1] << " " << ar1[0] << "\n"; - std::cout << "\n" << s_ar1[1] << " " << s_ar1[0] << "\n"; - - bitset2<63> bc5{ 1ull }; - bitset2<64> bc6{ 1ull }; - bitset2<65> bc7{ 1ull }; - constexpr bitset2<63> bc5a{ 1ull }; - constexpr bitset2<64> bc6a{ 1ull }; - constexpr bitset2<65> bc7a{ 1ull }; - constexpr bitset2<127> bc8a{ 1ull }; - constexpr bitset2<128> bc9a{ 1ull }; - constexpr bitset2<129> bc10a{ 1ull }; - constexpr auto bc5b= bc5a << 62; - constexpr auto bc6b= bc6a << 63; - constexpr auto bc7b= bc7a << 64; - constexpr auto bc8b= bc8a << 62; - constexpr auto bc8c= bc8a << 63; - constexpr auto bc8d= bc8a << 64; - constexpr auto bc9b= bc9a << 62; - constexpr auto bc9c= bc9a << 63; - constexpr auto bc9d= bc9a << 64; - constexpr auto bc10b= bc10a << 62; - constexpr auto bc10c= bc10a << 63; - constexpr auto bc10d= bc10a << 64; - std::cout << " " << bc8b << "\n " << bc8c << "\n " << bc8d << "\n"; - std::cout << " " << bc9b << "\n " << bc9c << "\n " << bc9d << "\n"; - std::cout << bc10b << "\n" << bc10c << "\n" << bc10d << "\n"; - std::cout << bc5b << " " << bc6b << " " << bc7b << "\n"; - for( size_t c= 0; c < 66; ++c ) - { - std::cout << bc5 << " " << bc6 << " " << bc7 << "\n"; - bc5 <<= 1; bc6 <<= 1; bc7 <<= 1; - } - - std::cout << "\n"; - constexpr auto bc5c= bc5b >> 62; - constexpr auto bc6c= bc6b >> 63; - constexpr auto bc7c= bc7b >> 64; - std::cout << bc5c << " " << bc6c << " " << bc7c << "\n"; - - constexpr auto bc5d= bc5a | bc5b; - constexpr auto bc5e= bc5d & bc5a; - constexpr auto bc5f= bc5d & bc5b; - constexpr auto bc5g= bc5a ^ bc5b; - constexpr auto bc5h= bc5d ^ bc5a; - constexpr auto bc5i= bc5d ^ bc5b; - constexpr auto bc5j= bc5a << 1; - std::cout << "\n" << bc5a << " |\n" << bc5b << " =\n" << bc5d << "\n"; - std::cout << "\n" << bc5d << " &\n" << bc5a << " =\n" << bc5e << "\n"; - std::cout << "\n" << bc5d << " &\n" << bc5b << " =\n" << bc5f << "\n"; - std::cout << "\n" << bc5a << " ^\n" << bc5b << " =\n" << bc5g << "\n"; - std::cout << "\n" << bc5d << " ^\n" << bc5a << " =\n" << bc5h << "\n"; - std::cout << "\n" << bc5d << " ^\n" << bc5b << " =\n" << bc5i << "\n"; - std::cout << "\n" << bc5a << " << 1 = " << bc5j << "\n"; - - constexpr auto bc7d= bc7a | bc7b; - constexpr auto bc7e= bc7d & bc7a; - constexpr auto bc7f= bc7d & bc7b; - constexpr auto bc7g= bc7a ^ bc7b; - constexpr auto bc7h= bc7d ^ bc7a; - constexpr auto bc7i= bc7d ^ bc7b; - std::cout << "\n" << bc7a << " |\n" << bc7b << " =\n" << bc7d << "\n"; - std::cout << "\n" << bc7d << " &\n" << bc7a << " =\n" << bc7e << "\n"; - std::cout << "\n" << bc7d << " &\n" << bc7b << " =\n" << bc7f << "\n"; - std::cout << "\n" << bc7a << " ^\n" << bc7b << " =\n" << bc7g << "\n"; - std::cout << "\n" << bc7d << " ^\n" << bc7a << " =\n" << bc7h << "\n"; - std::cout << "\n" << bc7d << " ^\n" << bc7b << " =\n" << bc7i << "\n"; - - constexpr auto bc5a_f= ~bc5a; - constexpr auto bc5d_f= ~bc5d; - constexpr auto bc7a_f= ~bc7a; - constexpr auto bc7d_f= ~bc7d; - std::cout << "\n~" << bc5a << " =\n " << bc5a_f << "\n"; - std::cout << "\n~" << bc5d << " =\n " << bc5d_f << "\n"; - std::cout << "\n~" << bc7a << " =\n " << bc7a_f << "\n"; - std::cout << "\n~" << bc7d << " =\n " << bc7d_f << "\n"; - std::cout << "\n"; - bitset2<65> bc11a{ 1ull }; - bitset2<65> bc11b{ 1ull }; - bc11b <<= 64; - bc11b |= ( bc11a << 1 ); - std::cout << bc11b << "\n"; - bc11b >>= 1; - std::cout << bc11b << "\n"; - std::cout << bc11b.to_string( '.', 'x' ) << "\n"; - - constexpr auto n_5a= bc5a.count(); - constexpr auto n_5a_f= bc5a_f.count(); - constexpr auto n_7a= bc7a.count(); - constexpr auto n_7a_f= bc7a_f.count(); - std::cout << "count( " << bc5a << " )= " << n_5a << "\n"; - std::cout << "count( " << bc5a_f << " )= " << n_5a_f << "\n"; - std::cout << "count( " << bc7a << " )= " << n_7a << "\n"; - std::cout << "count( " << bc7a_f << " )= " << n_7a_f << "\n"; - std::cout << "\n"; - b_63.reset(); - b_64.reset(); - b_65.reset(); - auto b_63a= b_63; - auto b_64a= b_64; - auto b_65a= b_65; - for( size_t c= 0; c < 64; c += 2 ) - { - if( c < 63 ) b_63[c]= true; - if( c < 64 ) b_64[c]= true; - if( c < 65 ) b_65[c]= true; - b_63a[c/2]= true; b_64a[c/2]= true; b_65a[c/2]= true; - } - std::cout << "Hash values:\n"; - std::cout << " " << b_63 << " " << std::hash<bitset2<63>>()( b_63 ) << "\n" - << " " << b_64 << " " << std::hash<bitset2<64>>()( b_64 ) << "\n" - << b_65 << " " << std::hash<bitset2<65>>()( b_65 ) << "\n"; - - bitset2<0> b_0a, b_0b; - constexpr auto bl_c7d= bc7d == bc7d; - std::cout << "\n" << ( b_63 == b_63 ) << " " - << ( b_64 == b_64 ) << " " - << ( b_65 == b_65 ) << "\n" - << ( b_63 != b_63a ) << " " - << ( b_64 != b_64a ) << " " - << ( b_65 != b_65a ) << " " - << bl_c7d << "\n" - << ( b_0a == b_0b ) << "\n"; - - constexpr bitset2<65> bs33a( 0xFFFFFFFFFFFFFFFFull ); - // constexpr auto bs33b= ( bs33a << 1 ); - //constexpr - auto bs33a_v= bs33a.to_ulong(); - std::cout << bs33a << " == " << bs33a_v << " == " << bs33a.to_hex_string() << "\n"; - // auto bs33b_v= bs33b.to_ulong(); // throws - // std::cout << bs33b << " == " << bs33b_v << "\n"; - - bitset2<63> bc2_63{ 0x700000000000000Eull }; - constexpr bitset2<63> bc2_63a{ 0x700000000000000Eull }; - constexpr auto bc2_63b= rotate_right( bc2_63a, 5 ); - bitset2<65> bc2_65{ 0x700000000000000Eull }; - constexpr bitset2<65> bc2_65a{ 0x700000000000000Eull }; - constexpr auto bc2_65b= rotate_right( bc2_65a, 5 ); - std::cout << " bc2_63= " << bc2_63 - << " == " << bc2_63.to_hex_string() << "\n"; - bc2_63.rotate_left( 5 ); - std::cout << "rot_left( bc2_63, 5) = " << bc2_63 << "\n"; - std::cout << "rot_right( bc2_63a,5)= " << bc2_63b << "\n"; - - std::cout << " bc2_65= " << bc2_65 - << " == " << bc2_65.to_hex_string() << "\n"; - bc2_65.rotate_left( 5 ); - std::cout << "rot_left( bc2_65, 5) = " << bc2_65 << "\n"; - std::cout << "rot_right( bc2_65a,5)= " << bc2_65b << "\n"; - - constexpr auto add_b5a= bc5a + bc5j; - constexpr auto add_b5b= bc5a + bc5a; - std::cout << bc5a << " +\n" << bc5j << " =\n" << add_b5a << "\n"; - std::cout << bc5a << " +\n" << bc5a << " =\n" << add_b5b << "\n"; - - constexpr std::array<ULLONG,2> arr_add_01a{{ 0xFFFFFFFFFFFFFFFFull, 0ull }}; - std::array<ULLONG,2> arr_add_01ap{{ 0xFFFFFFFFFFFFFFFFull, 0ull }}; - constexpr std::array<ULLONG,2> arr_add_01b{{ 0xFFFFFFFFFFFFFFFFull, 1ull }}; - constexpr bitset2<64> b_a_01a( 0xFFFFFFFFFFFFFFFFull ); - constexpr bitset2<128> b_a_02a( arr_add_01a ); - bitset2<128> b_a_02ap( arr_add_01ap ); - constexpr bitset2<128> b_a_02b( arr_add_01b ); - - std::cout << b_a_02ap.to_hex_string() << "\n"; - - constexpr auto add_b_a_01a= b_a_01a + b_a_01a; - constexpr auto add_b_a_02a= b_a_02a + b_a_02a; - constexpr auto add_b_a_02b= b_a_02a + b_a_02b; - constexpr auto add_b_a_02c= b_a_02b + b_a_02b; - std::cout << b_a_01a << " +\n" << b_a_01a << " =\n" << add_b_a_01a << "\n\n"; - std::cout << b_a_02a << " +\n" << b_a_02a << " =\n" << add_b_a_02a << "\n\n"; - std::cout << b_a_02a << " +\n" << b_a_02b << " =\n" << add_b_a_02b << "\n\n"; - std::cout << b_a_02b << " +\n" << b_a_02b << " =\n" << add_b_a_02c << "\n\n"; - - bitset2<65> bc2_65c{ 0xF00000000000000Eull }; - std::cout << bc2_65c << " +\n" << bc2_65a << " =\n"; - bc2_65c += bc2_65a; - std::cout << bc2_65c << "\n\n"; - - bitset2<65> bc2_65d{ 0xFFFFFFFFFFFFFFFEull }; - std::cout << "++" << bc2_65d << "=\n "; - std::cout << (++bc2_65d) << "\n"; - - bitset2<65> bc2_65e = bc2_65d << 1; - - std::cout << "++" << bc2_65d << "=\n "; - std::cout << (++bc2_65d) << "\n"; - - std::cout << "++" << bc2_65e << "=\n "; - std::cout << (++bc2_65e) << "\n"; - std::cout << " " << bc2_65e << "++ =\n "; - bc2_65e++; - std::cout << bc2_65e << "\n"; - - bitset2<65> bc2_65f= bitset2<65>{1ull} << 64; - bitset2<65> bc2_65g; - std::cout << "\n--" << bc2_65f << "=\n "; - std::cout << (--bc2_65f) << "\n"; - std::cout << " " << bc2_65f << "-- =\n "; - bc2_65f--; - std::cout << bc2_65f << "\n"; - std::cout << "--" << bc2_65g << "=\n "; - std::cout << (--bc2_65g) << "\n"; - - std::string bit_string = "101110"; - std::istringstream bit_stream( bit_string ); - bitset2<3> b_from_stream1; - bitset2<3> b_from_str2( bit_string, 3 ); - bitset2<4> b_from_str3( bit_string.c_str() + 1, 3 ); - bit_stream >> b_from_stream1; - std::cout << b_from_stream1 - << "= 0x" << b_from_stream1.to_hex_string() << '\n'; - std::cout << b_from_str2 - << "= 0x" << b_from_str2.to_hex_string() << '\n'; - std::cout << b_from_str3 - << "= 0x" << b_from_str3.to_hex_string() << '\n'; - - - constexpr std::array<ULLONG,1> s_arr_01a{{ 1ull }}; - constexpr std::array<ULLONG,2> s_arr_01b{{ 0xFFFFFFFFFFFFFFFFull, 1ull }}; - constexpr std::array<ULLONG,3> s_arr_01c{{ 0x1ull, 0xFFFFFFFFFFFFFFFFull, 0x3ull }}; - constexpr std::array<ULLONG,4> s_arr_01d{{ 0xEEEEEEEEEEEEEEEEull, 0xDull, 1ull, 0xFFFFFFFFFFFFFFFFull }}; - constexpr bitset2<129> b_from_s_arr01a{ s_arr_01a }; - constexpr bitset2<129> b_from_s_arr01b{ s_arr_01b }; - constexpr bitset2<129> b_from_s_arr01c{ s_arr_01c }; - constexpr bitset2<129> b_from_s_arr01d{ s_arr_01d }; - std::cout << "b_from_s_arr01a= " << b_from_s_arr01a.to_hex_string() << "\n"; - std::cout << "b_from_s_arr01b= " << b_from_s_arr01b.to_hex_string() << "\n"; - std::cout << "b_from_s_arr01c= " << b_from_s_arr01c.to_hex_string() << "\n"; - std::cout << "b_from_s_arr01d= " << b_from_s_arr01d.to_hex_string() << "\n"; - - constexpr bitset2<24> b24_empty{ 0ull }; - constexpr bitset2<24> b24_full= ~b24_empty; - constexpr bitset2<23> b23_a= convert_to<23>( b24_full ); - constexpr bitset2<25> b25_a= convert_to<25>( b24_full ); - constexpr auto b24_full_ui8= convert_to<24,uint8_t>( b24_full ); - std::cout << "b24_full= " << b24_full << "\n"; - std::cout << "b23_a= " << b23_a << "\n"; - std::cout << "b25_a= " << b25_a << "\n"; - std::cout << "b24_full_ui8= " << b24_full_ui8 << '\n'; - - bitset2<7> b7_a( "1010101" ); - bitset2<7> b7_b( "1000101" ); - bitset2<7> b7_c( "1110101" ); - bitset2<7> b7_d( "0110101" ); - bitset2<7> b7_e( "1010101" ); - - constexpr bitset2<7> b7_a_ce( 0b1010101ull ); - constexpr bitset2<7> b7_b_ce( 0b1000101ull ); - - assert( is_subset_of( b7_b, b7_a ) ); - assert( !is_subset_of( b7_c, b7_a ) ); - assert( !is_subset_of( b7_d, b7_a ) ); - assert( !is_subset_of( b7_a, b7_d ) ); - - assert( unequal( b7_a, b7_b ) ); - assert( !unequal( b7_e, b7_a ) ); - - static_assert( is_subset_of( b7_b_ce, b7_a_ce ), "" ); - static_assert( unequal( b7_a_ce, b7_b_ce ), "" ); - - assert( b7_b < b7_a ); - assert( b7_c > b7_a ); - assert( b7_e <= b7_a ); - assert( b7_a >= b7_d ); - - bitset2<2047> b2047_a( 1ull ); - auto b2047_b= b2047_a << 999; - auto b2047_c= b2047_a + b2047_b; - auto b2047_d= b2047_a << 1999; - std::cout << "b2047_a= " << b2047_a.to_hex_string() << "\n" - << "b2047_b= " << b2047_b.to_hex_string() << "\n" - << "b2047_c= " << b2047_c.to_hex_string() << "\n"; - std::cout << "bitset2<2047>::n_array= " << bitset2<2047>::n_array << '\n'; - assert( unequal( b2047_a, b2047_b ) ); - assert( unequal( b2047_b, b2047_d ) ); - assert( is_subset_of( b2047_a, b2047_c ) ); - assert( !is_subset_of( b2047_b, b2047_d ) ); - - bitset2<16> b16_a( "0000101000011111" ); - bitset2<16> b16_b; - hex_params<> hp1; - hp1.aCh= 'A'; - hp1.leadingZeroes= false; - hp1.prefix= "0x"; - std::cout << '\n' - << b16_a.to_hex_string() << '\n' // 0a1f - << b16_a.to_hex_string( hp1 ) // 0xA1F - << '\n' - << b16_b.to_hex_string() << '\n' // 0000 - << b16_b.to_hex_string( hex_params<>{'0', 'a', false, false, "0X"}) // 0X - << '\n'; -} // main diff --git a/ThirdParty/bitset2/tests/test_bitset2_02.cpp b/ThirdParty/bitset2/tests/test_bitset2_02.cpp deleted file mode 100644 index 9c8de9c842027b3199b549a5380b0f45c90d9864..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/test_bitset2_02.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -#include <iostream> -#include "bitset2.hpp" - - -int main() -{ - using namespace Bitset2; - - using ULLONG= unsigned long long; - - constexpr - std::array<ULLONG,1> a01{{1ull}}; - - constexpr - std::array<ULLONG,0> a02{}; - - constexpr auto a_app01= detail::array_funcs<1,ULLONG>().prepend( 2ull, a01 ); - constexpr auto a_app02= detail::array_funcs<0,ULLONG>().prepend( 3ull, a02 ); - std::cout << a_app01[0] << "\t" << a_app01[1] << "\n"; - std::cout << a_app02[0] << "\n"; - - //constexpr - auto aop0= detail::array_ops<65,ULLONG>( 0 ); - //constexpr - auto aop65= detail::array_ops<65,ULLONG>( 65 ); - //constexpr - auto slp65= Bitset2::bitset2<64>{ aop65.m_shft_left_pattern }; - - std::cout << "(aop0) m_n_shift_mod= " << aop0.m_n_shift_mod - << "\n m_shft_div= " << aop0.m_shft_div - << "\n m_shft_mod= " << aop0.m_shft_mod - << "\n m_shft_leftright_shift= " << aop0.m_shft_leftright_shift - << "\n m_shft_left_pattern= " << aop0.m_shft_left_pattern - << "\n m_shft_right_pattern= " << aop0.m_shft_right_pattern - << "\n n_words= " << aop0.n_words - << "\n n_array= " << aop0.n_array - << "\n"; - std::cout << "(aop65) m_n_shift_mod= " << aop65.m_n_shift_mod - << "\n m_shft_div= " << aop65.m_shft_div - << "\n m_shft_mod= " << aop65.m_shft_mod - << "\n m_shft_leftright_shift= " << aop65.m_shft_leftright_shift - << "\n m_shft_left_pattern= " << aop65.m_shft_left_pattern - << "\n = " << slp65 - << "\n m_shft_right_pattern= " << aop65.m_shft_right_pattern - << "\n n_words= " << aop65.n_words - << "\n n_array= " << aop65.n_array - << "\n"; -} diff --git a/ThirdParty/bitset2/tests/test_nonconst_constexpr01.cpp b/ThirdParty/bitset2/tests/test_nonconst_constexpr01.cpp deleted file mode 100644 index 03a2aa1bc22d5048a2044ff70a77c1b864c52c6f..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/test_nonconst_constexpr01.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "../bitset2.hpp" -#include <iostream> -#include <array> - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -ce_op( Bitset2::bitset2<N,T> const &bs, size_t n, size_t op_t ) -{ - auto ret_val= bs; - for( size_t c= 0; c < n; c++ ) - { - switch( op_t ) - { - case 1: ++ret_val; break; - case 2: ret_val++; break; - case 3: --ret_val; break; - case 4: ret_val--; break; - } - } - return ret_val; -} // ce_op - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -ce_opequal( Bitset2::bitset2<N,T> const &bs1, - Bitset2::bitset2<N,T> const &bs2, - size_t op_t ) -{ - auto ret_val= bs1; - - switch( op_t ) - { - case 1: ret_val += bs2; break; - case 2: ret_val |= bs2; break; - case 3: ret_val &= bs2; break; - case 4: ret_val ^= bs2; break; - case 5: ret_val.difference( bs2 ); break; - } - return ret_val; -} // ce_opequal - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -ce_shftequal( Bitset2::bitset2<N,T> const &bs1, - size_t shft, - size_t op_t ) -{ - auto ret_val= bs1; - - switch( op_t ) - { - case 1: ret_val <<= shft; break; - case 2: ret_val >>= shft; break; - case 3: ret_val.rotate_left( shft ); break; - case 4: ret_val.rotate_right( shft ); break; - } - return ret_val; -} // ce_shftequal - - -template<size_t N,class T> -constexpr -Bitset2::bitset2<N,T> -ce_sme_fncs( Bitset2::bitset2<N,T> const &bs1 ) -{ - auto ret_val= bs1; - Bitset2::bitset2<N,T> b2; - b2.set(); - b2.set( 12, false ); - b2.test_set( 15, false ); - - ret_val.reverse(); - ret_val.complement2(); - ret_val ^= b2; - - ret_val.flip(); - ret_val.flip( 42 ); - ret_val.flip(); - - return ret_val; -} // ce_sme_fncs - - -int main() -{ - using ULLONG= unsigned long long; - using namespace Bitset2; - - constexpr std::array<ULLONG,2> s_arr_01a{{ 0xFFFFFFFFFFFFFFFFull, 1ull }}; - constexpr std::array<ULLONG,2> s_arr_01b{{ 5ull, 0ull }}; - constexpr std::array<ULLONG,2> bit12{{ 1ull << 12, 0ull }}; - constexpr std::array<ULLONG,2> bit15{{ 1ull << 15, 0ull }}; - constexpr std::array<ULLONG,2> bit42{{ 1ull << 42, 0ull }}; - constexpr bitset2<129> zero; - constexpr bitset2<129> all_set= ~zero; - constexpr bitset2<129> sme_set1= - all_set ^ bitset2<129>{ bit12 } ^ bitset2<129>{ bit15 }; - constexpr bitset2<129> b_from_s_arr01a{ s_arr_01a }; - constexpr bitset2<129> b_from_s_arr01b{ s_arr_01b }; - constexpr auto minus_s_arr_01b= complement2( b_from_s_arr01b ); - constexpr auto add_01a_b= b_from_s_arr01a + b_from_s_arr01b; - constexpr auto sub_01a_b= b_from_s_arr01a + minus_s_arr_01b; - constexpr auto inc_01a_5= ce_op( b_from_s_arr01a, 5, 1 ); - constexpr auto inc_01b_5= ce_op( b_from_s_arr01a, 5, 2 ); - constexpr auto dec_01c_5= ce_op( b_from_s_arr01a, 5, 3 ); - constexpr auto dec_01d_5= ce_op( b_from_s_arr01a, 5, 4 ); - - constexpr auto or_01a_b= b_from_s_arr01a | b_from_s_arr01b; - constexpr auto and_01a_b= b_from_s_arr01a & b_from_s_arr01b; - constexpr auto xor_01a_b= b_from_s_arr01a ^ b_from_s_arr01b; - constexpr auto sdi_01a_b= difference( b_from_s_arr01a, b_from_s_arr01b ); - constexpr auto shl4_01a= b_from_s_arr01a << 4; - constexpr auto shr4_01a= b_from_s_arr01a >> 4; - constexpr auto rol4_01a= rotate_left( b_from_s_arr01a, 4 ); - constexpr auto ror4_01a= rotate_right( b_from_s_arr01a, 4 ); - - constexpr auto rev_01a= reverse( b_from_s_arr01a ); - constexpr auto cpl2_01a= complement2( rev_01a ); - constexpr auto xor12_01a= cpl2_01a ^ sme_set1; - constexpr auto xor42_01a= xor12_01a ^ bitset2<129>{ bit42 }; - - constexpr auto pe1= ce_opequal( b_from_s_arr01a, b_from_s_arr01b, 1 ); - constexpr auto oe1= ce_opequal( b_from_s_arr01a, b_from_s_arr01b, 2 ); - constexpr auto ae1= ce_opequal( b_from_s_arr01a, b_from_s_arr01b, 3 ); - constexpr auto xe1= ce_opequal( b_from_s_arr01a, b_from_s_arr01b, 4 ); - constexpr auto de1= ce_opequal( b_from_s_arr01a, b_from_s_arr01b, 5 ); - - constexpr auto sl4_1= ce_shftequal( b_from_s_arr01a, 4, 1 ); - constexpr auto sr4_1= ce_shftequal( b_from_s_arr01a, 4, 2 ); - constexpr auto rl4_1= ce_shftequal( b_from_s_arr01a, 4, 3 ); - constexpr auto rr4_1= ce_shftequal( b_from_s_arr01a, 4, 4 ); - constexpr auto smf_a= ce_sme_fncs( b_from_s_arr01a ); - - static_assert( add_01a_b == inc_01a_5, "" ); - static_assert( add_01a_b == inc_01b_5, "" ); - static_assert( sub_01a_b == dec_01c_5, "" ); - static_assert( sub_01a_b == dec_01d_5, "" ); - static_assert( add_01a_b == pe1, "" ); - static_assert( or_01a_b == oe1, "" ); - static_assert( and_01a_b == ae1, "" ); - static_assert( xor_01a_b == xe1, "" ); - static_assert( sdi_01a_b == de1, "" ); - static_assert( shl4_01a == sl4_1, "" ); - static_assert( shr4_01a == sr4_1, "" ); - static_assert( rol4_01a == rl4_1, "" ); - static_assert( ror4_01a == rr4_1, "" ); - static_assert( xor42_01a == smf_a, "" ); - - std::cout << inc_01a_5 << '\n' << inc_01b_5.to_hex_string() << "\n"; - std::cout << sub_01a_b << '\n' << dec_01c_5.to_hex_string() << "\n"; - - return 0; -} // main diff --git a/ThirdParty/bitset2/tests/test_ullong2array.cpp b/ThirdParty/bitset2/tests/test_ullong2array.cpp deleted file mode 100644 index 7649f6abe9e85a7f69f709eedd062bcbcad9bfa5..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/test_ullong2array.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "ullong2array.hpp" -#include "array2u_long_t.hpp" -#include <iostream> -#include <cstdint> -#include <cassert> - - -int main() -{ - using ULLONG= unsigned long long; - - auto const all_set= ~ULLONG(0); - - using namespace Bitset2::detail; - - using a2l_65ll= Bitset2::detail::array2u_long_t<65,ULLONG,ULLONG>; - - auto const a1= ullong2array<18,uint32_t>()( all_set ); - std::array<uint32_t,1> const expt1{{ uint32_t((1ull << 18) - 1) }}; - size_t ct= 0; - for( auto v: a1 ) - { - std::cout << v << ", "; - assert( v == expt1[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 1 ); - - - auto const a2= ullong2array<34,uint32_t>()( all_set ); - std::array<uint32_t,2> const - expt2{{ uint32_t(~uint32_t(0)), uint32_t((1ull << 2) - 1) }}; - ct= 0; - for( auto v: a2 ) - { - std::cout << v << ", "; - assert( v == expt2[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 2 ); - - - auto const a3= ullong2array<18,uint16_t>()( all_set ); - std::array<uint32_t,2> const - expt3{{ uint16_t(~uint16_t(0)), uint16_t((1ull << 2) - 1) }}; - ct= 0; - for( auto v: a3 ) - { - std::cout << v << ", "; - assert( v == expt3[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 2 ); - - - auto const a4= ullong2array<18,uint8_t>()( all_set ); - std::array<uint8_t,3> const - expt4{{uint8_t(~uint8_t(0)),uint8_t(~uint8_t(0)),uint8_t((1ull << 2) - 1)}}; - ct= 0; - for( auto v: a4 ) - { - std::cout << int(v) << ", "; - assert( v == expt4[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 3 ); - - - auto const a5= ullong2array<18,uint64_t>()( all_set ); - std::array<uint64_t,1> const expt5{{ uint64_t((1ull << 18) - 1) }}; - ct= 0; - for( auto v: a5 ) - { - std::cout << v << ", "; - assert( v == expt5[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 1 ); - - - auto const a6= ullong2array<34,uint64_t>()( all_set ); - std::array<uint64_t,1> const expt6{{ uint64_t((1ull << 34) - 1) }}; - ct= 0; - for( auto v: a6 ) - { - std::cout << v << ", "; - assert( v == expt6[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 1 ); - - - auto const a7= ullong2array<66,uint64_t>()( all_set ); - std::array<uint64_t,2> const - expt7{{ uint64_t(~uint64_t(0)), uint64_t(0) }}; - ct= 0; - for( auto v: a7 ) - { - std::cout << v << ", "; - assert( v == expt7[ct] ); ct++; - } - std::cout << "\n"; - assert( ct == 2 ); - - - a2l_65ll::array_t arr1{{ all_set, 0ull }}; - - std::cout << '\n' << a2l_65ll::i_pttrn << '\n'; - std::cout << a2l_65ll::h_pttrn << '\n'; - std::cout << a2l_65ll::allset << '\n'; - std::cout << a2l_65ll::n_array << '\n'; - std::cout << a2l_65ll::use_vals << '\n'; - std::cout << a2l_65ll().check_overflow( arr1 ) << '\n'; -} diff --git a/ThirdParty/bitset2/tests/tests01.cpp b/ThirdParty/bitset2/tests/tests01.cpp deleted file mode 100644 index 040e578f5c49d8caed9b28e363e288bb3eeca93b..0000000000000000000000000000000000000000 --- a/ThirdParty/bitset2/tests/tests01.cpp +++ /dev/null @@ -1,903 +0,0 @@ -// BITSET2 -// -// Copyright Claas Bontus -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ClaasBontus/bitset2 -// - - -#include "../bitset2.hpp" -#include "gen_randoms.hpp" -#include <bitset> -#include <cassert> -#include <cstdint> -#include <iostream> - -#define TESTMANY(F) \ - F <7 >(); \ - F <8 >(); \ - F <9 >(); \ - F <63 >(); \ - F <64 >(); \ - F <65 >(); \ - F <95 >(); \ - F <96 >(); \ - F <97 >(); \ - F <127>(); \ - F <128>(); \ - F <129>(); \ - F <255>(); \ - F <256>(); \ - F <257>(); - -#define TESTMANY2(F,T,S) \ - F <7, T>(S); \ - F <8, T>(S); \ - F <9, T>(S); \ - F <63, T>(S); \ - F <64, T>(S); \ - F <65, T>(S); \ - F <95, T>(S); \ - F <96, T>(S); \ - F <97, T>(S); \ - F <127,T>(S); \ - F <128,T>(S); \ - F <129,T>(S); \ - F <255,T>(S); \ - F <256,T>(S); \ - F <257,T>(S); - - -#define TESTMNY(F) \ - TESTMANY2(F,uint8_t, "uint8_t" ) \ - TESTMANY2(F,uint16_t,"uint16_t") \ - TESTMANY2(F,uint32_t,"uint32_t") \ - TESTMANY2(F,unsigned long long,"U_L_LONG") - - -template<size_t N,class T=unsigned long long> -using t1= Bitset2::bitset2<N,T>; - -template<size_t N> -using t1a= Bitset2::bitset2<N>; - -template<size_t N> -using t2= std::bitset<N>; - - -constexpr size_t n_loops= 100000; - -constexpr bool verbose= false; - - -template<size_t N,class T> -struct dummy_add -{ - enum : size_t - { ull_bits= sizeof(T) * CHAR_BIT - , div_val= N / ull_bits - , mod_val= N % ull_bits - , n_ull= ( mod_val != 0 ) ? (div_val+1) : div_val - , n_array= ( N == 0 ) ? 1 : n_ull - }; - // - enum : T - { all_one= T(~T(0)) - , hgh_pattern= (N==0) ? T(0) - : (mod_val==0) ? T(all_one) - : T(all_one >> (ull_bits-mod_val)) - }; - // - using array_t= std::array<T,n_array>; - // - array_t - add( array_t const &a1, array_t const &a2 ) const - { - array_t ret_val; - T crry= T(0); - - for( size_t c= 0; c < n_ull; ++c ) - { - T const v= T( a1[c] + a2[c] + crry ); - if( v < a1[c] || v < a2[c] || - ( a1[c] == all_one && a2[c] == all_one ) ) crry= T(1); - else crry= T(0); - ret_val[c]= v; - } - if( n_ull > 0 ) ret_val[n_ull-1] &= hgh_pattern; - - return ret_val; - } // add - // - // Returns false if a1 != a2 - bool - compare( array_t const &a1, array_t const &a2 ) - { - for( size_t c= 0; c < n_array; ++c ) - { - if( a1[c] != a2[c] ) return false; - } - return true; - } -}; // struct dummy_add - - -template<size_t N,class T> -t1<N,T> -dummy_reverse( t1<N,T> const & bs ) -{ - t1<N,T> ret_val; - for( size_t c= 0; c < N; ++c ) ret_val[c]= bs[N-c-1]; - - return ret_val; -} - - - -template<size_t N,class T> -void -test_any_all_none( char const * type_str ) -{ - std::cout << "Entering test_any_all_none N= " << N << " type= " << type_str << "\n"; - - t1<N,T> const empty1; - t2<N> const empty2; - auto const full1= ~empty1; - auto const full2= ~empty2; - - auto const empty1a= t1<N,T>( empty2 ); - auto const empty2a= t2<N>( empty1 ); - auto const full1a= t1<N,T>( full2 ); - auto const full2a= t2<N>( full1 ); - - assert( empty1.none() && !empty1.all() && !empty1.any() ); - assert( empty1a.none() && !empty1a.all() && !empty1a.any() ); - assert( empty2a.none() && !empty2a.all() && !empty2a.any() ); - assert( !full1.none() && full1.all() && full1.any() ); - assert( !full1a.none() && full1a.all() && full1a.any() ); - assert( !full2a.none() && full2a.all() && full2a.any() ); - - - constexpr t1<N,T> ce_empty1; - constexpr auto ce_full1= ~ce_empty1; - static_assert( ce_empty1.none() && !ce_empty1.all() && !ce_empty1.any(), "" ); - static_assert( !ce_full1.none() && ce_full1.all() && ce_full1.any(), "" ); - - - gen_random_bitset2<N,T> gen_rand; - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2= t2<N>( bs1 ); - auto const bs1a= t1<N,T>( bs2 ); - - if( verbose ) std::cout << bs1.to_hex_string() << "\t" << c << "\n"; - - assert( bs1 == bs1a ); - assert( bs1.none() == bs2.none() ); - assert( bs1.all() == bs2.all() ); - assert( bs1.any() == bs2.any() ); - } // for c -} // test_any_all_none - - - - -template<size_t N,class T> -void -test_set_count_size( char const * type_str ) -{ - std::cout << "Entering test_set_count_size N= " << N << " type= " << type_str << "\n"; - - t1<N,T> const empty1; - constexpr t1<N,T> ce_empty1; - constexpr t1<N,T> ce_full1= ~ce_empty1; - assert( empty1.size() == N ); - static_assert( ce_empty1.size() == N, "" ); - static_assert( ce_full1.count() == N, "" ); - static_assert( !ce_empty1.test( N - 3 ), "" ); - static_assert( ce_full1.test( N - 2 ), "" ); - - gen_random_bitset2<N,T> gen_rand; - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const cnt1= bs1.count(); - size_t n_set1= 0, n_set2= 0; - for( size_t b_c= 0; b_c < N; ++b_c ) - { - if( bs1.test( b_c ) ) ++n_set1; - if( bs1[b_c] ) ++n_set2; - } - - if( verbose ) std::cout << bs1.to_hex_string() << "\t" << n_set1 - << "\t" << c << "\t" << bs1 << "\n"; - - auto bs2= bs1; - bs2.flip(); - auto const cnt2= bs2.count(); - - assert( n_set1 == cnt1 ); - assert( n_set1 == n_set2 ); - assert( cnt2 == N - cnt1 ); - } // for c -} // test_set_count_size - - - - -template<size_t N,class T> -void -test_set( char const * type_str ) -{ - std::cout << "Entering test_set N= " << N << " type= " << type_str << "\n"; - - gen_random_bitset2<N,T> gen_rand; - for( size_t c= 0; c < n_loops; ++c ) - { - auto bs1= gen_rand(); - auto bs2= bs1; - auto bs3= t2<N>( bs1 ); - bool flag= false; - for( size_t b= 0; b < N; ++ b ) - { - bool const bt1= bs1[b]; - bs1.set( b, flag ); - auto const bt2= bs2.test_set( b, flag); - assert( bt1 == bt2 ); - bs3.set( b, flag ); - - flag= !flag; - } - assert( bs1 == bs2 ); - assert( bs1 == (t1<N,T>( bs3 )) ); - } // for c -} // test_set - - - - -template<size_t N,class T> -void -test_rotate( char const * type_str ) -{ - std::cout << "Entering test_rotate N= " << N << " type= " << type_str << "\n"; - - constexpr std::array<T,2> ce_arr1{{ T(2), T(5) }}; - constexpr std::array<T,2> ce_arr2{{ T(4), T(10) }}; - constexpr t1<74,T> ce_bs1( ce_arr1 ); - constexpr t1<74,T> ce_bs1_r= Bitset2::rotate_left( ce_bs1, 1 ); - constexpr t1<74,T> ce_bs2( ce_arr2 ); - static_assert( ce_bs1_r == ce_bs2, "" ); - - gen_random_bitset2<N,T> gen_rand; - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const cnt1= bs1.count(); - - for( size_t b_c= 0; b_c < 2 * N; ++b_c ) - { - auto const b_c_mod= b_c % N; - auto const bs2_r= Bitset2::rotate_right( bs1, b_c ); - auto const bs2_l= Bitset2::rotate_left( bs1, b_c ); - auto const bs2a= Bitset2::rotate_left( bs2_r, b_c ); - auto const bs2b= Bitset2::rotate_right( bs2_l, b_c ); - auto const bs2_r2= ( bs1 >> b_c_mod ) | ( bs1 << (N-b_c_mod) ); - auto const bs2_l2= ( bs1 << b_c_mod ) | ( bs1 >> (N-b_c_mod) ); - - auto bc1_c1= bs1; - auto bc1_c2= bs1; - bc1_c1.rotate_left( b_c ); - bc1_c2.rotate_right( b_c ); - - if( verbose ) - std::cout << bs1 << "\t" - << b_c << "\t" - << bs2_l << "\t" - << bs2_r << "\n"; - assert( cnt1 == bs2_r.count() ); - assert( cnt1 == bs2_l.count() ); - assert( bs2a == bs1 ); - assert( bs2b == bs1 ); - assert( bs2_r2 == bs2_r ); - assert( bs2_l2 == bs2_l ); - assert( bc1_c1 == bs2_l ); - assert( bc1_c2 == bs2_r ); - } - } // for c -} // test_rotate - - - - -template<size_t N,class T> -void -test_shift( char const * type_str ) -{ - std::cout << "Entering test_shift N= " << N << " type= " << type_str << "\n"; - - gen_random_bitset2<N,T> gen_rand; - t1<N,T> const empty1; - - constexpr size_t n_bts_m= sizeof(T) * CHAR_BIT - 1; - constexpr std::array<T,2> ce_arr1{{ T(2), T(5) }}; - constexpr std::array<T,2> ce_arr2{{ T(4), T(10) }}; - constexpr std::array<T,2> ce_arr3{{ T(1) + T(T(1) << n_bts_m), T(2) }}; - constexpr t1<74,T> ce_bs1( ce_arr1 ); - constexpr t1<74,T> ce_bs1_s1= ce_bs1 << 1; - constexpr t1<74,T> ce_bs1_s2= ce_bs1 >> 1; - constexpr t1<74,T> ce_bs2( ce_arr2 ); - constexpr t1<74,T> ce_bs3( ce_arr3 ); - static_assert( ce_bs1_s1 == ce_bs2, "" ); - static_assert( ce_bs1_s2 == ce_bs3, "" ); - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - - for( size_t b_c= 0; b_c <= N + 5; ++b_c ) - { - auto const bs1_l= bs1 << b_c; - auto const bs1_r= bs1 >> b_c; - auto bs1_c1= bs1; - auto bs1_c2= bs1; - bs1_c1 <<= b_c; - bs1_c2 >>= b_c; - if( verbose ) - std::cout << bs1 << "\t" - << bs1_l << "\t" - << bs1_r << "\n"; - if( b_c < N ) - { - t2<N> const bs2{ bs1 }; - auto const bs2_l= bs2 << b_c; - auto const bs2_r= bs2 >> b_c; - assert( bs2_l == t2<N>( bs1_l ) ); - assert( bs2_r == t2<N>( bs1_r ) ); - assert( bs1_c1 == bs1_l ); - assert( bs1_c2 == bs1_r ); - } - else - { - assert( bs1_l == empty1 ); - assert( bs1_r == empty1 ); - assert( bs1_c1 == empty1 ); - assert( bs1_c2 == empty1 ); - } - } // for b_c - } // for c -} // test_shift - - - - -template<size_t N,class T> -void -test_add( const char * type_str ) -{ - std::cout << "Entering test_add N= " << N << " type= " << type_str << "\n"; - - gen_random_bitset2<N,T> gen_rand; - dummy_add<N,T> adder; - t1<N,T> const zero; - t1<N,T> const one{{ T(1) }}; - t1<N,T> const all= t1<N,T>().set(); - - auto const all_twice= all + all; - auto all_twice2= all; - all_twice2 += all; - auto a_m1= all; - a_m1--; - auto a_m2= a_m1; - a_m2--; - auto all_twice_m1= all + a_m1; - assert( all_twice == a_m1 ); - assert( all_twice2 == a_m1 ); - assert( all_twice_m1 == a_m2 ); - - constexpr t1<N,T> ce_one{{ T(1) }}; - constexpr t1<N,T> ce_empty; - constexpr t1<N,T> ce_all= ~ce_empty; - constexpr t1<N,T> ce_all_but_one= ~ce_one; - constexpr auto ce_all_twice= ce_all + ce_all; - static_assert( ce_all_twice == ce_all_but_one, "" ); - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2= gen_rand(); - auto bs3= bs1; - auto bs4= bs1; - auto bs5= bs1; - ++bs3; --bs4; - bs5 += bs2; - - auto const add1= bs1 + bs2; - auto const add2= adder.add( bs1.data(), bs2.data() ); - auto const add3= adder.add( bs1.data(), one.data() ); - auto const add4= adder.add( bs1.data(), all.data() ); - if( verbose ) - std::cout << " " << bs1 << "\n+ " << bs2 - << "\n= " << add1 - << "\n, " << t1<N,T>(add2) << "\n\n"; - auto const cmp1= adder.compare( add2, add1.data() ); - auto const cmp2= adder.compare( add3, bs3.data() ); - auto const cmp3= adder.compare( add4, bs4.data() ); - auto const cmp4= adder.compare( add2, bs5.data() ); - - auto const exp_zero= bs1 + (~bs1 + one); - - assert( cmp1 ); - assert( cmp2 ); - assert( cmp3 ); - assert( cmp4 ); - assert( exp_zero == zero ); - } // for c -} // test_add - - - - -template<size_t N,class T> -void -test_difference( char const * type_str ) -{ - std::cout << "Entering test_difference N= " << N << " type= " << type_str << "\n"; - - constexpr std::array<T,2> ce_arr1{{ T(3), T(5) }}; - constexpr std::array<T,2> ce_arr2{{ T(6), T(1) }}; - constexpr t1<74,T> ce_bs1( ce_arr1 ); - constexpr t1<74,T> ce_bs2( ce_arr2 ); - constexpr auto ce_diff1= Bitset2::difference( ce_bs1, ce_bs2 ); - constexpr auto ce_ref1= ce_bs1 & ~ce_bs2; - static_assert( ce_diff1 == ce_ref1, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2= gen_rand(); - auto bs3= bs1; - - auto const d1= Bitset2::difference( bs1, bs2 ); - auto const d2= bs1 & ~bs2; - bs3.difference( bs2 ); - - assert( d2 == d1 ); - assert( bs3 == d1 ); - } // for c -} // test_difference - - - - - -template<size_t N,class T> -void -test_not( char const * type_str ) -{ - std::cout << "Entering test_not N= " << N << " type= " << type_str << "\n"; - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2= ~bs1; - for( size_t b_c= 0; b_c < N; ++b_c ) - { - if( verbose ) std::cout << "~" << bs1 << "\n=" << bs2 << "\n"; - assert( bs1[b_c] != bs2[b_c] ); - } - } // for c -} // test_not - - -template<size_t N,class T> -std::vector<size_t> -idx_lst( t1<N,T> const &bs ) -{ - std::vector<size_t> ret_val; - for( size_t c= 0; c < N; ++c ) - if( bs[c] ) ret_val.push_back( c ); - return ret_val; -} // idx_lst - - - -template<size_t N,class T> -void -test_find( char const * type_str ) -{ - std::cout << "Entering test_find N= " << N << " type= " << type_str << "\n"; - - constexpr t1<N,T> ce_bs1( 12ull ); - static_assert( ce_bs1.find_first() == 2, "" ); - static_assert( ce_bs1.find_next( 2 ) == 3, "" ); - static_assert( ce_bs1.find_next( 3 ) == t1<N,T>::npos, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < N; ++ c) - { - auto bs1= t1<N,T>(); - - assert( bs1.find_first() == (Bitset2::bitset2<N,T>::npos) ); - assert( bs1.find_next(0) == (Bitset2::bitset2<N,T>::npos) ); - - bs1[c]= true; - assert( bs1.find_first() == c ); - if( c > 0 ) - { - assert( bs1.find_next( c - 1 ) == c ); - - bs1[0]= true; - bs1[N-1]= true; - assert( bs1.find_first() == 0 ); - auto idx= bs1.find_next( c ); - if( c < N - 1 ) assert( idx == N - 1 ); - else assert( idx == (Bitset2::bitset2<N,T>::npos) ); - - for( size_t b= 0; b < c; ++b ) bs1[b]= true; - idx= bs1.find_next( c ); - if( c < N - 1 ) assert( idx == N - 1 ); - else assert( idx == (Bitset2::bitset2<N,T>::npos) ); - } - } // for c - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const lst= idx_lst( bs1 ); - if( lst.empty() ) assert( bs1.find_first() == (Bitset2::bitset2<N,T>::npos) ); - else - { - auto b_it= lst.begin(); - auto e_it= lst.end(); - auto idx= bs1.find_first(); - assert( idx == *(b_it++) ); - for( ; b_it != e_it; ++b_it ) - { - idx= bs1.find_next( idx ); - assert( idx == *b_it ); - } - idx= bs1.find_next( idx ); - assert( idx == (Bitset2::bitset2<N,T>::npos) ); - } - } // for c - -} // test_find - - - - -template<size_t N,class T> -void -test_bitwise_ops( char const * type_str ) -{ - std::cout << "Entering test_bitwise_ops N= " << N << " type= " << type_str << "\n"; - - constexpr std::array<T,2> ce_arr1{{ T(3), T(5) }}; - constexpr std::array<T,2> ce_arr2{{ T(5), T(1) }}; - constexpr std::array<T,2> ce_e_or{{ T(7), T(5) }}; - constexpr std::array<T,2> ce_e_and{{ T(1), T(1) }}; - constexpr std::array<T,2> ce_e_xor{{ T(6), T(4) }}; - constexpr t1<74,T> ce_bs1( ce_arr1 ); - constexpr t1<74,T> ce_bs2( ce_arr2 ); - constexpr t1<74,T> ce_bs_e_or( ce_e_or ); - constexpr t1<74,T> ce_bs_e_and( ce_e_and ); - constexpr t1<74,T> ce_bs_e_xor( ce_e_xor ); - constexpr auto ce_or= ce_bs1 | ce_bs2; - constexpr auto ce_and= ce_bs1 & ce_bs2; - constexpr auto ce_xor= ce_bs1 ^ ce_bs2; - static_assert( ce_or == ce_bs_e_or, "" ); - static_assert( ce_and == ce_bs_e_and, "" ); - static_assert( ce_xor == ce_bs_e_xor, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2= gen_rand(); - auto const b_or= bs1 | bs2; - auto const b_and= bs1 & bs2; - auto const b_xor= bs1 ^ bs2; - - auto const sbs1= t2<N>( bs1 ); - auto const sbs2= t2<N>( bs2 ); - auto const sb_or= sbs1 | sbs2; - auto const sb_and= sbs1 & sbs2; - auto const sb_xor= sbs1 ^ sbs2; - - if( verbose ) - std::cout << " " << bs1 << " op " << bs2 - << "\nop= |: " << b_or - << "\nop= &: " << b_and - << "\nop= ^: " << b_xor << "\n"; - - assert( sb_or == t2<N>( b_or ) ); - assert( sb_and == t2<N>( b_and ) ); - assert( sb_xor == t2<N>( b_xor ) ); - } // for c -} // test_bitwise_ops - - - - -template<size_t N,class T> -void -test_reverse( char const * type_str ) -{ - std::cout << "Entering test_reverse N= " << N << " type= " << type_str << "\n"; - - constexpr t1<N,T> ce_bs1( 3ull ); - constexpr auto ce_bs1_rev= Bitset2::reverse( ce_bs1 ); - constexpr auto ce_bs1_rot= Bitset2::rotate_right( ce_bs1, 2 ); - static_assert( ce_bs1_rev == ce_bs1_rot, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto bs2= bs1; - auto const bs3= dummy_reverse( bs1 ); - auto const bs4= Bitset2::reverse( bs1 ); - bs2.reverse(); - if( verbose ) - std::cout << " " << bs1 - << "\n2 " << bs2 - << "\n3 " << bs3 << '\n'; - assert( bs2 == bs3 ); - assert( bs4 == bs3 ); - bs2.reverse(); - assert( bs2 == bs1 ); - } // for c -} // test_reverse - - - -template<size_t N,class T> -void -test_convert( char const * type_str ) -{ - std::cout << "Entering test_convert N= " << N << " type= " << type_str << "\n"; - - constexpr t1<N,T> ce_bs1( 0ull ); - constexpr auto ce_bs2= ~ce_bs1; - constexpr auto ce_bs2a= ce_bs2 >> 1; - constexpr auto ce_bs2b= Bitset2::convert_to<N-1>( ce_bs2 ); - constexpr auto ce_bs2c= Bitset2::convert_to<N>( ce_bs2b ); - constexpr auto ce_bs2d= Bitset2::convert_to<N+1>( ce_bs2 ); - constexpr auto ce_bs2e= Bitset2::convert_to<N>( ce_bs2d ); - static_assert( ce_bs2c == ce_bs2a, "" ); - static_assert( ce_bs2e == ce_bs2, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto const bs2a= bs1 & ce_bs2a; - auto const bs2b= Bitset2::convert_to<N-1>( bs1 ); - auto const bs2c= Bitset2::convert_to<N>( bs2b ); - auto const bs2d= Bitset2::convert_to<N+1>( bs1 ); - auto const bs2e= Bitset2::convert_to<N>( bs2d ); - assert( bs2c == bs2a ); - assert( bs2e == bs1 ); - - auto const bs3a= Bitset2::convert_to<N,uint8_t>( bs1 ); - auto const bs3b= Bitset2::convert_to<N,T>( bs3a ); - auto const bs3c= Bitset2::convert_to<N,uint32_t>( bs3a ); - auto const bs4a= Bitset2::convert_to<N,uint64_t>( bs1 ); - auto const bs4b= Bitset2::convert_to<N,T>( bs4a ); - auto const bs5a= Bitset2::convert_to<N,uint64_t>( bs3a ); - auto const bs5b= Bitset2::convert_to<N,T>( bs5a ); - auto const bs5c= Bitset2::convert_to<N,uint32_t>( bs5a ); - assert( bs3b == bs1 ); - assert( bs4b == bs1 ); - assert( bs5b == bs1 ); - assert( bs3c == bs5c ); - - const Bitset2::bitset2<N,uint8_t> bs_1a{ bs1.data() }; - const Bitset2::bitset2<N,uint64_t> bs_1b{ bs1.data() }; - assert( bs_1a == bs3a ); - assert( bs_1b == bs4a ); - } // for c -} // test_convert - - - - -template<size_t N,class T> -void -test_compare( char const * type_str ) -{ - std::cout << "Entering test_compare N= " << N << " type= " << type_str << "\n"; - - constexpr t1<N,T> ce_bs1( 0ull ); - constexpr auto ce_bs2= ~ce_bs1; - constexpr auto ce_bs2a= ce_bs2 >> 1; - constexpr auto ce_bs2b= ce_bs2a; - static_assert( ce_bs2a < ce_bs2, "" ); - static_assert( ce_bs2b <= ce_bs2a, "" ); - static_assert( ce_bs2 > ce_bs2a, "" ); - static_assert( ce_bs2a >= ce_bs2b, "" ); - static_assert( ce_bs2a != ce_bs2, "" ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1= gen_rand(); - auto bs2= bs1; - auto const bs3= bs1; - --bs2; - if( bs1 != ce_bs1 ) - { - assert( bs2 < bs1 ); - assert( bs2 <= bs1 ); - assert( bs1 > bs2 ); - assert( bs1 >= bs1 ); - } - else - { - assert( bs1 == ce_bs1 ); - } - assert( bs3 <= bs1 ); - assert( bs3 >= bs1 ); - } // for c -} // test_compare - - - - -template<size_t N,class T> -void -test_complement2( char const * type_str ) -{ - std::cout << "Entering test_complement2 N= " << N << " type= " << type_str << "\n"; - - constexpr t1<N,T> zero( 0ull ); - constexpr auto allset= ~zero; - auto one= zero; - ++one; - - constexpr auto ce_bs1= Bitset2::complement2( zero ); - constexpr auto ce_bs2= Bitset2::complement2( allset ); - auto bs1= zero; - auto bs2= allset; - bs1.complement2(); - bs2.complement2(); - static_assert( ce_bs1 == zero, "" ); - assert( bs1 == zero ); - assert( bs2 == one ); - assert( ce_bs2 == one ); - - gen_random_bitset2<N,T> gen_rand; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs_1a= gen_rand(); - auto bs_1b= bs_1a; - auto const bs_1c= ~bs_1a + one; - auto const bs_2a= Bitset2::complement2( bs_1a ); - bs_1b.complement2(); - assert( bs_1a + bs_2a == zero ); - assert( bs_1a + bs_1b == zero ); - assert( bs_1b == bs_1c ); - } // for c -} // test_complement2 - - - -template<size_t N> -void -test_hash() -{ - std::cout << "Entering test_hash N= " << N << "\n"; - - gen_random_bitset2<N,uint8_t> gen_rand8; - gen_random_bitset2<N,uint16_t> gen_rand16; - gen_random_bitset2<N,uint32_t> gen_rand32; - gen_random_bitset2<N,uint64_t> gen_rand64; - - for( size_t c= 0; c < n_loops; ++c ) - { - auto const bs1_8= gen_rand8(); - auto const bs1a_8= t2<N>( bs1_8 ); - auto const bs2_8= t1<N,uint16_t>( bs1a_8 ); - auto const bs3_8= t1<N,uint32_t>( bs1a_8 ); - auto const bs4_8= t1<N,uint64_t>( bs1a_8 ); - - auto const hs1_8= std::hash<std::remove_cv_t<decltype(bs1_8)> >{}( bs1_8 ); - auto const hs2_8= std::hash<std::remove_cv_t<decltype(bs2_8)> >{}( bs2_8 ); - auto const hs3_8= std::hash<std::remove_cv_t<decltype(bs3_8)> >{}( bs3_8 ); - auto const hs4_8= std::hash<std::remove_cv_t<decltype(bs4_8)> >{}( bs4_8 ); - assert( hs1_8 == hs2_8 ); - assert( hs1_8 == hs3_8 ); - assert( hs1_8 == hs4_8 ); - - - auto const bs1_16= gen_rand16(); - auto const bs1a_16= t2<N>( bs1_16 ); - auto const bs2_16= t1<N,uint8_t>( bs1a_16 ); - auto const bs3_16= t1<N,uint32_t>( bs1a_16 ); - auto const bs4_16= t1<N,uint64_t>( bs1a_16 ); - - auto const hs1_16= std::hash<std::remove_cv_t<decltype(bs1_16)> >{}( bs1_16 ); - auto const hs2_16= std::hash<std::remove_cv_t<decltype(bs2_16)> >{}( bs2_16 ); - auto const hs3_16= std::hash<std::remove_cv_t<decltype(bs3_16)> >{}( bs3_16 ); - auto const hs4_16= std::hash<std::remove_cv_t<decltype(bs4_16)> >{}( bs4_16 ); - assert( hs1_16 == hs2_16 ); - assert( hs1_16 == hs3_16 ); - assert( hs1_16 == hs4_16 ); - - - auto const bs1_32= gen_rand32(); - auto const bs1a_32= t2<N>( bs1_32 ); - auto const bs2_32= t1<N,uint8_t>( bs1a_32 ); - auto const bs3_32= t1<N,uint16_t>( bs1a_32 ); - auto const bs4_32= t1<N,uint64_t>( bs1a_32 ); - - auto const hs1_32= std::hash<std::remove_cv_t<decltype(bs1_32)> >{}( bs1_32 ); - auto const hs2_32= std::hash<std::remove_cv_t<decltype(bs2_32)> >{}( bs2_32 ); - auto const hs3_32= std::hash<std::remove_cv_t<decltype(bs3_32)> >{}( bs3_32 ); - auto const hs4_32= std::hash<std::remove_cv_t<decltype(bs4_32)> >{}( bs4_32 ); - assert( hs1_32 == hs2_32 ); - assert( hs1_32 == hs3_32 ); - assert( hs1_32 == hs4_32 ); - - - auto const bs1_64= gen_rand64(); - auto const bs1a_64= t2<N>( bs1_64 ); - auto const bs2_64= t1<N,uint8_t>( bs1a_64 ); - auto const bs3_64= t1<N,uint16_t>( bs1a_64 ); - auto const bs4_64= t1<N,uint32_t>( bs1a_64 ); - - auto const hs1_64= std::hash<std::remove_cv_t<decltype(bs1_64)> >{}( bs1_64 ); - auto const hs2_64= std::hash<std::remove_cv_t<decltype(bs2_64)> >{}( bs2_64 ); - auto const hs3_64= std::hash<std::remove_cv_t<decltype(bs3_64)> >{}( bs3_64 ); - auto const hs4_64= std::hash<std::remove_cv_t<decltype(bs4_64)> >{}( bs4_64 ); - assert( hs1_64 == hs2_64 ); - assert( hs1_64 == hs3_64 ); - assert( hs1_64 == hs4_64 ); - } // for c -} // test_hash - - - -int -main() -{ - std::cout << "sizeof( bitset2<8> )= " << sizeof( t1a<8> ) << '\n'; - std::cout << "sizeof( bitset2<16> )= " << sizeof( t1a<16> ) << '\n'; - std::cout << "sizeof( bitset2<32> )= " << sizeof( t1a<32> ) << '\n'; - std::cout << "sizeof( bitset2<64> )= " << sizeof( t1a<64> ) << '\n'; - std::cout << "sizeof( bitset2<65> )= " << sizeof( t1a<65> ) << '\n'; - - TESTMNY(test_complement2) - TESTMNY(test_convert) - TESTMNY(test_add) - TESTMNY(test_compare) - TESTMNY(test_reverse) - TESTMNY(test_find) - TESTMNY(test_difference) - TESTMNY(test_any_all_none) - TESTMNY(test_set_count_size) - TESTMNY(test_set) - TESTMNY(test_not) - TESTMNY(test_bitwise_ops) - TESTMNY(test_shift) - TESTMNY(test_rotate) - - TESTMANY(test_hash) -} // main diff --git a/ThirdParty/phys/units/quantity.hpp b/ThirdParty/phys/units/quantity.hpp index bec55318685ffb0e69bfeeb19260ef20e6d1eed1..06fbb4b2c760dfc8641d58392aa30062ff7c4e84 100644 --- a/ThirdParty/phys/units/quantity.hpp +++ b/ThirdParty/phys/units/quantity.hpp @@ -144,9 +144,18 @@ namespace phys { d8 = DX::dim8 + DY::dim8 }; - typedef Collapse<dimensions<d1, d2, d3, d4, d5, d6, d7, d8>, T> type; + typedef dimensions<d1, d2, d3, d4, d5, d6, d7, d8> dim; + + typedef Collapse<dim, T> type; }; + /** + * convenience type for product dimension + */ + + template <typename DX, typename DY> + using product_d = typename product<DX, DY, Rep>::dim; + template <typename DX, typename DY, typename X, typename Y> using Product = typename product<DX, DY, PromoteMul<X, Y>>::type; @@ -166,9 +175,18 @@ namespace phys { d8 = DX::dim8 - DY::dim8 }; - typedef Collapse<dimensions<d1, d2, d3, d4, d5, d6, d7, d8>, T> type; + typedef dimensions<d1, d2, d3, d4, d5, d6, d7, d8> dim; + + typedef Collapse<dim, T> type; }; + /** + * convenience type for quotient dimension + */ + + template <typename DX, typename DY> + using quotient_d = typename quotient<DX, DY, Rep>::dim; + template <typename DX, typename DY, typename X, typename Y> using Quotient = typename quotient<DX, DY, PromoteMul<X, Y>>::type; @@ -188,9 +206,18 @@ namespace phys { d8 = -D::dim8 }; - typedef Collapse<dimensions<d1, d2, d3, d4, d5, d6, d7, d8>, T> type; + typedef dimensions<d1, d2, d3, d4, d5, d6, d7, d8> dim; + + typedef Collapse<dim, T> type; }; + /** + * convenience type for reciprocal dimension + */ + + template <typename DX, typename DY> + using reciprocal_d = typename reciprocal<DX, Rep>::dim; + template <typename D, typename X, typename Y> using Reciprocal = typename reciprocal<D, PromoteMul<X, Y>>::type; @@ -210,11 +237,20 @@ namespace phys { d8 = N * D::dim8 }; - typedef Collapse<dimensions<d1, d2, d3, d4, d5, d6, d7, d8>, T> type; + typedef dimensions<d1, d2, d3, d4, d5, d6, d7, d8> dim; + + typedef Collapse<dim, T> type; }; + /** + * convenience type for power dimension + */ + + template <typename DX, int N> + using power_d = typename power<DX, N, Rep>::dim; + template <typename D, int N, typename T> - using Power = typename detail::power<D, N, T>::type; + using Power = typename power<D, N, T>::type; /** * root type generator. @@ -238,9 +274,17 @@ namespace phys { d8 = D::dim8 / N }; - typedef Collapse<dimensions<d1, d2, d3, d4, d5, d6, d7, d8>, T> type; + typedef dimensions<d1, d2, d3, d4, d5, d6, d7, d8> dim; + + typedef Collapse<dim, T> type; }; + /** + * convenience type for root dimension + */ + template <typename D, int N> + using root_d = typename root<D, N, Rep>::dim; + template <typename D, int N, typename T> using Root = typename detail::root<D, N, T>::type;