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

Database-driven Jc function using lookup tables. More...

#include <cl_JcFunction_Database.hpp>

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

Public Member Functions

 JcFunctionDatabase (const string &aPath, const string &aLabel)
 Constructor - loads database from file.
void load_self_field (const string &aPath, const string &aLabel)
 Read the measured B = 0 level from the table's /source.
void reduce_self_field_rows (const Matrix< real > &aPoints, const index_t aColT, const index_t aColB, const index_t aColV, const real aScale, Vector< real > &aT, Vector< real > &aValue) const
 Bin the B = 0 rows by temperature and average over angle.
 ~JcFunctionDatabase () override=default
 Destructor - deletes the database.
real min_value () const override
void finalize_self_field ()
real self_field (const real T, real &aDT) const
void edge (const real angle, const real T, const bool aWithT, const bool aWithAngle, Edge &aEdge) const
bool continued (const real normB) const
 true if B lies on the continuation of this label
real anchor (const real a, const real V, const real S, const real aA_q, const real aV_q, const real aS_q, real &aJ_q) const
real jc_join (const real x, const real J, const real V, const real S, const real aJ_q, const real aV_q, const real aS_q, real &aValue_q, real &aDB) const
real continuation (const real normB, const real angle, const real T, const uint aMode, real &aDerivative) const
bool angle_is_snapped (const real angle) const
 Wrap the caller's angle into the table window.
real wrap_angle (const real angle) const
real eval (const real normB, const real angle, const real T) const override
 Evaluate Jc or n at given field, angle, and temperature.
real deval_dB (const real normB, const real angle, const real T) const override
 d(value)/d|B|, the exact derivative of eval
real deval_dbeta (const real normB, const real angle, const real T) const override
 d(value)/dθ, the exact derivative of eval
real deval_dT (const real normB, const real angle, const real T) const override
 d(value)/dT, the exact derivative of eval
Public Member Functions inherited from belfem::material::JcFunction
 JcFunction ()=default
virtual ~JcFunction ()=default
bool depends_on (const JcParameter aParameter) const
bool is_constant () const
virtual real eval (const real normB, const real angle) const
 Evaluate with field and angle dependence.

Static Public Member Functions

static Database * open_checked (const string &aPath, const string &aLabel)
 Open the table and refuse one the reader cannot serve.
static real interp_curve (const Vector< real > &aT, const Vector< real > &aValue, const real T, real &dJ0dT)

Additional Inherited Members

Protected Member Functions inherited from belfem::material::JcFunction
void set_dependency (const JcParameter aParameter)
 Mark function as depending on a parameter.
Protected Attributes inherited from belfem::material::JcFunction
JcDependency mDependency

Detailed Description

Database-driven Jc function using lookup tables.

Implements Jc(B, angle, T) or n(B, angle, T) through interpolation of tabulated data stored in HDF5 format.

The database uses a structured tensor grid with higher-order finite element interpolation (quad4/9/16 for 2D, hex8/27/64 for 3D).

Coordinate system:

  • Dimension 0: Temperature T [K] (linear scale)
  • Dimension 1: Magnetic field log10(B) [-] (log scale, B in T)
  • Dimension 2: Angle θ between n and B [rad]
  • Values: log10(Jc) or log10(n)

The database clamps out-of-range T and high-field inputs to the valid domain and handles periodic angle wrapping (angle ± π). Below Bmin, n and a jc table with a measured self-field curve continue the table C1 and non-increasing in |B| ( see the low-field notes below ); a jc table without that curve keeps the clamp.

Dependencies: normB, angleNxB, T

Database file format:

  • HDF5 file with structured tensor mesh
  • Dataset name matches material label
  • See Database class documentation for detailed format

Usage:

JcFunction* jc = factory.create_jc_function(
"path/to/ybco.hdf5", "jc" // group name; "jc" or "n" for the shipped tables
);
material->set_jc_function(jc); // Material takes ownership
Definition cl_BhCurve.cpp:19
@ jc
Definition cl_Material.hpp:186

Constructor & Destructor Documentation

◆ JcFunctionDatabase()

belfem::material::JcFunctionDatabase::JcFunctionDatabase ( const string & aPath,
const string & aLabel )
inline

Constructor - loads database from file.

Parameters
aPathPath to HDF5 database file
aLabelGroup name inside the HDF5 file — "jc" or "n" for the shipped tables. Only "jc" reads the measured self-field curve ( icw column, Icw/t_eff calibration ); anything else is an n table, continued below Bmin from the table alone.

Loads a database-driven Jc or n function from file. The constructor reads the database dimensions and extracts the valid ranges for each coordinate.

The database stores:

  • T in linear scale [K]
  • log10(B) where B is in [T]
  • angle in [rad]
  • log10(Jc) or log10(n) as values

Example database creation (Python with h5py):

# Create 3D grid: T × log10(B) × angle
T = np.linspace(4, 90, 50) # [K]
logB = np.linspace(-2, 1, 40) # log10(B), B in 0.01-10 T
angle = np.linspace(0, np.pi, 30) # [rad]
# Store log10(Jc) values on this grid

◆ ~JcFunctionDatabase()

belfem::material::JcFunctionDatabase::~JcFunctionDatabase ( )
overridedefault

Destructor - deletes the database.

Member Function Documentation

◆ anchor()

real belfem::material::JcFunctionDatabase::anchor ( const real a,
const real V,
const real S,
const real aA_q,
const real aV_q,
const real aS_q,
real & aJ_q ) const
inline

the jc anchor J = smax( a, b ) and its derivative along one of T or angle; aA_q, aV_q, aS_q are that derivative of a, V, S

◆ angle_is_snapped()

bool belfem::material::JcFunctionDatabase::angle_is_snapped ( const real angle) const
inline

Wrap the caller's angle into the table window.

theta in [ 0, pi ] passes through untouched; values within the same 1e-6 tolerance the ctor coverage guard uses are snapped onto the boundary — a table whose endpoints sit an ulp inside 0 or pi must not swap poles at exactly theta = 0 or pi. Anything further out uses the +-pi periodicity.

true where wrap_angle holds the angle on a window end, so the value does not change with it

◆ continuation()

real belfem::material::JcFunctionDatabase::continuation ( const real normB,
const real angle,
const real T,
const uint aMode,
real & aDerivative ) const
inline

value below Bmin and one derivative of it: aMode 0 d/dB, 1 d/dT, 2 d/dangle

◆ continued()

bool belfem::material::JcFunctionDatabase::continued ( const real normB) const
inline

true if B lies on the continuation of this label

◆ deval_dB()

real belfem::material::JcFunctionDatabase::deval_dB ( const real normB,
const real angle,
const real T ) const
inlineoverridevirtual

d(value)/d|B|, the exact derivative of eval

The table stores f = log10( value ) over u = log10 B, so d(value)/dB = value · (∂f/∂u) / B — ln10 cancels. Zero where eval clamps B ( above Bmax, and below Bmin for a jc table without a measured self-field curve ); at Bmin itself the continuation and the table share the slope.

Reimplemented from belfem::material::JcFunction.

◆ deval_dbeta()

real belfem::material::JcFunctionDatabase::deval_dbeta ( const real normB,
const real angle,
const real T ) const
inlineoverridevirtual

d(value)/dθ, the exact derivative of eval

θ is stored linearly, so d(value)/dθ = value · ln10 · ∂f/∂θ; the ±π wrap is a shift ( dθ_wrapped/dθ = 1 ), and the snap onto a window end holds the value ( zero ).

Reimplemented from belfem::material::JcFunction.

◆ deval_dT()

real belfem::material::JcFunctionDatabase::deval_dT ( const real normB,
const real angle,
const real T ) const
inlineoverridevirtual

d(value)/dT, the exact derivative of eval

T is stored linearly: d(value)/dT = value · ln10 · ∂f/∂T. Outside the temperature window the value is held, so the tangent is zero.

Reimplemented from belfem::material::JcFunction.

◆ edge()

void belfem::material::JcFunctionDatabase::edge ( const real angle,
const real T,
const bool aWithT,
const bool aWithAngle,
Edge & aEdge ) const
inline

the table on the face log10 B = log10 Bmin; d/dT and d/dangle terms only when asked for

◆ eval()

real belfem::material::JcFunctionDatabase::eval ( const real normB,
const real angle,
const real T ) const
inlineoverridevirtual

Evaluate Jc or n at given field, angle, and temperature.

Parameters
normBMagnetic field magnitude [T]
angleAngle between surface normal and field [rad]
TTemperature [K]
Returns
Jc [A/m²] or n [-]

T is clamped to [ Tmin, Tmax ] and B above Bmax to Bmax; the angle is wrapped into the table window. Below Bmin the value is the continuation described above ( a jc table without a measured self-field curve keeps the clamp ).

Reimplemented from belfem::material::JcFunction.

◆ finalize_self_field()

void belfem::material::JcFunctionDatabase::finalize_self_field ( )
inline

isotonic projection ( the running maximum from high to low T ) of the measured curve, and its knot slopes ( Fritsch & Butland 1984, Eq. 5; one-sided secants at the ends ), which keep every segment monotone ( Fritsch & Carlson 1980, §4 )

◆ interp_curve()

real belfem::material::JcFunctionDatabase::interp_curve ( const Vector< real > & aT,
const Vector< real > & aValue,
const real T,
real & dJ0dT )
inlinestatic

linear interpolation on the raw curve, clamped at both ends; used only to calibrate the curve at 77.5 K

◆ jc_join()

real belfem::material::JcFunctionDatabase::jc_join ( const real x,
const real J,
const real V,
const real S,
const real aJ_q,
const real aV_q,
const real aS_q,
real & aValue_q,
real & aDB ) const
inline

the jc Hermite on [ 0, Bmin ]: value, and the slope at B = 0 with its derivative along T or angle

◆ load_self_field()

void belfem::material::JcFunctionDatabase::load_self_field ( const string & aPath,
const string & aLabel )
inline

Read the measured B = 0 level from the table's /source.

The rebuilt tables embed their raw measurement rows as /source/points with /source/columns naming them, and those rows include the self-field scans the log10 B axis structurally cannot hold ( log10( 0 ) is undefined ). Rows at exactly B = 0 are binned by temperature and averaged over the stage angles – the average is the whole point, the measured angular scatter there being only a few tenths of a percent.

Silently inert on any file without /source: mHaveSelfField stays false and the jc table keeps the clamp below Bmin.

◆ min_value()

real belfem::material::JcFunctionDatabase::min_value ( ) const
inlineoverridevirtual

smallest value the table can produce; values are stored as log10, so exponentiate the raw minimum

Reimplemented from belfem::material::JcFunction.

◆ open_checked()

Database * belfem::material::JcFunctionDatabase::open_checked ( const string & aPath,
const string & aLabel )
inlinestatic

Open the table and refuse one the reader cannot serve.

Runs before any member reads the database, and owns it until every check has passed, so a refusal does not leak it. Every rank holds the same values ( Database broadcasts them ), so every rank refuses together.

◆ reduce_self_field_rows()

void belfem::material::JcFunctionDatabase::reduce_self_field_rows ( const Matrix< real > & aPoints,
const index_t aColT,
const index_t aColB,
const index_t aColV,
const real aScale,
Vector< real > & aT,
Vector< real > & aValue ) const
inline

Bin the B = 0 rows by temperature and average over angle.

The angular average IS the physics: at zero field there is no field direction, and the measured rows scatter only a few tenths of a percent across the stage angles. A temperature is a distinct bin when it differs by more than the tolerance, which is loose enough to merge one setpoint's jitter ( 77.48-77.51 K ) and tight enough to keep 2.5 K spacing apart.

◆ self_field()

real belfem::material::JcFunctionDatabase::self_field ( const real T,
real & aDT ) const
inline

the measured anchor and its dT: the C1 Hermite of the knots, continued linearly from the end knots outside them

◆ wrap_angle()

real belfem::material::JcFunctionDatabase::wrap_angle ( const real angle) const
inline

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