From 58d151c09caf40d8ed9b64e5c9b937604515b8b9 Mon Sep 17 00:00:00 2001 From: hrocho Date: Tue, 12 Dec 2017 17:18:26 +0100 Subject: [PATCH] compunt materials update --- material_database.cpp | 52 +++++++++++++++++++---------------- material_database.h | 55 +++++++++++++++++++------------------ tests/test_calculations.cpp | 2 +- tests/test_structures.cpp | 2 +- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/material_database.cpp b/material_database.cpp index b39793b..36990c3 100644 --- a/material_database.cpp +++ b/material_database.cpp @@ -7,31 +7,35 @@ namespace catima{ if(id>0 && id(id)); + } + + Material get_compound(material m){ + switch(m){ + case material::Plastics: return Material({{0,1,10},{0,6,9}},1.032); + case material::Air: return Material({{0,7,0.781},{0,8,0.2095},{0,18,0.0095}},0.0012); + case material::CH2: return Material({{0,6,1},{0,1,2}},0.94); + case material::LH2: return Material({{0,1,1}},0.0708); + case material::LD2: return Material({{2.01355,1,1}},0.162); + case material::Water: return Material({{0,1,2},{0,8,1}},1); + case material::Diamond: return Material({{0,6,1}},3.52); + case material::Glass: return Material({{0,14,1},{0,8,2}},2.4); + case material::ALMG3: return Material({{0,13,1}},2.67); + case material::ArCO2_30: return Material({{0,18,7},{0,8,6},{0,6,3}},0.00171); + case material::CF4: return Material({{0,6,1},{0,9,4}},0.00372); + case material::Isobutane: return Material({{0,6,4},{0,1,10}},0.00251); + case material::Kapton: return Material({{0,1,10},{0,6,22},{0,7,2},{0,8,5}},1.42); + case material::Mylar: return Material({{0,6,5},{0,1,4},{0,8,2}},1.38); + case material::NaF: return Material({{0,11,1},{0,9,1}},2.56); + case material::P10: return Material({{0,18,9},{0,6,1},{0,1,4}},0.00166); + case material::PolyOlefin: return Material({{0,8,10},{0,1,16}},0.9); + case material::CmO2: return Material({{0,96,1},{0,8,2}},12); + case material::Suprasil: return Material({{0,14,1},{0,8,2}},2.2); + case material::HAVAR: return Material({{0,27,42},{0,24,20},{0,28,13},{0,74,3},{0,42,2},{0,26,20}},8.3); + case material::Steel: return Material({{0,26,74},{0,24,18},{0,28,8}},8); default:break; } return Material(); - } + } -} +} // namespace catima diff --git a/material_database.h b/material_database.h index 168e423..bfb75d3 100644 --- a/material_database.h +++ b/material_database.h @@ -4,33 +4,36 @@ namespace catima{ - //namespace material{ - enum material{ - PLASTIC = 201, - AIR = 202, - CH2, - LH2, - LD2, - WATER, - DIAMOND, - GLASS, - ALMG3, - ARCO2_30, - CF4, - ISOBUTANE, - KAPTON, - MYLAR, - NAF, - P10, - POLYOLEFIN, - CMO2, - SUPRASIL, - HAVAR, - STEEL = 221 + enum class material{ + Plastics = 201, + Air = 202, + CH2 = 203, + LH2 = 204, + LD2 = 205, + Water = 206, + Diamond = 207, + Glass = 208, + ALMG3 = 209, + ArCO2_30 = 210, + CF4 = 211, + Isobutane = 212, + Kapton = 213, + Mylar = 214, + NaF = 215, + P10 = 216, + PolyOlefin = 217, + CmO2 = 218, + Suprasil = 219, + HAVAR = 220, + Steel = 221 }; - //} - Material get_material(int); + Material get_compound(material m); + Material get_material(int id); + inline Material get_material(material m){ + return get_compound(m); + }; + } -#endif \ No newline at end of file +#endif diff --git a/tests/test_calculations.cpp b/tests/test_calculations.cpp index af6bb3d..868834a 100644 --- a/tests/test_calculations.cpp +++ b/tests/test_calculations.cpp @@ -330,7 +330,7 @@ const lest::test specification[] = }, CASE("default material calculations"){ catima::Projectile p{12,6,6,350}; - auto air = catima::get_material(catima::material::AIR); + auto air = catima::get_material(catima::material::Air); air.thickness(0.500); auto res = catima::calculate(p(350),air); EXPECT(res.Eout == approx(345.6).epsilon(1e-2)); diff --git a/tests/test_structures.cpp b/tests/test_structures.cpp index a9c83b2..0d9ea69 100644 --- a/tests/test_structures.cpp +++ b/tests/test_structures.cpp @@ -70,7 +70,7 @@ const lest::test specification[] = EXPECT(m.density() == 2.0); EXPECT(m.M() == 12.0107); - m = catima::get_material(catima::material::WATER); + m = catima::get_material(catima::material::Water); EXPECT(m.get_element(0).first.A == 1.00794); EXPECT(m.get_element(0).first.Z == 1); EXPECT(m.get_element(1).first.A == 15.9994);