BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::material::UserDefinedMaterial Class Reference

User-defined material loaded from external shared library. More...

#include <cl_Material_UserDefined.hpp>

Inheritance diagram for belfem::material::UserDefinedMaterial:
[legend]
Collaboration diagram for belfem::material::UserDefinedMaterial:
[legend]

Public Member Functions

 UserDefinedMaterial (const string &aLibraryPath, const string &aLabel)
 Constructor - loads and initializes user-defined material.
 ~UserDefinedMaterial () override
 Destructor - closes the dynamically loaded library.
void set_user_defined_function (const MaterialProperty Property, const MaterialDependency Dependency, MatFunc1 *Function) override
 Set a user-defined function with one dependency (typically temperature).
void set_user_defined_function (const MaterialProperty Property, const MaterialDependency Dependency1, const MaterialDependency Dependency2, MatFunc2 *Function) override
 Set a user-defined function with two dependencies.
void set_user_defined_function (const MaterialProperty Property, const MaterialDependency Dependency1, const MaterialDependency Dependency2, const MaterialDependency Dependency3, MatFunc3 *Function) override
 Set a user-defined function with three dependencies.
void set_user_defined_polynomial (const MaterialProperty Property, const Cell< real > &Coefficients) override
 Set a polynomial function for a material property.
void set_user_defined_polynomial (const MaterialProperty Property, const std::vector< real > &Coefficients) override
 Set a polynomial function for a property (for UserDefinedMaterial).
real evaluate_polynomial (const MaterialProperty Property, const real T) const override
 Evaluate a polynomial function for a given property and temperature.
real evaluate_derivative_of_polynomial (const MaterialProperty Property, const real T) const override
Public Member Functions inherited from belfem::Material
 Material (const MaterialType aType, const bool aIsIsotropic=true)
 Constructor.
virtual ~Material ()
 Destructor - deletes owned B-H curves and Jc/n functions.
 Material (const Material &)=delete
Materialoperator= (const Material &)=delete
 Material (Material &&)=delete
Materialoperator= (Material &&)=delete
bool have (const MaterialProperty aProperty) const
 Check if a material property is available.
bool have_defect () const
 Check if the material has a defect.
bool have_heating () const
 Check if the material has a heating function.
bool use_piecewise () const
 Check if we use piecewise instead of power-law.
bool depends (const MaterialProperty aProperty, const MaterialDependency aDependency) const
 Check if a property depends on a specific variable.
const MaterialDependencyBitsetdependencies (const MaterialProperty aProperty) const
 Get all dependencies for a property.
bool is_isotropic () const
 Check if material is isotropic.
MaterialType type () const
 Get the material type.
const stringlabel () const
 Get material label.
const stringnumber () const
 Get material number/identifier.
void load_bh_curve (const material::BhCurve *aCurve)
 Activate a B-H curve as the permeability source (ferromagnets).
void flag (const uint8_t aIndex=0)
 Set flag (multi-purpose flag used by Kernel).
void unflag (const uint8_t aIndex=0)
 Clear flag.
bool is_flagged (const uint8_t aIndex=0) const
 Check if material is flagged.
bool is_constant (const MaterialProperty aProperty) const
 Check if a property is constant (temperature-independent).
virtual void set_RRR (const real RRR)
 Set the residual resistivity ratio (for noble metals).
virtual real density (const real T=gTroom) const
 Density as a function of temperature.
real ref_density () const
 Reference density at reference temperature.
real M () const
 Molar mass.
virtual real cp (const real T=gTroom) const
 Specific heat capacity.
virtual real dcpdT (const real T=gTroom) const
virtual real d2cpdT2 (const real T=gTroom) const
virtual real lambda (const real T=gTroom) const
 Thermal conductivity (isotropic).
virtual real dlambdadT (const real T=gTroom) const
virtual real lambda (const real T, const real B, const real beta) const
 Thermal conductivity for noble metals with magnetoresistance.
virtual real dlambdadT (const real T, const real B, const real beta) const
virtual real dlambdadB (const real T, const real B, const real beta) const
virtual real dlambdadbeta (const real T, const real B, const real beta) const
virtual real lambda (const real T, const real B_par, const real B_perp, const real J) const
 Thermal conductivity for HTS materials.
virtual real dlambdadT (const real T, const real B_par, const real B_perp, const real J) const
virtual real rho (const real T) const
 Electrical resistivity (isotropic).
virtual real drhodT (const real T) const
virtual real rho (const real T, const real B, const real beta) const
 Electrical resistivity for noble metals with magnetoresistance.
virtual real drhodT (const real T, const real B, const real beta) const
virtual real drhodB (const real T, const real B, const real beta) const
virtual real drhodbeta (const real T, const real B, const real beta) const
real rho_powerlaw (const real normJ) const
 Power law resistivity for HTS (constant jc and n).
real rho_powerlaw (const real normJ, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constant \(J_c\) / \(n\) with spatially-dependent defect modulation \(J_c \rightarrow J_c \cdot d(x,y,z,t)\).
real rho_powerlaw (const real normJ, real normB, const real angleNxB) const
 Power law resistivity for HTS (field-dependent jc, constant n).
real rho_powerlaw (const real normJ, real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) with spatial defect modulation.
real rho_powerlaw (const real normJ, const real T, real normB, const real angleNxB) const
 Power law resistivity for HTS (full temperature and field dependence).
real rho_powerlaw (const real normJ, const real T, real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Fully \((|B|, \angle, T)\)-dependent variant with spatial defect modulation applied to \(J_c\).
real rho_powerlaw (const real normJ, const real T) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only variant.
real rho_powerlaw (const real normJ, const real T, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only custom-callback variant with spatial defect modulation.
real rho_piecewise (const real normJ) const
 Piecewise resistivity for HTS (constant jc and n).
real rho_piecewise (const real normJ, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constant \(J_c\) / \(n\) with spatially-dependent defect modulation \(J_c \rightarrow J_c \cdot d(x,y,z,t)\).
real rho_piecewise (const real normJ, real normB, const real angleNxB) const
 Piecewise resistivity for HTS (field-dependent jc, constant n).
real rho_piecewise (const real normJ, real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) with spatial defect modulation.
real rho_piecewise (const real normJ, const real T, real normB, const real angleNxB) const
 Piecewise resistivity for HTS (full temperature and field dependence).
real rho_piecewise (const real normJ, const real T, real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Fully \((|B|, \angle, T)\)-dependent variant with spatial defect modulation applied to \(J_c\).
real rho_piecewise (const real normJ, const real T) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only variant: \(J_c(T)\) and \(n(T)\) from the user-supplied callbacks Material::jc_custom() / Material::n_custom().
real rho_piecewise (const real normJ, const real T, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only custom-callback variant with spatial defect modulation.
real rho_riva (const real normJ, const real T, const real normB, const real angleNxB) const
 Riva-law resistivity: the superconducting power-law channel in parallel with the normal-state channel.
real rho_riva (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 defect overload: jc_eff = D(x,y,z,t)·jc throughout
real drho_riva_dJ (const real normJ, const real T, const real normB, const real angleNxB) const
 dρ/d|J| of rho_riva: w²·dρ_PL/dJ with w = ρ_n/(ρ_PL+ρ_n)
real drho_riva_dJ (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
real drho_riva_dB (const real normJ, const real T, const real normB, const real angleNxB) const
 dρ/d|B| of rho_riva: w²·dρ_PL/dB ( dρ_n/dB = 0 on this path )
real drho_riva_dB (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
real drho_riva_dT (const real normJ, const real T, const real normB, const real angleNxB) const
 dρ/dT of rho_riva: w²·dρ_PL/dT + (1−w)²·dρ_n/dT
real drho_riva_dT (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
real n (const real normB, const real angleNxB, const real T) const
 Direct evaluation of the n-value as a function of \(|B|\), \(\angle(n,B)\) and \(T\).
real n (const real normB, const real angleNxB) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(n(|B|, \angle(n,B))\) without temperature dependence.
real jc (const real normB, const real angleNxB, const real T) const
 Direct evaluation of the critical current density \(J_c(|B|, \angle(n,B), T)\).
real jc (const real normB, const real angleNxB) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle(n,B))\) without temperature dependence.
real jc (const real normB, const real angleNxB, const real T, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Variant with spatial defect modulation \(J_c \rightarrow J_c \cdot d(x,y,z,t)\).
real jc (const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle(n,B))\) with spatial defect modulation \(J_c \rightarrow J_c \cdot d(x,y,z,t)\).
real drho_powerlaw_dJ (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of power-law resistivity with respect to current density magnitude.
real drho_powerlaw_dJ (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Fully \((|B|, \angle, T)\)-dependent variant with spatial defect modulation applied to \(J_c\).
real drho_powerlaw_dJ (const real normJ) const
 Analytic Jacobian \(d\rho_{eff}/dJ\) of the power-law model.
real drho_powerlaw_dJ (const real normJ, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constant \(J_c\) / \(n\) with spatial defect modulation applied to \(J_c\).
real drho_powerlaw_dJ (const real normJ, const real T) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only variant: \(J_c(T)\) and \(n(T)\) from Material::jc_custom() / Material::n_custom().
real drho_powerlaw_dJ (const real normJ, const real T, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only custom-callback variant with spatial defect modulation.
real drho_powerlaw_dJ (const real normJ, const real normB, const real angleNxB) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) via mJcFunction; \(n\) remains constant.
real drho_powerlaw_dJ (const real normJ, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) with spatial defect modulation; \(n\) remains constant.
real drho_piecewise_dJ (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of piecewise resistivity with respect to current density magnitude.
real drho_piecewise_dJ (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Fully \((|B|, \angle, T)\)-dependent variant with spatial defect modulation applied to \(J_c\).
real drho_powerlaw_dB (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of power-law resistivity with respect to |B| at fixed J, T, θ ( jc = jc(T,|B|,θ), n = n(T,|B|,θ) ).
real drho_powerlaw_dB (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 defect overload: jc_eff = D(x)·jc throughout, djc_eff = D·djc
real drho_powerlaw_dT (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of power-law resistivity with respect to T at fixed J, |B|, θ ( T-leg: jc(T), n(T) AND ρ_n(T) all move — the quench-feedback tangent ).
real drho_powerlaw_dT (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 defect overload: jc_eff = D(x)·jc throughout, djc_eff = D·djc
real drho_piecewise_dB (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of piecewise resistivity with respect to |B| at fixed J, T, θ
real drho_piecewise_dB (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 defect overload: jc_eff = D(x)·jc throughout, djc_eff = D·djc
real drho_piecewise_dT (const real normJ, const real T, const real normB, const real angleNxB) const
 Derivative of piecewise resistivity with respect to T at fixed J, |B|, θ ( T-leg ).
real drho_piecewise_dT (const real normJ, const real T, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 defect overload: jc_eff = D(x)·jc throughout, djc_eff = D·djc
real drho_piecewise_dJ (const real normJ) const
 Branch-aware Jacobian \(d\rho/dJ\) of the three-regime piecewise model.
real drho_piecewise_dJ (const real normJ, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constant \(J_c\) / \(n\) with spatial defect modulation applied to \(J_c\).
real drho_piecewise_dJ (const real normJ, const real T) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only variant: \(J_c(T)\) and \(n(T)\) from Material::jc_custom() / Material::n_custom().
real drho_piecewise_dJ (const real normJ, const real T, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Temperature-only custom-callback variant with spatial defect modulation.
real drho_piecewise_dJ (const real normJ, const real normB, const real angleNxB) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) via mJcFunction; \(n\) remains constant.
real drho_piecewise_dJ (const real normJ, const real normB, const real angleNxB, const real x, const real y, const real z, const real t) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Field-dependent \(J_c(|B|, \angle)\) with spatial defect modulation; \(n\) remains constant.
virtual real rho_i (const real T) const
 Intrinsic (phonon) electrical resistivity of a metal, ρ = ρ_i(T) + ρ_0.
virtual real H (const real B) const
 Magnetic field strength from flux density.
virtual real mu (const real H, const real T=BELFEM_QUIET_NAN) const
 Magnetic permeability.
virtual void dmudH (const real H, real &mu, real &dmudH) const
 Magnetic permeability and its derivative.
virtual real E (real T=gTroom) const
 Young's modulus.
virtual real nu (real T=gTroom) const
 Poisson's ratio.
virtual real G (real T=gTroom) const
 Shear modulus.
virtual real K (real T=gTroom) const
 Bulk modulus.
virtual real alpha (real T=gTroom) const
 Thermal expansion coefficient.
virtual real l (real T) const
 Relative length after thermal expansion.
virtual real Rp02 (real T=gTroom) const
 Yield stress (0.2% offset).
virtual real debye (const real T) const
 Debye temperature.
virtual void set_bh_curve (const material::BhCurve *aCurve)
 Assign a B-H curve to this material.
void set_jc_function (const material::JcFunction *aFunction)
 Assign a critical current density function.
void set_n_function (const material::JcFunction *aFunction)
 Assign a power law exponent function.
void set_piecewise (const bool aUsePiecewise)
void set_resistivity_law (const ResistivityLaw aLaw)
ResistivityLaw resistivity_law () const
bool use_riva () const
void set_user_defined_defect (DefectFunc *Function)
 Set a user-defined defect function with x, y, z, t dependencies.
void read_defect (const string &aLibraryPath, const string &aLabel)
 Read a defect from the library.
void set_user_defined_heating (HeatFunc *Function)
 Set a user-defined volumetric heat load [ W/m³ ] as a function of x, y, z [ m ] and t [ s ].
void read_heating (const string &aLibraryPath, const string &aLabel)
 Read a heating function from a plugin library.
void set_label (const string &aLabel)
 PROTECTED INTERFACE FOR DERIVED MATERIALS.
void set_number (const string &aNumber)
 Set material number/identifier (for derived classes).
void set_have (const MaterialProperty aProperty, const bool aHave=true)
 Mark a property as available.
void reset_dependencies (const MaterialProperty aProperty)
 Reset all dependencies for a property.
void set_dependency (const MaterialProperty aProperty, const MaterialDependency aDependency)
 Add a dependency to a property.
void set_constant (const MaterialProperty aProperty, const real aValue)
 Define a property as constant.
void set_custom (const MaterialProperty aProperty)
 Mark property as using custom evaluation function.
real constant_property (const MaterialProperty aProperty) const
 Get constant property value.
virtual real spline_property (const MaterialProperty aProperty, const real aX) const
 Evaluate property using spline interpolation.
virtual real dspline_property (const MaterialProperty aProperty, const real aX) const
virtual real ddspline_property (const MaterialProperty aProperty, const real aX) const
virtual void set_table_flags (const bool aFlag)
real volumetric_heatload (const real x, const real y, const real z, const real time) const
 Artificial volumetric heat load [ W/m³ ] from the heating plugin.

Protected Member Functions

real E_custom (const real T) const override
 Custom Young's modulus evaluation - calls user function.
real nu_custom (const real T) const override
 Custom Poisson's ratio evaluation - calls user function.
real cp_custom (const real T) const override
 Custom specific heat evaluation - calls user function.
real lambda_custom (const real T) const override
 Custom thermal conductivity evaluation (temperature only) - calls user function.
real lambda_custom (const real T, const real normB, const real angle) const override
 Custom thermal conductivity evaluation (with field) - calls user function.
real rho_custom (const real T) const override
 Custom electrical resistivity evaluation (temperature only) - calls user function.
real rho_kohler (const real T, const real normB, const real angle) const override
 Custom electrical resistivity evaluation (with field) - calls user function.
real jc_custom (const real T) const override
 Custom jc evaluation (temperature only) - calls user function.
real n_custom (const real T) const override
 Custom n evaluation (temperature only) - calls user function.
real alpha_custom (const real T) const override
 Custom thermal expansion coefficient evaluation - calls user function.
real Rp02_custom (const real T) const override
 Custom 0.2% proof stress evaluation - calls user function.
real mu_custom (const real H, const real T) const override
 Custom magnetic permeability evaluation - dispatches to polynomial or user function.
Protected Member Functions inherited from belfem::Material
real jc_eval (const real T, const real normB, const real angleNxB) const
 O1 "full-signature policy" helpers: the assembly path always passes the full ( T, normB, angleNxB ) set; the material consumes what its Jc / n functions depend on and ignores the rest.
real djc_eval_dB (const real T, const real normB, const real angleNxB) const
real dn_eval_dB (const real T, const real normB, const real angleNxB) const
 d(n)/d|B|, same routing as djc_eval_dB
real djc_eval_dT (const real T, const real normB, const real angleNxB) const
real dn_eval_dT (const real T, const real normB, const real angleNxB) const
 d(n)/dT, same routing as djc_eval_dT
real n_eval (const real T, const real normB, const real angleNxB) const
void check_riva_n_source () const
real n_eval_raw (const real T, const real normB, const real angleNxB) const
bool riva_rho_pl (const real normJ, const real jc, const real n, const real ec, real &rhoPL) const
void create_spline (const MaterialProperty aProperty, const real adYdX0=BELFEM_QUIET_NAN, const real adXdX1=BELFEM_QUIET_NAN)
 PROPERTY EVALUATION FUNCTIONS.
real alpha_switch_temperature () const
 Temperature below which alpha is taken from the Grueneisen branch.
real density_const (const real T) const
virtual real density_custom (const real T) const
real return_zero (const real T) const
 Shared binding for derivative channels that are identically zero.
real cp_const (const real T) const
real dcpdT_finite_difference (const real T) const
real d2cpdT2_finite_difference (const real T) const
real cp_spline (const real T) const
real dcpdT_spline (const real T) const
real d2cpdT2_spline (const real T) const
virtual real dcpdT_custom (const real T) const
virtual real d2cpdT2_custom (const real T) const
real lambda_const (const real T) const
real dlambdadT_finite_difference (const real T) const
real lambda_spline (const real T) const
real dlambdadT_spline (const real T) const
virtual real dlambdadT_custom (const real T) const
real drhodT_finite_difference (const real T) const
real rho_const (const real T) const
virtual real drhodT_custom (const real T) const
virtual real rho_spline (const real T) const
virtual real drhodT_spline (const real T) const
virtual real drhodT_kohler (const real T, const real normB, const real angleJxB) const
virtual real drhodB_kohler (const real T, const real normB, const real angleJxB) const
virtual real drhodbeta_kohler (const real T, const real normB, const real angleJxB) const
virtual real rho_table (const real T, const real normB, const real angleJxB) const
virtual real drhodT_table (const real T, const real normB, const real angleJxB) const
virtual real drhodB_table (const real T, const real normB, const real angleJxB) const
virtual real drhodbeta_table (const real T, const real normB, const real angleJxB) const
virtual real lambda_table (const real T, const real normB, const real angle) const
real H_const (const real B) const
virtual real H_bhcurve (const real B) const
real mu_const (const real H, const real T) const
virtual real mu_bhcurve (const real H, const real T) const
void dmudH_const (const real H, real &mu, real &dmudH) const
virtual void dmudH_bhcurve (const real H, real &mu, real &dmudH) const
real E_const (const real T) const
real E_spline (const real T) const
virtual real dEdT_custom (const real T) const
real nu_const (const real T) const
real nu_spline (const real T) const
real alpha_const (const real T) const
real alpha_spline (const real T) const
real Rp02_const (const real T) const
real Rp02_spline (const real T) const
real debye_const (const real T) const
real debye_spline (const real T) const
virtual real debye_custom (const real T) const
virtual real rho_i_custom (const real T) const
real rho_i_spline (const real T) const
virtual void reset_spline (const MaterialProperty aProperty)
virtual void create_spline (real(Material::*aFunction)(const real aT) const, const MaterialProperty aProperty, const uint aStartBC, const uint aEndBC, const real adYdX0=BELFEM_QUIET_NAN, const real adYdX1=BELFEM_QUIET_NAN)

Additional Inherited Members

Protected Attributes inherited from belfem::Material
real(Material::*) mFunctionRhoKohler (const real T, const real normB, const real angle) const = nullptr
real(Material::*) mFunctiondRhoKohlerdT (const real T, const real normB, const real angle) const = nullptr
real(Material::*) mFunctiondRhoKohlerdB (const real T, const real normB, const real angle) const = nullptr
real(Material::*) mFunctiondRhoKohlerdbeta (const real T, const real normB, const real angle) const = nullptr
real(Material::*) mFunctionH (const real B) const = nullptr
real(Material::*) mFunctionMu (const real H, const real T) const = nullptr
void(Material::*) mFunctionDMuDH (double, double &, double &) const = nullptr
const material::JcFunctionmJcFunction = nullptr
const material::JcFunctionmNFunction = nullptr

Detailed Description

User-defined material loaded from external shared library.

This class enables users to define custom materials by implementing property functions in a separate shared library (.so on Linux, .dylib on macOS). The library is dynamically loaded at runtime using dlopen.

LOADING MECHANISM: The library must contain an initialization function with the signature:

extern "C" void \<label\>_init(Material* mat);
Material(const MaterialType aType, const bool aIsIsotropic=true)
Constructor.
Definition cl_Material.cpp:149
const string & label() const
Get material label.
Definition cl_Material.hpp:1683

where <label> is the material label provided to the constructor.

PROPERTY DEFINITION: Within the init function, users can define material properties using:

SUPPORTED PROPERTIES:

  • Mechanical: E(T), nu(T), Rp02(T), alpha(T)
  • Thermal: cp(T), lambda(T) or lambda(T,B,angle), rho(T) or rho(T,B,angle)
  • Magnetic: mu(H,T)
  • Superconducting: jc(B,angle) or jc(B,angle,T), n(B,angle) or n(B,angle,T)

Example user library (mymat.cpp):

#include "cl_Material.hpp"
using namespace belfem;
// Custom resistivity function
real my_rho(const Material* mat, real T) {
return 1.7e-8 * (1.0 + 0.004 * (T - 293.0));
}
// Initialization function (must be extern "C")
extern "C" void MyAlloy_init(Material* mat) {
// Set constant properties
// Set custom resistivity function
&my_rho);
// Set polynomial for specific heat: cp = 385 + 0.12*T (DESCENDING order: T¹, T⁰)
std::vector<real> cp_coeffs = {0.12, 385.0};
}
Base class for all materials in BELFEM.
Definition cl_Material.hpp:279
void set_constant(const MaterialProperty aProperty, const real aValue)
Define a property as constant.
Definition cl_Material.cpp:257
virtual void set_user_defined_polynomial(const MaterialProperty Property, const std::vector< real > &Coefficients)
Set a polynomial function for a property (for UserDefinedMaterial).
Definition cl_Material.cpp:943
virtual void set_user_defined_function(const MaterialProperty Property, const MaterialDependency Dependency, MatFunc1 *Function)
Set a user-defined function with one dependency (for UserDefinedMaterial).
Definition cl_Material.cpp:749
void MyAlloy_init(Material *mat)
Definition example_user_material.cpp:86
USER GUIDES:
Definition cl_Capacitor.cpp:16
@ T
Definition cl_Material.hpp:122
@ nu
Definition cl_Material.hpp:156
@ E
Definition cl_Material.hpp:155
@ rho
Definition cl_Material.hpp:160
@ cp
Definition cl_Material.hpp:157
double real
Definition typedefs.hpp:36

Compile as shared library. An installed BELFEM keeps the module layout under include/belfem, and the headers include each other by bare name, so three directories are needed:

g++ -shared -fPIC mymat.cpp -o libmymat.so \
-I<prefix>/include/belfem/core \
-I<prefix>/include/belfem/containers \
-I<prefix>/include/belfem/physics/materials

The shipped share/belfem/templates/UserMaterialTemplate.cmake does this for both an installed prefix and a source tree.

Usage in BELFEM:

Material* mat = factory.create_material("libmymat.so", "MyAlloy");
Factory class for creating material objects and associated property functions.
Definition cl_MaterialFactory.hpp:74
Material * create_material(const string &aLabel, const real aRRR=BELFEM_QUIET_NAN, const bool aBuildTables=true)
Create a material by label.
Definition cl_MaterialFactory.cpp:491

Constructor & Destructor Documentation

◆ UserDefinedMaterial()

belfem::material::UserDefinedMaterial::UserDefinedMaterial ( const string & aLibraryPath,
const string & aLabel )

Constructor - loads and initializes user-defined material.

Dynamically loads the shared library at aLibraryPath and calls the initialization function "\<aLabel\>_init" to configure material properties.

Parameters
aLibraryPathPath to shared library (.so, .dylib, .dll)
aLabelMaterial label (must match init function name)
Exceptions
Errorif library cannot be loaded or init function not found

◆ ~UserDefinedMaterial()

belfem::material::UserDefinedMaterial::~UserDefinedMaterial ( )
override

Destructor - closes the dynamically loaded library.

Member Function Documentation

◆ alpha_custom()

real belfem::material::UserDefinedMaterial::alpha_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom thermal expansion coefficient evaluation - calls user function.

Reimplemented from belfem::Material.

◆ cp_custom()

real belfem::material::UserDefinedMaterial::cp_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom specific heat evaluation - calls user function.

Reimplemented from belfem::Material.

◆ E_custom()

real belfem::material::UserDefinedMaterial::E_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom Young's modulus evaluation - calls user function.

Reimplemented from belfem::Material.

◆ evaluate_derivative_of_polynomial()

real belfem::material::UserDefinedMaterial::evaluate_derivative_of_polynomial ( const MaterialProperty Property,
const real T ) const
inlineoverridevirtual

Reimplemented from belfem::Material.

◆ evaluate_polynomial()

real belfem::material::UserDefinedMaterial::evaluate_polynomial ( const MaterialProperty Property,
const real T ) const
inlineoverridevirtual

Evaluate a polynomial function for a given property and temperature.

Internal method used by polynomial-based property evaluations. Uses Horner's method for efficient polynomial evaluation.

Parameters
PropertyThe material property
TTemperature [K]
Returns
Property value at temperature T
Exceptions
Errorif polynomial for this property is not defined

Reimplemented from belfem::Material.

◆ jc_custom()

real belfem::material::UserDefinedMaterial::jc_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom jc evaluation (temperature only) - calls user function.

Reimplemented from belfem::Material.

◆ lambda_custom() [1/2]

real belfem::material::UserDefinedMaterial::lambda_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom thermal conductivity evaluation (temperature only) - calls user function.

Reimplemented from belfem::Material.

◆ lambda_custom() [2/2]

real belfem::material::UserDefinedMaterial::lambda_custom ( const real T,
const real normB,
const real angle ) const
inlineoverrideprotectedvirtual

Custom thermal conductivity evaluation (with field) - calls user function.

Reimplemented from belfem::Material.

◆ mu_custom()

real belfem::material::UserDefinedMaterial::mu_custom ( const real H,
const real T ) const
inlineoverrideprotectedvirtual

Custom magnetic permeability evaluation - dispatches to polynomial or user function.

Reimplemented from belfem::Material.

◆ n_custom()

real belfem::material::UserDefinedMaterial::n_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom n evaluation (temperature only) - calls user function.

Reimplemented from belfem::Material.

◆ nu_custom()

real belfem::material::UserDefinedMaterial::nu_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom Poisson's ratio evaluation - calls user function.

Reimplemented from belfem::Material.

◆ rho_custom()

real belfem::material::UserDefinedMaterial::rho_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom electrical resistivity evaluation (temperature only) - calls user function.

Reimplemented from belfem::Material.

◆ rho_kohler()

real belfem::material::UserDefinedMaterial::rho_kohler ( const real T,
const real normB,
const real angle ) const
inlineoverrideprotectedvirtual

Custom electrical resistivity evaluation (with field) - calls user function.

Reimplemented from belfem::Material.

◆ Rp02_custom()

real belfem::material::UserDefinedMaterial::Rp02_custom ( const real T) const
inlineoverrideprotectedvirtual

Custom 0.2% proof stress evaluation - calls user function.

Reimplemented from belfem::Material.

◆ set_user_defined_function() [1/3]

void belfem::material::UserDefinedMaterial::set_user_defined_function ( const MaterialProperty Property,
const MaterialDependency Dependency,
MatFunc1 * Function )
overridevirtual

Set a user-defined function with one dependency (typically temperature).

Assigns a custom function for evaluating a material property. The function receives the material pointer and one parameter (typically temperature).

Supported properties: E, nu, cp, lambda, rho, alpha, Rp02

Parameters
PropertyThe material property to define
DependencyThe dependency type (must be MaterialDependency::T)
FunctionPointer to user function: real(const Material*, real)
Exceptions
Errorif Dependency is not T, or if Property is jc or n (those take the field-dependent overloads below)

Example:

real my_cp(const Material* mat, real T) {
return 385.0 + 0.12*T;
}
mat->set_user_defined_function(MaterialProperty::cp,
&my_cp);

Reimplemented from belfem::Material.

◆ set_user_defined_function() [2/3]

void belfem::material::UserDefinedMaterial::set_user_defined_function ( const MaterialProperty Property,
const MaterialDependency Dependency1,
const MaterialDependency Dependency2,
const MaterialDependency Dependency3,
MatFunc3 * Function )
overridevirtual

Set a user-defined function with three dependencies.

Assigns a custom function for evaluating a material property with three parameters. Currently supports:

  • lambda(T, B, angle): Thermal conductivity with field dependence
  • rho(T, B, angle): Electrical resistivity with field dependence
  • jc(B, angle, T): Critical current density with temperature
  • n(B, angle, T): Power law exponent with temperature

Argument order differs by property: lambda/rho take (T, normB, angleBxJ); jc/n take (normB, angleNxB, T).

Parameters
PropertyThe material property to define
Dependency1First dependency (T for lambda/rho, normB for jc/n)
Dependency2Second dependency (normB for lambda/rho, angleNxB for jc/n)
Dependency3Third dependency (angleBxJ for lambda/rho, T for jc/n)
FunctionPointer to user function: real(const Material*, real, real, real)
Exceptions
Errorif property or dependency combination is not supported

Example:

real my_rho(const Material* mat, real T, real B, real angle) {
real rho0 = 1.7e-8 * (1.0 + 0.004*(T-293.0));
real delta_rho = rho0 * 0.01 * B*B; // Magnetoresistance
return rho0 + delta_rho;
}
mat->set_user_defined_function(MaterialProperty::rho,
&my_rho);
@ angleBxJ
Definition cl_Material.hpp:124
@ normB
Definition cl_Material.hpp:123

Reimplemented from belfem::Material.

◆ set_user_defined_function() [3/3]

void belfem::material::UserDefinedMaterial::set_user_defined_function ( const MaterialProperty Property,
const MaterialDependency Dependency1,
const MaterialDependency Dependency2,
MatFunc2 * Function )
overridevirtual

Set a user-defined function with two dependencies.

Assigns a custom function for evaluating a material property with two parameters. Currently supports:

  • mu(H, T): Magnetic permeability as function of field and temperature
  • jc(B, angle): Critical current density as function of field and angle
  • n(B, angle): Power law exponent as function of field and angle
Parameters
PropertyThe material property to define (mu, jc, or n)
Dependency1First dependency (normH for mu, normB for jc/n)
Dependency2Second dependency (T for mu, angleNxB for jc/n)
FunctionPointer to user function: real(const Material*, real, real)
Exceptions
Errorif property or dependency combination is not supported

Example:

real my_jc(const Material* mat, real B, real angle) {
return 1e9 / (1.0 + B/5.0);
}
mat->set_user_defined_function(MaterialProperty::jc,
&my_jc);
real my_jc(const Material *mat, real normB, real angleNxB, real T)
Definition example_user_material.cpp:141
@ angleNxB
Definition cl_Material.hpp:125
@ jc
Definition cl_Material.hpp:186

Reimplemented from belfem::Material.

◆ set_user_defined_polynomial() [1/2]

void belfem::material::UserDefinedMaterial::set_user_defined_polynomial ( const MaterialProperty Property,
const Cell< real > & Coefficients )
overridevirtual

Set a polynomial function for a material property.

Defines a property as a polynomial in temperature: f(T) = c₀T^n + c₁T^(n-1) + ... + c_n This is a convenience function that internally creates a user function using polyval().

IMPORTANT: Coefficients are in DESCENDING order (MATLAB style), highest degree first.

Supported properties: E, nu, cp, lambda, mu, rho, alpha, Rp02

Parameters
PropertyThe material property to define
CoefficientsPolynomial coefficients [c₀, c₁, c₂, ...] in DESCENDING order (highest degree first)
Exceptions
Errorif property does not support polynomial definition

Example:

// cp(T) = -1e-5*T² + 0.12*T + 385
std::vector<real> cp_coeffs = {-1e-5, 0.12, 385.0}; // Descending order: T², T¹, T⁰
mat->set_user_defined_polynomial(MaterialProperty::cp, cp_coeffs);

Reimplemented from belfem::Material.

◆ set_user_defined_polynomial() [2/2]

void belfem::material::UserDefinedMaterial::set_user_defined_polynomial ( const MaterialProperty Property,
const std::vector< real > & Coefficients )
overridevirtual

Set a polynomial function for a property (for UserDefinedMaterial).

Defines a property as a polynomial in temperature: f(T) = c₀T^n + c₁T^(n-1) + ... + c_n This is a convenience function for user-defined materials.

IMPORTANT: Coefficients are in DESCENDING order (MATLAB style), highest degree first.

Parameters
PropertyThe material property to define
CoefficientsPolynomial coefficients [c₀, c₁, c₂, ...] in DESCENDING order (highest degree first)
Note
This is a virtual method overridden by UserDefinedMaterial

Reimplemented from belfem::Material.


The documentation for this class was generated from the following files: