BELFEM 0.9.0
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
 Destructor - deletes the database.
real min_value () const override
real self_field (const real T, real &dJ0dT) const
void edge_value_and_slope (const real angle, const real T, real &V, real &S) const
 the table's own value and d/dB at the low-field edge
real wrap_angle (const real angle) const
 Wrap the caller's angle into the table window.
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| from the spline, clamp-consistent
real deval_dbeta (const real normB, const real angle, const real T) const override
 d(value)/dθ from the spline
real deval_dT (const real normB, const real angle, const real T) const override
 d(value)/dT from the spline, clamp-consistent
Public Member Functions inherited from belfem::material::JcFunction
 JcFunction ()=default
 Default constructor.
virtual ~JcFunction ()=default
 Virtual destructor.
bool depends_on (const JcParameter aParameter) const
 Check if function depends on a parameter.
bool is_constant () const
 Check if function is constant (no dependencies).
virtual real eval (const real normB, const real angle) const
 Evaluate with field and angle dependence.

Static Public Member Functions

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 a table with a /source group uses the self-field bridge instead of a 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
JcFunction()=default
Default constructor.
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. The self-field bridge keys on this label: only "jc" reads the icw column and applies the Icw/t_eff calibration; anything else is treated as an n table.

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 ( )
inlineoverride

Destructor - deletes the database.

Member Function Documentation

◆ deval_dB()

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

d(value)/d|B| from the spline, clamp-consistent

The table stores f = log10(value) over ( T, u = log10 B, θ ), so with value = 10^f and du/dB = 1/( B ln10 ):

d(value)/dB = value · ln10 · (∂f/∂u) · du/dB
            = value · (∂f/∂u) / B          — ln10 CANCELS.

( Verified independently by both audit voices 2026-08-13; an earlier plan note carried a spurious ln10 here. ) When |B| is outside the table window, eval() returns the CLAMPED value, which is constant in |B| — the consistent tangent is exactly zero, and the derivative implements that clamp decision itself rather than trusting a caller to.

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θ from the spline

θ is stored linearly, so the log10 storage contributes the full ln10: d(value)/dθ = value · ln10 · ∂f/∂θ. The ±π wrap is a shift ( dθ_wrapped/dθ = 1 ), applied identically to eval().

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 from the spline, clamp-consistent

T is stored linearly: d(value)/dT = value · ln10 · ∂f/∂T. Outside the temperature window the clamped value is constant in T — the consistent tangent is zero.

Reimplemented from belfem::material::JcFunction.

◆ edge_value_and_slope()

void belfem::material::JcFunctionDatabase::edge_value_and_slope ( const real angle,
const real T,
real & V,
real & S ) const
inline

the table's own value and d/dB at the low-field edge

◆ 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 [-] interpolated from database

Performs 3D tensor interpolation:

  1. Clamps T to [Tmin, Tmax]
  2. |B| ≥ Bmin: clamps B to [Bmin, Bmax] and converts to log10(B). |B| < Bmin: if the file carries a /source group, evaluates the C1 self-field bridge jc = J0(T) + c·B + b·B² ( see the low-field transition notes above ); otherwise clamps to Bmin
  3. Wraps angle into [angle_min, angle_max] using ±π periodicity; the caller delivers the unfolded θ ∈ [0, π], which passes through untouched — θ = π reads the stored 180° node, honoring the measured asymmetry about 90°
  4. Interpolates log10(Jc) or log10(n) using FEM shape functions
  5. Returns 10^(interpolated value)

Above Bmax and outside [Tmin, Tmax] inputs are clamped to the database bounds; below Bmin only tables without /source clamp.

Reimplemented from belfem::material::JcFunction.

◆ interp_curve()

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

measured angle-free value at B = 0 and its dT, by linear interpolation on the stored curve. Clamped at both ends: the curve spans the measured temperature range, not the table's

◆ 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 every accessor keeps the historical clamp, so older tables behave exactly as before.

◆ 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.

◆ 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 & dJ0dT ) const
inline

◆ wrap_angle()

real belfem::material::JcFunctionDatabase::wrap_angle ( 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.


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