fb0962ff95
This commit re-implements several critical physiological feedback loops that were lost, enhancing the realism of the simulation.
The following systems have been added:
1. **Full Digestive Loop:**
- The Gallbladder now has a `releaseBile` method, triggered by chyme in the intestines.
- The Pancreas has a `releaseEnzymes` method, also triggered by chyme.
- The Intestines' digestion logic has been updated to be more effective when bile and enzymes are present.
2. **Autonomic Nervous System Control:**
- The Brain now monitors blood gas (O2/CO2) and blood pressure levels.
- It dynamically adjusts the respiration rate of the Lungs via a new `setRespirationRate` method in response to blood gas changes.
- It controls the heart rate via a new `setHeartRate` method in response to blood pressure changes, simulating the baroreceptor reflex.
- The previous hardcoded rate control logic in the Lungs and Heart has been removed.
3. **Kidney Blood Pressure Regulation (RAAS):**
- A simplified Renin-Angiotensin-Aldosterone System has been implemented.
- The Kidneys now secrete renin in response to low blood pressure.
- The Liver produces a constant supply of angiotensinogen.
- A new `angiotensin_au` value in the Blood struct is calculated in the main patient update loop.
- This hormone now acts as a vasoconstrictor, directly affecting the blood pressure calculation in the Heart.
These changes significantly increase the complexity and fidelity of the medical simulation by modeling the interconnectedness of the major organ systems.
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "Organ.h"
|
|
#include <string>
|
|
|
|
/**
|
|
* @brief Represents the contraction state of the gallbladder.
|
|
*/
|
|
enum class GallbladderState {
|
|
STORING,
|
|
CONTRACTING
|
|
};
|
|
|
|
/**
|
|
* @brief Represents the Gallbladder, which stores and concentrates bile.
|
|
*/
|
|
class MEDICAL_LIB_API Gallbladder : public Organ {
|
|
public:
|
|
/**
|
|
* @brief Constructor for the Gallbladder class.
|
|
* @param id The ID of the organ.
|
|
*/
|
|
Gallbladder(int id);
|
|
|
|
/**
|
|
* @brief Updates the gallbladder's state over a time interval.
|
|
* @param patient A reference to the patient object.
|
|
* @param deltaTime_s The time elapsed in seconds.
|
|
*/
|
|
void update(Patient& patient, double deltaTime_s) override;
|
|
|
|
/**
|
|
* @brief Gets a string summary of the gallbladder's state.
|
|
* @return A string containing the gallbladder's state.
|
|
*/
|
|
std::string getSummary() const override;
|
|
|
|
/**
|
|
* @brief Adds bile from the liver.
|
|
* @param volume_mL The volume of bile to add.
|
|
*/
|
|
void storeBile(double volume_mL);
|
|
|
|
/**
|
|
* @brief Releases bile when stimulated (e.g., by chyme in duodenum).
|
|
* @param deltaTime_s The time step for this update.
|
|
* @return The amount of bile released in mL.
|
|
*/
|
|
double releaseBile(double deltaTime_s);
|
|
|
|
// --- Getters for Gallbladder State ---
|
|
|
|
/** @brief Gets the current volume of stored bile in mL. */
|
|
double getStoredBileVolume() const;
|
|
|
|
/** @brief Gets the concentration factor of the stored bile. */
|
|
double getBileConcentration() const;
|
|
|
|
/** @brief Gets the current state of the gallbladder. */
|
|
GallbladderState getCurrentState() const;
|
|
|
|
private:
|
|
// --- Helper to convert enum to string ---
|
|
std::string stateToString(GallbladderState state) const;
|
|
|
|
// --- Physiological Parameters ---
|
|
GallbladderState currentState;
|
|
double storedBile_mL;
|
|
double bileConcentrationFactor; // How concentrated the bile is (1x, 5x, etc.)
|
|
double bileReleaseRate_ml_per_s; // Rate of bile release when contracting
|
|
const double capacity_mL = 50.0;
|
|
};
|