Scientific Applications and Tutorials
HPFRACC is designed for computational physics and biophysics research. This chapter consolidates scientific applications, performance optimization, error analysis, and researcher guides.
Performance Optimization Guide
Intelligent Backend Selection
HPFRACC v3.0.0 features revolutionary intelligent backend selection with automatic optimization:
from hpfracc.ml.intelligent_backend_selector import IntelligentBackendSelector
# Automatic optimization - no configuration needed!
selector = IntelligentBackendSelector(enable_learning=True)
# All operations automatically benefit from intelligent selection
frac_deriv = hpfracc.create_fractional_derivative(alpha=0.5, definition="caputo")
result = frac_deriv(f, x) # Automatically uses optimal backend
Performance Benchmarks
For comprehensive optimization strategies, see HPFRACC Performance Optimization Guide (v3.0.0).
Error Analysis and Validation
Numerical Error Analysis
Compare numerical and analytical solutions:
from hpfracc.core.derivatives import create_fractional_derivative
from hpfracc.core.definitions import FractionalOrder
import numpy as np
def analytical_solution(x, alpha):
"""Analytical solution for D^α sin(x)."""
return np.sin(x + alpha * np.pi / 2)
# Compare numerical and analytical solutions
x = np.linspace(0, 2*np.pi, 100)
alpha = 0.5
# Numerical solution
deriv = create_fractional_derivative(FractionalOrder(alpha), method="RL")
numerical = deriv(lambda x: np.sin(x), x)
# Analytical solution
analytical = analytical_solution(x, alpha)
# Compute error
error = np.mean(np.abs((numerical - analytical) / analytical))
print(f"Relative error: {error:.6f}")
Convergence Analysis
Analyze numerical convergence:
from hpfracc.algorithms.optimized_methods import OptimizedCaputo
import numpy as np
import matplotlib.pyplot as plt
# Test different grid sizes
grid_sizes = [20, 40, 80, 160, 320]
alpha = 0.5
errors = []
for N in grid_sizes:
t = np.linspace(0.01, 2, N)
h = t[1] - t[0]
f = t**2
# Numerical result
caputo = OptimizedCaputo(order=alpha)
numerical = caputo.compute(f, t, h)
# Analytical result
analytical = 2 * t ** (2 - alpha) / gamma(3 - alpha)
# Calculate error
error = np.max(np.abs(numerical - analytical))
errors.append(error)
# Plot convergence
plt.loglog(grid_sizes, errors, 'bo-', label="Numerical Error")
plt.xlabel("Grid Size N")
plt.ylabel("Maximum Error")
plt.title(f"Convergence Analysis: Caputo Derivative (α = {alpha})")
plt.legend()
plt.grid(True)
plt.show()
Physics and Scientific Examples
Computational Physics
Fractional PDEs:
from hpfracc.core.derivatives import CaputoDerivative
from hpfracc.special.mittag_leffler import mittag_leffler
import numpy as np
# Fractional diffusion equation: ∂^α u/∂t^α = D ∇²u
alpha = 0.5 # Fractional order
D = 1.0 # Diffusion coefficient
# Create fractional derivative
caputo = CaputoDerivative(order=alpha)
# Simulate fractional diffusion
x = np.linspace(-5, 5, 100)
t = np.linspace(0, 2, 50)
initial_condition = np.exp(-x**2 / 2)
# Use Mittag-Leffler function for analytical solution
solution = []
for time in t:
# E_{α,1}(-D t^α) represents fractional diffusion
ml_arg = -D * time**alpha
ml_result = mittag_leffler(ml_arg, alpha, 1.0)
if not np.isnan(ml_result):
solution.append(initial_condition * ml_result.real)
print(f"Fractional diffusion computed for {len(solution)} time steps")
Viscoelastic Materials:
from hpfracc.core.integrals import FractionalIntegral
# Fractional oscillator: mẍ + cD^αx + kx = F(t)
alpha = 0.7 # Viscoelasticity order
omega = 1.0 # Natural frequency
# Create fractional integral for stress-strain relationship
integral = FractionalIntegral(order=alpha)
# Simulate viscoelastic response
t = np.linspace(0, 10, 100)
forcing = np.sin(omega * t)
# Response using Mittag-Leffler function
response = []
for time in t:
# E_{α,1}(-ω^α t^α) for fractional oscillator
ml_arg = -(omega**alpha) * (time**alpha)
ml_result = mittag_leffler(ml_arg, alpha, 1.0)
if not np.isnan(ml_result):
response.append(ml_result.real)
print(f"Viscoelastic response computed for α={alpha}")
Biophysics Applications
Protein Folding Dynamics:
from hpfracc.core.derivatives import CaputoDerivative
import numpy as np
# Fractional protein folding kinetics
alpha = 0.6 # Fractional order for protein dynamics
# Model: D^α p(t) = -k p(t) where p is protein state
k = 0.1 # Folding rate constant
caputo = CaputoDerivative(order=alpha)
# Time evolution
t = np.linspace(0, 10, 100)
p0 = 1.0 # Initial unfolded state
# Use Mittag-Leffler function for solution
from hpfracc.special.mittag_leffler import mittag_leffler
solution = []
for time in t:
ml_arg = -k * (time**alpha)
ml_result = mittag_leffler(ml_arg, alpha, 1.0)
if not np.isnan(ml_result):
solution.append(p0 * ml_result.real)
print(f"Protein folding dynamics computed for α={alpha}")
Researchers’ Quick Start Guide
For computational physics and biophysics researchers:
Installation
# Basic installation
pip install hpfracc
# With GPU support (recommended for research)
pip install hpfracc[gpu]
# With ML extras (for neural networks)
pip install hpfracc[ml]
Quick Verification
import hpfracc as hpc
print(f"HPFRACC version: {hpc.__version__}")
# Test basic functionality
from hpfracc.core.derivatives import CaputoDerivative
caputo = CaputoDerivative(order=0.5)
print("✅ Installation successful!")
For comprehensive researcher guide, see Researcher Quick Start Guide.
Scientific Tutorials
The library includes comprehensive scientific tutorials covering:
Fractional diffusion equations
Viscoelastic materials
Anomalous transport
Biophysical systems
Neural network applications
Scientific tutorials are embedded in this chapter. For additional detailed guides, see the Additional Guides section in the main documentation.
Summary
Scientific Applications provide:
✅ Performance Optimization: Intelligent backend selection with 10-100x speedup ✅ Error Analysis: Numerical validation and convergence studies ✅ Physics Examples: Fractional PDEs, viscoelasticity, diffusion ✅ Biophysics: Protein dynamics, membrane transport, drug delivery ✅ Research Tools: Quick start guides and comprehensive tutorials
Next Steps
Optimization Guide: See HPFRACC Performance Optimization Guide (v3.0.0) for detailed strategies
Researcher Guide: See Researcher Quick Start Guide for quick start
Scientific Tutorials: Embedded in this chapter with code examples
Examples: Check Basic Examples and Advanced Examples for practical examples