14 const unsigned int material_interaction_id,
19 AssertThrow(material_interaction_id <
21 ExcMessage(
"The material interaction of the effective medium "
22 "model does not exist."));
34 const auto &[fluid_id, dispersed_phase_id] =
40 ExcMessage(
"The fluid or the unresolved dispersed phase of "
41 "the fluid-dispersed phase interaction do not "
52 ExcMessage(
"Effective medium models are only available for "
53 "fluid-dispersed phase interactions."));
61std::shared_ptr<EffectiveMediumModel>
64 const unsigned int material_interaction_id,
76 return std::make_shared<NoEffectiveMediumModel>(physical_properties,
77 material_interaction_id,
81 EffectiveMediumModelType::bruggeman)
82 return std::make_shared<BruggemanEffectiveMediumModel>(
84 material_interaction_id,
88 AssertThrow(
false, InvalidEffectiveMediumModel());
94 const std::complex<double> phase_1_property =
96 const std::complex<double> phase_2_property =
105 const std::map<
field, std::vector<double>> &field_vectors,
106 std::vector<double> &property_vector)
108 const unsigned int n_points = property_vector.size();
112 std::vector<std::complex<double>> phase_1_property(n_points);
113 std::vector<std::complex<double>> phase_2_property(n_points);
114 std::vector<std::complex<double>> mixture_property(n_points);
124 for (
unsigned int i = 0; i < n_points; ++i)
137 const std::map<
field, std::vector<double>> &field_vectors,
139 std::vector<double> &jacobian_vector)
153 mixture_depends_on_field =
154 mixture_depends_on_field || model->depends_on(field_id);
156 mixture_depends_on_field =
157 mixture_depends_on_field || model->depends_on(field_id);
194 const std::map<field, double> &field_values)
const
196 double real_part = 0.0;
198 real_part += model->value(field_values);
200 double imaginary_part = 0.0;
202 imaginary_part += model->value(field_values);
204 return {real_part, imaginary_part};
210 const std::map<
field, std::vector<double>> &field_vectors,
211 std::vector<std::complex<double>> &phase_property)
const
213 const unsigned int n_points = phase_property.size();
214 std::vector<double> real_part(n_points, 0.0);
215 std::vector<double> imaginary_part(n_points, 0.0);
216 std::vector<double> term_values(n_points);
220 model->vector_value(field_vectors, term_values);
221 for (
unsigned int i = 0; i < n_points; ++i)
222 real_part[i] += term_values[i];
227 model->vector_value(field_vectors, term_values);
228 for (
unsigned int i = 0; i < n_points; ++i)
229 imaginary_part[i] += term_values[i];
232 for (
unsigned int i = 0; i < n_points; ++i)
233 phase_property[i] = {real_part[i], imaginary_part[i]};
238 const std::complex<double> mixture_property)
const
241 std::real(mixture_property) :
242 std::imag(mixture_property);
259 ExcMessage(
"Invalid effective medium property. The choices are "
260 "<electric_permittivity|magnetic_permeability>"));
266 const unsigned int material_interaction_id,
270 material_interaction_id,
282 const std::map<field, double> &field_values,
283 const std::complex<double> phase_1_property,
284 const std::complex<double> phase_2_property)
const
287 PhysicialPropertyModelFieldUndefined(
"BruggemanEffectiveMediumModel",
297 const std::map<
field, std::vector<double>> &field_vectors,
298 const std::vector<std::complex<double>> &phase_1_property,
299 const std::vector<std::complex<double>> &phase_2_property,
300 std::vector<std::complex<double>> &mixture_property)
const
303 PhysicialPropertyModelFieldUndefined(
"BruggemanEffectiveMediumModel",
308 AssertDimension(
void_fraction.size(), mixture_property.size());
309 AssertDimension(phase_1_property.size(), mixture_property.size());
310 AssertDimension(phase_2_property.size(), mixture_property.size());
312 for (
unsigned int i = 0; i < mixture_property.size(); ++i)
313 mixture_property[i] =
320 const std::complex<double> phase_1_property,
321 const std::complex<double> phase_2_property)
323 Assert(std::real(phase_1_property) > 0.0 &&
324 std::imag(phase_1_property) >= 0.0,
325 InvalidPhysicalPropertyComplex(phase_1_property));
326 Assert(std::real(phase_2_property) > 0.0 &&
327 std::imag(phase_2_property) >= 0.0,
328 InvalidPhysicalPropertyComplex(phase_2_property));
333 const double phase_1_fraction = std::clamp(
void_fraction, 0., 1.);
334 const double phase_2_fraction = 1.0 - phase_1_fraction;
335 const std::complex<double> factor =
336 (3.0 * phase_2_fraction - 1.0) * phase_2_property +
337 (3.0 * phase_1_fraction - 1.0) * phase_1_property;
338 const std::complex<double> discriminant_root =
339 std::sqrt(factor * factor + 8.0 * phase_2_property * phase_1_property);
344 const std::complex<double> root_1 = 0.25 * (factor + discriminant_root);
345 const std::complex<double> root_2 = 0.25 * (factor - discriminant_root);
353 constexpr double root_selection_relative_tolerance = 1e-12;
354 const double imaginary_part_tolerance =
355 root_selection_relative_tolerance *
356 (std::abs(phase_1_property) + std::abs(phase_2_property));
358 if (std::real(root_1) > 0.0 && std::imag(root_1) >= -imaginary_part_tolerance)
359 return {std::real(root_1), std::max(std::imag(root_1), 0.0)};
360 if (std::real(root_2) > 0.0 && std::imag(root_2) >= -imaginary_part_tolerance)
361 return {std::real(root_2), std::max(std::imag(root_2), 0.0)};
366 "The computed effective property is not in the first quadrant of the complex plane."));
static std::complex< double > bruggeman(const double void_fraction, const std::complex< double > phase_1_property, const std::complex< double > phase_2_property)
Bruggeman formula for a given void fraction.
void vector_apply_mixing_law(const std::map< field, std::vector< double > > &field_vectors, const std::vector< std::complex< double > > &phase_1_property, const std::vector< std::complex< double > > &phase_2_property, std::vector< std::complex< double > > &mixture_property) const override
Calculates the mixture property with the Bruggeman effective medium approximation at multiple points.
BruggemanEffectiveMediumModel(const Parameters::PhysicalProperties &physical_properties, const unsigned int material_interaction_id, const EffectiveMediumProperty property, const ComplexComponent complex_component)
Constructor. Adds the fields on which the models of phase 2 depend and the void fraction to the field...
std::complex< double > apply_mixing_law(const std::map< field, double > &field_values, const std::complex< double > phase_1_property, const std::complex< double > phase_2_property) const override
Calculates the mixture property with the Bruggeman effective medium approximation.
virtual std::complex< double > apply_mixing_law(const std::map< field, double > &field_values, const std::complex< double > phase_1_property, const std::complex< double > phase_2_property) const =0
Mixing law of the effective medium model.
const ComplexComponent complex_component
Part of the mixture property returned by the model.
double get_complex_component(const std::complex< double > mixture_property) const
Returns the selected part (real or imaginary) of a mixture property.
void add_phase_dependencies(const PhaseModels &phase_models)
Adds the fields on which the models of a phase depend to the fields on which the mixture property dep...
static Parameters::MaterialInteractions::EffectiveMediumModelType get_model_type(const Parameters::MaterialInteractions &interaction, const EffectiveMediumProperty property)
Returns the effective medium model chosen in a material interaction for a mixture property.
void vector_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector) override
Calculates the derivative of the selected part of the mixture property with respect to a field at mul...
double jacobian(const std::map< field, double > &field_values, const field id) override
Calculates the derivative of the selected part of the mixture property with respect to a field using ...
void vector_value(const std::map< field, std::vector< double > > &field_vectors, std::vector< double > &property_vector) override
Calculates the selected part of the mixture property at multiple points.
std::complex< double > phase_value(const PhaseModels &phase_models, const std::map< field, double > &field_values) const
Calculates the complex property of a phase from its models.
static std::shared_ptr< EffectiveMediumModel > model_cast(const Parameters::PhysicalProperties &physical_properties, const unsigned int material_interaction_id, const EffectiveMediumProperty &property, const ComplexComponent &complex_component)
Creates the model of a mixture property, with the mixing law given by the material interaction.
virtual void vector_apply_mixing_law(const std::map< field, std::vector< double > > &field_vectors, const std::vector< std::complex< double > > &phase_1_property, const std::vector< std::complex< double > > &phase_2_property, std::vector< std::complex< double > > &mixture_property) const =0
Mixing law of the effective medium model at multiple points.
void phase_vector_value(const PhaseModels &phase_models, const std::map< field, std::vector< double > > &field_vectors, std::vector< std::complex< double > > &phase_property) const
Calculates the complex property of a phase at multiple points from its models.
PhaseModels phase_2_models
Models of the property of phase 2.
PhaseModels phase_1_models
Models of the property of phase 1.
static PhaseModels create_phase_models(const Parameters::Material &material_properties, const EffectiveMediumProperty property)
Creates the models needed to calculate a property of the material of a phase.
double value(const std::map< field, double > &field_values) override
Calculates the selected part of the mixture property.
EffectiveMediumModel(const Parameters::PhysicalProperties &physical_properties, const unsigned int material_interaction_id, const EffectiveMediumProperty &property, const ComplexComponent &complex_component)
Constructor. Gets the materials of the two phases from the material interaction, creates the models o...
static std::shared_ptr< ElectricConductivityModel > model_cast(const Parameters::Material &material_properties)
Instantiates and returns a pointer to an ElectricConductivityModel object by casting it to the proper...
static std::shared_ptr< ElectricPermittivityModel > model_cast_imag(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ElectricPermittivityModel object by casting it to the proper ...
static std::shared_ptr< ElectricPermittivityModel > model_cast_real(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a ElectricPermittivityModel object by casting it to the proper ...
static std::shared_ptr< MagneticPermeabilityModel > model_cast_imag(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a MagneticPermeabilityModel object by casting it to the proper ...
static std::shared_ptr< MagneticPermeabilityModel > model_cast_real(const Parameters::Material &material_properties)
Instantiates and returns a pointer to a MagneticPermeabilityModel object by casting it to the proper ...
MaterialInteractions - Class that defines physical properties due to interactions between two differe...
enum Parameters::MaterialInteractions::MaterialInteractionsType material_interaction_type
EffectiveMediumModelType magnetic_permeability_effective_medium_model
EffectiveMediumModelType electric_permittivity_effective_medium_model
std::pair< std::pair< unsigned int, unsigned int >, unsigned int > fluid_dispersed_phase_interaction_with_material_interaction_id
Material - Class that defines the physical property of a material. Generally a material will be a flu...
PhysicalProperties - Define the possible physical properties. All continuum equations share the same ...
std::vector< Material > unresolved_dispersed_phases
unsigned int number_of_unresolved_dispersed_phases
unsigned int number_of_fluids
std::vector< Material > fluids
unsigned int number_of_material_interactions
std::vector< MaterialInteractions > material_interactions
void vector_numerical_jacobian(const std::map< field, std::vector< double > > &field_vectors, const field id, std::vector< double > &jacobian_vector)
vector_numerical_jacobian Calculates the vector of jacobian through forward finite difference (Euler)...
double numerical_jacobian(const std::map< field, double > &field_values, const field id)
numerical_jacobian Calculates the jacobian through a forward finite difference (Euler) approximation....
ComplexComponent
Part of a complex physical property returned by a model. A PhysicalPropertyModel can only return a si...
std::map< field, bool > model_depends_on
EffectiveMediumProperty
Physical property of a mixture that can be calculated with an effective medium model.
Models of the property of a phase. The effective property of the phase can be complex and builded fro...
std::vector< std::shared_ptr< PhysicalPropertyModel > > real_part_terms
Models whose values are summed to give the real part of the property.
std::vector< std::shared_ptr< PhysicalPropertyModel > > imaginary_part_terms