惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
量子位
小众软件
小众软件
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tenable Blog
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
Latest news
Latest news
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
NISL@THU
NISL@THU
T
Tor Project blog
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
博客园 - 聂微东
Last Week in AI
Last Week in AI
爱范儿
爱范儿
腾讯CDC
博客园 - Franky
美团技术团队
J
Java Code Geeks
O
OpenAI News
L
Lohrmann on Cybersecurity
Simon Willison's Weblog
Simon Willison's Weblog
有赞技术团队
有赞技术团队
T
Threatpost
G
GRAHAM CLULEY
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
宝玉的分享
宝玉的分享
I
Intezer
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
S
Security @ Cisco Blogs
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
Stack Overflow Blog
Stack Overflow Blog
Scott Helme
Scott Helme
H
Hacker News: Front Page
Cloudbric
Cloudbric

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Simulated an Entire Human Body in Python: From Ion Channels to Sepsis
cosmosoneness · 2026-06-02 · via DEV Community

humanbody — whole-body physiology simulator

What if you could create a human being inside your computer — not a 3D avatar, but a physiological one? A body with a beating heart whose blood pressure responds to blood loss, lungs that desaturate at altitude, a pancreas that releases insulin after a meal, and an immune system that can tip into sepsis?

That's humanbody: a single Python object you step forward in time.

from humanbody import HumanBody

body = HumanBody()
for _ in range(60):          # 60 seconds of life
    body.step(dt=1.0)

print(body.state_summary())
# HR=72, MAP=93, PaO2=97, SaO2=0.98, glucose=94, cortisol=15, pH=7.40 ...

Enter fullscreen mode Exit fullscreen mode

Every number that comes out of state_summary() is the emergent result of dozens of coupled differential equations — not a lookup table. Change one thing (bleed the patient, feed them, send them up a mountain) and the whole body responds the way a real body would.

It's 255 tests of mathematical physiology, and it's open source.

🔗 Code: github.com/cosmosoneness/Cosmos (under Emulation/Human_Body/)

Why build this?

Textbooks teach physiology one system at a time: here's the cardiac cycle, here's the nephron, here's the HPA axis. But the body isn't a list of chapters — it's a giant feedback network. When you exercise, your muscles demand oxygen, which raises your heart rate, which the baroreflex modulates, which shifts your blood pressure, which changes kidney filtration, which adjusts your fluid balance… all at once.

I wanted to feel those couplings, not just read about them. The only way to really understand a control system is to build one and watch it misbehave.

So I built the whole thing — fourteen phases, from molecules up to clinical scenarios.

The architecture: thinking in scales

The model is organized by biological scale, and the dependency arrow always points up:

molecular   →  enzyme kinetics, Hill dissociation, ATP/PCr/lactate
cellular    →  Hodgkin–Huxley ion channels, membrane potential
tissue      →  Krogh-cylinder oxygen diffusion
systems/    →  9 organ systems (the meat)
integration →  HumanBody aggregator + homeostasis
scenarios   →  clinical challenges you can run

Enter fullscreen mode Exit fullscreen mode

The nine organ systems each implement well-known models from the literature:

System Model
Cardiovascular Suga–Sagawa time-varying elastance + Ursino Windkessel + baroreflex
Respiratory Otis–Rohrer mechanics + alveolar gas equation + Hill O₂ dissociation
Nervous Wilson–Cowan cortical mass + brainstem rhythm generator + autonomic tone
Endocrine HPA / HPT / HPG axes + Dalla Man glucose–insulin + ADH/RAAS
Digestive 5-compartment GI transit + liver glycogen + microbiome SCFA
Renal glomerulus + tubular handling + countercurrent multiplier + acid–base
Musculoskeletal Hill-type muscle + PCr/lactate buffering + Lemaire bone remodeling
Integumentary Gagge two-node thermal model
Immune innate + adaptive + Perelson pathogen dynamics + SIRS criteria

They talk to each other through a shared signal bus — a dictionary of cross-system variables like mean arterial pressure, arterial oxygen, glucose, and cortisol — plus an event bus for discrete events like "a meal was eaten."

The hard part: time

Here's the thing nobody tells you about whole-body simulation — different systems live on wildly different timescales.

The heart beats on the order of milliseconds. A cardiac action potential, valve dynamics, the pressure pulse — all of it is stiff. Meanwhile, your cortisol rhythm plays out over hours, and bone remodeling takes weeks.

My first integration attempt used a naive forward-Euler step at dt = 1 second for everything. The result? Mean arterial pressure exploded to 5 × 10⁴⁹ mmHg. The cardiac ODE was catastrophically unstable at that step size.

The fix was per-system substepping: inside one body.step(dt=1.0), the engine runs the heart and circulation at 1 ms substeps (1000 iterations), the respiratory pump at 50 ms substeps, and everything slower at the full dt.

def step(self, dt=1.0, **perturbations):
    # Cardiac dynamics are stiff — substep finely
    n_cardio = max(1, int(dt / 1e-3))
    for _ in range(n_cardio):
        self.cardio.step(1e-3, signal=self.signal)

    # Respiratory — medium substep
    n_resp = max(1, int(dt / 0.05))
    for _ in range(n_resp):
        self.respiratory.step(0.05, signal=self.signal)

    # Slow systems — one macro step
    self.endocrine.step(dt, signal=self.signal)
    self.renal.step(dt, signal=self.signal)
    self.bus.publish(TickEvent(time=self.t, source="body", dt=dt))

Enter fullscreen mode Exit fullscreen mode

This is the same idea as multi-rate integration in circuit simulators. It's not glamorous, but it's the difference between a model and a number that overflows a float.

Watching it come alive: clinical scenarios

The payoff is the scenario framework. Seven clinical challenges ship built-in:

from humanbody.scenarios import HemorrhageScenario, run_scenario

result = run_scenario(HemorrhageScenario(volume_mL=1000), dt=1.0)
print(result.alerts)
# ['Shock: MAP < 65 mmHg']

Enter fullscreen mode Exit fullscreen mode

Run the hemorrhage scenario and you watch the baroreflex fight to maintain pressure as a liter of blood drains away — heart rate climbs, then pressure finally collapses into shock and the homeostasis monitor raises an alert.

Run sepsis and IL-6 rises, drives a fever and tachycardia, and the system checks itself against the actual SIRS criteria.

Run high-altitude and the barometric pressure drop propagates through the alveolar gas equation into the Hill oxygen-dissociation curve — SaO₂ falls, the chemoreflex kicks in, and ventilation rises.

Run diabetic ketoacidosis and glucose stays sky-high while bicarbonate falls and the pH drops below 7.3.

Each scenario is just a small class — and writing your own takes about a dozen lines:

from humanbody.scenarios.clinical import Scenario

class CaffeineDose(Scenario):
    """200 mg caffeine -> tachycardia + higher cortisol."""
    def __init__(self):
        super().__init__(name="Caffeine",
                         description="200 mg single dose",
                         duration=3600.0)
        self.applied = False

    def step_perturbation(self, body, t):
        if not self.applied and t >= 60:
            body.endocrine.hpa.stress_input += 0.2
            body.cardio.baroreflex.set_point += 5
            self.applied = True
        return {}

Enter fullscreen mode Exit fullscreen mode

What it can — and can't — do

Let me be honest about the boundaries, because that matters more than the demo.

It's good for: teaching integrated physiology, prototyping clinical scenarios, "what-if" experiments, and as a scaffold you can subclass into something research-grade. You learn an enormous amount just by breaking it.

It's not: a medical device, a source of patient-specific predictions, or publication-grade quantitative biology. Every ODE is forward-Euler with substepping — accurate enough to be qualitatively right, not quantitatively certified. Do not use it for medical decisions.

There's also a fun gotcha I left in the docs: ask for blood pressure at the wrong instant and you might see "MAP = 8.9 mmHg." That's not a bug — it's the instantaneous pressure sampled at diastole. The cardiac ODE is genuinely pulsatile at 1 ms resolution, so you have to average over a cycle to get a textbook number. The model is more honest than the summary statistic.

The bigger project

humanbody is actually one chapter of a larger repo I'm calling the Cosmos Research Institute — an umbrella for end-to-end "emulators" of real systems, from a cellular artificial-life world to connectome-level whole-brain emulation. The ambition is to keep building computational models of the world we live in until the name stops being a joke.

But you have to start somewhere, and the body is a beautiful place to start: it's the most sophisticated control system any of us will ever own, and now there's a version of it you can pip install and break to your heart's content.

Try it

git clone https://github.com/cosmosoneness/Cosmos.git
cd Cosmos/Emulation/Human_Body
pip install -e ".[dev]"
pytest tests/ -q          # 255 passed

humanbody run exercise --duration 600
humanbody serve --port 8000   # REST API

Enter fullscreen mode Exit fullscreen mode

  • 🔗 Source: github.com/cosmosoneness/Cosmos
  • 📖 Tutorial: the TUTORIAL.md in the repo has seven hands-on walkthroughs
  • ⭐ If it teaches you something, a star helps others find it

Built in Python with the help of Claude Code. The individual modules credit the papers they implement — Suga & Sagawa, Ursino, Dalla Man, Wilson & Cowan, Lemaire, Gagge, Perelson, and many others whose mathematical physiology made this possible.