MoCSI API Reference
Loading...
Searching...
No Matches
HeatConductivityVariableGundlach2013RegolithSolid.h
Go to the documentation of this file.
1#ifndef HEAT_CONDUCTIVITY_VARIABLE_GUNDLACH_2013_REGOLITH_SOLID_H
2#define HEAT_CONDUCTIVITY_VARIABLE_GUNDLACH_2013_REGOLITH_SOLID_H
3
4#define HEAT_CONDUCTIVITY_VARIABLE_GUNDLACH_2013_REGOLITH_SOLID_VERSION "7"
5
6#include <iostream>
7#include <memory>
8#include <numbers>
9#include <string>
10#include <valarray>
11
12#include "../../src/GenericSubmodule.h"
13#include "../../src/ModuleFactory.h"
14
31template <typename T>
33{
34 private:
35 static bool m_registered;
36 std::string m_ini_filepath{
37 "heat_conductivity/HeatConductivityVariableGundlach2013RegolithSolid.ini"};
38 T m_stefan_boltzmann_const{};
39 T m_boltzmann_const{};
40 T m_solar_const{};
41 T m_gas_const{};
42 T m_poissons_ratio{};
43 T m_youngs_modulus{};
44 T m_f1{};
45 T m_f2{};
46 T m_chi{};
47 T m_e1{};
48 T m_grain_radius{};
49 T m_volume_filling_factor{};
50 T m_emissivity{};
51
52 public:
54 bool setup(std::vector<std::shared_ptr<GenericSubmodule<T>>> all_submodules)
55 override; // loads module into necessary module chains (auto load for calculation
56 // chains)
57 bool exec(std::string_view param) override; // main functionality of the module
58
59 bool init() override;
60 bool preTimeStep() override;
61 bool postTimeStep() override { return true; };
62 bool output() override { return true; };
63
65
66 void setFieldPtr(std::shared_ptr<std::valarray<T>> field_ptr) override
67 {
68 this->module_field = field_ptr;
69 }
70
71 static std::shared_ptr<GenericSubmodule<T>> createMethode(SimulationClassBase<T>* sim)
72 {
73 return std::make_shared<HeatConductivityVariableGundlach2013RegolithSolid<T>>(sim);
74 }
75 static std::string getName() { return "HeatConductivityVariableGundlach2013RegolithSolid"; }
76 std::string_view getNameLocal() const override
77 {
78 return "HeatConductivityVariableGundlach2013RegolithSolid";
79 };
80 std::vector<std::string> getDependencies() const override
81 {
82 return this->ini_file_data.getStringVectorParameters("dependencies");
83 };
84};
85
86// ================= Implementation =================
87
88template <typename T>
91 : GenericSubmodule<T>(sim)
92{
93 try
94 {
95 std::string ini_folder_path{
96 this->sim->m_simulation_config.getStringParameters("ini_folder_path")};
97 this->ini_file_data.loadUserInput(ini_folder_path + m_ini_filepath);
99 }
100 catch (const BadInput& e)
101 {
102 std::cerr << "[HeatConductivityVariableGundlach2013RegolithSolid]: " << e.what() << '\n';
103 throw BadInput(
104 static_cast<std::string>("[HeatConductivityVariableGundlach2013RegolithSolid]: ")
105 + static_cast<std::string>(e.what()));
106 }
107}
108
109template <typename T>
111 std::vector<std::shared_ptr<GenericSubmodule<T>>> all_submodules)
112{
113 try
114 {
115 m_stefan_boltzmann_const =
116 this->ini_file_data.getDoubleParameters("stefan_boltzmann_const");
117 m_boltzmann_const = this->ini_file_data.getDoubleParameters("boltzmann_const");
118 m_solar_const = this->ini_file_data.getDoubleParameters("solar_const");
119 m_gas_const = this->ini_file_data.getDoubleParameters("gas_const");
120 m_poissons_ratio = this->ini_file_data.getDoubleParameters("poissons_ratio");
121 m_youngs_modulus = this->ini_file_data.getDoubleParameters("youngs_modulus");
122 m_f1 = this->ini_file_data.getDoubleParameters("f1");
123 m_f2 = this->ini_file_data.getDoubleParameters("f2");
124 m_chi = this->ini_file_data.getDoubleParameters("chi");
125 m_e1 = this->ini_file_data.getDoubleParameters("e1");
126 m_grain_radius = this->ini_file_data.getDoubleParameters("grain_radius");
127 m_volume_filling_factor = this->ini_file_data.getDoubleParameters("volume_filling_factor");
128
129 this->setSubmodules(all_submodules);
130
131 this->is_set_up = true;
132 }
133 catch (const BadInput& e)
134 {
135 std::cerr << "[HeatConductivityVariableGundlach2013RegolithSolid]: " << e.what() << '\n';
136 throw BadInput(
137 static_cast<std::string>("[HeatConductivityVariableGundlach2013RegolithSolid]: ")
138 + static_cast<std::string>(e.what()));
139 }
140 return true;
141}
142
143template <typename T>
145{
146 if (param == "InitChain")
147 {
148 return init();
149 }
150 if (param == "PreTimeStepChain")
151 {
152 return preTimeStep();
153 }
154 if (param == "PostTimeStepChain")
155 {
156 return postTimeStep();
157 }
158 if (param == "OutputChain")
159 {
160 return output();
161 }
162 return false;
163}
164
170template <typename T>
172{
173 try
174 {
175 m_emissivity = this->sim->getField("Emissivity")[0];
176 }
177 catch (const BadInput& e)
178 {
179 std::cerr << "[HeatConductivityVariableGundlach2013RegolithSolid]: Emissivity module not "
180 "loaded or accessable!\n [HeatConductivityVariableGundlach2013RegolithSolid]:"
181 << e.what() << '\n';
182 throw BadInput(static_cast<std::string>(
183 "[HeatConductivityVariableGundlach2013RegolithSolid]: Emissivity module "
184 "not loaded or "
185 "accessable!\n [HeatConductivityVariableGundlach2013RegolithSolid]:")
186 + static_cast<std::string>(e.what()));
187 }
188 const std::valarray<T>& temperature{this->sim->getField("Temperature")};
189 this->sub_module_chain.runChain("PreTimeStepChain"); // Solid heat conductivity
190 for (int i = 0; i < temperature.size(); ++i)
191 {
192 (*this->module_field)[i] =
193 8 * (this->m_stefan_boltzmann_const) * (this->m_emissivity)
194 * std::pow(temperature[i], 3.) * (this->m_e1)
195 * (1 - (this->m_volume_filling_factor)) / (this->m_volume_filling_factor)
196 * (this->m_grain_radius)
197 + (*this->module_field)[i]
198 * std::pow(
199 (9. * std::numbers::pi / 4.)
200 * ((1. - std::pow(this->m_poissons_ratio, 2)) / (this->m_youngs_modulus))
201 * (6.67e-5 * temperature[i]) / (this->m_grain_radius),
202 (1. / 3.))
203 * (this->m_f1)
204 * std::pow((this->m_f2) * (this->m_volume_filling_factor), std::numbers::e)
205 * (this->m_chi);
206 }
207}
208
209template <typename T>
211{
212 calculateHeatConductivity();
213 return true;
214}
215
216template <typename T>
218{
219 calculateHeatConductivity();
220 return true;
221}
222
223template <typename T>
225 ModuleFactory<T>::registerModule(getName(), createMethode);
226
227#endif // HEAT_CONDUCTIVITY_VARIABLE_GUNDLACH_2013_REGOLITH_SOLID_H
This error class inherits from std::exception and marks faulty parameter or CL inputs....
Definition IniParser.h:71
const char * what() const noexcept override
Definition IniParser.h:78
Abstract base class for the submodules. Submodules are below managing modules and will only be run by...
Definition GenericSubmodule.h:25
InputManager ini_file_data
Definition GenericSubmodule.h:36
std::vector< std::string > m_generic_submodules
Definition GenericSubmodule.h:34
const SimulationClassBase< T > * sim
Definition GenericSubmodule.h:32
std::shared_ptr< std::valarray< T > > module_field
Definition GenericSubmodule.h:29
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:33
bool preTimeStep() override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:210
bool output() override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:62
static std::string getName()
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:75
std::string_view getNameLocal() const override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:76
bool init() override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:217
std::vector< std::string > getDependencies() const override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:80
bool setup(std::vector< std::shared_ptr< GenericSubmodule< T > > > all_submodules) override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:110
static std::shared_ptr< GenericSubmodule< T > > createMethode(SimulationClassBase< T > *sim)
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:71
void calculateHeatConductivity()
Heat conductivity formulation from Gundlach and Blum 2013.
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:171
bool exec(std::string_view param) override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:144
bool postTimeStep() override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:61
void setFieldPtr(std::shared_ptr< std::valarray< T > > field_ptr) override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:66
std::vector< std::string > getStringVectorParameters(const std::string &key) const
Definition InputManager.cpp:508
void loadUserInput(const std::string &user_ini_file_path)
Public function to load and merge user supplied ini files with the already stored data.
Definition InputManager.cpp:45
std::string getStringParameters(const std::string &key) const
Getter function to access the m_parameters map and returns a string. Throws a BadInput error,...
Definition InputManager.cpp:498
static constexpr bool registerModule(std::string name, creation_method module) noexcept
Function that adds a module to the module registry map.
Definition ModuleFactory.h:76
Definition SimulationClassBase.h:19
InputManager m_simulation_config
Definition SimulationClassBase.h:29