Lab

Lab

Simulations, mini-games, dashboards and technical notes. Data comes from open sources, and every page cites its source and cutoff date.

> 23 experiments · Feb 2019 – Nov 2026

AI · By Gersaín Barrón Velázquez

Sargassum AI: detecting and forecasting sargassum with neural networks

Satellites, ocean currents and neural networks to see where sargassum is in the Mexican Caribbean and forecast where it will be in 7 days. With all the math, an honest test on the record 2025 season and a 3D simulator.

  • Python
  • PyTorch
  • U-Net
  • ConvLSTM
  • xarray
  • Remote sensing
  • Copernicus Marine
  • ERA5
  • Three.js
  • Blender
  • Astro
  • KaTeX

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (14/14): the control tower and whose failure it is

The end of the series. A traffic light with a normalized gap per link and an attribution rule that passes part of the failure up the chain, so the problem is fixed where it starts and not where it shows.

  • TypeScript
  • SVG
  • KaTeX
  • KPIs
  • Supply chain
  • Digital twin

AI assistance: Claude (Anthropic)

Data · By Gersaín Barrón Velázquez

Medicine supply digital twin (13/14): which data prevent a plan from being manipulated

An alert rule only works if the data it needs exists. Detection probability with several rules, the cost of false alarms and why, by Bayes' theorem, more alerts doesn't always mean more control.

  • TypeScript
  • SVG
  • KaTeX
  • Probability
  • Bayes' theorem
  • Anomaly detection
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Natural disaster simulation

A hurricane hits the coast of Mexico and a model decides what to move, when and where. Ensemble forecast, wind field, expected damage and a log that explains every decision, with the math step by step.

  • TypeScript
  • Canvas 2D
  • SVG
  • Astro
  • KaTeX
  • Monte Carlo
  • Geospatial modeling
  • Operations research

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (12/14): the last mile to the patient

The medicine reached the unit, but the patient isn't there. An exponential model of returning to the pharmacy window, abandonment, and what changes with lockers and motorbike home delivery.

  • TypeScript
  • SVG
  • KaTeX
  • Probability
  • Routing
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (11/14): how often to count the warehouse

The system and the shelf drift apart through small errors nobody sees. A monthly drift model, its equilibrium and why counting a little often beats counting everything once a year. And the probability behind the blind second count.

  • TypeScript
  • SVG
  • KaTeX
  • Probability
  • Inventory
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (10/14): framework contracts, penalties and termination

A framework contract sets how much can be ordered and what happens if the supplier doesn't deliver. The daily penalty on what's undelivered, the guarantee cap and the count of how many days late remain before termination.

  • TypeScript
  • SVG
  • KaTeX
  • Contracts
  • Simulation
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (9/14): buying with a price window and several sources

A bid can lose for being too expensive and also for being too cheap. How valid bids are decided, why it pays to split an item between several suppliers and what that insurance costs, with the expected-shortfall calculation.

  • TypeScript
  • SVG
  • KaTeX
  • Probability
  • Procurement
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (8/14): accumulated heat and who finds out

A temperature excursion isn't measured in degrees or hours, but in accumulated heat. The Q10 factor, each product's budget, and why a failure that starts on Friday afternoon can go unseen.

  • TypeScript
  • SVG
  • KaTeX
  • Kinetics
  • Cold chain
  • Monitoring
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (7/14): how long a fridge lasts without power

Newton's law of cooling applied to the cold chain. A single time constant explains why a household fridge goes from 5 to 8 °C in 25 minutes and an ice-lined one in three hours, and why the household fridge can't cope with a 33 °C room.

  • TypeScript
  • SVG
  • KaTeX
  • Differential equations
  • Cold chain
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (6/14): docks as a queue

Why going from 4 to 5 docks cuts the wait from two and a half hours to 17 minutes. The Erlang C formula, Little's law and a discrete-event simulation that checks them.

  • TypeScript
  • SVG
  • KaTeX
  • Queueing theory
  • Discrete-event simulation
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (5/14): routes with Clarke-Wright savings and 2-opt

What a delivery route costs, how the savings formula decides which units travel together, and how 2-opt undoes crossings. With the cost of every kilometre, every hour and every trip.

  • TypeScript
  • SVG
  • KaTeX
  • Vehicle routing
  • Heuristics
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (3/14): min-max vs forecast-based ordering

Two ways to replenish the central warehouse, simulated with the same demand and the same unpunctual suppliers. One holds more stock and gives worse service; the other places more, smaller orders. Why.

  • TypeScript
  • SVG
  • KaTeX
  • Simulation
  • Inventory
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (2/14): safety stock

How forecast uncertainty becomes units on the shelf. Where the square root of time comes from, what it costs to go from 95 to 99 %, and why an unpunctual supplier weighs more than variable demand.

  • TypeScript
  • SVG
  • KaTeX
  • Monte Carlo
  • Inventory
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Medicine supply digital twin (1/14): forecasting demand with Holt-Winters

The start of a 14-part series on a digital twin of medicine supply in a public health system. First piece, the forecast. Level, damped trend and weekly season, with every formula worked by hand.

  • TypeScript
  • SVG
  • KaTeX
  • Time series
  • Forecasting
  • Digital twin

AI assistance: Claude (Anthropic)

Data · By Gersaín Barrón Velázquez

Desulfurization digital twin (4/5): how far to trust the simulation? Mesh study and sweep

The same ladle on three meshes, the grid convergence index (GCI) computed step by step, and a sweep of gas flow against lance depth that ends in a power law with the one-third exponent predicted by plume theory.

  • OpenFOAM
  • ParaView
  • Python
  • TypeScript
  • SVG
  • KaTeX
  • CFD
  • Numerical verification

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Desulfurization digital twin (3/5): inside the ladle with CFD

A 3D simulation of the 150-tonne ladle with OpenFOAM. The equations of two interpenetrating fluids, the drag on each bubble, turbulence, and why the flow is averaged between 20 and 60 seconds.

  • OpenFOAM
  • ParaView
  • Blender
  • Python
  • three.js
  • CFD
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Desulfurization digital twin (2/5): powder mixtures, by moles not by kilograms

Lime, calcium carbide and magnesium in the same lance. Why the mixture rate constant is weighted by mole fractions, what goes wrong when you use kilograms, and a neat property of the half-life.

  • TypeScript
  • Python
  • SVG
  • KaTeX
  • Kinetic modeling
  • Digital twin

AI assistance: Claude (Anthropic)

Simulation · By Gersaín Barrón Velázquez

Desulfurization digital twin (1/5): the kinetic model

How a one-millimetre argon bubble decides how much sulfur stays in 150 tonnes of hot metal. The full chain of equations, solved by hand and live.

  • TypeScript
  • Python
  • SVG
  • KaTeX
  • Kinetic modeling
  • Digital twin

AI assistance: Claude (Anthropic)

Note · By Gersaín Barrón Velázquez

How this lab works

The workshop blueprint before the first experiment. Open data, Apache Airflow pipelines and a site that updates itself.

  • Apache Airflow
  • Python
  • SQL
  • Node.js
  • Astro

Data · By Gersaín Barrón Velázquez

OceanLab MX: ocean observatory and buoy digital twin

Ten virtual stations in the Mexican Pacific with real data refreshed every 15 minutes, map, history and forecasts, plus a 3D buoy digital twin with a C++ physics engine and C firmware on WebAssembly. With all the math.

  • C++
  • C
  • WebAssembly
  • Three.js
  • TypeScript
  • Astro
  • PHP
  • MySQL
  • Open-Meteo
  • KaTeX

AI assistance: Claude (Anthropic)