BELFEM 0.9.3
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
42 void
43 set_spline( const MaterialProperty aProperty, Spline * aSpline=nullptr ) ;
44
45 Spline *
46 spline( const MaterialProperty aProperty ) ;
47
48 real
49 spline_property( const MaterialProperty aProperty, const real aX ) const override ;
50
51 real
52 dspline_property( const MaterialProperty aProperty, const real aX ) const override ;
53
54 real
55 ddspline_property( const MaterialProperty aProperty, const real aX ) const override ;
56
60 real
61 l( real T ) const override ;
62
63 protected:
64
65 // un-hide the convenience overload create_spline( aProperty, adYdX0, adYdX1, aStep )
67
68 void
69 reset_spline( const MaterialProperty aProperty ) override ;
70
71 void
72 create_spline( real (Material::*aFunction)(const real aT) const,
73 const MaterialProperty aProperty,
74 const uint aStartBC,
75 const uint aEndBC,
76 const real adYdX0,
77 const real adYdX1,
78 const real aStep ) 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
116 real
117 alpha_composite( const Bezier * aBezier, const Vector< real > & aPoly, const real T ) const ;
118
124 real
126
131 void
132 create_low_temperature_alpha( const Bezier * aBezier , Vector< real > & aPoly,
133 const real aTSwitch = BELFEM_QUIET_NAN );
134
140 void
141 create_low_temperature_alpha( const real alpha, const real dalphadT, const real d2alphadT2,
142 Vector< real > & aPoly, const bool aCheckGuard = true );
143
144 private:
145
146 void
147 finish_cryo_expansion( const Vector< real > & aThermalExpansionCryo );
148
149 };
150
151 inline Spline *
153 {
154 return mSplines( static_cast< size_t >( aProperty ) ) ;
155 }
156
157 inline real
159 {
160 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
161 "Spline for property %s is not set", to_string( aProperty ).c_str() );
162 return mSplines( static_cast< size_t >( aProperty ) )->eval( aX ) ;
163 }
164
165 inline real
167 {
168 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
169 "Spline for property %s is not set", to_string( aProperty ).c_str() );
170 return mSplines( static_cast< size_t >( aProperty ) )->deval( aX ) ;
171 }
172
173 inline real
175 {
176 BELFEM_ASSERT( mSplines( static_cast< size_t >( aProperty ) ) != nullptr,
177 "Spline for property %s is not set", to_string( aProperty ).c_str() );
178 return mSplines( static_cast< size_t >( aProperty ) )->ddeval( aX ) ;
179 }
180
181 inline real
182 SplineLookupTable::l( const real T ) const
183 {
185 {
186 return 1.0 ;
187 }
188
189 return std::exp(
190 mSplines( static_cast< uint >( MaterialProperty::alpha ) )->integrate( T ) );
191 }
192
193//------------------------------------------------------------------------------
194
195 inline real
197 const Bezier * aBezier,
198 const Vector< real > & aPoly,
199 const real T ) const
200 {
201 if ( std::abs( T ) < BELFEM_EPSILON ) return 0. ;
202
203 if ( T < this->alpha_switch_temperature() )
204 {
205 // aPoly holds ln( C ) with C = alpha / cp ( Grueneisen equation of state )
206 return std::exp( polyval( aPoly, T ) ) * this->cp( T );
207 }
208 else
209 {
210 real xi = aBezier->xi_by_x( T );
211 real dLdxi, dTdxi ;
212 aBezier->dpoint( xi, dTdxi, dLdxi );
213 real L = 1 + aBezier->y_by_xi( xi );
214 return dLdxi / ( L * dTdxi );
215 }
216 }
217 }
218}
219
220#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:206
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
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
friend class material::SplineLookupTable
Definition cl_Material.hpp:346
Material(const MaterialType aType, const bool aIsIsotropic=true)
Definition cl_Material.cpp:149
virtual real cp(const real T=gTroom) const
Specific heat capacity.
Definition cl_Material.hpp:1738
void create_spline(const MaterialProperty aProperty, const real adYdX0=BELFEM_QUIET_NAN, const real adYdX1=BELFEM_QUIET_NAN, const real aStep=4.0)
PROPERTY EVALUATION FUNCTIONS.
Definition cl_Material.cpp:1045
real constant_property(const MaterialProperty aProperty) const
Definition cl_Material.hpp:1683
real alpha_switch_temperature() const
Temperature below which alpha is taken from the Grueneisen branch.
Definition cl_Material.hpp:2222
virtual real alpha(real T=gTroom) const
Thermal expansion coefficient.
Definition cl_Material.hpp:2136
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:182
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:196
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:174
void create_cryo_expansion(const Bezier *aThermalExpansion, Vector< real > &aThermalExpansionCryo, const real aTSwitch=BELFEM_QUIET_NAN)
Definition cl_Material_SplineLookupTable.cpp:161
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:283
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:182
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:166
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, const real aStep) 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:252
real spline_property(const MaterialProperty aProperty, const real aX) const override
Definition cl_Material_SplineLookupTable.hpp:158
void set_spline(const MaterialProperty aProperty, Spline *aSpline=nullptr)
Takes ownership of aSpline; the table deletes it.
Definition cl_Material_SplineLookupTable.cpp:33
Spline * spline(const MaterialProperty aProperty)
Definition cl_Material_SplineLookupTable.hpp:152
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:89
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:113
string to_string(const DomainType aDomainType)
Definition en_DomainType.cpp:21
#define BELFEM_QUIET_NAN
Definition typedefs.hpp:86