Nanoscale, plasma & surface-contact engineering
Nanoscale surface/transport physics, plasma and fusion parameters, dry and lubricated contact mechanics with wear-corrosion coupling, and antenna/RF link-budget equations across five independent kerne
Five modules for five formula-driven domains that share no code with each other: nanoscale surface, transport and colloidal physics (nanotechnology); plasma and fusion parameters (plasma_physics); dry and lubricated contact mechanics (tribology); a second, overlapping contact-mechanics module with two genuinely chemical additions (tribochemistry); and antenna sizing plus RF link budgets (antenna). Every function is a single closed-form equation — no iteration, no fitting, no Python — taking plain Float64 scalars in SI or the field's conventional units (eV for plasma temperatures, dB/dBm/dBi for RF) and returning one Float64 back.
from algenta import MojoRuntime
runtime = MojoRuntime(mode="local")
# Two independent derivations of free-space path loss for the same 2.4 GHz link at 10 m.
wl = runtime.execute("antenna", "wavelength_from_freq", [2.4e9, 3.0e8])["result"]
wl # 0.125 m
runtime.execute("antenna", "friis_path_loss", [10.0, wl])["result"]
# 60.0459970202808 dB -- 20*log10(4*pi*d/lambda)
runtime.execute("antenna", "free_space_loss_db", [0.01, 2400.0])["result"]
# 60.054224834232116 dB -- 32.45 + 20*log10(d_km) + 20*log10(f_MHz), same 10 m / 2.4 GHz link
# Same physics, two different closed-form parameterizations of the same constant --
# they agree to within 0.01 dB, the residual coming from the fixed c and rounded
# constant each formula bakes in.The modules
nanotechnology
Sphere geometry at the nanoscale (surface area, volume, surface-to-volume ratio, specific surface area), particle-in-a-box quantum confinement energy, gas-kinetic mean free path and Knudsen number, sphere-flat van der Waals force, Stokes-Einstein diffusion, Smoluchowski zeta-potential mobility, nanorod/nanotube aspect ratio, and the exact FCC sphere-packing fraction.
plasma_physics
Debye length, electron plasma frequency, thermal velocity, Larmor (gyro) radius, Coulomb logarithm, Spitzer resistivity, Alfvén speed, MHD beta, the Lawson nτ ignition criterion, and Bremsstrahlung radiated power density.
tribology
Coulomb/kinetic/static friction force, coefficient of friction, Hertz contact pressure, Archard wear volume, bearing pressure, Sommerfeld number, Stribeck parameter, flash temperature rise, a proportional EHD film-thickness estimate, and friction power loss.
tribochemistry
A second Hertz-contact and Archard-wear implementation (contact radius from force, max pressure, wear rate, wear volume, flash temperature), the Hamrock-Dowson EHD film thickness and lambda ratio, plus two functions with no tribology counterpart: work of adhesion from surface energy, and a wear-corrosion tribocorrosion synergy rate.
antenna
Half-wave dipole length, wavelength from frequency, Friis and ITU-form free-space path loss, EIRP, received power, directivity from beamwidths, antenna efficiency, effective aperture, link-budget margin, noise-figure-to-noise-temperature conversion, and aperture-based beamwidth estimation.
Nanoscale physics: sizes, transport, and colloidal forces
nanotechnology.mojo has no guard clauses anywhere in the file — every function is one line of direct arithmetic on the formula in its docstring. The worked examples below are hand-computed from those formulas (not the module's own smoke test, which only checks finiteness — see Verification) and checked against known real-world reference values where one exists.
A 5 nm-radius sphere (roughly a CdSe quantum dot or a small gold nanoparticle):
For a gold sphere that size (density 19,300 kg/m³, mass ≈1.0105e-20 kg), specific surface area (SA / mass) comes out to 31.09 m²/g — the right order of magnitude for real engineered nanoparticle powders, which are typically quoted in the tens of m²/g.
Quantum confinement. A particle-in-a-box estimate for a 5 nm CdSe dot (electron effective mass ≈0.13·mₑ, mₑ = 9.1093837015e-31 kg, h = 6.62607015e-34 J·s):
Real CdSe quantum dots at this size show confinement shifts in the tenths-of-an-eV range, so the formula's magnitude is physically sensible even though it is the textbook infinite-square-well approximation, not the finite-well or effective-mass-mismatch correction a real optical-properties calculation would add.
Mean free path and the Knudsen number. Nitrogen at STP (T = 298.15 K, collision diameter d ≈ 3.7e-10 m, P = 101,325 Pa):
Van der Waals force and Stokes-Einstein diffusion. A 50 nm sphere at 0.3 nm separation from a flat surface (Hamaker constant 1e-19 J, a typical condensed-matter value) feels van_der_waals_force = 9.259e-9 N. The same particle diffusing in water at 298 K (η = 8.9e-4 Pa·s) has diffusion_coefficient_stokes_einstein = 4.907e-11 m²/s — the right order of magnitude for nanoparticle tracking measurements at this size and viscosity.
Zeta potential. Given an electrophoretic mobility of 1e-8 m²/(V·s) in water (η = 8.9e-4 Pa·s, ε = 80·ε₀ = 7.0832e-10 F/m), zeta_potential_mobility (the Smoluchowski relation η·μ/ε) returns 0.01256 V ≈ 12.6 mV, inside the ±10-100 mV range real colloidal suspensions typically show.
Plasma and fusion parameters
plasma_physics.mojo is the opposite of nanotechnology.mojo in posture: every function that divides by a physical quantity guards it first and returns 0.0 (or, for coulomb_logarithm, a documented fallback of 10.0) rather than letting a non-positive temperature or density produce inf/NaN. Only fusion_lawson_criterion has no guard, because it is a plain product with no division to protect.
The worked examples use tokamak-core-scale parameters — T = 10 keV (1e4 eV), n = 1e20 m⁻³, and a 5.3 T field (ITER's design-scale toroidal field, used here only to pick a realistic magnitude, not to claim these are ITER's published operating numbers):
That plasma frequency is independently checkable: the NRL Plasma Formulary's textbook constant is ω_pe ≈ 5.64e4 · √(n[cm⁻³]) rad/s. At n = 1e20 m⁻³ = 1e14 cm⁻³, that gives 5.64e4 * sqrt(1e14) = 5.64e11 rad/s, matching the kernel's 5.641e11 to 4 significant figures.
Electron and deuteron gyroradii differing by roughly the square root of their mass ratio at equal temperature is the expected physical relationship, not a coincidence of the chosen numbers.
Two modules, one wear law: tribology and tribochemistry
The Archard wear equation (V = k·F·d / H) appears three times across these two modules: tribology.archard_wear_volume, tribochemistry.archard_wear_rate, and tribochemistry.wear_volume are all the same formula, byte-for-byte identical bodies apart from a parameter name (hardness vs. hardness_pa). Two more formulas are duplicated once each: tribology.coefficient_of_friction / tribochemistry.friction_coefficient (μ = Ff/Fn) and tribology.hertz_contact_pressure / tribochemistry.hertz_max_pressure (p₀ = 3F/(2πa²)).
Two things differ between the twins, and both matter to a caller switching between the modules:
Parameter order is not the same. tribology.archard_wear_volume(k, load, sliding_distance, hardness) takes load before distance; tribochemistry.archard_wear_rate(wear_coefficient, sliding_distance, normal_force, hardness) and wear_volume take distance before load. The product load * distance is commutative, so passing the same two numbers in the position the other module expects still gives the right answer by accident — but passing genuinely different-valued load and distance figures into the wrong module's argument order silently swaps them.
Guard posture is opposite. tribology's functions have no guard clauses at all — dividing by a zero contact_radius, hardness, or normal_force produces IEEE inf, not an error. tribochemistry's equivalents all guard: hertz_max_pressure returns 0.0 for contact_radius <= 0.0, archard_wear_rate and wear_volume return 0.0 for hardness <= 0.0, and friction_coefficient returns 0.0 for normal_force <= 0.0. Concretely:
tribochemistry also adds two functions with no tribology equivalent, both of which are the module's genuinely chemical content (see the note below): surface_energy_work (thermodynamic work of adhesion, W = 2γ) and tribocorrosion_rate (wear-corrosion synergy). Water's surface tension (γ = 72.8 mJ/m² at 20°C) gives a textbook cross-check:
tribology-only worked examples, all steel-on-steel dry-sliding order of magnitude:
A full antenna link budget
Chaining antenna's functions end to end for a 2.4 GHz link over 1 km, 20 dBm transmit power, 6 dBi transmit gain, 2 dBi receive gain, and an EIRP-referenced -85 dBm receiver sensitivity:
Guard posture varies sharply by module
Reading all five .mojo files rather than assuming a shared convention turns up a clean, verifiable split. Three modules never guard a division against a zero or negative input: nanotechnology, tribology, and antenna contain no if statements at all — every formula is computed directly, so a zero radius, contact_radius, normal_force, frequency, or aperture_dim produces IEEE inf/-inf/NaN rather than a caught error or a sentinel value. Two modules guard every function that divides: plasma_physics returns 0.0 (or 10.0 for coulomb_logarithm) for a non-positive temperature, density, charge, or field; tribochemistry returns 0.0 for a non-positive hardness, contact radius, effective modulus/radius, or roughness. Neither posture is validated by the modules' own tests — the auto-generated smoke suites (see Verification) call every function once with a fixed 0.5 for every argument, which never crosses zero and so never exercises either the guarded or unguarded branch.
A note on the name: tribochemistry is mostly a second contact-mechanics module
tribochemistry.mojo's docstring calls it "Surface chemistry of sliding contacts," but eight of its ten functions are contact-mechanics and wear formulas — three of them are literal duplicates of tribology functions (above) and the rest (hertz_contact_radius, flash_temperature, film_thickness_ehd, lambda_ratio) are Hertzian-contact and elastohydrodynamic-lubrication math with no reaction chemistry in them. Real tribochemistry, as a field, is about the chemical reactions a sliding contact drives — tribofilm formation, oxidative wear, additive decomposition — none of which appears here. Only two of the ten functions carry a genuinely chemical quantity: surface_energy_work (an interfacial thermodynamics term, the work needed to separate two adhered surfaces) and tribocorrosion_rate (the mechanical-plus-chemical wear-corrosion synergy that gives the real field of tribocorrosion its name). The module is real, working physics — it is just closer to "tribology, plus two chemistry-adjacent functions" than to a chemical-kinetics module.
Verification
All five mojo/tests/libs/test_*.mojo files behind this page (test_nanotechnology.mojo, test_plasma_physics.mojo, test_tribology.mojo, test_tribochemistry.mojo, test_antenna.mojo) are auto-generated coverage smoke tests: each calls every function once with a fixed 0.5 (or 0.5, 0.5, ...) for every argument and checks only that the result is finite — they pin no specific numeric output and never probe a zero, negative, or boundary input. Every number in this page was instead hand-computed independently from the real formulas in mojo/engine/nanotechnology.mojo, plasma_physics.mojo, tribology.mojo, tribochemistry.mojo, and antenna.mojo, cross-checked against known reference values where one exists: the exact FCC packing fraction (Kepler's conjecture), the ~68 nm mean free path of air at STP, the NRL Plasma Formulary's electron-plasma-frequency constant (5.64e4·√n[cm⁻³]), water's 145.6 mJ/m² work of cohesion, and the textbook isotropic effective aperture Ae = λ²/4π. Every number given can be reproduced by re-running the same arithmetic.
Next: see Classical ML algorithms for another page of small, self-contained formula modules verified the same way by hand, or browse the Runtime library catalog for every module and function in the engine.
Last updated
Was this helpful?