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 VERSION "5"
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 << e.what() << '\n';
103 }
104 m_stefan_boltzmann_const = this->ini_file_data.getDoubleParameters("stefan_boltzmann_const");
105 m_boltzmann_const = this->ini_file_data.getDoubleParameters("boltzmann_const");
106 m_solar_const = this->ini_file_data.getDoubleParameters("solar_const");
107 m_gas_const = this->ini_file_data.getDoubleParameters("gas_const");
108 m_poissons_ratio = this->ini_file_data.getDoubleParameters("poissons_ratio");
109 m_youngs_modulus = this->ini_file_data.getDoubleParameters("youngs_modulus");
110 m_f1 = this->ini_file_data.getDoubleParameters("f1");
111 m_f2 = this->ini_file_data.getDoubleParameters("f2");
112 m_chi = this->ini_file_data.getDoubleParameters("chi");
113 m_e1 = this->ini_file_data.getDoubleParameters("e1");
114 m_grain_radius = this->ini_file_data.getDoubleParameters("grain_radius");
115 m_volume_filling_factor = this->ini_file_data.getDoubleParameters("volume_filling_factor");
116}
117
118template <typename T>
120 std::vector<std::shared_ptr<GenericSubmodule<T>>> all_submodules)
121{
122 this->setSubmodules(all_submodules);
123
124 this->is_set_up = true;
125 return true;
126}
127
128template <typename T>
130{
131 if (param == "InitChain")
132 {
133 return init();
134 }
135 if (param == "PreTimeStepChain")
136 {
137 return preTimeStep();
138 }
139 if (param == "PostTimeStepChain")
140 {
141 return postTimeStep();
142 }
143 if (param == "OutputChain")
144 {
145 return output();
146 }
147 return false;
148}
149
155template <typename T>
157{
158 m_emissivity = this->sim->getField("Emissivity")[0];
159 const std::valarray<T>& temperature{this->sim->getField("Temperature")};
160 this->sub_module_chain.runChain("PreTimeStepChain"); // Solid heat conductivity
161 for (int i = 0; i < temperature.size(); ++i)
162 {
163 (*this->module_field)[i] =
164 8 * (this->m_stefan_boltzmann_const) * (this->m_emissivity)
165 * std::pow(temperature[i], 3.) * (this->m_e1)
166 * (1 - (this->m_volume_filling_factor)) / (this->m_volume_filling_factor)
167 * (this->m_grain_radius)
168 + (*this->module_field)[i]
169 * std::pow(
170 (9. * std::numbers::pi / 4.)
171 * ((1. - std::pow(this->m_poissons_ratio, 2)) / (this->m_youngs_modulus))
172 * (6.67e-5 * temperature[i]) / (this->m_grain_radius),
173 (1. / 3.))
174 * (this->m_f1)
175 * std::pow((this->m_f2) * (this->m_volume_filling_factor), std::numbers::e)
176 * (this->m_chi);
177 }
178}
179
180template <typename T>
182{
183 calculateHeatConductivity();
184 return true;
185}
186
187template <typename T>
189{
190 calculateHeatConductivity();
191 return true;
192}
193
194template <typename T>
196 ModuleFactory<T>::registerModule(getName(), createMethode);
197
198#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:181
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:188
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:119
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:156
bool exec(std::string_view param) override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:129
bool postTimeStep() override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:61
void setFieldPtr(std::shared_ptr< std::valarray< T > > field_ptr) override
Definition HeatConductivityVariableGundlach2013RegolithSolid.h:66
double getDoubleParameters(const std::string &key) const
Getter function to access the m_DoubleParameters map and returns a double.
Definition InputManager.cpp:477
std::vector< std::string > getStringVectorParameters(const std::string &key) const
Definition InputManager.cpp:503
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:42
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:493
static constexpr bool registerModule(std::string name, creation_method module) noexcept
Function that adds a module to the module registry map.
Definition ModuleFactory.h:75
Definition SimulationClassBase.h:19
InputManager m_simulation_config
Definition SimulationClassBase.h:29