@samatawy/rules
    Preparing search index...

    Science Functions

    These functions are available from @samatawy/rules-science and are not built into the core @samatawy/rules package.

    Install the science package alongside the core engine:

    npm install @samatawy/rules @samatawy/rules-science
    

    Register one or more science providers before using the functions in rules:

    import { FunctionFactory } from '@samatawy/rules';
    import {
    CommonChemistryFunctionsProvider,
    PhysicsConstantsProvider,
    } from '@samatawy/rules-science';

    FunctionFactory.registerProvider(CommonChemistryFunctionsProvider);
    FunctionFactory.registerProvider(PhysicsConstantsProvider);

    You can also register both together:

    import { registerScienceProviders } from '@samatawy/rules-science';

    registerScienceProviders();

    These currently expose physical constants.

    Alternative syntax: speed_of_light(). Returns the speed of light in meters per second.

    set lightSpeed = c()
    

    Returns standard gravity.

    set gravity = g()
    

    Returns Avogadro's constant.

    set particlesPerMole = avogadro()
    

    Returns Planck's constant.

    set planckValue = planck()
    

    Returns the electron rest mass.

    set mass = electron_mass()
    

    Returns the proton rest mass.

    set mass = proton_mass()
    

    Returns the neutron rest mass.

    set mass = neutron_mass()
    

    Returns the Boltzmann constant.

    set k = boltzmann()
    

    Returns the universal gas constant.

    set r = gas_constant()
    

    Returns the Faraday constant.

    set chargePerMole = faraday()
    

    Returns the gravitational constant.

    set gConst = gravitational_constant()
    

    Returns the unified atomic mass unit in kilograms.

    set amu = molecular_mass_unit()
    

    Returns the Bohr radius in meters.

    set radius = bohr_radius()
    

    Returns the Rydberg constant.

    set rydberg = rydberg_constant()
    

    Returns the Stefan-Boltzmann constant.

    set sigma = stefan_boltzmann_constant()
    

    Returns the elementary charge in coulombs.

    set charge = elementary_charge()
    

    These functions expose common element lookups and formula helpers.

    A listing of known values is included for 118 elements. Every effort was made to keep accuracy but the possibility of errors is not zero.

    Compacts a formula by combining repeated element counts.

    set compact = short_formula("C2H4O2")
    

    Returns the molecular weight derived from the formula.

    set mw = molecular_weight("H2SO4")
    

    Returns how many atoms of an element appear in a formula.

    set oxygenCount = atoms_of_element("O", "C6H12O6")
    

    Returns the mass fraction contributed by an element in a formula.

    set oxygenFraction = fractional_weight_of_element("O", "H2O")
    

    Returns the available periodic-table symbols.

    set symbols = element_symbols()
    

    Returns the atomic number for an element symbol.

    set z = atomic_number("O")
    

    Returns the atomic weight for an element symbol.

    set wt = atomic_weight("Fe")
    

    Returns the element name for a symbol.

    set name = element_name("Na")
    

    Returns the electron configuration text for a symbol.

    set config = electron_configuration("Cl")
    

    Returns the number of valence electrons when known.

    set valence = valence_electrons("C")
    

    Returns the common oxidation states.

    set states = common_oxidation_states("Mn")
    

    Returns the Pauling electronegativity when known.

    set en = electronegativity("O")
    

    Returns the atomic radius in picometers when known.

    set radius = atomic_radius_pm("Si")
    

    Returns the first ionization energy in kilojoules per mole when known.

    set ie = ionization_energy_kj_mol("Ne")
    

    Returns the electron affinity in kilojoules per mole when known.

    set ea = electron_affinity_kj_mol("F")
    

    Returns the standard phase at STP.

    set phase = phase_at_stp("Br")
    

    Returns the melting point in kelvin when known.

    set melt = melting_point_k("Al")
    

    Returns the boiling point in kelvin when known.

    set boil = boiling_point_k("N")
    

    Returns the density in grams per cubic centimeter when known.

    set density = density_g_cm3("Cu")