BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_Material_SplineLookupTable.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California, through
4 * Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_MATERIAL_SPLINELOOKUPTABLE_HPP
13#define BELFEM_CL_MATERIAL_SPLINELOOKUPTABLE_HPP
14#include "cl_Material.hpp"
15#include "cl_Spline.hpp"
16#include "cl_Vector.hpp"
17#include "cl_Bezier.hpp"
18#include "fn_polyval.hpp"
19
20namespace belfem
21{
22 namespace material
23 {
25 {
26 protected:
27
28 // Spline interpolations for tabulated properties
30
31 public:
32
33 SplineLookupTable( const MaterialType aType, const bool aIsIsotropic=true );
34
35 ~SplineLookupTable() override ;
36
40 void
41 set_spline( const MaterialProperty aProperty, Spline * aSpline=nullptr ) ;
42
46 Spline *
47 spline( const MaterialProperty aProperty ) ;
48
49 real
50 spline_property( const MaterialProperty aProperty, const real aX ) const override ;
51
52 real
53 dspline_property( const MaterialProperty aProperty, const real aX ) const override ;
54
55 real
56 ddspline_property( const MaterialProperty aProperty, const real aX ) const override ;
57
61 real
62 l( real T ) const override ;
63
64 protected:
65
66 // un-hide the convenience overload create_spline( aProperty, adYdX0, adYdX1 )
68
69 void
70 reset_spline( const MaterialProperty aProperty ) override ;
71
72 void
73 create_spline( real (Material::*aFunction)(const real aT) const,
74 const MaterialProperty aProperty,
75 const uint aStartBC,
76 const uint aEndBC,
77 const real adYdX0,
78 const real adYdX1 ) override ;
79
80 void
82 const Bezier * aThermalExpansion,
83 Vector< real > & aThermalExpansionCryo,
84 const real aTSwitch = BELFEM_QUIET_NAN ) ;
85
90 void
92 const real alpha, const real dalphadT, const real d2alphadT2,
93 Vector< real > & aThermalExpansionCryo ) ;
94
104 void
106 const real alpha,
107 Vector< real > & aThermalExpansionCryo,
108 const real aTSwitch = BELFEM_QUIET_NAN ) ;
109
110
117 real
118 alpha_composite( const Bezier * aBezier, const Vector< real > & aPoly, const real T ) const ;
119
120
126 real
128
133 void
134 create_low_temperature_alpha( const Bezier * aBezier , Vector< real > & aPoly,
135 const real aTSwitch = BELFEM_QUIET_NAN );
136
142 void
143 create_low_temperature_alpha( const real alpha, const real dalphadT, const real d2alphadT2,
144 Vector< real > & aPoly, const bool aCheckGuard = true );
145
146 private:
147
148 void
149 finish_cryo_expansion( const Vector< real > & aThermalExpansionCryo );
150
151 };
152
153 inline Spline *
155 {
156 return mSplines( static_cast< size_t >( aProperty ) ) ;
157 }
158
159 inline real
161 {
162 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
163 "Spline for property %s is not set", to_string( aProperty ).c_str() );
164 return mSplines( static_cast< size_t >( aProperty ) )->eval( aX ) ;
165 }
166
167 inline real
169 {
170 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
171 "Spline for property %s is not set", to_string( aProperty ).c_str() );
172 return mSplines( static_cast< size_t >( aProperty ) )->deval( aX ) ;
173 }
174
175 inline real
177 {
178 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
179 "Spline for property %s is not set", to_string( aProperty ).c_str() );
180 return mSplines( static_cast< size_t >( aProperty ) )->ddeval( aX ) ;
181 }
182
183 inline real
184 SplineLookupTable::l( const real T ) const
185 {
187 {
188 return 1.0 ;
189 }
190
191 return std::exp(
192 mSplines( static_cast< uint >( MaterialProperty::alpha ) )->integrate( T ) );
193 }
194
195//------------------------------------------------------------------------------
196
197 inline real
199 const Bezier * aBezier,
200 const Vector< real > & aPoly,
201 const real T ) const
202 {
203 if ( std::abs( T ) < BELFEM_EPSILON ) return 0. ;
204
205 if ( T < this->alpha_switch_temperature() )
206 {
207 // aPoly holds ln( C ) with C = alpha / cp ( Grueneisen equation of state )
208 return std::exp( polyval( aPoly, T ) ) * this->cp( T );
209 }
210 else
211 {
212 real xi = aBezier->xi_by_x( T );
213 real dLdxi, dTdxi ;
214 aBezier->dpoint( xi, dTdxi, dLdxi );
215 real L = 1 + aBezier->y_by_xi( xi );
216 return dLdxi / ( L * dTdxi );
217 }
218 }
219 }
220}
221
222#endif //BELFEM_CL_MATERIAL_SPLINELOOKUPTABLE_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Definition cl_Bezier.hpp:30
void dpoint(const real aXi, real &adXdXi, real &adYdXi) const
tangent vector as function of parameter coordinate
Definition cl_Bezier.cpp:210
real xi_by_x(const real aX) const
Inverts the function x_by_xi.
Definition cl_Bezier.cpp:88
real y_by_xi(const real aXi) const
The parameter coordinate goes from -1 <= xi <= 1.
Definition cl_Bezier.cpp:76
Cell is a wrapper around the standard vector.
Definition cl_Cell.hpp:42
friend class material::SplineLookupTable
Definition cl_Material.hpp:356
Material(const MaterialType aType, const bool aIsIsotropic=true)
Constructor.
Definition cl_Material.cpp:149
virtual real cp(const real T=gTroom) const
Specific heat capacity.
Definition cl_Material.hpp:1842
void create_spline(const MaterialProperty aProperty, const real adYdX0=BELFEM_QUIET_NAN, const real adXdX1=BELFEM_QUIET_NAN)
PROPERTY EVALUATION FUNCTIONS.
Definition cl_Material.cpp:1038
real constant_property(const MaterialProperty aProperty) const
Get constant property value.
Definition cl_Material.hpp:1787
real alpha_switch_temperature() const
Temperature below which alpha is taken from the Grueneisen branch.
Definition cl_Material.hpp:2333
virtual real alpha(real T=gTroom) const
Thermal expansion coefficient.
Definition cl_Material.hpp:2244
Cubic spline on a uniform grid, C2, with natural, parabolic or clamped boundary conditions.
Definition cl_Spline.hpp:45
real l(real T) const override
Relative length after thermal expansion, from integrated alpha spline.
Definition cl_Material_SplineLookupTable.hpp:184
real alpha_composite(const Bezier *aBezier, const Vector< real > &aPoly, const real T) const
composite thermal expansion for a Material::alpha_custom() override: the Grueneisen polynomial aPoly ...
Definition cl_Material_SplineLookupTable.hpp:198
Cell< Spline * > mSplines
Definition cl_Material_SplineLookupTable.hpp:29
real ddspline_property(const MaterialProperty aProperty, const real aX) const override
Definition cl_Material_SplineLookupTable.hpp:176
void create_cryo_expansion(const Bezier *aThermalExpansion, Vector< real > &aThermalExpansionCryo, const real aTSwitch=BELFEM_QUIET_NAN)
Definition cl_Material_SplineLookupTable.cpp:154
void create_low_temperature_alpha(const Bezier *aBezier, Vector< real > &aPoly, const real aTSwitch=BELFEM_QUIET_NAN)
Fit the cryogenic branch alpha = C( T ) cp( T ) below the split temperature from a dL/L Bezier ( the ...
Definition cl_Material_SplineLookupTable.cpp:276
void create_cryo_expansion_anchored(const real alpha, Vector< real > &aThermalExpansionCryo, const real aTSwitch=BELFEM_QUIET_NAN)
cryogenic branch anchored on the VALUE of alpha at the split only.
Definition cl_Material_SplineLookupTable.cpp:175
void reset_spline(const MaterialProperty aProperty) override
Definition cl_Material_SplineLookupTable.cpp:115
real dspline_property(const MaterialProperty aProperty, const real aX) const override
Definition cl_Material_SplineLookupTable.hpp:168
void create_spline(real(Material::*aFunction)(const real aT) const, const MaterialProperty aProperty, const uint aStartBC, const uint aEndBC, const real adYdX0, const real adYdX1) override
Definition cl_Material_SplineLookupTable.cpp:123
SplineLookupTable(const MaterialType aType, const bool aIsIsotropic=true)
Definition cl_Material_SplineLookupTable.cpp:17
real set_alpha_switch_temperature(const real aTSwitch=BELFEM_QUIET_NAN)
Fix the split temperature of the cryogenic expansion branch.
Definition cl_Material_SplineLookupTable.cpp:245
real spline_property(const MaterialProperty aProperty, const real aX) const override
Evaluate property using spline interpolation.
Definition cl_Material_SplineLookupTable.hpp:160
void set_spline(const MaterialProperty aProperty, Spline *aSpline=nullptr)
Assign a spline for property interpolation.
Definition cl_Material_SplineLookupTable.cpp:33
Spline * spline(const MaterialProperty aProperty)
Get spline for a property.
Definition cl_Material_SplineLookupTable.hpp:154
Evaluates a polynomial.
Definition cl_BhCurve.cpp:19
T polyval(const std::vector< T > &coeffs, const T x)
Definition cl_Material_UserDefined.hpp:28
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
constexpr real BELFEM_EPSILON
Definition typedefs.hpp:90
MaterialProperty
All material properties that can be defined.
Definition cl_Material.hpp:153
@ alpha
Definition cl_Material.hpp:161
@ T_ref_density
Definition cl_Material.hpp:173
double real
Definition typedefs.hpp:36
MaterialType
Material classification based on physical behavior.
Definition cl_Material.hpp:107
string to_string(const DomainType aDomainType)
Definition en_DomainType.cpp:21
#define BELFEM_QUIET_NAN
Definition typedefs.hpp:87