Biomedical, biomechanics, and psychoacoustics kernels
Bedside cardiovascular/renal/respiratory/pharmacokinetic formulas, gait and joint-mechanics equations, and human sound-perception models — three unrelated small physics/physiology libraries, not one "
Three small, stateless formula modules that apply closed-form physics and physiology equations to the human body: bedside clinical calculations (biomedical), the mechanics of joints, limbs, and gait (biomechanics), and how the ear and brain perceive loudness, pitch, and masking (psychoacoustics). None of these are simulators — each function is a single named formula (Cockcroft-Gault, the Fick principle, the Hill muscle model, the Bark scale) evaluated on scalar Float64 inputs, the same shape as every other kernel family in this corpus. biomedical is not the only clinical-formula module in the runtime library — the section below on its overlap with cardiology, nephrology, and pulmonology covers exactly which functions duplicate each other and how the signatures disagree.
from algenta import MojoRuntime
runtime = MojoRuntime(mode="local")
# Fick principle: 250 mL/min VO2, arterial/venous O2 content 20 and 15 mL/dL
runtime.execute("biomedical", "fick_cardiac_output", [250.0, 20.0, 15.0])["result"]
# 5.0 — L/min, a normal resting cardiac output
# Hill muscle model: Fmax=1000 N, shortening at 0.1 (of Vmax), Vmax=1.0, a=0.25
runtime.execute("biomechanics", "muscle_force_hill", [1000.0, 0.1, 1.0, 0.25])["result"]
# 642.857... — force drops off from Fmax as contraction velocity rises, per Hill's 1938 curveThe modules
biomedical
Cardiovascular, renal, respiratory, and pharmacokinetic bedside formulas: cardiac output (both the SV×HR and Fick-principle routes), mean arterial and pulse pressure, Du Bois body surface area, Cockcroft-Gault creatinine clearance (named glomerular_filtration_rate), oxygen delivery, the alveolar gas equation, BMI, drug clearance, anion gap, and Bazett-corrected QT.
biomechanics
Joint and gait mechanics: joint torque and power, angular velocity/acceleration, limb moment of inertia, ground-reaction-force ratio, stride length and cadence, walking metabolic cost, tendon elastic energy, two-segment center of mass, and the Hill muscle force-velocity model.
psychoacoustics
Human auditory perception, not physical sound propagation: phon↔sone loudness conversion, the Bark scale and critical bandwidth (ERB), a simplified simultaneous-masking spreading function, the Speech Intelligibility Index, an A-weighting approximation, frequency JND, post-masking temporal decay, and binaural masking level difference.
biomedical duplicates part of cardiology, nephrology, and pulmonology — same formulas, different signatures
biomedical.mojo's own docstring frames it as covering "cardiovascular, renal, respiratory, and pharmacokinetic calculations," and the runtime library also ships three dedicated clinical-specialty modules — cardiology, nephrology, and pulmonology — that are not documented on this page (a grep of gitbook/ finds no page for any of the three, only the auto-generated Runtime library catalog). Reading all four .mojo files side by side shows real, function-level overlap, not just a shared subject area:
Concept
biomedical
Overlapping specialty module
Cardiac output (SV×HR)
cardiac_output(stroke_volume_ml, heart_rate)
cardiology.cardiac_output(heart_rate, stroke_volume_ml) — same formula, arguments swapped
Mean arterial pressure
mean_arterial_pressure(systolic, diastolic)
cardiology.mean_arterial_pressure(systolic_mmhg, diastolic_mmhg) — identical formula and order
Pulse pressure
pulse_pressure(systolic, diastolic)
cardiology.pulse_pressure(systolic_mmhg, diastolic_mmhg) — identical formula and order
Fick cardiac output
fick_cardiac_output(vo2, cao2, cvo2)
cardiology.fick_cardiac_output(vo2_ml_per_min, cao2, cvo2) — same formula, different zero/negative guard (below)
Creatinine clearance
glomerular_filtration_rate(creatinine, age, weight, is_female: Bool)
nephrology.creatinine_clearance_cockroft(age, weight_kg, creatinine_mg_dl, is_female: Float64) — same Cockcroft-Gault formula, reordered args, different type for the sex flag
Alveolar gas equation
alveolar_gas_equation(fio2, patm, ph2o, paco2, rq) — fully parameterized
pulmonology.alveolar_oxygen(fio2, paco2_mmhg, barometric_mmhg) — same equation with ph2o and rq hardcoded to 47.0 and 0.8
Two of these differences are worth calling out precisely rather than just noting "they differ":
glomerular_filtration_rateis a misnomer inherited from its own docstring, not just this page's framing. The function computes Cockcroft-Gault creatinine clearance —((140-age)*weight) / (72*creatinine), optionally ×0.85 for a female patient — which is exactly whatnephrology.creatinine_clearance_cockroftcomputes and correctly names. Cockcroft-Gault CrCl is a weight-based estimate of renal clearance, not a measurement of glomerular filtration itself, and it is a clinically distinct quantity from the modern CKD-EPI eGFR equation thatnephrology.gfr_ckd_epiimplements separately (141 × min(Scr/κ,1)^α × max(Scr/κ,1)^-1.209 × 0.993^age [× 1.018 female], normalized to mL/min/1.73m² body-surface area — a different formula family entirely, using different inputs and no weight term at all).biomedical's own docstring header calls this "Cockcroft-Gault GFR," conflating the two concepts in the same breath the function name does.The two
fick_cardiac_outputimplementations disagree on which inputs they refuse.biomedical's guardsfabs(cao2 - cvo2) < 1e-30and returns0.0— it only catches a content difference that is exactly (to floating-point tolerance) zero.cardiology's guardscao2 - cvo2 <= 0.0— it also catches a negative difference (venous content exceeding arterial, which is not physiologically possible but is not excluded by the arguments' types). Callingbiomedical.fick_cardiac_output(250.0, 15.0, 20.0)(arterial and venous swapped by mistake) returns-5.0— a negative "cardiac output" — wherecardiology.fick_cardiac_output(250.0, 15.0, 20.0)returns0.0for the same inputs.
Worked examples — biomedical
Every number below is lifted directly from the real pinned assertions in tests/mojo/test_wave75.mojo ("Tests for Wave 75 — Biomedical, Ceramics, Wind Energy"), not hand-invented — see Verification for why that distinction matters here.
Worked examples — biomechanics
These are lifted directly from tests/mojo/test_wave92.mojo ("Tests for Wave 92 — Laundry, Volcanology, Biomechanics"), the file that carries this module's real pinned numeric assertions (23 of them), separate from the auto-generated smoke test.
center_of_mass_two_segments(5.0, 0.2, 3.0, 0.6) gives 0.35 — the weighted position between a 5 kg segment at 0.2 m and a 3 kg segment at 0.6 m, (5*0.2 + 3*0.6)/(5+3).
biomechanics has no divide-by-zero guards at all — biomedical guards nearly every division
Every division in biomedical.mojo is guarded: bmi, drug_clearance, corrected_qt_bazett, fick_cardiac_output, and alveolar_gas_equation all check their denominator against 1e-30 (or, for corrected_qt_bazett, an explicit rr_s <= 0.0) and return 0.0 instead of dividing. Reading biomechanics.mojo end to end, none of its four dividing functions do this: ground_reaction_force_ratio(grf, body_weight) divides by body_weight unconditionally, stride_length divides by cadence_steps_per_min / 2.0, cadence_from_velocity divides by stride_len, and muscle_force_hill's denominator vmax + velocity / a_hill can reach zero for a negative velocity equal to -vmax * a_hill. Calling any of these with a zero denominator returns Mojo's IEEE-754 inf (or nan for 0.0/0.0) rather than a sentinel 0.0 — a caller feeding this module live sensor data (a runner momentarily airborne with body_weight measured as 0.0, say) gets an infinite ratio back with no guard to catch it, unlike the equivalent situation in biomedical.
psychoacoustics: the module's real subject is perception, not the physics of sound
The hint that motivated this page's scope groups psychoacoustics with "physical acoustics," but reading psychoacoustics.mojo's docstring header ("Human perception of sound calculations") and its ten functions confirms it covers exclusively how a listener's ear and brain perceive a sound signal — loudness in phons/sones, the Bark psychoacoustic frequency scale, simultaneous and temporal masking, speech intelligibility, and binaural masking — never sound pressure, intensity, or power in physical units. The acoustics module documented in Acoustics, optics, and radiative materials kernels covers the complementary physical side (decibel arithmetic, the inverse-square law, room reverberation, Doppler shift). The two modules share no function names and neither imports the other; acoustics.sound_pressure_level computes a physical dB SPL from a pressure ratio, psychoacoustics.loudness_phon_to_sone converts a perceptual loudness level (which already accounts for the ear's frequency-dependent sensitivity) into a perceptual loudness magnitude — an entirely different measurement chain with no shared formula between them.
Loudness and critical bands
Masking and the A-weighting approximation
Verification
mojo/tests/libs/test_biomedical.mojo and test_biomechanics.mojo are auto-generated coverage smoke tests, matching the pattern documented on Classical ML algorithms: every function is called once against a shared 0.5-valued fixture and the only assertion is that the result is finite — neither file pins a specific numeric output. The real pinned assertions for these two modules live elsewhere, in tests/mojo/test_wave75.mojo (12 biomedical functions, 24 assertions) and tests/mojo/test_wave92.mojo (12 biomechanics functions, 23 assertions including two zero/edge cases) — every worked example in the biomedical and biomechanics sections above is lifted directly from those two files, not invented for this page.
psychoacoustics has no equivalent pinned-numeric wave file: a search of every tests/mojo/test_wave*.mojo file for the string psychoacoustics returns no match, so mojo/tests/libs/test_psychoacoustics.mojo's auto-generated finite-check smoke test is the only test coverage this module has. Every number in the psychoacoustics section above was instead computed independently in Python from the real formulas in mojo/engine/psychoacoustics.mojo, and cross-checked against a published reference value where one exists (the phon/sone doubling law, the A-weighting curve's 0 dB point at 1 kHz and its published ≈-19.1 dB value at 100 Hz, and the cited Traunmüller and Glasberg-Moore formulas) — reproduce any of them by re-running the same arithmetic.
Next: see Acoustics, optics, and radiative materials kernels for the physical-sound counterpart to psychoacoustics, or the Runtime library catalog for every module and function, including the cardiology, nephrology, and pulmonology modules this page's first section compares biomedical against.
Last updated
Was this helpful?