Substance Sim is a scientific research platform designed to model the pharmacokinetics (PK) and pharmacodynamics (PD) of psychoactive and medical substances. Unlike simple calculators, it uses differential equations to simulate absorption, distribution, metabolism, and excretion (ADME) processes.
- Advanced Math Engine: Implements the Bateman Function for dual-phase (absorption & elimination) kinetics.
- Pharmacodynamics: Uses the Hill Equation to model the non-linear relationship between concentration and biological effect.
- Neuroadaptation Model: Simulates tolerance build-up over time based on cumulative exposure (AUC).
- Multi-Dose Simulation: Supports complex dosing schedules (e.g., "3 doses every 4 hours") to analyze accumulation and toxicity.
- Medical & Psychoactive Models: Includes models for Caffeine, Alcohol, Nicotine, and Paracetamol (Liver Toxicity).
- Backend: Node.js, Express.js (REST API)
- Database: MongoDB (Scientific Data Storage)
- Frontend: HTML5, Bootstrap 5, Chart.js (Dual-Axis Visualization)
- Math: Custom implementation of PK/PD differential equations
-
Clone the repository:
git clone https://github.com/YusufOztoprak/substance-sim.git cd substance-sim -
Install dependencies:
npm install
-
Configure Environment: Create a
.envfile (or use the provided.env.example):PORT=3000 MONGO_URI=mongodb://localhost:27017/substance_sim
-
Seed the Database (Crucial Step): Populate the database with scientific data (Caffeine, Alcohol, Nicotine, Paracetamol):
npm run seed
-
Start the Simulation Engine:
npm start
-
Launch: Open
http://localhost:3000in your browser.
This engine goes beyond simple half-life calculations. It implements:
Simulates the rise (absorption) and fall (elimination) of substance levels.
Models the sigmoidal dose-response curve.
Calculates how the body adapts to the substance over time.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/substances |
Returns list of substances with PK parameters. |
POST |
/api/simulate |
Runs the simulation engine. Body: { substanceId, dose, weight, doses, interval } |
This project is licensed under the MIT License. See the LICENSE file for details.