Skip to content
cccskills
FreePublished on GitHub

physics-databases

Query physics databases — NIST CODATA constants, NIST Chemistry WebBook, Materials Project, Particle Data Group (PDG), OEIS sequences. Always use these instead of hardcoding physical constants.

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md7.4 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Physics Databases

Overview

Access physical constants and reference data from authoritative databases. Never hardcode physical constants — always query from scipy.constants (CODATA 2018) or NIST APIs.

CRITICAL: Always Use Database Values

  • NEVER type physical constants from memory
  • ALWAYS use scipy.constants or NIST lookup
  • Constants change between CODATA editions (e.g., 2014 → 2018 → 2022)

Core Workflows

1. CODATA Physical Constants (scipy.constants)

from scipy import constants as const

# Fundamental constants
print("=== Fundamental Constants (CODATA 2018) ===")
print(f"Speed of light:       c  = {const.c:.10e} m/s")
print(f"Planck constant:      h  = {const.h:.10e} J·s")
print(f"Reduced Planck:       ℏ  = {const.hbar:.10e} J·s")
print(f"Boltzmann constant:   k  = {const.k:.10e} J/K")
print(f"Gravitational const:  G  = {const.G:.10e} m³/(kg·s²)")
print(f"Elementary charge:    e  = {const.e:.10e} C")
print(f"Electron mass:        mₑ = {const.m_e:.10e} kg")
print(f"Proton mass:          mₚ = {const.m_p:.10e} kg")
print(f"Neutron mass:         mₙ = {const.m_n:.10e} kg")
print(f"Vacuum permittivity:  ε₀ = {const.epsilon_0:.10e} F/m")
print(f"Vacuum permeability:  μ₀ = {const.mu_0:.10e} H/m")
print(f"Avogadro number:      Nₐ = {const.N_A:.10e} mol⁻¹")
print(f"Gas constant:         R  = {const.R:.10e} J/(mol·K)")
print(f"Stefan-Boltzmann:     σ  = {const.sigma:.10e} W/(m²·K⁴)")
print(f"Fine structure:       α  = {const.fine_structure:.10e}")
print(f"Rydberg constant:     R∞ = {const.Rydberg:.10e} m⁻¹")
print(f"Bohr radius:          a₀ = {const.physical_constants['Bohr radius'][0]:.10e} m")
print(f"Standard gravity:     g  = {const.g:.6f} m/s²")
print(f"Standard atmosphere:  atm= {const.atm:.2f} Pa")

2. Unit Conversions

# Energy conversions
print("\n=== Energy Conversions ===")
print(f"1 eV  = {const.eV:.10e} J")
print(f"1 cal = {const.calorie:.6f} J")
print(f"1 BTU = {const.Btu:.6f} J")
print(f"1 erg = {const.erg:.10e} J")

# Length conversions
print("\n=== Length Conversions ===")
print(f"1 Å   = {const.angstrom:.10e} m")
print(f"1 au  = {const.au:.6e} m")  # astronomical unit
print(f"1 ly  = {const.light_year:.6e} m")
print(f"1 pc  = {const.parsec:.6e} m")

# Temperature
print(f"\n0°C = {const.zero_Celsius:.2f} K")

# Pressure
print(f"\n1 atm = {const.atm:.2f} Pa")
print(f"1 bar = {const.bar:.2f} Pa")
print(f"1 torr = {const.torr:.6f} Pa")

3. Look Up Any CODATA Constant

# Search by name
def find_constant(keyword):
    """Search CODATA constants by keyword."""
    results = []
    for name, (value, unit, uncertainty) in const.physical_constants.items():
        if keyword.lower() in name.lower():
            results.append((name, value, unit, uncertainty))
            print(f"  {name}")
            print(f"    = {value:.10e} {unit}")
            print(f"    ± {uncertainty:.4e}")
    return results

print("Searching for 'Bohr':")
find_constant("Bohr")

print("\nSearching for 'magnetic moment':")
find_constant("magnetic moment")

4. Materials Project API

# pip install mp-api
# Requires API key: https://materialsproject.org/api

def query_materials_project(formula, api_key=None):
    """
    Query Materials Project for material properties.
    Set MP_API_KEY environment variable or pass api_key.
    """
    try:
        from mp_api.client import MPRester
        import os

        key = api_key or os.environ.get('MP_API_KEY')
        if not key:
            print("Set MP_API_KEY environment variable")
            return None

        with MPRester(key) as mpr:
            docs = mpr.summary.search(formula=[formula])
            for doc in docs[:5]:
                print(f"  {doc.material_id}: {doc.formula_pretty}")
                print(f"    Space group: {doc.symmetry.symbol}")
                print(f"    Energy above hull: {doc.energy_above_hull:.4f} eV/atom")
                print(f"    Band gap: {doc.band_gap:.3f} eV")
                print(f"    Density: {doc.density:.3f} g/cm³")
            return docs
    except ImportError:
        print("Install mp-api: pip install mp-api")
        return None

# Example: query_materials_project("Si")

5. Particle Data Group (PDG)

# Key particle properties (from PDG 2024)
# These are reference values — for precision work, check pdg.lbl.gov

particles = {
    'electron': {
        'mass_MeV': 0.51099895,
        'charge': -1,
        'spin': 0.5,
        'lifetime': 'stable',
    },
    'proton': {
        'mass_MeV': 938.27208816,
        'charge': +1,
        'spin': 0.5,
        'lifetime': 'stable (> 10^34 years)',
    },
    'neutron': {
        'mass_MeV': 939.56542052,
        'charge': 0,
        'spin': 0.5,
        'lifetime_s': 878.4,  # ~14.6 minutes
    },
    'muon': {
        'mass_MeV': 105.6583755,
        'charge': -1,
        'spin': 0.5,
        'lifetime_s': 2.1969811e-6,
    },
    'pion_charged': {
        'mass_MeV': 139.57039,
        'charge': +1,
        'spin': 0,
        'lifetime_s': 2.6033e-8,
    },
    'W_boson': {
        'mass_GeV': 80.3692,
        'charge': +1,
        'spin': 1,
    },
    'Z_boson': {
        'mass_GeV': 91.1876,
        'charge': 0,
        'spin': 1,
    },
    'Higgs': {
        'mass_GeV': 125.20,
        'charge': 0,
        'spin': 0,
    },
}

# Always cite: "Particle Data Group, Phys. Rev. D 110, 030001 (2024)"
# For precision values: https://pdg.lbl.gov

6. Astronomical Constants

# Solar system data (IAU 2015 values)
print("\n=== Astronomical Constants ===")
print(f"Solar mass:    M☉ = 1.98892e30 kg")
print(f"Solar radius:  R☉ = 6.9634e8 m")
print(f"Solar luminosity: L☉ = 3.828e26 W")
print(f"Earth mass:    M⊕ = 5.9722e24 kg")
print(f"Earth radius:  R⊕ = 6.3781e6 m")
print(f"Moon mass:     M☾ = 7.342e22 kg")
print(f"AU:            1 AU = {const.au:.6e} m")

# For precise values, use astropy:
# from astropy import constants as astro_const
# print(astro_const.M_sun)

Quick Reference

ConstantSymbolValuescipy.constants
Speed of lightc2.998×10⁸ m/sconst.c
Planckh6.626×10⁻³⁴ J·sconst.h
Boltzmannk_B1.381×10⁻²³ J/Kconst.k
GravitationalG6.674×10⁻¹¹ m³/(kg·s²)const.G
Elementary chargee1.602×10⁻¹⁹ Cconst.e
Electron massm_e9.109×10⁻³¹ kgconst.m_e
Proton massm_p1.673×10⁻²⁷ kgconst.m_p
AvogadroN_A6.022×10²³ mol⁻¹const.N_A
Gas constantR8.314 J/(mol·K)const.R
1 eV—1.602×10⁻¹⁹ Jconst.eV
1 Å—1.0×10⁻¹⁰ mconst.angstrom

Tips

  1. Always from scipy import constants as const — never type values manually
  2. Check units: const.physical_constants['Bohr radius'] returns (value, unit, uncertainty)
  3. For astrophysics: use astropy.constants for additional astronomical constants
  4. For materials: use mp-api to query the Materials Project database
  5. Cite your source: "CODATA 2018 via scipy.constants" or "PDG 2024"

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Simplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device placement, mixed precision (FP16/BF16/FP8). Interactive config, single launch command. HuggingFace ecosystem standard.

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

ADMET property prediction for drug candidates. Full pharmacokinetic panel (Caco-2, PPB, clearance, CYP), toxicity (hERG, AMES, DILI), drug-likeness (Lipinski, QED), using RDKit descriptors and TDC models.

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

Interpretable ADMET analysis with mechanistic reasoning. Maps liabilities to structural causes and biological pathways. Based on CoTox (Park 2025) and DrugR (Liu 2026).

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

aeon

Free

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

The English summary is being prepared. Showing the original description.

huang-sh/DeepScience4Updated Jul 15, 2026

See all skills by huang-sh

Report a problem with this skill